summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.arcconfig3
-rw-r--r--Makefile10
-rw-r--r--Makefile.inc170
-rw-r--r--ObsoleteFiles.inc140
-rw-r--r--UPDATING22
-rw-r--r--bin/chflags/chflags.115
-rw-r--r--bin/chflags/chflags.c51
-rw-r--r--bin/chmod/chmod.114
-rw-r--r--bin/chmod/chmod.c90
-rw-r--r--bin/cp/cp.c29
-rw-r--r--bin/date/date.17
-rw-r--r--bin/date/date.c10
-rw-r--r--bin/pax/ar_subs.c1
-rw-r--r--bin/pax/buf_subs.c1
-rw-r--r--bin/pax/cache.c1
-rw-r--r--bin/pax/cpio.c2
-rw-r--r--bin/pax/file_subs.c1
-rw-r--r--bin/pax/gen_subs.c2
-rw-r--r--bin/pax/getoldopt.c3
-rw-r--r--bin/pax/pat_rep.c2
-rw-r--r--bin/pax/pax.c1
-rw-r--r--bin/pax/sel_subs.c1
-rw-r--r--bin/pax/tar.c2
-rw-r--r--bin/pax/tty_subs.c1
-rw-r--r--bin/ps/Makefile2
-rw-r--r--bin/ps/keyword.c282
-rw-r--r--bin/ps/print.c27
-rw-r--r--bin/ps/ps.16
-rw-r--r--bin/ps/ps.c101
-rw-r--r--bin/ps/ps.h1
-rw-r--r--cddl/contrib/opensolaris/common/ctf/ctf_create.c21
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l1
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c47
-rw-r--r--cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c12
-rw-r--r--cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c11
-rw-r--r--cddl/lib/Makefile7
-rw-r--r--cddl/lib/libdtrace/Makefile3
-rw-r--r--cddl/lib/libdtrace/siftr.d100
-rw-r--r--cddl/sbin/Makefile2
-rw-r--r--cddl/usr.bin/Makefile2
-rw-r--r--cddl/usr.bin/ctfconvert/Makefile5
-rw-r--r--cddl/usr.bin/ctfdump/Makefile3
-rw-r--r--cddl/usr.sbin/Makefile2
-rw-r--r--cddl/usr.sbin/dtrace/Makefile5
-rwxr-xr-xcddl/usr.sbin/dtrace/tests/tools/exclude.sh1
-rw-r--r--cddl/usr.sbin/lockstat/Makefile6
-rw-r--r--cddl/usr.sbin/plockstat/Makefile5
-rw-r--r--contrib/atf/atf-sh/atf_check_test.sh20
-rw-r--r--contrib/atf/atf-sh/misc_helpers.sh16
-rw-r--r--contrib/binutils/bfd/elf32-arm.c28
-rw-r--r--contrib/bmake/ChangeLog13
-rw-r--r--contrib/bmake/FILES2
-rw-r--r--contrib/bmake/Makefile6
-rw-r--r--contrib/bmake/cond.c37
-rwxr-xr-xcontrib/bmake/machine.sh6
-rw-r--r--contrib/bmake/mk/ChangeLog6
-rw-r--r--contrib/bmake/mk/dirdeps.mk9
-rw-r--r--contrib/bmake/mk/install-mk4
-rw-r--r--contrib/bmake/nonints.h4
-rw-r--r--contrib/bmake/unit-tests/Makefile.in5
-rw-r--r--contrib/bmake/unit-tests/cond2.exp7
-rw-r--r--contrib/bmake/unit-tests/cond2.mk25
-rw-r--r--contrib/bmake/var.c8
-rw-r--r--contrib/elftoolchain/addr2line/addr2line.16
-rw-r--r--contrib/elftoolchain/addr2line/addr2line.c44
-rwxr-xr-xcontrib/elftoolchain/common/native-elf-format4
-rw-r--r--contrib/elftoolchain/cxxfilt/c++filt.14
-rw-r--r--contrib/elftoolchain/elfcopy/elfcopy.14
-rw-r--r--contrib/elftoolchain/elfcopy/sections.c10
-rw-r--r--contrib/elftoolchain/elfcopy/segments.c4
-rw-r--r--contrib/elftoolchain/elfcopy/symbols.c4
-rw-r--r--contrib/elftoolchain/libdwarf/dwarf.314
-rw-r--r--contrib/elftoolchain/libdwarf/dwarf_add_line_entry.35
-rw-r--r--contrib/elftoolchain/libdwarf/dwarf_def_macro.34
-rw-r--r--contrib/elftoolchain/libdwarf/dwarf_expand_frame_instructions.34
-rw-r--r--contrib/elftoolchain/libdwarf/dwarf_formblock.34
-rw-r--r--contrib/elftoolchain/libdwarf/dwarf_formflag.34
-rw-r--r--contrib/elftoolchain/libdwarf/dwarf_formref.34
-rw-r--r--contrib/elftoolchain/libdwarf/dwarf_formsig8.34
-rw-r--r--contrib/elftoolchain/libdwarf/dwarf_formudata.34
-rw-r--r--contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs.35
-rw-r--r--contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg.34
-rw-r--r--contrib/elftoolchain/libdwarf/dwarf_get_ranges.34
-rw-r--r--contrib/elftoolchain/libdwarf/dwarf_hasattr.34
-rw-r--r--contrib/elftoolchain/libdwarf/dwarf_next_cu_header.35
-rw-r--r--contrib/elftoolchain/libdwarf/dwarf_producer_init.34
-rw-r--r--contrib/elftoolchain/libdwarf/dwarf_whatattr.34
-rw-r--r--contrib/elftoolchain/libelf/elf.37
-rw-r--r--contrib/elftoolchain/libelf/elf_begin.34
-rw-r--r--contrib/elftoolchain/libelf/elf_cntl.32
-rw-r--r--contrib/elftoolchain/libelf/elf_getdata.34
-rw-r--r--contrib/elftoolchain/libelf/elf_open.34
-rw-r--r--contrib/elftoolchain/libelf/elf_update.c8
-rw-r--r--contrib/elftoolchain/libelf/gelf.35
-rw-r--r--contrib/elftoolchain/libelftc/elftc_demangle.34
-rw-r--r--contrib/elftoolchain/libelftc/elftc_symbol_table_create.34
-rw-r--r--contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c4
-rw-r--r--contrib/elftoolchain/nm/nm.14
-rw-r--r--contrib/elftoolchain/readelf/readelf.14
-rw-r--r--contrib/elftoolchain/readelf/readelf.c32
-rw-r--r--contrib/elftoolchain/size/size.16
-rw-r--r--contrib/elftoolchain/size/size.c4
-rw-r--r--contrib/elftoolchain/strings/strings.16
-rw-r--r--contrib/gcc/dwarf2.h1
-rw-r--r--contrib/gcclibs/libgomp/ChangeLog430
-rw-r--r--contrib/gcclibs/libgomp/ChangeLog.gcc448
-rw-r--r--contrib/gcclibs/libgomp/Makefile.am21
-rw-r--r--contrib/gcclibs/libgomp/Makefile.in237
-rw-r--r--contrib/gcclibs/libgomp/aclocal.m45
-rw-r--r--contrib/gcclibs/libgomp/config.h.in16
-rw-r--r--contrib/gcclibs/libgomp/config/bsd/proc.c117
-rw-r--r--contrib/gcclibs/libgomp/config/linux/affinity.c107
-rw-r--r--contrib/gcclibs/libgomp/config/linux/proc.c179
-rw-r--r--contrib/gcclibs/libgomp/config/mingw32/proc.c82
-rw-r--r--contrib/gcclibs/libgomp/config/posix/affinity.c41
-rwxr-xr-xcontrib/gcclibs/libgomp/configure11122
-rw-r--r--contrib/gcclibs/libgomp/configure.ac77
-rw-r--r--contrib/gcclibs/libgomp/configure.tgt20
-rw-r--r--contrib/gcclibs/libgomp/env.c97
-rw-r--r--contrib/gcclibs/libgomp/iter.c22
-rw-r--r--contrib/gcclibs/libgomp/libgomp.h12
-rw-r--r--contrib/gcclibs/libgomp/libgomp.texi27
-rw-r--r--contrib/gcclibs/libgomp/omp.h.in49
-rw-r--r--contrib/gcclibs/libgomp/omp_lib.h.in10
-rw-r--r--contrib/gcclibs/libgomp/team.c23
-rw-r--r--contrib/gdb/gdb/c-valprint.c4
-rw-r--r--contrib/gdb/gdb/dwarf2expr.c60
-rw-r--r--contrib/gdb/gdb/dwarf2expr.h45
-rw-r--r--contrib/gdb/gdb/dwarf2loc.c41
-rw-r--r--contrib/gdb/gdb/dwarf2read.c5
-rw-r--r--contrib/gdb/gdb/value.h3
-rw-r--r--contrib/gdb/gdb/values.c17
-rw-r--r--contrib/ipfilter/tools/ipf.c2
-rw-r--r--contrib/ldns/drill/config.h4
-rw-r--r--contrib/ldns/drill/drill.111
-rwxr-xr-xcontrib/ldns/freebsd-configure.sh19
-rw-r--r--contrib/ldns/packaging/fedora/ldns.spec212
-rw-r--r--contrib/ldns/packaging/ldns-config.143
-rwxr-xr-xcontrib/ldns/packaging/ldns-config.in31
-rw-r--r--contrib/ldns/packaging/libldns.pc.in13
-rw-r--r--contrib/libarchive/libarchive/archive_read.c2
-rw-r--r--contrib/libarchive/libarchive/archive_read_support_format_cpio.c22
-rw-r--r--contrib/libxo/Makefile.am2
-rw-r--r--contrib/libxo/configure.ac13
-rw-r--r--contrib/libxo/doc/libxo.txt97
-rw-r--r--contrib/libxo/libxo/Makefile.am5
-rw-r--r--contrib/libxo/libxo/libxo.c693
-rw-r--r--contrib/libxo/libxo/xo.h115
-rw-r--r--contrib/libxo/libxo/xo_error.37
-rw-r--r--contrib/libxo/libxo/xo_format.556
-rw-r--r--contrib/libxo/libxo/xo_open_container.38
-rw-r--r--contrib/libxo/libxo/xo_open_marker.3138
-rw-r--r--contrib/libxo/libxo/xo_set_version.359
-rw-r--r--contrib/libxo/libxo/xoconfig.h12
-rw-r--r--contrib/libxo/libxo/xoconfig.h.in6
-rw-r--r--contrib/libxo/libxo/xoversion.h6
-rw-r--r--contrib/libxo/m4/libtool.m42561
-rw-r--r--contrib/libxo/m4/ltoptions.m4127
-rw-r--r--contrib/libxo/m4/ltversion.m412
-rw-r--r--contrib/libxo/tests/core/Makefile.am4
-rw-r--r--contrib/libxo/tests/core/saved/test_01.JP.out6
-rw-r--r--contrib/libxo/tests/core/saved/test_02.JP.out4
-rw-r--r--contrib/libxo/tests/core/saved/test_05.H.out2
-rw-r--r--contrib/libxo/tests/core/saved/test_05.HIPx.out59
-rw-r--r--contrib/libxo/tests/core/saved/test_05.HP.out59
-rw-r--r--contrib/libxo/tests/core/saved/test_05.J.out2
-rw-r--r--contrib/libxo/tests/core/saved/test_05.JP.out16
-rw-r--r--contrib/libxo/tests/core/saved/test_05.T.out10
-rw-r--r--contrib/libxo/tests/core/saved/test_05.X.out2
-rw-r--r--contrib/libxo/tests/core/saved/test_05.XP.out16
-rw-r--r--contrib/libxo/tests/core/saved/test_09.JP.out20
-rw-r--r--contrib/libxo/tests/core/saved/test_10.H.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_10.H.out1
-rw-r--r--contrib/libxo/tests/core/saved/test_10.HIPx.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_10.HIPx.out316
-rw-r--r--contrib/libxo/tests/core/saved/test_10.HP.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_10.HP.out316
-rw-r--r--contrib/libxo/tests/core/saved/test_10.J.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_10.J.out2
-rw-r--r--contrib/libxo/tests/core/saved/test_10.JP.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_10.JP.out113
-rw-r--r--contrib/libxo/tests/core/saved/test_10.T.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_10.T.out48
-rw-r--r--contrib/libxo/tests/core/saved/test_10.X.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_10.X.out1
-rw-r--r--contrib/libxo/tests/core/saved/test_10.XP.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_10.XP.out100
-rw-r--r--contrib/libxo/tests/core/saved/test_10.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_10.out38
-rw-r--r--contrib/libxo/tests/core/test_05.c17
-rw-r--r--contrib/libxo/tests/core/test_10.c212
-rw-r--r--contrib/libxo/xo/xo.12
-rw-r--r--contrib/libxo/xohtml/Makefile.am38
-rw-r--r--contrib/libxo/xohtml/xohtml.1125
-rw-r--r--contrib/libxo/xohtml/xohtml.css24
-rw-r--r--contrib/libxo/xohtml/xohtml.sh.in20
-rw-r--r--contrib/libxo/xolint/Makefile.am3
-rw-r--r--contrib/libxo/xolint/xolint.12
-rwxr-xr-xcontrib/libxo/xolint/xolint.pl63
-rw-r--r--contrib/mdocml/config.h2
-rw-r--r--contrib/netcat/netcat.c280
-rw-r--r--contrib/ntp/ChangeLog80
-rw-r--r--contrib/ntp/CommitLog2566
-rw-r--r--contrib/ntp/Makefile.in10
-rw-r--r--contrib/ntp/NEWS141
-rw-r--r--contrib/ntp/aclocal.m45
-rw-r--r--contrib/ntp/adjtimed/Makefile.in10
-rw-r--r--contrib/ntp/clockstuff/Makefile.in10
-rw-r--r--contrib/ntp/config.h.in4
-rwxr-xr-xcontrib/ntp/configure133
-rw-r--r--contrib/ntp/configure.ac64
-rw-r--r--contrib/ntp/html/build.html4
-rw-r--r--contrib/ntp/html/miscopt.html4
-rw-r--r--contrib/ntp/html/sntp.html6
-rw-r--r--contrib/ntp/include/Makefile.in10
-rw-r--r--contrib/ntp/include/binio.h10
-rw-r--r--contrib/ntp/include/isc/Makefile.in10
-rw-r--r--contrib/ntp/include/mbg_gps166.h1195
-rw-r--r--contrib/ntp/include/ntp.h35
-rw-r--r--contrib/ntp/include/ntp_calendar.h6
-rw-r--r--contrib/ntp/include/ntp_fp.h5
-rw-r--r--contrib/ntp/include/ntp_md5.h2
-rw-r--r--contrib/ntp/include/ntpd.h11
-rw-r--r--contrib/ntp/include/parse.h49
-rw-r--r--contrib/ntp/include/parse_conf.h14
-rw-r--r--contrib/ntp/kernel/Makefile.in10
-rw-r--r--contrib/ntp/kernel/sys/Makefile.in10
-rw-r--r--contrib/ntp/kernel/sys/parsestreams.h2
-rw-r--r--contrib/ntp/lib/isc/inet_ntop.c1
-rw-r--r--contrib/ntp/lib/isc/log.c24
-rw-r--r--contrib/ntp/lib/isc/result.c12
-rw-r--r--contrib/ntp/lib/isc/unix/file.c6
-rw-r--r--contrib/ntp/lib/isc/unix/ifiter_getifaddrs.c3
-rw-r--r--contrib/ntp/lib/isc/unix/ifiter_ioctl.c18
-rw-r--r--contrib/ntp/lib/isc/unix/net.c3
-rw-r--r--contrib/ntp/libntp/Makefile.in10
-rw-r--r--contrib/ntp/libntp/ntp_calendar.c74
-rw-r--r--contrib/ntp/libntp/work_fork.c2
-rw-r--r--contrib/ntp/libparse/Makefile.in10
-rw-r--r--contrib/ntp/libparse/clk_computime.c62
-rw-r--r--contrib/ntp/libparse/clk_dcf7000.c27
-rw-r--r--contrib/ntp/libparse/clk_hopf6021.c39
-rw-r--r--contrib/ntp/libparse/clk_meinberg.c177
-rw-r--r--contrib/ntp/libparse/clk_rawdcf.c44
-rw-r--r--contrib/ntp/libparse/clk_rcc8000.c31
-rw-r--r--contrib/ntp/libparse/clk_schmid.c36
-rw-r--r--contrib/ntp/libparse/clk_sel240x.c16
-rw-r--r--contrib/ntp/libparse/clk_trimtaip.c23
-rw-r--r--contrib/ntp/libparse/clk_trimtsip.c62
-rw-r--r--contrib/ntp/libparse/clk_varitext.c87
-rw-r--r--contrib/ntp/libparse/clk_wharton.c13
-rw-r--r--contrib/ntp/libparse/data_mbg.c143
-rw-r--r--contrib/ntp/libparse/gpstolfp.c10
-rw-r--r--contrib/ntp/libparse/parse.c120
-rw-r--r--contrib/ntp/libparse/parse_conf.c4
-rw-r--r--contrib/ntp/libparse/parsesolaris.c108
-rw-r--r--contrib/ntp/libparse/parsestreams.c126
-rw-r--r--contrib/ntp/libparse/trim_info.c2
-rw-r--r--contrib/ntp/ntpd/Makefile.in10
-rw-r--r--contrib/ntp/ntpd/cmd_args.c9
-rw-r--r--contrib/ntp/ntpd/invoke-ntp.conf.texi17
-rw-r--r--contrib/ntp/ntpd/invoke-ntp.keys.texi2
-rw-r--r--contrib/ntp/ntpd/invoke-ntpd.texi25
-rw-r--r--contrib/ntp/ntpd/keyword-gen-utd2
-rw-r--r--contrib/ntp/ntpd/keyword-gen.c2
-rw-r--r--contrib/ntp/ntpd/ntp.conf.5man23
-rw-r--r--contrib/ntp/ntpd/ntp.conf.5mdoc21
-rw-r--r--contrib/ntp/ntpd/ntp.conf.def17
-rw-r--r--contrib/ntp/ntpd/ntp.conf.html15
-rw-r--r--contrib/ntp/ntpd/ntp.conf.man.in23
-rw-r--r--contrib/ntp/ntpd/ntp.conf.mdoc.in21
-rw-r--r--contrib/ntp/ntpd/ntp.keys.5man4
-rw-r--r--contrib/ntp/ntpd/ntp.keys.5mdoc4
-rw-r--r--contrib/ntp/ntpd/ntp.keys.html2
-rw-r--r--contrib/ntp/ntpd/ntp.keys.man.in4
-rw-r--r--contrib/ntp/ntpd/ntp.keys.mdoc.in4
-rw-r--r--contrib/ntp/ntpd/ntp_config.c8
-rw-r--r--contrib/ntp/ntpd/ntp_control.c107
-rw-r--r--contrib/ntp/ntpd/ntp_crypto.c2
-rw-r--r--contrib/ntp/ntpd/ntp_keyword.h975
-rw-r--r--contrib/ntp/ntpd/ntp_leapsec.c12
-rw-r--r--contrib/ntp/ntpd/ntp_loopfilter.c136
-rw-r--r--contrib/ntp/ntpd/ntp_parser.c1600
-rw-r--r--contrib/ntp/ntpd/ntp_parser.h158
-rw-r--r--contrib/ntp/ntpd/ntp_peer.c20
-rw-r--r--contrib/ntp/ntpd/ntp_proto.c87
-rw-r--r--contrib/ntp/ntpd/ntpd-opts.c482
-rw-r--r--contrib/ntp/ntpd/ntpd-opts.h69
-rw-r--r--contrib/ntp/ntpd/ntpd.1ntpdman24
-rw-r--r--contrib/ntp/ntpd/ntpd.1ntpdmdoc21
-rw-r--r--contrib/ntp/ntpd/ntpd.c1
-rw-r--r--contrib/ntp/ntpd/ntpd.html76
-rw-r--r--contrib/ntp/ntpd/ntpd.man.in24
-rw-r--r--contrib/ntp/ntpd/ntpd.mdoc.in21
-rw-r--r--contrib/ntp/ntpd/ntpdbase-opts.def22
-rw-r--r--contrib/ntp/ntpd/refclock_palisade.c10
-rw-r--r--contrib/ntp/ntpd/refclock_palisade.h1
-rw-r--r--contrib/ntp/ntpd/refclock_parse.c838
-rw-r--r--contrib/ntp/ntpdate/Makefile.in10
-rw-r--r--contrib/ntp/ntpdc/Makefile.in10
-rw-r--r--contrib/ntp/ntpdc/invoke-ntpdc.texi4
-rw-r--r--contrib/ntp/ntpdc/ntpdc-opts.c14
-rw-r--r--contrib/ntp/ntpdc/ntpdc-opts.h6
-rw-r--r--contrib/ntp/ntpdc/ntpdc.1ntpdcman6
-rw-r--r--contrib/ntp/ntpdc/ntpdc.1ntpdcmdoc4
-rw-r--r--contrib/ntp/ntpdc/ntpdc.html4
-rw-r--r--contrib/ntp/ntpdc/ntpdc.man.in6
-rw-r--r--contrib/ntp/ntpdc/ntpdc.mdoc.in4
-rw-r--r--contrib/ntp/ntpq/Makefile.in10
-rw-r--r--contrib/ntp/ntpq/invoke-ntpq.texi4
-rw-r--r--contrib/ntp/ntpq/ntpq-opts.c14
-rw-r--r--contrib/ntp/ntpq/ntpq-opts.h6
-rw-r--r--contrib/ntp/ntpq/ntpq-subs.c2
-rw-r--r--contrib/ntp/ntpq/ntpq.1ntpqman6
-rw-r--r--contrib/ntp/ntpq/ntpq.1ntpqmdoc4
-rw-r--r--contrib/ntp/ntpq/ntpq.html4
-rw-r--r--contrib/ntp/ntpq/ntpq.man.in6
-rw-r--r--contrib/ntp/ntpq/ntpq.mdoc.in4
-rw-r--r--contrib/ntp/ntpsnmpd/Makefile.in10
-rw-r--r--contrib/ntp/ntpsnmpd/invoke-ntpsnmpd.texi4
-rw-r--r--contrib/ntp/ntpsnmpd/ntpsnmpd-opts.c14
-rw-r--r--contrib/ntp/ntpsnmpd/ntpsnmpd-opts.h6
-rw-r--r--contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdman6
-rw-r--r--contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc4
-rw-r--r--contrib/ntp/ntpsnmpd/ntpsnmpd.html2
-rw-r--r--contrib/ntp/ntpsnmpd/ntpsnmpd.man.in6
-rw-r--r--contrib/ntp/ntpsnmpd/ntpsnmpd.mdoc.in4
-rw-r--r--contrib/ntp/packageinfo.sh4
-rw-r--r--contrib/ntp/parseutil/Makefile.in10
-rw-r--r--contrib/ntp/parseutil/dcfd.c62
-rw-r--r--contrib/ntp/parseutil/testdcf.c25
-rw-r--r--contrib/ntp/scripts/Makefile.am1
-rw-r--r--contrib/ntp/scripts/Makefile.in11
-rw-r--r--contrib/ntp/scripts/build/Makefile.in10
-rw-r--r--contrib/ntp/scripts/calc_tickadj/Makefile.in10
-rw-r--r--contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjman6
-rw-r--r--contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc4
-rw-r--r--contrib/ntp/scripts/calc_tickadj/calc_tickadj.html2
-rw-r--r--contrib/ntp/scripts/calc_tickadj/calc_tickadj.man.in6
-rw-r--r--contrib/ntp/scripts/calc_tickadj/calc_tickadj.mdoc.in4
-rw-r--r--contrib/ntp/scripts/calc_tickadj/invoke-calc_tickadj.texi2
-rw-r--r--contrib/ntp/scripts/invoke-plot_summary.texi4
-rw-r--r--contrib/ntp/scripts/invoke-summary.texi4
-rw-r--r--contrib/ntp/scripts/lib/Makefile.in10
-rw-r--r--contrib/ntp/scripts/lib/NTP/Util.pm19
-rw-r--r--contrib/ntp/scripts/ntp-wait/Makefile.in10
-rw-r--r--contrib/ntp/scripts/ntp-wait/invoke-ntp-wait.texi4
-rw-r--r--contrib/ntp/scripts/ntp-wait/ntp-wait-opts4
-rw-r--r--contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitman6
-rw-r--r--contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitmdoc4
-rw-r--r--contrib/ntp/scripts/ntp-wait/ntp-wait.html4
-rw-r--r--contrib/ntp/scripts/ntp-wait/ntp-wait.man.in6
-rw-r--r--contrib/ntp/scripts/ntp-wait/ntp-wait.mdoc.in4
-rw-r--r--contrib/ntp/scripts/ntpsweep/Makefile.in10
-rw-r--r--contrib/ntp/scripts/ntpsweep/invoke-ntpsweep.texi4
-rw-r--r--contrib/ntp/scripts/ntpsweep/ntpsweep-opts4
-rw-r--r--contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepman6
-rw-r--r--contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepmdoc4
-rw-r--r--contrib/ntp/scripts/ntpsweep/ntpsweep.html4
-rw-r--r--contrib/ntp/scripts/ntpsweep/ntpsweep.man.in6
-rw-r--r--contrib/ntp/scripts/ntpsweep/ntpsweep.mdoc.in4
-rw-r--r--contrib/ntp/scripts/ntptrace/Makefile.in10
-rw-r--r--contrib/ntp/scripts/ntptrace/invoke-ntptrace.texi4
-rw-r--r--contrib/ntp/scripts/ntptrace/ntptrace-opts4
-rw-r--r--contrib/ntp/scripts/ntptrace/ntptrace.1ntptraceman6
-rw-r--r--contrib/ntp/scripts/ntptrace/ntptrace.1ntptracemdoc4
-rw-r--r--contrib/ntp/scripts/ntptrace/ntptrace.html4
-rw-r--r--contrib/ntp/scripts/ntptrace/ntptrace.man.in6
-rw-r--r--contrib/ntp/scripts/ntptrace/ntptrace.mdoc.in4
-rw-r--r--contrib/ntp/scripts/plot_summary-opts4
-rw-r--r--contrib/ntp/scripts/plot_summary.1plot_summaryman6
-rw-r--r--contrib/ntp/scripts/plot_summary.1plot_summarymdoc4
-rw-r--r--contrib/ntp/scripts/plot_summary.html4
-rw-r--r--contrib/ntp/scripts/plot_summary.man.in6
-rw-r--r--contrib/ntp/scripts/plot_summary.mdoc.in4
-rw-r--r--contrib/ntp/scripts/summary-opts4
-rw-r--r--contrib/ntp/scripts/summary.1summaryman6
-rw-r--r--contrib/ntp/scripts/summary.1summarymdoc4
-rw-r--r--contrib/ntp/scripts/summary.html4
-rw-r--r--contrib/ntp/scripts/summary.man.in6
-rw-r--r--contrib/ntp/scripts/summary.mdoc.in4
-rw-r--r--contrib/ntp/scripts/update-leap/Makefile.am97
-rw-r--r--contrib/ntp/scripts/update-leap/Makefile.in887
-rw-r--r--contrib/ntp/scripts/update-leap/invoke-update-leap.menu1
-rw-r--r--contrib/ntp/scripts/update-leap/invoke-update-leap.texi170
-rw-r--r--contrib/ntp/scripts/update-leap/update-leap434
-rw-r--r--contrib/ntp/scripts/update-leap/update-leap-opts72
-rw-r--r--contrib/ntp/scripts/update-leap/update-leap-opts.def163
-rw-r--r--contrib/ntp/scripts/update-leap/update-leap.1update-leapman169
-rw-r--r--contrib/ntp/scripts/update-leap/update-leap.1update-leapmdoc134
-rw-r--r--contrib/ntp/scripts/update-leap/update-leap.html274
-rw-r--r--contrib/ntp/scripts/update-leap/update-leap.man.in169
-rw-r--r--contrib/ntp/scripts/update-leap/update-leap.mdoc.in134
-rw-r--r--contrib/ntp/scripts/update-leap/update-leap.texi43
-rw-r--r--contrib/ntp/sntp/Makefile.in13
-rw-r--r--contrib/ntp/sntp/aclocal.m44
-rwxr-xr-xcontrib/ntp/sntp/configure44
-rw-r--r--contrib/ntp/sntp/include/Makefile.in13
-rw-r--r--contrib/ntp/sntp/include/version.def2
-rw-r--r--contrib/ntp/sntp/include/version.texi6
-rw-r--r--contrib/ntp/sntp/invoke-sntp.texi7
-rw-r--r--contrib/ntp/sntp/libevent/ChangeLog786
-rw-r--r--contrib/ntp/sntp/libevent/Makefile.am4
-rw-r--r--contrib/ntp/sntp/libevent/Makefile.in98
-rw-r--r--contrib/ntp/sntp/libevent/README218
-rw-r--r--contrib/ntp/sntp/libevent/WIN32-Code/nmake/event2/event-config.h4
-rw-r--r--contrib/ntp/sntp/libevent/WIN32-Code/tree.h677
-rw-r--r--contrib/ntp/sntp/libevent/aclocal.m43
-rw-r--r--contrib/ntp/sntp/libevent/buffer.c84
-rw-r--r--contrib/ntp/sntp/libevent/bufferevent.c13
-rw-r--r--contrib/ntp/sntp/libevent/bufferevent_async.c10
-rw-r--r--contrib/ntp/sntp/libevent/bufferevent_filter.c69
-rw-r--r--contrib/ntp/sntp/libevent/bufferevent_openssl.c2
-rw-r--r--contrib/ntp/sntp/libevent/bufferevent_pair.c33
-rw-r--r--contrib/ntp/sntp/libevent/config.h.in118
-rwxr-xr-xcontrib/ntp/sntp/libevent/configure4647
-rw-r--r--contrib/ntp/sntp/libevent/configure.ac33
-rw-r--r--contrib/ntp/sntp/libevent/evbuffer-internal.h14
-rw-r--r--contrib/ntp/sntp/libevent/evdns.c113
-rw-r--r--contrib/ntp/sntp/libevent/event.c48
-rw-r--r--contrib/ntp/sntp/libevent/event_tagging.c15
-rw-r--r--contrib/ntp/sntp/libevent/evrpc-internal.h1
-rw-r--r--contrib/ntp/sntp/libevent/evthread-internal.h7
-rw-r--r--contrib/ntp/sntp/libevent/evthread.c23
-rw-r--r--contrib/ntp/sntp/libevent/evutil.c42
-rw-r--r--contrib/ntp/sntp/libevent/evutil_time.c50
-rw-r--r--contrib/ntp/sntp/libevent/ht-internal.h1
-rw-r--r--contrib/ntp/sntp/libevent/http-internal.h2
-rw-r--r--contrib/ntp/sntp/libevent/http.c47
-rw-r--r--contrib/ntp/sntp/libevent/include/event2/buffer.h11
-rw-r--r--contrib/ntp/sntp/libevent/include/event2/bufferevent.h9
-rw-r--r--contrib/ntp/sntp/libevent/include/event2/dns.h18
-rw-r--r--contrib/ntp/sntp/libevent/include/event2/event.h10
-rw-r--r--contrib/ntp/sntp/libevent/include/event2/http.h14
-rw-r--r--contrib/ntp/sntp/libevent/include/event2/listener.h9
-rw-r--r--contrib/ntp/sntp/libevent/include/event2/util.h69
-rw-r--r--contrib/ntp/sntp/libevent/kqueue.c17
-rw-r--r--contrib/ntp/sntp/libevent/listener.c5
-rw-r--r--contrib/ntp/sntp/libevent/m4/acx_pthread.m4279
-rw-r--r--contrib/ntp/sntp/libevent/sample/http-server.c7
-rw-r--r--contrib/ntp/sntp/libevent/sample/https-client.c17
-rw-r--r--contrib/ntp/sntp/libevent/sample/include.am2
-rw-r--r--contrib/ntp/sntp/libevent/test/include.am3
-rw-r--r--contrib/ntp/sntp/libevent/test/regress.c37
-rw-r--r--contrib/ntp/sntp/libevent/test/regress.h6
-rw-r--r--contrib/ntp/sntp/libevent/test/regress_buffer.c53
-rw-r--r--contrib/ntp/sntp/libevent/test/regress_bufferevent.c152
-rw-r--r--contrib/ntp/sntp/libevent/test/regress_dns.c155
-rw-r--r--contrib/ntp/sntp/libevent/test/regress_finalize.c1
-rw-r--r--contrib/ntp/sntp/libevent/test/regress_http.c116
-rw-r--r--contrib/ntp/sntp/libevent/test/regress_main.c4
-rw-r--r--contrib/ntp/sntp/libevent/test/regress_minheap.c5
-rw-r--r--contrib/ntp/sntp/libevent/test/regress_ssl.c1
-rw-r--r--contrib/ntp/sntp/libevent/test/regress_thread.c5
-rw-r--r--contrib/ntp/sntp/libevent/test/regress_util.c36
-rw-r--r--contrib/ntp/sntp/libevent/test/regress_zlib.c17
-rw-r--r--contrib/ntp/sntp/libevent/test/test-fdleak.c20
-rw-r--r--contrib/ntp/sntp/libevent/test/test-ratelim.c11
-rw-r--r--contrib/ntp/sntp/libevent/test/test-time.c15
-rw-r--r--contrib/ntp/sntp/libevent/test/tinytest.c33
-rw-r--r--contrib/ntp/sntp/libevent/test/tinytest.h2
-rw-r--r--contrib/ntp/sntp/libevent/test/tinytest_macros.h27
-rw-r--r--contrib/ntp/sntp/libevent/time-internal.h3
-rw-r--r--contrib/ntp/sntp/libevent/util-internal.h2
-rw-r--r--contrib/ntp/sntp/libevent/whatsnew-2.1.txt53
-rw-r--r--contrib/ntp/sntp/libopts/Makefile.in13
-rw-r--r--contrib/ntp/sntp/libopts/m4/libopts.m424
-rw-r--r--contrib/ntp/sntp/loc/darwin1
-rw-r--r--contrib/ntp/sntp/loc/debian1
-rw-r--r--contrib/ntp/sntp/loc/freebsd1
-rw-r--r--contrib/ntp/sntp/loc/legacy1
-rw-r--r--contrib/ntp/sntp/loc/netbsd1
-rw-r--r--contrib/ntp/sntp/loc/solaris1
-rw-r--r--contrib/ntp/sntp/m4/ax_c99_struct_init.m459
-rw-r--r--contrib/ntp/sntp/m4/ntp_libntp.m48
-rw-r--r--contrib/ntp/sntp/m4/ntp_locinfo.m46
-rw-r--r--contrib/ntp/sntp/m4/openldap-thread-check.m4 (renamed from contrib/ntp/sntp/libevent/m4/openldap-thread-check.m4)0
-rw-r--r--contrib/ntp/sntp/m4/openldap.m4 (renamed from contrib/ntp/sntp/libevent/m4/openldap.m4)0
-rw-r--r--contrib/ntp/sntp/m4/version.m42
-rw-r--r--contrib/ntp/sntp/main.c22
-rw-r--r--contrib/ntp/sntp/scripts/Makefile.in13
-rw-r--r--contrib/ntp/sntp/sntp-opts.c14
-rw-r--r--contrib/ntp/sntp/sntp-opts.def3
-rw-r--r--contrib/ntp/sntp/sntp-opts.h6
-rw-r--r--contrib/ntp/sntp/sntp.1sntpman9
-rw-r--r--contrib/ntp/sntp/sntp.1sntpmdoc7
-rw-r--r--contrib/ntp/sntp/sntp.html7
-rw-r--r--contrib/ntp/sntp/sntp.man.in9
-rw-r--r--contrib/ntp/sntp/sntp.mdoc.in7
-rw-r--r--contrib/ntp/sntp/tests/Makefile.in13
-rw-r--r--contrib/ntp/tests/Makefile.in10
-rw-r--r--contrib/ntp/tests/libntp/Makefile.in10
-rw-r--r--contrib/ntp/tests/ntpd/Makefile.in10
-rw-r--r--contrib/ntp/util/Makefile.am2
-rw-r--r--contrib/ntp/util/Makefile.in12
-rw-r--r--contrib/ntp/util/invoke-ntp-keygen.texi4
-rw-r--r--contrib/ntp/util/jitter.c3
-rw-r--r--contrib/ntp/util/jitter.h401
-rw-r--r--contrib/ntp/util/ntp-keygen-opts.c14
-rw-r--r--contrib/ntp/util/ntp-keygen-opts.h6
-rw-r--r--contrib/ntp/util/ntp-keygen.1ntp-keygenman6
-rw-r--r--contrib/ntp/util/ntp-keygen.1ntp-keygenmdoc4
-rw-r--r--contrib/ntp/util/ntp-keygen.c30
-rw-r--r--contrib/ntp/util/ntp-keygen.html4
-rw-r--r--contrib/ntp/util/ntp-keygen.man.in6
-rw-r--r--contrib/ntp/util/ntp-keygen.mdoc.in4
-rw-r--r--contrib/openresolv/GNUmakefile4
-rw-r--r--contrib/openresolv/Makefile55
-rw-r--r--contrib/openresolv/config-null.mk1
-rw-r--r--contrib/openresolv/configure135
-rw-r--r--contrib/openresolv/dnsmasq.in143
-rw-r--r--contrib/openresolv/libc.in128
-rw-r--r--contrib/openresolv/named.in14
-rw-r--r--contrib/openresolv/pdns_recursor.in72
-rw-r--r--contrib/openresolv/pdnsd.in44
-rw-r--r--contrib/openresolv/resolvconf.8.in108
-rw-r--r--contrib/openresolv/resolvconf.conf.5.in152
-rw-r--r--contrib/openresolv/resolvconf.in524
-rw-r--r--contrib/openresolv/unbound.in18
-rwxr-xr-xcontrib/sqlite3/configure20
-rw-r--r--contrib/sqlite3/configure.ac2
-rw-r--r--contrib/sqlite3/shell.c928
-rw-r--r--contrib/sqlite3/sqlite3.183
-rw-r--r--contrib/sqlite3/sqlite3.c8407
-rw-r--r--contrib/sqlite3/sqlite3.h1398
-rw-r--r--contrib/tcpdump/tcpdump.c2
-rw-r--r--contrib/tzdata/africa67
-rw-r--r--contrib/tzdata/antarctica51
-rw-r--r--contrib/tzdata/backward1
-rw-r--r--contrib/tzdata/europe2
-rw-r--r--contrib/tzdata/northamerica167
-rw-r--r--contrib/tzdata/southamerica156
-rw-r--r--contrib/unbound/Makefile.in184
-rw-r--r--contrib/unbound/compat/getentropy_linux.c21
-rw-r--r--contrib/unbound/config.h15
-rw-r--r--contrib/unbound/config.h.in9
-rwxr-xr-xcontrib/unbound/configure122
-rw-r--r--contrib/unbound/configure.ac18
-rw-r--r--contrib/unbound/daemon/remote.c9
-rw-r--r--contrib/unbound/daemon/unbound.c33
-rw-r--r--contrib/unbound/daemon/worker.c2
-rw-r--r--contrib/unbound/doc/Changelog106
-rw-r--r--contrib/unbound/doc/README2
-rw-r--r--contrib/unbound/doc/example.conf12
-rw-r--r--contrib/unbound/doc/example.conf.in12
-rw-r--r--contrib/unbound/doc/libunbound.34
-rw-r--r--contrib/unbound/doc/libunbound.3.in4
-rw-r--r--contrib/unbound/doc/unbound-anchor.82
-rw-r--r--contrib/unbound/doc/unbound-anchor.8.in2
-rw-r--r--contrib/unbound/doc/unbound-checkconf.86
-rw-r--r--contrib/unbound/doc/unbound-checkconf.8.in6
-rw-r--r--contrib/unbound/doc/unbound-control.82
-rw-r--r--contrib/unbound/doc/unbound-control.8.in2
-rw-r--r--contrib/unbound/doc/unbound-host.12
-rw-r--r--contrib/unbound/doc/unbound-host.1.in2
-rw-r--r--contrib/unbound/doc/unbound.84
-rw-r--r--contrib/unbound/doc/unbound.8.in4
-rw-r--r--contrib/unbound/doc/unbound.conf.516
-rw-r--r--contrib/unbound/doc/unbound.conf.5.in16
-rw-r--r--contrib/unbound/iterator/iter_scrub.c4
-rw-r--r--contrib/unbound/iterator/iter_utils.c36
-rw-r--r--contrib/unbound/iterator/iter_utils.h9
-rw-r--r--contrib/unbound/iterator/iterator.c15
-rw-r--r--contrib/unbound/libunbound/libworker.c6
-rw-r--r--contrib/unbound/libunbound/python/libunbound.i8
-rw-r--r--contrib/unbound/services/listen_dnsport.c64
-rw-r--r--contrib/unbound/services/localzone.c29
-rw-r--r--contrib/unbound/services/localzone.h9
-rw-r--r--contrib/unbound/smallapp/unbound-checkconf.c20
-rwxr-xr-xcontrib/unbound/smallapp/unbound-control-setup.sh3
-rwxr-xr-xcontrib/unbound/smallapp/unbound-control-setup.sh.in3
-rw-r--r--contrib/unbound/smallapp/unbound-control.c8
-rw-r--r--contrib/unbound/util/config_file.c25
-rw-r--r--contrib/unbound/util/config_file.h11
-rw-r--r--contrib/unbound/util/configlexer.lex1
-rw-r--r--contrib/unbound/util/configparser.y18
-rw-r--r--contrib/unbound/util/iana_ports.inc7
-rw-r--r--contrib/unbound/util/net_help.c7
-rw-r--r--contrib/unbound/util/rtt.c2
-rw-r--r--contrib/unbound/util/rtt.h2
-rw-r--r--contrib/unbound/validator/val_secalgo.c3
-rw-r--r--contrib/unbound/validator/val_utils.c12
-rw-r--r--contrib/unbound/validator/val_utils.h7
-rw-r--r--contrib/unbound/validator/validator.c57
-rw-r--r--etc/Makefile8
-rw-r--r--etc/defaults/rc.conf2
-rw-r--r--etc/etc.arm/ttys4
-rw-r--r--etc/libmap32.conf2
-rw-r--r--etc/mtree/BSD.tests.dist6
-rw-r--r--etc/mtree/BSD.usr.dist10
-rw-r--r--etc/rc.d/Makefile4
-rwxr-xr-xetc/rc.d/devd2
-rwxr-xr-xetc/rc.d/hostid64
-rwxr-xr-xetc/rc.d/local_unbound2
-rw-r--r--gnu/lib/Makefile10
-rw-r--r--gnu/lib/libgomp/Makefile2
-rw-r--r--gnu/lib/libgomp/config.h6
-rw-r--r--gnu/usr.bin/cc/Makefile5
-rw-r--r--gnu/usr.bin/groff/src/preproc/Makefile2
-rw-r--r--gnu/usr.bin/groff/src/preproc/soelim/Makefile9
-rw-r--r--include/stdlib.h9
-rw-r--r--include/stringlist.h5
-rw-r--r--kerberos5/lib/Makefile2
-rw-r--r--kerberos5/lib/libhdb/Makefile4
-rw-r--r--kerberos5/lib/libheimsqlite/Makefile10
-rw-r--r--lib/Makefile13
-rw-r--r--lib/csu/Makefile5
-rw-r--r--lib/csu/i386/Makefile (renamed from lib/csu/i386-elf/Makefile)0
-rw-r--r--lib/csu/i386/crt1_c.c (renamed from lib/csu/i386-elf/crt1_c.c)0
-rw-r--r--lib/csu/i386/crt1_s.S (renamed from lib/csu/i386-elf/crt1_s.S)0
-rw-r--r--lib/csu/i386/crti.S (renamed from lib/csu/i386-elf/crti.S)0
-rw-r--r--lib/csu/i386/crtn.S (renamed from lib/csu/i386-elf/crtn.S)0
-rw-r--r--lib/libc/aarch64/Symbol.map1
-rw-r--r--lib/libc/aarch64/gen/Makefile.inc3
-rw-r--r--lib/libc/aarch64/gen/fabs.S33
-rw-r--r--lib/libc/arm/SYS.h2
-rw-r--r--lib/libc/arm/aeabi/aeabi_vfp_double.S8
-rw-r--r--lib/libc/arm/aeabi/aeabi_vfp_float.S8
-rw-r--r--lib/libc/arm/gen/_setjmp.S17
-rw-r--r--lib/libc/arm/gen/setjmp.S17
-rw-r--r--lib/libc/arm/sys/brk.S18
-rw-r--r--lib/libc/arm/sys/sbrk.S17
-rw-r--r--lib/libc/db/hash/hash.c7
-rw-r--r--lib/libc/gen/directory.325
-rw-r--r--lib/libc/gen/dlfcn.c5
-rw-r--r--lib/libc/gen/readdir.c6
-rw-r--r--lib/libc/gen/rewinddir.c1
-rw-r--r--lib/libc/gen/stringlist.c2
-rw-r--r--lib/libc/gen/telldir.c37
-rw-r--r--lib/libc/gen/telldir.h1
-rw-r--r--lib/libc/net/recv.c6
-rw-r--r--lib/libc/net/send.c6
-rw-r--r--lib/libc/stdlib/Makefile.inc5
-rw-r--r--lib/libc/stdlib/Symbol.map1
-rw-r--r--lib/libc/stdlib/reallocarray.3142
-rw-r--r--lib/libc/stdlib/reallocarray.c42
-rw-r--r--lib/libc/sys/fork.27
-rw-r--r--lib/libc/sys/socketpair.28
-rw-r--r--lib/libc/sys/truncate.226
-rw-r--r--lib/libc/tests/sys/Makefile2
-rw-r--r--lib/libcapsicum/libcapsicum.318
-rw-r--r--lib/libcapsicum/libcapsicum.c14
-rw-r--r--lib/libcapsicum/libcapsicum.h4
-rw-r--r--lib/libcapsicum/libcapsicum_dns.c44
-rw-r--r--lib/libcapsicum/libcapsicum_grp.c35
-rw-r--r--lib/libcapsicum/libcapsicum_pwd.c22
-rw-r--r--lib/libcapsicum/libcapsicum_random.c2
-rw-r--r--lib/libcapsicum/libcapsicum_service.c2
-rw-r--r--lib/libcapsicum/libcapsicum_sysctl.c2
-rw-r--r--lib/libcasper/libcasper.c4
-rw-r--r--lib/libedit/chartype.c100
-rw-r--r--lib/libedit/chartype.h12
-rw-r--r--lib/libedit/edit/readline/readline.h2
-rw-r--r--lib/libedit/el.c2
-rw-r--r--lib/libedit/eln.c18
-rw-r--r--lib/libedit/map.c8
-rw-r--r--lib/libedit/readline.c38
-rw-r--r--lib/libedit/tty.c8
-rw-r--r--lib/libelftc/elftc_version.c2
-rw-r--r--lib/libevent/Makefile1
-rw-r--r--lib/libmandoc/Makefile46
-rw-r--r--lib/libmd/Makefile8
-rw-r--r--lib/libmd/md4.h28
-rw-r--r--lib/libmd/md4c.c15
-rw-r--r--lib/libmd/md5.h37
-rw-r--r--lib/libmd/md5c.c19
-rw-r--r--lib/libmd/mdXhl.c15
-rw-r--r--lib/libmd/ripemd.h35
-rw-r--r--lib/libmd/rmd160c.c19
-rw-r--r--lib/libmd/sha.h68
-rw-r--r--lib/libmd/sha1c.c30
-rw-r--r--lib/libmd/sha256.h32
-rw-r--r--lib/libmd/sha256c.c15
-rw-r--r--lib/libmd/sha512.h32
-rw-r--r--lib/libmd/sha512c.c15
-rw-r--r--lib/libmd/shadriver.c3
-rw-r--r--lib/libnv/Makefile175
-rw-r--r--lib/libnv/nv.361
-rw-r--r--lib/libnv/tests/dnv_tests.cc38
-rw-r--r--lib/libnv/tests/nv_tests.cc75
-rw-r--r--lib/libnv/tests/nvlist_send_recv_test.c2
-rw-r--r--lib/libpmc/libpmc.c94
-rw-r--r--lib/libproc/Makefile2
-rw-r--r--lib/libprocstat/Makefile30
-rw-r--r--lib/libprocstat/libprocstat.353
-rw-r--r--lib/libthr/tests/Makefile2
-rw-r--r--lib/libthr/thread/thr_spec.c201
-rw-r--r--lib/libucl/Makefile4
-rw-r--r--lib/libufs/Makefile1
-rw-r--r--lib/libvmmapi/vmmapi.c34
-rw-r--r--lib/libvmmapi/vmmapi.h11
-rw-r--r--lib/libxo/Makefile2
-rw-r--r--lib/msun/src/e_j0.c2
-rw-r--r--lib/msun/src/e_j0f.c2
-rw-r--r--lib/msun/src/e_j1.c2
-rw-r--r--lib/msun/src/e_j1f.c2
-rw-r--r--lib/msun/tests/Makefile9
-rw-r--r--libexec/casper/dns/dns.c27
-rw-r--r--libexec/casper/grp/grp.c9
-rw-r--r--libexec/getty/subr.c14
-rw-r--r--libexec/rtld-elf/debug.h4
-rw-r--r--libexec/rtld-elf/rtld.c85
-rw-r--r--release/Makefile.ec229
-rw-r--r--release/Makefile.mirrors253
-rw-r--r--release/arm/BEAGLEBONE.conf60
-rw-r--r--release/arm/PANDABOARD.conf60
-rw-r--r--release/arm/RPI-B.conf69
-rw-r--r--release/arm/RPI2.conf43
-rw-r--r--release/arm/WANDBOARD-QUAD.conf37
-rw-r--r--release/arm/WANDBOARD.conf41
-rw-r--r--release/arm/ZEDBOARD.conf36
-rwxr-xr-xrelease/arm/release.sh156
-rwxr-xr-xrelease/arm64/make-memstick.sh2
-rw-r--r--release/doc/en_US.ISO8859-1/relnotes/article.xml190
-rw-r--r--release/doc/share/xml/release.ent1
-rw-r--r--release/doc/share/xml/sponsor.ent8
-rwxr-xr-xrelease/i386/make-memstick.sh13
-rwxr-xr-xrelease/release.sh559
-rw-r--r--release/tools/arm.subr137
-rw-r--r--release/tools/arm/crochet-BEAGLEBONE.conf29
-rw-r--r--release/tools/arm/crochet-PANDABOARD.conf29
-rw-r--r--release/tools/arm/crochet-RPI-B.conf29
-rw-r--r--release/tools/arm/crochet-WANDBOARD-QUAD.conf29
-rw-r--r--release/tools/arm/crochet-ZEDBOARD.conf29
-rw-r--r--release/tools/vmimage.subr13
-rw-r--r--sbin/casperd/casperd.c2
-rw-r--r--sbin/casperd/zygote.c4
-rw-r--r--sbin/devd/devd.conf.524
-rw-r--r--sbin/geom/class/mountver/geom_mountver.c4
-rw-r--r--sbin/geom/class/mountver/gmountver.813
-rw-r--r--sbin/geom/class/part/gpart.86
-rw-r--r--sbin/ifconfig/af_inet.c4
-rw-r--r--sbin/ifconfig/af_inet6.c2
-rw-r--r--sbin/ifconfig/ifconfig.827
-rw-r--r--sbin/ifconfig/iffib.c36
-rw-r--r--sbin/ifconfig/ifgif.c4
-rw-r--r--sbin/ifconfig/sfp.c189
-rw-r--r--sbin/ipfw/tables.c99
-rw-r--r--sbin/ping/ping.c3
-rw-r--r--sbin/resolvconf/Makefile2
-rw-r--r--share/doc/papers/Makefile1
-rw-r--r--share/doc/papers/bufbio/bio.ms20
-rw-r--r--share/doc/papers/hwpmc/Makefile8
-rw-r--r--share/doc/papers/hwpmc/hwpmc.ms34
-rw-r--r--share/doc/usd/06.bc/bc5
-rw-r--r--share/doc/usd/10.exref/exref/ex.rm2
-rw-r--r--share/doc/usd/18.msdiffs/ms.diffs1
-rw-r--r--share/doc/usd/22.trofftut/tt001
-rw-r--r--share/doc/usd/contents/contents.ms1
-rwxr-xr-xshare/dtrace/siftr68
-rw-r--r--share/man/man3/pthread_getspecific.35
-rw-r--r--share/man/man4/acpi.423
-rw-r--r--share/man/man4/ctl.418
-rw-r--r--share/man/man4/iic.499
-rw-r--r--share/man/man4/usb_quirk.45
-rw-r--r--share/man/man4/xen.448
-rw-r--r--share/man/man9/Makefile1
-rw-r--r--share/man/man9/namei.918
-rw-r--r--share/man/man9/psignal.924
-rw-r--r--share/misc/bsd-family-tree18
-rw-r--r--share/misc/committers-src.dot2
-rw-r--r--share/mk/atf.test.mk6
-rw-r--r--share/mk/bsd.incs.mk2
-rw-r--r--share/mk/bsd.lib.mk36
-rw-r--r--share/mk/bsd.prog.mk4
-rw-r--r--share/mk/src.libnames.mk86
-rw-r--r--share/mk/src.opts.mk2
-rw-r--r--share/syscons/keymaps/INDEX.keymaps2
-rw-r--r--share/vt/keymaps/INDEX.keymaps14
-rw-r--r--sys/amd64/acpica/acpi_machdep.c7
-rw-r--r--sys/amd64/amd64/apic_vector.S36
-rw-r--r--sys/amd64/amd64/cpu_switch.S75
-rw-r--r--sys/amd64/amd64/db_disasm.c4
-rw-r--r--sys/amd64/amd64/genassym.c2
-rw-r--r--sys/amd64/amd64/machdep.c1
-rw-r--r--sys/amd64/amd64/mp_machdep.c254
-rw-r--r--sys/amd64/amd64/mp_watchdog.c2
-rw-r--r--sys/amd64/amd64/pmap.c443
-rw-r--r--sys/amd64/amd64/vm_machdep.c2
-rw-r--r--sys/amd64/conf/GENERIC11
-rw-r--r--sys/amd64/conf/NOTES2
-rw-r--r--sys/amd64/include/cpufunc.h5
-rw-r--r--sys/amd64/include/md_var.h1
-rw-r--r--sys/amd64/include/pcpu.h4
-rw-r--r--sys/amd64/include/pmap.h15
-rw-r--r--sys/amd64/include/smp.h19
-rw-r--r--sys/amd64/include/vmm.h23
-rw-r--r--sys/amd64/include/vmm_instruction_emul.h12
-rw-r--r--sys/amd64/include/xen/xenfunc.h9
-rw-r--r--sys/amd64/include/xen/xenpmap.h227
-rw-r--r--sys/amd64/include/xen/xenvar.h61
-rw-r--r--sys/amd64/linux32/linux32_machdep.c10
-rw-r--r--sys/amd64/vmm/amd/amdv.c1
-rw-r--r--sys/amd64/vmm/amd/svm.c98
-rw-r--r--sys/amd64/vmm/amd/svm_msr.c31
-rw-r--r--sys/amd64/vmm/amd/vmcb.c1
-rw-r--r--sys/amd64/vmm/intel/vmx.c1
-rw-r--r--sys/amd64/vmm/intel/vmx_msr.c23
-rw-r--r--sys/amd64/vmm/io/vatpic.c1
-rw-r--r--sys/amd64/vmm/io/vatpit.c3
-rw-r--r--sys/amd64/vmm/io/vhpet.c1
-rw-r--r--sys/amd64/vmm/io/vioapic.c1
-rw-r--r--sys/amd64/vmm/io/vlapic.c20
-rw-r--r--sys/amd64/vmm/io/vpmtmr.c1
-rw-r--r--sys/amd64/vmm/io/vrtc.c118
-rw-r--r--sys/amd64/vmm/vmm.c61
-rw-r--r--sys/amd64/vmm/vmm_dev.c14
-rw-r--r--sys/amd64/vmm/vmm_instruction_emul.c235
-rw-r--r--sys/amd64/vmm/vmm_ioport.c6
-rw-r--r--sys/amd64/vmm/vmm_stat.c1
-rw-r--r--sys/amd64/vmm/x86.c53
-rw-r--r--sys/amd64/vmm/x86.h13
-rw-r--r--sys/arm/allwinner/a10_clk.c110
-rw-r--r--sys/arm/allwinner/a10_clk.h29
-rw-r--r--sys/arm/allwinner/a10_mmc.c689
-rw-r--r--sys/arm/allwinner/a10_mmc.h179
-rw-r--r--sys/arm/allwinner/a20/files.a202
-rw-r--r--sys/arm/allwinner/files.allwinner1
-rw-r--r--sys/arm/allwinner/std.a106
-rw-r--r--sys/arm/altera/socfpga/files.socfpga1
-rw-r--r--sys/arm/amlogic/aml8726/aml8726_ccm.c1
-rw-r--r--sys/arm/amlogic/aml8726/aml8726_machdep.c41
-rw-r--r--sys/arm/amlogic/aml8726/aml8726_mmc.c318
-rw-r--r--sys/arm/amlogic/aml8726/aml8726_mmc.h14
-rw-r--r--sys/arm/amlogic/aml8726/aml8726_pic.c10
-rw-r--r--sys/arm/amlogic/aml8726/aml8726_pinctrl.c1
-rw-r--r--sys/arm/amlogic/aml8726/aml8726_rng.c2
-rw-r--r--sys/arm/amlogic/aml8726/aml8726_rtc.c51
-rw-r--r--sys/arm/amlogic/aml8726/aml8726_sdxc-m8.c1
-rw-r--r--sys/arm/amlogic/aml8726/aml8726_uart.h10
-rw-r--r--sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c428
-rw-r--r--sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c4
-rw-r--r--sys/arm/amlogic/aml8726/files.aml87264
-rw-r--r--sys/arm/amlogic/aml8726/uart_dev_aml8726.c51
-rw-r--r--sys/arm/annapurna/alpine/alpine_machdep.c148
-rw-r--r--sys/arm/annapurna/alpine/alpine_machdep_mp.c335
-rw-r--r--sys/arm/annapurna/alpine/common.c158
-rw-r--r--sys/arm/annapurna/alpine/files.alpine16
-rw-r--r--sys/arm/annapurna/alpine/hal/al_hal_common.h70
-rw-r--r--sys/arm/annapurna/alpine/hal/al_hal_iofic.h222
-rw-r--r--sys/arm/annapurna/alpine/hal/al_hal_iofic_regs.h127
-rw-r--r--sys/arm/annapurna/alpine/hal/al_hal_nb_regs.h1823
-rw-r--r--sys/arm/annapurna/alpine/hal/al_hal_pbs_regs.h2751
-rw-r--r--sys/arm/annapurna/alpine/hal/al_hal_pcie.c2788
-rw-r--r--sys/arm/annapurna/alpine/hal/al_hal_pcie.h1157
-rw-r--r--sys/arm/annapurna/alpine/hal/al_hal_pcie_axi_reg.h1501
-rw-r--r--sys/arm/annapurna/alpine/hal/al_hal_pcie_interrupts.h271
-rw-r--r--sys/arm/annapurna/alpine/hal/al_hal_pcie_regs.h594
-rw-r--r--sys/arm/annapurna/alpine/hal/al_hal_pcie_w_reg.h1505
-rw-r--r--sys/arm/annapurna/alpine/hal/al_hal_plat_services.h419
-rw-r--r--sys/arm/annapurna/alpine/hal/al_hal_plat_types.h94
-rw-r--r--sys/arm/annapurna/alpine/hal/al_hal_reg_utils.h188
-rw-r--r--sys/arm/annapurna/alpine/hal/al_hal_types.h117
-rw-r--r--sys/arm/annapurna/alpine/hal/al_hal_unit_adapter_regs.h314
-rw-r--r--sys/arm/annapurna/alpine/std.alpine23
-rw-r--r--sys/arm/arm/autoconf.c1
-rw-r--r--sys/arm/arm/busdma_machdep-v6.c4
-rw-r--r--sys/arm/arm/busdma_machdep.c4
-rw-r--r--sys/arm/arm/cpufunc.c17
-rw-r--r--sys/arm/arm/cpufunc_asm_armv7.S9
-rw-r--r--sys/arm/arm/cpuinfo.c13
-rw-r--r--sys/arm/arm/db_disasm.c2
-rw-r--r--sys/arm/arm/elf_machdep.c12
-rw-r--r--sys/arm/arm/exception.S1
-rw-r--r--sys/arm/arm/fusu.S5
-rw-r--r--sys/arm/arm/generic_timer.c2
-rw-r--r--sys/arm/arm/intr.c2
-rw-r--r--sys/arm/arm/machdep.c71
-rw-r--r--sys/arm/arm/mp_machdep.c17
-rw-r--r--sys/arm/arm/pmap-v6-new.c110
-rw-r--r--sys/arm/arm/pmap.c8
-rw-r--r--sys/arm/arm/pmu.c30
-rw-r--r--sys/arm/arm/stdatomic.c28
-rw-r--r--sys/arm/arm/swtch.S11
-rw-r--r--sys/arm/arm/syscall.c11
-rw-r--r--sys/arm/arm/undefined.c149
-rw-r--r--sys/arm/arm/vm_machdep.c8
-rw-r--r--sys/arm/at91/at91_pio.c4
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c62
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_fb.c416
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_fbd.c263
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_mbox.c174
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_mbox_prop.h153
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_sdhci.c9
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_vcbus.h12
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2836.c50
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2836_mp.c206
-rw-r--r--sys/arm/broadcom/bcm2835/files.bcm28361
-rw-r--r--sys/arm/broadcom/bcm2835/std.bcm28361
-rw-r--r--sys/arm/conf/ALPINE78
-rw-r--r--sys/arm/conf/AML872637
-rw-r--r--sys/arm/conf/APALIS-IMX62
-rw-r--r--sys/arm/conf/ARMADAXP33
-rw-r--r--sys/arm/conf/ARNDALE2
-rw-r--r--sys/arm/conf/ARNDALE-OCTA2
-rw-r--r--sys/arm/conf/ATMEL37
-rw-r--r--sys/arm/conf/AVILA5
-rw-r--r--sys/arm/conf/BEAGLEBONE37
-rw-r--r--sys/arm/conf/BWCT98
-rw-r--r--sys/arm/conf/CAMBRIA5
-rw-r--r--sys/arm/conf/CHROMEBOOK2
-rw-r--r--sys/arm/conf/CHROMEBOOK-PEACH-PIT2
-rw-r--r--sys/arm/conf/CHROMEBOOK-SNOW2
-rw-r--r--sys/arm/conf/CHROMEBOOK-SPRING2
-rw-r--r--sys/arm/conf/CNS11XXNAS3
-rw-r--r--sys/arm/conf/COLIBRI-VF502
-rw-r--r--sys/arm/conf/COSMIC2
-rw-r--r--sys/arm/conf/CRB3
-rw-r--r--sys/arm/conf/CUBIEBOARD40
-rw-r--r--sys/arm/conf/CUBIEBOARD243
-rw-r--r--sys/arm/conf/DB-78XXX3
-rw-r--r--sys/arm/conf/DB-88F5XXX3
-rw-r--r--sys/arm/conf/DB-88F6XXX38
-rw-r--r--sys/arm/conf/DIGI-CCWMX532
-rw-r--r--sys/arm/conf/DOCKSTAR88
-rw-r--r--sys/arm/conf/DREAMPLUG-100188
-rw-r--r--sys/arm/conf/EA32503
-rw-r--r--sys/arm/conf/EB9200100
-rw-r--r--sys/arm/conf/EFIKA_MX31
-rw-r--r--sys/arm/conf/EP802193
-rw-r--r--sys/arm/conf/ETHERNUT539
-rw-r--r--sys/arm/conf/EXYNOS5.common4
-rw-r--r--sys/arm/conf/EXYNOS52504
-rw-r--r--sys/arm/conf/EXYNOS54204
-rw-r--r--sys/arm/conf/GUMSTIX3
-rw-r--r--sys/arm/conf/HL200106
-rw-r--r--sys/arm/conf/HL201108
-rw-r--r--sys/arm/conf/IMX5331
-rw-r--r--sys/arm/conf/IMX53-QSB2
-rw-r--r--sys/arm/conf/IMX634
-rw-r--r--sys/arm/conf/IQ312443
-rw-r--r--sys/arm/conf/KB920X117
-rw-r--r--sys/arm/conf/LN2410SBC1
-rw-r--r--sys/arm/conf/NSLU5
-rw-r--r--sys/arm/conf/ODROIDC15
-rw-r--r--sys/arm/conf/PANDABOARD37
-rw-r--r--sys/arm/conf/QILA9G20104
-rw-r--r--sys/arm/conf/QUARTZ2
-rw-r--r--sys/arm/conf/RADXA2
-rw-r--r--sys/arm/conf/RADXA-LITE2
-rw-r--r--sys/arm/conf/RK318837
-rw-r--r--sys/arm/conf/RPI-B36
-rw-r--r--sys/arm/conf/RPI247
-rw-r--r--sys/arm/conf/SAM9260EK35
-rw-r--r--sys/arm/conf/SAM9G20EK118
-rw-r--r--sys/arm/conf/SAM9X25EK105
-rw-r--r--sys/arm/conf/SHEEVAPLUG42
-rw-r--r--sys/arm/conf/SN9G4572
-rw-r--r--sys/arm/conf/SOCKIT.common35
-rw-r--r--sys/arm/conf/TS78003
-rw-r--r--sys/arm/conf/VERSATILEPB32
-rw-r--r--sys/arm/conf/VIRT45
-rw-r--r--sys/arm/conf/VSATV1025
-rw-r--r--sys/arm/conf/VYBRID37
-rw-r--r--sys/arm/conf/WANDBOARD-DUAL28
-rw-r--r--sys/arm/conf/WANDBOARD-QUAD28
-rw-r--r--sys/arm/conf/WANDBOARD-SOLO28
-rw-r--r--sys/arm/conf/ZEDBOARD34
-rw-r--r--sys/arm/conf/std.arm5
-rw-r--r--sys/arm/conf/std.armv638
-rw-r--r--sys/arm/freescale/imx/files.imx61
-rw-r--r--sys/arm/freescale/imx/imx6_anatop.c64
-rw-r--r--sys/arm/freescale/imx/imx6_ccm.c14
-rw-r--r--sys/arm/freescale/imx/imx6_ccmreg.h2
-rw-r--r--sys/arm/freescale/imx/imx_ccmvar.h4
-rw-r--r--sys/arm/freescale/imx/imx_sdhci.c2
-rw-r--r--sys/arm/freescale/vybrid/files.vybrid1
-rw-r--r--sys/arm/include/armreg.h3
-rw-r--r--sys/arm/include/asm.h10
-rw-r--r--sys/arm/include/atomic.h38
-rw-r--r--sys/arm/include/cpu-v6.h124
-rw-r--r--sys/arm/include/cpufunc.h1
-rw-r--r--sys/arm/include/elf.h45
-rw-r--r--sys/arm/include/pl310.h2
-rw-r--r--sys/arm/include/pmap-v6.h1
-rw-r--r--sys/arm/include/proc.h13
-rw-r--r--sys/arm/include/smp.h1
-rw-r--r--sys/arm/include/sysreg.h1
-rw-r--r--sys/arm/qemu/files.qemu1
-rw-r--r--sys/arm/rockchip/files.rk30xx1
-rw-r--r--sys/arm/samsung/exynos/files.exynos51
-rw-r--r--sys/arm/ti/aintc.c11
-rw-r--r--sys/arm/ti/am335x/am335x_dmtimer.c413
-rw-r--r--sys/arm/ti/am335x/am335x_ecap.c201
-rw-r--r--sys/arm/ti/am335x/am335x_ehrpwm.c (renamed from sys/arm/ti/am335x/am335x_pwm.c)230
-rw-r--r--sys/arm/ti/am335x/am335x_gpio.c9
-rw-r--r--sys/arm/ti/am335x/am335x_lcd.c147
-rw-r--r--sys/arm/ti/am335x/am335x_lcd.h6
-rw-r--r--sys/arm/ti/am335x/am335x_musb.c417
-rw-r--r--sys/arm/ti/am335x/am335x_pmic.c84
-rw-r--r--sys/arm/ti/am335x/am335x_prcm.c97
-rw-r--r--sys/arm/ti/am335x/am335x_pwm.h2
-rw-r--r--sys/arm/ti/am335x/am335x_pwmss.c163
-rw-r--r--sys/arm/ti/am335x/am335x_scm_padconf.c430
-rw-r--r--sys/arm/ti/am335x/am335x_usbss.c366
-rw-r--r--sys/arm/ti/am335x/files.am335x5
-rw-r--r--sys/arm/ti/cpsw/if_cpsw.c110
-rw-r--r--sys/arm/ti/cpsw/if_cpswreg.h2
-rw-r--r--sys/arm/ti/cpsw/if_cpswvar.h4
-rw-r--r--sys/arm/ti/files.ti2
-rw-r--r--sys/arm/ti/omap4/files.omap43
-rw-r--r--sys/arm/ti/omap4/omap4_gpio.c12
-rw-r--r--sys/arm/ti/omap4/omap4_prcm_clks.c316
-rw-r--r--sys/arm/ti/omap4/omap4_scm_padconf.c414
-rw-r--r--sys/arm/ti/omap4/omap4var.h91
-rw-r--r--sys/arm/ti/omap4/pandaboard/pandaboard.c1
-rw-r--r--sys/arm/ti/ti_adc.c2
-rw-r--r--sys/arm/ti/ti_common.c23
-rw-r--r--sys/arm/ti/ti_edma3.c11
-rw-r--r--sys/arm/ti/ti_gpio.c341
-rw-r--r--sys/arm/ti/ti_gpio.h20
-rw-r--r--sys/arm/ti/ti_hwmods.c170
-rw-r--r--sys/arm/ti/ti_hwmods.h34
-rw-r--r--sys/arm/ti/ti_i2c.c31
-rw-r--r--sys/arm/ti/ti_mbox.c2
-rw-r--r--sys/arm/ti/ti_pinmux.c445
-rw-r--r--sys/arm/ti/ti_pinmux.h80
-rw-r--r--sys/arm/ti/ti_prcm.h55
-rw-r--r--sys/arm/ti/ti_pruss.c32
-rw-r--r--sys/arm/ti/ti_pruss.h4
-rw-r--r--sys/arm/ti/ti_scm.c346
-rw-r--r--sys/arm/ti/ti_scm.h26
-rw-r--r--sys/arm/ti/ti_sdhci.c22
-rw-r--r--sys/arm/ti/ti_sdma.c2
-rw-r--r--sys/arm/ti/usb/omap_ehci.c728
-rw-r--r--sys/arm/ti/usb/omap_host.c466
-rw-r--r--sys/arm/ti/usb/omap_tll.c364
-rw-r--r--sys/arm/ti/usb/omap_usb.h224
-rw-r--r--sys/arm/xilinx/files.zynq71
-rw-r--r--sys/arm64/arm64/bus_machdep.c16
-rw-r--r--sys/arm64/arm64/bus_space_asm.S6
-rw-r--r--sys/arm64/arm64/busdma_bounce.c1080
-rw-r--r--sys/arm64/arm64/busdma_machdep.c305
-rw-r--r--sys/arm64/arm64/db_disasm.c41
-rw-r--r--sys/arm64/arm64/db_interface.c168
-rw-r--r--sys/arm64/arm64/db_trace.c152
-rw-r--r--sys/arm64/arm64/debug_monitor.c487
-rw-r--r--sys/arm64/arm64/gic_v3.c580
-rw-r--r--sys/arm64/arm64/gic_v3_fdt.c124
-rw-r--r--sys/arm64/arm64/gic_v3_reg.h185
-rw-r--r--sys/arm64/arm64/gic_v3_var.h106
-rw-r--r--sys/arm64/arm64/intr_machdep.c4
-rw-r--r--sys/arm64/arm64/locore.S14
-rw-r--r--sys/arm64/arm64/nexus.c10
-rw-r--r--sys/arm64/arm64/pmap.c12
-rw-r--r--sys/arm64/conf/GENERIC3
-rw-r--r--sys/arm64/include/armreg.h41
-rw-r--r--sys/arm64/include/bus_dma_impl.h96
-rw-r--r--sys/arm64/include/pmap.h2
-rw-r--r--sys/arm64/include/pmc_mdep.h23
-rw-r--r--sys/boot/arm/uboot/Makefile42
-rw-r--r--sys/boot/arm/uboot/ldscript.arm18
-rw-r--r--sys/boot/arm/uboot/start.S48
-rw-r--r--sys/boot/common/dev_net.c73
-rw-r--r--sys/boot/common/dev_net.h6
-rw-r--r--sys/boot/common/load_elf.c35
-rw-r--r--sys/boot/common/self_reloc.c (renamed from sys/boot/efi/loader/reloc.c)25
-rw-r--r--sys/boot/efi/boot1/Makefile5
-rw-r--r--sys/boot/efi/libefi/Makefile3
-rw-r--r--sys/boot/efi/loader/Makefile8
-rw-r--r--sys/boot/efi/loader/arch/amd64/start.S2
-rw-r--r--sys/boot/efi/loader/arch/arm/ldscript.arm2
-rw-r--r--sys/boot/efi/loader/arch/arm/start.S2
-rw-r--r--sys/boot/efi/loader/arch/arm64/Makefile.inc2
-rw-r--r--sys/boot/efi/loader/arch/arm64/start.S2
-rw-r--r--sys/boot/efi/loader/arch/i386/start.S4
-rw-r--r--sys/boot/efi/loader/main.c3
-rw-r--r--sys/boot/fdt/dts/arm/am335x-evm.dts158
-rw-r--r--sys/boot/fdt/dts/arm/am335x.dtsi349
-rw-r--r--sys/boot/fdt/dts/arm/annapurna-alpine.dts244
-rw-r--r--sys/boot/fdt/dts/arm/beaglebone-black.dts159
-rw-r--r--sys/boot/fdt/dts/arm/beaglebone-common.dtsi45
-rw-r--r--sys/boot/fdt/dts/arm/beaglebone.dts121
-rw-r--r--sys/boot/fdt/dts/arm/cubieboard.dts4
-rw-r--r--sys/boot/fdt/dts/arm/cubieboard2.dts4
-rw-r--r--sys/boot/fdt/dts/arm/odroidc1.dts11
-rw-r--r--sys/boot/fdt/dts/arm/pandaboard-common.dtsi49
-rw-r--r--sys/boot/fdt/dts/arm/pandaboard-es.dts31
-rw-r--r--sys/boot/fdt/dts/arm/pandaboard.dts161
-rw-r--r--sys/boot/fdt/dts/arm/rpi2.dts18
-rw-r--r--sys/boot/fdt/dts/arm/sun4i-a10.dtsi8
-rw-r--r--sys/boot/fdt/dts/arm/sun7i-a20.dtsi8
-rw-r--r--sys/boot/fdt/dts/arm/vsatv102-m6.dts10
-rw-r--r--sys/boot/forth/loader.conf10
-rw-r--r--sys/boot/i386/boot0/boot0.S4
-rw-r--r--sys/boot/sparc64/loader/main.c6
-rw-r--r--sys/boot/uboot/common/main.c9
-rw-r--r--sys/boot/uboot/lib/copy.c113
-rw-r--r--sys/boot/uboot/lib/elf_freebsd.c2
-rw-r--r--sys/boot/uboot/lib/libuboot.h5
-rw-r--r--sys/boot/uboot/lib/net.c109
-rw-r--r--sys/cam/ctl/ctl_backend_block.c6
-rw-r--r--sys/cddl/contrib/opensolaris/common/nvpair/nvpair.c1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c4
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c13
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c11
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c33
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c3
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c5
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c2
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h4
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c28
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_onexit.c2
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c7
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c24
-rw-r--r--sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c6
-rw-r--r--sys/cddl/dev/dtrace/amd64/dtrace_subr.c108
-rw-r--r--sys/cddl/dev/dtrace/i386/dtrace_subr.c116
-rw-r--r--sys/cddl/dev/profile/profile.c4
-rw-r--r--sys/compat/freebsd32/freebsd32_misc.c17
-rw-r--r--sys/compat/ndis/subr_ntoskrnl.c2
-rw-r--r--sys/compat/svr4/svr4_misc.c14
-rw-r--r--sys/conf/NOTES1
-rw-r--r--sys/conf/files53
-rw-r--r--sys/conf/files.amd649
-rw-r--r--sys/conf/files.arm1
-rw-r--r--sys/conf/files.arm6410
-rw-r--r--sys/conf/files.i38648
-rw-r--r--sys/conf/files.powerpc9
-rw-r--r--sys/conf/kern.mk2
-rw-r--r--sys/conf/kern.pre.mk2
-rw-r--r--sys/conf/options4
-rw-r--r--sys/conf/options.amd642
-rw-r--r--sys/conf/options.arm1
-rw-r--r--sys/conf/options.arm642
-rw-r--r--sys/conf/options.i3864
-rw-r--r--sys/contrib/dev/acpica/changes.txt48
-rw-r--r--sys/contrib/dev/acpica/common/adisasm.c17
-rw-r--r--sys/contrib/dev/acpica/common/ahpredef.c11
-rw-r--r--sys/contrib/dev/acpica/common/ahtable.c150
-rw-r--r--sys/contrib/dev/acpica/common/dmextern.c14
-rw-r--r--sys/contrib/dev/acpica/common/dmtable.c260
-rw-r--r--sys/contrib/dev/acpica/common/dmtbdump.c736
-rw-r--r--sys/contrib/dev/acpica/common/dmtbinfo.c486
-rw-r--r--sys/contrib/dev/acpica/compiler/aslascii.c38
-rw-r--r--sys/contrib/dev/acpica/compiler/aslcompiler.h1
-rw-r--r--sys/contrib/dev/acpica/compiler/aslcompiler.l15
-rw-r--r--sys/contrib/dev/acpica/compiler/asldefine.h2
-rw-r--r--sys/contrib/dev/acpica/compiler/aslfiles.c32
-rw-r--r--sys/contrib/dev/acpica/compiler/aslmessages.c5
-rw-r--r--sys/contrib/dev/acpica/compiler/aslmessages.h1
-rw-r--r--sys/contrib/dev/acpica/compiler/aslprepkg.c56
-rw-r--r--sys/contrib/dev/acpica/compiler/aslstartup.c4
-rw-r--r--sys/contrib/dev/acpica/compiler/aslutils.c22
-rw-r--r--sys/contrib/dev/acpica/compiler/dtcompile.c75
-rw-r--r--sys/contrib/dev/acpica/compiler/dtcompiler.h36
-rw-r--r--sys/contrib/dev/acpica/compiler/dtio.c12
-rw-r--r--sys/contrib/dev/acpica/compiler/dtsubtable.c5
-rw-r--r--sys/contrib/dev/acpica/compiler/dttable.c815
-rw-r--r--sys/contrib/dev/acpica/compiler/dttemplate.c8
-rw-r--r--sys/contrib/dev/acpica/compiler/dttemplate.h265
-rw-r--r--sys/contrib/dev/acpica/compiler/dtutils.c7
-rw-r--r--sys/contrib/dev/acpica/compiler/preprocess.h10
-rw-r--r--sys/contrib/dev/acpica/compiler/prscan.c185
-rw-r--r--sys/contrib/dev/acpica/compiler/prutils.c29
-rw-r--r--sys/contrib/dev/acpica/components/debugger/dbfileio.c18
-rw-r--r--sys/contrib/dev/acpica/components/debugger/dbinput.c2
-rw-r--r--sys/contrib/dev/acpica/components/dispatcher/dsmethod.c6
-rw-r--r--sys/contrib/dev/acpica/components/hardware/hwpci.c9
-rw-r--r--sys/contrib/dev/acpica/components/namespace/nsprepkg.c13
-rw-r--r--sys/contrib/dev/acpica/components/namespace/nsrepair.c2
-rw-r--r--sys/contrib/dev/acpica/components/parser/psopinfo.c3
-rw-r--r--sys/contrib/dev/acpica/components/utilities/utfileio.c9
-rw-r--r--sys/contrib/dev/acpica/components/utilities/uthex.c4
-rw-r--r--sys/contrib/dev/acpica/components/utilities/utxferror.c12
-rw-r--r--sys/contrib/dev/acpica/include/acdebug.h3
-rw-r--r--sys/contrib/dev/acpica/include/acdisasm.h81
-rw-r--r--sys/contrib/dev/acpica/include/aclocal.h19
-rw-r--r--sys/contrib/dev/acpica/include/acparser.h3
-rw-r--r--sys/contrib/dev/acpica/include/acpixf.h2
-rw-r--r--sys/contrib/dev/acpica/include/acpredef.h44
-rw-r--r--sys/contrib/dev/acpica/include/actbl.h17
-rw-r--r--sys/contrib/dev/acpica/include/actbl1.h207
-rw-r--r--sys/contrib/dev/acpica/include/actbl2.h174
-rw-r--r--sys/contrib/dev/acpica/include/actbl3.h104
-rw-r--r--sys/contrib/dev/acpica/include/actypes.h1
-rw-r--r--sys/contrib/dev/acpica/include/acutils.h2
-rw-r--r--sys/contrib/dev/acpica/include/acuuid.h64
-rw-r--r--sys/contrib/dev/acpica/include/platform/acenv.h3
-rw-r--r--sys/contrib/dev/acpica/include/platform/acenvex.h3
-rw-r--r--sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c10
-rw-r--r--sys/contrib/ipfilter/netinet/ip_fil_freebsd.c4
-rw-r--r--sys/contrib/vchiq/interface/compat/vchi_bsd.c2
-rw-r--r--sys/ddb/db_access.c2
-rw-r--r--sys/ddb/db_access.h2
-rw-r--r--sys/ddb/db_break.c22
-rw-r--r--sys/ddb/db_capture.c3
-rw-r--r--sys/ddb/db_command.c134
-rw-r--r--sys/ddb/db_examine.c35
-rw-r--r--sys/ddb/db_expr.c58
-rw-r--r--sys/ddb/db_input.c8
-rw-r--r--sys/ddb/db_main.c10
-rw-r--r--sys/ddb/db_print.c2
-rw-r--r--sys/ddb/db_ps.c20
-rw-r--r--sys/ddb/db_run.c75
-rw-r--r--sys/ddb/db_script.c8
-rw-r--r--sys/ddb/db_sym.c59
-rw-r--r--sys/ddb/db_sym.h8
-rw-r--r--sys/ddb/db_textdump.c5
-rw-r--r--sys/ddb/db_thread.c6
-rw-r--r--sys/ddb/db_variables.c2
-rw-r--r--sys/ddb/db_watch.c40
-rw-r--r--sys/ddb/db_write_cmd.c12
-rw-r--r--sys/ddb/ddb.h22
-rw-r--r--sys/dev/acpi_support/acpi_ibm.c12
-rw-r--r--sys/dev/acpica/acpi.c6
-rw-r--r--sys/dev/acpica/acpi_cpu.c200
-rw-r--r--sys/dev/acpica/acpi_package.c22
-rw-r--r--sys/dev/acpica/acpi_throttle.c8
-rw-r--r--sys/dev/acpica/acpi_timer.c3
-rw-r--r--sys/dev/acpica/acpivar.h2
-rw-r--r--sys/dev/altera/jtag_uart/altera_jtag_uart_tty.c4
-rw-r--r--sys/dev/ath/if_ath.c2
-rw-r--r--sys/dev/atkbdc/atkbd.c82
-rw-r--r--sys/dev/atkbdc/psm.c242
-rw-r--r--sys/dev/bxe/bxe.c195
-rw-r--r--sys/dev/bxe/bxe_stats.c1
-rw-r--r--sys/dev/bxe/bxe_stats.h3
-rw-r--r--sys/dev/ce/if_ce.c10
-rw-r--r--sys/dev/cp/if_cp.c6
-rw-r--r--sys/dev/ctau/if_ct.c6
-rw-r--r--sys/dev/cx/if_cx.c8
-rw-r--r--sys/dev/cxgb/cxgb_main.c4
-rw-r--r--sys/dev/cxgb/cxgb_sge.c2
-rw-r--r--sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c6
-rw-r--r--sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c2
-rw-r--r--sys/dev/cxgbe/t4_main.c4
-rw-r--r--sys/dev/dcons/dcons_os.c2
-rw-r--r--sys/dev/drm2/drm_irq.c2
-rw-r--r--sys/dev/drm2/i915/intel_display.c4
-rw-r--r--sys/dev/e1000/if_em.c3
-rw-r--r--sys/dev/e1000/if_igb.c79
-rw-r--r--sys/dev/fdt/fdt_common.c17
-rw-r--r--sys/dev/fdt/fdt_common.h1
-rw-r--r--sys/dev/fdt/simplebus.c2
-rw-r--r--sys/dev/glxsb/glxsb.c2
-rw-r--r--sys/dev/gpio/ofw_gpiobus.c2
-rw-r--r--sys/dev/gxemul/cons/gxemul_cons.c2
-rw-r--r--sys/dev/hifn/hifn7751.c4
-rw-r--r--sys/dev/hwpmc/hwpmc_amd.c46
-rw-r--r--sys/dev/hwpmc/hwpmc_arm64.c544
-rw-r--r--sys/dev/hwpmc/hwpmc_arm64.h51
-rw-r--r--sys/dev/hwpmc/hwpmc_arm64_md.c154
-rw-r--r--sys/dev/hwpmc/hwpmc_armv7.c12
-rw-r--r--sys/dev/hwpmc/hwpmc_core.c74
-rw-r--r--sys/dev/hwpmc/hwpmc_e500.c12
-rw-r--r--sys/dev/hwpmc/hwpmc_intel.c8
-rw-r--r--sys/dev/hwpmc/hwpmc_logging.c40
-rw-r--r--sys/dev/hwpmc/hwpmc_mips.c12
-rw-r--r--sys/dev/hwpmc/hwpmc_mips24k.c2
-rw-r--r--sys/dev/hwpmc/hwpmc_mips74k.c2
-rw-r--r--sys/dev/hwpmc/hwpmc_mod.c186
-rw-r--r--sys/dev/hwpmc/hwpmc_mpc7xxx.c12
-rw-r--r--sys/dev/hwpmc/hwpmc_octeon.c3
-rw-r--r--sys/dev/hwpmc/hwpmc_piv.c49
-rw-r--r--sys/dev/hwpmc/hwpmc_ppc970.c12
-rw-r--r--sys/dev/hwpmc/hwpmc_ppro.c26
-rw-r--r--sys/dev/hwpmc/hwpmc_soft.c6
-rw-r--r--sys/dev/hwpmc/hwpmc_tsc.c4
-rw-r--r--sys/dev/hwpmc/hwpmc_uncore.c48
-rw-r--r--sys/dev/hwpmc/hwpmc_xscale.c12
-rw-r--r--sys/dev/hwpmc/pmc_events.h366
-rw-r--r--sys/dev/hyperv/include/hyperv.h167
-rw-r--r--sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c882
-rw-r--r--sys/dev/hyperv/storvsc/hv_vstorage.h41
-rw-r--r--sys/dev/hyperv/utilities/hv_kvp.c11
-rw-r--r--sys/dev/hyperv/utilities/hv_util.c9
-rw-r--r--sys/dev/hyperv/vmbus/hv_channel.c98
-rw-r--r--sys/dev/hyperv/vmbus/hv_channel_mgmt.c265
-rw-r--r--sys/dev/hyperv/vmbus/hv_connection.c286
-rw-r--r--sys/dev/hyperv/vmbus/hv_hv.c66
-rw-r--r--sys/dev/hyperv/vmbus/hv_ring_buffer.c76
-rw-r--r--sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c364
-rw-r--r--sys/dev/hyperv/vmbus/hv_vmbus_priv.h71
-rw-r--r--sys/dev/if_ndis/if_ndis.c6
-rw-r--r--sys/dev/iicbus/iicbus.c49
-rw-r--r--sys/dev/iicbus/iicbus.h1
-rw-r--r--sys/dev/isci/isci_io_request.c2
-rw-r--r--sys/dev/iscsi/icl_soft.c88
-rw-r--r--sys/dev/iwn/if_iwn.c44
-rw-r--r--sys/dev/ixgbe/if_ix.c1073
-rw-r--r--sys/dev/ixgbe/if_ixv.c9
-rw-r--r--sys/dev/ixgbe/ix_txrx.c57
-rw-r--r--sys/dev/ixgbe/ixgbe.h39
-rw-r--r--sys/dev/ixgbe/ixgbe_82598.c7
-rw-r--r--sys/dev/ixgbe/ixgbe_82598.h2
-rw-r--r--sys/dev/ixgbe/ixgbe_82599.c6
-rw-r--r--sys/dev/ixgbe/ixgbe_82599.h2
-rw-r--r--sys/dev/ixgbe/ixgbe_api.c122
-rw-r--r--sys/dev/ixgbe/ixgbe_api.h11
-rw-r--r--sys/dev/ixgbe/ixgbe_common.c6
-rw-r--r--sys/dev/ixgbe/ixgbe_common.h2
-rw-r--r--sys/dev/ixgbe/ixgbe_dcb.c12
-rw-r--r--sys/dev/ixgbe/ixgbe_dcb.h2
-rw-r--r--sys/dev/ixgbe/ixgbe_dcb_82598.c2
-rw-r--r--sys/dev/ixgbe/ixgbe_dcb_82598.h2
-rw-r--r--sys/dev/ixgbe/ixgbe_dcb_82599.c2
-rw-r--r--sys/dev/ixgbe/ixgbe_dcb_82599.h2
-rw-r--r--sys/dev/ixgbe/ixgbe_mbx.c4
-rw-r--r--sys/dev/ixgbe/ixgbe_mbx.h2
-rw-r--r--sys/dev/ixgbe/ixgbe_osdep.h9
-rw-r--r--sys/dev/ixgbe/ixgbe_phy.c228
-rw-r--r--sys/dev/ixgbe/ixgbe_phy.h23
-rw-r--r--sys/dev/ixgbe/ixgbe_type.h265
-rw-r--r--sys/dev/ixgbe/ixgbe_vf.c3
-rw-r--r--sys/dev/ixgbe/ixgbe_vf.h2
-rw-r--r--sys/dev/ixgbe/ixgbe_x540.c12
-rw-r--r--sys/dev/ixgbe/ixgbe_x540.h2
-rw-r--r--sys/dev/ixgbe/ixgbe_x550.c3191
-rw-r--r--sys/dev/ixgbe/ixgbe_x550.h109
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/i40e_adminq.c0
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/i40e_adminq.h0
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/i40e_adminq_cmd.h0
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/i40e_alloc.h0
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/i40e_common.c0
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/i40e_hmc.c0
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/i40e_hmc.h0
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/i40e_lan_hmc.c0
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/i40e_lan_hmc.h0
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/i40e_nvm.c0
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/i40e_osdep.c0
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/i40e_osdep.h0
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/i40e_prototype.h0
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/i40e_register.h0
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/i40e_status.h0
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/i40e_type.h0
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/i40e_virtchnl.h0
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/if_ixl.c0
-rw-r--r--sys/dev/ixl/if_ixlv.c2
-rw-r--r--sys/dev/ixl/ixl.h2
-rw-r--r--[-rwxr-xr-x]sys/dev/ixl/ixl_txrx.c0
-rw-r--r--sys/dev/mfi/mfi.c2
-rw-r--r--sys/dev/mmc/mmc.c16
-rw-r--r--sys/dev/mrsas/mrsas.c312
-rw-r--r--sys/dev/mrsas/mrsas.h214
-rw-r--r--sys/dev/mrsas/mrsas_cam.c150
-rw-r--r--sys/dev/mrsas/mrsas_fp.c202
-rw-r--r--sys/dev/mrsas/mrsas_ioctl.c22
-rw-r--r--sys/dev/mrsas/mrsas_ioctl.h6
-rw-r--r--sys/dev/mrsas/mrsas_linux.c5
-rw-r--r--sys/dev/mwl/if_mwl.c2
-rw-r--r--sys/dev/nand/nandsim_chip.c2
-rw-r--r--sys/dev/nand/nfc_rb.c275
-rw-r--r--sys/dev/netmap/netmap_mem2.c83
-rw-r--r--sys/dev/ntb/if_ntb/if_ntb.c4
-rw-r--r--sys/dev/ntb/ntb_hw/ntb_hw.c4
-rw-r--r--sys/dev/nxge/if_nxge.c2
-rw-r--r--sys/dev/oce/oce_if.c2
-rw-r--r--sys/dev/ofw/ofw_bus_subr.c74
-rw-r--r--sys/dev/ofw/ofw_bus_subr.h5
-rw-r--r--sys/dev/ofw/ofw_iicbus.c6
-rw-r--r--sys/dev/ofw/ofwbus.c11
-rw-r--r--sys/dev/patm/if_patm_attach.c2
-rw-r--r--sys/dev/pccbb/pccbb_pci.c21
-rw-r--r--sys/dev/pci/pci_iov.c2
-rw-r--r--sys/dev/pci/pci_pci.c26
-rw-r--r--sys/dev/pci/pcib_private.h1
-rw-r--r--sys/dev/qlxgb/qla_os.c2
-rw-r--r--sys/dev/qlxgbe/ql_os.c2
-rw-r--r--sys/dev/qlxge/qls_os.c2
-rw-r--r--sys/dev/rndtest/rndtest.c2
-rw-r--r--sys/dev/safe/safe.c2
-rw-r--r--sys/dev/sdhci/sdhci.c11
-rw-r--r--sys/dev/sdhci/sdhci.h1
-rw-r--r--sys/dev/sfxge/sfxge.c85
-rw-r--r--sys/dev/sfxge/sfxge_port.c134
-rw-r--r--sys/dev/sfxge/sfxge_rx.c75
-rw-r--r--sys/dev/sfxge/sfxge_tx.c167
-rw-r--r--sys/dev/sfxge/sfxge_tx.h2
-rw-r--r--sys/dev/sound/midi/mpu401.c2
-rw-r--r--sys/dev/sound/pci/atiixp.c2
-rw-r--r--sys/dev/sound/pci/es137x.c2
-rw-r--r--sys/dev/sound/pci/hda/hdaa.c4
-rw-r--r--sys/dev/sound/pci/hda/hdac.c2
-rw-r--r--sys/dev/sound/pci/via8233.c2
-rw-r--r--sys/dev/sound/pcm/channel.c147
-rw-r--r--sys/dev/sound/pcm/channel.h1
-rw-r--r--sys/dev/sound/pcm/feeder_chain.c35
-rw-r--r--sys/dev/sound/pcm/sound.h8
-rw-r--r--sys/dev/sound/usb/uaudio.c57
-rw-r--r--sys/dev/twa/tw_osl_freebsd.c4
-rw-r--r--sys/dev/tws/tws.c4
-rw-r--r--sys/dev/uart/uart_dev_ti8250.c31
-rw-r--r--sys/dev/ubsec/ubsec.c2
-rw-r--r--sys/dev/usb/controller/dwc_otg.c74
-rw-r--r--sys/dev/usb/controller/dwc_otg.h3
-rw-r--r--sys/dev/usb/quirk/usb_quirk.c4
-rw-r--r--sys/dev/usb/quirk/usb_quirk.h1
-rw-r--r--sys/dev/usb/serial/u3g.c1
-rw-r--r--sys/dev/usb/serial/uftdi.c1
-rw-r--r--sys/dev/usb/serial/usb_serial.c5
-rw-r--r--sys/dev/usb/usb_device.c6
-rw-r--r--sys/dev/usb/usb_msctest.c190
-rw-r--r--sys/dev/usb/usb_msctest.h2
-rw-r--r--sys/dev/usb/usbdevs7
-rw-r--r--sys/dev/usb/video/udl.c14
-rw-r--r--sys/dev/usb/wlan/if_urtwn.c43
-rw-r--r--sys/dev/usb/wlan/if_urtwnreg.h2
-rw-r--r--sys/dev/virtio/network/if_vtnet.c5
-rw-r--r--sys/dev/virtio/random/virtio_random.c2
-rw-r--r--sys/dev/vt/hw/fb/vt_fb.c54
-rw-r--r--sys/dev/vt/hw/vga/vt_vga.c16
-rw-r--r--sys/dev/vt/vt.h5
-rw-r--r--sys/dev/vt/vt_core.c42
-rw-r--r--sys/dev/watchdog/watchdog.c4
-rw-r--r--sys/dev/wpi/if_wpi.c461
-rw-r--r--sys/dev/wpi/if_wpi_debug.h11
-rw-r--r--sys/dev/wpi/if_wpireg.h36
-rw-r--r--sys/dev/wpi/if_wpivar.h27
-rw-r--r--sys/dev/xen/balloon/balloon.c48
-rw-r--r--sys/dev/xen/blkback/blkback.c24
-rw-r--r--sys/dev/xen/control/control.c130
-rw-r--r--sys/dev/xen/grant_table/grant_table.c75
-rw-r--r--sys/dev/xen/netback/netback.c23
-rw-r--r--sys/dev/xen/netfront/netfront.c21
-rw-r--r--sys/dev/xen/privcmd/privcmd.c26
-rw-r--r--sys/fs/nfs/nfs_commonport.c2
-rw-r--r--sys/fs/nfsclient/nfs_clbio.c49
-rw-r--r--sys/fs/nfsclient/nfs_clrpcops.c38
-rw-r--r--sys/fs/nfsclient/nfs_clvnops.c16
-rw-r--r--sys/fs/procfs/procfs_ctl.c2
-rw-r--r--sys/gdb/gdb_cons.c2
-rw-r--r--sys/geom/gate/g_gate.c2
-rw-r--r--sys/geom/journal/g_journal.c2
-rw-r--r--sys/geom/mirror/g_mirror.c2
-rw-r--r--sys/geom/part/g_part_mbr.c3
-rw-r--r--sys/geom/raid3/g_raid3.c2
-rw-r--r--sys/geom/sched/gs_rr.c2
-rw-r--r--sys/geom/uncompress/g_uncompress.c40
-rw-r--r--sys/i386/acpica/acpi_machdep.c7
-rw-r--r--sys/i386/conf/DEFAULTS1
-rw-r--r--sys/i386/conf/GENERIC11
-rw-r--r--sys/i386/conf/XEN96
-rw-r--r--sys/i386/i386/apic_vector.s24
-rw-r--r--sys/i386/i386/db_disasm.c4
-rw-r--r--sys/i386/i386/genassym.c5
-rw-r--r--sys/i386/i386/machdep.c318
-rw-r--r--sys/i386/i386/minidump_machdep.c28
-rw-r--r--sys/i386/i386/mp_watchdog.c2
-rw-r--r--sys/i386/i386/support.s2
-rw-r--r--sys/i386/i386/swtch.s22
-rw-r--r--sys/i386/i386/sys_machdep.c103
-rw-r--r--sys/i386/i386/vm_machdep.c27
-rw-r--r--sys/i386/ibcs2/ibcs2_misc.c14
-rw-r--r--sys/i386/include/asmacros.h31
-rw-r--r--sys/i386/include/cpufunc.h46
-rw-r--r--sys/i386/include/intr_machdep.h8
-rw-r--r--sys/i386/include/md_var.h1
-rw-r--r--sys/i386/include/pcpu.h32
-rw-r--r--sys/i386/include/pmap.h81
-rw-r--r--sys/i386/include/segments.h6
-rw-r--r--sys/i386/include/smp.h7
-rw-r--r--sys/i386/include/vmparam.h8
-rw-r--r--sys/i386/include/xen/features.h22
-rw-r--r--sys/i386/include/xen/hypercall.h6
-rw-r--r--sys/i386/include/xen/xen-os.h99
-rw-r--r--sys/i386/include/xen/xenfunc.h1
-rw-r--r--sys/i386/include/xen/xenpmap.h237
-rw-r--r--sys/i386/include/xen/xenstored.h89
-rw-r--r--sys/i386/include/xen/xenvar.h85
-rw-r--r--sys/i386/isa/npx.c9
-rw-r--r--sys/i386/linux/linux_machdep.c14
-rw-r--r--sys/i386/pci/pci_cfgreg.c10
-rw-r--r--sys/i386/pci/pci_pir.c9
-rw-r--r--sys/i386/xen/clock.c570
-rw-r--r--sys/i386/xen/exception.s494
-rw-r--r--sys/i386/xen/locore.s360
-rw-r--r--sys/i386/xen/mp_machdep.c1292
-rw-r--r--sys/i386/xen/mptable.c109
-rw-r--r--sys/i386/xen/pmap.c4420
-rw-r--r--sys/i386/xen/xen_machdep.c1236
-rw-r--r--sys/kern/imgact_elf.c18
-rw-r--r--sys/kern/init_main.c4
-rw-r--r--sys/kern/kern_cons.c2
-rw-r--r--sys/kern/kern_cpuset.c2
-rw-r--r--sys/kern/kern_descrip.c38
-rw-r--r--sys/kern/kern_event.c2
-rw-r--r--sys/kern/kern_exec.c105
-rw-r--r--sys/kern/kern_exit.c14
-rw-r--r--sys/kern/kern_fork.c3
-rw-r--r--sys/kern/kern_intr.c5
-rw-r--r--sys/kern/kern_jail.c22
-rw-r--r--sys/kern/kern_ktr.c26
-rw-r--r--sys/kern/kern_malloc.c6
-rw-r--r--sys/kern/kern_proc.c2
-rw-r--r--sys/kern/kern_racct.c98
-rw-r--r--sys/kern/kern_rctl.c69
-rw-r--r--sys/kern/kern_shutdown.c16
-rw-r--r--sys/kern/kern_synch.c11
-rw-r--r--sys/kern/kern_tc.c39
-rw-r--r--sys/kern/kern_thr.c20
-rw-r--r--sys/kern/kern_thread.c83
-rw-r--r--sys/kern/sched_4bsd.c2
-rw-r--r--sys/kern/subr_dnvlist.c166
-rw-r--r--sys/kern/subr_nvlist.c919
-rw-r--r--sys/kern/subr_nvpair.c382
-rw-r--r--sys/kern/subr_param.c4
-rw-r--r--sys/kern/subr_trap.c22
-rw-r--r--sys/kern/subr_turnstile.c4
-rw-r--r--sys/kern/subr_vmem.c2
-rw-r--r--sys/kern/subr_witness.c2
-rw-r--r--sys/kern/sysv_msg.c42
-rw-r--r--sys/kern/sysv_sem.c25
-rw-r--r--sys/kern/sysv_shm.c80
-rw-r--r--sys/kern/uipc_domain.c4
-rw-r--r--sys/kern/uipc_mbuf.c1
-rw-r--r--sys/kern/vfs_bio.c93
-rw-r--r--sys/kern/vfs_syscalls.c6
-rw-r--r--sys/mips/atheros/files.ar71xx1
-rw-r--r--sys/mips/atheros/qca955x_pci.c606
-rw-r--r--sys/mips/beri/beri_simplebus.c2
-rw-r--r--sys/mips/cavium/octe/ethernet.c2
-rw-r--r--sys/mips/cavium/octeon_rnd.c2
-rw-r--r--sys/mips/conf/AP13510
-rw-r--r--sys/mips/conf/AP135.hints6
-rw-r--r--sys/mips/conf/QCA955X_BASE12
-rw-r--r--sys/mips/conf/ROUTERSTATION6
-rw-r--r--sys/mips/conf/RSPRO6
-rw-r--r--sys/mips/include/intr_machdep.h1
-rw-r--r--sys/mips/mips/busdma_machdep.c4
-rw-r--r--sys/mips/mips/db_disasm.c2
-rw-r--r--sys/mips/mips/pmap.c4
-rw-r--r--sys/mips/mips/vm_machdep.c2
-rw-r--r--sys/mips/nlm/dev/net/xlpge.c2
-rw-r--r--sys/mips/rmi/dev/xlr/rge.c4
-rw-r--r--sys/modules/Makefile1
-rw-r--r--sys/modules/ix/Makefile2
-rw-r--r--sys/modules/ixv/Makefile2
-rw-r--r--sys/net/if_bridge.c2
-rw-r--r--sys/net/if_gif.c12
-rw-r--r--sys/net/if_gif.h4
-rw-r--r--sys/net/if_gre.c17
-rw-r--r--sys/net/if_me.c16
-rw-r--r--sys/net/if_spppsubr.c16
-rw-r--r--sys/net/if_types.h16
-rw-r--r--sys/net/sff8436.h4
-rw-r--r--sys/net/sff8472.h20
-rw-r--r--sys/net80211/ieee80211.h5
-rw-r--r--sys/net80211/ieee80211_adhoc.c14
-rw-r--r--sys/net80211/ieee80211_freebsd.c6
-rw-r--r--sys/net80211/ieee80211_freebsd.h4
-rw-r--r--sys/net80211/ieee80211_hostap.c6
-rw-r--r--sys/net80211/ieee80211_ht.c21
-rw-r--r--sys/net80211/ieee80211_hwmp.c2
-rw-r--r--sys/net80211/ieee80211_input.h12
-rw-r--r--sys/net80211/ieee80211_mesh.c12
-rw-r--r--sys/net80211/ieee80211_node.c66
-rw-r--r--sys/net80211/ieee80211_output.c30
-rw-r--r--sys/net80211/ieee80211_proto.c2
-rw-r--r--sys/net80211/ieee80211_scan.c78
-rw-r--r--sys/net80211/ieee80211_scan.h6
-rw-r--r--sys/net80211/ieee80211_scan_sta.c7
-rw-r--r--sys/net80211/ieee80211_scan_sw.c82
-rw-r--r--sys/net80211/ieee80211_scan_sw.h1
-rw-r--r--sys/net80211/ieee80211_sta.c11
-rw-r--r--sys/net80211/ieee80211_wds.c9
-rw-r--r--sys/netgraph/netflow/ng_netflow.c2
-rw-r--r--sys/netgraph/netgraph.h2
-rw-r--r--sys/netinet/in_gif.c12
-rw-r--r--sys/netinet/in_kdtrace.c3
-rw-r--r--sys/netinet/in_kdtrace.h3
-rw-r--r--sys/netinet/in_pcb.c2
-rw-r--r--sys/netinet/ip_mroute.c6
-rw-r--r--sys/netinet/sctp_input.c3
-rw-r--r--sys/netinet/siftr.c4
-rw-r--r--sys/netinet/tcp_hostcache.c27
-rw-r--r--sys/netinet/tcp_input.c2
-rw-r--r--sys/netinet/tcp_subr.c10
-rw-r--r--sys/netinet/tcp_timewait.c7
-rw-r--r--sys/netinet6/in6.c9
-rw-r--r--sys/netinet6/in6_gif.c12
-rw-r--r--sys/netinet6/in6_ifattach.c4
-rw-r--r--sys/netinet6/in6_rmx.c2
-rw-r--r--sys/netinet6/ip6_ipsec.c29
-rw-r--r--sys/netinet6/ip6_output.c14
-rw-r--r--sys/netinet6/nd6.c8
-rw-r--r--sys/netinet6/nd6.h3
-rw-r--r--sys/netinet6/nd6_nbr.c23
-rw-r--r--sys/netipsec/esp.h6
-rw-r--r--sys/netipsec/ipsec_input.c1
-rw-r--r--sys/netipsec/ipsec_output.c5
-rw-r--r--sys/netipsec/key.c85
-rw-r--r--sys/netipsec/keysock.c2
-rw-r--r--sys/netpfil/ipfw/dn_sched.h2
-rw-r--r--sys/netpfil/ipfw/ip_dn_private.h2
-rw-r--r--sys/netpfil/ipfw/ip_dummynet.c2
-rw-r--r--sys/netpfil/ipfw/ip_fw2.c3
-rw-r--r--sys/netpfil/ipfw/ip_fw_dynamic.c2
-rw-r--r--sys/netpfil/ipfw/ip_fw_nat.c24
-rw-r--r--sys/netpfil/ipfw/ip_fw_pfil.c2
-rw-r--r--sys/netpfil/ipfw/ip_fw_sockopt.c5
-rw-r--r--sys/netpfil/ipfw/ip_fw_table.c13
-rw-r--r--sys/netpfil/ipfw/ip_fw_table_value.c11
-rw-r--r--sys/netpfil/pf/if_pfsync.c2
-rw-r--r--sys/netpfil/pf/pf.c46
-rw-r--r--sys/netpfil/pf/pf_if.c6
-rw-r--r--sys/netpfil/pf/pf_ioctl.c2
-rw-r--r--sys/netpfil/pf/pf_norm.c6
-rw-r--r--sys/ofed/drivers/net/mlx4/en_netdev.c4
-rw-r--r--sys/ofed/include/linux/bitops.h4
-rw-r--r--sys/ofed/include/linux/jiffies.h2
-rw-r--r--sys/ofed/include/linux/linux_idr.c30
-rw-r--r--sys/ofed/include/linux/timer.h4
-rw-r--r--sys/ofed/include/linux/workqueue.h2
-rw-r--r--sys/pc98/conf/GENERIC3
-rw-r--r--sys/powerpc/aim/aim_machdep.c (renamed from sys/powerpc/aim/machdep.c)345
-rw-r--r--sys/powerpc/aim/mmu_oea64.c5
-rw-r--r--sys/powerpc/booke/booke_machdep.c (renamed from sys/powerpc/booke/machdep.c)369
-rw-r--r--sys/powerpc/booke/pmap.c7
-rw-r--r--sys/powerpc/conf/GENERIC4
-rw-r--r--sys/powerpc/mambo/mambo_console.c2
-rw-r--r--sys/powerpc/mpc85xx/pci_mpc85xx.c14
-rw-r--r--sys/powerpc/mpc85xx/pci_mpc85xx_pcib.c104
-rw-r--r--sys/powerpc/ofw/ofw_machdep.c23
-rw-r--r--sys/powerpc/ofw/ofw_pcibus.c3
-rw-r--r--sys/powerpc/powerpc/busdma_machdep.c4
-rw-r--r--sys/powerpc/powerpc/db_disasm.c2
-rw-r--r--sys/powerpc/powerpc/machdep.c502
-rw-r--r--sys/powerpc/powerpc/uma_machdep.c (renamed from sys/powerpc/aim/uma_machdep.c)0
-rw-r--r--sys/powerpc/pseries/phyp_console.c2
-rw-r--r--sys/powerpc/pseries/vdevice.c2
-rw-r--r--sys/sparc64/conf/GENERIC3
-rw-r--r--sys/sparc64/sparc64/db_disasm.c2
-rw-r--r--sys/sys/callout.h2
-rw-r--r--sys/sys/cdefs.h26
-rw-r--r--sys/sys/diskmbr.h6
-rw-r--r--sys/sys/elf_common.h4
-rw-r--r--sys/sys/imgact.h3
-rw-r--r--sys/sys/imgact_elf.h1
-rw-r--r--sys/sys/ktr.h4
-rw-r--r--sys/sys/malloc.h2
-rw-r--r--sys/sys/module.h6
-rw-r--r--sys/sys/mouse.h7
-rw-r--r--sys/sys/nv.h134
-rw-r--r--sys/sys/nv_impl.h51
-rw-r--r--sys/sys/nvlist_impl.h4
-rw-r--r--sys/sys/nvpair_impl.h2
-rw-r--r--sys/sys/param.h2
-rw-r--r--sys/sys/pmc.h92
-rw-r--r--sys/sys/proc.h3
-rw-r--r--sys/sys/racct.h4
-rw-r--r--sys/sys/seq.h8
-rw-r--r--sys/sys/sockio.h3
-rw-r--r--sys/sys/systm.h2
-rw-r--r--sys/sys/timepps.h18
-rw-r--r--sys/vm/default_pager.c1
-rw-r--r--sys/vm/device_pager.c2
-rw-r--r--sys/vm/phys_pager.c2
-rw-r--r--sys/vm/sg_pager.c2
-rw-r--r--sys/vm/swap_pager.c93
-rw-r--r--sys/vm/uma.h3
-rw-r--r--sys/vm/uma_core.c44
-rw-r--r--sys/vm/vm_fault.c4
-rw-r--r--sys/vm/vm_map.c55
-rw-r--r--sys/vm/vm_meter.c16
-rw-r--r--sys/vm/vm_mmap.c32
-rw-r--r--sys/vm/vm_object.c31
-rw-r--r--sys/vm/vm_page.c191
-rw-r--r--sys/vm/vm_pageout.c66
-rw-r--r--sys/vm/vm_phys.c47
-rw-r--r--sys/vm/vm_phys.h1
-rw-r--r--sys/vm/vm_unix.c81
-rw-r--r--sys/vm/vnode_pager.c29
-rw-r--r--sys/x86/acpica/srat.c126
-rw-r--r--sys/x86/include/acpica_machdep.h1
-rw-r--r--sys/x86/include/apicvar.h1
-rw-r--r--sys/x86/include/segments.h8
-rw-r--r--sys/x86/include/specialreg.h6
-rw-r--r--sys/x86/x86/busdma_bounce.c9
-rw-r--r--sys/x86/x86/cpu_machdep.c103
-rw-r--r--sys/x86/x86/identcpu.c4
-rw-r--r--sys/x86/x86/intr_machdep.c7
-rw-r--r--sys/x86/x86/local_apic.c6
-rw-r--r--sys/x86/x86/mca.c2
-rw-r--r--sys/x86/xen/xen_apic.c20
-rw-r--r--sys/x86/xen/xen_intr.c4
-rw-r--r--sys/x86/xen/xen_nexus.c6
-rw-r--r--sys/x86/xen/xenpv.c84
-rw-r--r--sys/xen/xen-os.h7
-rw-r--r--sys/xen/xenmem/xenmem_if.m95
-rw-r--r--tests/Makefile1
-rw-r--r--tests/etc/Makefile (renamed from etc/tests/Makefile)4
-rw-r--r--tests/etc/rc.d/Makefile (renamed from etc/rc.d/tests/Makefile)0
-rwxr-xr-xtests/etc/rc.d/routing_test.sh (renamed from etc/rc.d/tests/routing_test.sh)0
-rw-r--r--tests/freebsd_test_suite/macros.h56
-rw-r--r--tests/sys/Makefile1
-rw-r--r--tests/sys/aio/Makefile2
-rw-r--r--tests/sys/aio/aio_kqueue_test.c36
-rw-r--r--tests/sys/aio/aio_test.c27
-rw-r--r--tests/sys/aio/lio_kqueue_test.c22
-rw-r--r--tests/sys/kern/Makefile2
-rw-r--r--tests/sys/kern/ptrace_test.c143
-rw-r--r--tests/sys/mqueue/Makefile2
-rw-r--r--tests/sys/mqueue/mqtest1.c4
-rw-r--r--tests/sys/mqueue/mqtest2.c4
-rw-r--r--tests/sys/mqueue/mqtest3.c4
-rw-r--r--tests/sys/mqueue/mqtest4.c4
-rw-r--r--tests/sys/mqueue/mqtest5.c4
-rwxr-xr-xtests/sys/mqueue/mqueue_test.sh27
-rw-r--r--tests/sys/vm/Makefile7
-rw-r--r--tests/sys/vm/mmap_test.c (renamed from tests/sys/kern/mmap_test.c)0
-rw-r--r--tools/bsdbox/Makefile.base2
-rw-r--r--tools/build/Makefile8
-rwxr-xr-xtools/build/check-links.sh13
-rw-r--r--tools/build/mk/OptionalObsoleteFiles.inc26
-rw-r--r--tools/build/stdlib.h42
-rw-r--r--tools/regression/p1003_1b/main.c1
-rw-r--r--tools/regression/p1003_1b/prutil.c9
-rw-r--r--tools/tools/ath/athaggrstats/Makefile1
-rw-r--r--tools/tools/ath/athstats/Makefile6
-rw-r--r--tools/tools/mwl/mwlstats/Makefile1
-rw-r--r--tools/tools/net80211/wlanstats/Makefile1
-rw-r--r--tools/tools/npe/npestats/Makefile1
-rw-r--r--usr.bin/Makefile5
-rw-r--r--usr.bin/bmake/Makefile4
-rw-r--r--usr.bin/bmake/unit-tests/Makefile5
-rw-r--r--usr.bin/calendar/calendars/calendar.freebsd1
-rw-r--r--usr.bin/calendar/calendars/calendar.holiday2
-rw-r--r--usr.bin/checknr/checknr.16
-rw-r--r--usr.bin/checknr/checknr.c146
-rw-r--r--usr.bin/col/Makefile6
-rw-r--r--usr.bin/col/col.129
-rw-r--r--usr.bin/col/col.c163
-rw-r--r--usr.bin/col/tests/Makefile11
-rwxr-xr-xusr.bin/col/tests/col.sh33
-rw-r--r--usr.bin/col/tests/rlf.in2
-rw-r--r--usr.bin/col/tests/rlf2.in2
-rw-r--r--usr.bin/ctlstat/ctlstat.83
-rw-r--r--usr.bin/cxxfilt/Makefile17
-rw-r--r--usr.bin/demandoc/Makefile11
-rw-r--r--usr.bin/elfdump/elfdump.c1
-rw-r--r--usr.bin/kdump/kdump.c2
-rw-r--r--usr.bin/m4/extern.h1
-rw-r--r--usr.bin/m4/gnum4.c20
-rw-r--r--usr.bin/m4/look.c68
-rw-r--r--usr.bin/m4/m4.16
-rw-r--r--usr.bin/m4/main.c7
-rw-r--r--usr.bin/m4/mdef.h21
-rw-r--r--usr.bin/m4/misc.c43
-rw-r--r--usr.bin/m4/parser.y8
-rwxr-xr-xusr.bin/man/man.sh5
-rw-r--r--usr.bin/mandoc/Makefile36
-rw-r--r--usr.bin/netstat/if.c16
-rw-r--r--usr.bin/netstat/route.c6
-rw-r--r--usr.bin/procstat/procstat.13
-rw-r--r--usr.bin/rctl/rctl.812
-rw-r--r--usr.bin/rctl/rctl.c47
-rw-r--r--usr.bin/soelim/Makefile11
-rw-r--r--usr.bin/soelim/soelim.1 (renamed from usr.bin/soeliminate/soeliminate.1)22
-rw-r--r--usr.bin/soelim/soelim.c (renamed from usr.bin/soeliminate/soeliminate.c)53
-rw-r--r--usr.bin/soelim/tests/Makefile15
-rw-r--r--usr.bin/soelim/tests/basic1
-rw-r--r--usr.bin/soelim/tests/basic-with-space.in3
-rw-r--r--usr.bin/soelim/tests/basic-with-space.out4
-rw-r--r--usr.bin/soelim/tests/basic.in3
-rw-r--r--usr.bin/soelim/tests/basic.out3
-rw-r--r--usr.bin/soelim/tests/nonexisting.in3
-rwxr-xr-xusr.bin/soelim/tests/soelim.sh103
-rw-r--r--usr.bin/soeliminate/Makefile5
-rwxr-xr-xusr.bin/ssh-copy-id/ssh-copy-id.sh2
-rw-r--r--usr.bin/tar/Makefile1
-rw-r--r--usr.bin/time/time.c18
-rw-r--r--usr.bin/vgrind/Makefile2
-rw-r--r--usr.bin/vgrind/extern.h8
-rw-r--r--usr.bin/vgrind/regexp.c129
-rw-r--r--usr.bin/vgrind/vfontedpr.c235
-rw-r--r--usr.bin/vgrind/vgrindefs.c46
-rw-r--r--usr.bin/vtfontcvt/vtfontcvt.c36
-rw-r--r--usr.bin/whois/whois.1130
-rw-r--r--usr.bin/whois/whois.c137
-rw-r--r--usr.sbin/acpi/acpidb/acpidb.c2
-rw-r--r--usr.sbin/acpi/iasl/Makefile4
-rw-r--r--usr.sbin/bhyve/acpi.c2
-rw-r--r--usr.sbin/bhyve/bhyve.821
-rw-r--r--usr.sbin/bhyve/block_if.c74
-rw-r--r--usr.sbin/bhyve/inout.c8
-rw-r--r--usr.sbin/bhyve/pci_ahci.c114
-rw-r--r--usr.sbin/bhyve/pci_emul.c38
-rw-r--r--usr.sbin/bhyve/pci_hostbridge.c2
-rw-r--r--usr.sbin/bhyve/pci_virtio_block.c1
-rw-r--r--usr.sbin/bhyve/pci_virtio_net.c26
-rw-r--r--usr.sbin/bhyve/pci_virtio_rnd.c1
-rw-r--r--usr.sbin/bhyve/task_switch.c151
-rw-r--r--usr.sbin/bhyve/virtio.c2
-rw-r--r--usr.sbin/bhyvectl/bhyvectl.c13
-rw-r--r--usr.sbin/bhyveload/bhyveload.c2
-rw-r--r--usr.sbin/bluetooth/bthidd/Makefile1
-rwxr-xr-xusr.sbin/bsdinstall/scripts/zfsboot30
-rw-r--r--usr.sbin/chown/chgrp.115
-rw-r--r--usr.sbin/chown/chown.811
-rw-r--r--usr.sbin/chown/chown.c106
-rw-r--r--usr.sbin/crunch/crunchide/exec_elf32.c28
-rw-r--r--usr.sbin/ctladm/ctladm.85
-rw-r--r--usr.sbin/ctld/ctld.85
-rw-r--r--usr.sbin/ctld/login.c3
-rw-r--r--usr.sbin/iostat/iostat.83
-rw-r--r--usr.sbin/iovctl/iovctl.c2
-rw-r--r--usr.sbin/kbdmap/kbdmap.c4
-rw-r--r--usr.sbin/mountd/mountd.88
-rw-r--r--usr.sbin/mountd/mountd.c40
-rw-r--r--usr.sbin/nfsd/nfsd.89
-rw-r--r--usr.sbin/nfsd/nfsd.c171
-rw-r--r--usr.sbin/ntp/config.h28
-rw-r--r--usr.sbin/ntp/doc/ntptime.84
-rwxr-xr-xusr.sbin/ntp/scripts/mkver2
-rw-r--r--usr.sbin/pmcstat/pmcstat.87
-rw-r--r--usr.sbin/pmcstat/pmcstat.c59
-rw-r--r--usr.sbin/pmcstat/pmcstat_log.c7
-rw-r--r--usr.sbin/pw/Makefile2
-rw-r--r--usr.sbin/pw/fileupd.c21
-rw-r--r--usr.sbin/pw/grupd.c4
-rw-r--r--usr.sbin/pw/pw_conf.c266
-rw-r--r--usr.sbin/pw/pw_nis.c3
-rw-r--r--usr.sbin/pw/pw_user.c37
-rw-r--r--usr.sbin/pw/pwupd.c109
-rw-r--r--usr.sbin/pw/pwupd.h3
-rw-r--r--usr.sbin/rtsold/if.c4
-rw-r--r--usr.sbin/syslogd/pathnames.h2
-rw-r--r--usr.sbin/uefisign/pe.c8
1819 files changed, 92767 insertions, 44999 deletions
diff --git a/.arcconfig b/.arcconfig
index a759f47..fa78c6d 100644
--- a/.arcconfig
+++ b/.arcconfig
@@ -1,4 +1,5 @@
{
"project.name": "S",
- "phabricator.uri" : "https://reviews.freebsd.org/"
+ "phabricator.uri" : "https://reviews.freebsd.org/",
+ "history.immutable" : true
}
diff --git a/Makefile b/Makefile
index c82880a..34ffe76 100644
--- a/Makefile
+++ b/Makefile
@@ -373,19 +373,19 @@ kernel-toolchains:
# existing system is.
#
.if make(universe) || make(universe_kernels) || make(tinderbox) || make(targets)
-TARGETS?=amd64 arm i386 mips pc98 powerpc sparc64
# XXX Add arm64 to universe only if we have an external binutils installed.
-# It does not build with the in-tree linnker.
+# It does not build with the in-tree linker.
.if exists(/usr/local/aarch64-freebsd/bin/ld)
-TARGETS+=arm64
-TARGET_ARCHES_arm64?= aarch64
-.else
+UNIVERSE_arm64=arm64
+.elif empty(${TARGETS})
universe: universe_arm64_skip
universe_epilogue: universe_arm64_skip
universe_arm64_skip: universe_prologue
@echo ">> arm64 skipped - install aarch64-binutils port or package to build"
.endif
+TARGETS?=amd64 arm ${UNIVERSE_arm64} i386 mips pc98 powerpc sparc64
TARGET_ARCHES_arm?= arm armeb armv6 armv6hf
+TARGET_ARCHES_arm64?= aarch64
TARGET_ARCHES_mips?= mipsel mips mips64el mips64 mipsn32
TARGET_ARCHES_powerpc?= powerpc powerpc64
TARGET_ARCHES_pc98?= i386
diff --git a/Makefile.inc1 b/Makefile.inc1
index 039c7e2..7539a14 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -1263,7 +1263,8 @@ _gperf= gnu/usr.bin/gperf
.endif
.if ${MK_GROFF} != "no"
-_groff= gnu/usr.bin/groff
+_groff= gnu/usr.bin/groff \
+ usr.bin/soelim
.endif
.if ${MK_VT} != "no"
@@ -1296,7 +1297,9 @@ _cat= bin/cat
_lex= usr.bin/lex
.endif
-.if ${BOOTSTRAPPING} < 1001507
+# r277259 crunchide: Correct 64-bit section header offset
+# r281674 crunchide: always include both 32- and 64-bit ELF support
+.if ${BOOTSTRAPPING} < 1100071
_crunch= usr.sbin/crunch
.endif
@@ -1360,6 +1363,9 @@ _kerberos5_bootstrap_tools= \
.ORDER: ${_kerberos5_bootstrap_tools:C/^/${_bt}-/g}
.endif
+# Rebuild up-to-date libmd for xinstall
+${_bt}-usr.bin/xinstall: ${_bt}-lib/libmd
+
bootstrap-tools: .PHONY
# Please document (add comment) why something is in 'bootstrap-tools'.
@@ -1462,11 +1468,6 @@ kernel-tools: .MAKE
_btxld= usr.sbin/btxld
.endif
.endif
-.if ${TARGET_ARCH} != ${MACHINE_ARCH}
-.if ${MK_RESCUE} != "no"
-_crunchide= usr.sbin/crunch/crunchide
-.endif
-.endif
# If we're given an XAS, don't build binutils.
.if ${XAS:M/*} == ""
@@ -1501,6 +1502,9 @@ _clang_libs= lib/clang
_cc= gnu/usr.bin/cc
.endif
.endif
+.if ${MK_USB} != "no"
+_usb_tools= sys/boot/usb/tools
+.endif
cross-tools: .MAKE
.for _tool in \
@@ -1511,7 +1515,7 @@ cross-tools: .MAKE
${_cc} \
${_btxld} \
${_crunchide} \
- sys/boot/usb/tools
+ ${_usb_tools}
${_+_}@${ECHODIR} "===> ${_tool} (obj,depend,all,install)"; \
cd ${.CURDIR}/${_tool} && \
${MAKE} DIRPRFX=${_tool}/ obj && \
@@ -1522,7 +1526,8 @@ cross-tools: .MAKE
NXBENV= MAKEOBJDIRPREFIX=${OBJTREE}/nxb \
INSTALL="sh ${.CURDIR}/tools/install.sh" \
- VERSION="${VERSION}"
+ VERSION="${VERSION}" \
+ PATH=${PATH}:${OBJTREE}/gperf_for_gcc/usr/bin
NXBMAKE= ${NXBENV} ${MAKE} \
TBLGEN=${OBJTREE}/nxb-bin/usr/bin/tblgen \
CLANG_TBLGEN=${OBJTREE}/nxb-bin/usr/bin/clang-tblgen \
@@ -1535,7 +1540,21 @@ NXBMAKE= ${NXBENV} ${MAKE} \
MK_CLANG_EXTRAS=no MK_CLANG_FULL=no \
MK_LLDB=no
+# native-xtools is the current target for qemu-user cross builds of ports
+# via poudriere and the imgact_binmisc kernel module.
+# For non-clang enabled targets that are still using the in tree gcc
+# we must build a gperf binary for one instance of its Makefiles. On
+# clang-enabled systems, the gperf binary is obsolete.
native-xtools: .MAKE
+.if ${MK_GCC_BOOTSTRAP} != "no"
+ mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
+ ${_+_}@${ECHODIR} "===> ${_gperf} (obj,depend,all,install)"; \
+ cd ${.CURDIR}/${_gperf} && \
+ ${NXBMAKE} DIRPRFX=${_gperf}/ obj && \
+ ${NXBMAKE} DIRPRFX=${_gperf}/ depend && \
+ ${NXBMAKE} DIRPRFX=${_gperf}/ all && \
+ ${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
+.endif
mkdir -p ${OBJTREE}/nxb-bin/bin
mkdir -p ${OBJTREE}/nxb-bin/sbin
mkdir -p ${OBJTREE}/nxb-bin/usr
@@ -1641,13 +1660,7 @@ _prereq_libs= gnu/lib/libssp/libssp_nonshared gnu/lib/libgcc lib/libcompiler_rt
# all shared libraries for ELF.
#
_startup_libs= gnu/lib/csu
-.if exists(${.CURDIR}/lib/csu/${MACHINE_ARCH}-elf)
-_startup_libs+= lib/csu/${MACHINE_ARCH}-elf
-.elif exists(${.CURDIR}/lib/csu/${MACHINE_ARCH})
-_startup_libs+= lib/csu/${MACHINE_ARCH}
-.else
-_startup_libs+= lib/csu/${MACHINE_CPUARCH}
-.endif
+_startup_libs+= lib/csu
_startup_libs+= gnu/lib/libgcc
_startup_libs+= lib/libcompiler_rt
_startup_libs+= lib/libc
@@ -1666,7 +1679,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} \
${_kerberos5_lib_libhdb} \
${_kerberos5_lib_libheimbase} \
${_kerberos5_lib_libheimntlm} \
- ${_kerberos5_lib_libheimsqlite} \
+ ${_libsqlite3} \
${_kerberos5_lib_libheimipcc} \
${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \
${_kerberos5_lib_libroken} \
@@ -1742,6 +1755,13 @@ _cddl_lib= cddl/lib
cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
cddl/lib/libzfs__L: lib/libgeom__L
cddl/lib/libctf__L: lib/libz__L
+# cddl/lib/libdtrace requires lib/libproc and lib/librtld_db; it's only built
+# on select architectures though (see cddl/lib/Makefile)
+.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" || \
+ ${MACHINE_CPUARCH} == "mips" || ${MACHINE_CPUARCH} == "powerpc" || \
+ ${MACHINE_CPUARCH} == "arm"
+_prebuild_libs+= lib/libproc lib/librtld_db
+.endif
.endif
.if ${MK_CRYPT} != "no"
@@ -1773,7 +1793,7 @@ _secure_lib= secure/lib
kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L
kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L \
- kerberos5/lib/libwind__L kerberos5/lib/libheimsqlite__L
+ kerberos5/lib/libwind__L lib/libsqlite3__L
kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L \
kerberos5/lib/libroken__L lib/libcom_err__L
kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \
@@ -1786,7 +1806,7 @@ kerberos5/lib/libroken__L: lib/libcrypt__L
kerberos5/lib/libwind__L: kerberos5/lib/libroken__L lib/libcom_err__L
kerberos5/lib/libheimbase__L: lib/libthr__L
kerberos5/lib/libheimipcc__L: kerberos5/lib/libroken__L kerberos5/lib/libheimbase__L lib/libthr__L
-kerberos5/lib/libheimsqlite__L: lib/libthr__L
+lib/libsqlite3__L: lib/libthr__L
.endif
.if ${MK_GSSAPI} != "no"
@@ -1802,7 +1822,7 @@ _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5
_kerberos5_lib_libhx509= kerberos5/lib/libhx509
_kerberos5_lib_libroken= kerberos5/lib/libroken
_kerberos5_lib_libheimntlm= kerberos5/lib/libheimntlm
-_kerberos5_lib_libheimsqlite= kerberos5/lib/libheimsqlite
+_libsqlite3= lib/libsqlite3
_kerberos5_lib_libheimipcc= kerberos5/lib/libheimipcc
_kerberos5_lib_libwind= kerberos5/lib/libwind
_libcom_err= lib/libcom_err
@@ -1816,6 +1836,16 @@ _lib_libypclnt= lib/libypclnt
lib/libradius__L: lib/libmd__L
.endif
+lib/libproc__L: \
+ ${_cddl_lib_libctf:D${_cddl_lib_libctf}__L} lib/libelf__L lib/librtld_db__L lib/libutil__L
+.if ${MK_CXX} != "no"
+.if ${MK_LIBCPLUSPLUS} != "no"
+lib/libproc__L: lib/libcxxrt__L
+.else # This implies MK_GNUCXX != "no"; see lib/libproc
+lib/libproc__L: gnu/lib/libsupc++__L
+.endif
+.endif
+
gnu/lib/libdialog__L: lib/msun__L lib/ncurses/ncursesw__L
.for _lib in ${_prereq_libs}
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
index 9e59f8a..ecba9fe 100644
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -38,6 +38,111 @@
# xargs -n1 | sort | uniq -d;
# done
+# 20150521
+OLD_FILES+=usr/bin/demandoc
+OLD_FILES+=usr/share/man/man1/demandoc.1.gz
+OLD_FILES+=usr/share/man/man3/mandoc.3.gz
+OLD_FILES+=usr/share/man/man3/mandoc_headers.3.gz
+# 20150520
+OLD_FILES+=usr/lib/libheimsqlite.a
+OLD_FILES+=usr/lib/libheimsqlite.so
+OLD_LIBS+=usr/lib/libheimsqlite.so.11
+OLD_FILES+=usr/lib/libheimsqlite_p.a
+OLD_FILES+=usr/lib32/libheimsqlite.a
+OLD_FILES+=usr/lib32/libheimsqlite.so
+OLD_LIBS+=usr/lib32/libheimsqlite.so.11
+OLD_FILES+=usr/lib32/libheimsqlite_p.a
+# 20150506
+OLD_FILES+=usr/share/man/man9/NDHASGIANT.9.gz
+# 20150504
+OLD_LIBS+=usr/lib32/private/libatf-c++.so.2
+OLD_LIBS+=usr/lib32/private/libbsdstat.so.1
+OLD_LIBS+=usr/lib32/private/libheimipcs.so.11
+OLD_LIBS+=usr/lib32/private/libsqlite3.so.0
+OLD_LIBS+=usr/lib32/private/libunbound.so.5
+OLD_LIBS+=usr/lib32/private/libatf-c.so.1
+OLD_LIBS+=usr/lib32/private/libheimipcc.so.11
+OLD_LIBS+=usr/lib32/private/libldns.so.5
+OLD_LIBS+=usr/lib32/private/libssh.so.5
+OLD_LIBS+=usr/lib32/private/libucl.so.1
+OLD_DIRS+=usr/lib32/private
+OLD_LIBS+=usr/lib/private/libatf-c++.so.2
+OLD_LIBS+=usr/lib/private/libbsdstat.so.1
+OLD_LIBS+=usr/lib/private/libheimipcs.so.11
+OLD_LIBS+=usr/lib/private/libsqlite3.so.0
+OLD_LIBS+=usr/lib/private/libunbound.so.5
+OLD_LIBS+=usr/lib/private/libatf-c.so.1
+OLD_LIBS+=usr/lib/private/libheimipcc.so.11
+OLD_LIBS+=usr/lib/private/libldns.so.5
+OLD_LIBS+=usr/lib/private/libssh.so.5
+OLD_LIBS+=usr/lib/private/libucl.so.1
+OLD_DIRS+=usr/lib/private
+# 20150501
+OLD_FILES+=usr/bin/soeliminate
+OLD_FILES+=usr/share/man/man1/soeliminate.1.gz
+# 20150501: Remove the nvlist_.*[vf] functions manpages.
+OLD_FILES+=usr/share/man/man3/nvlist_addf_binary.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_addf_bool.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_addf_descriptor.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_addf_null.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_addf_number.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_addf_nvlist.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_addf_string.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_addv_binary.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_addv_bool.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_addv_descriptor.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_addv_null.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_addv_number.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_addv_nvlist.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_addv_string.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_existsf_binary.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_existsf_bool.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_existsf_descriptor.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_existsf_null.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_existsf_number.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_existsf_nvlist.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_existsf_string.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_existsf_type.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_existsv_binary.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_existsv_bool.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_existsv_descriptor.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_existsv_null.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_existsv_number.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_existsv_nvlist.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_existsv_string.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_existsv_type.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_freef_binary.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_freef_bool.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_freef_descriptor.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_freef_null.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_freef_number.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_freef_nvlist.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_freef_string.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_freef_type.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_freev_binary.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_freev_bool.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_freev_descriptor.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_freev_null.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_freev_number.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_freev_nvlist.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_freev_string.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_freev_type.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_getf_binary.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_getf_bool.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_getf_descriptor.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_getf_number.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_getf_nvlist.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_getf_string.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_getv_binary.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_getv_bool.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_getv_descriptor.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_getv_number.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_getv_nvlist.3.gz
+OLD_FILES+=usr/share/man/man3/nvlist_getv_string.3.gz
+# 20150429:
+OLD_FILES+=usr/share/docs/papers/hwpmc.ascii.gz
+# 20150427: test/sys/kern/mmap_test moved to test/sys/vm/mmap_test
+OLD_FILES+=usr/tests/sys/kern/mmap_test
# 20150418
OLD_FILES+=sbin/mount_oldnfs
OLD_FILES+=usr/share/man/man8/mount_oldnfs.8.gz
@@ -357,6 +462,33 @@ OLD_LIBS+=usr/lib32/libopie.so.7
OLD_FILES+=usr/bin/otp-sha
OLD_FILES+=usr/share/man/man1/otp-sha.1.gz
# 20140807: Remove private lib files that should not be installed.
+OLD_FILES+=usr/lib32/private/libatf-c.a
+OLD_FILES+=usr/lib32/private/libatf-c.so
+OLD_FILES+=usr/lib32/private/libatf-c_p.a
+OLD_FILES+=usr/lib32/private/libatf-c++.a
+OLD_FILES+=usr/lib32/private/libatf-c++.so
+OLD_FILES+=usr/lib32/private/libatf-c++_p.a
+OLD_FILES+=usr/lib32/private/libbsdstat.a
+OLD_FILES+=usr/lib32/private/libbsdstat.so
+OLD_FILES+=usr/lib32/private/libbsdstat_p.a
+OLD_FILES+=usr/lib32/private/libheimipcc.a
+OLD_FILES+=usr/lib32/private/libheimipcc.so
+OLD_FILES+=usr/lib32/private/libheimipcc_p.a
+OLD_FILES+=usr/lib32/private/libheimipcs.a
+OLD_FILES+=usr/lib32/private/libheimipcs.so
+OLD_FILES+=usr/lib32/private/libheimipcs_p.a
+OLD_FILES+=usr/lib32/private/libldns.a
+OLD_FILES+=usr/lib32/private/libldns.so
+OLD_FILES+=usr/lib32/private/libldns_p.a
+OLD_FILES+=usr/lib32/private/libssh.a
+OLD_FILES+=usr/lib32/private/libssh.so
+OLD_FILES+=usr/lib32/private/libssh_p.a
+OLD_FILES+=usr/lib32/private/libunbound.a
+OLD_FILES+=usr/lib32/private/libunbound.so
+OLD_FILES+=usr/lib32/private/libunbound_p.a
+OLD_FILES+=usr/lib32/private/libucl.a
+OLD_FILES+=usr/lib32/private/libucl.so
+OLD_FILES+=usr/lib32/private/libucl_p.a
OLD_FILES+=usr/lib/private/libatf-c.a
OLD_FILES+=usr/lib/private/libatf-c.so
OLD_FILES+=usr/lib/private/libatf-c_p.a
@@ -377,7 +509,7 @@ OLD_FILES+=usr/lib/private/libldns.so
OLD_FILES+=usr/lib/private/libldns_p.a
OLD_FILES+=usr/lib/private/libssh.a
OLD_FILES+=usr/lib/private/libssh.so
-OLD_FILES+=usr/lib/private/libssh.p.a
+OLD_FILES+=usr/lib/private/libssh_p.a
OLD_FILES+=usr/lib/private/libunbound.a
OLD_FILES+=usr/lib/private/libunbound.so
OLD_FILES+=usr/lib/private/libunbound_p.a
@@ -529,8 +661,12 @@ OLD_FILES+=usr/libexec/bsdconfig/070.usermgmt/groupinput
# 20140223: Remove libyaml
OLD_FILES+=usr/lib/private/libyaml.a
OLD_FILES+=usr/lib/private/libyaml.so
-OLD_FILES+=usr/lib/private/libyaml.so.1
+OLD_LIBS+=usr/lib/private/libyaml.so.1
OLD_FILES+=usr/lib/private/libyaml_p.a
+OLD_FILES+=usr/lib32/private/libyaml.a
+OLD_FILES+=usr/lib32/private/libyaml.so
+OLD_LIBS+=usr/lib32/private/libyaml.so.1
+OLD_FILES+=usr/lib32/private/libyaml_p.a
# 20140216: new clang import which bumps version from 3.3 to 3.4.
OLD_FILES+=usr/bin/llvm-prof
OLD_FILES+=usr/bin/llvm-ranlib
diff --git a/UPDATING b/UPDATING
index 886020b..d961aa3 100644
--- a/UPDATING
+++ b/UPDATING
@@ -31,6 +31,28 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW:
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
+20150521:
+ TI platform code switched to using vendor DTS files and this update
+ may break existing systems running on Beaglebone, Beaglebone Black,
+ and Pandaboard:
+
+ - dtb files should be regenerated/reinstalled. Filenames are the
+ same but content is different now
+ - GPIO addressing was changed, now each GPIO bank (32 pins per bank)
+ has its own /dev/gpiocX device, e.g. pin 121 on /dev/gpioc0 in old
+ addressing scheme is now pin 25 on /dev/gpioc3.
+ - Pandaboard: /etc/ttys should be updated, serial console device is
+ now /dev/ttyu2, not /dev/ttyu0
+
+20150501:
+ soelim(1) from gnu/usr.bin/groff has been replaced by usr.bin/soelim.
+ If you need the GNU extension from groff soelim(1), install groff
+ from package: pkg install groff, or via ports: textproc/groff.
+
+20150423:
+ chmod, chflags, chown and chgrp now affect symlinks in -R mode as
+ defined in symlink(7); previously symlinks were silently ignored.
+
20150415:
The const qualifier has been removed from iconv(3) to comply with
POSIX. The ports tree is aware of this from r384038 onwards.
diff --git a/bin/chflags/chflags.1 b/bin/chflags/chflags.1
index 47d5b18..755cbce 100644
--- a/bin/chflags/chflags.1
+++ b/bin/chflags/chflags.1
@@ -32,7 +32,7 @@
.\" @(#)chflags.1 8.4 (Berkeley) 5/2/95
.\" $FreeBSD$
.\"
-.Dd April 8, 2013
+.Dd April 20, 2015
.Dt CHFLAGS 1
.Os
.Sh NAME
@@ -66,8 +66,9 @@ nor modify the exit status to reflect such failures.
.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.)
+option is specified, symbolic links on the command line are followed
+and hence unaffected by the command.
+(Symbolic links encountered during traversal are not followed.)
.It Fl h
If the
.Ar file
@@ -83,8 +84,12 @@ If the
option is specified, no symbolic links are followed.
This is the default.
.It Fl R
-Change the file flags for the file hierarchies rooted
-in the files instead of just the files themselves.
+Change the file flags of the file hierarchies rooted in the files,
+instead of just the files themselves.
+Beware of unintentionally matching the
+.Dq Pa ".."
+hard link to the parent directory when using wildcards like
+.Dq Li ".*" .
.It Fl v
Cause
.Nm
diff --git a/bin/chflags/chflags.c b/bin/chflags/chflags.c
index e94c34d..2029ac5 100644
--- a/bin/chflags/chflags.c
+++ b/bin/chflags/chflags.c
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <errno.h>
+#include <fcntl.h>
#include <fts.h>
#include <stdio.h>
#include <stdlib.h>
@@ -65,7 +66,6 @@ main(int argc, char *argv[])
int Hflag, Lflag, Rflag, fflag, hflag, vflag;
int ch, fts_options, oct, rval;
char *flags, *ep;
- int (*change_flags)(const char *, unsigned long);
Hflag = Lflag = Rflag = fflag = hflag = vflag = 0;
while ((ch = getopt(argc, argv, "HLPRfhv")) != -1)
@@ -104,20 +104,23 @@ main(int argc, char *argv[])
usage();
if (Rflag) {
- fts_options = FTS_PHYSICAL;
if (hflag)
- errx(1, "the -R and -h options "
- "may not be specified together");
- if (Hflag)
- fts_options |= FTS_COMFOLLOW;
+ errx(1, "the -R and -h options may not be "
+ "specified together.");
if (Lflag) {
- fts_options &= ~FTS_PHYSICAL;
- fts_options |= FTS_LOGICAL;
- }
- } else
- fts_options = hflag ? FTS_PHYSICAL : FTS_LOGICAL;
+ fts_options = FTS_LOGICAL;
+ } else {
+ fts_options = FTS_PHYSICAL;
- change_flags = hflag ? lchflags : chflags;
+ if (Hflag) {
+ fts_options |= FTS_COMFOLLOW;
+ }
+ }
+ } else if (hflag) {
+ fts_options = FTS_PHYSICAL;
+ } else {
+ fts_options = FTS_LOGICAL;
+ }
flags = *argv;
if (*flags >= '0' && *flags <= '7') {
@@ -142,12 +145,21 @@ main(int argc, char *argv[])
err(1, NULL);
for (rval = 0; (p = fts_read(ftsp)) != NULL;) {
+ int atflag;
+
+ if ((fts_options & FTS_LOGICAL) ||
+ ((fts_options & FTS_COMFOLLOW) &&
+ p->fts_level == FTS_ROOTLEVEL))
+ atflag = 0;
+ else
+ atflag = AT_SYMLINK_NOFOLLOW;
+
switch (p->fts_info) {
case FTS_D: /* Change it at FTS_DP if we're recursive. */
if (!Rflag)
fts_set(ftsp, p, FTS_SKIP);
continue;
- case FTS_DNR: /* Warn, chflag, continue. */
+ case FTS_DNR: /* Warn, chflags. */
warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
rval = 1;
break;
@@ -156,16 +168,6 @@ main(int argc, char *argv[])
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.
- */
- if (!hflag)
- continue;
- /* FALLTHROUGH */
default:
break;
}
@@ -175,7 +177,8 @@ main(int argc, char *argv[])
newflags = (p->fts_statp->st_flags | set) & clear;
if (newflags == p->fts_statp->st_flags)
continue;
- if ((*change_flags)(p->fts_accpath, newflags) && !fflag) {
+ if (chflagsat(AT_FDCWD, p->fts_accpath, newflags,
+ atflag) == -1 && !fflag) {
warn("%s", p->fts_path);
rval = 1;
} else if (vflag) {
diff --git a/bin/chmod/chmod.1 b/bin/chmod/chmod.1
index 34a1ff0..7efaabc 100644
--- a/bin/chmod/chmod.1
+++ b/bin/chmod/chmod.1
@@ -32,7 +32,7 @@
.\" @(#)chmod.1 8.4 (Berkeley) 3/31/94
.\" $FreeBSD$
.\"
-.Dd January 26, 2009
+.Dd April 20, 2015
.Dt CHMOD 1
.Os
.Sh NAME
@@ -63,9 +63,9 @@ nor modify the exit status to reflect such failures.
.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 by
-default.)
+option is specified, symbolic links on the command line are followed
+and hence unaffected by the command.
+(Symbolic links encountered during tree traversal are not followed.)
.It Fl h
If the file is a symbolic link, change the mode of the link itself
rather than the file that the link points to.
@@ -79,8 +79,12 @@ If the
option is specified, no symbolic links are followed.
This is the default.
.It Fl R
-Change the modes of the file hierarchies rooted in the files
+Change the modes of the file hierarchies rooted in the files,
instead of just the files themselves.
+Beware of unintentionally matching the
+.Dq Pa ".."
+hard link to the parent directory when using wildcards like
+.Dq Li ".*" .
.It Fl v
Cause
.Nm
diff --git a/bin/chmod/chmod.c b/bin/chmod/chmod.c
index dc51faa..9b80157 100644
--- a/bin/chmod/chmod.c
+++ b/bin/chmod/chmod.c
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <errno.h>
+#include <fcntl.h>
#include <fts.h>
#include <limits.h>
#include <stdio.h>
@@ -62,7 +63,7 @@ main(int argc, char *argv[])
FTS *ftsp;
FTSENT *p;
mode_t *set;
- int Hflag, Lflag, Rflag, ch, error, fflag, fts_options, hflag, rval;
+ int Hflag, Lflag, Rflag, ch, fflag, fts_options, hflag, rval;
int vflag;
char *mode;
mode_t newmode;
@@ -126,18 +127,23 @@ done: argv += optind;
usage();
if (Rflag) {
- fts_options = FTS_PHYSICAL;
if (hflag)
- errx(1,
- "the -R and -h options may not be specified together.");
- if (Hflag)
- fts_options |= FTS_COMFOLLOW;
+ errx(1, "the -R and -h options may not be "
+ "specified together.");
if (Lflag) {
- fts_options &= ~FTS_PHYSICAL;
- fts_options |= FTS_LOGICAL;
+ fts_options = FTS_LOGICAL;
+ } else {
+ fts_options = FTS_PHYSICAL;
+
+ if (Hflag) {
+ fts_options |= FTS_COMFOLLOW;
+ }
}
- } else
- fts_options = hflag ? FTS_PHYSICAL : FTS_LOGICAL;
+ } else if (hflag) {
+ fts_options = FTS_PHYSICAL;
+ } else {
+ fts_options = FTS_LOGICAL;
+ }
mode = *argv;
if ((set = setmode(mode)) == NULL)
@@ -146,12 +152,21 @@ done: argv += optind;
if ((ftsp = fts_open(++argv, fts_options, 0)) == NULL)
err(1, "fts_open");
for (rval = 0; (p = fts_read(ftsp)) != NULL;) {
+ int atflag;
+
+ if ((fts_options & FTS_LOGICAL) ||
+ ((fts_options & FTS_COMFOLLOW) &&
+ p->fts_level == FTS_ROOTLEVEL))
+ atflag = 0;
+ else
+ atflag = AT_SYMLINK_NOFOLLOW;
+
switch (p->fts_info) {
case FTS_D: /* Change it at FTS_DP. */
if (!Rflag)
fts_set(ftsp, p, FTS_SKIP);
continue;
- case FTS_DNR: /* Warn, chmod, continue. */
+ case FTS_DNR: /* Warn, chmod. */
warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
rval = 1;
break;
@@ -160,16 +175,6 @@ done: argv += optind;
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.
- */
- if (!hflag)
- continue;
- /* FALLTHROUGH */
default:
break;
}
@@ -182,32 +187,25 @@ done: argv += optind;
if (may_have_nfs4acl(p, hflag) == 0 &&
(newmode & ALLPERMS) == (p->fts_statp->st_mode & ALLPERMS))
continue;
- if (hflag)
- error = lchmod(p->fts_accpath, newmode);
- else
- error = chmod(p->fts_accpath, newmode);
- if (error) {
- if (!fflag) {
- warn("%s", p->fts_path);
- rval = 1;
- }
- } else {
- if (vflag) {
- (void)printf("%s", p->fts_path);
-
- if (vflag > 1) {
- char m1[12], m2[12];
-
- strmode(p->fts_statp->st_mode, m1);
- strmode((p->fts_statp->st_mode &
- S_IFMT) | newmode, m2);
- (void)printf(": 0%o [%s] -> 0%o [%s]",
- p->fts_statp->st_mode, m1,
- (p->fts_statp->st_mode & S_IFMT) |
- newmode, m2);
- }
- (void)printf("\n");
+ if (fchmodat(AT_FDCWD, p->fts_accpath, newmode, atflag) == -1
+ && !fflag) {
+ warn("%s", p->fts_path);
+ rval = 1;
+ } else if (vflag) {
+ (void)printf("%s", p->fts_path);
+
+ if (vflag > 1) {
+ char m1[12], m2[12];
+
+ strmode(p->fts_statp->st_mode, m1);
+ strmode((p->fts_statp->st_mode &
+ S_IFMT) | newmode, m2);
+ (void)printf(": 0%o [%s] -> 0%o [%s]",
+ p->fts_statp->st_mode, m1,
+ (p->fts_statp->st_mode & S_IFMT) |
+ newmode, m2);
}
+ (void)printf("\n");
}
}
if (errno)
diff --git a/bin/cp/cp.c b/bin/cp/cp.c
index b83eead..2ad5f4a 100644
--- a/bin/cp/cp.c
+++ b/bin/cp/cp.c
@@ -90,7 +90,6 @@ volatile sig_atomic_t info;
enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
static int copy(char *[], enum op, int);
-static int mastercmp(const FTSENT * const *, const FTSENT * const *);
static void siginfo(int __unused);
int
@@ -274,7 +273,7 @@ copy(char *argv[], enum op type, int fts_options)
mask = ~umask(0777);
umask(~mask);
- if ((ftsp = fts_open(argv, fts_options, mastercmp)) == NULL)
+ if ((ftsp = fts_open(argv, fts_options, NULL)) == NULL)
err(1, "fts_open");
for (badcp = rval = 0; (curr = fts_read(ftsp)) != NULL; badcp = 0) {
switch (curr->fts_info) {
@@ -488,32 +487,6 @@ copy(char *argv[], enum op type, int fts_options)
return (rval);
}
-/*
- * mastercmp --
- * The comparison function for the copy order. The order is to copy
- * non-directory files before directory files. The reason for this
- * is because files tend to be in the same cylinder group as their
- * parent directory, whereas directories tend not to be. Copying the
- * files first reduces seeking.
- */
-static int
-mastercmp(const FTSENT * const *a, const FTSENT * const *b)
-{
- int a_info, b_info;
-
- a_info = (*a)->fts_info;
- if (a_info == FTS_ERR || a_info == FTS_NS || a_info == FTS_DNR)
- return (0);
- b_info = (*b)->fts_info;
- if (b_info == FTS_ERR || b_info == FTS_NS || b_info == FTS_DNR)
- return (0);
- if (a_info == FTS_D)
- return (-1);
- if (b_info == FTS_D)
- return (1);
- return (0);
-}
-
static void
siginfo(int sig __unused)
{
diff --git a/bin/date/date.1 b/bin/date/date.1
index 5e9e664..dd791ec 100644
--- a/bin/date/date.1
+++ b/bin/date/date.1
@@ -32,7 +32,7 @@
.\" @(#)date.1 8.3 (Berkeley) 4/28/95
.\" $FreeBSD$
.\"
-.Dd April 26, 2014
+.Dd May 7, 2015
.Dt DATE 1
.Os
.Sh NAME
@@ -41,7 +41,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl jRu
-.Op Fl r Ar seconds
+.Op Fl r Ar seconds | Ar filename
.Oo
.Fl v
.Sm off
@@ -150,6 +150,9 @@ is the number of seconds since the Epoch
see
.Xr time 3 ) ,
and can be specified in decimal, octal, or hex.
+.It Fl r Ar filename
+Print the date and time of the last modification of
+.Ar filename .
.It Fl t Ar minutes_west
Set the system's value for minutes west of
.Tn GMT .
diff --git a/bin/date/date.c b/bin/date/date.c
index 2c09848..9ae6502 100644
--- a/bin/date/date.c
+++ b/bin/date/date.c
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/time.h>
+#include <sys/stat.h>
#include <ctype.h>
#include <err.h>
@@ -85,6 +86,7 @@ main(int argc, char *argv[])
struct vary *v;
const struct vary *badv;
struct tm lt;
+ struct stat sb;
v = NULL;
fmt = NULL;
@@ -116,8 +118,12 @@ main(int argc, char *argv[])
case 'r': /* user specified seconds */
rflag = 1;
tval = strtoq(optarg, &tmp, 0);
- if (*tmp != 0)
- usage();
+ if (*tmp != 0) {
+ if (stat(optarg, &sb) == 0)
+ tval = sb.st_mtim.tv_sec;
+ else
+ usage();
+ }
break;
case 't': /* minutes west of UTC */
/* error check; don't allow "PST" */
diff --git a/bin/pax/ar_subs.c b/bin/pax/ar_subs.c
index 4a3e5e7..bcab2fc 100644
--- a/bin/pax/ar_subs.c
+++ b/bin/pax/ar_subs.c
@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
-#include <stdlib.h>
#include "pax.h"
#include "extern.h"
diff --git a/bin/pax/buf_subs.c b/bin/pax/buf_subs.c
index 995e34c..4922fc8 100644
--- a/bin/pax/buf_subs.c
+++ b/bin/pax/buf_subs.c
@@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include "pax.h"
#include "extern.h"
diff --git a/bin/pax/cache.c b/bin/pax/cache.c
index 358707d..f6e52b4 100644
--- a/bin/pax/cache.c
+++ b/bin/pax/cache.c
@@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <pwd.h>
#include <grp.h>
-#include <unistd.h>
#include <stdlib.h>
#include "pax.h"
#include "cache.h"
diff --git a/bin/pax/cpio.c b/bin/pax/cpio.c
index 0d9cc9f..f385a59 100644
--- a/bin/pax/cpio.c
+++ b/bin/pax/cpio.c
@@ -45,8 +45,6 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <stdint.h>
#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
#include "pax.h"
#include "cpio.h"
#include "extern.h"
diff --git a/bin/pax/file_subs.c b/bin/pax/file_subs.c
index 5e4cce1..f18227e 100644
--- a/bin/pax/file_subs.c
+++ b/bin/pax/file_subs.c
@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <errno.h>
#include <sys/uio.h>
-#include <stdlib.h>
#include "pax.h"
#include "options.h"
#include "extern.h"
diff --git a/bin/pax/gen_subs.c b/bin/pax/gen_subs.c
index 708e8af..232ee77 100644
--- a/bin/pax/gen_subs.c
+++ b/bin/pax/gen_subs.c
@@ -45,8 +45,6 @@ __FBSDID("$FreeBSD$");
#include <langinfo.h>
#include <stdint.h>
#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
#include <string.h>
#include "pax.h"
#include "extern.h"
diff --git a/bin/pax/getoldopt.c b/bin/pax/getoldopt.c
index 2871721..838ff54 100644
--- a/bin/pax/getoldopt.c
+++ b/bin/pax/getoldopt.c
@@ -19,8 +19,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
-#include "pax.h"
-#include "extern.h"
+int getoldopt(int, char **, const char *);
int
getoldopt(int argc, char **argv, const char *optstring)
diff --git a/bin/pax/pat_rep.c b/bin/pax/pat_rep.c
index 7b07975..e8d17db 100644
--- a/bin/pax/pat_rep.c
+++ b/bin/pax/pat_rep.c
@@ -43,9 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
#include <stdlib.h>
-#include <errno.h>
#ifdef NET2_REGEX
#include <regexp.h>
#else
diff --git a/bin/pax/pax.c b/bin/pax/pax.c
index 0a53f9a..4e97610 100644
--- a/bin/pax/pax.c
+++ b/bin/pax/pax.c
@@ -58,7 +58,6 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
#include "pax.h"
#include "extern.h"
static int gen_init(void);
diff --git a/bin/pax/sel_subs.c b/bin/pax/sel_subs.c
index fe131f7..e9cc759 100644
--- a/bin/pax/sel_subs.c
+++ b/bin/pax/sel_subs.c
@@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <string.h>
#include <strings.h>
-#include <unistd.h>
#include <stdlib.h>
#include "pax.h"
#include "sel_subs.h"
diff --git a/bin/pax/tar.c b/bin/pax/tar.c
index 4ee2786a8..32bdd6e 100644
--- a/bin/pax/tar.c
+++ b/bin/pax/tar.c
@@ -44,8 +44,6 @@ __FBSDID("$FreeBSD$");
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
#include "pax.h"
#include "extern.h"
#include "tar.h"
diff --git a/bin/pax/tty_subs.c b/bin/pax/tty_subs.c
index b3d140e..b63da86 100644
--- a/bin/pax/tty_subs.c
+++ b/bin/pax/tty_subs.c
@@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$");
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
-#include <stdlib.h>
#include <string.h>
#include "pax.h"
#include "extern.h"
diff --git a/bin/ps/Makefile b/bin/ps/Makefile
index 30dbdc9..79e9fc6 100644
--- a/bin/ps/Makefile
+++ b/bin/ps/Makefile
@@ -11,6 +11,6 @@ SRCS= fmt.c keyword.c nlist.c print.c ps.c
# on large systems.
#
CFLAGS+=-DLAZY_PS
-LIBADD= m kvm jail
+LIBADD= m kvm jail xo
.include <bsd.prog.mk>
diff --git a/bin/ps/keyword.c b/bin/ps/keyword.c
index 38a9934..b802c37 100644
--- a/bin/ps/keyword.c
+++ b/bin/ps/keyword.c
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <libxo/xo.h>
#include "ps.h"
@@ -64,116 +65,170 @@ static int vcmp(const void *, const void *);
/* PLEASE KEEP THE TABLE BELOW SORTED ALPHABETICALLY!!! */
static VAR var[] = {
- {"%cpu", "%CPU", NULL, 0, pcpu, 0, CHAR, NULL, 0},
- {"%mem", "%MEM", NULL, 0, pmem, 0, CHAR, NULL, 0},
- {"acflag", "ACFLG", NULL, 0, kvar, KOFF(ki_acflag), USHORT, "x", 0},
- {"acflg", "", "acflag", 0, NULL, 0, CHAR, NULL, 0},
- {"args", "COMMAND", NULL, COMM|LJUST|USER, arguments, 0,
- CHAR, NULL, 0},
- {"blocked", "", "sigmask", 0, NULL, 0, CHAR, NULL, 0},
- {"caught", "", "sigcatch", 0, NULL, 0, CHAR, NULL, 0},
- {"class", "CLASS", NULL, LJUST, loginclass, 0, CHAR, NULL, 0},
- {"comm", "COMMAND", NULL, LJUST, ucomm, 0, CHAR, NULL, 0},
- {"command", "COMMAND", NULL, COMM|LJUST|USER, command, 0,
- CHAR, NULL, 0},
- {"cow", "COW", NULL, 0, kvar, KOFF(ki_cow), UINT, "u", 0},
- {"cpu", "CPU", NULL, 0, kvar, KOFF(ki_estcpu), UINT, "d", 0},
- {"cputime", "", "time", 0, NULL, 0, CHAR, NULL, 0},
- {"dsiz", "DSIZ", NULL, 0, kvar, KOFF(ki_dsize), PGTOK, "ld", 0},
- {"egid", "", "gid", 0, NULL, 0, CHAR, NULL, 0},
- {"egroup", "", "group", 0, NULL, 0, CHAR, NULL, 0},
- {"emul", "EMUL", NULL, LJUST, emulname, 0, CHAR, NULL, 0},
- {"etime", "ELAPSED", NULL, USER, elapsed, 0, CHAR, NULL, 0},
- {"etimes", "ELAPSED", NULL, USER, elapseds, 0, CHAR, NULL, 0},
- {"euid", "", "uid", 0, NULL, 0, CHAR, NULL, 0},
- {"f", "F", NULL, 0, kvar, KOFF(ki_flag), INT, "x", 0},
- {"f2", "F2", NULL, 0, kvar, KOFF(ki_flag2), INT, "08x", 0},
- {"fib", "FIB", NULL, 0, kvar, KOFF(ki_fibnum), INT, "d", 0},
- {"flags", "", "f", 0, NULL, 0, CHAR, NULL, 0},
- {"flags2", "", "f2", 0, NULL, 0, CHAR, NULL, 0},
- {"gid", "GID", NULL, 0, kvar, KOFF(ki_groups), UINT, UIDFMT, 0},
- {"group", "GROUP", NULL, LJUST, egroupname, 0, CHAR, NULL, 0},
- {"ignored", "", "sigignore", 0, NULL, 0, CHAR, NULL, 0},
- {"inblk", "INBLK", NULL, USER, rvar, ROFF(ru_inblock), LONG, "ld", 0},
- {"inblock", "", "inblk", 0, NULL, 0, CHAR, NULL, 0},
- {"jid", "JID", NULL, 0, kvar, KOFF(ki_jid), INT, "d", 0},
- {"jobc", "JOBC", NULL, 0, kvar, KOFF(ki_jobc), SHORT, "d", 0},
- {"ktrace", "KTRACE", NULL, 0, kvar, KOFF(ki_traceflag), INT, "x", 0},
- {"label", "LABEL", NULL, LJUST, label, 0, CHAR, NULL, 0},
- {"lim", "LIM", NULL, 0, maxrss, 0, CHAR, NULL, 0},
- {"lockname", "LOCK", NULL, LJUST, lockname, 0, CHAR, NULL, 0},
- {"login", "LOGIN", NULL, LJUST, logname, 0, CHAR, NULL, 0},
- {"logname", "", "login", 0, NULL, 0, CHAR, NULL, 0},
- {"lstart", "STARTED", NULL, LJUST|USER, lstarted, 0, CHAR, NULL, 0},
- {"lwp", "LWP", NULL, 0, kvar, KOFF(ki_tid), UINT, LWPFMT, 0},
- {"majflt", "MAJFLT", NULL, USER, rvar, ROFF(ru_majflt), LONG, "ld", 0},
- {"minflt", "MINFLT", NULL, USER, rvar, ROFF(ru_minflt), LONG, "ld", 0},
- {"msgrcv", "MSGRCV", NULL, USER, rvar, ROFF(ru_msgrcv), LONG, "ld", 0},
- {"msgsnd", "MSGSND", NULL, USER, rvar, ROFF(ru_msgsnd), LONG, "ld", 0},
- {"mwchan", "MWCHAN", NULL, LJUST, mwchan, 0, CHAR, NULL, 0},
- {"ni", "", "nice", 0, NULL, 0, CHAR, NULL, 0},
- {"nice", "NI", NULL, 0, kvar, KOFF(ki_nice), CHAR, "d", 0},
- {"nivcsw", "NIVCSW", NULL, USER, rvar, ROFF(ru_nivcsw), LONG, "ld", 0},
- {"nlwp", "NLWP", NULL, 0, kvar, KOFF(ki_numthreads), UINT, NLWPFMT, 0},
- {"nsignals", "", "nsigs", 0, NULL, 0, CHAR, NULL, 0},
- {"nsigs", "NSIGS", NULL, USER, rvar, ROFF(ru_nsignals), LONG, "ld", 0},
- {"nswap", "NSWAP", NULL, USER, rvar, ROFF(ru_nswap), LONG, "ld", 0},
- {"nvcsw", "NVCSW", NULL, USER, rvar, ROFF(ru_nvcsw), LONG, "ld", 0},
- {"nwchan", "NWCHAN", NULL, LJUST, nwchan, 0, CHAR, NULL, 0},
- {"oublk", "OUBLK", NULL, USER, rvar, ROFF(ru_oublock), LONG, "ld", 0},
- {"oublock", "", "oublk", 0, NULL, 0, CHAR, NULL, 0},
- {"paddr", "PADDR", NULL, 0, kvar, KOFF(ki_paddr), KPTR, "lx", 0},
- {"pagein", "PAGEIN", NULL, USER, pagein, 0, CHAR, NULL, 0},
- {"pcpu", "", "%cpu", 0, NULL, 0, CHAR, NULL, 0},
- {"pending", "", "sig", 0, NULL, 0, CHAR, NULL, 0},
- {"pgid", "PGID", NULL, 0, kvar, KOFF(ki_pgid), UINT, PIDFMT, 0},
- {"pid", "PID", NULL, 0, kvar, KOFF(ki_pid), UINT, PIDFMT, 0},
- {"pmem", "", "%mem", 0, NULL, 0, CHAR, NULL, 0},
- {"ppid", "PPID", NULL, 0, kvar, KOFF(ki_ppid), UINT, PIDFMT, 0},
- {"pri", "PRI", NULL, 0, pri, 0, CHAR, NULL, 0},
- {"re", "RE", NULL, INF127, kvar, KOFF(ki_swtime), UINT, "d", 0},
- {"rgid", "RGID", NULL, 0, kvar, KOFF(ki_rgid), UINT, UIDFMT, 0},
- {"rgroup", "RGROUP", NULL, LJUST, rgroupname, 0, CHAR, NULL, 0},
- {"rss", "RSS", NULL, 0, kvar, KOFF(ki_rssize), PGTOK, "ld", 0},
- {"rtprio", "RTPRIO", NULL, 0, priorityr, KOFF(ki_pri), CHAR, NULL, 0},
- {"ruid", "RUID", NULL, 0, kvar, KOFF(ki_ruid), UINT, UIDFMT, 0},
- {"ruser", "RUSER", NULL, LJUST, runame, 0, CHAR, NULL, 0},
- {"sid", "SID", NULL, 0, kvar, KOFF(ki_sid), UINT, PIDFMT, 0},
- {"sig", "PENDING", NULL, 0, kvar, KOFF(ki_siglist), INT, "x", 0},
- {"sigcatch", "CAUGHT", NULL, 0, kvar, KOFF(ki_sigcatch), UINT, "x", 0},
- {"sigignore", "IGNORED", NULL, 0, kvar, KOFF(ki_sigignore),
- UINT, "x", 0},
- {"sigmask", "BLOCKED", NULL, 0, kvar, KOFF(ki_sigmask), UINT, "x", 0},
- {"sl", "SL", NULL, INF127, kvar, KOFF(ki_slptime), UINT, "d", 0},
- {"ssiz", "SSIZ", NULL, 0, kvar, KOFF(ki_ssize), PGTOK, "ld", 0},
- {"start", "STARTED", NULL, LJUST|USER, started, 0, CHAR, NULL, 0},
- {"stat", "", "state", 0, NULL, 0, CHAR, NULL, 0},
- {"state", "STAT", NULL, LJUST, state, 0, CHAR, NULL, 0},
- {"svgid", "SVGID", NULL, 0, kvar, KOFF(ki_svgid), UINT, UIDFMT, 0},
- {"svuid", "SVUID", NULL, 0, kvar, KOFF(ki_svuid), UINT, UIDFMT, 0},
- {"systime", "SYSTIME", NULL, USER, systime, 0, CHAR, NULL, 0},
- {"tdaddr", "TDADDR", NULL, 0, kvar, KOFF(ki_tdaddr), KPTR, "lx", 0},
- {"tdev", "TDEV", NULL, 0, tdev, 0, CHAR, NULL, 0},
- {"tdnam", "TDNAM", NULL, LJUST, tdnam, 0, CHAR, NULL, 0},
- {"time", "TIME", NULL, USER, cputime, 0, CHAR, NULL, 0},
- {"tpgid", "TPGID", NULL, 0, kvar, KOFF(ki_tpgid), UINT, PIDFMT, 0},
- {"tracer", "TRACER", NULL, 0, kvar, KOFF(ki_tracer), UINT, PIDFMT, 0},
- {"tsid", "TSID", NULL, 0, kvar, KOFF(ki_tsid), UINT, PIDFMT, 0},
- {"tsiz", "TSIZ", NULL, 0, kvar, KOFF(ki_tsize), PGTOK, "ld", 0},
- {"tt", "TT ", NULL, 0, tname, 0, CHAR, NULL, 0},
- {"tty", "TTY", NULL, LJUST, longtname, 0, CHAR, NULL, 0},
- {"ucomm", "UCOMM", NULL, LJUST, ucomm, 0, CHAR, NULL, 0},
- {"uid", "UID", NULL, 0, kvar, KOFF(ki_uid), UINT, UIDFMT, 0},
- {"upr", "UPR", NULL, 0, upr, 0, CHAR, NULL, 0},
- {"uprocp", "UPROCP", NULL, 0, kvar, KOFF(ki_paddr), KPTR, "lx", 0},
- {"user", "USER", NULL, LJUST, uname, 0, CHAR, NULL, 0},
- {"usertime", "USERTIME", NULL, USER, usertime, 0, CHAR, NULL, 0},
- {"usrpri", "", "upr", 0, NULL, 0, CHAR, NULL, 0},
- {"vsize", "", "vsz", 0, NULL, 0, CHAR, NULL, 0},
- {"vsz", "VSZ", NULL, 0, vsize, 0, CHAR, NULL, 0},
- {"wchan", "WCHAN", NULL, LJUST, wchan, 0, CHAR, NULL, 0},
- {"xstat", "XSTAT", NULL, 0, kvar, KOFF(ki_xstat), USHORT, "x", 0},
- {"", NULL, NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"%cpu", "%CPU", NULL, "percent-cpu", 0, pcpu, 0, CHAR, NULL, 0},
+ {"%mem", "%MEM", NULL, "percent-memory", 0, pmem, 0, CHAR, NULL, 0},
+ {"acflag", "ACFLG", NULL, "accounting-flag", 0, kvar, KOFF(ki_acflag),
+ USHORT, "x", 0},
+ {"acflg", "", "acflag", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"args", "COMMAND", NULL, "arguments", COMM|LJUST|USER, arguments, 0,
+ CHAR, NULL, 0},
+ {"blocked", "", "sigmask", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"caught", "", "sigcatch", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"class", "CLASS", NULL, "login-class", LJUST, loginclass, 0, CHAR,
+ NULL, 0},
+ {"comm", "COMMAND", NULL, "command", LJUST, ucomm, 0, CHAR, NULL, 0},
+ {"command", "COMMAND", NULL, "command", COMM|LJUST|USER, command, 0,
+ CHAR, NULL, 0},
+ {"cow", "COW", NULL, "copy-on-write-faults", 0, kvar, KOFF(ki_cow),
+ UINT, "u", 0},
+ {"cpu", "CPU", NULL, "cpu-usage", 0, kvar, KOFF(ki_estcpu), UINT, "d",
+ 0},
+ {"cputime", "", "time", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"dsiz", "DSIZ", NULL, "data-size", 0, kvar, KOFF(ki_dsize), PGTOK,
+ "ld", 0},
+ {"egid", "", "gid", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"egroup", "", "group", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"emul", "EMUL", NULL, "emulation-envirnment", LJUST, emulname, 0,
+ CHAR, NULL, 0},
+ {"etime", "ELAPSED", NULL, "elapsed-time", USER, elapsed, 0, CHAR,
+ NULL, 0},
+ {"etimes", "ELAPSED", NULL, "elapsed-times", USER, elapseds, 0, CHAR,
+ NULL, 0},
+ {"euid", "", "uid", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"f", "F", NULL, "flags", 0, kvar, KOFF(ki_flag), INT, "x", 0},
+ {"f2", "F2", NULL, "flags2", 0, kvar, KOFF(ki_flag2), INT, "08x", 0},
+ {"fib", "FIB", NULL, "fib", 0, kvar, KOFF(ki_fibnum), INT, "d", 0},
+ {"flags", "", "f", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"flags2", "", "f2", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"gid", "GID", NULL, "gid", 0, kvar, KOFF(ki_groups), UINT, UIDFMT, 0},
+ {"group", "GROUP", NULL, "group", LJUST, egroupname, 0, CHAR, NULL, 0},
+ {"ignored", "", "sigignore", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"inblk", "INBLK", NULL, "read-blocks", USER, rvar, ROFF(ru_inblock),
+ LONG, "ld", 0},
+ {"inblock", "", "inblk", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"jid", "JID", NULL, "jail-id", 0, kvar, KOFF(ki_jid), INT, "d", 0},
+ {"jobc", "JOBC", NULL, "job-control-count", 0, kvar, KOFF(ki_jobc),
+ SHORT, "d", 0},
+ {"ktrace", "KTRACE", NULL, "ktrace", 0, kvar, KOFF(ki_traceflag), INT,
+ "x", 0},
+ {"label", "LABEL", NULL, "label", LJUST, label, 0, CHAR, NULL, 0},
+ {"lim", "LIM", NULL, "memory-limit", 0, maxrss, 0, CHAR, NULL, 0},
+ {"lockname", "LOCK", NULL, "lock-name", LJUST, lockname, 0, CHAR, NULL,
+ 0},
+ {"login", "LOGIN", NULL, "login-name", LJUST, logname, 0, CHAR, NULL,
+ 0},
+ {"logname", "", "login", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"lstart", "STARTED", NULL, "start-time", LJUST|USER, lstarted, 0,
+ CHAR, NULL, 0},
+ {"lwp", "LWP", NULL, "process-thread-id", 0, kvar, KOFF(ki_tid), UINT,
+ LWPFMT, 0},
+ {"majflt", "MAJFLT", NULL, "major-faults", USER, rvar, ROFF(ru_majflt),
+ LONG, "ld", 0},
+ {"minflt", "MINFLT", NULL, "minor-faults", USER, rvar, ROFF(ru_minflt),
+ LONG, "ld", 0},
+ {"msgrcv", "MSGRCV", NULL, "received-messages", USER, rvar,
+ ROFF(ru_msgrcv), LONG, "ld", 0},
+ {"msgsnd", "MSGSND", NULL, "sent-messages", USER, rvar,
+ ROFF(ru_msgsnd), LONG, "ld", 0},
+ {"mwchan", "MWCHAN", NULL, "wait-channel", LJUST, mwchan, 0, CHAR,
+ NULL, 0},
+ {"ni", "", "nice", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"nice", "NI", NULL, "nice", 0, kvar, KOFF(ki_nice), CHAR, "d", 0},
+ {"nivcsw", "NIVCSW", NULL, "involuntary-context-switches", USER, rvar,
+ ROFF(ru_nivcsw), LONG, "ld", 0},
+ {"nlwp", "NLWP", NULL, "threads", 0, kvar, KOFF(ki_numthreads), UINT,
+ NLWPFMT, 0},
+ {"nsignals", "", "nsigs", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"nsigs", "NSIGS", NULL, "signals-taken", USER, rvar,
+ ROFF(ru_nsignals), LONG, "ld", 0},
+ {"nswap", "NSWAP", NULL, "swaps", USER, rvar, ROFF(ru_nswap), LONG,
+ "ld", 0},
+ {"nvcsw", "NVCSW", NULL, "voluntary-context-switches", USER, rvar,
+ ROFF(ru_nvcsw), LONG, "ld", 0},
+ {"nwchan", "NWCHAN", NULL, "wait-channel-address", LJUST, nwchan, 0,
+ CHAR, NULL, 0},
+ {"oublk", "OUBLK", NULL, "written-blocks", USER, rvar,
+ ROFF(ru_oublock), LONG, "ld", 0},
+ {"oublock", "", "oublk", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"paddr", "PADDR", NULL, "process-address", 0, kvar, KOFF(ki_paddr),
+ KPTR, "lx", 0},
+ {"pagein", "PAGEIN", NULL, "pageins", USER, pagein, 0, CHAR, NULL, 0},
+ {"pcpu", "", "%cpu", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"pending", "", "sig", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"pgid", "PGID", NULL, "process-group", 0, kvar, KOFF(ki_pgid), UINT,
+ PIDFMT, 0},
+ {"pid", "PID", NULL, "pid", 0, kvar, KOFF(ki_pid), UINT, PIDFMT, 0},
+ {"pmem", "", "%mem", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"ppid", "PPID", NULL, "ppid", 0, kvar, KOFF(ki_ppid), UINT, PIDFMT, 0},
+ {"pri", "PRI", NULL, "priority", 0, pri, 0, CHAR, NULL, 0},
+ {"re", "RE", NULL, "residency-time", INF127, kvar, KOFF(ki_swtime),
+ UINT, "d", 0},
+ {"rgid", "RGID", NULL, "real-gid", 0, kvar, KOFF(ki_rgid), UINT,
+ UIDFMT, 0},
+ {"rgroup", "RGROUP", NULL, "real-group", LJUST, rgroupname, 0, CHAR,
+ NULL, 0},
+ {"rss", "RSS", NULL, "rss", 0, kvar, KOFF(ki_rssize), PGTOK, "ld", 0},
+ {"rtprio", "RTPRIO", NULL, "realtime-priority", 0, priorityr,
+ KOFF(ki_pri), CHAR, NULL, 0},
+ {"ruid", "RUID", NULL, "real-uid", 0, kvar, KOFF(ki_ruid), UINT,
+ UIDFMT, 0},
+ {"ruser", "RUSER", NULL, "real-user", LJUST, runame, 0, CHAR, NULL, 0},
+ {"sid", "SID", NULL, "sid", 0, kvar, KOFF(ki_sid), UINT, PIDFMT, 0},
+ {"sig", "PENDING", NULL, "signals-pending", 0, kvar, KOFF(ki_siglist),
+ INT, "x", 0},
+ {"sigcatch", "CAUGHT", NULL, "signals-caught", 0, kvar,
+ KOFF(ki_sigcatch), UINT, "x", 0},
+ {"sigignore", "IGNORED", NULL, "signals-ignored", 0, kvar,
+ KOFF(ki_sigignore), UINT, "x", 0},
+ {"sigmask", "BLOCKED", NULL, "signal-mask", 0, kvar, KOFF(ki_sigmask),
+ UINT, "x", 0},
+ {"sl", "SL", NULL, "sleep-time", INF127, kvar, KOFF(ki_slptime), UINT,
+ "d", 0},
+ {"ssiz", "SSIZ", NULL, "stack-size", 0, kvar, KOFF(ki_ssize), PGTOK,
+ "ld", 0},
+ {"start", "STARTED", NULL, "start-time", LJUST|USER, started, 0, CHAR,
+ NULL, 0},
+ {"stat", "", "state", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"state", "STAT", NULL, "state", LJUST, state, 0, CHAR, NULL, 0},
+ {"svgid", "SVGID", NULL, "saved-gid", 0, kvar, KOFF(ki_svgid), UINT,
+ UIDFMT, 0},
+ {"svuid", "SVUID", NULL, "saved-uid", 0, kvar, KOFF(ki_svuid), UINT,
+ UIDFMT, 0},
+ {"systime", "SYSTIME", NULL, "system-time", USER, systime, 0, CHAR,
+ NULL, 0},
+ {"tdaddr", "TDADDR", NULL, "thread-address", 0, kvar, KOFF(ki_tdaddr),
+ KPTR, "lx", 0},
+ {"tdev", "TDEV", NULL, "terminal-device", 0, tdev, 0, CHAR, NULL, 0},
+ {"tdnam", "TDNAM", NULL, "terminal-device-name", LJUST, tdnam, 0, CHAR,
+ NULL, 0},
+ {"time", "TIME", NULL, "cpu-time", USER, cputime, 0, CHAR, NULL, 0},
+ {"tpgid", "TPGID", NULL, "terminal-process-gid", 0, kvar,
+ KOFF(ki_tpgid), UINT, PIDFMT, 0},
+ {"tracer", "TRACER", NULL, "tracer", 0, kvar, KOFF(ki_tracer), UINT,
+ PIDFMT, 0},
+ {"tsid", "TSID", NULL, "terminal-sid", 0, kvar, KOFF(ki_tsid), UINT,
+ PIDFMT, 0},
+ {"tsiz", "TSIZ", NULL, "text-size", 0, kvar, KOFF(ki_tsize), PGTOK,
+ "ld", 0},
+ {"tt", "TT ", NULL, "terminal-name", 0, tname, 0, CHAR, NULL, 0},
+ {"tty", "TTY", NULL, "tty", LJUST, longtname, 0, CHAR, NULL, 0},
+ {"ucomm", "UCOMM", NULL, "accounting-name", LJUST, ucomm, 0, CHAR,
+ NULL, 0},
+ {"uid", "UID", NULL, "uid", 0, kvar, KOFF(ki_uid), UINT, UIDFMT, 0},
+ {"upr", "UPR", NULL, "user-priority", 0, upr, 0, CHAR, NULL, 0},
+ {"uprocp", "UPROCP", NULL, "process-address", 0, kvar, KOFF(ki_paddr),
+ KPTR, "lx", 0},
+ {"user", "USER", NULL, "user", LJUST, uname, 0, CHAR, NULL, 0},
+ {"usertime", "USERTIME", NULL, "user-time", USER, usertime, 0, CHAR,
+ NULL, 0},
+ {"usrpri", "", "upr", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"vsize", "", "vsz", NULL, 0, NULL, 0, CHAR, NULL, 0},
+ {"vsz", "VSZ", NULL, "virtual-size", 0, vsize, 0, CHAR, NULL, 0},
+ {"wchan", "WCHAN", NULL, "wait-channel", LJUST, wchan, 0, CHAR, NULL,
+ 0},
+ {"xstat", "XSTAT", NULL, "exit-status", 0, kvar, KOFF(ki_xstat),
+ USHORT, "x", 0},
+ {"", NULL, NULL, NULL, 0, NULL, 0, CHAR, NULL, 0},
};
void
@@ -185,16 +240,19 @@ showkey(void)
i = 0;
sep = "";
+ xo_open_list("key");
for (v = var; *(p = v->name); ++v) {
int len = strlen(p);
if (termwidth && (i += len + 1) > termwidth) {
i = len;
sep = "\n";
}
- (void) printf("%s%s", sep, p);
+ xo_emit("{P:/%s}{l:key/%s}", sep, p);
sep = " ";
}
- (void) printf("\n");
+ xo_emit("\n");
+ xo_close_list("key");
+ xo_finish();
}
void
diff --git a/bin/ps/print.c b/bin/ps/print.c
index 40ecd07..91daa44 100644
--- a/bin/ps/print.c
+++ b/bin/ps/print.c
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
#include <vis.h>
+#include <libxo/xo.h>
#include "ps.h"
@@ -85,15 +86,15 @@ printheader(void)
v = vent->var;
if (v->flag & LJUST) {
if (STAILQ_NEXT(vent, next_ve) == NULL) /* last one */
- (void)printf("%s", vent->header);
+ xo_emit("{T:/%s}", vent->header);
else
- (void)printf("%-*s", v->width, vent->header);
+ xo_emit("{T:/%-*s}", v->width, vent->header);
} else
- (void)printf("%*s", v->width, vent->header);
+ xo_emit("{T:/%*s}", v->width, vent->header);
if (STAILQ_NEXT(vent, next_ve) != NULL)
- (void)putchar(' ');
+ xo_emit("{P: }");
}
- (void)putchar('\n');
+ xo_emit("\n");
}
char *
@@ -102,7 +103,7 @@ arguments(KINFO *k, VARENT *ve)
char *vis_args;
if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH);
if (STAILQ_NEXT(ve, next_ve) != NULL && strlen(vis_args) > ARGUMENTS_WIDTH)
@@ -130,7 +131,7 @@ command(KINFO *k, VARENT *ve)
return (str);
}
if ((vis_args = malloc(strlen(k->ki_args) * 4 + 1)) == NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH);
if (STAILQ_NEXT(ve, next_ve) == NULL) {
@@ -139,7 +140,7 @@ command(KINFO *k, VARENT *ve)
if (k->ki_env) {
if ((vis_env = malloc(strlen(k->ki_env) * 4 + 1))
== NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
strvis(vis_env, k->ki_env,
VIS_TAB | VIS_NL | VIS_NOSLASH);
} else
@@ -215,7 +216,7 @@ state(KINFO *k, VARENT *ve __unused)
buf = malloc(16);
if (buf == NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
flag = k->ki_p->ki_flag;
tdflags = k->ki_p->ki_tdflags; /* XXXKSE */
@@ -391,7 +392,7 @@ started(KINFO *k, VARENT *ve __unused)
buf = malloc(buflen);
if (buf == NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
then = k->ki_p->ki_start.tv_sec;
tp = localtime(&then);
@@ -416,7 +417,7 @@ lstarted(KINFO *k, VARENT *ve __unused)
buf = malloc(buflen);
if (buf == NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
then = k->ki_p->ki_start.tv_sec;
(void)strftime(buf, buflen, "%c", localtime(&then));
@@ -762,7 +763,7 @@ printval(void *bp, VAR *v)
(void)asprintf(&str, ofmt, ps_pgtok(*(u_long *)bp));
break;
default:
- errx(1, "unknown type %d", v->type);
+ xo_errx(1, "unknown type %d", v->type);
}
return (str);
@@ -804,7 +805,7 @@ label(KINFO *k, VARENT *ve __unused)
string = NULL;
if (mac_prepare_process_label(&proclabel) == -1) {
- warn("mac_prepare_process_label");
+ xo_warn("mac_prepare_process_label");
goto out;
}
error = mac_get_pid(k->ki_p->ki_pid, proclabel);
diff --git a/bin/ps/ps.1 b/bin/ps/ps.1
index 6eead76..369e1d7 100644
--- a/bin/ps/ps.1
+++ b/bin/ps/ps.1
@@ -29,7 +29,7 @@
.\" @(#)ps.1 8.3 (Berkeley) 4/18/94
.\" $FreeBSD$
.\"
-.Dd December 9, 2014
+.Dd May 22, 2015
.Dt PS 1
.Os
.Sh NAME
@@ -37,6 +37,7 @@
.Nd process status
.Sh SYNOPSIS
.Nm
+.Op Fl -libxo
.Op Fl aCcdefHhjlmrSTuvwXxZ
.Op Fl O Ar fmt | Fl o Ar fmt
.Op Fl G Ar gid Ns Op , Ns Ar gid Ns Ar ...
@@ -47,6 +48,7 @@
.Op Fl t Ar tty Ns Op , Ns Ar tty Ns Ar ...
.Op Fl U Ar user Ns Op , Ns Ar user Ns Ar ...
.Nm
+.Op Fl -libxo
.Op Fl L
.Sh DESCRIPTION
The
@@ -733,7 +735,9 @@ Display information on all system processes:
.Xr procstat 1 ,
.Xr w 1 ,
.Xr kvm 3 ,
+.Xr libxo 3
.Xr strftime 3 ,
+.Xr xo_parse_args 3
.Xr mac 4 ,
.Xr procfs 5 ,
.Xr pstat 8 ,
diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index 449367c..0e5dd56 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <libxo/xo.h>
#include "ps.h"
@@ -184,7 +185,9 @@ main(int argc, char *argv[])
int all, ch, elem, flag, _fmt, i, lineno, linelen, left;
int descendancy, nentries, nkept, nselectors;
int prtheader, wflag, what, xkeep, xkeep_implied;
+ int fwidthmin, fwidthmax;
char errbuf[_POSIX2_LINE_MAX];
+ char fmtbuf[_POSIX2_LINE_MAX];
(void) setlocale(LC_ALL, "");
time(&now); /* Used by routines in print.c. */
@@ -221,6 +224,11 @@ main(int argc, char *argv[])
init_list(&uidlist, addelem_uid, sizeof(uid_t), "user");
memf = _PATH_DEVNULL;
nlistf = NULL;
+
+ argc = xo_parse_args(argc, argv);
+ if (argc < 0)
+ exit(1);
+
while ((ch = getopt(argc, argv, PS_ARGS)) != -1)
switch (ch) {
case 'A':
@@ -363,7 +371,7 @@ main(int argc, char *argv[])
#endif
case 'T':
if ((optarg = ttyname(STDIN_FILENO)) == NULL)
- errx(1, "stdin: not a terminal");
+ xo_errx(1, "stdin: not a terminal");
/* FALLTHROUGH */
case 't':
add_list(&ttylist, optarg);
@@ -434,8 +442,7 @@ main(int argc, char *argv[])
argv++;
}
if (*argv) {
- fprintf(stderr, "%s: illegal argument: %s\n",
- getprogname(), *argv);
+ xo_warnx("illegal argument: %s\n", *argv);
usage();
}
if (optfatal)
@@ -445,7 +452,7 @@ main(int argc, char *argv[])
kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
if (kd == 0)
- errx(1, "%s", errbuf);
+ xo_errx(1, "%s", errbuf);
if (!_fmt)
parsefmt(dfmt, 0);
@@ -453,7 +460,7 @@ main(int argc, char *argv[])
if (nselectors == 0) {
uidlist.l.ptr = malloc(sizeof(uid_t));
if (uidlist.l.ptr == NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
nselectors = 1;
uidlist.count = uidlist.maxcount = 1;
*uidlist.l.uids = getuid();
@@ -515,11 +522,11 @@ main(int argc, char *argv[])
nentries = -1;
kp = kvm_getprocs(kd, what, flag, &nentries);
if ((kp == NULL && nentries > 0) || (kp != NULL && nentries < 0))
- errx(1, "%s", kvm_geterr(kd));
+ xo_errx(1, "%s", kvm_geterr(kd));
nkept = 0;
if (nentries > 0) {
if ((kinfo = malloc(nentries * sizeof(*kinfo))) == NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
for (i = nentries; --i >= 0; ++kp) {
/*
* If the user specified multiple selection-criteria,
@@ -629,13 +636,18 @@ main(int argc, char *argv[])
/*
* Print header.
*/
+ xo_open_container("process-information");
printheader();
+ if (xo_get_style(NULL) != XO_STYLE_TEXT)
+ termwidth = UNLIMITED;
/*
* Output formatted lines.
*/
+ xo_open_list("process");
for (i = lineno = 0; i < nkept; i++) {
linelen = 0;
+ xo_open_instance("process");
STAILQ_FOREACH(vent, &varlist, next_ve) {
if (vent->var->flag & LJUST)
fmtstr = "%-*s";
@@ -645,21 +657,27 @@ main(int argc, char *argv[])
ks = STAILQ_FIRST(&kinfo[i].ki_ks);
STAILQ_REMOVE_HEAD(&kinfo[i].ki_ks, ks_next);
/* Truncate rightmost column if necessary. */
+ fwidthmax = _POSIX2_LINE_MAX;
if (STAILQ_NEXT(vent, next_ve) == NULL &&
termwidth != UNLIMITED && ks->ks_str != NULL) {
left = termwidth - linelen;
if (left > 0 && left < (int)strlen(ks->ks_str))
- ks->ks_str[left] = '\0';
+ fwidthmax = left;
}
+
str = ks->ks_str;
if (str == NULL)
str = "-";
/* No padding for the last column, if it's LJUST. */
- if (STAILQ_NEXT(vent, next_ve) == NULL &&
- vent->var->flag & LJUST)
- linelen += printf(fmtstr, 0, str);
- else
- linelen += printf(fmtstr, vent->var->width, str);
+ fwidthmin = (xo_get_style(NULL) != XO_STYLE_TEXT ||
+ (STAILQ_NEXT(vent, next_ve) == NULL &&
+ (vent->var->flag & LJUST))) ? 0 : vent->var->width;
+ snprintf(fmtbuf, sizeof(fmtbuf), "{:%s/%%%s%d..%ds}",
+ vent->var->field ?: vent->var->name,
+ (vent->var->flag & LJUST) ? "-" : "",
+ fwidthmin, fwidthmax);
+ xo_emit(fmtbuf, str);
+ linelen += fwidthmin;
if (ks->ks_str != NULL) {
free(ks->ks_str);
@@ -669,17 +687,22 @@ main(int argc, char *argv[])
ks = NULL;
if (STAILQ_NEXT(vent, next_ve) != NULL) {
- (void)putchar(' ');
+ xo_emit("{P: }");
linelen++;
}
}
- (void)putchar('\n');
+ xo_emit("\n");
+ xo_close_instance("process");
if (prtheader && lineno++ == prtheader - 4) {
- (void)putchar('\n');
+ xo_emit("\n");
printheader();
lineno = 0;
}
}
+ xo_close_list("process");
+ xo_close_container("process-information");
+ xo_finish();
+
free_list(&gidlist);
free_list(&jidlist);
free_list(&pidlist);
@@ -705,9 +728,9 @@ addelem_gid(struct listinfo *inf, const char *elem)
if (*elem == '\0' || strlen(elem) >= MAXLOGNAME) {
if (*elem == '\0')
- warnx("Invalid (zero-length) %s name", inf->lname);
+ xo_warnx("Invalid (zero-length) %s name", inf->lname);
else
- warnx("%s name too long: %s", inf->lname, elem);
+ xo_warnx("%s name too long: %s", inf->lname, elem);
optfatal = 1;
return (0); /* Do not add this value. */
}
@@ -732,7 +755,7 @@ addelem_gid(struct listinfo *inf, const char *elem)
if (grp == NULL)
grp = getgrnam(elem);
if (grp == NULL) {
- warnx("No %s %s '%s'", inf->lname, nameorID, elem);
+ xo_warnx("No %s %s '%s'", inf->lname, nameorID, elem);
optfatal = 1;
return (0);
}
@@ -773,7 +796,7 @@ addelem_pid(struct listinfo *inf, const char *elem)
long tempid;
if (*elem == '\0') {
- warnx("Invalid (zero-length) process id");
+ xo_warnx("Invalid (zero-length) process id");
optfatal = 1;
return (0); /* Do not add this value. */
}
@@ -781,10 +804,10 @@ addelem_pid(struct listinfo *inf, const char *elem)
errno = 0;
tempid = strtol(elem, &endp, 10);
if (*endp != '\0' || tempid < 0 || elem == endp) {
- warnx("Invalid %s: %s", inf->lname, elem);
+ xo_warnx("Invalid %s: %s", inf->lname, elem);
errno = ERANGE;
} else if (errno != 0 || tempid > pid_max) {
- warnx("%s too large: %s", inf->lname, elem);
+ xo_warnx("%s too large: %s", inf->lname, elem);
errno = ERANGE;
}
if (errno == ERANGE) {
@@ -855,19 +878,19 @@ addelem_tty(struct listinfo *inf, const char *elem)
if (ttypath) {
if (stat(ttypath, &sb) == -1) {
if (pathbuf3[0] != '\0')
- warn("%s, %s, and %s", pathbuf3, pathbuf2,
+ xo_warn("%s, %s, and %s", pathbuf3, pathbuf2,
ttypath);
else
- warn("%s", ttypath);
+ xo_warn("%s", ttypath);
optfatal = 1;
return (0);
}
if (!S_ISCHR(sb.st_mode)) {
if (pathbuf3[0] != '\0')
- warnx("%s, %s, and %s: Not a terminal",
+ xo_warnx("%s, %s, and %s: Not a terminal",
pathbuf3, pathbuf2, ttypath);
else
- warnx("%s: Not a terminal", ttypath);
+ xo_warnx("%s: Not a terminal", ttypath);
optfatal = 1;
return (0);
}
@@ -887,9 +910,9 @@ addelem_uid(struct listinfo *inf, const char *elem)
if (*elem == '\0' || strlen(elem) >= MAXLOGNAME) {
if (*elem == '\0')
- warnx("Invalid (zero-length) %s name", inf->lname);
+ xo_warnx("Invalid (zero-length) %s name", inf->lname);
else
- warnx("%s name too long: %s", inf->lname, elem);
+ xo_warnx("%s name too long: %s", inf->lname, elem);
optfatal = 1;
return (0); /* Do not add this value. */
}
@@ -899,12 +922,12 @@ addelem_uid(struct listinfo *inf, const char *elem)
errno = 0;
bigtemp = strtoul(elem, &endp, 10);
if (errno != 0 || *endp != '\0' || bigtemp > UID_MAX)
- warnx("No %s named '%s'", inf->lname, elem);
+ xo_warnx("No %s named '%s'", inf->lname, elem);
else {
/* The string is all digits, so it might be a userID. */
pwd = getpwuid((uid_t)bigtemp);
if (pwd == NULL)
- warnx("No %s name or ID matches '%s'",
+ xo_warnx("No %s name or ID matches '%s'",
inf->lname, elem);
}
}
@@ -961,7 +984,7 @@ add_list(struct listinfo *inf, const char *argp)
while (*argp != '\0' && strchr(W_SEP T_SEP,
*argp) == NULL)
argp++;
- warnx("Value too long: %.*s", (int)(argp - savep),
+ xo_warnx("Value too long: %.*s", (int)(argp - savep),
savep);
optfatal = 1;
}
@@ -1062,7 +1085,7 @@ descendant_sort(KINFO *ki, int items)
continue;
}
if ((ki[src].ki_d.prefix = malloc(lvl * 2 + 1)) == NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
for (n = 0; n < lvl - 2; n++) {
ki[src].ki_d.prefix[n * 2] =
path[n / 8] & 1 << (n % 8) ? '|' : ' ';
@@ -1100,7 +1123,7 @@ expand_list(struct listinfo *inf)
newlist = realloc(inf->l.ptr, newmax * inf->elemsize);
if (newlist == NULL) {
free(inf->l.ptr);
- errx(1, "realloc to %d %ss failed", newmax, inf->lname);
+ xo_errx(1, "realloc to %d %ss failed", newmax, inf->lname);
}
inf->maxcount = newmax;
inf->l.ptr = newlist;
@@ -1174,7 +1197,7 @@ format_output(KINFO *ki)
str = (v->oproc)(ki, vent);
ks = malloc(sizeof(*ks));
if (ks == NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
ks->ks_str = str;
STAILQ_INSERT_TAIL(&ki->ki_ks, ks, ks_next);
if (str != NULL) {
@@ -1240,7 +1263,7 @@ saveuser(KINFO *ki)
else
asprintf(&ki->ki_args, "(%s)", ki->ki_p->ki_comm);
if (ki->ki_args == NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
} else {
ki->ki_args = NULL;
}
@@ -1251,7 +1274,7 @@ saveuser(KINFO *ki)
else
ki->ki_env = strdup("()");
if (ki->ki_env == NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
} else {
ki->ki_env = NULL;
}
@@ -1372,7 +1395,7 @@ kludge_oldps_options(const char *optlist, char *origval, const char *nextarg)
* original value.
*/
if ((newopts = ns = malloc(len + 3)) == NULL)
- errx(1, "malloc failed");
+ xo_errx(1, "malloc failed");
if (*origval != '-')
*ns++ = '-'; /* add option flag */
@@ -1401,7 +1424,7 @@ pidmax_init(void)
intsize = sizeof(pid_max);
if (sysctlbyname("kern.pid_max", &pid_max, &intsize, NULL, 0) < 0) {
- warn("unable to read kern.pid_max");
+ xo_warn("unable to read kern.pid_max");
pid_max = 99999;
}
}
@@ -1411,7 +1434,7 @@ usage(void)
{
#define SINGLE_OPTS "[-aCcde" OPT_LAZY_f "HhjlmrSTuvwXxZ]"
- (void)fprintf(stderr, "%s\n%s\n%s\n%s\n",
+ (void)xo_error("%s\n%s\n%s\n%s\n",
"usage: ps " SINGLE_OPTS " [-O fmt | -o fmt] [-G gid[,gid...]]",
" [-J jid[,jid...]] [-M core] [-N system]",
" [-p pid[,pid...]] [-t tty[,tty...]] [-U user[,user...]]",
diff --git a/bin/ps/ps.h b/bin/ps/ps.h
index 86aaeb0..314fbf2 100644
--- a/bin/ps/ps.h
+++ b/bin/ps/ps.h
@@ -65,6 +65,7 @@ typedef struct var {
const char *name; /* name(s) of variable */
const char *header; /* default header */
const char *alias; /* aliases */
+ const char *field; /* xo field name */
#define COMM 0x01 /* needs exec arguments and environment (XXX) */
#define LJUST 0x02 /* left adjust on output (trailing blanks) */
#define USER 0x04 /* needs user structure */
diff --git a/cddl/contrib/opensolaris/common/ctf/ctf_create.c b/cddl/contrib/opensolaris/common/ctf/ctf_create.c
index 1c0988a..a2ca819 100644
--- a/cddl/contrib/opensolaris/common/ctf/ctf_create.c
+++ b/cddl/contrib/opensolaris/common/ctf/ctf_create.c
@@ -1328,15 +1328,28 @@ ctf_add_type(ctf_file_t *dst_fp, ctf_file_t *src_fp, ctf_id_t src_type)
* we are looking for. This is necessary to permit ctf_add_type() to
* operate recursively on entities such as a struct that contains a
* pointer member that refers to the same struct type.
+ *
+ * In the case of integer and floating point types, we match using the
+ * type encoding as well - else we may incorrectly return a bitfield
+ * type, for instance.
*/
if (dst_type == CTF_ERR && name[0] != '\0') {
for (dtd = ctf_list_prev(&dst_fp->ctf_dtdefs); dtd != NULL &&
CTF_TYPE_TO_INDEX(dtd->dtd_type) > dst_fp->ctf_dtoldid;
dtd = ctf_list_prev(dtd)) {
- if (CTF_INFO_KIND(dtd->dtd_data.ctt_info) == kind &&
- dtd->dtd_name != NULL &&
- strcmp(dtd->dtd_name, name) == 0)
- return (dtd->dtd_type);
+ if (CTF_INFO_KIND(dtd->dtd_data.ctt_info) != kind ||
+ dtd->dtd_name == NULL ||
+ strcmp(dtd->dtd_name, name) != 0)
+ continue;
+ if (kind == CTF_K_INTEGER || kind == CTF_K_FLOAT) {
+ if (ctf_type_encoding(src_fp, src_type,
+ &src_en) != 0)
+ continue;
+ if (bcmp(&src_en, &dtd->dtd_u.dtu_enc,
+ sizeof (ctf_encoding_t)) != 0)
+ continue;
+ }
+ return (dtd->dtd_type);
}
}
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l
index 925f8a5..192e1e2 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_lex.l
@@ -743,6 +743,7 @@ yyinit(dt_pcb_t *pcb)
#ifdef illumos
yysptr = yysbuf;
#endif
+ YY_FLUSH_BUFFER;
}
/*
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
index eaf0961..f9b9625 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
@@ -1785,17 +1785,11 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
"failed to open %s: %s", file, strerror(errno)));
}
#else
- if (dtp->dt_lazyload) {
- if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0666)) < 0)
- return (dt_link_error(dtp, NULL, -1, NULL,
- "failed to open %s: %s", file, strerror(errno)));
- } else {
- snprintf(tfile, sizeof(tfile), "%s.XXXXXX", file);
- if ((fd = mkstemp(tfile)) == -1)
- return (dt_link_error(dtp, NULL, -1, NULL,
- "failed to create temporary file %s: %s",
- tfile, strerror(errno)));
- }
+ snprintf(tfile, sizeof(tfile), "%s.XXXXXX", file);
+ if ((fd = mkostemp(tfile, O_CLOEXEC)) == -1)
+ return (dt_link_error(dtp, NULL, -1, NULL,
+ "failed to create temporary file %s: %s",
+ tfile, strerror(errno)));
#endif
/*
@@ -1868,23 +1862,9 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
(void) snprintf(cmd, len, fmt, dtp->dt_ld_path, file, fd, drti);
#else
const char *fmt = "%s -o %s -r %s %s";
+ dt_dirpath_t *dp = dt_list_next(&dtp->dt_lib_path);
-#if defined(__amd64__)
- /*
- * Arches which default to 64-bit need to explicitly use
- * the 32-bit library path.
- */
- int use_32 = (dtp->dt_oflags & DTRACE_O_ILP32);
-#else
- /*
- * Arches which are 32-bit only just use the normal
- * library path.
- */
- int use_32 = 0;
-#endif
-
- (void) snprintf(drti, sizeof (drti), "/usr/lib%s/dtrace/drti.o",
- use_32 ? "32" : "");
+ (void) snprintf(drti, sizeof (drti), "%s/drti.o", dp->dir_path);
len = snprintf(&tmp, 1, fmt, dtp->dt_ld_path, file, tfile,
drti) + 1;
@@ -1951,14 +1931,23 @@ dtrace_program_link(dtrace_hdl_t *dtp, dtrace_prog_t *pgp, uint_t dflags,
}
#endif
} else {
+#ifdef __FreeBSD__
+ if (rename(tfile, file) != 0) {
+ ret = dt_link_error(dtp, NULL, fd, NULL,
+ "failed to rename %s to %s: %s", tfile, file,
+ strerror(errno));
+ goto done;
+ }
+#endif
(void) close(fd);
}
done:
dtrace_dof_destroy(dtp, dof);
-#ifndef illumos
- unlink(tfile);
+#ifdef __FreeBSD__
+ if (!dtp->dt_lazyload)
+ (void) unlink(tfile);
#endif
return (ret);
}
diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
index c952243..80e4be9 100644
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
@@ -792,6 +792,7 @@ const char *_dtrace_libdir = "/usr/lib/dtrace"; /* default library directory */
#ifdef illumos
const char *_dtrace_provdir = "/dev/dtrace/provider"; /* provider directory */
#else
+const char *_dtrace_libdir32 = "/usr/lib32/dtrace";
const char *_dtrace_provdir = "/dev/dtrace"; /* provider directory */
#endif
@@ -1581,8 +1582,19 @@ alloc:
* compile, and to provide better error reporting (because the full
* reporting of compiler errors requires dtrace_open() to succeed).
*/
+#ifdef __FreeBSD__
+#ifdef __LP64__
+ if ((dtp->dt_oflags & DTRACE_O_ILP32) != 0) {
+ if (dtrace_setopt(dtp, "libdir", _dtrace_libdir32) != 0)
+ return (set_open_errno(dtp, errp, dtp->dt_errno));
+ }
+#endif
if (dtrace_setopt(dtp, "libdir", _dtrace_libdir) != 0)
return (set_open_errno(dtp, errp, dtp->dt_errno));
+#else
+ if (dtrace_setopt(dtp, "libdir", _dtrace_libdir) != 0)
+ return (set_open_errno(dtp, errp, dtp->dt_errno));
+#endif
return (dtp);
}
diff --git a/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c b/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c
index 7a265bd..7ad5141 100644
--- a/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c
+++ b/cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c
@@ -793,6 +793,7 @@ dump_nvlist(nvlist_t *list, int indent)
{
nvpair_t *elem = NULL;
boolean_t bool_value;
+ boolean_t *bool_array_value;
nvlist_t *nvlist_value;
nvlist_t **nvlist_array_value;
uint_t i, count;
@@ -853,6 +854,16 @@ dump_nvlist(nvlist_t *list, int indent)
NVP(elem, string, char *, char *, "'%s'");
break;
+ case DATA_TYPE_BOOLEAN_ARRAY:
+ (void) nvpair_value_boolean_array(elem,
+ &bool_array_value, &count);
+ for (i = 0; i < count; i++) {
+ (void) printf("%*s%s[%d]: %s\n", indent, "",
+ nvpair_name(elem), i,
+ bool_array_value[i] ? "true" : "false");
+ }
+ break;
+
case DATA_TYPE_BYTE_ARRAY:
NVPA(elem, byte_array, uchar_t, int, "%u");
break;
diff --git a/cddl/lib/Makefile b/cddl/lib/Makefile
index 955103e..48a77ab 100644
--- a/cddl/lib/Makefile
+++ b/cddl/lib/Makefile
@@ -33,4 +33,11 @@ _drti= drti
_libdtrace= libdtrace
.endif
+SUBDIR_DEPEND_libdtrace= libctf
+SUBDIR_DEPEND_libzfs_core= libnvpair
+SUBDIR_DEPEND_libzfs= libavl libnvpair libumem libuutil libzfs_core
+SUBDIR_DEPEND_libzpool= libavl libnvpair libumem
+
+SUBDIR_PARALLEL=
+
.include <bsd.subdir.mk>
diff --git a/cddl/lib/libdtrace/Makefile b/cddl/lib/libdtrace/Makefile
index 7678db6..128ccf5 100644
--- a/cddl/lib/libdtrace/Makefile
+++ b/cddl/lib/libdtrace/Makefile
@@ -50,6 +50,7 @@ DSRCS= errno.d \
io.d \
ip.d \
psinfo.d \
+ siftr.d \
signal.d \
tcp.d \
udp.d \
@@ -103,6 +104,8 @@ LFLAGS+=-l
YFLAGS+=-d
+LIBADD= ctf elf proc pthread rtld_db
+
CLEANFILES= dt_errtags.c dt_names.c
dt_errtags.c:
diff --git a/cddl/lib/libdtrace/siftr.d b/cddl/lib/libdtrace/siftr.d
new file mode 100644
index 0000000..a6ff844
--- /dev/null
+++ b/cddl/lib/libdtrace/siftr.d
@@ -0,0 +1,100 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (the "License").
+ * You may not use this file except in compliance with the License.
+ *
+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+ * If applicable, add the following below this CDDL HEADER, with the
+ * fields enclosed by brackets "[]" replaced with your own identifying
+ * information: Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ * $FreeBSD$
+ */
+
+#pragma D depends_on module siftr
+#pragma D depends_on provider tcp
+
+/*
+ * Convert a SIFTR direction value to a string
+ */
+#pragma D binding "1.12.1" SIFTR_IN
+inline int SIFTR_IN = 1;
+#pragma D binding "1.12.1" SIFTR_OUT
+inline int SIFTR_OUT = 2;
+
+/* SIFTR direction strings. */
+#pragma D binding "1.12.1" siftr_dir_string
+inline string siftr_dir_string[uint8_t direction] =
+ direction == SIFTR_IN ? "in" :
+ direction == SIFTR_OUT ? "out" :
+ "unknown" ;
+
+typedef struct siftrinfo {
+ struct timeval tval;
+ uint8_t direction;
+ uint8_t ipver;
+ uint32_t hash;
+ uint16_t tcp_localport;
+ uint16_t tcp_foreignport;
+ uint64_t snd_cwnd;
+ u_long snd_wnd;
+ u_long rcv_wnd;
+ u_long snd_bwnd;
+ u_long snd_ssthresh;
+ int conn_state;
+ u_int max_seg_size;
+ int smoothed_rtt;
+ u_char sack_enabled;
+ u_char snd_scale;
+ u_char rcv_scale;
+ u_int flags;
+ int rxt_length;
+ u_int snd_buf_hiwater;
+ u_int snd_buf_cc;
+ u_int rcv_buf_hiwater;
+ u_int rcv_buf_cc;
+ u_int sent_inflight_bytes;
+ int t_segqlen;
+ u_int flowid;
+ u_int flowtype;
+} siftrinfo_t;
+
+#pragma D binding "1.12.1" translator
+translator siftrinfo_t < struct pkt_node *p > {
+ direction = p == NULL ? 0 : p->direction;
+ ipver = p == NULL ? 0 : p->ipver;
+ hash = p == NULL ? 0 : p->hash;
+ tcp_localport = p == NULL ? 0 : ntohs(p->tcp_localport);
+ tcp_foreignport = p == NULL ? 0 : ntohs(p->tcp_foreignport);
+ snd_cwnd = p == NULL ? 0 : p->snd_cwnd;
+ snd_wnd = p == NULL ? 0 : p->snd_wnd;
+ rcv_wnd = p == NULL ? 0 : p->rcv_wnd;
+ snd_bwnd = p == NULL ? 0 : p->snd_bwnd;
+ snd_ssthresh = p == NULL ? 0 : p->snd_ssthresh;
+ conn_state = p == NULL ? 0 : p->conn_state;
+ max_seg_size = p == NULL ? 0 : p->max_seg_size;
+ smoothed_rtt = p == NULL ? 0 : p->smoothed_rtt;
+ sack_enabled = p == NULL ? 0 : p->sack_enabled;
+ snd_scale = p == NULL ? 0 : p->snd_scale;
+ rcv_scale = p == NULL ? 0 : p->rcv_scale;
+ flags = p == NULL ? 0 : p->flags;
+ rxt_length = p == NULL ? 0 : p->rxt_length;
+ snd_buf_hiwater = p == NULL ? 0 : p->snd_buf_hiwater;
+ snd_buf_cc = p == NULL ? 0 : p->snd_buf_cc;
+ rcv_buf_hiwater = p == NULL ? 0 : p->rcv_buf_hiwater;
+ rcv_buf_cc = p == NULL ? 0 : p->rcv_buf_cc;
+ sent_inflight_bytes = p == NULL ? 0 : p->sent_inflight_bytes;
+ t_segqlen = p == NULL ? 0 : p->t_segqlen;
+ flowid = p == NULL ? 0 : p->flowid;
+ flowtype = p == NULL ? 0 : p->flowtype;
+};
diff --git a/cddl/sbin/Makefile b/cddl/sbin/Makefile
index f40f2a4..19daabd 100644
--- a/cddl/sbin/Makefile
+++ b/cddl/sbin/Makefile
@@ -13,4 +13,6 @@ _zfs= zfs
_zpool= zpool
.endif
+SUBDIR_PARALLEL=
+
.include <bsd.subdir.mk>
diff --git a/cddl/usr.bin/Makefile b/cddl/usr.bin/Makefile
index 533697d..69179c5 100644
--- a/cddl/usr.bin/Makefile
+++ b/cddl/usr.bin/Makefile
@@ -26,4 +26,6 @@ _zstreamdump = zstreamdump
.endif
.endif
+SUBDIR_PARALLEL=
+
.include <bsd.subdir.mk>
diff --git a/cddl/usr.bin/ctfconvert/Makefile b/cddl/usr.bin/ctfconvert/Makefile
index f50cecb..b1dd8a2 100644
--- a/cddl/usr.bin/ctfconvert/Makefile
+++ b/cddl/usr.bin/ctfconvert/Makefile
@@ -3,8 +3,6 @@
.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/tools/ctf/common
.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/tools/ctf/cvt
-DEBUG_FLAGS= -g
-
PROG= ctfconvert
SRCS= alist.c \
ctf.c \
@@ -36,7 +34,6 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
-I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt \
-I${OPENSOLARIS_SYS_DISTDIR}/uts/common
-DPADD= ${LIBDWARF} ${LIBELF} ${LIBZ} ${LIBPTHREAD}
-LDADD= -ldwarf -lelf -lz -lpthread
+LIBADD= dwarf elf z pthread
.include <bsd.prog.mk>
diff --git a/cddl/usr.bin/ctfdump/Makefile b/cddl/usr.bin/ctfdump/Makefile
index e87e7a0..74adad2 100644
--- a/cddl/usr.bin/ctfdump/Makefile
+++ b/cddl/usr.bin/ctfdump/Makefile
@@ -17,7 +17,6 @@ CFLAGS+= -I${OPENSOLARIS_USR_DISTDIR} \
-I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/common \
-I${OPENSOLARIS_SYS_DISTDIR}/uts/common
-DPADD= ${LIBPTHREAD} ${LIBELF} ${LIBZ}
-LDADD= -lpthread -lelf -lz
+LIBADD= elf z
.include <bsd.prog.mk>
diff --git a/cddl/usr.sbin/Makefile b/cddl/usr.sbin/Makefile
index 73315ff..d309075 100644
--- a/cddl/usr.sbin/Makefile
+++ b/cddl/usr.sbin/Makefile
@@ -46,4 +46,6 @@ _dtruss= dtruss
_lockstat= lockstat
.endif
+SUBDIR_PARALLEL=
+
.include <bsd.subdir.mk>
diff --git a/cddl/usr.sbin/dtrace/Makefile b/cddl/usr.sbin/dtrace/Makefile
index dfccf88..8c5e3ab 100644
--- a/cddl/usr.sbin/dtrace/Makefile
+++ b/cddl/usr.sbin/dtrace/Makefile
@@ -20,9 +20,6 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
#CFLAGS+= -DNEED_ERRLOC
#YFLAGS+= -d
-DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBL} ${LIBPROC} \
- ${LIBCTF} ${LIBELF} ${LIBZ} ${LIBUTIL} ${LIBRTLD_DB}
-LDADD= -lpthread -ldtrace -ly -ll -lproc -lctf -lelf -lz -lutil \
- -lrtld_db
+LIBADD= dtrace
.include <bsd.prog.mk>
diff --git a/cddl/usr.sbin/dtrace/tests/tools/exclude.sh b/cddl/usr.sbin/dtrace/tests/tools/exclude.sh
index a42773d..33c9efc 100755
--- a/cddl/usr.sbin/dtrace/tests/tools/exclude.sh
+++ b/cddl/usr.sbin/dtrace/tests/tools/exclude.sh
@@ -38,7 +38,6 @@ exclude EXFAIL common/ip/tst.ipv4localudp.ksh
exclude EXFAIL common/mdb/tst.dtracedcmd.ksh
exclude EXFAIL common/misc/tst.dofmax.ksh
exclude EXFAIL common/misc/tst.include.ksh
-exclude EXFAIL common/pragma/tst.libchain.ksh
exclude EXFAIL common/safety/tst.copyin2.d
exclude EXFAIL common/safety/tst.msgdsize.d
exclude EXFAIL common/safety/tst.msgsize.d
diff --git a/cddl/usr.sbin/lockstat/Makefile b/cddl/usr.sbin/lockstat/Makefile
index 0668758..a4eb898 100644
--- a/cddl/usr.sbin/lockstat/Makefile
+++ b/cddl/usr.sbin/lockstat/Makefile
@@ -21,10 +21,6 @@ CFLAGS+= -DNEED_ERRLOC -g
#YFLAGS+= -d
-DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBL} ${LIBPROC} \
- ${LIBCTF} ${LIBELF} ${LIBZ} ${LIBRT} ${LIBUTIL} \
- ${LIBRTLD_DB}
-LDADD= -lpthread -ldtrace -ly -ll -lproc -lctf -lelf -lz -lrt -lutil \
- -lrtld_db
+LIBADD= elf dtrace rt
.include <bsd.prog.mk>
diff --git a/cddl/usr.sbin/plockstat/Makefile b/cddl/usr.sbin/plockstat/Makefile
index 05929589..fc10b56 100644
--- a/cddl/usr.sbin/plockstat/Makefile
+++ b/cddl/usr.sbin/plockstat/Makefile
@@ -18,9 +18,6 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \
-I${.CURDIR}/../../../cddl/lib/libdtrace \
-I${.CURDIR}/../../../sys
-DPADD= ${LIBPTHREAD} ${LIBDTRACE} ${LIBY} ${LIBL} ${LIBPROC} ${LIBCTF}\
- ${LIBELF} ${LIBZ} ${LIBRT} ${LIBRTLD_DB} ${LIBUTIL}
-LDADD= -lpthread -ldtrace -ly -ll -lproc -lctf -lelf -lz -lrt \
- -lrtld_db -lutil
+LIBADD= dtrace proc
.include <bsd.prog.mk>
diff --git a/contrib/atf/atf-sh/atf_check_test.sh b/contrib/atf/atf-sh/atf_check_test.sh
index 163e905..9e3cfb9 100644
--- a/contrib/atf/atf-sh/atf_check_test.sh
+++ b/contrib/atf/atf-sh/atf_check_test.sh
@@ -164,18 +164,22 @@ equal_body()
grep '^failed: \${x} != \${y} (a != b)$' resfile
}
-atf_test_case flush_stdout_on_timeout
-flush_stdout_on_timeout_body()
+atf_test_case flush_stdout_on_death
+flush_stdout_on_death_body()
{
- "$(atf_get_srcdir)/misc_helpers" -s "$(atf_get_srcdir)" atf_check_timeout \
- >out 2>err &
+ CONTROL_FILE="$(pwd)/done" "$(atf_get_srcdir)/misc_helpers" \
+ -s "$(atf_get_srcdir)" atf_check_flush_stdout >out 2>err &
pid="${!}"
- sleep 1
- kill "${pid}"
+ while [ ! -f ./done ]; do
+ echo "Still waiting for helper to create control file"
+ ls
+ sleep 1
+ done
+ kill -9 "${pid}"
grep 'Executing command.*true' out \
|| atf_fail 'First command not in output'
- grep 'Executing command.*sleep 42' out \
+ grep 'Executing command.*false' out \
|| atf_fail 'Second command not in output'
}
@@ -187,7 +191,7 @@ atf_init_test_cases()
atf_add_test_case null_stdout
atf_add_test_case null_stderr
atf_add_test_case equal
- atf_add_test_case flush_stdout_on_timeout
+ atf_add_test_case flush_stdout_on_death
}
# vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4
diff --git a/contrib/atf/atf-sh/misc_helpers.sh b/contrib/atf/atf-sh/misc_helpers.sh
index 62d6580..ca0f465 100644
--- a/contrib/atf/atf-sh/misc_helpers.sh
+++ b/contrib/atf/atf-sh/misc_helpers.sh
@@ -139,16 +139,20 @@ atf_check_equal_eval_fail_body()
atf_check_equal '${x}' '${y}'
}
-atf_test_case atf_check_timeout
-atf_check_timeout_head()
+atf_test_case atf_check_flush_stdout
+atf_check_flush_stdout_head()
{
atf_set "descr" "Helper test case for the t_atf_check test program"
- atf_set "timeout" 1
+ atf_set "timeout" "30"
}
-atf_check_timeout_body()
+atf_check_flush_stdout_body()
{
atf_check true
- atf_check sleep 42
+ atf_check -s exit:1 false
+ touch "${CONTROL_FILE:-done}"
+ while :; do
+ sleep 1
+ done
}
# -------------------------------------------------------------------------
@@ -281,7 +285,7 @@ atf_init_test_cases()
atf_add_test_case atf_check_equal_fail
atf_add_test_case atf_check_equal_eval_ok
atf_add_test_case atf_check_equal_eval_fail
- atf_add_test_case atf_check_timeout
+ atf_add_test_case atf_check_flush_stdout
# Add helper tests for t_config.
atf_add_test_case config_get
diff --git a/contrib/binutils/bfd/elf32-arm.c b/contrib/binutils/bfd/elf32-arm.c
index 4d7b486..ca40eac 100644
--- a/contrib/binutils/bfd/elf32-arm.c
+++ b/contrib/binutils/bfd/elf32-arm.c
@@ -6794,15 +6794,31 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd)
out_attr[Tag_ABI_VFP_args].i = in_attr[Tag_ABI_VFP_args].i;
else if (in_attr[Tag_ABI_FP_number_model].i != 0)
{
+ bfd *hasbfd, *hasnotbfd;
+
+ if (in_attr[Tag_ABI_VFP_args].i)
+ {
+ hasbfd = ibfd;
+ hasnotbfd = obfd;
+ }
+ else
+ {
+ hasbfd = obfd;
+ hasnotbfd = ibfd;
+ }
+
_bfd_error_handler
(_("ERROR: %B uses VFP register arguments, %B does not"),
- ibfd, obfd);
+ hasbfd, hasnotbfd);
return FALSE;
}
}
for (i = 4; i < NUM_KNOWN_OBJ_ATTRIBUTES; i++)
{
+ if (out_attr[i].type == 0)
+ out_attr[i].type = in_attr[i].type;
+
/* Merge this attribute with existing attributes. */
switch (i)
{
@@ -9359,6 +9375,16 @@ elf32_arm_post_process_headers (bfd * abfd, struct bfd_link_info * link_info ATT
if (globals->byteswap_code)
i_ehdrp->e_flags |= EF_ARM_BE8;
}
+
+ /*
+ * For EABI 5, we have to tag dynamic binaries and execs as either
+ * soft float or hard float.
+ */
+ if (EF_ARM_EABI_VERSION (i_ehdrp->e_flags) == EF_ARM_EABI_VER5 &&
+ (i_ehdrp->e_type == ET_DYN || i_ehdrp->e_type == ET_EXEC))
+ i_ehdrp->e_flags |=
+ bfd_elf_get_obj_attr_int (abfd, OBJ_ATTR_PROC, Tag_ABI_VFP_args) ?
+ EF_ARM_VFP_FLOAT : EF_ARM_SOFT_FLOAT;
}
static enum elf_reloc_type_class
diff --git a/contrib/bmake/ChangeLog b/contrib/bmake/ChangeLog
index 2fe7369..f46e95d 100644
--- a/contrib/bmake/ChangeLog
+++ b/contrib/bmake/ChangeLog
@@ -1,3 +1,16 @@
+2015-05-05 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile (MAKE_VERSION): 20150505
+ Merge with NetBSD make, pick up
+ o cond.c: be strict about lhs of comparison when evaluating .if
+ but less so when called from variable expansion.
+ o unit-tests/cond2.mk: test various error conditions
+
+2015-05-04 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * machine.sh (MACHINE): Add Bitrig
+ patch from joerg@netbsd.org
+
2015-04-18 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (MAKE_VERSION): 20150418
diff --git a/contrib/bmake/FILES b/contrib/bmake/FILES
index 8189973..c46e74b 100644
--- a/contrib/bmake/FILES
+++ b/contrib/bmake/FILES
@@ -96,6 +96,8 @@ unit-tests/comment.exp
unit-tests/comment.mk
unit-tests/cond1.exp
unit-tests/cond1.mk
+unit-tests/cond2.exp
+unit-tests/cond2.mk
unit-tests/doterror.exp
unit-tests/doterror.mk
unit-tests/dotwait.exp
diff --git a/contrib/bmake/Makefile b/contrib/bmake/Makefile
index 9a0abc6..803997a 100644
--- a/contrib/bmake/Makefile
+++ b/contrib/bmake/Makefile
@@ -1,7 +1,7 @@
-# $Id: Makefile,v 1.36 2015/04/18 19:58:53 sjg Exp $
+# $Id: Makefile,v 1.38 2015/05/05 21:58:05 sjg Exp $
# Base version on src date
-MAKE_VERSION= 20150418
+MAKE_VERSION= 20150505
PROG= bmake
@@ -94,7 +94,7 @@ SUBDIR+= unit-tests
# we skip a lot of this when building as part of FreeBSD etc.
# list of OS's which are derrived from BSD4.4
-BSD44_LIST= NetBSD FreeBSD OpenBSD DragonFly
+BSD44_LIST= NetBSD FreeBSD OpenBSD DragonFly MirBSD Bitrig
# we are...
OS!= uname -s
# are we 4.4BSD ?
diff --git a/contrib/bmake/cond.c b/contrib/bmake/cond.c
index a1c6705..b05a56c 100644
--- a/contrib/bmake/cond.c
+++ b/contrib/bmake/cond.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.67 2012/11/03 13:59:27 christos Exp $ */
+/* $NetBSD: cond.c,v 1.68 2015/05/05 21:51:09 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: cond.c,v 1.67 2012/11/03 13:59:27 christos Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.68 2015/05/05 21:51:09 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: cond.c,v 1.67 2012/11/03 13:59:27 christos Exp $");
+__RCSID("$NetBSD: cond.c,v 1.68 2015/05/05 21:51:09 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -181,6 +181,15 @@ static Token condPushBack=TOK_NONE; /* Single push-back token used in
static unsigned int cond_depth = 0; /* current .if nesting level */
static unsigned int cond_min_depth = 0; /* depth at makefile open */
+/*
+ * Indicate when we should be strict about lhs of comparisons.
+ * TRUE when Cond_EvalExpression is called from Cond_Eval (.if etc)
+ * FALSE when Cond_EvalExpression is called from var.c:ApplyModifiers
+ * since lhs is already expanded and we cannot tell if
+ * it was a variable reference or not.
+ */
+static Boolean lhsStrict;
+
static int
istoken(const char *str, const char *tok, size_t len)
{
@@ -517,7 +526,7 @@ CondCvtArg(char *str, double *value)
*/
/* coverity:[+alloc : arg-*2] */
static char *
-CondGetString(Boolean doEval, Boolean *quoted, void **freeIt)
+CondGetString(Boolean doEval, Boolean *quoted, void **freeIt, Boolean strictLHS)
{
Buffer buf;
char *cp;
@@ -601,6 +610,16 @@ CondGetString(Boolean doEval, Boolean *quoted, void **freeIt)
condExpr--; /* don't skip over next char */
break;
default:
+ if (strictLHS && !qt && *start != '$' &&
+ !isdigit((unsigned char) *start)) {
+ /* lhs must be quoted, a variable reference or number */
+ if (*freeIt) {
+ free(*freeIt);
+ *freeIt = NULL;
+ }
+ str = NULL;
+ goto cleanup;
+ }
Buf_AddByte(&buf, *condExpr);
break;
}
@@ -648,7 +667,7 @@ compare_expression(Boolean doEval)
* Parse the variable spec and skip over it, saving its
* value in lhs.
*/
- lhs = CondGetString(doEval, &lhsQuoted, &lhsFree);
+ lhs = CondGetString(doEval, &lhsQuoted, &lhsFree, lhsStrict);
if (!lhs)
goto done;
@@ -709,7 +728,7 @@ compare_expression(Boolean doEval)
goto done;
}
- rhs = CondGetString(doEval, &rhsQuoted, &rhsFree);
+ rhs = CondGetString(doEval, &rhsQuoted, &rhsFree, FALSE);
if (!rhs)
goto done;
@@ -1135,7 +1154,7 @@ CondE(Boolean doEval)
*-----------------------------------------------------------------------
*/
int
-Cond_EvalExpression(const struct If *info, char *line, Boolean *value, int eprint)
+Cond_EvalExpression(const struct If *info, char *line, Boolean *value, int eprint, Boolean strictLHS)
{
static const struct If *dflt_info;
const struct If *sv_if_info = if_info;
@@ -1143,6 +1162,8 @@ Cond_EvalExpression(const struct If *info, char *line, Boolean *value, int eprin
Token sv_condPushBack = condPushBack;
int rval;
+ lhsStrict = strictLHS;
+
while (*line == ' ' || *line == '\t')
line++;
@@ -1359,7 +1380,7 @@ Cond_Eval(char *line)
}
/* And evaluate the conditional expresssion */
- if (Cond_EvalExpression(ifp, line, &value, 1) == COND_INVALID) {
+ if (Cond_EvalExpression(ifp, line, &value, 1, TRUE) == COND_INVALID) {
/* Syntax error in conditional, error message already output. */
/* Skip everything to matching .endif */
cond_state[cond_depth] = SKIP_TO_ELSE;
diff --git a/contrib/bmake/machine.sh b/contrib/bmake/machine.sh
index 32a0f7a..2209eaa8 100755
--- a/contrib/bmake/machine.sh
+++ b/contrib/bmake/machine.sh
@@ -2,7 +2,7 @@
# derrived from /etc/rc_d/os.sh
# RCSid:
-# $Id: machine.sh,v 1.16 2010/10/17 00:05:51 sjg Exp $
+# $Id: machine.sh,v 1.17 2015/05/05 00:10:54 sjg Exp $
#
# @(#) Copyright (c) 1994-2002 Simon J. Gerraty
#
@@ -49,6 +49,10 @@ OpenBSD)
arch=`Which arch /usr/bin:/usr/ucb:$PATH`
MACHINE_ARCH=`$arch -s`;
;;
+Bitrig)
+ MACHINE=$OS$OSMAJOR.$machine
+ MACHINE_ARCH=`uname -m`;
+ ;;
*BSD)
MACHINE=$OS$OSMAJOR.$machine
;;
diff --git a/contrib/bmake/mk/ChangeLog b/contrib/bmake/mk/ChangeLog
index 597d814..9b4059e1 100644
--- a/contrib/bmake/mk/ChangeLog
+++ b/contrib/bmake/mk/ChangeLog
@@ -1,3 +1,9 @@
+2015-04-30 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): 20150430
+
+ * dirdeps.mk: fix _count_dirdeps for non-cache case.
+
2015-04-16 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20150411
diff --git a/contrib/bmake/mk/dirdeps.mk b/contrib/bmake/mk/dirdeps.mk
index fd03c82..4186346 100644
--- a/contrib/bmake/mk/dirdeps.mk
+++ b/contrib/bmake/mk/dirdeps.mk
@@ -1,4 +1,4 @@
-# $Id: dirdeps.mk,v 1.49 2015/03/11 21:39:28 sjg Exp $
+# $Id: dirdeps.mk,v 1.51 2015/05/06 06:07:30 sjg Exp $
# Copyright (c) 2010-2013, Juniper Networks, Inc.
# All rights reserved.
@@ -349,7 +349,7 @@ BUILD_DIRDEPS ?= yes
.if !defined(NO_DIRDEPS)
.if ${MK_DIRDEPS_CACHE} == "yes"
# this is where we will cache all our work
-DIRDEPS_CACHE?= ${_OBJDIR}/dirdeps.cache${.TARGETS:Nall:O:u:ts-:S,^,.,:N.}
+DIRDEPS_CACHE?= ${_OBJDIR}/dirdeps.cache${.TARGETS:Nall:O:u:ts-:S,/,_,g:S,^,.,:N.}
# just ensure this exists
build-dirdeps:
@@ -394,13 +394,14 @@ _count_dirdeps: .NOMETA
@echo '.info $${.newline}$${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]}' >&3
.endif
-.endif
-.elif !target(_count_dirdeps)
+.elif !make(dirdeps) && !target(_count_dirdeps)
beforedirdeps: _count_dirdeps
_count_dirdeps: .NOMETA
@echo "${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]} seconds=`expr ${now_utc} - ${start_utc}`"
.endif
+.endif
+
.if ${BUILD_DIRDEPS} == "yes"
.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.${DEP_MACHINE}:L:M$x}@} != ""
_debug_reldir = 1
diff --git a/contrib/bmake/mk/install-mk b/contrib/bmake/mk/install-mk
index 047fcfd..598cf39 100644
--- a/contrib/bmake/mk/install-mk
+++ b/contrib/bmake/mk/install-mk
@@ -55,7 +55,7 @@
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
-# $Id: install-mk,v 1.109 2015/04/16 16:59:00 sjg Exp $
+# $Id: install-mk,v 1.110 2015/05/01 06:37:49 sjg Exp $
#
# @(#) Copyright (c) 1994 Simon J. Gerraty
#
@@ -70,7 +70,7 @@
# sjg@crufty.net
#
-MK_VERSION=20150411
+MK_VERSION=20150430
OWNER=
GROUP=
MODE=444
diff --git a/contrib/bmake/nonints.h b/contrib/bmake/nonints.h
index b244f0b..9eaebc2 100644
--- a/contrib/bmake/nonints.h
+++ b/contrib/bmake/nonints.h
@@ -1,4 +1,4 @@
-/* $NetBSD: nonints.h,v 1.67 2014/09/07 20:55:34 joerg Exp $ */
+/* $NetBSD: nonints.h,v 1.68 2015/05/05 21:51:09 sjg Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -91,7 +91,7 @@ int Compat_Make(void *, void *);
/* cond.c */
struct If;
-int Cond_EvalExpression(const struct If *, char *, Boolean *, int);
+int Cond_EvalExpression(const struct If *, char *, Boolean *, int, Boolean);
int Cond_Eval(char *);
void Cond_restore_depth(unsigned int);
unsigned int Cond_save_depth(void);
diff --git a/contrib/bmake/unit-tests/Makefile.in b/contrib/bmake/unit-tests/Makefile.in
index f5f528c..6974d48 100644
--- a/contrib/bmake/unit-tests/Makefile.in
+++ b/contrib/bmake/unit-tests/Makefile.in
@@ -1,6 +1,6 @@
-# $Id: Makefile.in,v 1.46 2014/11/06 01:47:57 sjg Exp $
+# $Id: Makefile.in,v 1.47 2015/05/05 21:58:06 sjg Exp $
#
-# $NetBSD: Makefile,v 1.51 2014/10/20 23:21:11 sjg Exp $
+# $NetBSD: Makefile,v 1.52 2015/05/05 21:51:09 sjg Exp $
#
# Unit tests for make(1)
# The main targets are:
@@ -27,6 +27,7 @@ UNIT_TESTS:= ${srcdir}
TESTNAMES= \
comment \
cond1 \
+ cond2 \
error \
export \
export-all \
diff --git a/contrib/bmake/unit-tests/cond2.exp b/contrib/bmake/unit-tests/cond2.exp
new file mode 100644
index 0000000..22e76a5
--- /dev/null
+++ b/contrib/bmake/unit-tests/cond2.exp
@@ -0,0 +1,7 @@
+make: Bad conditional expression ` == "empty"' in == "empty"?oops:ok
+make: "cond2.mk" line 13: Malformed conditional ({TEST_TYPO} == "Ok")
+TEST_NOT_SET is empty or not defined
+make: "cond2.mk" line 20: Malformed conditional (${TEST_NOT_SET} == "empty")
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
diff --git a/contrib/bmake/unit-tests/cond2.mk b/contrib/bmake/unit-tests/cond2.mk
new file mode 100644
index 0000000..d6a0620
--- /dev/null
+++ b/contrib/bmake/unit-tests/cond2.mk
@@ -0,0 +1,25 @@
+# $Id: cond2.mk,v 1.1.1.1 2015/05/05 21:53:13 sjg Exp $
+
+TEST_UNAME_S= NetBSD
+
+# this should be ok
+X:= ${${TEST_UNAME_S} == "NetBSD":?Ok:fail}
+.if $X == "Ok"
+Y= good
+.endif
+# expect: Bad conditional expression ` == "empty"' in == "empty"?oops:ok
+X:= ${${TEST_NOT_SET} == "empty":?oops:ok}
+# expect: Malformed conditional ({TEST_TYPO} == "Ok")
+.if {TEST_TYPO} == "Ok"
+Y= oops
+.endif
+.if empty(TEST_NOT_SET)
+Y!= echo TEST_NOT_SET is empty or not defined >&2; echo
+.endif
+# expect: Malformed conditional (${TEST_NOT_SET} == "empty")
+.if ${TEST_NOT_SET} == "empty"
+Y= oops
+.endif
+
+all:
+ @echo $@
diff --git a/contrib/bmake/var.c b/contrib/bmake/var.c
index 2a94dee..e15c301 100644
--- a/contrib/bmake/var.c
+++ b/contrib/bmake/var.c
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.191 2014/09/14 02:32:51 dholland Exp $ */
+/* $NetBSD: var.c,v 1.192 2015/05/05 21:51:09 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.191 2014/09/14 02:32:51 dholland Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.192 2015/05/05 21:51:09 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: var.c,v 1.191 2014/09/14 02:32:51 dholland Exp $");
+__RCSID("$NetBSD: var.c,v 1.192 2015/05/05 21:51:09 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -3261,7 +3261,7 @@ ApplyModifiers(char *nstr, const char *tstr,
termc = *--cp;
delim = '\0';
- if (Cond_EvalExpression(NULL, v->name, &value, 0)
+ if (Cond_EvalExpression(NULL, v->name, &value, 0, FALSE)
== COND_INVALID) {
Error("Bad conditional expression `%s' in %s?%s:%s",
v->name, v->name, pattern.lhs, pattern.rhs);
diff --git a/contrib/elftoolchain/addr2line/addr2line.1 b/contrib/elftoolchain/addr2line/addr2line.1
index 98edda5..f000c29 100644
--- a/contrib/elftoolchain/addr2line/addr2line.1
+++ b/contrib/elftoolchain/addr2line/addr2line.1
@@ -22,7 +22,7 @@
.\" (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: addr2line.1 2066 2011-10-26 15:40:28Z jkoshy $
+.\" $Id: addr2line.1 3195 2015-05-12 17:22:19Z emaste $
.\"
.Dd July 25, 2010
.Os
@@ -99,7 +99,7 @@ Print a help message.
Print a version identifier and exit.
.El
.Sh OUTPUT FORMAT
-If the
+If the
.Fl f
option was not specified,
.Nm
@@ -156,4 +156,4 @@ its source file and line number use:
The
.Nm
utility was written by
-.An "Kai Wang" Aq kaiwang27@users.sourceforge.net .
+.An Kai Wang Aq Mt kaiwang27@users.sourceforge.net .
diff --git a/contrib/elftoolchain/addr2line/addr2line.c b/contrib/elftoolchain/addr2line/addr2line.c
index d6f5d73..cfdcc74 100644
--- a/contrib/elftoolchain/addr2line/addr2line.c
+++ b/contrib/elftoolchain/addr2line/addr2line.c
@@ -39,7 +39,7 @@
#include "_elftc.h"
-ELFTC_VCSID("$Id: addr2line.c 3174 2015-03-27 17:13:41Z emaste $");
+ELFTC_VCSID("$Id: addr2line.c 3197 2015-05-12 21:01:31Z emaste $");
static struct option longopts[] = {
{"target" , required_argument, NULL, 'b'},
@@ -84,6 +84,44 @@ version(void)
exit(0);
}
+/*
+ * Handle DWARF 4 'offset from' DW_AT_high_pc. Although we don't
+ * fully support DWARF 4, some compilers (like FreeBSD Clang 3.5.1)
+ * generate DW_AT_high_pc as an offset from DW_AT_low_pc.
+ *
+ * "If the value of the DW_AT_high_pc is of class address, it is the
+ * relocated address of the first location past the last instruction
+ * associated with the entity; if it is of class constant, the value
+ * is an unsigned integer offset which when added to the low PC gives
+ * the address of the first location past the last instruction
+ * associated with the entity."
+ *
+ * DWARF4 spec, section 2.17.2.
+ */
+static int
+handle_high_pc(Dwarf_Die die, Dwarf_Unsigned lopc, Dwarf_Unsigned *hipc)
+{
+ Dwarf_Error de;
+ Dwarf_Half form;
+ Dwarf_Attribute at;
+ int ret;
+
+ ret = dwarf_attr(die, DW_AT_high_pc, &at, &de);
+ if (ret == DW_DLV_ERROR) {
+ warnx("dwarf_attr failed: %s", dwarf_errmsg(de));
+ return (ret);
+ }
+ ret = dwarf_whatform(at, &form, &de);
+ if (ret == DW_DLV_ERROR) {
+ warnx("dwarf_whatform failed: %s", dwarf_errmsg(de));
+ return (ret);
+ }
+ if (dwarf_get_form_class(2, 0, 0, form) == DW_FORM_CLASS_CONSTANT)
+ *hipc += lopc;
+
+ return (DW_DLV_OK);
+}
+
static void
search_func(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Addr addr,
const char **rlt_func)
@@ -108,6 +146,8 @@ search_func(Dwarf_Debug dbg, Dwarf_Die die, Dwarf_Addr addr,
if (dwarf_attrval_unsigned(die, DW_AT_low_pc, &lopc, &de) ||
dwarf_attrval_unsigned(die, DW_AT_high_pc, &hipc, &de))
goto cont_search;
+ if (handle_high_pc(die, lopc, &hipc) != DW_DLV_OK)
+ goto cont_search;
if (addr < lopc || addr >= hipc)
goto cont_search;
@@ -202,6 +242,8 @@ translate(Dwarf_Debug dbg, const char* addrstr)
* Check if the address falls into the PC range of
* this CU.
*/
+ if (handle_high_pc(die, lopc, &hipc) != DW_DLV_OK)
+ continue;
if (addr < lopc || addr >= hipc)
continue;
}
diff --git a/contrib/elftoolchain/common/native-elf-format b/contrib/elftoolchain/common/native-elf-format
index 34d84bf..d36ab53 100755
--- a/contrib/elftoolchain/common/native-elf-format
+++ b/contrib/elftoolchain/common/native-elf-format
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $Id: native-elf-format 3167 2015-02-24 19:10:08Z emaste $
+# $Id: native-elf-format 3186 2015-04-16 22:16:40Z emaste $
#
# Find the native ELF format for a host platform by compiling a
# test object and examining the resulting object.
@@ -33,7 +33,7 @@ $1 ~ "Data:" {
$1 ~ "Machine:" {
if (match($0, "Intel.*386")) {
elfarch = "EM_386";
- } else if (match($0, ".*X86-64")) {
+ } else if (match($0, ".*[xX]86-64")) {
elfarch = "EM_X86_64";
} else {
elfarch = "unknown";
diff --git a/contrib/elftoolchain/cxxfilt/c++filt.1 b/contrib/elftoolchain/cxxfilt/c++filt.1
index 0a123c7..b191b44 100644
--- a/contrib/elftoolchain/cxxfilt/c++filt.1
+++ b/contrib/elftoolchain/cxxfilt/c++filt.1
@@ -22,7 +22,7 @@
.\" (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: c++filt.1 2175 2011-11-16 05:51:49Z jkoshy $
+.\" $Id: c++filt.1 3195 2015-05-12 17:22:19Z emaste $
.\"
.Dd August 24, 2011
.Os
@@ -106,4 +106,4 @@ and exit.
The
.Nm
utility was written by
-.An "Kai Wang" Aq kaiwang27@users.sourceforge.net .
+.An Kai Wang Aq Mt kaiwang27@users.sourceforge.net .
diff --git a/contrib/elftoolchain/elfcopy/elfcopy.1 b/contrib/elftoolchain/elfcopy/elfcopy.1
index ce8f120..4889570 100644
--- a/contrib/elftoolchain/elfcopy/elfcopy.1
+++ b/contrib/elftoolchain/elfcopy/elfcopy.1
@@ -21,7 +21,7 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $Id: elfcopy.1 3173 2015-03-27 16:46:13Z emaste $
+.\" $Id: elfcopy.1 3195 2015-05-12 17:22:19Z emaste $
.\"
.Dd March 27, 2015
.Os
@@ -330,4 +330,4 @@ Do not copy symbols that are not needed for relocation processing.
.Sh HISTORY
.Nm
has been implemented by
-.An "Kai Wang" Aq kaiwang27@users.sourceforge.net .
+.An Kai Wang Aq Mt kaiwang27@users.sourceforge.net .
diff --git a/contrib/elftoolchain/elfcopy/sections.c b/contrib/elftoolchain/elfcopy/sections.c
index 077bb74..7c43a35 100644
--- a/contrib/elftoolchain/elfcopy/sections.c
+++ b/contrib/elftoolchain/elfcopy/sections.c
@@ -34,7 +34,7 @@
#include "elfcopy.h"
-ELFTC_VCSID("$Id: sections.c 3174 2015-03-27 17:13:41Z emaste $");
+ELFTC_VCSID("$Id: sections.c 3185 2015-04-11 08:56:34Z kaiwang27 $");
static void add_gnu_debuglink(struct elfcopy *ecp);
static uint32_t calc_crc32(const char *p, size_t len, uint32_t crc);
@@ -1223,6 +1223,14 @@ update_shdr(struct elfcopy *ecp, int update_link)
osh.sh_info != 0)
osh.sh_info = ecp->secndx[osh.sh_info];
+ /*
+ * sh_info of SHT_GROUP section needs to point to the correct
+ * string in the symbol table.
+ */
+ if (s->type == SHT_GROUP && (ecp->flags & SYMTAB_EXIST) &&
+ (ecp->flags & SYMTAB_INTACT) == 0)
+ osh.sh_info = ecp->symndx[osh.sh_info];
+
if (!gelf_update_shdr(s->os, &osh))
errx(EXIT_FAILURE, "gelf_update_shdr() failed: %s",
elf_errmsg(-1));
diff --git a/contrib/elftoolchain/elfcopy/segments.c b/contrib/elftoolchain/elfcopy/segments.c
index 3ed6d93..1e271a6 100644
--- a/contrib/elftoolchain/elfcopy/segments.c
+++ b/contrib/elftoolchain/elfcopy/segments.c
@@ -34,7 +34,7 @@
#include "elfcopy.h"
-ELFTC_VCSID("$Id: segments.c 3177 2015-03-30 18:19:41Z emaste $");
+ELFTC_VCSID("$Id: segments.c 3196 2015-05-12 17:33:48Z emaste $");
static void insert_to_inseg_list(struct segment *seg, struct section *sec);
@@ -442,7 +442,7 @@ copy_phdr(struct elfcopy *ecp)
s = seg->v_sec[i];
seg->msz = s->vma + s->sz - seg->addr;
if (s->type != SHT_NOBITS)
- seg->fsz = seg->msz;
+ seg->fsz = s->off + s->sz - seg->off;
}
}
diff --git a/contrib/elftoolchain/elfcopy/symbols.c b/contrib/elftoolchain/elfcopy/symbols.c
index 49bb239..4a7d38a 100644
--- a/contrib/elftoolchain/elfcopy/symbols.c
+++ b/contrib/elftoolchain/elfcopy/symbols.c
@@ -33,7 +33,7 @@
#include "elfcopy.h"
-ELFTC_VCSID("$Id: symbols.c 3174 2015-03-27 17:13:41Z emaste $");
+ELFTC_VCSID("$Id: symbols.c 3191 2015-05-04 17:07:01Z jkoshy $");
/* Symbol table buffer structure. */
struct symbuf {
@@ -1090,7 +1090,7 @@ str_hash(const char *s)
{
uint32_t hash;
- for (hash = 2166136261; *s; s++)
+ for (hash = 2166136261UL; *s; s++)
hash = (hash ^ *s) * 16777619;
return (hash & (STHASHSIZE - 1));
diff --git a/contrib/elftoolchain/libdwarf/dwarf.3 b/contrib/elftoolchain/libdwarf/dwarf.3
index 5363034..dbb4179 100644
--- a/contrib/elftoolchain/libdwarf/dwarf.3
+++ b/contrib/elftoolchain/libdwarf/dwarf.3
@@ -21,7 +21,7 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $Id: dwarf.3 3130 2014-12-21 20:06:29Z jkoshy $
+.\" $Id: dwarf.3 3195 2015-05-12 17:22:19Z emaste $
.\"
.Dd December 21, 2014
.Os
@@ -44,7 +44,7 @@ is defined by the DWARF standard, see
.Xr dwarf 4 .
.Pp
The
-.Xr DWARF 3
+.Xr DWARF 3
API has two parts:
.Bl -bullet
.It
@@ -349,7 +349,7 @@ Retrieve a debugging information entry given an offset.
.It Fn dwarf_siblingof , Fn dwarf_siblingof_b
Retrieve the sibling descriptor for a debugging information entry.
.It Fn dwarf_srclang
-Retrive the source language attribute for a debugging information
+Retrieve the source language attribute for a debugging information
entry.
.It Fn dwarf_tag
Retrieve the tag for a debugging information entry.
@@ -742,12 +742,12 @@ The DWARF standard is defined by
The DWARF(3) API originated at Silicon Graphics Inc.
.Pp
A BSD-licensed implementation of a subset of the API was written by
-.An "John Birrell" Aq jb@FreeBSD.org
+.An John Birrell Aq Mt jb@FreeBSD.org
for the FreeBSD project.
The implementation was subsequently revised and completed by
-.An "Kai Wang" Aq kaiwang27@users.sourceforge.net .
+.An Kai Wang Aq Mt kaiwang27@users.sourceforge.net .
.Pp
Manual pages for this implementation were written by
-.An "Joseph Koshy" Aq jkoshy@users.sourceforge.net
+.An Joseph Koshy Aq Mt jkoshy@users.sourceforge.net
and
-.An "Kai Wang" Aq kaiwang27@users.sourceforge.net .
+.An Kai Wang Aq Mt kaiwang27@users.sourceforge.net .
diff --git a/contrib/elftoolchain/libdwarf/dwarf_add_line_entry.3 b/contrib/elftoolchain/libdwarf/dwarf_add_line_entry.3
index 2237717..16e8075 100644
--- a/contrib/elftoolchain/libdwarf/dwarf_add_line_entry.3
+++ b/contrib/elftoolchain/libdwarf/dwarf_add_line_entry.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dwarf_add_line_entry.3 2953 2013-06-30 20:21:38Z kaiwang27 $
+.\" $Id: dwarf_add_line_entry.3 3182 2015-04-10 16:08:10Z emaste $
.\"
.Dd June 30, 2013
.Os
@@ -66,7 +66,8 @@ Valid source file indices are those returned by the function
.Pp
Argument
.Ar off
-specifies a relocatable program address. The ELF symbol to be used
+specifies a relocatable program address.
+The ELF symbol to be used
for relocation is set by a prior call to the function
.Xr dwarf_lne_set_address 3 .
.Pp
diff --git a/contrib/elftoolchain/libdwarf/dwarf_def_macro.3 b/contrib/elftoolchain/libdwarf/dwarf_def_macro.3
index d4849b1..daa090f 100644
--- a/contrib/elftoolchain/libdwarf/dwarf_def_macro.3
+++ b/contrib/elftoolchain/libdwarf/dwarf_def_macro.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dwarf_def_macro.3 2122 2011-11-09 15:35:14Z jkoshy $
+.\" $Id: dwarf_def_macro.3 3182 2015-04-10 16:08:10Z emaste $
.\"
.Dd November 9, 2011
.Os
@@ -72,7 +72,7 @@ Argument
.Ar value
should point to a NUL-terminated string containing the value
of the macro.
-If the macro doesn't have a value, argument
+If the macro does not have a value, argument
.Ar value
should be set to NULL.
.Pp
diff --git a/contrib/elftoolchain/libdwarf/dwarf_expand_frame_instructions.3 b/contrib/elftoolchain/libdwarf/dwarf_expand_frame_instructions.3
index eaeb320..7bcd105 100644
--- a/contrib/elftoolchain/libdwarf/dwarf_expand_frame_instructions.3
+++ b/contrib/elftoolchain/libdwarf/dwarf_expand_frame_instructions.3
@@ -22,14 +22,14 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dwarf_expand_frame_instructions.3 2122 2011-11-09 15:35:14Z jkoshy $
+.\" $Id: dwarf_expand_frame_instructions.3 3181 2015-04-10 13:22:51Z emaste $
.\"
.Dd November 9, 2011
.Os
.Dt DWARF_EXPAND_FRAME_INSTRUCTIONS 3
.Sh NAME
.Nm dwarf_expand_frame_instructions
-.Nd expand frame instructions
+.Nd expand frame instructions
.Sh LIBRARY
.Lb libdwarf
.Sh SYNOPSIS
diff --git a/contrib/elftoolchain/libdwarf/dwarf_formblock.3 b/contrib/elftoolchain/libdwarf/dwarf_formblock.3
index 4ae824f..1ffb6e6 100644
--- a/contrib/elftoolchain/libdwarf/dwarf_formblock.3
+++ b/contrib/elftoolchain/libdwarf/dwarf_formblock.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dwarf_formblock.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\" $Id: dwarf_formblock.3 3182 2015-04-10 16:08:10Z emaste $
.\"
.Dd July 23, 2010
.Os
@@ -69,7 +69,7 @@ the DWARF(3) library.
The application should not attempt to free this memory
area.
Portable code may indicate that the memory area is to be freed by
-by using
+using
.Xr dwarf_dealloc 3 .
.Sh RETURN VALUES
Function
diff --git a/contrib/elftoolchain/libdwarf/dwarf_formflag.3 b/contrib/elftoolchain/libdwarf/dwarf_formflag.3
index 93d5902..2e23b33 100644
--- a/contrib/elftoolchain/libdwarf/dwarf_formflag.3
+++ b/contrib/elftoolchain/libdwarf/dwarf_formflag.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dwarf_formflag.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\" $Id: dwarf_formflag.3 3181 2015-04-10 13:22:51Z emaste $
.\"
.Dd June 21, 2010
.Os
@@ -58,7 +58,7 @@ or
If argument
.Ar err
is not NULL, it will be used to return an error descriptor in case
-of an error.
+of an error.
.Sh RETURN VALUES
Function
.Fn dwarf_formflag
diff --git a/contrib/elftoolchain/libdwarf/dwarf_formref.3 b/contrib/elftoolchain/libdwarf/dwarf_formref.3
index 9e3458f..abde30c 100644
--- a/contrib/elftoolchain/libdwarf/dwarf_formref.3
+++ b/contrib/elftoolchain/libdwarf/dwarf_formref.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dwarf_formref.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\" $Id: dwarf_formref.3 3181 2015-04-10 13:22:51Z emaste $
.\"
.Dd June 21, 2010
.Os
@@ -101,7 +101,7 @@ ELF section.
If argument
.Ar err
is not NULL, it will be used to return an error descriptor in case
-of an error.
+of an error.
.Sh RETURN VALUES
These functions return
.Dv DW_DLV_OK
diff --git a/contrib/elftoolchain/libdwarf/dwarf_formsig8.3 b/contrib/elftoolchain/libdwarf/dwarf_formsig8.3
index 5445324..a76c110 100644
--- a/contrib/elftoolchain/libdwarf/dwarf_formsig8.3
+++ b/contrib/elftoolchain/libdwarf/dwarf_formsig8.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dwarf_formsig8.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\" $Id: dwarf_formsig8.3 3181 2015-04-10 13:22:51Z emaste $
.\"
.Dd July 24, 2010
.Os
@@ -56,7 +56,7 @@ must be
If argument
.Ar err
is not NULL, it will be used to return an error descriptor in case
-of an error.
+of an error.
.Sh RETURN VALUES
Function
.Fn dwarf_formsig8
diff --git a/contrib/elftoolchain/libdwarf/dwarf_formudata.3 b/contrib/elftoolchain/libdwarf/dwarf_formudata.3
index f95fdea..9ed154e 100644
--- a/contrib/elftoolchain/libdwarf/dwarf_formudata.3
+++ b/contrib/elftoolchain/libdwarf/dwarf_formudata.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dwarf_formudata.3 2073 2011-10-27 03:30:47Z jkoshy $
+.\" $Id: dwarf_formudata.3 3181 2015-04-10 13:22:51Z emaste $
.\"
.Dd June 21, 2010
.Os
@@ -88,7 +88,7 @@ and
If argument
.Ar err
is not NULL, it will be used to return an error descriptor in case
-of an error.
+of an error.
.Sh RETURN VALUES
These functions return
.Dv DW_DLV_OK
diff --git a/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs.3 b/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs.3
index 014d138..f55d3d6 100644
--- a/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs.3
+++ b/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_all_regs.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dwarf_get_fde_info_for_all_regs.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\" $Id: dwarf_get_fde_info_for_all_regs.3 3182 2015-04-10 16:08:10Z emaste $
.\"
.Dd June 4, 2011
.Os
@@ -90,7 +90,8 @@ typedef struct {
For each of the register rules returned,
the
.Va dw_offset_relevant
-field is set to 1 if the register rule has a offset value. The
+field is set to 1 if the register rule has a offset value.
+The
.Va dw_regnum
field is set to the register number associated with the regsiter rule.
The
diff --git a/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg.3 b/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg.3
index 3d46806..fd05814 100644
--- a/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg.3
+++ b/contrib/elftoolchain/libdwarf/dwarf_get_fde_info_for_reg.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dwarf_get_fde_info_for_reg.3 2071 2011-10-27 03:20:00Z jkoshy $
+.\" $Id: dwarf_get_fde_info_for_reg.3 3181 2015-04-10 13:22:51Z emaste $
.\"
.Dd June 4, 2011
.Os
@@ -99,7 +99,7 @@ counter address associated with the register rule found.
If argument
.Ar err
is not NULL, it will be used to return an error descriptor in case
-of an error.
+of an error.
.Ss COMPATIBILITY
Function
.Fn dwarf_get_fde_info_for_reg
diff --git a/contrib/elftoolchain/libdwarf/dwarf_get_ranges.3 b/contrib/elftoolchain/libdwarf/dwarf_get_ranges.3
index 37847a1..15bad4d 100644
--- a/contrib/elftoolchain/libdwarf/dwarf_get_ranges.3
+++ b/contrib/elftoolchain/libdwarf/dwarf_get_ranges.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dwarf_get_ranges.3 2122 2011-11-09 15:35:14Z jkoshy $
+.\" $Id: dwarf_get_ranges.3 3182 2015-04-10 16:08:10Z emaste $
.\"
.Dd November 9, 2011
.Os
@@ -137,7 +137,7 @@ For this type of entry, the field
.Va dwr_addr1
is the value of the largest representable address offset, and
.Va dwr_addr2
-is a base address for the begining and ending address offsets of
+is a base address for the beginning and ending address offsets of
subsequent address range entries in the list.
.It Dv DW_RANGES_END
An end of list mark.
diff --git a/contrib/elftoolchain/libdwarf/dwarf_hasattr.3 b/contrib/elftoolchain/libdwarf/dwarf_hasattr.3
index 5875848..6598875 100644
--- a/contrib/elftoolchain/libdwarf/dwarf_hasattr.3
+++ b/contrib/elftoolchain/libdwarf/dwarf_hasattr.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dwarf_hasattr.3 3142 2015-01-29 23:11:14Z jkoshy $
+.\" $Id: dwarf_hasattr.3 3181 2015-04-10 13:22:51Z emaste $
.\"
.Dd April 17, 2010
.Os
@@ -64,7 +64,7 @@ If the named attribute is not present, a zero is written instead.
If argument
.Ar err
is not NULL, it will be used to return an error descriptor in case
-of an error.
+of an error.
.Sh RETURN VALUES
On success, function
.Fn dwarf_hasattr
diff --git a/contrib/elftoolchain/libdwarf/dwarf_next_cu_header.3 b/contrib/elftoolchain/libdwarf/dwarf_next_cu_header.3
index f172322..f68867d 100644
--- a/contrib/elftoolchain/libdwarf/dwarf_next_cu_header.3
+++ b/contrib/elftoolchain/libdwarf/dwarf_next_cu_header.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dwarf_next_cu_header.3 3128 2014-12-21 20:06:22Z jkoshy $
+.\" $Id: dwarf_next_cu_header.3 3182 2015-04-10 16:08:10Z emaste $
.\"
.Dd December 21, 2014
.Os
@@ -220,8 +220,7 @@ unit in the section.
.Ss Iterating Through Type Units in a Debug Context
When a DWARF debug context is allocated using
.Xr dwarf_init 3 ,
-an internal pointer assoicated with the context will point to the
-fisrt
+an internal pointer associated with the context will point to the first
.Dq \&.debug_types
section found in the debug object.
The first call to function
diff --git a/contrib/elftoolchain/libdwarf/dwarf_producer_init.3 b/contrib/elftoolchain/libdwarf/dwarf_producer_init.3
index 717335e..b8ca6a9 100644
--- a/contrib/elftoolchain/libdwarf/dwarf_producer_init.3
+++ b/contrib/elftoolchain/libdwarf/dwarf_producer_init.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dwarf_producer_init.3 2074 2011-10-27 03:34:33Z jkoshy $
+.\" $Id: dwarf_producer_init.3 3182 2015-04-10 16:08:10Z emaste $
.\"
.Dd August 20, 2011
.Os
@@ -58,7 +58,7 @@ descriptor representing a DWARF producer instance.
.Pp
The argument
.Ar errhand
-should contain the adddress of a function to be called in case of an
+should contain the address of a function to be called in case of an
error.
If this argument is
.Dv NULL ,
diff --git a/contrib/elftoolchain/libdwarf/dwarf_whatattr.3 b/contrib/elftoolchain/libdwarf/dwarf_whatattr.3
index a975d3e..d7f6dd4 100644
--- a/contrib/elftoolchain/libdwarf/dwarf_whatattr.3
+++ b/contrib/elftoolchain/libdwarf/dwarf_whatattr.3
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: dwarf_whatattr.3 3142 2015-01-29 23:11:14Z jkoshy $
+.\" $Id: dwarf_whatattr.3 3181 2015-04-10 13:22:51Z emaste $
.\"
.Dd May 22, 2010
.Os
@@ -51,7 +51,7 @@ and writes it to the location pointed to by argument
If argument
.Ar err
is not NULL, it will be used to return an error descriptor in case
-of an error.
+of an error.
.Sh RETURN VALUES
On success, function
.Fn dwarf_whatattr
diff --git a/contrib/elftoolchain/libelf/elf.3 b/contrib/elftoolchain/libelf/elf.3
index 618b4f7..20cb944 100644
--- a/contrib/elftoolchain/libelf/elf.3
+++ b/contrib/elftoolchain/libelf/elf.3
@@ -21,7 +21,7 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $Id: elf.3 3142 2015-01-29 23:11:14Z jkoshy $
+.\" $Id: elf.3 3195 2015-05-12 17:22:19Z emaste $
.\"
.Dd July 28, 2014
.Os
@@ -555,7 +555,7 @@ flag on an ELF descriptor using
.Xr elf_flagelf 3 ,
following which the library will use the data offsets and alignments
specified by the application when laying out the file.
-Application control of file layout is described further in the
+Application control of file layout is described further in the
.Xr elf_update 3
manual page.
.Pp
@@ -608,5 +608,4 @@ The current implementation of the ELF(3) API appeared in
.Fx 7.0 .
.Sh AUTHORS
The ELF library was written by
-.An "Joseph Koshy"
-.Aq jkoshy@FreeBSD.org .
+.An Joseph Koshy Aq Mt jkoshy@FreeBSD.org .
diff --git a/contrib/elftoolchain/libelf/elf_begin.3 b/contrib/elftoolchain/libelf/elf_begin.3
index 960456a..e6c11b6 100644
--- a/contrib/elftoolchain/libelf/elf_begin.3
+++ b/contrib/elftoolchain/libelf/elf_begin.3
@@ -21,7 +21,7 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $Id: elf_begin.3 2313 2011-12-11 06:19:24Z jkoshy $
+.\" $Id: elf_begin.3 3182 2015-04-10 16:08:10Z emaste $
.\"
.Dd December 11, 2011
.Os
@@ -272,7 +272,7 @@ was created.
.It Bq Er ELF_E_ARGUMENT
An
.Xr ar 1
-archive was opened with with
+archive was opened with
.Ar cmd
set to
.Dv ELF_C_RDWR .
diff --git a/contrib/elftoolchain/libelf/elf_cntl.3 b/contrib/elftoolchain/libelf/elf_cntl.3
index 32649d1..2578975 100644
--- a/contrib/elftoolchain/libelf/elf_cntl.3
+++ b/contrib/elftoolchain/libelf/elf_cntl.3
@@ -21,7 +21,7 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $Id: elf_cntl.3 289 2009-01-08 08:26:08Z jkoshy $
+.\" $Id: elf_cntl.3 3181 2015-04-10 13:22:51Z emaste $
.\"
.Dd August 9, 2006
.Os
diff --git a/contrib/elftoolchain/libelf/elf_getdata.3 b/contrib/elftoolchain/libelf/elf_getdata.3
index 8816a5a..68b2889 100644
--- a/contrib/elftoolchain/libelf/elf_getdata.3
+++ b/contrib/elftoolchain/libelf/elf_getdata.3
@@ -21,7 +21,7 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $Id: elf_getdata.3 1766 2011-08-22 06:01:03Z jkoshy $
+.\" $Id: elf_getdata.3 3181 2015-04-10 13:22:51Z emaste $
.\"
.Dd January 26, 2011
.Os
@@ -174,7 +174,7 @@ These functions return a valid pointer to a data descriptor if successful, or
NULL if an error occurs.
.Sh ERRORS
These functions may fail with the following errors:
-.Bl -tag -width "[ELF_E_RESOURCE]"
+.Bl -tag -width "[ELF_E_RESOURCE]"
.It Bq Er ELF_E_ARGUMENT
Either of the arguments
.Ar scn
diff --git a/contrib/elftoolchain/libelf/elf_open.3 b/contrib/elftoolchain/libelf/elf_open.3
index dad969e..3dd1e36 100644
--- a/contrib/elftoolchain/libelf/elf_open.3
+++ b/contrib/elftoolchain/libelf/elf_open.3
@@ -21,11 +21,11 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $Id: elf_open.3 2512 2012-05-31 06:15:57Z jkoshy $
+.\" $Id: elf_open.3 3181 2015-04-10 13:22:51Z emaste $
.\"
.Dd May 31, 2012
.Os
-.Dt ELF_OPEN 3
+.Dt ELF_OPEN 3
.Sh NAME
.Nm elf_open
.Nd open ELF objects and ar(1) archives
diff --git a/contrib/elftoolchain/libelf/elf_update.c b/contrib/elftoolchain/libelf/elf_update.c
index 70a7c2e..6cc109d 100644
--- a/contrib/elftoolchain/libelf/elf_update.c
+++ b/contrib/elftoolchain/libelf/elf_update.c
@@ -41,7 +41,7 @@
#include <sys/mman.h>
#endif
-ELFTC_VCSID("$Id: elf_update.c 3013 2014-03-23 06:16:59Z jkoshy $");
+ELFTC_VCSID("$Id: elf_update.c 3190 2015-05-04 15:23:08Z jkoshy $");
/*
* Layout strategy:
@@ -271,8 +271,10 @@ _libelf_compute_section_extents(Elf *e, Elf_Scn *s, off_t rc)
* offsets and alignment for sanity.
*/
if (e->e_flags & ELF_F_LAYOUT) {
- if (scn_alignment > sh_align || sh_offset % sh_align ||
- sh_size < scn_size) {
+ if (scn_alignment > sh_align ||
+ sh_offset % sh_align ||
+ sh_size < scn_size ||
+ sh_offset % _libelf_falign(elftype, ec)) {
LIBELF_SET_ERROR(LAYOUT, 0);
return (0);
}
diff --git a/contrib/elftoolchain/libelf/gelf.3 b/contrib/elftoolchain/libelf/gelf.3
index a5d68ce..d00d5b3 100644
--- a/contrib/elftoolchain/libelf/gelf.3
+++ b/contrib/elftoolchain/libelf/gelf.3
@@ -21,7 +21,7 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $Id: gelf.3 189 2008-07-20 10:38:08Z jkoshy $
+.\" $Id: gelf.3 3195 2015-05-12 17:22:19Z emaste $
.\"
.Dd September 1, 2006
.Os
@@ -197,5 +197,4 @@ This implementation of the API first appeared in
.Fx 7.0 .
.Sh AUTHORS
The GElf API was implemented by
-.An "Joseph Koshy"
-.Aq jkoshy@FreeBSD.org .
+.An Joseph Koshy Aq Mt jkoshy@FreeBSD.org .
diff --git a/contrib/elftoolchain/libelftc/elftc_demangle.3 b/contrib/elftoolchain/libelftc/elftc_demangle.3
index bbe67e5..44cf007 100644
--- a/contrib/elftoolchain/libelftc/elftc_demangle.3
+++ b/contrib/elftoolchain/libelftc/elftc_demangle.3
@@ -21,7 +21,7 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $Id: elftc_demangle.3 2065 2011-10-26 15:24:47Z jkoshy $
+.\" $Id: elftc_demangle.3 3182 2015-04-10 16:08:10Z emaste $
.\"
.Dd August 24, 2011
.Os
@@ -88,7 +88,7 @@ To decode a name that uses an unknown encoding style use:
.Bd -literal -offset indent
char buffer[1024];
const char *funcname;
-
+
funcname = ...; /* points to string to be demangled */
if (elftc_demangle(funcname, buffer, sizeof(buffer), 0) == 0)
printf("Demangled name: %\\n", buffer);
diff --git a/contrib/elftoolchain/libelftc/elftc_symbol_table_create.3 b/contrib/elftoolchain/libelftc/elftc_symbol_table_create.3
index 3ff2c35..76f90e9 100644
--- a/contrib/elftoolchain/libelftc/elftc_symbol_table_create.3
+++ b/contrib/elftoolchain/libelftc/elftc_symbol_table_create.3
@@ -21,7 +21,7 @@
.\" out of the use of this software, even if advised of the possibility of
.\" such damage.
.\"
-.\" $Id: elftc_symbol_table_create.3 2825 2012-12-29 14:25:33Z jkoshy $
+.\" $Id: elftc_symbol_table_create.3 3182 2015-04-10 16:08:10Z emaste $
.\"
.Dd December 29, 2012
.Os
@@ -224,7 +224,7 @@ should point to a location that will be updated with one of
the following values:
.Bl -tag -width indent -compact -offset indent
.It Dv ELFTC_INSERT_ERROR
-An error occured during insertion of the symbol.
+An error occurred during insertion of the symbol.
.It Dv ELFTC_INSERT_EXISTING
The name in argument
.Ar symbolname
diff --git a/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c b/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c
index 05a6302..1cdb0e7 100644
--- a/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c
+++ b/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c
@@ -36,7 +36,7 @@
#include "_libelftc.h"
-ELFTC_VCSID("$Id: libelftc_dem_gnu3.c 3123 2014-12-21 05:46:19Z kaiwang27 $");
+ELFTC_VCSID("$Id: libelftc_dem_gnu3.c 3194 2015-05-05 17:55:16Z emaste $");
/**
* @file cpp_demangle.c
@@ -316,7 +316,7 @@ cpp_demangle_push_fp(struct cpp_demangle_data *ddata,
rtn = 0;
if ((len = strlen(f)) > 0)
- rtn = cpp_demangle_push_str(ddata, f, len);
+ rtn = cpp_demangle_push_str(ddata, f, len);
free(f);
diff --git a/contrib/elftoolchain/nm/nm.1 b/contrib/elftoolchain/nm/nm.1
index 35439e4..4cdd737 100644
--- a/contrib/elftoolchain/nm/nm.1
+++ b/contrib/elftoolchain/nm/nm.1
@@ -22,7 +22,7 @@
.\" (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: nm.1 3145 2015-02-15 18:04:37Z emaste $
+.\" $Id: nm.1 3195 2015-05-12 17:22:19Z emaste $
.\"
.Dd February 15, 2015
.Os
@@ -335,4 +335,4 @@ were specified.
The
.Nm
utility and this manual page were written by
-.An Hyogeol Lee Aq hyogeollee@gmail.com .
+.An Hyogeol Lee Aq Mt hyogeollee@gmail.com .
diff --git a/contrib/elftoolchain/readelf/readelf.1 b/contrib/elftoolchain/readelf/readelf.1
index 8419d95..a71e85f 100644
--- a/contrib/elftoolchain/readelf/readelf.1
+++ b/contrib/elftoolchain/readelf/readelf.1
@@ -22,7 +22,7 @@
.\" (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: readelf.1 3059 2014-06-02 00:42:32Z kaiwang27 $
+.\" $Id: readelf.1 3195 2015-05-12 17:22:19Z emaste $
.\"
.Dd September 13, 2012
.Os
@@ -194,4 +194,4 @@ separate lines.
The
.Nm
utility was written by
-.An "Kai Wang" Aq kaiwang27@users.sourceforge.net .
+.An Kai Wang Aq Mt kaiwang27@users.sourceforge.net .
diff --git a/contrib/elftoolchain/readelf/readelf.c b/contrib/elftoolchain/readelf/readelf.c
index bca228c..29bc389 100644
--- a/contrib/elftoolchain/readelf/readelf.c
+++ b/contrib/elftoolchain/readelf/readelf.c
@@ -46,7 +46,7 @@
#include "_elftc.h"
-ELFTC_VCSID("$Id: readelf.c 3178 2015-03-30 18:29:13Z emaste $");
+ELFTC_VCSID("$Id: readelf.c 3189 2015-04-20 17:02:01Z emaste $");
/*
* readelf(1) options.
@@ -2673,7 +2673,7 @@ dump_phdr(struct readelf *re)
{
const char *rawfile;
GElf_Phdr phdr;
- size_t phnum;
+ size_t phnum, size;
int i, j;
#define PH_HDR "Type", "Offset", "VirtAddr", "PhysAddr", "FileSiz", \
@@ -2726,10 +2726,14 @@ dump_phdr(struct readelf *re)
" 0x%16.16jx 0x%16.16jx %c%c%c"
" %#jx\n", PH_CT);
if (phdr.p_type == PT_INTERP) {
- if ((rawfile = elf_rawfile(re->elf, NULL)) == NULL) {
+ if ((rawfile = elf_rawfile(re->elf, &size)) == NULL) {
warnx("elf_rawfile failed: %s", elf_errmsg(-1));
continue;
}
+ if (phdr.p_offset >= size) {
+ warnx("invalid program header offset");
+ continue;
+ }
printf(" [Requesting program interpreter: %s]\n",
rawfile + phdr.p_offset);
}
@@ -4378,13 +4382,22 @@ dump_mips_options(struct readelf *re, struct section *s)
p = d->d_buf;
pe = p + d->d_size;
while (p < pe) {
+ if (pe - p < 8) {
+ warnx("Truncated MIPS option header");
+ return;
+ }
kind = re->dw_decode(&p, 1);
size = re->dw_decode(&p, 1);
sndx = re->dw_decode(&p, 2);
info = re->dw_decode(&p, 4);
+ if (size < 8 || size - 8 > pe - p) {
+ warnx("Malformed MIPS option header");
+ return;
+ }
+ size -= 8;
switch (kind) {
case ODK_REGINFO:
- dump_mips_odk_reginfo(re, p, size - 8);
+ dump_mips_odk_reginfo(re, p, size);
break;
case ODK_EXCEPTIONS:
printf(" EXCEPTIONS FPU_MIN: %#x\n",
@@ -4435,7 +4448,7 @@ dump_mips_options(struct readelf *re, struct section *s)
default:
break;
}
- p += size - 8;
+ p += size;
}
}
@@ -7458,11 +7471,10 @@ main(int argc, char **argv)
errx(EXIT_FAILURE, "ELF library initialization failed: %s",
elf_errmsg(-1));
- for (i = 0; i < argc; i++)
- if (argv[i] != NULL) {
- re->filename = argv[i];
- dump_object(re);
- }
+ for (i = 0; i < argc; i++) {
+ re->filename = argv[i];
+ dump_object(re);
+ }
exit(EXIT_SUCCESS);
}
diff --git a/contrib/elftoolchain/size/size.1 b/contrib/elftoolchain/size/size.1
index 70f3bfd..97f76c2 100644
--- a/contrib/elftoolchain/size/size.1
+++ b/contrib/elftoolchain/size/size.1
@@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: size.1 2043 2011-10-23 14:49:16Z jkoshy $
+.\" $Id: size.1 3195 2015-05-12 17:22:19Z emaste $
.\"
.Dd August 25, 2011
.Dt SIZE 1
@@ -252,6 +252,6 @@ utility first appeared in
The
.Nm
utility was re-written by
-.An S. Sam Arun Raj Aq samarunraj@gmail.com
+.An S. Sam Arun Raj Aq Mt samarunraj@gmail.com
This manual page was written by
-.An S. Sam Arun Raj Aq samarunraj@gmail.com
+.An S. Sam Arun Raj Aq Mt samarunraj@gmail.com
diff --git a/contrib/elftoolchain/size/size.c b/contrib/elftoolchain/size/size.c
index 93133a9..40d75f8 100644
--- a/contrib/elftoolchain/size/size.c
+++ b/contrib/elftoolchain/size/size.c
@@ -38,7 +38,7 @@
#include "_elftc.h"
-ELFTC_VCSID("$Id: size.c 3174 2015-03-27 17:13:41Z emaste $");
+ELFTC_VCSID("$Id: size.c 3183 2015-04-10 16:18:42Z emaste $");
#define BUF_SIZE 1024
#define ELF_ALIGN(val,x) (((val)+(x)-1) & ~((x)-1))
@@ -604,7 +604,7 @@ handle_elf(char const *name)
arhdr->ar_name);
continue;
}
- /* Core dumps are handled seperately */
+ /* Core dumps are handled separately */
if (elfhdr.e_shnum == 0 && elfhdr.e_type == ET_CORE) {
exit_code = handle_core(name, elf, &elfhdr);
(void) elf_end(elf);
diff --git a/contrib/elftoolchain/strings/strings.1 b/contrib/elftoolchain/strings/strings.1
index d6816494..15ad7a7 100644
--- a/contrib/elftoolchain/strings/strings.1
+++ b/contrib/elftoolchain/strings/strings.1
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: strings.1 2352 2011-12-19 11:21:10Z jkoshy $
+.\" $Id: strings.1 3195 2015-05-12 17:22:19Z emaste $
.\"
.Dd December 19, 2011
.Dt STRINGS 1
@@ -157,6 +157,6 @@ when i386-only a.out format was dropped in favor of ELF.
The
.Nm
utility was re-written by
-.An S.Sam Arun Raj Aq samarunraj@gmail.com .
+.An S.Sam Arun Raj Aq Mt samarunraj@gmail.com .
This manual page was written by
-.An S.Sam Arun Raj Aq samarunraj@gmail.com .
+.An S.Sam Arun Raj Aq Mt samarunraj@gmail.com .
diff --git a/contrib/gcc/dwarf2.h b/contrib/gcc/dwarf2.h
index 524d2bd..ec37c8e 100644
--- a/contrib/gcc/dwarf2.h
+++ b/contrib/gcc/dwarf2.h
@@ -547,6 +547,7 @@ enum dwarf_location_atom
DW_OP_bit_piece = 0x9d,
/* GNU extensions. */
DW_OP_GNU_push_tls_address = 0xe0,
+ DW_OP_GNU_uninit = 0xf0,
/* HP extensions. */
DW_OP_HP_unknown = 0xe0, /* Ouch, the same as GNU_push_tls_address. */
DW_OP_HP_is_value = 0xe1,
diff --git a/contrib/gcclibs/libgomp/ChangeLog b/contrib/gcclibs/libgomp/ChangeLog
index 56191ec..2237892 100644
--- a/contrib/gcclibs/libgomp/ChangeLog
+++ b/contrib/gcclibs/libgomp/ChangeLog
@@ -1,6 +1,223 @@
-2007-07-19 Release Manager
+2010-05-22 Release Manager
- * GCC 4.2.1 released.
+ * GCC 4.3.5 released.
+
+2010-05-06 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+ PR other/43620
+ * configure.ac (AM_INIT_AUTOMAKE): Add no-dist.
+ * configure: Regenerate.
+ * aclocal.m4: Regenerate.
+ * config.h.in: Regenerate.
+ * Makefile.in: Regenerate.
+ * testsuite/Makefile.in: Regenerate.
+
+2009-08-19 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/41102
+ omp_lib.h.in: Fix -std=f95 errors.
+
+2009-08-14 Uros Bizjak <ubizjak@gmail.com>
+
+ Backport from mainline:
+ 2008-12-26 Uros Bizjak <ubizjak@gmail.com>
+
+ * testsuite/libgomp.c/atomic-6.c: Add -mieee for alpha*-*-* targets.
+
+2009-08-04 Release Manager
+
+ * GCC 4.3.4 released.
+
+2009-01-24 Release Manager
+
+ * GCC 4.3.3 released.
+
+2008-12-05 Janis Johnson <janis187@us.ibm.com>
+
+ Backport from mainline:
+ 2008-05-15 Janis Johnson <janis187@us.ibm.com>
+
+ * testsuite/lib/libgomp.exp: Load new torture support.
+
+2008-12-02 Janis Johnson <janis187@us.ibm.com>
+
+ Backport from mainline:
+ 2008-11-26 Janis Johnson <janis187@us.ibm.com>
+
+ PR testsuite/28870
+ * testsuite/lib/libgomp.exp: Include new timeout library files.
+ (libgomp_target_compile): Set timeout value from new proc.
+
+2008-08-27 Release Manager
+
+ * GCC 4.3.2 released.
+
+2008-06-12 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/36506
+ * testsuite/libgomp.c/reduction-5.c: New test.
+
+2008-06-06 Release Manager
+
+ * GCC 4.3.1 released.
+
+2008-05-23 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/36308
+ * testsuite/libgomp.c++/ctor-11.C: New test.
+ * testsuite/libgomp.c++/ctor-12.C: New test.
+
+2008-05-07 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/36106
+ * testsuite/libgomp.c/atomic-5.c: New test.
+ * testsuite/libgomp.c/atomic-6.c: New test.
+ * testsuite/libgomp.c/autopar-1.c: New test.
+
+2008-03-18 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/35611
+ * testsuite/libgomp.c/atomic-4.c: New test.
+
+ PR libgomp/35625
+ * iter.c (gomp_iter_guided_next_locked): If q > n, set end to ws->end.
+ (gomp_iter_guided_next): Likewise.
+ * testsuite/libgomp.c/pr35625.c: New test.
+
+2008-03-13 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/35185
+ * testsuite/libgomp.c++/pr35185.C: New test.
+
+2008-03-12 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/35549
+ * testsuite/libgomp.c/pr35549.c: New test.
+
+2008-03-06 Jakub Jelinek <jakub@redhat.com>
+
+ * testsuite/libgomp.c/atomic-3.c: New test.
+
+2008-03-05 Release Manager
+
+ * GCC 4.3.0 released.
+
+2008-02-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/35196
+ * testsuite/libgomp.c/pr35196.c: New test.
+
+ PR middle-end/35130
+ * testsuite/libgomp.fortran/pr35130.f90: New test.
+ * testsuite/libgomp.c/pr35130.c: New test.
+
+2008-01-25 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/33880
+ * testsuite/libgomp.c/pr33880.c: New test.
+ * testsuite/libgomp.fortran/pr33880.f90: New test.
+
+2008-01-24 David Edelsohn <edelsohn@gnu.org>
+
+ * configure: Regenerate.
+
+2008-01-08 Jakub Jelinek <jakub@redhat.com>
+
+ * configure.ac: Move futex checking into ../config/futex.m4.
+ * configure: Rebuilt.
+ * aclocal.m4: Rebuilt.
+ * Makefile.in: Rebuilt.
+
+ * configure.tgt: Rename have_tls to gcc_cv_have_tls to match
+ 2007-10-15 ../config/tls.m4 change.
+
+2007-12-19 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/34513
+ * testsuite/libgomp.c/pr34513.c: New test.
+ * testsuite/libgomp.c++/pr34513.C: New test.
+
+2007-12-17 Jack Howarth <howarth@bromo.med.uc.edu>
+
+ PR target/32765
+ * testsuite/libgomp.fortran/crayptr2.f90: Move dg-options for darwin.
+
+2007-12-04 Jakub Jelinek <jakub@redhat.com>
+
+ * omp.h.in (__GOMP_NOTHROW): Define. Use it on omp_* prototypes.
+
+2007-12-03 Jakub Jelinek <jakub@redhat.com>
+
+ * testsuite/libgomp.c/private-1.c: New test.
+
+2007-11-29 Andris Pavenis <andris.pavenis@iki.fi>
+ Paolo Bonzini <bonzini@gnu.org>
+
+ * Makefile.am: Use space as vpath separator. Use 'vpath %'
+ instead of 'VPATH ='.
+ * Makefile.in: Regenerate.
+
+2007-11-23 Matthias Klose <doko@ubuntu.com>
+
+ * configure.ac: Adjust makeinfo version check.
+ * configure: Regenerate.
+
+2007-11-10 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/34020
+ * testsuite/libgomp.fortran/pr34020.f90: New test.
+
+2007-11-06 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/33894
+ * testsuite/libgomp.c++/atomic-1.C: New test.
+
+2007-10-25 Jakub Jelinek <jakub@redhat.com>
+
+ PR libgomp/33275
+ * testsuite/libgomp.fortran/omp_parse3.f90 (test_threadprivate):
+ Make x and y integers rather than (implicit) reals. Add private (j)
+ clause to the last omp parallel.
+
+2007-10-15 Maciej W. Rozycki <macro@linux-mips.org>
+
+ * configure: Regenerate following changes to ../config/tls.m4.
+
+2007-09-28 Jakub Jelinek <jakub@redhat.com>
+
+ * testsuite/libgomp.fortran/stack.f90: New test.
+
+2007-09-10 Danny Smith <dannysmith@users.sourceforge.net>
+
+ * config/mingw32/proc.c: New file.
+
+2007-09-05 Uros Bizjak <ubizjak@gmail.com>
+
+ * testsuite/libgomp.c/atomic-1.c: Include cpuid.h for i386 targets.
+ (main): Use __get_cpuid to get i386 target fetaures.
+ * testsuite/libgomp.c/atomic-2.c: Include cpuid.h for x86_64 targets.
+ (main): Use __get_cpuid to get x86_64 target fetaures.
+
+2007-08-15 Jack Howarth <howarth@bromo.med.uc.edu>
+
+ PR target/32765
+ * testsuite/libgomp.fortran/pr32550.f90: Use -static-libgcc on Darwin.
+ * testsuite/libgomp.fortran/crayptr2.f90: Likwise.
+
+2007-07-12 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/32550
+ * testsuite/libgomp.fortran/pr32550.f90: New test.
+ * testsuite/libgomp.fortran/crayptr2.f90: New test.
+
+2007-07-05 H.J. Lu <hongjiu.lu@intel.com>
+
+ * aclocal.m4: Regenerated.
+
+2007-07-05 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/32359
+ * testsuite/libgomp.fortran/pr32359.f90: New.
2007-07-02 Jakub Jelinek <jakub@redhat.com>
@@ -21,9 +238,117 @@
* testsuite/libgomp.c/pr32362-2.c: New test.
* testsuite/libgomp.c/pr32362-3.c: New test.
-2007-05-13 Release Manager
+2007-06-07 Jakub Jelinek <jakub@redhat.com>
+
+ * team.c (gomp_team_start): Fix setting up thread_attr
+ stack size.
+
+2007-06-02 Paolo Bonzini <bonzini@gnu.org>
+
+ * configure: Regenerate.
+
+2007-05-23 Steve Ellcey <sje@cup.hp.com>
+
+ * Makefile.in: Regenerate.
+ * configure: Regenerate.
+ * aclocal.m4: Regenerate.
+ * testsuite/Makefile.in: Regenerate.
+
+2007-05-04 Jakub Jelinek <jakub@redhat.com>
+
+ * config/linux/proc.c: New file.
+
+ PR libgomp/28482
+ * configure.tgt: Don't link with -Wl,-z,nodlopen even on Linux.
+
+2007-04-19 Daniel Franke <franke.daniel@gmail.com>
- * GCC 4.2.0 released.
+ * libgomp.texi (GOMP_CPU_AFFINITY): Updated.
+
+2007-04-16 Matthias Klose <doko@debian.org>
+
+ * configure.tgt (i[456]86-*-linux*): Only add ia32 specific
+ flags if not building with -m64.
+ * testsuite/lib/libgomp-dg.exp (libgomp_init): Don't add -march
+ flag for i?86-*-* targets, if current target matches -m64.
+
+2007-04-14 Steve Ellcey <sje@cup.hp.com>
+
+ * Makefile.am: Add -I .. to ACLOCAL_AMFLAGS.
+ * Makefile.in: Regenerate.
+
+2007-04-07 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
+
+ PR testsuite/31369
+ * testsuite/libgomp.c++/c++.exp: Don't use concat when setting
+ ld_library_path.
+ * testsuite/libgomp.fortran/fortran.exp: Likewise.
+
+2007-04-04 Jakub Jelinek <jakub@redhat.com>
+
+ * libgomp.h (gomp_cpu_affinity, gomp_cpu_affinity_len): New extern
+ decls.
+ (gomp_init_affinity, gomp_init_thread_affinity): New prototypes.
+ * env.c (gomp_cpu_affinity, gomp_cpu_affinity_len): New variables.
+ (parse_affinity): New function.
+ (initialize_env): Call it and gomp_init_affinity.
+ * team.c (gomp_team_start): If gomp_cpu_affinity != NULL,
+ create new pthread_attr_t and call gomp_init_thread_affinity
+ on it for each thread before passing the attribute to pthread_create.
+ * config/linux/affinity.c: New file.
+ * config/posix/affinity.c: New file.
+ * configure.ac (HAVE_PTHREAD_AFFINITY_NP): New test.
+ * configure: Rebuilt.
+ * config.h.in: Rebuilt.
+ * Makefile.am (libgomp_la_SOURCES): Add affinity.c.
+ * Makefile.in: Rebuilt.
+
+2007-03-23 Andreas Tobler <a.tobler@schweiz.org>
+
+ * testsuite/lib/libgomp.exp (libgomp_init): Add -shared-libgcc for
+ *-*-darwin*.
+ * testsuite/libgomp.c++/c++.exp: Look for shared libstdc++ library
+ and use it if found.
+
+2007-03-18 Uros Bizjak <ubizjak@gmail.com>
+
+ * testsuite/config/default.exp: New file.
+ * testsuite/lib/libgomp.exp: New file.
+ * testsuite/lib/libgomp.dg (load_gcc_lib, libgomp_init,
+ libgomp_target_compile, libgomp_option_help, libgomp_option_proc,
+ load_lib *, load_gcc_lib *): Move to libgomp.exp.
+ (libgomp_load): Remove.
+ * testsuite/lib/libgomp.exp (libgomp_init): Compute
+ always_ld_library_path, not ld_library_path. Set additional_flags
+ to -march=i486 for ilp32 x86_64-*-* and i386-*-* targets.
+ (target_compile): Do not call libgomp_init. Append lang_library_path
+ and lang_link_flags to options.
+ * testsuite/libgomp.c/c.exp: Set DEFAULT_FLAGS to -O2. Set
+ ld_library_path from always_ld_library_path. Set LD_LIBRARY_PATH
+ here.
+ * testsuite/libgomp.c++/c++.exp: Set ld_library_path from
+ always_ld_library_path. Set LD_LIBRARY_PATH here.
+ * testsuite/libgomp.fortran/fortran.exp: Ditto.
+ * testsuite/libgomp.c/atomic-1.c: Set dg-options to
+ "-O2 -march=pentium" for ilp32 x86 targets. Simplify check for
+ CX8 flag.
+ * testsuite/libgomp.c/atomic-2.c: Set dg-options to "-O2 -mcx16" for
+ lp64 x86 targets. Do not check for SSE3 bit. Do not define bit_SSE3.
+ * testsuite/libgomp.c/pr29947-1.c: Remove default dg-options.
+ * testsuite/libgomp.c/pr29947-1.c: Ditto.
+ * testsuite/libgomp.c/atomic-10.c: Ditto.
+
+2007-03-21 Jakub Jelinek <jakub@redhat.com>
+
+ * testsuite/libgomp.fortran/appendix-a/a.22.8.f90: Add
+ dg-final cleanup-modules line.
+ * testsuite/libgomp.fortran/appendix-a/a.40.1.f90: Likewise.
+ * testsuite/libgomp.fortran/appendix-a/a.31.5.f90: Likewise.
+ * testsuite/libgomp.fortran/appendix-a/a.31.4.f90: Likewise.
+ * testsuite/libgomp.fortran/threadprivate2.f90: Likewise.
+ * testsuite/libgomp.fortran/reduction5.f90: Likewise.
+ * testsuite/libgomp.fortran/threadprivate3.f90: Likewise.
+ * testsuite/libgomp.fortran/threadprivate1.f90: Likewise.
2007-03-18 Andreas Schwab <schwab@suse.de>
@@ -31,15 +356,32 @@
extraction.
* configure: Regenerate.
+2007-03-01 Brooks Moses <brooks.moses@codesourcery.com>
+
+ * Makefile.am: Add install-pdf target as copied from
+ automake v1.10 rules.
+ * Makefile.in: Regenerate
+
2007-02-07 Jakub Jelinek <jakub@redhat.com>
+ PR libgomp/28486
+ * configure: Regenerate.
+
PR c++/30703
* testsuite/libgomp.c++/pr30703.C: New test.
-2007-02-07 Daniel Franke <franke.daniel@gmail.com>
+2007-02-02 Jakub Jelinek <jakub@redhat.com>
- Backport from mainline:
- 2007-01-31 Daniel Franke <franke.daniel@gmail.com>
+ Revert:
+ 2006-07-05 Eric Christopher <echristo@apple.com>
+ * configure.ac: Depend addition of -pthread on host OS.
+ * configure: Regenerate.
+
+2007-01-31 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+ * libgomp.texi: Fix spacing after abbreviations.
+
+2007-01-31 Daniel Franke <franke.daniel@gmail.com>
PR libgomp/30546
* configure.ac: Add check for makeinfo
@@ -50,74 +392,47 @@
* Makefile.in: Regenerated.
* testsuite/Makefile.in: Regenerated.
-2007-02-07 Daniel Franke <franke.daniel@gmail.com>
-
- Backport from mainline:
- 2007-01-31 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
-
- * libgomp.texi: Fix spacing after abbreviations.
-
- Backport from mainline:
- 2007-01-29 Daniel Franke <franke.daniel@gmail.com>
+2007-01-29 Daniel Franke <franke.daniel@gmail.com>
PR libgomp/30540
* libgomp.texi: More about implementation-dependent settings.
-2007-02-06 Roger Sayle <roger@eyesopen.com>
+2007-01-26 Tobias Burnus <burnus@net-b.de>
- PR libgomp/28296
- Backport from mainline.
- Revert:
- 2006-07-05 Eric Christopher <echristo@apple.com>
- * configure.ac: Depend addition of -pthread on host OS.
- * configure: Regenerate.
+ * testsuite/libgomp.fortran/fortran.exp: Support .f03 extension.
-2007-01-30 Tobias Burnus <burnus@net-b.de>
+2007-01-24 Jakub Jelinek <jakub@redhat.com>
- Backport from mainline.
- 2007-01-26 Tobias Burnus <burnus@net-b.de>
+ PR middle-end/30494
+ * testsuite/libgomp.c/pr30494.c: New test.
- * testsuite/libgomp.fortran/fortran.exp: Support .f03 extension.
+2007-01-15 Tom Tromey <tromey@redhat.com>
-2007-01-25 Daniel Franke <franke.daniel@gmail.com>
+ * configure: Rebuilt.
+ * configure.ac: Fixed comment.
- Backport from mainline:
- 2006-12-21 Daniel Franke <franke.daniel@gmail.com>
+2007-01-14 Daniel Franke <franke.daniel@gmail.com>
+
+ * libgomp.texi: Document implementation specific default values of
+ environment variables.
+
+2006-12-21 Daniel Franke <franke.daniel@gmail.com>
PR libgomp/28209
* libgomp.texi: New file.
* configure.ac: Add --enable-generated-files-in-srcdir option.
- * Makefile.am: Add info, dvi, pdf, html targets. On request,
- copy files to srcdir.
+ * Makefile.am: Add info, dvi, pdf, html targets. On request, copy
+ files to srcdir.
* Makefile.in: Regenerated.
+ * config.h.in: Regenerated.
* testsuite/Makefile.in: Regenerated.
* NOTES: Removed.
- Backport from mainline:
- 2007-01-14 Daniel Franke <franke.daniel@gmail.com>
- * libgomp.texi: Document implementation specific default values of
- environment variables.
-
-2007-01-24 Jakub Jelinek <jakub@redhat.com>
-
- PR middle-end/30494
- * testsuite/libgomp.c/pr30494.c: New test.
-
-2006-12-18 Daniel Franke <franke.daniel@gmail.com>
-
- Backport from mainline:
- 2006-12-04 Daniel Franke <franke.daniel@gmail.com>
+2006-12-04 Daniel Franke <franke.daniel@gmail.com>
PR libgomp/29949
* env.c (omp_set_num_threads): Set illegal thread count to 1.
- Backport from mainline:
- 2006-11-09 Uros Bizjak <ubizjak@gmail.com>
-
- * env.c (parse_schedule): Reject out of range values.
- (parse_unsigned_long): Reject out of range, negative
- or zero values.
-
2006-12-04 Eric Botcazou <ebotcazou@libertysurf.fr>
* configure: Regenerate.
@@ -135,6 +450,15 @@
* configure.tgt: Force initial-exec TLS model on Linux only.
+2006-11-13 Daniel Jacobowitz <dan@codesourcery.com>
+
+ * configure: Regenerated.
+
+2006-11-09 Uros Bizjak <ubizjak@gmail.com>
+
+ * env.c (parse_schedule): Reject out of range values.
+ (parse_unsigned_long): Reject out of range, negative or zero values.
+
2006-10-29 Jakub Jelinek <jakub@redhat.com>
PR fortran/29629
diff --git a/contrib/gcclibs/libgomp/ChangeLog.gcc44 b/contrib/gcclibs/libgomp/ChangeLog.gcc44
new file mode 100644
index 0000000..234d010
--- /dev/null
+++ b/contrib/gcclibs/libgomp/ChangeLog.gcc44
@@ -0,0 +1,8 @@
+2008-09-19 Jakub Jelinek <jakub@redhat.com> (r140497)
+ Andreas Tobler <a.tobler@schweiz.org>
+
+ * config/bsd/proc.c: New file.
+ * configure.tgt (*-*-darwin*): Use config_path "darwin posix".
+ * configure.ac: Check for header <sys/sysctl.h>
+ * configure: Regenerate.
+ * config.h.in: Likewise.
diff --git a/contrib/gcclibs/libgomp/Makefile.am b/contrib/gcclibs/libgomp/Makefile.am
index c2bfbea..55e3bf3 100644
--- a/contrib/gcclibs/libgomp/Makefile.am
+++ b/contrib/gcclibs/libgomp/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in
-ACLOCAL_AMFLAGS = -I ../config
+ACLOCAL_AMFLAGS = -I .. -I ../config
SUBDIRS = testsuite
## May be used by toolexeclibdir.
@@ -12,9 +12,7 @@ search_path = $(addprefix $(top_srcdir)/config/, $(config_path)) $(top_srcdir)
fincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/finclude
libsubincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
-empty =
-space = $(empty) $(empty)
-VPATH = $(subst $(space),:,$(strip $(search_path)))
+vpath % $(strip $(search_path))
AM_CPPFLAGS = $(addprefix -I, $(search_path))
AM_CFLAGS = $(XCFLAGS)
@@ -33,7 +31,7 @@ libgomp_la_LDFLAGS = $(libgomp_version_info) $(libgomp_version_script)
libgomp_la_SOURCES = alloc.c barrier.c critical.c env.c error.c iter.c \
loop.c ordered.c parallel.c sections.c single.c team.c work.c \
- lock.c mutex.c proc.c sem.c bar.c time.c fortran.c
+ lock.c mutex.c proc.c sem.c bar.c time.c fortran.c affinity.c
nodist_noinst_HEADERS = libgomp_f.h
nodist_libsubinclude_HEADERS = omp.h
@@ -51,10 +49,19 @@ env.lo: libgomp_f.h
env.o: libgomp_f.h
-# No install-html target
-.PHONY: install-html
+# No install-html or install-pdf support in automake yet
+.PHONY: install-html install-pdf
install-html:
+install-pdf: $(PDFS)
+ @$(NORMAL_INSTALL)
+ test -z "$(pdfdir)" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)"
+ @list='$(PDFS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/$$f'"; \
+ $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/$$f"; \
+ done
# Automake Documentation:
# If your package has Texinfo files in many directories, you can use the
diff --git a/contrib/gcclibs/libgomp/Makefile.in b/contrib/gcclibs/libgomp/Makefile.in
index 7fee1cc..57daccc 100644
--- a/contrib/gcclibs/libgomp/Makefile.in
+++ b/contrib/gcclibs/libgomp/Makefile.in
@@ -17,6 +17,7 @@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
+VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
@@ -37,24 +38,27 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
-DIST_COMMON = $(am__configure_deps) $(srcdir)/../config.guess \
- $(srcdir)/../config.sub $(srcdir)/../depcomp \
- $(srcdir)/../install-sh $(srcdir)/../ltmain.sh \
- $(srcdir)/../missing $(srcdir)/../mkinstalldirs \
- $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
- $(srcdir)/config.h.in $(srcdir)/libgomp.spec.in \
- $(srcdir)/libgomp_f.h.in $(srcdir)/omp.h.in \
- $(srcdir)/omp_lib.f90.in $(srcdir)/omp_lib.h.in \
- $(top_srcdir)/configure ChangeLog
+DIST_COMMON = $(srcdir)/../config.guess $(srcdir)/../config.sub \
+ ChangeLog $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+ $(top_srcdir)/configure $(am__configure_deps) \
+ $(srcdir)/config.h.in $(srcdir)/../mkinstalldirs \
+ $(srcdir)/omp.h.in $(srcdir)/omp_lib.h.in \
+ $(srcdir)/omp_lib.f90.in $(srcdir)/libgomp_f.h.in \
+ $(srcdir)/libgomp.spec.in $(srcdir)/../depcomp \
+ $(srcdir)/../ltmain.sh $(srcdir)/../config.guess \
+ $(srcdir)/../config.sub
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
$(top_srcdir)/../config/depstand.m4 \
$(top_srcdir)/../config/enable.m4 \
+ $(top_srcdir)/../config/futex.m4 \
$(top_srcdir)/../config/lead-dot.m4 \
$(top_srcdir)/../config/multi.m4 \
$(top_srcdir)/../config/stdint.m4 \
- $(top_srcdir)/../config/tls.m4 $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/../config/tls.m4 $(top_srcdir)/../ltoptions.m4 \
+ $(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \
+ $(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/../libtool.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
@@ -79,21 +83,20 @@ libgomp_la_LIBADD =
am_libgomp_la_OBJECTS = alloc.lo barrier.lo critical.lo env.lo \
error.lo iter.lo loop.lo ordered.lo parallel.lo sections.lo \
single.lo team.lo work.lo lock.lo mutex.lo proc.lo sem.lo \
- bar.lo time.lo fortran.lo
+ bar.lo time.lo fortran.lo affinity.lo
libgomp_la_OBJECTS = $(am_libgomp_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
depcomp = $(SHELL) $(top_srcdir)/../depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \
+LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
-LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libgomp_la_SOURCES)
-DIST_SOURCES = $(libgomp_la_SOURCES)
MULTISRCTOP =
MULTIBUILDTOP =
MULTIDIRS =
@@ -126,18 +129,6 @@ HEADERS = $(nodist_finclude_HEADERS) $(nodist_libsubinclude_HEADERS) \
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-distdir = $(PACKAGE)-$(VERSION)
-top_distdir = $(distdir)
-am__remove_distdir = \
- { test ! -d $(distdir) \
- || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
- && rm -fr $(distdir); }; }
-DIST_ARCHIVES = $(distdir).tar.gz
-GZIP_ENV = --best
-distuninstallcheck_listfiles = find . -type f -print
-distcleancheck_listfiles = find . -type f -print
-VPATH = $(subst $(space),:,$(strip $(search_path)))
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
@@ -157,6 +148,7 @@ CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
@@ -164,12 +156,15 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FC = @FC@
FCFLAGS = @FCFLAGS@
+FGREP = @FGREP@
GENINSRC_FALSE = @GENINSRC_FALSE@
GENINSRC_TRUE = @GENINSRC_TRUE@
+GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
LDFLAGS = @LDFLAGS@
LIBGOMP_BUILD_VERSIONED_SHLIB_FALSE = @LIBGOMP_BUILD_VERSIONED_SHLIB_FALSE@
LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE = @LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@
@@ -182,6 +177,7 @@ MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
+NM = @NM@
OBJEXT = @OBJEXT@
OMP_LOCK_ALIGN = @OMP_LOCK_ALIGN@
OMP_LOCK_KIND = @OMP_LOCK_KIND@
@@ -200,6 +196,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
PERL = @PERL@
RANLIB = @RANLIB@
SECTION_LDFLAGS = @SECTION_LDFLAGS@
+SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
@@ -210,6 +207,7 @@ XCFLAGS = @XCFLAGS@
XLDFLAGS = @XLDFLAGS@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
ac_ct_FC = @ac_ct_FC@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
@@ -244,6 +242,7 @@ libexecdir = @libexecdir@
libtool_VERSION = @libtool_VERSION@
link_gomp = @link_gomp@
localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
mandir = @mandir@
mkdir_p = @mkdir_p@
multi_basedir = @multi_basedir@
@@ -260,14 +259,12 @@ target_os = @target_os@
target_vendor = @target_vendor@
toolexecdir = @toolexecdir@
toolexeclibdir = @toolexeclibdir@
-ACLOCAL_AMFLAGS = -I ../config
+ACLOCAL_AMFLAGS = -I .. -I ../config
SUBDIRS = testsuite
gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
search_path = $(addprefix $(top_srcdir)/config/, $(config_path)) $(top_srcdir)
fincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/finclude
libsubincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
-empty =
-space = $(empty) $(empty)
AM_CPPFLAGS = $(addprefix -I, $(search_path))
AM_CFLAGS = $(XCFLAGS)
AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS)
@@ -279,7 +276,7 @@ libgomp_version_info = -version-info $(libtool_VERSION)
libgomp_la_LDFLAGS = $(libgomp_version_info) $(libgomp_version_script)
libgomp_la_SOURCES = alloc.c barrier.c critical.c env.c error.c iter.c \
loop.c ordered.c parallel.c sections.c single.c team.c work.c \
- lock.c mutex.c proc.c sem.c bar.c time.c fortran.c
+ lock.c mutex.c proc.c sem.c bar.c time.c fortran.c affinity.c
nodist_noinst_HEADERS = libgomp_f.h
nodist_libsubinclude_HEADERS = omp.h
@@ -406,6 +403,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/affinity.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alloc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bar.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/barrier.Plo@am__quote@
@@ -733,152 +731,6 @@ GTAGS:
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-
-distdir: $(DISTFILES)
- $(am__remove_distdir)
- mkdir $(distdir)
- $(mkdir_p) $(distdir)/. $(distdir)/.. $(distdir)/../config
- @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
- list='$(DISTFILES)'; for file in $$list; do \
- case $$file in \
- $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
- $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
- esac; \
- if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
- dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
- if test "$$dir" != "$$file" && test "$$dir" != "."; then \
- dir="/$$dir"; \
- $(mkdir_p) "$(distdir)$$dir"; \
- else \
- dir=''; \
- fi; \
- if test -d $$d/$$file; then \
- if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
- fi; \
- cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
- else \
- test -f $(distdir)/$$file \
- || cp -p $$d/$$file $(distdir)/$$file \
- || exit 1; \
- fi; \
- done
- list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
- if test "$$subdir" = .; then :; else \
- test -d "$(distdir)/$$subdir" \
- || $(mkdir_p) "$(distdir)/$$subdir" \
- || exit 1; \
- distdir=`$(am__cd) $(distdir) && pwd`; \
- top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
- (cd $$subdir && \
- $(MAKE) $(AM_MAKEFLAGS) \
- top_distdir="$$top_distdir" \
- distdir="$$distdir/$$subdir" \
- distdir) \
- || exit 1; \
- fi; \
- done
- $(MAKE) $(AM_MAKEFLAGS) \
- top_distdir="$(top_distdir)" distdir="$(distdir)" \
- dist-info
- -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
- ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
- ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
- ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
- || chmod -R a+r $(distdir)
-dist-gzip: distdir
- tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
- $(am__remove_distdir)
-
-dist-bzip2: distdir
- tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
- $(am__remove_distdir)
-
-dist-tarZ: distdir
- tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
- $(am__remove_distdir)
-
-dist-shar: distdir
- shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
- $(am__remove_distdir)
-
-dist-zip: distdir
- -rm -f $(distdir).zip
- zip -rq $(distdir).zip $(distdir)
- $(am__remove_distdir)
-
-dist dist-all: distdir
- tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
- $(am__remove_distdir)
-
-# This target untars the dist file and tries a VPATH configuration. Then
-# it guarantees that the distribution is self-contained by making another
-# tarfile.
-distcheck: dist
- case '$(DIST_ARCHIVES)' in \
- *.tar.gz*) \
- GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
- *.tar.bz2*) \
- bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
- *.tar.Z*) \
- uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
- *.shar.gz*) \
- GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
- *.zip*) \
- unzip $(distdir).zip ;;\
- esac
- chmod -R a-w $(distdir); chmod a+w $(distdir)
- mkdir $(distdir)/_build
- mkdir $(distdir)/_inst
- chmod a-w $(distdir)
- dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
- && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
- && cd $(distdir)/_build \
- && ../configure --srcdir=.. --prefix="$$dc_install_base" \
- $(DISTCHECK_CONFIGURE_FLAGS) \
- && $(MAKE) $(AM_MAKEFLAGS) \
- && $(MAKE) $(AM_MAKEFLAGS) dvi \
- && $(MAKE) $(AM_MAKEFLAGS) check \
- && $(MAKE) $(AM_MAKEFLAGS) install \
- && $(MAKE) $(AM_MAKEFLAGS) installcheck \
- && $(MAKE) $(AM_MAKEFLAGS) uninstall \
- && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
- distuninstallcheck \
- && chmod -R a-w "$$dc_install_base" \
- && ({ \
- (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
- && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
- && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
- && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
- distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
- } || { rm -rf "$$dc_destdir"; exit 1; }) \
- && rm -rf "$$dc_destdir" \
- && $(MAKE) $(AM_MAKEFLAGS) dist \
- && rm -rf $(DIST_ARCHIVES) \
- && $(MAKE) $(AM_MAKEFLAGS) distcleancheck
- $(am__remove_distdir)
- @(echo "$(distdir) archives ready for distribution: "; \
- list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
- sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}'
-distuninstallcheck:
- @cd $(distuninstallcheck_dir) \
- && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
- || { echo "ERROR: files left after uninstall:" ; \
- if test -n "$(DESTDIR)"; then \
- echo " (check DESTDIR support)"; \
- fi ; \
- $(distuninstallcheck_listfiles) ; \
- exit 1; } >&2
-distcleancheck: distclean
- @if test '$(srcdir)' = . ; then \
- echo "ERROR: distcleancheck can only run from a VPATH build" ; \
- exit 1 ; \
- fi
- @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
- || { echo "ERROR: files left in build directory after distclean:" ; \
- $(distcleancheck_listfiles) ; \
- exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile $(INFO_DEPS) $(LTLIBRARIES) all-multi $(HEADERS) \
@@ -1011,16 +863,13 @@ uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am all-local \
all-multi am--refresh check check-am clean clean-generic \
clean-libtool clean-multi clean-recursive \
- clean-toolexeclibLTLIBRARIES ctags ctags-recursive dist \
- dist-all dist-bzip2 dist-gzip dist-info dist-shar dist-tarZ \
- dist-zip distcheck distclean distclean-compile \
- distclean-generic distclean-hdr distclean-libtool \
- distclean-multi distclean-recursive distclean-tags \
- distcleancheck distdir distuninstallcheck dvi dvi-am html \
- html-am info info-am install install-am install-data \
- install-data-am install-exec install-exec-am install-info \
- install-info-am install-man install-multi \
- install-nodist_fincludeHEADERS \
+ clean-toolexeclibLTLIBRARIES ctags ctags-recursive dist-info \
+ distclean distclean-compile distclean-generic distclean-hdr \
+ distclean-libtool distclean-multi distclean-recursive \
+ distclean-tags dvi dvi-am html html-am info info-am install \
+ install-am install-data install-data-am install-exec \
+ install-exec-am install-info install-info-am install-man \
+ install-multi install-nodist_fincludeHEADERS \
install-nodist_libsubincludeHEADERS \
install-nodist_toolexeclibHEADERS install-strip \
install-toolexeclibLTLIBRARIES installcheck installcheck-am \
@@ -1036,6 +885,8 @@ uninstall-info: uninstall-info-recursive
uninstall-toolexeclibLTLIBRARIES
+vpath % $(strip $(search_path))
+
omp_lib_kinds.mod: omp_lib.mod
:
omp_lib.mod: omp_lib.f90
@@ -1045,10 +896,20 @@ fortran.o: libgomp_f.h
env.lo: libgomp_f.h
env.o: libgomp_f.h
-# No install-html target
-.PHONY: install-html
+# No install-html or install-pdf support in automake yet
+.PHONY: install-html install-pdf
install-html:
+install-pdf: $(PDFS)
+ @$(NORMAL_INSTALL)
+ test -z "$(pdfdir)" || $(mkinstalldirs) "$(DESTDIR)$(pdfdir)"
+ @list='$(PDFS)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(INSTALL_DATA) '$$d$$p' '$(DESTDIR)$(pdfdir)/$$f'"; \
+ $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(pdfdir)/$$f"; \
+ done
+
all-local: $(STAMP_GENINSRC)
stamp-geninsrc: libgomp.info
diff --git a/contrib/gcclibs/libgomp/aclocal.m4 b/contrib/gcclibs/libgomp/aclocal.m4
index 31c2eec..eee6ec0 100644
--- a/contrib/gcclibs/libgomp/aclocal.m4
+++ b/contrib/gcclibs/libgomp/aclocal.m4
@@ -859,8 +859,13 @@ AC_SUBST([am__untar])
m4_include([../config/acx.m4])
m4_include([../config/depstand.m4])
m4_include([../config/enable.m4])
+m4_include([../config/futex.m4])
m4_include([../config/lead-dot.m4])
m4_include([../config/multi.m4])
m4_include([../config/stdint.m4])
m4_include([../config/tls.m4])
+m4_include([../ltoptions.m4])
+m4_include([../ltsugar.m4])
+m4_include([../ltversion.m4])
+m4_include([../lt~obsolete.m4])
m4_include([acinclude.m4])
diff --git a/contrib/gcclibs/libgomp/config.h.in b/contrib/gcclibs/libgomp/config.h.in
index 0c15993..fa4206b 100644
--- a/contrib/gcclibs/libgomp/config.h.in
+++ b/contrib/gcclibs/libgomp/config.h.in
@@ -12,9 +12,15 @@
/* Define if the POSIX Semaphores do not work on your system. */
#undef HAVE_BROKEN_POSIX_SEMAPHORES
+/* Define to 1 if the target assembler supports thread-local storage. */
+#undef HAVE_CC_TLS
+
/* Define to 1 if you have the `clock_gettime' function. */
#undef HAVE_CLOCK_GETTIME
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
/* Define to 1 if you have the `getloadavg' function. */
#undef HAVE_GETLOADAVG
@@ -24,6 +30,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
+/* Define if pthread_{,attr_}{g,s}etaffinity_np is supported. */
+#undef HAVE_PTHREAD_AFFINITY_NP
+
/* Define to 1 if you have the <semaphore.h> header file. */
#undef HAVE_SEMAPHORE_H
@@ -48,6 +57,9 @@
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
+/* Define to 1 if you have the <sys/sysctl.h> header file. */
+#undef HAVE_SYS_SYSCTL_H
+
/* Define to 1 if you have the <sys/time.h> header file. */
#undef HAVE_SYS_TIME_H
@@ -60,6 +72,10 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#undef LT_OBJDIR
+
/* Name of package */
#undef PACKAGE
diff --git a/contrib/gcclibs/libgomp/config/bsd/proc.c b/contrib/gcclibs/libgomp/config/bsd/proc.c
new file mode 100644
index 0000000..513d8df
--- /dev/null
+++ b/contrib/gcclibs/libgomp/config/bsd/proc.c
@@ -0,0 +1,117 @@
+/* Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
+ Contributed by Richard Henderson <rth@redhat.com>.
+
+ This file is part of the GNU OpenMP Library (libgomp).
+
+ Libgomp is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ Libgomp 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 Lesser General Public License for
+ more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with libgomp; see the file COPYING.LIB. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA. */
+
+/* As a special exception, if you link this library with other files, some
+ of which are compiled with GCC, to produce an executable, this library
+ does not by itself 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 contains system specific routines related to counting
+ online processors and dynamic load balancing. It is expected that
+ a system may well want to write special versions of each of these.
+
+ The following implementation uses a mix of POSIX and BSD routines. */
+
+#include "libgomp.h"
+#include <unistd.h>
+#include <stdlib.h>
+#ifdef HAVE_GETLOADAVG
+# ifdef HAVE_SYS_LOADAVG_H
+# include <sys/loadavg.h>
+# endif
+#endif
+#ifdef HAVE_SYS_SYSCTL_H
+# include <sys/sysctl.h>
+#endif
+
+static int
+get_num_procs (void)
+{
+#ifdef _SC_NPROCESSORS_ONLN
+ return sysconf (_SC_NPROCESSORS_ONLN);
+#elif defined HW_NCPU
+ int ncpus = 1;
+ size_t len = sizeof(ncpus);
+ sysctl((int[2]) {CTL_HW, HW_NCPU}, 2, &ncpus, &len, NULL, 0);
+ return ncpus;
+#else
+ return 0;
+#endif
+}
+
+/* At startup, determine the default number of threads. It would seem
+ this should be related to the number of cpus online. */
+
+void
+gomp_init_num_threads (void)
+{
+ int ncpus = get_num_procs ();
+
+ if (ncpus > 0)
+ gomp_global_icv.nthreads_var = ncpus;
+}
+
+/* When OMP_DYNAMIC is set, at thread launch determine the number of
+ threads we should spawn for this team. */
+/* ??? I have no idea what best practice for this is. Surely some
+ function of the number of processors that are *still* online and
+ the load average. Here I use the number of processors online
+ minus the 15 minute load average. */
+
+unsigned
+gomp_dynamic_max_threads (void)
+{
+ unsigned n_onln, loadavg;
+ unsigned nthreads_var = gomp_icv (false)->nthreads_var;
+
+ n_onln = get_num_procs ();
+ if (!n_onln || n_onln > nthreads_var)
+ n_onln = nthreads_var;
+
+ loadavg = 0;
+#ifdef HAVE_GETLOADAVG
+ {
+ double dloadavg[3];
+ if (getloadavg (dloadavg, 3) == 3)
+ {
+ /* Add 0.1 to get a kind of biased rounding. */
+ loadavg = dloadavg[2] + 0.1;
+ }
+ }
+#endif
+
+ if (loadavg >= n_onln)
+ return 1;
+ else
+ return n_onln - loadavg;
+}
+
+int
+omp_get_num_procs (void)
+{
+ int ncpus = get_num_procs ();
+ if (ncpus <= 0)
+ ncpus = gomp_icv (false)->nthreads_var;
+ return ncpus;
+}
+
+ialias (omp_get_num_procs)
diff --git a/contrib/gcclibs/libgomp/config/linux/affinity.c b/contrib/gcclibs/libgomp/config/linux/affinity.c
new file mode 100644
index 0000000..8fcce5f
--- /dev/null
+++ b/contrib/gcclibs/libgomp/config/linux/affinity.c
@@ -0,0 +1,107 @@
+/* Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+ Contributed by Jakub Jelinek <jakub@redhat.com>.
+
+ This file is part of the GNU OpenMP Library (libgomp).
+
+ Libgomp is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ Libgomp 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 Lesser General Public License for
+ more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with libgomp; see the file COPYING.LIB. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA. */
+
+/* As a special exception, if you link this library with other files, some
+ of which are compiled with GCC, to produce an executable, this library
+ does not by itself 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 is a Linux specific implementation of a CPU affinity setting. */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#include "libgomp.h"
+#include <sched.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#ifdef HAVE_PTHREAD_AFFINITY_NP
+
+static unsigned int affinity_counter;
+#ifndef HAVE_SYNC_BUILTINS
+static gomp_mutex_t affinity_lock;
+#endif
+
+void
+gomp_init_affinity (void)
+{
+ cpu_set_t cpuset;
+ size_t idx, widx;
+
+ if (pthread_getaffinity_np (pthread_self (), sizeof (cpuset), &cpuset))
+ {
+ gomp_error ("could not get CPU affinity set");
+ free (gomp_cpu_affinity);
+ gomp_cpu_affinity = NULL;
+ gomp_cpu_affinity_len = 0;
+ return;
+ }
+
+ for (widx = idx = 0; idx < gomp_cpu_affinity_len; idx++)
+ if (gomp_cpu_affinity[idx] < CPU_SETSIZE
+ && CPU_ISSET (gomp_cpu_affinity[idx], &cpuset))
+ gomp_cpu_affinity[widx++] = gomp_cpu_affinity[idx];
+
+ if (widx == 0)
+ {
+ gomp_error ("no CPUs left for affinity setting");
+ free (gomp_cpu_affinity);
+ gomp_cpu_affinity = NULL;
+ gomp_cpu_affinity_len = 0;
+ return;
+ }
+
+ gomp_cpu_affinity_len = widx;
+ CPU_ZERO (&cpuset);
+ CPU_SET (gomp_cpu_affinity[0], &cpuset);
+ pthread_setaffinity_np (pthread_self (), sizeof (cpuset), &cpuset);
+ affinity_counter = 1;
+#ifndef HAVE_SYNC_BUILTINS
+ gomp_mutex_init (&affinity_lock);
+#endif
+}
+
+void
+gomp_init_thread_affinity (pthread_attr_t *attr)
+{
+ unsigned int cpu;
+ cpu_set_t cpuset;
+
+#ifdef HAVE_SYNC_BUILTINS
+ cpu = __sync_fetch_and_add (&affinity_counter, 1);
+#else
+ gomp_mutex_lock (&affinity_lock);
+ cpu = affinity_counter++;
+ gomp_mutex_unlock (&affinity_lock);
+#endif
+ cpu %= gomp_cpu_affinity_len;
+ CPU_ZERO (&cpuset);
+ CPU_SET (gomp_cpu_affinity[cpu], &cpuset);
+ pthread_attr_setaffinity_np (attr, sizeof (cpu_set_t), &cpuset);
+}
+
+#else
+
+#include "../posix/affinity.c"
+
+#endif
diff --git a/contrib/gcclibs/libgomp/config/linux/proc.c b/contrib/gcclibs/libgomp/config/linux/proc.c
new file mode 100644
index 0000000..2267cfb
--- /dev/null
+++ b/contrib/gcclibs/libgomp/config/linux/proc.c
@@ -0,0 +1,179 @@
+/* Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+ Contributed by Jakub Jelinek <jakub@redhat.com>.
+
+ This file is part of the GNU OpenMP Library (libgomp).
+
+ Libgomp is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ Libgomp 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 Lesser General Public License for
+ more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with libgomp; see the file COPYING.LIB. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA. */
+
+/* As a special exception, if you link this library with other files, some
+ of which are compiled with GCC, to produce an executable, this library
+ does not by itself 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 contains system specific routines related to counting
+ online processors and dynamic load balancing. */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE 1
+#endif
+#include "libgomp.h"
+#include <sched.h>
+#include <stdlib.h>
+#include <unistd.h>
+#ifdef HAVE_GETLOADAVG
+# ifdef HAVE_SYS_LOADAVG_H
+# include <sys/loadavg.h>
+# endif
+#endif
+
+#ifdef HAVE_PTHREAD_AFFINITY_NP
+static unsigned long
+cpuset_popcount (cpu_set_t *cpusetp)
+{
+#ifdef CPU_COUNT
+ /* glibc 2.6 and above provide a macro for this. */
+ return CPU_COUNT (cpusetp);
+#else
+ size_t i;
+ unsigned long ret = 0;
+ extern int check[sizeof (cpusetp->__bits[0]) == sizeof (unsigned long int)];
+
+ (void) check;
+ for (i = 0; i < sizeof (*cpusetp) / sizeof (cpusetp->__bits[0]); i++)
+ {
+ unsigned long int mask = cpusetp->__bits[i];
+ if (mask == 0)
+ continue;
+ ret += __builtin_popcountl (mask);
+ }
+ return ret;
+#endif
+}
+#endif
+
+/* At startup, determine the default number of threads. It would seem
+ this should be related to the number of cpus online. */
+
+void
+gomp_init_num_threads (void)
+{
+#ifdef HAVE_PTHREAD_AFFINITY_NP
+ cpu_set_t cpuset;
+
+ if (pthread_getaffinity_np (pthread_self (), sizeof (cpuset), &cpuset) == 0)
+ {
+ /* Count only the CPUs this process can use. */
+ gomp_nthreads_var = cpuset_popcount (&cpuset);
+ if (gomp_nthreads_var == 0)
+ gomp_nthreads_var = 1;
+ return;
+ }
+#endif
+#ifdef _SC_NPROCESSORS_ONLN
+ gomp_nthreads_var = sysconf (_SC_NPROCESSORS_ONLN);
+#endif
+}
+
+static int
+get_num_procs (void)
+{
+#ifdef HAVE_PTHREAD_AFFINITY_NP
+ cpu_set_t cpuset;
+
+ if (gomp_cpu_affinity == NULL)
+ {
+ /* Count only the CPUs this process can use. */
+ if (pthread_getaffinity_np (pthread_self (), sizeof (cpuset),
+ &cpuset) == 0)
+ {
+ int ret = cpuset_popcount (&cpuset);
+ return ret != 0 ? ret : 1;
+ }
+ }
+ else
+ {
+ size_t idx;
+ static int affinity_cpus;
+
+ /* We can't use pthread_getaffinity_np in this case
+ (we have changed it ourselves, it binds to just one CPU).
+ Count instead the number of different CPUs we are
+ using. */
+ CPU_ZERO (&cpuset);
+ if (affinity_cpus == 0)
+ {
+ int cpus = 0;
+ for (idx = 0; idx < gomp_cpu_affinity_len; idx++)
+ if (! CPU_ISSET (gomp_cpu_affinity[idx], &cpuset))
+ {
+ cpus++;
+ CPU_SET (gomp_cpu_affinity[idx], &cpuset);
+ }
+ affinity_cpus = cpus;
+ }
+ return affinity_cpus;
+ }
+#endif
+#ifdef _SC_NPROCESSORS_ONLN
+ return sysconf (_SC_NPROCESSORS_ONLN);
+#else
+ return gomp_nthreads_var;
+#endif
+}
+
+/* When OMP_DYNAMIC is set, at thread launch determine the number of
+ threads we should spawn for this team. */
+/* ??? I have no idea what best practice for this is. Surely some
+ function of the number of processors that are *still* online and
+ the load average. Here I use the number of processors online
+ minus the 15 minute load average. */
+
+unsigned
+gomp_dynamic_max_threads (void)
+{
+ unsigned n_onln, loadavg;
+
+ n_onln = get_num_procs ();
+ if (n_onln > gomp_nthreads_var)
+ n_onln = gomp_nthreads_var;
+
+ loadavg = 0;
+#ifdef HAVE_GETLOADAVG
+ {
+ double dloadavg[3];
+ if (getloadavg (dloadavg, 3) == 3)
+ {
+ /* Add 0.1 to get a kind of biased rounding. */
+ loadavg = dloadavg[2] + 0.1;
+ }
+ }
+#endif
+
+ if (loadavg >= n_onln)
+ return 1;
+ else
+ return n_onln - loadavg;
+}
+
+int
+omp_get_num_procs (void)
+{
+ return get_num_procs ();
+}
+
+ialias (omp_get_num_procs)
diff --git a/contrib/gcclibs/libgomp/config/mingw32/proc.c b/contrib/gcclibs/libgomp/config/mingw32/proc.c
new file mode 100644
index 0000000..def7bb5
--- /dev/null
+++ b/contrib/gcclibs/libgomp/config/mingw32/proc.c
@@ -0,0 +1,82 @@
+/* Copyright (C) 2007 Free Software Foundation, Inc.
+ Contributed by Danny Smith <dannysmith@users.sourceforge.net>
+
+ This file is part of the GNU OpenMP Library (libgomp).
+
+ Libgomp is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ Libgomp 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 Lesser General Public License for
+ more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with libgomp; see the file COPYING.LIB. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA. */
+
+/* As a special exception, if you link this library with other files, some
+ of which are compiled with GCC, to produce an executable, this library
+ does not by itself 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 contains system specific routines related to counting
+ online processors and dynamic load balancing. It is expected that
+ a system may well want to write special versions of each of these.
+
+ The following implementation uses win32 API routines. */
+
+#include "libgomp.h"
+#include <windows.h>
+
+/* Count the CPU's currently available to this process. */
+static int
+count_avail_process_cpus ()
+{
+ DWORD_PTR process_cpus;
+ DWORD_PTR system_cpus;
+
+ if (GetProcessAffinityMask (GetCurrentProcess (),
+ &process_cpus, &system_cpus))
+ {
+ unsigned int count;
+ for (count = 0; process_cpus != 0; process_cpus >>= 1)
+ if (process_cpus & 1)
+ count++;
+ return count;
+ }
+ return 1;
+}
+
+/* At startup, determine the default number of threads. It would seem
+ this should be related to the number of cpus available to the process. */
+
+void
+gomp_init_num_threads (void)
+{
+ gomp_nthreads_var = count_avail_process_cpus ();
+}
+
+/* When OMP_DYNAMIC is set, at thread launch determine the number of
+ threads we should spawn for this team. FIXME: How do we adjust for
+ load average on MS Windows? */
+
+unsigned
+gomp_dynamic_max_threads (void)
+{
+ int n_onln = count_avail_process_cpus ();
+ return n_onln > gomp_nthreads_var ? gomp_nthreads_var : n_onln;
+}
+
+int
+omp_get_num_procs (void)
+{
+ return count_avail_process_cpus ();
+}
+
+ialias (omp_get_num_procs)
diff --git a/contrib/gcclibs/libgomp/config/posix/affinity.c b/contrib/gcclibs/libgomp/config/posix/affinity.c
new file mode 100644
index 0000000..67cb37a
--- /dev/null
+++ b/contrib/gcclibs/libgomp/config/posix/affinity.c
@@ -0,0 +1,41 @@
+/* Copyright (C) 2006 Free Software Foundation, Inc.
+ Contributed by Jakub Jelinek <jakub@redhat.com>.
+
+ This file is part of the GNU OpenMP Library (libgomp).
+
+ Libgomp is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ Libgomp 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 Lesser General Public License for
+ more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with libgomp; see the file COPYING.LIB. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA. */
+
+/* As a special exception, if you link this library with other files, some
+ of which are compiled with GCC, to produce an executable, this library
+ does not by itself 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 is a generic stub implementation of a CPU affinity setting. */
+
+#include "libgomp.h"
+
+void
+gomp_init_affinity (void)
+{
+}
+
+void
+gomp_init_thread_affinity (pthread_attr_t *attr)
+{
+ (void) attr;
+}
diff --git a/contrib/gcclibs/libgomp/configure b/contrib/gcclibs/libgomp/configure
index af4254c..a5cee6a 100755
--- a/contrib/gcclibs/libgomp/configure
+++ b/contrib/gcclibs/libgomp/configure
@@ -241,6 +241,155 @@ IFS=" $as_nl"
$as_unset CDPATH
+
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$lt_ECHO in
+X*--fallback-echo)
+ # Remove one level of quotation (which was required for Make).
+ ECHO=`echo "$lt_ECHO" | sed 's,\\\\\$\\$0,'$0','`
+ ;;
+esac
+
+ECHO=${lt_ECHO-echo}
+if test "X$1" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+elif test "X$1" = X--fallback-echo; then
+ # Avoid inline document here, it may be left over
+ :
+elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
+ # Yippee, $ECHO works!
+ :
+else
+ # Restart under the correct shell.
+ exec $SHELL "$0" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+ # used as fallback echo
+ shift
+ cat <<_LT_EOF
+$*
+_LT_EOF
+ exit 0
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test -z "$lt_ECHO"; then
+ if test "X${echo_test_string+set}" != Xset; then
+ # find a string as large as possible, as long as the shell can cope with it
+ for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
+ # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+ if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
+ { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
+ then
+ break
+ fi
+ done
+ fi
+
+ if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ :
+ else
+ # The Solaris, AIX, and Digital Unix default echo programs unquote
+ # backslashes. This makes it impossible to quote backslashes using
+ # echo "$something" | sed 's/\\/\\\\/g'
+ #
+ # So, first we look for a working echo in the user's PATH.
+
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for dir in $PATH /usr/ucb; do
+ IFS="$lt_save_ifs"
+ if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+ test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ ECHO="$dir/echo"
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+
+ if test "X$ECHO" = Xecho; then
+ # We didn't find a better echo, so look for alternatives.
+ if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ # This shell has a builtin print -r that does the trick.
+ ECHO='print -r'
+ elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
+ test "X$CONFIG_SHELL" != X/bin/ksh; then
+ # If we have ksh, try running configure again with it.
+ ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+ export ORIGINAL_CONFIG_SHELL
+ CONFIG_SHELL=/bin/ksh
+ export CONFIG_SHELL
+ exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"}
+ else
+ # Try using printf.
+ ECHO='printf %s\n'
+ if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ # Cool, printf works
+ :
+ elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
+ test "X$echo_testing_string" = 'X\t' &&
+ echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+ export CONFIG_SHELL
+ SHELL="$CONFIG_SHELL"
+ export SHELL
+ ECHO="$CONFIG_SHELL $0 --fallback-echo"
+ elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
+ test "X$echo_testing_string" = 'X\t' &&
+ echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ ECHO="$CONFIG_SHELL $0 --fallback-echo"
+ else
+ # maybe with a smaller string...
+ prev=:
+
+ for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
+ if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
+ then
+ break
+ fi
+ prev="$cmd"
+ done
+
+ if test "$prev" != 'sed 50q "$0"'; then
+ echo_test_string=`eval $prev`
+ export echo_test_string
+ exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"}
+ else
+ # Oops. We lost completely, so just stick with echo.
+ ECHO=echo
+ fi
+ fi
+ fi
+ fi
+ fi
+fi
+
+# Copy echo and quote the copy suitably for passing to libtool from
+# the Makefile, instead of quoting the original, which is used later.
+lt_ECHO=$ECHO
+if test "X$lt_ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then
+ lt_ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo"
+fi
+
+
+
+
# Name of the host.
# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
# so uname gets run too.
@@ -308,7 +457,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS GENINSRC_TRUE GENINSRC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar multi_basedir toolexecdir toolexeclibdir CC ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CFLAGS AR ac_ct_AR RANLIB ac_ct_RANLIB PERL BUILD_INFO_TRUE BUILD_INFO_FALSE LN_S LIBTOOL enable_shared enable_static MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT FC FCFLAGS LDFLAGS ac_ct_FC libtool_VERSION CPP CPPFLAGS EGREP SECTION_LDFLAGS OPT_LDFLAGS LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE LIBGOMP_BUILD_VERSIONED_SHLIB_FALSE config_path XCFLAGS XLDFLAGS link_gomp USE_FORTRAN_TRUE USE_FORTRAN_FALSE OMP_LOCK_SIZE OMP_LOCK_ALIGN OMP_NEST_LOCK_SIZE OMP_NEST_LOCK_ALIGN OMP_LOCK_KIND OMP_NEST_LOCK_KIND LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS GENINSRC_TRUE GENINSRC_FALSE build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar multi_basedir toolexecdir toolexeclibdir CC ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CFLAGS AR ac_ct_AR RANLIB ac_ct_RANLIB PERL BUILD_INFO_TRUE BUILD_INFO_FALSE LIBTOOL SED EGREP FGREP GREP LD DUMPBIN ac_ct_DUMPBIN NM LN_S lt_ECHO CPP CPPFLAGS enable_shared enable_static MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT FC FCFLAGS LDFLAGS ac_ct_FC libtool_VERSION SECTION_LDFLAGS OPT_LDFLAGS LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE LIBGOMP_BUILD_VERSIONED_SHLIB_FALSE config_path XCFLAGS XLDFLAGS link_gomp USE_FORTRAN_TRUE USE_FORTRAN_FALSE OMP_LOCK_SIZE OMP_LOCK_ALIGN OMP_NEST_LOCK_SIZE OMP_NEST_LOCK_ALIGN OMP_LOCK_KIND OMP_NEST_LOCK_KIND LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -718,13 +867,13 @@ echo X"$0" |
/^X\(\/\).*/{ s//\1/; q; }
s/.*/./; q'`
srcdir=$ac_confdir
- if test ! -r "$srcdir/$ac_unique_file"; then
+ if test ! -r $srcdir/$ac_unique_file; then
srcdir=..
fi
else
ac_srcdir_defaulted=no
fi
-if test ! -r "$srcdir/$ac_unique_file"; then
+if test ! -r $srcdir/$ac_unique_file; then
if test "$ac_srcdir_defaulted" = yes; then
{ echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
{ (exit 1); exit 1; }; }
@@ -733,7 +882,7 @@ if test ! -r "$srcdir/$ac_unique_file"; then
{ (exit 1); exit 1; }; }
fi
fi
-(cd $srcdir && test -r "./$ac_unique_file") 2>/dev/null ||
+(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
{ echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
{ (exit 1); exit 1; }; }
srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
@@ -749,6 +898,14 @@ ac_env_target_alias_set=${target_alias+set}
ac_env_target_alias_value=$target_alias
ac_cv_env_target_alias_set=${target_alias+set}
ac_cv_env_target_alias_value=$target_alias
+ac_env_CPP_set=${CPP+set}
+ac_env_CPP_value=$CPP
+ac_cv_env_CPP_set=${CPP+set}
+ac_cv_env_CPP_value=$CPP
+ac_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_env_CPPFLAGS_value=$CPPFLAGS
+ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_cv_env_CPPFLAGS_value=$CPPFLAGS
ac_env_FC_set=${FC+set}
ac_env_FC_value=$FC
ac_cv_env_FC_set=${FC+set}
@@ -761,14 +918,6 @@ ac_env_LDFLAGS_set=${LDFLAGS+set}
ac_env_LDFLAGS_value=$LDFLAGS
ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
ac_cv_env_LDFLAGS_value=$LDFLAGS
-ac_env_CPP_set=${CPP+set}
-ac_env_CPP_value=$CPP
-ac_cv_env_CPP_set=${CPP+set}
-ac_cv_env_CPP_value=$CPP
-ac_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_env_CPPFLAGS_value=$CPPFLAGS
-ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_cv_env_CPPFLAGS_value=$CPPFLAGS
#
# Report the --help message.
@@ -854,8 +1003,6 @@ Optional Features:
--enable-version-specific-runtime-libs
Specify that runtime libraries should be installed
in a compiler-specific directory [default=no]
- --enable-linux-futex Use the Linux futex system call
- [default=default]
--enable-generated-files-in-srcdir
put copies of generated files in source dir intended
for creating source tarballs for users without
@@ -863,12 +1010,17 @@ Optional Features:
--enable-multilib build many library versions (default)
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
- --enable-shared=PKGS build shared libraries default=yes
- --enable-static=PKGS build static libraries default=yes
- --enable-fast-install=PKGS optimize for fast installation default=yes
+ --enable-shared[=PKGS]
+ build shared libraries [default=yes]
+ --enable-static[=PKGS]
+ build static libraries [default=yes]
+ --enable-fast-install[=PKGS]
+ optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--enable-maintainer-mode enable make rules and dependencies not useful
(and sometimes confusing) to the casual installer
+ --enable-linux-futex use the Linux futex system call
+ [default=default]
--enable-tls Use thread-local storage [default=yes]
--enable-symvers=STYLE enables symbol versioning of the shared library
[default=yes]
@@ -876,8 +1028,9 @@ Optional Features:
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
- --with-gnu-ld assume the C compiler uses GNU ld default=no
- --with-pic try to use only PIC/non-PIC objects default=use both
+ --with-pic try to use only PIC/non-PIC objects [default=use
+ both]
+ --with-gnu-ld assume the C compiler uses GNU ld [default=no]
Some influential environment variables:
CC C compiler command
@@ -886,9 +1039,9 @@ Some influential environment variables:
nonstandard directory <lib dir>
CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
headers in a nonstandard directory <include dir>
+ CPP C preprocessor
FC Fortran compiler command
FCFLAGS Fortran compiler flags
- CPP C preprocessor
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
@@ -1365,26 +1518,6 @@ fi;
echo "$as_me:$LINENO: result: $enable_version_specific_runtime_libs" >&5
echo "${ECHO_T}$enable_version_specific_runtime_libs" >&6
-echo "$as_me:$LINENO: checking for --enable-linux-futex" >&5
-echo $ECHO_N "checking for --enable-linux-futex... $ECHO_C" >&6
- # Check whether --enable-linux-futex or --disable-linux-futex was given.
-if test "${enable_linux_futex+set}" = set; then
- enableval="$enable_linux_futex"
-
- case "$enableval" in
- yes|no|default) ;;
- *) { { echo "$as_me:$LINENO: error: Unknown argument to enable/disable linux-futex" >&5
-echo "$as_me: error: Unknown argument to enable/disable linux-futex" >&2;}
- { (exit 1); exit 1; }; } ;;
- esac
-
-else
- enable_linux_futex=default
-fi;
-
-echo "$as_me:$LINENO: result: $enable_linux_futex" >&5
-echo "${ECHO_T}$enable_linux_futex" >&6
-
# We would like our source tree to be readonly. However when releases or
# pre-releases are generated, the flex/bison generated files as well as the
# various formats of manuals need to be included along with the rest of the
@@ -1556,7 +1689,7 @@ target_alias=${target_alias-$host_alias}
# we can do about that; they come from AC_INIT).
# foreign: we don't follow the normal rules for GNU packages (no COPYING
# file in the top srcdir, etc, etc), so stop complaining.
-# no-dependencies: turns off auto dependency generation (just for now)
+# no-dist: we don't want 'dist' and related rules.
# -Wall: turns on all automake warnings...
# -Wno-portability: ...except this one, since GNU make is required.
# -Wno-override: ... and this one, since we do want this in testsuite.
@@ -3526,13 +3659,10 @@ else
sed -n 's/^.*GNU texinfo.* \([0-9][0-9.]*\).*$/\1/p'`
case $ac_prog_version in
- '') gcc_cv_prog_makeinfo_modern=no;;
- 4.[4-9]*) gcc_cv_prog_makeinfo_modern=yes;;
- *) gcc_cv_prog_makeinfo_modern=no;;
- esac
- if test $gcc_cv_prog_makeinfo_modern = no; then
- MAKEINFO="${CONFIG_SHELL-/bin/sh} $ac_aux_dir/missing makeinfo"
- fi
+ '') gcc_cv_prog_makeinfo_modern=no;;
+ 4.[4-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*) gcc_cv_prog_makeinfo_modern=yes;;
+ *) gcc_cv_prog_makeinfo_modern=no;;
+ esac
fi
echo "$as_me:$LINENO: result: $gcc_cv_prog_makeinfo_modern" >&5
@@ -3540,6 +3670,9 @@ echo "${ECHO_T}$gcc_cv_prog_makeinfo_modern" >&6
else
gcc_cv_prog_makeinfo_modern=no
fi
+ if test $gcc_cv_prog_makeinfo_modern = no; then
+ MAKEINFO="${CONFIG_SHELL-/bin/sh} $ac_aux_dir/missing makeinfo"
+ fi
@@ -3554,73 +3687,264 @@ fi
# Configure libtool
+
+
+macro_version='2.1a'
+macro_revision='1.2435'
+
+
+
+
+
+
+
+
+
+
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+# Set options
+
+enable_dlopen=no
+
+
+enable_win32_dll=no
+
+
# Check whether --enable-shared or --disable-shared was given.
if test "${enable_shared+set}" = set; then
enableval="$enable_shared"
p=${PACKAGE-default}
-case $enableval in
-yes) enable_shared=yes ;;
-no) enable_shared=no ;;
-*)
- enable_shared=no
- # Look at the argument we got. We use all the common list separators.
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
- for pkg in $enableval; do
- if test "X$pkg" = "X$p"; then
- enable_shared=yes
- fi
- done
- IFS="$ac_save_ifs"
- ;;
-esac
+ case $enableval in
+ yes) enable_shared=yes ;;
+ no) enable_shared=no ;;
+ *)
+ enable_shared=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_shared=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
else
enable_shared=yes
fi;
+
+
+
+
+
+
+
+
# Check whether --enable-static or --disable-static was given.
if test "${enable_static+set}" = set; then
enableval="$enable_static"
p=${PACKAGE-default}
-case $enableval in
-yes) enable_static=yes ;;
-no) enable_static=no ;;
-*)
- enable_static=no
- # Look at the argument we got. We use all the common list separators.
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
- for pkg in $enableval; do
- if test "X$pkg" = "X$p"; then
- enable_static=yes
- fi
- done
- IFS="$ac_save_ifs"
- ;;
-esac
+ case $enableval in
+ yes) enable_static=yes ;;
+ no) enable_static=no ;;
+ *)
+ enable_static=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_static=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
else
enable_static=yes
fi;
+
+
+
+
+
+
+
+
+
+# Check whether --with-pic or --without-pic was given.
+if test "${with_pic+set}" = set; then
+ withval="$with_pic"
+ pic_mode="$withval"
+else
+ pic_mode=default
+fi;
+
+test -z "$pic_mode" && pic_mode=default
+
+
+
+
+
+
+
# Check whether --enable-fast-install or --disable-fast-install was given.
if test "${enable_fast_install+set}" = set; then
enableval="$enable_fast_install"
p=${PACKAGE-default}
-case $enableval in
-yes) enable_fast_install=yes ;;
-no) enable_fast_install=no ;;
-*)
- enable_fast_install=no
- # Look at the argument we got. We use all the common list separators.
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
- for pkg in $enableval; do
- if test "X$pkg" = "X$p"; then
- enable_fast_install=yes
- fi
- done
- IFS="$ac_save_ifs"
- ;;
-esac
+ case $enableval in
+ yes) enable_fast_install=yes ;;
+ no) enable_fast_install=no ;;
+ *)
+ enable_fast_install=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_fast_install=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
else
enable_fast_install=yes
fi;
+
+
+
+
+
+
+
+echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5
+echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6
+if test "${lt_cv_path_SED+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for lt_ac_prog in sed gsed; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
+ lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+ fi
+ done
+ done
+done
+IFS=$as_save_IFS
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+ test ! -f $lt_ac_sed && continue
+ cat /dev/null > conftest.in
+ lt_ac_count=0
+ echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+ # Check for GNU sed and select it if it is found.
+ if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+ lt_cv_path_SED=$lt_ac_sed
+ break
+ fi
+ while true; do
+ cat conftest.in conftest.in >conftest.tmp
+ mv conftest.tmp conftest.in
+ cp conftest.in conftest.nl
+ echo >>conftest.nl
+ $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+ cmp -s conftest.out conftest.nl || break
+ # 10000 chars as input seems more than enough
+ test $lt_ac_count -gt 10 && break
+ lt_ac_count=`expr $lt_ac_count + 1`
+ if test $lt_ac_count -gt $lt_ac_max; then
+ lt_ac_max=$lt_ac_count
+ lt_cv_path_SED=$lt_ac_sed
+ fi
+ done
+done
+
+fi
+
+SED=$lt_cv_path_SED
+
+echo "$as_me:$LINENO: result: $SED" >&5
+echo "${ECHO_T}$SED" >&6
+
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+
+
+
+
+
+
+
+
+
+
+
+echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6
+if test "${ac_cv_prog_egrep+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+ then ac_cv_prog_egrep='grep -E'
+ else ac_cv_prog_egrep='egrep'
+ fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
+echo "${ECHO_T}$ac_cv_prog_egrep" >&6
+ EGREP=$ac_cv_prog_egrep
+
+
+echo "$as_me:$LINENO: checking for fgrep" >&5
+echo $ECHO_N "checking for fgrep... $ECHO_C" >&6
+if test "${ac_cv_prog_fgrep+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if echo 'ab*c' | (grep -F 'ab*c') >/dev/null 2>&1
+ then ac_cv_prog_fgrep='grep -F'
+ else ac_cv_prog_fgrep='fgrep'
+ fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_fgrep" >&5
+echo "${ECHO_T}$ac_cv_prog_fgrep" >&6
+ FGREP=$ac_cv_prog_fgrep
+
+
+test -z "$GREP" && GREP=grep
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# Check whether --with-gnu-ld or --without-gnu-ld was given.
if test "${with_gnu_ld+set}" = set; then
withval="$with_gnu_ld"
@@ -3631,8 +3955,8 @@ fi;
ac_prog=ld
if test "$GCC" = yes; then
# Check if gcc -print-prog-name=ld gives a path.
- echo "$as_me:$LINENO: checking for ld used by GCC" >&5
-echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6
+ echo "$as_me:$LINENO: checking for ld used by $CC" >&5
+echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6
case $host in
*-*-mingw*)
# gcc leaves a trailing carriage return which upsets mingw
@@ -3642,12 +3966,12 @@ echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6
esac
case $ac_prog in
# Accept absolute paths.
- [\\/]* | [A-Za-z]:[\\/]*)
+ [\\/]* | ?:[\\/]*)
re_direlt='/[^/][^/]*/\.\./'
- # Canonicalize the path of ld
- ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
- while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
- ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+ # Canonicalize the pathname of ld
+ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
done
test -z "$LD" && LD="$ac_prog"
;;
@@ -3671,22 +3995,26 @@ if test "${lt_cv_path_LD+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -z "$LD"; then
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
for ac_dir in $PATH; do
+ IFS="$lt_save_ifs"
test -z "$ac_dir" && ac_dir=.
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
lt_cv_path_LD="$ac_dir/$ac_prog"
# Check to see if the program is GNU ld. I'd rather use --version,
- # but apparently some GNU ld's only accept -v.
+ # but apparently some variants of GNU ld only accept -v.
# Break only if it was the GNU/non-GNU ld that we prefer.
- if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+ *GNU* | *'with BFD'*)
test "$with_gnu_ld" != no && break
- else
+ ;;
+ *)
test "$with_gnu_ld" != yes && break
- fi
+ ;;
+ esac
fi
done
- IFS="$ac_save_ifs"
+ IFS="$lt_save_ifs"
else
lt_cv_path_LD="$LD" # Let the user override the test with a path.
fi
@@ -3708,32 +4036,31 @@ echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
if test "${lt_cv_prog_gnu_ld+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- # I'd rather use --version here, but apparently some GNU ld's only accept -v.
-if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+ # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
lt_cv_prog_gnu_ld=yes
-else
+ ;;
+*)
lt_cv_prog_gnu_ld=no
-fi
+ ;;
+esac
fi
echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6
with_gnu_ld=$lt_cv_prog_gnu_ld
-echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5
-echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6
-if test "${lt_cv_ld_reload_flag+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- lt_cv_ld_reload_flag='-r'
-fi
-echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5
-echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6
-reload_flag=$lt_cv_ld_reload_flag
-test -n "$reload_flag" && reload_flag=" $reload_flag"
-echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5
-echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6
+
+
+
+
+
+
+
+echo "$as_me:$LINENO: checking for BSD- or MS-compatible name lister (nm)" >&5
+echo $ECHO_N "checking for BSD- or MS-compatible name lister (nm)... $ECHO_C" >&6
if test "${lt_cv_path_NM+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
@@ -3741,35 +4068,173 @@ else
# Let the user override the test.
lt_cv_path_NM="$NM"
else
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
- for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
- test -z "$ac_dir" && ac_dir=.
- tmp_nm=$ac_dir/${ac_tool_prefix}nm
- if test -f $tmp_nm || test -f $tmp_nm$ac_exeext ; then
- # Check to see if the nm accepts a BSD-compat flag.
- # Adding the `sed 1q' prevents false positives on HP-UX, which says:
- # nm: unknown option "B" ignored
- # Tru64's nm complains that /dev/null is an invalid object file
- if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then
- lt_cv_path_NM="$tmp_nm -B"
- break
- elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
- lt_cv_path_NM="$tmp_nm -p"
- break
- else
- lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
- continue # so that we can try to find one that supports BSD flags
+ lt_nm_to_check="${ac_tool_prefix}nm"
+ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+ lt_nm_to_check="$lt_nm_to_check nm"
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ tmp_nm="$ac_dir/$lt_tmp_nm"
+ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+ # Check to see if the nm accepts a BSD-compat flag.
+ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # nm: unknown option "B" ignored
+ # Tru64's nm complains that /dev/null is an invalid object file
+ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+ */dev/null* | *'Invalid file or object type'*)
+ lt_cv_path_NM="$tmp_nm -B"
+ break
+ ;;
+ *)
+ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+ */dev/null*)
+ lt_cv_path_NM="$tmp_nm -p"
+ break
+ ;;
+ *)
+ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+ continue # so that we can try to find one that supports BSD flags
+ ;;
+ esac
+ ;;
+ esac
fi
- fi
+ done
+ IFS="$lt_save_ifs"
done
- IFS="$ac_save_ifs"
- test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
+ : ${lt_cv_path_NM=no}
+fi
+fi
+echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5
+echo "${ECHO_T}$lt_cv_path_NM" >&6
+if test "$lt_cv_path_NM" != "no"; then
+ NM="$lt_cv_path_NM"
+else
+ # Didn't find any BSD compatible name lister, look for dumpbin.
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in "dumpbin -symbols" "link -dump -symbols"
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_DUMPBIN+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$DUMPBIN"; then
+ ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+DUMPBIN=$ac_cv_prog_DUMPBIN
+if test -n "$DUMPBIN"; then
+ echo "$as_me:$LINENO: result: $DUMPBIN" >&5
+echo "${ECHO_T}$DUMPBIN" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$DUMPBIN" && break
+ done
+fi
+if test -z "$DUMPBIN"; then
+ ac_ct_DUMPBIN=$DUMPBIN
+ for ac_prog in "dumpbin -symbols" "link -dump -symbols"
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_DUMPBIN+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_DUMPBIN"; then
+ ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
fi
fi
+ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
+if test -n "$ac_ct_DUMPBIN"; then
+ echo "$as_me:$LINENO: result: $ac_ct_DUMPBIN" >&5
+echo "${ECHO_T}$ac_ct_DUMPBIN" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$ac_ct_DUMPBIN" && break
+done
+test -n "$ac_ct_DUMPBIN" || ac_ct_DUMPBIN=":"
-NM="$lt_cv_path_NM"
-echo "$as_me:$LINENO: result: $NM" >&5
-echo "${ECHO_T}$NM" >&6
+ DUMPBIN=$ac_ct_DUMPBIN
+fi
+
+
+ if test "$DUMPBIN" != ":"; then
+ NM="$DUMPBIN"
+ fi
+fi
+test -z "$NM" && NM=nm
+
+
+
+
+
+
+echo "$as_me:$LINENO: checking the name lister ($NM) interface" >&5
+echo $ECHO_N "checking the name lister ($NM) interface... $ECHO_C" >&6
+if test "${lt_cv_nm_interface+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_cv_nm_interface="BSD nm"
+ echo "int some_variable = 0;" > conftest.$ac_ext
+ (eval echo "\"\$as_me:4223: $ac_compile\"" >&5)
+ (eval "$ac_compile" 2>conftest.err)
+ cat conftest.err >&5
+ (eval echo "\"\$as_me:4226: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+ (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+ cat conftest.err >&5
+ (eval echo "\"\$as_me:4229: output\"" >&5)
+ cat conftest.out >&5
+ if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+ lt_cv_nm_interface="MS dumpbin"
+ fi
+ rm -f conftest*
+fi
+echo "$as_me:$LINENO: result: $lt_cv_nm_interface" >&5
+echo "${ECHO_T}$lt_cv_nm_interface" >&6
echo "$as_me:$LINENO: checking whether ln -s works" >&5
echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6
@@ -3782,8 +4247,234 @@ else
echo "${ECHO_T}no, using $LN_S" >&6
fi
-echo "$as_me:$LINENO: checking how to recognise dependant libraries" >&5
-echo $ECHO_N "checking how to recognise dependant libraries... $ECHO_C" >&6
+# find the maximum length of command line arguments
+echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5
+echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6
+if test "${lt_cv_sys_max_cmd_len+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ i=0
+ teststring="ABCD"
+
+ case $build_os in
+ msdosdjgpp*)
+ # On DJGPP, this test can blow up pretty badly due to problems in libc
+ # (any single argument exceeding 2000 bytes causes a buffer overrun
+ # during glob expansion). Even if it were fixed, the result of this
+ # check would be larger than it should be.
+ lt_cv_sys_max_cmd_len=12288; # 12K is about right
+ ;;
+
+ gnu*)
+ # Under GNU Hurd, this test is not required because there is
+ # no limit to the length of command line arguments.
+ # Libtool will interpret -1 as no limit whatsoever
+ lt_cv_sys_max_cmd_len=-1;
+ ;;
+
+ cygwin* | mingw*)
+ # On Win9x/ME, this test blows up -- it succeeds, but takes
+ # about 5 minutes as the teststring grows exponentially.
+ # Worse, since 9x/ME are not pre-emptively multitasking,
+ # you end up with a "frozen" computer, even though with patience
+ # the test eventually succeeds (with a max line length of 256k).
+ # Instead, let's just punt: use the minimum linelength reported by
+ # all of the supported platforms: 8192 (on NT/2K/XP).
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ amigaos*)
+ # On AmigaOS with pdksh, this test takes hours, literally.
+ # So we just punt and use a minimum line length of 8192.
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+ # This has been around since 386BSD, at least. Likely further.
+ if test -x /sbin/sysctl; then
+ lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+ elif test -x /usr/sbin/sysctl; then
+ lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+ else
+ lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
+ fi
+ # And add a safety zone
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ ;;
+
+ interix*)
+ # We know the value 262144 and hardcode it with a safety zone (like BSD)
+ lt_cv_sys_max_cmd_len=196608
+ ;;
+
+ osf*)
+ # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+ # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+ # nice to cause kernel panics so lets avoid the loop below.
+ # First set a reasonable default.
+ lt_cv_sys_max_cmd_len=16384
+ #
+ if test -x /sbin/sysconfig; then
+ case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+ *1*) lt_cv_sys_max_cmd_len=-1 ;;
+ esac
+ fi
+ ;;
+ sco3.2v5*)
+ lt_cv_sys_max_cmd_len=102400
+ ;;
+ sysv5* | sco5v6* | sysv4.2uw2*)
+ kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+ if test -n "$kargmax"; then
+ lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'`
+ else
+ lt_cv_sys_max_cmd_len=32768
+ fi
+ ;;
+ *)
+ lt_cv_sys_max_cmd_len=`getconf ARG_MAX 2> /dev/null`
+ if test -n $lt_cv_sys_max_cmd_len; then
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ else
+ # Make teststring a little bigger before we do anything with it.
+ # a 1K string should be a reasonable start.
+ for i in 1 2 3 4 5 6 7 8 ; do
+ teststring=$teststring$teststring
+ done
+ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+ # If test is not a shell built-in, we'll probably end up computing a
+ # maximum length that is only half of the actual maximum length, but
+ # we can't tell.
+ while { test "X"`$SHELL $0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
+ = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
+ test $i != 17 # 1/2 MB should be enough
+ do
+ i=`expr $i + 1`
+ teststring=$teststring$teststring
+ done
+ # Only check the string length outside the loop.
+ lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+ teststring=
+ # Add a significant safety factor because C++ compilers can tack on
+ # massive amounts of additional arguments before passing them to the
+ # linker. It appears as though 1/2 is a usable value.
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+ fi
+ ;;
+ esac
+
+fi
+
+if test -n $lt_cv_sys_max_cmd_len ; then
+ echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5
+echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6
+else
+ echo "$as_me:$LINENO: result: none" >&5
+echo "${ECHO_T}none" >&6
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+
+
+
+
+
+
+: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+
+echo "$as_me:$LINENO: checking whether the shell understands some XSI constructs" >&5
+echo $ECHO_N "checking whether the shell understands some XSI constructs... $ECHO_C" >&6
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+ test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
+ = c,a/b,, ) >/dev/null 2>&1 \
+ && xsi_shell=yes
+echo "$as_me:$LINENO: result: $xsi_shell" >&5
+echo "${ECHO_T}$xsi_shell" >&6
+
+
+echo "$as_me:$LINENO: checking whether the shell understands \"+=\"" >&5
+echo $ECHO_N "checking whether the shell understands \"+=\"... $ECHO_C" >&6
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
+ >/dev/null 2>&1 \
+ && lt_shell_append=yes
+echo "$as_me:$LINENO: result: $lt_shell_append" >&5
+echo "${ECHO_T}$lt_shell_append" >&6
+
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ lt_unset=unset
+else
+ lt_unset=false
+fi
+
+
+
+
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+ # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+ lt_SP2NL='tr \040 \012'
+ lt_NL2SP='tr \015\012 \040\040'
+ ;;
+ *) # EBCDIC based system
+ lt_SP2NL='tr \100 \n'
+ lt_NL2SP='tr \r\n \100\100'
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5
+echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6
+if test "${lt_cv_ld_reload_flag+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_cv_ld_reload_flag='-r'
+fi
+echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5
+echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+ darwin*)
+ if test "$GCC" = yes; then
+ reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+ else
+ reload_cmds='$LD$reload_flag -o $output$reload_objs'
+ fi
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+
+echo "$as_me:$LINENO: checking how to recognize dependent libraries" >&5
+echo $ECHO_N "checking how to recognize dependent libraries... $ECHO_C" >&6
if test "${lt_cv_deplibs_check_method+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
@@ -3796,13 +4487,13 @@ lt_cv_deplibs_check_method='unknown'
# `unknown' -- same as none, but documents that we really don't know.
# 'pass_all' -- all dependencies passed with no checks.
# 'test_compile' -- check by making test program.
-# 'file_magic [regex]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given egrep regex.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
# If you have `file' or equivalent on your system and you're not sure
# whether `pass_all' will *always* work, you probably want this one.
case $host_os in
-aix*)
+aix[4-9]*)
lt_cv_deplibs_check_method=pass_all
;;
@@ -3810,39 +4501,42 @@ beos*)
lt_cv_deplibs_check_method=pass_all
;;
-bsdi4*)
+bsdi[45]*)
lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
lt_cv_file_magic_cmd='/usr/bin/file -L'
lt_cv_file_magic_test_file=/shlib/libc.so
;;
-cygwin* | mingw* |pw32*)
- lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
- lt_cv_file_magic_cmd='$OBJDUMP -f'
+cygwin*)
+ # func_win32_libid is a shell function defined in ltmain.sh
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='func_win32_libid'
+ ;;
+
+mingw* | pw32*)
+ # Base MSYS/MinGW do not provide the 'file' command needed by
+ # func_win32_libid shell function, so use a weaker test based on 'objdump',
+ # unless we find 'file', for example because we are cross-compiling.
+ if ( file / ) >/dev/null 2>&1; then
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='func_win32_libid'
+ else
+ lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+ lt_cv_file_magic_cmd='$OBJDUMP -f'
+ fi
;;
darwin* | rhapsody*)
- # this will be overwritten by pass_all, but leave it in just in case
- lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library'
- lt_cv_file_magic_cmd='/usr/bin/file -L'
- case "$host_os" in
- rhapsody* | darwin1.012)
- lt_cv_file_magic_test_file='/System/Library/Frameworks/System.framework/System'
- ;;
- *) # Darwin 1.3 on
- lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib'
- ;;
- esac
lt_cv_deplibs_check_method=pass_all
;;
-freebsd* | kfreebsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+freebsd* | dragonfly*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
case $host_cpu in
i*86 )
# Not sure whether the presence of OpenBSD here was a mistake.
# Let's accept both of them until this is cleared up.
- lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library'
+ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
lt_cv_file_magic_cmd=/usr/bin/file
lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
;;
@@ -3856,92 +4550,116 @@ gnu*)
lt_cv_deplibs_check_method=pass_all
;;
-hpux10.20*|hpux11*)
+hpux10.20* | hpux11*)
+ lt_cv_file_magic_cmd=/usr/bin/file
case $host_cpu in
- hppa*)
- lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
- lt_cv_file_magic_cmd=/usr/bin/file
- lt_cv_file_magic_test_file=/usr/lib/libc.sl
- ;;
ia64*)
lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
- lt_cv_file_magic_cmd=/usr/bin/file
lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
;;
- esac
- ;;
-
-irix5* | irix6*)
- case $host_os in
- irix5*)
- # this will be overridden with pass_all, but let us keep it just in case
- lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1"
+ hppa*64*)
+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'
+ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
;;
*)
- case $LD in
- *-32|*"-32 ") libmagic=32-bit;;
- *-n32|*"-n32 ") libmagic=N32;;
- *-64|*"-64 ") libmagic=64-bit;;
- *) libmagic=never-match;;
- esac
- # this will be overridden with pass_all, but let us keep it just in case
- lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1"
+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
+ lt_cv_file_magic_test_file=/usr/lib/libc.sl
;;
esac
- lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*`
+ ;;
+
+interix[3-9]*)
+ # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $LD in
+ *-32|*"-32 ") libmagic=32-bit;;
+ *-n32|*"-n32 ") libmagic=N32;;
+ *-64|*"-64 ") libmagic=64-bit;;
+ *) libmagic=never-match;;
+ esac
lt_cv_deplibs_check_method=pass_all
;;
# This must be Linux ELF.
-linux-gnu*)
+linux* | k*bsd*-gnu)
lt_cv_deplibs_check_method=pass_all
;;
-netbsd* | knetbsd*-gnu)
- if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
- lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'
+netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
else
- lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so$'
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
fi
;;
-newsos6)
+newos6*)
lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
lt_cv_file_magic_cmd=/usr/bin/file
lt_cv_file_magic_test_file=/usr/lib/libnls.so
;;
+*nto* | *qnx*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+openbsd*)
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
+ else
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+ fi
+ ;;
+
osf3* | osf4* | osf5*)
- # this will be overridden with pass_all, but let us keep it just in case
- lt_cv_deplibs_check_method='file_magic COFF format alpha shared library'
- lt_cv_file_magic_test_file=/shlib/libc.so
lt_cv_deplibs_check_method=pass_all
;;
-sco3.2v5*)
+rdos*)
lt_cv_deplibs_check_method=pass_all
;;
solaris*)
lt_cv_deplibs_check_method=pass_all
- lt_cv_file_magic_test_file=/lib/libc.so
;;
-sysv5uw[78]* | sysv4*uw2*)
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
lt_cv_deplibs_check_method=pass_all
;;
-sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+sysv4 | sysv4.3*)
case $host_vendor in
- ncr)
- lt_cv_deplibs_check_method=pass_all
- ;;
motorola)
lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
;;
+ ncr)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ sequent)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+ ;;
+ sni)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
+ lt_cv_file_magic_test_file=/lib/libc.so
+ ;;
+ siemens)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ pc)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
esac
;;
+
+tpf*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
esac
fi
@@ -3949,223 +4667,29 @@ echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5
echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6
file_magic_cmd=$lt_cv_file_magic_cmd
deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
-# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
-
-# find the maximum length of command line arguments
-echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5
-echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6
-if test "${lt_cv_sys_max_cmd_len+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- i=0
- teststring="ABCD"
-
- case $build_os in
- msdosdjgpp*)
- # On DJGPP, this test can blow up pretty badly due to problems in libc
- # (any single argument exceeding 2000 bytes causes a buffer overrun
- # during glob expansion). Even if it were fixed, the result of this
- # check would be larger than it should be.
- lt_cv_sys_max_cmd_len=12288; # 12K is about right
- ;;
-
- cygwin* | mingw*)
- # On Win9x/ME, this test blows up -- it succeeds, but takes
- # about 5 minutes as the teststring grows exponentially.
- # Worse, since 9x/ME are not pre-emptively multitasking,
- # you end up with a "frozen" computer, even though with patience
- # the test eventually succeeds (with a max line length of 256k).
- # Instead, let's just punt: use the minimum linelength reported by
- # all of the supported platforms: 8192 (on NT/2K/XP).
- lt_cv_sys_max_cmd_len=8192;
- ;;
-
- amigaos*)
- # On AmigaOS with pdksh, this test takes hours, literally.
- # So we just punt and use a minimum line length of 8192.
- lt_cv_sys_max_cmd_len=8192;
- ;;
-
- netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
- # This has been around since 386BSD, at least. Likely further.
- if test -x /sbin/sysctl; then
- lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
- elif test -x /usr/sbin/sysctl; then
- lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
- else
- lt_cv_sys_max_cmd_len=65536 # usable default for *BSD
- fi
- # And add a safety zone
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
- lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
- ;;
- esac
-
-fi
-
-if test -n "$lt_cv_sys_max_cmd_len" ; then
- echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5
-echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6
-else
- echo "$as_me:$LINENO: result: none" >&5
-echo "${ECHO_T}none" >&6
-fi
-
-
-# Only perform the check for file, if the check method requires it
-case $deplibs_check_method in
-file_magic*)
- if test "$file_magic_cmd" = '$MAGIC_CMD'; then
- echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5
-echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6
-if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- case $MAGIC_CMD in
- /*)
- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
- ;;
- ?:/*)
- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path.
- ;;
- *)
- ac_save_MAGIC_CMD="$MAGIC_CMD"
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="/usr/bin:$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/${ac_tool_prefix}file; then
- lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
- if test -n "$file_magic_test_file"; then
- case $deplibs_check_method in
- "file_magic "*)
- file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
- MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
- egrep "$file_magic_regex" > /dev/null; then
- :
- else
- cat <<EOF 1>&2
-
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such. This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem. Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool@gnu.org
-EOF
- fi ;;
- esac
- fi
- break
- fi
- done
- IFS="$ac_save_ifs"
- MAGIC_CMD="$ac_save_MAGIC_CMD"
- ;;
-esac
-fi
-
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
- echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
-echo "${ECHO_T}$MAGIC_CMD" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-if test -z "$lt_cv_path_MAGIC_CMD"; then
- if test -n "$ac_tool_prefix"; then
- echo "$as_me:$LINENO: checking for file" >&5
-echo $ECHO_N "checking for file... $ECHO_C" >&6
-if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- case $MAGIC_CMD in
- /*)
- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
- ;;
- ?:/*)
- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path.
- ;;
- *)
- ac_save_MAGIC_CMD="$MAGIC_CMD"
- IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
- ac_dummy="/usr/bin:$PATH"
- for ac_dir in $ac_dummy; do
- test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/file; then
- lt_cv_path_MAGIC_CMD="$ac_dir/file"
- if test -n "$file_magic_test_file"; then
- case $deplibs_check_method in
- "file_magic "*)
- file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
- MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
- if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
- egrep "$file_magic_regex" > /dev/null; then
- :
- else
- cat <<EOF 1>&2
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such. This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem. Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool@gnu.org
-EOF
- fi ;;
- esac
- fi
- break
- fi
- done
- IFS="$ac_save_ifs"
- MAGIC_CMD="$ac_save_MAGIC_CMD"
- ;;
-esac
-fi
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
- echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
-echo "${ECHO_T}$MAGIC_CMD" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
- else
- MAGIC_CMD=:
- fi
-fi
- fi
- ;;
-esac
if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+ # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_RANLIB+set}" = set; then
+if test "${ac_cv_prog_AR+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- if test -n "$RANLIB"; then
- ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+ if test -n "$AR"; then
+ ac_cv_prog_AR="$AR" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
@@ -4174,7 +4698,7 @@ do
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+ ac_cv_prog_AR="${ac_tool_prefix}ar"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
@@ -4183,27 +4707,27 @@ done
fi
fi
-RANLIB=$ac_cv_prog_RANLIB
-if test -n "$RANLIB"; then
- echo "$as_me:$LINENO: result: $RANLIB" >&5
-echo "${ECHO_T}$RANLIB" >&6
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+ echo "$as_me:$LINENO: result: $AR" >&5
+echo "${ECHO_T}$AR" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
fi
-if test -z "$ac_cv_prog_RANLIB"; then
- ac_ct_RANLIB=$RANLIB
- # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
+if test -z "$ac_cv_prog_AR"; then
+ ac_ct_AR=$AR
+ # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
+if test "${ac_cv_prog_ac_ct_AR+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- if test -n "$ac_ct_RANLIB"; then
- ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+ if test -n "$ac_ct_AR"; then
+ ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
@@ -4212,30 +4736,43 @@ do
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_RANLIB="ranlib"
+ ac_cv_prog_ac_ct_AR="ar"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
- test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":"
+ test -z "$ac_cv_prog_ac_ct_AR" && ac_cv_prog_ac_ct_AR="false"
fi
fi
-ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
-if test -n "$ac_ct_RANLIB"; then
- echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
-echo "${ECHO_T}$ac_ct_RANLIB" >&6
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+ echo "$as_me:$LINENO: result: $ac_ct_AR" >&5
+echo "${ECHO_T}$ac_ct_AR" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
- RANLIB=$ac_ct_RANLIB
+ AR=$ac_ct_AR
else
- RANLIB="$ac_cv_prog_RANLIB"
+ AR="$ac_cv_prog_AR"
fi
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+
+
+
+
+
+
+
+
+
+
+
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
set dummy ${ac_tool_prefix}strip; ac_word=$2
@@ -4316,96 +4853,472 @@ else
STRIP="$ac_cv_prog_STRIP"
fi
+test -z "$STRIP" && STRIP=:
-# Check for any special flags to pass to ltconfig.
-libtool_flags="--cache-file=$cache_file"
-test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
-test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
-test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
-test "$GCC" = yes && libtool_flags="$libtool_flags --with-gcc"
-test "$lt_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
-# Check whether --enable-libtool-lock or --disable-libtool-lock was given.
-if test "${enable_libtool_lock+set}" = set; then
- enableval="$enable_libtool_lock"
-fi;
-test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
-test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
-# Check whether --with-pic or --without-pic was given.
-if test "${with_pic+set}" = set; then
- withval="$with_pic"
- pic_mode="$withval"
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_RANLIB+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
else
- pic_mode=default
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+ echo "$as_me:$LINENO: result: $RANLIB" >&5
+echo "${ECHO_T}$RANLIB" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+ ac_ct_RANLIB=$RANLIB
+ # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_RANLIB"; then
+ ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_RANLIB="ranlib"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+ test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":"
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+ echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5
+echo "${ECHO_T}$ac_ct_RANLIB" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ RANLIB=$ac_ct_RANLIB
+else
+ RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+test -z "$RANLIB" && RANLIB=:
+
+
+
+
+
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+ case $host_os in
+ openbsd*)
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+ ;;
+ *)
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+ ;;
+ esac
+ old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5
+echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6
+if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix. What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+ symcode='[BCDT]'
+ ;;
+cygwin* | mingw* | pw32*)
+ symcode='[ABCDGISTW]'
+ ;;
+hpux*)
+ if test "$host_cpu" = ia64; then
+ symcode='[ABCDEGRST]'
+ fi
+ ;;
+irix* | nonstopux*)
+ symcode='[BCDEGRST]'
+ ;;
+osf*)
+ symcode='[BCDEGQRST]'
+ ;;
+solaris*)
+ symcode='[BDRT]'
+ ;;
+sco3.2v5*)
+ symcode='[DT]'
+ ;;
+sysv4.2uw2*)
+ symcode='[DT]'
+ ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+ symcode='[ABDT]'
+ ;;
+sysv4)
+ symcode='[DFNSTU]'
+ ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+ symcode='[ABCDGIRSTW]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+ opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+ ;;
+esac
+
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+ # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+ symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+ # Write the raw and C identifiers.
+ if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+ # Fake it for dumpbin and say T for any non-static function
+ # and D for any global variable.
+ # Also find C++ and __fastcall symbols from MSVC++,
+ # which start with @ or ?.
+ lt_cv_sys_global_symbol_pipe="$AWK '"\
+" {last_section=section; section=\$ 3};"\
+" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+" \$ 0!~/External *\|/{next};"\
+" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+" {if(hide[section]) next};"\
+" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+" s[1]~/^[@?]/{print s[1], s[1]; next};"\
+" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+" ' prfx=^$ac_symprfx"
+ else
+ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+ fi
+
+ # Check to see that the pipe works correctly.
+ pipe_works=no
+
+ rm -f conftest*
+ cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
+
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # Now try to grab the symbols.
+ nlist=conftest.nm
+ if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5
+ (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && test -s "$nlist"; then
+ # Try sorting and uniquifying the output.
+ if sort "$nlist" | uniq > "$nlist"T; then
+ mv -f "$nlist"T "$nlist"
+ else
+ rm -f "$nlist"T
+ fi
+
+ # Make sure that we snagged all the symbols we need.
+ if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+ if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+ cat <<_LT_EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+ # Now generate the symbol file.
+ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+ cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols. */
+const struct {
+ const char *name;
+ void *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[] =
+{
+ { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+ cat <<\_LT_EOF >> conftest.$ac_ext
+ {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+ return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+ # Now try linking the two files.
+ mv conftest.$ac_objext conftstm.$ac_objext
+ lt_save_LIBS="$LIBS"
+ lt_save_CFLAGS="$CFLAGS"
+ LIBS="conftstm.$ac_objext"
+ CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && test -s conftest${ac_exeext}; then
+ pipe_works=yes
+ fi
+ LIBS="$lt_save_LIBS"
+ CFLAGS="$lt_save_CFLAGS"
+ else
+ echo "cannot find nm_test_func in $nlist" >&5
+ fi
+ else
+ echo "cannot find nm_test_var in $nlist" >&5
+ fi
+ else
+ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
+ fi
+ else
+ echo "$progname: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ fi
+ rm -f conftest* conftst*
+
+ # Do not use the global_symbol_pipe unless it works.
+ if test "$pipe_works" = yes; then
+ break
+ else
+ lt_cv_sys_global_symbol_pipe=
+ fi
+done
+
+fi
+
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+ lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+ echo "$as_me:$LINENO: result: failed" >&5
+echo "${ECHO_T}failed" >&6
+else
+ echo "$as_me:$LINENO: result: ok" >&5
+echo "${ECHO_T}ok" >&6
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --enable-libtool-lock or --disable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then
+ enableval="$enable_libtool_lock"
+
fi;
-test x"$pic_mode" = xyes && libtool_flags="$libtool_flags --prefer-pic"
-test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic"
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
# Some flags need to be propagated to the compiler or linker for good
# libtool support.
case $host in
-*-*-irix6*)
+ia64-*-hpux*)
# Find out which ABI we are using.
- echo '#line 4353 "configure"' > conftest.$ac_ext
+ echo 'int i;' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
- if test "$lt_cv_prog_gnu_ld" = yes; then
case `/usr/bin/file conftest.$ac_objext` in
- *32-bit*)
- LD="${LD-ld} -melf32bsmip"
- ;;
- *N32*)
- LD="${LD-ld} -melf32bmipn32"
- ;;
- *64-bit*)
- LD="${LD-ld} -melf64bmip"
- ;;
- esac
- else
- case `/usr/bin/file conftest.$ac_objext` in
- *32-bit*)
- LD="${LD-ld} -32"
- ;;
- *N32*)
- LD="${LD-ld} -n32"
- ;;
- *64-bit*)
- LD="${LD-ld} -64"
- ;;
+ *ELF-32*)
+ HPUX_IA64_MODE="32"
+ ;;
+ *ELF-64*)
+ HPUX_IA64_MODE="64"
+ ;;
esac
- fi
fi
rm -rf conftest*
;;
-
-ia64-*-hpux*)
+*-*-irix6*)
# Find out which ABI we are using.
- echo 'int i;' > conftest.$ac_ext
+ echo '#line 5285 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
- case "`/usr/bin/file conftest.o`" in
- *ELF-32*)
- HPUX_IA64_MODE="32"
- ;;
- *ELF-64*)
- HPUX_IA64_MODE="64"
- ;;
- esac
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -melf32bsmip"
+ ;;
+ *N32*)
+ LD="${LD-ld} -melf32bmipn32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -melf64bmip"
+ ;;
+ esac
+ else
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -32"
+ ;;
+ *N32*)
+ LD="${LD-ld} -n32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -64"
+ ;;
+ esac
+ fi
fi
rm -rf conftest*
;;
-x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
# Find out which ABI we are using.
echo 'int i;' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
@@ -4413,39 +5326,45 @@ x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; then
- case "`/usr/bin/file conftest.o`" in
- *32-bit*)
- case $host in
- x86_64-*linux*)
- LD="${LD-ld} -m elf_i386"
- ;;
- ppc64-*linux*|powerpc64-*linux*)
- LD="${LD-ld} -m elf32ppclinux"
- ;;
- s390x-*linux*)
- LD="${LD-ld} -m elf_s390"
- ;;
- sparc64-*linux*)
- LD="${LD-ld} -m elf32_sparc"
- ;;
- esac
- ;;
- *64-bit*)
- case $host in
- x86_64-*linux*)
- LD="${LD-ld} -m elf_x86_64"
- ;;
- ppc*-*linux*|powerpc*-*linux*)
- LD="${LD-ld} -m elf64ppc"
- ;;
- s390*-*linux*)
- LD="${LD-ld} -m elf64_s390"
- ;;
- sparc*-*linux*)
- LD="${LD-ld} -m elf64_sparc"
- ;;
- esac
- ;;
+ case `/usr/bin/file conftest.o` in
+ *32-bit*)
+ case $host in
+ x86_64-*kfreebsd*-gnu)
+ LD="${LD-ld} -m elf_i386_fbsd"
+ ;;
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_i386"
+ ;;
+ ppc64-*linux*|powerpc64-*linux*)
+ LD="${LD-ld} -m elf32ppclinux"
+ ;;
+ s390x-*linux*)
+ LD="${LD-ld} -m elf_s390"
+ ;;
+ sparc64-*linux*)
+ LD="${LD-ld} -m elf32_sparc"
+ ;;
+ esac
+ ;;
+ *64-bit*)
+ case $host in
+ x86_64-*kfreebsd*-gnu)
+ LD="${LD-ld} -m elf_x86_64_fbsd"
+ ;;
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_x86_64"
+ ;;
+ ppc*-*linux*|powerpc*-*linux*)
+ LD="${LD-ld} -m elf64ppc"
+ ;;
+ s390*-*linux*|s390*-*tpf*)
+ LD="${LD-ld} -m elf64_s390"
+ ;;
+ sparc*-*linux*)
+ LD="${LD-ld} -m elf64_sparc"
+ ;;
+ esac
+ ;;
esac
fi
rm -rf conftest*
@@ -4460,9 +5379,7 @@ echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6
if test "${lt_cv_cc_needs_belf+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
-
-
- ac_ext=c
+ ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
@@ -4528,114 +5445,4553 @@ echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6
CFLAGS="$SAVE_CFLAGS"
fi
;;
+sparc*-*solaris*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ case `/usr/bin/file conftest.o` in
+ *64-bit*)
+ case $lt_cv_prog_gnu_ld in
+ yes*) LD="${LD-ld} -m elf64_sparc" ;;
+ *) LD="${LD-ld} -64" ;;
+ esac
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+esac
+
+need_locks="$enable_libtool_lock"
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if test "${ac_cv_prog_CPP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ :
+else
+ { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_header_stdc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_stdc=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then
+ :
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ctype.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ exit(2);
+ exit (0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_Header=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+for ac_header in dlfcn.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_Header=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+test -z "$LN_S" && LN_S="ln -s"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+
+echo "$as_me:$LINENO: checking for objdir" >&5
+echo $ECHO_N "checking for objdir... $ECHO_C" >&6
+if test "${lt_cv_objdir+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+ lt_cv_objdir=.libs
+else
+ # MS-DOS does not allow filenames that begin with a dot.
+ lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+fi
+echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5
+echo "${ECHO_T}$lt_cv_objdir" >&6
+objdir=$lt_cv_objdir
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define LT_OBJDIR "$lt_cv_objdir/"
+_ACEOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+case $host_os in
+aix3*)
+ # AIX sometimes has problems with the GCC collect2 program. For some
+ # reason, if we set the COLLECT_NAMES environment variable, the problems
+ # vanish in a puff of smoke.
+ if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+ fi
+ ;;
+esac
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+for cc_temp in $compiler""; do
+ case $cc_temp in
+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+ \-*) ;;
+ *) break;;
+ esac
+done
+cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+ echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5
+echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $MAGIC_CMD in
+[\\/*] | ?:[\\/]*)
+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+ ;;
+*)
+ lt_save_MAGIC_CMD="$MAGIC_CMD"
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+ for ac_dir in $ac_dummy; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/${ac_tool_prefix}file; then
+ lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+ if test -n "$file_magic_test_file"; then
+ case $deplibs_check_method in
+ "file_magic "*)
+ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ :
+ else
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such. This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem. Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+ fi ;;
+ esac
+ fi
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+ MAGIC_CMD="$lt_save_MAGIC_CMD"
+ ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+ echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
+echo "${ECHO_T}$MAGIC_CMD" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+
+
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+ if test -n "$ac_tool_prefix"; then
+ echo "$as_me:$LINENO: checking for file" >&5
+echo $ECHO_N "checking for file... $ECHO_C" >&6
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ case $MAGIC_CMD in
+[\\/*] | ?:[\\/]*)
+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+ ;;
+*)
+ lt_save_MAGIC_CMD="$MAGIC_CMD"
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+ for ac_dir in $ac_dummy; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/file; then
+ lt_cv_path_MAGIC_CMD="$ac_dir/file"
+ if test -n "$file_magic_test_file"; then
+ case $deplibs_check_method in
+ "file_magic "*)
+ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ :
+ else
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such. This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem. Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+ fi ;;
+ esac
+ fi
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+ MAGIC_CMD="$lt_save_MAGIC_CMD"
+ ;;
esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+ echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5
+echo "${ECHO_T}$MAGIC_CMD" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+
+ else
+ MAGIC_CMD=:
+ fi
+fi
+
+ fi
+ ;;
+esac
+
+# Use C for the default configuration in the libtool script
+
+lt_save_CC="$CC"
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+objext=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM conftest*
+
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+
+lt_prog_compiler_no_builtin_flag=
+
+if test "$GCC" = yes; then
+ lt_prog_compiler_no_builtin_flag=' -fno-builtin'
+
+ echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6
+if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_cv_prog_compiler_rtti_exceptions=no
+ ac_outfile=conftest.$ac_objext
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="-fno-rtti -fno-exceptions"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:6385: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:6389: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings other than the usual output.
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_rtti_exceptions=yes
+ fi
+ fi
+ $RM conftest*
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6
+
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+ lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
+else
+ :
+fi
+
+fi
+
+
+
+
+
+
+ lt_prog_compiler_wl=
+lt_prog_compiler_pic=
+lt_prog_compiler_static=
+
+echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
+echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
+
+ if test "$GCC" = yes; then
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_static='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ if test "$host_cpu" = m68k; then
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
+ fi
+ ;;
+
+ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+
+ mingw* | cygwin* | pw32* | os2*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ # Although the cygwin gcc ignores -fPIC, still need this for old-style
+ # (--disable-auto-import) libraries
+ lt_prog_compiler_pic='-DDLL_EXPORT'
+ ;;
+
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ lt_prog_compiler_pic='-fno-common'
+ ;;
+
+ hpux*)
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic='-fPIC'
+ ;;
+ esac
+ ;;
+
+ interix[3-9]*)
+ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+ # Instead, we relocate shared libraries at runtime.
+ ;;
+
+ msdosdjgpp*)
+ # Just because we use GCC doesn't mean we suddenly get shared libraries
+ # on systems that don't support them.
+ lt_prog_compiler_can_build_shared=no
+ enable_shared=no
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ lt_prog_compiler_pic='-fPIC -shared'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ lt_prog_compiler_pic=-Kconform_pic
+ fi
+ ;;
+
+ *)
+ lt_prog_compiler_pic='-fPIC'
+ ;;
+ esac
+ else
+ # PORTME Check for flag to pass linker flags through the system compiler.
+ case $host_os in
+ aix*)
+ lt_prog_compiler_wl='-Wl,'
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static='-Bstatic'
+ else
+ lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+ darwin*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ case $cc_basename in
+ xlc*)
+ lt_prog_compiler_pic='-qnocommon'
+ lt_prog_compiler_wl='-Wl,'
+ ;;
+ esac
+ ;;
+
+ mingw* | cygwin* | pw32* | os2*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ lt_prog_compiler_pic='-DDLL_EXPORT'
+ ;;
+
+ hpux9* | hpux10* | hpux11*)
+ lt_prog_compiler_wl='-Wl,'
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic='+Z'
+ ;;
+ esac
+ # Is there a better lt_prog_compiler_static that works with the bundled CC?
+ lt_prog_compiler_static='${wl}-a ${wl}archive'
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ lt_prog_compiler_wl='-Wl,'
+ # PIC (with -KPIC) is the default.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+
+ linux* | k*bsd*-gnu)
+ case $cc_basename in
+ icc* | ecc*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-static'
+ ;;
+ pgcc* | pgf77* | pgf90* | pgf95*)
+ # Portland Group compilers (*not* the Pentium gcc compiler,
+ # which looks to be a dead project)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-fpic'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+ ccc*)
+ lt_prog_compiler_wl='-Wl,'
+ # All Alpha code is PIC.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C 5.9
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ lt_prog_compiler_wl='-Wl,'
+ ;;
+ *Sun\ F*)
+ # Sun Fortran 8.3 passes all unrecognized flags to the linker
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ lt_prog_compiler_wl=''
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ newsos6)
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ lt_prog_compiler_pic='-fPIC -shared'
+ ;;
+
+ osf3* | osf4* | osf5*)
+ lt_prog_compiler_wl='-Wl,'
+ # All OSF/1 code is PIC.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+
+ rdos*)
+ lt_prog_compiler_static='-non_shared'
+ ;;
+
+ solaris*)
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ case $cc_basename in
+ f77* | f90* | f95*)
+ lt_prog_compiler_wl='-Qoption ld ';;
+ *)
+ lt_prog_compiler_wl='-Wl,';;
+ esac
+ ;;
+
+ sunos4*)
+ lt_prog_compiler_wl='-Qoption ld '
+ lt_prog_compiler_pic='-PIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ sysv4 | sysv4.2uw2* | sysv4.3*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec ;then
+ lt_prog_compiler_pic='-Kconform_pic'
+ lt_prog_compiler_static='-Bstatic'
+ fi
+ ;;
+
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ unicos*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_can_build_shared=no
+ ;;
+
+ uts4*)
+ lt_prog_compiler_pic='-pic'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ *)
+ lt_prog_compiler_can_build_shared=no
+ ;;
+ esac
+ fi
+
+case $host_os in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ lt_prog_compiler_pic=
+ ;;
+ *)
+ lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
+ ;;
+esac
+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic" >&6
+
+
+
+
-# Save cache, so that ltconfig can load it
-cat >confcache <<\_ACEOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs, see configure's option --config-cache.
-# It is not useful on other systems. If it contains results you don't
-# want to keep, you may remove or edit it.
#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
+# Check to make sure the PIC flag actually works.
#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
+if test -n "$lt_prog_compiler_pic"; then
+ echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6
+if test "${lt_prog_compiler_pic_works+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_prog_compiler_pic_works=no
+ ac_outfile=conftest.$ac_objext
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:6707: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:6711: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings other than the usual output.
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+ lt_prog_compiler_pic_works=yes
+ fi
+ fi
+ $RM conftest*
+
+fi
+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_works" >&6
+
+if test x"$lt_prog_compiler_pic_works" = xyes; then
+ case $lt_prog_compiler_pic in
+ "" | " "*) ;;
+ *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
+ esac
+else
+ lt_prog_compiler_pic=
+ lt_prog_compiler_can_build_shared=no
+fi
+
+fi
+
+
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
+echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
+if test "${lt_prog_compiler_static_works+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_prog_compiler_static_works=no
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+ echo "$lt_simple_link_test_code" > conftest.$ac_ext
+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+ # The linker can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ # Append any errors to the config.log.
+ cat conftest.err 1>&5
+ $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if diff conftest.exp conftest.er2 >/dev/null; then
+ lt_prog_compiler_static_works=yes
+ fi
+ else
+ lt_prog_compiler_static_works=yes
+ fi
+ fi
+ $RM conftest*
+ LDFLAGS="$save_LDFLAGS"
+
+fi
+echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works" >&5
+echo "${ECHO_T}$lt_prog_compiler_static_works" >&6
+
+if test x"$lt_prog_compiler_static_works" = xyes; then
+ :
+else
+ lt_prog_compiler_static=
+fi
+
+
+
+
+
+
+
+ echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
+if test "${lt_cv_prog_compiler_c_o+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_cv_prog_compiler_c_o=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:6812: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:6816: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_c_o=yes
+ fi
+ fi
+ chmod u+w . 2>&5
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6
+
+
+
+
+
+
+ echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
+if test "${lt_cv_prog_compiler_c_o+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_cv_prog_compiler_c_o=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:6867: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:6871: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_c_o=yes
+ fi
+ fi
+ chmod u+w . 2>&5
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
+echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
+ hard_links=yes
+ $RM conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ echo "$as_me:$LINENO: result: $hard_links" >&5
+echo "${ECHO_T}$hard_links" >&6
+ if test "$hard_links" = no; then
+ { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+
+
+
+
+
+
+ echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
+
+ runpath_var=
+ allow_undefined_flag=
+ always_export_symbols=no
+ archive_cmds=
+ archive_expsym_cmds=
+ compiler_needs_object=no
+ enable_shared_with_static_runtimes=no
+ export_dynamic_flag_spec=
+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ hardcode_automatic=no
+ hardcode_direct=no
+ hardcode_direct_absolute=no
+ hardcode_libdir_flag_spec=
+ hardcode_libdir_flag_spec_ld=
+ hardcode_libdir_separator=
+ hardcode_minus_L=no
+ hardcode_shlibpath_var=unsupported
+ inherit_rpath=no
+ link_all_deplibs=unknown
+ module_cmds=
+ module_expsym_cmds=
+ old_archive_from_new_cmds=
+ old_archive_from_expsyms_cmds=
+ thread_safe_flag_spec=
+ whole_archive_flag_spec=
+ # include_expsyms should be a list of space-separated symbols to be *always*
+ # included in the symbol list
+ include_expsyms=
+ # exclude_expsyms can be an extended regexp of symbols to exclude
+ # it will be wrapped by ` (' and `)$', so one must not match beginning or
+ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+ # as well as any symbol that contains `d'.
+ exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+ # platforms (ab)use it in PIC code, but their linkers get confused if
+ # the symbol is explicitly referenced. Since portable code cannot
+ # rely on this symbol name, it's probably fine to never include it in
+ # preloaded symbol tables.
+ extract_expsyms_cmds=
+
+ case $host_os in
+ cygwin* | mingw* | pw32*)
+ # FIXME: the MSVC++ port hasn't been tested in a loooong time
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ if test "$GCC" != yes; then
+ with_gnu_ld=no
+ fi
+ ;;
+ interix*)
+ # we just hope/assume this is gcc and not c89 (= MSVC++)
+ with_gnu_ld=yes
+ ;;
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+ esac
+
+ ld_shlibs=yes
+ if test "$with_gnu_ld" = yes; then
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ wlarc='${wl}'
+
+ # Set some defaults for GNU ld with shared library support. These
+ # are reset later if shared libraries are not supported. Putting them
+ # here allows them to be overridden if necessary.
+ runpath_var=LD_RUN_PATH
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ export_dynamic_flag_spec='${wl}--export-dynamic'
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+ whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ whole_archive_flag_spec=
+ fi
+ supports_anon_versioning=no
+ case `$LD -v 2>&1` in
+ *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+ *\ 2.11.*) ;; # other 2.11 versions
+ *) supports_anon_versioning=yes ;;
+ esac
+
+ # See if GNU ld supports shared libraries.
+ case $host_os in
+ aix[3-9]*)
+ # On AIX/PPC, the GNU linker is very broken
+ if test "$host_cpu" != ia64; then
+ ld_shlibs=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support. If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+_LT_EOF
+ fi
+ ;;
+
+ amigaos*)
+ if test "$host_cpu" = m68k; then
+ archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ fi
+
+ # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+ # that the semantics of dynamic libraries on AmigaOS, at least up
+ # to version 4, is to share data among multiple programs linked
+ # with the same dynamic library. Since this doesn't match the
+ # behavior of shared libraries on other platforms, we can't use
+ # them.
+ ld_shlibs=no
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ allow_undefined_flag=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ cygwin* | mingw* | pw32*)
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
+ # as there is no search path for DLLs.
+ hardcode_libdir_flag_spec='-L$libdir'
+ allow_undefined_flag=unsupported
+ always_export_symbols=no
+ enable_shared_with_static_runtimes=yes
+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ interix[3-9]*)
+ hardcode_direct=no
+ hardcode_shlibpath_var=no
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec='${wl}-E'
+ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+ # Instead, shared libraries are loaded at an image base (0x10000000 by
+ # default) and relocated if they conflict, which is a slow very memory
+ # consuming and fragmenting process. To avoid this, we pick a random,
+ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ ;;
+
+ gnu* | linux* | tpf* | k*bsd*-gnu)
+ tmp_diet=no
+ if test "$host_os" = linux-dietlibc; then
+ case $cc_basename in
+ diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
+ esac
+ fi
+ if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+ && test "$tmp_diet" = no
+ then
+ tmp_addflag=
+ case $cc_basename,$host_cpu in
+ pgcc*) # Portland Group C compiler
+ whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag'
+ ;;
+ pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
+ whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag -Mnomain' ;;
+ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
+ tmp_addflag=' -i_dynamic' ;;
+ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
+ tmp_addflag=' -i_dynamic -nofor_main' ;;
+ ifc* | ifort*) # Intel Fortran compiler
+ tmp_addflag=' -nofor_main' ;;
+ esac
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*) # Sun C 5.9
+ whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ compiler_needs_object=yes
+ tmp_sharedflag='-G' ;;
+ *Sun\ F*) # Sun Fortran 8.3
+ tmp_sharedflag='-G' ;;
+ *)
+ tmp_sharedflag='-shared' ;;
+ esac
+ archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+ if test "x$supports_anon_versioning" = xyes; then
+ archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ fi
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+ wlarc=
+ else
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ fi
+ ;;
+
+ solaris*)
+ if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+ ld_shlibs=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+ case `$LD -v 2>&1` in
+ *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+ ld_shlibs=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ ;;
+ *)
+ # For security reasons, it is highly recommended that you always
+ # use absolute paths for naming shared libraries, and exclude the
+ # DT_RUNPATH tag from executables and libraries. But doing so
+ # requires that you compile everything twice, which is a pain.
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+ ;;
+
+ sunos4*)
+ archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ wlarc=
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ *)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+
+ if test "$ld_shlibs" = no; then
+ runpath_var=
+ hardcode_libdir_flag_spec=
+ export_dynamic_flag_spec=
+ whole_archive_flag_spec=
+ fi
+ else
+ # PORTME fill in a description of your system's linker (not GNU ld)
+ case $host_os in
+ aix3*)
+ allow_undefined_flag=unsupported
+ always_export_symbols=yes
+ archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+ # Note: this linker hardcodes the directories in LIBPATH if there
+ # are no directories specified by -L.
+ hardcode_minus_L=yes
+ if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+ # Neither direct hardcoding nor static linking is supported with a
+ # broken collect2.
+ hardcode_direct=unsupported
+ fi
+ ;;
+
+ aix[4-9]*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+ export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ else
+ export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ fi
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+ for ld_flag in $LDFLAGS; do
+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ aix_use_runtimelinking=yes
+ break
+ fi
+ done
+ ;;
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ archive_cmds=''
+ hardcode_direct=yes
+ hardcode_direct_absolute=yes
+ hardcode_libdir_separator=':'
+ link_all_deplibs=yes
+ file_list_spec='${wl}-f,'
+
+ if test "$GCC" = yes; then
+ case $host_os in aix4.[012]|aix4.[012].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" &&
+ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ hardcode_direct=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ hardcode_minus_L=yes
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_libdir_separator=
+ fi
+ ;;
+ esac
+ shared_flag='-shared'
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to export.
+ always_export_symbols=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ allow_undefined_flag='-berok'
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, don't put newlines in cache variables' values.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
+int
+main ()
{
- (set) 2>&1 |
- case `(ac_space=' '; set | grep ac_space) 2>&1` in
- *ac_space=\ *)
- # `set' does not quote correctly, so add quotes (double-quote
- # substitution turns \\\\ into \\, and sed turns \\ into \).
- sed -n \
- "s/'/'\\\\''/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\(.*\)$/\1/
+ p
+ }
+ }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+ aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+ archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+ allow_undefined_flag="-z nodefs"
+ archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\(.*\)$/\1/
+ p
+ }
+ }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+ aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ no_undefined_flag=' ${wl}-bernotok'
+ allow_undefined_flag=' ${wl}-berok'
+ # Exported symbols can be pulled into shared objects from archives
+ whole_archive_flag_spec='$convenience'
+ archive_cmds_need_lc=yes
+ # This is similar to how AIX traditionally builds its shared libraries.
+ archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ amigaos*)
+ if test "$host_cpu" = m68k; then
+ archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ fi
+ # see comment about different semantics on the GNU ld section
+ ld_shlibs=no
+ ;;
+
+ bsdi[45]*)
+ export_dynamic_flag_spec=-rdynamic
+ ;;
+
+ cygwin* | mingw* | pw32*)
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ hardcode_libdir_flag_spec=' '
+ allow_undefined_flag=unsupported
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ archive_cmds='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+ # The linker will automatically build a .lib file if we build a DLL.
+ old_archive_from_new_cmds='true'
+ # FIXME: Should let the user specify the lib program.
+ old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
+ fix_srcfile_path='`cygpath -w "$srcfile"`'
+ enable_shared_with_static_runtimes=yes
+ ;;
+
+ darwin* | rhapsody*)
+ case $host_os in
+ rhapsody* | darwin1.[012])
+ allow_undefined_flag='${wl}-undefined ${wl}suppress'
+ ;;
+ *) # Darwin 1.3 on
+ case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
+ 10.[012])
+ allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+ ;;
+ 10.*)
+ allow_undefined_flag='${wl}-undefined ${wl}dynamic_lookup'
+ ;;
+ esac
+ ;;
+ esac
+ archive_cmds_need_lc=no
+ hardcode_direct=no
+ hardcode_automatic=yes
+ hardcode_shlibpath_var=unsupported
+ whole_archive_flag_spec=''
+ link_all_deplibs=yes
+ if test "$GCC" = yes ; then
+ if test "${lt_cv_apple_cc_single_mod+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_cv_apple_cc_single_mod=no
+ if test -z "${LT_MULTI_MODULE}"; then
+ # By default we will add the -single_module flag. You can override
+ # by either setting the environment variable LT_MULTI_MODULE
+ # non-empty at configure time, or by adding -multi-module to the
+ # link flags.
+ echo "int foo(void){return 1;}" > conftest.c
+ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+ -dynamiclib ${wl}-single_module conftest.c
+ if test -f libconftest.dylib; then
+ lt_cv_apple_cc_single_mod=yes
+ rm libconftest.dylib
+ fi
+ rm conftest.$ac_ext
+ fi
+fi
+
+ output_verbose_link_cmd=echo
+ if test "X$lt_cv_apple_cc_single_mod" = Xyes ; then
+ archive_cmds='$CC -dynamiclib $single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+ archive_expsym_cmds='sed "s,^,_," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $single_module -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ else
+ archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+ archive_expsym_cmds='sed "s,^,_," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ fi
+ module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+ module_expsym_cmds='sed -e "s,^,_," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ else
+ case $cc_basename in
+ xlc*)
+ output_verbose_link_cmd=echo
+ archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`$ECHO $rpath/$soname` $verstring'
+ module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+ archive_expsym_cmds='sed "s,^,_," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ module_expsym_cmds='sed "s,^,_," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ ;;
+ *)
+ ld_shlibs=no
+ ;;
+ esac
+ fi
+ ;;
+
+ dgux*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_shlibpath_var=no
+ ;;
+
+ freebsd1*)
+ ld_shlibs=no
+ ;;
+
+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+ # support. Future versions do this automatically, but an explicit c++rt0.o
+ # does not break anything, and helps significantly (at the cost of a little
+ # extra space).
+ freebsd2.2*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+ freebsd2*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+ freebsd* | dragonfly*)
+ archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ hpux9*)
+ if test "$GCC" = yes; then
+ archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ fi
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ export_dynamic_flag_spec='${wl}-E'
+ ;;
+
+ hpux10*)
+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ if test "$with_gnu_ld" = no; then
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_flag_spec_ld='+b $libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+ hardcode_direct_absolute=yes
+ export_dynamic_flag_spec='${wl}-E'
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ fi
+ ;;
+
+ hpux11*)
+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ case $host_cpu in
+ hppa*64*)
+ archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ else
+ case $host_cpu in
+ hppa*64*)
+ archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ fi
+ if test "$with_gnu_ld" = no; then
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ hardcode_direct=no
+ hardcode_shlibpath_var=no
+ ;;
+ *)
+ hardcode_direct=yes
+ hardcode_direct_absolute=yes
+ export_dynamic_flag_spec='${wl}-E'
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ ;;
+ esac
+ fi
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ if test "$GCC" = yes; then
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ # Try to use the -exported_symbol ld option, if it does not
+ # work, assume that -exports_file does not work either and
+ # implicitly export all symbols.
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+ cat >conftest.$ac_ext <<_ACEOF
+int foo(void) {}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS="$save_LDFLAGS"
+ else
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+ fi
+ archive_cmds_need_lc='no'
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ inherit_rpath=yes
+ link_all_deplibs=yes
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+ else
+ archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+ fi
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ newsos6)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_shlibpath_var=no
+ ;;
+
+ *nto* | *qnx*)
+ ;;
+
+ openbsd*)
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ hardcode_direct_absolute=yes
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec='${wl}-E'
+ else
+ case $host_os in
+ openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-R$libdir'
+ ;;
+ *)
+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ ;;
+
+ os2*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ allow_undefined_flag=unsupported
+ archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+ old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+ ;;
+
+ osf3*)
+ if test "$GCC" = yes; then
+ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ allow_undefined_flag=' -expect_unresolved \*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ fi
+ archive_cmds_need_lc='no'
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ ;;
+
+ osf4* | osf5*) # as osf3* with the addition of -msym flag
+ if test "$GCC" = yes; then
+ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ else
+ allow_undefined_flag=' -expect_unresolved \*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+ # Both c and cxx compiler support -rpath directly
+ hardcode_libdir_flag_spec='-rpath $libdir'
+ fi
+ archive_cmds_need_lc='no'
+ hardcode_libdir_separator=:
+ ;;
+
+ solaris*)
+ no_undefined_flag=' -z defs'
+ if test "$GCC" = yes; then
+ wlarc='${wl}'
+ archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ else
+ case `$CC -V 2>&1` in
+ *"Compilers 5.0"*)
+ wlarc=''
+ archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+ ;;
+ *)
+ wlarc='${wl}'
+ archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ ;;
+ esac
+ fi
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_shlibpath_var=no
+ case $host_os in
+ solaris2.[0-5] | solaris2.[0-5].*) ;;
+ *)
+ # The compiler driver will combine and reorder linker options,
+ # but understands `-z linker_flag'. GCC discards it without `$wl',
+ # but is careful enough not to reorder.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ if test "$GCC" = yes; then
+ whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ else
+ whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
+ fi
+ ;;
+ esac
+ link_all_deplibs=yes
+ ;;
+
+ sunos4*)
+ if test "x$host_vendor" = xsequent; then
+ # Use $CC to link under sequent, because it throws in some extra .o
+ # files that make .init and .fini sections work.
+ archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ sysv4)
+ case $host_vendor in
+ sni)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes # is this really true???
+ ;;
+ siemens)
+ ## LD is ld it makes a PLAMLIB
+ ## CC just makes a GrossModule.
+ archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ reload_cmds='$CC -r -o $output$reload_objs'
+ hardcode_direct=no
+ ;;
+ motorola)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ runpath_var='LD_RUN_PATH'
+ hardcode_shlibpath_var=no
;;
+
+ sysv4.3*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var=no
+ export_dynamic_flag_spec='-Bexport'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var=no
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ ld_shlibs=yes
+ fi
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+ no_undefined_flag='${wl}-z,text'
+ archive_cmds_need_lc=no
+ hardcode_shlibpath_var=no
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6*)
+ # Note: We can NOT use -z defs as we might desire, because we do not
+ # link with -lc, and that would cause any symbols used from libc to
+ # always be unresolved, which means just about no library would
+ # ever link correctly. If we're not using GNU ld we use -z text
+ # though, which does catch some bad symbols but isn't as heavy-handed
+ # as -z defs.
+ no_undefined_flag='${wl}-z,text'
+ allow_undefined_flag='${wl}-z,nodefs'
+ archive_cmds_need_lc=no
+ hardcode_shlibpath_var=no
+ hardcode_libdir_flag_spec='${wl}-R,$libdir'
+ hardcode_libdir_separator=':'
+ link_all_deplibs=yes
+ export_dynamic_flag_spec='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ uts4*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_shlibpath_var=no
+ ;;
+
*)
- # `set' quotes correctly as required by POSIX, so do not add quotes.
- sed -n \
- "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ ld_shlibs=no
;;
- esac;
-} |
- sed '
- t clear
- : clear
- s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
- t end
- /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
- : end' >>confcache
-if diff $cache_file confcache >/dev/null 2>&1; then :; else
- if test -w $cache_file; then
- test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
- cat confcache >$cache_file
+ esac
+
+ if test x$host_vendor = xsni; then
+ case $host in
+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ export_dynamic_flag_spec='${wl}-Blargedynsym'
+ ;;
+ esac
+ fi
+ fi
+
+echo "$as_me:$LINENO: result: $ld_shlibs" >&5
+echo "${ECHO_T}$ld_shlibs" >&6
+test "$ld_shlibs" = no && can_build_shared=no
+
+with_gnu_ld=$with_gnu_ld
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc" in
+x|xyes)
+ # Assume -lc should be added
+ archive_cmds_need_lc=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $archive_cmds in
+ *'~'*)
+ # FIXME: we may have to deal with multi-command sequences.
+ ;;
+ '$CC '*)
+ # Test whether the compiler implicitly links with -lc since on some
+ # systems, -lgcc has to come before -lc. If gcc already passes -lc
+ # to ld, don't add -lc before -lgcc.
+ echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
+echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
+ $RM conftest*
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$lt_prog_compiler_wl
+ pic_flag=$lt_prog_compiler_pic
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$allow_undefined_flag
+ allow_undefined_flag=
+ if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\"") >&5
+ (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+ then
+ archive_cmds_need_lc=no
+ else
+ archive_cmds_need_lc=yes
+ fi
+ allow_undefined_flag=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $RM conftest*
+ echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5
+echo "${ECHO_T}$archive_cmds_need_lc" >&6
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
+echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
+withGCC=$GCC
+if test "$withGCC" = yes; then
+ case $host_os in
+ darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+ *) lt_awk_arg="/^libraries:/" ;;
+ esac
+ lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
+ # if the path contains ";" then we assume it to be the separator
+ # otherwise default to the standard path separator (i.e. ":") - it is
+ # assumed that no part of a normal pathname contains ";" but that should
+ # okay in the real world where ";" in dirpaths is itself problematic.
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
else
- echo "not updating unwritable cache $cache_file"
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ # Ok, now we have the path, separated by spaces, we can step through it
+ # and add multilib dir if necessary.
+ lt_tmp_lt_search_path_spec=
+ lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+ for lt_sys_path in $lt_search_path_spec; do
+ if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+ else
+ test -d "$lt_sys_path" && \
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+ fi
+ done
+ lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+ lt_foo="";
+ lt_count=0;
+ for (lt_i = NF; lt_i > 0; lt_i--) {
+ if ($lt_i != "" && $lt_i != ".") {
+ if ($lt_i == "..") {
+ lt_count++;
+ } else {
+ if (lt_count == 0) {
+ lt_foo="/" $lt_i lt_foo;
+ } else {
+ lt_count--;
+ }
+ }
+ }
+ }
+ if (lt_foo != "") { lt_freq[lt_foo]++; }
+ if (lt_freq[lt_foo] == 1) { print lt_foo; }
+}'`
+ sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
+else
+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX 3 has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+
+aix[4-9]*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ hardcode_into_libs=yes
+ if test "$host_cpu" = ia64; then
+ # AIX 5 supports IA64
+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ else
+ # With GCC up to 2.95.x, collect2 would create an import file
+ # for dependence libraries. The import file would start with
+ # the line `#! .'. This would cause the generated library to
+ # depend on `.', always an invalid library. This was fixed in
+ # development snapshots of GCC prior to 3.0.
+ case $host_os in
+ aix4 | aix4.[01] | aix4.[01].*)
+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+ echo ' yes '
+ echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+ :
+ else
+ can_build_shared=no
+ fi
+ ;;
+ esac
+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ if test "$aix_use_runtimelinking" = yes; then
+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+ # instead of lib<name>.a to let people know that these are not
+ # typical AIX shared libraries.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+ # We preserve .a as extension for shared libraries through AIX4.2
+ # and later when we are not doing run time linking.
+ library_names_spec='${libname}${release}.a $libname.a'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+ shlibpath_var=LIBPATH
+ fi
+ ;;
+
+amigaos*)
+ if test "$host_cpu" = m68k; then
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ else
+ dynamic_linker=no
+ fi
+ ;;
+
+beos*)
+ library_names_spec='${libname}${shared_ext}'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi[45]*)
+ version_type=linux
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw* | pw32*)
+ version_type=windows
+ shrext_cmds=".dll"
+ need_version=no
+ need_lib_prefix=no
+
+ case $withGCC,$host_os in
+ yes,cygwin* | yes,mingw* | yes,pw32*)
+ library_names_spec='$libname.dll.a'
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname~
+ chmod a+x \$dldir/$dlname~
+ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+ fi'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+
+ case $host_os in
+ cygwin*)
+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+ ;;
+ mingw*)
+ # MinGW DLLs use traditional 'lib' prefix
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+ # It is most probably a Windows format PATH printed by
+ # mingw gcc, but we are running on Cygwin. Gcc prints its search
+ # path with ; separators, and with drive letters. We can handle the
+ # drive letters (cygwin fileutils understands them), so leave them,
+ # especially as we might pass files found there to a mingw objdump,
+ # which wouldn't understand a cygwinified path. Ahh.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+ ;;
+
+ *)
+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+darwin* | rhapsody*)
+ dynamic_linker="$host_os dyld"
+ version_type=darwin
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+ soname_spec='${libname}${release}${major}$shared_ext'
+ shlibpath_overrides_runpath=yes
+ shlibpath_var=DYLD_LIBRARY_PATH
+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+dgux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+freebsd1*)
+ dynamic_linker=no
+ ;;
+
+freebsd* | dragonfly*)
+ # DragonFly does not have aout. When/if they implement a new
+ # versioning mechanism, adjust this.
+ if test -x /usr/bin/objformat; then
+ objformat=`/usr/bin/objformat`
+ else
+ case $host_os in
+ freebsd[123]*) objformat=aout ;;
+ *) objformat=elf ;;
+ esac
+ fi
+ version_type=freebsd-$objformat
+ case $version_type in
+ freebsd-elf*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ need_version=yes
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_os in
+ freebsd2*)
+ shlibpath_overrides_runpath=yes
+ ;;
+ freebsd3.[01]* | freebsdelf3.[01]*)
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+ *) # from 4.6 on, and DragonFly
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+gnu*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ hardcode_into_libs=yes
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ case $host_cpu in
+ ia64*)
+ shrext_cmds='.so'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.so"
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ if test "X$HPUX_IA64_MODE" = X32; then
+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ else
+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ fi
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ hppa*64*)
+ shrext_cmds='.sl'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ *)
+ shrext_cmds='.sl'
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=SHLIB_PATH
+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+ esac
+ # HP-UX runs *really* slowly unless shared libraries are mode 555.
+ postinstall_cmds='chmod 555 $lib'
+ ;;
+
+interix[3-9]*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $host_os in
+ nonstopux*) version_type=nonstopux ;;
+ *)
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ version_type=linux
+ else
+ version_type=irix
+ fi ;;
+ esac
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ case $host_os in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+ libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+ libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+ libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ hardcode_into_libs=yes
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+ dynamic_linker=no
+ ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ # Some binutils ld are patched to set DT_RUNPATH
+ save_LDFLAGS=$LDFLAGS
+ save_libdir=$libdir
+ eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
+ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir"; then
+ shlibpath_overrides_runpath=yes
+fi
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS=$save_LDFLAGS
+ libdir=$save_libdir
+
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ # Append ld.so.conf contents to the search path
+ if test -f /etc/ld.so.conf; then
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ fi
+
+ # We used to test for /lib/ld.so.1 and disable shared libraries on
+ # powerpc, because MkLinux only supported shared libraries with the
+ # GNU dynamic linker. Since this was broken with cross compilers,
+ # most powerpc-linux boxes support dynamic linking these days and
+ # people can always --disable-shared, the test was removed, and we
+ # assume the GNU/Linux dynamic linker is in use.
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
+netbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+
+newsos6)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+*nto* | *qnx*)
+ version_type=qnx
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='ldqnx.so'
+ ;;
+
+openbsd*)
+ version_type=sunos
+ sys_lib_dlsearch_path_spec="/usr/lib"
+ need_lib_prefix=no
+ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+ case $host_os in
+ openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+ *) need_version=no ;;
+ esac
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+ openbsd2.[89] | openbsd2.[89].*)
+ shlibpath_overrides_runpath=no
+ ;;
+ *)
+ shlibpath_overrides_runpath=yes
+ ;;
+ esac
+ else
+ shlibpath_overrides_runpath=yes
+ fi
+ ;;
+
+os2*)
+ libname_spec='$name'
+ shrext_cmds=".dll"
+ need_lib_prefix=no
+ library_names_spec='$libname${shared_ext} $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4* | osf5*)
+ version_type=osf
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+rdos*)
+ dynamic_linker=no
+ ;;
+
+solaris*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4 | sysv4.3*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_vendor in
+ sni)
+ shlibpath_overrides_runpath=no
+ need_lib_prefix=no
+ runpath_var=LD_RUN_PATH
+ ;;
+ siemens)
+ need_lib_prefix=no
+ ;;
+ motorola)
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+ ;;
+ esac
+ ;;
+
+sysv4*MP*)
+ if test -d /usr/nec ;then
+ version_type=linux
+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+ soname_spec='$libname${shared_ext}.$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ version_type=freebsd-elf
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ if test "$with_gnu_ld" = yes; then
+ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+ else
+ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+ case $host_os in
+ sco3.2v5*)
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+ ;;
+ esac
fi
+ sys_lib_dlsearch_path_spec='/usr/lib'
+ ;;
+
+tpf*)
+ # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+uts4*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+echo "$as_me:$LINENO: result: $dynamic_linker" >&5
+echo "${ECHO_T}$dynamic_linker" >&6
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
fi
-rm -f confcache
-# Actually configure libtool. ac_aux_dir is where install-sh is found.
-AR="$AR" LTCC="$CC" CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
-MAGIC_CMD="$MAGIC_CMD" LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
-LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" STRIP="$STRIP" \
-AS="$AS" DLLTOOL="$DLLTOOL" OBJDUMP="$OBJDUMP" \
-objext="$OBJEXT" exeext="$EXEEXT" reload_flag="$reload_flag" \
-deplibs_check_method="$deplibs_check_method" file_magic_cmd="$file_magic_cmd" \
-${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
-$libtool_flags --no-verify --build="$build" $ac_aux_dir/ltmain.sh $host \
-|| { { echo "$as_me:$LINENO: error: libtool configure failed" >&5
-echo "$as_me: error: libtool configure failed" >&2;}
- { (exit 1); exit 1; }; }
-# Reload cache, that may have been modified by ltconfig
-if test -r "$cache_file"; then
- # Some versions of bash will fail to source /dev/null (special
- # files actually), so we avoid doing that.
- if test -f "$cache_file"; then
- { echo "$as_me:$LINENO: loading cache $cache_file" >&5
-echo "$as_me: loading cache $cache_file" >&6;}
- case $cache_file in
- [\\/]* | ?:[\\/]* ) . $cache_file;;
- *) . ./$cache_file;;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
+echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" ||
+ test -n "$runpath_var" ||
+ test "X$hardcode_automatic" = "Xyes" ; then
+
+ # We can hardcode non-existent directories.
+ if test "$hardcode_direct" != no &&
+ # If the only mechanism to avoid hardcoding is shlibpath_var, we
+ # have to relink, otherwise we might link with an installed library
+ # when we should be linking with a yet-to-be-installed one
+ ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
+ test "$hardcode_minus_L" != no; then
+ # Linking always hardcodes the temporary library directory.
+ hardcode_action=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ hardcode_action=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ hardcode_action=unsupported
+fi
+echo "$as_me:$LINENO: result: $hardcode_action" >&5
+echo "${ECHO_T}$hardcode_action" >&6
+
+if test "$hardcode_action" = relink ||
+ test "$inherit_rpath" = yes; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
+fi
+
+
+
+
+
+
+ if test "x$enable_dlopen" != xyes; then
+ enable_dlopen=unknown
+ enable_dlopen_self=unknown
+ enable_dlopen_self_static=unknown
+else
+ lt_cv_dlopen=no
+ lt_cv_dlopen_libs=
+
+ case $host_os in
+ beos*)
+ lt_cv_dlopen="load_add_on"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+ ;;
+
+ mingw* | pw32*)
+ lt_cv_dlopen="LoadLibrary"
+ lt_cv_dlopen_libs=
+ ;;
+
+ cygwin*)
+ lt_cv_dlopen="dlopen"
+ lt_cv_dlopen_libs=
+ ;;
+
+ darwin*)
+ # if libdl is installed we need to link against it
+ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dl_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dl_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
+if test $ac_cv_lib_dl_dlopen = yes; then
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+
+ lt_cv_dlopen="dyld"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+
+fi
+
+ ;;
+
+ *)
+ echo "$as_me:$LINENO: checking for shl_load" >&5
+echo $ECHO_N "checking for shl_load... $ECHO_C" >&6
+if test "${ac_cv_func_shl_load+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define shl_load to an innocuous variant, in case <limits.h> declares shl_load.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define shl_load innocuous_shl_load
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char shl_load (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef shl_load
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char shl_load ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_shl_load) || defined (__stub___shl_load)
+choke me
+#else
+char (*f) () = shl_load;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != shl_load;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_shl_load=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_shl_load=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5
+echo "${ECHO_T}$ac_cv_func_shl_load" >&6
+if test $ac_cv_func_shl_load = yes; then
+ lt_cv_dlopen="shl_load"
+else
+ echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5
+echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6
+if test "${ac_cv_lib_dld_shl_load+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char shl_load ();
+int
+main ()
+{
+shl_load ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dld_shl_load=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dld_shl_load=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5
+echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6
+if test $ac_cv_lib_dld_shl_load = yes; then
+ lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
+else
+ echo "$as_me:$LINENO: checking for dlopen" >&5
+echo $ECHO_N "checking for dlopen... $ECHO_C" >&6
+if test "${ac_cv_func_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define dlopen to an innocuous variant, in case <limits.h> declares dlopen.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define dlopen innocuous_dlopen
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char dlopen (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef dlopen
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_dlopen) || defined (__stub___dlopen)
+choke me
+#else
+char (*f) () = dlopen;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != dlopen;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5
+echo "${ECHO_T}$ac_cv_func_dlopen" >&6
+if test $ac_cv_func_dlopen = yes; then
+ lt_cv_dlopen="dlopen"
+else
+ echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5
+echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dl_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dl_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6
+if test $ac_cv_lib_dl_dlopen = yes; then
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+ echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5
+echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6
+if test "${ac_cv_lib_svld_dlopen+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dlopen ();
+int
+main ()
+{
+dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_svld_dlopen=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_svld_dlopen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5
+echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6
+if test $ac_cv_lib_svld_dlopen = yes; then
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+ echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5
+echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6
+if test "${ac_cv_lib_dld_dld_link+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char dld_link ();
+int
+main ()
+{
+dld_link ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_dld_dld_link=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_dld_dld_link=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5
+echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6
+if test $ac_cv_lib_dld_dld_link = yes; then
+ lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+ ;;
+ esac
+
+ if test "x$lt_cv_dlopen" != xno; then
+ enable_dlopen=yes
+ else
+ enable_dlopen=no
+ fi
+
+ case $lt_cv_dlopen in
+ dlopen)
+ save_CPPFLAGS="$CPPFLAGS"
+ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+ save_LDFLAGS="$LDFLAGS"
+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+ save_LIBS="$LIBS"
+ LIBS="$lt_cv_dlopen_libs $LIBS"
+
+ echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5
+echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6
+if test "${lt_cv_dlopen_self+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$cross_compiling" = yes; then :
+ lt_cv_dlopen_self=cross
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+#line 9664 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ /* dlclose (self); */
+ }
+ else
+ puts (dlerror ());
+
+ exit (status);
+}
+_LT_EOF
+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) >&5 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+ x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+ x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
esac
+ else :
+ # compilation failed
+ lt_cv_dlopen_self=no
fi
+fi
+rm -fr conftest*
+
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5
+echo "${ECHO_T}$lt_cv_dlopen_self" >&6
+
+ if test "x$lt_cv_dlopen_self" = xyes; then
+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+ echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5
+echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6
+if test "${lt_cv_dlopen_self_static+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
else
- { echo "$as_me:$LINENO: creating cache $cache_file" >&5
-echo "$as_me: creating cache $cache_file" >&6;}
- >$cache_file
+ if test "$cross_compiling" = yes; then :
+ lt_cv_dlopen_self_static=cross
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+#line 9764 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ /* dlclose (self); */
+ }
+ else
+ puts (dlerror ());
+
+ exit (status);
+}
+_LT_EOF
+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) >&5 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+ x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+ x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
+ esac
+ else :
+ # compilation failed
+ lt_cv_dlopen_self_static=no
+ fi
fi
+rm -fr conftest*
+
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5
+echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6
+ fi
+
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ LIBS="$save_LIBS"
+ ;;
+ esac
+
+ case $lt_cv_dlopen_self in
+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+ *) enable_dlopen_self=unknown ;;
+ esac
+
+ case $lt_cv_dlopen_self_static in
+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+ *) enable_dlopen_self_static=unknown ;;
+ esac
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+striplib=
+old_striplib=
+echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5
+echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+ test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+ case $host_os in
+ darwin*)
+ if test -n "$STRIP" ; then
+ striplib="$STRIP -x"
+ old_striplib="$STRIP -S"
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ fi
+ ;;
+ *)
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ ;;
+ esac
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+ # Report which library types will actually be built
+ echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
+echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
+ echo "$as_me:$LINENO: result: $can_build_shared" >&5
+echo "${ECHO_T}$can_build_shared" >&6
+
+ echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
+echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6
+ test "$can_build_shared" = "no" && enable_shared=no
+
+ # On AIX, shared libraries and static libraries use the same namespace, and
+ # are all built from PIC.
+ case $host_os in
+ aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+
+ aix[4-9]*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ esac
+ echo "$as_me:$LINENO: result: $enable_shared" >&5
+echo "${ECHO_T}$enable_shared" >&6
+
+ echo "$as_me:$LINENO: checking whether to build static libraries" >&5
+echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6
+ # Make sure either enable_shared or enable_static is yes.
+ test "$enable_shared" = yes || enable_static=yes
+ echo "$as_me:$LINENO: result: $enable_static" >&5
+echo "${ECHO_T}$enable_static" >&6
+
+
+
+
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+
+
-# This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh $ac_aux_dir/ltcf-c.sh"
-# Always use our own libtool.
-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
-# Redirect the config.log output again, so that the ltconfig log is not
-# clobbered by the next message.
-exec 5>>./config.log
+ ac_config_commands="$ac_config_commands libtool"
+
+
+
+
+# Only expand once:
+
+
@@ -4760,7 +10116,7 @@ fi
# Provide some information about the compiler.
-echo "$as_me:4763:" \
+echo "$as_me:10119:" \
"checking for Fortran compiler version" >&5
ac_compiler=`set X $ac_compile; echo $2`
{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
@@ -4903,241 +10259,2926 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
-FCFLAGS="$FCFLAGS -Wall"
-# For libtool versioning info, format is CURRENT:REVISION:AGE
-libtool_VERSION=1:0:0
+ac_ext=${FC_SRCEXT-f}
+ac_compile='$FC -c $FCFLAGS $FCFLAGS_SRCEXT conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $FCFLAGS_SRCEXT conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ for ac_prog in f95 fort xlf95 ifc efc pgf95 lf95 gfortran f90 xlf90 pgf90 epcf90 g77 f77 xlf frt pgf77 fort77 fl32 af77
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_FC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$FC"; then
+ ac_cv_prog_FC="$FC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_FC="$ac_tool_prefix$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+fi
+fi
+FC=$ac_cv_prog_FC
+if test -n "$FC"; then
+ echo "$as_me:$LINENO: result: $FC" >&5
+echo "${ECHO_T}$FC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
-# Check header files.
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
-echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
- CPP=
+ test -n "$FC" && break
+ done
fi
-if test -z "$CPP"; then
- if test "${ac_cv_prog_CPP+set}" = set; then
+if test -z "$FC"; then
+ ac_ct_FC=$FC
+ for ac_prog in f95 fort xlf95 ifc efc pgf95 lf95 gfortran f90 xlf90 pgf90 epcf90 g77 f77 xlf frt pgf77 fort77 fl32 af77
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_FC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
- # Double quotes because CPP needs to be expanded
- for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
- do
- ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
+ if test -n "$ac_ct_FC"; then
+ ac_cv_prog_ac_ct_FC="$ac_ct_FC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_FC="$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_FC=$ac_cv_prog_ac_ct_FC
+if test -n "$ac_ct_FC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_FC" >&5
+echo "${ECHO_T}$ac_ct_FC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$ac_ct_FC" && break
+done
+
+ FC=$ac_ct_FC
+fi
+
+
+# Provide some information about the compiler.
+echo "$as_me:10355:" \
+ "checking for Fortran compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
+ (eval $ac_compiler --version </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
+ (eval $ac_compiler -v </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
+ (eval $ac_compiler -V </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+rm -f a.out
+
+# If we don't use `.F' as extension, the preprocessor is not run on the
+# input file. (Note that this only needs to work for GNU compilers.)
+ac_save_ext=$ac_ext
+ac_ext=F
+echo "$as_me:$LINENO: checking whether we are using the GNU Fortran compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU Fortran compiler... $ECHO_C" >&6
+if test "${ac_cv_fc_compiler_gnu+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
+ program main
+#ifndef __GNUC__
+ choke me
#endif
- Syntax error
+
+ end
_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
-fi
-if test -z "$ac_cpp_err"; then
- :
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_fc_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_compiler_gnu=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- # Broken: fails on valid input.
-continue
+ac_compiler_gnu=no
fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_fc_compiler_gnu=$ac_compiler_gnu
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
+fi
+echo "$as_me:$LINENO: result: $ac_cv_fc_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_fc_compiler_gnu" >&6
+ac_ext=$ac_save_ext
+ac_test_FFLAGS=${FCFLAGS+set}
+ac_save_FFLAGS=$FCFLAGS
+FCFLAGS=
+echo "$as_me:$LINENO: checking whether $FC accepts -g" >&5
+echo $ECHO_N "checking whether $FC accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_fc_g+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ FCFLAGS=-g
+cat >conftest.$ac_ext <<_ACEOF
+ program main
+
+ end
_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_fc_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_fc_g=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_prog_fc_g=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_fc_g" >&5
+echo "${ECHO_T}$ac_cv_prog_fc_g" >&6
+if test "$ac_test_FFLAGS" = set; then
+ FCFLAGS=$ac_save_FFLAGS
+elif test $ac_cv_prog_fc_g = yes; then
+ if test "x$ac_cv_fc_compiler_gnu" = xyes; then
+ FCFLAGS="-g -O2"
else
- ac_cpp_err=
+ FCFLAGS="-g"
fi
else
- ac_cpp_err=yes
+ if test "x$ac_cv_fc_compiler_gnu" = xyes; then
+ FCFLAGS="-O2"
+ else
+ FCFLAGS=
+ fi
fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
- # Passes both tests.
-ac_preproc_ok=:
-break
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+if test -z "$FC" || test "X$FC" = "Xno"; then
+ _lt_disable_FC=yes
fi
-rm -f conftest.err conftest.$ac_ext
+
+
+ ac_ext=${FC_SRCEXT-f}
+ac_compile='$FC -c $FCFLAGS $FCFLAGS_SRCEXT conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $FCFLAGS_SRCEXT conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+
+
+archive_cmds_need_lc_FC=no
+allow_undefined_flag_FC=
+always_export_symbols_FC=no
+archive_expsym_cmds_FC=
+export_dynamic_flag_spec_FC=
+hardcode_direct_FC=no
+hardcode_direct_absolute_FC=no
+hardcode_libdir_flag_spec_FC=
+hardcode_libdir_flag_spec_ld_FC=
+hardcode_libdir_separator_FC=
+hardcode_minus_L_FC=no
+hardcode_automatic_FC=no
+inherit_rpath_FC=no
+module_cmds_FC=
+module_expsym_cmds_FC=
+link_all_deplibs_FC=unknown
+old_archive_cmds_FC=$old_archive_cmds
+no_undefined_flag_FC=
+whole_archive_flag_spec_FC=
+enable_shared_with_static_runtimes_FC=no
+
+# Source file extension for fc test sources.
+ac_ext=${ac_fc_srcext-f}
+
+# Object file extension for compiled fc test sources.
+objext=o
+objext_FC=$objext
+
+# No sense in running all these tests if we already determined that
+# the FC compiler isn't working. Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_FC" != yes; then
+ # Code to be used in simple compile tests
+ lt_simple_compile_test_code="\
+ subroutine t
+ return
+ end
+"
+
+ # Code to be used in simple link tests
+ lt_simple_link_test_code="\
+ program t
+ end
+"
+
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+ # save warnings/boilerplate of simple test code
+ ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+
+ ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM conftest*
+
+
+ # Allow CC to be a program name with arguments.
+ lt_save_CC="$CC"
+ CC=${FC-"f95"}
+ compiler=$CC
+ compiler_FC=$CC
+ for cc_temp in $compiler""; do
+ case $cc_temp in
+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+ \-*) ;;
+ *) break;;
+ esac
done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- break
+cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+
+ if test -n "$compiler"; then
+ echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5
+echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6
+ echo "$as_me:$LINENO: result: $can_build_shared" >&5
+echo "${ECHO_T}$can_build_shared" >&6
+
+ echo "$as_me:$LINENO: checking whether to build shared libraries" >&5
+echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6
+ test "$can_build_shared" = "no" && enable_shared=no
+
+ # On AIX, shared libraries and static libraries use the same namespace, and
+ # are all built from PIC.
+ case $host_os in
+ aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+ aix[4-9]*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ esac
+ echo "$as_me:$LINENO: result: $enable_shared" >&5
+echo "${ECHO_T}$enable_shared" >&6
+
+ echo "$as_me:$LINENO: checking whether to build static libraries" >&5
+echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6
+ # Make sure either enable_shared or enable_static is yes.
+ test "$enable_shared" = yes || enable_static=yes
+ echo "$as_me:$LINENO: result: $enable_static" >&5
+echo "${ECHO_T}$enable_static" >&6
+
+ GCC_FC="$ac_cv_fc_compiler_gnu"
+ LD_FC="$LD"
+
+ ## CAVEAT EMPTOR:
+ ## There is no encapsulation within the following macros, do not change
+ ## the running order or otherwise move them around unless you know exactly
+ ## what you are doing...
+ # Dependencies to place before and after the object being linked:
+predep_objects_FC=
+postdep_objects_FC=
+predeps_FC=
+postdeps_FC=
+compiler_lib_search_path_FC=
+
+cat > conftest.$ac_ext <<_LT_EOF
+ subroutine foo
+ implicit none
+ integer a
+ a=0
+ return
+ end
+_LT_EOF
+
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # Parse the compiler output and extract the necessary
+ # objects, libraries and library flags.
+
+ # Sentinel used to keep track of whether or not we are before
+ # the conftest object file.
+ pre_test_object_deps_done=no
+
+ # The `*' in the case matches for architectures that use `case' in
+ # $output_verbose_cmd can trigger glob expansion during the loop
+ # eval without this substitution.
+ output_verbose_link_cmd=`$ECHO "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
+
+ for p in `eval $output_verbose_link_cmd`; do
+ case $p in
+
+ -L* | -R* | -l*)
+ # Some compilers place space between "-{L,R}" and the path.
+ # Remove the space.
+ if test $p = "-L" ||
+ test $p = "-R"; then
+ prev=$p
+ continue
+ else
+ prev=
+ fi
+
+ if test "$pre_test_object_deps_done" = no; then
+ case $p in
+ -L* | -R*)
+ # Internal compiler library paths should come after those
+ # provided the user. The postdeps already come after the
+ # user supplied libs so there is no need to process them.
+ if test -z "$compiler_lib_search_path_FC"; then
+ compiler_lib_search_path_FC="${prev}${p}"
+ else
+ compiler_lib_search_path_FC="${compiler_lib_search_path_FC} ${prev}${p}"
+ fi
+ ;;
+ # The "-l" case would never come before the object being
+ # linked, so don't bother handling this case.
+ esac
+ else
+ if test -z "$postdeps_FC"; then
+ postdeps_FC="${prev}${p}"
+ else
+ postdeps_FC="${postdeps_FC} ${prev}${p}"
+ fi
+ fi
+ ;;
+
+ *.$objext)
+ # This assumes that the test object file only shows up
+ # once in the compiler output.
+ if test "$p" = "conftest.$objext"; then
+ pre_test_object_deps_done=yes
+ continue
+ fi
+
+ if test "$pre_test_object_deps_done" = no; then
+ if test -z "$predep_objects_FC"; then
+ predep_objects_FC="$p"
+ else
+ predep_objects_FC="$predep_objects_FC $p"
+ fi
+ else
+ if test -z "$postdep_objects_FC"; then
+ postdep_objects_FC="$p"
+ else
+ postdep_objects_FC="$postdep_objects_FC $p"
+ fi
+ fi
+ ;;
+
+ *) ;; # Ignore the rest.
+
+ esac
+ done
+
+ # Clean up.
+ rm -f a.out a.exe
+else
+ echo "libtool.m4: error: problem compiling FC test program"
fi
- done
- ac_cv_prog_CPP=$CPP
+$RM -f confest.$objext
+
+# PORTME: override above test on systems where it is broken
+
+
+case " $postdeps_FC " in
+*" -lc "*) archive_cmds_need_lc_FC=no ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ lt_prog_compiler_wl_FC=
+lt_prog_compiler_pic_FC=
+lt_prog_compiler_static_FC=
+
+echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5
+echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6
+
+ if test "$GCC" = yes; then
+ lt_prog_compiler_wl_FC='-Wl,'
+ lt_prog_compiler_static_FC='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static_FC='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ if test "$host_cpu" = m68k; then
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ lt_prog_compiler_pic_FC='-m68020 -resident32 -malways-restore-a4'
+ fi
+ ;;
+
+ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+
+ mingw* | cygwin* | pw32* | os2*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ # Although the cygwin gcc ignores -fPIC, still need this for old-style
+ # (--disable-auto-import) libraries
+ lt_prog_compiler_pic_FC='-DDLL_EXPORT'
+ ;;
+
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ lt_prog_compiler_pic_FC='-fno-common'
+ ;;
+
+ hpux*)
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic_FC='-fPIC'
+ ;;
+ esac
+ ;;
+
+ interix[3-9]*)
+ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+ # Instead, we relocate shared libraries at runtime.
+ ;;
+
+ msdosdjgpp*)
+ # Just because we use GCC doesn't mean we suddenly get shared libraries
+ # on systems that don't support them.
+ lt_prog_compiler_can_build_shared_FC=no
+ enable_shared=no
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ lt_prog_compiler_pic_FC='-fPIC -shared'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ lt_prog_compiler_pic_FC=-Kconform_pic
+ fi
+ ;;
+
+ *)
+ lt_prog_compiler_pic_FC='-fPIC'
+ ;;
+ esac
+ else
+ # PORTME Check for flag to pass linker flags through the system compiler.
+ case $host_os in
+ aix*)
+ lt_prog_compiler_wl_FC='-Wl,'
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static_FC='-Bstatic'
+ else
+ lt_prog_compiler_static_FC='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+ darwin*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ case $cc_basename in
+ xlc*)
+ lt_prog_compiler_pic_FC='-qnocommon'
+ lt_prog_compiler_wl_FC='-Wl,'
+ ;;
+ esac
+ ;;
+
+ mingw* | cygwin* | pw32* | os2*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ lt_prog_compiler_pic_FC='-DDLL_EXPORT'
+ ;;
+
+ hpux9* | hpux10* | hpux11*)
+ lt_prog_compiler_wl_FC='-Wl,'
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic_FC='+Z'
+ ;;
+ esac
+ # Is there a better lt_prog_compiler_static that works with the bundled CC?
+ lt_prog_compiler_static_FC='${wl}-a ${wl}archive'
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ lt_prog_compiler_wl_FC='-Wl,'
+ # PIC (with -KPIC) is the default.
+ lt_prog_compiler_static_FC='-non_shared'
+ ;;
+
+ linux* | k*bsd*-gnu)
+ case $cc_basename in
+ icc* | ecc*)
+ lt_prog_compiler_wl_FC='-Wl,'
+ lt_prog_compiler_pic_FC='-KPIC'
+ lt_prog_compiler_static_FC='-static'
+ ;;
+ pgcc* | pgf77* | pgf90* | pgf95*)
+ # Portland Group compilers (*not* the Pentium gcc compiler,
+ # which looks to be a dead project)
+ lt_prog_compiler_wl_FC='-Wl,'
+ lt_prog_compiler_pic_FC='-fpic'
+ lt_prog_compiler_static_FC='-Bstatic'
+ ;;
+ ccc*)
+ lt_prog_compiler_wl_FC='-Wl,'
+ # All Alpha code is PIC.
+ lt_prog_compiler_static_FC='-non_shared'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C 5.9
+ lt_prog_compiler_pic_FC='-KPIC'
+ lt_prog_compiler_static_FC='-Bstatic'
+ lt_prog_compiler_wl_FC='-Wl,'
+ ;;
+ *Sun\ F*)
+ # Sun Fortran 8.3 passes all unrecognized flags to the linker
+ lt_prog_compiler_pic_FC='-KPIC'
+ lt_prog_compiler_static_FC='-Bstatic'
+ lt_prog_compiler_wl_FC=''
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ newsos6)
+ lt_prog_compiler_pic_FC='-KPIC'
+ lt_prog_compiler_static_FC='-Bstatic'
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ lt_prog_compiler_pic_FC='-fPIC -shared'
+ ;;
+
+ osf3* | osf4* | osf5*)
+ lt_prog_compiler_wl_FC='-Wl,'
+ # All OSF/1 code is PIC.
+ lt_prog_compiler_static_FC='-non_shared'
+ ;;
+
+ rdos*)
+ lt_prog_compiler_static_FC='-non_shared'
+ ;;
+
+ solaris*)
+ lt_prog_compiler_pic_FC='-KPIC'
+ lt_prog_compiler_static_FC='-Bstatic'
+ case $cc_basename in
+ f77* | f90* | f95*)
+ lt_prog_compiler_wl_FC='-Qoption ld ';;
+ *)
+ lt_prog_compiler_wl_FC='-Wl,';;
+ esac
+ ;;
+
+ sunos4*)
+ lt_prog_compiler_wl_FC='-Qoption ld '
+ lt_prog_compiler_pic_FC='-PIC'
+ lt_prog_compiler_static_FC='-Bstatic'
+ ;;
+
+ sysv4 | sysv4.2uw2* | sysv4.3*)
+ lt_prog_compiler_wl_FC='-Wl,'
+ lt_prog_compiler_pic_FC='-KPIC'
+ lt_prog_compiler_static_FC='-Bstatic'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec ;then
+ lt_prog_compiler_pic_FC='-Kconform_pic'
+ lt_prog_compiler_static_FC='-Bstatic'
+ fi
+ ;;
+
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ lt_prog_compiler_wl_FC='-Wl,'
+ lt_prog_compiler_pic_FC='-KPIC'
+ lt_prog_compiler_static_FC='-Bstatic'
+ ;;
+
+ unicos*)
+ lt_prog_compiler_wl_FC='-Wl,'
+ lt_prog_compiler_can_build_shared_FC=no
+ ;;
+
+ uts4*)
+ lt_prog_compiler_pic_FC='-pic'
+ lt_prog_compiler_static_FC='-Bstatic'
+ ;;
+
+ *)
+ lt_prog_compiler_can_build_shared_FC=no
+ ;;
+ esac
+ fi
+
+case $host_os in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ lt_prog_compiler_pic_FC=
+ ;;
+ *)
+ lt_prog_compiler_pic_FC="$lt_prog_compiler_pic_FC"
+ ;;
+esac
+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_FC" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_FC" >&6
+
+
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_FC"; then
+ echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_FC works" >&5
+echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_FC works... $ECHO_C" >&6
+if test "${lt_prog_compiler_pic_works_FC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_prog_compiler_pic_works_FC=no
+ ac_outfile=conftest.$ac_objext
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$lt_prog_compiler_pic_FC"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:11071: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:11075: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings other than the usual output.
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+ lt_prog_compiler_pic_works_FC=yes
+ fi
+ fi
+ $RM conftest*
fi
- CPP=$ac_cv_prog_CPP
+echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_FC" >&5
+echo "${ECHO_T}$lt_prog_compiler_pic_works_FC" >&6
+
+if test x"$lt_prog_compiler_pic_works_FC" = xyes; then
+ case $lt_prog_compiler_pic_FC in
+ "" | " "*) ;;
+ *) lt_prog_compiler_pic_FC=" $lt_prog_compiler_pic_FC" ;;
+ esac
else
- ac_cv_prog_CPP=$CPP
+ lt_prog_compiler_pic_FC=
+ lt_prog_compiler_can_build_shared_FC=no
fi
-echo "$as_me:$LINENO: result: $CPP" >&5
-echo "${ECHO_T}$CPP" >&6
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
- # Use a header file that comes with gcc, so configuring glibc
- # with a fresh cross-compiler works.
- # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
- # <limits.h> exists even on freestanding compilers.
- # On the NeXT, cc -E runs the code through the compiler's parser,
- # not just through cpp. "Syntax error" is here to catch this case.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
- Syntax error
+
+fi
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl_FC eval lt_tmp_static_flag=\"$lt_prog_compiler_static_FC\"
+echo "$as_me:$LINENO: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+echo $ECHO_N "checking if $compiler static flag $lt_tmp_static_flag works... $ECHO_C" >&6
+if test "${lt_prog_compiler_static_works_FC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_prog_compiler_static_works_FC=no
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+ echo "$lt_simple_link_test_code" > conftest.$ac_ext
+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+ # The linker can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ # Append any errors to the config.log.
+ cat conftest.err 1>&5
+ $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if diff conftest.exp conftest.er2 >/dev/null; then
+ lt_prog_compiler_static_works_FC=yes
+ fi
+ else
+ lt_prog_compiler_static_works_FC=yes
+ fi
+ fi
+ $RM conftest*
+ LDFLAGS="$save_LDFLAGS"
+
+fi
+echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works_FC" >&5
+echo "${ECHO_T}$lt_prog_compiler_static_works_FC" >&6
+
+if test x"$lt_prog_compiler_static_works_FC" = xyes; then
+ :
+else
+ lt_prog_compiler_static_FC=
+fi
+
+
+
+
+ echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
+if test "${lt_cv_prog_compiler_c_o_FC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_cv_prog_compiler_c_o_FC=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:11170: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:11174: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_c_o_FC=yes
+ fi
+ fi
+ chmod u+w . 2>&5
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_FC" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o_FC" >&6
+
+
+
+ echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5
+echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6
+if test "${lt_cv_prog_compiler_c_o_FC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_cv_prog_compiler_c_o_FC=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+ (eval echo "\"\$as_me:11222: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:11226: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_c_o_FC=yes
+ fi
+ fi
+ chmod u+w . 2>&5
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+
+fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_FC" >&5
+echo "${ECHO_T}$lt_cv_prog_compiler_c_o_FC" >&6
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_FC" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ echo "$as_me:$LINENO: checking if we can lock with hard links" >&5
+echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6
+ hard_links=yes
+ $RM conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ echo "$as_me:$LINENO: result: $hard_links" >&5
+echo "${ECHO_T}$hard_links" >&6
+ if test "$hard_links" = no; then
+ { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+
+
+
+ echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6
+
+ runpath_var=
+ allow_undefined_flag_FC=
+ always_export_symbols_FC=no
+ archive_cmds_FC=
+ archive_expsym_cmds_FC=
+ compiler_needs_object_FC=no
+ enable_shared_with_static_runtimes_FC=no
+ export_dynamic_flag_spec_FC=
+ export_symbols_cmds_FC='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ hardcode_automatic_FC=no
+ hardcode_direct_FC=no
+ hardcode_direct_absolute_FC=no
+ hardcode_libdir_flag_spec_FC=
+ hardcode_libdir_flag_spec_ld_FC=
+ hardcode_libdir_separator_FC=
+ hardcode_minus_L_FC=no
+ hardcode_shlibpath_var_FC=unsupported
+ inherit_rpath_FC=no
+ link_all_deplibs_FC=unknown
+ module_cmds_FC=
+ module_expsym_cmds_FC=
+ old_archive_from_new_cmds_FC=
+ old_archive_from_expsyms_cmds_FC=
+ thread_safe_flag_spec_FC=
+ whole_archive_flag_spec_FC=
+ # include_expsyms should be a list of space-separated symbols to be *always*
+ # included in the symbol list
+ include_expsyms_FC=
+ # exclude_expsyms can be an extended regexp of symbols to exclude
+ # it will be wrapped by ` (' and `)$', so one must not match beginning or
+ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+ # as well as any symbol that contains `d'.
+ exclude_expsyms_FC="_GLOBAL_OFFSET_TABLE_"
+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+ # platforms (ab)use it in PIC code, but their linkers get confused if
+ # the symbol is explicitly referenced. Since portable code cannot
+ # rely on this symbol name, it's probably fine to never include it in
+ # preloaded symbol tables.
+ extract_expsyms_cmds=
+
+ case $host_os in
+ cygwin* | mingw* | pw32*)
+ # FIXME: the MSVC++ port hasn't been tested in a loooong time
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ if test "$GCC" != yes; then
+ with_gnu_ld=no
+ fi
+ ;;
+ interix*)
+ # we just hope/assume this is gcc and not c89 (= MSVC++)
+ with_gnu_ld=yes
+ ;;
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+ esac
+
+ ld_shlibs_FC=yes
+ if test "$with_gnu_ld" = yes; then
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ wlarc='${wl}'
+
+ # Set some defaults for GNU ld with shared library support. These
+ # are reset later if shared libraries are not supported. Putting them
+ # here allows them to be overridden if necessary.
+ runpath_var=LD_RUN_PATH
+ hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+ export_dynamic_flag_spec_FC='${wl}--export-dynamic'
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+ whole_archive_flag_spec_FC="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ whole_archive_flag_spec_FC=
+ fi
+ supports_anon_versioning=no
+ case `$LD -v 2>&1` in
+ *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+ *\ 2.11.*) ;; # other 2.11 versions
+ *) supports_anon_versioning=yes ;;
+ esac
+
+ # See if GNU ld supports shared libraries.
+ case $host_os in
+ aix[3-9]*)
+ # On AIX/PPC, the GNU linker is very broken
+ if test "$host_cpu" != ia64; then
+ ld_shlibs_FC=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support. If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+_LT_EOF
+ fi
+ ;;
+
+ amigaos*)
+ if test "$host_cpu" = m68k; then
+ archive_cmds_FC='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec_FC='-L$libdir'
+ hardcode_minus_L_FC=yes
+ fi
+
+ # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+ # that the semantics of dynamic libraries on AmigaOS, at least up
+ # to version 4, is to share data among multiple programs linked
+ # with the same dynamic library. Since this doesn't match the
+ # behavior of shared libraries on other platforms, we can't use
+ # them.
+ ld_shlibs_FC=no
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ allow_undefined_flag_FC=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ archive_cmds_FC='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ ld_shlibs_FC=no
+ fi
+ ;;
+
+ cygwin* | mingw* | pw32*)
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, FC) is actually meaningless,
+ # as there is no search path for DLLs.
+ hardcode_libdir_flag_spec_FC='-L$libdir'
+ allow_undefined_flag_FC=unsupported
+ always_export_symbols_FC=no
+ enable_shared_with_static_runtimes_FC=yes
+ export_symbols_cmds_FC='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ archive_expsym_cmds_FC='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ else
+ ld_shlibs_FC=no
+ fi
+ ;;
+
+ interix[3-9]*)
+ hardcode_direct_FC=no
+ hardcode_shlibpath_var_FC=no
+ hardcode_libdir_flag_spec_FC='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec_FC='${wl}-E'
+ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+ # Instead, shared libraries are loaded at an image base (0x10000000 by
+ # default) and relocated if they conflict, which is a slow very memory
+ # consuming and fragmenting process. To avoid this, we pick a random,
+ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+ archive_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ archive_expsym_cmds_FC='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ ;;
+
+ gnu* | linux* | tpf* | k*bsd*-gnu)
+ tmp_diet=no
+ if test "$host_os" = linux-dietlibc; then
+ case $cc_basename in
+ diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
+ esac
+ fi
+ if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+ && test "$tmp_diet" = no
+ then
+ tmp_addflag=
+ case $cc_basename,$host_cpu in
+ pgcc*) # Portland Group C compiler
+ whole_archive_flag_spec_FC='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag'
+ ;;
+ pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
+ whole_archive_flag_spec_FC='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag -Mnomain' ;;
+ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
+ tmp_addflag=' -i_dynamic' ;;
+ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
+ tmp_addflag=' -i_dynamic -nofor_main' ;;
+ ifc* | ifort*) # Intel Fortran compiler
+ tmp_addflag=' -nofor_main' ;;
+ esac
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*) # Sun C 5.9
+ whole_archive_flag_spec_FC='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ compiler_needs_object_FC=yes
+ tmp_sharedflag='-G' ;;
+ *Sun\ F*) # Sun Fortran 8.3
+ tmp_sharedflag='-G' ;;
+ *)
+ tmp_sharedflag='-shared' ;;
+ esac
+ archive_cmds_FC='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+ if test "x$supports_anon_versioning" = xyes; then
+ archive_expsym_cmds_FC='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ fi
+ else
+ ld_shlibs_FC=no
+ fi
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ archive_cmds_FC='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+ wlarc=
+ else
+ archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ fi
+ ;;
+
+ solaris*)
+ if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+ ld_shlibs_FC=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs_FC=no
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+ case `$LD -v 2>&1` in
+ *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+ ld_shlibs_FC=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ ;;
+ *)
+ # For security reasons, it is highly recommended that you always
+ # use absolute paths for naming shared libraries, and exclude the
+ # DT_RUNPATH tag from executables and libraries. But doing so
+ # requires that you compile everything twice, which is a pain.
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+ archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs_FC=no
+ fi
+ ;;
+ esac
+ ;;
+
+ sunos4*)
+ archive_cmds_FC='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ wlarc=
+ hardcode_direct_FC=yes
+ hardcode_shlibpath_var_FC=no
+ ;;
+
+ *)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs_FC=no
+ fi
+ ;;
+ esac
+
+ if test "$ld_shlibs_FC" = no; then
+ runpath_var=
+ hardcode_libdir_flag_spec_FC=
+ export_dynamic_flag_spec_FC=
+ whole_archive_flag_spec_FC=
+ fi
+ else
+ # PORTME fill in a description of your system's linker (not GNU ld)
+ case $host_os in
+ aix3*)
+ allow_undefined_flag_FC=unsupported
+ always_export_symbols_FC=yes
+ archive_expsym_cmds_FC='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+ # Note: this linker hardcodes the directories in LIBPATH if there
+ # are no directories specified by -L.
+ hardcode_minus_L_FC=yes
+ if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+ # Neither direct hardcoding nor static linking is supported with a
+ # broken collect2.
+ hardcode_direct_FC=unsupported
+ fi
+ ;;
+
+ aix[4-9]*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+ export_symbols_cmds_FC='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ else
+ export_symbols_cmds_FC='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ fi
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+ for ld_flag in $LDFLAGS; do
+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ aix_use_runtimelinking=yes
+ break
+ fi
+ done
+ ;;
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ archive_cmds_FC=''
+ hardcode_direct_FC=yes
+ hardcode_direct_absolute_FC=yes
+ hardcode_libdir_separator_FC=':'
+ link_all_deplibs_FC=yes
+ file_list_spec_FC='${wl}-f,'
+
+ if test "$GCC" = yes; then
+ case $host_os in aix4.[012]|aix4.[012].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" &&
+ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ hardcode_direct_FC=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ hardcode_minus_L_FC=yes
+ hardcode_libdir_flag_spec_FC='-L$libdir'
+ hardcode_libdir_separator_FC=
+ fi
+ ;;
+ esac
+ shared_flag='-shared'
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to export.
+ always_export_symbols_FC=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ allow_undefined_flag_FC='-berok'
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ cat >conftest.$ac_ext <<_ACEOF
+ program main
+
+ end
_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
- else
- ac_cpp_err=
- fi
-else
- ac_cpp_err=yes
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_fc_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\(.*\)$/\1/
+ p
+ }
+ }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+ aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
fi
-if test -z "$ac_cpp_err"; then
- :
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- # Broken: fails on valid input.
-continue
fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
- # OK, works on sane cases. Now check whether non-existent headers
- # can be detected and how.
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
+ hardcode_libdir_flag_spec_FC='${wl}-blibpath:$libdir:'"$aix_libpath"
+ archive_expsym_cmds_FC='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ hardcode_libdir_flag_spec_FC='${wl}-R $libdir:/usr/lib:/lib'
+ allow_undefined_flag_FC="-z nodefs"
+ archive_expsym_cmds_FC="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ cat >conftest.$ac_ext <<_ACEOF
+ program main
+
+ end
_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <ac_nonexistent.h>
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_fc_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\(.*\)$/\1/
+ p
+ }
+ }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+ aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+ hardcode_libdir_flag_spec_FC='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ no_undefined_flag_FC=' ${wl}-bernotok'
+ allow_undefined_flag_FC=' ${wl}-berok'
+ # Exported symbols can be pulled into shared objects from archives
+ whole_archive_flag_spec_FC='$convenience'
+ archive_cmds_need_lc_FC=yes
+ # This is similar to how AIX traditionally builds its shared libraries.
+ archive_expsym_cmds_FC="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ amigaos*)
+ if test "$host_cpu" = m68k; then
+ archive_cmds_FC='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec_FC='-L$libdir'
+ hardcode_minus_L_FC=yes
+ fi
+ # see comment about different semantics on the GNU ld section
+ ld_shlibs_FC=no
+ ;;
+
+ bsdi[45]*)
+ export_dynamic_flag_spec_FC=-rdynamic
+ ;;
+
+ cygwin* | mingw* | pw32*)
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ hardcode_libdir_flag_spec_FC=' '
+ allow_undefined_flag_FC=unsupported
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ archive_cmds_FC='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+ # The linker will automatically build a .lib file if we build a DLL.
+ old_archive_from_new_cmds_FC='true'
+ # FIXME: Should let the user specify the lib program.
+ old_archive_cmds_FC='lib -OUT:$oldlib$oldobjs$old_deplibs'
+ fix_srcfile_path_FC='`cygpath -w "$srcfile"`'
+ enable_shared_with_static_runtimes_FC=yes
+ ;;
+
+ darwin* | rhapsody*)
+ case $host_os in
+ rhapsody* | darwin1.[012])
+ allow_undefined_flag_FC='${wl}-undefined ${wl}suppress'
+ ;;
+ *) # Darwin 1.3 on
+ case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
+ 10.[012])
+ allow_undefined_flag_FC='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+ ;;
+ 10.*)
+ allow_undefined_flag_FC='${wl}-undefined ${wl}dynamic_lookup'
+ ;;
+ esac
+ ;;
+ esac
+ archive_cmds_need_lc_FC=no
+ hardcode_direct_FC=no
+ hardcode_automatic_FC=yes
+ hardcode_shlibpath_var_FC=unsupported
+ whole_archive_flag_spec_FC=''
+ link_all_deplibs_FC=yes
+ if test "$GCC" = yes ; then
+ if test "${lt_cv_apple_cc_single_mod+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ lt_cv_apple_cc_single_mod=no
+ if test -z "${LT_MULTI_MODULE}"; then
+ # By default we will add the -single_module flag. You can override
+ # by either setting the environment variable LT_MULTI_MODULE
+ # non-empty at configure time, or by adding -multi-module to the
+ # link flags.
+ echo "int foo(void){return 1;}" > conftest.c
+ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+ -dynamiclib ${wl}-single_module conftest.c
+ if test -f libconftest.dylib; then
+ lt_cv_apple_cc_single_mod=yes
+ rm libconftest.dylib
+ fi
+ rm conftest.$ac_ext
+ fi
+fi
+
+ output_verbose_link_cmd=echo
+ if test "X$lt_cv_apple_cc_single_mod" = Xyes ; then
+ archive_cmds_FC='$CC -dynamiclib $single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+ archive_expsym_cmds_FC='sed "s,^,_," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $single_module -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ else
+ archive_cmds_FC='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+ archive_expsym_cmds_FC='sed "s,^,_," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ fi
+ module_cmds_FC='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+ module_expsym_cmds_FC='sed -e "s,^,_," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ else
+ case $cc_basename in
+ xlc*)
+ output_verbose_link_cmd=echo
+ archive_cmds_FC='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`$ECHO $rpath/$soname` $verstring'
+ module_cmds_FC='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+ # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+ archive_expsym_cmds_FC='sed "s,^,_," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ module_expsym_cmds_FC='sed "s,^,_," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ ;;
+ *)
+ ld_shlibs_FC=no
+ ;;
+ esac
+ fi
+ ;;
+
+ dgux*)
+ archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec_FC='-L$libdir'
+ hardcode_shlibpath_var_FC=no
+ ;;
+
+ freebsd1*)
+ ld_shlibs_FC=no
+ ;;
+
+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+ # support. Future versions do this automatically, but an explicit c++rt0.o
+ # does not break anything, and helps significantly (at the cost of a little
+ # extra space).
+ freebsd2.2*)
+ archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+ hardcode_libdir_flag_spec_FC='-R$libdir'
+ hardcode_direct_FC=yes
+ hardcode_shlibpath_var_FC=no
+ ;;
+
+ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+ freebsd2*)
+ archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct_FC=yes
+ hardcode_minus_L_FC=yes
+ hardcode_shlibpath_var_FC=no
+ ;;
+
+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+ freebsd* | dragonfly*)
+ archive_cmds_FC='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec_FC='-R$libdir'
+ hardcode_direct_FC=yes
+ hardcode_shlibpath_var_FC=no
+ ;;
+
+ hpux9*)
+ if test "$GCC" = yes; then
+ archive_cmds_FC='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ archive_cmds_FC='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ fi
+ hardcode_libdir_flag_spec_FC='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator_FC=:
+ hardcode_direct_FC=yes
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L_FC=yes
+ export_dynamic_flag_spec_FC='${wl}-E'
+ ;;
+
+ hpux10*)
+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ archive_cmds_FC='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds_FC='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ if test "$with_gnu_ld" = no; then
+ hardcode_libdir_flag_spec_FC='${wl}+b ${wl}$libdir'
+ hardcode_libdir_flag_spec_ld_FC='+b $libdir'
+ hardcode_libdir_separator_FC=:
+ hardcode_direct_FC=yes
+ hardcode_direct_absolute_FC=yes
+ export_dynamic_flag_spec_FC='${wl}-E'
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L_FC=yes
+ fi
+ ;;
+
+ hpux11*)
+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ case $host_cpu in
+ hppa*64*)
+ archive_cmds_FC='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds_FC='$CC -shared ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ archive_cmds_FC='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ else
+ case $host_cpu in
+ hppa*64*)
+ archive_cmds_FC='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds_FC='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ archive_cmds_FC='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ fi
+ if test "$with_gnu_ld" = no; then
+ hardcode_libdir_flag_spec_FC='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator_FC=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ hardcode_direct_FC=no
+ hardcode_shlibpath_var_FC=no
+ ;;
+ *)
+ hardcode_direct_FC=yes
+ hardcode_direct_absolute_FC=yes
+ export_dynamic_flag_spec_FC='${wl}-E'
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L_FC=yes
+ ;;
+ esac
+ fi
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ if test "$GCC" = yes; then
+ archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ # Try to use the -exported_symbol ld option, if it does not
+ # work, assume that -exports_file does not work either and
+ # implicitly export all symbols.
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+ cat >conftest.$ac_ext <<_ACEOF
+int foo(void) {}
_ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
- (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } >/dev/null; then
- if test -s conftest.err; then
- ac_cpp_err=$ac_c_preproc_warn_flag
- ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_fc_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS="$save_LDFLAGS"
+ else
+ archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+ fi
+ archive_cmds_need_lc_FC='no'
+ hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_FC=:
+ inherit_rpath_FC=yes
+ link_all_deplibs_FC=yes
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+ else
+ archive_cmds_FC='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+ fi
+ hardcode_libdir_flag_spec_FC='-R$libdir'
+ hardcode_direct_FC=yes
+ hardcode_shlibpath_var_FC=no
+ ;;
+
+ newsos6)
+ archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct_FC=yes
+ hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_FC=:
+ hardcode_shlibpath_var_FC=no
+ ;;
+
+ *nto* | *qnx*)
+ ;;
+
+ openbsd*)
+ hardcode_direct_FC=yes
+ hardcode_shlibpath_var_FC=no
+ hardcode_direct_absolute_FC=yes
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ archive_cmds_FC='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_FC='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+ hardcode_libdir_flag_spec_FC='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec_FC='${wl}-E'
+ else
+ case $host_os in
+ openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+ archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec_FC='-R$libdir'
+ ;;
+ *)
+ archive_cmds_FC='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec_FC='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ ;;
+
+ os2*)
+ hardcode_libdir_flag_spec_FC='-L$libdir'
+ hardcode_minus_L_FC=yes
+ allow_undefined_flag_FC=unsupported
+ archive_cmds_FC='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+ old_archive_from_new_cmds_FC='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+ ;;
+
+ osf3*)
+ if test "$GCC" = yes; then
+ allow_undefined_flag_FC=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ allow_undefined_flag_FC=' -expect_unresolved \*'
+ archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ fi
+ archive_cmds_need_lc_FC='no'
+ hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_FC=:
+ ;;
+
+ osf4* | osf5*) # as osf3* with the addition of -msym flag
+ if test "$GCC" = yes; then
+ allow_undefined_flag_FC=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+ else
+ allow_undefined_flag_FC=' -expect_unresolved \*'
+ archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ archive_expsym_cmds_FC='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+ # Both c and cxx compiler support -rpath directly
+ hardcode_libdir_flag_spec_FC='-rpath $libdir'
+ fi
+ archive_cmds_need_lc_FC='no'
+ hardcode_libdir_separator_FC=:
+ ;;
+
+ solaris*)
+ no_undefined_flag_FC=' -z defs'
+ if test "$GCC" = yes; then
+ wlarc='${wl}'
+ archive_cmds_FC='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_FC='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ else
+ case `$CC -V 2>&1` in
+ *"Compilers 5.0"*)
+ wlarc=''
+ archive_cmds_FC='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ archive_expsym_cmds_FC='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+ ;;
+ *)
+ wlarc='${wl}'
+ archive_cmds_FC='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_FC='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ ;;
+ esac
+ fi
+ hardcode_libdir_flag_spec_FC='-R$libdir'
+ hardcode_shlibpath_var_FC=no
+ case $host_os in
+ solaris2.[0-5] | solaris2.[0-5].*) ;;
+ *)
+ # The compiler driver will combine and reorder linker options,
+ # but understands `-z linker_flag'. GCC discards it without `$wl',
+ # but is careful enough not to reorder.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ if test "$GCC" = yes; then
+ whole_archive_flag_spec_FC='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ else
+ whole_archive_flag_spec_FC='-z allextract$convenience -z defaultextract'
+ fi
+ ;;
+ esac
+ link_all_deplibs_FC=yes
+ ;;
+
+ sunos4*)
+ if test "x$host_vendor" = xsequent; then
+ # Use $CC to link under sequent, because it throws in some extra .o
+ # files that make .init and .fini sections work.
+ archive_cmds_FC='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds_FC='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ hardcode_libdir_flag_spec_FC='-L$libdir'
+ hardcode_direct_FC=yes
+ hardcode_minus_L_FC=yes
+ hardcode_shlibpath_var_FC=no
+ ;;
+
+ sysv4)
+ case $host_vendor in
+ sni)
+ archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct_FC=yes # is this really true???
+ ;;
+ siemens)
+ ## LD is ld it makes a PLAMLIB
+ ## CC just makes a GrossModule.
+ archive_cmds_FC='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ reload_cmds_FC='$CC -r -o $output$reload_objs'
+ hardcode_direct_FC=no
+ ;;
+ motorola)
+ archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct_FC=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ runpath_var='LD_RUN_PATH'
+ hardcode_shlibpath_var_FC=no
+ ;;
+
+ sysv4.3*)
+ archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var_FC=no
+ export_dynamic_flag_spec_FC='-Bexport'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var_FC=no
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ ld_shlibs_FC=yes
+ fi
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+ no_undefined_flag_FC='${wl}-z,text'
+ archive_cmds_need_lc_FC=no
+ hardcode_shlibpath_var_FC=no
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ archive_cmds_FC='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_FC='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds_FC='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_FC='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6*)
+ # Note: We can NOT use -z defs as we might desire, because we do not
+ # link with -lc, and that would cause any symbols used from libc to
+ # always be unresolved, which means just about no library would
+ # ever link correctly. If we're not using GNU ld we use -z text
+ # though, which does catch some bad symbols but isn't as heavy-handed
+ # as -z defs.
+ no_undefined_flag_FC='${wl}-z,text'
+ allow_undefined_flag_FC='${wl}-z,nodefs'
+ archive_cmds_need_lc_FC=no
+ hardcode_shlibpath_var_FC=no
+ hardcode_libdir_flag_spec_FC='${wl}-R,$libdir'
+ hardcode_libdir_separator_FC=':'
+ link_all_deplibs_FC=yes
+ export_dynamic_flag_spec_FC='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ archive_cmds_FC='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_FC='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds_FC='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_FC='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ uts4*)
+ archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec_FC='-L$libdir'
+ hardcode_shlibpath_var_FC=no
+ ;;
+
+ *)
+ ld_shlibs_FC=no
+ ;;
+ esac
+
+ if test x$host_vendor = xsni; then
+ case $host in
+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ export_dynamic_flag_spec_FC='${wl}-Blargedynsym'
+ ;;
+ esac
+ fi
+ fi
+
+echo "$as_me:$LINENO: result: $ld_shlibs_FC" >&5
+echo "${ECHO_T}$ld_shlibs_FC" >&6
+test "$ld_shlibs_FC" = no && can_build_shared=no
+
+with_gnu_ld_FC=$with_gnu_ld
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_FC" in
+x|xyes)
+ # Assume -lc should be added
+ archive_cmds_need_lc_FC=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $archive_cmds_FC in
+ *'~'*)
+ # FIXME: we may have to deal with multi-command sequences.
+ ;;
+ '$CC '*)
+ # Test whether the compiler implicitly links with -lc since on some
+ # systems, -lgcc has to come before -lc. If gcc already passes -lc
+ # to ld, don't add -lc before -lgcc.
+ echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5
+echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6
+ $RM conftest*
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$lt_prog_compiler_wl_FC
+ pic_flag=$lt_prog_compiler_pic_FC
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$allow_undefined_flag_FC
+ allow_undefined_flag_FC=
+ if { (eval echo "$as_me:$LINENO: \"$archive_cmds_FC 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\"") >&5
+ (eval $archive_cmds_FC 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+ then
+ archive_cmds_need_lc_FC=no
+ else
+ archive_cmds_need_lc_FC=yes
+ fi
+ allow_undefined_flag_FC=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $RM conftest*
+ echo "$as_me:$LINENO: result: $archive_cmds_need_lc_FC" >&5
+echo "${ECHO_T}$archive_cmds_need_lc_FC" >&6
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5
+echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6
+withGCC=$ac_cv_fc_compiler_gnu
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX 3 has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+
+aix[4-9]*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ hardcode_into_libs=yes
+ if test "$host_cpu" = ia64; then
+ # AIX 5 supports IA64
+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
else
- ac_cpp_err=
+ # With GCC up to 2.95.x, collect2 would create an import file
+ # for dependence libraries. The import file would start with
+ # the line `#! .'. This would cause the generated library to
+ # depend on `.', always an invalid library. This was fixed in
+ # development snapshots of GCC prior to 3.0.
+ case $host_os in
+ aix4 | aix4.[01] | aix4.[01].*)
+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+ echo ' yes '
+ echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+ :
+ else
+ can_build_shared=no
+ fi
+ ;;
+ esac
+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ if test "$aix_use_runtimelinking" = yes; then
+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+ # instead of lib<name>.a to let people know that these are not
+ # typical AIX shared libraries.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+ # We preserve .a as extension for shared libraries through AIX4.2
+ # and later when we are not doing run time linking.
+ library_names_spec='${libname}${release}.a $libname.a'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+ shlibpath_var=LIBPATH
fi
-else
- ac_cpp_err=yes
+ ;;
+
+amigaos*)
+ if test "$host_cpu" = m68k; then
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ else
+ dynamic_linker=no
+ fi
+ ;;
+
+beos*)
+ library_names_spec='${libname}${shared_ext}'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi[45]*)
+ version_type=linux
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw* | pw32*)
+ version_type=windows
+ shrext_cmds=".dll"
+ need_version=no
+ need_lib_prefix=no
+
+ case $withGCC,$host_os in
+ yes,cygwin* | yes,mingw* | yes,pw32*)
+ library_names_spec='$libname.dll.a'
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname~
+ chmod a+x \$dldir/$dlname~
+ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+ fi'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+
+ case $host_os in
+ cygwin*)
+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+ ;;
+ mingw*)
+ # MinGW DLLs use traditional 'lib' prefix
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+ # It is most probably a Windows format PATH printed by
+ # mingw gcc, but we are running on Cygwin. Gcc prints its search
+ # path with ; separators, and with drive letters. We can handle the
+ # drive letters (cygwin fileutils understands them), so leave them,
+ # especially as we might pass files found there to a mingw objdump,
+ # which wouldn't understand a cygwinified path. Ahh.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+ ;;
+
+ *)
+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+darwin* | rhapsody*)
+ dynamic_linker="$host_os dyld"
+ version_type=darwin
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+ soname_spec='${libname}${release}${major}$shared_ext'
+ shlibpath_overrides_runpath=yes
+ shlibpath_var=DYLD_LIBRARY_PATH
+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+dgux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+freebsd1*)
+ dynamic_linker=no
+ ;;
+
+freebsd* | dragonfly*)
+ # DragonFly does not have aout. When/if they implement a new
+ # versioning mechanism, adjust this.
+ if test -x /usr/bin/objformat; then
+ objformat=`/usr/bin/objformat`
+ else
+ case $host_os in
+ freebsd[123]*) objformat=aout ;;
+ *) objformat=elf ;;
+ esac
+ fi
+ version_type=freebsd-$objformat
+ case $version_type in
+ freebsd-elf*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ need_version=yes
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_os in
+ freebsd2*)
+ shlibpath_overrides_runpath=yes
+ ;;
+ freebsd3.[01]* | freebsdelf3.[01]*)
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+ *) # from 4.6 on, and DragonFly
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+gnu*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ hardcode_into_libs=yes
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ case $host_cpu in
+ ia64*)
+ shrext_cmds='.so'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.so"
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ if test "X$HPUX_IA64_MODE" = X32; then
+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ else
+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ fi
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ hppa*64*)
+ shrext_cmds='.sl'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ *)
+ shrext_cmds='.sl'
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=SHLIB_PATH
+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+ esac
+ # HP-UX runs *really* slowly unless shared libraries are mode 555.
+ postinstall_cmds='chmod 555 $lib'
+ ;;
+
+interix[3-9]*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $host_os in
+ nonstopux*) version_type=nonstopux ;;
+ *)
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ version_type=linux
+ else
+ version_type=irix
+ fi ;;
+ esac
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ case $host_os in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+ libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+ libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+ libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ hardcode_into_libs=yes
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+ dynamic_linker=no
+ ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ # Some binutils ld are patched to set DT_RUNPATH
+ save_LDFLAGS=$LDFLAGS
+ save_libdir=$libdir
+ eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_FC\"; \
+ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_FC\""
+ cat >conftest.$ac_ext <<_ACEOF
+ program main
+
+ end
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_fc_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir"; then
+ shlibpath_overrides_runpath=yes
fi
-if test -z "$ac_cpp_err"; then
- # Broken: success on invalid input.
-continue
+
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
- # Passes both tests.
-ac_preproc_ok=:
-break
fi
-rm -f conftest.err conftest.$ac_ext
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS=$save_LDFLAGS
+ libdir=$save_libdir
+
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ # Append ld.so.conf contents to the search path
+ if test -f /etc/ld.so.conf; then
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ fi
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then
- :
+ # We used to test for /lib/ld.so.1 and disable shared libraries on
+ # powerpc, because MkLinux only supported shared libraries with the
+ # GNU dynamic linker. Since this was broken with cross compilers,
+ # most powerpc-linux boxes support dynamic linking these days and
+ # people can always --disable-shared, the test was removed, and we
+ # assume the GNU/Linux dynamic linker is in use.
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
+netbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+
+newsos6)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+*nto* | *qnx*)
+ version_type=qnx
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='ldqnx.so'
+ ;;
+
+openbsd*)
+ version_type=sunos
+ sys_lib_dlsearch_path_spec="/usr/lib"
+ need_lib_prefix=no
+ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+ case $host_os in
+ openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+ *) need_version=no ;;
+ esac
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+ openbsd2.[89] | openbsd2.[89].*)
+ shlibpath_overrides_runpath=no
+ ;;
+ *)
+ shlibpath_overrides_runpath=yes
+ ;;
+ esac
+ else
+ shlibpath_overrides_runpath=yes
+ fi
+ ;;
+
+os2*)
+ libname_spec='$name'
+ shrext_cmds=".dll"
+ need_lib_prefix=no
+ library_names_spec='$libname${shared_ext} $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4* | osf5*)
+ version_type=osf
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+rdos*)
+ dynamic_linker=no
+ ;;
+
+solaris*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4 | sysv4.3*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_vendor in
+ sni)
+ shlibpath_overrides_runpath=no
+ need_lib_prefix=no
+ runpath_var=LD_RUN_PATH
+ ;;
+ siemens)
+ need_lib_prefix=no
+ ;;
+ motorola)
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+ ;;
+ esac
+ ;;
+
+sysv4*MP*)
+ if test -d /usr/nec ;then
+ version_type=linux
+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+ soname_spec='$libname${shared_ext}.$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ version_type=freebsd-elf
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ if test "$with_gnu_ld" = yes; then
+ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+ else
+ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+ case $host_os in
+ sco3.2v5*)
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+ ;;
+ esac
+ fi
+ sys_lib_dlsearch_path_spec='/usr/lib'
+ ;;
+
+tpf*)
+ # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_name_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+uts4*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+echo "$as_me:$LINENO: result: $dynamic_linker" >&5
+echo "${ECHO_T}$dynamic_linker" >&6
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5
+echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6
+hardcode_action_FC=
+if test -n "$hardcode_libdir_flag_spec_FC" ||
+ test -n "$runpath_var_FC" ||
+ test "X$hardcode_automatic_FC" = "Xyes" ; then
+
+ # We can hardcode non-existent directories.
+ if test "$hardcode_direct_FC" != no &&
+ # If the only mechanism to avoid hardcoding is shlibpath_var, we
+ # have to relink, otherwise we might link with an installed library
+ # when we should be linking with a yet-to-be-installed one
+ ## test "$_LT_TAGVAR(hardcode_shlibpath_var, FC)" != no &&
+ test "$hardcode_minus_L_FC" != no; then
+ # Linking always hardcodes the temporary library directory.
+ hardcode_action_FC=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ hardcode_action_FC=immediate
+ fi
else
- { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&5
-echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ hardcode_action_FC=unsupported
+fi
+echo "$as_me:$LINENO: result: $hardcode_action_FC" >&5
+echo "${ECHO_T}$hardcode_action_FC" >&6
+
+if test "$hardcode_action_FC" = relink ||
+ test "$inherit_rpath_FC" = yes; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
fi
+
+
+
+
+
+
+ fi # test -n "$compiler"
+
+ CC="$lt_save_CC"
+fi # test "$_lt_disable_FC" != yes
+
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -5145,21 +13186,13 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
-echo "$as_me:$LINENO: checking for egrep" >&5
-echo $ECHO_N "checking for egrep... $ECHO_C" >&6
-if test "${ac_cv_prog_egrep+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if echo a | (grep -E '(a|b)') >/dev/null 2>&1
- then ac_cv_prog_egrep='grep -E'
- else ac_cv_prog_egrep='egrep'
- fi
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
-echo "${ECHO_T}$ac_cv_prog_egrep" >&6
- EGREP=$ac_cv_prog_egrep
+FCFLAGS="$FCFLAGS -Wall"
+
+# For libtool versioning info, format is CURRENT:REVISION:AGE
+libtool_VERSION=1:0:0
+# Check header files.
echo "$as_me:$LINENO: checking for ANSI C header files" >&5
echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
if test "${ac_cv_header_stdc+set}" = set; then
@@ -5391,83 +13424,11 @@ _ACEOF
fi
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-
-
-
-
-
-
-
-
-
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
- inttypes.h stdint.h unistd.h
-do
-as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_includes_default
-
-#include <$ac_header>
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag"
- || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- eval "$as_ac_Header=yes"
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-eval "$as_ac_Header=no"
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
-if test `eval echo '${'$as_ac_Header'}'` = yes; then
- cat >>confdefs.h <<_ACEOF
-#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-
-for ac_header in unistd.h semaphore.h sys/loadavg.h sys/time.h
+for ac_header in unistd.h semaphore.h sys/loadavg.h sys/sysctl.h sys/time.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
@@ -8681,6 +16642,24 @@ cat >>confdefs.h <<\_ACEOF
_ACEOF
;;
+esac
+
+ # Check whether --enable-linux-futex or --disable-linux-futex was given.
+if test "${enable_linux_futex+set}" = set; then
+ enableval="$enable_linux_futex"
+
+ case "$enableval" in
+ yes|no|default) ;;
+ *) { { echo "$as_me:$LINENO: error: Unknown argument to enable/disable linux-futex" >&5
+echo "$as_me: error: Unknown argument to enable/disable linux-futex" >&2;}
+ { (exit 1); exit 1; }; } ;;
+ esac
+
+else
+ enable_linux_futex=default
+fi;
+
+case "$target" in
*-linux*)
case "$enable_linux_futex" in
default)
@@ -8729,7 +16708,9 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- cat >conftest.$ac_ext <<_ACEOF
+ save_LIBS="$LIBS"
+ LIBS="-lpthread $LIBS"
+ cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
@@ -8777,7 +16758,7 @@ sed 's/^/| /' conftest.$ac_ext >&5
if test x$cross_compiling = xno; then
if getconf GNU_LIBPTHREAD_VERSION 2>/dev/null \
- | LC_ALL=C grep -i NPTL > /dev/null 2>/dev/null; then
+ | LC_ALL=C grep -i NPTL > /dev/null 2>/dev/null; then :; else
{ echo "$as_me:$LINENO: WARNING: The kernel might not support futex or gettid syscalls.
If so, please configure with --disable-linux-futex" >&5
echo "$as_me: WARNING: The kernel might not support futex or gettid syscalls.
@@ -8788,6 +16769,7 @@ If so, please configure with --disable-linux-futex" >&2;}
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
+ LIBS="$save_LIBS"
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
@@ -8849,7 +16831,76 @@ rm -f conftest.err conftest.$ac_objext \
;;
esac
;;
+ *)
+ enable_linux_futex=no
+ ;;
esac
+if test x$enable_linux_futex = xyes; then
+ :
+fi
+
+
+# Check for pthread_{,attr_}[sg]etaffinity_np.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#define _GNU_SOURCE
+ #include <pthread.h>
+int
+main ()
+{
+cpu_set_t cpuset;
+ pthread_attr_t attr;
+ pthread_getaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
+ if (CPU_ISSET (0, &cpuset))
+ CPU_SET (1, &cpuset);
+ else
+ CPU_ZERO (&cpuset);
+ pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
+ pthread_attr_init (&attr);
+ pthread_attr_getaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);
+ pthread_attr_setaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_PTHREAD_AFFINITY_NP 1
+_ACEOF
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
# At least for glibc, clock_gettime is in librt. But don't pull that
# in if it still doesn't give us the function we want.
@@ -8948,17 +16999,17 @@ fi;
echo "$as_me:$LINENO: checking whether the target supports thread-local storage" >&5
echo $ECHO_N "checking whether the target supports thread-local storage... $ECHO_C" >&6
-if test "${have_tls+set}" = set; then
+if test "${gcc_cv_have_tls+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test "$cross_compiling" = yes; then
- cat >conftest.$ac_ext <<_ACEOF
-__thread int foo;
+ cat >conftest.$ac_ext <<_ACEOF
+__thread int a; int b; int main() { return a = b; }
_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
@@ -8972,20 +17023,22 @@ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
+ { ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- have_tls=yes
+ gcc_cv_have_tls=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
-have_tls=no
+gcc_cv_have_tls=no
fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
else
cat >conftest.$ac_ext <<_ACEOF
@@ -9002,7 +17055,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- save_LDFLAGS="$LDFLAGS"
+ chktls_save_LDFLAGS="$LDFLAGS"
LDFLAGS="-static $LDFLAGS"
cat >conftest.$ac_ext <<_ACEOF
int main() { return 0; }
@@ -9050,14 +17103,14 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
- have_tls=yes
+ gcc_cv_have_tls=yes
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
-have_tls=no
+gcc_cv_have_tls=no
fi
rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
@@ -9065,25 +17118,147 @@ else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
-have_tls=yes
+gcc_cv_have_tls=yes
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS="$chktls_save_LDFLAGS"
+ if test $gcc_cv_have_tls = yes; then
+ chktls_save_CFLAGS="$CFLAGS"
+ thread_CFLAGS=failed
+ for flag in '' '-pthread' '-lpthread'; do
+ CFLAGS="$flag $chktls_save_CFLAGS"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <pthread.h>
+ void *g(void *d) { return NULL; }
+int
+main ()
+{
+pthread_t t; pthread_create(&t,NULL,g,NULL);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag"
+ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ thread_CFLAGS="$flag"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- LDFLAGS="$save_LDFLAGS"
+ if test "X$thread_CFLAGS" != Xfailed; then
+ break
+ fi
+ done
+ CFLAGS="$chktls_save_CFLAGS"
+ if test "X$thread_CFLAGS" != Xfailed; then
+ CFLAGS="$thread_CFLAGS $chktls_save_CFLAGS"
+ if test "$cross_compiling" = yes; then
+ { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run test program while cross compiling
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <pthread.h>
+ __thread int a;
+ static int *a_in_other_thread;
+ static void *
+ thread_func (void *arg)
+ {
+ a_in_other_thread = &a;
+ return (void *)0;
+ }
+int
+main ()
+{
+pthread_t thread;
+ void *thread_retval;
+ int *a_in_main_thread;
+ if (pthread_create (&thread, (pthread_attr_t *)0,
+ thread_func, (void *)0))
+ return 0;
+ a_in_main_thread = &a;
+ if (pthread_join (thread, &thread_retval))
+ return 0;
+ return (a_in_other_thread == a_in_main_thread);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ gcc_cv_have_tls=yes
else
echo "$as_me: program exited with status $ac_status" >&5
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
( exit $ac_status )
-have_tls=no
+gcc_cv_have_tls=no
fi
rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
fi
+ CFLAGS="$chktls_save_CFLAGS"
+ fi
+ fi
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+gcc_cv_have_tls=no
fi
-echo "$as_me:$LINENO: result: $have_tls" >&5
-echo "${ECHO_T}$have_tls" >&6
- if test "$enable_tls $have_tls" = "yes yes"; then
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+echo "$as_me:$LINENO: result: $gcc_cv_have_tls" >&5
+echo "${ECHO_T}$gcc_cv_have_tls" >&6
+ if test "$enable_tls $gcc_cv_have_tls" = "yes yes"; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_TLS 1
@@ -9288,6 +17463,118 @@ _ACEOF
fi
+
+# Check whether --with-gnu-ld or --without-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then
+ withval="$with_gnu_ld"
+ test "$withval" = no || with_gnu_ld=yes
+else
+ with_gnu_ld=no
+fi;
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ echo "$as_me:$LINENO: checking for ld used by $CC" >&5
+echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [\\/]* | ?:[\\/]*)
+ re_direlt='/[^/][^/]*/\.\./'
+ # Canonicalize the pathname of ld
+ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ echo "$as_me:$LINENO: checking for GNU ld" >&5
+echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6
+else
+ echo "$as_me:$LINENO: checking for non-GNU ld" >&5
+echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6
+fi
+if test "${lt_cv_path_LD+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -z "$LD"; then
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ lt_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some variants of GNU ld only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+ test "$with_gnu_ld" != yes && break
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+else
+ lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+ echo "$as_me:$LINENO: result: $LD" >&5
+echo "${ECHO_T}$LD" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
+echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
+ { (exit 1); exit 1; }; }
+echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
+echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
+if test "${lt_cv_prog_gnu_ld+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ lt_cv_prog_gnu_ld=yes
+ ;;
+*)
+ lt_cv_prog_gnu_ld=no
+ ;;
+esac
+fi
+echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5
+echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+
+
+
+
+
# If we're not using GNU ld, then there's no point in even trying these
# tests. Check for that first. We should have already tested for gld
# by now (in libtool), but require it now just to be safe...
@@ -11703,6 +19990,339 @@ CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
CC="$CC"
AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`'
+macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`'
+enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`'
+enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`'
+pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`'
+enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`'
+host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`'
+host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`'
+host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`'
+build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`'
+build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`'
+build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`'
+SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`'
+Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`'
+GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`'
+EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`'
+FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`'
+LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`'
+NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`'
+LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`'
+max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`'
+ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`'
+exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`'
+lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`'
+lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`'
+lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`'
+reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`'
+reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`'
+file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`'
+AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`'
+AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`'
+STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`'
+RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`'
+old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`'
+CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`'
+compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`'
+GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address" | $Xsed -e "$delay_single_quote_subst"`'
+objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`'
+SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`'
+ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`'
+MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`'
+need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`'
+libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`'
+shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`'
+export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
+whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`'
+allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`'
+no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`'
+inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`'
+link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`'
+fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`'
+always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`'
+export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`'
+include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`'
+prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`'
+variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`'
+need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`'
+need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`'
+version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`'
+runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`'
+shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`'
+shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`'
+libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`'
+library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`'
+soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`'
+postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`'
+sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`'
+sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`'
+enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`'
+enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`'
+enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`'
+old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`'
+striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`'
+predep_objects='`$ECHO "X$predep_objects" | $Xsed -e "$delay_single_quote_subst"`'
+postdep_objects='`$ECHO "X$postdep_objects" | $Xsed -e "$delay_single_quote_subst"`'
+predeps='`$ECHO "X$predeps" | $Xsed -e "$delay_single_quote_subst"`'
+postdeps='`$ECHO "X$postdeps" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_path='`$ECHO "X$compiler_lib_search_path" | $Xsed -e "$delay_single_quote_subst"`'
+LD_FC='`$ECHO "X$LD_FC" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_cmds_FC='`$ECHO "X$old_archive_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_FC='`$ECHO "X$compiler_FC" | $Xsed -e "$delay_single_quote_subst"`'
+GCC_FC='`$ECHO "X$GCC_FC" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag_FC='`$ECHO "X$lt_prog_compiler_no_builtin_flag_FC" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_wl_FC='`$ECHO "X$lt_prog_compiler_wl_FC" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_pic_FC='`$ECHO "X$lt_prog_compiler_pic_FC" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_static_FC='`$ECHO "X$lt_prog_compiler_static_FC" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o_FC='`$ECHO "X$lt_cv_prog_compiler_c_o_FC" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_need_lc_FC='`$ECHO "X$archive_cmds_need_lc_FC" | $Xsed -e "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes_FC='`$ECHO "X$enable_shared_with_static_runtimes_FC" | $Xsed -e "$delay_single_quote_subst"`'
+export_dynamic_flag_spec_FC='`$ECHO "X$export_dynamic_flag_spec_FC" | $Xsed -e "$delay_single_quote_subst"`'
+whole_archive_flag_spec_FC='`$ECHO "X$whole_archive_flag_spec_FC" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_needs_object_FC='`$ECHO "X$compiler_needs_object_FC" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_new_cmds_FC='`$ECHO "X$old_archive_from_new_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds_FC='`$ECHO "X$old_archive_from_expsyms_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_FC='`$ECHO "X$archive_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+archive_expsym_cmds_FC='`$ECHO "X$archive_expsym_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+module_cmds_FC='`$ECHO "X$module_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+module_expsym_cmds_FC='`$ECHO "X$module_expsym_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+with_gnu_ld_FC='`$ECHO "X$with_gnu_ld_FC" | $Xsed -e "$delay_single_quote_subst"`'
+allow_undefined_flag_FC='`$ECHO "X$allow_undefined_flag_FC" | $Xsed -e "$delay_single_quote_subst"`'
+no_undefined_flag_FC='`$ECHO "X$no_undefined_flag_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_FC='`$ECHO "X$hardcode_libdir_flag_spec_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_ld_FC='`$ECHO "X$hardcode_libdir_flag_spec_ld_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_separator_FC='`$ECHO "X$hardcode_libdir_separator_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_FC='`$ECHO "X$hardcode_direct_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_absolute_FC='`$ECHO "X$hardcode_direct_absolute_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_minus_L_FC='`$ECHO "X$hardcode_minus_L_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_shlibpath_var_FC='`$ECHO "X$hardcode_shlibpath_var_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_automatic_FC='`$ECHO "X$hardcode_automatic_FC" | $Xsed -e "$delay_single_quote_subst"`'
+inherit_rpath_FC='`$ECHO "X$inherit_rpath_FC" | $Xsed -e "$delay_single_quote_subst"`'
+link_all_deplibs_FC='`$ECHO "X$link_all_deplibs_FC" | $Xsed -e "$delay_single_quote_subst"`'
+fix_srcfile_path_FC='`$ECHO "X$fix_srcfile_path_FC" | $Xsed -e "$delay_single_quote_subst"`'
+always_export_symbols_FC='`$ECHO "X$always_export_symbols_FC" | $Xsed -e "$delay_single_quote_subst"`'
+export_symbols_cmds_FC='`$ECHO "X$export_symbols_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+exclude_expsyms_FC='`$ECHO "X$exclude_expsyms_FC" | $Xsed -e "$delay_single_quote_subst"`'
+include_expsyms_FC='`$ECHO "X$include_expsyms_FC" | $Xsed -e "$delay_single_quote_subst"`'
+prelink_cmds_FC='`$ECHO "X$prelink_cmds_FC" | $Xsed -e "$delay_single_quote_subst"`'
+file_list_spec_FC='`$ECHO "X$file_list_spec_FC" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_action_FC='`$ECHO "X$hardcode_action_FC" | $Xsed -e "$delay_single_quote_subst"`'
+predep_objects_FC='`$ECHO "X$predep_objects_FC" | $Xsed -e "$delay_single_quote_subst"`'
+postdep_objects_FC='`$ECHO "X$postdep_objects_FC" | $Xsed -e "$delay_single_quote_subst"`'
+predeps_FC='`$ECHO "X$predeps_FC" | $Xsed -e "$delay_single_quote_subst"`'
+postdeps_FC='`$ECHO "X$postdeps_FC" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_path_FC='`$ECHO "X$compiler_lib_search_path_FC" | $Xsed -e "$delay_single_quote_subst"`'
+
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# Quote evaled strings.
+for var in SED \
+GREP \
+EGREP \
+FGREP \
+LD \
+NM \
+LN_S \
+lt_SP2NL \
+lt_NL2SP \
+reload_flag \
+deplibs_check_method \
+file_magic_cmd \
+AR \
+AR_FLAGS \
+STRIP \
+RANLIB \
+CC \
+CFLAGS \
+compiler \
+lt_cv_sys_global_symbol_pipe \
+lt_cv_sys_global_symbol_to_cdecl \
+lt_cv_sys_global_symbol_to_c_name_address \
+SHELL \
+ECHO \
+lt_prog_compiler_no_builtin_flag \
+lt_prog_compiler_wl \
+lt_prog_compiler_pic \
+lt_prog_compiler_static \
+lt_cv_prog_compiler_c_o \
+need_locks \
+shrext_cmds \
+export_dynamic_flag_spec \
+whole_archive_flag_spec \
+compiler_needs_object \
+with_gnu_ld \
+allow_undefined_flag \
+no_undefined_flag \
+hardcode_libdir_flag_spec \
+hardcode_libdir_flag_spec_ld \
+hardcode_libdir_separator \
+fix_srcfile_path \
+exclude_expsyms \
+include_expsyms \
+file_list_spec \
+variables_saved_for_relink \
+libname_spec \
+library_names_spec \
+soname_spec \
+finish_eval \
+old_striplib \
+striplib \
+predep_objects \
+postdep_objects \
+predeps \
+postdeps \
+compiler_lib_search_path \
+LD_FC \
+compiler_FC \
+lt_prog_compiler_no_builtin_flag_FC \
+lt_prog_compiler_wl_FC \
+lt_prog_compiler_pic_FC \
+lt_prog_compiler_static_FC \
+lt_cv_prog_compiler_c_o_FC \
+export_dynamic_flag_spec_FC \
+whole_archive_flag_spec_FC \
+compiler_needs_object_FC \
+with_gnu_ld_FC \
+allow_undefined_flag_FC \
+no_undefined_flag_FC \
+hardcode_libdir_flag_spec_FC \
+hardcode_libdir_flag_spec_ld_FC \
+hardcode_libdir_separator_FC \
+fix_srcfile_path_FC \
+exclude_expsyms_FC \
+include_expsyms_FC \
+file_list_spec_FC \
+predep_objects_FC \
+postdep_objects_FC \
+predeps_FC \
+postdeps_FC \
+compiler_lib_search_path_FC; do
+ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+ *[\\\\\\\`\\"\\\$]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+# Double-quote double-evaled strings.
+for var in reload_cmds \
+old_postinstall_cmds \
+old_postuninstall_cmds \
+old_archive_cmds \
+extract_expsyms_cmds \
+old_archive_from_new_cmds \
+old_archive_from_expsyms_cmds \
+archive_cmds \
+archive_expsym_cmds \
+module_cmds \
+module_expsym_cmds \
+export_symbols_cmds \
+prelink_cmds \
+postinstall_cmds \
+postuninstall_cmds \
+finish_cmds \
+sys_lib_search_path_spec \
+sys_lib_dlsearch_path_spec \
+old_archive_cmds_FC \
+old_archive_from_new_cmds_FC \
+old_archive_from_expsyms_cmds_FC \
+archive_cmds_FC \
+archive_expsym_cmds_FC \
+module_cmds_FC \
+module_expsym_cmds_FC \
+export_symbols_cmds_FC \
+prelink_cmds_FC; do
+ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+ *[\\\\\\\`\\"\\\$]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+# Fix-up fallback echo if it was mangled by the above quoting rules.
+case \$lt_ECHO in
+*'\\\$0 --fallback-echo"') lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\`
+ ;;
+esac
+
+ac_aux_dir='$ac_aux_dir'
+xsi_shell='$xsi_shell'
+lt_shell_append='$lt_shell_append'
+
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+
+
+ PACKAGE='$PACKAGE'
+ VERSION='$VERSION'
+ TIMESTAMP='$TIMESTAMP'
+ RM='$RM'
+ ofile='$ofile'
+
+
+
+
+
+
GCC="$GCC"
CC="$CC"
acx_cv_header_stdint="$acx_cv_header_stdint"
@@ -11739,6 +20359,7 @@ do
"libgomp.spec" ) CONFIG_FILES="$CONFIG_FILES libgomp.spec" ;;
"default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;;
"depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+ "libtool" ) CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
"gstdint.h" ) CONFIG_COMMANDS="$CONFIG_COMMANDS gstdint.h" ;;
"config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
@@ -11886,8 +20507,19 @@ s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t
s,@PERL@,$PERL,;t t
s,@BUILD_INFO_TRUE@,$BUILD_INFO_TRUE,;t t
s,@BUILD_INFO_FALSE@,$BUILD_INFO_FALSE,;t t
-s,@LN_S@,$LN_S,;t t
s,@LIBTOOL@,$LIBTOOL,;t t
+s,@SED@,$SED,;t t
+s,@EGREP@,$EGREP,;t t
+s,@FGREP@,$FGREP,;t t
+s,@GREP@,$GREP,;t t
+s,@LD@,$LD,;t t
+s,@DUMPBIN@,$DUMPBIN,;t t
+s,@ac_ct_DUMPBIN@,$ac_ct_DUMPBIN,;t t
+s,@NM@,$NM,;t t
+s,@LN_S@,$LN_S,;t t
+s,@lt_ECHO@,$lt_ECHO,;t t
+s,@CPP@,$CPP,;t t
+s,@CPPFLAGS@,$CPPFLAGS,;t t
s,@enable_shared@,$enable_shared,;t t
s,@enable_static@,$enable_static,;t t
s,@MAINTAINER_MODE_TRUE@,$MAINTAINER_MODE_TRUE,;t t
@@ -11898,9 +20530,6 @@ s,@FCFLAGS@,$FCFLAGS,;t t
s,@LDFLAGS@,$LDFLAGS,;t t
s,@ac_ct_FC@,$ac_ct_FC,;t t
s,@libtool_VERSION@,$libtool_VERSION,;t t
-s,@CPP@,$CPP,;t t
-s,@CPPFLAGS@,$CPPFLAGS,;t t
-s,@EGREP@,$EGREP,;t t
s,@SECTION_LDFLAGS@,$SECTION_LDFLAGS,;t t
s,@OPT_LDFLAGS@,$OPT_LDFLAGS,;t t
s,@LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE@,$LIBGOMP_BUILD_VERSIONED_SHLIB_TRUE,;t t
@@ -12609,6 +21238,716 @@ echo "$as_me: error: cannot create directory $dirpart/$fdir" >&2;}
done
done
;;
+ libtool )
+
+ # See if we are running on zsh, and set the options which allow our
+ # commands through without removal of \ escapes.
+ if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+ fi
+
+ cfgfile="${ofile}T"
+ trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+ $RM "$cfgfile"
+
+ cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me (GNU $PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+# 2006, 2007 Free Software Foundation, Inc.
+#
+# This file is part of GNU Libtool:
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# 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, a copy can be downloaded from
+# http://www.gnu.org/copyleft/gpl.html, or by writing to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, 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.
+
+
+# The names of the tagged configurations supported by this script.
+available_tags="FC "
+
+# ### BEGIN LIBTOOL CONFIG
+
+# Which release of libtool.m4 was used?
+macro_version=$macro_version
+macro_revision=$macro_revision
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# What type of objects to build.
+pic_mode=$pic_mode
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# A sed program that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="\$SED -e 1s/^X//"
+
+# A grep program that handles long lines.
+GREP=$lt_GREP
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# A literal string matcher.
+FGREP=$lt_FGREP
+
+# A BSD- or MS-compatible name lister.
+NM=$lt_NM
+
+# Whether we need soft or hard links.
+LN_S=$lt_LN_S
+
+# What is the maximum length of a command?
+max_cmd_len=$max_cmd_len
+
+# Object file suffix (normally "o").
+objext=$ac_objext
+
+# Executable file suffix (normally "").
+exeext=$exeext
+
+# whether the shell understands "unset".
+lt_unset=$lt_unset
+
+# turn spaces into newlines.
+SP2NL=$lt_lt_SP2NL
+
+# turn newlines into spaces.
+NL2SP=$lt_lt_NL2SP
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == "file_magic".
+file_magic_cmd=$lt_file_magic_cmd
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A symbol stripping program.
+STRIP=$lt_STRIP
+
+# Commands used to install an old-style archive.
+RANLIB=$lt_RANLIB
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# A C compiler.
+LTCC=$lt_CC
+
+# LTCC compiler flags.
+LTCFLAGS=$lt_CFLAGS
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration.
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair.
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# An echo program that does not interpret backslashes.
+ECHO=$lt_ECHO
+
+# Used to examine libraries when file_magic_cmd begins with "file".
+MAGIC_CMD=$MAGIC_CMD
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Old archive suffix (normally "a").
+libext=$libext
+
+# Shared library suffix (normally ".so").
+shrext_cmds=$lt_shrext_cmds
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at link time.
+variables_saved_for_relink=$lt_variables_saved_for_relink
+
+# Do we need the "lib" prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Library versioning type.
+version_type=$version_type
+
+# Shared library runtime path variable.
+runpath_var=$runpath_var
+
+# Shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names. First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Command to use after installation of a shared archive.
+postinstall_cmds=$lt_postinstall_cmds
+
+# Command to use after uninstallation of a shared archive.
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# As "finish_cmds", except a single script fragment to be evaled but
+# not shown.
+finish_eval=$lt_finish_eval
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Compile-time system search path for libraries.
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries.
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+
+# The linker used to build libraries.
+LD=$lt_LD
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds
+
+# A language specific compiler.
+CC=$lt_compiler
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds
+archive_expsym_cmds=$lt_archive_expsym_cmds
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds
+module_expsym_cmds=$lt_module_expsym_cmds
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
+
+# If ld is used when linking, flag to hardcode \$libdir into a binary
+# during linking. This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
+
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path=$lt_fix_srcfile_path
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects
+postdep_objects=$lt_postdep_objects
+predeps=$lt_predeps
+postdeps=$lt_postdeps
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path
+
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+ case $host_os in
+ aix3*)
+ cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program. For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+fi
+_LT_EOF
+ ;;
+ esac
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+
+ # We use sed instead of cat because bash on DJGPP gets confused if
+ # if finds mixed CR/LF and LF-only lines. Since sed operates in
+ # text mode, it properly converts lines to CR/LF. This bash problem
+ # is reportedly fixed, but why not run on old versions too?
+ sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
+ || (rm -f "$cfgfile"; exit 1)
+
+ case $xsi_shell in
+ yes)
+ cat << \_LT_EOF >> "$cfgfile"
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE. If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+ case ${1} in
+ */*) func_dirname_result="${1%/*}${2}" ;;
+ * ) func_dirname_result="${3}" ;;
+ esac
+}
+
+# func_basename file
+func_basename ()
+{
+ func_basename_result="${1##*/}"
+}
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+func_stripname ()
+{
+ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+ # positional parameters, so assign one to ordinary parameter first.
+ func_stripname_result=${3}
+ func_stripname_result=${func_stripname_result#"${1}"}
+ func_stripname_result=${func_stripname_result%"${2}"}
+}
+
+# func_opt_split
+func_opt_split ()
+{
+ func_opt_split_opt=${1%%=*}
+ func_opt_split_arg=${1#*=}
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+ case ${1} in
+ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
+ *) func_lo2o_result=${1} ;;
+ esac
+}
+_LT_EOF
+ ;;
+ *) # Bourne compatible functions.
+ cat << \_LT_EOF >> "$cfgfile"
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE. If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+ # Extract subdirectory from the argument.
+ func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
+ if test "X$func_dirname_result" = "X${1}"; then
+ func_dirname_result="${3}"
+ else
+ func_dirname_result="$func_dirname_result${2}"
+ fi
+}
+
+# func_basename file
+func_basename ()
+{
+ func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
+}
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+# func_strip_suffix prefix name
+func_stripname ()
+{
+ case ${2} in
+ .*) func_stripname_result=`$ECHO "X${3}" \
+ | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
+ *) func_stripname_result=`$ECHO "X${3}" \
+ | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
+ esac
+}
+
+# sed scripts:
+my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q'
+my_sed_long_arg='1s/^-[^=]*=//'
+
+# func_opt_split
+func_opt_split ()
+{
+ func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
+ func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+ func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
+}
+_LT_EOF
+esac
+
+case $lt_shell_append in
+ yes)
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+ eval "$1+=\$2"
+}
+_LT_EOF
+ ;;
+ *)
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+ eval "$1=\$$1\$2"
+}
+_LT_EOF
+ ;;
+ esac
+
+
+ sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
+ || (rm -f "$cfgfile"; exit 1)
+
+ mv -f "$cfgfile" "$ofile" ||
+ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+ chmod +x "$ofile"
+
+
+ cat <<_LT_EOF >> "$ofile"
+
+# ### BEGIN LIBTOOL TAG CONFIG: FC
+
+# The linker used to build libraries.
+LD=$lt_LD_FC
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds_FC
+
+# A language specific compiler.
+CC=$lt_compiler_FC
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC_FC
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_FC
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_FC
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_FC
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_FC
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_FC
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_FC
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_FC
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_FC
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_FC
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object_FC
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_FC
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_FC
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds_FC
+archive_expsym_cmds=$lt_archive_expsym_cmds_FC
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds_FC
+module_expsym_cmds=$lt_module_expsym_cmds_FC
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld_FC
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_FC
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_FC
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_FC
+
+# If ld is used when linking, flag to hardcode \$libdir into a binary
+# during linking. This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_FC
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_FC
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct_FC
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute_FC
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L_FC
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_FC
+
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic_FC
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath_FC
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_FC
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path=$lt_fix_srcfile_path_FC
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols_FC
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_FC
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_FC
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_FC
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds_FC
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec_FC
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_FC
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects_FC
+postdep_objects=$lt_postdep_objects_FC
+predeps=$lt_predeps_FC
+postdeps=$lt_postdeps_FC
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_FC
+
+# ### END LIBTOOL TAG CONFIG: FC
+_LT_EOF
+
+ ;;
gstdint.h )
if test "$GCC" = yes; then
echo "/* generated for " `$CC --version | sed 1q` "*/" > tmp-stdint.h
@@ -12650,33 +21989,51 @@ if test "$acx_cv_header_stdint" = stddef.h; then
#ifndef _UINT8_T
#define _UINT8_T
+ #ifndef __uint8_t_defined
+ #define __uint8_t_defined
typedef unsigned $acx_cv_type_int8_t uint8_t;
#endif
+ #endif
#ifndef _UINT16_T
#define _UINT16_T
+ #ifndef __uint16_t_defined
+ #define __uint16_t_defined
typedef unsigned $acx_cv_type_int16_t uint16_t;
#endif
+ #endif
#ifndef _UINT32_T
#define _UINT32_T
+ #ifndef __uint32_t_defined
+ #define __uint32_t_defined
typedef unsigned $acx_cv_type_int32_t uint32_t;
#endif
+ #endif
#ifndef _INT8_T
#define _INT8_T
+ #ifndef __int8_t_defined
+ #define __int8_t_defined
typedef $acx_cv_type_int8_t int8_t;
#endif
+ #endif
#ifndef _INT16_T
#define _INT16_T
+ #ifndef __int16_t_defined
+ #define __int16_t_defined
typedef $acx_cv_type_int16_t int16_t;
#endif
+ #endif
#ifndef _INT32_T
#define _INT32_T
+ #ifndef __int32_t_defined
+ #define __int32_t_defined
typedef $acx_cv_type_int32_t int32_t;
#endif
+ #endif
EOF
elif test "$ac_cv_type_u_int32_t" = yes; then
sed 's/^ *//' >> tmp-stdint.h <<EOF
@@ -12694,18 +22051,27 @@ elif test "$ac_cv_type_u_int32_t" = yes; then
#ifndef _UINT8_T
#define _UINT8_T
+ #ifndef __uint8_t_defined
+ #define __uint8_t_defined
typedef u_int8_t uint8_t;
#endif
+ #endif
#ifndef _UINT16_T
#define _UINT16_T
+ #ifndef __uint16_t_defined
+ #define __uint16_t_defined
typedef u_int16_t uint16_t;
#endif
+ #endif
#ifndef _UINT32_T
#define _UINT32_T
+ #ifndef __uint32_t_defined
+ #define __uint32_t_defined
typedef u_int32_t uint32_t;
#endif
+ #endif
EOF
else
sed 's/^ *//' >> tmp-stdint.h <<EOF
@@ -12753,8 +22119,11 @@ elif test "$ac_cv_type_u_int64_t" = yes; then
#endif
#ifndef _UINT64_T
#define _UINT64_T
+ #ifndef __uint64_t_defined
+ #define __uint64_t_defined
typedef u_int64_t uint64_t;
#endif
+ #endif
EOF
elif test -n "$acx_cv_type_int64_t"; then
sed 's/^ *//' >> tmp-stdint.h <<EOF
@@ -12766,8 +22135,11 @@ elif test -n "$acx_cv_type_int64_t"; then
#endif
#ifndef _UINT64_T
#define _UINT64_T
+ #ifndef __uint64_t_defined
+ #define __uint64_t_defined
typedef unsigned $acx_cv_type_int64_t uint64_t;
#endif
+ #endif
EOF
else
sed 's/^ *//' >> tmp-stdint.h <<EOF
@@ -12776,8 +22148,10 @@ else
#if defined __STDC_VERSION__ && (__STDC_VERSION__-0) >= 199901L
#ifndef _INT64_T
#define _INT64_T
+ #ifndef __int64_t_defined
typedef long long int64_t;
#endif
+ #endif
#ifndef _UINT64_T
#define _UINT64_T
typedef unsigned long long uint64_t;
@@ -12822,8 +22196,12 @@ if test "$ac_cv_type_uintptr_t" != yes; then
sed 's/^ *//' >> tmp-stdint.h <<EOF
/* Define intptr_t based on sizeof(void*) = $ac_cv_sizeof_void_p */
+ #ifndef __uintptr_t_defined
typedef u$acx_cv_type_intptr_t uintptr_t;
+ #endif
+ #ifndef __intptr_t_defined
typedef $acx_cv_type_intptr_t intptr_t;
+ #endif
EOF
fi
diff --git a/contrib/gcclibs/libgomp/configure.ac b/contrib/gcclibs/libgomp/configure.ac
index fc0f003..c43858d 100644
--- a/contrib/gcclibs/libgomp/configure.ac
+++ b/contrib/gcclibs/libgomp/configure.ac
@@ -15,12 +15,6 @@ LIBGOMP_ENABLE(version-specific-runtime-libs, no, ,
permit yes|no)
AC_MSG_RESULT($enable_version_specific_runtime_libs)
-AC_MSG_CHECKING([for --enable-linux-futex])
-LIBGOMP_ENABLE(linux-futex, default, ,
- [Use the Linux futex system call],
- permit yes|no|default)
-AC_MSG_RESULT($enable_linux_futex)
-
# We would like our source tree to be readonly. However when releases or
# pre-releases are generated, the flex/bison generated files as well as the
# various formats of manuals need to be included along with the rest of the
@@ -64,11 +58,11 @@ target_alias=${target_alias-$host_alias}
# we can do about that; they come from AC_INIT).
# foreign: we don't follow the normal rules for GNU packages (no COPYING
# file in the top srcdir, etc, etc), so stop complaining.
-# no-dependencies: turns off auto dependency generation (just for now)
+# no-dist: we don't want 'dist' and related rules.
# -Wall: turns on all automake warnings...
# -Wno-portability: ...except this one, since GNU make is required.
# -Wno-override: ... and this one, since we do want this in testsuite.
-AM_INIT_AUTOMAKE([1.9.0 foreign -Wall -Wno-portability -Wno-override])
+AM_INIT_AUTOMAKE([1.9.0 foreign no-dist -Wall -Wno-portability -Wno-override])
AM_ENABLE_MULTILIB(, ..)
# Calculate toolexeclibdir
@@ -135,7 +129,7 @@ AC_PROG_INSTALL
# that we can use it.
ACX_CHECK_PROG_VER([MAKEINFO], [makeinfo], [--version],
[GNU texinfo.* \([0-9][0-9.]*\)],
- [4.[4-9]*])
+ [4.[4-9]*|4.[1-9][0-9]*|[5-9]*|[1-9][0-9]*])
AM_CONDITIONAL(BUILD_INFO, test $gcc_cv_prog_makeinfo_modern = "yes")
@@ -160,7 +154,7 @@ AC_SUBST(libtool_VERSION)
# Check header files.
AC_STDC_HEADERS
AC_HEADER_TIME
-AC_CHECK_HEADERS(unistd.h semaphore.h sys/loadavg.h sys/time.h)
+AC_CHECK_HEADERS(unistd.h semaphore.h sys/loadavg.h sys/sysctl.h sys/time.h)
GCC_HEADER_STDINT(gstdint.h)
@@ -193,50 +187,29 @@ case "$host" in
AC_DEFINE(HAVE_BROKEN_POSIX_SEMAPHORES, 1,
Define if the POSIX Semaphores do not work on your system.)
;;
- *-linux*)
- case "$enable_linux_futex" in
- default)
- # If headers don't have gettid/futex syscalls definition, then
- # default to no, otherwise there will be compile time failures.
- # Otherwise, default to yes. If we don't detect we are
- # compiled/linked against NPTL and not cross-compiling, check
- # if programs are run by default against NPTL and if not, issue
- # a warning.
- enable_linux_futex=no
- AC_LINK_IFELSE(
- [AC_LANG_PROGRAM(
- [#include <sys/syscall.h>
- int lk;],
- [syscall (SYS_gettid); syscall (SYS_futex, &lk, 0, 0, 0);])],
- [AC_LINK_IFELSE(
- [AC_LANG_PROGRAM(
- [#ifndef _GNU_SOURCE
- #define _GNU_SOURCE 1
- #endif
- #include <pthread.h>
- pthread_t th; void *status;],
- [pthread_tryjoin_np (th, &status);])],[enable_linux_futex=yes],
- [if test x$cross_compiling = xno; then
- if getconf GNU_LIBPTHREAD_VERSION 2>/dev/null \
- | LC_ALL=C grep -i NPTL > /dev/null 2>/dev/null; then
- AC_MSG_WARN([The kernel might not support futex or gettid syscalls.
-If so, please configure with --disable-linux-futex])
- fi
- fi
- enable_linux_futex=yes])])
- ;;
- yes)
- AC_LINK_IFELSE(
- [AC_LANG_PROGRAM(
- [#include <sys/syscall.h>
- int lk;],
- [syscall (SYS_gettid); syscall (SYS_futex, &lk, 0, 0, 0);])],[],
- [AC_MSG_ERROR([SYS_gettid and SYS_futex required for --enable-linux-futex])])
- ;;
- esac
- ;;
esac
+GCC_LINUX_FUTEX(:)
+
+# Check for pthread_{,attr_}[sg]etaffinity_np.
+AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [#define _GNU_SOURCE
+ #include <pthread.h>],
+ [cpu_set_t cpuset;
+ pthread_attr_t attr;
+ pthread_getaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
+ if (CPU_ISSET (0, &cpuset))
+ CPU_SET (1, &cpuset);
+ else
+ CPU_ZERO (&cpuset);
+ pthread_setaffinity_np (pthread_self (), sizeof (cpu_set_t), &cpuset);
+ pthread_attr_init (&attr);
+ pthread_attr_getaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);
+ pthread_attr_setaffinity_np (&attr, sizeof (cpu_set_t), &cpuset);])],
+ AC_DEFINE(HAVE_PTHREAD_AFFINITY_NP, 1,
+[ Define if pthread_{,attr_}{g,s}etaffinity_np is supported.]))
+
# At least for glibc, clock_gettime is in librt. But don't pull that
# in if it still doesn't give us the function we want.
if test $ac_cv_func_clock_gettime = no; then
diff --git a/contrib/gcclibs/libgomp/configure.tgt b/contrib/gcclibs/libgomp/configure.tgt
index 89bae02..a666943 100644
--- a/contrib/gcclibs/libgomp/configure.tgt
+++ b/contrib/gcclibs/libgomp/configure.tgt
@@ -11,14 +11,11 @@
# XLDFLAGS Add extra link flags to use.
# Optimize TLS usage by avoiding the overhead of dynamic allocation.
-# This does require that the library be present during process
-# startup, so mark the library as not to be dlopened.
-if test $have_tls = yes ; then
+if test $gcc_cv_have_tls = yes ; then
case "${target}" in
*-*-linux*)
XCFLAGS="${XCFLAGS} -ftls-model=initial-exec"
- XLDFLAGS="${XLDFLAGS} -Wl,-z,nodlopen"
;;
esac
fi
@@ -49,9 +46,14 @@ if test $enable_linux_futex = yes; then
# Note that bare i386 is not included here. We need cmpxchg.
i[456]86-*-linux*)
config_path="linux/x86 linux posix"
- if test -z "$with_arch"; then
- XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
- fi
+ case " ${CC} ${CFLAGS} " in
+ *" -m64 "*)
+ ;;
+ *)
+ if test -z "$with_arch"; then
+ XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
+ fi
+ esac
;;
# Similar jiggery-pokery for x86_64 multilibs, except here we
@@ -105,6 +107,10 @@ case "${target}" in
XLDFLAGS="${XLDFLAGS} -lposix4"
;;
+ *-*-darwin*)
+ config_path="bsd posix"
+ ;;
+
*)
;;
diff --git a/contrib/gcclibs/libgomp/env.c b/contrib/gcclibs/libgomp/env.c
index f07b31b..4a07bfa 100644
--- a/contrib/gcclibs/libgomp/env.c
+++ b/contrib/gcclibs/libgomp/env.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@redhat.com>.
This file is part of the GNU OpenMP Library (libgomp).
@@ -42,6 +42,8 @@ bool gomp_dyn_var = false;
bool gomp_nest_var = false;
enum gomp_schedule_type gomp_run_sched_var = GFS_DYNAMIC;
unsigned long gomp_run_sched_chunk = 1;
+unsigned short *gomp_cpu_affinity;
+size_t gomp_cpu_affinity_len;
/* Parse the OMP_SCHEDULE environment variable. */
@@ -177,6 +179,97 @@ parse_boolean (const char *name, bool *value)
gomp_error ("Invalid value for environment variable %s", name);
}
+/* Parse the GOMP_CPU_AFFINITY environment varible. Return true if one was
+ present and it was successfully parsed. */
+
+static bool
+parse_affinity (void)
+{
+ char *env, *end;
+ unsigned long cpu_beg, cpu_end, cpu_stride;
+ unsigned short *cpus = NULL;
+ size_t allocated = 0, used = 0, needed;
+
+ env = getenv ("GOMP_CPU_AFFINITY");
+ if (env == NULL)
+ return false;
+
+ do
+ {
+ while (*env == ' ' || *env == '\t')
+ env++;
+
+ cpu_beg = strtoul (env, &end, 0);
+ cpu_end = cpu_beg;
+ cpu_stride = 1;
+ if (env == end || cpu_beg >= 65536)
+ goto invalid;
+
+ env = end;
+ if (*env == '-')
+ {
+ cpu_end = strtoul (++env, &end, 0);
+ if (env == end || cpu_end >= 65536 || cpu_end < cpu_beg)
+ goto invalid;
+
+ env = end;
+ if (*env == ':')
+ {
+ cpu_stride = strtoul (++env, &end, 0);
+ if (env == end || cpu_stride == 0 || cpu_stride >= 65536)
+ goto invalid;
+
+ env = end;
+ }
+ }
+
+ needed = (cpu_end - cpu_beg) / cpu_stride + 1;
+ if (used + needed >= allocated)
+ {
+ unsigned short *new_cpus;
+
+ if (allocated < 64)
+ allocated = 64;
+ if (allocated > needed)
+ allocated <<= 1;
+ else
+ allocated += 2 * needed;
+ new_cpus = realloc (cpus, allocated * sizeof (unsigned short));
+ if (new_cpus == NULL)
+ {
+ free (cpus);
+ gomp_error ("not enough memory to store GOMP_CPU_AFFINITY list");
+ return false;
+ }
+
+ cpus = new_cpus;
+ }
+
+ while (needed--)
+ {
+ cpus[used++] = cpu_beg;
+ cpu_beg += cpu_stride;
+ }
+
+ while (*env == ' ' || *env == '\t')
+ env++;
+
+ if (*env == ',')
+ env++;
+ else if (*env == '\0')
+ break;
+ }
+ while (1);
+
+ gomp_cpu_affinity = cpus;
+ gomp_cpu_affinity_len = used;
+ return true;
+
+ invalid:
+ gomp_error ("Invalid value for enviroment variable GOMP_CPU_AFFINITY");
+ return false;
+}
+
static void __attribute__((constructor))
initialize_env (void)
{
@@ -190,6 +283,8 @@ initialize_env (void)
parse_boolean ("OMP_NESTED", &gomp_nest_var);
if (!parse_unsigned_long ("OMP_NUM_THREADS", &gomp_nthreads_var))
gomp_init_num_threads ();
+ if (parse_affinity ())
+ gomp_init_affinity ();
/* Not strictly environment related, but ordering constructors is tricky. */
pthread_attr_init (&gomp_thread_attr);
diff --git a/contrib/gcclibs/libgomp/iter.c b/contrib/gcclibs/libgomp/iter.c
index 1a8a2a7..2d5dd2e 100644
--- a/contrib/gcclibs/libgomp/iter.c
+++ b/contrib/gcclibs/libgomp/iter.c
@@ -242,16 +242,16 @@ gomp_iter_guided_next_locked (long *pstart, long *pend)
if (ws->next == ws->end)
return false;
- n = (ws->end - ws->next) / ws->incr;
+ start = ws->next;
+ n = (ws->end - start) / ws->incr;
q = (n + nthreads - 1) / nthreads;
if (q < ws->chunk_size)
q = ws->chunk_size;
- if (q > n)
- q = n;
-
- start = ws->next;
- end = start + q * ws->incr;
+ if (q <= n)
+ end = start + q * ws->incr;
+ else
+ end = ws->end;
ws->next = end;
*pstart = start;
@@ -286,15 +286,15 @@ gomp_iter_guided_next (long *pstart, long *pend)
if (start == end)
return false;
- n = (end - start) / ws->incr;
+ n = (end - start) / incr;
q = (n + nthreads - 1) / nthreads;
if (q < chunk_size)
q = chunk_size;
- if (q > n)
- q = n;
-
- nend = start + q * incr;
+ if (__builtin_expect (q <= n, 1))
+ nend = start + q * incr;
+ else
+ nend = end;
tmp = __sync_val_compare_and_swap (&ws->next, start, nend);
if (__builtin_expect (tmp == start, 1))
diff --git a/contrib/gcclibs/libgomp/libgomp.h b/contrib/gcclibs/libgomp/libgomp.h
index 47e68e6..7075250 100644
--- a/contrib/gcclibs/libgomp/libgomp.h
+++ b/contrib/gcclibs/libgomp/libgomp.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2007 Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@redhat.com>.
This file is part of the GNU OpenMP Library (libgomp).
@@ -246,8 +246,18 @@ extern unsigned long gomp_run_sched_chunk;
/* The attributes to be used during thread creation. */
extern pthread_attr_t gomp_thread_attr;
+/* Other variables. */
+
+extern unsigned short *gomp_cpu_affinity;
+extern size_t gomp_cpu_affinity_len;
+
/* Function prototypes. */
+/* affinity.c */
+
+extern void gomp_init_affinity (void);
+extern void gomp_init_thread_affinity (pthread_attr_t *);
+
/* alloc.c */
extern void *gomp_malloc (size_t) __attribute__((malloc));
diff --git a/contrib/gcclibs/libgomp/libgomp.texi b/contrib/gcclibs/libgomp/libgomp.texi
index c48cf93..f92a5da 100644
--- a/contrib/gcclibs/libgomp/libgomp.texi
+++ b/contrib/gcclibs/libgomp/libgomp.texi
@@ -895,14 +895,25 @@ dynamic scheduling and a chunk size of 1 is used.
@cindex Environment Variable
@table @asis
@item @emph{Description}:
-A patch for this extension has been submitted, but was not yet applied at the
-time of writing.
-
-@item @emph{Reference}:
-@uref{http://gcc.gnu.org/ml/gcc-patches/2006-05/msg00982.html,
-GCC Patches Mailinglist}
-@uref{http://gcc.gnu.org/ml/gcc-patches/2006-05/msg01133.html,
-GCC Patches Mailinglist}
+Binds threads to specific CPUs. The variable should contain a space- or
+comma-separated list of CPUs. This list may contain different kind of
+entries: either single CPU numbers in any order, a range of CPUs (M-N)
+or a range with some stride (M-N:S). CPU numbers are zero based. For example,
+@code{GOMP_CPU_AFFINITY="0 3 1-2 4-15:2"} will bind the initial thread
+to CPU 0, the second to CPU 3, the third to CPU 1, the fourth to
+CPU 2, the fifth to CPU 4, the sixth through tenth to CPUs 6, 8, 10, 12,
+and 14 respectively and then start assigning back from the beginning of
+the list. @code{GOMP_CPU_AFFINITY=0} binds all threads to CPU 0.
+
+There is no GNU OpenMP library routine to determine whether a CPU affinity
+specification is in effect. As a workaround, language-specific library
+functions, e.g., @code{getenv} in C or @code{GET_ENVIRONMENT_VARIABLE} in
+Fortran, may be used to query the setting of the @code{GOMP_CPU_AFFINITY}
+environment variable. A defined CPU affinity on startup cannot be changed
+or disabled during the runtime of the application.
+
+If this environment variable is omitted, the host system will handle the
+assignment of threads to CPUs.
@end table
diff --git a/contrib/gcclibs/libgomp/omp.h.in b/contrib/gcclibs/libgomp/omp.h.in
index 44fda90..5ebcdbb 100644
--- a/contrib/gcclibs/libgomp/omp.h.in
+++ b/contrib/gcclibs/libgomp/omp.h.in
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2007 Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@redhat.com>.
This file is part of the GNU OpenMP Library (libgomp).
@@ -49,36 +49,39 @@ typedef struct
#ifdef __cplusplus
extern "C" {
+# define __GOMP_NOTHROW throw ()
+#else
+# define __GOMP_NOTHROW __attribute__((__nothrow__))
#endif
-extern void omp_set_num_threads (int);
-extern int omp_get_num_threads (void);
-extern int omp_get_max_threads (void);
-extern int omp_get_thread_num (void);
-extern int omp_get_num_procs (void);
+extern void omp_set_num_threads (int) __GOMP_NOTHROW;
+extern int omp_get_num_threads (void) __GOMP_NOTHROW;
+extern int omp_get_max_threads (void) __GOMP_NOTHROW;
+extern int omp_get_thread_num (void) __GOMP_NOTHROW;
+extern int omp_get_num_procs (void) __GOMP_NOTHROW;
-extern int omp_in_parallel (void);
+extern int omp_in_parallel (void) __GOMP_NOTHROW;
-extern void omp_set_dynamic (int);
-extern int omp_get_dynamic (void);
+extern void omp_set_dynamic (int) __GOMP_NOTHROW;
+extern int omp_get_dynamic (void) __GOMP_NOTHROW;
-extern void omp_set_nested (int);
-extern int omp_get_nested (void);
+extern void omp_set_nested (int) __GOMP_NOTHROW;
+extern int omp_get_nested (void) __GOMP_NOTHROW;
-extern void omp_init_lock (omp_lock_t *);
-extern void omp_destroy_lock (omp_lock_t *);
-extern void omp_set_lock (omp_lock_t *);
-extern void omp_unset_lock (omp_lock_t *);
-extern int omp_test_lock (omp_lock_t *);
+extern void omp_init_lock (omp_lock_t *) __GOMP_NOTHROW;
+extern void omp_destroy_lock (omp_lock_t *) __GOMP_NOTHROW;
+extern void omp_set_lock (omp_lock_t *) __GOMP_NOTHROW;
+extern void omp_unset_lock (omp_lock_t *) __GOMP_NOTHROW;
+extern int omp_test_lock (omp_lock_t *) __GOMP_NOTHROW;
-extern void omp_init_nest_lock (omp_nest_lock_t *);
-extern void omp_destroy_nest_lock (omp_nest_lock_t *);
-extern void omp_set_nest_lock (omp_nest_lock_t *);
-extern void omp_unset_nest_lock (omp_nest_lock_t *);
-extern int omp_test_nest_lock (omp_nest_lock_t *);
+extern void omp_init_nest_lock (omp_nest_lock_t *) __GOMP_NOTHROW;
+extern void omp_destroy_nest_lock (omp_nest_lock_t *) __GOMP_NOTHROW;
+extern void omp_set_nest_lock (omp_nest_lock_t *) __GOMP_NOTHROW;
+extern void omp_unset_nest_lock (omp_nest_lock_t *) __GOMP_NOTHROW;
+extern int omp_test_nest_lock (omp_nest_lock_t *) __GOMP_NOTHROW;
-extern double omp_get_wtime (void);
-extern double omp_get_wtick (void);
+extern double omp_get_wtime (void) __GOMP_NOTHROW;
+extern double omp_get_wtick (void) __GOMP_NOTHROW;
#ifdef __cplusplus
}
diff --git a/contrib/gcclibs/libgomp/omp_lib.h.in b/contrib/gcclibs/libgomp/omp_lib.h.in
index 734f2f7..2376b23 100644
--- a/contrib/gcclibs/libgomp/omp_lib.h.in
+++ b/contrib/gcclibs/libgomp/omp_lib.h.in
@@ -38,16 +38,16 @@
external omp_set_num_threads
external omp_get_dynamic, omp_get_nested
- logical*4 omp_get_dynamic, omp_get_nested
+ logical(4) omp_get_dynamic, omp_get_nested
external omp_test_lock, omp_in_parallel
- logical*4 omp_test_lock, omp_in_parallel
+ logical(4) omp_test_lock, omp_in_parallel
external omp_get_max_threads, omp_get_num_procs
- integer*4 omp_get_max_threads, omp_get_num_procs
+ integer(4) omp_get_max_threads, omp_get_num_procs
external omp_get_num_threads, omp_get_thread_num
- integer*4 omp_get_num_threads, omp_get_thread_num
+ integer(4) omp_get_num_threads, omp_get_thread_num
external omp_test_nest_lock
- integer*4 omp_test_nest_lock
+ integer(4) omp_test_nest_lock
external omp_get_wtick, omp_get_wtime
double precision omp_get_wtick, omp_get_wtime
diff --git a/contrib/gcclibs/libgomp/team.c b/contrib/gcclibs/libgomp/team.c
index 060f4ea..7d50bfc 100644
--- a/contrib/gcclibs/libgomp/team.c
+++ b/contrib/gcclibs/libgomp/team.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
Contributed by Richard Henderson <rth@redhat.com>.
This file is part of the GNU OpenMP Library (libgomp).
@@ -183,6 +183,7 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads,
struct gomp_team *team;
bool nested;
unsigned i, n, old_threads_used = 0;
+ pthread_attr_t thread_attr, *attr;
thr = gomp_thread ();
nested = thr->ts.team != NULL;
@@ -265,6 +266,17 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads,
}
}
+ attr = &gomp_thread_attr;
+ if (gomp_cpu_affinity != NULL)
+ {
+ size_t stacksize;
+ pthread_attr_init (&thread_attr);
+ pthread_attr_setdetachstate (&thread_attr, PTHREAD_CREATE_DETACHED);
+ if (! pthread_attr_getstacksize (&gomp_thread_attr, &stacksize))
+ pthread_attr_setstacksize (&thread_attr, stacksize);
+ attr = &thread_attr;
+ }
+
start_data = gomp_alloca (sizeof (struct gomp_thread_start_data)
* (nthreads-i));
@@ -283,12 +295,17 @@ gomp_team_start (void (*fn) (void *), void *data, unsigned nthreads,
start_data->fn_data = data;
start_data->nested = nested;
- err = pthread_create (&pt, &gomp_thread_attr,
- gomp_thread_start, start_data);
+ if (gomp_cpu_affinity != NULL)
+ gomp_init_thread_affinity (attr);
+
+ err = pthread_create (&pt, attr, gomp_thread_start, start_data);
if (err != 0)
gomp_fatal ("Thread creation failed: %s", strerror (err));
}
+ if (gomp_cpu_affinity != NULL)
+ pthread_attr_destroy (&thread_attr);
+
do_release:
gomp_barrier_wait (nested ? &team->barrier : &gomp_threads_dock);
diff --git a/contrib/gdb/gdb/c-valprint.c b/contrib/gdb/gdb/c-valprint.c
index 999aa82..913793a 100644
--- a/contrib/gdb/gdb/c-valprint.c
+++ b/contrib/gdb/gdb/c-valprint.c
@@ -559,6 +559,10 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
fprintf_filtered (stream, ") ");
}
}
+
+ if (!value_initialized (val))
+ fprintf_filtered (stream, " [uninitialized] ");
+
if (objectprint && (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_CLASS))
{
/* Attempt to determine real type of object */
diff --git a/contrib/gdb/gdb/dwarf2expr.c b/contrib/gdb/gdb/dwarf2expr.c
index 294afa0..c7ae563 100644
--- a/contrib/gdb/gdb/dwarf2expr.c
+++ b/contrib/gdb/gdb/dwarf2expr.c
@@ -42,6 +42,8 @@ new_dwarf_expr_context (void)
retval->stack_len = 0;
retval->stack_allocated = 10;
retval->stack = xmalloc (retval->stack_allocated * sizeof (CORE_ADDR));
+ retval->num_pieces = 0;
+ retval->pieces = 0;
return retval;
}
@@ -51,6 +53,7 @@ void
free_dwarf_expr_context (struct dwarf_expr_context *ctx)
{
xfree (ctx->stack);
+ xfree (ctx->pieces);
xfree (ctx);
}
@@ -100,6 +103,29 @@ dwarf_expr_fetch (struct dwarf_expr_context *ctx, int n)
}
+/* Add a new piece to CTX's piece list. */
+static void
+add_piece (struct dwarf_expr_context *ctx,
+ int in_reg, CORE_ADDR value, ULONGEST size)
+{
+ struct dwarf_expr_piece *p;
+
+ ctx->num_pieces++;
+
+ if (ctx->pieces)
+ ctx->pieces = xrealloc (ctx->pieces,
+ (ctx->num_pieces
+ * sizeof (struct dwarf_expr_piece)));
+ else
+ ctx->pieces = xmalloc (ctx->num_pieces
+ * sizeof (struct dwarf_expr_piece));
+
+ p = &ctx->pieces[ctx->num_pieces - 1];
+ p->in_reg = in_reg;
+ p->value = value;
+ p->size = size;
+}
+
/* Evaluate the expression at ADDR (LEN bytes long) using the context
CTX. */
@@ -230,6 +256,7 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
unsigned char *op_end)
{
ctx->in_reg = 0;
+ ctx->initialized = 1; /* Default is initialized. */
while (op_ptr < op_end)
{
@@ -356,9 +383,12 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
case DW_OP_reg29:
case DW_OP_reg30:
case DW_OP_reg31:
- if (op_ptr != op_end && *op_ptr != DW_OP_piece)
- error ("DWARF-2 expression error: DW_OP_reg operations must be "
- "used either alone or in conjuction with DW_OP_piece.");
+ if (op_ptr != op_end
+ && *op_ptr != DW_OP_piece
+ && *op_ptr != DW_OP_bit_piece
+ && *op_ptr != DW_OP_GNU_uninit)
+ error (_("DWARF-2 expression error: DW_OP_reg operations must be "
+ "used either alone or in conjuction with DW_OP_piece."));
result = op - DW_OP_reg0;
ctx->in_reg = 1;
@@ -661,6 +691,30 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
case DW_OP_nop:
goto no_push;
+ case DW_OP_piece:
+ {
+ ULONGEST size;
+ CORE_ADDR addr_or_regnum;
+
+ /* Record the piece. */
+ op_ptr = read_uleb128 (op_ptr, op_end, &size);
+ addr_or_regnum = dwarf_expr_fetch (ctx, 0);
+ add_piece (ctx, ctx->in_reg, addr_or_regnum, size);
+
+ /* Pop off the address/regnum, and clear the in_reg flag. */
+ dwarf_expr_pop (ctx);
+ ctx->in_reg = 0;
+ }
+ goto no_push;
+
+ case DW_OP_GNU_uninit:
+ if (op_ptr != op_end)
+ error (_("DWARF-2 expression error: DW_OP_GNU_unint must always "
+ "be the very last op."));
+
+ ctx->initialized = 0;
+ goto no_push;
+
default:
error ("Unhandled dwarf expression opcode 0x%x", op);
}
diff --git a/contrib/gdb/gdb/dwarf2expr.h b/contrib/gdb/gdb/dwarf2expr.h
index 0a60edb..1892c90 100644
--- a/contrib/gdb/gdb/dwarf2expr.h
+++ b/contrib/gdb/gdb/dwarf2expr.h
@@ -74,6 +74,51 @@ struct dwarf_expr_context
/* Non-zero if the result is in a register. The register number
will be on the expression stack. */
int in_reg;
+ /* Initialization status of variable: Non-zero if variable has been
+ initialized; zero otherwise. */
+ int initialized;
+
+ /* An array of pieces. PIECES points to its first element;
+ NUM_PIECES is its length.
+
+ Each time DW_OP_piece is executed, we add a new element to the
+ end of this array, recording the current top of the stack, the
+ current in_reg flag, and the size given as the operand to
+ DW_OP_piece. We then pop the top value from the stack, clear the
+ in_reg flag, and resume evaluation.
+
+ The Dwarf spec doesn't say whether DW_OP_piece pops the top value
+ from the stack. We do, ensuring that clients of this interface
+ expecting to see a value left on the top of the stack (say, code
+ evaluating frame base expressions or CFA's specified with
+ DW_CFA_def_cfa_expression) will get an error if the expression
+ actually marks all the values it computes as pieces.
+
+ If an expression never uses DW_OP_piece, num_pieces will be zero.
+ (It would be nice to present these cases as expressions yielding
+ a single piece, with in_reg clear, so that callers need not
+ distinguish between the no-DW_OP_piece and one-DW_OP_piece cases.
+ But expressions with no DW_OP_piece operations have no value to
+ place in a piece's 'size' field; the size comes from the
+ surrounding data. So the two cases need to be handled
+ separately.) */
+ int num_pieces;
+ struct dwarf_expr_piece *pieces;
+};
+
+/* A piece of an object, as recorded by DW_OP_piece or DW_OP_bit_piece. */
+struct dwarf_expr_piece
+{
+ /* If IN_REG is zero, then the piece is in memory, and VALUE is its address.
+ If IN_REG is non-zero, then the piece is in a register, and VALUE
+ is the register number. */
+ int in_reg;
+
+ /* This piece's address or register number. */
+ CORE_ADDR value;
+
+ /* The length of the piece, in bytes. */
+ ULONGEST size;
};
struct dwarf_expr_context *new_dwarf_expr_context (void);
diff --git a/contrib/gdb/gdb/dwarf2loc.c b/contrib/gdb/gdb/dwarf2loc.c
index 208e9d1..c81d46f 100644
--- a/contrib/gdb/gdb/dwarf2loc.c
+++ b/contrib/gdb/gdb/dwarf2loc.c
@@ -206,6 +206,7 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
struct objfile *objfile)
{
CORE_ADDR result;
+ struct gdbarch *arch = get_frame_arch (frame);
struct value *retval;
struct dwarf_expr_baton baton;
struct dwarf_expr_context *ctx;
@@ -230,7 +231,32 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
dwarf_expr_eval (ctx, data, size);
result = dwarf_expr_fetch (ctx, 0);
- if (ctx->in_reg)
+ if (ctx->num_pieces > 0)
+ {
+ int i;
+ long offset = 0;
+ bfd_byte *contents;
+
+ retval = allocate_value (SYMBOL_TYPE (var));
+ contents = VALUE_CONTENTS_RAW (retval);
+ for (i = 0; i < ctx->num_pieces; i++)
+ {
+ struct dwarf_expr_piece *p = &ctx->pieces[i];
+ if (p->in_reg)
+ {
+ bfd_byte regval[MAX_REGISTER_SIZE];
+ int gdb_regnum = DWARF2_REG_TO_REGNUM (p->value);
+ get_frame_register (frame, gdb_regnum, regval);
+ memcpy (contents + offset, regval, p->size);
+ }
+ else /* In memory? */
+ {
+ read_memory (p->value, contents + offset, p->size);
+ }
+ offset += p->size;
+ }
+ }
+ else if (ctx->in_reg)
{
int regnum = DWARF2_REG_TO_REGNUM (result);
retval = value_from_register (SYMBOL_TYPE (var), regnum, frame);
@@ -245,6 +271,8 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
VALUE_ADDRESS (retval) = result;
}
+ set_value_initialized (retval, ctx->initialized);
+
free_dwarf_expr_context (ctx);
return retval;
@@ -322,6 +350,17 @@ dwarf2_loc_desc_needs_frame (unsigned char *data, unsigned short size)
in_reg = ctx->in_reg;
+ if (ctx->num_pieces > 0)
+ {
+ int i;
+
+ /* If the location has several pieces, and any of them are in
+ registers, then we will need a frame to fetch them from. */
+ for (i = 0; i < ctx->num_pieces; i++)
+ if (ctx->pieces[i].in_reg)
+ in_reg = 1;
+ }
+
free_dwarf_expr_context (ctx);
return baton.needs_frame || in_reg;
diff --git a/contrib/gdb/gdb/dwarf2read.c b/contrib/gdb/gdb/dwarf2read.c
index 852172b..d3dd560 100644
--- a/contrib/gdb/gdb/dwarf2read.c
+++ b/contrib/gdb/gdb/dwarf2read.c
@@ -7110,6 +7110,8 @@ dwarf_stack_op_name (unsigned op)
/* GNU extensions. */
case DW_OP_GNU_push_tls_address:
return "DW_OP_GNU_push_tls_address";
+ case DW_OP_GNU_uninit:
+ return "DW_OP_GNU_uninit";
default:
return "OP_<unknown>";
}
@@ -7634,6 +7636,9 @@ decode_locdesc (struct dwarf_block *blk, struct dwarf2_cu *cu)
dwarf2_complex_location_expr_complaint ();
break;
+ case DW_OP_GNU_uninit:
+ break;
+
default:
complaint (&symfile_complaints, "unsupported stack op: '%s'",
dwarf_stack_op_name (op));
diff --git a/contrib/gdb/gdb/value.h b/contrib/gdb/gdb/value.h
index a01b438..9e547a3 100644
--- a/contrib/gdb/gdb/value.h
+++ b/contrib/gdb/gdb/value.h
@@ -165,6 +165,9 @@ struct value
/* The BFD section associated with this value. */
asection *bfd_section;
+ /* If value is a variable, is it initialized or not. */
+ int initialized;
+
/* Actual contents of the value. For use of this value; setting
it uses the stuff above. Not valid if lazy is nonzero.
Target byte-order. We force it to be aligned properly for any
diff --git a/contrib/gdb/gdb/values.c b/contrib/gdb/gdb/values.c
index 87baf21..32e4b25 100644
--- a/contrib/gdb/gdb/values.c
+++ b/contrib/gdb/gdb/values.c
@@ -101,6 +101,7 @@ allocate_value (struct type *type)
VALUE_EMBEDDED_OFFSET (val) = 0;
VALUE_POINTED_TO_OFFSET (val) = 0;
val->modifiable = 1;
+ val->initialized = 1; /* Default to initialized. */
return val;
}
@@ -1311,6 +1312,22 @@ using_struct_return (struct type *value_type, int gcc_p)
== RETURN_VALUE_STRUCT_CONVENTION);
}
+/* Set the initialized field in a value struct. */
+
+void
+set_value_initialized (struct value *val, int status)
+{
+ val->initialized = status;
+}
+
+/* Return the initialized field in a value struct. */
+
+int
+value_initialized (struct value *val)
+{
+ return val->initialized;
+}
+
void
_initialize_values (void)
{
diff --git a/contrib/ipfilter/tools/ipf.c b/contrib/ipfilter/tools/ipf.c
index dd60142..08cfb0a 100644
--- a/contrib/ipfilter/tools/ipf.c
+++ b/contrib/ipfilter/tools/ipf.c
@@ -296,7 +296,7 @@ static void packetlogon(opt)
printf("set log flag: nomatch\n");
change = 1;
}
- if (strstr(opt, "block") || index(opt, 'd')) {
+ if (strstr(opt, "block") || strchr(opt, 'd')) {
flag |= FF_LOGBLOCK;
if (opts & OPT_VERBOSE)
printf("set log flag: block\n");
diff --git a/contrib/ldns/drill/config.h b/contrib/ldns/drill/config.h
index 74b1e40..f012625 100644
--- a/contrib/ldns/drill/config.h
+++ b/contrib/ldns/drill/config.h
@@ -122,7 +122,7 @@
#define PACKAGE_NAME "ldns"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "ldns 1.6.16"
+#define PACKAGE_STRING "ldns 1.6.17"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libdns"
@@ -131,7 +131,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.6.16"
+#define PACKAGE_VERSION "1.6.17"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
diff --git a/contrib/ldns/drill/drill.1 b/contrib/ldns/drill/drill.1
index 971b73a..cfbde05 100644
--- a/contrib/ldns/drill/drill.1
+++ b/contrib/ldns/drill/drill.1
@@ -83,6 +83,11 @@ Chase the signature(s) of 'name' to a known key or as high up in
the tree as possible.
.TP
+\fB\-I \fIIPv4 or IPv6 address\fR
+Source address to query from. The source address has to be present
+on an interface of the host running drill.
+
+.TP
\fB\-V \fIlevel\fR
Be more verbose. Set level to 5 to see the actual query that is sent.
@@ -217,6 +222,12 @@ specify named base64 tsig key, and optional an algorithm (defaults to hmac-md5.s
\fB\-z \fR
don't randomize the nameserver list before sending queries.
+.SH "EXIT STATUS"
+The exit status is 0 if the looked up answer is secure and trusted,
+or insecure.
+The exit status is not 0 if the looked up answer is untrusted or bogus,
+or an error occurred while performing the lookup.
+
.SH "FILES"
.TP
/etc/unbound/root.key
diff --git a/contrib/ldns/freebsd-configure.sh b/contrib/ldns/freebsd-configure.sh
new file mode 100755
index 0000000..3ad6446
--- /dev/null
+++ b/contrib/ldns/freebsd-configure.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+set -e
+
+ldns=$(dirname $(realpath $0))
+cd $ldns
+
+libtoolize --copy
+autoheader
+autoconf
+./configure --prefix= --exec-prefix=/usr
+
+cd $ldns/drill
+autoheader
+autoconf
+./configure --prefix= --exec-prefix=/usr
diff --git a/contrib/ldns/packaging/fedora/ldns.spec b/contrib/ldns/packaging/fedora/ldns.spec
new file mode 100644
index 0000000..6658d01
--- /dev/null
+++ b/contrib/ldns/packaging/fedora/ldns.spec
@@ -0,0 +1,212 @@
+%{?!with_python: %global with_python 1}
+
+%if %{with_python}
+%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
+%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
+%endif
+
+Summary: Lowlevel DNS(SEC) library with API
+Name: ldns
+Version: 1.6.13
+Release: 1%{?dist}
+License: BSD
+Url: http://www.nlnetlabs.nl/%{name}/
+Source: http://www.nlnetlabs.nl/downloads/%{%name}/%{name}-%{version}.tar.gz
+Group: System Environment/Libraries
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildRequires: perl, libpcap-devel, openssl-devel , gcc-c++, doxygen,
+# Only needed for builds from svn snapshot
+# BuildRequires: libtool, autoconf, automake
+
+%if %{with_python}
+BuildRequires: python-devel, swig
+%endif
+
+%description
+ldns is a library with the aim to simplify DNS programing in C. All
+lowlevel DNS/DNSSEC operations are supported. We also define a higher
+level API which allows a programmer to (for instance) create or sign
+packets.
+
+%package devel
+Summary: Development package that includes the ldns header files
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+The devel package contains the ldns library and the include files
+
+%if %{with_python}
+%package python
+Summary: Python extensions for ldns
+Group: Applications/System
+Requires: %{name} = %{version}-%{release}
+
+%description python
+Python extensions for ldns
+%endif
+
+%prep
+%setup -q
+# To built svn snapshots
+# rm config.guess config.sub ltmain.sh
+# aclocal
+# libtoolize -c
+# autoreconf
+
+%build
+%configure --disable-rpath --disable-static --with-sha2 --disable-gost \
+%if %{with_python}
+ --with-pyldns
+%endif
+
+(cd drill ; %configure --disable-rpath --disable-static --with-sha2 --disable-gost --with-ldns=%{buildroot}/lib/ )
+(cd examples ; %configure --disable-rpath --disable-static --with-sha2 --disable-gost --with-ldns=%{buildroot}/lib/ )
+
+make %{?_smp_mflags}
+( cd drill ; make %{?_smp_mflags} )
+( cd examples ; make %{?_smp_mflags} )
+make %{?_smp_mflags} doc
+
+%install
+rm -rf %{buildroot}
+
+make DESTDIR=%{buildroot} INSTALL="%{__install} -p" install
+make DESTDIR=%{buildroot} INSTALL="%{__install} -p" install-doc
+
+# don't install another set of man pages from doc/
+rm -rf doc/man/
+
+# don't package building script for install-doc in doc section
+rm doc/doxyparse.pl
+
+# remove .la files
+rm -rf %{buildroot}%{_libdir}/*.la %{buildroot}%{python_sitearch}/*.la
+(cd drill ; make DESTDIR=%{buildroot} install)
+(cd examples; make DESTDIR=%{buildroot} install)
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(-,root,root)
+%{_libdir}/libldns*so.*
+%{_bindir}/drill
+%{_bindir}/ldnsd
+%{_bindir}/ldns-chaos
+%{_bindir}/ldns-compare-zones
+%{_bindir}/ldns-[d-z]*
+%doc README LICENSE
+%{_mandir}/*/*
+
+%files devel
+%defattr(-,root,root,-)
+%{_libdir}/libldns*so
+%{_bindir}/ldns-config
+%dir %{_includedir}/ldns
+%{_includedir}/ldns/*.h
+%doc doc Changelog README
+
+%if %{with_python}
+%files python
+%defattr(-,root,root)
+%{python_sitearch}/*
+%endif
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%changelog
+* Thu Sep 22 2011 Paul Wouters <paul@xelerance.com> - 1.6.11-1
+- Updated to 1.6.11
+- Cleanup spec for
+- Python goes into sitearch, not sitelib
+
+* Wed Jun 08 2011 Paul Wouters <paul@xelerance.com> - 1.6.10-1
+- Updated to 1.6.10
+- commented out build dependancies for svn snapshots
+
+* Sun Mar 27 2011 Paul Wouters <paul@xelerance.com> - 1.6.9-1
+- Updated to 1.6.9
+
+* Mon Jan 24 2011 Paul Wouters <paul@xelerance.com> - 1.6.8-1
+- Updated to 1.6.8
+
+* Thu Aug 26 2010 Paul Wouters <paul@xelerance.com> - 1.6.6-1
+- Upgraded to 1.6.6
+
+* Mon Apr 26 2010 Paul Wouters <paul@xelerance.com> - 1.6.4-4
+- Disable a debug line that was added to find the LOC issue that causes
+ unexpected output for automated tools using ldns-read-zone
+
+* Thu Feb 11 2010 Paul Wouters <paul@xelerance.com> - 1.6.4-3
+- Applied fix svn 3186 for LOC record parsing
+
+* Fri Jan 22 2010 Paul Wouters <paul@xelerance.com> - 1.6.4-2
+- libtool on EL-5 does not take --install as argument
+
+* Fri Jan 22 2010 Paul Wouters <paul@xelerance.com> - 1.6.4-1
+- Upgraded to 1.6.4
+- Added ldns-python sub package
+- Patch for installing ldns-python files
+- Patch for rpath in ldns-python
+
+* Sun Aug 16 2009 Paul Wouters <paul@xelerance.com> - 1.6.1-2
+- Bump version, sources file was not updated.
+
+* Sun Aug 16 2009 Paul Wouters <paul@xelerance.com> - 1.6.1-1
+-Updated to 1.6.1
+
+* Sat Jul 11 2009 Paul Wouters <paul@xelerance.com> - 1.6.0-1
+- Updated to 1.6.0
+
+* Thu Apr 16 2009 Paul Wouters <paul@xelerance.com> - 1.5.1-2
+- Memory management bug when generating a sha256 key, see:
+ https://bugzilla.redhat.com/show_bug.cgi?id=493953
+
+* Fri Feb 13 2009 Paul Wouters <paul@xelerance.com> - 1.5.1-1
+- Upgrade to 1.5.1 (1.5.0 was a dud release)
+
+* Sun Nov 9 2008 Paul Wouters <paul@xelerance.com> - 1.4.0-2
+- libldns.so was missing in files section.
+
+* Sun Nov 9 2008 Paul Wouters <paul@xelerance.com> - 1.4.0-1
+- Updated to 1.4.0
+- enable SHA2 functionality
+
+* Mon Jun 30 2008 Paul Wouters <paul@xelerance.com> - 1.3.0-1
+- Updated to latest release
+
+* Thu Nov 29 2007 Paul Wouters <paul@xelerance.com> - 1.2.2-1
+- Upgraded to 1.2.2.
+
+* Mon Sep 11 2006 Paul Wouters <paul@xelerance.com> 1.0.1-4
+- Commented out 1.1.0 make targets, put make 1.0.1 targets.
+
+* Mon Sep 11 2006 Paul Wouters <paul@xelerance.com> 1.0.1-3
+- Fixed changelog typo in date
+- Rebuild requested for PT_GNU_HASH support from gcc
+- Did not upgrade to 1.1.0 due to compile issues on x86_64
+
+* Fri Jan 6 2006 Paul Wouters <paul@xelerance.com> 1.0.1-1
+- Upgraded to 1.0.1. Removed temporary clean hack from spec file.
+
+* Sun Dec 18 2005 Paul Wouters <paul@xelerance.com> 1.0.0-8
+- Cannot use make clean because there are no Makefiles. Use hardcoded rm.
+
+* Sun Dec 18 2005 Paul Wouters <paul@xelerance.com> 1.0.0-7
+- Patched 'make clean' target to get rid of object files shipped with 1.0.0
+
+* Sun Dec 13 2005 Paul Wouters <paul@xelerance.com> 1.0.0-6
+- added a make clean for 2.3.3 since .o files were left behind upstream,
+ causing failure on ppc platform
+
+* Sun Dec 11 2005 Tom "spot" Callaway <tcallawa@redhat.com> 1.0.0-5
+- minor cleanups
+
+* Wed Oct 5 2005 Paul Wouters <paul@xelerance.com> 0.70_1205
+- reworked for svn version
+
+* Sun Sep 25 2005 Paul Wouters <paul@xelerance.com> - 0.70
+- Initial version
diff --git a/contrib/ldns/packaging/ldns-config.1 b/contrib/ldns/packaging/ldns-config.1
new file mode 100644
index 0000000..c5a00a1
--- /dev/null
+++ b/contrib/ldns/packaging/ldns-config.1
@@ -0,0 +1,43 @@
+.TH ldns-config 1 "22 Sep 2011"
+.SH NAME
+ldns-config \- show compiler and linker flags for ldns usage.
+.SH SYNOPSIS
+.B ldns-config
+[
+.IR OPTIONS
+]
+
+.SH DESCRIPTION
+When writing programs using ldns, you have to tell the compiler
+where to look for include files and what libraries from which location
+to link to. \fBldns-config\fR can be used to find out what flags to use
+with the C compiler and the linker.
+
+.SH OPTIONS
+.TP
+\fB--cflags\fR
+Show the C compiler flags needed to compile with ldns
+
+.TP
+\fB--libs\fR
+Show the flags to be used to link with ldns
+
+.TP
+\fB--version\fR
+Shows the version of the installed ldns library
+
+.TP
+\fB--help\fR
+Show \fBldns-config\fR usage description
+
+.SH AUTHOR
+Written by the ldns team.
+
+.SH REPORTING BUGS
+Report bugs to <ldns-team@nlnetlabs.nl>.
+
+.SH COPYRIGHT
+Copyright (C) 2011 NLnet Labs. This is free software. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE.
+
diff --git a/contrib/ldns/packaging/ldns-config.in b/contrib/ldns/packaging/ldns-config.in
new file mode 100755
index 0000000..b728ba5
--- /dev/null
+++ b/contrib/ldns/packaging/ldns-config.in
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+prefix="@prefix@"
+exec_prefix="@exec_prefix@"
+VERSION="@PACKAGE_VERSION@"
+CFLAGS="@CFLAGS@"
+CPPFLAGS="@CPPFLAGS@ @LIBSSL_CPPFLAGS@ @PYTHON_CPPFLAGS@"
+LDFLAGS="@LDFLAGS@ @LIBSSL_LDFLAGS@ @PYTHON_LDFLAGS@"
+LIBS="@LIBS@ @LIBSSL_LIBS@"
+LIBDIR="@libdir@"
+INCLUDEDIR="@includedir@"
+
+for arg in $@
+do
+ if [ $arg = "--cflags" ]
+ then
+ echo "-I${INCLUDEDIR}"
+ fi
+ if [ $arg = "--libs" ]
+ then
+ echo "${LDFLAGS} -L${LIBDIR} ${LIBS} -lldns"
+ fi
+ if [ $arg = "-h" ] || [ $arg = "--help" ]
+ then
+ echo "Usage: $0 [--cflags] [--libs] [--version]"
+ fi
+ if [ $arg = "--version" ]
+ then
+ echo "${VERSION}"
+ fi
+done
diff --git a/contrib/ldns/packaging/libldns.pc.in b/contrib/ldns/packaging/libldns.pc.in
new file mode 100644
index 0000000..923b688
--- /dev/null
+++ b/contrib/ldns/packaging/libldns.pc.in
@@ -0,0 +1,13 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: ldns
+Description: Library for DNS programming
+URL: http://www.nlnetlabs.nl/projects/ldns
+Version: @PACKAGE_VERSION@
+Requires:
+Libs: -L${libdir} -lldns
+Libs.private: @LDFLAGS@
+Cflags: -I${includedir}
diff --git a/contrib/libarchive/libarchive/archive_read.c b/contrib/libarchive/libarchive/archive_read.c
index c7f4da1..9513729 100644
--- a/contrib/libarchive/libarchive/archive_read.c
+++ b/contrib/libarchive/libarchive/archive_read.c
@@ -1395,6 +1395,8 @@ __archive_read_filter_consume(struct archive_read_filter * filter,
{
int64_t skipped;
+ if (request < 0)
+ return ARCHIVE_FATAL;
if (request == 0)
return 0;
diff --git a/contrib/libarchive/libarchive/archive_read_support_format_cpio.c b/contrib/libarchive/libarchive/archive_read_support_format_cpio.c
index d9c77e4..8038af8 100644
--- a/contrib/libarchive/libarchive/archive_read_support_format_cpio.c
+++ b/contrib/libarchive/libarchive/archive_read_support_format_cpio.c
@@ -198,7 +198,7 @@ static int archive_read_format_cpio_read_data(struct archive_read *,
static int archive_read_format_cpio_read_header(struct archive_read *,
struct archive_entry *);
static int archive_read_format_cpio_skip(struct archive_read *);
-static int be4(const unsigned char *);
+static int64_t be4(const unsigned char *);
static int find_odc_header(struct archive_read *);
static int find_newc_header(struct archive_read *);
static int header_bin_be(struct archive_read *, struct cpio *,
@@ -213,7 +213,7 @@ static int header_afiol(struct archive_read *, struct cpio *,
struct archive_entry *, size_t *, size_t *);
static int is_octal(const char *, size_t);
static int is_hex(const char *, size_t);
-static int le4(const unsigned char *);
+static int64_t le4(const unsigned char *);
static int record_hardlink(struct archive_read *a,
struct cpio *cpio, struct archive_entry *entry);
@@ -864,8 +864,11 @@ header_bin_le(struct archive_read *a, struct cpio *cpio,
/* Read fixed-size portion of header. */
h = __archive_read_ahead(a, bin_header_size, NULL);
- if (h == NULL)
+ if (h == NULL) {
+ archive_set_error(&a->archive, 0,
+ "End of file trying to read next cpio header");
return (ARCHIVE_FATAL);
+ }
/* Parse out binary fields. */
header = (const unsigned char *)h;
@@ -900,8 +903,11 @@ header_bin_be(struct archive_read *a, struct cpio *cpio,
/* Read fixed-size portion of header. */
h = __archive_read_ahead(a, bin_header_size, NULL);
- if (h == NULL)
+ if (h == NULL) {
+ archive_set_error(&a->archive, 0,
+ "End of file trying to read next cpio header");
return (ARCHIVE_FATAL);
+ }
/* Parse out binary fields. */
header = (const unsigned char *)h;
@@ -944,17 +950,17 @@ archive_read_format_cpio_cleanup(struct archive_read *a)
return (ARCHIVE_OK);
}
-static int
+static int64_t
le4(const unsigned char *p)
{
- return ((p[0]<<16) + (p[1]<<24) + (p[2]<<0) + (p[3]<<8));
+ return ((p[0] << 16) + (((int64_t)p[1]) << 24) + (p[2] << 0) + (p[3] << 8));
}
-static int
+static int64_t
be4(const unsigned char *p)
{
- return ((p[0]<<24) + (p[1]<<16) + (p[2]<<8) + (p[3]));
+ return ((((int64_t)p[0]) << 24) + (p[1] << 16) + (p[2] << 8) + (p[3]));
}
/*
diff --git a/contrib/libxo/Makefile.am b/contrib/libxo/Makefile.am
index 4ff2aad..1abfd5e 100644
--- a/contrib/libxo/Makefile.am
+++ b/contrib/libxo/Makefile.am
@@ -10,7 +10,7 @@
ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = libxo xo xolint tests doc
+SUBDIRS = libxo xo xolint xohtml tests doc
bin_SCRIPTS=libxo-config
dist_doc_DATA = Copyright
diff --git a/contrib/libxo/configure.ac b/contrib/libxo/configure.ac
index b2553b8..5491d57 100644
--- a/contrib/libxo/configure.ac
+++ b/contrib/libxo/configure.ac
@@ -12,7 +12,7 @@
#
AC_PREREQ(2.2)
-AC_INIT([libxo], [0.2.0], [phil@juniper.net])
+AC_INIT([libxo], [0.3.2], [phil@juniper.net])
AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability])
# Support silent build rules. Requires at least automake-1.11.
@@ -133,6 +133,14 @@ AC_ARG_ENABLE([debug],
AC_MSG_RESULT([$LIBXO_DEBUG])
AM_CONDITIONAL([LIBXO_DEBUG], [test "$LIBXO_DEBUG" != "no"])
+AC_MSG_CHECKING([whether to build with text-only rendering])
+AC_ARG_ENABLE([text-only],
+ [ --enable-text-only Turn on text-only rendering],
+ [LIBXO_TEXT_ONLY=yes; AC_DEFINE([LIBXO_TEXT_ONLY], [1], [Enable text-only rendering])],
+ [LIBXO_TEXT_ONLY=no])
+AC_MSG_RESULT([$LIBXO_TEXT_ONLY])
+AM_CONDITIONAL([LIBXO_TEXT_ONLY], [test "$LIBXO_TEXT_ONLY" != "no"])
+
AC_CHECK_LIB([m], [lrint])
AM_CONDITIONAL([HAVE_LIBM], [test "$HAVE_LIBM" != "no"])
@@ -233,6 +241,7 @@ AC_CONFIG_FILES([
libxo/xoversion.h
xo/Makefile
xolint/Makefile
+ xohtml/Makefile
packaging/libxo.pc
doc/Makefile
tests/Makefile
@@ -253,6 +262,7 @@ AC_MSG_NOTICE([summary of build options:
bindir: ${XO_BINDIR}
includedir: ${XO_INCLUDEDIR}
share dir: ${XO_SHAREDIR}
+ oxtradoc dir: ${SLAX_OXTRADOCDIR}
compiler: ${CC} (${HAVE_GCC:-no})
compiler flags: ${CFLAGS}
@@ -262,4 +272,5 @@ AC_MSG_NOTICE([summary of build options:
debug: ${LIBXO_DEBUG:-no}
printf-like: ${HAVE_PRINTFLIKE:-no}
libxo-options: ${LIBXO_OPTS:-no}
+ text-only: ${LIBXO_TEXT_ONLY:-no}
])
diff --git a/contrib/libxo/doc/libxo.txt b/contrib/libxo/doc/libxo.txt
index 31aec53..81a40b6 100644
--- a/contrib/libxo/doc/libxo.txt
+++ b/contrib/libxo/doc/libxo.txt
@@ -134,7 +134,7 @@ A single libxo function call in source code is all that's required:
<host>my-box</host>
<domain>example.com</domain>
JSON:
- "host": my-box",
+ "host": "my-box",
"domain": "example.com"
For brevity, the HTML output is emitted.
@@ -228,17 +228,17 @@ data, including data type, description, and an XPath location.
<div class="line">
<div class="data" data-tag="blocks">36</div>
<div class="padding"> </div>
- <div class="data data-tag="path">./src</div>
+ <div class="data" data-tag="path">./src</div>
</div>
<div class="line">
<div class="data" data-tag="blocks">40</div>
<div class="padding"> </div>
- <div class="data data-tag="path">./bin</div>
+ <div class="data" data-tag="path">./bin</div>
</div>
<div class="line">
<div class="data" data-tag="blocks">90</div>
<div class="padding"> </div>
- <div class="data data-tag="path">./</div>
+ <div class="data" data-tag="path">./</div>
</div>
** Format Strings @format-strings@
@@ -285,6 +285,7 @@ content. The roles are listed below; only one role is permitted:
|---+--------------+-------------------------------------------------|
| M | Name | Description |
|---+--------------+-------------------------------------------------|
+| C | color/effect | Field has color and effect controls |
| D | decoration | Field is non-text (e.g., colon, comma) |
| E | error | Field is an error message |
| L | label | Field is text that prefixes a value |
@@ -298,6 +299,56 @@ content. The roles are listed below; only one role is permitted:
| ] | stop anchor | End a section of anchored variable-width text |
|---+--------------+-------------------------------------------------|
+**** The Color Role ({C:})
+
+Colors and effects control how text values are displayed; they are
+used for display styles (TEXT and HTML). The color content can be
+either static, when placed directly within the field descriptor, or a
+printf-style format descriptor can be used, if preceded by a slash ("/"):
+
+ xo_emit("{C:bold}{Lwc:Cost}{:cost/%u}{C:reset}\n", cost);
+ xo_emit("{C:/fg-%s,bg-%s}{Lwc:Cost}{:cost/%u}{C:reset}\n",
+ fg_color, bg_color, cost);
+
+The content should be a comma-separated list of zero or more colors or
+display effects. Colors and effects remain in effect until
+modified by other "C" roles. If the content is empty, the "reset"
+action is performed.
+
+|---------------+-------------------------------------------------|
+| Name | Description |
+|---------------+-------------------------------------------------|
+| bg-XXXXX | Change background color |
+| bold | Start bold text effect |
+| fg-XXXXX | Change foreground color |
+| inverse | Start inverse (aka reverse) text effect |
+| no-bold | Stop bold text effect |
+| no-inverse | Stop inverse (aka reverse) text effect |
+| no-underline | Stop underline text effect |
+| normal | Reset effects (only) |
+| reset | Reset colors and effects (restore defaults) |
+| underline | Start underline text effect |
+|---------------+-------------------------------------------------|
+
+The following color names are supported:
+
+|---------------|
+| Name |
+|---------------|
+| black |
+| blue |
+| cyan |
+| default |
+| green |
+| magenta |
+| red |
+| white |
+| yellow |
+|---------------|
+
+Color names are prefixed with either "fg-" or "bg-" to change the
+foreground and background colors, respectively.
+
**** The Decoration Role ({D:})
Decorations are typically punctuation marks such as colons,
@@ -1404,9 +1455,21 @@ functions like xo_failure, xo_warn, xo_err, etc. The program name is
initialized by xo_parse_args, but subsequent calls to xo_set_program
can override this value.
+ xo_set_program(argv[0]);
+
Note that the value is not copied, so the memory passed to
xo_set_program (and xo_parse_args) must be maintained by the caller.
+*** xo_set_version
+
+The xo_set_version function records a version number to be emitted as
+part of the data for encoding styles (XML and JSON). This version
+number is suitable for tracking changes in the content, allowing a
+user of the data to discern which version of the data model is in use.
+
+ void xo_set_version (const char *version);
+ void xo_set_version_h (xo_handle_t *xop, const char *version);
+
*** Field Information (xo_info_t) @info@
HTML data can include additional information in attributes that
@@ -1705,6 +1768,32 @@ The "-V" option does not report errors, but prints a complete list of
all field names, sorted alphabetically. The output can help spot
inconsistencies and spelling errors.
+* xohtml
+
+xohtml is a tool for turning the output of libxo-enabled commands into
+html files suitable for display in modern HTML web browsers. It can
+be used to test and debug HTML output, as well as to make the user
+ache to escape the world of 70s terminal devices.
+
+xohtml is given a command, either on the command line or via the "-c"
+option. If not command is given, standard input is used. The
+command's output is wrapped in HTML tags, with references to
+supporting CSS and Javascript files, and written to standard output or
+the file given in the "-f" option. The "-b" option can be used to
+provide an alternative base path for the support files.
+
+|--------------+---------------------------------------------------|
+| Option | Meaning |
+|--------------+---------------------------------------------------|
+| -b <base> | Base path for finding css/javascript files |
+| -c <command> | Command to execute |
+| -f <file> | Output file name |
+|--------------+---------------------------------------------------|
+
+The "-c" option takes a full command with arguments, including
+any libxo options needed to generate html ("--libxo=html"). This
+value must be quoted if it consists of multiple tokens.
+
* FAQs
This section contains the set of questions that users typically ask,
diff --git a/contrib/libxo/libxo/Makefile.am b/contrib/libxo/libxo/Makefile.am
index 3303e94..0047b63 100644
--- a/contrib/libxo/libxo/Makefile.am
+++ b/contrib/libxo/libxo/Makefile.am
@@ -38,12 +38,15 @@ man_MANS = \
xo_no_setlocale.3 \
xo_open_container.3 \
xo_open_list.3 \
+ xo_open_marker.3 \
xo_parse_args.3 \
xo_set_allocator.3 \
xo_set_flags.3 \
xo_set_info.3 \
xo_set_options.3 \
xo_set_style.3 \
+ xo_set_version.3 \
xo_set_writer.3
-EXTRA_DIST =
+EXTRA_DIST = ${man_MANS}
+
diff --git a/contrib/libxo/libxo/libxo.c b/contrib/libxo/libxo/libxo.c
index e9d05ce..4fd18fd 100644
--- a/contrib/libxo/libxo/libxo.c
+++ b/contrib/libxo/libxo/libxo.c
@@ -121,6 +121,50 @@ typedef struct xo_stack_s {
char *xs_keys; /* XPath predicate for any key fields */
} xo_stack_t;
+/* "colors" refers to fancy ansi codes */
+#define XO_COL_DEFAULT 0
+#define XO_COL_BLACK 1
+#define XO_COL_RED 2
+#define XO_COL_GREEN 3
+#define XO_COL_YELLOW 4
+#define XO_COL_BLUE 5
+#define XO_COL_MAGENTA 6
+#define XO_COL_CYAN 7
+#define XO_COL_WHITE 8
+
+#define XO_NUM_COLORS 9
+
+/* "effects" refers to fancy ansi codes */
+/*
+ * Yes, there's no blink. We're civilized. We like users. Blink
+ * isn't something one does to someone you like. Friends don't let
+ * friends use blink. On friends. You know what I mean. Blink is
+ * like, well, it's like bursting into show tunes at a funeral. It's
+ * just not done. Not something anyone wants. And on those rare
+ * instances where it might actually be appropriate, it's still wrong.
+ * It's likely done my the wrong person for the wrong reason. Just
+ * like blink. And if I implemented blink, I'd be like a funeral
+ * director who adds "Would you like us to burst into show tunes?" on
+ * the list of questions asking while making funeral arrangements.
+ * It's formalizing wrongness in the wrong way. And we're just too
+ * civilized to do that. Hhhmph!
+ */
+#define XO_EFF_RESET (1<<0)
+#define XO_EFF_NORMAL (1<<1)
+#define XO_EFF_BOLD (1<<2)
+#define XO_EFF_UNDERLINE (1<<3)
+#define XO_EFF_INVERSE (1<<4)
+
+#define XO_EFF_CLEAR_BITS XO_EFF_RESET
+
+typedef uint8_t xo_effect_t;
+typedef uint8_t xo_color_t;
+typedef struct xo_colors_s {
+ xo_effect_t xoc_effects; /* Current effect set */
+ xo_color_t xoc_col_fg; /* Foreground color */
+ xo_color_t xoc_col_bg; /* Background color */
+} xo_colors_t;
+
/*
* xo_handle_t: this is the principle data structure for libxo.
* It's used as a store for state, options, and content.
@@ -136,7 +180,6 @@ struct xo_handle_s {
xo_formatter_t xo_formatter; /* Custom formating function */
xo_checkpointer_t xo_checkpointer; /* Custom formating support function */
void *xo_opaque; /* Opaque data for write function */
- FILE *xo_fp; /* XXX File pointer */
xo_buffer_t xo_data; /* Output data */
xo_buffer_t xo_fmt; /* Work area for building format strings */
xo_buffer_t xo_attrs; /* Work area for building XML attributes */
@@ -154,6 +197,11 @@ struct xo_handle_s {
int xo_anchor_min_width; /* Desired width of anchored text */
unsigned xo_units_offset; /* Start of units insertion point */
unsigned xo_columns; /* Columns emitted during this xo_emit call */
+ uint8_t xo_color_map_fg[XO_NUM_COLORS]; /* Foreground color mappings */
+ uint8_t xo_color_map_bg[XO_NUM_COLORS]; /* Background color mappings */
+ xo_colors_t xo_colors; /* Current color and effect values */
+ xo_buffer_t xo_color_buf; /* HTML: buffer of colors and effects */
+ char *xo_version; /* Version string */
};
/* Flags for formatting functions */
@@ -161,7 +209,7 @@ typedef unsigned long xo_xff_flags_t;
#define XFF_COLON (1<<0) /* Append a ":" */
#define XFF_COMMA (1<<1) /* Append a "," iff there's more output */
#define XFF_WS (1<<2) /* Append a blank */
-#define XFF_ENCODE_ONLY (1<<3) /* Only emit for encoding formats (xml and json) */
+#define XFF_ENCODE_ONLY (1<<3) /* Only emit for encoding formats (xml, json) */
#define XFF_QUOTE (1<<4) /* Force quotes */
#define XFF_NOQUOTE (1<<5) /* Force no quotes */
@@ -277,6 +325,24 @@ static void
xo_anchor_clear (xo_handle_t *xop);
/*
+ * xo_style is used to retrieve the current style. When we're built
+ * for "text only" mode, we use this function to drive the removal
+ * of most of the code in libxo. We return a constant and the compiler
+ * happily removes the non-text code that is not longer executed. This
+ * trims our code nicely without needing to trampel perfectly readable
+ * code with ifdefs.
+ */
+static inline unsigned short
+xo_style (xo_handle_t *xop UNUSED)
+{
+#ifdef LIBXO_TEXT_ONLY
+ return XO_STYLE_TEXT;
+#else /* LIBXO_TEXT_ONLY */
+ return xop->xo_style;
+#endif /* LIBXO_TEXT_ONLY */
+}
+
+/*
* Callback to write data to a FILE pointer
*/
static int
@@ -321,6 +387,24 @@ xo_buf_init (xo_buffer_t *xbp)
}
/*
+ * Reset the buffer to empty
+ */
+static void
+xo_buf_reset (xo_buffer_t *xbp)
+{
+ xbp->xb_curp = xbp->xb_bufp;
+}
+
+/*
+ * Reset the buffer to empty
+ */
+static int
+xo_buf_is_empty (xo_buffer_t *xbp)
+{
+ return (xbp->xb_curp == xbp->xb_bufp);
+}
+
+/*
* Initialize the contents of an xo_buffer_t.
*/
static void
@@ -363,8 +447,8 @@ xo_no_setlocale (void)
/*
* We need to decide if stdout is line buffered (_IOLBF). Lacking a
* standard way to decide this (e.g. getlinebuf()), we have configure
- * look to find __flbf, which glibc supported. If not, we'll rely
- * on isatty, with the assumption that terminals are the only thing
+ * look to find __flbf, which glibc supported. If not, we'll rely on
+ * isatty, with the assumption that terminals are the only thing
* that's line buffered. We _could_ test for "steam._flags & _IOLBF",
* which is all __flbf does, but that's even tackier. Like a
* bedazzled Elvis outfit on an ugly lap dog sort of tacky. Not
@@ -399,6 +483,13 @@ xo_init_handle (xo_handle_t *xop)
xop->xo_flags |= XOF_FLUSH_LINE;
/*
+ * We only want to do color output on terminals, but we only want
+ * to do this if the user has asked for color.
+ */
+ if ((xop->xo_flags & XOF_COLOR_ALLOWED) && isatty(1))
+ xop->xo_flags |= XOF_COLOR;
+
+ /*
* We need to initialize the locale, which isn't really pretty.
* Libraries should depend on their caller to set up the
* environment. But we really can't count on the caller to do
@@ -497,7 +588,7 @@ xo_default (xo_handle_t *xop)
/*
* Return the number of spaces we should be indenting. If
- * we are pretty-printing, theis is indent * indent_by.
+ * we are pretty-printing, this is indent * indent_by.
*/
static int
xo_indent (xo_handle_t *xop)
@@ -647,6 +738,21 @@ xo_buf_append (xo_buffer_t *xbp, const char *str, int len)
xbp->xb_curp += len;
}
+/*
+ * Append the given NUL-terminated string to the given buffer
+ */
+static void
+xo_buf_append_str (xo_buffer_t *xbp, const char *str)
+{
+ int len = strlen(str);
+
+ if (!xo_buf_has_room(xbp, len))
+ return;
+
+ memcpy(xbp->xb_curp, str, len);
+ xbp->xb_curp += len;
+}
+
static void
xo_buf_escape (xo_handle_t *xop, xo_buffer_t *xbp,
const char *str, int len, xo_xff_flags_t flags)
@@ -656,7 +762,7 @@ xo_buf_escape (xo_handle_t *xop, xo_buffer_t *xbp,
memcpy(xbp->xb_curp, str, len);
- switch (xop->xo_style) {
+ switch (xo_style(xop)) {
case XO_STYLE_XML:
case XO_STYLE_HTML:
len = xo_escape_xml(xbp, len, (flags & XFF_ATTR));
@@ -711,7 +817,7 @@ xo_vsnprintf (xo_handle_t *xop, xo_buffer_t *xbp, const char *fmt, va_list vap)
else
rc = vsnprintf(xbp->xb_curp, left, fmt, va_local);
- if (rc > xbp->xb_size) {
+ if (rc >= left) {
if (!xo_buf_has_room(xbp, rc)) {
va_end(va_local);
return -1;
@@ -721,7 +827,7 @@ xo_vsnprintf (xo_handle_t *xop, xo_buffer_t *xbp, const char *fmt, va_list vap)
* After we call vsnprintf(), the stage of vap is not defined.
* We need to copy it before we pass. Then we have to do our
* own logic below to move it along. This is because the
- * implementation can have va_list be a point (bsd) or a
+ * implementation can have va_list be a pointer (bsd) or a
* structure (macosx) or anything in between.
*/
@@ -730,7 +836,7 @@ xo_vsnprintf (xo_handle_t *xop, xo_buffer_t *xbp, const char *fmt, va_list vap)
left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
if (xop->xo_formatter)
- xop->xo_formatter(xop, xbp->xb_curp, left, fmt, va_local);
+ rc = xop->xo_formatter(xop, xbp->xb_curp, left, fmt, va_local);
else
rc = vsnprintf(xbp->xb_curp, left, fmt, va_local);
}
@@ -1219,7 +1325,7 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap)
int need_nl = (fmt[strlen(fmt) - 1] != '\n');
- switch (xop->xo_style) {
+ switch (xo_style(xop)) {
case XO_STYLE_XML:
xbp = &xop->xo_data;
if (xop->xo_flags & XOF_PRETTY)
@@ -1431,6 +1537,10 @@ xo_destroy (xo_handle_t *xop_arg)
xo_buf_cleanup(&xop->xo_fmt);
xo_buf_cleanup(&xop->xo_predicate);
xo_buf_cleanup(&xop->xo_attrs);
+ xo_buf_cleanup(&xop->xo_color_buf);
+
+ if (xop->xo_version)
+ xo_free(xop->xo_version);
if (xop_arg == NULL) {
bzero(&xo_default_handle, sizeof(xo_default_handle));
@@ -1457,7 +1567,7 @@ xo_style_t
xo_get_style (xo_handle_t *xop)
{
xop = xo_default(xop);
- return xop->xo_style;
+ return xo_style(xop);
}
static int
@@ -1492,6 +1602,8 @@ xo_name_to_flag (const char *name)
return XOF_INFO;
if (strcmp(name, "warn-xml") == 0)
return XOF_WARN_XML;
+ if (strcmp(name, "color") == 0)
+ return XOF_COLOR_ALLOWED;
if (strcmp(name, "columns") == 0)
return XOF_COLUMNS;
if (strcmp(name, "dtrt") == 0)
@@ -1547,6 +1659,11 @@ xo_set_options (xo_handle_t *xop, const char *input)
xop = xo_default(xop);
+#ifdef LIBXO_COLOR_ON_BY_DEFAULT
+ /* If the installer used --enable-color-on-by-default, then we allow it */
+ xop->xo_flags |= XOF_COLOR_ALLOWED;
+#endif /* LIBXO_COLOR_ON_BY_DEFAULT */
+
/*
* We support a simpler, old-school style of giving option
* also, using a single character for each option. It's
@@ -1557,6 +1674,10 @@ xo_set_options (xo_handle_t *xop, const char *input)
for (input++ ; *input; input++) {
switch (*input) {
+ case 'c':
+ xop->xo_flags |= XOF_COLOR_ALLOWED;
+ break;
+
case 'f':
xop->xo_flags |= XOF_FLUSH;
break;
@@ -1634,6 +1755,11 @@ xo_set_options (xo_handle_t *xop, const char *input)
if (vp)
*vp++ = '\0';
+ if (strcmp("colors", cp) == 0) {
+ /* XXX Look for colors=red-blue+green-yellow */
+ continue;
+ }
+
new_style = xo_name_to_style(cp);
if (new_style >= 0) {
if (style >= 0)
@@ -1645,7 +1771,9 @@ xo_set_options (xo_handle_t *xop, const char *input)
if (new_flag != 0)
xop->xo_flags |= new_flag;
else {
- if (strcmp(cp, "indent") == 0) {
+ if (strcmp(cp, "no-color") == 0) {
+ xop->xo_flags &= ~XOF_COLOR_ALLOWED;
+ } else if (strcmp(cp, "indent") == 0) {
xop->xo_indent_by = atoi(vp);
} else {
xo_warnx("unknown option: '%s'", cp);
@@ -1801,7 +1929,7 @@ xo_line_ensure_open (xo_handle_t *xop, xo_xff_flags_t flags UNUSED)
if (xop->xo_flags & XOF_DIV_OPEN)
return;
- if (xop->xo_style != XO_STYLE_HTML)
+ if (xo_style(xop) != XO_STYLE_HTML)
return;
xop->xo_flags |= XOF_DIV_OPEN;
@@ -1819,7 +1947,7 @@ xo_line_close (xo_handle_t *xop)
{
static char div_close[] = "</div>";
- switch (xop->xo_style) {
+ switch (xo_style(xop)) {
case XO_STYLE_HTML:
if (!(xop->xo_flags & XOF_DIV_OPEN))
xo_line_ensure_open(xop, 0);
@@ -1976,7 +2104,7 @@ xo_format_string_direct (xo_handle_t *xop, xo_buffer_t *xbp,
if (width < 0)
width = iswcntrl(wc) ? 0 : 1;
- if (xop->xo_style == XO_STYLE_TEXT || xop->xo_style == XO_STYLE_HTML) {
+ if (xo_style(xop) == XO_STYLE_TEXT || xo_style(xop) == XO_STYLE_HTML) {
if (max > 0 && cols + width > max)
break;
}
@@ -1985,7 +2113,7 @@ xo_format_string_direct (xo_handle_t *xop, xo_buffer_t *xbp,
case XF_ENC_UTF8:
/* Output in UTF-8 needs to be escaped, based on the style */
- switch (xop->xo_style) {
+ switch (xo_style(xop)) {
case XO_STYLE_XML:
case XO_STYLE_HTML:
if (wc == '<')
@@ -2071,7 +2199,7 @@ xo_format_string (xo_handle_t *xop, xo_buffer_t *xbp, xo_xff_flags_t flags,
wchar_t *wcp = NULL;
int len, cols = 0, rc = 0;
int off = xbp->xb_curp - xbp->xb_bufp, off2;
- int need_enc = (xop->xo_style == XO_STYLE_TEXT)
+ int need_enc = (xo_style(xop) == XO_STYLE_TEXT)
? XF_ENC_LOCALE : XF_ENC_UTF8;
if (xo_check_conversion(xop, xfp->xf_enc, need_enc))
@@ -2185,7 +2313,7 @@ static void
xo_data_append_content (xo_handle_t *xop, const char *str, int len)
{
int cols;
- int need_enc = (xop->xo_style == XO_STYLE_TEXT)
+ int need_enc = (xo_style(xop) == XO_STYLE_TEXT)
? XF_ENC_LOCALE : XF_ENC_UTF8;
cols = xo_format_string_direct(xop, &xop->xo_data, XFF_UNESCAPE,
@@ -2246,9 +2374,9 @@ xo_format_data (xo_handle_t *xop, xo_buffer_t *xbp,
xo_format_t xf;
const char *cp, *ep, *sp, *xp = NULL;
int rc, cols;
- int style = (flags & XFF_XML) ? XO_STYLE_XML : xop->xo_style;
+ int style = (flags & XFF_XML) ? XO_STYLE_XML : xo_style(xop);
unsigned make_output = !(flags & XFF_NO_OUTPUT);
- int need_enc = (xop->xo_style == XO_STYLE_TEXT)
+ int need_enc = (xo_style(xop) == XO_STYLE_TEXT)
? XF_ENC_LOCALE : XF_ENC_UTF8;
if (xbp == NULL)
@@ -2310,11 +2438,11 @@ xo_format_data (xo_handle_t *xop, xo_buffer_t *xbp,
/* Hidden fields are only visible to JSON and XML */
if (xop->xo_flags & XFF_ENCODE_ONLY) {
if (style != XO_STYLE_XML
- && xop->xo_style != XO_STYLE_JSON)
+ && xo_style(xop) != XO_STYLE_JSON)
xf.xf_skip = 1;
} else if (xop->xo_flags & XFF_DISPLAY_ONLY) {
if (style != XO_STYLE_TEXT
- && xop->xo_style != XO_STYLE_HTML)
+ && xo_style(xop) != XO_STYLE_HTML)
xf.xf_skip = 1;
}
@@ -2420,8 +2548,8 @@ xo_format_data (xo_handle_t *xop, xo_buffer_t *xbp,
rc = xo_format_string(xop, xbp, flags, &xf);
if ((flags & XFF_TRIM_WS)
- && (xop->xo_style == XO_STYLE_XML
- || xop->xo_style == XO_STYLE_JSON))
+ && (xo_style(xop) == XO_STYLE_XML
+ || xo_style(xop) == XO_STYLE_JSON))
rc = xo_trim_ws(xbp, rc);
} else {
@@ -2567,6 +2695,20 @@ xo_fix_encoding (xo_handle_t *xop UNUSED, char *encoding)
}
static void
+xo_color_append_html (xo_handle_t *xop)
+{
+ /*
+ * If the color buffer has content, we add it now. It's already
+ * prebuilt and ready, since we want to add it to every <div>.
+ */
+ if (!xo_buf_is_empty(&xop->xo_color_buf)) {
+ xo_buffer_t *xbp = &xop->xo_color_buf;
+
+ xo_data_append(xop, xbp->xb_bufp, xbp->xb_curp - xbp->xb_bufp);
+ }
+}
+
+static void
xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
const char *name, int nlen,
const char *value, int vlen,
@@ -2663,6 +2805,16 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
xo_data_append(xop, div_start, sizeof(div_start) - 1);
xo_data_append(xop, class, strlen(class));
+ /*
+ * If the color buffer has content, we add it now. It's already
+ * prebuilt and ready, since we want to add it to every <div>.
+ */
+ if (!xo_buf_is_empty(&xop->xo_color_buf)) {
+ xo_buffer_t *xbp = &xop->xo_color_buf;
+
+ xo_data_append(xop, xbp->xb_bufp, xbp->xb_curp - xbp->xb_bufp);
+ }
+
if (name) {
xo_data_append(xop, div_tag, sizeof(div_tag) - 1);
xo_data_escape(xop, name, nlen);
@@ -2753,7 +2905,7 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
static void
xo_format_text (xo_handle_t *xop, const char *str, int len)
{
- switch (xop->xo_style) {
+ switch (xo_style(xop)) {
case XO_STYLE_TEXT:
xo_buf_append_locale(xop, &xop->xo_data, str, len);
break;
@@ -2768,7 +2920,8 @@ static void
xo_format_title (xo_handle_t *xop, const char *str, int len,
const char *fmt, int flen)
{
- static char div_open[] = "<div class=\"title\">";
+ static char div_open[] = "<div class=\"title";
+ static char div_middle[] = "\">";
static char div_close[] = "</div>";
if (flen == 0) {
@@ -2776,7 +2929,7 @@ xo_format_title (xo_handle_t *xop, const char *str, int len,
flen = 2;
}
- switch (xop->xo_style) {
+ switch (xo_style(xop)) {
case XO_STYLE_XML:
case XO_STYLE_JSON:
/*
@@ -2794,12 +2947,14 @@ xo_format_title (xo_handle_t *xop, const char *str, int len,
int rc;
int need_enc = XF_ENC_LOCALE;
- if (xop->xo_style == XO_STYLE_HTML) {
+ if (xo_style(xop) == XO_STYLE_HTML) {
need_enc = XF_ENC_UTF8;
xo_line_ensure_open(xop, 0);
if (xop->xo_flags & XOF_PRETTY)
xo_buf_indent(xop, xop->xo_indent_by);
xo_buf_append(&xop->xo_data, div_open, sizeof(div_open) - 1);
+ xo_color_append_html(xop);
+ xo_buf_append(&xop->xo_data, div_middle, sizeof(div_middle) - 1);
}
start = xbp->xb_curp - xbp->xb_bufp; /* Reset start */
@@ -2862,7 +3017,7 @@ xo_format_title (xo_handle_t *xop, const char *str, int len,
}
/* If we're styling HTML, then we need to escape it */
- if (xop->xo_style == XO_STYLE_HTML) {
+ if (xo_style(xop) == XO_STYLE_HTML) {
rc = xo_escape_xml(xbp, rc, 0);
}
@@ -2870,7 +3025,7 @@ xo_format_title (xo_handle_t *xop, const char *str, int len,
xbp->xb_curp += rc;
move_along:
- if (xop->xo_style == XO_STYLE_HTML) {
+ if (xo_style(xop) == XO_STYLE_HTML) {
xo_data_append(xop, div_close, sizeof(div_close) - 1);
if (xop->xo_flags & XOF_PRETTY)
xo_data_append(xop, "\n", 1);
@@ -2978,7 +3133,7 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
}
}
- switch (xop->xo_style) {
+ switch (xo_style(xop)) {
case XO_STYLE_TEXT:
if (flags & XFF_ENCODE_ONLY)
flags |= XFF_NO_OUTPUT;
@@ -3103,7 +3258,9 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
}
if (flags & XFF_LEAF_LIST) {
- if (first && pretty)
+ if (!first && pretty)
+ xo_data_append(xop, "\n", 1);
+ if (pretty)
xo_buf_indent(xop, -1);
} else {
if (pretty)
@@ -3122,10 +3279,10 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
xbp->xb_bufp[off] = '_';
}
xo_data_append(xop, "\":", 2);
+ if (pretty)
+ xo_data_append(xop, " ", 1);
}
- if (pretty)
- xo_data_append(xop, " ", 1);
if (quote)
xo_data_append(xop, "\"", 1);
@@ -3142,7 +3299,7 @@ xo_format_content (xo_handle_t *xop, const char *class_name,
const char *xml_tag, int display_only,
const char *str, int len, const char *fmt, int flen)
{
- switch (xop->xo_style) {
+ switch (xo_style(xop)) {
case XO_STYLE_TEXT:
if (len) {
xo_data_append_content(xop, str, len);
@@ -3195,6 +3352,362 @@ xo_format_content (xo_handle_t *xop, const char *class_name,
}
}
+static const char *xo_color_names[] = {
+ "default", /* XO_COL_DEFAULT */
+ "black", /* XO_COL_BLACK */
+ "red", /* XO_CLOR_RED */
+ "green", /* XO_COL_GREEN */
+ "yellow", /* XO_COL_YELLOW */
+ "blue", /* XO_COL_BLUE */
+ "magenta", /* XO_COL_MAGENTA */
+ "cyan", /* XO_COL_CYAN */
+ "white", /* XO_COL_WHITE */
+ NULL
+};
+
+static int
+xo_color_find (const char *str)
+{
+ int i;
+
+ for (i = 0; xo_color_names[i]; i++) {
+ if (strcmp(xo_color_names[i], str) == 0)
+ return i;
+ }
+
+ return -1;
+}
+
+static const char *xo_effect_names[] = {
+ "reset", /* XO_EFF_RESET */
+ "normal", /* XO_EFF_NORMAL */
+ "bold", /* XO_EFF_BOLD */
+ "underline", /* XO_EFF_UNDERLINE */
+ "inverse", /* XO_EFF_INVERSE */
+ NULL
+};
+
+static const char *xo_effect_on_codes[] = {
+ "0", /* XO_EFF_RESET */
+ "0", /* XO_EFF_NORMAL */
+ "1", /* XO_EFF_BOLD */
+ "4", /* XO_EFF_UNDERLINE */
+ "7", /* XO_EFF_INVERSE */
+ NULL
+};
+
+#if 0
+/*
+ * See comment below re: joy of terminal standards. These can
+ * be use by just adding:
+ * if (newp->xoc_effects & bit)
+ * code = xo_effect_on_codes[i];
+ * + else
+ * + code = xo_effect_off_codes[i];
+ * in xo_color_handle_text.
+ */
+static const char *xo_effect_off_codes[] = {
+ "0", /* XO_EFF_RESET */
+ "0", /* XO_EFF_NORMAL */
+ "21", /* XO_EFF_BOLD */
+ "24", /* XO_EFF_UNDERLINE */
+ "27", /* XO_EFF_INVERSE */
+ NULL
+};
+#endif /* 0 */
+
+static int
+xo_effect_find (const char *str)
+{
+ int i;
+
+ for (i = 0; xo_effect_names[i]; i++) {
+ if (strcmp(xo_effect_names[i], str) == 0)
+ return i;
+ }
+
+ return -1;
+}
+
+static void
+xo_colors_parse (xo_handle_t *xop, xo_colors_t *xocp, char *str)
+{
+#ifdef LIBXO_TEXT_ONLY
+ return;
+#endif /* LIBXO_TEXT_ONLY */
+
+ char *cp, *ep, *np, *xp;
+ int len = strlen(str);
+ int rc;
+
+ /*
+ * Possible tokens: colors, bg-colors, effects, no-effects, "reset".
+ */
+ for (cp = str, ep = cp + len - 1; cp && cp < ep; cp = np) {
+ /* Trim leading whitespace */
+ while (isspace((int) *cp))
+ cp += 1;
+
+ np = strchr(cp, ',');
+ if (np)
+ *np++ = '\0';
+
+ /* Trim trailing whitespace */
+ xp = cp + strlen(cp) - 1;
+ while (isspace(*xp) && xp > cp)
+ *xp-- = '\0';
+
+ if (cp[0] == 'f' && cp[1] == 'g' && cp[2] == '-') {
+ rc = xo_color_find(cp + 3);
+ if (rc < 0)
+ goto unknown;
+
+ xocp->xoc_col_fg = rc;
+
+ } else if (cp[0] == 'b' && cp[1] == 'g' && cp[2] == '-') {
+ rc = xo_color_find(cp + 3);
+ if (rc < 0)
+ goto unknown;
+ xocp->xoc_col_bg = rc;
+
+ } else if (cp[0] == 'n' && cp[1] == 'o' && cp[2] == '-') {
+ rc = xo_effect_find(cp + 3);
+ if (rc < 0)
+ goto unknown;
+ xocp->xoc_effects &= ~(1 << rc);
+
+ } else {
+ rc = xo_effect_find(cp);
+ if (rc < 0)
+ goto unknown;
+ xocp->xoc_effects |= 1 << rc;
+
+ switch (1 << rc) {
+ case XO_EFF_RESET:
+ xocp->xoc_col_fg = xocp->xoc_col_bg = 0;
+ /* Note: not "|=" since we want to wipe out the old value */
+ xocp->xoc_effects = XO_EFF_RESET;
+ break;
+
+ case XO_EFF_NORMAL:
+ xocp->xoc_effects &= ~(XO_EFF_BOLD | XO_EFF_UNDERLINE
+ | XO_EFF_INVERSE | XO_EFF_NORMAL);
+ break;
+ }
+ }
+ continue;
+
+ unknown:
+ if (xop->xo_flags & XOF_WARN)
+ xo_failure(xop, "unknown color/effect string detected: '%s'", cp);
+ }
+}
+
+static inline int
+xo_colors_enabled (xo_handle_t *xop UNUSED)
+{
+#ifdef LIBXO_TEXT_ONLY
+ return 0;
+#else /* LIBXO_TEXT_ONLY */
+ return ((xop->xo_flags & XOF_COLOR) ? 1 : 0);
+#endif /* LIBXO_TEXT_ONLY */
+}
+
+static void
+xo_colors_handle_text (xo_handle_t *xop UNUSED, xo_colors_t *newp)
+{
+ char buf[BUFSIZ];
+ char *cp = buf, *ep = buf + sizeof(buf);
+ unsigned i, bit;
+ xo_colors_t *oldp = &xop->xo_colors;
+ const char *code = NULL;
+
+ /*
+ * Start the buffer with an escape. We don't want to add the '['
+ * now, since we let xo_effect_text_add unconditionally add the ';'.
+ * We'll replace the first ';' with a '[' when we're done.
+ */
+ *cp++ = 0x1b; /* Escape */
+
+ /*
+ * Terminals were designed back in the age before "certainty" was
+ * invented, when standards were more what you'd call "guidelines"
+ * than actual rules. Anyway we can't depend on them to operate
+ * correctly. So when display attributes are changed, we punt,
+ * reseting them all and turning back on the ones we want to keep.
+ * Longer, but should be completely reliable. Savvy?
+ */
+ if (oldp->xoc_effects != (newp->xoc_effects & oldp->xoc_effects)) {
+ newp->xoc_effects |= XO_EFF_RESET;
+ oldp->xoc_effects = 0;
+ }
+
+ for (i = 0, bit = 1; xo_effect_names[i]; i++, bit <<= 1) {
+ if ((newp->xoc_effects & bit) == (oldp->xoc_effects & bit))
+ continue;
+
+ if (newp->xoc_effects & bit)
+ code = xo_effect_on_codes[i];
+
+ cp += snprintf(cp, ep - cp, ";%s", code);
+ if (cp >= ep)
+ return; /* Should not occur */
+
+ if (bit == XO_EFF_RESET) {
+ /* Mark up the old value so we can detect current values as new */
+ oldp->xoc_effects = 0;
+ oldp->xoc_col_fg = oldp->xoc_col_bg = XO_COL_DEFAULT;
+ }
+ }
+
+ if (newp->xoc_col_fg != oldp->xoc_col_fg) {
+ cp += snprintf(cp, ep - cp, ";3%u",
+ (newp->xoc_col_fg != XO_COL_DEFAULT)
+ ? newp->xoc_col_fg - 1 : 9);
+ }
+
+ if (newp->xoc_col_bg != oldp->xoc_col_bg) {
+ cp += snprintf(cp, ep - cp, ";4%u",
+ (newp->xoc_col_bg != XO_COL_DEFAULT)
+ ? newp->xoc_col_bg - 1 : 9);
+ }
+
+ if (cp - buf != 1 && cp < ep - 3) {
+ buf[1] = '['; /* Overwrite leading ';' */
+ *cp++ = 'm';
+ *cp = '\0';
+ xo_buf_append(&xop->xo_data, buf, cp - buf);
+ }
+}
+
+static void
+xo_colors_handle_html (xo_handle_t *xop, xo_colors_t *newp)
+{
+ xo_colors_t *oldp = &xop->xo_colors;
+
+ /*
+ * HTML colors are mostly trivial: fill in xo_color_buf with
+ * a set of class tags representing the colors and effects.
+ */
+
+ /* If nothing changed, then do nothing */
+ if (oldp->xoc_effects == newp->xoc_effects
+ && oldp->xoc_col_fg == newp->xoc_col_fg
+ && oldp->xoc_col_bg == newp->xoc_col_bg)
+ return;
+
+ unsigned i, bit;
+ xo_buffer_t *xbp = &xop->xo_color_buf;
+
+ xo_buf_reset(xbp); /* We rebuild content after each change */
+
+ for (i = 0, bit = 1; xo_effect_names[i]; i++, bit <<= 1) {
+ if (!(newp->xoc_effects & bit))
+ continue;
+
+ xo_buf_append_str(xbp, " effect-");
+ xo_buf_append_str(xbp, xo_effect_names[i]);
+ }
+
+ const char *fg = NULL;
+ const char *bg = NULL;
+
+ if (newp->xoc_col_fg != XO_COL_DEFAULT)
+ fg = xo_color_names[newp->xoc_col_fg];
+ if (newp->xoc_col_bg != XO_COL_DEFAULT)
+ bg = xo_color_names[newp->xoc_col_bg];
+
+ if (newp->xoc_effects & XO_EFF_INVERSE) {
+ const char *tmp = fg;
+ fg = bg;
+ bg = tmp;
+ if (fg == NULL)
+ fg = "inverse";
+ if (bg == NULL)
+ bg = "inverse";
+
+ }
+
+ if (fg) {
+ xo_buf_append_str(xbp, " color-fg-");
+ xo_buf_append_str(xbp, fg);
+ }
+
+ if (bg) {
+ xo_buf_append_str(xbp, " color-bg-");
+ xo_buf_append_str(xbp, bg);
+ }
+}
+
+static void
+xo_format_colors (xo_handle_t *xop, const char *str, int len,
+ const char *fmt, int flen)
+{
+ xo_buffer_t xb;
+
+ /* If the string is static and we've in an encoding style, bail */
+ if (len != 0
+ && (xo_style(xop) == XO_STYLE_XML || xo_style(xop) == XO_STYLE_JSON))
+ return;
+
+ xo_buf_init(&xb);
+
+ if (len)
+ xo_buf_append(&xb, str, len);
+ else if (flen)
+ xo_format_data(xop, &xb, fmt, flen, 0);
+ else
+ xo_buf_append(&xb, "reset", 6); /* Default if empty */
+
+ if (xo_colors_enabled(xop)) {
+ switch (xo_style(xop)) {
+ case XO_STYLE_TEXT:
+ case XO_STYLE_HTML:
+ xo_buf_append(&xb, "", 1);
+
+ xo_colors_t xoc = xop->xo_colors;
+ xo_colors_parse(xop, &xoc, xb.xb_bufp);
+
+ if (xo_style(xop) == XO_STYLE_TEXT) {
+ /*
+ * Text mode means emitting the colors as ANSI character
+ * codes. This will allow people who like colors to have
+ * colors. The issue is, of course conflicting with the
+ * user's perfectly reasonable color scheme. Which leads
+ * to the hell of LSCOLORS, where even app need to have
+ * customization hooks for adjusting colors. Instead we
+ * provide a simpler-but-still-annoying answer where one
+ * can map colors to other colors.
+ */
+ xo_colors_handle_text(xop, &xoc);
+ xoc.xoc_effects &= ~XO_EFF_RESET; /* After handling it */
+
+ } else {
+ /*
+ * HTML output is wrapped in divs, so the color information
+ * must appear in every div until cleared. Most pathetic.
+ * Most unavoidable.
+ */
+ xoc.xoc_effects &= ~XO_EFF_RESET; /* Before handling effects */
+ xo_colors_handle_html(xop, &xoc);
+ }
+
+ xop->xo_colors = xoc;
+ break;
+
+ case XO_STYLE_XML:
+ case XO_STYLE_JSON:
+ /*
+ * Nothing to do; we did all that work just to clear the stack of
+ * formatting arguments.
+ */
+ break;
+ }
+ }
+
+ xo_buf_cleanup(&xb);
+}
+
static void
xo_format_units (xo_handle_t *xop, const char *str, int len,
const char *fmt, int flen)
@@ -3211,9 +3724,9 @@ xo_format_units (xo_handle_t *xop, const char *str, int len,
int start = xop->xo_units_offset;
int stop = xbp->xb_curp - xbp->xb_bufp;
- if (xop->xo_style == XO_STYLE_XML)
+ if (xo_style(xop) == XO_STYLE_XML)
xo_buf_append(xbp, units_start_xml, sizeof(units_start_xml) - 1);
- else if (xop->xo_style == XO_STYLE_HTML)
+ else if (xo_style(xop) == XO_STYLE_HTML)
xo_buf_append(xbp, units_start_html, sizeof(units_start_html) - 1);
else
return;
@@ -3295,7 +3808,7 @@ static void
xo_anchor_start (xo_handle_t *xop, const char *str, int len,
const char *fmt, int flen)
{
- if (xop->xo_style != XO_STYLE_TEXT && xop->xo_style != XO_STYLE_HTML)
+ if (xo_style(xop) != XO_STYLE_TEXT && xo_style(xop) != XO_STYLE_HTML)
return;
if (xop->xo_flags & XOF_ANCHOR)
@@ -3317,7 +3830,7 @@ static void
xo_anchor_stop (xo_handle_t *xop, const char *str, int len,
const char *fmt, int flen)
{
- if (xop->xo_style != XO_STYLE_TEXT && xop->xo_style != XO_STYLE_HTML)
+ if (xo_style(xop) != XO_STYLE_TEXT && xo_style(xop) != XO_STYLE_HTML)
return;
if (!(xop->xo_flags & XOF_ANCHOR)) {
@@ -3484,6 +3997,7 @@ xo_do_emit (xo_handle_t *xop, const char *fmt)
}
switch (*sp) {
+ case 'C':
case 'D':
case 'E':
case 'L':
@@ -3621,6 +4135,8 @@ xo_do_emit (xo_handle_t *xop, const char *fmt)
xo_anchor_start(xop, content, clen, format, flen);
else if (ftype == ']')
xo_anchor_stop(xop, content, clen, format, flen);
+ else if (ftype == 'C')
+ xo_format_colors(xop, content, clen, format, flen);
else if (clen || format) { /* Need either content or format */
if (format == NULL) {
@@ -3726,7 +4242,7 @@ xo_attr_hv (xo_handle_t *xop, const char *name, const char *fmt, va_list vap)
const int extra = 5; /* space, equals, quote, quote, and nul */
xop = xo_default(xop);
- if (xop->xo_style != XO_STYLE_XML)
+ if (xo_style(xop) != XO_STYLE_XML)
return 0;
int nlen = strlen(name);
@@ -3798,7 +4314,7 @@ static void
xo_depth_change (xo_handle_t *xop, const char *name,
int delta, int indent, xo_state_t state, xo_xsf_flags_t flags)
{
- if (xop->xo_style == XO_STYLE_HTML || xop->xo_style == XO_STYLE_TEXT)
+ if (xo_style(xop) == XO_STYLE_HTML || xo_style(xop) == XO_STYLE_TEXT)
indent = 0;
if (xop->xo_flags & XOF_DTRT)
@@ -3884,6 +4400,20 @@ xo_stack_flags (unsigned xflags)
return 0;
}
+static void
+xo_emit_top (xo_handle_t *xop, const char *ppn)
+{
+ xo_printf(xop, "%*s{%s", xo_indent(xop), "", ppn);
+ xop->xo_flags |= XOF_TOP_EMITTED;
+
+ if (xop->xo_version) {
+ xo_printf(xop, "%*s\"__version\": \"%s\", %s",
+ xo_indent(xop), "", xop->xo_version, ppn);
+ xo_free(xop->xo_version);
+ xop->xo_version = NULL;
+ }
+}
+
static int
xo_do_open_container (xo_handle_t *xop, xo_xof_flags_t flags, const char *name)
{
@@ -3898,7 +4428,7 @@ xo_do_open_container (xo_handle_t *xop, xo_xof_flags_t flags, const char *name)
flags |= xop->xo_flags; /* Pick up handle flags */
- switch (xop->xo_style) {
+ switch (xo_style(xop)) {
case XO_STYLE_XML:
rc = xo_printf(xop, "%*s<%s", xo_indent(xop), "", name);
@@ -3915,12 +4445,9 @@ xo_do_open_container (xo_handle_t *xop, xo_xof_flags_t flags, const char *name)
case XO_STYLE_JSON:
xo_stack_set_flags(xop);
- if (!(xop->xo_flags & XOF_NO_TOP)) {
- if (!(xop->xo_flags & XOF_TOP_EMITTED)) {
- xo_printf(xop, "%*s{%s", xo_indent(xop), "", ppn);
- xop->xo_flags |= XOF_TOP_EMITTED;
- }
- }
+ if (!(xop->xo_flags & XOF_NO_TOP)
+ && !(xop->xo_flags & XOF_TOP_EMITTED))
+ xo_emit_top(xop, ppn);
if (xop->xo_stack[xop->xo_depth].xs_flags & XSF_NOT_FIRST)
pre_nl = (xop->xo_flags & XOF_PRETTY) ? ",\n" : ", ";
@@ -3992,7 +4519,7 @@ xo_do_close_container (xo_handle_t *xop, const char *name)
}
}
- switch (xop->xo_style) {
+ switch (xo_style(xop)) {
case XO_STYLE_XML:
xo_depth_change(xop, name, -1, -1, XSS_CLOSE_CONTAINER, 0);
rc = xo_printf(xop, "%*s</%s>%s", xo_indent(xop), "", name, ppn);
@@ -4048,17 +4575,14 @@ xo_do_open_list (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name)
xop = xo_default(xop);
- if (xop->xo_style == XO_STYLE_JSON) {
+ if (xo_style(xop) == XO_STYLE_JSON) {
const char *ppn = (xop->xo_flags & XOF_PRETTY) ? "\n" : "";
const char *pre_nl = "";
indent = 1;
- if (!(xop->xo_flags & XOF_NO_TOP)) {
- if (!(xop->xo_flags & XOF_TOP_EMITTED)) {
- xo_printf(xop, "%*s{%s", xo_indent(xop), "", ppn);
- xop->xo_flags |= XOF_TOP_EMITTED;
- }
- }
+ if (!(xop->xo_flags & XOF_NO_TOP)
+ && !(xop->xo_flags & XOF_TOP_EMITTED))
+ xo_emit_top(xop, ppn);
if (name == NULL) {
xo_failure(xop, "NULL passed for list name");
@@ -4133,7 +4657,7 @@ xo_do_close_list (xo_handle_t *xop, const char *name)
}
}
- if (xop->xo_style == XO_STYLE_JSON) {
+ if (xo_style(xop) == XO_STYLE_JSON) {
if (xop->xo_stack[xop->xo_depth].xs_flags & XSF_NOT_FIRST)
pre_nl = (xop->xo_flags & XOF_PRETTY) ? "\n" : "";
xop->xo_stack[xop->xo_depth].xs_flags |= XSF_NOT_FIRST;
@@ -4182,7 +4706,7 @@ xo_do_open_leaf_list (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name)
xop = xo_default(xop);
- if (xop->xo_style == XO_STYLE_JSON) {
+ if (xo_style(xop) == XO_STYLE_JSON) {
const char *ppn = (xop->xo_flags & XOF_PRETTY) ? "\n" : "";
const char *pre_nl = "";
@@ -4238,7 +4762,7 @@ xo_do_close_leaf_list (xo_handle_t *xop, const char *name)
}
}
- if (xop->xo_style == XO_STYLE_JSON) {
+ if (xo_style(xop) == XO_STYLE_JSON) {
if (xop->xo_stack[xop->xo_depth].xs_flags & XSF_NOT_FIRST)
pre_nl = (xop->xo_flags & XOF_PRETTY) ? "\n" : "";
xop->xo_stack[xop->xo_depth].xs_flags |= XSF_NOT_FIRST;
@@ -4271,7 +4795,7 @@ xo_do_open_instance (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name)
name = XO_FAILURE_NAME;
}
- switch (xop->xo_style) {
+ switch (xo_style(xop)) {
case XO_STYLE_XML:
rc = xo_printf(xop, "%*s<%s", xo_indent(xop), "", name);
@@ -4357,7 +4881,7 @@ xo_do_close_instance (xo_handle_t *xop, const char *name)
}
}
- switch (xop->xo_style) {
+ switch (xo_style(xop)) {
case XO_STYLE_XML:
xo_depth_change(xop, name, -1, -1, XSS_CLOSE_INSTANCE, 0);
rc = xo_printf(xop, "%*s</%s>%s", xo_indent(xop), "", name, ppn);
@@ -4639,8 +5163,8 @@ xo_transition (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name,
rc = xo_do_open_instance(xop, flags, name);
break;
- case XSS_TRANSITION(XSS_OPEN_CONTAINER, XSS_OPEN_INSTANCE):
case XSS_TRANSITION(XSS_INIT, XSS_OPEN_INSTANCE):
+ case XSS_TRANSITION(XSS_OPEN_CONTAINER, XSS_OPEN_INSTANCE):
rc = xo_do_open_list(xop, flags, name);
if (rc >= 0)
goto open_instance;
@@ -4673,6 +5197,8 @@ xo_transition (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name,
case XSS_TRANSITION(XSS_INIT, XSS_CLOSE_INSTANCE):
/* This one makes no sense; ignore it */
+ xo_failure(xop, "xo_close_instance ignored when called from "
+ "initial state ('%s')", name ?: "(unknown)");
break;
case XSS_TRANSITION(XSS_OPEN_CONTAINER, XSS_CLOSE_INSTANCE):
@@ -4715,6 +5241,8 @@ xo_transition (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name,
case XSS_TRANSITION(XSS_INIT, XSS_CLOSE_LEAF_LIST):
/* Makes no sense; ignore */
+ xo_failure(xop, "xo_close_leaf_list ignored when called from "
+ "initial state ('%s')", name ?: "(unknown)");
break;
case XSS_TRANSITION(XSS_OPEN_CONTAINER, XSS_CLOSE_LEAF_LIST):
@@ -4836,7 +5364,7 @@ xo_flush_h (xo_handle_t *xop)
xop = xo_default(xop);
- switch (xop->xo_style) {
+ switch (xo_style(xop)) {
case XO_STYLE_HTML:
if (xop->xo_flags & XOF_DIV_OPEN) {
xop->xo_flags &= ~XOF_DIV_OPEN;
@@ -4871,7 +5399,7 @@ xo_finish_h (xo_handle_t *xop)
if (!(xop->xo_flags & XOF_NO_CLOSE))
xo_do_close_all(xop, xop->xo_stack);
- switch (xop->xo_style) {
+ switch (xo_style(xop)) {
case XO_STYLE_JSON:
if (!(xop->xo_flags & XOF_NO_TOP)) {
if (xop->xo_flags & XOF_TOP_EMITTED)
@@ -4913,7 +5441,7 @@ xo_error_hv (xo_handle_t *xop, const char *fmt, va_list vap)
fmt = newfmt;
}
- switch (xop->xo_style) {
+ switch (xo_style(xop)) {
case XO_STYLE_TEXT:
vfprintf(stderr, fmt, vap);
break;
@@ -5052,6 +5580,41 @@ xo_set_program (const char *name)
xo_program = name;
}
+void
+xo_set_version_h (xo_handle_t *xop, const char *version UNUSED)
+{
+ xop = xo_default(xop);
+
+ if (version == NULL || strchr(version, '"') != NULL)
+ return;
+
+ switch (xo_style(xop)) {
+ case XO_STYLE_XML:
+ /* For XML, we record this as an attribute for the first tag */
+ xo_attr_h(xop, "__version", "%s", version);
+ break;
+
+ case XO_STYLE_JSON:
+ {
+ /*
+ * For XML, we record the version string in our handle, and emit
+ * it in xo_emit_top.
+ */
+ int len = strlen(version) + 1;
+ xop->xo_version = xo_realloc(NULL, len);
+ if (xop->xo_version)
+ memcpy(xop->xo_version, version, len);
+ }
+ break;
+ }
+}
+
+void
+xo_set_version (const char *version)
+{
+ xo_set_version_h(NULL, version);
+}
+
#ifdef UNIT_TEST
int
main (int argc, char **argv)
diff --git a/contrib/libxo/libxo/xo.h b/contrib/libxo/libxo/xo.h
index ea289f0..c065740 100644
--- a/contrib/libxo/libxo/xo.h
+++ b/contrib/libxo/libxo/xo.h
@@ -9,7 +9,7 @@
*/
/**
- * libxo provides a means of generating text, XML, and JSON output
+ * libxo provides a means of generating text, XML, JSON, and HTML output
* using a single set of function calls, maximizing the value of output
* while minimizing the cost/impact on the code.
*/
@@ -17,6 +17,27 @@
#ifndef INCLUDE_XO_H
#define INCLUDE_XO_H
+#include <sys/types.h>
+
+#ifdef __dead2
+#define NORETURN __dead2
+#else
+#define NORETURN
+#endif /* __dead2 */
+
+/*
+ * Normally we'd use the HAVE_PRINTFLIKE define triggered by the
+ * --enable-printflike option to configure, but we don't install
+ * our internal "xoconfig.h", and I'd rather not. Taking the
+ * coward's path, we'll turn it on inside a #if that allows
+ * others to turn it off where needed. Not ideal, but functional.
+ */
+#if !defined(NO_PRINTFLIKE) && !defined(__linux__)
+#define PRINTFLIKE(_x, _y) __printflike(_x, _y)
+#else
+#define PRINTFLIKE(_x, _y)
+#endif /* NO_PRINTFLIKE */
+
/** Formatting types */
typedef unsigned xo_style_t;
#define XO_STYLE_TEXT 0 /** Generate text output */
@@ -58,6 +79,8 @@ typedef unsigned long long xo_xof_flags_t;
#define XOF_FLUSH_LINE XOF_BIT(23) /** Flush after each newline */
#define XOF_NO_CLOSE XOF_BIT(24) /** xo_finish won't close open elements */
+#define XOF_COLOR_ALLOWED XOF_BIT(25) /** Allow color/effects to be enabled */
+#define XOF_COLOR XOF_BIT(26) /** Enable color and effects */
/*
* The xo_info_t structure provides a mapping between names and
@@ -260,64 +283,116 @@ void
xo_set_leading_xpath (xo_handle_t *xop, const char *path);
void
-xo_warn_hc (xo_handle_t *xop, int code, const char *fmt, ...);
+xo_warn_hc (xo_handle_t *xop, int code, const char *fmt, ...) PRINTFLIKE(3, 4);
void
-xo_warn_c (int code, const char *fmt, ...);
+xo_warn_c (int code, const char *fmt, ...) PRINTFLIKE(2, 3);
void
-xo_warn (const char *fmt, ...);
+xo_warn (const char *fmt, ...) PRINTFLIKE(1, 2);
void
-xo_warnx (const char *fmt, ...);
+xo_warnx (const char *fmt, ...) PRINTFLIKE(1, 2);
void
-xo_err (int eval, const char *fmt, ...) __dead2;
+xo_err (int eval, const char *fmt, ...) NORETURN PRINTFLIKE(2, 3);
void
-xo_errx (int eval, const char *fmt, ...) __dead2;
+xo_errx (int eval, const char *fmt, ...) NORETURN PRINTFLIKE(2, 3);
void
-xo_errc (int eval, int code, const char *fmt, ...) __dead2;
+xo_errc (int eval, int code, const char *fmt, ...) NORETURN PRINTFLIKE(3, 4);
void
xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap);
void
-xo_message_hc (xo_handle_t *xop, int code, const char *fmt, ...);
+xo_message_hc (xo_handle_t *xop, int code, const char *fmt, ...) PRINTFLIKE(3, 4);
void
-xo_message_c (int code, const char *fmt, ...);
+xo_message_c (int code, const char *fmt, ...) PRINTFLIKE(2, 3);
void
-xo_message (const char *fmt, ...);
+xo_message (const char *fmt, ...) PRINTFLIKE(1, 2);
void
xo_no_setlocale (void);
+/**
+ * @brief Lift libxo-specific arguments from a set of arguments
+ *
+ * libxo-enable programs typically use command line options to enable
+ * all the nifty-cool libxo features. xo_parse_args() makes this simple
+ * by pre-processing the command line arguments given to main(), handling
+ * and removing the libxo-specific ones, meaning anything starting with
+ * "--libxo". A full description of these arguments is in the base
+ * documentation.
+ * @param[in] argc Number of arguments (ala #main())
+ * @param[in] argc Array of argument strings (ala #main())
+ * @return New number of arguments, or -1 for failure.
+ */
int
xo_parse_args (int argc, char **argv);
-/*
+/**
* This is the "magic" number returned by libxo-supporting commands
* when passed the equally magic "--libxo-check" option. If you
- * return this, we can assume that since you know the magic handshake,
- * you'll happily handle future --libxo options and not do something
- * violent like reboot the box or create another hole in the ozone
- * layer.
+ * return this, we can (unsafely) assume that since you know the magic
+ * handshake, you'll happily handle future --libxo options and not do
+ * something violent like reboot the box or create another hole in the
+ * ozone layer.
*/
#define XO_HAS_LIBXO 121
-/*
- * externs for our version number strings
+/**
+ * externs for libxo's version number strings
*/
-extern const char xo_version[];
-extern const char xo_version_extra[];
+extern const char xo_version[]; /** Base version triple string */
+extern const char xo_version_extra[]; /** Extra version magic content */
+/**
+ * @brief Dump the internal stack of a libxo handle.
+ *
+ * This diagnostic function is something I will ask you to call from
+ * your program when you write to tell me libxo has gone bat-stink
+ * crazy and has discarded your list or container or content. Output
+ * content will be what we lovingly call "developer entertainment".
+ * @param[in] xop A valid libxo handle, or NULL for the default handle
+ */
void
xo_dump_stack (xo_handle_t *xop);
+/**
+ * @brief Recode the name of the program, suitable for error output.
+ *
+ * libxo will record the given name for use while generating error
+ * messages. The contents are not copied, so the value must continue
+ * to point to a valid memory location. This allows the caller to change
+ * the value, but requires the caller to manage the memory. Typically
+ * this is called with argv[0] from main().
+ * @param[in] name The name of the current application program
+ */
void
xo_set_program (const char *name);
+/**
+ * @brief Add a version string to the output, where possible.
+ *
+ * Adds a version number to the output, suitable for tracking
+ * changes in the content. This is only important for the "encoding"
+ * format styles (XML and JSON) and allows a user of the data to
+ * discern which version of the data model is in use.
+ * @param[in] version The version number, encoded as a string
+ */
+void
+xo_set_version (const char *version);
+
+/**
+ * #xo_set_version with a handle.
+ * @param[in] xop A valid libxo handle, or NULL for the default handle
+ * @param[in] version The version number, encoded as a string
+ */
+void
+xo_set_version_h (xo_handle_t *xop, const char *version);
+
#endif /* INCLUDE_XO_H */
diff --git a/contrib/libxo/libxo/xo_error.3 b/contrib/libxo/libxo/xo_error.3
index da91785..01431cb 100644
--- a/contrib/libxo/libxo/xo_error.3
+++ b/contrib/libxo/libxo/xo_error.3
@@ -28,12 +28,13 @@ The
argument is a string containing printf-style formatting
instructions that describe the remaining arguments.
.Pp
-When converting an application to libxo, one can replace
+When converting an application to
+.Nm libxo ,
+one can replace
.Em "fprintf(stderr,...)"
calls with
.Fn xo_error
calls.
-.Pp
.Sh ADDITIONAL DOCUMENTATION
Complete documentation can be found on github:
.Bd -literal -offset indent
@@ -53,7 +54,7 @@ is available at:
https://github.com/Juniper/libxo/releases
.Ed
.Sh SEE ALSO
-.Xr printf 3
+.Xr printf 3 ,
.Xr xo_emit 3
.Sh HISTORY
The
diff --git a/contrib/libxo/libxo/xo_format.5 b/contrib/libxo/libxo/xo_format.5
index b021b98..bce5dc5 100644
--- a/contrib/libxo/libxo/xo_format.5
+++ b/contrib/libxo/libxo/xo_format.5
@@ -74,7 +74,7 @@ function as an unsigned integer.
.Ed
.Pp
This single line of code can generate text ("In stock: 65\\n"), XML
-("<in-stock>65</in-stock>"), JSON ('"in-stock": 6'), or HTML (too
+("<in-stock>65</in-stock>"), JSON ('"in-stock": 65'), or HTML (too
lengthy to be listed here).
.Ss Modifier Roles
Modifiers are optional, and indicate the role and formatting of the
@@ -96,6 +96,55 @@ The roles are listed below; only one role is permitted:
.It \&] "stop anchor " "End a section of anchored variable-width text"
.El
.Pp
+.Ss The Color Role ({C:})
+Colors and effects control how text values are displayed; they are
+used for display styles (TEXT and HTML).
+The color content can be
+either static, when placed directly within the field descriptor, or a
+printf-style format descriptor can be used, if preceded by a slash ("/"):
+.Bd -literal -offset indent
+ xo_emit("{C:bold}{Lwc:Cost}{:cost/%u}{C:reset}\n", cost);
+ xo_emit("{C:/fg-%s,bg-%s}{Lwc:Cost}{:cost/%u}{C:reset}\n",
+ fg_color, bg_color, cost);
+.Ed
+.Pp
+The content should be a comma-separated list of zero or more colors or
+display effects.
+.Pp
+Colors and effects remain in effect until modified by other "C" roles.
+.Pp
+If the content is empty, the "reset" action is performed.
+.Pp
+.Bl -column "no-underline"
+.It Sy "Name Description"
+.It "bg-xxxxx " "Change background color"
+.It "bold " "Start bold text effect"
+.It "fg-xxxxx " "Change foreground color"
+.It "inverse " "Start inverse (aka reverse) text effect"
+.It "no-bold " "Stop bold text effect"
+.It "no-inverse " "Stop inverse (aka reverse) text effect"
+.It "no-underline " "Stop underline text effect"
+.It "normal " "Reset effects (only)"
+.It "reset " "Reset colors and effects (restore defaults)"
+.It "underline " "Start underline text effect"
+.El
+.Pp
+The following color names are supported:
+.Bl -column "no-underline"
+.It Sy "Name"
+.It black
+.It blue
+.It cyan
+.It default
+.It green
+.It magenta
+.It red
+.It white
+.It yellow
+.El
+.Pp
+Color names are prefixed with either "fg-" or "bg-" to change the
+foreground and background colors, respectively.
.Ss The Decoration Role ({D:})
Decorations are typically punctuation marks such as colons,
semi-colons, and commas used to decorate the text and make it simpler
@@ -230,6 +279,7 @@ content emitted for some output styles:
.It d "display " "Only emit field for display styles (text/HTML)"
.It e "encoding " "Only emit for encoding styles (XML/JSON)"
.It k "key " "Field is a key, suitable for XPath predicates"
+.It l "leaf " "Field is a leaf-list, a list of leaf values"
.It n "no-quotes " "Do not quote the field when using JSON style"
.It q "quotes " "Quote the field when using JSON style"
.It w "white space " "A blank ("" "") is appended after the label"
@@ -269,8 +319,8 @@ the display output styles, TEXT and HTML.
The display modifier is the opposite of the encoding modifier, and
they are often used to give to distinct views of the underlying data.
.Ss The Encoding Modifier ({e:})
-The display modifier indicated the field should only be generated for
-the display output styles, TEXT and HTML.
+The encoding modifier indicated the field should only be generated for
+the encoding output styles, such as JSON and XML.
.Bd -literal -offset indent
EXAMPLE:
xo_emit("{Lcw:Name}{:name} {e:id/%d}\\n", "phil", 1);
diff --git a/contrib/libxo/libxo/xo_open_container.3 b/contrib/libxo/libxo/xo_open_container.3
index 86412ca..3649556 100644
--- a/contrib/libxo/libxo/xo_open_container.3
+++ b/contrib/libxo/libxo/xo_open_container.3
@@ -11,8 +11,8 @@
.Dt LIBXO 3
.Os
.Sh NAME
-.Nm xo_emit
-.Nd emit formatted output based on format string and arguments
+.Nm xo_open_container
+.Nd open (and close) container constructs
.Sh LIBRARY
.Lb libxo
.Sh SYNOPSIS
@@ -48,7 +48,7 @@
.Fn xo_close_container_d "void"
.Sh DESCRIPTION
.Nm libxo
-represents to types of hierarchy:
+represents two types of hierarchy:
.Dq containers
and
.Dq lists .
@@ -72,7 +72,7 @@ or
.Fn xo_close_container_h
functions.
.Pp
-Each open call must have a matching close call.
+Each open call should have a matching close call.
If the
.Dv XOF_WARN
flag is set and the name given does not match the name of
diff --git a/contrib/libxo/libxo/xo_open_marker.3 b/contrib/libxo/libxo/xo_open_marker.3
new file mode 100644
index 0000000..d7a858c
--- /dev/null
+++ b/contrib/libxo/libxo/xo_open_marker.3
@@ -0,0 +1,138 @@
+.\" #
+.\" # Copyright (c) 2015, Juniper Networks, Inc.
+.\" # All rights reserved.
+.\" # This SOFTWARE is licensed under the LICENSE provided in the
+.\" # ../Copyright file. By downloading, installing, copying, or
+.\" # using the SOFTWARE, you agree to be bound by the terms of that
+.\" # LICENSE.
+.\" # Phil Shafer, January 2015
+.\"
+.Dd January 22, 2015
+.Dt LIBXO 3
+.Os
+.Sh NAME
+.Nm xo_open_marker
+.Nd prevent and allow closing of open constructs
+.Sh LIBRARY
+.Lb libxo
+.Sh SYNOPSIS
+.In libxo/xo.h
+.Sh NAME
+.Nm xo_open_marker
+.Nm xo_open_marker_h
+.Nm xo_close_marker
+.Nm xo_close_marker_h
+.Nd open and close markers
+.Sh LIBRARY
+.Lb libxo
+.Sh SYNOPSIS
+.Ft int
+.Fn xo_open_marker "const char *name"
+.Ft int
+.Fn xo_open_marker_h "xo_handle_t *handle" "const char *name"
+.Ft int
+.Fn xo_close_marker "const char *name"
+.Ft int
+.Fn xo_close_marker_h "xo_handle_t *handle" "const char *name"
+.Sh DESCRIPTION
+.Nm libxo
+represents hierarchy using two constructs:
+.Dq containers
+and
+.Dq lists .
+A marker can be used to affect how open constructs are closed, either
+by preventing their (implicit or explicit) closure or by forcing their
+closure.
+While a marker is open, no other open constructs can be closed.
+When a marker is closed, all constructs open since the marker was opened
+will be closed.
+A marker is used to "freeze" any open constructs.
+Calls to
+.Fn xo_close_*
+functions that would normally close them will be ignored, effectively
+blocking their closure.
+However when
+.Fn xo_close_marker
+is called, any containers, lists, or leaf-lists open since the
+matching
+.Fn xo_open_marker
+call will be close and the marker discarded.
+Markers use names which are not user-visible, allowing the caller to
+choose appropriate internal names.
+The marker has no value and is not emitted in any form.
+.Pp
+To open a marker, call
+.Fn xo_open_marker
+or
+.Fn xo_open_marker_h .
+The former uses the default handle and
+the latter accepts a specific handle.
+.Pp
+To close a marker, use the
+.Fn xo_close_marker
+or
+.Fn xo_close_marker_h
+functions.
+.Pp
+Each open call must have a matching close call.
+.Pp
+In this example, the
+.Fn xo_close_container
+call on line [1] will be ignored, since the open marker "outer"
+will prevent close of any open constructs that precede it.
+The
+.Fn xo_close_marker
+call on line [2] will close the "system" container, since it was
+opened after the "outer" marker.
+.Bd -literal -offset indent -compact
+ Example:
+
+ xo_open_container("top");
+ xo_open_marker("outer");
+ xo_open_container("system");
+ xo_emit("{:host-name/%s%s%s", hostname,
+ domainname ? "." : "", domainname ?: "");
+ xo_close_container("top"); /* [1] */
+ xo_close_marker("outer"); /* [2] */
+ xo_close_container("top");
+.Ed
+.Pp
+In this example, the code whiffles through a list of fish, calling a
+function to emit details about each fish. The marker "fish-guts" is
+used to ensure that any constructs opened by the function are closed
+properly.
+.Bd -literal -offset indent
+ for (i = 0; fish[i]; i++) {
+ xo_open_instance("fish");
+ xo_open_marker("fish-guts");
+ dump_fish_details(i);
+ xo_close_marker("fish-guts");
+ }
+.Ed
+.Sh ADDITIONAL DOCUMENTATION
+Complete documentation can be found on github:
+.Bd -literal -offset indent
+http://juniper.github.io/libxo/libxo-manual.html
+.Ed
+.Pp
+.Nm libxo
+lives on github as:
+.Bd -literal -offset indent
+https://github.com/Juniper/libxo
+.Ed
+.Pp
+The latest release of
+.Nm libxo
+is available at:
+.Bd -literal -offset indent
+https://github.com/Juniper/libxo/releases
+.Ed
+.Sh SEE ALSO
+.Xr xo_emit 3
+.Sh HISTORY
+The
+.Nm libxo
+library was added in
+.Fx 11.0 .
+.Sh AUTHOR
+Phil Shafer
diff --git a/contrib/libxo/libxo/xo_set_version.3 b/contrib/libxo/libxo/xo_set_version.3
new file mode 100644
index 0000000..888aef5
--- /dev/null
+++ b/contrib/libxo/libxo/xo_set_version.3
@@ -0,0 +1,59 @@
+.\" #
+.\" # Copyright (c) 2015, Juniper Networks, Inc.
+.\" # All rights reserved.
+.\" # This SOFTWARE is licensed under the LICENSE provided in the
+.\" # ../Copyright file. By downloading, installing, copying, or
+.\" # using the SOFTWARE, you agree to be bound by the terms of that
+.\" # LICENSE.
+.\" # Phil Shafer, July 2014
+.\"
+.Dd December 4, 2014
+.Dt LIBXO 3
+.Os
+.Sh NAME
+.Nm xo_set_version
+.Nd record content version information in encoded output
+.Sh LIBRARY
+.Lb libxo
+.Sh SYNOPSIS
+.In libxo/xo.h
+.Ft void
+.Fn xo_set_version "const char *version"
+.Ft void
+.Fn xo_set_version_h "xo_handle_t *xop" "const char *version"
+.Sh DESCRIPTION
+The
+.Nm xo_set_version
+function records a version number to be emitted as
+part of the data for encoding styles (XML and JSON).
+This version number is suitable for tracking changes in the content,
+allowing a user of the data to discern which version of the data model
+is in use.
+.Sh ADDITIONAL DOCUMENTATION
+Complete documentation can be found on github:
+.Bd -literal -offset indent
+http://juniper.github.io/libxo/libxo-manual.html
+.Ed
+.Pp
+.Nm libxo
+lives on github as:
+.Bd -literal -offset indent
+https://github.com/Juniper/libxo
+.Ed
+.Pp
+The latest release of
+.Nm libxo
+is available at:
+.Bd -literal -offset indent
+https://github.com/Juniper/libxo/releases
+.Ed
+.Sh SEE ALSO
+.Xr xo_emit 3 ,
+.Xr libxo 3
+.Sh HISTORY
+The
+.Nm libxo
+library was added in
+.Fx 11.0 .
+.Sh AUTHOR
+Phil Shafer
diff --git a/contrib/libxo/libxo/xoconfig.h b/contrib/libxo/libxo/xoconfig.h
index 4c596b4..dd1823e 100644
--- a/contrib/libxo/libxo/xoconfig.h
+++ b/contrib/libxo/libxo/xoconfig.h
@@ -150,8 +150,10 @@
/* Enable debugging */
/* #undef LIBXO_DEBUG */
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
+/* Enable text-only rendering */
+/* #undef LIBXO_TEXT_ONLY */
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/"
/* Name of package */
@@ -164,7 +166,7 @@
#define PACKAGE_NAME "libxo"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libxo 0.2.0"
+#define PACKAGE_STRING "libxo 0.3.2"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libxo"
@@ -173,7 +175,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
-#define PACKAGE_VERSION "0.2.0"
+#define PACKAGE_VERSION "0.3.2"
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
@@ -187,7 +189,7 @@
#define STDC_HEADERS 1
/* Version number of package */
-#define VERSION "0.2.0"
+#define VERSION "0.3.2"
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
diff --git a/contrib/libxo/libxo/xoconfig.h.in b/contrib/libxo/libxo/xoconfig.h.in
index 467f564..ad992f3 100644
--- a/contrib/libxo/libxo/xoconfig.h.in
+++ b/contrib/libxo/libxo/xoconfig.h.in
@@ -149,8 +149,10 @@
/* Enable debugging */
#undef LIBXO_DEBUG
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
- */
+/* Enable text-only rendering */
+#undef LIBXO_TEXT_ONLY
+
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
#undef LT_OBJDIR
/* Name of package */
diff --git a/contrib/libxo/libxo/xoversion.h b/contrib/libxo/libxo/xoversion.h
index 4c29e82..6a60596 100644
--- a/contrib/libxo/libxo/xoversion.h
+++ b/contrib/libxo/libxo/xoversion.h
@@ -18,17 +18,17 @@
/**
* The version string
*/
-#define LIBXO_VERSION "0.2.0"
+#define LIBXO_VERSION "0.3.2"
/**
* The version number
*/
-#define LIBXO_VERSION_NUMBER 2000
+#define LIBXO_VERSION_NUMBER 3002
/**
* The version number as a string
*/
-#define LIBXO_VERSION_STRING "2000"
+#define LIBXO_VERSION_STRING "3002"
/**
* The version number extra info as a string
diff --git a/contrib/libxo/m4/libtool.m4 b/contrib/libxo/m4/libtool.m4
index 44e0ecf..a3bc337 100644
--- a/contrib/libxo/m4/libtool.m4
+++ b/contrib/libxo/m4/libtool.m4
@@ -1,8 +1,6 @@
# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
#
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-# 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc.
# Written by Gordon Matzigkeit, 1996
#
# This file is free software; the Free Software Foundation gives
@@ -10,36 +8,30 @@
# modifications, as long as this notice is preserved.
m4_define([_LT_COPYING], [dnl
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
-# 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
-# Written by Gordon Matzigkeit, 1996
-#
-# This file is part of GNU Libtool.
-#
-# GNU Libtool 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.
+# Copyright (C) 2014 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions. There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool 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 of the License, or
+# (at your option) any later version.
#
-# As a special exception to the GNU General Public License,
-# if you distribute this file as part of a program or library that
-# is built using GNU Libtool, you may include this file under the
-# same distribution terms that you use for the rest of that program.
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program or library that is built
+# using GNU Libtool, you may include this file under the same
+# distribution terms that you use for the rest of that program.
#
-# GNU Libtool is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# GNU Libtool 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 Libtool; see the file COPYING. If not, a copy
-# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
-# obtained by writing to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
])
-# serial 57 LT_INIT
+# serial 58 LT_INIT
# LT_PREREQ(VERSION)
@@ -67,7 +59,7 @@ esac
# LT_INIT([OPTIONS])
# ------------------
AC_DEFUN([LT_INIT],
-[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
+[AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK
AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
AC_BEFORE([$0], [LT_LANG])dnl
AC_BEFORE([$0], [LT_OUTPUT])dnl
@@ -91,7 +83,7 @@ dnl Parse OPTIONS
_LT_SET_OPTIONS([$0], [$1])
# This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ltmain"
+LIBTOOL_DEPS=$ltmain
# Always use our own libtool.
LIBTOOL='$(SHELL) $(top_builddir)/libtool'
@@ -111,26 +103,43 @@ dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
+# _LT_PREPARE_CC_BASENAME
+# -----------------------
+m4_defun([_LT_PREPARE_CC_BASENAME], [
+# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+ for cc_temp in @S|@*""; do
+ case $cc_temp in
+ compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+ distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+ \-*) ;;
+ *) break;;
+ esac
+ done
+ func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+])# _LT_PREPARE_CC_BASENAME
+
+
# _LT_CC_BASENAME(CC)
# -------------------
-# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
+# It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME,
+# but that macro is also expanded into generated libtool script, which
+# arranges for $SED and $ECHO to be set by different means.
m4_defun([_LT_CC_BASENAME],
-[for cc_temp in $1""; do
- case $cc_temp in
- compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
- distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
- \-*) ;;
- *) break;;
- esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+[m4_require([_LT_PREPARE_CC_BASENAME])dnl
+AC_REQUIRE([_LT_DECL_SED])dnl
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
+func_cc_basename $1
+cc_basename=$func_cc_basename_result
])
# _LT_FILEUTILS_DEFAULTS
# ----------------------
# It is okay to use these file commands and assume they have been set
-# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
+# sensibly after 'm4_require([_LT_FILEUTILS_DEFAULTS])'.
m4_defun([_LT_FILEUTILS_DEFAULTS],
[: ${CP="cp -f"}
: ${MV="mv -f"}
@@ -177,15 +186,16 @@ m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl
m4_require([_LT_CMD_OLD_ARCHIVE])dnl
m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
m4_require([_LT_WITH_SYSROOT])dnl
+m4_require([_LT_CMD_TRUNCATE])dnl
_LT_CONFIG_LIBTOOL_INIT([
-# See if we are running on zsh, and set the options which allow our
+# See if we are running on zsh, and set the options that allow our
# commands through without removal of \ escapes INIT.
-if test -n "\${ZSH_VERSION+set}" ; then
+if test -n "\${ZSH_VERSION+set}"; then
setopt NO_GLOB_SUBST
fi
])
-if test -n "${ZSH_VERSION+set}" ; then
+if test -n "${ZSH_VERSION+set}"; then
setopt NO_GLOB_SUBST
fi
@@ -198,7 +208,7 @@ aix3*)
# AIX sometimes has problems with the GCC collect2 program. For some
# reason, if we set the COLLECT_NAMES environment variable, the problems
# vanish in a puff of smoke.
- if test "X${COLLECT_NAMES+set}" != Xset; then
+ if test set != "${COLLECT_NAMES+set}"; then
COLLECT_NAMES=
export COLLECT_NAMES
fi
@@ -209,14 +219,14 @@ esac
ofile=libtool
can_build_shared=yes
-# All known linkers require a `.a' archive for static linking (except MSVC,
+# All known linkers require a '.a' archive for static linking (except MSVC,
# which needs '.lib').
libext=a
-with_gnu_ld="$lt_cv_prog_gnu_ld"
+with_gnu_ld=$lt_cv_prog_gnu_ld
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
+old_CC=$CC
+old_CFLAGS=$CFLAGS
# Set sane defaults for various variables
test -z "$CC" && CC=cc
@@ -269,14 +279,14 @@ no_glob_subst='s/\*/\\\*/g'
# _LT_PROG_LTMAIN
# ---------------
-# Note that this code is called both from `configure', and `config.status'
+# Note that this code is called both from 'configure', and 'config.status'
# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably,
-# `config.status' has no value for ac_aux_dir unless we are using Automake,
+# 'config.status' has no value for ac_aux_dir unless we are using Automake,
# so we pass a copy along to make sure it has a sensible value anyway.
m4_defun([_LT_PROG_LTMAIN],
[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
-ltmain="$ac_aux_dir/ltmain.sh"
+ltmain=$ac_aux_dir/ltmain.sh
])# _LT_PROG_LTMAIN
@@ -286,7 +296,7 @@ ltmain="$ac_aux_dir/ltmain.sh"
# So that we can recreate a full libtool script including additional
# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
-# in macros and then make a single call at the end using the `libtool'
+# in macros and then make a single call at the end using the 'libtool'
# label.
@@ -421,8 +431,8 @@ m4_define([_lt_decl_all_varnames],
# _LT_CONFIG_STATUS_DECLARE([VARNAME])
# ------------------------------------
-# Quote a variable value, and forward it to `config.status' so that its
-# declaration there will have the same value as in `configure'. VARNAME
+# Quote a variable value, and forward it to 'config.status' so that its
+# declaration there will have the same value as in 'configure'. VARNAME
# must have a single quote delimited value for this to work.
m4_define([_LT_CONFIG_STATUS_DECLARE],
[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`'])
@@ -446,7 +456,7 @@ m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
# Output comment and list of tags supported by the script
m4_defun([_LT_LIBTOOL_TAGS],
[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
-available_tags="_LT_TAGS"dnl
+available_tags='_LT_TAGS'dnl
])
@@ -474,7 +484,7 @@ m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
# _LT_LIBTOOL_CONFIG_VARS
# -----------------------
# Produce commented declarations of non-tagged libtool config variables
-# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
+# suitable for insertion in the LIBTOOL CONFIG section of the 'libtool'
# script. Tagged libtool config variables (even for the LIBTOOL CONFIG
# section) are produced by _LT_LIBTOOL_TAG_VARS.
m4_defun([_LT_LIBTOOL_CONFIG_VARS],
@@ -500,8 +510,8 @@ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of
# variables for single and double quote escaping we saved from calls
# to _LT_DECL, we can put quote escaped variables declarations
-# into `config.status', and then the shell code to quote escape them in
-# for loops in `config.status'. Finally, any additional code accumulated
+# into 'config.status', and then the shell code to quote escape them in
+# for loops in 'config.status'. Finally, any additional code accumulated
# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
m4_defun([_LT_CONFIG_COMMANDS],
[AC_PROVIDE_IFELSE([LT_OUTPUT],
@@ -547,7 +557,7 @@ for var in lt_decl_all_varnames([[ \
]], lt_decl_quote_varnames); do
case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
*[[\\\\\\\`\\"\\\$]]*)
- eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
;;
*)
eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -560,7 +570,7 @@ for var in lt_decl_all_varnames([[ \
]], lt_decl_dquote_varnames); do
case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
*[[\\\\\\\`\\"\\\$]]*)
- eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes
;;
*)
eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
@@ -576,7 +586,7 @@ _LT_OUTPUT_LIBTOOL_INIT
# Generate a child script FILE with all initialization necessary to
# reuse the environment learned by the parent script, and make the
# file executable. If COMMENT is supplied, it is inserted after the
-# `#!' sequence but before initialization text begins. After this
+# '#!' sequence but before initialization text begins. After this
# macro, additional text can be appended to FILE to form the body of
# the child script. The macro ends with non-zero status if the
# file could not be fully written (such as if the disk is full).
@@ -598,7 +608,7 @@ AS_SHELL_SANITIZE
_AS_PREPARE
exec AS_MESSAGE_FD>&1
_ASEOF
-test $lt_write_fail = 0 && chmod +x $1[]dnl
+test 0 = "$lt_write_fail" && chmod +x $1[]dnl
m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT
# LT_OUTPUT
@@ -621,7 +631,7 @@ exec AS_MESSAGE_LOG_FD>>config.log
} >&AS_MESSAGE_LOG_FD
lt_cl_help="\
-\`$as_me' creates a local libtool stub from the current configuration,
+'$as_me' creates a local libtool stub from the current configuration,
for use in further configure time tests before the real libtool is
generated.
@@ -643,7 +653,7 @@ Copyright (C) 2011 Free Software Foundation, Inc.
This config.lt script is free software; the Free Software Foundation
gives unlimited permision to copy, distribute and modify it."
-while test $[#] != 0
+while test 0 != $[#]
do
case $[1] in
--version | --v* | -V )
@@ -656,10 +666,10 @@ do
lt_cl_silent=: ;;
-*) AC_MSG_ERROR([unrecognized option: $[1]
-Try \`$[0] --help' for more information.]) ;;
+Try '$[0] --help' for more information.]) ;;
*) AC_MSG_ERROR([unrecognized argument: $[1]
-Try \`$[0] --help' for more information.]) ;;
+Try '$[0] --help' for more information.]) ;;
esac
shift
done
@@ -685,7 +695,7 @@ chmod +x "$CONFIG_LT"
# open by configure. Here we exec the FD to /dev/null, effectively closing
# config.log, so it can be properly (re)opened and appended to by config.lt.
lt_cl_success=:
-test "$silent" = yes &&
+test yes = "$silent" &&
lt_config_lt_args="$lt_config_lt_args --quiet"
exec AS_MESSAGE_LOG_FD>/dev/null
$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
@@ -705,27 +715,31 @@ m4_defun([_LT_CONFIG],
_LT_CONFIG_SAVE_COMMANDS([
m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
m4_if(_LT_TAG, [C], [
- # See if we are running on zsh, and set the options which allow our
+ # See if we are running on zsh, and set the options that allow our
# commands through without removal of \ escapes.
- if test -n "${ZSH_VERSION+set}" ; then
+ if test -n "${ZSH_VERSION+set}"; then
setopt NO_GLOB_SUBST
fi
- cfgfile="${ofile}T"
+ cfgfile=${ofile}T
trap "$RM \"$cfgfile\"; exit 1" 1 2 15
$RM "$cfgfile"
cat <<_LT_EOF >> "$cfgfile"
#! $SHELL
-
-# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
-# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Generated automatically by $as_me ($PACKAGE) $VERSION
# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
-#
+
+# Provide generalized library-building support services.
+# Written by Gordon Matzigkeit, 1996
+
_LT_COPYING
_LT_LIBTOOL_TAGS
+# Configured defaults for sys_lib_dlsearch_path munging.
+: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"}
+
# ### BEGIN LIBTOOL CONFIG
_LT_LIBTOOL_CONFIG_VARS
_LT_LIBTOOL_TAG_VARS
@@ -733,13 +747,24 @@ _LT_LIBTOOL_TAG_VARS
_LT_EOF
+ cat <<'_LT_EOF' >> "$cfgfile"
+
+# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_PREPARE_MUNGE_PATH_LIST
+_LT_PREPARE_CC_BASENAME
+
+# ### END FUNCTIONS SHARED WITH CONFIGURE
+
+_LT_EOF
+
case $host_os in
aix3*)
cat <<\_LT_EOF >> "$cfgfile"
# AIX sometimes has problems with the GCC collect2 program. For some
# reason, if we set the COLLECT_NAMES environment variable, the problems
# vanish in a puff of smoke.
-if test "X${COLLECT_NAMES+set}" != Xset; then
+if test set != "${COLLECT_NAMES+set}"; then
COLLECT_NAMES=
export COLLECT_NAMES
fi
@@ -756,8 +781,6 @@ _LT_EOF
sed '$q' "$ltmain" >> "$cfgfile" \
|| (rm -f "$cfgfile"; exit 1)
- _LT_PROG_REPLACE_SHELLFNS
-
mv -f "$cfgfile" "$ofile" ||
(rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
chmod +x "$ofile"
@@ -775,7 +798,6 @@ _LT_EOF
[m4_if([$1], [], [
PACKAGE='$PACKAGE'
VERSION='$VERSION'
- TIMESTAMP='$TIMESTAMP'
RM='$RM'
ofile='$ofile'], [])
])dnl /_LT_CONFIG_SAVE_COMMANDS
@@ -974,7 +996,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
[lt_cv_apple_cc_single_mod=no
- if test -z "${LT_MULTI_MODULE}"; then
+ if test -z "$LT_MULTI_MODULE"; then
# By default we will add the -single_module flag. You can override
# by either setting the environment variable LT_MULTI_MODULE
# non-empty at configure time, or by adding -multi_module to the
@@ -992,7 +1014,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
cat conftest.err >&AS_MESSAGE_LOG_FD
# Otherwise, if the output was created with a 0 exit code from
# the compiler, it worked.
- elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+ elif test -f libconftest.dylib && test 0 = "$_lt_result"; then
lt_cv_apple_cc_single_mod=yes
else
cat conftest.err >&AS_MESSAGE_LOG_FD
@@ -1010,7 +1032,7 @@ m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
[lt_cv_ld_exported_symbols_list=yes],
[lt_cv_ld_exported_symbols_list=no])
- LDFLAGS="$save_LDFLAGS"
+ LDFLAGS=$save_LDFLAGS
])
AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
@@ -1032,7 +1054,7 @@ _LT_EOF
_lt_result=$?
if test -s conftest.err && $GREP force_load conftest.err; then
cat conftest.err >&AS_MESSAGE_LOG_FD
- elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+ elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then
lt_cv_ld_force_load=yes
else
cat conftest.err >&AS_MESSAGE_LOG_FD
@@ -1042,32 +1064,32 @@ _LT_EOF
])
case $host_os in
rhapsody* | darwin1.[[012]])
- _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+ _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
darwin1.*)
- _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
darwin*) # darwin 5.x on
# if running on 10.5 or later, the deployment target defaults
# to the OS version, if on x86, and 10.4, the deployment
# target defaults to 10.4. Don't you love it?
case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
- _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
- 10.[[012]]*)
- _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
+ 10.[[012]][[,.]]*)
+ _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
10.*)
- _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+ _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
esac
;;
esac
- if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+ if test yes = "$lt_cv_apple_cc_single_mod"; then
_lt_dar_single_mod='$single_module'
fi
- if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
- _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+ if test yes = "$lt_cv_ld_exported_symbols_list"; then
+ _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym'
else
- _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib'
fi
- if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+ if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then
_lt_dsymutil='~$DSYMUTIL $lib || :'
else
_lt_dsymutil=
@@ -1087,29 +1109,29 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES],
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_automatic, $1)=yes
_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
- if test "$lt_cv_ld_force_load" = "yes"; then
- _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+ if test yes = "$lt_cv_ld_force_load"; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes],
[FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes])
else
_LT_TAGVAR(whole_archive_flag_spec, $1)=''
fi
_LT_TAGVAR(link_all_deplibs, $1)=yes
- _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+ _LT_TAGVAR(allow_undefined_flag, $1)=$_lt_dar_allow_undefined
case $cc_basename in
- ifort*) _lt_dar_can_shared=yes ;;
+ ifort*|nagfor*) _lt_dar_can_shared=yes ;;
*) _lt_dar_can_shared=$GCC ;;
esac
- if test "$_lt_dar_can_shared" = "yes"; then
+ if test yes = "$_lt_dar_can_shared"; then
output_verbose_link_cmd=func_echo_all
- _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
- _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
- _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
- _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+ _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
+ _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
+ _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
m4_if([$1], [CXX],
-[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
- _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
- _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+[ if test yes != "$lt_cv_apple_cc_single_mod"; then
+ _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil"
fi
],[])
else
@@ -1129,7 +1151,7 @@ m4_defun([_LT_DARWIN_LINKER_FEATURES],
# Allow to override them for all tags through lt_cv_aix_libpath.
m4_defun([_LT_SYS_MODULE_PATH_AIX],
[m4_require([_LT_DECL_SED])dnl
-if test "${lt_cv_aix_libpath+set}" = set; then
+if test set = "${lt_cv_aix_libpath+set}"; then
aix_libpath=$lt_cv_aix_libpath
else
AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])],
@@ -1147,7 +1169,7 @@ else
_LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
fi],[])
if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
- _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib"
+ _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=/usr/lib:/lib
fi
])
aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])
@@ -1167,8 +1189,8 @@ m4_define([_LT_SHELL_INIT],
# -----------------------
# Find how we can fake an echo command that does not interpret backslash.
# In particular, with Autoconf 2.60 or later we add some code to the start
-# of the generated configure script which will find a shell with a builtin
-# printf (which we can use as an echo command).
+# of the generated configure script that will find a shell with a builtin
+# printf (that we can use as an echo command).
m4_defun([_LT_PROG_ECHO_BACKSLASH],
[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
@@ -1196,10 +1218,10 @@ fi
# Invoke $ECHO with all args, space-separated.
func_echo_all ()
{
- $ECHO "$*"
+ $ECHO "$*"
}
-case "$ECHO" in
+case $ECHO in
printf*) AC_MSG_RESULT([printf]) ;;
print*) AC_MSG_RESULT([print -r]) ;;
*) AC_MSG_RESULT([cat]) ;;
@@ -1225,16 +1247,17 @@ _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])
AC_DEFUN([_LT_WITH_SYSROOT],
[AC_MSG_CHECKING([for sysroot])
AC_ARG_WITH([sysroot],
-[ --with-sysroot[=DIR] Search for dependent libraries within DIR
- (or the compiler's sysroot if not specified).],
+[AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@],
+ [Search for dependent libraries within DIR (or the compiler's sysroot
+ if not specified).])],
[], [with_sysroot=no])
dnl lt_sysroot will always be passed unquoted. We quote it here
dnl in case the user passed a directory name.
lt_sysroot=
-case ${with_sysroot} in #(
+case $with_sysroot in #(
yes)
- if test "$GCC" = yes; then
+ if test yes = "$GCC"; then
lt_sysroot=`$CC --print-sysroot 2>/dev/null`
fi
;; #(
@@ -1244,14 +1267,14 @@ case ${with_sysroot} in #(
no|'')
;; #(
*)
- AC_MSG_RESULT([${with_sysroot}])
+ AC_MSG_RESULT([$with_sysroot])
AC_MSG_ERROR([The sysroot must be an absolute path.])
;;
esac
AC_MSG_RESULT([${lt_sysroot:-no}])
_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl
-[dependent libraries, and in which our libraries should be installed.])])
+[dependent libraries, and where our libraries should be installed.])])
# _LT_ENABLE_LOCK
# ---------------
@@ -1259,31 +1282,33 @@ m4_defun([_LT_ENABLE_LOCK],
[AC_ARG_ENABLE([libtool-lock],
[AS_HELP_STRING([--disable-libtool-lock],
[avoid locking (might break parallel builds)])])
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+test no = "$enable_libtool_lock" || enable_libtool_lock=yes
# Some flags need to be propagated to the compiler or linker for good
# libtool support.
case $host in
ia64-*-hpux*)
- # Find out which ABI we are using.
+ # Find out what ABI is being produced by ac_compile, and set mode
+ # options accordingly.
echo 'int i;' > conftest.$ac_ext
if AC_TRY_EVAL(ac_compile); then
case `/usr/bin/file conftest.$ac_objext` in
*ELF-32*)
- HPUX_IA64_MODE="32"
+ HPUX_IA64_MODE=32
;;
*ELF-64*)
- HPUX_IA64_MODE="64"
+ HPUX_IA64_MODE=64
;;
esac
fi
rm -rf conftest*
;;
*-*-irix6*)
- # Find out which ABI we are using.
+ # Find out what ABI is being produced by ac_compile, and set linker
+ # options accordingly.
echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
if AC_TRY_EVAL(ac_compile); then
- if test "$lt_cv_prog_gnu_ld" = yes; then
+ if test yes = "$lt_cv_prog_gnu_ld"; then
case `/usr/bin/file conftest.$ac_objext` in
*32-bit*)
LD="${LD-ld} -melf32bsmip"
@@ -1312,9 +1337,46 @@ ia64-*-hpux*)
rm -rf conftest*
;;
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+mips64*-*linux*)
+ # Find out what ABI is being produced by ac_compile, and set linker
+ # options accordingly.
+ echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ emul=elf
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ emul="${emul}32"
+ ;;
+ *64-bit*)
+ emul="${emul}64"
+ ;;
+ esac
+ case `/usr/bin/file conftest.$ac_objext` in
+ *MSB*)
+ emul="${emul}btsmip"
+ ;;
+ *LSB*)
+ emul="${emul}ltsmip"
+ ;;
+ esac
+ case `/usr/bin/file conftest.$ac_objext` in
+ *N32*)
+ emul="${emul}n32"
+ ;;
+ esac
+ LD="${LD-ld} -m $emul"
+ fi
+ rm -rf conftest*
+ ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
- # Find out which ABI we are using.
+ # Find out what ABI is being produced by ac_compile, and set linker
+ # options accordingly. Note that the listed cases only cover the
+ # situations where additional linker options are needed (such as when
+ # doing 32-bit compilation for a host where ld defaults to 64-bit, or
+ # vice versa); the common cases where no linker options are needed do
+ # not appear in the list.
echo 'int i;' > conftest.$ac_ext
if AC_TRY_EVAL(ac_compile); then
case `/usr/bin/file conftest.o` in
@@ -1324,9 +1386,19 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
LD="${LD-ld} -m elf_i386_fbsd"
;;
x86_64-*linux*)
- LD="${LD-ld} -m elf_i386"
+ case `/usr/bin/file conftest.o` in
+ *x86-64*)
+ LD="${LD-ld} -m elf32_x86_64"
+ ;;
+ *)
+ LD="${LD-ld} -m elf_i386"
+ ;;
+ esac
;;
- ppc64-*linux*|powerpc64-*linux*)
+ powerpc64le-*linux*)
+ LD="${LD-ld} -m elf32lppclinux"
+ ;;
+ powerpc64-*linux*)
LD="${LD-ld} -m elf32ppclinux"
;;
s390x-*linux*)
@@ -1345,7 +1417,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
x86_64-*linux*)
LD="${LD-ld} -m elf_x86_64"
;;
- ppc*-*linux*|powerpc*-*linux*)
+ powerpcle-*linux*)
+ LD="${LD-ld} -m elf64lppc"
+ ;;
+ powerpc-*linux*)
LD="${LD-ld} -m elf64ppc"
;;
s390*-*linux*|s390*-*tpf*)
@@ -1363,19 +1438,20 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
*-*-sco3.2v5*)
# On SCO OpenServer 5, we need -belf to get full-featured binaries.
- SAVE_CFLAGS="$CFLAGS"
+ SAVE_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS -belf"
AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
[AC_LANG_PUSH(C)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
AC_LANG_POP])
- if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+ if test yes != "$lt_cv_cc_needs_belf"; then
# this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
- CFLAGS="$SAVE_CFLAGS"
+ CFLAGS=$SAVE_CFLAGS
fi
;;
*-*solaris*)
- # Find out which ABI we are using.
+ # Find out what ABI is being produced by ac_compile, and set linker
+ # options accordingly.
echo 'int i;' > conftest.$ac_ext
if AC_TRY_EVAL(ac_compile); then
case `/usr/bin/file conftest.o` in
@@ -1383,7 +1459,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
case $lt_cv_prog_gnu_ld in
yes*)
case $host in
- i?86-*-solaris*)
+ i?86-*-solaris*|x86_64-*-solaris*)
LD="${LD-ld} -m elf_x86_64"
;;
sparc*-*-solaris*)
@@ -1392,7 +1468,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
esac
# GNU ld 2.21 introduced _sol2 emulations. Use them if available.
if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
- LD="${LD-ld}_sol2"
+ LD=${LD-ld}_sol2
fi
;;
*)
@@ -1408,7 +1484,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
;;
esac
-need_locks="$enable_libtool_lock"
+need_locks=$enable_libtool_lock
])# _LT_ENABLE_LOCK
@@ -1427,11 +1503,11 @@ AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
[echo conftest.$ac_objext > conftest.lst
lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD'
AC_TRY_EVAL([lt_ar_try])
- if test "$ac_status" -eq 0; then
+ if test 0 -eq "$ac_status"; then
# Ensure the archiver fails upon bogus file names.
rm -f conftest.$ac_objext libconftest.a
AC_TRY_EVAL([lt_ar_try])
- if test "$ac_status" -ne 0; then
+ if test 0 -ne "$ac_status"; then
lt_cv_ar_at_file=@
fi
fi
@@ -1439,7 +1515,7 @@ AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
])
])
-if test "x$lt_cv_ar_at_file" = xno; then
+if test no = "$lt_cv_ar_at_file"; then
archiver_list_spec=
else
archiver_list_spec=$lt_cv_ar_at_file
@@ -1470,7 +1546,7 @@ old_postuninstall_cmds=
if test -n "$RANLIB"; then
case $host_os in
- openbsd*)
+ bitrig* | openbsd*)
old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
;;
*)
@@ -1506,7 +1582,7 @@ AC_CACHE_CHECK([$1], [$2],
[$2=no
m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
echo "$lt_simple_compile_test_code" > conftest.$ac_ext
- lt_compiler_flag="$3"
+ lt_compiler_flag="$3" ## exclude from sc_useless_quotes_in_assignment
# Insert the option either (1) after the last *FLAGS variable, or
# (2) before a word containing "conftest.", or (3) at the end.
# Note that $ac_compile itself does not contain backslashes and begins
@@ -1533,7 +1609,7 @@ AC_CACHE_CHECK([$1], [$2],
$RM conftest*
])
-if test x"[$]$2" = xyes; then
+if test yes = "[$]$2"; then
m4_if([$5], , :, [$5])
else
m4_if([$6], , :, [$6])
@@ -1555,7 +1631,7 @@ AC_DEFUN([_LT_LINKER_OPTION],
m4_require([_LT_DECL_SED])dnl
AC_CACHE_CHECK([$1], [$2],
[$2=no
- save_LDFLAGS="$LDFLAGS"
+ save_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS $3"
echo "$lt_simple_link_test_code" > conftest.$ac_ext
if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
@@ -1574,10 +1650,10 @@ AC_CACHE_CHECK([$1], [$2],
fi
fi
$RM -r conftest*
- LDFLAGS="$save_LDFLAGS"
+ LDFLAGS=$save_LDFLAGS
])
-if test x"[$]$2" = xyes; then
+if test yes = "[$]$2"; then
m4_if([$4], , :, [$4])
else
m4_if([$5], , :, [$5])
@@ -1598,7 +1674,7 @@ AC_DEFUN([LT_CMD_MAX_LEN],
AC_MSG_CHECKING([the maximum length of command line arguments])
AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
i=0
- teststring="ABCD"
+ teststring=ABCD
case $build_os in
msdosdjgpp*)
@@ -1638,7 +1714,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
lt_cv_sys_max_cmd_len=8192;
;;
- netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+ bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*)
# This has been around since 386BSD, at least. Likely further.
if test -x /sbin/sysctl; then
lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -1688,22 +1764,23 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
;;
*)
lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
- if test -n "$lt_cv_sys_max_cmd_len"; then
+ if test -n "$lt_cv_sys_max_cmd_len" && \
+ test undefined != "$lt_cv_sys_max_cmd_len"; then
lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
else
# Make teststring a little bigger before we do anything with it.
# a 1K string should be a reasonable start.
- for i in 1 2 3 4 5 6 7 8 ; do
+ for i in 1 2 3 4 5 6 7 8; do
teststring=$teststring$teststring
done
SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
# If test is not a shell built-in, we'll probably end up computing a
# maximum length that is only half of the actual maximum length, but
# we can't tell.
- while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+ while { test X`env echo "$teststring$teststring" 2>/dev/null` \
= "X$teststring$teststring"; } >/dev/null 2>&1 &&
- test $i != 17 # 1/2 MB should be enough
+ test 17 != "$i" # 1/2 MB should be enough
do
i=`expr $i + 1`
teststring=$teststring$teststring
@@ -1719,7 +1796,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
;;
esac
])
-if test -n $lt_cv_sys_max_cmd_len ; then
+if test -n "$lt_cv_sys_max_cmd_len"; then
AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
else
AC_MSG_RESULT(none)
@@ -1747,7 +1824,7 @@ m4_defun([_LT_HEADER_DLFCN],
# ----------------------------------------------------------------
m4_defun([_LT_TRY_DLOPEN_SELF],
[m4_require([_LT_HEADER_DLFCN])dnl
-if test "$cross_compiling" = yes; then :
+if test yes = "$cross_compiling"; then :
[$4]
else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
@@ -1794,9 +1871,9 @@ else
# endif
#endif
-/* When -fvisbility=hidden is used, assume the code has been annotated
+/* When -fvisibility=hidden is used, assume the code has been annotated
correspondingly for the symbols needed. */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
int fnord () __attribute__((visibility("default")));
#endif
@@ -1822,7 +1899,7 @@ int main ()
return status;
}]
_LT_EOF
- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+ if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then
(./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
lt_status=$?
case x$lt_status in
@@ -1843,7 +1920,7 @@ rm -fr conftest*
# ------------------
AC_DEFUN([LT_SYS_DLOPEN_SELF],
[m4_require([_LT_HEADER_DLFCN])dnl
-if test "x$enable_dlopen" != xyes; then
+if test yes != "$enable_dlopen"; then
enable_dlopen=unknown
enable_dlopen_self=unknown
enable_dlopen_self_static=unknown
@@ -1853,44 +1930,52 @@ else
case $host_os in
beos*)
- lt_cv_dlopen="load_add_on"
+ lt_cv_dlopen=load_add_on
lt_cv_dlopen_libs=
lt_cv_dlopen_self=yes
;;
mingw* | pw32* | cegcc*)
- lt_cv_dlopen="LoadLibrary"
+ lt_cv_dlopen=LoadLibrary
lt_cv_dlopen_libs=
;;
cygwin*)
- lt_cv_dlopen="dlopen"
+ lt_cv_dlopen=dlopen
lt_cv_dlopen_libs=
;;
darwin*)
- # if libdl is installed we need to link against it
+ # if libdl is installed we need to link against it
AC_CHECK_LIB([dl], [dlopen],
- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
- lt_cv_dlopen="dyld"
+ [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],[
+ lt_cv_dlopen=dyld
lt_cv_dlopen_libs=
lt_cv_dlopen_self=yes
])
;;
+ tpf*)
+ # Don't try to run any link tests for TPF. We know it's impossible
+ # because TPF is a cross-compiler, and we know how we open DSOs.
+ lt_cv_dlopen=dlopen
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=no
+ ;;
+
*)
AC_CHECK_FUNC([shl_load],
- [lt_cv_dlopen="shl_load"],
+ [lt_cv_dlopen=shl_load],
[AC_CHECK_LIB([dld], [shl_load],
- [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
+ [lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld],
[AC_CHECK_FUNC([dlopen],
- [lt_cv_dlopen="dlopen"],
+ [lt_cv_dlopen=dlopen],
[AC_CHECK_LIB([dl], [dlopen],
- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+ [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],
[AC_CHECK_LIB([svld], [dlopen],
- [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+ [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld],
[AC_CHECK_LIB([dld], [dld_link],
- [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
+ [lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld])
])
])
])
@@ -1899,21 +1984,21 @@ else
;;
esac
- if test "x$lt_cv_dlopen" != xno; then
- enable_dlopen=yes
- else
+ if test no = "$lt_cv_dlopen"; then
enable_dlopen=no
+ else
+ enable_dlopen=yes
fi
case $lt_cv_dlopen in
dlopen)
- save_CPPFLAGS="$CPPFLAGS"
- test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+ save_CPPFLAGS=$CPPFLAGS
+ test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
- save_LDFLAGS="$LDFLAGS"
+ save_LDFLAGS=$LDFLAGS
wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
- save_LIBS="$LIBS"
+ save_LIBS=$LIBS
LIBS="$lt_cv_dlopen_libs $LIBS"
AC_CACHE_CHECK([whether a program can dlopen itself],
@@ -1923,7 +2008,7 @@ else
lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
])
- if test "x$lt_cv_dlopen_self" = xyes; then
+ if test yes = "$lt_cv_dlopen_self"; then
wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
lt_cv_dlopen_self_static, [dnl
@@ -1933,9 +2018,9 @@ else
])
fi
- CPPFLAGS="$save_CPPFLAGS"
- LDFLAGS="$save_LDFLAGS"
- LIBS="$save_LIBS"
+ CPPFLAGS=$save_CPPFLAGS
+ LDFLAGS=$save_LDFLAGS
+ LIBS=$save_LIBS
;;
esac
@@ -2027,8 +2112,8 @@ m4_defun([_LT_COMPILER_FILE_LOCKS],
m4_require([_LT_FILEUTILS_DEFAULTS])dnl
_LT_COMPILER_C_O([$1])
-hard_links="nottested"
-if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+hard_links=nottested
+if test no = "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" && test no != "$need_locks"; then
# do not overwrite the value of need_locks provided by the user
AC_MSG_CHECKING([if we can lock with hard links])
hard_links=yes
@@ -2038,8 +2123,8 @@ if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" !=
ln conftest.a conftest.b 2>&5 || hard_links=no
ln conftest.a conftest.b 2>/dev/null && hard_links=no
AC_MSG_RESULT([$hard_links])
- if test "$hard_links" = no; then
- AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+ if test no = "$hard_links"; then
+ AC_MSG_WARN(['$CC' does not support '-c -o', so 'make -j' may be unsafe])
need_locks=warn
fi
else
@@ -2066,8 +2151,8 @@ objdir=$lt_cv_objdir
_LT_DECL([], [objdir], [0],
[The name of the directory that contains temporary libtool files])dnl
m4_pattern_allow([LT_OBJDIR])dnl
-AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
- [Define to the sub-directory in which libtool stores uninstalled libraries.])
+AC_DEFINE_UNQUOTED([LT_OBJDIR], "$lt_cv_objdir/",
+ [Define to the sub-directory where libtool stores uninstalled libraries.])
])# _LT_CHECK_OBJDIR
@@ -2079,15 +2164,15 @@ m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
_LT_TAGVAR(hardcode_action, $1)=
if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
test -n "$_LT_TAGVAR(runpath_var, $1)" ||
- test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+ test yes = "$_LT_TAGVAR(hardcode_automatic, $1)"; then
# We can hardcode non-existent directories.
- if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
+ if test no != "$_LT_TAGVAR(hardcode_direct, $1)" &&
# If the only mechanism to avoid hardcoding is shlibpath_var, we
# have to relink, otherwise we might link with an installed library
# when we should be linking with a yet-to-be-installed one
- ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
- test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
+ ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" &&
+ test no != "$_LT_TAGVAR(hardcode_minus_L, $1)"; then
# Linking always hardcodes the temporary library directory.
_LT_TAGVAR(hardcode_action, $1)=relink
else
@@ -2101,12 +2186,12 @@ else
fi
AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
-if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
- test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
+if test relink = "$_LT_TAGVAR(hardcode_action, $1)" ||
+ test yes = "$_LT_TAGVAR(inherit_rpath, $1)"; then
# Fast installation is not supported
enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
- test "$enable_shared" = no; then
+elif test yes = "$shlibpath_overrides_runpath" ||
+ test no = "$enable_shared"; then
# Fast installation is not necessary
enable_fast_install=needless
fi
@@ -2130,7 +2215,7 @@ else
# FIXME - insert some real tests, host_os isn't really good enough
case $host_os in
darwin*)
- if test -n "$STRIP" ; then
+ if test -n "$STRIP"; then
striplib="$STRIP -x"
old_striplib="$STRIP -S"
AC_MSG_RESULT([yes])
@@ -2148,6 +2233,47 @@ _LT_DECL([], [striplib], [1])
])# _LT_CMD_STRIPLIB
+# _LT_PREPARE_MUNGE_PATH_LIST
+# ---------------------------
+# Make sure func_munge_path_list() is defined correctly.
+m4_defun([_LT_PREPARE_MUNGE_PATH_LIST],
+[[# func_munge_path_list VARIABLE PATH
+# -----------------------------------
+# VARIABLE is name of variable containing _space_ separated list of
+# directories to be munged by the contents of PATH, which is string
+# having a format:
+# "DIR[:DIR]:"
+# string "DIR[ DIR]" will be prepended to VARIABLE
+# ":DIR[:DIR]"
+# string "DIR[ DIR]" will be appended to VARIABLE
+# "DIRP[:DIRP]::[DIRA:]DIRA"
+# string "DIRP[ DIRP]" will be prepended to VARIABLE and string
+# "DIRA[ DIRA]" will be appended to VARIABLE
+# "DIR[:DIR]"
+# VARIABLE will be replaced by "DIR[ DIR]"
+func_munge_path_list ()
+{
+ case x@S|@2 in
+ x)
+ ;;
+ *:)
+ eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\"
+ ;;
+ x:*)
+ eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\"
+ ;;
+ *::*)
+ eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
+ eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\"
+ ;;
+ *)
+ eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\"
+ ;;
+ esac
+}
+]])# _LT_PREPARE_PATH_LIST
+
+
# _LT_SYS_DYNAMIC_LINKER([TAG])
# -----------------------------
# PORTME Fill in your ld.so characteristics
@@ -2158,17 +2284,18 @@ m4_require([_LT_FILEUTILS_DEFAULTS])dnl
m4_require([_LT_DECL_OBJDUMP])dnl
m4_require([_LT_DECL_SED])dnl
m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl
AC_MSG_CHECKING([dynamic linker characteristics])
m4_if([$1],
[], [
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
case $host_os in
- darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
- *) lt_awk_arg="/^libraries:/" ;;
+ darwin*) lt_awk_arg='/^libraries:/,/LR/' ;;
+ *) lt_awk_arg='/^libraries:/' ;;
esac
case $host_os in
- mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;;
- *) lt_sed_strip_eq="s,=/,/,g" ;;
+ mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;;
+ *) lt_sed_strip_eq='s|=/|/|g' ;;
esac
lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
case $lt_search_path_spec in
@@ -2184,28 +2311,35 @@ if test "$GCC" = yes; then
;;
esac
# Ok, now we have the path, separated by spaces, we can step through it
- # and add multilib dir if necessary.
+ # and add multilib dir if necessary...
lt_tmp_lt_search_path_spec=
- lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+ lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+ # ...but if some path component already ends with the multilib dir we assume
+ # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer).
+ case "$lt_multi_os_dir; $lt_search_path_spec " in
+ "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*)
+ lt_multi_os_dir=
+ ;;
+ esac
for lt_sys_path in $lt_search_path_spec; do
- if test -d "$lt_sys_path/$lt_multi_os_dir"; then
- lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
- else
+ if test -d "$lt_sys_path$lt_multi_os_dir"; then
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir"
+ elif test -n "$lt_multi_os_dir"; then
test -d "$lt_sys_path" && \
lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
fi
done
lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
-BEGIN {RS=" "; FS="/|\n";} {
- lt_foo="";
- lt_count=0;
+BEGIN {RS = " "; FS = "/|\n";} {
+ lt_foo = "";
+ lt_count = 0;
for (lt_i = NF; lt_i > 0; lt_i--) {
if ($lt_i != "" && $lt_i != ".") {
if ($lt_i == "..") {
lt_count++;
} else {
if (lt_count == 0) {
- lt_foo="/" $lt_i lt_foo;
+ lt_foo = "/" $lt_i lt_foo;
} else {
lt_count--;
}
@@ -2219,7 +2353,7 @@ BEGIN {RS=" "; FS="/|\n";} {
# for these hosts.
case $host_os in
mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
- $SED 's,/\([[A-Za-z]]:\),\1,g'` ;;
+ $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;;
esac
sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
else
@@ -2228,7 +2362,7 @@ fi])
library_names_spec=
libname_spec='lib$name'
soname_spec=
-shrext_cmds=".so"
+shrext_cmds=.so
postinstall_cmds=
postuninstall_cmds=
finish_cmds=
@@ -2245,14 +2379,17 @@ hardcode_into_libs=no
# flags to be left without arguments
need_version=unknown
+AC_ARG_VAR([LT_SYS_LIBRARY_PATH],
+[User-defined run-time library search path.])
+
case $host_os in
aix3*)
version_type=linux # correct to gnu/linux during the next big refactor
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname.a'
shlibpath_var=LIBPATH
# AIX 3 has no versioning support, so we append a major version to the name.
- soname_spec='${libname}${release}${shared_ext}$major'
+ soname_spec='$libname$release$shared_ext$major'
;;
aix[[4-9]]*)
@@ -2260,41 +2397,91 @@ aix[[4-9]]*)
need_lib_prefix=no
need_version=no
hardcode_into_libs=yes
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# AIX 5 supports IA64
- library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'
shlibpath_var=LD_LIBRARY_PATH
else
# With GCC up to 2.95.x, collect2 would create an import file
# for dependence libraries. The import file would start with
- # the line `#! .'. This would cause the generated library to
- # depend on `.', always an invalid library. This was fixed in
+ # the line '#! .'. This would cause the generated library to
+ # depend on '.', always an invalid library. This was fixed in
# development snapshots of GCC prior to 3.0.
case $host_os in
aix4 | aix4.[[01]] | aix4.[[01]].*)
if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
echo ' yes '
- echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+ echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then
:
else
can_build_shared=no
fi
;;
esac
- # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # Using Import Files as archive members, it is possible to support
+ # filename-based versioning of shared library archives on AIX. While
+ # this would work for both with and without runtime linking, it will
+ # prevent static linking of such archives. So we do filename-based
+ # shared library versioning with .so extension only, which is used
+ # when both runtime linking and shared linking is enabled.
+ # Unfortunately, runtime linking may impact performance, so we do
+ # not want this to be the default eventually. Also, we use the
+ # versioned .so libs for executables only if there is the -brtl
+ # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.
+ # To allow for filename-based versioning support, we need to create
+ # libNAME.so.V as an archive file, containing:
+ # *) an Import File, referring to the versioned filename of the
+ # archive as well as the shared archive member, telling the
+ # bitwidth (32 or 64) of that shared object, and providing the
+ # list of exported symbols of that shared object, eventually
+ # decorated with the 'weak' keyword
+ # *) the shared object with the F_LOADONLY flag set, to really avoid
+ # it being seen by the linker.
+ # At run time we better use the real file rather than another symlink,
+ # but for link time we create the symlink libNAME.so -> libNAME.so.V
+
+ case $with_aix_soname,$aix_use_runtimelinking in
+ # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct
# soname into executable. Probably we can add versioning support to
# collect2, so additional links can be useful in future.
- if test "$aix_use_runtimelinking" = yes; then
+ aix,yes) # traditional libtool
+ dynamic_linker='AIX unversionable lib.so'
# If using run time linking (on AIX 4.2 or later) use lib<name>.so
# instead of lib<name>.a to let people know that these are not
# typical AIX shared libraries.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- else
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ ;;
+ aix,no) # traditional AIX only
+ dynamic_linker='AIX lib.a[(]lib.so.V[)]'
# We preserve .a as extension for shared libraries through AIX4.2
# and later when we are not doing run time linking.
- library_names_spec='${libname}${release}.a $libname.a'
- soname_spec='${libname}${release}${shared_ext}$major'
- fi
+ library_names_spec='$libname$release.a $libname.a'
+ soname_spec='$libname$release$shared_ext$major'
+ ;;
+ svr4,*) # full svr4 only
+ dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)]"
+ library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+ # We do not specify a path in Import Files, so LIBPATH fires.
+ shlibpath_overrides_runpath=yes
+ ;;
+ *,yes) # both, prefer svr4
+ dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)], lib.a[(]lib.so.V[)]"
+ library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'
+ # unpreferred sharedlib libNAME.a needs extra handling
+ postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'
+ postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'
+ # We do not specify a path in Import Files, so LIBPATH fires.
+ shlibpath_overrides_runpath=yes
+ ;;
+ *,no) # both, prefer aix
+ dynamic_linker="AIX lib.a[(]lib.so.V[)], lib.so.V[(]$shared_archive_member_spec.o[)]"
+ library_names_spec='$libname$release.a $libname.a'
+ soname_spec='$libname$release$shared_ext$major'
+ # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling
+ postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'
+ postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'
+ ;;
+ esac
shlibpath_var=LIBPATH
fi
;;
@@ -2304,18 +2491,18 @@ amigaos*)
powerpc)
# Since July 2007 AmigaOS4 officially supports .so libraries.
# When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
;;
m68k)
library_names_spec='$libname.ixlibrary $libname.a'
# Create ${libname}_ixlibrary.a entries in /sys/libs.
- finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
;;
esac
;;
beos*)
- library_names_spec='${libname}${shared_ext}'
+ library_names_spec='$libname$shared_ext'
dynamic_linker="$host_os ld.so"
shlibpath_var=LIBRARY_PATH
;;
@@ -2323,8 +2510,8 @@ beos*)
bsdi[[45]]*)
version_type=linux # correct to gnu/linux during the next big refactor
need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
shlibpath_var=LD_LIBRARY_PATH
sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
@@ -2336,7 +2523,7 @@ bsdi[[45]]*)
cygwin* | mingw* | pw32* | cegcc*)
version_type=windows
- shrext_cmds=".dll"
+ shrext_cmds=.dll
need_version=no
need_lib_prefix=no
@@ -2345,8 +2532,8 @@ cygwin* | mingw* | pw32* | cegcc*)
# gcc
library_names_spec='$libname.dll.a'
# DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ postinstall_cmds='base_file=`basename \$file`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
dldir=$destdir/`dirname \$dlpath`~
test -d \$dldir || mkdir -p \$dldir~
$install_prog $dir/$dlname \$dldir/$dlname~
@@ -2362,17 +2549,17 @@ cygwin* | mingw* | pw32* | cegcc*)
case $host_os in
cygwin*)
# Cygwin DLLs use 'cyg' prefix rather than 'lib'
- soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
m4_if([$1], [],[
sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
;;
mingw* | cegcc*)
# MinGW DLLs use traditional 'lib' prefix
- soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
;;
pw32*)
# pw32 DLLs use 'pw' prefix rather than 'lib'
- library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
;;
esac
dynamic_linker='Win32 ld.exe'
@@ -2381,8 +2568,8 @@ m4_if([$1], [],[
*,cl*)
# Native MSVC
libname_spec='$name'
- soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
- library_names_spec='${libname}.dll.lib'
+ soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext'
+ library_names_spec='$libname.dll.lib'
case $build_os in
mingw*)
@@ -2409,7 +2596,7 @@ m4_if([$1], [],[
sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
;;
*)
- sys_lib_search_path_spec="$LIB"
+ sys_lib_search_path_spec=$LIB
if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
# It is most probably a Windows format PATH.
sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
@@ -2422,8 +2609,8 @@ m4_if([$1], [],[
esac
# DLL is installed to $(libdir)/../bin by postinstall_cmds
- postinstall_cmds='base_file=`basename \${file}`~
- dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ postinstall_cmds='base_file=`basename \$file`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~
dldir=$destdir/`dirname \$dlpath`~
test -d \$dldir || mkdir -p \$dldir~
$install_prog $dir/$dlname \$dldir/$dlname'
@@ -2436,7 +2623,7 @@ m4_if([$1], [],[
*)
# Assume MSVC wrapper
- library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib'
dynamic_linker='Win32 ld.exe'
;;
esac
@@ -2449,8 +2636,8 @@ darwin* | rhapsody*)
version_type=darwin
need_lib_prefix=no
need_version=no
- library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
- soname_spec='${libname}${release}${major}$shared_ext'
+ library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'
+ soname_spec='$libname$release$major$shared_ext'
shlibpath_overrides_runpath=yes
shlibpath_var=DYLD_LIBRARY_PATH
shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
@@ -2463,8 +2650,8 @@ dgux*)
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
shlibpath_var=LD_LIBRARY_PATH
;;
@@ -2482,12 +2669,13 @@ freebsd* | dragonfly*)
version_type=freebsd-$objformat
case $version_type in
freebsd-elf*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
need_version=no
need_lib_prefix=no
;;
freebsd-*)
- library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
need_version=yes
;;
esac
@@ -2512,26 +2700,15 @@ freebsd* | dragonfly*)
esac
;;
-gnu*)
- version_type=linux # correct to gnu/linux during the next big refactor
- need_lib_prefix=no
- need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- shlibpath_var=LD_LIBRARY_PATH
- shlibpath_overrides_runpath=no
- hardcode_into_libs=yes
- ;;
-
haiku*)
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
dynamic_linker="$host_os runtime_loader"
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
shlibpath_var=LIBRARY_PATH
- shlibpath_overrides_runpath=yes
+ shlibpath_overrides_runpath=no
sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
hardcode_into_libs=yes
;;
@@ -2549,14 +2726,15 @@ hpux9* | hpux10* | hpux11*)
dynamic_linker="$host_os dld.so"
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
- if test "X$HPUX_IA64_MODE" = X32; then
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
+ if test 32 = "$HPUX_IA64_MODE"; then
sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ sys_lib_dlsearch_path_spec=/usr/lib/hpux32
else
sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ sys_lib_dlsearch_path_spec=/usr/lib/hpux64
fi
- sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
;;
hppa*64*)
shrext_cmds='.sl'
@@ -2564,8 +2742,8 @@ hpux9* | hpux10* | hpux11*)
dynamic_linker="$host_os dld.sl"
shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
;;
@@ -2574,8 +2752,8 @@ hpux9* | hpux10* | hpux11*)
dynamic_linker="$host_os dld.sl"
shlibpath_var=SHLIB_PATH
shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
;;
esac
# HP-UX runs *really* slowly unless shared libraries are mode 555, ...
@@ -2588,8 +2766,8 @@ interix[[3-9]]*)
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=no
@@ -2600,7 +2778,7 @@ irix5* | irix6* | nonstopux*)
case $host_os in
nonstopux*) version_type=nonstopux ;;
*)
- if test "$lt_cv_prog_gnu_ld" = yes; then
+ if test yes = "$lt_cv_prog_gnu_ld"; then
version_type=linux # correct to gnu/linux during the next big refactor
else
version_type=irix
@@ -2608,8 +2786,8 @@ irix5* | irix6* | nonstopux*)
esac
need_lib_prefix=no
need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ soname_spec='$libname$release$shared_ext$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'
case $host_os in
irix5* | nonstopux*)
libsuff= shlibsuff=
@@ -2628,8 +2806,8 @@ irix5* | irix6* | nonstopux*)
esac
shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
shlibpath_overrides_runpath=no
- sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
- sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"
+ sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"
hardcode_into_libs=yes
;;
@@ -2638,13 +2816,33 @@ linux*oldld* | linux*aout* | linux*coff*)
dynamic_linker=no
;;
+linux*android*)
+ version_type=none # Android doesn't support versioned libraries.
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='$libname$release$shared_ext'
+ soname_spec='$libname$release$shared_ext'
+ finish_cmds=
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ dynamic_linker='Android linker'
+ # Don't embed -rpath directories since the linker doesn't support them.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ ;;
+
# This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu)
+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=no
@@ -2669,7 +2867,12 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu)
# before this can be enabled.
hardcode_into_libs=yes
- # Append ld.so.conf contents to the search path
+ # Ideally, we could use ldconfig to report *all* directores which are
+ # searched for libraries, however this is still not possible. Aside from not
+ # being certain /sbin/ldconfig is available, command
+ # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,
+ # even though it is searched at run-time. Try to do the best guess by
+ # appending ld.so.conf contents (and includes) to the search path.
if test -f /etc/ld.so.conf; then
lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
@@ -2689,12 +2892,12 @@ netbsd*)
need_lib_prefix=no
need_version=no
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
dynamic_linker='NetBSD (a.out) ld.so'
else
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
dynamic_linker='NetBSD ld.elf_so'
fi
shlibpath_var=LD_LIBRARY_PATH
@@ -2704,7 +2907,7 @@ netbsd*)
newsos6)
version_type=linux # correct to gnu/linux during the next big refactor
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=yes
;;
@@ -2713,58 +2916,68 @@ newsos6)
version_type=qnx
need_lib_prefix=no
need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=no
hardcode_into_libs=yes
dynamic_linker='ldqnx.so'
;;
-openbsd*)
+openbsd* | bitrig*)
version_type=sunos
- sys_lib_dlsearch_path_spec="/usr/lib"
+ sys_lib_dlsearch_path_spec=/usr/lib
need_lib_prefix=no
- # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
- case $host_os in
- openbsd3.3 | openbsd3.3.*) need_version=yes ;;
- *) need_version=no ;;
- esac
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
- finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
- shlibpath_var=LD_LIBRARY_PATH
- if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- case $host_os in
- openbsd2.[[89]] | openbsd2.[[89]].*)
- shlibpath_overrides_runpath=no
- ;;
- *)
- shlibpath_overrides_runpath=yes
- ;;
- esac
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
+ need_version=no
else
- shlibpath_overrides_runpath=yes
+ need_version=yes
fi
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
;;
os2*)
libname_spec='$name'
- shrext_cmds=".dll"
+ version_type=windows
+ shrext_cmds=.dll
+ need_version=no
need_lib_prefix=no
- library_names_spec='$libname${shared_ext} $libname.a'
+ # OS/2 can only load a DLL with a base name of 8 characters or less.
+ soname_spec='`test -n "$os2dllname" && libname="$os2dllname";
+ v=$($ECHO $release$versuffix | tr -d .-);
+ n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);
+ $ECHO $n$v`$shared_ext'
+ library_names_spec='${libname}_dll.$libext'
dynamic_linker='OS/2 ld.exe'
- shlibpath_var=LIBPATH
+ shlibpath_var=BEGINLIBPATH
+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ postinstall_cmds='base_file=`basename \$file`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname~
+ chmod a+x \$dldir/$dlname~
+ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+ fi'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
;;
osf3* | osf4* | osf5*)
version_type=osf
need_lib_prefix=no
need_version=no
- soname_spec='${libname}${release}${shared_ext}$major'
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='$libname$release$shared_ext$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
shlibpath_var=LD_LIBRARY_PATH
sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
- sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
;;
rdos*)
@@ -2775,8 +2988,8 @@ solaris*)
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=yes
hardcode_into_libs=yes
@@ -2786,11 +2999,11 @@ solaris*)
sunos4*)
version_type=sunos
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'
finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=yes
- if test "$with_gnu_ld" = yes; then
+ if test yes = "$with_gnu_ld"; then
need_lib_prefix=no
fi
need_version=yes
@@ -2798,8 +3011,8 @@ sunos4*)
sysv4 | sysv4.3*)
version_type=linux # correct to gnu/linux during the next big refactor
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
shlibpath_var=LD_LIBRARY_PATH
case $host_vendor in
sni)
@@ -2820,24 +3033,24 @@ sysv4 | sysv4.3*)
;;
sysv4*MP*)
- if test -d /usr/nec ;then
+ if test -d /usr/nec; then
version_type=linux # correct to gnu/linux during the next big refactor
- library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
- soname_spec='$libname${shared_ext}.$major'
+ library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext'
+ soname_spec='$libname$shared_ext.$major'
shlibpath_var=LD_LIBRARY_PATH
fi
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
- version_type=freebsd-elf
+ version_type=sco
need_lib_prefix=no
need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=yes
hardcode_into_libs=yes
- if test "$with_gnu_ld" = yes; then
+ if test yes = "$with_gnu_ld"; then
sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
else
sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
@@ -2855,7 +3068,7 @@ tpf*)
version_type=linux # correct to gnu/linux during the next big refactor
need_lib_prefix=no
need_version=no
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=no
hardcode_into_libs=yes
@@ -2863,8 +3076,8 @@ tpf*)
uts4*)
version_type=linux # correct to gnu/linux during the next big refactor
- library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
- soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'
+ soname_spec='$libname$release$shared_ext$major'
shlibpath_var=LD_LIBRARY_PATH
;;
@@ -2873,20 +3086,30 @@ uts4*)
;;
esac
AC_MSG_RESULT([$dynamic_linker])
-test "$dynamic_linker" = no && can_build_shared=no
+test no = "$dynamic_linker" && can_build_shared=no
variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
fi
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
- sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then
+ sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec
fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
- sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+
+if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then
+ sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec
fi
+# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...
+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec
+
+# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code
+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"
+
+# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool
+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH
+
_LT_DECL([], [variables_saved_for_relink], [1],
[Variables whose values should be saved in libtool wrapper scripts and
restored at link time])
@@ -2919,39 +3142,41 @@ _LT_DECL([], [hardcode_into_libs], [0],
[Whether we should hardcode library paths into libraries])
_LT_DECL([], [sys_lib_search_path_spec], [2],
[Compile-time system search path for libraries])
-_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
- [Run-time system search path for libraries])
+_LT_DECL([sys_lib_dlsearch_path_spec], [configure_time_dlsearch_path], [2],
+ [Detected run-time system search path for libraries])
+_LT_DECL([], [configure_time_lt_sys_library_path], [2],
+ [Explicit LT_SYS_LIBRARY_PATH set during ./configure time])
])# _LT_SYS_DYNAMIC_LINKER
# _LT_PATH_TOOL_PREFIX(TOOL)
# --------------------------
-# find a file program which can recognize shared library
+# find a file program that can recognize shared library
AC_DEFUN([_LT_PATH_TOOL_PREFIX],
[m4_require([_LT_DECL_EGREP])dnl
AC_MSG_CHECKING([for $1])
AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
[case $MAGIC_CMD in
[[\\/*] | ?:[\\/]*])
- lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+ lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.
;;
*)
- lt_save_MAGIC_CMD="$MAGIC_CMD"
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ lt_save_MAGIC_CMD=$MAGIC_CMD
+ lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
dnl $ac_dummy forces splitting on constant user-supplied paths.
dnl POSIX.2 word splitting is done only on the output of word expansions,
dnl not every word. This closes a longstanding sh security hole.
ac_dummy="m4_if([$2], , $PATH, [$2])"
for ac_dir in $ac_dummy; do
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
test -z "$ac_dir" && ac_dir=.
- if test -f $ac_dir/$1; then
- lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+ if test -f "$ac_dir/$1"; then
+ lt_cv_path_MAGIC_CMD=$ac_dir/"$1"
if test -n "$file_magic_test_file"; then
case $deplibs_check_method in
"file_magic "*)
file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
- MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+ MAGIC_CMD=$lt_cv_path_MAGIC_CMD
if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
$EGREP "$file_magic_regex" > /dev/null; then
:
@@ -2974,11 +3199,11 @@ _LT_EOF
break
fi
done
- IFS="$lt_save_ifs"
- MAGIC_CMD="$lt_save_MAGIC_CMD"
+ IFS=$lt_save_ifs
+ MAGIC_CMD=$lt_save_MAGIC_CMD
;;
esac])
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+MAGIC_CMD=$lt_cv_path_MAGIC_CMD
if test -n "$MAGIC_CMD"; then
AC_MSG_RESULT($MAGIC_CMD)
else
@@ -2996,7 +3221,7 @@ dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
# _LT_PATH_MAGIC
# --------------
-# find a file program which can recognize a shared library
+# find a file program that can recognize a shared library
m4_defun([_LT_PATH_MAGIC],
[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
if test -z "$lt_cv_path_MAGIC_CMD"; then
@@ -3023,16 +3248,16 @@ m4_require([_LT_PROG_ECHO_BACKSLASH])dnl
AC_ARG_WITH([gnu-ld],
[AS_HELP_STRING([--with-gnu-ld],
[assume the C compiler uses GNU ld @<:@default=no@:>@])],
- [test "$withval" = no || with_gnu_ld=yes],
+ [test no = "$withval" || with_gnu_ld=yes],
[with_gnu_ld=no])dnl
ac_prog=ld
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
# Check if gcc -print-prog-name=ld gives a path.
AC_MSG_CHECKING([for ld used by $CC])
case $host in
*-*-mingw*)
- # gcc leaves a trailing carriage return which upsets mingw
+ # gcc leaves a trailing carriage return, which upsets mingw
ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
*)
ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
@@ -3046,7 +3271,7 @@ if test "$GCC" = yes; then
while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
done
- test -z "$LD" && LD="$ac_prog"
+ test -z "$LD" && LD=$ac_prog
;;
"")
# If it fails, then pretend we aren't using GCC.
@@ -3057,37 +3282,37 @@ if test "$GCC" = yes; then
with_gnu_ld=unknown
;;
esac
-elif test "$with_gnu_ld" = yes; then
+elif test yes = "$with_gnu_ld"; then
AC_MSG_CHECKING([for GNU ld])
else
AC_MSG_CHECKING([for non-GNU ld])
fi
AC_CACHE_VAL(lt_cv_path_LD,
[if test -z "$LD"; then
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
for ac_dir in $PATH; do
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
test -z "$ac_dir" && ac_dir=.
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
- lt_cv_path_LD="$ac_dir/$ac_prog"
+ lt_cv_path_LD=$ac_dir/$ac_prog
# Check to see if the program is GNU ld. I'd rather use --version,
# but apparently some variants of GNU ld only accept -v.
# Break only if it was the GNU/non-GNU ld that we prefer.
case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
*GNU* | *'with BFD'*)
- test "$with_gnu_ld" != no && break
+ test no != "$with_gnu_ld" && break
;;
*)
- test "$with_gnu_ld" != yes && break
+ test yes != "$with_gnu_ld" && break
;;
esac
fi
done
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
else
- lt_cv_path_LD="$LD" # Let the user override the test with a path.
+ lt_cv_path_LD=$LD # Let the user override the test with a path.
fi])
-LD="$lt_cv_path_LD"
+LD=$lt_cv_path_LD
if test -n "$LD"; then
AC_MSG_RESULT($LD)
else
@@ -3141,13 +3366,13 @@ esac
reload_cmds='$LD$reload_flag -o $output$reload_objs'
case $host_os in
cygwin* | mingw* | pw32* | cegcc*)
- if test "$GCC" != yes; then
+ if test yes != "$GCC"; then
reload_cmds=false
fi
;;
darwin*)
- if test "$GCC" = yes; then
- reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+ if test yes = "$GCC"; then
+ reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs'
else
reload_cmds='$LD$reload_flag -o $output$reload_objs'
fi
@@ -3158,6 +3383,43 @@ _LT_TAGDECL([], [reload_cmds], [2])dnl
])# _LT_CMD_RELOAD
+# _LT_PATH_DD
+# -----------
+# find a working dd
+m4_defun([_LT_PATH_DD],
+[AC_CACHE_CHECK([for a working dd], [ac_cv_path_lt_DD],
+[printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+: ${lt_DD:=$DD}
+AC_PATH_PROGS_FEATURE_CHECK([lt_DD], [dd],
+[if "$ac_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+ cmp -s conftest.i conftest.out \
+ && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=:
+fi])
+rm -f conftest.i conftest2.i conftest.out])
+])# _LT_PATH_DD
+
+
+# _LT_CMD_TRUNCATE
+# ----------------
+# find command to truncate a binary pipe
+m4_defun([_LT_CMD_TRUNCATE],
+[m4_require([_LT_PATH_DD])
+AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin],
+[printf 0123456789abcdef0123456789abcdef >conftest.i
+cat conftest.i conftest.i >conftest2.i
+lt_cv_truncate_bin=
+if "$ac_cv_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then
+ cmp -s conftest.i conftest.out \
+ && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1"
+fi
+rm -f conftest.i conftest2.i conftest.out
+test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"])
+_LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1],
+ [Command to truncate a binary pipe])
+])# _LT_CMD_TRUNCATE
+
+
# _LT_CHECK_MAGIC_METHOD
# ----------------------
# how to check for library dependencies
@@ -3173,13 +3435,13 @@ lt_cv_deplibs_check_method='unknown'
# Need to set the preceding variable on all platforms that support
# interlibrary dependencies.
# 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
+# 'unknown' -- same as none, but documents that we really don't know.
# 'pass_all' -- all dependencies passed with no checks.
# 'test_compile' -- check by making test program.
# 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
+# that responds to the $file_magic_cmd with a given extended regex.
+# If you have 'file' or equivalent on your system and you're not sure
+# whether 'pass_all' will *always* work, you probably want this one.
case $host_os in
aix[[4-9]]*)
@@ -3206,8 +3468,7 @@ mingw* | pw32*)
# Base MSYS/MinGW do not provide the 'file' command needed by
# func_win32_libid shell function, so use a weaker test based on 'objdump',
# unless we find 'file', for example because we are cross-compiling.
- # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
- if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+ if ( file / ) >/dev/null 2>&1; then
lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
lt_cv_file_magic_cmd='func_win32_libid'
else
@@ -3243,10 +3504,6 @@ freebsd* | dragonfly*)
fi
;;
-gnu*)
- lt_cv_deplibs_check_method=pass_all
- ;;
-
haiku*)
lt_cv_deplibs_check_method=pass_all
;;
@@ -3285,7 +3542,7 @@ irix5* | irix6* | nonstopux*)
;;
# This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu)
+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
lt_cv_deplibs_check_method=pass_all
;;
@@ -3307,8 +3564,8 @@ newos6*)
lt_cv_deplibs_check_method=pass_all
;;
-openbsd*)
- if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+openbsd* | bitrig*)
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
else
lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
@@ -3361,6 +3618,9 @@ sysv4 | sysv4.3*)
tpf*)
lt_cv_deplibs_check_method=pass_all
;;
+os2*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
esac
])
@@ -3401,33 +3661,38 @@ AC_DEFUN([LT_PATH_NM],
AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
[if test -n "$NM"; then
# Let the user override the test.
- lt_cv_path_NM="$NM"
+ lt_cv_path_NM=$NM
else
- lt_nm_to_check="${ac_tool_prefix}nm"
+ lt_nm_to_check=${ac_tool_prefix}nm
if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
lt_nm_to_check="$lt_nm_to_check nm"
fi
for lt_tmp_nm in $lt_nm_to_check; do
- lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR
for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
test -z "$ac_dir" && ac_dir=.
- tmp_nm="$ac_dir/$lt_tmp_nm"
- if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+ tmp_nm=$ac_dir/$lt_tmp_nm
+ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then
# Check to see if the nm accepts a BSD-compat flag.
- # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # Adding the 'sed 1q' prevents false positives on HP-UX, which says:
# nm: unknown option "B" ignored
# Tru64's nm complains that /dev/null is an invalid object file
- case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
- */dev/null* | *'Invalid file or object type'*)
+ # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty
+ case $build_os in
+ mingw*) lt_bad_file=conftest.nm/nofile ;;
+ *) lt_bad_file=/dev/null ;;
+ esac
+ case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in
+ *$lt_bad_file* | *'Invalid file or object type'*)
lt_cv_path_NM="$tmp_nm -B"
- break
+ break 2
;;
*)
case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
*/dev/null*)
lt_cv_path_NM="$tmp_nm -p"
- break
+ break 2
;;
*)
lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
@@ -3438,21 +3703,21 @@ else
esac
fi
done
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
done
: ${lt_cv_path_NM=no}
fi])
-if test "$lt_cv_path_NM" != "no"; then
- NM="$lt_cv_path_NM"
+if test no != "$lt_cv_path_NM"; then
+ NM=$lt_cv_path_NM
else
# Didn't find any BSD compatible name lister, look for dumpbin.
if test -n "$DUMPBIN"; then :
# Let the user override the test.
else
AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :)
- case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+ case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in
*COFF*)
- DUMPBIN="$DUMPBIN -symbols"
+ DUMPBIN="$DUMPBIN -symbols -headers"
;;
*)
DUMPBIN=:
@@ -3460,8 +3725,8 @@ else
esac
fi
AC_SUBST([DUMPBIN])
- if test "$DUMPBIN" != ":"; then
- NM="$DUMPBIN"
+ if test : != "$DUMPBIN"; then
+ NM=$DUMPBIN
fi
fi
test -z "$NM" && NM=nm
@@ -3507,8 +3772,8 @@ lt_cv_sharedlib_from_linklib_cmd,
case $host_os in
cygwin* | mingw* | pw32* | cegcc*)
- # two different shell functions defined in ltmain.sh
- # decide which to use based on capabilities of $DLLTOOL
+ # two different shell functions defined in ltmain.sh;
+ # decide which one to use based on capabilities of $DLLTOOL
case `$DLLTOOL --help 2>&1` in
*--identify-strict*)
lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
@@ -3520,7 +3785,7 @@ cygwin* | mingw* | pw32* | cegcc*)
;;
*)
# fallback: assume linklib IS sharedlib
- lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+ lt_cv_sharedlib_from_linklib_cmd=$ECHO
;;
esac
])
@@ -3547,13 +3812,28 @@ AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool
lt_cv_path_mainfest_tool=yes
fi
rm -f conftest*])
-if test "x$lt_cv_path_mainfest_tool" != xyes; then
+if test yes != "$lt_cv_path_mainfest_tool"; then
MANIFEST_TOOL=:
fi
_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl
])# _LT_PATH_MANIFEST_TOOL
+# _LT_DLL_DEF_P([FILE])
+# ---------------------
+# True iff FILE is a Windows DLL '.def' file.
+# Keep in sync with func_dll_def_p in the libtool script
+AC_DEFUN([_LT_DLL_DEF_P],
+[dnl
+ test DEF = "`$SED -n dnl
+ -e '\''s/^[[ ]]*//'\'' dnl Strip leading whitespace
+ -e '\''/^\(;.*\)*$/d'\'' dnl Delete empty lines and comments
+ -e '\''s/^\(EXPORTS\|LIBRARY\)\([[ ]].*\)*$/DEF/p'\'' dnl
+ -e q dnl Only consider the first "real" line
+ $1`" dnl
+])# _LT_DLL_DEF_P
+
+
# LT_LIB_M
# --------
# check for math library
@@ -3565,11 +3845,11 @@ case $host in
# These system don't have libm, or don't need it
;;
*-ncr-sysv4.3*)
- AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+ AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=-lmw)
AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
;;
*)
- AC_CHECK_LIB(m, cos, LIBM="-lm")
+ AC_CHECK_LIB(m, cos, LIBM=-lm)
;;
esac
AC_SUBST([LIBM])
@@ -3588,7 +3868,7 @@ m4_defun([_LT_COMPILER_NO_RTTI],
_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
-if test "$GCC" = yes; then
+if test yes = "$GCC"; then
case $cc_basename in
nvcc*)
_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;
@@ -3640,7 +3920,7 @@ cygwin* | mingw* | pw32* | cegcc*)
symcode='[[ABCDGISTW]]'
;;
hpux*)
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
symcode='[[ABCDEGRST]]'
fi
;;
@@ -3673,14 +3953,44 @@ case `$NM -V 2>&1` in
symcode='[[ABCDGIRSTW]]' ;;
esac
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+ # Gets list of data symbols to import.
+ lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'"
+ # Adjust the below global symbol transforms to fixup imported variables.
+ lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'"
+ lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'"
+ lt_c_name_lib_hook="\
+ -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\
+ -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'"
+else
+ # Disable hooks by default.
+ lt_cv_sys_global_symbol_to_import=
+ lt_cdecl_hook=
+ lt_c_name_hook=
+ lt_c_name_lib_hook=
+fi
+
# Transform an extracted symbol line into a proper C declaration.
# Some systems (esp. on ia64) link data and code symbols differently,
# so use this general approach.
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+lt_cv_sys_global_symbol_to_cdecl="sed -n"\
+$lt_cdecl_hook\
+" -e 's/^T .* \(.*\)$/extern int \1();/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'"
# Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'"
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address="sed -n"\
+$lt_c_name_hook\
+" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'"
+
+# Transform an extracted symbol line into symbol name with lib prefix and
+# symbol address.
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\
+$lt_c_name_lib_hook\
+" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\
+" -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\
+" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'"
# Handle CRLF in mingw tool chain
opt_cr=
@@ -3698,21 +4008,24 @@ for ac_symprfx in "" "_"; do
# Write the raw and C identifiers.
if test "$lt_cv_nm_interface" = "MS dumpbin"; then
- # Fake it for dumpbin and say T for any non-static function
- # and D for any global variable.
+ # Fake it for dumpbin and say T for any non-static function,
+ # D for any global variable and I for any imported variable.
# Also find C++ and __fastcall symbols from MSVC++,
# which start with @ or ?.
lt_cv_sys_global_symbol_pipe="$AWK ['"\
" {last_section=section; section=\$ 3};"\
" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+" /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\
+" /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\
+" /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\
" \$ 0!~/External *\|/{next};"\
" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
" {if(hide[section]) next};"\
-" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
-" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
-" s[1]~/^[@?]/{print s[1], s[1]; next};"\
-" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+" {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\
+" {split(\$ 0,a,/\||\r/); split(a[2],s)};"\
+" s[1]~/^[@?]/{print f,s[1],s[1]; next};"\
+" s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\
" ' prfx=^$ac_symprfx]"
else
lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
@@ -3752,11 +4065,11 @@ _LT_EOF
if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
cat <<_LT_EOF > conftest.$ac_ext
/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
+/* DATA imports from DLLs on WIN32 can't be const, because runtime
relocations are performed -- see ld's documentation on pseudo-relocs. */
# define LT@&t@_DLSYM_CONST
-#elif defined(__osf__)
+#elif defined __osf__
/* This system does not cope well with relocations in const data. */
# define LT@&t@_DLSYM_CONST
#else
@@ -3782,7 +4095,7 @@ lt__PROGRAM__LTX_preloaded_symbols[[]] =
{
{ "@PROGRAM@", (void *) 0 },
_LT_EOF
- $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+ $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
cat <<\_LT_EOF >> conftest.$ac_ext
{0, (void *) 0}
};
@@ -3802,9 +4115,9 @@ _LT_EOF
mv conftest.$ac_objext conftstm.$ac_objext
lt_globsym_save_LIBS=$LIBS
lt_globsym_save_CFLAGS=$CFLAGS
- LIBS="conftstm.$ac_objext"
+ LIBS=conftstm.$ac_objext
CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
- if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+ if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then
pipe_works=yes
fi
LIBS=$lt_globsym_save_LIBS
@@ -3825,7 +4138,7 @@ _LT_EOF
rm -rf conftest* conftst*
# Do not use the global_symbol_pipe unless it works.
- if test "$pipe_works" = yes; then
+ if test yes = "$pipe_works"; then
break
else
lt_cv_sys_global_symbol_pipe=
@@ -3852,12 +4165,16 @@ _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
[Take the output of nm and produce a listing of raw symbols and C names])
_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
[Transform the output of nm in a proper C declaration])
+_LT_DECL([global_symbol_to_import], [lt_cv_sys_global_symbol_to_import], [1],
+ [Transform the output of nm into a list of symbols to manually relocate])
_LT_DECL([global_symbol_to_c_name_address],
[lt_cv_sys_global_symbol_to_c_name_address], [1],
[Transform the output of nm in a C name address pair])
_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
[lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
[Transform the output of nm in a C name address pair when lib prefix is needed])
+_LT_DECL([nm_interface], [lt_cv_nm_interface], [1],
+ [The name lister interface])
_LT_DECL([], [nm_file_list_spec], [1],
[Specify filename containing input files for $NM])
]) # _LT_CMD_GLOBAL_SYMBOLS
@@ -3873,17 +4190,18 @@ _LT_TAGVAR(lt_prog_compiler_static, $1)=
m4_if([$1], [CXX], [
# C++ specific cases for pic, static, wl, etc.
- if test "$GXX" = yes; then
+ if test yes = "$GXX"; then
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
case $host_os in
aix*)
# All AIX code is PIC.
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# AIX 5 now supports IA64 processor
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
fi
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
;;
amigaos*)
@@ -3894,8 +4212,8 @@ m4_if([$1], [CXX], [
;;
m68k)
# FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
+ # adding the '-m68020' flag to GCC prevents building anything better,
+ # like '-m68040'.
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
;;
esac
@@ -3911,6 +4229,11 @@ m4_if([$1], [CXX], [
# (--disable-auto-import) libraries
m4_if([$1], [GCJ], [],
[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ case $host_os in
+ os2*)
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+ ;;
+ esac
;;
darwin* | rhapsody*)
# PIC is the default on this platform
@@ -3960,7 +4283,7 @@ m4_if([$1], [CXX], [
case $host_os in
aix[[4-9]]*)
# All AIX code is PIC.
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# AIX 5 now supports IA64 processor
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
else
@@ -4001,14 +4324,14 @@ m4_if([$1], [CXX], [
case $cc_basename in
CC*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
- if test "$host_cpu" != ia64; then
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
+ if test ia64 != "$host_cpu"; then
_LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
fi
;;
aCC*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
case $host_cpu in
hppa*64*|ia64*)
# +Z the default
@@ -4037,7 +4360,7 @@ m4_if([$1], [CXX], [
;;
esac
;;
- linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
case $cc_basename in
KCC*)
# KAI C++ Compiler
@@ -4045,7 +4368,7 @@ m4_if([$1], [CXX], [
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
;;
ecpc* )
- # old Intel C++ for x86_64 which still supported -KPIC.
+ # old Intel C++ for x86_64, which still supported -KPIC.
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
@@ -4190,17 +4513,18 @@ m4_if([$1], [CXX], [
fi
],
[
- if test "$GCC" = yes; then
+ if test yes = "$GCC"; then
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
case $host_os in
aix*)
# All AIX code is PIC.
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# AIX 5 now supports IA64 processor
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
fi
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
;;
amigaos*)
@@ -4211,8 +4535,8 @@ m4_if([$1], [CXX], [
;;
m68k)
# FIXME: we need at least 68020 code to build shared libraries, but
- # adding the `-m68020' flag to GCC prevents building anything better,
- # like `-m68040'.
+ # adding the '-m68020' flag to GCC prevents building anything better,
+ # like '-m68040'.
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
;;
esac
@@ -4229,6 +4553,11 @@ m4_if([$1], [CXX], [
# (--disable-auto-import) libraries
m4_if([$1], [GCJ], [],
[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ case $host_os in
+ os2*)
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+ ;;
+ esac
;;
darwin* | rhapsody*)
@@ -4299,7 +4628,7 @@ m4_if([$1], [CXX], [
case $host_os in
aix*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# AIX 5 now supports IA64 processor
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
else
@@ -4307,11 +4636,30 @@ m4_if([$1], [CXX], [
fi
;;
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+ case $cc_basename in
+ nagfor*)
+ # NAG Fortran compiler
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ esac
+ ;;
+
mingw* | cygwin* | pw32* | os2* | cegcc*)
# This hack is so that the source file can tell whether it is being
# built for inclusion in a dll (and should export symbols for example).
m4_if([$1], [GCJ], [],
[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ case $host_os in
+ os2*)
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static'
+ ;;
+ esac
;;
hpux9* | hpux10* | hpux11*)
@@ -4327,7 +4675,7 @@ m4_if([$1], [CXX], [
;;
esac
# Is there a better lt_prog_compiler_static that works with the bundled CC?
- _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive'
;;
irix5* | irix6* | nonstopux*)
@@ -4336,9 +4684,9 @@ m4_if([$1], [CXX], [
_LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
;;
- linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
case $cc_basename in
- # old Intel for x86_64 which still supported -KPIC.
+ # old Intel for x86_64, which still supported -KPIC.
ecc*)
_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
@@ -4363,6 +4711,12 @@ m4_if([$1], [CXX], [
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
;;
+ tcc*)
+ # Fabrice Bellard et al's Tiny C Compiler
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
# Portland Group compilers (*not* the Pentium gcc compiler,
# which looks to be a dead project)
@@ -4460,7 +4814,7 @@ m4_if([$1], [CXX], [
;;
sysv4*MP*)
- if test -d /usr/nec ;then
+ if test -d /usr/nec; then
_LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
fi
@@ -4489,7 +4843,7 @@ m4_if([$1], [CXX], [
fi
])
case $host_os in
- # For platforms which do not support PIC, -DPIC is meaningless:
+ # For platforms that do not support PIC, -DPIC is meaningless:
*djgpp*)
_LT_TAGVAR(lt_prog_compiler_pic, $1)=
;;
@@ -4555,17 +4909,21 @@ m4_if([$1], [CXX], [
case $host_os in
aix[[4-9]]*)
# If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- # Also, AIX nm treats weak defined symbols like other global defined
- # symbols, whereas GNU nm marks them as "W".
+ # -C means demangle to GNU nm, but means don't demangle to AIX nm.
+ # Without the "-l" option, or with the "-B" option, AIX nm treats
+ # weak defined symbols like other global defined symbols, whereas
+ # GNU nm marks them as "W".
+ # While the 'weak' keyword is ignored in the Export File, we need
+ # it in the Import File for the 'aix-soname' feature, so we have
+ # to replace the "-B" option with "-P" for AIX nm.
if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
- _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
else
- _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
fi
;;
pw32*)
- _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+ _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds
;;
cygwin* | mingw* | cegcc*)
case $cc_basename in
@@ -4611,9 +4969,9 @@ m4_if([$1], [CXX], [
# included in the symbol list
_LT_TAGVAR(include_expsyms, $1)=
# exclude_expsyms can be an extended regexp of symbols to exclude
- # it will be wrapped by ` (' and `)$', so one must not match beginning or
- # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
- # as well as any symbol that contains `d'.
+ # it will be wrapped by ' (' and ')$', so one must not match beginning or
+ # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc',
+ # as well as any symbol that contains 'd'.
_LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
# platforms (ab)use it in PIC code, but their linkers get confused if
@@ -4629,7 +4987,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
# FIXME: the MSVC++ port hasn't been tested in a loooong time
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
- if test "$GCC" != yes; then
+ if test yes != "$GCC"; then
with_gnu_ld=no
fi
;;
@@ -4637,7 +4995,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
# we just hope/assume this is gcc and not c89 (= MSVC++)
with_gnu_ld=yes
;;
- openbsd*)
+ openbsd* | bitrig*)
with_gnu_ld=no
;;
esac
@@ -4647,7 +5005,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
# On some targets, GNU ld is compatible enough with the native linker
# that we're better off using the native interface for both.
lt_use_gnu_ld_interface=no
- if test "$with_gnu_ld" = yes; then
+ if test yes = "$with_gnu_ld"; then
case $host_os in
aix*)
# The AIX port of GNU ld has always aspired to compatibility
@@ -4669,24 +5027,24 @@ dnl Note also adjust exclude_expsyms for C++ above.
esac
fi
- if test "$lt_use_gnu_ld_interface" = yes; then
+ if test yes = "$lt_use_gnu_ld_interface"; then
# If archive_cmds runs LD, not CC, wlarc should be empty
- wlarc='${wl}'
+ wlarc='$wl'
# Set some defaults for GNU ld with shared library support. These
# are reset later if shared libraries are not supported. Putting them
# here allows them to be overridden if necessary.
runpath_var=LD_RUN_PATH
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
# ancient GNU ld didn't support --whole-archive et. al.
if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
- _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
else
_LT_TAGVAR(whole_archive_flag_spec, $1)=
fi
supports_anon_versioning=no
- case `$LD -v 2>&1` in
+ case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in
*GNU\ gold*) supports_anon_versioning=yes ;;
*\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
*\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
@@ -4699,7 +5057,7 @@ dnl Note also adjust exclude_expsyms for C++ above.
case $host_os in
aix[[3-9]]*)
# On AIX/PPC, the GNU linker is very broken
- if test "$host_cpu" != ia64; then
+ if test ia64 != "$host_cpu"; then
_LT_TAGVAR(ld_shlibs, $1)=no
cat <<_LT_EOF 1>&2
@@ -4718,7 +5076,7 @@ _LT_EOF
case $host_cpu in
powerpc)
# see comment about AmigaOS4 .so support
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)=''
;;
m68k)
@@ -4734,7 +5092,7 @@ _LT_EOF
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
# Joseph Beckenbach <jrb3@best.com> says some releases of gcc
# support --undefined. This deserves some investigation. FIXME
- _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
@@ -4744,7 +5102,7 @@ _LT_EOF
# _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
# as there is no search path for DLLs.
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols'
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
_LT_TAGVAR(always_export_symbols, $1)=no
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
@@ -4752,61 +5110,89 @@ _LT_EOF
_LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file, use it as
+ # is; otherwise, prepend EXPORTS...
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
;;
haiku*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
_LT_TAGVAR(link_all_deplibs, $1)=yes
;;
+ os2*)
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ shrext_cmds=.dll
+ _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+ $ECHO EXPORTS >> $output_objdir/$libname.def~
+ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+ emximp -o $lib $output_objdir/$libname.def'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+ $ECHO EXPORTS >> $output_objdir/$libname.def~
+ prefix_cmds="$SED"~
+ if test EXPORTS = "`$SED 1q $export_symbols`"; then
+ prefix_cmds="$prefix_cmds -e 1d";
+ fi~
+ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+ emximp -o $lib $output_objdir/$libname.def'
+ _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ ;;
+
interix[[3-9]]*)
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
# Instead, shared libraries are loaded at an image base (0x10000000 by
# default) and relocated if they conflict, which is a slow very memory
# consuming and fragmenting process. To avoid this, we pick a random,
# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
# time. Moving up from 0x10000000 also allows more sbrk(2) space.
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
;;
gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
tmp_diet=no
- if test "$host_os" = linux-dietlibc; then
+ if test linux-dietlibc = "$host_os"; then
case $cc_basename in
diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
esac
fi
if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
- && test "$tmp_diet" = no
+ && test no = "$tmp_diet"
then
tmp_addflag=' $pic_flag'
tmp_sharedflag='-shared'
case $cc_basename,$host_cpu in
pgcc*) # Portland Group C compiler
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
tmp_addflag=' $pic_flag'
;;
pgf77* | pgf90* | pgf95* | pgfortran*)
# Portland Group f77 and f90 compilers
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
tmp_addflag=' $pic_flag -Mnomain' ;;
ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
tmp_addflag=' -i_dynamic' ;;
@@ -4817,42 +5203,47 @@ _LT_EOF
lf95*) # Lahey Fortran 8.1
_LT_TAGVAR(whole_archive_flag_spec, $1)=
tmp_sharedflag='--shared' ;;
+ nagfor*) # NAGFOR 5.3
+ tmp_sharedflag='-Wl,-shared' ;;
xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
tmp_sharedflag='-qmkshrobj'
tmp_addflag= ;;
nvcc*) # Cuda Compiler Driver 2.2
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
_LT_TAGVAR(compiler_needs_object, $1)=yes
;;
esac
case `$CC -V 2>&1 | sed 5q` in
*Sun\ C*) # Sun C 5.9
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
_LT_TAGVAR(compiler_needs_object, $1)=yes
tmp_sharedflag='-G' ;;
*Sun\ F*) # Sun Fortran 8.3
tmp_sharedflag='-G' ;;
esac
- _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
- if test "x$supports_anon_versioning" = xyes; then
+ if test yes = "$supports_anon_versioning"; then
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- echo "local: *; };" >> $output_objdir/$libname.ver~
- $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
fi
case $cc_basename in
+ tcc*)
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic'
+ ;;
xlf* | bgf* | bgxlf* | mpixlf*)
# IBM XL Fortran 10.1 on PPC cannot create shared libs itself
_LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
_LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
- if test "x$supports_anon_versioning" = xyes; then
+ if test yes = "$supports_anon_versioning"; then
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- echo "local: *; };" >> $output_objdir/$libname.ver~
- $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
fi
;;
esac
@@ -4866,8 +5257,8 @@ _LT_EOF
_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
wlarc=
else
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
fi
;;
@@ -4885,8 +5276,8 @@ _LT_EOF
_LT_EOF
elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
@@ -4898,7 +5289,7 @@ _LT_EOF
_LT_TAGVAR(ld_shlibs, $1)=no
cat <<_LT_EOF 1>&2
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot
*** reliably create shared libraries on SCO systems. Therefore, libtool
*** is disabling shared libraries support. We urge you to upgrade GNU
*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
@@ -4913,9 +5304,9 @@ _LT_EOF
# DT_RUNPATH tag from executables and libraries. But doing so
# requires that you compile everything twice, which is a pain.
if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
@@ -4932,15 +5323,15 @@ _LT_EOF
*)
if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
;;
esac
- if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
+ if test no = "$_LT_TAGVAR(ld_shlibs, $1)"; then
runpath_var=
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
_LT_TAGVAR(export_dynamic_flag_spec, $1)=
@@ -4956,7 +5347,7 @@ _LT_EOF
# Note: this linker hardcodes the directories in LIBPATH if there
# are no directories specified by -L.
_LT_TAGVAR(hardcode_minus_L, $1)=yes
- if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+ if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then
# Neither direct hardcoding nor static linking is supported with a
# broken collect2.
_LT_TAGVAR(hardcode_direct, $1)=unsupported
@@ -4964,34 +5355,57 @@ _LT_EOF
;;
aix[[4-9]]*)
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# On IA64, the linker does run time linking by default, so we don't
# have to do anything special.
aix_use_runtimelinking=no
exp_sym_flag='-Bexport'
- no_entry_flag=""
+ no_entry_flag=
else
# If we're using GNU nm, then we don't want the "-C" option.
- # -C means demangle to AIX nm, but means don't demangle with GNU nm
- # Also, AIX nm treats weak defined symbols like other global
- # defined symbols, whereas GNU nm marks them as "W".
+ # -C means demangle to GNU nm, but means don't demangle to AIX nm.
+ # Without the "-l" option, or with the "-B" option, AIX nm treats
+ # weak defined symbols like other global defined symbols, whereas
+ # GNU nm marks them as "W".
+ # While the 'weak' keyword is ignored in the Export File, we need
+ # it in the Import File for the 'aix-soname' feature, so we have
+ # to replace the "-B" option with "-P" for AIX nm.
if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
- _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
else
- _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
fi
aix_use_runtimelinking=no
# Test if we are trying to use run time linking or normal
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
+ # have runtime linking enabled, and use it for executables.
+ # For shared libraries, we enable/disable runtime linking
+ # depending on the kind of the shared library created -
+ # when "with_aix_soname,aix_use_runtimelinking" is:
+ # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables
+ # "aix,yes" lib.so shared, rtl:yes, for executables
+ # lib.a static archive
+ # "both,no" lib.so.V(shr.o) shared, rtl:yes
+ # lib.a(lib.so.V) shared, rtl:no, for executables
+ # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+ # lib.a(lib.so.V) shared, rtl:no
+ # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables
+ # lib.a static archive
case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
for ld_flag in $LDFLAGS; do
- if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then
aix_use_runtimelinking=yes
break
fi
done
+ if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+ # With aix-soname=svr4, we create the lib.so.V shared archives only,
+ # so we don't have lib.a shared libs to link our executables.
+ # We have to force runtime linking in this case.
+ aix_use_runtimelinking=yes
+ LDFLAGS="$LDFLAGS -Wl,-brtl"
+ fi
;;
esac
@@ -5010,13 +5424,21 @@ _LT_EOF
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
_LT_TAGVAR(link_all_deplibs, $1)=yes
- _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+ _LT_TAGVAR(file_list_spec, $1)='$wl-f,'
+ case $with_aix_soname,$aix_use_runtimelinking in
+ aix,*) ;; # traditional, no import file
+ svr4,* | *,yes) # use import file
+ # The Import File defines what to hardcode.
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+ ;;
+ esac
- if test "$GCC" = yes; then
+ if test yes = "$GCC"; then
case $host_os in aix4.[[012]]|aix4.[[012]].*)
# We only want to do this on AIX 4.2 and lower, the check
# below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
+ collect2name=`$CC -print-prog-name=collect2`
if test -f "$collect2name" &&
strings "$collect2name" | $GREP resolve_lib_name >/dev/null
then
@@ -5035,61 +5457,80 @@ _LT_EOF
;;
esac
shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
+ if test yes = "$aix_use_runtimelinking"; then
+ shared_flag="$shared_flag "'$wl-G'
fi
+ # Need to ensure runtime linking is disabled for the traditional
+ # shared library, or the linker may eventually find shared libraries
+ # /with/ Import File - we do not want to mix them.
+ shared_flag_aix='-shared'
+ shared_flag_svr4='-shared $wl-G'
else
# not using gcc
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
# chokes on -Wl,-G. The following line is correct:
shared_flag='-G'
else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
+ if test yes = "$aix_use_runtimelinking"; then
+ shared_flag='$wl-G'
else
- shared_flag='${wl}-bM:SRE'
+ shared_flag='$wl-bM:SRE'
fi
+ shared_flag_aix='$wl-bM:SRE'
+ shared_flag_svr4='$wl-G'
fi
fi
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall'
# It seems that -bexpall does not export symbols beginning with
# underscore (_), so it is better to generate a list of symbols to export.
_LT_TAGVAR(always_export_symbols, $1)=yes
- if test "$aix_use_runtimelinking" = yes; then
+ if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
# Warning - without using the other runtime loading flags (-brtl),
# -berok will link without error, but may produce a broken library.
_LT_TAGVAR(allow_undefined_flag, $1)='-berok'
# Determine the default libpath from the value encoded in an
# empty executable.
_LT_SYS_MODULE_PATH_AIX([$1])
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
else
- if test "$host_cpu" = ia64; then
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+ if test ia64 = "$host_cpu"; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib'
_LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
- _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
else
# Determine the default libpath from the value encoded in an
# empty executable.
_LT_SYS_MODULE_PATH_AIX([$1])
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
# Warning - without using the other run time loading flags,
# -berok will link without error, but may produce a broken library.
- _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
- _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
- if test "$with_gnu_ld" = yes; then
+ _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok'
+ _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok'
+ if test yes = "$with_gnu_ld"; then
# We only use this code for GNU lds that support --whole-archive.
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
else
# Exported symbols can be pulled into shared objects from archives
_LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
fi
_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
- # This is similar to how AIX traditionally builds its shared libraries.
- _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+ # -brtl affects multiple linker settings, -berok does not and is overridden later
+ compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`'
+ if test svr4 != "$with_aix_soname"; then
+ # This is similar to how AIX traditionally builds its shared libraries.
+ _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+ fi
+ if test aix != "$with_aix_soname"; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp'
+ else
+ # used by -dlpreopen to get the symbols
+ _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir'
+ fi
+ _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d'
fi
fi
;;
@@ -5098,7 +5539,7 @@ _LT_EOF
case $host_cpu in
powerpc)
# see comment about AmigaOS4 .so support
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)=''
;;
m68k)
@@ -5128,16 +5569,17 @@ _LT_EOF
# Tell ltmain to make .lib files, not .a files.
libext=lib
# Tell ltmain to make .dll files, not .so files.
- shrext_cmds=".dll"
+ shrext_cmds=.dll
# FIXME: Setting linknames here is a bad hack.
- _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
- _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
- else
- sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
- fi~
- $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
- linknames='
+ _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+ cp "$export_symbols" "$output_objdir/$soname.def";
+ echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+ else
+ $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+ fi~
+ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+ linknames='
# The linker will not automatically build a static lib if we build a DLL.
# _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
@@ -5146,18 +5588,18 @@ _LT_EOF
# Don't use ranlib
_LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
_LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
- lt_tool_outputfile="@TOOL_OUTPUT@"~
- case $lt_outputfile in
- *.exe|*.EXE) ;;
- *)
- lt_outputfile="$lt_outputfile.exe"
- lt_tool_outputfile="$lt_tool_outputfile.exe"
- ;;
- esac~
- if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
- $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
- $RM "$lt_outputfile.manifest";
- fi'
+ lt_tool_outputfile="@TOOL_OUTPUT@"~
+ case $lt_outputfile in
+ *.exe|*.EXE) ;;
+ *)
+ lt_outputfile=$lt_outputfile.exe
+ lt_tool_outputfile=$lt_tool_outputfile.exe
+ ;;
+ esac~
+ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+ $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+ $RM "$lt_outputfile.manifest";
+ fi'
;;
*)
# Assume MSVC wrapper
@@ -5166,7 +5608,7 @@ _LT_EOF
# Tell ltmain to make .lib files, not .a files.
libext=lib
# Tell ltmain to make .dll files, not .so files.
- shrext_cmds=".dll"
+ shrext_cmds=.dll
# FIXME: Setting linknames here is a bad hack.
_LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
# The linker will automatically build a .lib file if we build a DLL.
@@ -5216,33 +5658,33 @@ _LT_EOF
;;
hpux9*)
- if test "$GCC" = yes; then
- _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ if test yes = "$GCC"; then
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
else
- _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
fi
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
_LT_TAGVAR(hardcode_direct, $1)=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
_LT_TAGVAR(hardcode_minus_L, $1)=yes
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
;;
hpux10*)
- if test "$GCC" = yes && test "$with_gnu_ld" = no; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ if test yes,no = "$GCC,$with_gnu_ld"; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
else
_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
fi
- if test "$with_gnu_ld" = no; then
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ if test no = "$with_gnu_ld"; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
_LT_TAGVAR(hardcode_minus_L, $1)=yes
@@ -5250,25 +5692,25 @@ _LT_EOF
;;
hpux11*)
- if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+ if test yes,no = "$GCC,$with_gnu_ld"; then
case $host_cpu in
hppa*64*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
;;
ia64*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
;;
*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
;;
esac
else
case $host_cpu in
hppa*64*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
;;
ia64*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
;;
*)
m4_if($1, [], [
@@ -5276,14 +5718,14 @@ _LT_EOF
# (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
_LT_LINKER_OPTION([if $CC understands -b],
_LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b],
- [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
+ [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
[_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])],
- [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
+ [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
;;
esac
fi
- if test "$with_gnu_ld" = no; then
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ if test no = "$with_gnu_ld"; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
case $host_cpu in
@@ -5294,7 +5736,7 @@ _LT_EOF
*)
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
@@ -5305,16 +5747,16 @@ _LT_EOF
;;
irix5* | irix6* | nonstopux*)
- if test "$GCC" = yes; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ if test yes = "$GCC"; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
# Try to use the -exported_symbol ld option, if it does not
# work, assume that -exports_file does not work either and
# implicitly export all symbols.
# This should be the same for all languages, so no per-tag cache variable.
AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol],
[lt_cv_irix_exported_symbol],
- [save_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+ [save_LDFLAGS=$LDFLAGS
+ LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null"
AC_LINK_IFELSE(
[AC_LANG_SOURCE(
[AC_LANG_CASE([C], [[int foo (void) { return 0; }]],
@@ -5327,21 +5769,31 @@ _LT_EOF
end]])])],
[lt_cv_irix_exported_symbol=yes],
[lt_cv_irix_exported_symbol=no])
- LDFLAGS="$save_LDFLAGS"])
- if test "$lt_cv_irix_exported_symbol" = yes; then
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+ LDFLAGS=$save_LDFLAGS])
+ if test yes = "$lt_cv_irix_exported_symbol"; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
fi
else
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
fi
_LT_TAGVAR(archive_cmds_need_lc, $1)='no'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
_LT_TAGVAR(inherit_rpath, $1)=yes
_LT_TAGVAR(link_all_deplibs, $1)=yes
;;
+ linux*)
+ case $cc_basename in
+ tcc*)
+ # Fabrice Bellard et al's Tiny C Compiler
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ ;;
+
netbsd*)
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
@@ -5356,7 +5808,7 @@ _LT_EOF
newsos6)
_LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
_LT_TAGVAR(hardcode_direct, $1)=yes
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
;;
@@ -5364,27 +5816,19 @@ _LT_EOF
*nto* | *qnx*)
;;
- openbsd*)
+ openbsd* | bitrig*)
if test -f /usr/libexec/ld.so; then
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
- if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
else
- case $host_os in
- openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
- _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- ;;
- *)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- ;;
- esac
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
fi
else
_LT_TAGVAR(ld_shlibs, $1)=no
@@ -5395,33 +5839,53 @@ _LT_EOF
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
_LT_TAGVAR(hardcode_minus_L, $1)=yes
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
- _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
- _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+ shrext_cmds=.dll
+ _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+ $ECHO EXPORTS >> $output_objdir/$libname.def~
+ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+ emximp -o $lib $output_objdir/$libname.def'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+ $ECHO EXPORTS >> $output_objdir/$libname.def~
+ prefix_cmds="$SED"~
+ if test EXPORTS = "`$SED 1q $export_symbols`"; then
+ prefix_cmds="$prefix_cmds -e 1d";
+ fi~
+ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+ emximp -o $lib $output_objdir/$libname.def'
+ _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
;;
osf3*)
- if test "$GCC" = yes; then
- _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ if test yes = "$GCC"; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
else
_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
fi
_LT_TAGVAR(archive_cmds_need_lc, $1)='no'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
;;
osf4* | osf5*) # as osf3* with the addition of -msym flag
- if test "$GCC" = yes; then
- _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ if test yes = "$GCC"; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
else
_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
- $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+ $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp'
# Both c and cxx compiler support -rpath directly
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -5432,24 +5896,24 @@ _LT_EOF
solaris*)
_LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
- if test "$GCC" = yes; then
- wlarc='${wl}'
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ if test yes = "$GCC"; then
+ wlarc='$wl'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
- $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
else
case `$CC -V 2>&1` in
*"Compilers 5.0"*)
wlarc=''
- _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
- $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+ $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
;;
*)
- wlarc='${wl}'
- _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ wlarc='$wl'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
- $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
;;
esac
fi
@@ -5459,11 +5923,11 @@ _LT_EOF
solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
*)
# The compiler driver will combine and reorder linker options,
- # but understands `-z linker_flag'. GCC discards it without `$wl',
+ # but understands '-z linker_flag'. GCC discards it without '$wl',
# but is careful enough not to reorder.
# Supported since Solaris 2.6 (maybe 2.5.1?)
- if test "$GCC" = yes; then
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ if test yes = "$GCC"; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
else
_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
fi
@@ -5473,10 +5937,10 @@ _LT_EOF
;;
sunos4*)
- if test "x$host_vendor" = xsequent; then
+ if test sequent = "$host_vendor"; then
# Use $CC to link under sequent, because it throws in some extra .o
# files that make .init and .fini sections work.
- _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags'
else
_LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
fi
@@ -5525,43 +5989,43 @@ _LT_EOF
;;
sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
- _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
runpath_var='LD_RUN_PATH'
- if test "$GCC" = yes; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ if test yes = "$GCC"; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
else
- _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
fi
;;
sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
+ # Note: We CANNOT use -z defs as we might desire, because we do not
# link with -lc, and that would cause any symbols used from libc to
# always be unresolved, which means just about no library would
# ever link correctly. If we're not using GNU ld we use -z text
# though, which does catch some bad symbols but isn't as heavy-handed
# as -z defs.
- _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
- _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+ _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
+ _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs'
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
_LT_TAGVAR(link_all_deplibs, $1)=yes
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport'
runpath_var='LD_RUN_PATH'
- if test "$GCC" = yes; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ if test yes = "$GCC"; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
else
- _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
fi
;;
@@ -5576,17 +6040,17 @@ _LT_EOF
;;
esac
- if test x$host_vendor = xsni; then
+ if test sni = "$host_vendor"; then
case $host in
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Blargedynsym'
;;
esac
fi
fi
])
AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
-test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no
_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
@@ -5603,7 +6067,7 @@ x|xyes)
# Assume -lc should be added
_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
- if test "$enable_shared" = yes && test "$GCC" = yes; then
+ if test yes,yes = "$GCC,$enable_shared"; then
case $_LT_TAGVAR(archive_cmds, $1) in
*'~'*)
# FIXME: we may have to deal with multi-command sequences.
@@ -5683,12 +6147,12 @@ _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
_LT_TAGDECL([], [hardcode_libdir_separator], [1],
[Whether we need a single "-rpath" flag with a separated argument])
_LT_TAGDECL([], [hardcode_direct], [0],
- [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+ [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes
DIR into the resulting binary])
_LT_TAGDECL([], [hardcode_direct_absolute], [0],
- [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+ [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes
DIR into the resulting binary and the resulting library dependency is
- "absolute", i.e impossible to change by setting ${shlibpath_var} if the
+ "absolute", i.e impossible to change by setting $shlibpath_var if the
library is relocated])
_LT_TAGDECL([], [hardcode_minus_L], [0],
[Set to "yes" if using the -LDIR flag during linking hardcodes DIR
@@ -5729,10 +6193,10 @@ dnl [Compiler flag to generate thread safe objects])
# ------------------------
# Ensure that the configuration variables for a C compiler are suitably
# defined. These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
+# the compiler configuration to 'libtool'.
m4_defun([_LT_LANG_C_CONFIG],
[m4_require([_LT_DECL_EGREP])dnl
-lt_save_CC="$CC"
+lt_save_CC=$CC
AC_LANG_PUSH(C)
# Source file extension for C test sources.
@@ -5772,18 +6236,18 @@ if test -n "$compiler"; then
LT_SYS_DLOPEN_SELF
_LT_CMD_STRIPLIB
- # Report which library types will actually be built
+ # Report what library types will actually be built
AC_MSG_CHECKING([if libtool supports shared libraries])
AC_MSG_RESULT([$can_build_shared])
AC_MSG_CHECKING([whether to build shared libraries])
- test "$can_build_shared" = "no" && enable_shared=no
+ test no = "$can_build_shared" && enable_shared=no
# On AIX, shared libraries and static libraries use the same namespace, and
# are all built from PIC.
case $host_os in
aix3*)
- test "$enable_shared" = yes && enable_static=no
+ test yes = "$enable_shared" && enable_static=no
if test -n "$RANLIB"; then
archive_cmds="$archive_cmds~\$RANLIB \$lib"
postinstall_cmds='$RANLIB $lib'
@@ -5791,8 +6255,12 @@ if test -n "$compiler"; then
;;
aix[[4-9]]*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
+ if test ia64 != "$host_cpu"; then
+ case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+ yes,aix,yes) ;; # shared object as lib.so file only
+ yes,svr4,*) ;; # shared object as lib.so archive member only
+ yes,*) enable_static=no ;; # shared object in lib.a archive as well
+ esac
fi
;;
esac
@@ -5800,13 +6268,13 @@ if test -n "$compiler"; then
AC_MSG_CHECKING([whether to build static libraries])
# Make sure either enable_shared or enable_static is yes.
- test "$enable_shared" = yes || enable_static=yes
+ test yes = "$enable_shared" || enable_static=yes
AC_MSG_RESULT([$enable_static])
_LT_CONFIG($1)
fi
AC_LANG_POP
-CC="$lt_save_CC"
+CC=$lt_save_CC
])# _LT_LANG_C_CONFIG
@@ -5814,14 +6282,14 @@ CC="$lt_save_CC"
# --------------------------
# Ensure that the configuration variables for a C++ compiler are suitably
# defined. These variables are subsequently used by _LT_CONFIG to write
-# the compiler configuration to `libtool'.
+# the compiler configuration to 'libtool'.
m4_defun([_LT_LANG_CXX_CONFIG],
[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
m4_require([_LT_DECL_EGREP])dnl
m4_require([_LT_PATH_MANIFEST_TOOL])dnl
-if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
- ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
- (test "X$CXX" != "Xg++"))) ; then
+if test -n "$CXX" && ( test no != "$CXX" &&
+ ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) ||
+ (test g++ != "$CXX"))); then
AC_PROG_CXXCPP
else
_lt_caught_CXX_error=yes
@@ -5863,7 +6331,7 @@ _LT_TAGVAR(objext, $1)=$objext
# the CXX compiler isn't working. Some variables (like enable_shared)
# are currently assumed to apply to all compilers on this platform,
# and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_caught_CXX_error" != yes; then
+if test yes != "$_lt_caught_CXX_error"; then
# Code to be used in simple compile tests
lt_simple_compile_test_code="int some_variable = 0;"
@@ -5905,35 +6373,35 @@ if test "$_lt_caught_CXX_error" != yes; then
if test -n "$compiler"; then
# We don't want -fno-exception when compiling C++ code, so set the
# no_builtin_flag separately
- if test "$GXX" = yes; then
+ if test yes = "$GXX"; then
_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
else
_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
fi
- if test "$GXX" = yes; then
+ if test yes = "$GXX"; then
# Set up default GNU C++ configuration
LT_PATH_LD
# Check if GNU C++ uses GNU ld as the underlying linker, since the
# archiving commands below assume that GNU ld is being used.
- if test "$with_gnu_ld" = yes; then
- _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ if test yes = "$with_gnu_ld"; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
# If archive_cmds runs LD, not CC, wlarc should be empty
# XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
# investigate it a little bit more. (MM)
- wlarc='${wl}'
+ wlarc='$wl'
# ancient GNU ld didn't support --whole-archive et. al.
if eval "`$CC -print-prog-name=ld` --help 2>&1" |
$GREP 'no-whole-archive' > /dev/null; then
- _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
else
_LT_TAGVAR(whole_archive_flag_spec, $1)=
fi
@@ -5969,18 +6437,30 @@ if test "$_lt_caught_CXX_error" != yes; then
_LT_TAGVAR(ld_shlibs, $1)=no
;;
aix[[4-9]]*)
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# On IA64, the linker does run time linking by default, so we don't
# have to do anything special.
aix_use_runtimelinking=no
exp_sym_flag='-Bexport'
- no_entry_flag=""
+ no_entry_flag=
else
aix_use_runtimelinking=no
# Test if we are trying to use run time linking or normal
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
- # need to do runtime linking.
+ # have runtime linking enabled, and use it for executables.
+ # For shared libraries, we enable/disable runtime linking
+ # depending on the kind of the shared library created -
+ # when "with_aix_soname,aix_use_runtimelinking" is:
+ # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables
+ # "aix,yes" lib.so shared, rtl:yes, for executables
+ # lib.a static archive
+ # "both,no" lib.so.V(shr.o) shared, rtl:yes
+ # lib.a(lib.so.V) shared, rtl:no, for executables
+ # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables
+ # lib.a(lib.so.V) shared, rtl:no
+ # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables
+ # lib.a static archive
case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
for ld_flag in $LDFLAGS; do
case $ld_flag in
@@ -5990,6 +6470,13 @@ if test "$_lt_caught_CXX_error" != yes; then
;;
esac
done
+ if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then
+ # With aix-soname=svr4, we create the lib.so.V shared archives only,
+ # so we don't have lib.a shared libs to link our executables.
+ # We have to force runtime linking in this case.
+ aix_use_runtimelinking=yes
+ LDFLAGS="$LDFLAGS -Wl,-brtl"
+ fi
;;
esac
@@ -6008,13 +6495,21 @@ if test "$_lt_caught_CXX_error" != yes; then
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
_LT_TAGVAR(link_all_deplibs, $1)=yes
- _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+ _LT_TAGVAR(file_list_spec, $1)='$wl-f,'
+ case $with_aix_soname,$aix_use_runtimelinking in
+ aix,*) ;; # no import file
+ svr4,* | *,yes) # use import file
+ # The Import File defines what to hardcode.
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+ ;;
+ esac
- if test "$GXX" = yes; then
+ if test yes = "$GXX"; then
case $host_os in aix4.[[012]]|aix4.[[012]].*)
# We only want to do this on AIX 4.2 and lower, the check
# below for broken collect2 doesn't work under 4.3+
- collect2name=`${CC} -print-prog-name=collect2`
+ collect2name=`$CC -print-prog-name=collect2`
if test -f "$collect2name" &&
strings "$collect2name" | $GREP resolve_lib_name >/dev/null
then
@@ -6032,64 +6527,84 @@ if test "$_lt_caught_CXX_error" != yes; then
fi
esac
shared_flag='-shared'
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag="$shared_flag "'${wl}-G'
+ if test yes = "$aix_use_runtimelinking"; then
+ shared_flag=$shared_flag' $wl-G'
fi
+ # Need to ensure runtime linking is disabled for the traditional
+ # shared library, or the linker may eventually find shared libraries
+ # /with/ Import File - we do not want to mix them.
+ shared_flag_aix='-shared'
+ shared_flag_svr4='-shared $wl-G'
else
# not using gcc
- if test "$host_cpu" = ia64; then
+ if test ia64 = "$host_cpu"; then
# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
# chokes on -Wl,-G. The following line is correct:
shared_flag='-G'
else
- if test "$aix_use_runtimelinking" = yes; then
- shared_flag='${wl}-G'
+ if test yes = "$aix_use_runtimelinking"; then
+ shared_flag='$wl-G'
else
- shared_flag='${wl}-bM:SRE'
+ shared_flag='$wl-bM:SRE'
fi
+ shared_flag_aix='$wl-bM:SRE'
+ shared_flag_svr4='$wl-G'
fi
fi
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall'
# It seems that -bexpall does not export symbols beginning with
# underscore (_), so it is better to generate a list of symbols to
# export.
_LT_TAGVAR(always_export_symbols, $1)=yes
- if test "$aix_use_runtimelinking" = yes; then
+ if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then
# Warning - without using the other runtime loading flags (-brtl),
# -berok will link without error, but may produce a broken library.
- _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+ # The "-G" linker flag allows undefined symbols.
+ _LT_TAGVAR(no_undefined_flag, $1)='-bernotok'
# Determine the default libpath from the value encoded in an empty
# executable.
_LT_SYS_MODULE_PATH_AIX([$1])
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
else
- if test "$host_cpu" = ia64; then
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+ if test ia64 = "$host_cpu"; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib'
_LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
- _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
else
# Determine the default libpath from the value encoded in an
# empty executable.
_LT_SYS_MODULE_PATH_AIX([$1])
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
# Warning - without using the other run time loading flags,
# -berok will link without error, but may produce a broken library.
- _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
- _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
- if test "$with_gnu_ld" = yes; then
+ _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok'
+ _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok'
+ if test yes = "$with_gnu_ld"; then
# We only use this code for GNU lds that support --whole-archive.
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
else
# Exported symbols can be pulled into shared objects from archives
_LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
fi
_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
- # This is similar to how AIX traditionally builds its shared
- # libraries.
- _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'
+ # -brtl affects multiple linker settings, -berok does not and is overridden later
+ compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`'
+ if test svr4 != "$with_aix_soname"; then
+ # This is similar to how AIX traditionally builds its shared
+ # libraries. Need -bnortl late, we may have -brtl in LDFLAGS.
+ _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'
+ fi
+ if test aix != "$with_aix_soname"; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp'
+ else
+ # used by -dlpreopen to get the symbols
+ _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir'
+ fi
+ _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d'
fi
fi
;;
@@ -6099,7 +6614,7 @@ if test "$_lt_caught_CXX_error" != yes; then
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
# Joseph Beckenbach <jrb3@best.com> says some releases of gcc
# support --undefined. This deserves some investigation. FIXME
- _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
@@ -6127,57 +6642,58 @@ if test "$_lt_caught_CXX_error" != yes; then
# Tell ltmain to make .lib files, not .a files.
libext=lib
# Tell ltmain to make .dll files, not .so files.
- shrext_cmds=".dll"
+ shrext_cmds=.dll
# FIXME: Setting linknames here is a bad hack.
- _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
- _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
- else
- $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
- fi~
- $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
- linknames='
+ _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+ cp "$export_symbols" "$output_objdir/$soname.def";
+ echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";
+ else
+ $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;
+ fi~
+ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+ linknames='
# The linker will not automatically build a static lib if we build a DLL.
# _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
# Don't use ranlib
_LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
_LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
- lt_tool_outputfile="@TOOL_OUTPUT@"~
- case $lt_outputfile in
- *.exe|*.EXE) ;;
- *)
- lt_outputfile="$lt_outputfile.exe"
- lt_tool_outputfile="$lt_tool_outputfile.exe"
- ;;
- esac~
- func_to_tool_file "$lt_outputfile"~
- if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
- $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
- $RM "$lt_outputfile.manifest";
- fi'
+ lt_tool_outputfile="@TOOL_OUTPUT@"~
+ case $lt_outputfile in
+ *.exe|*.EXE) ;;
+ *)
+ lt_outputfile=$lt_outputfile.exe
+ lt_tool_outputfile=$lt_tool_outputfile.exe
+ ;;
+ esac~
+ func_to_tool_file "$lt_outputfile"~
+ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then
+ $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+ $RM "$lt_outputfile.manifest";
+ fi'
;;
*)
# g++
# _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
# as there is no search path for DLLs.
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols'
_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
_LT_TAGVAR(always_export_symbols, $1)=no
_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
- # If the export-symbols file already is a .def file (1st line
- # is EXPORTS), use it as is; otherwise, prepend...
- _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
- cp $export_symbols $output_objdir/$soname.def;
- else
- echo EXPORTS > $output_objdir/$soname.def;
- cat $export_symbols >> $output_objdir/$soname.def;
- fi~
- $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file, use it as
+ # is; otherwise, prepend EXPORTS...
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
else
_LT_TAGVAR(ld_shlibs, $1)=no
fi
@@ -6188,6 +6704,34 @@ if test "$_lt_caught_CXX_error" != yes; then
_LT_DARWIN_LINKER_FEATURES($1)
;;
+ os2*)
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ shrext_cmds=.dll
+ _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+ $ECHO EXPORTS >> $output_objdir/$libname.def~
+ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~
+ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+ emximp -o $lib $output_objdir/$libname.def'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~
+ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~
+ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~
+ $ECHO EXPORTS >> $output_objdir/$libname.def~
+ prefix_cmds="$SED"~
+ if test EXPORTS = "`$SED 1q $export_symbols`"; then
+ prefix_cmds="$prefix_cmds -e 1d";
+ fi~
+ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~
+ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~
+ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~
+ emximp -o $lib $output_objdir/$libname.def'
+ _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ ;;
+
dgux*)
case $cc_basename in
ec++*)
@@ -6222,18 +6766,15 @@ if test "$_lt_caught_CXX_error" != yes; then
_LT_TAGVAR(ld_shlibs, $1)=yes
;;
- gnu*)
- ;;
-
haiku*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
_LT_TAGVAR(link_all_deplibs, $1)=yes
;;
hpux9*)
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
# but as the default
@@ -6245,7 +6786,7 @@ if test "$_lt_caught_CXX_error" != yes; then
_LT_TAGVAR(ld_shlibs, $1)=no
;;
aCC*)
- _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
@@ -6254,11 +6795,11 @@ if test "$_lt_caught_CXX_error" != yes; then
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
;;
*)
- if test "$GXX" = yes; then
- _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ if test yes = "$GXX"; then
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'
else
# FIXME: insert proper C++ library support
_LT_TAGVAR(ld_shlibs, $1)=no
@@ -6268,15 +6809,15 @@ if test "$_lt_caught_CXX_error" != yes; then
;;
hpux10*|hpux11*)
- if test $with_gnu_ld = no; then
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ if test no = "$with_gnu_ld"; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
case $host_cpu in
hppa*64*|ia64*)
;;
*)
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
;;
esac
fi
@@ -6302,13 +6843,13 @@ if test "$_lt_caught_CXX_error" != yes; then
aCC*)
case $host_cpu in
hppa*64*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
ia64*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
esac
# Commands to make compiler produce verbose output that lists
@@ -6319,20 +6860,20 @@ if test "$_lt_caught_CXX_error" != yes; then
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
- output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
;;
*)
- if test "$GXX" = yes; then
- if test $with_gnu_ld = no; then
+ if test yes = "$GXX"; then
+ if test no = "$with_gnu_ld"; then
case $host_cpu in
hppa*64*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
ia64*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
;;
esac
fi
@@ -6347,22 +6888,22 @@ if test "$_lt_caught_CXX_error" != yes; then
interix[[3-9]]*)
_LT_TAGVAR(hardcode_direct, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
# Instead, shared libraries are loaded at an image base (0x10000000 by
# default) and relocated if they conflict, which is a slow very memory
# consuming and fragmenting process. To avoid this, we pick a random,
# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
# time. Moving up from 0x10000000 also allows more sbrk(2) space.
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
;;
irix5* | irix6*)
case $cc_basename in
CC*)
# SGI C++
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
# Archives containing C++ object files must be created using
# "CC -ar", where "CC" is the IRIX C++ compiler. This is
@@ -6371,22 +6912,22 @@ if test "$_lt_caught_CXX_error" != yes; then
_LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
;;
*)
- if test "$GXX" = yes; then
- if test "$with_gnu_ld" = no; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ if test yes = "$GXX"; then
+ if test no = "$with_gnu_ld"; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
else
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib'
fi
fi
_LT_TAGVAR(link_all_deplibs, $1)=yes
;;
esac
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
_LT_TAGVAR(inherit_rpath, $1)=yes
;;
- linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
case $cc_basename in
KCC*)
# Kuck and Associates, Inc. (KAI) C++ Compiler
@@ -6394,8 +6935,8 @@ if test "$_lt_caught_CXX_error" != yes; then
# KCC will only create a shared library if the output file
# ends with ".so" (or ".sl" for HP-UX), so rename the library
# to its proper name (with version) after linking.
- _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib'
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
@@ -6404,10 +6945,10 @@ if test "$_lt_caught_CXX_error" != yes; then
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
- output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
# Archives containing C++ object files must be created using
# "CC -Bstatic", where "CC" is the KAI C++ compiler.
@@ -6421,59 +6962,59 @@ if test "$_lt_caught_CXX_error" != yes; then
# earlier do not add the objects themselves.
case `$CC -V 2>&1` in
*"Version 7."*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
;;
*) # Version 8.0 or newer
tmp_idyn=
case $host_cpu in
ia64*) tmp_idyn=' -i_dynamic';;
esac
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
;;
esac
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive'
;;
pgCC* | pgcpp*)
# Portland Group C++ compiler
case `$CC -V` in
*pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*)
_LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
- rm -rf $tpldir~
- $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
- compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
_LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
- rm -rf $tpldir~
- $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
- $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
- $RANLIB $oldlib'
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+ $RANLIB $oldlib'
_LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
- rm -rf $tpldir~
- $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
- $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
- rm -rf $tpldir~
- $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
- $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
;;
*) # Version 6 and above use weak symbols
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'
;;
esac
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl--rpath $wl$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
;;
cxx*)
# Compaq C++
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib $wl-retain-symbols-file $wl$export_symbols'
runpath_var=LD_RUN_PATH
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
@@ -6487,18 +7028,18 @@ if test "$_lt_caught_CXX_error" != yes; then
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
;;
xl* | mpixl* | bgxl*)
# IBM XL 8.0 on PPC, with GNU ld
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
- _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
- if test "x$supports_anon_versioning" = xyes; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'
+ if test yes = "$supports_anon_versioning"; then
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
- cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
- echo "local: *; };" >> $output_objdir/$libname.ver~
- $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
fi
;;
*)
@@ -6506,10 +7047,10 @@ if test "$_lt_caught_CXX_error" != yes; then
*Sun\ C*)
# Sun C++ 5.9
_LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
- _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
_LT_TAGVAR(compiler_needs_object, $1)=yes
# Not sure whether something based on
@@ -6567,22 +7108,17 @@ if test "$_lt_caught_CXX_error" != yes; then
_LT_TAGVAR(ld_shlibs, $1)=yes
;;
- openbsd2*)
- # C++ shared libraries are fairly broken
- _LT_TAGVAR(ld_shlibs, $1)=no
- ;;
-
- openbsd*)
+ openbsd* | bitrig*)
if test -f /usr/libexec/ld.so; then
_LT_TAGVAR(hardcode_direct, $1)=yes
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
- if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
- _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'
fi
output_verbose_link_cmd=func_echo_all
else
@@ -6598,9 +7134,9 @@ if test "$_lt_caught_CXX_error" != yes; then
# KCC will only create a shared library if the output file
# ends with ".so" (or ".sl" for HP-UX), so rename the library
# to its proper name (with version) after linking.
- _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
# Archives containing C++ object files must be created using
@@ -6618,17 +7154,17 @@ if test "$_lt_caught_CXX_error" != yes; then
cxx*)
case $host in
osf3*)
- _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
;;
*)
_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
- echo "-hidden">> $lib.exp~
- $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
- $RM $lib.exp'
+ echo "-hidden">> $lib.exp~
+ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~
+ $RM $lib.exp'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
;;
esac
@@ -6643,21 +7179,21 @@ if test "$_lt_caught_CXX_error" != yes; then
# explicitly linking system object files so we need to strip them
# from the output so that they don't get included in the library
# dependencies.
- output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
;;
*)
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ if test yes,no = "$GXX,$with_gnu_ld"; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*'
case $host in
osf3*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
;;
*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'
;;
esac
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=:
# Commands to make compiler produce verbose output that lists
@@ -6703,9 +7239,9 @@ if test "$_lt_caught_CXX_error" != yes; then
# Sun C++ 4.2, 5.x and Centerline C++
_LT_TAGVAR(archive_cmds_need_lc,$1)=yes
_LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
- _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
- $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+ $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
@@ -6713,7 +7249,7 @@ if test "$_lt_caught_CXX_error" != yes; then
solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
*)
# The compiler driver will combine and reorder linker options,
- # but understands `-z linker_flag'.
+ # but understands '-z linker_flag'.
# Supported since Solaris 2.6 (maybe 2.5.1?)
_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
;;
@@ -6730,30 +7266,30 @@ if test "$_lt_caught_CXX_error" != yes; then
;;
gcx*)
# Green Hills C++ Compiler
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
# The C++ compiler must be used to create the archive.
_LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
;;
*)
# GNU C++ compiler with Solaris linker
- if test "$GXX" = yes && test "$with_gnu_ld" = no; then
- _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+ if test yes,no = "$GXX,$with_gnu_ld"; then
+ _LT_TAGVAR(no_undefined_flag, $1)=' $wl-z ${wl}defs'
if $CC --version | $GREP -v '^2\.7' > /dev/null; then
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
- $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+ $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
# linking a shared library.
output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
else
- # g++ 2.7 appears to require `-G' NOT `-shared' on this
+ # g++ 2.7 appears to require '-G' NOT '-shared' on this
# platform.
- _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
- $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+ $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
# Commands to make compiler produce verbose output that lists
# what "hidden" libraries, object files and flags are used when
@@ -6761,11 +7297,11 @@ if test "$_lt_caught_CXX_error" != yes; then
output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
fi
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir'
case $host_os in
solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
*)
- _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'
;;
esac
fi
@@ -6774,52 +7310,52 @@ if test "$_lt_caught_CXX_error" != yes; then
;;
sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
- _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
runpath_var='LD_RUN_PATH'
case $cc_basename in
CC*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
;;
*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
;;
esac
;;
sysv5* | sco3.2v5* | sco5v6*)
- # Note: We can NOT use -z defs as we might desire, because we do not
+ # Note: We CANNOT use -z defs as we might desire, because we do not
# link with -lc, and that would cause any symbols used from libc to
# always be unresolved, which means just about no library would
# ever link correctly. If we're not using GNU ld we use -z text
# though, which does catch some bad symbols but isn't as heavy-handed
# as -z defs.
- _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
- _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+ _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text'
+ _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs'
_LT_TAGVAR(archive_cmds_need_lc, $1)=no
_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
- _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir'
_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
_LT_TAGVAR(link_all_deplibs, $1)=yes
- _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport'
runpath_var='LD_RUN_PATH'
case $cc_basename in
CC*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
_LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~
- '"$_LT_TAGVAR(old_archive_cmds, $1)"
+ '"$_LT_TAGVAR(old_archive_cmds, $1)"
_LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~
- '"$_LT_TAGVAR(reload_cmds, $1)"
+ '"$_LT_TAGVAR(reload_cmds, $1)"
;;
*)
- _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
- _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
;;
esac
;;
@@ -6850,10 +7386,10 @@ if test "$_lt_caught_CXX_error" != yes; then
esac
AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
- test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+ test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no
- _LT_TAGVAR(GCC, $1)="$GXX"
- _LT_TAGVAR(LD, $1)="$LD"
+ _LT_TAGVAR(GCC, $1)=$GXX
+ _LT_TAGVAR(LD, $1)=$LD
## CAVEAT EMPTOR:
## There is no encapsulation within the following macros, do not change
@@ -6880,7 +7416,7 @@ if test "$_lt_caught_CXX_error" != yes; then
lt_cv_path_LD=$lt_save_path_LD
lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-fi # test "$_lt_caught_CXX_error" != yes
+fi # test yes != "$_lt_caught_CXX_error"
AC_LANG_POP
])# _LT_LANG_CXX_CONFIG
@@ -6902,13 +7438,14 @@ AC_REQUIRE([_LT_DECL_SED])
AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])
func_stripname_cnf ()
{
- case ${2} in
- .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
- *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+ case @S|@2 in
+ .*) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%\\\\@S|@2\$%%"`;;
+ *) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%@S|@2\$%%"`;;
esac
} # func_stripname_cnf
])# _LT_FUNC_STRIPNAME_CNF
+
# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
# ---------------------------------
# Figure out "hidden" library dependencies from verbose
@@ -6992,13 +7529,13 @@ if AC_TRY_EVAL(ac_compile); then
pre_test_object_deps_done=no
for p in `eval "$output_verbose_link_cmd"`; do
- case ${prev}${p} in
+ case $prev$p in
-L* | -R* | -l*)
# Some compilers place space between "-{L,R}" and the path.
# Remove the space.
- if test $p = "-L" ||
- test $p = "-R"; then
+ if test x-L = "$p" ||
+ test x-R = "$p"; then
prev=$p
continue
fi
@@ -7014,16 +7551,16 @@ if AC_TRY_EVAL(ac_compile); then
case $p in
=*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
esac
- if test "$pre_test_object_deps_done" = no; then
- case ${prev} in
+ if test no = "$pre_test_object_deps_done"; then
+ case $prev in
-L | -R)
# Internal compiler library paths should come after those
# provided the user. The postdeps already come after the
# user supplied libs so there is no need to process them.
if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
- _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+ _LT_TAGVAR(compiler_lib_search_path, $1)=$prev$p
else
- _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+ _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} $prev$p"
fi
;;
# The "-l" case would never come before the object being
@@ -7031,9 +7568,9 @@ if AC_TRY_EVAL(ac_compile); then
esac
else
if test -z "$_LT_TAGVAR(postdeps, $1)"; then
- _LT_TAGVAR(postdeps, $1)="${prev}${p}"
+ _LT_TAGVAR(postdeps, $1)=$prev$p
else
- _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
+ _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} $prev$p"
fi
fi
prev=
@@ -7048,15 +7585,15 @@ if AC_TRY_EVAL(ac_compile); then
continue
fi
- if test "$pre_test_object_deps_done" = no; then
+ if test no = "$pre_test_object_deps_done"; then
if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
- _LT_TAGVAR(predep_objects, $1)="$p"
+ _LT_TAGVAR(predep_objects, $1)=$p
else
_LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
fi
else
if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
- _LT_TAGVAR(postdep_objects, $1)="$p"
+ _LT_TAGVAR(postdep_objects, $1)=$p
else
_LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
fi
@@ -7087,51 +7624,6 @@ interix[[3-9]]*)
_LT_TAGVAR(postdep_objects,$1)=
_LT_TAGVAR(postdeps,$1)=
;;
-
-linux*)
- case `$CC -V 2>&1 | sed 5q` in
- *Sun\ C*)
- # Sun C++ 5.9
-
- # The more standards-conforming stlport4 library is
- # incompatible with the Cstd library. Avoid specifying
- # it if it's in CXXFLAGS. Ignore libCrun as
- # -library=stlport4 depends on it.
- case " $CXX $CXXFLAGS " in
- *" -library=stlport4 "*)
- solaris_use_stlport4=yes
- ;;
- esac
-
- if test "$solaris_use_stlport4" != yes; then
- _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
- fi
- ;;
- esac
- ;;
-
-solaris*)
- case $cc_basename in
- CC* | sunCC*)
- # The more standards-conforming stlport4 library is
- # incompatible with the Cstd library. Avoid specifying
- # it if it's in CXXFLAGS. Ignore libCrun as
- # -library=stlport4 depends on it.
- case " $CXX $CXXFLAGS " in
- *" -library=stlport4 "*)
- solaris_use_stlport4=yes
- ;;
- esac
-
- # Adding this requires a known-good setup of shared libraries for
- # Sun compiler versions before 5.6, else PIC objects from an old
- # archive will be linked into the output, leading to subtle bugs.
- if test "$solaris_use_stlport4" != yes; then
- _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
- fi
- ;;
- esac
- ;;
esac
])
@@ -7140,7 +7632,7 @@ case " $_LT_TAGVAR(postdeps, $1) " in
esac
_LT_TAGVAR(compiler_lib_search_dirs, $1)=
if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
- _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | $SED -e 's! -L! !g' -e 's!^ !!'`
fi
_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
[The directories searched by this compiler when creating a shared library])
@@ -7160,10 +7652,10 @@ _LT_TAGDECL([], [compiler_lib_search_path], [1],
# --------------------------
# Ensure that the configuration variables for a Fortran 77 compiler are
# suitably defined. These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
m4_defun([_LT_LANG_F77_CONFIG],
[AC_LANG_PUSH(Fortran 77)
-if test -z "$F77" || test "X$F77" = "Xno"; then
+if test -z "$F77" || test no = "$F77"; then
_lt_disable_F77=yes
fi
@@ -7200,7 +7692,7 @@ _LT_TAGVAR(objext, $1)=$objext
# the F77 compiler isn't working. Some variables (like enable_shared)
# are currently assumed to apply to all compilers on this platform,
# and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_F77" != yes; then
+if test yes != "$_lt_disable_F77"; then
# Code to be used in simple compile tests
lt_simple_compile_test_code="\
subroutine t
@@ -7222,7 +7714,7 @@ if test "$_lt_disable_F77" != yes; then
_LT_LINKER_BOILERPLATE
# Allow CC to be a program name with arguments.
- lt_save_CC="$CC"
+ lt_save_CC=$CC
lt_save_GCC=$GCC
lt_save_CFLAGS=$CFLAGS
CC=${F77-"f77"}
@@ -7236,21 +7728,25 @@ if test "$_lt_disable_F77" != yes; then
AC_MSG_RESULT([$can_build_shared])
AC_MSG_CHECKING([whether to build shared libraries])
- test "$can_build_shared" = "no" && enable_shared=no
+ test no = "$can_build_shared" && enable_shared=no
# On AIX, shared libraries and static libraries use the same namespace, and
# are all built from PIC.
case $host_os in
aix3*)
- test "$enable_shared" = yes && enable_static=no
+ test yes = "$enable_shared" && enable_static=no
if test -n "$RANLIB"; then
archive_cmds="$archive_cmds~\$RANLIB \$lib"
postinstall_cmds='$RANLIB $lib'
fi
;;
aix[[4-9]]*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
+ if test ia64 != "$host_cpu"; then
+ case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+ yes,aix,yes) ;; # shared object as lib.so file only
+ yes,svr4,*) ;; # shared object as lib.so archive member only
+ yes,*) enable_static=no ;; # shared object in lib.a archive as well
+ esac
fi
;;
esac
@@ -7258,11 +7754,11 @@ if test "$_lt_disable_F77" != yes; then
AC_MSG_CHECKING([whether to build static libraries])
# Make sure either enable_shared or enable_static is yes.
- test "$enable_shared" = yes || enable_static=yes
+ test yes = "$enable_shared" || enable_static=yes
AC_MSG_RESULT([$enable_static])
- _LT_TAGVAR(GCC, $1)="$G77"
- _LT_TAGVAR(LD, $1)="$LD"
+ _LT_TAGVAR(GCC, $1)=$G77
+ _LT_TAGVAR(LD, $1)=$LD
## CAVEAT EMPTOR:
## There is no encapsulation within the following macros, do not change
@@ -7279,9 +7775,9 @@ if test "$_lt_disable_F77" != yes; then
fi # test -n "$compiler"
GCC=$lt_save_GCC
- CC="$lt_save_CC"
- CFLAGS="$lt_save_CFLAGS"
-fi # test "$_lt_disable_F77" != yes
+ CC=$lt_save_CC
+ CFLAGS=$lt_save_CFLAGS
+fi # test yes != "$_lt_disable_F77"
AC_LANG_POP
])# _LT_LANG_F77_CONFIG
@@ -7291,11 +7787,11 @@ AC_LANG_POP
# -------------------------
# Ensure that the configuration variables for a Fortran compiler are
# suitably defined. These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
m4_defun([_LT_LANG_FC_CONFIG],
[AC_LANG_PUSH(Fortran)
-if test -z "$FC" || test "X$FC" = "Xno"; then
+if test -z "$FC" || test no = "$FC"; then
_lt_disable_FC=yes
fi
@@ -7332,7 +7828,7 @@ _LT_TAGVAR(objext, $1)=$objext
# the FC compiler isn't working. Some variables (like enable_shared)
# are currently assumed to apply to all compilers on this platform,
# and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_FC" != yes; then
+if test yes != "$_lt_disable_FC"; then
# Code to be used in simple compile tests
lt_simple_compile_test_code="\
subroutine t
@@ -7354,7 +7850,7 @@ if test "$_lt_disable_FC" != yes; then
_LT_LINKER_BOILERPLATE
# Allow CC to be a program name with arguments.
- lt_save_CC="$CC"
+ lt_save_CC=$CC
lt_save_GCC=$GCC
lt_save_CFLAGS=$CFLAGS
CC=${FC-"f95"}
@@ -7370,21 +7866,25 @@ if test "$_lt_disable_FC" != yes; then
AC_MSG_RESULT([$can_build_shared])
AC_MSG_CHECKING([whether to build shared libraries])
- test "$can_build_shared" = "no" && enable_shared=no
+ test no = "$can_build_shared" && enable_shared=no
# On AIX, shared libraries and static libraries use the same namespace, and
# are all built from PIC.
case $host_os in
aix3*)
- test "$enable_shared" = yes && enable_static=no
+ test yes = "$enable_shared" && enable_static=no
if test -n "$RANLIB"; then
archive_cmds="$archive_cmds~\$RANLIB \$lib"
postinstall_cmds='$RANLIB $lib'
fi
;;
aix[[4-9]]*)
- if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
- test "$enable_shared" = yes && enable_static=no
+ if test ia64 != "$host_cpu"; then
+ case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in
+ yes,aix,yes) ;; # shared object as lib.so file only
+ yes,svr4,*) ;; # shared object as lib.so archive member only
+ yes,*) enable_static=no ;; # shared object in lib.a archive as well
+ esac
fi
;;
esac
@@ -7392,11 +7892,11 @@ if test "$_lt_disable_FC" != yes; then
AC_MSG_CHECKING([whether to build static libraries])
# Make sure either enable_shared or enable_static is yes.
- test "$enable_shared" = yes || enable_static=yes
+ test yes = "$enable_shared" || enable_static=yes
AC_MSG_RESULT([$enable_static])
- _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
- _LT_TAGVAR(LD, $1)="$LD"
+ _LT_TAGVAR(GCC, $1)=$ac_cv_fc_compiler_gnu
+ _LT_TAGVAR(LD, $1)=$LD
## CAVEAT EMPTOR:
## There is no encapsulation within the following macros, do not change
@@ -7416,7 +7916,7 @@ if test "$_lt_disable_FC" != yes; then
GCC=$lt_save_GCC
CC=$lt_save_CC
CFLAGS=$lt_save_CFLAGS
-fi # test "$_lt_disable_FC" != yes
+fi # test yes != "$_lt_disable_FC"
AC_LANG_POP
])# _LT_LANG_FC_CONFIG
@@ -7426,7 +7926,7 @@ AC_LANG_POP
# --------------------------
# Ensure that the configuration variables for the GNU Java Compiler compiler
# are suitably defined. These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
m4_defun([_LT_LANG_GCJ_CONFIG],
[AC_REQUIRE([LT_PROG_GCJ])dnl
AC_LANG_SAVE
@@ -7460,7 +7960,7 @@ CC=${GCJ-"gcj"}
CFLAGS=$GCJFLAGS
compiler=$CC
_LT_TAGVAR(compiler, $1)=$CC
-_LT_TAGVAR(LD, $1)="$LD"
+_LT_TAGVAR(LD, $1)=$LD
_LT_CC_BASENAME([$compiler])
# GCJ did not exist at the time GCC didn't implicitly link libc in.
@@ -7497,7 +7997,7 @@ CFLAGS=$lt_save_CFLAGS
# --------------------------
# Ensure that the configuration variables for the GNU Go compiler
# are suitably defined. These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
m4_defun([_LT_LANG_GO_CONFIG],
[AC_REQUIRE([LT_PROG_GO])dnl
AC_LANG_SAVE
@@ -7531,7 +8031,7 @@ CC=${GOC-"gccgo"}
CFLAGS=$GOFLAGS
compiler=$CC
_LT_TAGVAR(compiler, $1)=$CC
-_LT_TAGVAR(LD, $1)="$LD"
+_LT_TAGVAR(LD, $1)=$LD
_LT_CC_BASENAME([$compiler])
# Go did not exist at the time GCC didn't implicitly link libc in.
@@ -7568,7 +8068,7 @@ CFLAGS=$lt_save_CFLAGS
# -------------------------
# Ensure that the configuration variables for the Windows resource compiler
# are suitably defined. These variables are subsequently used by _LT_CONFIG
-# to write the compiler configuration to `libtool'.
+# to write the compiler configuration to 'libtool'.
m4_defun([_LT_LANG_RC_CONFIG],
[AC_REQUIRE([LT_PROG_RC])dnl
AC_LANG_SAVE
@@ -7584,7 +8084,7 @@ _LT_TAGVAR(objext, $1)=$objext
lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
# Code to be used in simple link tests
-lt_simple_link_test_code="$lt_simple_compile_test_code"
+lt_simple_link_test_code=$lt_simple_compile_test_code
# ltmain only uses $CC for tagged configurations so make sure $CC is set.
_LT_TAG_COMPILER
@@ -7594,7 +8094,7 @@ _LT_COMPILER_BOILERPLATE
_LT_LINKER_BOILERPLATE
# Allow CC to be a program name with arguments.
-lt_save_CC="$CC"
+lt_save_CC=$CC
lt_save_CFLAGS=$CFLAGS
lt_save_GCC=$GCC
GCC=
@@ -7623,7 +8123,7 @@ AC_DEFUN([LT_PROG_GCJ],
[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
[m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
[AC_CHECK_TOOL(GCJ, gcj,)
- test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+ test set = "${GCJFLAGS+set}" || GCJFLAGS="-g -O2"
AC_SUBST(GCJFLAGS)])])[]dnl
])
@@ -7734,7 +8234,7 @@ lt_ac_count=0
# Add /usr/xpg4/bin/sed as it is typically found on Solaris
# along with /bin/sed that truncates output.
for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
- test ! -f $lt_ac_sed && continue
+ test ! -f "$lt_ac_sed" && continue
cat /dev/null > conftest.in
lt_ac_count=0
echo $ECHO_N "0123456789$ECHO_C" >conftest.in
@@ -7751,9 +8251,9 @@ for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
$lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
cmp -s conftest.out conftest.nl || break
# 10000 chars as input seems more than enough
- test $lt_ac_count -gt 10 && break
+ test 10 -lt "$lt_ac_count" && break
lt_ac_count=`expr $lt_ac_count + 1`
- if test $lt_ac_count -gt $lt_ac_max; then
+ if test "$lt_ac_count" -gt "$lt_ac_max"; then
lt_ac_max=$lt_ac_count
lt_cv_path_SED=$lt_ac_sed
fi
@@ -7777,27 +8277,7 @@ dnl AC_DEFUN([LT_AC_PROG_SED], [])
# Find out whether the shell is Bourne or XSI compatible,
# or has some other useful features.
m4_defun([_LT_CHECK_SHELL_FEATURES],
-[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
-# Try some XSI features
-xsi_shell=no
-( _lt_dummy="a/b/c"
- test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
- = c,a/b,b/c, \
- && eval 'test $(( 1 + 1 )) -eq 2 \
- && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
- && xsi_shell=yes
-AC_MSG_RESULT([$xsi_shell])
-_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
-
-AC_MSG_CHECKING([whether the shell understands "+="])
-lt_shell_append=no
-( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
- >/dev/null 2>&1 \
- && lt_shell_append=yes
-AC_MSG_RESULT([$lt_shell_append])
-_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
-
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+[if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
lt_unset=unset
else
lt_unset=false
@@ -7821,102 +8301,9 @@ _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
])# _LT_CHECK_SHELL_FEATURES
-# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY)
-# ------------------------------------------------------
-# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and
-# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY.
-m4_defun([_LT_PROG_FUNCTION_REPLACE],
-[dnl {
-sed -e '/^$1 ()$/,/^} # $1 /c\
-$1 ()\
-{\
-m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1])
-} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \
- && mv -f "$cfgfile.tmp" "$cfgfile" \
- || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
-test 0 -eq $? || _lt_function_replace_fail=:
-])
-
-
-# _LT_PROG_REPLACE_SHELLFNS
-# -------------------------
-# Replace existing portable implementations of several shell functions with
-# equivalent extended shell implementations where those features are available..
-m4_defun([_LT_PROG_REPLACE_SHELLFNS],
-[if test x"$xsi_shell" = xyes; then
- _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl
- case ${1} in
- */*) func_dirname_result="${1%/*}${2}" ;;
- * ) func_dirname_result="${3}" ;;
- esac])
-
- _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl
- func_basename_result="${1##*/}"])
-
- _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl
- case ${1} in
- */*) func_dirname_result="${1%/*}${2}" ;;
- * ) func_dirname_result="${3}" ;;
- esac
- func_basename_result="${1##*/}"])
-
- _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl
- # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
- # positional parameters, so assign one to ordinary parameter first.
- func_stripname_result=${3}
- func_stripname_result=${func_stripname_result#"${1}"}
- func_stripname_result=${func_stripname_result%"${2}"}])
-
- _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl
- func_split_long_opt_name=${1%%=*}
- func_split_long_opt_arg=${1#*=}])
-
- _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl
- func_split_short_opt_arg=${1#??}
- func_split_short_opt_name=${1%"$func_split_short_opt_arg"}])
-
- _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl
- case ${1} in
- *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
- *) func_lo2o_result=${1} ;;
- esac])
-
- _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo])
-
- _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))])
-
- _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}])
-fi
-
-if test x"$lt_shell_append" = xyes; then
- _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"])
-
- _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl
- func_quote_for_eval "${2}"
-dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \
- eval "${1}+=\\\\ \\$func_quote_for_eval_result"])
-
- # Save a `func_append' function call where possible by direct use of '+='
- sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
- && mv -f "$cfgfile.tmp" "$cfgfile" \
- || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
- test 0 -eq $? || _lt_function_replace_fail=:
-else
- # Save a `func_append' function call even when '+=' is not available
- sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
- && mv -f "$cfgfile.tmp" "$cfgfile" \
- || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
- test 0 -eq $? || _lt_function_replace_fail=:
-fi
-
-if test x"$_lt_function_replace_fail" = x":"; then
- AC_MSG_WARN([Unable to substitute extended shell functions in $ofile])
-fi
-])
-
# _LT_PATH_CONVERSION_FUNCTIONS
# -----------------------------
-# Determine which file name conversion functions should be used by
+# Determine what file name conversion functions should be used by
# func_to_host_file (and, implicitly, by func_to_host_path). These are needed
# for certain cross-compile configurations and native mingw.
m4_defun([_LT_PATH_CONVERSION_FUNCTIONS],
diff --git a/contrib/libxo/m4/ltoptions.m4 b/contrib/libxo/m4/ltoptions.m4
index 5d9acd8..94b0829 100644
--- a/contrib/libxo/m4/ltoptions.m4
+++ b/contrib/libxo/m4/ltoptions.m4
@@ -1,14 +1,14 @@
# Helper functions for option handling. -*- Autoconf -*-
#
-# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
-# Inc.
+# Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software
+# Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
-# serial 7 ltoptions.m4
+# serial 8 ltoptions.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
@@ -29,7 +29,7 @@ m4_define([_LT_SET_OPTION],
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
_LT_MANGLE_DEFUN([$1], [$2]),
- [m4_warning([Unknown $1 option `$2'])])[]dnl
+ [m4_warning([Unknown $1 option '$2'])])[]dnl
])
@@ -75,13 +75,15 @@ m4_if([$1],[LT_INIT],[
dnl
dnl If no reference was made to various pairs of opposing options, then
dnl we run the default mode handler for the pair. For example, if neither
- dnl `shared' nor `disable-shared' was passed, we enable building of shared
+ dnl 'shared' nor 'disable-shared' was passed, we enable building of shared
dnl archives by default:
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
- [_LT_ENABLE_FAST_INSTALL])
+ [_LT_ENABLE_FAST_INSTALL])
+ _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4],
+ [_LT_WITH_AIX_SONAME([aix])])
])
])# _LT_SET_OPTIONS
@@ -112,7 +114,7 @@ AU_DEFUN([AC_LIBTOOL_DLOPEN],
[_LT_SET_OPTION([LT_INIT], [dlopen])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `dlopen' option into LT_INIT's first parameter.])
+put the 'dlopen' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
@@ -148,7 +150,7 @@ AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
_LT_SET_OPTION([LT_INIT], [win32-dll])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `win32-dll' option into LT_INIT's first parameter.])
+put the 'win32-dll' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
@@ -157,9 +159,9 @@ dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
# _LT_ENABLE_SHARED([DEFAULT])
# ----------------------------
-# implement the --enable-shared flag, and supports the `shared' and
-# `disable-shared' LT_INIT options.
-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+# implement the --enable-shared flag, and supports the 'shared' and
+# 'disable-shared' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_SHARED],
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([shared],
@@ -172,14 +174,14 @@ AC_ARG_ENABLE([shared],
*)
enable_shared=no
# Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_shared=yes
fi
done
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
;;
esac],
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
@@ -211,9 +213,9 @@ dnl AC_DEFUN([AM_DISABLE_SHARED], [])
# _LT_ENABLE_STATIC([DEFAULT])
# ----------------------------
-# implement the --enable-static flag, and support the `static' and
-# `disable-static' LT_INIT options.
-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+# implement the --enable-static flag, and support the 'static' and
+# 'disable-static' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_STATIC],
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([static],
@@ -226,14 +228,14 @@ AC_ARG_ENABLE([static],
*)
enable_static=no
# Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_static=yes
fi
done
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
;;
esac],
[enable_static=]_LT_ENABLE_STATIC_DEFAULT)
@@ -265,9 +267,9 @@ dnl AC_DEFUN([AM_DISABLE_STATIC], [])
# _LT_ENABLE_FAST_INSTALL([DEFAULT])
# ----------------------------------
-# implement the --enable-fast-install flag, and support the `fast-install'
-# and `disable-fast-install' LT_INIT options.
-# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+# implement the --enable-fast-install flag, and support the 'fast-install'
+# and 'disable-fast-install' LT_INIT options.
+# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'.
m4_define([_LT_ENABLE_FAST_INSTALL],
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
AC_ARG_ENABLE([fast-install],
@@ -280,14 +282,14 @@ AC_ARG_ENABLE([fast-install],
*)
enable_fast_install=no
# Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for pkg in $enableval; do
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
if test "X$pkg" = "X$p"; then
enable_fast_install=yes
fi
done
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
;;
esac],
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
@@ -304,14 +306,14 @@ AU_DEFUN([AC_ENABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `fast-install' option into LT_INIT's first parameter.])
+the 'fast-install' option into LT_INIT's first parameter.])
])
AU_DEFUN([AC_DISABLE_FAST_INSTALL],
[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
-the `disable-fast-install' option into LT_INIT's first parameter.])
+the 'disable-fast-install' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
@@ -319,11 +321,64 @@ dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
+# _LT_WITH_AIX_SONAME([DEFAULT])
+# ----------------------------------
+# implement the --with-aix-soname flag, and support the `aix-soname=aix'
+# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
+# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'.
+m4_define([_LT_WITH_AIX_SONAME],
+[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
+shared_archive_member_spec=
+case $host,$enable_shared in
+power*-*-aix[[5-9]]*,yes)
+ AC_MSG_CHECKING([which variant of shared library versioning to provide])
+ AC_ARG_WITH([aix-soname],
+ [AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
+ [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
+ [case $withval in
+ aix|svr4|both)
+ ;;
+ *)
+ AC_MSG_ERROR([Unknown argument to --with-aix-soname])
+ ;;
+ esac
+ lt_cv_with_aix_soname=$with_aix_soname],
+ [AC_CACHE_VAL([lt_cv_with_aix_soname],
+ [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
+ with_aix_soname=$lt_cv_with_aix_soname])
+ AC_MSG_RESULT([$with_aix_soname])
+ if test aix != "$with_aix_soname"; then
+ # For the AIX way of multilib, we name the shared archive member
+ # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',
+ # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.
+ # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,
+ # the AIX toolchain works better with OBJECT_MODE set (default 32).
+ if test 64 = "${OBJECT_MODE-32}"; then
+ shared_archive_member_spec=shr_64
+ else
+ shared_archive_member_spec=shr
+ fi
+ fi
+ ;;
+*)
+ with_aix_soname=aix
+ ;;
+esac
+
+_LT_DECL([], [shared_archive_member_spec], [0],
+ [Shared archive member basename, for filename based shared library versioning on AIX])dnl
+])# _LT_WITH_AIX_SONAME
+
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])])
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])])
+LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
+
+
# _LT_WITH_PIC([MODE])
# --------------------
-# implement the --with-pic flag, and support the `pic-only' and `no-pic'
+# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
# LT_INIT options.
-# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
+# MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'.
m4_define([_LT_WITH_PIC],
[AC_ARG_WITH([pic],
[AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
@@ -334,19 +389,17 @@ m4_define([_LT_WITH_PIC],
*)
pic_mode=default
# Look at the argument we got. We use all the common list separators.
- lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for lt_pkg in $withval; do
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
if test "X$lt_pkg" = "X$lt_p"; then
pic_mode=yes
fi
done
- IFS="$lt_save_ifs"
+ IFS=$lt_save_ifs
;;
esac],
- [pic_mode=default])
-
-test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
+ [pic_mode=m4_default([$1], [default])])
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
])# _LT_WITH_PIC
@@ -359,7 +412,7 @@ AU_DEFUN([AC_LIBTOOL_PICMODE],
[_LT_SET_OPTION([LT_INIT], [pic-only])
AC_DIAGNOSE([obsolete],
[$0: Remove this warning and the call to _LT_SET_OPTION when you
-put the `pic-only' option into LT_INIT's first parameter.])
+put the 'pic-only' option into LT_INIT's first parameter.])
])
dnl aclocal-1.4 backwards compatibility:
diff --git a/contrib/libxo/m4/ltversion.m4 b/contrib/libxo/m4/ltversion.m4
index 07a8602..fa04b52 100644
--- a/contrib/libxo/m4/ltversion.m4
+++ b/contrib/libxo/m4/ltversion.m4
@@ -1,6 +1,6 @@
# ltversion.m4 -- version numbers -*- Autoconf -*-
#
-# Copyright (C) 2004 Free Software Foundation, Inc.
+# Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc.
# Written by Scott James Remnant, 2004
#
# This file is free software; the Free Software Foundation gives
@@ -9,15 +9,15 @@
# @configure_input@
-# serial 3337 ltversion.m4
+# serial 4179 ltversion.m4
# This file is part of GNU Libtool
-m4_define([LT_PACKAGE_VERSION], [2.4.2])
-m4_define([LT_PACKAGE_REVISION], [1.3337])
+m4_define([LT_PACKAGE_VERSION], [2.4.6])
+m4_define([LT_PACKAGE_REVISION], [2.4.6])
AC_DEFUN([LTVERSION_VERSION],
-[macro_version='2.4.2'
-macro_revision='1.3337'
+[macro_version='2.4.6'
+macro_revision='2.4.6'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0)
])
diff --git a/contrib/libxo/tests/core/Makefile.am b/contrib/libxo/tests/core/Makefile.am
index f145d18..92f5f36 100644
--- a/contrib/libxo/tests/core/Makefile.am
+++ b/contrib/libxo/tests/core/Makefile.am
@@ -20,7 +20,8 @@ test_05.c \
test_06.c \
test_07.c \
test_08.c \
-test_09.c
+test_09.c \
+test_10.c
test_01_test_SOURCES = test_01.c
test_02_test_SOURCES = test_02.c
@@ -31,6 +32,7 @@ test_06_test_SOURCES = test_06.c
test_07_test_SOURCES = test_07.c
test_08_test_SOURCES = test_08.c
test_09_test_SOURCES = test_09.c
+test_10_test_SOURCES = test_10.c
# TEST_CASES := $(shell cd ${srcdir} ; echo *.c )
diff --git a/contrib/libxo/tests/core/saved/test_01.JP.out b/contrib/libxo/tests/core/saved/test_01.JP.out
index e1fd231..4790065 100644
--- a/contrib/libxo/tests/core/saved/test_01.JP.out
+++ b/contrib/libxo/tests/core/saved/test_01.JP.out
@@ -91,7 +91,11 @@
},
"data": {
"item": [
- "gum", "rope", "ladder", "bolt", "water"
+ "gum",
+ "rope",
+ "ladder",
+ "bolt",
+ "water"
]
},
"cost": 425,
diff --git a/contrib/libxo/tests/core/saved/test_02.JP.out b/contrib/libxo/tests/core/saved/test_02.JP.out
index 21b168b..ade2dc2 100644
--- a/contrib/libxo/tests/core/saved/test_02.JP.out
+++ b/contrib/libxo/tests/core/saved/test_02.JP.out
@@ -26,7 +26,9 @@
"cur": 20,
"max": 125,
"flag": [
- "one", "two", "three"
+ "one",
+ "two",
+ "three"
],
"empty-tag": true,
"t1": "1000",
diff --git a/contrib/libxo/tests/core/saved/test_05.H.out b/contrib/libxo/tests/core/saved/test_05.H.out
index b75d728..136b956 100644
--- a/contrib/libxo/tests/core/saved/test_05.H.out
+++ b/contrib/libxo/tests/core/saved/test_05.H.out
@@ -1 +1 @@
-<div class="line"><div class="text">Οá½Ï‡á½¶ ταá½Ï„á½° παÏίσταταί μοι </div><div class="data" data-tag="v1">γιγνώσκειν</div><div class="text">, </div><div class="data" data-tag="v2">ὦ ἄνδÏες ᾿Αθηναῖοι</div></div><div class="line"><div class="text">გთხáƒáƒ•áƒ— </div><div class="data" data-tag="v1">áƒáƒ®áƒšáƒáƒ•áƒ” გáƒáƒ˜áƒáƒ áƒáƒ— რეგისტრáƒáƒªáƒ˜áƒ</div><div class="text"> </div><div class="data" data-tag="v2">Unicode-ის მეáƒáƒ—ე სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ</div></div><div class="line"><div class="title">First Name </div><div class="title">Last Name </div><div class="title">Department </div><div class="title">Time (%)</div></div><div class="line"><div class="data" data-tag="first-name">Jim</div><div class="text"> (</div><div class="data" data-tag="nic-name">"რეგტ"</div><div class="text">)</div><div class="padding"> </div><div class="data" data-tag="last-name">გთხáƒáƒ•áƒ— áƒáƒ® </div><div class="data" data-tag="department"> 431</div><div class="data" data-tag="percent-time"> 90</div></div><div class="line"><div class="data" data-tag="first-name">Terry</div><div class="text"> (</div><div class="data" data-tag="nic-name">"&lt;one"</div><div class="text">)</div><div class="padding"> </div><div class="data" data-tag="last-name">Οá½Ï‡á½¶ ταá½Ï„á½° παÏ</div><div class="data" data-tag="department"> 660</div><div class="data" data-tag="percent-time"> 90</div></div><div class="line"><div class="data" data-tag="first-name">Leslie</div><div class="text"> (</div><div class="data" data-tag="nic-name">"Les"</div><div class="text">)</div><div class="padding"> </div><div class="data" data-tag="last-name">Patterson </div><div class="data" data-tag="department"> 341</div><div class="data" data-tag="percent-time"> 60</div></div><div class="line"><div class="data" data-tag="first-name">Ashley</div><div class="text"> (</div><div class="data" data-tag="nic-name">"Ash"</div><div class="text">)</div><div class="padding"> </div><div class="data" data-tag="last-name">Meter &amp; Smith </div><div class="data" data-tag="department"> 1440</div><div class="data" data-tag="percent-time"> 40</div></div><div class="line"><div class="data" data-tag="first-name">0123456789</div><div class="text"> (</div><div class="data" data-tag="nic-name">"0123456789"</div><div class="text">)</div><div class="data" data-tag="last-name">01234567890123</div><div class="data" data-tag="department"> 1440</div><div class="data" data-tag="percent-time"> 40</div></div><div class="line"><div class="data" data-tag="first-name">áƒáƒ®áƒšáƒ</div><div class="text"> (</div><div class="data" data-tag="nic-name">"გáƒáƒ˜áƒáƒ áƒ"</div><div class="text">)</div><div class="padding"> </div><div class="data" data-tag="last-name">სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ </div><div class="data" data-tag="department"> 123</div><div class="data" data-tag="percent-time"> 90</div></div> \ No newline at end of file
+<div class="line"><div class="text">Οá½Ï‡á½¶ ταá½Ï„á½° παÏίσταταί μοι </div><div class="data" data-tag="v1">γιγνώσκειν</div><div class="text">, </div><div class="data" data-tag="v2">ὦ ἄνδÏες ᾿Αθηναῖοι</div></div><div class="line"><div class="text">გთხáƒáƒ•áƒ— </div><div class="data" data-tag="v1">áƒáƒ®áƒšáƒáƒ•áƒ” გáƒáƒ˜áƒáƒ áƒáƒ— რეგისტრáƒáƒªáƒ˜áƒ</div><div class="text"> </div><div class="data" data-tag="v2">Unicode-ის მეáƒáƒ—ე სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ</div></div><div class="line"><div class="title">Width</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="width">63</div></div><div class="line"><div class="text">[</div><div class="data" data-tag="sinhala">෴ණ්ණ෴</div><div class="text">]</div></div><div class="line"><div class="title">Width</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="width">7</div></div><div class="line"><div class="text">[</div><div class="data" data-tag="sinhala">à·´</div><div class="text">]</div></div><div class="line"><div class="title">Width</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="width">3</div></div><div class="line"><div class="text">[</div><div class="data" data-tag="sinhala">෴ණ්ණ</div><div class="text">]</div></div><div class="line"><div class="text">[</div><div class="data" data-tag="not-sinhala">1234</div><div class="text">]</div></div><div class="line"><div class="text">[</div><div class="data" data-tag="tag">ර්â€à¶</div><div class="text">]</div></div><div class="line"><div class="title">Width</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="width">5</div></div><div class="line"><div class="title">First Name </div><div class="title">Last Name </div><div class="title">Department </div><div class="title">Time (%)</div></div><div class="line"><div class="data" data-tag="first-name">Jim</div><div class="text"> (</div><div class="data" data-tag="nic-name">"რეგტ"</div><div class="text">)</div><div class="padding"> </div><div class="data" data-tag="last-name">გთხáƒáƒ•áƒ— áƒáƒ® </div><div class="data" data-tag="department"> 431</div><div class="data" data-tag="percent-time"> 90</div></div><div class="line"><div class="data" data-tag="first-name">Terry</div><div class="text"> (</div><div class="data" data-tag="nic-name">"&lt;one"</div><div class="text">)</div><div class="padding"> </div><div class="data" data-tag="last-name">Οá½Ï‡á½¶ ταá½Ï„á½° παÏ</div><div class="data" data-tag="department"> 660</div><div class="data" data-tag="percent-time"> 90</div></div><div class="line"><div class="data" data-tag="first-name">Leslie</div><div class="text"> (</div><div class="data" data-tag="nic-name">"Les"</div><div class="text">)</div><div class="padding"> </div><div class="data" data-tag="last-name">Patterson </div><div class="data" data-tag="department"> 341</div><div class="data" data-tag="percent-time"> 60</div></div><div class="line"><div class="data" data-tag="first-name">Ashley</div><div class="text"> (</div><div class="data" data-tag="nic-name">"Ash"</div><div class="text">)</div><div class="padding"> </div><div class="data" data-tag="last-name">Meter &amp; Smith </div><div class="data" data-tag="department"> 1440</div><div class="data" data-tag="percent-time"> 40</div></div><div class="line"><div class="data" data-tag="first-name">0123456789</div><div class="text"> (</div><div class="data" data-tag="nic-name">"0123456789"</div><div class="text">)</div><div class="data" data-tag="last-name">01234567890123</div><div class="data" data-tag="department"> 1440</div><div class="data" data-tag="percent-time"> 40</div></div><div class="line"><div class="data" data-tag="first-name">áƒáƒ®áƒšáƒ</div><div class="text"> (</div><div class="data" data-tag="nic-name">"გáƒáƒ˜áƒáƒ áƒ"</div><div class="text">)</div><div class="padding"> </div><div class="data" data-tag="last-name">სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ </div><div class="data" data-tag="department"> 123</div><div class="data" data-tag="percent-time"> 90</div></div><div class="line"><div class="data" data-tag="first-name">෴ණ්ණ෴෴ණ්ණ෴</div><div class="text"> (</div><div class="data" data-tag="nic-name">"Mick"</div><div class="text">)</div><div class="padding"> </div><div class="data" data-tag="last-name">෴ණ්ණ෴෴ණ්ණ෴෴ණ්ණ</div><div class="data" data-tag="department"> 110</div><div class="data" data-tag="percent-time"> 20</div></div> \ No newline at end of file
diff --git a/contrib/libxo/tests/core/saved/test_05.HIPx.out b/contrib/libxo/tests/core/saved/test_05.HIPx.out
index 2054de1..105f848 100644
--- a/contrib/libxo/tests/core/saved/test_05.HIPx.out
+++ b/contrib/libxo/tests/core/saved/test_05.HIPx.out
@@ -11,6 +11,55 @@
<div class="data" data-tag="v2" data-xpath="/employees/v2">Unicode-ის მეáƒáƒ—ე სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ</div>
</div>
<div class="line">
+ <div class="title">Width</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="width" data-xpath="/employees/width">63</div>
+</div>
+<div class="line">
+ <div class="text">[</div>
+ <div class="data" data-tag="sinhala" data-xpath="/employees/sinhala">෴ණ්ණ෴</div>
+ <div class="text">]</div>
+</div>
+<div class="line">
+ <div class="title">Width</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="width" data-xpath="/employees/width">7</div>
+</div>
+<div class="line">
+ <div class="text">[</div>
+ <div class="data" data-tag="sinhala" data-xpath="/employees/sinhala">à·´</div>
+ <div class="text">]</div>
+</div>
+<div class="line">
+ <div class="title">Width</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="width" data-xpath="/employees/width">3</div>
+</div>
+<div class="line">
+ <div class="text">[</div>
+ <div class="data" data-tag="sinhala" data-xpath="/employees/sinhala">෴ණ්ණ</div>
+ <div class="text">]</div>
+</div>
+<div class="line">
+ <div class="text">[</div>
+ <div class="data" data-tag="not-sinhala" data-xpath="/employees/not-sinhala">1234</div>
+ <div class="text">]</div>
+</div>
+<div class="line">
+ <div class="text">[</div>
+ <div class="data" data-tag="tag" data-xpath="/employees/tag">ර්â€à¶</div>
+ <div class="text">]</div>
+</div>
+<div class="line">
+ <div class="title">Width</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="width" data-xpath="/employees/width">5</div>
+</div>
+<div class="line">
<div class="title">First Name </div>
<div class="title">Last Name </div>
<div class="title">Department </div>
@@ -75,3 +124,13 @@
<div class="data" data-tag="department" data-xpath="/employees/employee/department"> 123</div>
<div class="data" data-tag="percent-time" data-xpath="/employees/employee/percent-time" data-type="number" data-help="Percentage of full &amp; part time (%)"> 90</div>
</div>
+<div class="line">
+ <div class="data" data-tag="first-name" data-xpath="/employees/employee/first-name" data-type="string" data-help="First name of employee">෴ණ්ණ෴෴ණ්ණ෴</div>
+ <div class="text"> (</div>
+ <div class="data" data-tag="nic-name" data-xpath="/employees/employee/nic-name">"Mick"</div>
+ <div class="text">)</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="last-name" data-xpath="/employees/employee/last-name" data-type="string" data-help="Last name of employee">෴ණ්ණ෴෴ණ්ණ෴෴ණ්ණ</div>
+ <div class="data" data-tag="department" data-xpath="/employees/employee/department"> 110</div>
+ <div class="data" data-tag="percent-time" data-xpath="/employees/employee/percent-time" data-type="number" data-help="Percentage of full &amp; part time (%)"> 20</div>
+</div>
diff --git a/contrib/libxo/tests/core/saved/test_05.HP.out b/contrib/libxo/tests/core/saved/test_05.HP.out
index 1c34b95..e66cf2b 100644
--- a/contrib/libxo/tests/core/saved/test_05.HP.out
+++ b/contrib/libxo/tests/core/saved/test_05.HP.out
@@ -11,6 +11,55 @@
<div class="data" data-tag="v2">Unicode-ის მეáƒáƒ—ე სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ</div>
</div>
<div class="line">
+ <div class="title">Width</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="width">63</div>
+</div>
+<div class="line">
+ <div class="text">[</div>
+ <div class="data" data-tag="sinhala">෴ණ්ණ෴</div>
+ <div class="text">]</div>
+</div>
+<div class="line">
+ <div class="title">Width</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="width">7</div>
+</div>
+<div class="line">
+ <div class="text">[</div>
+ <div class="data" data-tag="sinhala">à·´</div>
+ <div class="text">]</div>
+</div>
+<div class="line">
+ <div class="title">Width</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="width">3</div>
+</div>
+<div class="line">
+ <div class="text">[</div>
+ <div class="data" data-tag="sinhala">෴ණ්ණ</div>
+ <div class="text">]</div>
+</div>
+<div class="line">
+ <div class="text">[</div>
+ <div class="data" data-tag="not-sinhala">1234</div>
+ <div class="text">]</div>
+</div>
+<div class="line">
+ <div class="text">[</div>
+ <div class="data" data-tag="tag">ර්â€à¶</div>
+ <div class="text">]</div>
+</div>
+<div class="line">
+ <div class="title">Width</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="width">5</div>
+</div>
+<div class="line">
<div class="title">First Name </div>
<div class="title">Last Name </div>
<div class="title">Department </div>
@@ -75,3 +124,13 @@
<div class="data" data-tag="department"> 123</div>
<div class="data" data-tag="percent-time"> 90</div>
</div>
+<div class="line">
+ <div class="data" data-tag="first-name">෴ණ්ණ෴෴ණ්ණ෴</div>
+ <div class="text"> (</div>
+ <div class="data" data-tag="nic-name">"Mick"</div>
+ <div class="text">)</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="last-name">෴ණ්ණ෴෴ණ්ණ෴෴ණ්ණ</div>
+ <div class="data" data-tag="department"> 110</div>
+ <div class="data" data-tag="percent-time"> 20</div>
+</div>
diff --git a/contrib/libxo/tests/core/saved/test_05.J.out b/contrib/libxo/tests/core/saved/test_05.J.out
index 5155489..25d13ea 100644
--- a/contrib/libxo/tests/core/saved/test_05.J.out
+++ b/contrib/libxo/tests/core/saved/test_05.J.out
@@ -1,2 +1,2 @@
-{"employees": {"v1":"γιγνώσκειν","v2":"ὦ ἄνδÏες ᾿Αθηναῖοι","v1":"áƒáƒ®áƒšáƒáƒ•áƒ” გáƒáƒ˜áƒáƒ áƒáƒ— რეგისტრáƒáƒªáƒ˜áƒ","v2":"Unicode-ის მეáƒáƒ—ე სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ", "employee": [{"first-name":"Jim","nic-name":"\"რეგტ\"","last-name":"გთხáƒáƒ•áƒ— áƒáƒ®","department":431,"percent-time":90,"benefits":"full"}, {"first-name":"Terry","nic-name":"\"<one\"","last-name":"Οá½Ï‡á½¶ ταá½Ï„á½° παÏίσταταί μοι Jones","department":660,"percent-time":90,"benefits":"full"}, {"first-name":"Leslie","nic-name":"\"Les\"","last-name":"Patterson","department":341,"percent-time":60,"benefits":"full"}, {"first-name":"Ashley","nic-name":"\"Ash\"","last-name":"Meter & Smith","department":1440,"percent-time":40}, {"first-name":"0123456789","nic-name":"\"0123456789\"","last-name":"012345678901234567890","department":1440,"percent-time":40}, {"first-name":"áƒáƒ®áƒšáƒ","nic-name":"\"გáƒáƒ˜áƒáƒ áƒ\"","last-name":"სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ","department":123,"percent-time":90,"benefits":"full"}]}
+{"employees": {"v1":"γιγνώσκειν","v2":"ὦ ἄνδÏες ᾿Αθηναῖοι","v1":"áƒáƒ®áƒšáƒáƒ•áƒ” გáƒáƒ˜áƒáƒ áƒáƒ— რეგისტრáƒáƒªáƒ˜áƒ","v2":"Unicode-ის მეáƒáƒ—ე სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ","width":55,"sinhala":"෴ණ්ණ෴","width":5,"sinhala":"à·´","width":1,"sinhala":"෴ණ්ණ෴෴ණ්ණ෴","not-sinhala":"123456","tag":"ර්â€à¶","width":3, "employee": [{"first-name":"Jim","nic-name":"\"რეგტ\"","last-name":"გთხáƒáƒ•áƒ— áƒáƒ®","department":431,"percent-time":90,"benefits":"full"}, {"first-name":"Terry","nic-name":"\"<one\"","last-name":"Οá½Ï‡á½¶ ταá½Ï„á½° παÏίσταταί μοι Jones","department":660,"percent-time":90,"benefits":"full"}, {"first-name":"Leslie","nic-name":"\"Les\"","last-name":"Patterson","department":341,"percent-time":60,"benefits":"full"}, {"first-name":"Ashley","nic-name":"\"Ash\"","last-name":"Meter & Smith","department":1440,"percent-time":40}, {"first-name":"0123456789","nic-name":"\"0123456789\"","last-name":"012345678901234567890","department":1440,"percent-time":40}, {"first-name":"áƒáƒ®áƒšáƒ","nic-name":"\"გáƒáƒ˜áƒáƒ áƒ\"","last-name":"სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ","department":123,"percent-time":90,"benefits":"full"}, {"first-name":"෴ණ්ණ෴෴ණ්ණ෴","nic-name":"\"Mick\"","last-name":"෴ණ්ණ෴෴ණ්ණ෴෴ණ්ණ෴෴෴","department":110,"percent-time":20}]}
}
diff --git a/contrib/libxo/tests/core/saved/test_05.JP.out b/contrib/libxo/tests/core/saved/test_05.JP.out
index 7d77d70..c321917 100644
--- a/contrib/libxo/tests/core/saved/test_05.JP.out
+++ b/contrib/libxo/tests/core/saved/test_05.JP.out
@@ -4,6 +4,15 @@
"v2": "ὦ ἄνδÏες ᾿Αθηναῖοι",
"v1": "áƒáƒ®áƒšáƒáƒ•áƒ” გáƒáƒ˜áƒáƒ áƒáƒ— რეგისტრáƒáƒªáƒ˜áƒ",
"v2": "Unicode-ის მეáƒáƒ—ე სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ",
+ "width": 55,
+ "sinhala": "෴ණ්ණ෴",
+ "width": 5,
+ "sinhala": "à·´",
+ "width": 1,
+ "sinhala": "෴ණ්ණ෴෴ණ්ණ෴",
+ "not-sinhala": "123456",
+ "tag": "ර්â€à¶",
+ "width": 3,
"employee": [
{
"first-name": "Jim",
@@ -50,6 +59,13 @@
"department": 123,
"percent-time": 90,
"benefits": "full"
+ },
+ {
+ "first-name": "෴ණ්ණ෴෴ණ්ණ෴",
+ "nic-name": "\"Mick\"",
+ "last-name": "෴ණ්ණ෴෴ණ්ණ෴෴ණ්ණ෴෴෴",
+ "department": 110,
+ "percent-time": 20
}
]
}
diff --git a/contrib/libxo/tests/core/saved/test_05.T.out b/contrib/libxo/tests/core/saved/test_05.T.out
index c709f6c..db713a6 100644
--- a/contrib/libxo/tests/core/saved/test_05.T.out
+++ b/contrib/libxo/tests/core/saved/test_05.T.out
@@ -1,5 +1,14 @@
Οá½Ï‡á½¶ ταá½Ï„á½° παÏίσταταί μοι γιγνώσκειν, ὦ ἄνδÏες ᾿Αθηναῖοι
გთხáƒáƒ•áƒ— áƒáƒ®áƒšáƒáƒ•áƒ” გáƒáƒ˜áƒáƒ áƒáƒ— რეგისტრáƒáƒªáƒ˜áƒ Unicode-ის მეáƒáƒ—ე სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ
+Width: 63
+[෴ණ්ණ෴]
+Width: 7
+[à·´]
+Width: 3
+[෴ණ්ණ]
+[1234]
+[ර්â€à¶]
+Width: 5
First Name Last Name Department Time (%)
Jim ("რეგტ") გთხáƒáƒ•áƒ— áƒáƒ® 431 90
Terry ("<one") Οá½Ï‡á½¶ ταá½Ï„á½° Ï€Î±Ï 660 90
@@ -7,3 +16,4 @@ Leslie ("Les") Patterson 341 60
Ashley ("Ash") Meter & Smith 1440 40
0123456789 ("0123456789")01234567890123 1440 40
áƒáƒ®áƒšáƒ ("გáƒáƒ˜áƒáƒ áƒ") სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ 123 90
+෴ණ්ණ෴෴ණ්ණ෴ ("Mick") ෴ණ්ණ෴෴ණ්ණ෴෴ණ්ණ 110 20
diff --git a/contrib/libxo/tests/core/saved/test_05.X.out b/contrib/libxo/tests/core/saved/test_05.X.out
index 85ecbbc..7cd2926 100644
--- a/contrib/libxo/tests/core/saved/test_05.X.out
+++ b/contrib/libxo/tests/core/saved/test_05.X.out
@@ -1 +1 @@
-<employees><v1>γιγνώσκειν</v1><v2>ὦ ἄνδÏες ᾿Αθηναῖοι</v2><v1>áƒáƒ®áƒšáƒáƒ•áƒ” გáƒáƒ˜áƒáƒ áƒáƒ— რეგისტრáƒáƒªáƒ˜áƒ</v1><v2>Unicode-ის მეáƒáƒ—ე სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ</v2><employee><first-name>Jim</first-name><nic-name>"რეგტ"</nic-name><last-name>გთხáƒáƒ•áƒ— áƒáƒ®</last-name><department>431</department><percent-time>90</percent-time><benefits full-time="honest &amp; for true">full</benefits></employee><employee><first-name>Terry</first-name><nic-name>"&lt;one"</nic-name><last-name>Οá½Ï‡á½¶ ταá½Ï„á½° παÏίσταταί μοι Jones</last-name><department>660</department><percent-time>90</percent-time><benefits full-time="honest &amp; for true">full</benefits></employee><employee><first-name>Leslie</first-name><nic-name>"Les"</nic-name><last-name>Patterson</last-name><department>341</department><percent-time>60</percent-time><benefits full-time="honest &amp; for true">full</benefits></employee><employee><first-name>Ashley</first-name><nic-name>"Ash"</nic-name><last-name>Meter &amp; Smith</last-name><department>1440</department><percent-time>40</percent-time></employee><employee><first-name>0123456789</first-name><nic-name>"0123456789"</nic-name><last-name>012345678901234567890</last-name><department>1440</department><percent-time>40</percent-time></employee><employee><first-name>áƒáƒ®áƒšáƒ</first-name><nic-name>"გáƒáƒ˜áƒáƒ áƒ"</nic-name><last-name>სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ</last-name><department>123</department><percent-time>90</percent-time><benefits full-time="honest &amp; for true">full</benefits></employee></employees> \ No newline at end of file
+<employees><v1>γιγνώσκειν</v1><v2>ὦ ἄνδÏες ᾿Αθηναῖοι</v2><v1>áƒáƒ®áƒšáƒáƒ•áƒ” გáƒáƒ˜áƒáƒ áƒáƒ— რეგისტრáƒáƒªáƒ˜áƒ</v1><v2>Unicode-ის მეáƒáƒ—ე სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ</v2><width>55</width><sinhala>෴ණ්ණ෴</sinhala><width>5</width><sinhala>à·´</sinhala><width>1</width><sinhala>෴ණ්ණ෴෴ණ්ණ෴</sinhala><not-sinhala>123456</not-sinhala><tag>ර්â€à¶</tag><width>3</width><employee><first-name>Jim</first-name><nic-name>"რეგტ"</nic-name><last-name>გთხáƒáƒ•áƒ— áƒáƒ®</last-name><department>431</department><percent-time>90</percent-time><benefits full-time="honest &amp; for true">full</benefits></employee><employee><first-name>Terry</first-name><nic-name>"&lt;one"</nic-name><last-name>Οá½Ï‡á½¶ ταá½Ï„á½° παÏίσταταί μοι Jones</last-name><department>660</department><percent-time>90</percent-time><benefits full-time="honest &amp; for true">full</benefits></employee><employee><first-name>Leslie</first-name><nic-name>"Les"</nic-name><last-name>Patterson</last-name><department>341</department><percent-time>60</percent-time><benefits full-time="honest &amp; for true">full</benefits></employee><employee><first-name>Ashley</first-name><nic-name>"Ash"</nic-name><last-name>Meter &amp; Smith</last-name><department>1440</department><percent-time>40</percent-time></employee><employee><first-name>0123456789</first-name><nic-name>"0123456789"</nic-name><last-name>012345678901234567890</last-name><department>1440</department><percent-time>40</percent-time></employee><employee><first-name>áƒáƒ®áƒšáƒ</first-name><nic-name>"გáƒáƒ˜áƒáƒ áƒ"</nic-name><last-name>სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ</last-name><department>123</department><percent-time>90</percent-time><benefits full-time="honest &amp; for true">full</benefits></employee><employee><first-name>෴ණ්ණ෴෴ණ්ණ෴</first-name><nic-name>"Mick"</nic-name><last-name>෴ණ්ණ෴෴ණ්ණ෴෴ණ්ණ෴෴෴</last-name><department>110</department><percent-time>20</percent-time></employee></employees> \ No newline at end of file
diff --git a/contrib/libxo/tests/core/saved/test_05.XP.out b/contrib/libxo/tests/core/saved/test_05.XP.out
index 55507eb..6ef573f 100644
--- a/contrib/libxo/tests/core/saved/test_05.XP.out
+++ b/contrib/libxo/tests/core/saved/test_05.XP.out
@@ -3,6 +3,15 @@
<v2>ὦ ἄνδÏες ᾿Αθηναῖοι</v2>
<v1>áƒáƒ®áƒšáƒáƒ•áƒ” გáƒáƒ˜áƒáƒ áƒáƒ— რეგისტრáƒáƒªáƒ˜áƒ</v1>
<v2>Unicode-ის მეáƒáƒ—ე სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ</v2>
+ <width>55</width>
+ <sinhala>෴ණ්ණ෴</sinhala>
+ <width>5</width>
+ <sinhala>à·´</sinhala>
+ <width>1</width>
+ <sinhala>෴ණ්ණ෴෴ණ්ණ෴</sinhala>
+ <not-sinhala>123456</not-sinhala>
+ <tag>ර්â€à¶</tag>
+ <width>3</width>
<employee>
<first-name>Jim</first-name>
<nic-name>"რეგტ"</nic-name>
@@ -49,4 +58,11 @@
<percent-time>90</percent-time>
<benefits full-time="honest &amp; for true">full</benefits>
</employee>
+ <employee>
+ <first-name>෴ණ්ණ෴෴ණ්ණ෴</first-name>
+ <nic-name>"Mick"</nic-name>
+ <last-name>෴ණ්ණ෴෴ණ්ණ෴෴ණ්ණ෴෴෴</last-name>
+ <department>110</department>
+ <percent-time>20</percent-time>
+ </employee>
</employees>
diff --git a/contrib/libxo/tests/core/saved/test_09.JP.out b/contrib/libxo/tests/core/saved/test_09.JP.out
index 8340b27..48e20c1 100644
--- a/contrib/libxo/tests/core/saved/test_09.JP.out
+++ b/contrib/libxo/tests/core/saved/test_09.JP.out
@@ -3,22 +3,34 @@
"data": {
"contents": {
"name": [
- "gum", "rope", "ladder", "bolt", "water"
+ "gum",
+ "rope",
+ "ladder",
+ "bolt",
+ "water"
]
},
"contents": {
"item": [
- "gum", "rope", "ladder", "bolt", "water"
+ "gum",
+ "rope",
+ "ladder",
+ "bolt",
+ "water"
]
},
"contents": {
"item": [
- "gum", "rope", "ladder", "bolt", "water"
+ "gum",
+ "rope",
+ "ladder",
+ "bolt",
+ "water"
],
"total": "six",
"one": "one",
"two": [
- "two"
+ "two"
],
"three": "three"
}
diff --git a/contrib/libxo/tests/core/saved/test_10.H.err b/contrib/libxo/tests/core/saved/test_10.H.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.H.err
diff --git a/contrib/libxo/tests/core/saved/test_10.H.out b/contrib/libxo/tests/core/saved/test_10.H.out
new file mode 100644
index 0000000..d4ec07d
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.H.out
@@ -0,0 +1 @@
+<div class="line"><div class="title color-fg-blue">blue</div><div class="title color-fg-green color-bg-blue">green</div><div class="title color-fg-red color-bg-green">red</div><div class="title color-fg-yellow color-bg-red">yellow</div><div class="title color-bg-yellow">default</div></div><div class="line"><div class="data effect-bold" data-tag="data">bold</div><div class="text effect-bold"> </div><div class="data effect-bold effect-underline" data-tag="data">bold-ul</div><div class="text effect-bold effect-underline"> </div><div class="data effect-bold effect-underline effect-inverse color-fg-inverse color-bg-inverse" data-tag="data">triple</div><div class="text effect-bold effect-underline effect-inverse color-fg-inverse color-bg-inverse"> </div><div class="data effect-underline effect-inverse color-fg-inverse color-bg-inverse" data-tag="data">inv-ul</div><div class="text effect-underline effect-inverse color-fg-inverse color-bg-inverse"> </div><div class="data effect-underline" data-tag="data">underline</div><div class="text effect-underline"> </div><div class="data" data-tag="data">plain</div></div><div class="line"><div class="title">Item </div><div class="title effect-bold effect-underline"> Total Sold</div><div class="title effect-underline"> In Stock</div><div class="title effect-underline effect-inverse color-fg-inverse color-bg-inverse"> On Order</div><div class="title"> SKU</div></div><div class="line"><div class="data" data-tag="name" data-key="key">gum </div><div class="data" data-tag="sold"> 1412</div><div class="data" data-tag="in-stock"> 54</div><div class="data color-fg-yellow" data-tag="on-order"> 10</div><div class="data" data-tag="sku" data-key="key"> GRO-000-415</div></div><div class="line"><div class="data" data-tag="name" data-key="key">rope </div><div class="data" data-tag="sold"> 85</div><div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock"> 4</div><div class="data" data-tag="on-order"> 2</div><div class="data" data-tag="sku" data-key="key"> HRD-000-212</div></div><div class="line"><div class="data" data-tag="name" data-key="key">ladder </div><div class="data" data-tag="sold"> 0</div><div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock"> 2</div><div class="data" data-tag="on-order"> 1</div><div class="data" data-tag="sku" data-key="key"> HRD-000-517</div></div><div class="line"><div class="data" data-tag="name" data-key="key">bolt </div><div class="data" data-tag="sold"> 4123</div><div class="data" data-tag="in-stock"> 144</div><div class="data color-fg-yellow" data-tag="on-order"> 42</div><div class="data" data-tag="sku" data-key="key"> HRD-000-632</div></div><div class="line"><div class="data" data-tag="name" data-key="key">water </div><div class="data" data-tag="sold"> 17</div><div class="data" data-tag="in-stock"> 14</div><div class="data" data-tag="on-order"> 2</div><div class="data" data-tag="sku" data-key="key"> GRO-000-2331</div></div><div class="line"></div><div class="line"></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">gum</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">1412.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock">54</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">10</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">GRO-000-415</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">rope</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">85.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock">4</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">2</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">HRD-000-212</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">ladder</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock">2</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">1</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">HRD-000-517</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">bolt</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">4123.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock">144</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">42</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">HRD-000-632</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">water</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">17.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock">14</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">2</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">GRO-000-2331</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">fish</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label effect-bold color-fg-white color-bg-blue">Total sold</div><div class="text effect-bold color-fg-white color-bg-blue">: </div><div class="data effect-bold color-fg-white color-bg-blue" data-tag="sold">1321.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">45</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">1</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">GRO-000-533</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">gum</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">rope</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">ladder</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">bolt</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">water</div></div><div class="line"><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div></div><div class="line"><div class="text">X</div><div class="padding"> </div><div class="text">X</div><div class="label">Cost</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="cost">425</div></div><div class="line"><div class="text">X</div><div class="padding"> </div><div class="text">X</div><div class="label">Cost</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="cost">455</div></div> \ No newline at end of file
diff --git a/contrib/libxo/tests/core/saved/test_10.HIPx.err b/contrib/libxo/tests/core/saved/test_10.HIPx.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.HIPx.err
diff --git a/contrib/libxo/tests/core/saved/test_10.HIPx.out b/contrib/libxo/tests/core/saved/test_10.HIPx.out
new file mode 100644
index 0000000..ef64173
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.HIPx.out
@@ -0,0 +1,316 @@
+<div class="line">
+ <div class="title color-fg-blue">blue</div>
+ <div class="title color-fg-green color-bg-blue">green</div>
+ <div class="title color-fg-red color-bg-green">red</div>
+ <div class="title color-fg-yellow color-bg-red">yellow</div>
+ <div class="title color-bg-yellow">default</div>
+</div>
+<div class="line">
+ <div class="data effect-bold" data-tag="data" data-xpath="/top/data/data">bold</div>
+ <div class="text effect-bold"> </div>
+ <div class="data effect-bold effect-underline" data-tag="data" data-xpath="/top/data/data">bold-ul</div>
+ <div class="text effect-bold effect-underline"> </div>
+ <div class="data effect-bold effect-underline effect-inverse color-fg-inverse color-bg-inverse" data-tag="data" data-xpath="/top/data/data">triple</div>
+ <div class="text effect-bold effect-underline effect-inverse color-fg-inverse color-bg-inverse"> </div>
+ <div class="data effect-underline effect-inverse color-fg-inverse color-bg-inverse" data-tag="data" data-xpath="/top/data/data">inv-ul</div>
+ <div class="text effect-underline effect-inverse color-fg-inverse color-bg-inverse"> </div>
+ <div class="data effect-underline" data-tag="data" data-xpath="/top/data/data">underline</div>
+ <div class="text effect-underline"> </div>
+ <div class="data" data-tag="data" data-xpath="/top/data/data">plain</div>
+</div>
+<div class="line">
+ <div class="title">Item </div>
+ <div class="title effect-bold effect-underline"> Total Sold</div>
+ <div class="title effect-underline"> In Stock</div>
+ <div class="title effect-underline effect-inverse color-fg-inverse color-bg-inverse"> On Order</div>
+ <div class="title"> SKU</div>
+</div>
+<div class="line">
+ <div class="data" data-tag="name" data-xpath="/top/data/item/name" data-type="string" data-help="Name of the item" data-key="key">gum </div>
+ <div class="data" data-tag="sold" data-xpath="/top/data/item[sku = 'GRO-000-415'][name = 'gum']/sold" data-type="number" data-help="Number of items sold"> 1412</div>
+ <div class="data" data-tag="in-stock" data-xpath="/top/data/item[sku = 'GRO-000-415'][name = 'gum']/in-stock" data-type="number" data-help="Number of items in stock"> 54</div>
+ <div class="data color-fg-yellow" data-tag="on-order" data-xpath="/top/data/item[sku = 'GRO-000-415'][name = 'gum']/on-order" data-type="number" data-help="Number of items on order"> 10</div>
+ <div class="data" data-tag="sku" data-xpath="/top/data/item/sku" data-type="string" data-help="Stock Keeping Unit" data-key="key"> GRO-000-415</div>
+</div>
+<div class="line">
+ <div class="data" data-tag="name" data-xpath="/top/data/item/name" data-type="string" data-help="Name of the item" data-key="key">rope </div>
+ <div class="data" data-tag="sold" data-xpath="/top/data/item[sku = 'HRD-000-212'][name = 'rope']/sold" data-type="number" data-help="Number of items sold"> 85</div>
+ <div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock" data-xpath="/top/data/item[sku = 'HRD-000-212'][name = 'rope']/in-stock" data-type="number" data-help="Number of items in stock"> 4</div>
+ <div class="data" data-tag="on-order" data-xpath="/top/data/item[sku = 'HRD-000-212'][name = 'rope']/on-order" data-type="number" data-help="Number of items on order"> 2</div>
+ <div class="data" data-tag="sku" data-xpath="/top/data/item/sku" data-type="string" data-help="Stock Keeping Unit" data-key="key"> HRD-000-212</div>
+</div>
+<div class="line">
+ <div class="data" data-tag="name" data-xpath="/top/data/item/name" data-type="string" data-help="Name of the item" data-key="key">ladder </div>
+ <div class="data" data-tag="sold" data-xpath="/top/data/item[sku = 'HRD-000-517'][name = 'ladder']/sold" data-type="number" data-help="Number of items sold"> 0</div>
+ <div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock" data-xpath="/top/data/item[sku = 'HRD-000-517'][name = 'ladder']/in-stock" data-type="number" data-help="Number of items in stock"> 2</div>
+ <div class="data" data-tag="on-order" data-xpath="/top/data/item[sku = 'HRD-000-517'][name = 'ladder']/on-order" data-type="number" data-help="Number of items on order"> 1</div>
+ <div class="data" data-tag="sku" data-xpath="/top/data/item/sku" data-type="string" data-help="Stock Keeping Unit" data-key="key"> HRD-000-517</div>
+</div>
+<div class="line">
+ <div class="data" data-tag="name" data-xpath="/top/data/item/name" data-type="string" data-help="Name of the item" data-key="key">bolt </div>
+ <div class="data" data-tag="sold" data-xpath="/top/data/item[sku = 'HRD-000-632'][name = 'bolt']/sold" data-type="number" data-help="Number of items sold"> 4123</div>
+ <div class="data" data-tag="in-stock" data-xpath="/top/data/item[sku = 'HRD-000-632'][name = 'bolt']/in-stock" data-type="number" data-help="Number of items in stock"> 144</div>
+ <div class="data color-fg-yellow" data-tag="on-order" data-xpath="/top/data/item[sku = 'HRD-000-632'][name = 'bolt']/on-order" data-type="number" data-help="Number of items on order"> 42</div>
+ <div class="data" data-tag="sku" data-xpath="/top/data/item/sku" data-type="string" data-help="Stock Keeping Unit" data-key="key"> HRD-000-632</div>
+</div>
+<div class="line">
+ <div class="data" data-tag="name" data-xpath="/top/data/item/name" data-type="string" data-help="Name of the item" data-key="key">water </div>
+ <div class="data" data-tag="sold" data-xpath="/top/data/item[sku = 'GRO-000-2331'][name = 'water']/sold" data-type="number" data-help="Number of items sold"> 17</div>
+ <div class="data" data-tag="in-stock" data-xpath="/top/data/item[sku = 'GRO-000-2331'][name = 'water']/in-stock" data-type="number" data-help="Number of items in stock"> 14</div>
+ <div class="data" data-tag="on-order" data-xpath="/top/data/item[sku = 'GRO-000-2331'][name = 'water']/on-order" data-type="number" data-help="Number of items on order"> 2</div>
+ <div class="data" data-tag="sku" data-xpath="/top/data/item/sku" data-type="string" data-help="Stock Keeping Unit" data-key="key"> GRO-000-2331</div>
+</div>
+<div class="line">
+</div>
+<div class="line">
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="text"> '</div>
+ <div class="data" data-tag="name" data-xpath="/top/data/item/name" data-type="string" data-help="Name of the item" data-key="key">gum</div>
+ <div class="text">':</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">Total sold</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sold" data-xpath="/top/data/item[sku = 'GRO-000-415'][name = 'gum']/sold" data-type="number" data-help="Number of items sold">1412.0</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">In stock</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock" data-xpath="/top/data/item[sku = 'GRO-000-415'][name = 'gum']/in-stock" data-type="number" data-help="Number of items in stock">54</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">On order</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="on-order" data-xpath="/top/data/item[sku = 'GRO-000-415'][name = 'gum']/on-order" data-type="number" data-help="Number of items on order">10</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">SKU</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sku" data-xpath="/top/data/item/sku" data-type="string" data-help="Stock Keeping Unit" data-key="key">GRO-000-415</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="text"> '</div>
+ <div class="data" data-tag="name" data-xpath="/top/data/item/name" data-type="string" data-help="Name of the item" data-key="key">rope</div>
+ <div class="text">':</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">Total sold</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sold" data-xpath="/top/data/item[sku = 'HRD-000-212'][name = 'rope']/sold" data-type="number" data-help="Number of items sold">85.0</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">In stock</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock" data-xpath="/top/data/item[sku = 'HRD-000-212'][name = 'rope']/in-stock" data-type="number" data-help="Number of items in stock">4</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">On order</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="on-order" data-xpath="/top/data/item[sku = 'HRD-000-212'][name = 'rope']/on-order" data-type="number" data-help="Number of items on order">2</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">SKU</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sku" data-xpath="/top/data/item/sku" data-type="string" data-help="Stock Keeping Unit" data-key="key">HRD-000-212</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="text"> '</div>
+ <div class="data" data-tag="name" data-xpath="/top/data/item/name" data-type="string" data-help="Name of the item" data-key="key">ladder</div>
+ <div class="text">':</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">Total sold</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sold" data-xpath="/top/data/item[sku = 'HRD-000-517'][name = 'ladder']/sold" data-type="number" data-help="Number of items sold">0</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">In stock</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock" data-xpath="/top/data/item[sku = 'HRD-000-517'][name = 'ladder']/in-stock" data-type="number" data-help="Number of items in stock">2</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">On order</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="on-order" data-xpath="/top/data/item[sku = 'HRD-000-517'][name = 'ladder']/on-order" data-type="number" data-help="Number of items on order">1</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">SKU</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sku" data-xpath="/top/data/item/sku" data-type="string" data-help="Stock Keeping Unit" data-key="key">HRD-000-517</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="text"> '</div>
+ <div class="data" data-tag="name" data-xpath="/top/data/item/name" data-type="string" data-help="Name of the item" data-key="key">bolt</div>
+ <div class="text">':</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">Total sold</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sold" data-xpath="/top/data/item[sku = 'HRD-000-632'][name = 'bolt']/sold" data-type="number" data-help="Number of items sold">4123.0</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">In stock</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock" data-xpath="/top/data/item[sku = 'HRD-000-632'][name = 'bolt']/in-stock" data-type="number" data-help="Number of items in stock">144</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">On order</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="on-order" data-xpath="/top/data/item[sku = 'HRD-000-632'][name = 'bolt']/on-order" data-type="number" data-help="Number of items on order">42</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">SKU</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sku" data-xpath="/top/data/item/sku" data-type="string" data-help="Stock Keeping Unit" data-key="key">HRD-000-632</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="text"> '</div>
+ <div class="data" data-tag="name" data-xpath="/top/data/item/name" data-type="string" data-help="Name of the item" data-key="key">water</div>
+ <div class="text">':</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">Total sold</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sold" data-xpath="/top/data/item[sku = 'GRO-000-2331'][name = 'water']/sold" data-type="number" data-help="Number of items sold">17.0</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">In stock</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock" data-xpath="/top/data/item[sku = 'GRO-000-2331'][name = 'water']/in-stock" data-type="number" data-help="Number of items in stock">14</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">On order</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="on-order" data-xpath="/top/data/item[sku = 'GRO-000-2331'][name = 'water']/on-order" data-type="number" data-help="Number of items on order">2</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">SKU</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sku" data-xpath="/top/data/item/sku" data-type="string" data-help="Stock Keeping Unit" data-key="key">GRO-000-2331</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="text"> '</div>
+ <div class="data" data-tag="name" data-xpath="/top/data/item/name" data-type="string" data-help="Name of the item" data-key="key">fish</div>
+ <div class="text">':</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label effect-bold color-fg-white color-bg-blue">Total sold</div>
+ <div class="text effect-bold color-fg-white color-bg-blue">: </div>
+ <div class="data effect-bold color-fg-white color-bg-blue" data-tag="sold" data-xpath="/top/data/item[sku = 'GRO-000-533'][name = 'fish']/sold" data-type="number" data-help="Number of items sold">1321.0</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">In stock</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="in-stock" data-xpath="/top/data/item[sku = 'GRO-000-533'][name = 'fish']/in-stock" data-type="number" data-help="Number of items in stock">45</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">On order</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="on-order" data-xpath="/top/data/item[sku = 'GRO-000-533'][name = 'fish']/on-order" data-type="number" data-help="Number of items on order">1</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">SKU</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sku" data-xpath="/top/data/item/sku" data-type="string" data-help="Stock Keeping Unit" data-key="key">GRO-000-533</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="item" data-xpath="/top/data/item">gum</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="item" data-xpath="/top/data/item">rope</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="item" data-xpath="/top/data/item">ladder</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="item" data-xpath="/top/data/item">bolt</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="item" data-xpath="/top/data/item">water</div>
+</div>
+<div class="line">
+ <div class="text">X</div>
+ <div class="text">X</div>
+ <div class="text">X</div>
+ <div class="text">X</div>
+ <div class="text">X</div>
+ <div class="text">X</div>
+ <div class="text">X</div>
+ <div class="text">X</div>
+</div>
+<div class="line">
+ <div class="text">X</div>
+ <div class="padding"> </div>
+ <div class="text">X</div>
+ <div class="label">Cost</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="cost" data-xpath="/top/cost">425</div>
+</div>
+<div class="line">
+ <div class="text">X</div>
+ <div class="padding"> </div>
+ <div class="text">X</div>
+ <div class="label">Cost</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="cost" data-xpath="/top/cost">455</div>
+</div>
diff --git a/contrib/libxo/tests/core/saved/test_10.HP.err b/contrib/libxo/tests/core/saved/test_10.HP.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.HP.err
diff --git a/contrib/libxo/tests/core/saved/test_10.HP.out b/contrib/libxo/tests/core/saved/test_10.HP.out
new file mode 100644
index 0000000..abb1b01
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.HP.out
@@ -0,0 +1,316 @@
+<div class="line">
+ <div class="title color-fg-blue">blue</div>
+ <div class="title color-fg-green color-bg-blue">green</div>
+ <div class="title color-fg-red color-bg-green">red</div>
+ <div class="title color-fg-yellow color-bg-red">yellow</div>
+ <div class="title color-bg-yellow">default</div>
+</div>
+<div class="line">
+ <div class="data effect-bold" data-tag="data">bold</div>
+ <div class="text effect-bold"> </div>
+ <div class="data effect-bold effect-underline" data-tag="data">bold-ul</div>
+ <div class="text effect-bold effect-underline"> </div>
+ <div class="data effect-bold effect-underline effect-inverse color-fg-inverse color-bg-inverse" data-tag="data">triple</div>
+ <div class="text effect-bold effect-underline effect-inverse color-fg-inverse color-bg-inverse"> </div>
+ <div class="data effect-underline effect-inverse color-fg-inverse color-bg-inverse" data-tag="data">inv-ul</div>
+ <div class="text effect-underline effect-inverse color-fg-inverse color-bg-inverse"> </div>
+ <div class="data effect-underline" data-tag="data">underline</div>
+ <div class="text effect-underline"> </div>
+ <div class="data" data-tag="data">plain</div>
+</div>
+<div class="line">
+ <div class="title">Item </div>
+ <div class="title effect-bold effect-underline"> Total Sold</div>
+ <div class="title effect-underline"> In Stock</div>
+ <div class="title effect-underline effect-inverse color-fg-inverse color-bg-inverse"> On Order</div>
+ <div class="title"> SKU</div>
+</div>
+<div class="line">
+ <div class="data" data-tag="name" data-key="key">gum </div>
+ <div class="data" data-tag="sold"> 1412</div>
+ <div class="data" data-tag="in-stock"> 54</div>
+ <div class="data color-fg-yellow" data-tag="on-order"> 10</div>
+ <div class="data" data-tag="sku" data-key="key"> GRO-000-415</div>
+</div>
+<div class="line">
+ <div class="data" data-tag="name" data-key="key">rope </div>
+ <div class="data" data-tag="sold"> 85</div>
+ <div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock"> 4</div>
+ <div class="data" data-tag="on-order"> 2</div>
+ <div class="data" data-tag="sku" data-key="key"> HRD-000-212</div>
+</div>
+<div class="line">
+ <div class="data" data-tag="name" data-key="key">ladder </div>
+ <div class="data" data-tag="sold"> 0</div>
+ <div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock"> 2</div>
+ <div class="data" data-tag="on-order"> 1</div>
+ <div class="data" data-tag="sku" data-key="key"> HRD-000-517</div>
+</div>
+<div class="line">
+ <div class="data" data-tag="name" data-key="key">bolt </div>
+ <div class="data" data-tag="sold"> 4123</div>
+ <div class="data" data-tag="in-stock"> 144</div>
+ <div class="data color-fg-yellow" data-tag="on-order"> 42</div>
+ <div class="data" data-tag="sku" data-key="key"> HRD-000-632</div>
+</div>
+<div class="line">
+ <div class="data" data-tag="name" data-key="key">water </div>
+ <div class="data" data-tag="sold"> 17</div>
+ <div class="data" data-tag="in-stock"> 14</div>
+ <div class="data" data-tag="on-order"> 2</div>
+ <div class="data" data-tag="sku" data-key="key"> GRO-000-2331</div>
+</div>
+<div class="line">
+</div>
+<div class="line">
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="text"> '</div>
+ <div class="data" data-tag="name" data-key="key">gum</div>
+ <div class="text">':</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">Total sold</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sold">1412.0</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">In stock</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock">54</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">On order</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="on-order">10</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">SKU</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sku" data-key="key">GRO-000-415</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="text"> '</div>
+ <div class="data" data-tag="name" data-key="key">rope</div>
+ <div class="text">':</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">Total sold</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sold">85.0</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">In stock</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock">4</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">On order</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="on-order">2</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">SKU</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sku" data-key="key">HRD-000-212</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="text"> '</div>
+ <div class="data" data-tag="name" data-key="key">ladder</div>
+ <div class="text">':</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">Total sold</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sold">0</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">In stock</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock">2</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">On order</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="on-order">1</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">SKU</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sku" data-key="key">HRD-000-517</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="text"> '</div>
+ <div class="data" data-tag="name" data-key="key">bolt</div>
+ <div class="text">':</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">Total sold</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sold">4123.0</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">In stock</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock">144</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">On order</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="on-order">42</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">SKU</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sku" data-key="key">HRD-000-632</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="text"> '</div>
+ <div class="data" data-tag="name" data-key="key">water</div>
+ <div class="text">':</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">Total sold</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sold">17.0</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">In stock</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data effect-inverse color-fg-inverse color-bg-inverse" data-tag="in-stock">14</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">On order</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="on-order">2</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">SKU</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sku" data-key="key">GRO-000-2331</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="text"> '</div>
+ <div class="data" data-tag="name" data-key="key">fish</div>
+ <div class="text">':</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label effect-bold color-fg-white color-bg-blue">Total sold</div>
+ <div class="text effect-bold color-fg-white color-bg-blue">: </div>
+ <div class="data effect-bold color-fg-white color-bg-blue" data-tag="sold">1321.0</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">In stock</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="in-stock">45</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">On order</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="on-order">1</div>
+</div>
+<div class="line">
+ <div class="padding"> </div>
+ <div class="label">SKU</div>
+ <div class="text">: </div>
+ <div class="data" data-tag="sku" data-key="key">GRO-000-533</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="item">gum</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="item">rope</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="item">ladder</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="item">bolt</div>
+</div>
+<div class="line">
+ <div class="label">Item</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="item">water</div>
+</div>
+<div class="line">
+ <div class="text">X</div>
+ <div class="text">X</div>
+ <div class="text">X</div>
+ <div class="text">X</div>
+ <div class="text">X</div>
+ <div class="text">X</div>
+ <div class="text">X</div>
+ <div class="text">X</div>
+</div>
+<div class="line">
+ <div class="text">X</div>
+ <div class="padding"> </div>
+ <div class="text">X</div>
+ <div class="label">Cost</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="cost">425</div>
+</div>
+<div class="line">
+ <div class="text">X</div>
+ <div class="padding"> </div>
+ <div class="text">X</div>
+ <div class="label">Cost</div>
+ <div class="decoration">:</div>
+ <div class="padding"> </div>
+ <div class="data" data-tag="cost">455</div>
+</div>
diff --git a/contrib/libxo/tests/core/saved/test_10.J.err b/contrib/libxo/tests/core/saved/test_10.J.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.J.err
diff --git a/contrib/libxo/tests/core/saved/test_10.J.out b/contrib/libxo/tests/core/saved/test_10.J.out
new file mode 100644
index 0000000..5091685
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.J.out
@@ -0,0 +1,2 @@
+{"__version": "3.1.4", "top": {"data": {"item": [],"data":"bold","data":"bold-ul","data":"triple","data":"inv-ul","data":"underline","data":"plain", "item": [{"sku":"GRO-000-415","name":"gum","sold":1412,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17,"in-stock":14,"on-order":2}]}, "data": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412.0,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85.0,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123.0,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17.0,"in-stock":14,"on-order":2}]}, "data": {"item": [{"sku":"GRO-000-533","name":"fish","sold":1321.0,"in-stock":45,"on-order":1}]}, "data": {"item": ["gum","rope","ladder","bolt","water"]},"cost":425,"cost":455}
+}
diff --git a/contrib/libxo/tests/core/saved/test_10.JP.err b/contrib/libxo/tests/core/saved/test_10.JP.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.JP.err
diff --git a/contrib/libxo/tests/core/saved/test_10.JP.out b/contrib/libxo/tests/core/saved/test_10.JP.out
new file mode 100644
index 0000000..0ca3269
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.JP.out
@@ -0,0 +1,113 @@
+{
+ "__version": "3.1.4",
+ "top": {
+ "data": {
+ "item": [
+ ],
+ "data": "bold",
+ "data": "bold-ul",
+ "data": "triple",
+ "data": "inv-ul",
+ "data": "underline",
+ "data": "plain",
+ "item": [
+ {
+ "sku": "GRO-000-415",
+ "name": "gum",
+ "sold": 1412,
+ "in-stock": 54,
+ "on-order": 10
+ },
+ {
+ "sku": "HRD-000-212",
+ "name": "rope",
+ "sold": 85,
+ "in-stock": 4,
+ "on-order": 2
+ },
+ {
+ "sku": "HRD-000-517",
+ "name": "ladder",
+ "sold": 0,
+ "in-stock": 2,
+ "on-order": 1
+ },
+ {
+ "sku": "HRD-000-632",
+ "name": "bolt",
+ "sold": 4123,
+ "in-stock": 144,
+ "on-order": 42
+ },
+ {
+ "sku": "GRO-000-2331",
+ "name": "water",
+ "sold": 17,
+ "in-stock": 14,
+ "on-order": 2
+ }
+ ]
+ },
+ "data": {
+ "item": [
+ {
+ "sku": "GRO-000-415",
+ "name": "gum",
+ "sold": 1412.0,
+ "in-stock": 54,
+ "on-order": 10
+ },
+ {
+ "sku": "HRD-000-212",
+ "name": "rope",
+ "sold": 85.0,
+ "in-stock": 4,
+ "on-order": 2
+ },
+ {
+ "sku": "HRD-000-517",
+ "name": "ladder",
+ "sold": 0,
+ "in-stock": 2,
+ "on-order": 1
+ },
+ {
+ "sku": "HRD-000-632",
+ "name": "bolt",
+ "sold": 4123.0,
+ "in-stock": 144,
+ "on-order": 42
+ },
+ {
+ "sku": "GRO-000-2331",
+ "name": "water",
+ "sold": 17.0,
+ "in-stock": 14,
+ "on-order": 2
+ }
+ ]
+ },
+ "data": {
+ "item": [
+ {
+ "sku": "GRO-000-533",
+ "name": "fish",
+ "sold": 1321.0,
+ "in-stock": 45,
+ "on-order": 1
+ }
+ ]
+ },
+ "data": {
+ "item": [
+ "gum",
+ "rope",
+ "ladder",
+ "bolt",
+ "water"
+ ]
+ },
+ "cost": 425,
+ "cost": 455
+ }
+}
diff --git a/contrib/libxo/tests/core/saved/test_10.T.err b/contrib/libxo/tests/core/saved/test_10.T.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.T.err
diff --git a/contrib/libxo/tests/core/saved/test_10.T.out b/contrib/libxo/tests/core/saved/test_10.T.out
new file mode 100644
index 0000000..21fa81b
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.T.out
@@ -0,0 +1,48 @@
+bluegreenredyellowdefault
+bold bold-ul triple inv-ul underline plain
+Item  Total Sold In Stock On Order SKU
+gum 1412 54 10 GRO-000-415
+rope 85 4 2 HRD-000-212
+ladder 0 2 1 HRD-000-517
+bolt 4123 144 42 HRD-000-632
+water 17 14 2 GRO-000-2331
+
+
+Item 'gum':
+ Total sold: 1412.0
+ In stock: 54
+ On order: 10
+ SKU: GRO-000-415
+Item 'rope':
+ Total sold: 85.0
+ In stock: 4
+ On order: 2
+ SKU: HRD-000-212
+Item 'ladder':
+ Total sold: 0
+ In stock: 2
+ On order: 1
+ SKU: HRD-000-517
+Item 'bolt':
+ Total sold: 4123.0
+ In stock: 144
+ On order: 42
+ SKU: HRD-000-632
+Item 'water':
+ Total sold: 17.0
+ In stock: 14
+ On order: 2
+ SKU: GRO-000-2331
+Item 'fish':
+ Total sold: 1321.0
+ In stock: 45
+ On order: 1
+ SKU: GRO-000-533
+Item: gum
+Item: rope
+Item: ladder
+Item: bolt
+Item: water
+XXXXXXXX
+X XCost: 425
+X XCost: 455
diff --git a/contrib/libxo/tests/core/saved/test_10.X.err b/contrib/libxo/tests/core/saved/test_10.X.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.X.err
diff --git a/contrib/libxo/tests/core/saved/test_10.X.out b/contrib/libxo/tests/core/saved/test_10.X.out
new file mode 100644
index 0000000..49c6dd8
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.X.out
@@ -0,0 +1 @@
+<top __version="3.1.4"><data test="value"><data test2="value2">bold</data><data>bold-ul</data><data>triple</data><data>inv-ul</data><data>underline</data><data>plain</data><item><sku test3="value3" key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku test3="value3" key="key">HRD-000-212</sku><name key="key">rope</name><sold>85</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku test3="value3" key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku test3="value3" key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku test3="value3" key="key">GRO-000-2331</sku><name key="key">water</name><sold>17</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412.0</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku key="key">HRD-000-212</sku><name key="key">rope</name><sold>85.0</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123.0</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku key="key">GRO-000-2331</sku><name key="key">water</name><sold>17.0</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-533</sku><name key="key">fish</name><sold>1321.0</sold><in-stock>45</in-stock><on-order>1</on-order></item></data><data><item test4="value4">gum</item><item test4="value4">rope</item><item test4="value4">ladder</item><item test4="value4">bolt</item><item test4="value4">water</item></data><cost>425</cost><cost>455</cost></top> \ No newline at end of file
diff --git a/contrib/libxo/tests/core/saved/test_10.XP.err b/contrib/libxo/tests/core/saved/test_10.XP.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.XP.err
diff --git a/contrib/libxo/tests/core/saved/test_10.XP.out b/contrib/libxo/tests/core/saved/test_10.XP.out
new file mode 100644
index 0000000..33c88d9
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.XP.out
@@ -0,0 +1,100 @@
+<top __version="3.1.4">
+ <data test="value">
+ <data test2="value2">bold</data>
+ <data>bold-ul</data>
+ <data>triple</data>
+ <data>inv-ul</data>
+ <data>underline</data>
+ <data>plain</data>
+ <item>
+ <sku test3="value3" key="key">GRO-000-415</sku>
+ <name key="key">gum</name>
+ <sold>1412</sold>
+ <in-stock>54</in-stock>
+ <on-order>10</on-order>
+ </item>
+ <item>
+ <sku test3="value3" key="key">HRD-000-212</sku>
+ <name key="key">rope</name>
+ <sold>85</sold>
+ <in-stock>4</in-stock>
+ <on-order>2</on-order>
+ </item>
+ <item>
+ <sku test3="value3" key="key">HRD-000-517</sku>
+ <name key="key">ladder</name>
+ <sold>0</sold>
+ <in-stock>2</in-stock>
+ <on-order>1</on-order>
+ </item>
+ <item>
+ <sku test3="value3" key="key">HRD-000-632</sku>
+ <name key="key">bolt</name>
+ <sold>4123</sold>
+ <in-stock>144</in-stock>
+ <on-order>42</on-order>
+ </item>
+ <item>
+ <sku test3="value3" key="key">GRO-000-2331</sku>
+ <name key="key">water</name>
+ <sold>17</sold>
+ <in-stock>14</in-stock>
+ <on-order>2</on-order>
+ </item>
+ </data>
+ <data>
+ <item>
+ <sku key="key">GRO-000-415</sku>
+ <name key="key">gum</name>
+ <sold>1412.0</sold>
+ <in-stock>54</in-stock>
+ <on-order>10</on-order>
+ </item>
+ <item>
+ <sku key="key">HRD-000-212</sku>
+ <name key="key">rope</name>
+ <sold>85.0</sold>
+ <in-stock>4</in-stock>
+ <on-order>2</on-order>
+ </item>
+ <item>
+ <sku key="key">HRD-000-517</sku>
+ <name key="key">ladder</name>
+ <sold>0</sold>
+ <in-stock>2</in-stock>
+ <on-order>1</on-order>
+ </item>
+ <item>
+ <sku key="key">HRD-000-632</sku>
+ <name key="key">bolt</name>
+ <sold>4123.0</sold>
+ <in-stock>144</in-stock>
+ <on-order>42</on-order>
+ </item>
+ <item>
+ <sku key="key">GRO-000-2331</sku>
+ <name key="key">water</name>
+ <sold>17.0</sold>
+ <in-stock>14</in-stock>
+ <on-order>2</on-order>
+ </item>
+ </data>
+ <data>
+ <item>
+ <sku key="key">GRO-000-533</sku>
+ <name key="key">fish</name>
+ <sold>1321.0</sold>
+ <in-stock>45</in-stock>
+ <on-order>1</on-order>
+ </item>
+ </data>
+ <data>
+ <item test4="value4">gum</item>
+ <item test4="value4">rope</item>
+ <item test4="value4">ladder</item>
+ <item test4="value4">bolt</item>
+ <item test4="value4">water</item>
+ </data>
+ <cost>425</cost>
+ <cost>455</cost>
+</top>
diff --git a/contrib/libxo/tests/core/saved/test_10.err b/contrib/libxo/tests/core/saved/test_10.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.err
diff --git a/contrib/libxo/tests/core/saved/test_10.out b/contrib/libxo/tests/core/saved/test_10.out
new file mode 100644
index 0000000..c2ad7a0
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_10.out
@@ -0,0 +1,38 @@
+Item Total Sold In Stock On Order SKU
+gum 1412 54 10 GRO-000-415
+rope 85 4 2 HRD-000-212
+ladder 0 2 1 HRD-000-517
+bolt 4123 144 42 HRD-000-632
+water 17 14 2 GRO-000-2331
+
+
+Item 'gum':
+ Total sold: 1412.0
+ In stock: 54
+ On order: 10
+ SKU: GRO-000-415
+Item 'rope':
+ Total sold: 85.0
+ In stock: 4
+ On order: 2
+ SKU: HRD-000-212
+Item 'ladder':
+ Total sold: 0
+ In stock: 2
+ On order: 1
+ SKU: HRD-000-517
+Item 'bolt':
+ Total sold: 4123.0
+ In stock: 144
+ On order: 42
+ SKU: HRD-000-632
+Item 'water':
+ Total sold: 17.0
+ In stock: 14
+ On order: 2
+ SKU: GRO-000-2331
+Item 'fish':
+ Total sold: 1321.0
+ In stock: 45
+ On order: 1
+ SKU: GRO-000-533
diff --git a/contrib/libxo/tests/core/test_05.c b/contrib/libxo/tests/core/test_05.c
index 61241b8..a883a88 100644
--- a/contrib/libxo/tests/core/test_05.c
+++ b/contrib/libxo/tests/core/test_05.c
@@ -39,23 +39,38 @@ main (int argc, char **argv)
{ "Ashley", "Ash", "Meter & Smith", 1440, 40 },
{ "0123456789", "0123456789", "012345678901234567890", 1440, 40 },
{ "áƒáƒ®áƒšáƒ", "გáƒáƒ˜áƒáƒ áƒ", "სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ", 123, 90 },
+ { "෴ණ්ණ෴෴ණ්ණ෴", "Mick",
+ "෴ණ්ණ෴෴ණ්ණ෴෴ණ්ණ෴෴෴", 110, 20 },
{ NULL, NULL }
}, *ep = employees;
+ int rc;
argc = xo_parse_args(argc, argv);
if (argc < 0)
return 1;
xo_set_info(NULL, info, info_count);
+ xo_set_flags(NULL, XOF_COLUMNS);
xo_open_container("employees");
xo_emit("Οá½Ï‡á½¶ ταá½Ï„á½° παÏίσταταί μοι {:v1/%s}, {:v2/%s}\n",
"γιγνώσκειν", "ὦ ἄνδÏες ᾿Αθηναῖοι");
- xo_emit("გთხáƒáƒ•áƒ— {:v1/%s} {:v2/%s}\n",
+ rc = xo_emit("გთხáƒáƒ•áƒ— {:v1/%s} {:v2/%s}\n",
"áƒáƒ®áƒšáƒáƒ•áƒ” გáƒáƒ˜áƒáƒ áƒáƒ— რეგისტრáƒáƒªáƒ˜áƒ",
"Unicode-ის მეáƒáƒ—ე სáƒáƒ”რთáƒáƒ¨áƒáƒ áƒ˜áƒ¡áƒ");
+ xo_emit("{Twc:Width}{:width/%d}\n", rc);
+
+ /* Okay, Sinhala is uber cool ... */
+ rc = xo_emit("[{:sinhala}]\n", "෴ණ්ණ෴");
+ xo_emit("{Twc:Width}{:width/%d}\n", rc);
+ rc = xo_emit("[{:sinhala}]\n", "à·´");
+ xo_emit("{Twc:Width}{:width/%d}\n", rc);
+ rc = xo_emit("[{:sinhala/%-4..4s/%s}]\n", "෴ණ්ණ෴෴ණ්ණ෴");
+ xo_emit("[{:not-sinhala/%-4..4s/%s}]\n", "123456");
+ rc = xo_emit("[{:tag/%s}]\n", "ර්â€à¶");
+ xo_emit("{Twc:Width}{:width/%d}\n", rc);
xo_open_list("employee");
diff --git a/contrib/libxo/tests/core/test_10.c b/contrib/libxo/tests/core/test_10.c
new file mode 100644
index 0000000..223ec55
--- /dev/null
+++ b/contrib/libxo/tests/core/test_10.c
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2014, Juniper Networks, Inc.
+ * All rights reserved.
+ * This SOFTWARE is licensed under the LICENSE provided in the
+ * ../Copyright file. By downloading, installing, copying, or otherwise
+ * using the SOFTWARE, you agree to be bound by the terms of that
+ * LICENSE.
+ * Phil Shafer, July 2014
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <ctype.h>
+
+#include "xo.h"
+
+int
+main (int argc, char **argv)
+{
+ static char base_grocery[] = "GRO";
+ static char base_hardware[] = "HRD";
+ struct item {
+ const char *i_title;
+ int i_sold;
+ int i_instock;
+ int i_onorder;
+ const char *i_sku_base;
+ int i_sku_num;
+ };
+ struct item list[] = {
+ { "gum", 1412, 54, 10, base_grocery, 415 },
+ { "rope", 85, 4, 2, base_hardware, 212 },
+ { "ladder", 0, 2, 1, base_hardware, 517 },
+ { "bolt", 4123, 144, 42, base_hardware, 632 },
+ { "water", 17, 14, 2, base_grocery, 2331 },
+ { NULL, 0, 0, 0, NULL, 0 }
+ };
+ struct item list2[] = {
+ { "fish", 1321, 45, 1, base_grocery, 533 },
+ { NULL, 0, 0, 0, NULL, 0 }
+ };
+ struct item *ip;
+ xo_info_t info[] = {
+ { "in-stock", "number", "Number of items in stock" },
+ { "name", "string", "Name of the item" },
+ { "on-order", "number", "Number of items on order" },
+ { "sku", "string", "Stock Keeping Unit" },
+ { "sold", "number", "Number of items sold" },
+ { NULL, NULL, NULL },
+ };
+ int info_count = (sizeof(info) / sizeof(info[0])) - 1;
+
+ argc = xo_parse_args(argc, argv);
+ if (argc < 0)
+ return 1;
+
+ for (argc = 1; argv[argc]; argc++) {
+ if (strcmp(argv[argc], "xml") == 0)
+ xo_set_style(NULL, XO_STYLE_XML);
+ else if (strcmp(argv[argc], "json") == 0)
+ xo_set_style(NULL, XO_STYLE_JSON);
+ else if (strcmp(argv[argc], "text") == 0)
+ xo_set_style(NULL, XO_STYLE_TEXT);
+ else if (strcmp(argv[argc], "html") == 0)
+ xo_set_style(NULL, XO_STYLE_HTML);
+ else if (strcmp(argv[argc], "pretty") == 0)
+ xo_set_flags(NULL, XOF_PRETTY);
+ else if (strcmp(argv[argc], "xpath") == 0)
+ xo_set_flags(NULL, XOF_XPATH);
+ else if (strcmp(argv[argc], "info") == 0)
+ xo_set_flags(NULL, XOF_INFO);
+ else if (strcmp(argv[argc], "error") == 0) {
+ close(-1);
+ xo_err(1, "error detected");
+ }
+ }
+
+ xo_set_info(NULL, info, info_count);
+ xo_set_flags(NULL, XOF_KEYS);
+
+ /* Normally one would use "XOF_COLOR_ALLOWED", but we want to force it */
+ xo_set_flags(NULL, XOF_COLOR);
+
+ xo_set_version("3.1.4");
+
+ xo_open_container_h(NULL, "top");
+
+ xo_attr("test", "value");
+ xo_open_container("data");
+ xo_open_list("item");
+ xo_attr("test2", "value2");
+
+ static const char *colors[] =
+ { "blue", "green", "red", "yellow", "default", NULL };
+
+ int i;
+ for (i = 0; colors[i]; i++) {
+ if (i > 0)
+ xo_emit("{C:/bg-%s}", colors[i-1]);
+ xo_emit("{C:/fg-%s}{T:/%s}", colors[i], colors[i]);
+ }
+ xo_emit("{C:reset}\n");
+
+ xo_emit("{C:bold}{:data} {C:underline}{:data} {C:inverse}{:data} "
+ "{C:no-bold}{:data} {C:no-inverse}{:data} "
+ "{C:no-underline}{:data}\n",
+ "bold", "bold-ul", "triple", "inv-ul", "underline", "plain");
+
+ xo_emit("{T:Item/%-10s}{C:bold,underline}{T:Total Sold/%12s}{C:no-bold}"
+ "{T:In Stock/%12s}{C:/%s}"
+ "{T:On Order/%12s}{C:normal}{T:SKU/%5s}\n", "inverse");
+
+#if 0
+ xo_finish();
+ return 0;
+#endif
+
+ for (ip = list; ip->i_title; ip++) {
+ xo_open_instance("item");
+ xo_attr("test3", "value3");
+
+ xo_emit("{keq:sku/%s-%u/%s-000-%u}"
+ "{k:name/%-10s/%s}{n:sold/%12u/%u}"
+ "{C:/%s}{:in-stock/%12u/%u}{C:normal}"
+ "{C:/fg-%s}{:on-order/%12u/%u}{C:/fg-default}"
+ "{qkd:sku/%5s-000-%u/%s-000-%u}\n",
+ ip->i_sku_base, ip->i_sku_num,
+ ip->i_title, ip->i_sold,
+ (ip->i_instock < 5) ? "inverse" : "normal", ip->i_instock,
+ (ip->i_onorder > 5) ? "yellow" : "default", ip->i_onorder,
+ ip->i_sku_base, ip->i_sku_num);
+
+ xo_close_instance("item");
+ }
+
+ xo_close_list("item");
+ xo_close_container("data");
+
+ xo_emit("\n\n");
+
+ xo_open_container("data");
+ xo_open_list("item");
+
+ for (ip = list; ip->i_title; ip++) {
+ xo_open_instance("item");
+
+ xo_emit("{keq:sku/%s-%u/%s-000-%u}", ip->i_sku_base, ip->i_sku_num);
+ xo_emit("{L:Item} '{k:name/%s}':\n", ip->i_title);
+ xo_emit("{P: }{L:Total sold}: {n:sold/%u%s}\n",
+ ip->i_sold, ip->i_sold ? ".0" : "");
+ xo_emit("{P: }{Lcw:In stock}{C:inverse}{:in-stock/%u}{C:}\n",
+ ip->i_instock);
+ xo_emit("{P: }{Lcw:On order}{:on-order/%u}\n", ip->i_onorder);
+ xo_emit("{P: }{L:SKU}: {qkd:sku/%s-000-%u}\n",
+ ip->i_sku_base, ip->i_sku_num);
+
+ xo_close_instance("item");
+ }
+
+ xo_close_list("item");
+ xo_close_container("data");
+
+ xo_open_container("data");
+ xo_open_list("item");
+
+ for (ip = list2; ip->i_title; ip++) {
+ xo_open_instance("item");
+
+ xo_emit("{keq:sku/%s-%u/%s-000-%u}", ip->i_sku_base, ip->i_sku_num);
+ xo_emit("{L:Item} '{k:name/%s}':\n", ip->i_title);
+ xo_emit("{P: }{C:bg-blue , fg-white, bold }{L:Total sold}: "
+ "{n:sold/%u%s}{C:}\n",
+ ip->i_sold, ip->i_sold ? ".0" : "");
+ xo_emit("{P: }{Lcw:In stock}{:in-stock/%u}\n", ip->i_instock);
+ xo_emit("{P: }{Lcw:On order}{:on-order/%u}\n", ip->i_onorder);
+ xo_emit("{P: }{L:SKU}: {qkd:sku/%s-000-%u}\n",
+ ip->i_sku_base, ip->i_sku_num);
+
+ xo_close_instance("item");
+ }
+
+ xo_close_list("item");
+ xo_close_container("data");
+
+ xo_open_container("data");
+ xo_open_list("item");
+
+ for (ip = list; ip->i_title; ip++) {
+ xo_attr("test4", "value4");
+ xo_emit("{Lwc:Item}{l:item}\n", ip->i_title);
+ }
+
+ xo_close_list("item");
+ xo_close_container("data");
+
+ xo_emit("X{P:}X", "epic fail");
+ xo_emit("X{T:}X", "epic fail");
+ xo_emit("X{N:}X", "epic fail");
+ xo_emit("X{L:}X\n", "epic fail");
+
+ xo_emit("X{P: }X{Lwc:Cost}{:cost/%u}\n", 425);
+ xo_emit("X{P:/%30s}X{Lwc:Cost}{:cost/%u}\n", "", 455);
+
+ xo_close_container_h(NULL, "top");
+
+ xo_finish();
+
+ return 0;
+}
diff --git a/contrib/libxo/xo/xo.1 b/contrib/libxo/xo/xo.1
index 12fc959..9dcae85 100644
--- a/contrib/libxo/xo/xo.1
+++ b/contrib/libxo/xo/xo.1
@@ -74,7 +74,7 @@ utility accepts a format string suitable for
.Xr xo_emit 3
and a set of zero or more arguments used to supply data for that string.
.Bd -literal -offset indent
- xo "The {k:name} weighs {:weight/%d} pounds.\n" fish 6
+ xo "The {k:name} weighs {:weight/%d} pounds.\\n" fish 6
TEXT:
The fish weighs 6 pounds.
diff --git a/contrib/libxo/xohtml/Makefile.am b/contrib/libxo/xohtml/Makefile.am
new file mode 100644
index 0000000..49dffed
--- /dev/null
+++ b/contrib/libxo/xohtml/Makefile.am
@@ -0,0 +1,38 @@
+#
+# Copyright 2015, Juniper Networks, Inc.
+# All rights reserved.
+# This SOFTWARE is licensed under the LICENSE provided in the
+# ../Copyright file. By downloading, installing, copying, or otherwise
+# using the SOFTWARE, you agree to be bound by the terms of that
+# LICENSE.
+
+man_MANS = xohtml.1
+
+EXTERNAL_FILES = \
+ external/jquery.js \
+ external/jquery.qtip.css \
+ external/jquery.qtip.js
+
+INTERNAL_FILES = \
+ xohtml.js \
+ xohtml.css
+
+EXTRA_DIST = \
+ xohtml.1 \
+ xohtml.sh.in \
+ ${INTERNAL_FILES} \
+ ${EXTERNAL_FILES}
+
+install-exec-hook:
+ install xohtml.sh ${DESTDIR}${bindir}/xohtml
+ mkdir -p ${DESTDIR}${XO_SHAREDIR}/external
+ for file in ${INTERNAL_FILES}; do \
+ install ${srcdir}/$$file ${DESTDIR}${XO_SHAREDIR} ; done
+ for file in ${EXTERNAL_FILES}; do \
+ install ${srcdir}/$$file ${DESTDIR}${XO_SHAREDIR}/external ; done
+
+uninstall-hook:
+ for file in ${INTERNAL_FILES} ${EXTERNAL_FILES}; do \
+ rm ${DESTDIR}${XO_SHAREDIR}/$$file ; done
+ rmdir ${DESTDIR}${XO_SHAREDIR}/external
+ rm -f ${DESTDIR}${bindir}/xohtml
diff --git a/contrib/libxo/xohtml/xohtml.1 b/contrib/libxo/xohtml/xohtml.1
new file mode 100644
index 0000000..d520cb3
--- /dev/null
+++ b/contrib/libxo/xohtml/xohtml.1
@@ -0,0 +1,125 @@
+.\" #
+.\" # Copyright (c) 2015, Juniper Networks, Inc.
+.\" # All rights reserved.
+.\" # This SOFTWARE is licensed under the LICENSE provided in the
+.\" # ../Copyright file. By downloading, installing, copying, or
+.\" # using the SOFTWARE, you agree to be bound by the terms of that
+.\" # LICENSE.
+.\" # Phil Shafer, July 2014
+.\"
+.Dd December 4, 2014
+.Dt XOHTML 1
+.Os
+.Sh NAME
+.Nm xohtml
+.Nd display libxo html output
+.Xr xo_emit 3
+.Sh SYNOPSIS
+.Nm xohtml
+.Op Fl c
+.Op Fl "b <base>"
+.Op Fl "c" <command>"
+.Op Fl "f" <output>
+.Op Ar command argument...
+.Sh DESCRIPTION
+.Nm
+is a tool for preparing
+.Xr libxo 3
+HTML output for display in modern HTML web browsers.
+.Nm
+can operate in two modes.
+If command is provided
+either with the
+.Fl c
+option or as argument(s) to the
+.Nm
+command, that command is executed and the resulting output is processed.
+If no command is given, the
+standard input is used.
+.Pp
+.Nm
+is typically used to wrap
+.Nm libxo
+output with sufficient HTML content to allow display in a web browser.
+This includes parent HTML tags as well as
+.Nm CSS
+stylesheets and
+.Nm Javascript
+files.
+.Pp
+If the command is given directly on the command line,
+.Nm
+will add the "--libxo=html" option needed to generate HTML output
+from
+.Nm libxo "-enabled"
+applications. See
+.Xr libxo 3
+for details.
+.Pp
+The following options are available:
+.Bl -tag -width indent
+.It Fl "b <base>"
+.It Fl "-base <base>"
+Supplies a source path for the CSS and Javascript files referenced in
+the output of
+.Nm xohtml .
+.It Fl "c <command>"
+.It Fl "-command <command>"
+Use the given command instead of one on the command line.
+This command should be quoted if it consists of multiple tokens, and
+should contain the "--libxo=html" option or equivalent, since the
+command is used directly.
+.It Fl "f <file>"
+.It Fl "-file <file>"
+Output is saved to the given file, rather than to the standard output
+descriptor.
+.El
+.Pp
+.Sh EXAMPLES
+The following command line will run "du --libxo=html ~/src" and save
+the output to /tmp/src.html:
+.Bd -literal -offset indent
+ xohtml du ~/src > /tmp/src.html
+.Ed
+.Pp
+The following command line will run "du --libxo=html,warn ~/src" and save
+the output to /tmp/src.html:
+.Bd -literal -offset indent
+ du --libxo=html,warn ~/src | xohtml -f /tmp/src.html
+.Ed
+.Pp
+The following command line will run "du --libxo=html,warn ~/src" and save
+the output to /tmp/src.html:
+.Bd -literal -offset indent
+ xohtml -c "du --libxo=html,warn ~/src" -f /tmp/src.html
+.Ed
+.Pp
+.Sh ADDITIONAL DOCUMENTATION
+Complete documentation can be found on github:
+.Bd -literal -offset indent
+http://juniper.github.io/libxo/libxo-manual.html
+.Ed
+.Pp
+.Nm libxo
+lives on github as:
+.Bd -literal -offset indent
+https://github.com/Juniper/libxo
+.Ed
+.Pp
+The latest release of
+.Nm libxo
+is available at:
+.Bd -literal -offset indent
+https://github.com/Juniper/libxo/releases
+.Ed
+.Sh SEE ALSO
+.Xr libxo 3 ,
+.Xr xo_emit 3
+.Sh HISTORY
+The
+.Nm libxo
+library was added in
+.Fx 11.0 .
+.Sh AUTHOR
+Phil Shafer
+
diff --git a/contrib/libxo/xohtml/xohtml.css b/contrib/libxo/xohtml/xohtml.css
index 655bf12..fc9ea06 100644
--- a/contrib/libxo/xohtml/xohtml.css
+++ b/contrib/libxo/xohtml/xohtml.css
@@ -1014,3 +1014,27 @@ div.xpath {
position: relative;
top: 1px;
}
+
+div.color-fg-black { color: black; }
+div.color-fg-red { color: red; }
+div.color-fg-green { color: green; }
+div.color-fg-yellow { color: yellow; }
+div.color-fg-blue { color: blue; }
+div.color-fg-magenta { color: magenta; }
+div.color-fg-cyan { color: cyan; }
+div.color-fg-white { color: white; }
+
+div.color-bg-black { background-color: black; }
+div.color-bg-red { background-color: red; }
+div.color-bg-green { background-color: green; }
+div.color-bg-yellow { background-color: yellow; }
+div.color-bg-blue { background-color: blue; }
+div.color-bg-magenta { background-color: magenta; }
+div.color-bg-cyan { background-color: cyan; }
+div.color-bg-white { background-color: white; }
+
+div.color-fg-inverse { color: white; }
+div.color-bg-inverse { background-color: black; }
+
+div.effect-bold { font-weight:bold; }
+div.effect-underline { text-decoration: underline; }
diff --git a/contrib/libxo/xohtml/xohtml.sh.in b/contrib/libxo/xohtml/xohtml.sh.in
index cbd3066..a15d82e 100644
--- a/contrib/libxo/xohtml/xohtml.sh.in
+++ b/contrib/libxo/xohtml/xohtml.sh.in
@@ -13,6 +13,16 @@ BASE=@XO_SHAREDIR@
CMD=cat
DONE=
+do_help () {
+ echo "xohtml: wrap libxo-enabled output in HTML"
+ echo "Usage: xohtml [options] [command [arguments]]"
+ echo "Valid options are:"
+ echo " -b <basepath> | --base <basepath>"
+ echo " -c <command> | --command <command>"
+ echo " -f <output-file> | --file <output-file>"
+ exit 1
+}
+
while [ -z "$DONE" -a ! -z "$1" ]; do
case "$1" in
-b|--base)
@@ -31,12 +41,22 @@ while [ -z "$DONE" -a ! -z "$1" ]; do
shift;
exec > "$FILE";
;;
+ -*)
+ do_help
+ ;;
*)
DONE=1;
+ XX=$1;
+ shift;
+ CMD="$XX --libxo=html $@"
;;
esac
done
+if [ "$CMD" = "cat" -a -t 0 ]; then
+ do_help
+fi
+
echo "<html>\n<head>\n"
echo '<meta http-equiv="content-type" content="text/html; charset=utf-8"/>'
echo '<link rel="stylesheet" href="'$BASE'/xohtml.css">'
diff --git a/contrib/libxo/xolint/Makefile.am b/contrib/libxo/xolint/Makefile.am
index a847e72..ec5c36d 100644
--- a/contrib/libxo/xolint/Makefile.am
+++ b/contrib/libxo/xolint/Makefile.am
@@ -12,3 +12,6 @@ EXTRA_DIST = xolint.1 xolint.pl
install-exec-hook:
install ${srcdir}/xolint.pl ${DESTDIR}${bindir}/xolint
+
+uninstall-hook:
+ rm -f ${DESTDIR}${bindir}/xolint
diff --git a/contrib/libxo/xolint/xolint.1 b/contrib/libxo/xolint/xolint.1
index fcf7bcd..16a59fc 100644
--- a/contrib/libxo/xolint/xolint.1
+++ b/contrib/libxo/xolint/xolint.1
@@ -99,6 +99,6 @@ https://github.com/Juniper/libxo/releases
The
.Nm libxo
library was added in
-.Fx 10.1 .
+.Fx 11.0 .
.Sh AUTHOR
Phil Shafer
diff --git a/contrib/libxo/xolint/xolint.pl b/contrib/libxo/xolint/xolint.pl
index 427edf7..515f7fa 100755
--- a/contrib/libxo/xolint/xolint.pl
+++ b/contrib/libxo/xolint/xolint.pl
@@ -347,32 +347,32 @@ sub check_field {
error("only one field role can be used (" . join(", ", @roles) . ")")
if $#roles > 0;
- # Field is a note, label, or title
- if ($field[0] =~ /[DLNT]/) {
+ # Field is a color, note, label, or title
+ if ($field[0] =~ /[CDLNT]/) {
- #@ Potential missing slash after N, L, or T with format
+ #@ Potential missing slash after C, D, N, L, or T with format
#@ xo_emit("{T:%6.6s}\n", "Max");
#@ should be:
#@ xo_emit("{T:/%6.6s}\n", "Max");
#@ The "%6.6s" will be a literal, not a field format. While
#@ it's possibly valid, it's likely a missing "/".
- info("potential missing slash after N, L, or T with format")
+ info("potential missing slash after C, D, N, L, or T with format")
if $field[1] =~ /%/;
#@ An encoding format cannot be given (roles: DNLT)
#@ xo_emit("{T:Max//%s}", "Max");
- #@ Fields with the D, N, L, and T roles are not emitted in
+ #@ Fields with the C, D, N, L, and T roles are not emitted in
#@ the 'encoding' style (JSON, XML), so an encoding format
#@ would make no sense.
error("encoding format cannot be given when content is present")
if $field[3];
}
- # Field is a decoration, label, or title
- if ($field[0] =~ /DLN/) {
- #@ Format cannot be given when content is present (roles: DLN)
+ # Field is a color, decoration, label, or title
+ if ($field[0] =~ /[CDLN]/) {
+ #@ Format cannot be given when content is present (roles: CDLN)
#@ xo_emit("{N:Max/%6.6s}", "Max");
- #@ Fields with the D, L, or N roles can't have both
+ #@ Fields with the C, D, L, or N roles can't have both
#@ static literal content ("{L:Label}") and a
#@ format ("{L:/%s}").
#@ This error will also occur when the content has a backslash
@@ -383,6 +383,49 @@ sub check_field {
if $field[1] && $field[2];
}
+ # Field is a color/effect
+ if ($field[0] =~ /C/) {
+ if ($field[1]) {
+ my $val;
+ my @sub = split(/,/, $field[1]);
+ grep { s/^\s*//; s/\s*$//; } @sub;
+
+ for $val (@sub) {
+ if ($val =~ /^(default,black,red,green,yellow,blue,magenta,cyan,white)$/) {
+
+ #@ Field has color without fg- or bg- (role: C)
+ #@ xo_emit("{C:green}{:foo}{C:}", x);
+ #@ Should be:
+ #@ xo_emit("{C:fg-green}{:foo}{C:}", x);
+ #@ Colors must be prefixed by either "fg-" or "bg-".
+ error("Field has color without fg- or bg- (role: C)");
+
+ } elsif ($val =~ /^(fg|bg)-(default|black|red|green|yellow|blue|magenta|cyan|white)$/) {
+ # color
+ } elsif ($val =~ /^(bold|underline)$/) {
+ } elsif ($val =~ /^(no-)?(bold|underline|inverse)$/) {
+ # effect
+
+ } elsif ($val =~ /^(reset|normal)$/) {
+ # effect also
+ } else {
+ #@ Field has invalid color or effect (role: C)
+ #@ xo_emit("{C:fg-purple,bold}{:foo}{C:gween}", x);
+ #@ Should be:
+ #@ xo_emit("{C:fg-red,bold}{:foo}{C:fg-green}", x);
+ #@ The list of colors and effects are limited. The
+ #@ set of colors includes default, black, red, green,
+ #@ yellow, blue, magenta, cyan, and white, which must
+ #@ be prefixed by either "fg-" or "bg-". Effects are
+ #@ limited to bold, no-bold, underline, no-underline,
+ #@ inverse, no-inverse, normal, and reset. Values must
+ #@ be separated by commas.
+ error("Field has invalid color or effect (role: C) ($val)");
+ }
+ }
+ }
+ }
+
# A value field
if (length($field[0]) == 0 || $field[0] =~ /V/) {
@@ -456,7 +499,7 @@ sub check_field {
#@ Should be:
#@ xo_emit("{D:((}{:good}{D:))}", "yes");
#@ This is minor, but fields should use proper roles. Decoration
- #@ fields are meant to hold puncuation and other characters used
+ #@ fields are meant to hold punctuation and other characters used
#@ to decorate the content, typically to make it more readable
#@ to human readers.
warn("decoration field contains invalid character")
diff --git a/contrib/mdocml/config.h b/contrib/mdocml/config.h
index b952c45..e7d3c63 100644
--- a/contrib/mdocml/config.h
+++ b/contrib/mdocml/config.h
@@ -12,7 +12,7 @@
#define HAVE_FTS 1
#define HAVE_GETSUBOPT 1
#define HAVE_MMAP 1
-#define HAVE_REALLOCARRAY 0
+#define HAVE_REALLOCARRAY 1
#define HAVE_STRCASESTR 1
#define HAVE_STRLCAT 1
#define HAVE_STRLCPY 1
diff --git a/contrib/netcat/netcat.c b/contrib/netcat/netcat.c
index bb853c9..041fff8 100644
--- a/contrib/netcat/netcat.c
+++ b/contrib/netcat/netcat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netcat.c,v 1.122 2014/07/20 01:38:40 guenther Exp $ */
+/* $OpenBSD: netcat.c,v 1.127 2015/02/14 22:40:22 jca Exp $ */
/*
* Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
*
@@ -42,7 +42,6 @@
#include <sys/un.h>
#include <netinet/in.h>
-#include <netinet/in_systm.h>
#ifdef IPSEC
#include <netipsec/ipsec.h>
#endif
@@ -73,6 +72,12 @@
#define PORT_MAX_LEN 6
#define UNIX_DG_TMP_SOCKET_SIZE 19
+#define POLL_STDIN 0
+#define POLL_NETOUT 1
+#define POLL_NETIN 2
+#define POLL_STDOUT 3
+#define BUFSIZE 16384
+
/* Command Line Options */
int dflag; /* detached, no stdin */
int Fflag; /* fdpass sock to stdout */
@@ -117,10 +122,12 @@ int udptest(int);
int unix_bind(char *);
int unix_connect(char *);
int unix_listen(char *);
-void set_common_sockopts(int);
+void set_common_sockopts(int, int);
int map_tos(char *, int *);
void report_connect(const struct sockaddr *, socklen_t);
void usage(int);
+ssize_t drainbuf(int, unsigned char *, size_t *);
+ssize_t fillbuf(int, unsigned char *, size_t *);
#ifdef IPSEC
void add_ipsec_policy(int, char *);
@@ -436,7 +443,7 @@ main(int argc, char *argv[])
&len);
if (connfd == -1) {
/* For now, all errnos are fatal */
- err(1, "accept");
+ err(1, "accept");
}
if (vflag)
report_connect((struct sockaddr *)&cliaddr, len);
@@ -663,7 +670,7 @@ remote_connect(const char *host, const char *port, struct addrinfo hints)
freeaddrinfo(ares);
}
- set_common_sockopts(s);
+ set_common_sockopts(s, res0->ai_family);
if (timeout_connect(s, res0->ai_addr, res0->ai_addrlen) == 0)
break;
@@ -767,6 +774,8 @@ local_listen(char *host, char *port, struct addrinfo hints)
err(1, "disable TCP options");
}
+ set_common_sockopts(s, res0->ai_family);
+
if (bind(s, (struct sockaddr *)res0->ai_addr,
res0->ai_addrlen) == 0)
break;
@@ -790,68 +799,224 @@ local_listen(char *host, char *port, struct addrinfo hints)
* Loop that polls on the network file descriptor and stdin.
*/
void
-readwrite(int nfd)
+readwrite(int net_fd)
{
- struct pollfd pfd[2];
- unsigned char buf[16 * 1024];
- int n, wfd = fileno(stdin);
- int lfd = fileno(stdout);
- int plen;
-
- plen = sizeof(buf);
-
- /* Setup Network FD */
- pfd[0].fd = nfd;
- pfd[0].events = POLLIN;
-
- /* Set up STDIN FD. */
- pfd[1].fd = wfd;
- pfd[1].events = POLLIN;
+ struct pollfd pfd[4];
+ int stdin_fd = STDIN_FILENO;
+ int stdout_fd = STDOUT_FILENO;
+ unsigned char netinbuf[BUFSIZE];
+ size_t netinbufpos = 0;
+ unsigned char stdinbuf[BUFSIZE];
+ size_t stdinbufpos = 0;
+ int n, num_fds;
+ ssize_t ret;
+
+ /* don't read from stdin if requested */
+ if (dflag)
+ stdin_fd = -1;
+
+ /* stdin */
+ pfd[POLL_STDIN].fd = stdin_fd;
+ pfd[POLL_STDIN].events = POLLIN;
+
+ /* network out */
+ pfd[POLL_NETOUT].fd = net_fd;
+ pfd[POLL_NETOUT].events = 0;
+
+ /* network in */
+ pfd[POLL_NETIN].fd = net_fd;
+ pfd[POLL_NETIN].events = POLLIN;
+
+ /* stdout */
+ pfd[POLL_STDOUT].fd = stdout_fd;
+ pfd[POLL_STDOUT].events = 0;
+
+ while (1) {
+ /* both inputs are gone, buffers are empty, we are done */
+ if (pfd[POLL_STDIN].fd == -1 && pfd[POLL_NETIN].fd == -1
+ && stdinbufpos == 0 && netinbufpos == 0) {
+ close(net_fd);
+ return;
+ }
+ /* both outputs are gone, we can't continue */
+ if (pfd[POLL_NETOUT].fd == -1 && pfd[POLL_STDOUT].fd == -1) {
+ close(net_fd);
+ return;
+ }
+ /* listen and net in gone, queues empty, done */
+ if (lflag && pfd[POLL_NETIN].fd == -1
+ && stdinbufpos == 0 && netinbufpos == 0) {
+ close(net_fd);
+ return;
+ }
- while (pfd[0].fd != -1) {
+ /* help says -i is for "wait between lines sent". We read and
+ * write arbitrary amounts of data, and we don't want to start
+ * scanning for newlines, so this is as good as it gets */
if (iflag)
sleep(iflag);
- if ((n = poll(pfd, 2 - dflag, timeout)) < 0) {
- int saved_errno = errno;
- close(nfd);
- errc(1, saved_errno, "Polling Error");
+ /* poll */
+ num_fds = poll(pfd, 4, timeout);
+
+ /* treat poll errors */
+ if (num_fds == -1) {
+ close(net_fd);
+ err(1, "polling error");
}
- if (n == 0)
+ /* timeout happened */
+ if (num_fds == 0)
return;
- if (pfd[0].revents & POLLIN) {
- if ((n = read(nfd, buf, plen)) < 0)
- return;
- else if (n == 0) {
- shutdown(nfd, SHUT_RD);
- pfd[0].fd = -1;
- pfd[0].events = 0;
- } else {
- if (tflag)
- atelnet(nfd, buf, n);
- if (atomicio(vwrite, lfd, buf, n) != n)
- return;
+ /* treat socket error conditions */
+ for (n = 0; n < 4; n++) {
+ if (pfd[n].revents & (POLLERR|POLLNVAL)) {
+ pfd[n].fd = -1;
}
}
+ /* reading is possible after HUP */
+ if (pfd[POLL_STDIN].events & POLLIN &&
+ pfd[POLL_STDIN].revents & POLLHUP &&
+ ! (pfd[POLL_STDIN].revents & POLLIN))
+ pfd[POLL_STDIN].fd = -1;
+
+ if (pfd[POLL_NETIN].events & POLLIN &&
+ pfd[POLL_NETIN].revents & POLLHUP &&
+ ! (pfd[POLL_NETIN].revents & POLLIN))
+ pfd[POLL_NETIN].fd = -1;
+
+ if (pfd[POLL_NETOUT].revents & POLLHUP) {
+ if (Nflag)
+ shutdown(pfd[POLL_NETOUT].fd, SHUT_WR);
+ pfd[POLL_NETOUT].fd = -1;
+ }
+ /* if HUP, stop watching stdout */
+ if (pfd[POLL_STDOUT].revents & POLLHUP)
+ pfd[POLL_STDOUT].fd = -1;
+ /* if no net out, stop watching stdin */
+ if (pfd[POLL_NETOUT].fd == -1)
+ pfd[POLL_STDIN].fd = -1;
+ /* if no stdout, stop watching net in */
+ if (pfd[POLL_STDOUT].fd == -1) {
+ if (pfd[POLL_NETIN].fd != -1)
+ shutdown(pfd[POLL_NETIN].fd, SHUT_RD);
+ pfd[POLL_NETIN].fd = -1;
+ }
- if (!dflag && pfd[1].revents & POLLIN) {
- if ((n = read(wfd, buf, plen)) < 0)
- return;
- else if (n == 0) {
- if (Nflag)
- shutdown(nfd, SHUT_WR);
- pfd[1].fd = -1;
- pfd[1].events = 0;
- } else {
- if (atomicio(vwrite, nfd, buf, n) != n)
- return;
+ /* try to read from stdin */
+ if (pfd[POLL_STDIN].revents & POLLIN && stdinbufpos < BUFSIZE) {
+ ret = fillbuf(pfd[POLL_STDIN].fd, stdinbuf,
+ &stdinbufpos);
+ /* error or eof on stdin - remove from pfd */
+ if (ret == 0 || ret == -1)
+ pfd[POLL_STDIN].fd = -1;
+ /* read something - poll net out */
+ if (stdinbufpos > 0)
+ pfd[POLL_NETOUT].events = POLLOUT;
+ /* filled buffer - remove self from polling */
+ if (stdinbufpos == BUFSIZE)
+ pfd[POLL_STDIN].events = 0;
+ }
+ /* try to write to network */
+ if (pfd[POLL_NETOUT].revents & POLLOUT && stdinbufpos > 0) {
+ ret = drainbuf(pfd[POLL_NETOUT].fd, stdinbuf,
+ &stdinbufpos);
+ if (ret == -1)
+ pfd[POLL_NETOUT].fd = -1;
+ /* buffer empty - remove self from polling */
+ if (stdinbufpos == 0)
+ pfd[POLL_NETOUT].events = 0;
+ /* buffer no longer full - poll stdin again */
+ if (stdinbufpos < BUFSIZE)
+ pfd[POLL_STDIN].events = POLLIN;
+ }
+ /* try to read from network */
+ if (pfd[POLL_NETIN].revents & POLLIN && netinbufpos < BUFSIZE) {
+ ret = fillbuf(pfd[POLL_NETIN].fd, netinbuf,
+ &netinbufpos);
+ if (ret == -1)
+ pfd[POLL_NETIN].fd = -1;
+ /* eof on net in - remove from pfd */
+ if (ret == 0) {
+ shutdown(pfd[POLL_NETIN].fd, SHUT_RD);
+ pfd[POLL_NETIN].fd = -1;
}
+ /* read something - poll stdout */
+ if (netinbufpos > 0)
+ pfd[POLL_STDOUT].events = POLLOUT;
+ /* filled buffer - remove self from polling */
+ if (netinbufpos == BUFSIZE)
+ pfd[POLL_NETIN].events = 0;
+ /* handle telnet */
+ if (tflag)
+ atelnet(pfd[POLL_NETIN].fd, netinbuf,
+ netinbufpos);
+ }
+ /* try to write to stdout */
+ if (pfd[POLL_STDOUT].revents & POLLOUT && netinbufpos > 0) {
+ ret = drainbuf(pfd[POLL_STDOUT].fd, netinbuf,
+ &netinbufpos);
+ if (ret == -1)
+ pfd[POLL_STDOUT].fd = -1;
+ /* buffer empty - remove self from polling */
+ if (netinbufpos == 0)
+ pfd[POLL_STDOUT].events = 0;
+ /* buffer no longer full - poll net in again */
+ if (netinbufpos < BUFSIZE)
+ pfd[POLL_NETIN].events = POLLIN;
+ }
+
+ /* stdin gone and queue empty? */
+ if (pfd[POLL_STDIN].fd == -1 && stdinbufpos == 0) {
+ if (pfd[POLL_NETOUT].fd != -1 && Nflag)
+ shutdown(pfd[POLL_NETOUT].fd, SHUT_WR);
+ pfd[POLL_NETOUT].fd = -1;
+ }
+ /* net in gone and queue empty? */
+ if (pfd[POLL_NETIN].fd == -1 && netinbufpos == 0) {
+ pfd[POLL_STDOUT].fd = -1;
}
}
}
+ssize_t
+drainbuf(int fd, unsigned char *buf, size_t *bufpos)
+{
+ ssize_t n;
+ ssize_t adjust;
+
+ n = write(fd, buf, *bufpos);
+ /* don't treat EAGAIN, EINTR as error */
+ if (n == -1 && (errno == EAGAIN || errno == EINTR))
+ n = -2;
+ if (n <= 0)
+ return n;
+ /* adjust buffer */
+ adjust = *bufpos - n;
+ if (adjust > 0)
+ memmove(buf, buf + n, adjust);
+ *bufpos -= n;
+ return n;
+}
+
+
+ssize_t
+fillbuf(int fd, unsigned char *buf, size_t *bufpos)
+{
+ size_t num = BUFSIZE - *bufpos;
+ ssize_t n;
+
+ n = read(fd, buf + *bufpos, num);
+ /* don't treat EAGAIN, EINTR as error */
+ if (n == -1 && (errno == EAGAIN || errno == EINTR))
+ n = -2;
+ if (n <= 0)
+ return n;
+ *bufpos += n;
+ return n;
+}
+
/*
* fdpass()
* Pass the connected file descriptor to stdout and exit.
@@ -1025,7 +1190,7 @@ udptest(int s)
}
void
-set_common_sockopts(int s)
+set_common_sockopts(int s, int af)
{
int x = 1;
@@ -1040,8 +1205,17 @@ set_common_sockopts(int s)
err(1, NULL);
}
if (Tflag != -1) {
- if (setsockopt(s, IPPROTO_IP, IP_TOS,
- &Tflag, sizeof(Tflag)) == -1)
+ int proto, option;
+
+ if (af == AF_INET6) {
+ proto = IPPROTO_IPV6;
+ option = IPV6_TCLASS;
+ } else {
+ proto = IPPROTO_IP;
+ option = IP_TOS;
+ }
+
+ if (setsockopt(s, proto, option, &Tflag, sizeof(Tflag)) == -1)
err(1, "set IP ToS");
}
if (Iflag) {
diff --git a/contrib/ntp/ChangeLog b/contrib/ntp/ChangeLog
index 400cf79..e75384c 100644
--- a/contrib/ntp/ChangeLog
+++ b/contrib/ntp/ChangeLog
@@ -1,4 +1,80 @@
---
+(4.2.8p2) 2015/04/07 Released by Harlan Stenn <stenn@ntp.org>
+(4.2.8p2-RC3) 2015/04/03 Released by Harlan Stenn <stenn@ntp.org>
+
+* [Bug 2763] Fix for different thresholds for forward and backward steps.
+---
+(4.2.8p2-RC2) 2015/04/03 Released by Harlan Stenn <stenn@ntp.org>
+
+* [Bug 2592] FLAG_TSTAMP_PPS cleanup for refclock_parse.c.
+* [Bug 2769] New script: update-leap
+* [Bug 2769] cleannup for update-leap
+* [Bug 2788] New flag -G (force_step_once).
+* [Bug 2794] Clean up kernel clock status reports.
+* [Bug 2795] Cannot build without OpenSLL (on Win32).
+ Provided a Win32 specific wrapper around libevent/arc4random.c.
+ fixed some minor warnings.
+* [Bug 2796] ntp-keygen crashes in 'getclock()' on Win32.
+* [Bug 2797] ntp-keygen trapped in endless loop for MD5 keys
+ on big-endian machines.
+* [Bug 2798] sntp should decode and display the leap indicator.
+* Simple cleanup to html/build.html
+---
+(4.2.8p2-RC1) 2015/03/30 Released by Harlan Stenn <stenn@ntp.org>
+
+* [Bug 2794] Don't let reports on normal kernel status changes
+ look like errors.
+* [Bug 2788] New flag -G (force_step_once).
+* [Bug 2592] Account for PPS sources which can provide an accurate
+ absolute time stamp, and status information.
+ Fixed indention and removed trailing whitespace.
+* [Bug 1787] DCF77's formerly "antenna" bit is "call bit" since 2003.
+* [Bug 1960] setsockopt IPV6_MULTICAST_IF: Invalid argument.
+* [Bug 2346] "graceful termination" signals do not do peer cleanup.
+* [Bug 2728] See if C99-style structure initialization works.
+* [Bug 2747] Upgrade libevent to 2.1.5-beta.
+* [Bug 2749] ntp/lib/NTP/Util.pm needs update for ntpq -w, IPv6, .POOL. .
+* [Bug 2751] jitter.h has stale copies of l_fp macros.
+* [Bug 2756] ntpd hangs in startup with gcc 3.3.5 on ARM.
+* [Bug 2757] Quiet compiler warnings.
+* [Bug 2759] Expose nonvolatile/clk_wander_threshold to ntpq.
+* [Bug 2763] Allow different thresholds for forward and backward steps.
+* [Bug 2766] ntp-keygen output files should not be world-readable.
+* [Bug 2767] ntp-keygen -M should symlink to ntp.keys.
+* [Bug 2771] nonvolatile value is documented in wrong units.
+* [Bug 2773] Early leap announcement from Palisade/Thunderbolt
+* [Bug 2774] Unreasonably verbose printout - leap pending/warning
+* [Bug 2775] ntp-keygen.c fails to compile under Windows.
+* [Bug 2777] Fixed loops and decoding of Meinberg GPS satellite info.
+ Removed non-ASCII characters from some copyright comments.
+ Removed trailing whitespace.
+ Updated definitions for Meinberg clocks from current Meinberg header files.
+ Now use C99 fixed-width types and avoid non-ASCII characters in comments.
+ Account for updated definitions pulled from Meinberg header files.
+ Updated comments on Meinberg GPS receivers which are not only called GPS16x.
+ Replaced some constant numbers by defines from ntp_calendar.h
+ Modified creation of parse-specific variables for Meinberg devices
+ in gps16x_message().
+ Reworked mk_utcinfo() to avoid printing of ambiguous leap second dates.
+ Modified mbg_tm_str() which now expexts an additional parameter controlling
+ if the time status shall be printed.
+* [Sec 2779] ntpd accepts unauthenticated packets with symmetric key crypto.
+* [Sec 2781] Authentication doesn't protect symmetric associations against
+ DoS attacks.
+* [Bug 2783] Quiet autoconf warnings about missing AC_LANG_SOURCE.
+* [Bug 2789] Quiet compiler warnings from libevent.
+* [Bug 2790] If ntpd sets the Windows MM timer highest resolution
+ pause briefly before measuring system clock precision to yield
+ correct results.
+* Comment from Juergen Perlinger in ntp_calendar.c to make the code clearer.
+* Use predefined function types for parse driver functions
+ used to set up function pointers.
+ Account for changed prototype of parse_inp_fnc_t functions.
+ Cast parse conversion results to appropriate types to avoid
+ compiler warnings.
+ Let ioctl() for Windows accept a (void *) to avoid compiler warnings
+ when called with pointers to different types.
+---
(4.2.8p1) 2015/02/04 Released by Harlan Stenn <stenn@ntp.org>
* Update the NEWS file.
@@ -14,7 +90,7 @@
(This should work for all versions of Windows >= W2K)
* [Bug 2738] Missing buffer initialization in refclocK_parse.c::parsestate().
* [Bug 2739] Parse driver with PPS enabled occasionally evaluates
- PPS timestamp with wrong sign.
+ PPS timestamp with wrong sign.
Removed some German umlauts.
* [Bug 2740] Removed some obsolete code from the parse driver.
* [Bug 2741] Incorrect buffer check in refclocK_parse.c::parsestatus().
@@ -94,7 +170,7 @@
* [Bug 2678] nmea_control() now checks 'refclock_params()' result.
(4.2.7p481) 2014/11/22 Released by Harlan Stenn <stenn@ntp.org>
* [Bug 2314] Only enable PPS if kernel consumer binding succeeds.
-* [Bug 2314] Kernel PPS binding EOPNOTSUPP is a failure condition.
+* [Bug 2314] Kernel PPS binding EOPNOTSUPP is a failure condition.
* Rename pps_enable to hardpps_enable.
(4.2.7p480) 2014/11/21 Released by Harlan Stenn <stenn@ntp.org>
* [Bug 2677] PATH_MAX isn't #define'd under Windows.
diff --git a/contrib/ntp/CommitLog b/contrib/ntp/CommitLog
index 38097ac..0e87846 100644
--- a/contrib/ntp/CommitLog
+++ b/contrib/ntp/CommitLog
@@ -1,3 +1,2569 @@
+ChangeSet@1.3320, 2015-04-07 04:28:16-04:00, stenn@deacon.udel.edu
+ NTP_4_2_8P2
+ TAG: NTP_4_2_8P2
+
+ ChangeLog@1.1633 +1 -0
+ NTP_4_2_8P2
+
+ ntpd/invoke-ntp.conf.texi@1.182 +1 -1
+ NTP_4_2_8P2
+
+ ntpd/invoke-ntp.keys.texi@1.178 +1 -1
+ NTP_4_2_8P2
+
+ ntpd/invoke-ntpd.texi@1.495 +2 -2
+ NTP_4_2_8P2
+
+ ntpd/ntp.conf.5man@1.216 +3 -3
+ NTP_4_2_8P2
+
+ ntpd/ntp.conf.5mdoc@1.216 +2 -2
+ NTP_4_2_8P2
+
+ ntpd/ntp.conf.html@1.173 +1 -1
+ NTP_4_2_8P2
+
+ ntpd/ntp.conf.man.in@1.216 +3 -3
+ NTP_4_2_8P2
+
+ ntpd/ntp.conf.mdoc.in@1.216 +2 -2
+ NTP_4_2_8P2
+
+ ntpd/ntp.keys.5man@1.212 +2 -2
+ NTP_4_2_8P2
+
+ ntpd/ntp.keys.5mdoc@1.212 +2 -2
+ NTP_4_2_8P2
+
+ ntpd/ntp.keys.html@1.174 +1 -1
+ NTP_4_2_8P2
+
+ ntpd/ntp.keys.man.in@1.212 +2 -2
+ NTP_4_2_8P2
+
+ ntpd/ntp.keys.mdoc.in@1.212 +2 -2
+ NTP_4_2_8P2
+
+ ntpd/ntpd-opts.c@1.517 +245 -245
+ NTP_4_2_8P2
+
+ ntpd/ntpd-opts.h@1.516 +3 -3
+ NTP_4_2_8P2
+
+ ntpd/ntpd.1ntpdman@1.324 +3 -3
+ NTP_4_2_8P2
+
+ ntpd/ntpd.1ntpdmdoc@1.324 +2 -2
+ NTP_4_2_8P2
+
+ ntpd/ntpd.html@1.168 +2 -2
+ NTP_4_2_8P2
+
+ ntpd/ntpd.man.in@1.324 +3 -3
+ NTP_4_2_8P2
+
+ ntpd/ntpd.mdoc.in@1.324 +2 -2
+ NTP_4_2_8P2
+
+ ntpdc/invoke-ntpdc.texi@1.492 +2 -2
+ NTP_4_2_8P2
+
+ ntpdc/ntpdc-opts.c@1.510 +107 -107
+ NTP_4_2_8P2
+
+ ntpdc/ntpdc-opts.h@1.509 +3 -3
+ NTP_4_2_8P2
+
+ ntpdc/ntpdc.1ntpdcman@1.323 +3 -3
+ NTP_4_2_8P2
+
+ ntpdc/ntpdc.1ntpdcmdoc@1.323 +2 -2
+ NTP_4_2_8P2
+
+ ntpdc/ntpdc.html@1.336 +2 -2
+ NTP_4_2_8P2
+
+ ntpdc/ntpdc.man.in@1.323 +3 -3
+ NTP_4_2_8P2
+
+ ntpdc/ntpdc.mdoc.in@1.323 +2 -2
+ NTP_4_2_8P2
+
+ ntpq/invoke-ntpq.texi@1.498 +2 -2
+ NTP_4_2_8P2
+
+ ntpq/ntpq-opts.c@1.515 +106 -106
+ NTP_4_2_8P2
+
+ ntpq/ntpq-opts.h@1.513 +3 -3
+ NTP_4_2_8P2
+
+ ntpq/ntpq.1ntpqman@1.326 +3 -3
+ NTP_4_2_8P2
+
+ ntpq/ntpq.1ntpqmdoc@1.326 +2 -2
+ NTP_4_2_8P2
+
+ ntpq/ntpq.html@1.165 +2 -2
+ NTP_4_2_8P2
+
+ ntpq/ntpq.man.in@1.326 +3 -3
+ NTP_4_2_8P2
+
+ ntpq/ntpq.mdoc.in@1.326 +2 -2
+ NTP_4_2_8P2
+
+ ntpsnmpd/invoke-ntpsnmpd.texi@1.494 +2 -2
+ NTP_4_2_8P2
+
+ ntpsnmpd/ntpsnmpd-opts.c@1.512 +68 -68
+ NTP_4_2_8P2
+
+ ntpsnmpd/ntpsnmpd-opts.h@1.511 +3 -3
+ NTP_4_2_8P2
+
+ ntpsnmpd/ntpsnmpd.1ntpsnmpdman@1.323 +3 -3
+ NTP_4_2_8P2
+
+ ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc@1.323 +2 -2
+ NTP_4_2_8P2
+
+ ntpsnmpd/ntpsnmpd.html@1.163 +1 -1
+ NTP_4_2_8P2
+
+ ntpsnmpd/ntpsnmpd.man.in@1.323 +3 -3
+ NTP_4_2_8P2
+
+ ntpsnmpd/ntpsnmpd.mdoc.in@1.323 +2 -2
+ NTP_4_2_8P2
+
+ packageinfo.sh@1.509 +2 -2
+ NTP_4_2_8P2
+
+ scripts/calc_tickadj/calc_tickadj.1calc_tickadjman@1.84 +3 -3
+ NTP_4_2_8P2
+
+ scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc@1.85 +2 -2
+ NTP_4_2_8P2
+
+ scripts/calc_tickadj/calc_tickadj.html@1.86 +1 -1
+ NTP_4_2_8P2
+
+ scripts/calc_tickadj/calc_tickadj.man.in@1.83 +3 -3
+ NTP_4_2_8P2
+
+ scripts/calc_tickadj/calc_tickadj.mdoc.in@1.85 +2 -2
+ NTP_4_2_8P2
+
+ scripts/calc_tickadj/invoke-calc_tickadj.texi@1.88 +1 -1
+ NTP_4_2_8P2
+
+ scripts/invoke-plot_summary.texi@1.105 +2 -2
+ NTP_4_2_8P2
+
+ scripts/invoke-summary.texi@1.105 +2 -2
+ NTP_4_2_8P2
+
+ scripts/ntp-wait/invoke-ntp-wait.texi@1.315 +2 -2
+ NTP_4_2_8P2
+
+ scripts/ntp-wait/ntp-wait-opts@1.51 +2 -2
+ NTP_4_2_8P2
+
+ scripts/ntp-wait/ntp-wait.1ntp-waitman@1.312 +3 -3
+ NTP_4_2_8P2
+
+ scripts/ntp-wait/ntp-wait.1ntp-waitmdoc@1.313 +2 -2
+ NTP_4_2_8P2
+
+ scripts/ntp-wait/ntp-wait.html@1.332 +2 -2
+ NTP_4_2_8P2
+
+ scripts/ntp-wait/ntp-wait.man.in@1.312 +3 -3
+ NTP_4_2_8P2
+
+ scripts/ntp-wait/ntp-wait.mdoc.in@1.313 +2 -2
+ NTP_4_2_8P2
+
+ scripts/ntpsweep/invoke-ntpsweep.texi@1.103 +2 -2
+ NTP_4_2_8P2
+
+ scripts/ntpsweep/ntpsweep-opts@1.53 +2 -2
+ NTP_4_2_8P2
+
+ scripts/ntpsweep/ntpsweep.1ntpsweepman@1.91 +3 -3
+ NTP_4_2_8P2
+
+ scripts/ntpsweep/ntpsweep.1ntpsweepmdoc@1.91 +2 -2
+ NTP_4_2_8P2
+
+ scripts/ntpsweep/ntpsweep.html@1.104 +2 -2
+ NTP_4_2_8P2
+
+ scripts/ntpsweep/ntpsweep.man.in@1.91 +3 -3
+ NTP_4_2_8P2
+
+ scripts/ntpsweep/ntpsweep.mdoc.in@1.92 +2 -2
+ NTP_4_2_8P2
+
+ scripts/ntptrace/invoke-ntptrace.texi@1.104 +2 -2
+ NTP_4_2_8P2
+
+ scripts/ntptrace/ntptrace-opts@1.53 +2 -2
+ NTP_4_2_8P2
+
+ scripts/ntptrace/ntptrace.1ntptraceman@1.91 +3 -3
+ NTP_4_2_8P2
+
+ scripts/ntptrace/ntptrace.1ntptracemdoc@1.92 +2 -2
+ NTP_4_2_8P2
+
+ scripts/ntptrace/ntptrace.html@1.105 +2 -2
+ NTP_4_2_8P2
+
+ scripts/ntptrace/ntptrace.man.in@1.91 +3 -3
+ NTP_4_2_8P2
+
+ scripts/ntptrace/ntptrace.mdoc.in@1.93 +2 -2
+ NTP_4_2_8P2
+
+ scripts/plot_summary-opts@1.53 +2 -2
+ NTP_4_2_8P2
+
+ scripts/plot_summary.1plot_summaryman@1.103 +3 -3
+ NTP_4_2_8P2
+
+ scripts/plot_summary.1plot_summarymdoc@1.103 +2 -2
+ NTP_4_2_8P2
+
+ scripts/plot_summary.html@1.106 +2 -2
+ NTP_4_2_8P2
+
+ scripts/plot_summary.man.in@1.103 +3 -3
+ NTP_4_2_8P2
+
+ scripts/plot_summary.mdoc.in@1.103 +2 -2
+ NTP_4_2_8P2
+
+ scripts/summary-opts@1.53 +2 -2
+ NTP_4_2_8P2
+
+ scripts/summary.1summaryman@1.103 +3 -3
+ NTP_4_2_8P2
+
+ scripts/summary.1summarymdoc@1.103 +2 -2
+ NTP_4_2_8P2
+
+ scripts/summary.html@1.106 +2 -2
+ NTP_4_2_8P2
+
+ scripts/summary.man.in@1.103 +3 -3
+ NTP_4_2_8P2
+
+ scripts/summary.mdoc.in@1.103 +2 -2
+ NTP_4_2_8P2
+
+ scripts/update-leap/invoke-update-leap.texi@1.4 +1 -1
+ NTP_4_2_8P2
+
+ scripts/update-leap/update-leap-opts@1.4 +2 -2
+ NTP_4_2_8P2
+
+ scripts/update-leap/update-leap.1update-leapman@1.4 +3 -3
+ NTP_4_2_8P2
+
+ scripts/update-leap/update-leap.1update-leapmdoc@1.4 +2 -2
+ NTP_4_2_8P2
+
+ scripts/update-leap/update-leap.html@1.4 +1 -1
+ NTP_4_2_8P2
+
+ scripts/update-leap/update-leap.man.in@1.4 +3 -3
+ NTP_4_2_8P2
+
+ scripts/update-leap/update-leap.mdoc.in@1.4 +2 -2
+ NTP_4_2_8P2
+
+ sntp/invoke-sntp.texi@1.492 +2 -2
+ NTP_4_2_8P2
+
+ sntp/sntp-opts.c@1.511 +159 -159
+ NTP_4_2_8P2
+
+ sntp/sntp-opts.h@1.509 +3 -3
+ NTP_4_2_8P2
+
+ sntp/sntp.1sntpman@1.327 +3 -3
+ NTP_4_2_8P2
+
+ sntp/sntp.1sntpmdoc@1.327 +2 -2
+ NTP_4_2_8P2
+
+ sntp/sntp.html@1.507 +2 -2
+ NTP_4_2_8P2
+
+ sntp/sntp.man.in@1.327 +3 -3
+ NTP_4_2_8P2
+
+ sntp/sntp.mdoc.in@1.327 +2 -2
+ NTP_4_2_8P2
+
+ util/invoke-ntp-keygen.texi@1.495 +2 -2
+ NTP_4_2_8P2
+
+ util/ntp-keygen-opts.c@1.513 +173 -173
+ NTP_4_2_8P2
+
+ util/ntp-keygen-opts.h@1.511 +3 -3
+ NTP_4_2_8P2
+
+ util/ntp-keygen.1ntp-keygenman@1.323 +3 -3
+ NTP_4_2_8P2
+
+ util/ntp-keygen.1ntp-keygenmdoc@1.323 +2 -2
+ NTP_4_2_8P2
+
+ util/ntp-keygen.html@1.169 +2 -2
+ NTP_4_2_8P2
+
+ util/ntp-keygen.man.in@1.323 +3 -3
+ NTP_4_2_8P2
+
+ util/ntp-keygen.mdoc.in@1.323 +2 -2
+ NTP_4_2_8P2
+
+ChangeSet@1.3319, 2015-04-07 04:05:46-04:00, stenn@deacon.udel.edu
+ ntp-4.2.8p2
+
+ packageinfo.sh@1.508 +2 -2
+ ntp-4.2.8p2
+
+ChangeSet@1.3318, 2015-04-07 07:57:32+00:00, stenn@psp-fb1.ntp.org
+ NEWS update
+
+ NEWS@1.135 +4 -2
+ NEWS update
+
+ChangeSet@1.3314.1.3, 2015-04-03 03:56:38-04:00, stenn@deacon.udel.edu
+ NTP_4_2_8P2_RC3
+ TAG: NTP_4_2_8P2_RC3
+
+ ChangeLog@1.1629.1.3 +1 -0
+ NTP_4_2_8P2_RC3
+
+ ntpd/invoke-ntp.conf.texi@1.181 +1 -1
+ NTP_4_2_8P2_RC3
+
+ ntpd/invoke-ntp.keys.texi@1.177 +1 -1
+ NTP_4_2_8P2_RC3
+
+ ntpd/invoke-ntpd.texi@1.494 +2 -2
+ NTP_4_2_8P2_RC3
+
+ ntpd/ntp.conf.5man@1.215 +3 -3
+ NTP_4_2_8P2_RC3
+
+ ntpd/ntp.conf.5mdoc@1.215 +1 -1
+ NTP_4_2_8P2_RC3
+
+ ntpd/ntp.conf.html@1.172 +1 -1
+ NTP_4_2_8P2_RC3
+
+ ntpd/ntp.conf.man.in@1.215 +3 -3
+ NTP_4_2_8P2_RC3
+
+ ntpd/ntp.conf.mdoc.in@1.215 +1 -1
+ NTP_4_2_8P2_RC3
+
+ ntpd/ntp.keys.5man@1.211 +2 -2
+ NTP_4_2_8P2_RC3
+
+ ntpd/ntp.keys.5mdoc@1.211 +1 -1
+ NTP_4_2_8P2_RC3
+
+ ntpd/ntp.keys.html@1.173 +1 -1
+ NTP_4_2_8P2_RC3
+
+ ntpd/ntp.keys.man.in@1.211 +2 -2
+ NTP_4_2_8P2_RC3
+
+ ntpd/ntp.keys.mdoc.in@1.211 +1 -1
+ NTP_4_2_8P2_RC3
+
+ ntpd/ntpd-opts.c@1.516 +7 -7
+ NTP_4_2_8P2_RC3
+
+ ntpd/ntpd-opts.h@1.515 +3 -3
+ NTP_4_2_8P2_RC3
+
+ ntpd/ntpd.1ntpdman@1.323 +3 -3
+ NTP_4_2_8P2_RC3
+
+ ntpd/ntpd.1ntpdmdoc@1.323 +1 -1
+ NTP_4_2_8P2_RC3
+
+ ntpd/ntpd.html@1.167 +2 -2
+ NTP_4_2_8P2_RC3
+
+ ntpd/ntpd.man.in@1.323 +3 -3
+ NTP_4_2_8P2_RC3
+
+ ntpd/ntpd.mdoc.in@1.323 +1 -1
+ NTP_4_2_8P2_RC3
+
+ ntpdc/invoke-ntpdc.texi@1.491 +2 -2
+ NTP_4_2_8P2_RC3
+
+ ntpdc/ntpdc-opts.c@1.509 +7 -7
+ NTP_4_2_8P2_RC3
+
+ ntpdc/ntpdc-opts.h@1.508 +3 -3
+ NTP_4_2_8P2_RC3
+
+ ntpdc/ntpdc.1ntpdcman@1.322 +3 -3
+ NTP_4_2_8P2_RC3
+
+ ntpdc/ntpdc.1ntpdcmdoc@1.322 +1 -1
+ NTP_4_2_8P2_RC3
+
+ ntpdc/ntpdc.html@1.335 +2 -2
+ NTP_4_2_8P2_RC3
+
+ ntpdc/ntpdc.man.in@1.322 +3 -3
+ NTP_4_2_8P2_RC3
+
+ ntpdc/ntpdc.mdoc.in@1.322 +1 -1
+ NTP_4_2_8P2_RC3
+
+ ntpq/invoke-ntpq.texi@1.497 +2 -2
+ NTP_4_2_8P2_RC3
+
+ ntpq/ntpq-opts.c@1.514 +7 -7
+ NTP_4_2_8P2_RC3
+
+ ntpq/ntpq-opts.h@1.512 +3 -3
+ NTP_4_2_8P2_RC3
+
+ ntpq/ntpq.1ntpqman@1.325 +3 -3
+ NTP_4_2_8P2_RC3
+
+ ntpq/ntpq.1ntpqmdoc@1.325 +1 -1
+ NTP_4_2_8P2_RC3
+
+ ntpq/ntpq.html@1.164 +2 -2
+ NTP_4_2_8P2_RC3
+
+ ntpq/ntpq.man.in@1.325 +3 -3
+ NTP_4_2_8P2_RC3
+
+ ntpq/ntpq.mdoc.in@1.325 +1 -1
+ NTP_4_2_8P2_RC3
+
+ ntpsnmpd/invoke-ntpsnmpd.texi@1.493 +2 -2
+ NTP_4_2_8P2_RC3
+
+ ntpsnmpd/ntpsnmpd-opts.c@1.511 +7 -7
+ NTP_4_2_8P2_RC3
+
+ ntpsnmpd/ntpsnmpd-opts.h@1.510 +3 -3
+ NTP_4_2_8P2_RC3
+
+ ntpsnmpd/ntpsnmpd.1ntpsnmpdman@1.322 +3 -3
+ NTP_4_2_8P2_RC3
+
+ ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc@1.322 +1 -1
+ NTP_4_2_8P2_RC3
+
+ ntpsnmpd/ntpsnmpd.html@1.162 +1 -1
+ NTP_4_2_8P2_RC3
+
+ ntpsnmpd/ntpsnmpd.man.in@1.322 +3 -3
+ NTP_4_2_8P2_RC3
+
+ ntpsnmpd/ntpsnmpd.mdoc.in@1.322 +1 -1
+ NTP_4_2_8P2_RC3
+
+ packageinfo.sh@1.507 +1 -1
+ NTP_4_2_8P2_RC3
+
+ scripts/calc_tickadj/calc_tickadj.1calc_tickadjman@1.83 +3 -3
+ NTP_4_2_8P2_RC3
+
+ scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc@1.84 +1 -1
+ NTP_4_2_8P2_RC3
+
+ scripts/calc_tickadj/calc_tickadj.html@1.85 +1 -1
+ NTP_4_2_8P2_RC3
+
+ scripts/calc_tickadj/calc_tickadj.man.in@1.82 +3 -3
+ NTP_4_2_8P2_RC3
+
+ scripts/calc_tickadj/calc_tickadj.mdoc.in@1.84 +1 -1
+ NTP_4_2_8P2_RC3
+
+ scripts/calc_tickadj/invoke-calc_tickadj.texi@1.87 +1 -1
+ NTP_4_2_8P2_RC3
+
+ scripts/invoke-plot_summary.texi@1.104 +2 -2
+ NTP_4_2_8P2_RC3
+
+ scripts/invoke-summary.texi@1.104 +2 -2
+ NTP_4_2_8P2_RC3
+
+ scripts/ntp-wait/invoke-ntp-wait.texi@1.314 +2 -2
+ NTP_4_2_8P2_RC3
+
+ scripts/ntp-wait/ntp-wait-opts@1.50 +2 -2
+ NTP_4_2_8P2_RC3
+
+ scripts/ntp-wait/ntp-wait.1ntp-waitman@1.311 +3 -3
+ NTP_4_2_8P2_RC3
+
+ scripts/ntp-wait/ntp-wait.1ntp-waitmdoc@1.312 +1 -1
+ NTP_4_2_8P2_RC3
+
+ scripts/ntp-wait/ntp-wait.html@1.331 +2 -2
+ NTP_4_2_8P2_RC3
+
+ scripts/ntp-wait/ntp-wait.man.in@1.311 +3 -3
+ NTP_4_2_8P2_RC3
+
+ scripts/ntp-wait/ntp-wait.mdoc.in@1.312 +1 -1
+ NTP_4_2_8P2_RC3
+
+ scripts/ntpsweep/invoke-ntpsweep.texi@1.102 +2 -2
+ NTP_4_2_8P2_RC3
+
+ scripts/ntpsweep/ntpsweep-opts@1.52 +2 -2
+ NTP_4_2_8P2_RC3
+
+ scripts/ntpsweep/ntpsweep.1ntpsweepman@1.90 +3 -3
+ NTP_4_2_8P2_RC3
+
+ scripts/ntpsweep/ntpsweep.1ntpsweepmdoc@1.90 +1 -1
+ NTP_4_2_8P2_RC3
+
+ scripts/ntpsweep/ntpsweep.html@1.103 +2 -2
+ NTP_4_2_8P2_RC3
+
+ scripts/ntpsweep/ntpsweep.man.in@1.90 +3 -3
+ NTP_4_2_8P2_RC3
+
+ scripts/ntpsweep/ntpsweep.mdoc.in@1.91 +1 -1
+ NTP_4_2_8P2_RC3
+
+ scripts/ntptrace/invoke-ntptrace.texi@1.103 +2 -2
+ NTP_4_2_8P2_RC3
+
+ scripts/ntptrace/ntptrace-opts@1.52 +2 -2
+ NTP_4_2_8P2_RC3
+
+ scripts/ntptrace/ntptrace.1ntptraceman@1.90 +3 -3
+ NTP_4_2_8P2_RC3
+
+ scripts/ntptrace/ntptrace.1ntptracemdoc@1.91 +1 -1
+ NTP_4_2_8P2_RC3
+
+ scripts/ntptrace/ntptrace.html@1.104 +2 -2
+ NTP_4_2_8P2_RC3
+
+ scripts/ntptrace/ntptrace.man.in@1.90 +3 -3
+ NTP_4_2_8P2_RC3
+
+ scripts/ntptrace/ntptrace.mdoc.in@1.92 +1 -1
+ NTP_4_2_8P2_RC3
+
+ scripts/plot_summary-opts@1.52 +2 -2
+ NTP_4_2_8P2_RC3
+
+ scripts/plot_summary.1plot_summaryman@1.102 +3 -3
+ NTP_4_2_8P2_RC3
+
+ scripts/plot_summary.1plot_summarymdoc@1.102 +1 -1
+ NTP_4_2_8P2_RC3
+
+ scripts/plot_summary.html@1.105 +2 -2
+ NTP_4_2_8P2_RC3
+
+ scripts/plot_summary.man.in@1.102 +3 -3
+ NTP_4_2_8P2_RC3
+
+ scripts/plot_summary.mdoc.in@1.102 +1 -1
+ NTP_4_2_8P2_RC3
+
+ scripts/summary-opts@1.52 +2 -2
+ NTP_4_2_8P2_RC3
+
+ scripts/summary.1summaryman@1.102 +3 -3
+ NTP_4_2_8P2_RC3
+
+ scripts/summary.1summarymdoc@1.102 +1 -1
+ NTP_4_2_8P2_RC3
+
+ scripts/summary.html@1.105 +2 -2
+ NTP_4_2_8P2_RC3
+
+ scripts/summary.man.in@1.102 +3 -3
+ NTP_4_2_8P2_RC3
+
+ scripts/summary.mdoc.in@1.102 +1 -1
+ NTP_4_2_8P2_RC3
+
+ scripts/update-leap/invoke-update-leap.texi@1.3 +1 -1
+ NTP_4_2_8P2_RC3
+
+ scripts/update-leap/update-leap-opts@1.3 +2 -2
+ NTP_4_2_8P2_RC3
+
+ scripts/update-leap/update-leap.1update-leapman@1.3 +3 -3
+ NTP_4_2_8P2_RC3
+
+ scripts/update-leap/update-leap.1update-leapmdoc@1.3 +1 -1
+ NTP_4_2_8P2_RC3
+
+ scripts/update-leap/update-leap.html@1.3 +6 -5
+ NTP_4_2_8P2_RC3
+
+ scripts/update-leap/update-leap.man.in@1.3 +3 -3
+ NTP_4_2_8P2_RC3
+
+ scripts/update-leap/update-leap.mdoc.in@1.3 +1 -1
+ NTP_4_2_8P2_RC3
+
+ sntp/invoke-sntp.texi@1.491 +2 -2
+ NTP_4_2_8P2_RC3
+
+ sntp/sntp-opts.c@1.510 +7 -7
+ NTP_4_2_8P2_RC3
+
+ sntp/sntp-opts.h@1.508 +3 -3
+ NTP_4_2_8P2_RC3
+
+ sntp/sntp.1sntpman@1.326 +3 -3
+ NTP_4_2_8P2_RC3
+
+ sntp/sntp.1sntpmdoc@1.326 +1 -1
+ NTP_4_2_8P2_RC3
+
+ sntp/sntp.html@1.506 +2 -2
+ NTP_4_2_8P2_RC3
+
+ sntp/sntp.man.in@1.326 +3 -3
+ NTP_4_2_8P2_RC3
+
+ sntp/sntp.mdoc.in@1.326 +1 -1
+ NTP_4_2_8P2_RC3
+
+ util/invoke-ntp-keygen.texi@1.494 +2 -2
+ NTP_4_2_8P2_RC3
+
+ util/ntp-keygen-opts.c@1.512 +7 -7
+ NTP_4_2_8P2_RC3
+
+ util/ntp-keygen-opts.h@1.510 +3 -3
+ NTP_4_2_8P2_RC3
+
+ util/ntp-keygen.1ntp-keygenman@1.322 +3 -3
+ NTP_4_2_8P2_RC3
+
+ util/ntp-keygen.1ntp-keygenmdoc@1.322 +1 -1
+ NTP_4_2_8P2_RC3
+
+ util/ntp-keygen.html@1.168 +2 -2
+ NTP_4_2_8P2_RC3
+
+ util/ntp-keygen.man.in@1.322 +3 -3
+ NTP_4_2_8P2_RC3
+
+ util/ntp-keygen.mdoc.in@1.322 +1 -1
+ NTP_4_2_8P2_RC3
+
+ChangeSet@1.3314.1.2, 2015-04-03 03:35:54-04:00, stenn@deacon.udel.edu
+ [Bug 2763] Fix for different thresholds for forward and backward steps
+
+ ChangeLog@1.1629.1.2 +3 -0
+ [Bug 2763] Fix for different thresholds for forward and backward steps
+
+ ntpd/ntp_loopfilter.c@1.183 +2 -2
+ [Bug 2763] Fix for different thresholds for forward and backward steps
+
+ChangeSet@1.3314.1.1, 2015-04-03 01:16:34-04:00, stenn@deacon.udel.edu
+ NTP_4_2_8P2_RC2
+ TAG: NTP_4_2_8P2_RC2
+
+ ChangeLog@1.1629.1.1 +1 -0
+ NTP_4_2_8P2_RC2
+
+ ntpd/invoke-ntp.conf.texi@1.180 +1 -1
+ NTP_4_2_8P2_RC2
+
+ ntpd/invoke-ntp.keys.texi@1.176 +1 -1
+ NTP_4_2_8P2_RC2
+
+ ntpd/invoke-ntpd.texi@1.493 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpd/ntp.conf.5man@1.214 +3 -3
+ NTP_4_2_8P2_RC2
+
+ ntpd/ntp.conf.5mdoc@1.214 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpd/ntp.conf.html@1.171 +1 -1
+ NTP_4_2_8P2_RC2
+
+ ntpd/ntp.conf.man.in@1.214 +3 -3
+ NTP_4_2_8P2_RC2
+
+ ntpd/ntp.conf.mdoc.in@1.214 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpd/ntp.keys.5man@1.210 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpd/ntp.keys.5mdoc@1.210 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpd/ntp.keys.html@1.172 +1 -1
+ NTP_4_2_8P2_RC2
+
+ ntpd/ntp.keys.man.in@1.210 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpd/ntp.keys.mdoc.in@1.210 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpd/ntpd-opts.c@1.515 +7 -7
+ NTP_4_2_8P2_RC2
+
+ ntpd/ntpd-opts.h@1.514 +3 -3
+ NTP_4_2_8P2_RC2
+
+ ntpd/ntpd.1ntpdman@1.322 +3 -3
+ NTP_4_2_8P2_RC2
+
+ ntpd/ntpd.1ntpdmdoc@1.322 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpd/ntpd.html@1.166 +50 -26
+ NTP_4_2_8P2_RC2
+
+ ntpd/ntpd.man.in@1.322 +3 -3
+ NTP_4_2_8P2_RC2
+
+ ntpd/ntpd.mdoc.in@1.322 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpdc/invoke-ntpdc.texi@1.490 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpdc/ntpdc-opts.c@1.508 +7 -7
+ NTP_4_2_8P2_RC2
+
+ ntpdc/ntpdc-opts.h@1.507 +3 -3
+ NTP_4_2_8P2_RC2
+
+ ntpdc/ntpdc.1ntpdcman@1.321 +3 -3
+ NTP_4_2_8P2_RC2
+
+ ntpdc/ntpdc.1ntpdcmdoc@1.321 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpdc/ntpdc.html@1.334 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpdc/ntpdc.man.in@1.321 +3 -3
+ NTP_4_2_8P2_RC2
+
+ ntpdc/ntpdc.mdoc.in@1.321 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpq/invoke-ntpq.texi@1.496 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpq/ntpq-opts.c@1.513 +7 -7
+ NTP_4_2_8P2_RC2
+
+ ntpq/ntpq-opts.h@1.511 +3 -3
+ NTP_4_2_8P2_RC2
+
+ ntpq/ntpq.1ntpqman@1.324 +3 -3
+ NTP_4_2_8P2_RC2
+
+ ntpq/ntpq.1ntpqmdoc@1.324 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpq/ntpq.html@1.163 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpq/ntpq.man.in@1.324 +3 -3
+ NTP_4_2_8P2_RC2
+
+ ntpq/ntpq.mdoc.in@1.324 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpsnmpd/invoke-ntpsnmpd.texi@1.492 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpsnmpd/ntpsnmpd-opts.c@1.510 +7 -7
+ NTP_4_2_8P2_RC2
+
+ ntpsnmpd/ntpsnmpd-opts.h@1.509 +3 -3
+ NTP_4_2_8P2_RC2
+
+ ntpsnmpd/ntpsnmpd.1ntpsnmpdman@1.321 +3 -3
+ NTP_4_2_8P2_RC2
+
+ ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc@1.321 +2 -2
+ NTP_4_2_8P2_RC2
+
+ ntpsnmpd/ntpsnmpd.html@1.161 +1 -1
+ NTP_4_2_8P2_RC2
+
+ ntpsnmpd/ntpsnmpd.man.in@1.321 +3 -3
+ NTP_4_2_8P2_RC2
+
+ ntpsnmpd/ntpsnmpd.mdoc.in@1.321 +2 -2
+ NTP_4_2_8P2_RC2
+
+ packageinfo.sh@1.506 +1 -1
+ NTP_4_2_8P2_RC2
+
+ scripts/calc_tickadj/calc_tickadj.1calc_tickadjman@1.82 +3 -3
+ NTP_4_2_8P2_RC2
+
+ scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc@1.83 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/calc_tickadj/calc_tickadj.html@1.84 +1 -1
+ NTP_4_2_8P2_RC2
+
+ scripts/calc_tickadj/calc_tickadj.man.in@1.81 +3 -3
+ NTP_4_2_8P2_RC2
+
+ scripts/calc_tickadj/calc_tickadj.mdoc.in@1.83 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/calc_tickadj/invoke-calc_tickadj.texi@1.86 +1 -1
+ NTP_4_2_8P2_RC2
+
+ scripts/invoke-plot_summary.texi@1.103 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/invoke-summary.texi@1.103 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/ntp-wait/invoke-ntp-wait.texi@1.313 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/ntp-wait/ntp-wait-opts@1.49 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/ntp-wait/ntp-wait.1ntp-waitman@1.310 +3 -3
+ NTP_4_2_8P2_RC2
+
+ scripts/ntp-wait/ntp-wait.1ntp-waitmdoc@1.311 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/ntp-wait/ntp-wait.html@1.330 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/ntp-wait/ntp-wait.man.in@1.310 +3 -3
+ NTP_4_2_8P2_RC2
+
+ scripts/ntp-wait/ntp-wait.mdoc.in@1.311 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/ntpsweep/invoke-ntpsweep.texi@1.101 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/ntpsweep/ntpsweep-opts@1.51 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/ntpsweep/ntpsweep.1ntpsweepman@1.89 +3 -3
+ NTP_4_2_8P2_RC2
+
+ scripts/ntpsweep/ntpsweep.1ntpsweepmdoc@1.89 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/ntpsweep/ntpsweep.html@1.102 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/ntpsweep/ntpsweep.man.in@1.89 +3 -3
+ NTP_4_2_8P2_RC2
+
+ scripts/ntpsweep/ntpsweep.mdoc.in@1.90 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/ntptrace/invoke-ntptrace.texi@1.102 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/ntptrace/ntptrace-opts@1.51 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/ntptrace/ntptrace.1ntptraceman@1.89 +3 -3
+ NTP_4_2_8P2_RC2
+
+ scripts/ntptrace/ntptrace.1ntptracemdoc@1.90 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/ntptrace/ntptrace.html@1.103 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/ntptrace/ntptrace.man.in@1.89 +3 -3
+ NTP_4_2_8P2_RC2
+
+ scripts/ntptrace/ntptrace.mdoc.in@1.91 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/plot_summary-opts@1.51 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/plot_summary.1plot_summaryman@1.101 +3 -3
+ NTP_4_2_8P2_RC2
+
+ scripts/plot_summary.1plot_summarymdoc@1.101 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/plot_summary.html@1.104 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/plot_summary.man.in@1.101 +3 -3
+ NTP_4_2_8P2_RC2
+
+ scripts/plot_summary.mdoc.in@1.101 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/summary-opts@1.51 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/summary.1summaryman@1.101 +3 -3
+ NTP_4_2_8P2_RC2
+
+ scripts/summary.1summarymdoc@1.101 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/summary.html@1.104 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/summary.man.in@1.101 +3 -3
+ NTP_4_2_8P2_RC2
+
+ scripts/summary.mdoc.in@1.101 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/update-leap/invoke-update-leap.texi@1.2 +6 -5
+ NTP_4_2_8P2_RC2
+
+ scripts/update-leap/update-leap-opts@1.2 +2 -2
+ NTP_4_2_8P2_RC2
+
+ scripts/update-leap/update-leap.1update-leapman@1.2 +7 -6
+ NTP_4_2_8P2_RC2
+
+ scripts/update-leap/update-leap.1update-leapmdoc@1.2 +6 -5
+ NTP_4_2_8P2_RC2
+
+ scripts/update-leap/update-leap.html@1.2 +48 -72
+ NTP_4_2_8P2_RC2
+
+ scripts/update-leap/update-leap.man.in@1.2 +7 -6
+ NTP_4_2_8P2_RC2
+
+ scripts/update-leap/update-leap.mdoc.in@1.2 +6 -5
+ NTP_4_2_8P2_RC2
+
+ sntp/invoke-sntp.texi@1.490 +2 -2
+ NTP_4_2_8P2_RC2
+
+ sntp/sntp-opts.c@1.509 +7 -7
+ NTP_4_2_8P2_RC2
+
+ sntp/sntp-opts.h@1.507 +3 -3
+ NTP_4_2_8P2_RC2
+
+ sntp/sntp.1sntpman@1.325 +3 -3
+ NTP_4_2_8P2_RC2
+
+ sntp/sntp.1sntpmdoc@1.325 +2 -2
+ NTP_4_2_8P2_RC2
+
+ sntp/sntp.html@1.505 +111 -135
+ NTP_4_2_8P2_RC2
+
+ sntp/sntp.man.in@1.325 +3 -3
+ NTP_4_2_8P2_RC2
+
+ sntp/sntp.mdoc.in@1.325 +2 -2
+ NTP_4_2_8P2_RC2
+
+ util/invoke-ntp-keygen.texi@1.493 +2 -2
+ NTP_4_2_8P2_RC2
+
+ util/ntp-keygen-opts.c@1.511 +7 -7
+ NTP_4_2_8P2_RC2
+
+ util/ntp-keygen-opts.h@1.509 +3 -3
+ NTP_4_2_8P2_RC2
+
+ util/ntp-keygen.1ntp-keygenman@1.321 +3 -3
+ NTP_4_2_8P2_RC2
+
+ util/ntp-keygen.1ntp-keygenmdoc@1.321 +2 -2
+ NTP_4_2_8P2_RC2
+
+ util/ntp-keygen.html@1.167 +2 -2
+ NTP_4_2_8P2_RC2
+
+ util/ntp-keygen.man.in@1.321 +3 -3
+ NTP_4_2_8P2_RC2
+
+ util/ntp-keygen.mdoc.in@1.321 +2 -2
+ NTP_4_2_8P2_RC2
+
+ChangeSet@1.3314, 2015-04-03 02:36:18+00:00, stenn@psp-fb1.ntp.org
+ merge cleanup
+
+ NEWS@1.133 +6 -5
+ merge cleanup
+
+ChangeSet@1.3313, 2015-04-03 02:31:18+00:00, stenn@psp-fb1.ntp.org
+ merge cleanup
+
+ ChangeLog@1.1629 +3 -3
+ merge cleanup
+
+ChangeSet@1.3308.2.11, 2015-04-02 21:42:37+00:00, stenn@psp-deb1.ntp.org
+ [Bug 2592] FLAG_TSTAMP_PPS cleanup for refclock_parse.c
+
+ ChangeLog@1.1625.2.9 +1 -0
+ [Bug 2592] FLAG_TSTAMP_PPS cleanup for refclock_parse.c
+
+ChangeSet@1.3308.2.10, 2015-04-02 20:17:55+00:00, stenn@psp-deb1.ntp.org
+ merge cleanup
+
+ ChangeLog@1.1625.2.8 +1 -3
+ merge cleanup
+
+ChangeSet@1.3308.2.9, 2015-04-02 21:41:22+02:00, jnperlin@nemesis.localnet
+ [Bug 2795] Cannot build without OpenSLL (on Win32).
+ fixed minor warning
+
+ ChangeLog@1.1625.2.7 +3 -0
+ [Bug 2795] Cannot build without OpenSLL (on Win32).
+ fixed minor warning
+
+ include/ntp_md5.h@1.10 +1 -1
+ [Bug 2795] Cannot build without OpenSLL (on Win32).
+ OpenSSL declares EVP_md5() as function without arguments; surrogate should do the same.
+
+ChangeSet@1.3308.6.2, 2015-04-02 07:45:04+00:00, stenn@psp-deb1.ntp.org
+ cleanup
+
+ ChangeLog@1.1625.6.3 +0 -2
+ cleanup
+
+ ChangeLog@1.1625.6.2 +6 -0
+
+ ntpd/invoke-ntpd.texi@1.492 +20 -3
+ [Bug 2788] New -G flag (force step once) cleanup.
+
+ ntpd/ntp_loopfilter.c@1.182 +17 -6
+ [Bug 2794] Clean up kernel clock status reports.
+ Trailing whitespace cleanup.
+
+ ntpd/ntpd-opts.c@1.514 +249 -249
+ Autogenerated file.
+
+ ntpd/ntpd-opts.h@1.513 +3 -3
+ Autogenerated file.
+
+ ntpd/ntpd.1ntpdman@1.321 +19 -5
+ Autogenerated file.
+
+ ntpd/ntpd.1ntpdmdoc@1.321 +17 -4
+ Autogenerated file.
+
+ ntpd/ntpd.man.in@1.321 +19 -5
+ Autogenerated file.
+
+ ntpd/ntpd.mdoc.in@1.321 +17 -4
+ Autogenerated file.
+
+ ntpd/ntpdbase-opts.def@1.29 +9 -6
+ [Bug 2788] New flag -G (force_step_once) - documentation cleanup.
+
+ChangeSet@1.3308.2.7, 2015-04-02 07:34:40+00:00, stenn@psp-deb1.ntp.org
+ Simple cleanup to html/build.html
+
+ ChangeLog@1.1625.2.5 +1 -0
+ Simple cleanup to html/build.html
+
+ html/build.html@1.28 +2 -2
+ Simple cleanup to html/build.html
+
+ChangeSet@1.3308.2.6, 2015-04-02 03:15:42+00:00, stenn@psp-fb1.ntp.org
+ typos
+
+ ChangeLog@1.1625.2.4 +4 -4
+ typos
+
+ChangeSet@1.3308.5.2, 2015-04-01 11:08:14+00:00, stenn@psp-deb1.ntp.org
+ [Bug 2798] sntp should decode and display the leap indicator
+
+ html/sntp.html@1.12 +3 -3
+ [Bug 2798] sntp should decode and display the leap indicator
+
+ sntp/invoke-sntp.texi@1.489 +4 -3
+ [Bug 2798] sntp should decode and display the leap indicator
+
+ sntp/sntp-opts.c@1.508 +1 -1
+ [Bug 2798] sntp should decode and display the leap indicator
+
+ sntp/sntp-opts.def@1.47 +2 -1
+ [Bug 2798] sntp should decode and display the leap indicator
+
+ sntp/sntp-opts.h@1.506 +1 -1
+ [Bug 2798] sntp should decode and display the leap indicator
+
+ sntp/sntp.1sntpman@1.324 +5 -4
+ [Bug 2798] sntp should decode and display the leap indicator
+
+ sntp/sntp.1sntpmdoc@1.324 +4 -3
+ [Bug 2798] sntp should decode and display the leap indicator
+
+ sntp/sntp.html@1.504 +136 -111
+ [Bug 2798] sntp should decode and display the leap indicator
+
+ sntp/sntp.man.in@1.324 +5 -4
+ [Bug 2798] sntp should decode and display the leap indicator
+
+ sntp/sntp.mdoc.in@1.324 +4 -3
+ [Bug 2798] sntp should decode and display the leap indicator
+
+ChangeSet@1.3308.5.1, 2015-04-01 10:44:24+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2798] sntp should decode and display the leap indicator
+
+ ChangeLog@1.1625.5.1 +3 -0
+ [Bug 2798] sntp should decode and display the leap indicator
+
+ sntp/main.c@1.95 +21 -1
+ [Bug 2798] sntp should decode and display the leap indicator
+
+ChangeSet@1.3308.4.1, 2015-03-30 20:14:46+02:00, jnperlin@hydra.(none)
+ [Bug 2797] ntp-keygen trapped in endless loop for MD5 keys on big-endian machines
+
+ ChangeLog@1.1625.4.1 +3 -0
+ [Bug 2797] ntp-keygen trapped in endless loop for MD5 keys on big-endian machines
+
+ util/ntp-keygen.c@1.104 +4 -4
+ [Bug 2797] ntp-keygen trapped in endless loop for MD5 keys on big-endian machines
+
+ChangeSet@1.3308.3.1, 2015-03-30 19:39:17+02:00, jnperlin@nemesis.localnet
+ [Bug 2796] ntp-keygen crashes in 'getclock()' on Win32
+
+ ChangeLog@1.1625.3.1 +2 -0
+ [Bug 2796] ntp-keygen crashes in 'getclock()' on Win32
+
+ ports/winnt/libntp/getclock.c@1.5 +2 -0
+ [Bug 2796] ntp-keygen crashes in 'getclock()' on Win32
+ make sure 'init_win_precise_time()' gets called
+
+ChangeSet@1.3308.2.4, 2015-03-30 19:10:12+02:00, jnperlin@nemesis.localnet
+ [Bug 2795] Cannot build without OpenSLL (on Win32)
+ Provided a Win32 specific wrapper around libevent/arc4random.c
+
+ ChangeLog@1.1625.2.2 +3 -0
+ [Bug 2795] Cannot build without OpenSLL (on Win32)
+ Provided a Win32 specific wrapper around libevent/arc4random.c
+
+ ports/winnt/libntp/arc4wrap.c@1.1 +84 -0
+ [Bug 2795] Cannot build without OpenSLL (on Win32)
+ Provided a Win32 specific wrapper around libevent/arc4random.c
+
+ ports/winnt/libntp/arc4wrap.c@1.0 +0 -0
+
+ ports/winnt/vs2005/libntp.vcproj@1.24 +4 -0
+ [Bug 2795] Cannot build without OpenSLL (on Win32)
+ Provided a Win32 specific wrapper around libevent/arc4random.c
+
+ ports/winnt/vs2008/libntp/libntp.vcproj@1.52 +6 -2
+ [Bug 2795] Cannot build without OpenSLL (on Win32)
+ Provided a Win32 specific wrapper around libevent/arc4random.c
+
+ ports/winnt/vs2013/libntp/libntp.vcxproj@1.6 +1 -0
+ [Bug 2795] Cannot build without OpenSLL (on Win32)
+ Provided a Win32 specific wrapper around libevent/arc4random.c
+
+ ports/winnt/vs2013/libntp/libntp.vcxproj.filters@1.4 +6 -0
+ [Bug 2795] Cannot build without OpenSLL (on Win32)
+ Provided a Win32 specific wrapper around libevent/arc4random.c
+
+ChangeSet@1.3305.3.8, 2015-03-30 15:55:43+02:00, martin@pc-martin.(none)
+ [Bug 2794] Don't let reports on normal kernel status changes look like errors.
+
+ ChangeLog@1.1622.3.8 +2 -0
+ [Bug 2794] Don't let reports on normal kernel status changes look like errors.
+
+ ntpd/ntp_loopfilter.c@1.181 +30 -19
+ [Bug 2794] Don't let reports on normal kernel status changes look like errors.
+
+ChangeSet@1.3305.3.7, 2015-03-30 11:23:48+02:00, martin@pc-martin.(none)
+ [Bug 2788] New flag -G (force_step_once)
+
+ ChangeLog@1.1622.3.7 +1 -0
+ [Bug 2788] New flag -G (force_step_once)
+
+ include/ntpd.h@1.185.1.1 +4 -3
+ [Bug 2788] Support new flag -G (force_step_once)
+ Removed trailing whitespace.
+
+ ntpd/cmd_args.c@1.62 +6 -3
+ [Bug 2788] New flag -G (force_step_once)
+ Removed trailing whitespace.
+
+ ntpd/ntp_loopfilter.c@1.180 +21 -15
+ [Bug 2788] New flag -G (force_step_once)
+ Removed trailing whitespace.
+
+ ntpd/ntpd-opts.c@1.511.1.1 +255 -225
+ [Bug 2788] New flag -G (force_step_once)
+
+ ntpd/ntpd-opts.h@1.510.1.1 +36 -29
+ [Bug 2788] New flag -G (force_step_once)
+
+ ntpd/ntpdbase-opts.def@1.28 +17 -2
+ [Bug 2788] New flag -G (force_step_once)
+ Removed trailing whitespace.
+
+ChangeSet@1.3308.1.3, 2015-03-30 09:11:33+00:00, stenn@psp-fb1.ntp.org
+ Start the RC cycle for ntp-4.2.8p2
+
+ NEWS@1.130.1.2 +82 -1
+ Start the RC cycle for ntp-4.2.8p2
+
+ChangeSet@1.3308.2.3, 2015-03-30 04:48:27-04:00, stenn@deacon.udel.edu
+ NTP_4_2_8P2_RC1
+ TAG: NTP_4_2_8P2_RC1
+
+ ChangeLog@1.1625.2.1 +1 -0
+ NTP_4_2_8P2_RC1
+
+ ntpd/invoke-ntp.conf.texi@1.179 +1 -1
+ NTP_4_2_8P2_RC1
+
+ ntpd/invoke-ntp.keys.texi@1.175 +1 -1
+ NTP_4_2_8P2_RC1
+
+ ntpd/invoke-ntpd.texi@1.491 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpd/ntp.conf.5man@1.213 +3 -3
+ NTP_4_2_8P2_RC1
+
+ ntpd/ntp.conf.5mdoc@1.213 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpd/ntp.conf.html@1.170 +13 -2
+ NTP_4_2_8P2_RC1
+
+ ntpd/ntp.conf.man.in@1.213 +3 -3
+ NTP_4_2_8P2_RC1
+
+ ntpd/ntp.conf.mdoc.in@1.213 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpd/ntp.keys.5man@1.209 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpd/ntp.keys.5mdoc@1.209 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpd/ntp.keys.html@1.171 +1 -1
+ NTP_4_2_8P2_RC1
+
+ ntpd/ntp.keys.man.in@1.209 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpd/ntp.keys.mdoc.in@1.209 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpd/ntpd-opts.c@1.512 +239 -239
+ NTP_4_2_8P2_RC1
+
+ ntpd/ntpd-opts.h@1.511 +3 -3
+ NTP_4_2_8P2_RC1
+
+ ntpd/ntpd.1ntpdman@1.320 +3 -3
+ NTP_4_2_8P2_RC1
+
+ ntpd/ntpd.1ntpdmdoc@1.320 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpd/ntpd.html@1.165 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpd/ntpd.man.in@1.320 +3 -3
+ NTP_4_2_8P2_RC1
+
+ ntpd/ntpd.mdoc.in@1.320 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpdc/invoke-ntpdc.texi@1.489 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpdc/ntpdc-opts.c@1.507 +107 -107
+ NTP_4_2_8P2_RC1
+
+ ntpdc/ntpdc-opts.h@1.506 +3 -3
+ NTP_4_2_8P2_RC1
+
+ ntpdc/ntpdc.1ntpdcman@1.320 +3 -3
+ NTP_4_2_8P2_RC1
+
+ ntpdc/ntpdc.1ntpdcmdoc@1.320 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpdc/ntpdc.html@1.333 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpdc/ntpdc.man.in@1.320 +3 -3
+ NTP_4_2_8P2_RC1
+
+ ntpdc/ntpdc.mdoc.in@1.320 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpq/invoke-ntpq.texi@1.495 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpq/ntpq-opts.c@1.512 +106 -106
+ NTP_4_2_8P2_RC1
+
+ ntpq/ntpq-opts.h@1.510 +3 -3
+ NTP_4_2_8P2_RC1
+
+ ntpq/ntpq.1ntpqman@1.323 +3 -3
+ NTP_4_2_8P2_RC1
+
+ ntpq/ntpq.1ntpqmdoc@1.323 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpq/ntpq.html@1.162 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpq/ntpq.man.in@1.323 +3 -3
+ NTP_4_2_8P2_RC1
+
+ ntpq/ntpq.mdoc.in@1.323 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpsnmpd/invoke-ntpsnmpd.texi@1.491 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpsnmpd/ntpsnmpd-opts.c@1.509 +68 -68
+ NTP_4_2_8P2_RC1
+
+ ntpsnmpd/ntpsnmpd-opts.h@1.508 +3 -3
+ NTP_4_2_8P2_RC1
+
+ ntpsnmpd/ntpsnmpd.1ntpsnmpdman@1.320 +3 -3
+ NTP_4_2_8P2_RC1
+
+ ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc@1.320 +2 -2
+ NTP_4_2_8P2_RC1
+
+ ntpsnmpd/ntpsnmpd.html@1.160 +1 -1
+ NTP_4_2_8P2_RC1
+
+ ntpsnmpd/ntpsnmpd.man.in@1.320 +3 -3
+ NTP_4_2_8P2_RC1
+
+ ntpsnmpd/ntpsnmpd.mdoc.in@1.320 +2 -2
+ NTP_4_2_8P2_RC1
+
+ packageinfo.sh@1.505 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/calc_tickadj/calc_tickadj.1calc_tickadjman@1.81 +3 -3
+ NTP_4_2_8P2_RC1
+
+ scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc@1.82 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/calc_tickadj/calc_tickadj.html@1.83 +1 -1
+ NTP_4_2_8P2_RC1
+
+ scripts/calc_tickadj/calc_tickadj.man.in@1.80 +3 -3
+ NTP_4_2_8P2_RC1
+
+ scripts/calc_tickadj/calc_tickadj.mdoc.in@1.82 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/calc_tickadj/invoke-calc_tickadj.texi@1.85 +1 -1
+ NTP_4_2_8P2_RC1
+
+ scripts/invoke-plot_summary.texi@1.102 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/invoke-summary.texi@1.102 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/ntp-wait/invoke-ntp-wait.texi@1.312 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/ntp-wait/ntp-wait-opts@1.48 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/ntp-wait/ntp-wait.1ntp-waitman@1.309 +3 -3
+ NTP_4_2_8P2_RC1
+
+ scripts/ntp-wait/ntp-wait.1ntp-waitmdoc@1.310 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/ntp-wait/ntp-wait.html@1.329 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/ntp-wait/ntp-wait.man.in@1.309 +3 -3
+ NTP_4_2_8P2_RC1
+
+ scripts/ntp-wait/ntp-wait.mdoc.in@1.310 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/ntpsweep/invoke-ntpsweep.texi@1.100 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/ntpsweep/ntpsweep-opts@1.50 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/ntpsweep/ntpsweep.1ntpsweepman@1.88 +3 -3
+ NTP_4_2_8P2_RC1
+
+ scripts/ntpsweep/ntpsweep.1ntpsweepmdoc@1.88 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/ntpsweep/ntpsweep.html@1.101 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/ntpsweep/ntpsweep.man.in@1.88 +3 -3
+ NTP_4_2_8P2_RC1
+
+ scripts/ntpsweep/ntpsweep.mdoc.in@1.89 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/ntptrace/invoke-ntptrace.texi@1.101 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/ntptrace/ntptrace-opts@1.50 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/ntptrace/ntptrace.1ntptraceman@1.88 +3 -3
+ NTP_4_2_8P2_RC1
+
+ scripts/ntptrace/ntptrace.1ntptracemdoc@1.89 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/ntptrace/ntptrace.html@1.102 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/ntptrace/ntptrace.man.in@1.88 +3 -3
+ NTP_4_2_8P2_RC1
+
+ scripts/ntptrace/ntptrace.mdoc.in@1.90 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/plot_summary-opts@1.50 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/plot_summary.1plot_summaryman@1.100 +3 -3
+ NTP_4_2_8P2_RC1
+
+ scripts/plot_summary.1plot_summarymdoc@1.100 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/plot_summary.html@1.103 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/plot_summary.man.in@1.100 +3 -3
+ NTP_4_2_8P2_RC1
+
+ scripts/plot_summary.mdoc.in@1.100 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/summary-opts@1.50 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/summary.1summaryman@1.100 +3 -3
+ NTP_4_2_8P2_RC1
+
+ scripts/summary.1summarymdoc@1.100 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/summary.html@1.103 +2 -2
+ NTP_4_2_8P2_RC1
+
+ scripts/summary.man.in@1.100 +3 -3
+ NTP_4_2_8P2_RC1
+
+ scripts/summary.mdoc.in@1.100 +2 -2
+ NTP_4_2_8P2_RC1
+
+ sntp/invoke-sntp.texi@1.488 +2 -2
+ NTP_4_2_8P2_RC1
+
+ sntp/sntp-opts.c@1.507 +159 -159
+ NTP_4_2_8P2_RC1
+
+ sntp/sntp-opts.h@1.505 +3 -3
+ NTP_4_2_8P2_RC1
+
+ sntp/sntp.1sntpman@1.323 +3 -3
+ NTP_4_2_8P2_RC1
+
+ sntp/sntp.1sntpmdoc@1.323 +2 -2
+ NTP_4_2_8P2_RC1
+
+ sntp/sntp.html@1.503 +2 -2
+ NTP_4_2_8P2_RC1
+
+ sntp/sntp.man.in@1.323 +3 -3
+ NTP_4_2_8P2_RC1
+
+ sntp/sntp.mdoc.in@1.323 +2 -2
+ NTP_4_2_8P2_RC1
+
+ util/invoke-ntp-keygen.texi@1.492 +2 -2
+ NTP_4_2_8P2_RC1
+
+ util/ntp-keygen-opts.c@1.510 +173 -173
+ NTP_4_2_8P2_RC1
+
+ util/ntp-keygen-opts.h@1.508 +3 -3
+ NTP_4_2_8P2_RC1
+
+ util/ntp-keygen.1ntp-keygenman@1.320 +3 -3
+ NTP_4_2_8P2_RC1
+
+ util/ntp-keygen.1ntp-keygenmdoc@1.320 +2 -2
+ NTP_4_2_8P2_RC1
+
+ util/ntp-keygen.html@1.166 +2 -2
+ NTP_4_2_8P2_RC1
+
+ util/ntp-keygen.man.in@1.320 +3 -3
+ NTP_4_2_8P2_RC1
+
+ util/ntp-keygen.mdoc.in@1.320 +2 -2
+ NTP_4_2_8P2_RC1
+
+ChangeSet@1.3308.2.2, 2015-03-30 04:25:58-04:00, stenn@deacon.udel.edu
+ Begin 4.2.8p2-RC1
+
+ packageinfo.sh@1.504 +1 -1
+ Begin 4.2.8p2-RC1
+
+ChangeSet@1.3308.2.1, 2015-03-30 08:18:35+00:00, stenn@psp-fb1.ntp.org
+ Start the RC cycle for ntp-4.2.8p2
+
+ NEWS@1.130.1.1 +49 -0
+ Start the RC cycle for ntp-4.2.8p2
+
+ChangeSet@1.3311, 2015-03-29 05:05:41+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2769] cleannup for update-leap
+
+ ChangeLog@1.1627 +1 -0
+ [Bug 2769] cleannup for update-leap
+
+ChangeSet@1.3310, 2015-03-29 04:10:31+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2769] cleannup for update-leap
+
+ NEWS@1.131 +8 -0
+ [Bug 2769] cleannup for update-leap
+
+ scripts/update-leap/Makefile.am@1.3 +1 -0
+ [Bug 2769] cleannup for update-leap
+
+ scripts/update-leap/update-leap-opts.def@1.2 +4 -3
+ [Bug 2769] cleannup for update-leap
+
+ChangeSet@1.3308, 2015-03-29 01:49:10+00:00, stenn@psp-deb1.ntp.org
+ [Bug 2346] "graceful termination" signals do not do peer cleanup
+
+ ChangeLog@1.1625 +1 -0
+ [Bug 2346] "graceful termination" signals do not do peer cleanup
+
+ include/ntpd.h@1.186 +1 -0
+ [Bug 2346] "graceful termination" signals do not do peer cleanup
+
+ ntpd/ntp_peer.c@1.154 +20 -0
+ [Bug 2346] "graceful termination" signals do not do peer cleanup
+
+ ntpd/ntpd.c@1.159 +1 -0
+ [Bug 2346] "graceful termination" signals do not do peer cleanup
+
+ChangeSet@1.3305.3.6, 2015-03-25 17:32:25+01:00, martin@pc-martin.(none)
+ [Bug 2592] Account for PPS sources which can provide an accurate absolute time stamp, and status information.
+
+ ChangeLog@1.1622.3.6 +2 -0
+ [Bug 2592] Account for PPS sources which can provide an accurate absolute time stamp, and status information.
+
+ include/ntp.h@1.213 +2 -1
+ New flag FLAG_TSTAMP_PPS.
+
+ ntpd/ntp_proto.c@1.353.1.2 +2 -1
+ [Bug 2592] Account for PPS sources which can provide an accurate absolute time stamp, and status information.
+
+ ntpd/refclock_parse.c@1.78 +2 -2
+ [Bug 2592] Parse driver can return absolute timestamp with PPS, and status information.
+
+ChangeSet@1.3305.3.5, 2015-03-25 17:24:59+01:00, martin@pc-martin.(none)
+ Fixed indention and removed trailing whitespace.
+
+ ChangeLog@1.1622.3.5 +1 -0
+ Fixed indention and removed trailing whitespace.
+
+ include/ntp.h@1.212 +4 -4
+ Fixed indention.
+
+ include/parse_conf.h@1.7 +6 -6
+ Fixed indention.
+
+ ntpd/ntp_proto.c@1.353.1.1 +27 -27
+ Removed trailing whitespace.
+
+ ntpd/refclock_parse.c@1.77 +16 -16
+ Fixed indention.
+
+ChangeSet@1.3305.3.4, 2015-03-22 07:59:12+00:00, stenn@psp-fb1.ntp.org
+ merge cleanup
+
+ ChangeLog@1.1622.3.4 +0 -1
+ merge cleanup
+
+ChangeSet@1.3305.5.3, 2015-03-22 07:24:07+00:00, stenn@psp-fb1.ntp.org
+ Bug 2791 -> Bug 2789
+
+ ChangeLog@1.1622.5.3 +1 -1
+ Bug 2791 -> Bug 2789
+
+ChangeSet@1.3305.5.2, 2015-03-22 06:59:06+00:00, stenn@psp-fb1.ntp.org
+ Merge cleanup
+
+ ChangeLog@1.1622.5.2 +22 -22
+ Merge cleanup
+
+ChangeSet@1.3305.4.2, 2015-03-22 03:48:52+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2769] New script: update-leap
+
+ .point-changed-filelist@1.26 +7 -0
+ [Bug 2769] New script: update-leap
+
+ scripts/update-leap/Makefile.am@1.2 +2 -1
+ [Bug 2769] New script: update-leap
+
+ChangeSet@1.3305.4.1, 2015-03-22 03:01:33+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2769] New script: update-leap
+
+ BitKeeper/etc/ignore@1.86 +1 -0
+ added Makefile.in
+
+ ChangeLog@1.1622.4.1 +1 -0
+ [Bug 2769] New script: update-leap
+
+ configure.ac@1.585 +8 -7
+ [Bug 2769] New script: update-leap
+
+ scripts/Makefile.am@1.40 +1 -0
+ [Bug 2769] New script: update-leap
+
+ scripts/update-leap/Makefile.am@1.1 +95 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2769/scripts/update-leap/Makefile.am
+
+ scripts/update-leap/Makefile.am@1.0 +0 -0
+
+ scripts/update-leap/invoke-update-leap.menu@1.1 +1 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2769/scripts/update-leap/invoke-update-leap.menu
+
+ scripts/update-leap/invoke-update-leap.menu@1.0 +0 -0
+
+ scripts/update-leap/invoke-update-leap.texi@1.1 +169 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2769/scripts/update-leap/invoke-update-leap.texi
+
+ scripts/update-leap/invoke-update-leap.texi@1.0 +0 -0
+
+ scripts/update-leap/update-leap@1.1 +434 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2769/scripts/update-leap/update-leap
+
+ scripts/update-leap/update-leap@1.0 +0 -0
+
+ scripts/update-leap/update-leap-opts@1.1 +72 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2769/scripts/update-leap/update-leap-opts
+
+ scripts/update-leap/update-leap-opts@1.0 +0 -0
+
+ scripts/update-leap/update-leap-opts.def@1.1 +162 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2769/scripts/update-leap/update-leap-opts.def
+
+ scripts/update-leap/update-leap-opts.def@1.0 +0 -0
+
+ scripts/update-leap/update-leap.1update-leapman@1.1 +168 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2769/scripts/update-leap/update-leap.1update-leapman
+
+ scripts/update-leap/update-leap.1update-leapman@1.0 +0 -0
+
+ scripts/update-leap/update-leap.1update-leapmdoc@1.1 +133 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2769/scripts/update-leap/update-leap.1update-leapmdoc
+
+ scripts/update-leap/update-leap.1update-leapmdoc@1.0 +0 -0
+
+ scripts/update-leap/update-leap.html@1.1 +297 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2769/scripts/update-leap/update-leap.html
+
+ scripts/update-leap/update-leap.html@1.0 +0 -0
+
+ scripts/update-leap/update-leap.man.in@1.1 +168 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2769/scripts/update-leap/update-leap.man.in
+
+ scripts/update-leap/update-leap.man.in@1.0 +0 -0
+
+ scripts/update-leap/update-leap.mdoc.in@1.1 +133 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2769/scripts/update-leap/update-leap.mdoc.in
+
+ scripts/update-leap/update-leap.mdoc.in@1.0 +0 -0
+
+ scripts/update-leap/update-leap.texi@1.1 +43 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2769/scripts/update-leap/update-leap.texi
+
+ scripts/update-leap/update-leap.texi@1.0 +0 -0
+
+ sntp/loc/darwin@1.3 +1 -0
+ [Bug 2769] New script: update-leap
+
+ sntp/loc/debian@1.4 +1 -0
+ [Bug 2769] New script: update-leap
+
+ sntp/loc/freebsd@1.6 +1 -0
+ [Bug 2769] New script: update-leap
+
+ sntp/loc/legacy@1.7 +1 -0
+ [Bug 2769] New script: update-leap
+
+ sntp/loc/netbsd@1.4 +1 -0
+ [Bug 2769] New script: update-leap
+
+ sntp/loc/solaris@1.7 +1 -0
+ [Bug 2769] New script: update-leap
+
+ sntp/m4/ntp_locinfo.m4@1.18 +6 -0
+ [Bug 2769] New script: update-leap
+
+ChangeSet@1.3305.3.1, 2015-03-20 13:03:38+01:00, burnicki@pc-martin4.
+ [Bug 2790] If ntpd sets the Windows MM timer highest resolution then pause
+ briefly before measuring system clock precision to yield correct results.
+
+ ChangeLog@1.1622.3.1 +3 -1
+ [Bug 2790] If ntpd sets the Windows MM timer highest resolution then pause
+ briefly before measuring system clock precision to yield correct results.
+
+ ports/winnt/ntpd/nt_clockstuff.c@1.65 +4 -0
+ [Bug 2790] If ntpd sets the Windows MM timer highest resolution then pause
+ briefly before measuring system clock precision to yield correct results.
+
+ChangeSet@1.3305.2.6, 2015-03-20 11:47:15+01:00, martin@pc-martin.(none)
+ [Bug 2791] Quiet compiler warnings from libevent.
+
+ ChangeLog@1.1622.2.6 +1 -0
+ [Bug 2791] Quiet compiler warnings from libevent.
+
+ sntp/libevent/evthread-internal.h@1.8 +2 -2
+ [Bug 2791] Fixed function prototypes to quiet compiler warnings.
+
+ChangeSet@1.3305.2.5, 2015-03-20 11:36:15+01:00, martin@pc-martin.(none)
+ [Bug 1787] DCF77's formerly "antenna" bit is "call bit" since 2003.
+
+ ChangeLog@1.1622.2.5 +4 -3
+ [Bug 1787] DCF77's formerly "antenna" bit is "call bit" since 2003.
+
+ include/parse.h@1.12 +3 -3
+ [Bug 1787] DCF77's formerly "antenna" bit is "call bit" since 2003.
+
+ libparse/clk_meinberg.c@1.14 +7 -4
+ [Bug 1787] DCF77's formerly "antenna" bit is "call bit" since 2003.
+
+ libparse/clk_rawdcf.c@1.20 +3 -2
+ [Bug 1787] DCF77's formerly "antenna" bit is "call bit" since 2003.
+
+ libparse/clk_schmid.c@1.13 +3 -3
+ [Bug 1787] DCF77's formerly "antenna" bit is "call bit" since 2003.
+
+ libparse/parse.c@1.19 +1 -1
+ Quiet compiler warning.
+
+ ntpd/refclock_parse.c@1.76 +1 -1
+ [Bug 1787] DCF77's formerly "antenna" bit is "call bit" since 2003.
+
+ parseutil/dcfd.c@1.28 +26 -25
+ [Bug 1787] DCF77's formerly "antenna" bit is "call bit" since 2003.
+ Removed trailing whitespace.
+
+ parseutil/testdcf.c@1.10 +11 -10
+ [Bug 1787] DCF77's formerly "antenna" bit is "call bit" since 2003.
+ Removed trailing whitespace and fixed indention.
+
+ChangeSet@1.3305.2.4, 2015-03-19 17:00:30+01:00, martin@pc-martin.(none)
+ Added a comment from Juergen Perlinger in ntp_date.c to make the code clearer.
+
+ ChangeLog@1.1622.2.4 +1 -0
+ Added a comment from Juergen Perlinger in ntp_date.c to make the code clearer.
+
+ libntp/ntp_calendar.c@1.15 +40 -34
+ Added a comment from Juergen Perlinger to make the code clearer.
+ Removed trailing whitespace.
+
+ChangeSet@1.3305.2.3, 2015-03-19 16:52:05+01:00, martin@pc-martin.(none)
+ Use predefined function types for parse driver functions used to set up function pointers.
+ Account for changed prototype of parse_inp_fnc_t functions.
+ Cast parse conversion results to appropriate types to avoid compiler warnings.
+ Let ioctl() for Windows accept a (void *) to avoid compiler warnings when called with pointers to different types.
+
+ ChangeLog@1.1622.2.3 +7 -0
+ Use predefined function types for parse driver functions used to set up function pointers.
+ Account for changed prototype of parse_inp_fnc_t functions.
+ Cast parse conversion results to appropriate types to avoid compiler warnings.
+ Let ioctl() for Windows accept a (void *) to avoid compiler warnings when called with pointers to different types.
+
+ include/binio.h@1.6 +10 -0
+ Added macros casting the result of the conversion function to a dedicated with to avoid compiler warnings.
+
+ include/mbg_gps166.h@1.13 +1 -1
+ Use specific data type with mbg_csum() to avoid compiler warnings.
+
+ include/parse.h@1.11 +15 -11
+ Introduced some dedicated function types simplifying use with function pointers.
+ Let parse input functions expect a char instead of an unsigned int since chars are used anyway.
+ This helps to avoid compiler warnings.
+
+ libparse/clk_computime.c@1.12 +10 -10
+ Use predefined function types for functions used to set up function pointers.
+ Account for changed prototype of parse_inp_fnc_t functions.
+
+ libparse/clk_dcf7000.c@1.12 +8 -7
+ Use predefined function types for functions used to set up function pointers.
+ Account for changed prototype of parse_inp_fnc_t functions.
+
+ libparse/clk_hopf6021.c@1.11 +21 -20
+ Use predefined function types for functions used to set up function pointers.
+ Account for changed prototype of parse_inp_fnc_t functions.
+
+ libparse/clk_meinberg.c@1.13 +20 -19
+ Use predefined function types for functions used to set up function pointers.
+ Account for changed prototype of parse_inp_fnc_t functions.
+ Cast conversion results to appropriate types to avoid compiler warnings.
+
+ libparse/clk_rawdcf.c@1.19 +8 -7
+ Use predefined function types for functions used to set up function pointers.
+ Account for changed prototype of parse_inp_fnc_t functions.
+ Cast to appropriate types to avoid compiler warnings.
+
+ libparse/clk_rcc8000.c@1.11 +17 -16
+ Use predefined function types for functions used to set up function pointers.
+ Account for changed prototype of parse_inp_fnc_t functions.
+
+ libparse/clk_schmid.c@1.12 +9 -9
+ Use predefined function types for functions used to set up function pointers.
+ Account for changed prototype of parse_inp_fnc_t functions.
+
+ libparse/clk_sel240x.c@1.4 +5 -11
+ Use predefined function types for functions used to set up function pointers.
+ Account for changed prototype of parse_inp_fnc_t functions.
+ Cast to appropriate types to avoid compiler warnings.
+
+ libparse/clk_trimtaip.c@1.12 +8 -7
+ Use predefined function types for functions used to set up function pointers.
+ Account for changed prototype of parse_inp_fnc_t functions.
+
+ libparse/clk_trimtsip.c@1.13 +18 -18
+ Use predefined function types for functions used to set up function pointers.
+ Account for changed prototype of parse_inp_fnc_t functions.
+ Cast conversion results to appropriate types to avoid compiler warnings.
+ Use commonly defined constants to handle GPS week number wraparounds.
+
+ libparse/clk_varitext.c@1.11 +6 -5
+ Use predefined function types for functions used to set up function pointers.
+ Account for changed prototype of parse_inp_fnc_t functions.
+
+ libparse/clk_wharton.c@1.10 +7 -4
+ Use predefined function types for functions used to set up function pointers.
+ Account for changed prototype of parse_inp_fnc_t functions.
+
+ libparse/data_mbg.c@1.15 +36 -36
+ Cast conversion results to appropriate types to avoid compiler warnings.
+
+ libparse/gpstolfp.c@1.12 +1 -1
+ Type cast to avoid compiler warning.
+
+ libparse/parse.c@1.18 +14 -14
+ Use predefined function types for functions used to set up function pointers.
+ Account for changed prototype of parse_inp_fnc_t functions.
+ Cast conversion results to appropriate types to avoid compiler warnings.
+
+ ntpd/refclock_parse.c@1.75 +49 -48
+ Cast conversion results to appropriate types to avoid compiler warnings.
+
+ ports/winnt/include/termios.h@1.17 +1 -1
+ Changed the prototype for ioctl() to accept a (void *) to avoid compiler warnings when called with pointers to different types.
+
+ ports/winnt/libntp/termios.c@1.30 +2 -1
+ Let ioctl() accept a (void *) to avoid compiler warnings when called with pointers to different types.
+
+ChangeSet@1.3305.1.19, 2015-03-19 07:54:24+00:00, stenn@psp-deb1.ntp.org
+ ntp_proto.c, ChangeLog:
+ [Sec 2779] ntpd accepts unauthenticated packets with symmetric key crypto.
+ [Sec 2781] Authentication doesn't protect symmetric associations against DoS attacks.
+
+ ChangeLog@1.1622.1.16 +3 -0
+ [Sec 2779] ntpd accepts unauthenticated packets with symmetric key crypto.
+ [Sec 2781] Authentication doesn't protect symmetric associations against DoS attacks.
+
+ ntpd/ntp_proto.c@1.354 +16 -14
+ [Sec 2779] ntpd accepts unauthenticated packets with symmetric key crypto.
+ [Sec 2781] Authentication doesn't protect symmetric associations against DoS attacks.
+
+ChangeSet@1.3305.1.18, 2015-03-16 09:17:42+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ ChangeLog@1.1622.1.15 +1 -0
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ include/ntp.h@1.211 +13 -11
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ include/ntpd.h@1.185 +2 -1
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ ntpd/invoke-ntp.conf.texi@1.178 +15 -2
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ ntpd/keyword-gen-utd@1.22 +1 -1
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ ntpd/keyword-gen.c@1.27 +2 -0
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ ntpd/ntp.conf.5man@1.212 +19 -4
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ ntpd/ntp.conf.5mdoc@1.212 +18 -3
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ ntpd/ntp.conf.def@1.15 +16 -1
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ ntpd/ntp.conf.man.in@1.212 +19 -4
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ ntpd/ntp.conf.mdoc.in@1.212 +18 -3
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ ntpd/ntp_config.c@1.323 +8 -0
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ ntpd/ntp_keyword.h@1.24 +492 -483
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ ntpd/ntp_loopfilter.c@1.179 +27 -5
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ ntpd/ntp_parser.c@1.90 +803 -797
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ ntpd/ntp_parser.h@1.56 +81 -77
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ ntpd/ntp_parser.y@1.83 +4 -0
+ [Bug 2763] Allow different thresholds for forward and backward steps
+
+ChangeSet@1.3305.2.2, 2015-03-13 10:28:32+01:00, martin@pc-martin.(none)
+ Removed non-ASCII characters from some copyright comments.
+ Removed trailing whitespace.
+ Updated definitions for Meinberg clocks from current Meinberg header files. Now use C99 fixed-width types and avoid non-ASCII characters in comments.
+ Account for updated definitions pulled from Meinberg header files.
+ Updated comments on Meinberg GPS receivers which are not only called GPS16x.
+ Replaced some constant numbers by defines from ntp_calendar.h
+ Modified creation of parse-specific variables for Meinberg devices in gps16x_message().
+ Reworked mk_utcinfo() to avoid printing of ambiguous leap second dates.
+ Modified mbg_tm_str() which now expexts an additional parameter controlling if the time status shall be printed.
+
+ ChangeLog@1.1622.2.2 +12 -0
+ Removed non-ASCII characters from some copyright comments.
+ Removed trailing whitespace.
+ Updated definitions for Meinberg clocks from current Meinberg header files. Now use C99 fixed-width types and avoid non-ASCII characters in comments.
+ Account for updated definitions pulled from Meinberg header files.
+ Updated comments on Meinberg GPS receivers which are not only called GPS16x.
+ Replaced some constant numbers by defines from ntp_calendar.h
+ Modified creation of parse-specific variables for Meinberg devices in gps16x_message().
+ Reworked mk_utcinfo() to avoid printing of ambiguous leap second dates.
+ Modified mbg_tm_str() which now expexts an additional parameter controlling if the time status shall be printed.
+
+ include/mbg_gps166.h@1.12 +841 -408
+ Updated definitions for Meinberg clocks from current Meinberg header files. Now use C99 fixed-width types and avoid non-ASCII characters in comments.
+ Updated prototype for mbg_tm_str() which now takes one more parameter.
+
+ include/ntp_calendar.h@1.17 +4 -2
+ Added definitions for DAYSPERWEEK and SECSPERWEEK.
+
+ include/parse.h@1.10 +14 -7
+ Removed non-ASCII characters from copyright comment.
+ Removed trailing whitespace.
+ Moved a few definitions from gpstolfp.c here so they can also be used in other c modules.
+
+ include/parse_conf.h@1.6 +1 -1
+ Removed non-ASCII characters from copyright comment.
+
+ kernel/sys/parsestreams.h@1.8 +1 -1
+ Removed non-ASCII characters from copyright comment.
+
+ libparse/clk_computime.c@1.11 +23 -23
+ Removed non-ASCII characters from copyright comment.
+ Removed trailing whitespace.
+
+ libparse/clk_dcf7000.c@1.11 +7 -7
+ Removed non-ASCII characters from copyright comment.
+ Removed trailing whitespace.
+
+ libparse/clk_meinberg.c@1.12 +71 -70
+ Updated comments on Meinberg GPS receivers which are not only called GPS16x.
+ Removed non-ASCII characters from copyright comment.
+ Removed trailing whitespace.
+
+ libparse/clk_rawdcf.c@1.18 +12 -12
+ Removed non-ASCII characters from copyright comment.
+ Removed trailing whitespace.
+
+ libparse/clk_schmid.c@1.11 +7 -7
+ Removed non-ASCII characters from copyright comment.
+ Removed trailing whitespace.
+
+ libparse/clk_trimtaip.c@1.11 +5 -5
+ Removed non-ASCII characters from copyright comment.
+ Removed trailing whitespace.
+
+ libparse/clk_trimtsip.c@1.12 +13 -13
+ Removed non-ASCII characters from copyright comment.
+ Removed trailing whitespace.
+
+ libparse/clk_varitext.c@1.10 +38 -38
+ Removed non-ASCII characters from copyright comment.
+ Removed trailing whitespace.
+
+ libparse/clk_wharton.c@1.9 +1 -1
+ Fixed a typo.
+
+ libparse/data_mbg.c@1.14 +39 -36
+ Account for updated definitions pulled from Meinberg header files.
+ Updated definitions for Meinberg clocks from current Meinberg header files. Now use C99 fixed-width types and avoid non-ASCII characters in comments.
+ Replaced some constant numbers by defines from ntp_calendar.h.
+ Modified mbg_tm_str() which now expexts an additional parameter controlling if the time status shall be printed.
+
+ libparse/gpstolfp.c@1.11 +4 -6
+ Moved some commonly used constants to parse.h.
+ Removed duplicate defines and use those in ntp_calendar.h.
+ Also replaced some constant numbers by defines from ntp_calendar.h.
+
+ libparse/parse.c@1.17 +46 -46
+ Removed non-ASCII characters from copyright comment.
+ Removed trailing whitespace.
+
+ libparse/parse_conf.c@1.11 +2 -2
+ Removed non-ASCII characters from copyright comment.
+
+ libparse/parsesolaris.c@1.12 +55 -55
+ Removed non-ASCII characters from copyright comment.
+ Removed trailing whitespace.
+
+ libparse/parsestreams.c@1.8 +63 -63
+ Removed non-ASCII characters from copyright comment.
+ Removed trailing whitespace.
+
+ libparse/trim_info.c@1.6 +1 -1
+ Removed non-ASCII characters from copyright comment.
+
+ ntpd/refclock_parse.c@1.74 +326 -295
+ Removed non-ASCII characters from copyright comment.
+ Removed trailing whitespace.
+ Reworked mk_utcinfo() to avoid printing of ambiguous leap second dates.
+ Modified creation of parse-specific variables for Meinberg devices in gps16x_message().
+
+ parseutil/dcfd.c@1.27 +2 -2
+ Removed non-ASCII characters from copyright comment.
+
+ parseutil/testdcf.c@1.9 +2 -2
+ Removed non-ASCII characters from copyright comment.
+
+ChangeSet@1.3305.1.17, 2015-03-10 11:21:46+00:00, stenn@psp-fb1.ntp.org
+ merge cleanup
+
+ ChangeLog@1.1622.1.14 +1 -3
+ merge cleanup
+
+ ntpd/ntp_loopfilter.c@1.178 +5 -2
+ merge cleanup
+
+ChangeSet@1.3305.2.1, 2015-03-10 10:48:25+01:00, martin@pc-martin.(none)
+ Fixed loops and decoding of Meinberg GPS satellite info.
+
+ ChangeLog@1.1622.2.1 +1 -0
+ Fixed loops and decoding of Meinberg GPS satellite info.
+
+ libparse/data_mbg.c@1.13 +3 -3
+ Fixed loops handling Meinberg GPS satellite info.
+
+ ntpd/refclock_parse.c@1.73 +44 -68
+ Fixed loops and decoding of Meinberg GPS satellite info.
+
+ChangeSet@1.3305.1.16, 2015-03-09 06:36:19-04:00, murray@pogo.udel.edu
+ ChangeLog, ntp_loopfilter.c:
+ Fix for bug 2774
+
+ ChangeLog@1.1622.1.13 +3 -0
+ Fix for bug 2774
+
+ ntpd/ntp_loopfilter.c@1.177 +4 -1
+ Fix for bug 2774
+
+ChangeSet@1.3305.1.15, 2015-03-05 10:17:02+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2783] Quiet autoconf warnings about missing AC_LANG_SOURCE
+
+ ChangeLog@1.1622.1.12 +1 -0
+ [Bug 2783] Quiet autoconf warnings about missing AC_LANG_SOURCE
+
+ configure.ac@1.584 +24 -22
+ [Bug 2783] Quiet autoconf warnings about missing AC_LANG_SOURCE
+
+ sntp/libopts/m4/libopts.m4@1.33 +12 -12
+ [Bug 2783] Quiet autoconf warnings about missing AC_LANG_SOURCE
+
+ sntp/m4/ntp_libntp.m4@1.29 +4 -4
+ [Bug 2783] Quiet autoconf warnings about missing AC_LANG_SOURCE
+
+ChangeSet@1.3305.1.14, 2015-03-04 11:16:31+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2775] ntp-keygen.c fails to compile under Windows
+
+ ChangeLog@1.1622.1.11 +1 -0
+ [Bug 2775] ntp-keygen.c fails to compile under Windows.
+
+ util/ntp-keygen.c@1.103 +7 -1
+ [Bug 2775] ntp-keygen.c fails to compile under Windows
+
+ChangeSet@1.3305.1.13, 2015-03-01 21:46:56-05:00, stenn@pogo.udel.edu
+ cleanup
+
+ ChangeLog@1.1622.1.10 +1 -2
+ cleanup
+
+ChangeSet@1.3305.1.12, 2015-03-01 02:50:18-05:00, murray@pogo.udel.edu
+ refclock_palisade.h, ChangeLog, refclock_palisade.c:
+ Fix bug 2773 - early leap from Palisade/Thunderbolt
+
+ ChangeLog@1.1622.1.9 +2 -0
+ Fix bug 2773 - early leap from Palisade/Thunderbolt
+
+ ntpd/refclock_palisade.c@1.42 +8 -2
+ Fix bug 2773 - early leap from Palisade/Thunderbolt
+
+ ntpd/refclock_palisade.h@1.15 +1 -0
+ Fix bug 2773 - early leap from Palisade/Thunderbolt
+
+ChangeSet@1.3305.1.11, 2015-02-28 12:12:13+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2751] jitter.h has stale copies of l_fp macros
+
+ util/Makefile.am@1.78 +1 -1
+ [Bug 2751] jitter.h has stale copies of l_fp macros
+
+ChangeSet@1.3305.1.10, 2015-02-28 12:04:02+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2771] nonvolatile value is documented in wrong units
+
+ ChangeLog@1.1622.1.8 +1 -0
+ [Bug 2771] nonvolatile value is documented in wrong units
+
+ html/miscopt.html@1.80 +2 -2
+ [Bug 2771] nonvolatile value is documented in wrong units
+
+ChangeSet@1.3305.1.9, 2015-02-28 11:34:24+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2767] ntp-keygen -M should symlink to ntp.keys
+
+ ChangeLog@1.1622.1.7 +1 -0
+ [Bug 2767] ntp-keygen -M should symlink to ntp.keys
+
+ util/ntp-keygen.c@1.102 +6 -2
+ [Bug 2767] ntp-keygen -M should symlink to ntp.keys
+
+ChangeSet@1.3305.1.8, 2015-02-28 11:28:04+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2766] ntp-keygen output files should not be world-readable
+
+ ChangeLog@1.1622.1.6 +1 -0
+ [Bug 2766] ntp-keygen output files should not be world-readable
+
+ util/ntp-keygen.c@1.101 +5 -1
+ [Bug 2766] ntp-keygen output files should not be world-readable
+
+ChangeSet@1.3305.1.7, 2015-02-28 11:18:57+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2759] Expose nonvolatile/clk_wander_threshold to ntpq
+
+ ChangeLog@1.1622.1.5 +1 -0
+ [Bug 2759] Expose nonvolatile/clk_wander_threshold to ntpq
+
+ ntpd/ntp_control.c@1.196 +56 -51
+ [Bug 2759] Expose nonvolatile/clk_wander_threshold to ntpq
+
+ChangeSet@1.3305.1.6, 2015-02-28 09:47:20+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2757] Quiet compiler warnings.
+
+ lib/isc/inet_ntop.c@1.14 +1 -0
+ [Bug 2757] Quiet compiler warnings.
+
+ lib/isc/log.c@1.8 +12 -12
+ [Bug 2757] Quiet compiler warnings.
+
+ ntpd/ntp_leapsec.c@1.16 +6 -6
+ [Bug 2757] Quiet compiler warnings.
+
+ parseutil/dcfd.c@1.26 +7 -0
+ [Bug 2757] Quiet compiler warnings.
+
+ sntp/libevent/include/event2/event.h@1.11 +4 -0
+ [Bug 2757] Quiet compiler warnings.
+
+ChangeSet@1.3305.1.5, 2015-02-28 09:11:24+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2756] ntpd hangs in startup with gcc 3.3.5 on ARM
+
+ ChangeLog@1.1622.1.4 +1 -0
+ [Bug 2756] ntpd hangs in startup with gcc 3.3.5 on ARM
+
+ configure.ac@1.583 +0 -2
+ [Bug 2756] ntpd hangs in startup with gcc 3.3.5 on ARM
+
+ include/ntp_fp.h@1.32 +4 -1
+ [Bug 2756] ntpd hangs in startup with gcc 3.3.5 on ARM
+
+ChangeSet@1.3305.1.4, 2015-02-25 07:58:47+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2751] jitter.h has stale copies of l_fp macros
+
+ BitKeeper/deleted/fd/jitter.h~11d7c056cb18e28@1.5 +0 -0
+ Delete: util/jitter.h
+
+ ChangeLog@1.1622.1.3 +1 -0
+ [Bug 2751] jitter.h has stale copies of l_fp macros
+
+ util/jitter.c@1.11 +1 -2
+ [Bug 2751] jitter.h has stale copies of l_fp macros
+
+ChangeSet@1.3305.1.3, 2015-02-21 05:56:16-05:00, stenn@deacon.udel.edu
+ Update triggers for bk-6
+
+ BitKeeper/triggers/post-incoming.license-warn@1.9 +3 -0
+ Update triggers for bk-6
+
+ BitKeeper/triggers/pre-resolve.license-chk@1.10 +3 -0
+ Update triggers for bk-6
+
+ BitKeeper/triggers/send@1.16 +2 -2
+ Update triggers for bk-6
+
+ChangeSet@1.3305.1.2, 2015-02-21 10:35:38+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2757] Quiet compiler warnings
+
+ ChangeLog@1.1622.1.2 +1 -0
+ [Bug 2757] Quiet compiler warnings
+
+ lib/isc/result.c@1.4 +6 -6
+ [Bug 2757] Quiet compiler warnings
+
+ lib/isc/unix/file.c@1.7 +3 -3
+ [Bug 2757] Quiet compiler warnings
+
+ lib/isc/unix/ifiter_ioctl.c@1.32.1.1 +4 -0
+ [Bug 2757] Quiet compiler warnings
+
+ lib/isc/unix/net.c@1.19 +2 -1
+ [Bug 2757] Quiet compiler warnings
+
+ libntp/work_fork.c@1.13 +1 -1
+ [Bug 2757] Quiet compiler warnings
+
+ ntpd/ntp_crypto.c@1.174 +1 -1
+ [Bug 2757] Quiet compiler warnings
+
+ChangeSet@1.3305.1.1, 2015-02-21 09:51:32+00:00, stenn@psp-deb1.ntp.org
+ [Bug 2749] ntp/lib/NTP/Util.pm needs update for ntpq -w, IPv6, .POOL.
+
+ ChangeLog@1.1622.1.1 +1 -0
+ [Bug 2749] ntp/lib/NTP/Util.pm needs update for ntpq -w, IPv6, .POOL.
+
+ scripts/lib/NTP/Util.pm@1.3 +15 -4
+ [Bug 2749] ntp/lib/NTP/Util.pm needs update for ntpq -w, IPv6, .POOL.
+
+ChangeSet@1.3306, 2015-02-21 09:28:08+00:00, stenn@psp-fb1.ntp.org
+ [Bug 1960] setsockopt IPV6_MULTICAST_IF: Invalid argument
+
+ ChangeLog@1.1623 +1 -0
+ [Bug 1960] setsockopt IPV6_MULTICAST_IF: Invalid argument
+
+ lib/isc/unix/ifiter_getifaddrs.c@1.14 +3 -0
+ [Bug 1960] setsockopt IPV6_MULTICAST_IF: Invalid argument
+
+ lib/isc/unix/ifiter_ioctl.c@1.33 +12 -2
+ [Bug 1960] setsockopt IPV6_MULTICAST_IF: Invalid argument
+
+ChangeSet@1.3302.1.1, 2015-02-21 07:15:54+00:00, stenn@psp-deb1.ntp.org
+ [Bug 2728] See if C99-style structure initialization works
+
+ ChangeLog@1.1620.1.1 +3 -0
+ [Bug 2728] See if C99-style structure initialization works
+
+ configure.ac@1.582 +1 -0
+ [Bug 2728] See if C99-style structure initialization works
+
+ ntpq/ntpq-subs.c@1.104 +1 -1
+ [Bug 2728] See if C99-style structure initialization works
+
+ ports/winnt/include/config.h@1.111 +1 -1
+ [Bug 2728] See if C99-style structure initialization works
+
+ sntp/m4/ax_c99_struct_init.m4@1.1 +59 -0
+ BitKeeper file /home/stenn/ntp-stable-2728/sntp/m4/ax_c99_struct_init.m4
+
+ sntp/m4/ax_c99_struct_init.m4@1.0 +0 -0
+
+ChangeSet@1.3304, 2015-02-11 09:08:51+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ ChangeLog@1.1621 +3 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ChangeSet@1.3303, 2015-02-11 09:05:59+00:00, stenn@psp-fb1.ntp.org
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ BitKeeper/deleted/5b/README~3a69bb76c676898e@1.7 +0 -0
+ Delete: sntp/libevent/README
+
+ sntp/libevent/ChangeLog@1.9 +726 -60
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/Makefile.am@1.13 +3 -1
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/README.md@1.1 +318 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2747/sntp/libevent/README.md
+
+ sntp/libevent/README.md@1.0 +0 -0
+
+ sntp/libevent/WIN32-Code/getopt.c@1.1 +149 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2747/sntp/libevent/WIN32-Code/getopt.c
+
+ sntp/libevent/WIN32-Code/getopt.c@1.0 +0 -0
+
+ sntp/libevent/WIN32-Code/getopt.h@1.1 +33 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2747/sntp/libevent/WIN32-Code/getopt.h
+
+ sntp/libevent/WIN32-Code/getopt.h@1.0 +0 -0
+
+ sntp/libevent/WIN32-Code/getopt_long.c@1.1 +233 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2747/sntp/libevent/WIN32-Code/getopt_long.c
+
+ sntp/libevent/WIN32-Code/getopt_long.c@1.0 +0 -0
+
+ sntp/libevent/WIN32-Code/nmake/event2/event-config.h@1.2 +2 -2
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/WIN32-Code/tree.h@1.2 +0 -677
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/buffer.c@1.10 +74 -10
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/bufferevent.c@1.8 +9 -4
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/bufferevent_async.c@1.7 +6 -4
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/bufferevent_filter.c@1.7 +50 -23
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/bufferevent_openssl.c@1.9 +2 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/bufferevent_pair.c@1.8 +32 -1
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/configure.ac@1.17 +15 -18
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/evbuffer-internal.h@1.8 +13 -1
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/evdns.c@1.10 +80 -33
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/event.c@1.13 +38 -10
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/event_tagging.c@1.5 +14 -1
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/evrpc-internal.h@1.3 +1 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/evthread-internal.h@1.7 +7 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/evthread.c@1.8 +17 -6
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/evutil.c@1.10 +28 -14
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/evutil_time.c@1.5 +50 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/ht-internal.h@1.4 +0 -1
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/http-internal.h@1.6 +2 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/http.c@1.10 +45 -2
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/include/event2/buffer.h@1.7 +3 -8
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/include/event2/bufferevent.h@1.6 +5 -4
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/include/event2/dns.h@1.7 +17 -1
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/include/event2/event.h@1.10 +6 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/include/event2/http.h@1.7 +14 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/include/event2/listener.h@1.4 +9 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/include/event2/util.h@1.7 +69 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/kqueue.c@1.7 +17 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/listener.c@1.7 +5 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/sample/http-server.c@1.10 +5 -2
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/sample/https-client.c@1.2 +15 -2
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/sample/include.am@1.3 +2 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/include.am@1.4 +2 -1
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/print-winsock-errors.c@1.1 +84 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2747/sntp/libevent/test/print-winsock-errors.c
+
+ sntp/libevent/test/print-winsock-errors.c@1.0 +0 -0
+
+ sntp/libevent/test/regress.c@1.6 +29 -8
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/regress.h@1.5 +5 -1
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/regress_buffer.c@1.8 +47 -6
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/regress_bufferevent.c@1.6 +150 -2
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/regress_dns.c@1.8 +141 -14
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/regress_finalize.c@1.2 +1 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/regress_http.c@1.8 +107 -9
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/regress_main.c@1.7 +4 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/regress_minheap.c@1.3 +3 -2
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/regress_ssl.c@1.7 +1 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/regress_thread.c@1.6 +3 -2
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/regress_util.c@1.7 +19 -17
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/regress_zlib.c@1.5 +10 -7
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/test-fdleak.c@1.2 +10 -10
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/test-ratelim.c@1.9 +5 -6
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/test-ratelim.sh@1.1 +88 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2747/sntp/libevent/test/test-ratelim.sh
+
+ sntp/libevent/test/test-ratelim.sh@1.0 +0 -0
+
+ sntp/libevent/test/test-time.c@1.5 +9 -6
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/tinytest.c@1.6 +33 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/tinytest.h@1.4 +2 -0
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/test/tinytest_demo.c@1.1 +260 -0
+ BitKeeper file /a/etc/amd.stage/thump2-g3/export/ntp/home/stenn/ntp-stable-2747/sntp/libevent/test/tinytest_demo.c
+
+ sntp/libevent/test/tinytest_demo.c@1.0 +0 -0
+
+ sntp/libevent/test/tinytest_macros.h@1.3 +21 -6
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/time-internal.h@1.2 +0 -3
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/util-internal.h@1.10 +1 -1
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/libevent/whatsnew-2.1.txt@1.4 +52 -1
+ [Bug 2747] Upgrade libevent to 2.1.5-beta
+
+ sntp/m4/LICENSE-OPENLDAP@1.2 +0 -0
+ Rename: sntp/libevent/m4/LICENSE-OPENLDAP -> sntp/m4/LICENSE-OPENLDAP
+
+ sntp/m4/openldap-thread-check.m4@1.5 +0 -0
+ Rename: sntp/libevent/m4/openldap-thread-check.m4 -> sntp/m4/openldap-thread-check.m4
+
+ sntp/m4/openldap.m4@1.2 +0 -0
+ Rename: sntp/libevent/m4/openldap.m4 -> sntp/m4/openldap.m4
+
ChangeSet@1.3302, 2015-02-04 02:44:25-05:00, stenn@deacon.udel.edu
NTP_4_2_8P1
TAG: NTP_4_2_8P1
diff --git a/contrib/ntp/Makefile.in b/contrib/ntp/Makefile.in
index abd5a09..47232a6 100644
--- a/contrib/ntp/Makefile.in
+++ b/contrib/ntp/Makefile.in
@@ -49,8 +49,7 @@ DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -79,6 +78,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -347,6 +348,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/NEWS b/contrib/ntp/NEWS
index d33f059..a425a9a 100644
--- a/contrib/ntp/NEWS
+++ b/contrib/ntp/NEWS
@@ -1,4 +1,145 @@
---
+NTP 4.2.8p2 (Harlan Stenn <stenn@ntp.org>, 2015/04/xx)
+
+Focus: Security and Bug fixes, enhancements.
+
+Severity: MEDIUM
+
+In addition to bug fixes and enhancements, this release fixes the
+following medium-severity vulnerabilities involving private key
+authentication:
+
+* [Sec 2779] ntpd accepts unauthenticated packets with symmetric key crypto.
+
+ References: Sec 2779 / CVE-2015-1798 / VU#374268
+ Affects: All NTP4 releases starting with ntp-4.2.5p99 up to but not
+ including ntp-4.2.8p2 where the installation uses symmetric keys
+ to authenticate remote associations.
+ CVSS: (AV:A/AC:M/Au:N/C:P/I:P/A:P) Base Score: 5.4
+ Date Resolved: Stable (4.2.8p2) 07 Apr 2015
+ Summary: When ntpd is configured to use a symmetric key to authenticate
+ a remote NTP server/peer, it checks if the NTP message
+ authentication code (MAC) in received packets is valid, but not if
+ there actually is any MAC included. Packets without a MAC are
+ accepted as if they had a valid MAC. This allows a MITM attacker to
+ send false packets that are accepted by the client/peer without
+ having to know the symmetric key. The attacker needs to know the
+ transmit timestamp of the client to match it in the forged reply
+ and the false reply needs to reach the client before the genuine
+ reply from the server. The attacker doesn't necessarily need to be
+ relaying the packets between the client and the server.
+
+ Authentication using autokey doesn't have this problem as there is
+ a check that requires the key ID to be larger than NTP_MAXKEY,
+ which fails for packets without a MAC.
+ Mitigation:
+ Upgrade to 4.2.8p2, or later, from the NTP Project Download Page
+ or the NTP Public Services Project Download Page
+ Configure ntpd with enough time sources and monitor it properly.
+ Credit: This issue was discovered by Miroslav Lichvar, of Red Hat.
+
+* [Sec 2781] Authentication doesn't protect symmetric associations against
+ DoS attacks.
+
+ References: Sec 2781 / CVE-2015-1799 / VU#374268
+ Affects: All NTP releases starting with at least xntp3.3wy up to but
+ not including ntp-4.2.8p2 where the installation uses symmetric
+ key authentication.
+ CVSS: (AV:A/AC:M/Au:N/C:P/I:P/A:P) Base Score: 5.4
+ Note: the CVSS base Score for this issue could be 4.3 or lower, and
+ it could be higher than 5.4.
+ Date Resolved: Stable (4.2.8p2) 07 Apr 2015
+ Summary: An attacker knowing that NTP hosts A and B are peering with
+ each other (symmetric association) can send a packet to host A
+ with source address of B which will set the NTP state variables
+ on A to the values sent by the attacker. Host A will then send
+ on its next poll to B a packet with originate timestamp that
+ doesn't match the transmit timestamp of B and the packet will
+ be dropped. If the attacker does this periodically for both
+ hosts, they won't be able to synchronize to each other. This is
+ a known denial-of-service attack, described at
+ https://www.eecis.udel.edu/~mills/onwire.html .
+
+ According to the document the NTP authentication is supposed to
+ protect symmetric associations against this attack, but that
+ doesn't seem to be the case. The state variables are updated even
+ when authentication fails and the peers are sending packets with
+ originate timestamps that don't match the transmit timestamps on
+ the receiving side.
+
+ This seems to be a very old problem, dating back to at least
+ xntp3.3wy. It's also in the NTPv3 (RFC 1305) and NTPv4 (RFC 5905)
+ specifications, so other NTP implementations with support for
+ symmetric associations and authentication may be vulnerable too.
+ An update to the NTP RFC to correct this error is in-process.
+ Mitigation:
+ Upgrade to 4.2.8p2, or later, from the NTP Project Download Page
+ or the NTP Public Services Project Download Page
+ Note that for users of autokey, this specific style of MITM attack
+ is simply a long-known potential problem.
+ Configure ntpd with appropriate time sources and monitor ntpd.
+ Alert your staff if problems are detected.
+ Credit: This issue was discovered by Miroslav Lichvar, of Red Hat.
+
+* New script: update-leap
+The update-leap script will verify and if necessary, update the
+leap-second definition file.
+It requires the following commands in order to work:
+
+ wget logger tr sed shasum
+
+Some may choose to run this from cron. It needs more portability testing.
+
+Bug Fixes and Improvements:
+
+* [Bug 1787] DCF77's formerly "antenna" bit is "call bit" since 2003.
+* [Bug 1960] setsockopt IPV6_MULTICAST_IF: Invalid argument.
+* [Bug 2346] "graceful termination" signals do not do peer cleanup.
+* [Bug 2728] See if C99-style structure initialization works.
+* [Bug 2747] Upgrade libevent to 2.1.5-beta.
+* [Bug 2749] ntp/lib/NTP/Util.pm needs update for ntpq -w, IPv6, .POOL. .
+* [Bug 2751] jitter.h has stale copies of l_fp macros.
+* [Bug 2756] ntpd hangs in startup with gcc 3.3.5 on ARM.
+* [Bug 2757] Quiet compiler warnings.
+* [Bug 2759] Expose nonvolatile/clk_wander_threshold to ntpq.
+* [Bug 2763] Allow different thresholds for forward and backward steps.
+* [Bug 2766] ntp-keygen output files should not be world-readable.
+* [Bug 2767] ntp-keygen -M should symlink to ntp.keys.
+* [Bug 2771] nonvolatile value is documented in wrong units.
+* [Bug 2773] Early leap announcement from Palisade/Thunderbolt
+* [Bug 2774] Unreasonably verbose printout - leap pending/warning
+* [Bug 2775] ntp-keygen.c fails to compile under Windows.
+* [Bug 2777] Fixed loops and decoding of Meinberg GPS satellite info.
+ Removed non-ASCII characters from some copyright comments.
+ Removed trailing whitespace.
+ Updated definitions for Meinberg clocks from current Meinberg header files.
+ Now use C99 fixed-width types and avoid non-ASCII characters in comments.
+ Account for updated definitions pulled from Meinberg header files.
+ Updated comments on Meinberg GPS receivers which are not only called GPS16x.
+ Replaced some constant numbers by defines from ntp_calendar.h
+ Modified creation of parse-specific variables for Meinberg devices
+ in gps16x_message().
+ Reworked mk_utcinfo() to avoid printing of ambiguous leap second dates.
+ Modified mbg_tm_str() which now expexts an additional parameter controlling
+ if the time status shall be printed.
+* [Sec 2779] ntpd accepts unauthenticated packets with symmetric key crypto.
+* [Sec 2781] Authentication doesn't protect symmetric associations against
+ DoS attacks.
+* [Bug 2783] Quiet autoconf warnings about missing AC_LANG_SOURCE.
+* [Bug 2789] Quiet compiler warnings from libevent.
+* [Bug 2790] If ntpd sets the Windows MM timer highest resolution
+ pause briefly before measuring system clock precision to yield
+ correct results.
+* Comment from Juergen Perlinger in ntp_calendar.c to make the code clearer.
+* Use predefined function types for parse driver functions
+ used to set up function pointers.
+ Account for changed prototype of parse_inp_fnc_t functions.
+ Cast parse conversion results to appropriate types to avoid
+ compiler warnings.
+ Let ioctl() for Windows accept a (void *) to avoid compiler warnings
+ when called with pointers to different types.
+
+---
NTP 4.2.8p1 (Harlan Stenn <stenn@ntp.org>, 2015/02/04)
Focus: Security and Bug fixes, enhancements.
diff --git a/contrib/ntp/aclocal.m4 b/contrib/ntp/aclocal.m4
index c82bc09..24036a4 100644
--- a/contrib/ntp/aclocal.m4
+++ b/contrib/ntp/aclocal.m4
@@ -1132,8 +1132,7 @@ AC_SUBST([am__untar])
m4_include([sntp/libopts/m4/libopts.m4])
m4_include([sntp/libopts/m4/stdnoreturn.m4])
-m4_include([sntp/libevent/m4/openldap-thread-check.m4])
-m4_include([sntp/libevent/m4/openldap.m4])
+m4_include([sntp/m4/ax_c99_struct_init.m4])
m4_include([sntp/m4/define_dir.m4])
m4_include([sntp/m4/hms_search_lib.m4])
m4_include([sntp/m4/libtool.m4])
@@ -1162,5 +1161,7 @@ m4_include([sntp/m4/ntp_rlimit.m4])
m4_include([sntp/m4/ntp_sntp.m4])
m4_include([sntp/m4/ntp_ver_suffix.m4])
m4_include([sntp/m4/ntp_vpathhack.m4])
+m4_include([sntp/m4/openldap-thread-check.m4])
+m4_include([sntp/m4/openldap.m4])
m4_include([sntp/m4/os_cflags.m4])
m4_include([sntp/m4/snprintf.m4])
diff --git a/contrib/ntp/adjtimed/Makefile.in b/contrib/ntp/adjtimed/Makefile.in
index a6e97da..56f4dfb 100644
--- a/contrib/ntp/adjtimed/Makefile.in
+++ b/contrib/ntp/adjtimed/Makefile.in
@@ -49,8 +49,7 @@ subdir = adjtimed
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -79,6 +78,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -329,6 +330,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/clockstuff/Makefile.in b/contrib/ntp/clockstuff/Makefile.in
index f04ff2c..c852adb 100644
--- a/contrib/ntp/clockstuff/Makefile.in
+++ b/contrib/ntp/clockstuff/Makefile.in
@@ -42,8 +42,7 @@ subdir = clockstuff
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -72,6 +71,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -325,6 +326,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/config.h.in b/contrib/ntp/config.h.in
index 76facf9..5ca9484 100644
--- a/contrib/ntp/config.h.in
+++ b/contrib/ntp/config.h.in
@@ -1331,6 +1331,10 @@
/* Should we recommend a minimum value for tickadj? */
#undef MIN_REC_TICKADJ
+/* Define to 1 if the compiler does not support C99's structure
+ initialization. */
+#undef MISSING_C99_STRUCT_INIT
+
/* Do we need HPUX adjtime() library support? */
#undef NEED_HPUX_ADJTIME
diff --git a/contrib/ntp/configure b/contrib/ntp/configure
index 28e0c37..29d777c 100755
--- a/contrib/ntp/configure
+++ b/contrib/ntp/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for ntp 4.2.8p1.
+# Generated by GNU Autoconf 2.68 for ntp 4.2.8p2.
#
# Report bugs to <http://bugs.ntp.org./>.
#
@@ -570,8 +570,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='ntp'
PACKAGE_TARNAME='ntp'
-PACKAGE_VERSION='4.2.8p1'
-PACKAGE_STRING='ntp 4.2.8p1'
+PACKAGE_VERSION='4.2.8p2'
+PACKAGE_STRING='ntp 4.2.8p2'
PACKAGE_BUGREPORT='http://bugs.ntp.org./'
PACKAGE_URL='http://www.ntp.org./'
@@ -710,6 +710,13 @@ LD
FGREP
SED
LIBTOOL
+INSTALL_UPDATE_LEAP_FALSE
+INSTALL_UPDATE_LEAP_TRUE
+UPDATE_LEAP_NI
+UPDATE_LEAP_MS
+UPDATE_LEAP_DS
+UPDATE_LEAP_DL
+UPDATE_LEAP_DB
TIMETRIM_NI
TIMETRIM_MS
TIMETRIM_DS
@@ -1573,7 +1580,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures ntp 4.2.8p1 to adapt to many kinds of systems.
+\`configure' configures ntp 4.2.8p2 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1643,7 +1650,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of ntp 4.2.8p1:";;
+ short | recursive ) echo "Configuration of ntp 4.2.8p2:";;
esac
cat <<\_ACEOF
@@ -1872,7 +1879,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-ntp configure 4.2.8p1
+ntp configure 4.2.8p2
generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
@@ -2697,7 +2704,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by ntp $as_me 4.2.8p1, which was
+It was created by ntp $as_me 4.2.8p2, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@
@@ -3644,7 +3651,7 @@ fi
# Define the identity of the package.
PACKAGE='ntp'
- VERSION='4.2.8p1'
+ VERSION='4.2.8p2'
cat >>confdefs.h <<_ACEOF
@@ -7780,6 +7787,44 @@ $as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h
fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports C99 structure initialization" >&5
+$as_echo_n "checking whether the compiler supports C99 structure initialization... " >&6; }
+
+
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ struct foo_s {int i1; int i2;};
+ int main() { struct foo_s foo[] = { { .i1 = 1, .i2 = 1 }, { .i1 = 2, .i2 = 2 }, { .i1 = 0, .i2 = 0 } }; }
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+$as_echo "#define MISSING_C99_STRUCT_INIT 1" >>confdefs.h
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking to see if we need ylwrap VPATH hack" >&5
$as_echo_n "checking to see if we need ylwrap VPATH hack... " >&6; }
@@ -7946,6 +7991,19 @@ fi
+
+ if test -z "$UPDATE_LEAP_NI" ; then
+ INSTALL_UPDATE_LEAP_TRUE=
+ INSTALL_UPDATE_LEAP_FALSE='#'
+else
+ INSTALL_UPDATE_LEAP_TRUE='#'
+ INSTALL_UPDATE_LEAP_FALSE=
+fi
+
+
+
+
+
# So far, the only shared library we might use is libopts.
# It's a small library - we might as well use a static version of it.
# Check whether --enable-shared was given.
@@ -31709,10 +31767,10 @@ else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
- #include <sys/syscall.h>
- #if !defined(SYS_ntp_gettime) || !defined(SYS_ntp_adjtime)
- # error
- #endif
+ #include <sys/syscall.h>
+ #if !defined(SYS_ntp_gettime) || !defined(SYS_ntp_adjtime)
+ # error
+ #endif
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
@@ -31748,10 +31806,10 @@ else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
- #include <sys/timex.h>
- #ifndef STA_FLL
- # error
- #endif
+ #include <sys/timex.h>
+ #ifndef STA_FLL
+ # error
+ #endif
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
@@ -35326,7 +35384,6 @@ esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we should enable NIST lockclock scheme" >&5
$as_echo_n "checking if we should enable NIST lockclock scheme... " >&6; }
-
# Check whether --enable-nist was given.
if test "${enable_nist+set}" = set; then :
enableval=$enable_nist; ans=$enableval
@@ -35348,7 +35405,6 @@ esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we want support for Samba's signing daemon" >&5
$as_echo_n "checking if we want support for Samba's signing daemon... " >&6; }
-
# Check whether --enable-ntp-signd was given.
if test "${enable_ntp_signd+set}" = set; then :
enableval=$enable_ntp_signd; ans=$enableval
@@ -36444,33 +36500,35 @@ ac_config_files="$ac_config_files parseutil/Makefile"
ac_config_files="$ac_config_files scripts/Makefile"
-ac_config_files="$ac_config_files scripts/lib/Makefile"
+ac_config_files="$ac_config_files scripts/build/Makefile"
-ac_config_files="$ac_config_files scripts/calc_tickadj/calc_tickadj"
+ac_config_files="$ac_config_files scripts/build/mkver"
ac_config_files="$ac_config_files scripts/calc_tickadj/Makefile"
-ac_config_files="$ac_config_files scripts/build/mkver"
+ac_config_files="$ac_config_files scripts/calc_tickadj/calc_tickadj"
-ac_config_files="$ac_config_files scripts/ntp-wait/ntp-wait"
+ac_config_files="$ac_config_files scripts/lib/Makefile"
ac_config_files="$ac_config_files scripts/ntp-wait/Makefile"
-ac_config_files="$ac_config_files scripts/ntpsweep/ntpsweep"
+ac_config_files="$ac_config_files scripts/ntp-wait/ntp-wait"
ac_config_files="$ac_config_files scripts/ntpsweep/Makefile"
-ac_config_files="$ac_config_files scripts/ntptrace/ntptrace"
+ac_config_files="$ac_config_files scripts/ntpsweep/ntpsweep"
ac_config_files="$ac_config_files scripts/ntptrace/Makefile"
+ac_config_files="$ac_config_files scripts/ntptrace/ntptrace"
+
ac_config_files="$ac_config_files scripts/ntpver"
ac_config_files="$ac_config_files scripts/plot_summary"
ac_config_files="$ac_config_files scripts/summary"
-ac_config_files="$ac_config_files scripts/build/Makefile"
+ac_config_files="$ac_config_files scripts/update-leap/Makefile"
ac_config_files="$ac_config_files tests/Makefile"
@@ -36664,6 +36722,10 @@ if test -z "${INSTALL_NTPSWEEP_TRUE}" && test -z "${INSTALL_NTPSWEEP_FALSE}"; th
as_fn_error $? "conditional \"INSTALL_NTPSWEEP\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${INSTALL_UPDATE_LEAP_TRUE}" && test -z "${INSTALL_UPDATE_LEAP_FALSE}"; then
+ as_fn_error $? "conditional \"INSTALL_UPDATE_LEAP\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${GL_GENERATE_STDNORETURN_H_TRUE}" && test -z "${GL_GENERATE_STDNORETURN_H_FALSE}"; then
as_fn_error $? "conditional \"GL_GENERATE_STDNORETURN_H\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -37109,7 +37171,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by ntp $as_me 4.2.8p1, which was
+This file was extended by ntp $as_me 4.2.8p2, which was
generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -37176,7 +37238,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-ntp config.status 4.2.8p1
+ntp config.status 4.2.8p2
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"
@@ -37703,20 +37765,21 @@ do
"ntpsnmpd/Makefile") CONFIG_FILES="$CONFIG_FILES ntpsnmpd/Makefile" ;;
"parseutil/Makefile") CONFIG_FILES="$CONFIG_FILES parseutil/Makefile" ;;
"scripts/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;;
- "scripts/lib/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/lib/Makefile" ;;
- "scripts/calc_tickadj/calc_tickadj") CONFIG_FILES="$CONFIG_FILES scripts/calc_tickadj/calc_tickadj" ;;
- "scripts/calc_tickadj/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/calc_tickadj/Makefile" ;;
+ "scripts/build/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/build/Makefile" ;;
"scripts/build/mkver") CONFIG_FILES="$CONFIG_FILES scripts/build/mkver" ;;
- "scripts/ntp-wait/ntp-wait") CONFIG_FILES="$CONFIG_FILES scripts/ntp-wait/ntp-wait" ;;
+ "scripts/calc_tickadj/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/calc_tickadj/Makefile" ;;
+ "scripts/calc_tickadj/calc_tickadj") CONFIG_FILES="$CONFIG_FILES scripts/calc_tickadj/calc_tickadj" ;;
+ "scripts/lib/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/lib/Makefile" ;;
"scripts/ntp-wait/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/ntp-wait/Makefile" ;;
- "scripts/ntpsweep/ntpsweep") CONFIG_FILES="$CONFIG_FILES scripts/ntpsweep/ntpsweep" ;;
+ "scripts/ntp-wait/ntp-wait") CONFIG_FILES="$CONFIG_FILES scripts/ntp-wait/ntp-wait" ;;
"scripts/ntpsweep/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/ntpsweep/Makefile" ;;
- "scripts/ntptrace/ntptrace") CONFIG_FILES="$CONFIG_FILES scripts/ntptrace/ntptrace" ;;
+ "scripts/ntpsweep/ntpsweep") CONFIG_FILES="$CONFIG_FILES scripts/ntpsweep/ntpsweep" ;;
"scripts/ntptrace/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/ntptrace/Makefile" ;;
+ "scripts/ntptrace/ntptrace") CONFIG_FILES="$CONFIG_FILES scripts/ntptrace/ntptrace" ;;
"scripts/ntpver") CONFIG_FILES="$CONFIG_FILES scripts/ntpver" ;;
"scripts/plot_summary") CONFIG_FILES="$CONFIG_FILES scripts/plot_summary" ;;
"scripts/summary") CONFIG_FILES="$CONFIG_FILES scripts/summary" ;;
- "scripts/build/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/build/Makefile" ;;
+ "scripts/update-leap/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/update-leap/Makefile" ;;
"tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
"tests/libntp/Makefile") CONFIG_FILES="$CONFIG_FILES tests/libntp/Makefile" ;;
"tests/ntpd/Makefile") CONFIG_FILES="$CONFIG_FILES tests/ntpd/Makefile" ;;
@@ -39254,8 +39317,8 @@ _LT_EOF
;;
"ntpd/complete.conf":F) sed -e '/^rlimit$/d' < ntpd/complete.conf > ntpd/complete.conf.new && mv ntpd/complete.conf.new ntpd/complete.conf ;;
"ntpdc/nl.pl":F) chmod +x ntpdc/nl.pl ;;
- "scripts/calc_tickadj/calc_tickadj":F) chmod +x scripts/calc_tickadj/calc_tickadj ;;
"scripts/build/mkver":F) chmod +x scripts/build/mkver ;;
+ "scripts/calc_tickadj/calc_tickadj":F) chmod +x scripts/calc_tickadj/calc_tickadj ;;
"scripts/ntp-wait/ntp-wait":F) chmod +x scripts/ntp-wait/ntp-wait ;;
"scripts/ntpsweep/ntpsweep":F) chmod +x scripts/ntpsweep/ntpsweep ;;
"scripts/ntptrace/ntptrace":F) chmod +x scripts/ntptrace/ntptrace ;;
diff --git a/contrib/ntp/configure.ac b/contrib/ntp/configure.ac
index 6942ceb..dc5c7fc 100644
--- a/contrib/ntp/configure.ac
+++ b/contrib/ntp/configure.ac
@@ -68,6 +68,7 @@ AC_PROG_CPP
AC_PROG_CXX
AC_PROG_YACC
AC_PROG_CC_C_O
+AX_C99_STRUCT_INIT
NTP_VPATH_HACK dnl used only by ntpd/Makefile.am
@@ -1499,12 +1500,13 @@ AC_CACHE_CHECK(
;;
*)
AC_PREPROC_IFELSE(
- [
- #include <sys/syscall.h>
- #if !defined(SYS_ntp_gettime) || !defined(SYS_ntp_adjtime)
- # error
- #endif
- ],
+ [AC_LANG_SOURCE(
+ [
+ #include <sys/syscall.h>
+ #if !defined(SYS_ntp_gettime) || !defined(SYS_ntp_adjtime)
+ # error
+ #endif
+ ])],
[ntp_cv_var_ntp_syscalls=kernel]
)
;;
@@ -1526,12 +1528,13 @@ AC_CACHE_CHECK(
[if sys/timex.h has STA_FLL],
[ntp_cv_var_sta_fll],
[AC_PREPROC_IFELSE(
- [
- #include <sys/timex.h>
- #ifndef STA_FLL
- # error
- #endif
- ],
+ [AC_LANG_SOURCE(
+ [
+ #include <sys/timex.h>
+ #ifndef STA_FLL
+ # error
+ #endif
+ ])],
[ntp_cv_var_sta_fll=yes],
[ntp_cv_var_sta_fll=no]
)]
@@ -1586,12 +1589,12 @@ AC_MSG_CHECKING([for TTY PPS ioctl TIOCGPPSEV])
case "$ac_cv_header_termios_h" in
yes)
AC_PREPROC_IFELSE(
- [
+ [AC_LANG_SOURCE([
#include <termios.h>
#ifndef TIOCGPPSEV
# error
#endif
- ],
+ ])],
[ntp_ok=yes],
[ntp_ok=no]
)
@@ -1612,12 +1615,12 @@ AC_MSG_CHECKING([for TTY PPS ioctl TIOCSPPS])
case "$ac_cv_header_termios_h" in
yes)
AC_PREPROC_IFELSE(
- [
+ [AC_LANG_SOURCE([
#include <termios.h>
#ifndef TIOCSPPS
# error
#endif
- ],
+ ])],
[ntp_ok=yes],
[ntp_ok=no]
)
@@ -1638,12 +1641,12 @@ AC_MSG_CHECKING([for TTY PPS ioctl CIOGETEV])
case "$ac_cv_header_sys_ppsclock_h" in
yes)
AC_PREPROC_IFELSE(
- [
+ [AC_LANG_SOURCE([
#include <sys/ppsclock.h>
#ifndef CIOGETEV
# error
#endif
- ],
+ ])],
[ntp_ok=yes],
[ntp_ok=no]
)
@@ -1689,7 +1692,7 @@ case "$ac_cv_header_sys_ppsclock_h$ac_cv_header_linux_serial_h" in
yesyes)
AC_MSG_CHECKING([ioctl TIOCGSERIAL, TIOCSSERIAL, ASYNC_PPS_CD_POS, ASYNC_PPS_CD_NEG])
AC_PREPROC_IFELSE(
- [
+ [AC_LANG_SOURCE([
#include <sys/time.h>
typedef int u_int;
#include <sys/ppsclock.h>
@@ -1710,7 +1713,7 @@ case "$ac_cv_header_sys_ppsclock_h$ac_cv_header_linux_serial_h" in
#ifndef CIOGETEV
# error
#endif
- ],
+ ])],
[ntp_ok=yes],
[ntp_ok=no]
)
@@ -4193,7 +4196,6 @@ case "$ans" in
esac
AC_MSG_CHECKING([if we should enable NIST lockclock scheme])
-
AC_ARG_ENABLE(
[nist],
[AS_HELP_STRING(
@@ -4213,7 +4215,6 @@ case "$ans" in
esac
AC_MSG_CHECKING([if we want support for Samba's signing daemon])
-
AC_ARG_ENABLE(
[ntp-signd],
[AS_HELP_STRING(
@@ -4266,14 +4267,14 @@ AC_CACHE_CHECK(
[for interface list sysctl],
[ntp_cv_iflist_sysctl],
[AC_PREPROC_IFELSE(
- [
+ [AC_LANG_SOURCE([
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/socket.h>
#ifndef NET_RT_IFLIST
# error
#endif
- ],
+ ])],
[ntp_cv_iflist_sysctl=yes],
[ntp_cv_iflist_sysctl=no]
)]
@@ -4333,20 +4334,21 @@ AC_CONFIG_FILES([ntpq/Makefile])
AC_CONFIG_FILES([ntpsnmpd/Makefile])
AC_CONFIG_FILES([parseutil/Makefile])
AC_CONFIG_FILES([scripts/Makefile])
-AC_CONFIG_FILES([scripts/lib/Makefile])
-AC_CONFIG_FILES([scripts/calc_tickadj/calc_tickadj], [chmod +x scripts/calc_tickadj/calc_tickadj])
-AC_CONFIG_FILES([scripts/calc_tickadj/Makefile])
+AC_CONFIG_FILES([scripts/build/Makefile])
AC_CONFIG_FILES([scripts/build/mkver], [chmod +x scripts/build/mkver])
-AC_CONFIG_FILES([scripts/ntp-wait/ntp-wait], [chmod +x scripts/ntp-wait/ntp-wait])
+AC_CONFIG_FILES([scripts/calc_tickadj/Makefile])
+AC_CONFIG_FILES([scripts/calc_tickadj/calc_tickadj], [chmod +x scripts/calc_tickadj/calc_tickadj])
+AC_CONFIG_FILES([scripts/lib/Makefile])
AC_CONFIG_FILES([scripts/ntp-wait/Makefile])
-AC_CONFIG_FILES([scripts/ntpsweep/ntpsweep], [chmod +x scripts/ntpsweep/ntpsweep])
+AC_CONFIG_FILES([scripts/ntp-wait/ntp-wait], [chmod +x scripts/ntp-wait/ntp-wait])
AC_CONFIG_FILES([scripts/ntpsweep/Makefile])
-AC_CONFIG_FILES([scripts/ntptrace/ntptrace], [chmod +x scripts/ntptrace/ntptrace])
+AC_CONFIG_FILES([scripts/ntpsweep/ntpsweep], [chmod +x scripts/ntpsweep/ntpsweep])
AC_CONFIG_FILES([scripts/ntptrace/Makefile])
+AC_CONFIG_FILES([scripts/ntptrace/ntptrace], [chmod +x scripts/ntptrace/ntptrace])
AC_CONFIG_FILES([scripts/ntpver], [chmod +x scripts/ntpver])
AC_CONFIG_FILES([scripts/plot_summary], [chmod +x scripts/plot_summary])
AC_CONFIG_FILES([scripts/summary], [chmod +x scripts/summary])
-AC_CONFIG_FILES([scripts/build/Makefile])
+AC_CONFIG_FILES([scripts/update-leap/Makefile])
AC_CONFIG_FILES([tests/Makefile])
AC_CONFIG_FILES([tests/libntp/Makefile])
AC_CONFIG_FILES([tests/ntpd/Makefile])
diff --git a/contrib/ntp/html/build.html b/contrib/ntp/html/build.html
index 9683b29..5e3c2d8 100644
--- a/contrib/ntp/html/build.html
+++ b/contrib/ntp/html/build.html
@@ -11,7 +11,7 @@
<img src="pic/beaver.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html">from <i>Pogo</i>, Walt Kelly</a>
<p>For putting out compiler fires.</p>
<p>Last update:
- <!-- #BeginDate format:En2m -->31-Mar-2014 05:39<!-- #EndDate -->
+ <!-- #BeginDate format:En2m -->1-Apr-2015 02:57<!-- #EndDate -->
</p>
<br clear="left">
<h4>Related Links</h4>
@@ -27,7 +27,7 @@
</ul>
<hr>
<h4 id="build">Building and Installing the Distribution</h4>
-<p>It is not possible in a software distribution such as this to support every individual computer and operating system with a common executable, even with the same system but different versions and options. Therefore, it is necessary to configure, build and install for each system and version. In almost all cases, these procedures are completely automatic, The user types <tt>./configure</tt>, <tt>make</tt> and <tt>install</tt> in that order and the autoconfigure system does the rest. There are some exceptions, as noted below and on the <a href="hints.html">Hints and Kinks</a> pages.</p>
+<p>It is not possible in a software distribution such as this to support every individual computer and operating system with a common executable, even with the same system but different versions and options. Therefore, it is necessary to configure, build and install for each system and version. In almost all cases, these procedures are completely automatic, The user types <tt>./configure</tt>, and <tt>make install</tt> in that order and the autoconfigure system does the rest. There are some exceptions, as noted below and on the <a href="hints.html">Hints and Kinks</a> pages.</p>
<p>If available, the OpenSSL library from <a href="http://www.openssl.org">http://www.openssl.org</a> is used to support public key cryptography. The library must be built and installed prior to building NTP. The procedures for doing that are included in the OpenSSL documentation. The library is found during the normal NTP configure phase and the interface routines compiled automatically. Only the <tt>libcrypto.a</tt> library file and <tt>openssl</tt> header files are needed. If the library is not available or disabled, this step is not required.</p>
<p>The <a href="config.html">Build Options</a> page describes a number of options that determine whether debug support is included, whether and which reference clock drivers are included and the locations of the executables and library files, if not the default. By default debugging options and all reference clock drivers are included.</p>
<h4 id="unix">Building and Installing for Unix</h4>
diff --git a/contrib/ntp/html/miscopt.html b/contrib/ntp/html/miscopt.html
index 62f41b6..5750d17 100644
--- a/contrib/ntp/html/miscopt.html
+++ b/contrib/ntp/html/miscopt.html
@@ -10,7 +10,7 @@
<img src="pic/boom3.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Pogo</i>, Walt Kelly</a>
<p>We have three, now looking for more.</p>
<p>Last update:
- <!-- #BeginDate format:En2m -->31-Jan-2014 06:54<!-- #EndDate -->
+ <!-- #BeginDate format:En2m -->28-Feb-2015 12:01<!-- #EndDate -->
UTC</p>
<br clear="left">
<h4>Related Links</h4>
@@ -90,7 +90,7 @@
</dl>
</dd>
<dt id="nonvolatile"><tt>nonvolatile <i>threshold</i></tt></dt>
- <dd>Specify the <i><tt>threshold</tt></i> in PPM to write the frequency file, with default 0.1 PPM. The frequency file is inspected each hour. If the difference between the current frequency and the last value written exceeds the threshold, the file is written and the <tt><em>threshold</em></tt> becomes the new threshold value. If the threshold is not exceeded, it is reduced by half. This is intended to reduce the frequency of unnecessary file writes for embedded systems with nonvolatile memory.</dd>
+ <dd>Specify the <i><tt>threshold</tt></i> in seconds to write the frequency file, with default of 1e-7 (0.1 PPM). The frequency file is inspected each hour. If the difference between the current frequency and the last value written exceeds the threshold, the file is written and the <tt><em>threshold</em></tt> becomes the new threshold value. If the threshold is not exceeded, it is reduced by half. This is intended to reduce the frequency of unnecessary file writes for embedded systems with nonvolatile memory.</dd>
<dt id="phone"><tt>phone <i>dial</i> ...</tt></dt>
<dd>This command is used in conjunction with the ACTS modem driver (type 18). The arguments consist of a maximum of 10 telephone numbers used to dial USNO, NIST or European time services. The Hayes command ATDT&nbsp;is normally prepended to the number, which can contain other modem control codes as well.</dd>
<dt id="reset"><tt>reset [allpeers] [auth] [ctl] [io] [mem] [sys] [timer]</tt></dt>
diff --git a/contrib/ntp/html/sntp.html b/contrib/ntp/html/sntp.html
index fa17203..84c6f29 100644
--- a/contrib/ntp/html/sntp.html
+++ b/contrib/ntp/html/sntp.html
@@ -11,7 +11,7 @@
<img src="pic/dogsnake.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
<p>S is for snakeoil.</p>
<p>Last update:
- <!-- #BeginDate format:En2m -->7-Dec-2014 11:09<!-- #EndDate -->
+ <!-- #BeginDate format:En2m -->1-Apr-2015 11:05<!-- #EndDate -->
UTC</p>
<br clear="left">
<hr>
@@ -20,8 +20,8 @@
<h4>Description</h4>
<p>This program is a Simple Network Time Protocol (SNTP) client that can be used to query a Network Time Protocol (NTP) server and display the time offset of the system clock relative to the server clock. Run as root it can correct the system clock to this offset as well. It can be run as an interactive command or from a script by a <tt>cron</tt> job. The program implements the SNTP client protocol defined in RFC 5905, including the full on-wire protocol but does not provide the sanity checks, access controls, security functions and mitigation algorithms as in the full NTP version 4 specification, also defined in RFC 5905.</p>
<p>By default, <tt>sntp</tt> writes the local date and time (i.e., not UTC) to the standard output in the format</p>
-<p><tt>2011-08-04 00:40:36.642222 (+0000) +0.006611 +/- 0.041061 psp-os1 149.20.68.26</tt></p>
-<p>where the <tt>+0.006611 +/- 0.041061</tt> indicates the time offset and error bound of the system clock relative to the server clock, in seconds.</p>
+<p><tt>2011-08-04 00:40:36.642222 (+0000) +0.006611 +/- 0.041061 psp-os1 149.20.68.26 s3 no-leap</tt></p>
+<p>where the <tt>+0.006611 +/- 0.041061</tt> indicates the time offset and error bound of the system clock relative to the server clock, in seconds. The hostname and/or the IP is displayed, as is the stratum of the server. Finally, the leap indicator status is displayed.</p>
<p>If -b <i>bcaddress</i> is not specified, the program sends a single message to each address and waits up to <i>uctimeout</i> (default 5) seconds for a unicast server response. Otherwise, it sends no message and waits up to <i>bctimeout</i> (default 68) seconds for a broadcast NTP message.</p>
<h4>Options</h4>
<p><tt>sntp</tt> recognizes the following options:</p>
diff --git a/contrib/ntp/include/Makefile.in b/contrib/ntp/include/Makefile.in
index 36c9b86..cb21004 100644
--- a/contrib/ntp/include/Makefile.in
+++ b/contrib/ntp/include/Makefile.in
@@ -40,8 +40,7 @@ DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/Makefile.am \
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -70,6 +69,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -327,6 +328,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/include/binio.h b/contrib/ntp/include/binio.h
index d1ee944..cf98633 100644
--- a/contrib/ntp/include/binio.h
+++ b/contrib/ntp/include/binio.h
@@ -42,11 +42,21 @@ void put_lsb_short (unsigned char **, long);
long get_lsb_long (unsigned char **);
void put_lsb_long (unsigned char **, long);
+#define get_lsb_int16( _x_ ) ((int16_t) get_lsb_short( _x_ ))
+#define get_lsb_uint16( _x_ ) ((uint16_t) get_lsb_short( _x_ ))
+#define get_lsb_int32( _x_ ) ((int32_t) get_lsb_long( _x_ ))
+#define get_lsb_uint32( _x_ ) ((uint32_t) get_lsb_long( _x_ ))
+
long get_msb_short (unsigned char **);
void put_msb_short (unsigned char **, long);
long get_msb_long (unsigned char **);
void put_msb_long (unsigned char **, long);
+#define get_msb_int16( _x_ ) ((int16_t) get_msb_short( _x_ ))
+#define get_msb_uint16( _x_ ) ((uint16_t) get_msb_short( _x_ ))
+#define get_msb_int32( _x_ ) ((int32_t) get_msb_long( _x_ ))
+#define get_msb_uint32( _x_ ) ((uint32_t) get_msb_long( _x_ ))
+
#endif
/*
* History:
diff --git a/contrib/ntp/include/isc/Makefile.in b/contrib/ntp/include/isc/Makefile.in
index f29d145..ad0da46 100644
--- a/contrib/ntp/include/isc/Makefile.in
+++ b/contrib/ntp/include/isc/Makefile.in
@@ -40,8 +40,7 @@ DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -70,6 +69,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -289,6 +290,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/include/mbg_gps166.h b/contrib/ntp/include/mbg_gps166.h
index 974deba..b9b3d77 100644
--- a/contrib/ntp/include/mbg_gps166.h
+++ b/contrib/ntp/include/mbg_gps166.h
@@ -39,206 +39,459 @@
#define MBG_GPS166_H
-/***************************************************************************/
-/* */
-/* File: GPSSERIO.H 4.1 */
-/* */
-/* Project: Common C Library */
-/* */
-/* Compiler: Borland C++ */
-/* */
-/* Author: M. Burnicki, Meinberg Funkuhren */
-/* */
-/* */
-/* Description: */
-/* This file defines structures and codes to be used to access GPS166 */
-/* via its serial interface COM0. COM0 should be set to a high baud */
-/* rate, default is 19200. */
-/* */
-/* Standard GPS166 serial operation is to send a time string that is */
-/* compatible with Meinberg UA31 or PZF535 DCF77 radio remote clocks. */
-/* That string can be transmitted automatically once per second, once */
-/* per minute or on request per ASCII '?'. */
-/* */
-/* Parameter setup or parameter readout works using blocks of binary */
-/* data which have to be isolated from the standard string. A block of */
-/* data starts with a SOH code (ASCII Start Of Header, 0x01) followed */
-/* by a message header with constant length and a data portion with */
-/* variable length. The first field (cmd) of the message header holds */
-/* the command code rsp. the type of data to be transmitted. The next */
-/* field (len) gives the number of data bytes that are transmitted */
-/* after the header. This number ranges from 0 to sizeof( MSG_DATA ). */
-/* The third field (data_csum) holds a checksum of all data bytes and */
-/* the last field of the header finally holds the checksum of the. */
-/* header. */
-/* */
-/***************************************************************************/
-
-/* the control codes defined below are to be or'ed with a command/type code */
-
-#define GPS_REQACK 0x8000 /* to GPS166: request acknowledge */
-#define GPS_ACK 0x4000 /* from GPS166: acknowledge a command */
-#define GPS_NACK 0x2000 /* from GPS166: error receiving command */
-
-#define GPS_CTRL_MSK 0xF000 /* masks control code from command */
-
-
-/* The codes below specify commands/types of data to be supplied to GPS166: */
-
-/* GPS166 auto-message to host */
-/* þ host request, GPS166 response */
-/* þ þ host download to GPS166 */
-/* þ þ þ */
-enum { /* þ þ þ */
- /* system data */
- GPS_AUTO_ON = 0x000, /* þ þ þ X þ enable auto-messages from GPS166 */
- GPS_AUTO_OFF, /* þ þ þ X þ disable auto-messages from GPS166 */
- GPS_SW_REV, /* þ þ X þ þ request software revision */
- GPS_STAT, /* þ þ X þ þ request status of buffered variables */
- GPS_TIME, /* þ X þ þ X þ current time or capture or init board time */
- GPS_POS_XYZ, /* þ þ X þ X þ current position in ECEF coords */
- GPS_POS_LLA, /* þ þ X þ X þ current position in geographic coords */
- GPS_TZDL, /* þ þ X þ X þ time zone / daylight saving */
- GPS_PORT_PARM, /* þ þ X þ X þ parameters of the serial ports */
- GPS_SYNTH, /* þ þ X þ X þ synthesizer's frequency and phase */
- GPS_ANT_INFO, /* þ X þ X þ þ time diff after antenna disconnect */
- GPS_UCAP, /* þ X þ X þ þ user capture */
+/***************************************************************************
+ *
+ * Definitions taken from Meinberg's gpsserio.h and gpsdefs.h files.
+ *
+ * Author: Martin Burnicki, Meinberg Funkuhren
+ *
+ * Copyright (c) Meinberg Funkuhren, Bad Pyrmont, Germany
+ *
+ * Description:
+ * Structures and codes to be used to access Meinberg GPS clocks via
+ * their serial interface COM0. COM0 should be set to a high baud rate,
+ * default is 19200.
+ *
+ * Standard Meinberg GPS serial operation is to send the Meinberg
+ * standard time string automatically once per second, once per
+ * minute, or on request per ASCII '?'.
+ *
+ * GPS parameter setup or parameter readout uses blocks of binary
+ * data which have to be isolated from the standard string. A block
+ * of data starts with a SOH code (ASCII Start Of Header, 0x01)
+ * followed by a message header with constant length and a block of
+ * data with variable length.
+ *
+ * The first field (cmd) of the message header holds the command
+ * code resp. the type of data to be transmitted. The next field (len)
+ * gives the number of data bytes that follow the header. This number
+ * ranges from 0 to sizeof( MSG_DATA ). The third field (data_csum)
+ * holds a checksum of all data bytes and the last field of the header
+ * finally holds the checksum of the header itself.
+ *
+ ***************************************************************************/
+
+/**
+ * @brief GPS epoch bias from ordinary time_t epoch
+ *
+ * The Unix time_t epoch is usually 1970-01-01 00:00 whereas
+ * the GPS epoch is 1980-01-06 00:00, so the difference is 10 years,
+ * plus 2 days due to leap years (1972 and 1976), plus the difference
+ * of the day-of-month (6 - 1), so:<br>
+ *
+ * time_t t = ( gps_week * ::SECS_PER_WEEK ) + sec_of_week + ::GPS_SEC_BIAS
+ */
+#define GPS_SEC_BIAS 315964800UL // ( ( ( 10UL * 365UL ) + 2 + 5 ) * SECS_PER_DAY )
+
+
+#ifndef _COM_HS_DEFINED
+ /**
+ * @brief Enumeration of handshake modes
+ */
+ enum COM_HANSHAKE_MODES { HS_NONE, HS_XONXOFF, HS_RTSCTS, N_COM_HS };
+ #define _COM_HS_DEFINED
+#endif
+
+#ifndef _COM_PARM_DEFINED
+ /**
+ * @brief A data type to configure a serial port's baud rate
+ *
+ * @see ::MBG_BAUD_RATES
+ */
+ typedef int32_t BAUD_RATE;
+
+ /**
+ * @brief Indices used to identify a parameter in the framing string
+ *
+ * @see ::MBG_FRAMING_STRS
+ */
+ enum MBG_FRAMING_STR_IDXS { F_DBITS, F_PRTY, F_STBITS };
+
+ /**
+ * @brief A structure to store the configuration of a serial port
+ */
+ typedef struct
+ {
+ BAUD_RATE baud_rate; ///< transmission speed, e.g. 19200L, see ::MBG_BAUD_RATES
+ char framing[4]; ///< ASCIIZ framing string, e.g. "8N1" or "7E2", see ::MBG_FRAMING_STRS
+ int16_t handshake; ///< handshake mode, yet only ::HS_NONE supported
+
+ } COM_PARM;
+
+ #define _COM_PARM_DEFINED
+#endif
+
+
+/**
+ * @brief Enumeration of modes supported for time string transmission
+ *
+ * This determines e.g. at which point in time a string starts
+ * to be transmitted via the serial port.
+ * Used with ::PORT_SETTINGS::mode.
+ *
+ * @see ::STR_MODE_MASKS
+ */
+enum STR_MODES
+{
+ STR_ON_REQ, ///< transmission on request by received '?' character only
+ STR_PER_SEC, ///< transmission automatically if second changes
+ STR_PER_MIN, ///< transmission automatically if minute changes
+ STR_AUTO, ///< transmission automatically if required, e.g. on capture event
+ STR_ON_REQ_SEC, ///< transmission if second changes and a request has been received before
+ N_STR_MODE ///< the number of known modes
+};
+
+
+/**
+ * The number of serial ports which are at least available
+ * even with very old GPS receiver models. For devices providing
+ * a ::RECEIVER_INFO structure the number of provided COM ports
+ * is available in ::RECEIVER_INFO::n_com_ports.
+ */
+#define DEFAULT_N_COM 2
+
+
+/**
+ * @brief A The structure used to store the configuration of two serial ports
+ *
+ * @deprecated This structure is deprecated, ::PORT_SETTINGS and related structures
+ * should be used instead, if supported by the device.
+ */
+typedef struct
+{
+ COM_PARM com[DEFAULT_N_COM]; ///< COM0 and COM1 settings
+ uint8_t mode[DEFAULT_N_COM]; ///< COM0 and COM1 output mode
+
+} PORT_PARM;
+
+
+/**
+ * @brief The type of a GPS command code
+ *
+ * @see ::GPS_CMD_CODES
+ */
+typedef uint16_t GPS_CMD;
+
+
+/**
+ * @brief Control codes to be or'ed with a particular command/type code
+ */
+enum GPS_CMD_CTRL_CODES
+{
+ GPS_REQACK = 0x8000, ///< to device: request acknowledge
+ GPS_ACK = 0x4000, ///< from device: acknowledge a command
+ GPS_NACK = 0x2000, ///< from device: error evaluating a command
+};
+
+#define GPS_CTRL_MSK 0xF000 ///< bit mask of all ::GPS_CMD_CTRL_CODES
+
+
+/**
+ * @brief Command codes for the binary protocol
+ *
+ * These codes specify commands and associated data types used by Meinberg's
+ * binary protocol to exchange data with a device via serial port, direct USB,
+ * or socket I/O.
+ *
+ * Some commands and associated data structures can be read (r) from a device, others
+ * can be written (w) to the device, and some can also be sent automatically (a) by
+ * a device after a ::GPS_AUTO_ON command has been sent to the device.
+ * The individual command codes are marked with (rwa) accordingly, where '-' is used
+ * to indicate that a particular mode is not supported.
+ *
+ * @note Not all command code are supported by all devices.
+ * See the hints for a particular command.
+ *
+ * @note If ::GPS_ALM, ::GPS_EPH or a code named ..._IDX is sent to retrieve
+ * some data from a device then an uint16_t parameter must be also supplied
+ * in order to specify the index number of the data set to be returned.
+ * The valid index range depends on the command code.
+ * For ::GPS_ALM and ::GPS_EPH the index is the SV number which may be 0 or
+ * ::MIN_SVNO_GPS to ::MAX_SVNO_GPS. If the number is 0 then all ::N_SVNO_GPS
+ * almanacs or ephemeris data structures are returned.
+ *
+ * @see ::GPS_CMD_CODES_TABLE
+ */
+enum GPS_CMD_CODES
+{ /* system data */
+ GPS_AUTO_ON = 0x000, ///< (-w-) no data, enable auto-msgs from device
+ GPS_AUTO_OFF, ///< (-w-) no data, disable auto-msgs from device
+ GPS_SW_REV, ///< (r--) deprecated, ::SW_REV, software revision, use only if ::GPS_RECEIVER_INFO not supp.
+ GPS_BVAR_STAT, ///< (r--) ::BVAR_STAT, status of buffered variables, only if ::GPS_MODEL_HAS_BVAR_STAT
+ GPS_TIME, ///< (-wa) ::TTM, current time or capture, or init board time
+ GPS_POS_XYZ, ///< (rw-) ::XYZ, current position in ECEF coordinates, only if ::GPS_MODEL_HAS_POS_XYZ
+ GPS_POS_LLA, ///< (rw-) ::LLA, current position in geographic coordinates, only if ::GPS_MODEL_HAS_POS_LLA
+ GPS_TZDL, ///< (rw-) ::TZDL, time zone / daylight saving, only if ::GPS_MODEL_HAS_TZDL
+ GPS_PORT_PARM, ///< (rw-) deprecated, ::PORT_PARM, use ::PORT_SETTINGS etc. if ::GPS_RECEIVER_INFO supported
+ GPS_SYNTH, ///< (rw-) ::SYNTH, synthesizer settings, only if ::GPS_HAS_SYNTH
+ GPS_ANT_INFO, ///< (r-a) ::ANT_INFO, time diff after antenna disconnect, only if ::GPS_MODEL_HAS_ANT_INFO
+ GPS_UCAP, ///< (r-a) ::TTM, user capture events, only if ::RECEIVER_INFO::n_ucaps > 0
/* GPS data */
- GPS_CFGH = 0x100, /* þ þ X þ X þ SVs' configuration and health codes */
- GPS_ALM, /* þ þ X þ X þ one SV's almanac */
- GPS_EPH, /* þ þ X þ X þ one SV's ephemeris */
- GPS_UTC, /* þ þ X þ X þ UTC correction parameters */
- GPS_IONO, /* þ þ X þ X þ ionospheric correction parameters */
- GPS_ASCII_MSG /* þ þ X þ þ the GPS ASCII message */
+ GPS_CFGH = 0x100, ///< (rw-) ::CFGH, SVs' configuration and health codes
+ GPS_ALM, ///< (rw-) req: uint16_t SV num, ::SV_ALM, one SV's almanac
+ GPS_EPH, ///< (rw-) req: uint16_t SV num, ::SV_EPH, one SV's ephemeris
+ GPS_UTC, ///< (rw-) ::UTC, GPS %UTC correction parameters
+ GPS_IONO, ///< (rw-) ::IONO, GPS ionospheric correction parameters
+ GPS_ASCII_MSG ///< (r--) ::ASCII_MSG, the GPS ASCII message
};
-/*
- * modelled after GPSDEFS.H Revision 1.5
- */
-/***************************************************************************/
-/* */
-/* File: GPSDEFS.H 4.1 */
-/* */
-/* Project: Common C Library */
-/* */
-/* Compiler: Borland C++ */
-/* */
-/* Author: M. Burnicki, Meinberg Funkuhren */
-/* */
-/* */
-/* Description: */
-/* General definitions to be used with GPS166 */
-/* GPS166 Rev. 1.23 or above */
-/* */
-/* Modifications: see file GPSLIB.TXT */
-/* */
-/***************************************************************************/
-#define _GPSDEFS_H
-/* the type of various checksums */
#ifndef _CSUM_DEFINED
- typedef unsigned short CSUM;
-# define _CSUM_DEFINED
+ typedef uint16_t CSUM; /* checksum used by some structures stored in non-volatile memory */
+ #define _CSUM_DEFINED
#endif
-/* the message header */
-typedef struct {
- unsigned short gps_cmd;
- unsigned short gps_len;
- unsigned short gps_data_csum;
- unsigned short gps_hdr_csum;
+/**
+ * @brief The header of a binary message.
+ */
+typedef struct
+{
+ GPS_CMD cmd; ///< see ::GPS_CMD_CODES
+ uint16_t len; ///< length of the data portion appended after the header
+ CSUM data_csum; ///< checksum of the data portion appended after the header
+ CSUM hdr_csum; ///< checksum of the preceding header bytes
+
} GPS_MSG_HDR;
-/* a struct used to hold the software revision information */
-typedef struct {
- unsigned short code; /* e.g. 0x0120 means rev. 1.20 */
- unsigned char name[17]; /* used to identify customized versions */
+#define GPS_ID_STR_LEN 16
+#define GPS_ID_STR_SIZE ( GPS_ID_STR_LEN + 1 )
+
+/**
+ * @brief Software revision information
+ *
+ * Contains a software revision code, plus an optional
+ * identifier for a customized version.
+ */
+typedef struct
+{
+ uint16_t code; ///< Version number, e.g. 0x0120 means v1.20
+ char name[GPS_ID_STR_SIZE]; ///< Optional string identifying a customized version
+ uint8_t reserved; ///< Reserved field to yield even structure size
+
} SW_REV;
-/* GPS ASCII message */
-typedef struct {
- CSUM csum; /* checksum of the remaining bytes */
- short valid; /* flag data are valid */
- char s[23]; /* 22 chars GPS ASCII message plus trailing zero */
-} ASCII_MSG;
+/**
+ * @brief GNSS satellite numbers
+ *
+ * @todo: Check if MAX_SVNO_GLN is 94 instead of 95, and thus
+ * N_SVNO_GLN is 30 instead of 31, as reported by Wikipedia.
+ */
+enum GNSS_SVNOS
+{
+ MIN_SVNO_GPS = 1, ///< min. GPS satellite PRN number
+ MAX_SVNO_GPS = 32, ///< max. GPS satellite PRN number
+ N_SVNO_GPS = 32, ///< max. number of active GPS satellites
+
+ MIN_SVNO_WAAS = 33, ///< min. WAAS satellite number
+ MAX_SVNO_WAAS = 64, ///< max. WAAS satellite number
+ N_SVNO_WAAS = 32, ///< max. number of active WAAS satellites
+
+ MIN_SVNO_GLONASS = 65, ///< min. Glonass satellite number (64 + sat slot ID)
+ MAX_SVNO_GLONASS = 95, ///< max. Glonass satellite number (64 + sat slot ID)
+ N_SVNO_GLONASS = 31 ///< max. number of active Glonass satellites
+};
+
+
+typedef uint16_t SVNO; ///< the number of an SV (Space Vehicle, i.e. satellite)
+typedef uint16_t HEALTH; ///< an SV's 6 bit health code
+typedef uint16_t CFG; ///< an SV's 4 bit configuration code
+typedef uint16_t IOD; ///< Issue-Of-Data code
+
+
+/**
+ * @brief Status flags of battery buffered data
+ *
+ * Related to data received from the satellites, or data derived thereof.
+ *
+ * All '0' means OK, single bits set to '1' indicate
+ * the associated type of GPS data is not available.
+ *
+ * @see ::BVAR_FLAGS
+ */
+typedef uint16_t BVAR_STAT;
+
+#define _mbg_swab_bvar_stat( _p ) _mbg_swab16( (_p) )
-#define MIN_SVNO 1 /* min. SV number */
-#define MAX_SVNO 32 /* max. SV number */
-#define N_SVNO ( MAX_SVNO - MIN_SVNO + 1) /* number of possibly active SVs */
+/**
+ * @brief Enumeration of flag bits used to define ::BVAR_FLAGS
+ *
+ * For each bit which is set this means the associated data set in
+ * non-volatile memory is not available, or incomplete.
+ * Most data sets will just be re-collected from the data streams sent
+ * by the satellites. However, the receiver position has usually been
+ * computed earlier during normal operation, and will be re-computed
+ * when a sufficient number of satellites can be received.
+ *
+ * @see ::BVAR_STAT
+ * @see ::BVAR_FLAGS
+ * @see ::BVAR_FLAG_NAMES
+ */
+enum BVAR_FLAG_BITS
+{
+ BVAR_BIT_CFGH_INVALID, ///< Satellite configuration and health parameters incomplete
+ BVAR_BIT_ALM_NOT_COMPLETE, ///< Almanac parameters incomplete
+ BVAR_BIT_UTC_INVALID, ///< %UTC offset parameters incomplete
+ BVAR_BIT_IONO_INVALID, ///< Ionospheric correction parameters incomplete
+ BVAR_BIT_RCVR_POS_INVALID, ///< No valid receiver position available
+ N_BVAR_BIT ///< number of defined ::BVAR_STAT bits
+};
+
+
+/**
+ * @brief Bit masks associated with ::BVAR_FLAG_BITS
+ *
+ * Used with ::BVAR_STAT.
+ *
+ * @see ::BVAR_STAT
+ * @see ::BVAR_FLAG_BITS
+ * @see ::BVAR_FLAG_NAMES
+ */
+enum BVAR_FLAGS
+{
+ BVAR_CFGH_INVALID = ( 1UL << BVAR_BIT_CFGH_INVALID ), ///< see ::BVAR_BIT_CFGH_INVALID
+ BVAR_ALM_NOT_COMPLETE = ( 1UL << BVAR_BIT_ALM_NOT_COMPLETE ), ///< see ::BVAR_BIT_ALM_NOT_COMPLETE
+ BVAR_UTC_INVALID = ( 1UL << BVAR_BIT_UTC_INVALID ), ///< see ::BVAR_BIT_UTC_INVALID
+ BVAR_IONO_INVALID = ( 1UL << BVAR_BIT_IONO_INVALID ), ///< see ::BVAR_BIT_IONO_INVALID
+ BVAR_RCVR_POS_INVALID = ( 1UL << BVAR_BIT_RCVR_POS_INVALID ), ///< see ::BVAR_BIT_RCVR_POS_INVALID
+};
-typedef short SVNO; /* the number of a SV */
-typedef unsigned short HEALTH; /* a SV's health code */
-typedef unsigned short CFG; /* a SV's configuration code */
-typedef unsigned short IOD; /* Issue-Of-Data code */
-/* Date and time referred to the linear time scale defined by GPS. */
-/* GPS time is defined by the number of weeks since midnight from */
-/* January 5, 1980 to January 6, 1980 plus the number of seconds of */
-/* the current week plus fractions of a second. GPS time differs from */
-/* UTC because UTC is corrected with leap seconds while GPS time scale */
-/* is continuous. */
+/**
+ * @brief A structure used to hold time in GPS format
+ *
+ * Date and time refer to the linear time scale defined by GPS, with
+ * the epoch starting at %UTC midnight at the beginning of January 6, 1980.
+ *
+ * GPS time is counted by the week numbers since the epoch, plus second
+ * of the week, plus fraction of the second. The week number transmitted
+ * by the satellites rolls over from 1023 to 0, but Meinberg devices
+ * just continue to count the weeks beyond the 1024 week limit to keep
+ * the receiver's internal time.
+ *
+ * %UTC time differs from GPS time since a number of leap seconds have
+ * been inserted in the %UTC time scale after the GPS epoche. The number
+ * of leap seconds is disseminated by the satellites using the ::UTC
+ * parameter set, which also provides info on pending leap seconds.
+ */
+typedef struct
+{
+ uint16_t wn; ///< the week number since GPS has been installed
+ uint32_t sec; ///< the second of that week
+ uint32_t tick; ///< fractions of a second, 1/::RECEIVER_INFO::ticks_per_sec units
-typedef struct {
- unsigned short wn; /* the week number since GPS has been installed */
- unsigned long sec; /* the second of that week */
- unsigned long tick; /* fractions of a second; scale: 1E-7 */
} T_GPS;
-/* Local date and time computed from GPS time. The current number */
-/* of leap seconds have to be added to get UTC from GPS time. */
-/* Additional corrections could have been made according to the */
-/* time zone/daylight saving parameters (TZDL, see below) defined */
-/* by the user. The status field can be checked to see which corrections */
-/* have been applied. */
-
-#ifndef GPS166_TM_DEFINED
- typedef struct {
- short year; /* 0..9999 */
- char month; /* 1..12 */
- char mday; /* 1..31 */
- short yday; /* 1..366 */
- char wday; /* 0..6 == Sun..Sat */
- char hour; /* 0..23 */
- char minute; /* 0..59 */
- char second; /* 0..59 */
- long frac; /* fractions of a second, scale 1E-7 */
- long offs_from_utc; /* local time's offset from UTC */
- unsigned short status; /* flags */
- } TM;
-
- /* status flags used with conversion from GPS time to local time */
-
-# define TM_UTC 0x01 /* UTC correction has been made */
-# define TM_LOCAL 0x02 /* UTC has been converted to local time */
-# define TM_DL_ANN 0x04 /* state of daylight saving is going to change */
-# define TM_DL_ENB 0x08 /* daylight saving is enabled */
-# define TM_LS_ANN 0x10 /* leap second will be inserted */
-# define TM_LS_ENB 0x20 /* current second is leap second */
-
-# define GPS166_TM_DEFINED
-#endif
+/**
+ * @brief Local date and time computed from GPS time
+ *
+ * The current number of leap seconds have to be added to get %UTC
+ * from GPS time. Additional corrections could have been made according
+ * to the time zone/daylight saving parameters ::TZDL defined by the user.
+ * The status field can be checked to see which corrections
+ * have actually been applied.
+ *
+ * @note Conversion from GPS time to %UTC and/or local time can only be
+ * done if some valid ::UTC correction parameters are available in the
+ * receiver's non-volatile memory.
+ */
+typedef struct
+{
+ int16_t year; ///< year number, 0..9999
+ int8_t month; ///< month, 1..12
+ int8_t mday; ///< day of month, 1..31
+ int16_t yday; ///< day of year, 1..365, or 366 in case of leap year
+ int8_t wday; ///< day of week, 0..6 == Sun..Sat
+ int8_t hour; ///< hours, 0..23
+ int8_t min; ///< minutes, 0..59
+ int8_t sec; ///< seconds, 0..59, or 60 in case of inserted leap second
+ int32_t frac; ///< fractions of a second, 1/::RECEIVER_INFO::ticks_per_sec units
+ int32_t offs_from_utc; ///< local time offset from %UTC [sec]
+ uint16_t status; ///< status flags, see ::TM_GPS_STATUS_BIT_MASKS
+
+} TM_GPS;
+
+
+
+/**
+ * @brief Status flag bits used to define ::TM_GPS_STATUS_BIT_MASKS
+ *
+ * These bits report info on the time conversion from GPS time to %UTC
+ * and/or local time as well as device status info.
+ *
+ * @see ::TM_GPS_STATUS_BIT_MASKS
+ */
+enum TM_GPS_STATUS_BITS
+{
+ TM_BIT_UTC, ///< %UTC correction has been made
+ TM_BIT_LOCAL, ///< %UTC has been converted to local time according to ::TZDL settings
+ TM_BIT_DL_ANN, ///< state of daylight saving is going to change
+ TM_BIT_DL_ENB, ///< daylight saving is in effect
+ TM_BIT_LS_ANN, ///< leap second pending
+ TM_BIT_LS_ENB, ///< current second is leap second
+ TM_BIT_LS_ANN_NEG, ///< set in addition to ::TM_BIT_LS_ANN if leap sec is negative
+ TM_BIT_INVT, ///< invalid time, e.g. if RTC battery bas been empty
+
+ TM_BIT_EXT_SYNC, ///< synchronized externally
+ TM_BIT_HOLDOVER, ///< in holdover mode after previous synchronization
+ TM_BIT_ANT_SHORT, ///< antenna cable short circuited
+ TM_BIT_NO_WARM, ///< OCXO has not warmed up
+ TM_BIT_ANT_DISCONN, ///< antenna currently disconnected
+ TM_BIT_SYN_FLAG, ///< TIME_SYN output is low
+ TM_BIT_NO_SYNC, ///< time sync actually not verified
+ TM_BIT_NO_POS ///< position actually not verified, LOCK LED off
+};
-/* the status flags below are defined starting with rev. 1.32 */
+/**
+ * @brief Status flag masks used with ::TM_GPS::status
+ *
+ * These bits report info on the time conversion from GPS time to %UTC
+ * and/or local time as well as device status info.
+ *
+ * @see ::TM_GPS_STATUS_BITS
+ */
+enum TM_GPS_STATUS_BIT_MASKS
+{
+ TM_UTC = ( 1UL << TM_BIT_UTC ), ///< see ::TM_BIT_UTC
+ TM_LOCAL = ( 1UL << TM_BIT_LOCAL ), ///< see ::TM_BIT_LOCAL
+ TM_DL_ANN = ( 1UL << TM_BIT_DL_ANN ), ///< see ::TM_BIT_DL_ANN
+ TM_DL_ENB = ( 1UL << TM_BIT_DL_ENB ), ///< see ::TM_BIT_DL_ENB
+ TM_LS_ANN = ( 1UL << TM_BIT_LS_ANN ), ///< see ::TM_BIT_LS_ANN
+ TM_LS_ENB = ( 1UL << TM_BIT_LS_ENB ), ///< see ::TM_BIT_LS_ENB
+ TM_LS_ANN_NEG = ( 1UL << TM_BIT_LS_ANN_NEG ), ///< see ::TM_BIT_LS_ANN_NEG
+ TM_INVT = ( 1UL << TM_BIT_INVT ), ///< see ::TM_BIT_INVT
+
+ TM_EXT_SYNC = ( 1UL << TM_BIT_EXT_SYNC ), ///< see ::TM_BIT_EXT_SYNC
+ TM_HOLDOVER = ( 1UL << TM_BIT_HOLDOVER ), ///< see ::TM_BIT_HOLDOVER
+ TM_ANT_SHORT = ( 1UL << TM_BIT_ANT_SHORT ), ///< see ::TM_BIT_ANT_SHORT
+ TM_NO_WARM = ( 1UL << TM_BIT_NO_WARM ), ///< see ::TM_BIT_NO_WARM
+ TM_ANT_DISCONN = ( 1UL << TM_BIT_ANT_DISCONN ), ///< see ::TM_BIT_ANT_DISCONN
+ TM_SYN_FLAG = ( 1UL << TM_BIT_SYN_FLAG ), ///< see ::TM_BIT_SYN_FLAG
+ TM_NO_SYNC = ( 1UL << TM_BIT_NO_SYNC ), ///< see ::TM_BIT_NO_SYNC
+ TM_NO_POS = ( 1UL << TM_BIT_NO_POS ) ///< see ::TM_BIT_NO_POS
+};
-#define TM_ANT_DISCONN 0x1000 /* antenna currently disconnected */
-#define TM_SYN_FLAG 0x2000 /* TIME_SYN output is low */
-#define TM_NO_SYNC 0x4000 /* not sync'ed after reset */
-#define TM_NO_POS 0x8000 /* position not computed after reset, */
- /* LOCK LED off */
-/* a struct used to transmit information on date and time */
+/**
+ * @brief A structure used to transmit information on date and time
+ *
+ * This structure can be used to transfer the current time, in which
+ * case the channel field has to be set to -1, or an event capture time
+ * retrieved from the on-board FIFO, in which case the channel field
+ * contains the index of the time capture input, e.g. 0 or 1.
+ */
+typedef struct
+{
+ int16_t channel; ///< -1: the current on-board time; >= 0 the capture channel number
+ T_GPS t; ///< time in GPS scale and format
+ TM_GPS tm; ///< time converted to %UTC and/or local time according to ::TZDL settings
-typedef struct {
- short channel; /* -1: the current time; 0, 1: capture 0, 1 */
- T_GPS t; /* time in GPS format */
- TM tm; /* that time converted to local time */
} TTM;
@@ -249,282 +502,462 @@ typedef struct {
/* to geographic coordinates as defined by WGS84 (World Geodetic */
/* System from 1984). */
-#ifndef _XYZ_DEFINED
- /* sequence and number of components of a cartesian position */
- enum { XP, YP, ZP, N_XYZ };
+/**
+ * @brief Sequence and number of components of a cartesian position
+ */
+enum XYZ_FIELDS { XP, YP, ZP, N_XYZ }; // x, y, z
+
+/**
+ * @brief A position in cartesian coordinates
+ *
+ * Usually earth centered, earth fixed (ECEF) coordinates,
+ * in [m].
+ *
+ * @note In the original code this is an array of double.
+ *
+ * @see ::XYZ_FIELDS
+ */
+typedef l_fp XYZ[N_XYZ];
- /* a type of array holding a cartesian position */
- typedef l_fp XYZ[N_XYZ]; /* values are in [m] */
-# define _XYZ_DEFINED
-#endif
+/**
+ * @brief Sequence and number of components of a geographic position
+ */
+enum LLA_FIELDS { LAT, LON, ALT, N_LLA }; /* latitude, longitude, altitude */
+/**
+ * @brief A geographic position based on latitude, longitude, and altitude
+ *
+ * The geographic position associated to specific cartesian coordinates
+ * depends on the characteristics of the ellipsoid used for the computation,
+ * the so-called geographic datum. GPS uses the WGS84 (World Geodetic System
+ * from 1984) ellipsoid by default.
+ *
+ * lon, lat in [rad], alt in [m]
+ *
+ * @note In the original code this is an array of double.
+ *
+ * @see ::LLA_FIELDS
+ */
+typedef l_fp LLA[N_LLA];
-#ifndef _LLA_DEFINED
- /* sequence and number of components of a geographic position */
- enum { LAT, LON, ALT, N_LLA }; /* latitude, longitude, altitude */
- /* a type of array holding a geographic position */
- typedef l_fp LLA[N_LLA]; /* lon, lat in [rad], alt in [m] */
+/**
+ * @defgroup group_synth Synthesizer parameters
+ *
+ * Synthesizer frequency is expressed as a
+ * four digit decimal number (freq) to be multiplied by 0.1 Hz and an
+ * base 10 exponent (range). If the effective frequency is less than
+ * 10 kHz its phase is synchronized corresponding to the variable phase.
+ * Phase may be in a range from -360 deg to +360 deg with a resolution
+ * of 0.1 deg, so the resulting numbers to be stored are in a range of
+ * -3600 to +3600.
+ *
+ * Example:<br>
+ * Assume the value of freq is 2345 (decimal) and the value of phase is 900.
+ * If range == 0 the effective frequency is 234.5 Hz with a phase of +90 deg.
+ * If range == 1 the synthesizer will generate a 2345 Hz output frequency
+ * and so on.
+ *
+ * Limitations:<br>
+ * If freq == 0 the synthesizer is disabled. If range == 0 the least
+ * significant digit of freq is limited to 0, 3, 5 or 6. The resulting
+ * frequency is shown in the examples below:
+ * - freq == 1230 --> 123.0 Hz
+ * - freq == 1233 --> 123 1/3 Hz (real 1/3 Hz, NOT 123.3 Hz)
+ * - freq == 1235 --> 123.5 Hz
+ * - freq == 1236 --> 123 2/3 Hz (real 2/3 Hz, NOT 123.6 Hz)
+ *
+ * If range == ::MAX_SYNTH_RANGE the value of freq must not exceed 1000, so
+ * the output frequency is limited to 10 MHz (see ::MAX_SYNTH_FREQ_VAL).
+ *
+ * @{ */
-# define _LLA_DEFINED
-#endif
+#define N_SYNTH_FREQ_DIGIT 4 ///< number of digits to edit
+#define MAX_SYNTH_FREQ 1000 ///< if range == ::MAX_SYNTH_RANGE
-/* Synthesizer parameters. Synthesizer frequency is expressed as a */
-/* four digit decimal number (freq) to be multiplied by 0.1 Hz and an */
-/* base 10 exponent (range). If the effective frequency is less than */
-/* 10 kHz its phase is synchronized corresponding to the variable phase. */
-/* Phase may be in a range from -360° to +360° with a resolution of 0.1°, */
-/* so the resulting numbers to be stored are in a range of -3600 to +3600. */
-
-/* Example: */
-/* Assume the value of freq is 2345 (decimal) and the value of phase is 900. */
-/* If range == 0 the effective frequency is 234.5 Hz with a phase of +90°. */
-/* If range == 1 the synthesizer will generate a 2345 Hz output frequency */
-/* and so on. */
-
-/* Limitations: */
-/* If freq == 0 the synthesizer is disabled. If range == 0 the least */
-/* significant digit of freq is limited to 0, 3, 5 or 6. The resulting */
-/* frequency is shown in the examples below: */
-/* freq == 1230 --> 123.0 Hz */
-/* freq == 1233 --> 123 1/3 Hz (real 1/3 Hz, NOT 123.3 Hz) */
-/* freq == 1235 --> 123.5 Hz */
-/* freq == 1236 --> 123 2/3 Hz (real 2/3 Hz, NOT 123.6 Hz) */
-
-/* If range == MAX_RANGE the value of freq must not exceed 1200, so the */
-/* output frequency is limited to 12 MHz. */
-
-/* Phase will be ignored if the resulting frequency is greater or equal */
-/* to 10 kHz. */
-
-#define MAX_SYNTH_FREQ 1200 /* if range == MAX_SYNTH_RANGE */
#define MIN_SYNTH_RANGE 0
#define MAX_SYNTH_RANGE 5
-#define MAX_SYNTH_PHASE 3600
+#define N_SYNTH_RANGE ( MAX_SYNTH_RANGE - MIN_SYNTH_RANGE + 1 )
-typedef struct {
- short freq; /* four digits used; scale: 0.1; e.g. 1234 -> 123.4 Hz */
- short range; /* scale factor for freq; 0..MAX_SYNTH_RANGE */
- short phase; /* -MAX_SYNTH_PHASE..+MAX_SYNTH_PHASE; >0 -> pulses later */
-} SYNTH;
+#define N_SYNTH_PHASE_DIGIT 4
+#define MAX_SYNTH_PHASE 3600
+#define MAX_SYNTH_FREQ_EDIT 9999 ///< max sequence of digits when editing
-/* Time zone/daylight saving parameters. */
-/* the name of a time zone, 5 characters plus trailing zero */
-typedef char TZ_NAME[6];
+/**
+ * @brief The maximum frequency that can be configured for the synthesizer
+ */
+#define MAX_SYNTH_FREQ_VAL 10000000UL ///< 10 MHz
+/* == MAX_SYNTH_FREQ * 10^(MAX_SYNTH_RANGE-1) */
-typedef struct {
- long offs; /* offset from UTC to local time [sec] */
- long offs_dl; /* additional offset if daylight saving enabled [sec] */
- TM tm_on; /* date/time when daylight saving starts */
- TM tm_off; /* date/time when daylight saving ends */
- TZ_NAME name[2]; /* names without and with daylight saving enabled */
-} TZDL;
+/**
+ * @brief The synthesizer's phase is only be synchronized if the frequency is below this limit
+ */
+#define SYNTH_PHASE_SYNC_LIMIT 10000UL ///< 10 kHz
-/* The constant below is defined beginning with software rev. 1.29. */
-/* If the year in tzdl.tmon and tzdl.tm_off is or'ed with that constant, */
-/* the receiver automatically generates daylight saving year by year. */
-/* See GPSLIB.TXT for more information. */
+/**
+ * A Macro used to determine the position of the decimal point
+ * when printing the synthesizer frequency as 4 digit value
+ */
+#define _synth_dp_pos_from_range( _r ) \
+ ( ( ( N_SYNTH_RANGE - (_r) ) % ( N_SYNTH_FREQ_DIGIT - 1 ) ) + 1 )
+
+/**
+ * @brief Synthesizer frequency units
+ *
+ * An initializer for commonly displayed synthesizer frequency units
+ * (::N_SYNTH_RANGE strings)
+ */
+#define DEFAULT_FREQ_RANGES \
+{ \
+ "Hz", \
+ "kHz", \
+ "kHz", \
+ "kHz", \
+ "MHz", \
+ "MHz", \
+}
-#define DL_AUTO_FLAG 0x8000
-/* Example: */
-/* for automatic daylight saving enable/disable in Central Europe, */
-/* the variables are to be set as shown below: */
-/* offs = 3600L one hour from UTC */
-/* offs_dl = 3600L one additional hour if daylight saving enabled */
-/* tm_on = first Sunday from March 25, 02:00:00h ( year |= DL_AUTO_FLAG ) */
-/* tm_off = first Sunday from Sept 24, 03:00:00h ( year |= DL_AUTO_FLAG ) */
-/* name[0] == "MEZ " name if daylight saving not enabled */
-/* name[1] == "MESZ " name if daylight saving is enabled */
+/**
+ * @brief Synthesizer configuration parameters
+ */
+typedef struct
+{
+ int16_t freq; ///< four digits used; scale: 0.1 Hz; e.g. 1234 -> 123.4 Hz
+ int16_t range; ///< scale factor for freq; 0..::MAX_SYNTH_RANGE
+ int16_t phase; ///< -::MAX_SYNTH_PHASE..+::MAX_SYNTH_PHASE; >0 -> pulses later
+} SYNTH;
+#define _mbg_swab_synth( _p ) \
+{ \
+ _mbg_swab16( &(_p)->freq ); \
+ _mbg_swab16( &(_p)->range ); \
+ _mbg_swab16( &(_p)->phase ); \
+}
-/* the structure below was defined in rev. 1.31. It reflects the status */
-/* of the antenna, the times of last disconnect/reconnect and the boards */
-/* clock offset after the phase of disconnection. */
-typedef struct {
- short status; /* current status of antenna */
- TM tm_disconn; /* time of antenna disconnect */
- TM tm_reconn; /* time of antenna reconnect */
- long delta_t; /* clock offset at reconnect time, units: TICKS_PER_SEC */
-} ANT_INFO;
+/**
+ * @brief Enumeration of synthesizer states
+ */
+enum SYNTH_STATES
+{
+ SYNTH_DISABLED, ///< disbled by cfg, i.e. freq == 0.0
+ SYNTH_OFF, ///< not enabled after power-up
+ SYNTH_FREE, ///< enabled, but not synchronized
+ SYNTH_DRIFTING, ///< has initially been sync'd, but now running free
+ SYNTH_SYNC, ///< fully synchronized
+ N_SYNTH_STATE ///< the number of known states
+};
+
+/**
+ * @brief A structure used to report the synthesizer state
+ */
+typedef struct
+{
+ uint8_t state; ///< state code as enumerated in ::SYNTH_STATES
+ uint8_t flags; ///< reserved, currently always 0
-/* the status field may be set to one of the values below: */
+} SYNTH_STATE;
-enum {
- ANT_INVALID, /* struct not set yet because ant. has not been disconn. */
- ANT_DISCONN, /* ant. now disconn., tm_reconn and delta_t not set */
- ANT_RECONN /* ant. has been disconn. and reconn., all fields valid */
-};
+#define _mbg_swab_synth_state( _p ) _nop_macro_fnc()
+#define SYNTH_FLAG_PHASE_IGNORED 0x01
-/* Summary of configuration and health data of all SVs. */
+/** @} defgroup group_synth */
-typedef struct {
- CSUM csum; /* checksum of the remaining bytes */
- short valid; /* flag data are valid */
- T_GPS tot_51; /* time of transmission, page 51 */
- T_GPS tot_63; /* time of transmission, page 63 */
- T_GPS t0a; /* complete reference time almanac */
- CFG cfg[N_SVNO]; /* SV configuration from page 63 */
- HEALTH health[N_SVNO]; /* SV health from pages 51, 63 */
-} CFGH;
+/**
+ * @defgroup group_tzdl Time zone / daylight saving parameters
+ *
+ * Example: <br>
+ * For automatic daylight saving enable/disable in Central Europe,
+ * the variables are to be set as shown below: <br>
+ * - offs = 3600L one hour from %UTC
+ * - offs_dl = 3600L one additional hour if daylight saving enabled
+ * - tm_on = first Sunday from March 25, 02:00:00h ( year |= ::DL_AUTO_FLAG )
+ * - tm_off = first Sunday from October 25, 03:00:00h ( year |= ::DL_AUTO_FLAG )
+ * - name[0] == "CET " name if daylight saving not enabled
+ * - name[1] == "CEST " name if daylight saving is enabled
+ *
+ * @{ */
+
+/**
+ * @brief The name of a time zone
+ *
+ * @note Up to 5 printable characters, plus trailing zero
+ */
+typedef char TZ_NAME[6];
+/**
+ * @brief Time zone / daylight saving parameters
+ *
+ * This structure is used to specify how a device converts on-board %UTC
+ * to local time, including computation of beginning and end of daylight
+ * saving time (DST), if required.
+ *
+ * @note The ::TZDL structure contains members of type ::TM_GPS to specify
+ * the times for beginning and end of DST. However, the ::TM_GPS::frac,
+ * ::TM_GPS::offs_from_utc, and ::TM_GPS::status fields of these ::TZDL::tm_on
+ * and ::TZDL::tm_off members are ignored for the conversion to local time,
+ * and thus should be 0.
+ */
+typedef struct
+{
+ int32_t offs; ///< standard offset from %UTC to local time [sec]
+ int32_t offs_dl; ///< additional offset if daylight saving enabled [sec]
+ TM_GPS tm_on; ///< date/time when daylight saving starts
+ TM_GPS tm_off; ///< date/time when daylight saving ends
+ TZ_NAME name[2]; ///< names without and with daylight saving enabled
+} TZDL;
+
+/**
+ * @brief A flag indicating automatic computation of DST
+ *
+ * If this flag is or'ed to the year numbers in ::TZDL::tm_on and ::TZDL::tm_off
+ * then daylight saving is computed automatically year by year.
+ */
+#define DL_AUTO_FLAG 0x8000
-/* UTC correction parameters */
+/** @} defgroup group_tzdl */
-typedef struct {
- CSUM csum; /* checksum of the remaining bytes */
- short valid; /* flag data are valid */
- T_GPS t0t; /* Reference Time UTC Parameters [sec] */
- l_fp A0; /* ± Clock Correction Coefficient 0 [sec] */
- l_fp A1; /* ± Clock Correction Coefficient 1 [sec/sec] */
- u_short WNlsf; /* week number of nearest leap second */
- short DNt; /* the day number at the end of which LS is inserted */
- char delta_tls; /* */
- char delta_tlsf; /* */
+/**
+ * @brief Antenna status and error at reconnect information
+ *
+ * The structure below reflects the status of the antenna,
+ * the times of last disconnect/reconnect, and the board's
+ * clock offset when it has synchronized again after the
+ * disconnection interval.
+ *
+ * @note ::ANT_INFO::status changes back to ::ANT_RECONN only
+ * after the antenna has been reconnected <b>and</b> the
+ * receiver has re-synchronized to the satellite signal.
+ * In this case ::ANT_INFO::delta_t reports the time offset
+ * before resynchronization, i.e. how much the internal
+ * time has drifted while the antenna was disconnected.
+ */
+typedef struct
+{
+ int16_t status; ///< current status of antenna, see ::ANT_STATUS_CODES
+ TM_GPS tm_disconn; ///< time of antenna disconnect
+ TM_GPS tm_reconn; ///< time of antenna reconnect
+ int32_t delta_t; ///< clock offs at reconn. time in 1/::RECEIVER_INFO::ticks_per_sec units
-} UTC;
+} ANT_INFO;
-/* a struct used to hold the settings of a serial port */
-#ifndef _COM_PARM_DEFINED
- typedef long BAUD_RATE;
+/**
+ * @brief Status code used with ::ANT_INFO::status
+ */
+enum ANT_STATUS_CODES
+{
+ ANT_INVALID, ///< No other fields valid since antenna has not yet been disconnected
+ ANT_DISCONN, ///< Antenna is disconnected, tm_reconn and delta_t not yet set
+ ANT_RECONN, ///< Antenna has been disconnect, and receiver sync. after reconnect, so all fields valid
+ N_ANT_STATUS_CODES ///< the number of known status codes
+};
- /* indices used to identify a parameter in the framing string */
- enum { F_DBITS, F_PRTY, F_STBITS };
- /* types of handshake */
- enum { HS_NONE, HS_XONXOFF, HS_RTSCTS };
- typedef struct {
- BAUD_RATE baud_rate; /* e.g. 19200L */
- char framing[4]; /* e.g. "8N1" */
- short handshake; /* a numeric value, only HS_NONE supported yet */
- } COM_PARM;
+/**
+ * @brief Summary of configuration and health data of all satellites
+ */
+typedef struct
+{
+ CSUM csum; ///< checksum of the remaining bytes
+ int16_t valid; ///< flag data are valid
+
+ T_GPS tot_51; ///< time of transmission, page 51
+ T_GPS tot_63; ///< time of transmission, page 63
+ T_GPS t0a; ///< complete reference time almanac
+
+ CFG cfg[N_SVNO_GPS]; ///< 4 bit SV configuration code from page 63
+ HEALTH health[N_SVNO_GPS]; ///< 6 bit SV health codes from pages 51, 63
+
+} CFGH;
+
-#define _COM_PARM_DEFINED
-#endif
+/**
+ * @brief GPS %UTC correction parameters
+ *
+ * %UTC correction parameters basically as sent by the GPS satellites.
+ *
+ * The csum field is only used by the card's firmware to check the
+ * consistency of the structure in non-volatile memory.
+ *
+ * The field labeled valid indicates if the parameter set is valid, i.e.
+ * if it contains data received from the satellites.
+ *
+ * t0t, A0 and A1 contain fractional correction parameters for the current
+ * GPS-%UTC time offset in addition to the whole seconds. This is evaluated
+ * by the receivers' firmware to convert GPS time to %UTC time.
+ *
+ * The delta_tls field contains the current full seconds offset between
+ * GPS time and %UTC, which corresponds to the number of leap seconds inserted
+ * into the %UTC time scale since GPS was put into operation in January 1980.
+ *
+ * delta_tlfs holds the number of "future" leap seconds, i.e. the %UTC offset
+ * after the next leap second event defined by WNlsf and DNt.
+ *
+ * The fields WNlsf and DNt specify the GPS week number and the day number
+ * in that week for the end of which a leap second has been scheduled.
+ *
+ * @note: The satellites transmit WNlsf only as a signed 8 bit value, so it
+ * can only define a point in time which is +/- 127 weeks off the current time.
+ * The firmware tries to expand this based on the current week number, but
+ * the result is ambiguous if the leap second occurs or occurred more
+ * than 127 weeks in the future or past.
+ *
+ * So the leap second date should <b>only</b> be evaluated and displayed
+ * in a user interface if the fields delta_tls and delta_tlsf have
+ * different values, in which case there is indeed a leap second announcement
+ * inside the +/- 127 week range.
+ *
+ * @note In the original code the type of A0 and A1 is double.
+ */
+typedef struct
+{
+ CSUM csum; ///< Checksum of the remaining bytes
+ int16_t valid; ///< Flag indicating %UTC parameters are valid
+ T_GPS t0t; ///< Reference Time %UTC Parameters [wn|sec]
+ l_fp A0; ///< +- Clock Correction Coefficient 0 [sec]
+ l_fp A1; ///< +- Clock Correction Coefficient 1 [sec/sec]
-/* the codes below define what has to comes out of the serial ports */
+ uint16_t WNlsf; ///< Week number of nearest leap second
+ int16_t DNt; ///< The day number at the end of which a leap second occurs
+ int8_t delta_tls; ///< Current %UTC offset to GPS system time [sec]
+ int8_t delta_tlsf; ///< Future %UTC offset to GPS system time after next leap second transition [sec]
-enum { STR_ON_REQ, STR_PER_SEC,
- STR_PER_MIN, N_STR_MODE_0, /* COM0 and COM1 */
- STR_UCAP = N_STR_MODE_0,
- STR_UCAP_REQ, N_STR_MODE_1 /* COM1 only */
- };
+} UTC;
-#define N_COM 2 /* the number of serial ports */
+/**
+ * @brief GPS ASCII message
+ */
+typedef struct
+{
+ CSUM csum; ///< checksum of the remaining bytes */
+ int16_t valid; ///< flag data are valid
+ char s[23]; ///< 22 chars GPS ASCII message plus trailing zero
-/* the structure used to store the modes of both serial ports */
+} ASCII_MSG;
-typedef struct {
- COM_PARM com[N_COM]; /* COM0 and COM1 settings */
- u_char mode[N_COM]; /* COM0 and COM1 output mode */
-} PORT_PARM;
-/* Ephemeris parameters of one specific SV. Needed to compute the position */
-/* of a satellite at a given time with high precision. Valid for an */
-/* interval of 4 to 6 hours from start of transmission. */
-
-typedef struct {
- CSUM csum; /* checksum of the remaining bytes */
- short valid; /* flag data are valid */
-
- HEALTH health; /* health indication of transmitting SV [---] */
- IOD IODC; /* Issue Of Data, Clock */
- IOD IODE2; /* Issue of Data, Ephemeris (Subframe 2) */
- IOD IODE3; /* Issue of Data, Ephemeris (Subframe 3) */
- T_GPS tt; /* time of transmission */
- T_GPS t0c; /* Reference Time Clock [---] */
- T_GPS t0e; /* Reference Time Ephemeris [---] */
-
- l_fp sqrt_A; /* Square Root of semi-major Axis [sqrt(m)] */
- l_fp e; /* Eccentricity [---] */
- l_fp M0; /* ± Mean Anomaly at Ref. Time [rad] */
- l_fp omega; /* ± Argument of Perigee [rad] */
- l_fp OMEGA0; /* ± Longit. of Asc. Node of orbit plane [rad] */
- l_fp OMEGADOT; /* ± Rate of Right Ascension [rad/sec] */
- l_fp deltan; /* ± Mean Motion Diff. from computed value [rad/sec] */
- l_fp i0; /* ± Inclination Angle [rad] */
- l_fp idot; /* ± Rate of Inclination Angle [rad/sec] */
- l_fp crc; /* ± Cosine Corr. Term to Orbit Radius [m] */
- l_fp crs; /* ± Sine Corr. Term to Orbit Radius [m] */
- l_fp cuc; /* ± Cosine Corr. Term to Arg. of Latitude [rad] */
- l_fp cus; /* ± Sine Corr. Term to Arg. of Latitude [rad] */
- l_fp cic; /* ± Cosine Corr. Term to Inclination Angle [rad] */
- l_fp cis; /* ± Sine Corr. Term to Inclination Angle [rad] */
-
- l_fp af0; /* ± Clock Correction Coefficient 0 [sec] */
- l_fp af1; /* ± Clock Correction Coefficient 1 [sec/sec] */
- l_fp af2; /* ± Clock Correction Coefficient 2 [sec/sec²] */
- l_fp tgd; /* ± estimated group delay differential [sec] */
-
- u_short URA; /* predicted User Range Accuracy */
-
- u_char L2code; /* code on L2 channel [---] */
- u_char L2flag; /* L2 P data flag [---] */
+/**
+ * @brief Ephemeris parameters of one specific satellite
+ *
+ * Needed to compute the position of a satellite at a given time with
+ * high precision. Valid for an interval of 4 to 6 hours from start
+ * of transmission.
+ */
+typedef struct
+{
+ CSUM csum; ///< checksum of the remaining bytes
+ int16_t valid; ///< flag data are valid
+
+ HEALTH health; ///< health indication of transmitting SV [---]
+ IOD IODC; ///< Issue Of Data, Clock
+ IOD IODE2; ///< Issue of Data, Ephemeris (Subframe 2)
+ IOD IODE3; ///< Issue of Data, Ephemeris (Subframe 3)
+ T_GPS tt; ///< time of transmission
+ T_GPS t0c; ///< Reference Time Clock [---]
+ T_GPS t0e; ///< Reference Time Ephemeris [---]
+
+ l_fp sqrt_A; ///< Square Root of semi-major Axis [sqrt(m)]
+ l_fp e; ///< Eccentricity [---]
+ l_fp M0; ///< +- Mean Anomaly at Ref. Time [rad]
+ l_fp omega; ///< +- Argument of Perigee [rad]
+ l_fp OMEGA0; ///< +- Longit. of Asc. Node of orbit plane [rad]
+ l_fp OMEGADOT; ///< +- Rate of Right Ascension [rad/sec]
+ l_fp deltan; ///< +- Mean Motion Diff. from computed value [rad/sec]
+ l_fp i0; ///< +- Inclination Angle [rad]
+ l_fp idot; ///< +- Rate of Inclination Angle [rad/sec]
+ l_fp crc; ///< +- Cosine Corr. Term to Orbit Radius [m]
+ l_fp crs; ///< +- Sine Corr. Term to Orbit Radius [m]
+ l_fp cuc; ///< +- Cosine Corr. Term to Arg. of Latitude [rad]
+ l_fp cus; ///< +- Sine Corr. Term to Arg. of Latitude [rad]
+ l_fp cic; ///< +- Cosine Corr. Term to Inclination Angle [rad]
+ l_fp cis; ///< +- Sine Corr. Term to Inclination Angle [rad]
+
+ l_fp af0; ///< +- Clock Correction Coefficient 0 [sec]
+ l_fp af1; ///< +- Clock Correction Coefficient 1 [sec/sec]
+ l_fp af2; ///< +- Clock Correction Coefficient 2 [sec/sec^2]
+ l_fp tgd; ///< +- estimated group delay differential [sec]
+
+ uint16_t URA; ///< predicted User Range Accuracy
+
+ uint8_t L2code; ///< code on L2 channel [---]
+ uint8_t L2flag; ///< L2 P data flag [---]
} EPH;
-/* Almanac parameters of one specific SV. A reduced precision set of */
-/* parameters used to check if a satellite is in view at a given time. */
-/* Valid for an interval of more than 7 days from start of transmission. */
-typedef struct {
- CSUM csum; /* checksum of the remaining bytes */
- short valid; /* flag data are valid */
- HEALTH health; /* [---] */
- T_GPS t0a; /* Reference Time Almanac [sec] */
+/**
+ * @brief Almanac parameters of one specific satellite
+ *
+ * A reduced precision set of parameters used to check if a satellite
+ * is in view at a given time. Valid for an interval of more than 7 days
+ * from start of transmission.
+ */
+typedef struct
+{
+ CSUM csum; ///< checksum of the remaining bytes
+ int16_t valid; ///< flag data are valid
+
+ HEALTH health; ///< [---]
+ T_GPS t0a; ///< Reference Time Almanac [sec]
+
+ l_fp sqrt_A; ///< Square Root of semi-major Axis [sqrt(m)]
+ l_fp e; ///< Eccentricity [---]
- l_fp sqrt_A; /* Square Root of semi-major Axis [sqrt(m)] */
- l_fp e; /* Eccentricity [---] */
+ l_fp M0; ///< +- Mean Anomaly at Ref. Time [rad]
+ l_fp omega; ///< +- Argument of Perigee [rad]
+ l_fp OMEGA0; ///< +- Longit. of Asc. Node of orbit plane [rad]
+ l_fp OMEGADOT; ///< +- Rate of Right Ascension [rad/sec]
+ l_fp deltai; ///< +- [rad]
+ l_fp af0; ///< +- Clock Correction Coefficient 0 [sec]
+ l_fp af1; ///< +- Clock Correction Coefficient 1 [sec/sec]
- l_fp M0; /* ± Mean Anomaly at Ref. Time [rad] */
- l_fp omega; /* ± Argument of Perigee [rad] */
- l_fp OMEGA0; /* ± Longit. of Asc. Node of orbit plane [rad] */
- l_fp OMEGADOT; /* ± Rate of Right Ascension [rad/sec] */
- l_fp deltai; /* ± [rad] */
- l_fp af0; /* ± Clock Correction Coefficient 0 [sec] */
- l_fp af1; /* ± Clock Correction Coefficient 1 [sec/sec] */
} ALM;
-/* ionospheric correction parameters */
-typedef struct {
- CSUM csum; /* checksum of the remaining bytes */
- short valid; /* flag data are valid */
+/**
+ * @brief Ionospheric correction parameters
+ */
+typedef struct
+{
+ CSUM csum; ///< checksum of the remaining bytes
+ int16_t valid; ///< flag data are valid
- l_fp alpha_0; /* Ionosph. Corr. Coeff. Alpha 0 [sec] */
- l_fp alpha_1; /* Ionosph. Corr. Coeff. Alpha 1 [sec/deg] */
- l_fp alpha_2; /* Ionosph. Corr. Coeff. Alpha 2 [sec/deg^2] */
- l_fp alpha_3; /* Ionosph. Corr. Coeff. Alpha 3 [sec/deg^3] */
+ l_fp alpha_0; ///< Ionosph. Corr. Coeff. Alpha 0 [sec]
+ l_fp alpha_1; ///< Ionosph. Corr. Coeff. Alpha 1 [sec/deg]
+ l_fp alpha_2; ///< Ionosph. Corr. Coeff. Alpha 2 [sec/deg^2]
+ l_fp alpha_3; ///< Ionosph. Corr. Coeff. Alpha 3 [sec/deg^3]
- l_fp beta_0; /* Ionosph. Corr. Coeff. Beta 0 [sec] */
- l_fp beta_1; /* Ionosph. Corr. Coeff. Beta 1 [sec/deg] */
- l_fp beta_2; /* Ionosph. Corr. Coeff. Beta 2 [sec/deg^2] */
- l_fp beta_3; /* Ionosph. Corr. Coeff. Beta 3 [sec/deg^3] */
+ l_fp beta_0; ///< Ionosph. Corr. Coeff. Beta 0 [sec]
+ l_fp beta_1; ///< Ionosph. Corr. Coeff. Beta 1 [sec/deg]
+ l_fp beta_2; ///< Ionosph. Corr. Coeff. Beta 2 [sec/deg^2]
+ l_fp beta_3; ///< Ionosph. Corr. Coeff. Beta 3 [sec/deg^3]
} IONO;
-void mbg_tm_str (char **, TM *, int);
+
+
+void mbg_tm_str (char **, TM_GPS *, int, int);
void mbg_tgps_str (char **, T_GPS *, int);
void get_mbg_header (unsigned char **, GPS_MSG_HDR *);
void put_mbg_header (unsigned char **, GPS_MSG_HDR *);
@@ -534,7 +967,7 @@ void get_mbg_svno (unsigned char **, SVNO *);
void get_mbg_health (unsigned char **, HEALTH *);
void get_mbg_cfg (unsigned char **, CFG *);
void get_mbg_tgps (unsigned char **, T_GPS *);
-void get_mbg_tm (unsigned char **, TM *);
+void get_mbg_tm (unsigned char **, TM_GPS *);
void get_mbg_ttm (unsigned char **, TTM *);
void get_mbg_synth (unsigned char **, SYNTH *);
void get_mbg_tzdl (unsigned char **, TZDL *);
@@ -548,7 +981,7 @@ void get_mbg_eph (unsigned char **, EPH *);
void get_mbg_alm (unsigned char **, ALM *);
void get_mbg_iono (unsigned char **, IONO *);
-unsigned long mbg_csum (unsigned char *, unsigned int);
+CSUM mbg_csum (unsigned char *, unsigned int);
#endif
/*
diff --git a/contrib/ntp/include/ntp.h b/contrib/ntp/include/ntp.h
index 38343f2..4ffc35f 100644
--- a/contrib/ntp/include/ntp.h
+++ b/contrib/ntp/include/ntp.h
@@ -435,7 +435,7 @@ struct peer {
#define STRATUM_UNSPEC ((u_char)16) /* unspecified */
/*
- * Values for peer.flags
+ * Values for peer.flags (u_int)
*/
#define FLAG_CONFIG 0x0001 /* association was configured */
#define FLAG_PREEMPT 0x0002 /* preemptable association */
@@ -453,8 +453,9 @@ struct peer {
#define FLAG_XB 0x2000 /* interleaved broadcast */
#define FLAG_XBOGUS 0x4000 /* interleaved bogus packet */
#ifdef OPENSSL
-#define FLAG_ASSOC 0x8000 /* autokey request */
+# define FLAG_ASSOC 0x8000 /* autokey request */
#endif /* OPENSSL */
+#define FLAG_TSTAMP_PPS 0x10000 /* PPS source provides absolute timestamp */
/*
* Definitions for the clear() routine. We use memset() to clear
@@ -713,17 +714,19 @@ struct pkt {
*/
#define LOOP_DRIFTINIT 1 /* iniitialize frequency */
#define LOOP_KERN_CLEAR 2 /* set initial frequency offset */
-#define LOOP_MAX 3 /* set step offset */
-#define LOOP_PANIC 4 /* set panic offseet */
-#define LOOP_PHI 5 /* set dispersion rate */
-#define LOOP_MINSTEP 6 /* set step timeout */
-#define LOOP_MINPOLL 7 /* set min poll interval (log2 s) */
-#define LOOP_ALLAN 8 /* set minimum Allan intercept */
-#define LOOP_HUFFPUFF 9 /* set huff-n'-puff filter length */
-#define LOOP_FREQ 10 /* set initial frequency */
-#define LOOP_CODEC 11 /* set audio codec frequency */
-#define LOOP_LEAP 12 /* insert leap after second 23:59 */
-#define LOOP_TICK 13 /* sim. low precision clock */
+#define LOOP_MAX 3 /* set both step offsets */
+#define LOOP_MAX_BACK 4 /* set bacward-step offset */
+#define LOOP_MAX_FWD 5 /* set forward-step offset */
+#define LOOP_PANIC 6 /* set panic offseet */
+#define LOOP_PHI 7 /* set dispersion rate */
+#define LOOP_MINSTEP 8 /* set step timeout */
+#define LOOP_MINPOLL 9 /* set min poll interval (log2 s) */
+#define LOOP_ALLAN 10 /* set minimum Allan intercept */
+#define LOOP_HUFFPUFF 11 /* set huff-n'-puff filter length */
+#define LOOP_FREQ 12 /* set initial frequency */
+#define LOOP_CODEC 13 /* set audio codec frequency */
+#define LOOP_LEAP 14 /* insert leap after second 23:59 */
+#define LOOP_TICK 15 /* sim. low precision clock */
/*
* Configuration items for the stats printer
@@ -875,13 +878,13 @@ struct endpoint {
*/
#define AM_ERR -1 /* error */
#define AM_NOMATCH 0 /* no match */
-#define AM_PROCPKT 1 /* server/symmetric packet */
-#define AM_BCST 2 /* broadcast packet */
+#define AM_PROCPKT 1 /* server/symmetric packet */
+#define AM_BCST 2 /* broadcast packet */
#define AM_FXMIT 3 /* client packet */
#define AM_MANYCAST 4 /* manycast or pool */
#define AM_NEWPASS 5 /* new passive */
#define AM_NEWBCL 6 /* new broadcast */
-#define AM_POSSBCL 7 /* discard broadcast */
+#define AM_POSSBCL 7 /* discard broadcast */
/* NetInfo configuration locations */
#ifdef HAVE_NETINFO
diff --git a/contrib/ntp/include/ntp_calendar.h b/contrib/ntp/include/ntp_calendar.h
index 3ee1ff7..3afb627 100644
--- a/contrib/ntp/include/ntp_calendar.h
+++ b/contrib/ntp/include/ntp_calendar.h
@@ -83,13 +83,15 @@ extern systime_func_ptr ntpcal_set_timefunc(systime_func_ptr);
#define SECSPERMIN (60) /* seconds per minute */
#define MINSPERHR (60) /* minutes per hour */
#define HRSPERDAY (24) /* hours per day */
+#define DAYSPERWEEK (7) /* days per week */
#define DAYSPERYEAR (365) /* days per year */
#define SECSPERHR (SECSPERMIN * MINSPERHR)
#define SECSPERDAY (SECSPERHR * HRSPERDAY)
+#define SECSPERWEEK (DAYSPERWEEK * SECSPERDAY)
#define SECSPERYEAR (365 * SECSPERDAY) /* regular year */
#define SECSPERLEAPYEAR (366 * SECSPERDAY) /* leap year */
-#define SECSPERAVGYEAR 31556952 /* mean year length over 400yrs */
+#define SECSPERAVGYEAR 31556952 /* mean year length over 400yrs */
/*
* Gross hacks. I have illicit knowlege that there won't be overflows
@@ -113,7 +115,7 @@ extern uint32_t caltontp (const struct calendar *);
* Convert between 'time_t' and 'vint64'
*/
extern vint64 time_to_vint64(const time_t *);
-extern time_t vint64_to_time(const vint64 *);
+extern time_t vint64_to_time(const vint64 *);
/*
* Get the build date & time. ATTENTION: The time zone is not specified!
diff --git a/contrib/ntp/include/ntp_fp.h b/contrib/ntp/include/ntp_fp.h
index 1b97e8b..7806932 100644
--- a/contrib/ntp/include/ntp_fp.h
+++ b/contrib/ntp/include/ntp_fp.h
@@ -264,10 +264,13 @@ typedef u_int32 u_fp;
* headers. So far the problem has only been seen with gcc, but it
* may also affect Sun compilers, in which case the defined(__GNUC__)
* term should be removed.
+ * XSCALE also generates bad code for these, at least with GCC 3.3.5.
+ * This is unrelated to math.h, but the same solution applies.
*/
#if defined(HAVE_U_INT64) && \
!(defined(__SVR4) && defined(__sun) && \
- defined(sparc) && defined(__GNUC__))
+ defined(sparc) && defined(__GNUC__) || \
+ defined(__arm__) && defined(__XSCALE__) && defined(__GNUC__))
#include <math.h> /* ldexp() */
diff --git a/contrib/ntp/include/ntp_md5.h b/contrib/ntp/include/ntp_md5.h
index 9f43378..2306b9a 100644
--- a/contrib/ntp/include/ntp_md5.h
+++ b/contrib/ntp/include/ntp_md5.h
@@ -24,7 +24,7 @@
typedef MD5_CTX EVP_MD_CTX;
# define EVP_get_digestbynid(t) NULL
-# define EVP_md5(v) NULL
+# define EVP_md5() NULL
# define EVP_MD_CTX_init(c)
# define EVP_MD_CTX_set_flags(c, f)
# define EVP_DigestInit(c, dt) (MD5Init(c), 1)
diff --git a/contrib/ntp/include/ntpd.h b/contrib/ntp/include/ntpd.h
index 77fe484..f0bbeb0 100644
--- a/contrib/ntp/include/ntpd.h
+++ b/contrib/ntp/include/ntpd.h
@@ -188,6 +188,7 @@ extern void unpeer (struct peer *);
extern void clear_all (void);
extern int score_all (struct peer *);
extern struct peer *findmanycastpeer(struct recvbuf *);
+extern void peer_cleanup (void);
/* ntp_crypto.c */
#ifdef AUTOKEY
@@ -385,7 +386,8 @@ extern endpt * ep_list; /* linked list */
/* ntp_loopfilter.c */
extern double drift_comp; /* clock frequency (s/s) */
extern double clock_stability; /* clock stability (s/s) */
-extern double clock_max; /* max offset before step (s) */
+extern double clock_max_back; /* max backward offset before step (s) */
+extern double clock_max_fwd; /* max forward offset before step (s) */
extern double clock_panic; /* max offset before panic (s) */
extern double clock_phi; /* dispersion rate (s/s) */
extern double clock_minstep; /* step timeout (s) */
@@ -403,8 +405,9 @@ extern int kern_enable; /* kernel support enabled */
extern int hardpps_enable; /* kernel PPS discipline enabled */
extern int ext_enable; /* external clock enabled */
extern int cal_enable; /* refclock calibrate enable */
-extern int allow_panic; /* allow panic correction */
-extern int mode_ntpdate; /* exit on first clock set */
+extern int allow_panic; /* allow panic correction (-g) */
+extern int force_step_once; /* always step time once at startup (-G) */
+extern int mode_ntpdate; /* exit on first clock set (-q) */
extern int peer_ntpdate; /* count of ntpdate peers */
/*
@@ -518,7 +521,7 @@ extern u_int32 conf_file_sum; /* Simple sum of characters */
/* ntp_signd.c */
#ifdef HAVE_NTP_SIGND
-extern void send_via_ntp_signd(struct recvbuf *, int, keyid_t, int,
+extern void send_via_ntp_signd(struct recvbuf *, int, keyid_t, int,
struct pkt *);
#endif
diff --git a/contrib/ntp/include/parse.h b/contrib/ntp/include/parse.h
index 3a98408..ca6855d 100644
--- a/contrib/ntp/include/parse.h
+++ b/contrib/ntp/include/parse.h
@@ -4,7 +4,7 @@
* parse.h,v 4.12 2007/01/14 08:36:03 kardel RELEASE_20070114_A
*
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -105,6 +105,13 @@ extern unsigned int splclock (void);
#endif
/*
+ * some constants useful for GPS time conversion
+ */
+#define GPSORIGIN 2524953600UL /* NTP origin - GPS origin in seconds */
+#define GPSWRAP 990U /* assume week count less than this in the previous epoch */
+#define GPSWEEKS 1024U /* number of weeks until the GPS epch rolls over */
+
+/*
* state flags
*/
#define PARSEB_POWERUP 0x00000001 /* no synchronisation */
@@ -127,7 +134,7 @@ extern unsigned int splclock (void);
/*
* optional status information
*/
-#define PARSEB_ALTERNATE 0x00001000 /* alternate antenna used */
+#define PARSEB_CALLBIT 0x00001000 /* "call bit" used to signalize irregularities in the control facilities */
#define PARSEB_POSITION 0x00002000 /* position available */
#define PARSEB_MESSAGE 0x00004000 /* addtitional message data */
/*
@@ -145,7 +152,7 @@ extern unsigned int splclock (void);
#define PARSEB_PPS 0x20000000 /* valid PPS sample */
#define PARSE_TCINFO (PARSEB_ANNOUNCE|PARSEB_POWERUP|PARSEB_NOSYNC|PARSEB_DST|\
- PARSEB_UTC|PARSEB_LEAPS|PARSEB_ALTERNATE|PARSEB_S_LEAP|\
+ PARSEB_UTC|PARSEB_LEAPS|PARSEB_CALLBIT|PARSEB_S_LEAP|\
PARSEB_S_LOCATION|PARSEB_TIMECODE|PARSEB_MESSAGE)
#define PARSE_POWERUP(x) ((x) & PARSEB_POWERUP)
@@ -156,7 +163,7 @@ extern unsigned int splclock (void);
#define PARSE_UTC(x) ((x) & PARSEB_UTC)
#define PARSE_LEAPADD(x) (PARSE_SYNC(x) && (((x) & PARSEB_LEAPS) == PARSEB_LEAPADD))
#define PARSE_LEAPDEL(x) (PARSE_SYNC(x) && (((x) & PARSEB_LEAPS) == PARSEB_LEAPDEL))
-#define PARSE_ALTERNATE(x) ((x) & PARSEB_ALTERNATE)
+#define PARSE_CALLBIT(x) ((x) & PARSEB_CALLBIT)
#define PARSE_LEAPSECOND(x) (PARSE_SYNC(x) && ((x) & PARSEB_LEAP_SECOND))
#define PARSE_S_LEAP(x) ((x) & PARSEB_S_LEAP)
@@ -229,13 +236,13 @@ typedef struct parsetime parsetime_t;
#define PARSE_IO_CSIZE 0x00000003
#define PARSE_IO_CS5 0x00000000
#define PARSE_IO_CS6 0x00000001
-#define PARSE_IO_CS7 0x00000002
-#define PARSE_IO_CS8 0x00000003
+#define PARSE_IO_CS7 0x00000002
+#define PARSE_IO_CS8 0x00000003
/*
* ioctl structure
*/
-union parsectl
+union parsectl
{
struct parsegettc
{
@@ -258,7 +265,7 @@ union parsectl
u_long parse_cs; /* character size (needed for stripping) */
} parsesetcs;
};
-
+
typedef union parsectl parsectl_t;
/*------ for conversion routines --------*/
@@ -266,7 +273,7 @@ typedef union parsectl parsectl_t;
struct parse /* parse module local data */
{
int parse_flags; /* operation and current status flags */
-
+
int parse_ioflags; /* io handling flags (5-8 Bit control currently) */
/*
@@ -286,7 +293,7 @@ struct parse /* parse module local data */
char *parse_ldata; /* last data buffer */
unsigned short parse_ldsize; /* last data buffer length */
u_long parse_badformat; /* number of unparsable pakets */
-
+
timestamp_t parse_lastchar; /* last time a character was received */
parsetime_t parse_dtime; /* external data prototype */
};
@@ -337,15 +344,19 @@ typedef struct clocktime clocktime_t;
#define SYNC_ZERO 0x00
#define SYNC_ONE 0x01
+typedef u_long parse_inp_fnc_t(parse_t *, char, timestamp_t *);
+typedef u_long parse_cvt_fnc_t(unsigned char *, int, struct format *, clocktime_t *, void *);
+typedef u_long parse_pps_fnc_t(parse_t *, int, timestamp_t *);
+
struct clockformat
{
/* special input protocol - implies fixed format */
- u_long (*input) (parse_t *, unsigned int, timestamp_t *);
+ parse_inp_fnc_t *input;
/* conversion routine */
- u_long (*convert) (unsigned char *, int, struct format *, clocktime_t *, void *);
+ parse_cvt_fnc_t *convert;
/* routine for handling RS232 sync events (time stamps) */
/* PPS input routine */
- u_long (*syncpps) (parse_t *, int, timestamp_t *);
+ parse_pps_fnc_t *syncpps;
/* time code synthesizer */
void *data; /* local parameters */
@@ -361,7 +372,7 @@ typedef struct clockformat clockformat_t;
*/
extern int parse_ioinit (parse_t *);
extern void parse_ioend (parse_t *);
-extern int parse_ioread (parse_t *, unsigned int, timestamp_t *);
+extern int parse_ioread (parse_t *, char, timestamp_t *);
extern int parse_iopps (parse_t *, int, timestamp_t *);
extern void parse_iodone (parse_t *);
extern int parse_timecode (parsectl_t *, parse_t *);
@@ -369,8 +380,8 @@ extern int parse_getfmt (parsectl_t *, parse_t *);
extern int parse_setfmt (parsectl_t *, parse_t *);
extern int parse_setcs (parsectl_t *, parse_t *);
-extern unsigned int parse_restart (parse_t *, unsigned int);
-extern unsigned int parse_addchar (parse_t *, unsigned int);
+extern unsigned int parse_restart (parse_t *, char);
+extern unsigned int parse_addchar (parse_t *, char);
extern unsigned int parse_end (parse_t *);
extern int Strok (const unsigned char *, const unsigned char *);
@@ -379,9 +390,9 @@ extern int Stoi (const unsigned char *, long *, int);
extern time_t parse_to_unixtime (clocktime_t *, u_long *);
extern u_long updatetimeinfo (parse_t *, u_long);
extern void syn_simple (parse_t *, timestamp_t *, struct format *, u_long);
-extern u_long pps_simple (parse_t *, int, timestamp_t *);
-extern u_long pps_one (parse_t *, int, timestamp_t *);
-extern u_long pps_zero (parse_t *, int, timestamp_t *);
+extern parse_pps_fnc_t pps_simple;
+extern parse_pps_fnc_t pps_one;
+extern parse_pps_fnc_t pps_zero;
extern int parse_timedout (parse_t *, timestamp_t *, struct timeval *);
#endif
diff --git a/contrib/ntp/include/parse_conf.h b/contrib/ntp/include/parse_conf.h
index 319dd54..d17d616 100644
--- a/contrib/ntp/include/parse_conf.h
+++ b/contrib/ntp/include/parse_conf.h
@@ -4,7 +4,7 @@
* parse_conf.h,v 4.7 2005/06/25 10:58:45 kardel RELEASE_20050625_A
*
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -41,13 +41,13 @@
/*
* field location structure
*/
-#define O_DAY 0
+#define O_DAY 0
#define O_MONTH 1
-#define O_YEAR 2
-#define O_HOUR 3
-#define O_MIN 4
-#define O_SEC 5
-#define O_WDAY 6
+#define O_YEAR 2
+#define O_HOUR 3
+#define O_MIN 4
+#define O_SEC 5
+#define O_WDAY 6
#define O_FLAGS 7
#define O_ZONE 8
#define O_UTCHOFFSET 9
diff --git a/contrib/ntp/kernel/Makefile.in b/contrib/ntp/kernel/Makefile.in
index 5c85def..2147529 100644
--- a/contrib/ntp/kernel/Makefile.in
+++ b/contrib/ntp/kernel/Makefile.in
@@ -38,8 +38,7 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -68,6 +67,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -324,6 +325,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/kernel/sys/Makefile.in b/contrib/ntp/kernel/sys/Makefile.in
index 8333476..2e8f990 100644
--- a/contrib/ntp/kernel/sys/Makefile.in
+++ b/contrib/ntp/kernel/sys/Makefile.in
@@ -40,8 +40,7 @@ DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/Makefile.am \
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -70,6 +69,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -289,6 +290,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/kernel/sys/parsestreams.h b/contrib/ntp/kernel/sys/parsestreams.h
index e784f9e..bd40093 100644
--- a/contrib/ntp/kernel/sys/parsestreams.h
+++ b/contrib/ntp/kernel/sys/parsestreams.h
@@ -4,7 +4,7 @@
* parsestreams.h,v 4.5 2005/06/25 10:52:47 kardel RELEASE_20050625_A
*
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/contrib/ntp/lib/isc/inet_ntop.c b/contrib/ntp/lib/isc/inet_ntop.c
index 26d5dca..7730180 100644
--- a/contrib/ntp/lib/isc/inet_ntop.c
+++ b/contrib/ntp/lib/isc/inet_ntop.c
@@ -135,6 +135,7 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
best.base = -1;
cur.base = -1;
+ best.len = cur.len = 0;
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
if (words[i] == 0) {
if (cur.base == -1)
diff --git a/contrib/ntp/lib/isc/log.c b/contrib/ntp/lib/isc/log.c
index ce98303..38f0c4f 100644
--- a/contrib/ntp/lib/isc/log.c
+++ b/contrib/ntp/lib/isc/log.c
@@ -1143,7 +1143,7 @@ sync_channellist(isc_logconfig_t *lcfg) {
static isc_result_t
greatest_version(isc_logchannel_t *channel, int *greatestp) {
/* XXXDCL HIGHLY NT */
- char *basename, *digit_end;
+ char *basenam, *digit_end;
const char *dirname;
int version, greatest = -1;
unsigned int basenamelen;
@@ -1160,23 +1160,23 @@ greatest_version(isc_logchannel_t *channel, int *greatestp) {
* It is safe to DE_CONST the file.name because it was copied
* with isc_mem_strdup in isc_log_createchannel.
*/
- basename = strrchr(FILE_NAME(channel), sep);
+ basenam = strrchr(FILE_NAME(channel), sep);
#ifdef _WIN32
basename2 = strrchr(FILE_NAME(channel), '\\');
- if ((basename != NULL && basename2 != NULL && basename2 > basename) ||
- (basename == NULL && basename2 != NULL)) {
- basename = basename2;
+ if ((basenam != NULL && basename2 != NULL && basename2 > basenam) ||
+ (basenam == NULL && basename2 != NULL)) {
+ basenam = basename2;
sep = '\\';
}
#endif
- if (basename != NULL) {
- *basename++ = '\0';
+ if (basenam != NULL) {
+ *basenam++ = '\0';
dirname = FILE_NAME(channel);
} else {
- DE_CONST(FILE_NAME(channel), basename);
+ DE_CONST(FILE_NAME(channel), basenam);
dirname = ".";
}
- basenamelen = strlen(basename);
+ basenamelen = strlen(basenam);
isc_dir_init(&dir);
result = isc_dir_open(&dir, dirname);
@@ -1184,8 +1184,8 @@ greatest_version(isc_logchannel_t *channel, int *greatestp) {
/*
* Replace the file separator if it was taken out.
*/
- if (basename != FILE_NAME(channel))
- *(basename - 1) = sep;
+ if (basenam != FILE_NAME(channel))
+ *(basenam - 1) = sep;
/*
* Return if the directory open failed.
@@ -1195,7 +1195,7 @@ greatest_version(isc_logchannel_t *channel, int *greatestp) {
while (isc_dir_read(&dir) == ISC_R_SUCCESS) {
if (dir.entry.length > basenamelen &&
- strncmp(dir.entry.name, basename, basenamelen) == 0 &&
+ strncmp(dir.entry.name, basenam, basenamelen) == 0 &&
dir.entry.name[basenamelen] == '.') {
version = strtol(&dir.entry.name[basenamelen + 1],
diff --git a/contrib/ntp/lib/isc/result.c b/contrib/ntp/lib/isc/result.c
index 520f161..da57272 100644
--- a/contrib/ntp/lib/isc/result.c
+++ b/contrib/ntp/lib/isc/result.c
@@ -172,7 +172,7 @@ const char *
isc_result_totext(isc_result_t result) {
resulttable *table;
const char *txt, *default_text;
- int index;
+ int idx;
initialize();
@@ -183,15 +183,15 @@ isc_result_totext(isc_result_t result) {
table != NULL;
table = ISC_LIST_NEXT(table, link)) {
if (result >= table->base && result <= table->last) {
- index = (int)(result - table->base);
- default_text = table->text[index];
+ idx = (int)(result - table->base);
+ default_text = table->text[idx];
/*
- * Note: we use 'index + 1' as the message number
- * instead of index because isc_msgcat_get() requires
+ * Note: we use 'idx + 1' as the message number
+ * instead of idx because isc_msgcat_get() requires
* the message number to be > 0.
*/
txt = isc_msgcat_get(table->msgcat, table->set,
- index + 1, default_text);
+ idx + 1, default_text);
break;
}
}
diff --git a/contrib/ntp/lib/isc/unix/file.c b/contrib/ntp/lib/isc/unix/file.c
index 3b59e86..9eda4a3 100644
--- a/contrib/ntp/lib/isc/unix/file.c
+++ b/contrib/ntp/lib/isc/unix/file.c
@@ -508,7 +508,7 @@ isc_file_safecreate(const char *filename, FILE **fp) {
}
isc_result_t
-isc_file_splitpath(isc_mem_t *mctx, char *path, char **dirname, char **basename)
+isc_file_splitpath(isc_mem_t *mctx, char *path, char **dirnam, char **basenam)
{
char *dir, *file, *slash;
@@ -537,8 +537,8 @@ isc_file_splitpath(isc_mem_t *mctx, char *path, char **dirname, char **basename)
return (ISC_R_INVALIDFILE);
}
- *dirname = dir;
- *basename = file;
+ *dirnam = dir;
+ *basenam = file;
return (ISC_R_SUCCESS);
}
diff --git a/contrib/ntp/lib/isc/unix/ifiter_getifaddrs.c b/contrib/ntp/lib/isc/unix/ifiter_getifaddrs.c
index c2e4044..425b9b4 100644
--- a/contrib/ntp/lib/isc/unix/ifiter_getifaddrs.c
+++ b/contrib/ntp/lib/isc/unix/ifiter_getifaddrs.c
@@ -212,6 +212,9 @@ internal_current(isc_interfaceiter_t *iter) {
get_addr(family, &iter->current.broadcast, ifa->ifa_broadaddr,
ifa->ifa_name);
+#ifdef ISC_PLATFORM_HAVEIFNAMETOINDEX
+ iter->current.ifindex = if_nametoindex(iter->current.name);
+#endif
return (ISC_R_SUCCESS);
}
diff --git a/contrib/ntp/lib/isc/unix/ifiter_ioctl.c b/contrib/ntp/lib/isc/unix/ifiter_ioctl.c
index a684867..c8e4970 100644
--- a/contrib/ntp/lib/isc/unix/ifiter_ioctl.c
+++ b/contrib/ntp/lib/isc/unix/ifiter_ioctl.c
@@ -109,6 +109,10 @@ struct isc_interfaceiter {
#endif
#endif
+/* Silence a warning when this file is #included */
+int
+isc_ioctl(int fildes, int req, char *arg);
+
int
isc_ioctl(int fildes, int req, char *arg) {
int trys;
@@ -588,6 +592,9 @@ internal_current4(isc_interfaceiter_t *iter) {
}
iter->current.netmask.type.in6.s6_addr[i] = (~0 << bits) & 0xff;
}
+#ifdef ISC_PLATFORM_HAVEIFNAMETOINDEX
+ iter->current.ifindex = if_nametoindex(iter->current.name);
+#endif
return (ISC_R_SUCCESS);
inet:
@@ -664,6 +671,9 @@ internal_current4(isc_interfaceiter_t *iter) {
}
get_addr(family, &iter->current.netmask,
(struct sockaddr *)&ifreq.ifr_addr, ifreq.ifr_name);
+#ifdef ISC_PLATFORM_HAVEIFNAMETOINDEX
+ iter->current.ifindex = if_nametoindex(iter->current.name);
+#endif
return (ISC_R_SUCCESS);
}
@@ -704,7 +714,6 @@ internal_current6(isc_interfaceiter_t *iter) {
get_addr(family, &iter->current.address,
(struct sockaddr *)&lifreq.lifr_addr, lifreq.lifr_name);
- iter->current.ifindex = lifreq.lifr_index;
if (isc_netaddr_islinklocal(&iter->current.address))
isc_netaddr_setzone(&iter->current.address,
(isc_uint32_t)lifreq.lifr_index);
@@ -844,7 +853,9 @@ internal_current6(isc_interfaceiter_t *iter) {
iter->current.netmask.type.in6.s6_addr[i / 8] =
(~0 << bits) & 0xff;
}
-
+#ifdef ISC_PLATFORM_HAVEIFNAMETOINDEX
+ iter->current.ifindex = if_nametoindex(iter->current.name);
+#endif
return (ISC_R_SUCCESS);
}
#endif
@@ -867,6 +878,9 @@ internal_current6(isc_interfaceiter_t *iter) {
get_addr(family, &iter->current.netmask,
(struct sockaddr *)&lifreq.lifr_addr, lifreq.lifr_name);
+#ifdef ISC_PLATFORM_HAVEIFNAMETOINDEX
+ iter->current.ifindex = if_nametoindex(iter->current.name);
+#endif
return (ISC_R_SUCCESS);
}
#endif
diff --git a/contrib/ntp/lib/isc/unix/net.c b/contrib/ntp/lib/isc/unix/net.c
index 2ba17d16..7056668 100644
--- a/contrib/ntp/lib/isc/unix/net.c
+++ b/contrib/ntp/lib/isc/unix/net.c
@@ -106,7 +106,8 @@ const struct in6_addr isc_net_in6addrloop = IN6ADDR_LOOPBACK_INIT;
static isc_once_t once_ipv6only = ISC_ONCE_INIT;
# endif
-# if defined(ISC_PLATFORM_HAVEIN6PKTINFO)
+# if defined(ISC_PLATFORM_HAVEIPV6) && \
+ defined(WANT_IPV6) && defined(ISC_PLATFORM_HAVEIN6PKTINFO)
static isc_once_t once_ipv6pktinfo = ISC_ONCE_INIT;
# endif
#endif /* ISC_PLATFORM_HAVEIPV6 */
diff --git a/contrib/ntp/libntp/Makefile.in b/contrib/ntp/libntp/Makefile.in
index 0ff8c52..1b45116 100644
--- a/contrib/ntp/libntp/Makefile.in
+++ b/contrib/ntp/libntp/Makefile.in
@@ -41,8 +41,7 @@ subdir = libntp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -71,6 +70,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -444,6 +445,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/libntp/ntp_calendar.c b/contrib/ntp/libntp/ntp_calendar.c
index 94ca0e9..ff91fcf 100644
--- a/contrib/ntp/libntp/ntp_calendar.c
+++ b/contrib/ntp/libntp/ntp_calendar.c
@@ -29,7 +29,7 @@ ntpcal_set_timefunc(
)
{
systime_func_ptr res;
-
+
res = systime_func;
if (NULL == nfunc)
nfunc = &time;
@@ -118,7 +118,7 @@ vint64_to_time(
#endif
return res;
-}
+}
/*
*---------------------------------------------------------------------
@@ -170,7 +170,7 @@ ntpcal_get_build_date(
#ifdef DEBUG
static int ignore = 0;
#endif
-
+
ZERO(*jd);
jd->year = 1970;
jd->month = 1;
@@ -255,7 +255,7 @@ static const uint16_t real_month_table[2][13] = {
* in the proleptic Gregorian calendar. The begin of the Christian Era
* (0001-01-01) is RD(1).
*
- *
+ *
* Some notes on the implementation:
*
* Calendar algorithms thrive on the division operation, which is one of
@@ -351,7 +351,7 @@ ntpcal_periodic_extend(
char cpl = 0; /* modulo complement flag */
char neg = 0; /* sign change flag */
- /* make the cycle positive and adjust the flags */
+ /* make the cycle positive and adjust the flags */
if (cycle < 0) {
cycle = - cycle;
neg ^= 1;
@@ -407,21 +407,21 @@ ntpcal_ntp_to_time(
#ifdef HAVE_INT64
- res.q_s = (pivot != NULL)
+ res.q_s = (pivot != NULL)
? *pivot
- : now();
+ : now();
res.Q_s -= 0x80000000; /* unshift of half range */
ntp -= (uint32_t)JAN_1970; /* warp into UN*X domain */
ntp -= res.D_s.lo; /* cycle difference */
res.Q_s += (uint64_t)ntp; /* get expanded time */
#else /* no 64bit scalars */
-
+
time_t tmp;
-
- tmp = (pivot != NULL)
+
+ tmp = (pivot != NULL)
? *pivot
- : now();
+ : now();
res = time_to_vint64(&tmp);
M_SUB(res.D_s.hi, res.D_s.lo, 0, 0x80000000);
ntp -= (uint32_t)JAN_1970; /* warp into UN*X domain */
@@ -465,9 +465,9 @@ ntpcal_ntp_to_ntp(
res.Q_s += (uint64_t)ntp; /* get expanded time */
#else /* no 64bit scalars */
-
+
time_t tmp;
-
+
tmp = (pivot)
? *pivot
: now();
@@ -492,7 +492,7 @@ ntpcal_ntp_to_ntp(
*/
/*
- *-------------------------------------------------------------------
+ *-------------------------------------------------------------------
* Split a 64bit seconds value into elapsed days in 'res.hi' and
* elapsed seconds since midnight in 'res.lo' using explicit floor
* division. This function happily accepts negative time values as
@@ -532,7 +532,7 @@ ntpcal_daysplit(
isneg = M_ISNEG(op.D_s.hi);
if (isneg)
M_NEG(op.D_s.hi, op.D_s.lo);
-
+
/* save remainder of DIV 128, shift for divide */
r = op.D_s.lo & 127; /* save remainder bits */
op.D_s.lo = (op.D_s.lo >> 7) | (op.D_s.hi << 25);
@@ -572,16 +572,16 @@ ntpcal_daysplit(
} else
q = ~q + 1;
}
-
+
res.hi = q;
res.lo = r;
-#endif
+#endif
return res;
}
/*
- *-------------------------------------------------------------------
+ *-------------------------------------------------------------------
* Split a 32bit seconds value into h/m/s and excessive days. This
* function happily accepts negative time values as timestamps before
* midnight.
@@ -632,7 +632,7 @@ ntpcal_split_eradays(
{
ntpcal_split res;
int32_t n400, n100, n004, n001, yday; /* calendar year cycles */
-
+
/*
* Split off calendar cycles, using floor division in the first
* step. After that first step, simple division does it because
@@ -652,7 +652,7 @@ ntpcal_split_eradays(
yday = yday % GREGORIAN_NORMAL_LEAP_CYCLE_DAYS;
n001 = yday / DAYSPERYEAR;
yday = yday % DAYSPERYEAR;
-
+
/*
* check for leap cycle overflows and calculate the leap flag
* if needed
@@ -665,11 +665,11 @@ ntpcal_split_eradays(
*isleapyear = 1;
} else if (isleapyear)
*isleapyear = (n001 == 3) && ((n004 != 24) || (n100 == 3));
-
+
/* now merge the cycles to elapsed years, using horner scheme */
res.hi = ((4*n400 + n100)*25 + n004)*4 + n001;
res.lo = yday;
-
+
return res;
}
@@ -724,7 +724,13 @@ ntpcal_rd_to_date(
leaps = 0;
retv = 0;
- /* get day-of-week first */
+ /* Get day-of-week first. Since rd is signed, the remainder can
+ * be in the range [-6..+6], but the assignment to an unsigned
+ * variable maps the negative values to positive values >=7.
+ * This makes the sign correction look strange, but adding 7
+ * causes the needed wrap-around into the desired value range of
+ * zero to six, both inclusive.
+ */
jd->weekday = rd % 7;
if (jd->weekday >= 7) /* unsigned! */
jd->weekday += 7;
@@ -794,7 +800,7 @@ ntpcal_daysec_to_date(
{
int32_t days;
int ts[3];
-
+
days = priv_timesplit(ts, sec);
jd->hour = (uint8_t)ts[0];
jd->minute = (uint8_t)ts[1];
@@ -817,7 +823,7 @@ ntpcal_daysec_to_tm(
{
int32_t days;
int32_t ts[3];
-
+
days = priv_timesplit(ts, sec);
utm->tm_hour = ts[0];
utm->tm_min = ts[1];
@@ -946,7 +952,7 @@ ntpcal_dayjoin(
/* fix sign */
if (isneg)
M_NEG(res.D_s.hi, res.D_s.lo);
-
+
/* properly add seconds */
p2 = 0;
if (secs < 0) {
@@ -957,7 +963,7 @@ ntpcal_dayjoin(
}
M_ADD(res.D_s.hi, res.D_s.lo, p2, p1);
-#endif
+#endif
return res;
}
@@ -1279,7 +1285,7 @@ ntpcal_ntp64_to_date(
)
{
ntpcal_split ds;
-
+
ds = ntpcal_daysplit(ntp);
ds.hi += ntpcal_daysec_to_date(jd, ds.lo);
@@ -1294,7 +1300,7 @@ ntpcal_ntp_to_date(
)
{
vint64 ntp64;
-
+
/*
* Unfold ntp time around current time into NTP domain. Split
* into days and seconds, shift days into CE domain and
@@ -1516,12 +1522,12 @@ isocal_split_eraweeks(
res.lo += (res.lo >= 10435);
cents = res.lo / 5218;
res.lo %= 5218; /* res.lo is weeks in century now */
-
+
/* convert elapsed weeks in century to elapsed years and weeks */
res.lo = res.lo * 157 + bctab[cents];
res.hi += cents * 100 + res.lo / 8192;
- res.lo = (res.lo % 8192) / 157;
-
+ res.lo = (res.lo % 8192) / 157;
+
return res;
}
@@ -1538,7 +1544,7 @@ isocal_ntp64_to_date(
{
ntpcal_split ds;
int32_t ts[3];
-
+
/*
* Split NTP time into days and seconds, shift days into CE
* domain and process the parts.
@@ -1576,7 +1582,7 @@ isocal_ntp_to_date(
)
{
vint64 ntp64;
-
+
/*
* Unfold ntp time around current time into NTP domain, then
* convert the full time stamp.
diff --git a/contrib/ntp/libntp/work_fork.c b/contrib/ntp/libntp/work_fork.c
index 10329e7..dab02bc 100644
--- a/contrib/ntp/libntp/work_fork.c
+++ b/contrib/ntp/libntp/work_fork.c
@@ -382,7 +382,7 @@ fork_blocking_child(
int rc;
int was_pipe;
int is_pipe;
- int saved_errno;
+ int saved_errno = 0;
int childpid;
int keep_fd;
int fd;
diff --git a/contrib/ntp/libparse/Makefile.in b/contrib/ntp/libparse/Makefile.in
index 1594eb1..d473a77 100644
--- a/contrib/ntp/libparse/Makefile.in
+++ b/contrib/ntp/libparse/Makefile.in
@@ -43,8 +43,7 @@ subdir = libparse
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -73,6 +72,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -352,6 +353,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/libparse/clk_computime.c b/contrib/ntp/libparse/clk_computime.c
index 1068576..5026232 100644
--- a/contrib/ntp/libparse/clk_computime.c
+++ b/contrib/ntp/libparse/clk_computime.c
@@ -7,15 +7,15 @@
* /src/NTP/ntp4-dev/libparse/clk_computime.c,v 4.10 2005/04/16 17:32:10 kardel RELEASE_20050508_A
*
* clk_computime.c,v 4.10 2005/04/16 17:32:10 kardel RELEASE_20050508_A
- *
+ *
* Supports Diem's Computime Radio Clock
- *
+ *
* Used the Meinberg clock as a template for Diem's Computime Radio Clock
*
* adapted by Alois Camenzind <alois.camenzind@ubs.ch>
- *
+ *
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -59,22 +59,22 @@ extern int printf (const char *, ...);
/*
* The Computime receiver sends a datagram in the following format every minute
- *
- * Timestamp T:YY:MM:MD:WD:HH:MM:SSCRLF
+ *
+ * Timestamp T:YY:MM:MD:WD:HH:MM:SSCRLF
* Pos 0123456789012345678901 2 3
* 0000000000111111111122 2 2
* Parse T: : : : : : : rn
- *
- * T Startcharacter "T" specifies start of the timestamp
- * YY Year MM Month 1-12
- * MD Day of the month
- * WD Day of week
- * HH Hour
- * MM Minute
+ *
+ * T Startcharacter "T" specifies start of the timestamp
+ * YY Year MM Month 1-12
+ * MD Day of the month
+ * WD Day of week
+ * HH Hour
+ * MM Minute
* SS Second
- * CR Carriage return
+ * CR Carriage return
* LF Linefeed
- *
+ *
*/
static struct format computime_fmt =
@@ -88,10 +88,10 @@ static struct format computime_fmt =
0
};
-static u_long cvt_computime (unsigned char *, int, struct format *, clocktime_t *, void *);
-static unsigned long inp_computime (parse_t *, unsigned int, timestamp_t *);
+static parse_cvt_fnc_t cvt_computime;
+static parse_inp_fnc_t inp_computime;
-clockformat_t clock_computime =
+clockformat_t clock_computime =
{
inp_computime, /* Computime input handling */
cvt_computime, /* Computime conversion */
@@ -99,15 +99,15 @@ clockformat_t clock_computime =
(void *)&computime_fmt, /* conversion configuration */
"Diem's Computime Radio Clock", /* Computime Radio Clock */
24, /* string buffer */
- 0 /* no private data (complete pakets) */
+ 0 /* no private data (complete packets) */
};
/*
- * cvt_computime
- *
+ * parse_cvt_fnc_t cvt_computime
+ *
* convert simple type format
*/
-static u_long
+static u_long
cvt_computime(
unsigned char *buffer,
int size,
@@ -117,7 +117,7 @@ cvt_computime(
)
{
- if (!Strok(buffer, format->fixed_string)) {
+ if (!Strok(buffer, format->fixed_string)) {
return CVT_NONE;
} else {
if (Stoi(&buffer[format->field_offsets[O_DAY].offset], &clock_time->day,
@@ -131,7 +131,7 @@ cvt_computime(
Stoi(&buffer[format->field_offsets[O_MIN].offset], &clock_time->minute,
format->field_offsets[O_MIN].length) ||
Stoi(&buffer[format->field_offsets[O_SEC].offset], &clock_time->second,
- format->field_offsets[O_SEC].length)) {
+ format->field_offsets[O_SEC].length)) {
return CVT_FAIL | CVT_BADFMT;
} else {
@@ -144,31 +144,31 @@ cvt_computime(
}
/*
- * inp_computime
+ * parse_inp_fnc_t inp_computime
*
- * grep data from input stream
+ * grab data from input stream
*/
static u_long
inp_computime(
parse_t *parseio,
- unsigned int ch,
+ char ch,
timestamp_t *tstamp
)
{
unsigned int rtc;
-
+
parseprintf(DD_PARSE, ("inp_computime(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
-
+
switch (ch)
{
case 'T':
parseprintf(DD_PARSE, ("inp_computime: START seen\n"));
-
+
parseio->parse_index = 1;
parseio->parse_data[0] = ch;
parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
return PARSE_INP_SKIP;
-
+
case '\n':
parseprintf(DD_PARSE, ("inp_computime: END seen\n"));
if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
diff --git a/contrib/ntp/libparse/clk_dcf7000.c b/contrib/ntp/libparse/clk_dcf7000.c
index bfd9a74..f1da9ef 100644
--- a/contrib/ntp/libparse/clk_dcf7000.c
+++ b/contrib/ntp/libparse/clk_dcf7000.c
@@ -1,12 +1,12 @@
/*
* /src/NTP/ntp4-dev/libparse/clk_dcf7000.c,v 4.10 2005/04/16 17:32:10 kardel RELEASE_20050508_A
- *
+ *
* clk_dcf7000.c,v 4.10 2005/04/16 17:32:10 kardel RELEASE_20050508_A
*
* ELV DCF7000 module
*
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -63,9 +63,10 @@ static struct format dcf7000_fmt =
},
(const unsigned char *)" - - - - - - - \r",
0
-};
-static u_long cvt_dcf7000 (unsigned char *, int, struct format *, clocktime_t *, void *);
-static unsigned long inp_dcf7000 (parse_t *, unsigned int, timestamp_t *);
+};
+
+static parse_cvt_fnc_t cvt_dcf7000;
+static parse_inp_fnc_t inp_dcf7000;
clockformat_t clock_dcf7000 =
{
@@ -75,11 +76,11 @@ clockformat_t clock_dcf7000 =
(void *)&dcf7000_fmt, /* conversion configuration */
"ELV DCF7000", /* ELV clock */
24, /* string buffer */
- 0 /* no private data (complete pakets) */
+ 0 /* no private data (complete packets) */
};
/*
- * cvt_dcf7000
+ * parse_cvt_fnc_t cvt_dcf7000
*
* convert dcf7000 type format
*/
@@ -117,7 +118,7 @@ cvt_dcf7000(
{
unsigned char *f = &buffer[format->field_offsets[O_FLAGS].offset];
long flags;
-
+
clock_time->flags = 0;
clock_time->usecond = 0;
@@ -144,21 +145,21 @@ cvt_dcf7000(
}
/*
- * inp_dcf700
+ * parse_inp_fnc_t inp_dcf700
*
- * grep data from input stream
+ * grab data from input stream
*/
static u_long
inp_dcf7000(
parse_t *parseio,
- unsigned int ch,
+ char ch,
timestamp_t *tstamp
)
{
unsigned int rtc;
-
+
parseprintf(DD_PARSE, ("inp_dcf7000(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
-
+
switch (ch)
{
case '\r':
diff --git a/contrib/ntp/libparse/clk_hopf6021.c b/contrib/ntp/libparse/clk_hopf6021.c
index 033d2d2..357ac2e 100644
--- a/contrib/ntp/libparse/clk_hopf6021.c
+++ b/contrib/ntp/libparse/clk_hopf6021.c
@@ -37,10 +37,10 @@
extern int printf (const char *, ...);
#endif
-/*
- * hopf Funkuhr 6021
+/*
+ * hopf Funkuhr 6021
* used with 9600,8N1,
- * UTC ueber serielle Schnittstelle
+ * UTC ueber serielle Schnittstelle
* Sekundenvorlauf ON
* ETX zum Sekundenvorlauf ON
* Datenstring 6021
@@ -71,7 +71,7 @@ extern int printf (const char *, ...);
* x x 0 x - Wintertime
* x x 1 x - Summertime
* 0 0 x x - Time/Date invalid
- * 0 1 x x - Internal clock used
+ * 0 1 x x - Internal clock used
* 1 0 x x - Radio clock
* 1 1 x x - Radio clock highprecision
*
@@ -90,10 +90,10 @@ extern int printf (const char *, ...);
#define HOPF_DSTWARN 0x01 /* DST switch warning */
#define HOPF_DST 0x02 /* DST in effect */
-#define HOPF_MODE 0x0C /* operation mode mask */
+#define HOPF_MODE 0x0C /* operation mode mask */
#define HOPF_INVALID 0x00 /* no time code available */
#define HOPF_INTERNAL 0x04 /* internal clock */
-#define HOPF_RADIO 0x08 /* radio clock */
+#define HOPF_RADIO 0x08 /* radio clock */
#define HOPF_RADIOHP 0x0C /* high precision radio clock */
#define HOPF_UTC 0x08 /* time code in UTC */
@@ -102,13 +102,13 @@ extern int printf (const char *, ...);
static struct format hopf6021_fmt =
{
{
- { 9, 2 }, {11, 2}, { 13, 2}, /* Day, Month, Year */
- { 3, 2 }, { 5, 2}, { 7, 2}, /* Hour, Minute, Second */
+ { 9, 2 }, {11, 2}, { 13, 2}, /* Day, Month, Year */
+ { 3, 2 }, { 5, 2}, { 7, 2}, /* Hour, Minute, Second */
{ 2, 1 }, { 1, 1}, { 0, 0}, /* Weekday, Flags, Zone */
/* ... */
},
(const unsigned char *)"\002 \n\r\003",
- 0
+ 0
};
#define OFFS(x) format->field_offsets[(x)].offset
@@ -118,8 +118,8 @@ static struct format hopf6021_fmt =
('A' <= (x) && (x) <= 'F') ? (x) - 'A' + 10 : \
-1)
-static unsigned long cvt_hopf6021 (unsigned char *, int, struct format *, clocktime_t *, void *);
-static unsigned long inp_hopf6021 (parse_t *, unsigned int, timestamp_t *);
+static parse_cvt_fnc_t cvt_hopf6021;
+static parse_inp_fnc_t inp_hopf6021;
clockformat_t clock_hopf6021 =
{
@@ -132,7 +132,8 @@ clockformat_t clock_hopf6021 =
0 /* private data length, no private data */
};
-static unsigned long
+/* parse_cvt_fnc_t cvt_hopf6021 */
+static u_long
cvt_hopf6021(
unsigned char *buffer,
int size,
@@ -162,8 +163,8 @@ cvt_hopf6021(
clock_time->usecond = 0;
clock_time->utcoffset = 0;
- status = hexval(buffer[OFFS(O_FLAGS)]);
- weekday= hexval(buffer[OFFS(O_WDAY)]);
+ status = (u_char) hexval(buffer[OFFS(O_FLAGS)]);
+ weekday= (u_char) hexval(buffer[OFFS(O_WDAY)]);
if ((status == 0xFF) || (weekday == 0xFF))
{
@@ -213,21 +214,21 @@ cvt_hopf6021(
}
/*
- * inp_hopf6021
+ * parse_inp_fnc_t inp_hopf6021
*
- * grep data from input stream
+ * grab data from input stream
*/
static u_long
inp_hopf6021(
parse_t *parseio,
- unsigned int ch,
+ char ch,
timestamp_t *tstamp
)
{
unsigned int rtc;
-
+
parseprintf(DD_PARSE, ("inp_hopf6021(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
-
+
switch (ch)
{
case ETX:
diff --git a/contrib/ntp/libparse/clk_meinberg.c b/contrib/ntp/libparse/clk_meinberg.c
index a94c3f7..4047be5 100644
--- a/contrib/ntp/libparse/clk_meinberg.c
+++ b/contrib/ntp/libparse/clk_meinberg.c
@@ -1,12 +1,12 @@
/*
* /src/NTP/REPOSITORY/ntp4-dev/libparse/clk_meinberg.c,v 4.12.2.1 2005/09/25 10:22:35 kardel RELEASE_20050925_A
- *
+ *
* clk_meinberg.c,v 4.12.2.1 2005/09/25 10:22:35 kardel RELEASE_20050925_A
*
* Meinberg clock support
*
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -65,7 +65,7 @@
/*
* The Meinberg receiver every second sends a datagram of the following form
* (Standard Format)
- *
+ *
* <STX>D:<dd>.<mm>.<yy>;T:<w>;U:<hh>:<mm>:<ss>;<S><F><D><A><ETX>
* pos: 0 00 00 0 00 0 11 111 1 111 12 2 22 2 22 2 2 2 3 3 3
* 1 23 45 6 78 9 01 234 5 678 90 1 23 4 56 7 8 9 0 1 2
@@ -105,12 +105,14 @@
* <A> = '!' during the hour preceeding an daylight saving time
* start/end change
* <L> = 'A' LEAP second announcement
- * <R> = 'R' alternate antenna
+ * <R> = 'R' "call bit" used to signalize irregularities in the control facilities,
+ * usually ' ', until 2003 indicated transmission via alternate antenna
*
- * Meinberg GPS166 receiver
+ * Meinberg GPS receivers
*
- * You must get the Uni-Erlangen firmware for the GPS receiver support
+ * For very old devices you must get the Uni-Erlangen firmware for the GPS receiver support
* to work to full satisfaction !
+ * With newer GPS receiver types the Uni Erlangen string format can be configured at the device.
*
* <STX><dd>.<mm>.<yy>; <w>; <hh>:<mm>:<ss>; <+/-><00:00>; <U><S><F><D><A><L><R><L>; <position...><ETX>
*
@@ -118,7 +120,7 @@
* 123456789012345678901234567890123456789012345678901234567890123456
* \x0209.07.93; 5; 08:48:26; +00:00; #*S!A L; 49.5736N 11.0280E 373m\x03
*
- *
+ *
* <STX> = '\002' ASCII start of text
* <ETX> = '\003' ASCII end of text
* <dd>,<mm>,<yy> = day, month, year(2 digits!!)
@@ -131,8 +133,10 @@
* <A> = '!' during the hour preceeding an daylight saving time
* start/end change
* <L> = 'A' LEAP second announcement
- * <R> = 'R' alternate antenna (reminiscent of PZF535) usually ' '
- * <L> = 'L' on 23:59:60
+ * <R> = 'R' "call bit" used to signalize irregularities in the control facilities,
+ * usually ' ', until 2003 indicated transmission via alternate antenna
+ * (reminiscent of PZF receivers)
+ * <L> = 'L' on 23:59:60
*
* Binary messages have a lead in for a fixed header of SOH
*/
@@ -150,19 +154,20 @@
/* Ret val: the checksum */
/*+-------------------------------------------------------------*/
-unsigned long
+CSUM
mbg_csum(
unsigned char *p,
unsigned int n
)
{
- unsigned long sum = 0;
+ unsigned int sum = 0;
unsigned int i;
-
+
for ( i = 0; i < n; i++ )
sum += *p++;
-
- return( sum );
+
+ return (CSUM) sum;
+
} /* csum */
void
@@ -171,10 +176,10 @@ get_mbg_header(
GPS_MSG_HDR *headerp
)
{
- headerp->gps_cmd = get_lsb_short(bufpp);
- headerp->gps_len = get_lsb_short(bufpp);
- headerp->gps_data_csum = get_lsb_short(bufpp);
- headerp->gps_hdr_csum = get_lsb_short(bufpp);
+ headerp->cmd = (GPS_CMD) get_lsb_short(bufpp);
+ headerp->len = get_lsb_uint16(bufpp);
+ headerp->data_csum = (CSUM) get_lsb_short(bufpp);
+ headerp->hdr_csum = (CSUM) get_lsb_short(bufpp);
}
static struct format meinberg_fmt[] =
@@ -209,10 +214,10 @@ static struct format meinberg_fmt[] =
}
};
-static u_long cvt_meinberg (unsigned char *, int, struct format *, clocktime_t *, void *);
-static u_long cvt_mgps (unsigned char *, int, struct format *, clocktime_t *, void *);
-static u_long mbg_input (parse_t *, unsigned int, timestamp_t *);
-static u_long gps_input (parse_t *, unsigned int, timestamp_t *);
+static parse_cvt_fnc_t cvt_meinberg;
+static parse_cvt_fnc_t cvt_mgps;
+static parse_inp_fnc_t mbg_input;
+static parse_inp_fnc_t gps_input;
struct msg_buf
{
@@ -224,7 +229,7 @@ struct msg_buf
#define MBG_HEADER 1 /* receiving header */
#define MBG_DATA 2 /* receiving data */
#define MBG_STRING 3 /* receiving standard data message */
-
+
clockformat_t clock_meinberg[] =
{
{
@@ -234,7 +239,7 @@ clockformat_t clock_meinberg[] =
0, /* conversion configuration */
"Meinberg Standard", /* Meinberg simple format - beware */
32, /* string buffer */
- 0 /* no private data (complete pakets) */
+ 0 /* no private data (complete packets) */
},
{
mbg_input, /* normal input handling */
@@ -243,21 +248,21 @@ clockformat_t clock_meinberg[] =
0, /* conversion configuration */
"Meinberg Extended", /* Meinberg enhanced format */
32, /* string buffer */
- 0 /* no private data (complete pakets) */
+ 0 /* no private data (complete packets) */
},
{
gps_input, /* no input handling */
- cvt_mgps, /* Meinberg GPS166 conversion */
+ cvt_mgps, /* Meinberg GPS receiver conversion */
pps_one, /* easy PPS monitoring */
(void *)&meinberg_fmt[2], /* conversion configuration */
- "Meinberg GPS Extended", /* Meinberg FAU GPS format */
+ "Meinberg GPS Extended", /* Meinberg FAU GPS format */
512, /* string buffer */
- sizeof(struct msg_buf) /* no private data (complete pakets) */
+ sizeof(struct msg_buf) /* no private data (complete packets) */
}
};
/*
- * cvt_meinberg
+ * parse_cvt_fnc_t cvt_meinberg
*
* convert simple type format
*/
@@ -271,7 +276,7 @@ cvt_meinberg(
)
{
struct format *format;
-
+
/*
* select automagically correct data format
*/
@@ -312,7 +317,7 @@ cvt_meinberg(
else
{
unsigned char *f = &buffer[format->field_offsets[O_FLAGS].offset];
-
+
clock_time->usecond = 0;
clock_time->flags = PARSEB_S_LEAP;
@@ -348,7 +353,7 @@ cvt_meinberg(
case ' ':
clock_time->utcoffset = -1*60*60; /* MET */
break;
-
+
case 'S':
clock_time->utcoffset = -2*60*60; /* MED */
break;
@@ -360,27 +365,27 @@ cvt_meinberg(
clock_time->utcoffset = 0; /* UTC */
clock_time->flags |= PARSEB_UTC;
break;
-
+
default:
return CVT_FAIL|CVT_BADFMT;
}
}
-
+
/*
* gather status flags
*/
if (buffer[format->field_offsets[O_ZONE].offset] == 'S')
clock_time->flags |= PARSEB_DST;
-
+
if (f[0] == '#')
clock_time->flags |= PARSEB_POWERUP;
-
+
if (f[1] == '*')
clock_time->flags |= PARSEB_NOSYNC;
-
+
if (f[3] == '!')
clock_time->flags |= PARSEB_ANNOUNCE;
-
+
/*
* oncoming leap second
* 'a' code not confirmed - earth is not
@@ -388,27 +393,27 @@ cvt_meinberg(
*/
if (f[3] == 'A')
clock_time->flags |= PARSEB_LEAPADD;
-
+
if (f[3] == 'a')
clock_time->flags |= PARSEB_LEAPDEL;
-
-
+
+
if (format->flags & MBG_EXTENDED)
{
clock_time->flags |= PARSEB_S_ANTENNA;
-
+
/*
* DCF77 does not encode the direction -
* so we take the current default -
* earth slowing down
*/
clock_time->flags &= ~PARSEB_LEAPDEL;
-
+
if (f[4] == 'A')
clock_time->flags |= PARSEB_LEAPADD;
-
+
if (f[5] == 'R')
- clock_time->flags |= PARSEB_ALTERNATE;
+ clock_time->flags |= PARSEB_CALLBIT;
}
return CVT_OK;
}
@@ -416,31 +421,31 @@ cvt_meinberg(
/*
- * mbg_input
+ * parse_inp_fnc_t mbg_input
*
- * grep data from input stream
+ * grab data from input stream
*/
static u_long
mbg_input(
parse_t *parseio,
- unsigned int ch,
+ char ch,
timestamp_t *tstamp
)
{
unsigned int rtc;
-
+
parseprintf(DD_PARSE, ("mbg_input(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
-
+
switch (ch)
{
case STX:
parseprintf(DD_PARSE, ("mbg_input: STX seen\n"));
-
+
parseio->parse_index = 1;
parseio->parse_data[0] = ch;
parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
return PARSE_INP_SKIP;
-
+
case ETX:
parseprintf(DD_PARSE, ("mbg_input: ETX seen\n"));
if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
@@ -455,7 +460,7 @@ mbg_input(
/*
- * cvt_mgps
+ * parse_cvt_fnc_t cvt_mgps
*
* convert Meinberg GPS format
*/
@@ -493,9 +498,9 @@ cvt_mgps(
{
long h;
unsigned char *f = &buffer[format->field_offsets[O_FLAGS].offset];
-
+
clock_time->flags = PARSEB_S_LEAP|PARSEB_S_POSITION;
-
+
clock_time->usecond = 0;
/*
@@ -522,22 +527,22 @@ cvt_mgps(
clock_time->utcoffset = -clock_time->utcoffset;
}
}
-
+
/*
* gather status flags
*/
if (buffer[format->field_offsets[O_ZONE].offset] == 'S')
clock_time->flags |= PARSEB_DST;
-
+
if (clock_time->utcoffset == 0)
clock_time->flags |= PARSEB_UTC;
-
+
/*
* no sv's seen - no time & position
*/
if (f[0] == '#')
clock_time->flags |= PARSEB_POWERUP;
-
+
/*
* at least one sv seen - time (for last position)
*/
@@ -546,13 +551,13 @@ cvt_mgps(
else
if (!(clock_time->flags & PARSEB_POWERUP))
clock_time->flags |= PARSEB_POSITION;
-
+
/*
* oncoming zone switch
*/
if (f[3] == '!')
clock_time->flags |= PARSEB_ANNOUNCE;
-
+
/*
* oncoming leap second
* 'a' code not confirmed - earth is not
@@ -560,14 +565,14 @@ cvt_mgps(
*/
if (f[4] == 'A')
clock_time->flags |= PARSEB_LEAPADD;
-
+
if (f[4] == 'a')
clock_time->flags |= PARSEB_LEAPDEL;
/*
* f[5] == ' '
*/
-
+
/*
* this is the leap second
*/
@@ -580,35 +585,35 @@ cvt_mgps(
}
/*
- * gps_input
+ * parse_inp_fnc_t gps_input
*
* grep binary data from input stream
*/
static u_long
gps_input(
parse_t *parseio,
- unsigned int ch,
+ char ch,
timestamp_t *tstamp
)
{
CSUM calc_csum; /* used to compare the incoming csums */
GPS_MSG_HDR header;
struct msg_buf *msg_buf;
-
+
msg_buf = (struct msg_buf *)parseio->parse_pdata;
parseprintf(DD_PARSE, ("gps_input(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
if (!msg_buf)
return PARSE_INP_SKIP;
-
+
if ( msg_buf->phase == MBG_NONE )
{ /* not receiving yet */
switch (ch)
{
case SOH:
parseprintf(DD_PARSE, ("gps_input: SOH seen\n"));
-
+
msg_buf->len = sizeof( header ); /* prepare to receive msg header */
msg_buf->phase = MBG_HEADER; /* receiving header */
break;
@@ -621,7 +626,7 @@ gps_input(
parseio->parse_index = 1;
parseio->parse_data[0] = ch;
break;
-
+
default:
return PARSE_INP_SKIP; /* keep searching */
}
@@ -638,7 +643,7 @@ gps_input(
if ((msg_buf->phase == MBG_STRING) &&
(parseio->parse_index < parseio->parse_dsize))
parseio->parse_data[parseio->parse_index++] = ch;
-
+
parseio->parse_dtime.parse_msg[parseio->parse_dtime.parse_msglen++] = ch;
if (parseio->parse_dtime.parse_msglen > sizeof(parseio->parse_dtime.parse_msg))
@@ -649,7 +654,7 @@ gps_input(
parseio->parse_ldsize = parseio->parse_index;
return PARSE_INP_DATA;
}
-
+
switch (msg_buf->phase)
{
case MBG_HEADER:
@@ -685,41 +690,41 @@ gps_input(
if ( msg_buf->phase == MBG_HEADER )
{ /* header complete now */
unsigned char *datap = parseio->parse_dtime.parse_msg + 1;
-
+
get_mbg_header(&datap, &header);
-
+
parseprintf(DD_PARSE, ("gps_input: header: cmd 0x%x, len %d, dcsum 0x%x, hcsum 0x%x\n",
- (int)header.gps_cmd, (int)header.gps_len, (int)header.gps_data_csum,
- (int)header.gps_hdr_csum));
-
+ (int)header.cmd, (int)header.len, (int)header.data_csum,
+ (int)header.hdr_csum));
+
calc_csum = mbg_csum( (unsigned char *) parseio->parse_dtime.parse_msg + 1, (unsigned short)6 );
- if ( calc_csum != header.gps_hdr_csum )
+ if ( calc_csum != header.hdr_csum )
{
parseprintf(DD_PARSE, ("gps_input: header checksum mismatch expected 0x%x, got 0x%x\n",
(int)calc_csum, (int)mbg_csum( (unsigned char *) parseio->parse_dtime.parse_msg, (unsigned short)6 )));
-
+
msg_buf->phase = MBG_NONE; /* back to hunting mode */
return PARSE_INP_DATA; /* invalid header checksum received - pass up for detection */
}
- if ((header.gps_len == 0) || /* no data to wait for */
- (header.gps_len >= (sizeof (parseio->parse_dtime.parse_msg) - sizeof(header) - 1))) /* blows anything we have space for */
+ if ((header.len == 0) || /* no data to wait for */
+ (header.len >= (sizeof (parseio->parse_dtime.parse_msg) - sizeof(header) - 1))) /* blows anything we have space for */
{
msg_buf->phase = MBG_NONE; /* back to hunting mode */
- return (header.gps_len == 0) ? PARSE_INP_DATA : PARSE_INP_SKIP; /* message complete/throwaway */
+ return (header.len == 0) ? PARSE_INP_DATA : PARSE_INP_SKIP; /* message complete/throwaway */
}
-
- parseprintf(DD_PARSE, ("gps_input: expecting %d bytes of data message\n", (int)header.gps_len));
-
- msg_buf->len = header.gps_len;/* save number of bytes to wait for */
+
+ parseprintf(DD_PARSE, ("gps_input: expecting %d bytes of data message\n", (int)header.len));
+
+ msg_buf->len = header.len;/* save number of bytes to wait for */
msg_buf->phase = MBG_DATA; /* flag header already complete */
return PARSE_INP_SKIP;
}
parseprintf(DD_PARSE, ("gps_input: message data complete\n"));
-
+
/* Header and data have been received. The header checksum has been */
/* checked */
diff --git a/contrib/ntp/libparse/clk_rawdcf.c b/contrib/ntp/libparse/clk_rawdcf.c
index d6e4b18..132fbc3 100644
--- a/contrib/ntp/libparse/clk_rawdcf.c
+++ b/contrib/ntp/libparse/clk_rawdcf.c
@@ -1,12 +1,12 @@
/*
* /src/NTP/REPOSITORY/ntp4-dev/libparse/clk_rawdcf.c,v 4.18 2006/06/22 18:40:01 kardel RELEASE_20060622_A
- *
+ *
* clk_rawdcf.c,v 4.18 2006/06/22 18:40:01 kardel RELEASE_20060622_A
*
* Raw DCF77 pulse clock support
*
* Copyright (c) 1995-2006 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -75,7 +75,8 @@
* Second Contents
* 0 - 10 AM: free, FM: 0
* 11 - 14 free
- * 15 R - alternate antenna
+ * 15 R - "call bit" used to signalize irregularities in the control facilities
+ * (until 2003 indicated transmission via alternate antenna)
* 16 A1 - expect zone change (1 hour before)
* 17 - 18 Z1,Z2 - time zone
* 0 0 illegal
@@ -101,9 +102,9 @@
* 59 - usually missing (minute indication), except for leap insertion
*/
-static u_long pps_rawdcf (parse_t *, int, timestamp_t *);
-static u_long cvt_rawdcf (unsigned char *, int, struct format *, clocktime_t *, void *);
-static u_long inp_rawdcf (parse_t *, unsigned int, timestamp_t *);
+static parse_pps_fnc_t pps_rawdcf;
+static parse_cvt_fnc_t cvt_rawdcf;
+static parse_inp_fnc_t inp_rawdcf;
typedef struct last_tcode {
time_t tcode; /* last converted time code */
@@ -127,13 +128,13 @@ static struct dcfparam
{
const unsigned char *onebits;
const unsigned char *zerobits;
-} dcfparameter =
+} dcfparameter =
{
(const unsigned char *)"###############RADMLS1248124P124812P1248121241248112481248P??", /* 'ONE' representation */
(const unsigned char *)"--------------------s-------p------p----------------------p__" /* 'ZERO' representation */
};
-static struct rawdcfcode
+static struct rawdcfcode
{
char offset; /* start bit */
} rawdcfcode[] =
@@ -189,7 +190,7 @@ ext_bf(
int i, first;
first = rawdcfcode[idx].offset;
-
+
for (i = rawdcfcode[idx+1].offset - 1; i >= first; i--)
{
sum <<= 1;
@@ -238,7 +239,7 @@ convert_rawdcf(
#endif
return CVT_NONE;
}
-
+
for (i = 0; i < size; i++)
{
if ((*s != *b) && (*s != *c))
@@ -307,7 +308,7 @@ convert_rawdcf(
clock_time->flags |= PARSEB_LEAPADD; /* default: DCF77 data format deficiency */
if (ext_bf(buffer, DCF_R, dcfprm->zerobits))
- clock_time->flags |= PARSEB_ALTERNATE;
+ clock_time->flags |= PARSEB_CALLBIT;
parseprintf(DD_RAWDCF,("parse: convert_rawdcf: TIME CODE OK: %d:%d, %d.%d.%d, flags 0x%lx\n",
(int)clock_time->hour, (int)clock_time->minute, (int)clock_time->day, (int)clock_time->month,(int) clock_time->year,
@@ -327,6 +328,7 @@ convert_rawdcf(
}
/*
+ * parse_cvt_fnc_t cvt_rawdcf
* raw dcf input routine - needs to fix up 50 baud
* characters for 1/0 decision
*/
@@ -379,7 +381,7 @@ cvt_rawdcf(
ch >>= 1;
}
- *s = i;
+ *s = (unsigned char) i;
histbuf[i]++;
cutoff += i;
lowmax++;
@@ -504,12 +506,12 @@ cvt_rawdcf(
}
}
}
-
+
return rtc;
}
/*
- * pps_rawdcf
+ * parse_pps_fnc_t pps_rawdcf
*
* currently a very stupid version - should be extended to decode
* also ones and zeros (which is easy)
@@ -546,30 +548,30 @@ snt_rawdcf(
#else
parseio->parse_dtime.parse_time.fp.l_ui++;
#endif
-
+
parseprintf(DD_RAWDCF,("parse: snt_rawdcf: time stamp synthesized offset %d seconds\n", parseio->parse_index - 1));
-
+
return updatetimeinfo(parseio, parseio->parse_lstate);
}
return CVT_NONE;
}
/*
- * inp_rawdcf
+ * parse_inp_fnc_t inp_rawdcf
*
* grab DCF77 data from input stream
*/
static u_long
inp_rawdcf(
parse_t *parseio,
- unsigned int ch,
+ char ch,
timestamp_t *tstamp
)
{
static struct timeval timeout = { 1, 500000 }; /* 1.5 secongs denote second #60 */
-
+
parseprintf(DD_PARSE, ("inp_rawdcf(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
-
+
parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
if (parse_timedout(parseio, tstamp, &timeout))
@@ -583,7 +585,7 @@ inp_rawdcf(
else
{
unsigned int rtc;
-
+
rtc = parse_addchar(parseio, ch);
if (rtc == PARSE_INP_SKIP)
{
diff --git a/contrib/ntp/libparse/clk_rcc8000.c b/contrib/ntp/libparse/clk_rcc8000.c
index 6dca166..a690e588 100644
--- a/contrib/ntp/libparse/clk_rcc8000.c
+++ b/contrib/ntp/libparse/clk_rcc8000.c
@@ -1,6 +1,6 @@
/*
* /src/NTP/ntp4-dev/libparse/clk_rcc8000.c,v 4.9 2004/11/14 15:29:41 kardel RELEASE_20050508_A
- *
+ *
* clk_rcc8000.c,v 4.9 2004/11/14 15:29:41 kardel RELEASE_20050508_A
*
* Radiocode Clocks Ltd RCC 8000 Intelligent Off-Air Master Clock support
@@ -49,16 +49,16 @@ extern int printf (const char *, ...);
#define O_USEC O_WDAY
static struct format rcc8000_fmt =
-{ { { 13, 2 }, {16, 2}, { 19, 2}, /* Day, Month, Year */
- { 0, 2 }, { 3, 2}, { 6, 2}, /* Hour, Minute, Second */
+{ { { 13, 2 }, {16, 2}, { 19, 2}, /* Day, Month, Year */
+ { 0, 2 }, { 3, 2}, { 6, 2}, /* Hour, Minute, Second */
{ 9, 3 }, {28, 1}, { 0, 0}, /* uSec, Status (Valid,Reject,BST,Leapyear) */ },
- (const unsigned char *)" : : . / / \r\n",
+ (const unsigned char *)" : : . / / \r\n",
/*"15:50:36.534 30/09/94 273 5 A\x0d\x0a" */
- 0
+ 0
};
-static unsigned long cvt_rcc8000 (unsigned char *, int, struct format *, clocktime_t *, void *);
-static unsigned long inp_rcc8000 (parse_t *, unsigned int, timestamp_t *);
+static parse_cvt_fnc_t cvt_rcc8000;
+static parse_inp_fnc_t inp_rcc8000;
clockformat_t clock_rcc8000 =
{
@@ -71,7 +71,8 @@ clockformat_t clock_rcc8000 =
0 /* no private data */
};
-static unsigned long
+/* parse_cvt_fnc_t cvt_rcc8000 */
+static u_long
cvt_rcc8000(
unsigned char *buffer,
int size,
@@ -121,27 +122,27 @@ cvt_rcc8000(
clock_time->flags |= PARSEB_POWERUP;
clock_time->flags |= PARSEB_UTC; /* British special - guess why 8-) */
-
+
/* other flags not used */
}
return CVT_OK;
}
/*
- * inp_rcc8000
+ * parse_inp_fnc_t inp_rcc8000
*
- * grep data from input stream
+ * grab data from input stream
*/
static u_long
inp_rcc8000(
parse_t *parseio,
- unsigned int ch,
+ char ch,
timestamp_t *tstamp
)
{
unsigned int rtc;
-
+
parseprintf(DD_PARSE, ("inp_rcc8000(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
-
+
switch (ch)
{
case '\n':
@@ -150,7 +151,7 @@ inp_rcc8000(
return parse_end(parseio);
else
return rtc;
-
+
default:
if (parseio->parse_index == 0) /* take sample at start of message */
diff --git a/contrib/ntp/libparse/clk_schmid.c b/contrib/ntp/libparse/clk_schmid.c
index 045f0fc..5e303b9 100644
--- a/contrib/ntp/libparse/clk_schmid.c
+++ b/contrib/ntp/libparse/clk_schmid.c
@@ -1,13 +1,13 @@
/*
* /src/NTP/ntp4-dev/libparse/clk_schmid.c,v 4.9 2005/04/16 17:32:10 kardel RELEASE_20050508_A
- *
+ *
* clk_schmid.c,v 4.9 2005/04/16 17:32:10 kardel RELEASE_20050508_A
*
* Schmid clock support
* based on information and testing from Adam W. Feigin et. al (Swisstime iis.ethz.ch)
*
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -61,7 +61,7 @@ extern int printf (const char *, ...);
* The command to Schmid's DCF77 clock is a single byte; each bit
* allows the user to select some part of the time string, as follows (the
* output for the lsb is sent first).
- *
+ *
* Bit 0: time in MEZ, 4 bytes *binary, not BCD*; hh.mm.ss.tenths
* Bit 1: date 3 bytes *binary, not BCD: dd.mm.yy
* Bit 2: week day, 1 byte (unused here)
@@ -82,15 +82,15 @@ extern int printf (const char *, ...);
#define WS_TIME 0x01
#define WS_SIGNAL 0x02
-#define WS_ALTERNATE 0x01
+#define WS_CALLBIT 0x01 /* "call bit" used to signalize irregularities in the control facilities */
#define WS_ANNOUNCE 0x02
#define WS_TZ 0x0c
#define WS_MET 0x08
#define WS_MEST 0x04
#define WS_LEAP 0x10
-static u_long cvt_schmid (unsigned char *, int, struct format *, clocktime_t *, void *);
-static unsigned long inp_schmid (parse_t *, unsigned int, timestamp_t *);
+static parse_cvt_fnc_t cvt_schmid;
+static parse_inp_fnc_t inp_schmid;
clockformat_t clock_schmid =
{
@@ -103,7 +103,7 @@ clockformat_t clock_schmid =
0, /* no private data (complete messages) */
};
-
+/* parse_cvt_fnc_t */
static u_long
cvt_schmid(
unsigned char *buffer,
@@ -155,7 +155,7 @@ cvt_schmid(
default:
return CVT_FAIL|CVT_BADFMT;
}
-
+
if (!(buffer[7] & WS_TIME))
{
clock_time->flags |= PARSEB_POWERUP;
@@ -168,9 +168,9 @@ cvt_schmid(
if (buffer[7] & WS_SIGNAL)
{
- if (buffer[8] & WS_ALTERNATE)
+ if (buffer[8] & WS_CALLBIT)
{
- clock_time->flags |= PARSEB_ALTERNATE;
+ clock_time->flags |= PARSEB_CALLBIT;
}
if (buffer[8] & WS_ANNOUNCE)
@@ -185,32 +185,32 @@ cvt_schmid(
}
clock_time->flags |= PARSEB_S_LEAP|PARSEB_S_ANTENNA;
-
+
return CVT_OK;
}
}
}
/*
- * inp_schmid
+ * parse_inp_fnc_t inp_schmid
*
- * grep data from input stream
+ * grab data from input stream
*/
static u_long
inp_schmid(
parse_t *parseio,
- unsigned int ch,
+ char ch,
timestamp_t *tstamp
)
{
unsigned int rtc;
-
+
parseprintf(DD_PARSE, ("inp_schmid(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
-
- switch (ch)
+
+ switch ((uint8_t)ch)
{
case 0xFD: /* */
- parseprintf(DD_PARSE, ("mbg_input: ETX seen\n"));
+ parseprintf(DD_PARSE, ("inp_schmid: 0xFD seen\n"));
if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
return parse_end(parseio);
else
diff --git a/contrib/ntp/libparse/clk_sel240x.c b/contrib/ntp/libparse/clk_sel240x.c
index a09d347..b1390b4 100644
--- a/contrib/ntp/libparse/clk_sel240x.c
+++ b/contrib/ntp/libparse/clk_sel240x.c
@@ -3,7 +3,7 @@
// Schweitzer Engineering Laboratories, Inc. <opensource@selinc.com>
//////////////////////////////////////////////////////////////////////////////
-// Need to have _XOPEN_SOURCE defined for time.h to give the
+// Need to have _XOPEN_SOURCE defined for time.h to give the
// correct strptime signature. As per feature_test_macros(7),
// define this before including any header files.
@@ -51,14 +51,8 @@
// a '?'. But we are only going to call it synced when we receive a ' '
//////////////////////////////////////////////////////////////////////////////
-static unsigned long inp_sel240x( parse_t *parseio,
- unsigned int ch,
- timestamp_t *tstamp);
-static unsigned long cvt_sel240x( unsigned char *buffer,
- int size,
- struct format *format,
- clocktime_t *clock_time,
- void *local );
+static parse_inp_fnc_t inp_sel240x;
+static parse_cvt_fnc_t cvt_sel240x;
// Parse clock format structure describing the message above
static struct format sel240x_fmt =
@@ -94,7 +88,7 @@ clockformat_t clock_sel240x =
//////////////////////////////////////////////////////////////////////////////
static unsigned long
inp_sel240x( parse_t *parseio,
- unsigned int ch,
+ char ch,
timestamp_t *tstamp
)
{
@@ -139,7 +133,7 @@ cvt_sel240x( unsigned char *buffer,
{
struct tm ptime;
buffer++;
- buffer = (unsigned char *) strptime(
+ buffer = (unsigned char *) strptime(
(const char *)buffer, "%Y:%j:%H:%M:%S", &ptime );
if( *(buffer+1) != '\x0d' )
{
diff --git a/contrib/ntp/libparse/clk_trimtaip.c b/contrib/ntp/libparse/clk_trimtaip.c
index 322d0fa..426e897 100644
--- a/contrib/ntp/libparse/clk_trimtaip.c
+++ b/contrib/ntp/libparse/clk_trimtaip.c
@@ -6,7 +6,7 @@
* Trimble SV6 clock support - several collected codepieces
*
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -78,8 +78,8 @@ extern int printf (const char *, ...);
0
};
-static unsigned long cvt_trimtaip (unsigned char *, int, struct format *, clocktime_t *, void *);
-static unsigned long inp_trimtaip (parse_t *, unsigned int, timestamp_t *);
+static parse_cvt_fnc_t cvt_trimtaip;
+static parse_inp_fnc_t inp_trimtaip;
clockformat_t clock_trimtaip =
{
@@ -92,7 +92,8 @@ clockformat_t clock_trimtaip =
0 /* no private data */
};
-static unsigned long
+/* parse_cvt_fnc_t cvt_trimtaip */
+static u_long
cvt_trimtaip(
unsigned char *buffer,
int size,
@@ -141,31 +142,31 @@ cvt_trimtaip(
}
/*
- * inp_trimtaip
+ * parse_inp_fnc_t inp_trimtaip
*
- * grep data from input stream
+ * grab data from input stream
*/
static u_long
inp_trimtaip(
parse_t *parseio,
- unsigned int ch,
+ char ch,
timestamp_t *tstamp
)
{
unsigned int rtc;
-
+
parseprintf(DD_PARSE, ("inp_trimtaip(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
-
+
switch (ch)
{
case '>':
parseprintf(DD_PARSE, ("inp_trimptaip: START seen\n"));
-
+
parseio->parse_index = 1;
parseio->parse_data[0] = ch;
parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
return PARSE_INP_SKIP;
-
+
case '<':
parseprintf(DD_PARSE, ("inp_trimtaip: END seen\n"));
if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
diff --git a/contrib/ntp/libparse/clk_trimtsip.c b/contrib/ntp/libparse/clk_trimtsip.c
index 743e39c..6c71d75 100644
--- a/contrib/ntp/libparse/clk_trimtsip.c
+++ b/contrib/ntp/libparse/clk_trimtsip.c
@@ -7,7 +7,7 @@
* Thanks to Sven Dietrich for providing test hardware
*
* Copyright (c) 1995-2009 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -116,7 +116,7 @@ struct trimble
#define STATUS_UNSAFE 1 /* not enough receivers for full precision */
#define STATUS_SYNC 2 /* enough information for good operation */
-static unsigned long inp_tsip (parse_t *, unsigned int, timestamp_t *);
+static unsigned long inp_tsip (parse_t *, char, timestamp_t *);
static unsigned long cvt_trimtsip (unsigned char *, int, struct format *, clocktime_t *, void *);
struct clockformat clock_trimtsip =
@@ -136,7 +136,7 @@ struct clockformat clock_trimtsip =
static unsigned long
inp_tsip(
parse_t *parseio,
- unsigned int ch,
+ char ch,
timestamp_t *tstamp
)
{
@@ -183,7 +183,7 @@ inp_tsip(
/* DLE,ETX -> end of packet */
parseio->parse_data[parseio->parse_index++] = DLE;
parseio->parse_data[parseio->parse_index] = ch;
- parseio->parse_ldsize = parseio->parse_index+1;
+ parseio->parse_ldsize = (u_short) (parseio->parse_index + 1);
memcpy(parseio->parse_ldata, parseio->parse_data, parseio->parse_ldsize);
parseio->parse_dtime.parse_msg[parseio->parse_dtime.parse_msglen++] = DLE;
parseio->parse_dtime.parse_msg[parseio->parse_dtime.parse_msglen++] = ch;
@@ -200,13 +200,13 @@ inp_tsip(
return PARSE_INP_SKIP;
}
-
-static int
+
+static short
getshort(
unsigned char *p
)
{
- return get_msb_short(&p);
+ return (short) get_msb_short(&p);
}
/*
@@ -245,7 +245,7 @@ cvt_trimtsip(
{
unsigned char *bp;
cmd = buffer[1];
-
+
switch(cmd)
{
case CMD_RCURTIME:
@@ -258,15 +258,15 @@ cvt_trimtsip(
bp = &mb(0);
if (fetch_ieee754(&bp, IEEE_SINGLE, &secs, trim_offsets) != IEEE_OK)
return CVT_FAIL|CVT_BADFMT;
-
+
if ((secs.l_i <= 0) ||
(t->t_utcknown == 0))
{
clock_time->flags = PARSEB_POWERUP;
return CVT_OK;
}
- if (week < 990) {
- week += 1024;
+ if (week < GPSWRAP) {
+ week += GPSWEEKS;
}
/* time OK */
@@ -275,7 +275,7 @@ cvt_trimtsip(
bp = &mb(6);
if (fetch_ieee754(&bp, IEEE_SINGLE, &utcoffset, trim_offsets) != IEEE_OK)
return CVT_FAIL|CVT_BADFMT;
-
+
L_SUB(&secs, &utcoffset); /* adjust GPS time to UTC time */
gpstolfp((unsigned short)week, (unsigned short)0,
@@ -289,10 +289,10 @@ cvt_trimtsip(
if (t->t_leap == ADDSECOND)
clock_time->flags |= PARSEB_LEAPADD;
-
+
if (t->t_leap == DELSECOND)
clock_time->flags |= PARSEB_LEAPDEL;
-
+
switch (t->t_operable)
{
case STATUS_SYNC:
@@ -307,12 +307,12 @@ cvt_trimtsip(
clock_time->flags |= PARSEB_NOSYNC|PARSEB_POWERUP;
break;
}
-
+
if (t->t_mode == 0)
clock_time->flags |= PARSEB_POSITION;
-
+
clock_time->flags |= PARSEB_S_LEAP|PARSEB_S_POSITION;
-
+
return CVT_OK;
} /* case 0x41 */
@@ -346,26 +346,26 @@ cvt_trimtsip(
{
l_fp t0t;
unsigned char *lbp;
-
+
/* UTC correction data - derive a leap warning */
- int tls = t->t_gpsutc = getshort((unsigned char *)&mb(12)); /* current leap correction (GPS-UTC) */
- int tlsf = t->t_gpsutcleap = getshort((unsigned char *)&mb(24)); /* new leap correction */
-
- t->t_weekleap = getshort((unsigned char *)&mb(20)); /* week no of leap correction */
- if (t->t_weekleap < 990)
- t->t_weekleap += 1024;
-
- t->t_dayleap = getshort((unsigned char *)&mb(22)); /* day in week of leap correction */
- t->t_week = getshort((unsigned char *)&mb(18)); /* current week no */
- if (t->t_week < 990)
- t->t_week += 1024;
-
+ int tls = t->t_gpsutc = (u_short) getshort((unsigned char *)&mb(12)); /* current leap correction (GPS-UTC) */
+ int tlsf = t->t_gpsutcleap = (u_short) getshort((unsigned char *)&mb(24)); /* new leap correction */
+
+ t->t_weekleap = (u_short) getshort((unsigned char *)&mb(20)); /* week no of leap correction */
+ if (t->t_weekleap < GPSWRAP)
+ t->t_weekleap = (u_short)(t->t_weekleap + GPSWEEKS);
+
+ t->t_dayleap = (u_short) getshort((unsigned char *)&mb(22)); /* day in week of leap correction */
+ t->t_week = (u_short) getshort((unsigned char *)&mb(18)); /* current week no */
+ if (t->t_week < GPSWRAP)
+ t->t_week = (u_short)(t->t_weekleap + GPSWEEKS);
+
lbp = (unsigned char *)&mb(14); /* last update time */
if (fetch_ieee754(&lbp, IEEE_SINGLE, &t0t, trim_offsets) != IEEE_OK)
return CVT_FAIL|CVT_BADFMT;
t->t_utcknown = t0t.l_ui != 0;
-
+
if ((t->t_utcknown) && /* got UTC information */
(tlsf != tls) && /* something will change */
((t->t_weekleap - t->t_week) < 5)) /* and close in the future */
diff --git a/contrib/ntp/libparse/clk_varitext.c b/contrib/ntp/libparse/clk_varitext.c
index 295ce0a..022549e 100644
--- a/contrib/ntp/libparse/clk_varitext.c
+++ b/contrib/ntp/libparse/clk_varitext.c
@@ -9,14 +9,14 @@
* clk_varitext.c,v 1.5 2005/04/16 17:32:10 kardel RELEASE_20050508_A
*
* Varitext code variant by A.McConnell 1997/01/19
- *
+ *
* Supports Varitext's Radio Clock
- *
+ *
* Used the Meinberg/Computime clock as a template for Varitext Radio Clock
*
* Codebase:
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -67,31 +67,31 @@ static const u_char VT_LAST_TELEGRAM_OK = 0x20;
/*
* The Varitext receiver sends a datagram in the following format every minute
- *
- * Timestamp T:YY:MM:MD:WD:HH:MM:SSCRLFSTXXX
+ *
+ * Timestamp T:YY:MM:MD:WD:HH:MM:SSCRLFSTXXX
* Pos 0123456789012345678901 2 3 4567
* 0000000000111111111122 2 2 2222
- * Parse T: : : : : : : \r\n
- *
- * T Startcharacter "T" specifies start of the timestamp
- * YY Year MM Month 1-12
- * MD Day of the month
- * WD Day of week
- * HH Hour
- * MM Minute
- * SS Second
- * CR Carriage return
- * LF Linefeed
+ * Parse T: : : : : : : \r\n
+ *
+ * T Startcharacter "T" specifies start of the timestamp
+ * YY Year MM Month 1-12
+ * MD Day of the month
+ * WD Day of week
+ * HH Hour
+ * MM Minute
+ * SS Second
+ * CR Carriage return
+ * LF Linefeed
* ST Status character
* Bit 0 - Set= Initialised; Reset=Time Invalid (DO NOT USE)
- * Bit 1 - Set= Synchronised; Reset= Unsynchronised
- * Bit 2 - Set= Alarm state; Reset= No alarm
- * Bit 3 - Set= BST; Reset= GMT
- * Bit 4 - Set= Seasonal change in approx hour; Reset= No seasonal change expected
+ * Bit 1 - Set= Synchronised; Reset= Unsynchronised
+ * Bit 2 - Set= Alarm state; Reset= No alarm
+ * Bit 3 - Set= BST; Reset= GMT
+ * Bit 4 - Set= Seasonal change in approx hour; Reset= No seasonal change expected
* Bit 5 - Set= Last MSF telegram was OK; Reset= Last telegram was in error;
- * Bit 6 - Always set
+ * Bit 6 - Always set
* Bit 7 - Unused
- * XXX Checksum calculated using Fletcher's method (ignored for now).
+ * XXX Checksum calculated using Fletcher's method (ignored for now).
*/
static struct format varitext_fmt =
@@ -105,8 +105,8 @@ static struct format varitext_fmt =
0
};
-static u_long cvt_varitext (unsigned char *, int, struct format *, clocktime_t *, void *);
-static u_long inp_varitext (parse_t *, unsigned int, timestamp_t *);
+static parse_cvt_fnc_t cvt_varitext;
+static parse_inp_fnc_t inp_varitext;
struct varitext {
unsigned char start_found;
@@ -128,11 +128,11 @@ clockformat_t clock_varitext =
};
/*
- * cvt_varitext
- *
+ * parse_cvt_fnc_t cvt_varitext
+ *
* convert simple type format
*/
-static u_long
+static u_long
cvt_varitext(
unsigned char *buffer,
int size,
@@ -142,7 +142,7 @@ cvt_varitext(
)
{
- if (!Strok(buffer, format->fixed_string)) {
+ if (!Strok(buffer, format->fixed_string)) {
return CVT_NONE;
} else {
if (Stoi(&buffer[format->field_offsets[O_DAY].offset], &clock_time->day,
@@ -156,7 +156,7 @@ cvt_varitext(
Stoi(&buffer[format->field_offsets[O_MIN].offset], &clock_time->minute,
format->field_offsets[O_MIN].length) ||
Stoi(&buffer[format->field_offsets[O_SEC].offset], &clock_time->second,
- format->field_offsets[O_SEC].length)) {
+ format->field_offsets[O_SEC].length)) {
return CVT_FAIL | CVT_BADFMT;
} else {
u_char *f = (u_char*) &buffer[format->field_offsets[O_FLAGS].offset];
@@ -170,24 +170,25 @@ cvt_varitext(
clock_time->flags |= PARSEB_DST;
}
/*
- if (!((*f) & VT_INITIALISED)) Clock not initialised
+ if (!((*f) & VT_INITIALISED)) Clock not initialised
clock_time->flags |= PARSEB_POWERUP;
-
- if (!((*f) & VT_SYNCHRONISED)) Clock not synchronised
+
+ if (!((*f) & VT_SYNCHRONISED)) Clock not synchronised
clock_time->flags |= PARSEB_NOSYNC;
-
- if (((*f) & VT_SEASON_CHANGE)) Seasonal change expected in the next hour
+
+ if (((*f) & VT_SEASON_CHANGE)) Seasonal change expected in the next hour
clock_time->flags |= PARSEB_ANNOUNCE;
*/
- return CVT_OK;
+ return CVT_OK;
}
}
}
-static u_long
+/* parse_inp_fnc_t inp_varitext */
+static u_long
inp_varitext(
parse_t *parseio,
- unsigned int ch,
+ char ch,
timestamp_t *tstamp
)
{
@@ -196,10 +197,10 @@ inp_varitext(
parseprintf(DD_PARSE, ("inp_varitext(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
- if (!t)
+ if (!t)
return PARSE_INP_SKIP; /* local data not allocated - sigh! */
- if (ch == 'T')
+ if (ch == 'T')
t->tstamp = *tstamp;
if ((t->previous_ch == 'T') && (ch == ':'))
@@ -224,7 +225,7 @@ inp_varitext(
return rtc;
}
- if (t->end_found)
+ if (t->end_found)
{
if (++(t->end_count) == 4) /* Finally found the end of the message */
{
@@ -235,16 +236,16 @@ inp_varitext(
return parse_end(parseio);
else
return rtc;
- }
+ }
}
- if ((t->previous_ch == '\r') && (ch == '\n'))
+ if ((t->previous_ch == '\r') && (ch == '\n'))
{
t->end_found = 1;
}
}
-
+
t->previous_ch = ch;
return PARSE_INP_SKIP;
diff --git a/contrib/ntp/libparse/clk_wharton.c b/contrib/ntp/libparse/clk_wharton.c
index 55ab43a..a65bc53 100644
--- a/contrib/ntp/libparse/clk_wharton.c
+++ b/contrib/ntp/libparse/clk_wharton.c
@@ -74,8 +74,11 @@ extern void printf (const char *, ...);
*
*/
+static parse_cvt_fnc_t cvt_wharton_400a;
+static parse_inp_fnc_t inp_wharton_400a;
+
/*
- * cvt_wharton_400a
+ * parse_cvt_fnc_t cvt_wharton_400a
*
* convert simple type format
*/
@@ -121,14 +124,14 @@ cvt_wharton_400a(
}
/*
- * inp_wharton_400a
+ * parse_inp_fnc_t inp_wharton_400a
*
- * grep data from input stream
+ * grab data from input stream
*/
static u_long
inp_wharton_400a(
parse_t *parseio,
- unsigned int ch,
+ char ch,
timestamp_t *tstamp
)
{
@@ -166,7 +169,7 @@ clockformat_t clock_wharton_400a =
0, /* conversion configuration */
"WHARTON 400A Series clock Output Format 1", /* String format name */
15, /* string buffer */
- 0 /* no private data (complete pakets) */
+ 0 /* no private data (complete packets) */
};
#else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_WHARTON_400A) */
diff --git a/contrib/ntp/libparse/data_mbg.c b/contrib/ntp/libparse/data_mbg.c
index 23ca755..0b3808c 100644
--- a/contrib/ntp/libparse/data_mbg.c
+++ b/contrib/ntp/libparse/data_mbg.c
@@ -43,6 +43,7 @@
#include "ntp_types.h"
#include "ntp_stdlib.h"
#include "ntp_fp.h"
+#include "ntp_calendar.h"
#include "mbg_gps166.h"
#include "binio.h"
#include "ieee754io.h"
@@ -63,10 +64,10 @@ put_mbg_header(
GPS_MSG_HDR *headerp
)
{
- put_lsb_short(bufpp, headerp->gps_cmd);
- put_lsb_short(bufpp, headerp->gps_len);
- put_lsb_short(bufpp, headerp->gps_data_csum);
- put_lsb_short(bufpp, headerp->gps_hdr_csum);
+ put_lsb_short(bufpp, headerp->cmd);
+ put_lsb_short(bufpp, headerp->len);
+ put_lsb_short(bufpp, headerp->data_csum);
+ put_lsb_short(bufpp, headerp->hdr_csum);
}
void
@@ -75,7 +76,7 @@ get_mbg_sw_rev(
SW_REV *sw_revp
)
{
- sw_revp->code = get_lsb_short(bufpp);
+ sw_revp->code = get_lsb_uint16(bufpp);
memcpy(sw_revp->name, *bufpp, sizeof(sw_revp->name));
*bufpp += sizeof(sw_revp->name);
}
@@ -86,8 +87,8 @@ get_mbg_ascii_msg(
ASCII_MSG *ascii_msgp
)
{
- ascii_msgp->csum = get_lsb_short(bufpp);
- ascii_msgp->valid = get_lsb_short(bufpp);
+ ascii_msgp->csum = (CSUM) get_lsb_short(bufpp);
+ ascii_msgp->valid = get_lsb_int16(bufpp);
memcpy(ascii_msgp->s, *bufpp, sizeof(ascii_msgp->s));
*bufpp += sizeof(ascii_msgp->s);
}
@@ -98,7 +99,7 @@ get_mbg_svno(
SVNO *svnop
)
{
- *svnop = get_lsb_short(bufpp);
+ *svnop = (SVNO) get_lsb_short(bufpp);
}
void
@@ -107,7 +108,7 @@ get_mbg_health(
HEALTH *healthp
)
{
- *healthp = get_lsb_short(bufpp);
+ *healthp = (HEALTH) get_lsb_short(bufpp);
}
void
@@ -116,7 +117,7 @@ get_mbg_cfg(
CFG *cfgp
)
{
- *cfgp = get_lsb_short(bufpp);
+ *cfgp = (CFG) get_lsb_short(bufpp);
}
void
@@ -125,7 +126,7 @@ get_mbg_tgps(
T_GPS *tgpsp
)
{
- tgpsp->wn = get_lsb_short(bufpp);
+ tgpsp->wn = get_lsb_uint16(bufpp);
tgpsp->sec = get_lsb_long(bufpp);
tgpsp->tick = get_lsb_long(bufpp);
}
@@ -133,20 +134,20 @@ get_mbg_tgps(
void
get_mbg_tm(
unsigned char **buffpp,
- TM *tmp
+ TM_GPS *tmp
)
{
- tmp->year = get_lsb_short(buffpp);
+ tmp->year = get_lsb_int16(buffpp);
tmp->month = *(*buffpp)++;
- tmp->mday = *(*buffpp)++;
- tmp->yday = get_lsb_short(buffpp);
- tmp->wday = *(*buffpp)++;
- tmp->hour = *(*buffpp)++;
- tmp->minute = *(*buffpp)++;
- tmp->second = *(*buffpp)++;
- tmp->frac = get_lsb_long(buffpp);
+ tmp->mday = *(*buffpp)++;
+ tmp->yday = get_lsb_int16(buffpp);
+ tmp->wday = *(*buffpp)++;
+ tmp->hour = *(*buffpp)++;
+ tmp->min = *(*buffpp)++;
+ tmp->sec = *(*buffpp)++;
+ tmp->frac = get_lsb_long(buffpp);
tmp->offs_from_utc = get_lsb_long(buffpp);
- tmp->status= get_lsb_short(buffpp);
+ tmp->status = get_lsb_uint16(buffpp);
}
void
@@ -155,7 +156,7 @@ get_mbg_ttm(
TTM *ttmp
)
{
- ttmp->channel = get_lsb_short(buffpp);
+ ttmp->channel = get_lsb_int16(buffpp);
get_mbg_tgps(buffpp, &ttmp->t);
get_mbg_tm(buffpp, &ttmp->tm);
}
@@ -166,9 +167,9 @@ get_mbg_synth(
SYNTH *synthp
)
{
- synthp->freq = get_lsb_short(buffpp);
- synthp->range = get_lsb_short(buffpp);
- synthp->phase = get_lsb_short(buffpp);
+ synthp->freq = get_lsb_int16(buffpp);
+ synthp->range = get_lsb_int16(buffpp);
+ synthp->phase = get_lsb_int16(buffpp);
}
static void
@@ -201,7 +202,7 @@ get_mbg_antinfo(
ANT_INFO *antinfop
)
{
- antinfop->status = get_lsb_short(buffpp);
+ antinfop->status = get_lsb_int16(buffpp);
get_mbg_tm(buffpp, &antinfop->tm_disconn);
get_mbg_tm(buffpp, &antinfop->tm_reconn);
antinfop->delta_t = get_lsb_long(buffpp);
@@ -216,8 +217,8 @@ mbg_time_status_str(
{
static struct state
{
- int flag; /* bit flag */
- const char *string; /* bit name */
+ int flag; /* bit flag */
+ const char *string; /* bit name */
} states[] =
{
{ TM_UTC, "UTC CORR" },
@@ -233,7 +234,7 @@ mbg_time_status_str(
{
char *start, *p;
struct state *s;
-
+
start = p = *buffpp;
for (s = states; s->flag; s++)
@@ -252,25 +253,27 @@ mbg_time_status_str(
*buffpp = p;
}
}
-
+
void
mbg_tm_str(
char **buffpp,
- TM *tmp,
- int size
+ TM_GPS *tmp,
+ int size,
+ int print_status
)
{
char *s = *buffpp;
snprintf(*buffpp, size, "%04d-%02d-%02d %02d:%02d:%02d.%07ld (%c%02d%02d) ",
tmp->year, tmp->month, tmp->mday,
- tmp->hour, tmp->minute, tmp->second, tmp->frac,
+ tmp->hour, tmp->min, tmp->sec, (long) tmp->frac,
(tmp->offs_from_utc < 0) ? '-' : '+',
abs((int)tmp->offs_from_utc) / 3600,
(abs((int)tmp->offs_from_utc) / 60) % 60);
*buffpp += strlen(*buffpp);
- mbg_time_status_str(buffpp, tmp->status, size - (*buffpp - s));
+ if (print_status)
+ mbg_time_status_str(buffpp, tmp->status, size - (*buffpp - s));
}
void
@@ -281,8 +284,8 @@ mbg_tgps_str(
)
{
snprintf(*buffpp, size, "week %d + %ld days + %ld.%07ld sec",
- tgpsp->wn, tgpsp->sec / 86400,
- tgpsp->sec % 86400, tgpsp->tick);
+ tgpsp->wn, (long) tgpsp->sec / SECSPERDAY,
+ (long) tgpsp->sec % SECSPERDAY, (long) tgpsp->tick);
*buffpp += strlen(*buffpp);
}
@@ -293,19 +296,19 @@ get_mbg_cfgh(
)
{
int i;
-
- cfghp->csum = get_lsb_short(buffpp);
- cfghp->valid = get_lsb_short(buffpp);
+
+ cfghp->csum = (CSUM) get_lsb_short(buffpp);
+ cfghp->valid = get_lsb_int16(buffpp);
get_mbg_tgps(buffpp, &cfghp->tot_51);
get_mbg_tgps(buffpp, &cfghp->tot_63);
get_mbg_tgps(buffpp, &cfghp->t0a);
- for (i = MIN_SVNO; i <= MAX_SVNO; i++)
+ for (i = 0; i < N_SVNO_GPS; i++)
{
get_mbg_cfg(buffpp, &cfghp->cfg[i]);
}
-
- for (i = MIN_SVNO; i <= MAX_SVNO; i++)
+
+ for (i = 0; i < N_SVNO_GPS; i++)
{
get_mbg_health(buffpp, &cfghp->health[i]);
}
@@ -317,23 +320,23 @@ get_mbg_utc(
UTC *utcp
)
{
- utcp->csum = get_lsb_short(buffpp);
- utcp->valid = get_lsb_short(buffpp);
+ utcp->csum = (CSUM) get_lsb_short(buffpp);
+ utcp->valid = get_lsb_int16(buffpp);
get_mbg_tgps(buffpp, &utcp->t0t);
-
+
if (fetch_ieee754(buffpp, IEEE_DOUBLE, &utcp->A0, mbg_double) != IEEE_OK)
{
L_CLR(&utcp->A0);
}
-
+
if (fetch_ieee754(buffpp, IEEE_DOUBLE, &utcp->A1, mbg_double) != IEEE_OK)
{
L_CLR(&utcp->A1);
}
- utcp->WNlsf = get_lsb_short(buffpp);
- utcp->DNt = get_lsb_short(buffpp);
+ utcp->WNlsf = get_lsb_uint16(buffpp);
+ utcp->DNt = get_lsb_int16(buffpp);
utcp->delta_tls = *(*buffpp)++;
utcp->delta_tlsf = *(*buffpp)++;
}
@@ -345,7 +348,7 @@ get_mbg_lla(
)
{
int i;
-
+
for (i = LAT; i <= ALT; i++)
{
if (fetch_ieee754(buffpp, IEEE_DOUBLE, &lla[i], mbg_double) != IEEE_OK)
@@ -367,7 +370,7 @@ get_mbg_xyz(
)
{
int i;
-
+
for (i = XP; i <= ZP; i++)
{
if (fetch_ieee754(buffpp, IEEE_DOUBLE, &xyz[i], mbg_double) != IEEE_OK)
@@ -384,13 +387,13 @@ get_mbg_comparam(
)
{
size_t i;
-
+
comparamp->baud_rate = get_lsb_long(buffpp);
for (i = 0; i < sizeof(comparamp->framing); i++)
{
comparamp->framing[i] = *(*buffpp)++;
}
- comparamp->handshake = get_lsb_short(buffpp);
+ comparamp->handshake = get_lsb_int16(buffpp);
}
void
@@ -400,12 +403,12 @@ get_mbg_portparam(
)
{
int i;
-
- for (i = 0; i < N_COM; i++)
+
+ for (i = 0; i < DEFAULT_N_COM; i++)
{
get_mbg_comparam(buffpp, &portparamp->com[i]);
}
- for (i = 0; i < N_COM; i++)
+ for (i = 0; i < DEFAULT_N_COM; i++)
{
portparamp->mode[i] = *(*buffpp)++;
}
@@ -416,20 +419,20 @@ get_mbg_portparam(
{ \
L_CLR(addr); \
}
-
+
void
get_mbg_eph(
unsigned char ** buffpp,
EPH *ephp
)
{
- ephp->csum = get_lsb_short(buffpp);
- ephp->valid = get_lsb_short(buffpp);
-
- ephp->health = get_lsb_short(buffpp);
- ephp->IODC = get_lsb_short(buffpp);
- ephp->IODE2 = get_lsb_short(buffpp);
- ephp->IODE3 = get_lsb_short(buffpp);
+ ephp->csum = (CSUM) get_lsb_short(buffpp);
+ ephp->valid = get_lsb_int16(buffpp);
+
+ ephp->health = (HEALTH) get_lsb_short(buffpp);
+ ephp->IODC = (IOD) get_lsb_short(buffpp);
+ ephp->IODE2 = (IOD) get_lsb_short(buffpp);
+ ephp->IODE3 = (IOD) get_lsb_short(buffpp);
get_mbg_tgps(buffpp, &ephp->tt);
get_mbg_tgps(buffpp, &ephp->t0c);
@@ -456,7 +459,7 @@ get_mbg_eph(
FETCH_DOUBLE(buffpp, &ephp->af2);
FETCH_DOUBLE(buffpp, &ephp->tgd);
- ephp->URA = get_lsb_short(buffpp);
+ ephp->URA = get_lsb_uint16(buffpp);
ephp->L2code = *(*buffpp)++;
ephp->L2flag = *(*buffpp)++;
@@ -468,10 +471,10 @@ get_mbg_alm(
ALM *almp
)
{
- almp->csum = get_lsb_short(buffpp);
- almp->valid = get_lsb_short(buffpp);
-
- almp->health = get_lsb_short(buffpp);
+ almp->csum = (CSUM) get_lsb_short(buffpp);
+ almp->valid = get_lsb_int16(buffpp);
+
+ almp->health = (HEALTH) get_lsb_short(buffpp);
get_mbg_tgps(buffpp, &almp->t0a);
@@ -493,8 +496,8 @@ get_mbg_iono(
IONO *ionop
)
{
- ionop->csum = get_lsb_short(buffpp);
- ionop->valid = get_lsb_short(buffpp);
+ ionop->csum = (CSUM) get_lsb_short(buffpp);
+ ionop->valid = get_lsb_int16(buffpp);
FETCH_DOUBLE(buffpp, &ionop->alpha_0);
FETCH_DOUBLE(buffpp, &ionop->alpha_1);
diff --git a/contrib/ntp/libparse/gpstolfp.c b/contrib/ntp/libparse/gpstolfp.c
index 5354dd3..c162429 100644
--- a/contrib/ntp/libparse/gpstolfp.c
+++ b/contrib/ntp/libparse/gpstolfp.c
@@ -34,10 +34,8 @@
*/
#include <config.h>
#include "ntp_fp.h"
-
-#define GPSORIGIN 2524953600UL /* NTP origin - GPS origin in seconds */
-#define SECSPERWEEK (unsigned)(604800) /* seconds per week - GPS tells us about weeks */
-#define GPSWRAP 990 /* assume week count less than this in the previous epoch */
+#include "ntp_calendar.h"
+#include "parse.h"
void
gpstolfp(
@@ -49,10 +47,10 @@ gpstolfp(
{
if (weeks < GPSWRAP)
{
- weeks += 1024;
+ weeks += GPSWEEKS;
}
- lfp->l_ui = weeks * SECSPERWEEK + days * 86400 + seconds + GPSORIGIN; /* convert to NTP time */
+ lfp->l_ui = (uint32_t)(weeks * SECSPERWEEK + days * SECSPERDAY + seconds + GPSORIGIN); /* convert to NTP time */
lfp->l_uf = 0;
}
diff --git a/contrib/ntp/libparse/parse.c b/contrib/ntp/libparse/parse.c
index 85e5299..9e663f9 100644
--- a/contrib/ntp/libparse/parse.c
+++ b/contrib/ntp/libparse/parse.c
@@ -1,6 +1,6 @@
/*
* /src/NTP/ntp4-dev/libparse/parse.c,v 4.20 2005/08/06 17:39:40 kardel RELEASE_20050806_A
- *
+ *
* parse.c,v 4.20 2005/08/06 17:39:40 kardel RELEASE_20050806_A
*
* Parser module for reference clock
@@ -12,7 +12,7 @@
* when PARSEKERNEL is not defined NTP time stamps will be used.
*
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -106,7 +106,7 @@ Strcmp(
while (!(c = *s++ - *t++) && *s && *t)
/* empty loop */;
-
+
return c;
}
@@ -154,10 +154,10 @@ parse_ioinit(
)
{
parseprintf(DD_PARSE, ("parse_iostart\n"));
-
+
parseio->parse_plen = 0;
parseio->parse_pdata = (void *)0;
-
+
parseio->parse_data = 0;
parseio->parse_ldata = 0;
parseio->parse_dsize = 0;
@@ -166,7 +166,7 @@ parse_ioinit(
parseio->parse_ioflags = PARSE_IO_CS7; /* usual unix default */
parseio->parse_index = 0;
parseio->parse_ldsize = 0;
-
+
return 1;
}
@@ -188,15 +188,15 @@ parse_ioend(
unsigned int
parse_restart(
parse_t *parseio,
- unsigned int ch
+ char ch
)
{
unsigned int updated = PARSE_INP_SKIP;
-
+
/*
* re-start packet - timeout - overflow - start symbol
*/
-
+
if (parseio->parse_index)
{
/*
@@ -208,17 +208,17 @@ parse_restart(
parseio->parse_ldsize = parseio->parse_index;
updated = PARSE_INP_TIME;
}
-
+
parseio->parse_index = 1;
parseio->parse_data[0] = ch;
parseprintf(DD_PARSE, ("parse: parse_restart: buffer start (updated = %x)\n", updated));
return updated;
}
-
+
unsigned int
parse_addchar(
parse_t *parseio,
- unsigned int ch
+ char ch
)
{
/*
@@ -239,7 +239,7 @@ parse_addchar(
*/
return parse_restart(parseio, ch);
}
-
+
unsigned int
parse_end(
parse_t *parseio
@@ -260,11 +260,11 @@ parse_end(
int
parse_ioread(
register parse_t *parseio,
- register unsigned int ch,
+ register char ch,
register timestamp_t *tstamp
)
{
- register unsigned updated = CVT_NONE;
+ register u_int updated = CVT_NONE;
/*
* within STREAMS CSx (x < 8) chars still have the upper bits set
* so we normalize the characters by masking unecessary bits off.
@@ -282,9 +282,9 @@ parse_ioread(
case PARSE_IO_CS7:
ch &= 0x7F;
break;
-
+
case PARSE_IO_CS8:
- ch &= 0xFF;
+ ch &= (char) 0xFFU;
break;
}
@@ -306,18 +306,18 @@ parse_ioread(
{
updated = CVT_OK;
}
-
+
if (input_status & PARSE_INP_TIME) /* time sample is available */
{
- updated = timepacket(parseio);
+ updated = (u_int) timepacket(parseio);
}
-
+
if (input_status & PARSE_INP_DATA) /* got additional data */
{
updated |= CVT_ADDITIONAL;
}
}
-
+
/*
* remember last character time
@@ -353,7 +353,7 @@ parse_iopps(
register timestamp_t *ptime
)
{
- register unsigned updated = CVT_NONE;
+ register u_int updated = CVT_NONE;
/*
* PPS pulse information will only be delivered to ONE clock format
@@ -364,7 +364,7 @@ parse_iopps(
if (clockformats[parseio->parse_lformat]->syncpps)
{
- updated = clockformats[parseio->parse_lformat]->syncpps(parseio, status == SYNC_ONE, ptime);
+ updated = (u_int) clockformats[parseio->parse_lformat]->syncpps(parseio, status == SYNC_ONE, ptime);
parseprintf(DD_PARSE, ("parse_iopps: updated = 0x%x\n", updated));
}
@@ -403,13 +403,13 @@ parse_to_unixtime(
)
{
#define SETRTC(_X_) { if (cvtrtc) *cvtrtc = (_X_); }
- static int days_of_month[] =
+ static int days_of_month[] =
{
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
register int i;
time_t t;
-
+
if (clock_time->utctime)
return clock_time->utctime; /* if the conversion routine gets it right away - why not */
@@ -423,12 +423,12 @@ parse_to_unixtime(
SETRTC(CVT_FAIL|CVT_BADDATE);
return -1;
}
-
+
/*
* sorry, slow section here - but it's not time critical anyway
*/
t = julian0(clock_time->year) - julian0(1970); /* Y2kFixes */
- /* month */
+ /* month */
if (clock_time->month <= 0 || clock_time->month > 12)
{
SETRTC(CVT_FAIL|CVT_BADDATE);
@@ -466,7 +466,7 @@ parse_to_unixtime(
t = TIMES24(t) + clock_time->hour;
- /* min */
+ /* min */
if (clock_time->minute < 0 || clock_time->minute > 59)
{
SETRTC(CVT_FAIL|CVT_BADTIME);
@@ -475,7 +475,7 @@ parse_to_unixtime(
t = TIMES60(t) + clock_time->minute;
/* sec */
-
+
if (clock_time->second < 0 || clock_time->second > 60) /* allow for LEAPs */
{
SETRTC(CVT_FAIL|CVT_BADTIME);
@@ -510,7 +510,7 @@ Stoi(
while(*s == ' ')
s++;
-
+
if (*s == '-')
{
s++;
@@ -519,7 +519,7 @@ Stoi(
else
if (*s == '+')
s++;
-
+
for(;;)
{
c = *s++;
@@ -573,16 +573,16 @@ updatetimeinfo(
{
int s = splhigh();
#endif
-
+
parseio->parse_lstate = parseio->parse_dtime.parse_state | flags | PARSEB_TIMECODE;
-
+
parseio->parse_dtime.parse_state = parseio->parse_lstate;
#ifdef PARSEKERNEL
(void)splx((unsigned int)s);
}
#endif
-
+
#ifdef PARSEKERNEL
parseprintf(DD_PARSE, ("updatetimeinfo status=0x%x, time=%x\n", parseio->parse_dtime.parse_state,
@@ -591,7 +591,7 @@ updatetimeinfo(
parseprintf(DD_PARSE, ("updatetimeinfo status=0x%lx, time=%x\n", (long)parseio->parse_dtime.parse_state,
parseio->parse_dtime.parse_time.fp.l_ui));
#endif
-
+
return CVT_OK; /* everything fine and dandy... */
}
@@ -614,7 +614,7 @@ syn_simple(
}
/*
- * pps_simple
+ * parse_pps_fnc_t pps_simple
*
* handle a pps time stamp
*/
@@ -628,12 +628,12 @@ pps_simple(
{
parseio->parse_dtime.parse_ptime = *ptime;
parseio->parse_dtime.parse_state |= PARSEB_PPS|PARSEB_S_PPS;
-
+
return CVT_NONE;
}
/*
- * pps_one
+ * parse_pps_fnc_t pps_one
*
* handle a pps time stamp in ONE edge
*/
@@ -647,12 +647,12 @@ pps_one(
{
if (status)
return pps_simple(parseio, status, ptime);
-
+
return CVT_NONE;
}
/*
- * pps_zero
+ * parse_pps_fnc_t pps_zero
*
* handle a pps time stamp in ZERO edge
*/
@@ -666,7 +666,7 @@ pps_zero(
{
if (!status)
return pps_simple(parseio, status, ptime);
-
+
return CVT_NONE;
}
@@ -684,13 +684,13 @@ timepacket(
register time_t t;
u_long cvtrtc; /* current conversion result */
clocktime_t clock_time;
-
+
memset((char *)&clock_time, 0, sizeof clock_time);
format = parseio->parse_lformat;
if (format == (unsigned short)~0)
return CVT_NONE;
-
+
switch ((cvtrtc = clockformats[format]->convert ?
clockformats[format]->convert((unsigned char *)parseio->parse_ldata, parseio->parse_ldsize, (struct format *)(clockformats[format]->data), &clock_time, parseio->parse_pdata) :
CVT_NONE) & CVT_MASK)
@@ -698,17 +698,17 @@ timepacket(
case CVT_FAIL:
parseio->parse_badformat++;
break;
-
+
case CVT_NONE:
/*
* too bad - pretend bad format
*/
parseio->parse_badformat++;
break;
-
+
case CVT_OK:
break;
-
+
case CVT_SKIP:
return CVT_NONE;
@@ -716,7 +716,7 @@ timepacket(
/* shouldn't happen */
#ifndef PARSEKERNEL
msyslog(LOG_WARNING, "parse: INTERNAL error: bad return code of convert routine \"%s\"", clockformats[format]->name);
-#endif
+#endif
return CVT_FAIL|cvtrtc;
}
@@ -724,7 +724,7 @@ timepacket(
{
return CVT_FAIL|cvtrtc;
}
-
+
/*
* time stamp
*/
@@ -732,7 +732,7 @@ timepacket(
parseio->parse_dtime.parse_time.tv.tv_sec = t;
parseio->parse_dtime.parse_time.tv.tv_usec = clock_time.usecond;
#else
- parseio->parse_dtime.parse_time.fp.l_ui = t + JAN_1970;
+ parseio->parse_dtime.parse_time.fp.l_ui = (uint32_t) (t + JAN_1970);
TVUTOTSF(clock_time.usecond, parseio->parse_dtime.parse_time.fp.l_uf);
#endif
@@ -758,7 +758,7 @@ parse_timecode(
*/
dct->parsegettc.parse_badformat = parse->parse_badformat;
parse->parse_badformat = 0;
-
+
if (parse->parse_ldsize <= PARSE_TCMAX)
{
dct->parsegettc.parse_count = parse->parse_ldsize;
@@ -771,7 +771,7 @@ parse_timecode(
}
}
-
+
/*ARGSUSED*/
int
parse_setfmt(
@@ -792,7 +792,7 @@ parse_setfmt(
if (parse->parse_pdata)
FREE(parse->parse_pdata, parse->parse_plen);
parse->parse_pdata = 0;
-
+
parse->parse_plen = clockformats[i]->plen;
if (parse->parse_plen)
@@ -809,9 +809,9 @@ parse_setfmt(
if (parse->parse_data)
FREE(parse->parse_data, (unsigned)(parse->parse_dsize * 2 + 2));
parse->parse_ldata = parse->parse_data = 0;
-
+
parse->parse_dsize = clockformats[i]->length;
-
+
if (parse->parse_dsize)
{
parse->parse_data = (char*)MALLOC((unsigned)(parse->parse_dsize * 2 + 2));
@@ -820,20 +820,20 @@ parse_setfmt(
if (parse->parse_pdata)
FREE(parse->parse_pdata, parse->parse_plen);
parse->parse_pdata = 0;
-
+
parseprintf(DD_PARSE, ("init failed: malloc for data area failed\n"));
return 0;
}
}
-
+
/*
* leave room for '\0'
*/
parse->parse_ldata = parse->parse_data + parse->parse_dsize + 1;
-
+
parse->parse_lformat = i;
-
+
return 1;
}
}
@@ -852,7 +852,7 @@ parse_getfmt(
if (dct->parseformat.parse_format < nformats &&
Strlen(clockformats[dct->parseformat.parse_format]->name) <= PARSE_TCMAX)
{
- dct->parseformat.parse_count = Strlen(clockformats[dct->parseformat.parse_format]->name)+1;
+ dct->parseformat.parse_count = (unsigned short) (Strlen(clockformats[dct->parseformat.parse_format]->name) + 1);
memcpy(dct->parseformat.parse_buffer, clockformats[dct->parseformat.parse_format]->name, dct->parseformat.parse_count);
return 1;
}
@@ -870,7 +870,7 @@ parse_setcs(
)
{
parse->parse_ioflags &= ~PARSE_IO_CSIZE;
- parse->parse_ioflags |= dct->parsesetcs.parse_cs & PARSE_IO_CSIZE;
+ parse->parse_ioflags |= (int) (dct->parsesetcs.parse_cs & PARSE_IO_CSIZE);
return 1;
}
diff --git a/contrib/ntp/libparse/parse_conf.c b/contrib/ntp/libparse/parse_conf.c
index b7234dd..37871c9 100644
--- a/contrib/ntp/libparse/parse_conf.c
+++ b/contrib/ntp/libparse/parse_conf.c
@@ -1,6 +1,6 @@
/*
* /src/NTP/ntp4-dev/libparse/parse_conf.c,v 4.9 2005/04/16 17:32:10 kardel RELEASE_20050508_A
- *
+ *
* parse_conf.c,v 4.9 2005/04/16 17:32:10 kardel RELEASE_20050508_A
*
* Parser configuration module for reference clocks
@@ -12,7 +12,7 @@
* when STREAM is not defined NTP time stamps will be used.
*
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/contrib/ntp/libparse/parsesolaris.c b/contrib/ntp/libparse/parsesolaris.c
index d3756af..8c91257 100644
--- a/contrib/ntp/libparse/parsesolaris.c
+++ b/contrib/ntp/libparse/parsesolaris.c
@@ -1,12 +1,12 @@
/*
* /src/NTP/ntp4-dev/libparse/parsesolaris.c,v 4.11 2005/04/16 17:32:10 kardel RELEASE_20050508_A
- *
+ *
* parsesolaris.c,v 4.11 2005/04/16 17:32:10 kardel RELEASE_20050508_A
*
* STREAMS module for reference clocks
*
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -74,7 +74,7 @@ static struct fmodsw fmod_templ =
extern struct mod_ops mod_strmodops;
-static struct modlstrmod modlstrmod =
+static struct modlstrmod modlstrmod =
{
&mod_strmodops, /* a STREAMS module */
"PARSE - NTP reference", /* name this baby - keep room for revision number */
@@ -100,13 +100,13 @@ _init(
)
{
static char revision[] = "4.6";
- char *s, *S;
+ char *s, *S;
char *t;
-
+
#ifndef lint
t = rcsid;
#endif
-
+
/*
* copy RCS revision into Drv_name
*
@@ -125,20 +125,20 @@ _init(
}
if (*s == ' ') s++;
}
-
- t = modlstrmod.strmod_linkinfo;
+
+ t = modlstrmod.strmod_linkinfo;
while (*t && (*t != ' '))
{
t++;
}
if (*t == ' ') t++;
-
+
S = s;
while (*S && (((*S >= '0') && (*S <= '9')) || (*S == '.')))
{
S++;
}
-
+
if (*s && *t && (S > s))
{
if (strlen(t) >= (S - s))
@@ -308,7 +308,7 @@ setup_stream(
}
else
{
- pprintf(DD_OPEN, "parse: setup_stream - FAILED - no MEMORY for allocb\n");
+ pprintf(DD_OPEN, "parse: setup_stream - FAILED - no MEMORY for allocb\n");
return 0;
}
}
@@ -325,18 +325,18 @@ parseopen(
{
register parsestream_t *parse;
static int notice = 0;
-
- pprintf(DD_OPEN, "parse: OPEN - q=%x\n", q);
-
+
+ pprintf(DD_OPEN, "parse: OPEN - q=%x\n", q);
+
if (sflag != MODOPEN)
{ /* open only for modules */
- pprintf(DD_OPEN, "parse: OPEN - FAILED - not MODOPEN\n");
+ pprintf(DD_OPEN, "parse: OPEN - FAILED - not MODOPEN\n");
return EIO;
}
if (q->q_ptr != (caddr_t)NULL)
{
- pprintf(DD_OPEN, "parse: OPEN - FAILED - EXCLUSIVE ONLY\n");
+ pprintf(DD_OPEN, "parse: OPEN - FAILED - EXCLUSIVE ONLY\n");
return EBUSY;
}
@@ -346,10 +346,10 @@ parseopen(
return ENOMEM;
}
- pprintf(DD_OPEN, "parse: OPEN - parse area q=%x, q->q_ptr=%x\n", q, q->q_ptr);
+ pprintf(DD_OPEN, "parse: OPEN - parse area q=%x, q->q_ptr=%x\n", q, q->q_ptr);
WR(q)->q_ptr = q->q_ptr;
- pprintf(DD_OPEN, "parse: OPEN - WQ parse area q=%x, q->q_ptr=%x\n", WR(q), WR(q)->q_ptr);
-
+ pprintf(DD_OPEN, "parse: OPEN - WQ parse area q=%x, q->q_ptr=%x\n", WR(q), WR(q)->q_ptr);
+
parse = (parsestream_t *) q->q_ptr;
bzero((caddr_t)parse, sizeof(*parse));
parse->parse_queue = q;
@@ -360,7 +360,7 @@ parseopen(
qprocson(q);
- pprintf(DD_OPEN, "parse: OPEN - initializing io subsystem q=%x\n", q);
+ pprintf(DD_OPEN, "parse: OPEN - initializing io subsystem q=%x\n", q);
if (!parse_ioinit(&parse->parse_io))
{
@@ -374,12 +374,12 @@ parseopen(
return EIO;
}
- pprintf(DD_OPEN, "parse: OPEN - initializing stream q=%x\n", q);
+ pprintf(DD_OPEN, "parse: OPEN - initializing stream q=%x\n", q);
if (setup_stream(q, M_PARSE))
{
(void) init_linemon(q); /* hook up PPS ISR routines if possible */
- pprintf(DD_OPEN, "parse: OPEN - SUCCEEDED\n");
+ pprintf(DD_OPEN, "parse: OPEN - SUCCEEDED\n");
/*
* I know that you know the delete key, but you didn't write this
@@ -412,19 +412,19 @@ parseclose(
{
register parsestream_t *parse = (parsestream_t *)q->q_ptr;
register unsigned long s;
-
+
pprintf(DD_CLOSE, "parse: CLOSE\n");
-
+
qprocsoff(q);
s = splhigh();
-
+
if (parse->parse_dqueue)
close_linemon(parse->parse_dqueue, q);
parse->parse_dqueue = (queue_t *)0;
(void) splx(s);
-
+
parse_ioend(&parse->parse_io);
kmem_free((caddr_t)parse, sizeof(parsestream_t));
@@ -444,7 +444,7 @@ parsersvc(
)
{
mblk_t *mp;
-
+
while ((mp = getq(q)))
{
if (canputnext(q) || (mp->b_datap->db_type > QPCTL))
@@ -477,15 +477,15 @@ parsewput(
register mblk_t *datap;
register struct iocblk *iocp;
parsestream_t *parse = (parsestream_t *)q->q_ptr;
-
+
pprintf(DD_WPUT, "parse: parsewput\n");
-
+
switch (mp->b_datap->db_type)
{
default:
putnext(q, mp);
break;
-
+
case M_IOCTL:
iocp = (void *)mp->b_rptr;
switch (iocp->ioc_cmd)
@@ -519,7 +519,7 @@ parsewput(
iocp->ioc_count = sizeof(struct ppsclockev);
qreply(q, mp);
break;
-
+
case PARSEIOC_ENABLE:
case PARSEIOC_DISABLE:
{
@@ -537,7 +537,7 @@ parsewput(
}
qreply(q, mp);
break;
- }
+ }
case PARSEIOC_TIMECODE:
case PARSEIOC_SETFMT:
@@ -553,7 +553,7 @@ parsewput(
pprintf(DD_WPUT, "parse: parsewput - PARSEIOC_TIMECODE\n");
ok = parse_timecode(dct, &parse->parse_io);
break;
-
+
case PARSEIOC_SETFMT:
pprintf(DD_WPUT, "parse: parsewput - PARSEIOC_SETFMT\n");
ok = parse_setfmt(dct, &parse->parse_io);
@@ -600,7 +600,7 @@ rdchar(
else
{
register mblk_t *mmp = *mp;
-
+
*mp = (*mp)->b_cont;
freeb(mmp);
}
@@ -619,7 +619,7 @@ parserput(
{
register unsigned char type;
mblk_t *mp = imp;
-
+
switch (type = mp->b_datap->db_type)
{
default:
@@ -636,7 +636,7 @@ parserput(
else
putq(q, mp);
break;
-
+
case M_BREAK:
case M_DATA:
{
@@ -691,7 +691,7 @@ parserput(
if (nmp) freemsg(nmp);
parse_iodone(&parse->parse_io);
}
- }
+ }
}
else
{
@@ -733,7 +733,7 @@ parserput(
gethrestime(&hres_time);
c_time.tv.tv_sec = hres_time.tv_sec;
c_time.tv.tv_usec = hres_time.tv_nsec / 1000;
-
+
pprintf(DD_RPUT, "parse: parserput - M_%sHANGUP\n", (type == M_HANGUP) ? "" : "UN");
if ((parse->parse_status & PARSE_ENABLE) &&
@@ -758,7 +758,7 @@ parserput(
}
else
putq(q, mp);
-
+
if (status)
{
parse->parse_ppsclockev.tv = c_time.tv;
@@ -780,7 +780,7 @@ init_linemon(
)
{
register queue_t *dq;
-
+
dq = WR(q);
/*
* we ARE doing very bad things down here (basically stealing ISR
@@ -916,14 +916,14 @@ init_zs_linemon(
szs->zsops.zsop_xsint = (void (*) (struct zscom *))zs_xsisr; /* place our bastard */
szs->oldzsops = zs->zs_ops;
emergencyzs = zs->zs_ops;
-
+
zs->zs_ops = &szs->zsops; /* hook it up */
/*
- * XXX: this is usually done via zsopinit()
+ * XXX: this is usually done via zsopinit()
* - have yet to find a way to call that routine
*/
zs->zs_xsint = (void (*) (struct zscom *))zs_xsisr;
-
+
mutex_exit(zs->zs_excl);
pprintf(DD_INSTALL, "init_zs_linemon: CD monitor installed\n");
@@ -934,7 +934,7 @@ init_zs_linemon(
}
/*
- * unregister our ISR routine - must call under splhigh() (or
+ * unregister our ISR routine - must call under splhigh() (or
* whatever block ZS status interrupts)
*/
static void
@@ -970,7 +970,7 @@ close_zs_linemon(
mutex_exit(zs->zs_excl);
kmem_free((caddr_t)szs, sizeof (struct savedzsops));
-
+
pprintf(DD_INSTALL, "close_zs_linemon: CD monitor deleted\n");
return;
}
@@ -1005,7 +1005,7 @@ zs_xsisr(
{
timestamp_t cdevent;
register int status;
-
+
/*
* time stamp
*/
@@ -1024,7 +1024,7 @@ zs_xsisr(
* ok - now the hard part - find ourself
*/
loopcheck = MAXDEPTH;
-
+
while (q)
{
if (q->q_qinfo && q->q_qinfo->qi_minfo)
@@ -1052,7 +1052,7 @@ zs_xsisr(
*/
parse_iodone(&((parsestream_t *)q->q_ptr)->parse_io);
}
-
+
if (status)
{
((parsestream_t *)q->q_ptr)->parse_ppsclockev.tv = cdevent.tv;
@@ -1091,9 +1091,9 @@ zs_xsisr(
SCC_WRITE0(ZSWR0_RESET_STATUS); /* might kill other conditions here */
return;
}
- }
+ }
- pprintf(DD_ISR, "zs_xsisr: non CD event 0x%x for \"%s\"\n",
+ pprintf(DD_ISR, "zs_xsisr: non CD event 0x%x for \"%s\"\n",
(za->za_rr0 ^ zsstatus) & ~ZSRR0_CD,dname);
/*
* we are now gathered here to process some unusual external status
@@ -1108,7 +1108,7 @@ zs_xsisr(
q = za->za_ttycommon.t_readq;
loopcheck = MAXDEPTH;
-
+
/*
* the real thing for everything else ...
*/
@@ -1120,7 +1120,7 @@ zs_xsisr(
if (!strcmp(dname, parseinfo.st_rdinit->qi_minfo->mi_idname))
{
register void (*zsisr) (struct zscom *);
-
+
/*
* back home - phew (hopping along stream queues might
* prove dangerous to your health)
@@ -1129,7 +1129,7 @@ zs_xsisr(
zsisr(zs);
else
panic("zs_xsisr: unable to locate original ISR");
-
+
pprintf(DD_ISR, "zs_xsisr: non CD event was processed for \"%s\"\n", dname);
/*
* now back to our program ...
@@ -1151,7 +1151,7 @@ zs_xsisr(
* corrupted TTY structures
*/
printf("zs_zsisr: looking for \"%s\" - found \"%s\" - taking EMERGENCY path\n", parseinfo.st_rdinit->qi_minfo->mi_idname, dname ? dname : "-NIL-");
-
+
if (emergencyzs && emergencyzs->zsop_xsint)
emergencyzs->zsop_xsint(zs);
else
diff --git a/contrib/ntp/libparse/parsestreams.c b/contrib/ntp/libparse/parsestreams.c
index 3fb4cc3..6cd9d8f 100644
--- a/contrib/ntp/libparse/parsestreams.c
+++ b/contrib/ntp/libparse/parsestreams.c
@@ -1,13 +1,13 @@
/*
* /src/NTP/ntp4-dev/libparse/parsestreams.c,v 4.11 2005/04/16 17:32:10 kardel RELEASE_20050508_A
- *
+ *
* parsestreams.c,v 4.11 2005/04/16 17:32:10 kardel RELEASE_20050508_A
*
* STREAMS module for reference clocks
* (SunOS4.x)
*
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -110,7 +110,7 @@ static char mnam[] = "PARSEPPS "; /* name this baby - keep room for revision
#else
static char mnam[] = "PARSE "; /* name this baby - keep room for revision number */
#endif
-struct vdldrv parsesync_vd =
+struct vdldrv parsesync_vd =
{
VDMAGIC_PSEUDO, /* nothing like a real driver - a STREAMS module */
mnam,
@@ -166,7 +166,7 @@ Strcmp(
while (!(c = *s++ - *t++) && *s && *t)
/* empty loop */;
-
+
return c;
}
@@ -186,10 +186,10 @@ Strncmp(
while (n-- && !(c = *s++ - *t++) && *s && *t)
/* empty loop */;
-
+
return c;
}
-
+
void
ntp_memset(
char *a,
@@ -217,12 +217,12 @@ xxxinit(
{
extern struct fmodsw fmodsw[];
extern int fmodcnt;
-
+
struct fmodsw *fm = fmodsw;
struct fmodsw *fmend = &fmodsw[fmodcnt];
struct fmodsw *ifm = (struct fmodsw *)0;
char *mname = parseinfo.st_rdinit->qi_minfo->mi_idname;
-
+
switch (fc)
{
case VDLOAD:
@@ -233,13 +233,13 @@ xxxinit(
*/
while (fm <= fmend)
{
- if (!Strncmp(fm->f_name, mname, FMNAMESZ))
+ if (!Strncmp(fm->f_name, mname, FMNAMESZ))
{
printf("vddrinit[%s]: STREAMS module already loaded.\n", mname);
return(EBUSY);
}
else
- if ((ifm == (struct fmodsw *)0) &&
+ if ((ifm == (struct fmodsw *)0) &&
(fm->f_name[0] == '\0') &&
(fm->f_str == (struct streamtab *)0))
{
@@ -261,7 +261,7 @@ xxxinit(
{
static char revision[] = "4.7";
char *s, *S, *t;
-
+
s = rcsid; /* NOOP - keep compilers happy */
Strncpy(ifm->f_name, mname, FMNAMESZ);
@@ -285,20 +285,20 @@ xxxinit(
}
if (*s == ' ') s++;
}
-
- t = parsesync_vd.Drv_name;
+
+ t = parsesync_vd.Drv_name;
while (*t && (*t != ' '))
{
t++;
}
if (*t == ' ') t++;
-
+
S = s;
while (*S && (((*S >= '0') && (*S <= '9')) || (*S == '.')))
{
S++;
}
-
+
if (*s && *t && (S > s))
{
if (Strlen(t) >= (S - s))
@@ -307,9 +307,9 @@ xxxinit(
}
}
return (0);
- }
+ }
break;
-
+
case VDUNLOAD:
if (parsebusy > 0)
{
@@ -328,7 +328,7 @@ xxxinit(
fm->f_name[0] = '\0';
fm->f_str = (struct streamtab *)0;
fm++;
-
+
break;
}
fm++;
@@ -341,14 +341,14 @@ xxxinit(
else
return (0);
}
-
+
case VDSTAT:
return (0);
default:
return (EIO);
-
+
}
return EIO;
}
@@ -460,7 +460,7 @@ setup_stream(
}
else
{
- parseprintf(DD_OPEN,("parse: setup_stream - FAILED - no MEMORY for allocb\n"));
+ parseprintf(DD_OPEN,("parse: setup_stream - FAILED - no MEMORY for allocb\n"));
return 0;
}
}
@@ -476,37 +476,37 @@ parseopen(
{
register parsestream_t *parse;
static int notice = 0;
-
- parseprintf(DD_OPEN,("parse: OPEN\n"));
-
+
+ parseprintf(DD_OPEN,("parse: OPEN\n"));
+
if (sflag != MODOPEN)
{ /* open only for modules */
- parseprintf(DD_OPEN,("parse: OPEN - FAILED - not MODOPEN\n"));
+ parseprintf(DD_OPEN,("parse: OPEN - FAILED - not MODOPEN\n"));
return OPENFAIL;
}
if (q->q_ptr != (caddr_t)NULL)
{
u.u_error = EBUSY;
- parseprintf(DD_OPEN,("parse: OPEN - FAILED - EXCLUSIVE ONLY\n"));
+ parseprintf(DD_OPEN,("parse: OPEN - FAILED - EXCLUSIVE ONLY\n"));
return OPENFAIL;
}
#ifdef VDDRV
parsebusy++;
#endif
-
+
q->q_ptr = (caddr_t)kmem_alloc(sizeof(parsestream_t));
if (q->q_ptr == (caddr_t)0)
{
- parseprintf(DD_OPEN,("parse: OPEN - FAILED - no memory\n"));
+ parseprintf(DD_OPEN,("parse: OPEN - FAILED - no memory\n"));
#ifdef VDDRV
parsebusy--;
#endif
return OPENFAIL;
}
WR(q)->q_ptr = q->q_ptr;
-
+
parse = (parsestream_t *)(void *)q->q_ptr;
bzero((caddr_t)parse, sizeof(*parse));
parse->parse_queue = q;
@@ -531,7 +531,7 @@ parseopen(
{
(void) init_linemon(q); /* hook up PPS ISR routines if possible */
- parseprintf(DD_OPEN,("parse: OPEN - SUCCEEDED\n"));
+ parseprintf(DD_OPEN,("parse: OPEN - SUCCEEDED\n"));
/*
* I know that you know the delete key, but you didn't write this
@@ -569,17 +569,17 @@ parseclose(
{
register parsestream_t *parse = (parsestream_t *)(void *)q->q_ptr;
register unsigned long s;
-
+
parseprintf(DD_CLOSE,("parse: CLOSE\n"));
-
+
s = splhigh();
-
+
if (parse->parse_dqueue)
close_linemon(parse->parse_dqueue, q);
parse->parse_dqueue = (queue_t *)0;
(void) splx(s);
-
+
parse_ioend(&parse->parse_io);
kmem_free((caddr_t)parse, sizeof(parsestream_t));
@@ -602,7 +602,7 @@ parsersvc(
)
{
mblk_t *mp;
-
+
while ((mp = getq(q)))
{
if (canput(q->q_next) || (mp->b_datap->db_type > QPCTL))
@@ -635,15 +635,15 @@ parsewput(
register mblk_t *datap;
register struct iocblk *iocp;
parsestream_t *parse = (parsestream_t *)(void *)q->q_ptr;
-
+
parseprintf(DD_WPUT,("parse: parsewput\n"));
-
+
switch (mp->b_datap->db_type)
{
default:
putnext(q, mp);
break;
-
+
case M_IOCTL:
iocp = (struct iocblk *)(void *)mp->b_rptr;
switch (iocp->ioc_cmd)
@@ -676,7 +676,7 @@ parsewput(
iocp->ioc_count = sizeof(struct ppsclockev);
qreply(q, mp);
break;
-
+
case PARSEIOC_ENABLE:
case PARSEIOC_DISABLE:
{
@@ -694,7 +694,7 @@ parsewput(
}
qreply(q, mp);
break;
- }
+ }
case PARSEIOC_TIMECODE:
case PARSEIOC_SETFMT:
@@ -710,7 +710,7 @@ parsewput(
parseprintf(DD_WPUT,("parse: parsewput - PARSEIOC_TIMECODE\n"));
ok = parse_timecode(dct, &parse->parse_io);
break;
-
+
case PARSEIOC_SETFMT:
parseprintf(DD_WPUT,("parse: parsewput - PARSEIOC_SETFMT\n"));
ok = parse_setfmt(dct, &parse->parse_io);
@@ -757,7 +757,7 @@ rdchar(
else
{
register mblk_t *mmp = *mp;
-
+
*mp = (*mp)->b_cont;
freeb(mmp);
}
@@ -775,7 +775,7 @@ parserput(
)
{
unsigned char type;
-
+
switch (type = mp->b_datap->db_type)
{
default:
@@ -791,7 +791,7 @@ parserput(
else
putq(q, mp);
break;
-
+
case M_BREAK:
case M_DATA:
{
@@ -844,7 +844,7 @@ parserput(
if (nmp) freemsg(nmp);
parse_iodone(&parse->parse_io);
}
- }
+ }
}
else
{
@@ -883,7 +883,7 @@ parserput(
register int status = cd_invert ^ (type == M_UNHANGUP);
uniqtime(&ctime.tv);
-
+
parseprintf(DD_RPUT,("parse: parserput - M_%sHANGUP\n", (type == M_HANGUP) ? "" : "UN"));
if ((parse->parse_status & PARSE_ENABLE) &&
@@ -908,7 +908,7 @@ parserput(
}
else
putq(q, mp);
-
+
if (status)
{
parse->parse_ppsclockev.tv = ctime.tv;
@@ -930,7 +930,7 @@ init_linemon(
)
{
register queue_t *dq;
-
+
dq = WR(q);
/*
* we ARE doing very bad things down here (basically stealing ISR
@@ -1038,7 +1038,7 @@ init_zs_linemon(
else
{
unsigned long s;
-
+
/*
* we do a direct replacement, in case others fiddle also
* if somebody else grabs our hook and we disconnect
@@ -1064,9 +1064,9 @@ init_zs_linemon(
szs->zsops.zsop_xsint = zs_xsisr; /* place our bastard */
szs->oldzsops = zs->zs_ops;
emergencyzs = zs->zs_ops;
-
+
zsopinit(zs, &szs->zsops); /* hook it up */
-
+
(void) splx(s);
parseprintf(DD_INSTALL, ("init_zs_linemon: CD monitor installed\n"));
@@ -1099,11 +1099,11 @@ close_zs_linemon(
else
{
register struct savedzsops *szs = (struct savedzsops *)parsestream->parse_data;
-
+
zsopinit(zs, szs->oldzsops); /* reset to previous handler functions */
kmem_free((caddr_t)szs, sizeof (struct savedzsops));
-
+
parseprintf(DD_INSTALL, ("close_zs_linemon: CD monitor deleted\n"));
return;
}
@@ -1148,7 +1148,7 @@ zs_xsisr(
{
timestamp_t cdevent;
register int status;
-
+
za->za_rr0 = (za->za_rr0 & ~(cdmask)) | (zsstatus & (cdmask));
#ifdef PPS_SYNC
@@ -1163,7 +1163,7 @@ zs_xsisr(
* time stamp
*/
uniqtime(&cdevent.tv);
-
+
#ifdef PPS_SYNC
(void)splx(s);
#endif
@@ -1190,7 +1190,7 @@ zs_xsisr(
* ok - now the hard part - find ourself
*/
loopcheck = MAXDEPTH;
-
+
while (q)
{
if (q->q_qinfo && q->q_qinfo->qi_minfo)
@@ -1218,7 +1218,7 @@ zs_xsisr(
*/
parse_iodone(&((parsestream_t *)(void *)q->q_ptr)->parse_io);
}
-
+
if (status)
{
((parsestream_t *)(void *)q->q_ptr)->parse_ppsclockev.tv = cdevent.tv;
@@ -1251,13 +1251,13 @@ zs_xsisr(
zsaddr->zscc_control = ZSWR0_RESET_STATUS; /* might kill other conditions here */
return 0;
}
- }
+ }
if (zsstatus & cdmask) /* fake CARRIER status */
za->za_flags |= ZAS_CARR_ON;
else
za->za_flags &= ~ZAS_CARR_ON;
-
+
/*
* we are now gathered here to process some unusual external status
* interrupts.
@@ -1271,7 +1271,7 @@ zs_xsisr(
q = za->za_ttycommon.t_readq;
loopcheck = MAXDEPTH;
-
+
/*
* the real thing for everything else ...
*/
@@ -1283,7 +1283,7 @@ zs_xsisr(
if (!Strcmp(dname, parseinfo.st_rdinit->qi_minfo->mi_idname))
{
register int (*zsisr) (struct zscom *);
-
+
/*
* back home - phew (hopping along stream queues might
* prove dangerous to your health)
@@ -1292,7 +1292,7 @@ zs_xsisr(
return zsisr(zs);
else
panic("zs_xsisr: unable to locate original ISR");
-
+
parseprintf(DD_ISR, ("zs_xsisr: non CD event was processed for \"%s\"\n", dname));
/*
* now back to our program ...
@@ -1314,7 +1314,7 @@ zs_xsisr(
* corrupted TTY structures
*/
printf("zs_zsisr: looking for \"%s\" - found \"%s\" - taking EMERGENCY path\n", parseinfo.st_rdinit->qi_minfo->mi_idname, dname ? dname : "-NIL-");
-
+
if (emergencyzs && emergencyzs->zsop_xsint)
emergencyzs->zsop_xsint(zs);
else
diff --git a/contrib/ntp/libparse/trim_info.c b/contrib/ntp/libparse/trim_info.c
index 619e238..4178209 100644
--- a/contrib/ntp/libparse/trim_info.c
+++ b/contrib/ntp/libparse/trim_info.c
@@ -6,7 +6,7 @@
* $Created: Sun Aug 2 20:20:34 1998 $
*
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff --git a/contrib/ntp/ntpd/Makefile.in b/contrib/ntp/ntpd/Makefile.in
index 09af628..ed489f6 100644
--- a/contrib/ntp/ntpd/Makefile.in
+++ b/contrib/ntp/ntpd/Makefile.in
@@ -52,8 +52,7 @@ subdir = ntpd
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -82,6 +81,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -431,6 +432,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/ntpd/cmd_args.c b/contrib/ntp/ntpd/cmd_args.c
index 045c0a9..14e86f7 100644
--- a/contrib/ntp/ntpd/cmd_args.c
+++ b/contrib/ntp/ntpd/cmd_args.c
@@ -76,6 +76,9 @@ getCmdOpts(
if (HAVE_OPT( PANICGATE ))
allow_panic = TRUE;
+ if (HAVE_OPT( FORCE_STEP_ONCE ))
+ force_step_once = TRUE;
+
#ifdef HAVE_DROPROOT
if (HAVE_OPT( JAILDIR )) {
droproot = 1;
@@ -175,14 +178,14 @@ getCmdOpts(
if (HAVE_OPT( UPDATEINTERVAL )) {
long val = OPT_VALUE_UPDATEINTERVAL;
-
+
if (val >= 0)
interface_interval = val;
else {
- fprintf(stderr,
+ fprintf(stderr,
"command line interface update interval %ld must not be negative\n",
val);
- msyslog(LOG_ERR,
+ msyslog(LOG_ERR,
"command line interface update interval %ld must not be negative",
val);
errflg++;
diff --git a/contrib/ntp/ntpd/invoke-ntp.conf.texi b/contrib/ntp/ntpd/invoke-ntp.conf.texi
index 23569fc..7151efb 100644
--- a/contrib/ntp/ntpd/invoke-ntp.conf.texi
+++ b/contrib/ntp/ntpd/invoke-ntp.conf.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntp.conf.texi)
#
-# It has been AutoGen-ed February 4, 2015 at 02:41:59 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:25:50 AM by AutoGen 5.18.5pre4
# From the definitions ntp.conf.def
# and the template file agtexi-file.tpl
@end ignore
@@ -2482,7 +2482,7 @@ holds
the names of all peer variables and the
@code{clock_var_list}
holds the names of the reference clock variables.
-@item @code{tinker} @code{[@code{allan} @kbd{allan} | @code{dispersion} @kbd{dispersion} | @code{freq} @kbd{freq} | @code{huffpuff} @kbd{huffpuff} | @code{panic} @kbd{panic} | @code{step} @kbd{srep} | @code{stepout} @kbd{stepout}]}
+@item @code{tinker} @code{[@code{allan} @kbd{allan} | @code{dispersion} @kbd{dispersion} | @code{freq} @kbd{freq} | @code{huffpuff} @kbd{huffpuff} | @code{panic} @kbd{panic} | @code{step} @kbd{step} | @code{stepback} @kbd{stepback} | @code{stepfwd} @kbd{stepfwd} | @code{stepout} @kbd{stepout}]}
This command can be used to alter several system variables in
very exceptional circumstances.
It should occur in the
@@ -2539,6 +2539,19 @@ adjustments will never occur.
Note: The kernel time discipline is
disabled if the step threshold is set to zero or greater than the
default.
+@item @code{stepback} @kbd{stepback}
+The argument is the step threshold for the backward direction,
+which by default is 0.128 s.
+It can
+be set to any positive number in seconds.
+If both the forward and backward step thresholds are set to zero, step
+adjustments will never occur.
+Note: The kernel time discipline is
+disabled if
+each direction of step threshold are either
+set to zero or greater than .5 second.
+@item @code{stepfwd} @kbd{stepfwd}
+As for stepback, but for the forward direction.
@item @code{stepout} @kbd{stepout}
The argument is the stepout timeout, which by default is 900 s.
It can
diff --git a/contrib/ntp/ntpd/invoke-ntp.keys.texi b/contrib/ntp/ntpd/invoke-ntp.keys.texi
index dbafe1c..b0d4940 100644
--- a/contrib/ntp/ntpd/invoke-ntp.keys.texi
+++ b/contrib/ntp/ntpd/invoke-ntp.keys.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntp.keys.texi)
#
-# It has been AutoGen-ed February 4, 2015 at 02:42:02 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:25:52 AM by AutoGen 5.18.5pre4
# From the definitions ntp.keys.def
# and the template file agtexi-file.tpl
@end ignore
diff --git a/contrib/ntp/ntpd/invoke-ntpd.texi b/contrib/ntp/ntpd/invoke-ntpd.texi
index 75a5257..b6c69db 100644
--- a/contrib/ntp/ntpd/invoke-ntpd.texi
+++ b/contrib/ntp/ntpd/invoke-ntpd.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntpd.texi)
#
-# It has been AutoGen-ed February 4, 2015 at 02:42:04 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:25:54 AM by AutoGen 5.18.5pre4
# From the definitions ntpd-opts.def
# and the template file agtexi-cmd.tpl
@end ignore
@@ -95,6 +95,7 @@ This software is released under the NTP license, <http://ntp.org/license>.
* ntpd configfile:: configfile option (-c)
* ntpd driftfile:: driftfile option (-f)
* ntpd panicgate:: panicgate option (-g)
+* ntpd force-step-once:: force-step-once option (-G)
* ntpd jaildir:: jaildir option (-i)
* ntpd interface:: interface option (-I)
* ntpd keyfile:: keyfile option (-k)
@@ -141,7 +142,7 @@ with a status code of 0.
@exampleindent 0
@example
-ntpd - NTP daemon program - Ver. 4.2.8p1
+ntpd - NTP daemon program - Ver. 4.2.8p2
Usage: ntpd [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... \
[ <server1> ... <serverN> ]
Flg Arg Option-Name Description
@@ -162,6 +163,7 @@ Usage: ntpd [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... \
-f Str driftfile frequency drift file name
-g no panicgate Allow the first adjustment to be Big
- may appear multiple times
+ -G no force-step-once Step any initial offset correction.
-i Str jaildir Jail directory
-I Str interface Listen on an interface name or address
- may appear multiple times
@@ -298,7 +300,7 @@ The name and path of the frequency file,
by default.
This is the same operation as the
@code{driftfile} @kbd{driftfile}
-configuration specification in the
+configuration specification in the
@file{/etc/ntp.conf}
file.
@node ntpd panicgate
@@ -326,6 +328,21 @@ options.
See the
@code{tinker}
configuration file directive for other options.
+@node ntpd force-step-once
+@subsection force-step-once option (-G)
+@cindex ntpd-force-step-once
+
+This is the ``step any initial offset correction.'' option.
+Normally,
+@code{ntpd}
+steps the time if the time offset exceeds the step threshold,
+which is 128 ms by default, and otherwise slews the time.
+This option forces the initial offset correction to be stepped,
+so the highest time accuracy can be achieved quickly.
+However, this may also cause the time to be stepped back
+so this option must not be used if
+applications requiring monotonic time are running.
+See the @code{tinker} configuration file directive for other options.
@node ntpd jaildir
@subsection jaildir option (-i)
@cindex ntpd-jaildir
@@ -370,7 +387,7 @@ Open the network address given, or all the addresses associated with the
given interface name. This option may appear multiple times. This option
also implies not opening other addresses, except wildcard and localhost.
This option is deprecated. Please consider using the configuration file
-@code{interface} command, which is more versatile.
+@code{interface} command, which is more versatile.
@node ntpd keyfile
@subsection keyfile option (-k)
@cindex ntpd-keyfile
diff --git a/contrib/ntp/ntpd/keyword-gen-utd b/contrib/ntp/ntpd/keyword-gen-utd
index 0485fee..b9b59bd 100644
--- a/contrib/ntp/ntpd/keyword-gen-utd
+++ b/contrib/ntp/ntpd/keyword-gen-utd
@@ -1 +1 @@
- * Generated 2015-01-03 23:51:10 UTC diff_ignore_line
+ * Generated 2015-03-16 09:05:44 UTC diff_ignore_line
diff --git a/contrib/ntp/ntpd/keyword-gen.c b/contrib/ntp/ntpd/keyword-gen.c
index bb593ab..5872e2a 100644
--- a/contrib/ntp/ntpd/keyword-gen.c
+++ b/contrib/ntp/ntpd/keyword-gen.c
@@ -206,6 +206,8 @@ struct key_tok ntp_keywords[] = {
{ "filenum", T_Filenum, FOLLBY_TOKEN },
/* tinker_option */
{ "step", T_Step, FOLLBY_TOKEN },
+{ "stepback", T_Stepback, FOLLBY_TOKEN },
+{ "stepfwd", T_Stepfwd, FOLLBY_TOKEN },
{ "panic", T_Panic, FOLLBY_TOKEN },
{ "dispersion", T_Dispersion, FOLLBY_TOKEN },
{ "stepout", T_Stepout, FOLLBY_TOKEN },
diff --git a/contrib/ntp/ntpd/ntp.conf.5man b/contrib/ntp/ntpd/ntp.conf.5man
index 1e9ba66..f1ed4b2 100644
--- a/contrib/ntp/ntpd/ntp.conf.5man
+++ b/contrib/ntp/ntpd/ntp.conf.5man
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntp.conf 5man "04 Feb 2015" "4.2.8p1" "File Formats"
+.TH ntp.conf 5man "07 Apr 2015" "4.2.8p2" "File Formats"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-sPaOCn/ag-RPaGBn)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-gKaW.1/ag-tKaO91)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:41:46 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:25:37 AM by AutoGen 5.18.5pre4
.\" From the definitions ntp.conf.def
.\" and the template file agman-cmd.tpl
.SH NAME
@@ -2786,7 +2786,7 @@ the names of all peer variables and the
\fIclock_var_list\f[]
holds the names of the reference clock variables.
.TP 7
-.NOP \f\*[B-Font]tinker\f[] [\f\*[B-Font]allan\f[] \f\*[I-Font]allan\f[] | \f\*[B-Font]dispersion\f[] \f\*[I-Font]dispersion\f[] | \f\*[B-Font]freq\f[] \f\*[I-Font]freq\f[] | \f\*[B-Font]huffpuff\f[] \f\*[I-Font]huffpuff\f[] | \f\*[B-Font]panic\f[] \f\*[I-Font]panic\f[] | \f\*[B-Font]step\f[] \f\*[I-Font]srep\f[] | \f\*[B-Font]stepout\f[] \f\*[I-Font]stepout\f[]]
+.NOP \f\*[B-Font]tinker\f[] [\f\*[B-Font]allan\f[] \f\*[I-Font]allan\f[] | \f\*[B-Font]dispersion\f[] \f\*[I-Font]dispersion\f[] | \f\*[B-Font]freq\f[] \f\*[I-Font]freq\f[] | \f\*[B-Font]huffpuff\f[] \f\*[I-Font]huffpuff\f[] | \f\*[B-Font]panic\f[] \f\*[I-Font]panic\f[] | \f\*[B-Font]step\f[] \f\*[I-Font]step\f[] | \f\*[B-Font]stepback\f[] \f\*[I-Font]stepback\f[] | \f\*[B-Font]stepfwd\f[] \f\*[I-Font]stepfwd\f[] | \f\*[B-Font]stepout\f[] \f\*[I-Font]stepout\f[]]
This command can be used to alter several system variables in
very exceptional circumstances.
It should occur in the
@@ -2852,6 +2852,21 @@ Note: The kernel time discipline is
disabled if the step threshold is set to zero or greater than the
default.
.TP 7
+.NOP \f\*[B-Font]stepback\f[] \f\*[I-Font]stepback\f[]
+The argument is the step threshold for the backward direction,
+which by default is 0.128 s.
+It can
+be set to any positive number in seconds.
+If both the forward and backward step thresholds are set to zero, step
+adjustments will never occur.
+Note: The kernel time discipline is
+disabled if
+each direction of step threshold are either
+set to zero or greater than .5 second.
+.TP 7
+.NOP \f\*[B-Font]stepfwd\f[] \f\*[I-Font]stepfwd\f[]
+As for stepback, but for the forward direction.
+.TP 7
.NOP \f\*[B-Font]stepout\f[] \f\*[I-Font]stepout\f[]
The argument is the stepout timeout, which by default is 900 s.
It can
diff --git a/contrib/ntp/ntpd/ntp.conf.5mdoc b/contrib/ntp/ntpd/ntp.conf.5mdoc
index 069a543..1a52a12 100644
--- a/contrib/ntp/ntpd/ntp.conf.5mdoc
+++ b/contrib/ntp/ntpd/ntp.conf.5mdoc
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTP_CONF 5mdoc File Formats
.Os
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:42:07 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:25:57 AM by AutoGen 5.18.5pre4
.\" From the definitions ntp.conf.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
@@ -2618,7 +2618,9 @@ holds the names of the reference clock variables.
.Cm freq Ar freq |
.Cm huffpuff Ar huffpuff |
.Cm panic Ar panic |
-.Cm step Ar srep |
+.Cm step Ar step |
+.Cm stepback Ar stepback |
+.Cm stepfwd Ar stepfwd |
.Cm stepout Ar stepout
.Oc
.Xc
@@ -2678,6 +2680,19 @@ adjustments will never occur.
Note: The kernel time discipline is
disabled if the step threshold is set to zero or greater than the
default.
+.It Cm stepback Ar stepback
+The argument is the step threshold for the backward direction,
+which by default is 0.128 s.
+It can
+be set to any positive number in seconds.
+If both the forward and backward step thresholds are set to zero, step
+adjustments will never occur.
+Note: The kernel time discipline is
+disabled if
+each direction of step threshold are either
+set to zero or greater than .5 second.
+.It Cm stepfwd Ar stepfwd
+As for stepback, but for the forward direction.
.It Cm stepout Ar stepout
The argument is the stepout timeout, which by default is 900 s.
It can
diff --git a/contrib/ntp/ntpd/ntp.conf.def b/contrib/ntp/ntpd/ntp.conf.def
index 6f0bae1..e5c44b7 100644
--- a/contrib/ntp/ntpd/ntp.conf.def
+++ b/contrib/ntp/ntpd/ntp.conf.def
@@ -2620,7 +2620,9 @@ holds the names of the reference clock variables.
.Cm freq Ar freq |
.Cm huffpuff Ar huffpuff |
.Cm panic Ar panic |
-.Cm step Ar srep |
+.Cm step Ar step |
+.Cm stepback Ar stepback |
+.Cm stepfwd Ar stepfwd |
.Cm stepout Ar stepout
.Oc
.Xc
@@ -2680,6 +2682,19 @@ adjustments will never occur.
Note: The kernel time discipline is
disabled if the step threshold is set to zero or greater than the
default.
+.It Cm stepback Ar stepback
+The argument is the step threshold for the backward direction,
+which by default is 0.128 s.
+It can
+be set to any positive number in seconds.
+If both the forward and backward step thresholds are set to zero, step
+adjustments will never occur.
+Note: The kernel time discipline is
+disabled if
+each direction of step threshold are either
+set to zero or greater than .5 second.
+.It Cm stepfwd Ar stepfwd
+As for stepback, but for the forward direction.
.It Cm stepout Ar stepout
The argument is the stepout timeout, which by default is 900 s.
It can
diff --git a/contrib/ntp/ntpd/ntp.conf.html b/contrib/ntp/ntpd/ntp.conf.html
index b237cc0..7ab25e3 100644
--- a/contrib/ntp/ntpd/ntp.conf.html
+++ b/contrib/ntp/ntpd/ntp.conf.html
@@ -33,7 +33,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>
<p>This document describes the configuration file for the NTP Project's
<code>ntpd</code> program.
- <p>This document applies to version 4.2.8p1 of <code>ntp.conf</code>.
+ <p>This document applies to version 4.2.8p2 of <code>ntp.conf</code>.
<div class="shortcontents">
<h2>Short Contents</h2>
@@ -2463,7 +2463,7 @@ holds
the names of all peer variables and the
<code>clock_var_list</code>
holds the names of the reference clock variables.
-<br><dt><code>tinker</code> <code>[allan </code><kbd>allan</kbd><code> | dispersion </code><kbd>dispersion</kbd><code> | freq </code><kbd>freq</kbd><code> | huffpuff </code><kbd>huffpuff</kbd><code> | panic </code><kbd>panic</kbd><code> | step </code><kbd>srep</kbd><code> | stepout </code><kbd>stepout</kbd><code>]</code><dd>This command can be used to alter several system variables in
+<br><dt><code>tinker</code> <code>[allan </code><kbd>allan</kbd><code> | dispersion </code><kbd>dispersion</kbd><code> | freq </code><kbd>freq</kbd><code> | huffpuff </code><kbd>huffpuff</kbd><code> | panic </code><kbd>panic</kbd><code> | step </code><kbd>step</kbd><code> | stepback </code><kbd>stepback</kbd><code> | stepfwd </code><kbd>stepfwd</kbd><code> | stepout </code><kbd>stepout</kbd><code>]</code><dd>This command can be used to alter several system variables in
very exceptional circumstances.
It should occur in the
configuration file before any other configuration options.
@@ -2513,6 +2513,17 @@ adjustments will never occur.
Note: The kernel time discipline is
disabled if the step threshold is set to zero or greater than the
default.
+<br><dt><code>stepback</code> <kbd>stepback</kbd><dd>The argument is the step threshold for the backward direction,
+which by default is 0.128 s.
+It can
+be set to any positive number in seconds.
+If both the forward and backward step thresholds are set to zero, step
+adjustments will never occur.
+Note: The kernel time discipline is
+disabled if
+each direction of step threshold are either
+set to zero or greater than .5 second.
+<br><dt><code>stepfwd</code> <kbd>stepfwd</kbd><dd>As for stepback, but for the forward direction.
<br><dt><code>stepout</code> <kbd>stepout</kbd><dd>The argument is the stepout timeout, which by default is 900 s.
It can
be set to any positive number in seconds.
diff --git a/contrib/ntp/ntpd/ntp.conf.man.in b/contrib/ntp/ntpd/ntp.conf.man.in
index ec2c866..548151d 100644
--- a/contrib/ntp/ntpd/ntp.conf.man.in
+++ b/contrib/ntp/ntpd/ntp.conf.man.in
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntp.conf 5 "04 Feb 2015" "4.2.8p1" "File Formats"
+.TH ntp.conf 5 "07 Apr 2015" "4.2.8p2" "File Formats"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-sPaOCn/ag-RPaGBn)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-gKaW.1/ag-tKaO91)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:41:46 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:25:37 AM by AutoGen 5.18.5pre4
.\" From the definitions ntp.conf.def
.\" and the template file agman-cmd.tpl
.SH NAME
@@ -2786,7 +2786,7 @@ the names of all peer variables and the
\fIclock_var_list\f[]
holds the names of the reference clock variables.
.TP 7
-.NOP \f\*[B-Font]tinker\f[] [\f\*[B-Font]allan\f[] \f\*[I-Font]allan\f[] | \f\*[B-Font]dispersion\f[] \f\*[I-Font]dispersion\f[] | \f\*[B-Font]freq\f[] \f\*[I-Font]freq\f[] | \f\*[B-Font]huffpuff\f[] \f\*[I-Font]huffpuff\f[] | \f\*[B-Font]panic\f[] \f\*[I-Font]panic\f[] | \f\*[B-Font]step\f[] \f\*[I-Font]srep\f[] | \f\*[B-Font]stepout\f[] \f\*[I-Font]stepout\f[]]
+.NOP \f\*[B-Font]tinker\f[] [\f\*[B-Font]allan\f[] \f\*[I-Font]allan\f[] | \f\*[B-Font]dispersion\f[] \f\*[I-Font]dispersion\f[] | \f\*[B-Font]freq\f[] \f\*[I-Font]freq\f[] | \f\*[B-Font]huffpuff\f[] \f\*[I-Font]huffpuff\f[] | \f\*[B-Font]panic\f[] \f\*[I-Font]panic\f[] | \f\*[B-Font]step\f[] \f\*[I-Font]step\f[] | \f\*[B-Font]stepback\f[] \f\*[I-Font]stepback\f[] | \f\*[B-Font]stepfwd\f[] \f\*[I-Font]stepfwd\f[] | \f\*[B-Font]stepout\f[] \f\*[I-Font]stepout\f[]]
This command can be used to alter several system variables in
very exceptional circumstances.
It should occur in the
@@ -2852,6 +2852,21 @@ Note: The kernel time discipline is
disabled if the step threshold is set to zero or greater than the
default.
.TP 7
+.NOP \f\*[B-Font]stepback\f[] \f\*[I-Font]stepback\f[]
+The argument is the step threshold for the backward direction,
+which by default is 0.128 s.
+It can
+be set to any positive number in seconds.
+If both the forward and backward step thresholds are set to zero, step
+adjustments will never occur.
+Note: The kernel time discipline is
+disabled if
+each direction of step threshold are either
+set to zero or greater than .5 second.
+.TP 7
+.NOP \f\*[B-Font]stepfwd\f[] \f\*[I-Font]stepfwd\f[]
+As for stepback, but for the forward direction.
+.TP 7
.NOP \f\*[B-Font]stepout\f[] \f\*[I-Font]stepout\f[]
The argument is the stepout timeout, which by default is 900 s.
It can
diff --git a/contrib/ntp/ntpd/ntp.conf.mdoc.in b/contrib/ntp/ntpd/ntp.conf.mdoc.in
index ec45a74..da935ed6 100644
--- a/contrib/ntp/ntpd/ntp.conf.mdoc.in
+++ b/contrib/ntp/ntpd/ntp.conf.mdoc.in
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTP_CONF 5 File Formats
.Os
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:42:07 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:25:57 AM by AutoGen 5.18.5pre4
.\" From the definitions ntp.conf.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
@@ -2618,7 +2618,9 @@ holds the names of the reference clock variables.
.Cm freq Ar freq |
.Cm huffpuff Ar huffpuff |
.Cm panic Ar panic |
-.Cm step Ar srep |
+.Cm step Ar step |
+.Cm stepback Ar stepback |
+.Cm stepfwd Ar stepfwd |
.Cm stepout Ar stepout
.Oc
.Xc
@@ -2678,6 +2680,19 @@ adjustments will never occur.
Note: The kernel time discipline is
disabled if the step threshold is set to zero or greater than the
default.
+.It Cm stepback Ar stepback
+The argument is the step threshold for the backward direction,
+which by default is 0.128 s.
+It can
+be set to any positive number in seconds.
+If both the forward and backward step thresholds are set to zero, step
+adjustments will never occur.
+Note: The kernel time discipline is
+disabled if
+each direction of step threshold are either
+set to zero or greater than .5 second.
+.It Cm stepfwd Ar stepfwd
+As for stepback, but for the forward direction.
.It Cm stepout Ar stepout
The argument is the stepout timeout, which by default is 900 s.
It can
diff --git a/contrib/ntp/ntpd/ntp.keys.5man b/contrib/ntp/ntpd/ntp.keys.5man
index 7ba8b58..a505afb 100644
--- a/contrib/ntp/ntpd/ntp.keys.5man
+++ b/contrib/ntp/ntpd/ntp.keys.5man
@@ -1,8 +1,8 @@
-.TH ntp.keys 5man "04 Feb 2015" "4.2.8p1" "File Formats"
+.TH ntp.keys 5man "07 Apr 2015" "4.2.8p2" "File Formats"
.\"
.\" EDIT THIS FILE WITH CAUTION (ntp.man)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:41:51 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:25:42 AM by AutoGen 5.18.5pre4
.\" From the definitions ntp.keys.def
.\" and the template file agman-file.tpl
.Sh NAME
diff --git a/contrib/ntp/ntpd/ntp.keys.5mdoc b/contrib/ntp/ntpd/ntp.keys.5mdoc
index 8d7dacc..a7157ec 100644
--- a/contrib/ntp/ntpd/ntp.keys.5mdoc
+++ b/contrib/ntp/ntpd/ntp.keys.5mdoc
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTP_KEYS 5mdoc File Formats
.Os SunOS 5.10
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:42:10 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:26:00 AM by AutoGen 5.18.5pre4
.\" From the definitions ntp.keys.def
.\" and the template file agmdoc-file.tpl
.Sh NAME
diff --git a/contrib/ntp/ntpd/ntp.keys.html b/contrib/ntp/ntpd/ntp.keys.html
index 2329476..98a22ef 100644
--- a/contrib/ntp/ntpd/ntp.keys.html
+++ b/contrib/ntp/ntpd/ntp.keys.html
@@ -33,7 +33,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>
<p>This document describes the symmetric key file for the NTP Project's
<code>ntpd</code> program.
- <p>This document applies to version 4.2.8p1 of <code>ntp.keys</code>.
+ <p>This document applies to version 4.2.8p2 of <code>ntp.keys</code>.
<div class="shortcontents">
<h2>Short Contents</h2>
diff --git a/contrib/ntp/ntpd/ntp.keys.man.in b/contrib/ntp/ntpd/ntp.keys.man.in
index b1ec652..c7585af 100644
--- a/contrib/ntp/ntpd/ntp.keys.man.in
+++ b/contrib/ntp/ntpd/ntp.keys.man.in
@@ -1,8 +1,8 @@
-.TH ntp.keys 5 "04 Feb 2015" "4.2.8p1" "File Formats"
+.TH ntp.keys 5 "07 Apr 2015" "4.2.8p2" "File Formats"
.\"
.\" EDIT THIS FILE WITH CAUTION (ntp.man)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:41:51 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:25:42 AM by AutoGen 5.18.5pre4
.\" From the definitions ntp.keys.def
.\" and the template file agman-file.tpl
.Sh NAME
diff --git a/contrib/ntp/ntpd/ntp.keys.mdoc.in b/contrib/ntp/ntpd/ntp.keys.mdoc.in
index 1f3fea5..e6590db 100644
--- a/contrib/ntp/ntpd/ntp.keys.mdoc.in
+++ b/contrib/ntp/ntpd/ntp.keys.mdoc.in
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTP_KEYS 5 File Formats
.Os SunOS 5.10
.\" EDIT THIS FILE WITH CAUTION (ntp.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:42:10 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:26:00 AM by AutoGen 5.18.5pre4
.\" From the definitions ntp.keys.def
.\" and the template file agmdoc-file.tpl
.Sh NAME
diff --git a/contrib/ntp/ntpd/ntp_config.c b/contrib/ntp/ntpd/ntp_config.c
index b9f0e24..a224579 100644
--- a/contrib/ntp/ntpd/ntp_config.c
+++ b/contrib/ntp/ntpd/ntp_config.c
@@ -2705,6 +2705,14 @@ config_tinker(
item = LOOP_MAX;
break;
+ case T_Stepback:
+ item = LOOP_MAX_BACK;
+ break;
+
+ case T_Stepfwd:
+ item = LOOP_MAX_FWD;
+ break;
+
case T_Stepout:
item = LOOP_MINSTEP;
break;
diff --git a/contrib/ntp/ntpd/ntp_control.c b/contrib/ntp/ntpd/ntp_control.c
index c53cf52..2a1cf22 100644
--- a/contrib/ntp/ntpd/ntp_control.c
+++ b/contrib/ntp/ntpd/ntp_control.c
@@ -228,7 +228,8 @@ static const struct ctl_proc control_codes[] = {
#define CS_TIMER_OVERRUNS 86
#define CS_TIMER_XMTS 87
#define CS_FUZZ 88
-#define CS_MAX_NOAUTOKEY CS_FUZZ
+#define CS_WANDER_THRESH 89
+#define CS_MAX_NOAUTOKEY CS_WANDER_THRESH
#ifdef AUTOKEY
#define CS_FLAGS (1 + CS_MAX_NOAUTOKEY)
#define CS_HOST (2 + CS_MAX_NOAUTOKEY)
@@ -423,6 +424,7 @@ static const struct ctl_var sys_var[] = {
{ CS_TIMER_OVERRUNS, RO, "timer_overruns" }, /* 86 */
{ CS_TIMER_XMTS, RO, "timer_xmts" }, /* 87 */
{ CS_FUZZ, RO, "fuzz" }, /* 88 */
+ { CS_WANDER_THRESH, RO, "clk_wander_threshold" }, /* 89 */
#ifdef AUTOKEY
{ CS_FLAGS, RO, "flags" }, /* 1 + CS_MAX_NOAUTOKEY */
{ CS_HOST, RO, "host" }, /* 2 + CS_MAX_NOAUTOKEY */
@@ -485,7 +487,7 @@ static const struct ctl_var peer_var[] = {
{ 0, PADDING, "" }, /* 0 */
{ CP_CONFIG, RO, "config" }, /* 1 */
{ CP_AUTHENABLE, RO, "authenable" }, /* 2 */
- { CP_AUTHENTIC, RO, "authentic" }, /* 3 */
+ { CP_AUTHENTIC, RO, "authentic" }, /* 3 */
{ CP_SRCADR, RO, "srcadr" }, /* 4 */
{ CP_SRCPORT, RO, "srcport" }, /* 5 */
{ CP_DSTADR, RO, "dstadr" }, /* 6 */
@@ -537,7 +539,7 @@ static const struct ctl_var peer_var[] = {
{ CP_FLAGS, RO, "flags" }, /* 1 + CP_MAX_NOAUTOKEY */
{ CP_HOST, RO, "host" }, /* 2 + CP_MAX_NOAUTOKEY */
{ CP_VALID, RO, "valid" }, /* 3 + CP_MAX_NOAUTOKEY */
- { CP_INITSEQ, RO, "initsequence" }, /* 4 + CP_MAX_NOAUTOKEY */
+ { CP_INITSEQ, RO, "initsequence" }, /* 4 + CP_MAX_NOAUTOKEY */
{ CP_INITKEY, RO, "initkey" }, /* 5 + CP_MAX_NOAUTOKEY */
{ CP_INITTSP, RO, "timestamp" }, /* 6 + CP_MAX_NOAUTOKEY */
{ CP_SIGNATURE, RO, "signature" }, /* 7 + CP_MAX_NOAUTOKEY */
@@ -690,37 +692,37 @@ int num_ctl_traps;
*/
#ifdef REFCLOCK
static const u_char clocktypes[] = {
- CTL_SST_TS_NTP, /* REFCLK_NONE (0) */
+ CTL_SST_TS_NTP, /* REFCLK_NONE (0) */
CTL_SST_TS_LOCAL, /* REFCLK_LOCALCLOCK (1) */
- CTL_SST_TS_UHF, /* deprecated REFCLK_GPS_TRAK (2) */
+ CTL_SST_TS_UHF, /* deprecated REFCLK_GPS_TRAK (2) */
CTL_SST_TS_HF, /* REFCLK_WWV_PST (3) */
CTL_SST_TS_LF, /* REFCLK_WWVB_SPECTRACOM (4) */
- CTL_SST_TS_UHF, /* REFCLK_TRUETIME (5) */
- CTL_SST_TS_UHF, /* REFCLK_IRIG_AUDIO (6) */
+ CTL_SST_TS_UHF, /* REFCLK_TRUETIME (5) */
+ CTL_SST_TS_UHF, /* REFCLK_IRIG_AUDIO (6) */
CTL_SST_TS_HF, /* REFCLK_CHU (7) */
CTL_SST_TS_LF, /* REFCLOCK_PARSE (default) (8) */
CTL_SST_TS_LF, /* REFCLK_GPS_MX4200 (9) */
- CTL_SST_TS_UHF, /* REFCLK_GPS_AS2201 (10) */
- CTL_SST_TS_UHF, /* REFCLK_GPS_ARBITER (11) */
- CTL_SST_TS_UHF, /* REFCLK_IRIG_TPRO (12) */
+ CTL_SST_TS_UHF, /* REFCLK_GPS_AS2201 (10) */
+ CTL_SST_TS_UHF, /* REFCLK_GPS_ARBITER (11) */
+ CTL_SST_TS_UHF, /* REFCLK_IRIG_TPRO (12) */
CTL_SST_TS_ATOM, /* REFCLK_ATOM_LEITCH (13) */
CTL_SST_TS_LF, /* deprecated REFCLK_MSF_EES (14) */
- CTL_SST_TS_NTP, /* not used (15) */
- CTL_SST_TS_UHF, /* REFCLK_IRIG_BANCOMM (16) */
- CTL_SST_TS_UHF, /* REFCLK_GPS_DATU (17) */
+ CTL_SST_TS_NTP, /* not used (15) */
+ CTL_SST_TS_UHF, /* REFCLK_IRIG_BANCOMM (16) */
+ CTL_SST_TS_UHF, /* REFCLK_GPS_DATU (17) */
CTL_SST_TS_TELEPHONE, /* REFCLK_NIST_ACTS (18) */
CTL_SST_TS_HF, /* REFCLK_WWV_HEATH (19) */
- CTL_SST_TS_UHF, /* REFCLK_GPS_NMEA (20) */
- CTL_SST_TS_UHF, /* REFCLK_GPS_VME (21) */
+ CTL_SST_TS_UHF, /* REFCLK_GPS_NMEA (20) */
+ CTL_SST_TS_UHF, /* REFCLK_GPS_VME (21) */
CTL_SST_TS_ATOM, /* REFCLK_ATOM_PPS (22) */
CTL_SST_TS_NTP, /* not used (23) */
CTL_SST_TS_NTP, /* not used (24) */
- CTL_SST_TS_NTP, /* not used (25) */
- CTL_SST_TS_UHF, /* REFCLK_GPS_HP (26) */
+ CTL_SST_TS_NTP, /* not used (25) */
+ CTL_SST_TS_UHF, /* REFCLK_GPS_HP (26) */
CTL_SST_TS_LF, /* REFCLK_ARCRON_MSF (27) */
CTL_SST_TS_UHF, /* REFCLK_SHM (28) */
- CTL_SST_TS_UHF, /* REFCLK_PALISADE (29) */
- CTL_SST_TS_UHF, /* REFCLK_ONCORE (30) */
+ CTL_SST_TS_UHF, /* REFCLK_PALISADE (29) */
+ CTL_SST_TS_UHF, /* REFCLK_ONCORE (30) */
CTL_SST_TS_UHF, /* REFCLK_JUPITER (31) */
CTL_SST_TS_LF, /* REFCLK_CHRONOLOG (32) */
CTL_SST_TS_LF, /* REFCLK_DUMBCLOCK (33) */
@@ -728,7 +730,7 @@ static const u_char clocktypes[] = {
CTL_SST_TS_LF, /* REFCLK_PCF (35) */
CTL_SST_TS_HF, /* REFCLK_WWV (36) */
CTL_SST_TS_LF, /* REFCLK_FG (37) */
- CTL_SST_TS_UHF, /* REFCLK_HOPF_SERIAL (38) */
+ CTL_SST_TS_UHF, /* REFCLK_HOPF_SERIAL (38) */
CTL_SST_TS_UHF, /* REFCLK_HOPF_PCI (39) */
CTL_SST_TS_LF, /* REFCLK_JJY (40) */
CTL_SST_TS_UHF, /* REFCLK_TT560 (41) */
@@ -759,17 +761,17 @@ static u_char ctl_sys_num_events;
u_long ctltimereset; /* time stats reset */
u_long numctlreq; /* number of requests we've received */
u_long numctlbadpkts; /* number of bad control packets */
-u_long numctlresponses; /* number of resp packets sent with data */
-u_long numctlfrags; /* number of fragments sent */
+u_long numctlresponses; /* number of resp packets sent with data */
+u_long numctlfrags; /* number of fragments sent */
u_long numctlerrors; /* number of error responses sent */
u_long numctltooshort; /* number of too short input packets */
-u_long numctlinputresp; /* number of responses on input */
-u_long numctlinputfrag; /* number of fragments on input */
+u_long numctlinputresp; /* number of responses on input */
+u_long numctlinputfrag; /* number of fragments on input */
u_long numctlinputerr; /* number of input pkts with err bit set */
-u_long numctlbadoffset; /* number of input pkts with nonzero offset */
+u_long numctlbadoffset; /* number of input pkts with nonzero offset */
u_long numctlbadversion; /* number of input pkts with unknown version */
u_long numctldatatooshort; /* data too short for count */
-u_long numctlbadop; /* bad op code found in packet */
+u_long numctlbadop; /* bad op code found in packet */
u_long numasyncmsgs; /* number of async messages we've sent */
/*
@@ -788,7 +790,7 @@ static int res_offset; /* offset of payload in response */
static u_char * datapt;
static u_char * dataend;
static int datalinelen;
-static int datasent; /* flag to avoid initial ", " */
+static int datasent; /* flag to avoid initial ", " */
static int datanotbinflag;
static sockaddr_u *rmt_addr;
static struct interface *lcl_inter;
@@ -852,7 +854,7 @@ ctl_error(
* Fill in the fields. We assume rpkt.sequence and rpkt.associd
* have already been filled in.
*/
- rpkt.r_m_e_op = (u_char)CTL_RESPONSE | CTL_ERROR |
+ rpkt.r_m_e_op = (u_char)CTL_RESPONSE | CTL_ERROR |
(res_opcode & CTL_OP_MASK);
rpkt.status = htons((u_short)(errcode << 8) & 0xff00);
rpkt.count = 0;
@@ -870,7 +872,7 @@ ctl_error(
CTL_HEADER_LEN);
}
-/*
+/*
* save_config - Implements ntpq -c "saveconfig <filename>"
* Writes current configuration including any runtime
* changes by ntpq's :config or config-from-file
@@ -934,7 +936,7 @@ save_config(
if (0 == strftime(filename, sizeof(filename), filespec,
localtime(&now)))
strlcpy(filename, filespec, sizeof(filename));
-
+
/*
* Conceptually we should be searching for DIRSEP in filename,
* however Windows actually recognizes both forward and
@@ -1324,7 +1326,7 @@ static void
ctl_putdata(
const char *dp,
unsigned int dlen,
- int bin /* set to 1 when data is binary */
+ int bin /* set to 1 when data is binary */
)
{
int overhead;
@@ -1694,7 +1696,7 @@ ctl_putrefid(
return;
iptr = (char *)&refid;
iplim = iptr + sizeof(refid);
- for ( ; optr < oplim && iptr < iplim && '\0' != *iptr;
+ for ( ; optr < oplim && iptr < iplim && '\0' != *iptr;
iptr++, optr++)
if (isprint((int)*iptr))
*optr = *iptr;
@@ -1762,7 +1764,7 @@ ctl_putsys(
static const double to_ms =
# ifdef STA_NANO
- 1.0e-6; /* nsec to msec */
+ 1.0e-6; /* nsec to msec */
# else
1.0e-3; /* usec to msec */
# endif
@@ -1954,12 +1956,12 @@ ctl_putsys(
ctl_putdata(buf, (unsigned)( buffp - buf ), 0);
break;
}
-
+
case CS_TAI:
if (sys_tai > 0)
ctl_putuint(sys_var[CS_TAI].text, sys_tai);
break;
-
+
case CS_LEAPTAB:
{
leap_signature_t lsig;
@@ -1968,7 +1970,7 @@ ctl_putsys(
ctl_putfs(sys_var[CS_LEAPTAB].text, lsig.ttime);
break;
}
-
+
case CS_LEAPEND:
{
leap_signature_t lsig;
@@ -2113,7 +2115,7 @@ ctl_putsys(
break;
case CS_AUTHRESET:
- ctl_putuint(sys_var[varid].text,
+ ctl_putuint(sys_var[varid].text,
current_time - auth_timereset);
break;
@@ -2147,7 +2149,7 @@ ctl_putsys(
case CS_K_OFFSET:
CTL_IF_KERNLOOP(
- ctl_putdblf,
+ ctl_putdblf,
(sys_var[varid].text, 0, -1, to_ms * ntx.offset)
);
break;
@@ -2327,6 +2329,9 @@ ctl_putsys(
case CS_FUZZ:
ctl_putdbl(sys_var[varid].text, sys_fuzz * 1e3);
break;
+ case CS_WANDER_THRESH:
+ ctl_putdbl(sys_var[varid].text, wander_threshold * 1e6);
+ break;
#ifdef AUTOKEY
case CS_FLAGS:
if (crypto_flags)
@@ -2633,7 +2638,7 @@ ctl_putpeer(
memcpy(s, k->text, i);
s += i;
}
- if (s + 2 < be) {
+ if (s + 2 < be) {
*s++ = '"';
*s = '\0';
ctl_putdata(buf, (u_int)(s - buf), 0);
@@ -2712,7 +2717,7 @@ ctl_putpeer(
strlen(p->ident));
break;
-
+
#endif /* AUTOKEY */
}
}
@@ -2821,7 +2826,7 @@ ctl_putclock(
sizeof(buf))
break; /* really long var name */
- snprintf(s, sizeof(buf), "%s=\"",
+ snprintf(s, sizeof(buf), "%s=\"",
clock_var[CC_VARLIST].text);
s += strlen(s);
t = s;
@@ -3309,7 +3314,7 @@ static void configure(
snprintf(remote_config.err_msg,
sizeof(remote_config.err_msg),
"runtime configuration prohibited by restrict ... nomodify");
- ctl_putdata(remote_config.err_msg,
+ ctl_putdata(remote_config.err_msg,
strlen(remote_config.err_msg), 0);
ctl_flushpkt(0);
NLOG(NLOG_SYSINFO)
@@ -3365,7 +3370,7 @@ static void configure(
config_remotely(&rbufp->recv_srcadr);
- /*
+ /*
* Check if errors were reported. If not, output 'Config
* Succeeded'. Else output the error count. It would be nice
* to output any parser error messages.
@@ -3374,10 +3379,10 @@ static void configure(
retval = snprintf(remote_config.err_msg,
sizeof(remote_config.err_msg),
"Config Succeeded");
- if (retval > 0)
+ if (retval > 0)
remote_config.err_pos += retval;
}
-
+
ctl_putdata(remote_config.err_msg, remote_config.err_pos, 0);
ctl_flushpkt(0);
@@ -3790,7 +3795,7 @@ static void read_mru_list(
while (NULL != (v = ctl_getitem(in_parms, &val)) &&
!(EOV & v->flags)) {
- int si;
+ int si;
if (!strcmp(nonce_text, v->text)) {
if (NULL != pnonce)
@@ -3887,7 +3892,7 @@ static void read_mru_list(
pch = sptoa(&mon->rmtadr);
ctl_putunqstr("addr.older", pch, strlen(pch));
- /*
+ /*
* Move on to the first entry the client doesn't have,
* except in the special case of a limit of one. In
* that case return the starting point entry.
@@ -3897,7 +3902,7 @@ static void read_mru_list(
} else { /* start with the oldest */
mon = TAIL_DLIST(mon_mru_list, mru);
}
-
+
/*
* send up to limit= entries in up to frags= datagrams
*/
@@ -4656,7 +4661,7 @@ ctlfindtrap(
for (n = 0; n < COUNTOF(ctl_traps); n++)
if ((ctl_traps[n].tr_flags & TRAP_INUSE)
&& ADDR_PORT_EQ(raddr, &ctl_traps[n].tr_addr)
- && (linter == ctl_traps[n].tr_localaddr))
+ && (linter == ctl_traps[n].tr_localaddr))
return &ctl_traps[n];
return NULL;
@@ -4713,7 +4718,7 @@ report_event(
const char * src;
u_char errlast;
- errlast = (u_char)err & ~PEER_EVENT;
+ errlast = (u_char)err & ~PEER_EVENT;
if (peer->last_event == errlast)
peer->num_events = 0;
if (peer->num_events >= CTL_PEER_MAXEVENTS)
@@ -4985,7 +4990,7 @@ get_ext_sys_var(const char *tag)
}
}
}
-
+
return val;
}
diff --git a/contrib/ntp/ntpd/ntp_crypto.c b/contrib/ntp/ntpd/ntp_crypto.c
index 8edc357..7a5a100 100644
--- a/contrib/ntp/ntpd/ntp_crypto.c
+++ b/contrib/ntp/ntpd/ntp_crypto.c
@@ -1731,7 +1731,7 @@ crypto_args(
tstamp_t tstamp; /* NTP timestamp */
struct exten *ep; /* extension field pointer */
u_int len; /* extension field length */
- size_t slen;
+ size_t slen = 0;
tstamp = crypto_time();
len = sizeof(struct exten);
diff --git a/contrib/ntp/ntpd/ntp_keyword.h b/contrib/ntp/ntpd/ntp_keyword.h
index 131cf0f..7237936 100644
--- a/contrib/ntp/ntpd/ntp_keyword.h
+++ b/contrib/ntp/ntpd/ntp_keyword.h
@@ -2,7 +2,7 @@
* ntp_keyword.h
*
* NOTE: edit this file with caution, it is generated by keyword-gen.c
- * Generated 2015-01-03 23:51:10 UTC diff_ignore_line
+ * Generated 2015-03-16 09:05:44 UTC diff_ignore_line
*
*/
#include "ntp_scanner.h"
@@ -10,7 +10,7 @@
#define LOWEST_KEYWORD_ID 258
-const char * const keyword_text[187] = {
+const char * const keyword_text[189] = {
/* 0 258 T_Abbrev */ "abbrev",
/* 1 259 T_Age */ "age",
/* 2 260 T_All */ "all",
@@ -160,49 +160,51 @@ const char * const keyword_text[187] = {
/* 146 404 T_Stats */ "stats",
/* 147 405 T_Statsdir */ "statsdir",
/* 148 406 T_Step */ "step",
- /* 149 407 T_Stepout */ "stepout",
- /* 150 408 T_Stratum */ "stratum",
- /* 151 409 T_String */ NULL,
- /* 152 410 T_Sys */ "sys",
- /* 153 411 T_Sysstats */ "sysstats",
- /* 154 412 T_Tick */ "tick",
- /* 155 413 T_Time1 */ "time1",
- /* 156 414 T_Time2 */ "time2",
- /* 157 415 T_Timer */ "timer",
- /* 158 416 T_Timingstats */ "timingstats",
- /* 159 417 T_Tinker */ "tinker",
- /* 160 418 T_Tos */ "tos",
- /* 161 419 T_Trap */ "trap",
- /* 162 420 T_True */ "true",
- /* 163 421 T_Trustedkey */ "trustedkey",
- /* 164 422 T_Ttl */ "ttl",
- /* 165 423 T_Type */ "type",
- /* 166 424 T_U_int */ NULL,
- /* 167 425 T_Unconfig */ "unconfig",
- /* 168 426 T_Unpeer */ "unpeer",
- /* 169 427 T_Version */ "version",
- /* 170 428 T_WanderThreshold */ NULL,
- /* 171 429 T_Week */ "week",
- /* 172 430 T_Wildcard */ "wildcard",
- /* 173 431 T_Xleave */ "xleave",
- /* 174 432 T_Year */ "year",
- /* 175 433 T_Flag */ NULL,
- /* 176 434 T_EOC */ NULL,
- /* 177 435 T_Simulate */ "simulate",
- /* 178 436 T_Beep_Delay */ "beep_delay",
- /* 179 437 T_Sim_Duration */ "simulation_duration",
- /* 180 438 T_Server_Offset */ "server_offset",
- /* 181 439 T_Duration */ "duration",
- /* 182 440 T_Freq_Offset */ "freq_offset",
- /* 183 441 T_Wander */ "wander",
- /* 184 442 T_Jitter */ "jitter",
- /* 185 443 T_Prop_Delay */ "prop_delay",
- /* 186 444 T_Proc_Delay */ "proc_delay"
+ /* 149 407 T_Stepback */ "stepback",
+ /* 150 408 T_Stepfwd */ "stepfwd",
+ /* 151 409 T_Stepout */ "stepout",
+ /* 152 410 T_Stratum */ "stratum",
+ /* 153 411 T_String */ NULL,
+ /* 154 412 T_Sys */ "sys",
+ /* 155 413 T_Sysstats */ "sysstats",
+ /* 156 414 T_Tick */ "tick",
+ /* 157 415 T_Time1 */ "time1",
+ /* 158 416 T_Time2 */ "time2",
+ /* 159 417 T_Timer */ "timer",
+ /* 160 418 T_Timingstats */ "timingstats",
+ /* 161 419 T_Tinker */ "tinker",
+ /* 162 420 T_Tos */ "tos",
+ /* 163 421 T_Trap */ "trap",
+ /* 164 422 T_True */ "true",
+ /* 165 423 T_Trustedkey */ "trustedkey",
+ /* 166 424 T_Ttl */ "ttl",
+ /* 167 425 T_Type */ "type",
+ /* 168 426 T_U_int */ NULL,
+ /* 169 427 T_Unconfig */ "unconfig",
+ /* 170 428 T_Unpeer */ "unpeer",
+ /* 171 429 T_Version */ "version",
+ /* 172 430 T_WanderThreshold */ NULL,
+ /* 173 431 T_Week */ "week",
+ /* 174 432 T_Wildcard */ "wildcard",
+ /* 175 433 T_Xleave */ "xleave",
+ /* 176 434 T_Year */ "year",
+ /* 177 435 T_Flag */ NULL,
+ /* 178 436 T_EOC */ NULL,
+ /* 179 437 T_Simulate */ "simulate",
+ /* 180 438 T_Beep_Delay */ "beep_delay",
+ /* 181 439 T_Sim_Duration */ "simulation_duration",
+ /* 182 440 T_Server_Offset */ "server_offset",
+ /* 183 441 T_Duration */ "duration",
+ /* 184 442 T_Freq_Offset */ "freq_offset",
+ /* 185 443 T_Wander */ "wander",
+ /* 186 444 T_Jitter */ "jitter",
+ /* 187 445 T_Prop_Delay */ "prop_delay",
+ /* 188 446 T_Proc_Delay */ "proc_delay"
};
-#define SCANNER_INIT_S 830
+#define SCANNER_INIT_S 837
-const scan_state sst[833] = {
+const scan_state sst[840] = {
/*SS_T( ch, f-by, match, other ), */
0, /* 0 */
S_ST( '-', 3, 322, 0 ), /* 1 */
@@ -248,7 +250,7 @@ const scan_state sst[833] = {
S_ST( 'd', 3, 42, 0 ), /* 41 beep_ */
S_ST( 'e', 3, 43, 0 ), /* 42 beep_d */
S_ST( 'l', 3, 44, 0 ), /* 43 beep_de */
- S_ST( 'a', 3, 436, 0 ), /* 44 beep_del */
+ S_ST( 'a', 3, 438, 0 ), /* 44 beep_del */
S_ST( 'r', 3, 46, 34 ), /* 45 b */
S_ST( 'o', 3, 47, 0 ), /* 46 br */
S_ST( 'a', 3, 48, 0 ), /* 47 bro */
@@ -346,7 +348,7 @@ const scan_state sst[833] = {
S_ST( 'a', 3, 140, 0 ), /* 139 dur */
S_ST( 't', 3, 141, 0 ), /* 140 dura */
S_ST( 'i', 3, 142, 0 ), /* 141 durat */
- S_ST( 'o', 3, 439, 0 ), /* 142 durati */
+ S_ST( 'o', 3, 441, 0 ), /* 142 durati */
S_ST( 'e', 3, 144, 105 ), /* 143 */
S_ST( 'n', 3, 292, 0 ), /* 144 e */
S_ST( 'a', 3, 146, 0 ), /* 145 en */
@@ -372,7 +374,7 @@ const scan_state sst[833] = {
S_ST( 'f', 3, 166, 0 ), /* 165 freq_o */
S_ST( 'f', 3, 167, 0 ), /* 166 freq_of */
S_ST( 's', 3, 168, 0 ), /* 167 freq_off */
- S_ST( 'e', 3, 440, 0 ), /* 168 freq_offs */
+ S_ST( 'e', 3, 442, 0 ), /* 168 freq_offs */
S_ST( 'u', 3, 170, 161 ), /* 169 f */
S_ST( 'd', 3, 171, 0 ), /* 170 fu */
S_ST( 'g', 3, 304, 0 ), /* 171 fud */
@@ -432,7 +434,7 @@ const scan_state sst[833] = {
S_ST( 'i', 3, 226, 0 ), /* 225 j */
S_ST( 't', 3, 227, 0 ), /* 226 ji */
S_ST( 't', 3, 228, 0 ), /* 227 jit */
- S_ST( 'e', 3, 442, 0 ), /* 228 jitt */
+ S_ST( 'e', 3, 444, 0 ), /* 228 jitt */
S_ST( 'k', 3, 236, 224 ), /* 229 */
S_ST( 'e', 3, 324, 0 ), /* 230 k */
S_ST( 'r', 3, 232, 0 ), /* 231 ke */
@@ -457,7 +459,7 @@ const scan_state sst[833] = {
S_ST( 's', 3, 251, 249 ), /* 250 li */
S_ST( 't', 3, 252, 0 ), /* 251 lis */
S_ST( 'e', 3, 332, 0 ), /* 252 list */
- S_ST( 'o', 3, 447, 244 ), /* 253 l */
+ S_ST( 'o', 3, 449, 244 ), /* 253 l */
S_ST( 'g', 3, 315, 0 ), /* 254 lo */
S_ST( 'c', 3, 256, 0 ), /* 255 log */
S_ST( 'o', 3, 257, 0 ), /* 256 logc */
@@ -521,7 +523,7 @@ const scan_state sst[833] = {
S_ST( 'e', 1, 0, 0 ), /* 314 T_Includefile */
S_ST( 'f', 3, 317, 255 ), /* 315 log */
S_ST( 'e', 0, 0, 0 ), /* 316 T_Interface */
- S_ST( 'i', 3, 409, 0 ), /* 317 logf */
+ S_ST( 'i', 3, 411, 0 ), /* 317 logf */
S_ST( 'o', 0, 0, 193 ), /* 318 T_Io */
S_ST( '4', 0, 0, 0 ), /* 319 T_Ipv4 */
S_ST( '4', 0, 0, 0 ), /* 320 T_Ipv4_flag */
@@ -551,7 +553,7 @@ const scan_state sst[833] = {
S_ST( 'm', 0, 0, 0 ), /* 344 T_Maxmem */
S_ST( 'l', 0, 0, 0 ), /* 345 T_Maxpoll */
S_ST( 's', 0, 0, 0 ), /* 346 T_Mdnstries */
- S_ST( 'm', 0, 500, 0 ), /* 347 T_Mem */
+ S_ST( 'm', 0, 502, 0 ), /* 347 T_Mem */
S_ST( 'k', 0, 0, 0 ), /* 348 T_Memlock */
S_ST( 'k', 0, 0, 0 ), /* 349 T_Minclock */
S_ST( 'h', 0, 0, 0 ), /* 350 T_Mindepth */
@@ -577,23 +579,23 @@ const scan_state sst[833] = {
S_ST( 'e', 0, 0, 0 ), /* 370 T_Noserve */
S_ST( 'p', 0, 0, 0 ), /* 371 T_Notrap */
S_ST( 't', 0, 0, 0 ), /* 372 T_Notrust */
- S_ST( 'p', 0, 596, 0 ), /* 373 T_Ntp */
+ S_ST( 'p', 0, 598, 0 ), /* 373 T_Ntp */
S_ST( 't', 0, 0, 0 ), /* 374 T_Ntpport */
S_ST( 't', 1, 0, 0 ), /* 375 T_NtpSignDsocket */
- S_ST( 'n', 0, 611, 0 ), /* 376 T_Orphan */
+ S_ST( 'n', 0, 613, 0 ), /* 376 T_Orphan */
S_ST( 't', 0, 0, 0 ), /* 377 T_Orphanwait */
S_ST( 'c', 0, 0, 0 ), /* 378 T_Panic */
- S_ST( 'r', 1, 620, 0 ), /* 379 T_Peer */
+ S_ST( 'r', 1, 622, 0 ), /* 379 T_Peer */
S_ST( 's', 0, 0, 0 ), /* 380 T_Peerstats */
S_ST( 'e', 2, 0, 0 ), /* 381 T_Phone */
- S_ST( 'd', 0, 628, 0 ), /* 382 T_Pid */
+ S_ST( 'd', 0, 630, 0 ), /* 382 T_Pid */
S_ST( 'e', 1, 0, 0 ), /* 383 T_Pidfile */
S_ST( 'l', 1, 0, 0 ), /* 384 T_Pool */
S_ST( 't', 0, 0, 0 ), /* 385 T_Port */
S_ST( 't', 0, 0, 0 ), /* 386 T_Preempt */
S_ST( 'r', 0, 0, 0 ), /* 387 T_Prefer */
S_ST( 's', 0, 0, 0 ), /* 388 T_Protostats */
- S_ST( 'w', 1, 0, 634 ), /* 389 T_Pw */
+ S_ST( 'w', 1, 0, 636 ), /* 389 T_Pw */
S_ST( 'e', 1, 0, 0 ), /* 390 T_Randfile */
S_ST( 's', 0, 0, 0 ), /* 391 T_Rawstats */
S_ST( 'd', 1, 0, 0 ), /* 392 T_Refid */
@@ -603,439 +605,446 @@ const scan_state sst[833] = {
S_ST( 'e', 0, 0, 0 ), /* 396 T_Revoke */
S_ST( 't', 0, 0, 0 ), /* 397 T_Rlimit */
S_ST( 'r', 1, 0, 0 ), /* 398 T_Saveconfigdir */
- S_ST( 'r', 1, 711, 0 ), /* 399 T_Server */
+ S_ST( 'r', 1, 713, 0 ), /* 399 T_Server */
S_ST( 'r', 1, 0, 0 ), /* 400 T_Setvar */
S_ST( 'e', 0, 0, 0 ), /* 401 T_Source */
S_ST( 'e', 0, 0, 0 ), /* 402 T_Stacksize */
S_ST( 's', 0, 0, 0 ), /* 403 T_Statistics */
- S_ST( 's', 0, 754, 749 ), /* 404 T_Stats */
+ S_ST( 's', 0, 756, 751 ), /* 404 T_Stats */
S_ST( 'r', 1, 0, 0 ), /* 405 T_Statsdir */
- S_ST( 'p', 0, 757, 0 ), /* 406 T_Step */
- S_ST( 't', 0, 0, 0 ), /* 407 T_Stepout */
- S_ST( 'm', 0, 0, 0 ), /* 408 T_Stratum */
- S_ST( 'l', 3, 334, 0 ), /* 409 logfi */
- S_ST( 's', 0, 764, 0 ), /* 410 T_Sys */
- S_ST( 's', 0, 0, 0 ), /* 411 T_Sysstats */
- S_ST( 'k', 0, 0, 0 ), /* 412 T_Tick */
- S_ST( '1', 0, 0, 0 ), /* 413 T_Time1 */
- S_ST( '2', 0, 0, 413 ), /* 414 T_Time2 */
- S_ST( 'r', 0, 0, 414 ), /* 415 T_Timer */
- S_ST( 's', 0, 0, 0 ), /* 416 T_Timingstats */
- S_ST( 'r', 0, 0, 0 ), /* 417 T_Tinker */
- S_ST( 's', 0, 0, 0 ), /* 418 T_Tos */
- S_ST( 'p', 1, 0, 0 ), /* 419 T_Trap */
- S_ST( 'e', 0, 0, 0 ), /* 420 T_True */
- S_ST( 'y', 0, 0, 0 ), /* 421 T_Trustedkey */
- S_ST( 'l', 0, 0, 0 ), /* 422 T_Ttl */
- S_ST( 'e', 0, 0, 0 ), /* 423 T_Type */
- S_ST( 'o', 3, 428, 254 ), /* 424 lo */
- S_ST( 'g', 1, 0, 0 ), /* 425 T_Unconfig */
- S_ST( 'r', 1, 0, 0 ), /* 426 T_Unpeer */
- S_ST( 'n', 0, 0, 0 ), /* 427 T_Version */
- S_ST( 'p', 3, 433, 0 ), /* 428 loo */
- S_ST( 'k', 0, 0, 0 ), /* 429 T_Week */
- S_ST( 'd', 0, 0, 0 ), /* 430 T_Wildcard */
- S_ST( 'e', 0, 0, 0 ), /* 431 T_Xleave */
- S_ST( 'r', 0, 0, 0 ), /* 432 T_Year */
- S_ST( 's', 3, 434, 0 ), /* 433 loop */
- S_ST( 't', 3, 445, 0 ), /* 434 loops */
- S_ST( 'e', 0, 0, 0 ), /* 435 T_Simulate */
- S_ST( 'y', 0, 0, 0 ), /* 436 T_Beep_Delay */
- S_ST( 'n', 0, 0, 0 ), /* 437 T_Sim_Duration */
- S_ST( 't', 0, 0, 0 ), /* 438 T_Server_Offset */
- S_ST( 'n', 0, 0, 0 ), /* 439 T_Duration */
- S_ST( 't', 0, 0, 0 ), /* 440 T_Freq_Offset */
- S_ST( 'r', 0, 0, 0 ), /* 441 T_Wander */
- S_ST( 'r', 0, 0, 0 ), /* 442 T_Jitter */
- S_ST( 'y', 0, 0, 0 ), /* 443 T_Prop_Delay */
- S_ST( 'y', 0, 0, 0 ), /* 444 T_Proc_Delay */
- S_ST( 'a', 3, 446, 0 ), /* 445 loopst */
- S_ST( 't', 3, 335, 0 ), /* 446 loopsta */
- S_ST( 'w', 3, 448, 424 ), /* 447 lo */
- S_ST( 'p', 3, 449, 0 ), /* 448 low */
- S_ST( 'r', 3, 450, 0 ), /* 449 lowp */
- S_ST( 'i', 3, 451, 0 ), /* 450 lowpr */
- S_ST( 'o', 3, 452, 0 ), /* 451 lowpri */
- S_ST( 't', 3, 453, 0 ), /* 452 lowprio */
- S_ST( 'r', 3, 454, 0 ), /* 453 lowpriot */
- S_ST( 'a', 3, 336, 0 ), /* 454 lowpriotr */
- S_ST( 'm', 3, 536, 237 ), /* 455 */
- S_ST( 'a', 3, 474, 0 ), /* 456 m */
- S_ST( 'n', 3, 458, 0 ), /* 457 ma */
- S_ST( 'y', 3, 459, 0 ), /* 458 man */
- S_ST( 'c', 3, 460, 0 ), /* 459 many */
- S_ST( 'a', 3, 461, 0 ), /* 460 manyc */
- S_ST( 's', 3, 462, 0 ), /* 461 manyca */
- S_ST( 't', 3, 468, 0 ), /* 462 manycas */
- S_ST( 'c', 3, 464, 0 ), /* 463 manycast */
- S_ST( 'l', 3, 465, 0 ), /* 464 manycastc */
- S_ST( 'i', 3, 466, 0 ), /* 465 manycastcl */
- S_ST( 'e', 3, 467, 0 ), /* 466 manycastcli */
- S_ST( 'n', 3, 337, 0 ), /* 467 manycastclie */
- S_ST( 's', 3, 469, 463 ), /* 468 manycast */
- S_ST( 'e', 3, 470, 0 ), /* 469 manycasts */
- S_ST( 'r', 3, 471, 0 ), /* 470 manycastse */
- S_ST( 'v', 3, 472, 0 ), /* 471 manycastser */
- S_ST( 'e', 3, 338, 0 ), /* 472 manycastserv */
- S_ST( 's', 3, 339, 457 ), /* 473 ma */
- S_ST( 'x', 3, 489, 473 ), /* 474 ma */
- S_ST( 'a', 3, 476, 0 ), /* 475 max */
- S_ST( 'g', 3, 340, 0 ), /* 476 maxa */
- S_ST( 'c', 3, 478, 475 ), /* 477 max */
- S_ST( 'l', 3, 479, 0 ), /* 478 maxc */
- S_ST( 'o', 3, 480, 0 ), /* 479 maxcl */
- S_ST( 'c', 3, 341, 0 ), /* 480 maxclo */
- S_ST( 'd', 3, 485, 477 ), /* 481 max */
- S_ST( 'e', 3, 483, 0 ), /* 482 maxd */
- S_ST( 'p', 3, 484, 0 ), /* 483 maxde */
- S_ST( 't', 3, 342, 0 ), /* 484 maxdep */
- S_ST( 'i', 3, 486, 482 ), /* 485 maxd */
- S_ST( 's', 3, 343, 0 ), /* 486 maxdi */
- S_ST( 'm', 3, 488, 481 ), /* 487 max */
- S_ST( 'e', 3, 344, 0 ), /* 488 maxm */
- S_ST( 'p', 3, 490, 487 ), /* 489 max */
- S_ST( 'o', 3, 491, 0 ), /* 490 maxp */
- S_ST( 'l', 3, 345, 0 ), /* 491 maxpo */
- S_ST( 'd', 3, 493, 456 ), /* 492 m */
- S_ST( 'n', 3, 494, 0 ), /* 493 md */
- S_ST( 's', 3, 495, 0 ), /* 494 mdn */
- S_ST( 't', 3, 496, 0 ), /* 495 mdns */
- S_ST( 'r', 3, 497, 0 ), /* 496 mdnst */
- S_ST( 'i', 3, 498, 0 ), /* 497 mdnstr */
- S_ST( 'e', 3, 346, 0 ), /* 498 mdnstri */
- S_ST( 'e', 3, 347, 492 ), /* 499 m */
- S_ST( 'l', 3, 501, 0 ), /* 500 mem */
- S_ST( 'o', 3, 502, 0 ), /* 501 meml */
- S_ST( 'c', 3, 348, 0 ), /* 502 memlo */
- S_ST( 'i', 3, 504, 499 ), /* 503 m */
- S_ST( 'n', 3, 521, 0 ), /* 504 mi */
- S_ST( 'c', 3, 506, 0 ), /* 505 min */
- S_ST( 'l', 3, 507, 0 ), /* 506 minc */
- S_ST( 'o', 3, 508, 0 ), /* 507 mincl */
- S_ST( 'c', 3, 349, 0 ), /* 508 minclo */
- S_ST( 'd', 3, 513, 505 ), /* 509 min */
- S_ST( 'e', 3, 511, 0 ), /* 510 mind */
- S_ST( 'p', 3, 512, 0 ), /* 511 minde */
- S_ST( 't', 3, 350, 0 ), /* 512 mindep */
- S_ST( 'i', 3, 514, 510 ), /* 513 mind */
- S_ST( 's', 3, 351, 0 ), /* 514 mindi */
- S_ST( 'i', 3, 516, 509 ), /* 515 min */
- S_ST( 'm', 3, 517, 0 ), /* 516 mini */
- S_ST( 'u', 3, 352, 0 ), /* 517 minim */
- S_ST( 'p', 3, 519, 515 ), /* 518 min */
- S_ST( 'o', 3, 520, 0 ), /* 519 minp */
- S_ST( 'l', 3, 353, 0 ), /* 520 minpo */
- S_ST( 's', 3, 522, 518 ), /* 521 min */
- S_ST( 'a', 3, 523, 0 ), /* 522 mins */
- S_ST( 'n', 3, 354, 0 ), /* 523 minsa */
- S_ST( 'o', 3, 526, 503 ), /* 524 m */
- S_ST( 'd', 3, 355, 0 ), /* 525 mo */
- S_ST( 'n', 3, 530, 525 ), /* 526 mo */
- S_ST( 'i', 3, 528, 0 ), /* 527 mon */
- S_ST( 't', 3, 529, 0 ), /* 528 moni */
- S_ST( 'o', 3, 357, 0 ), /* 529 monit */
- S_ST( 't', 3, 358, 527 ), /* 530 mon */
- S_ST( 'r', 3, 359, 524 ), /* 531 m */
- S_ST( 's', 3, 533, 531 ), /* 532 m */
- S_ST( 's', 3, 534, 0 ), /* 533 ms */
- S_ST( 'n', 3, 535, 0 ), /* 534 mss */
- S_ST( 't', 3, 328, 0 ), /* 535 mssn */
- S_ST( 'u', 3, 537, 532 ), /* 536 m */
- S_ST( 'l', 3, 538, 0 ), /* 537 mu */
- S_ST( 't', 3, 539, 0 ), /* 538 mul */
- S_ST( 'i', 3, 540, 0 ), /* 539 mult */
- S_ST( 'c', 3, 541, 0 ), /* 540 multi */
- S_ST( 'a', 3, 542, 0 ), /* 541 multic */
- S_ST( 's', 3, 543, 0 ), /* 542 multica */
- S_ST( 't', 3, 544, 0 ), /* 543 multicas */
- S_ST( 'c', 3, 545, 0 ), /* 544 multicast */
- S_ST( 'l', 3, 546, 0 ), /* 545 multicastc */
- S_ST( 'i', 3, 547, 0 ), /* 546 multicastcl */
- S_ST( 'e', 3, 548, 0 ), /* 547 multicastcli */
- S_ST( 'n', 3, 360, 0 ), /* 548 multicastclie */
- S_ST( 'n', 3, 592, 455 ), /* 549 */
- S_ST( 'i', 3, 361, 0 ), /* 550 n */
- S_ST( 'o', 3, 587, 550 ), /* 551 n */
- S_ST( 'l', 3, 553, 0 ), /* 552 no */
- S_ST( 'i', 3, 554, 0 ), /* 553 nol */
- S_ST( 'n', 3, 362, 0 ), /* 554 noli */
- S_ST( 'm', 3, 560, 552 ), /* 555 no */
- S_ST( 'o', 3, 557, 0 ), /* 556 nom */
- S_ST( 'd', 3, 558, 0 ), /* 557 nomo */
- S_ST( 'i', 3, 559, 0 ), /* 558 nomod */
- S_ST( 'f', 3, 363, 0 ), /* 559 nomodi */
- S_ST( 'r', 3, 561, 556 ), /* 560 nom */
- S_ST( 'u', 3, 562, 0 ), /* 561 nomr */
- S_ST( 'l', 3, 563, 0 ), /* 562 nomru */
- S_ST( 'i', 3, 564, 0 ), /* 563 nomrul */
- S_ST( 's', 3, 364, 0 ), /* 564 nomruli */
- S_ST( 'n', 3, 566, 555 ), /* 565 no */
- S_ST( 'v', 3, 567, 365 ), /* 566 non */
- S_ST( 'o', 3, 568, 0 ), /* 567 nonv */
- S_ST( 'l', 3, 569, 0 ), /* 568 nonvo */
- S_ST( 'a', 3, 570, 0 ), /* 569 nonvol */
- S_ST( 't', 3, 571, 0 ), /* 570 nonvola */
- S_ST( 'i', 3, 572, 0 ), /* 571 nonvolat */
- S_ST( 'l', 3, 366, 0 ), /* 572 nonvolati */
- S_ST( 'p', 3, 574, 565 ), /* 573 no */
- S_ST( 'e', 3, 575, 0 ), /* 574 nop */
- S_ST( 'e', 3, 367, 0 ), /* 575 nope */
- S_ST( 'q', 3, 577, 573 ), /* 576 no */
- S_ST( 'u', 3, 578, 0 ), /* 577 noq */
- S_ST( 'e', 3, 579, 0 ), /* 578 noqu */
- S_ST( 'r', 3, 368, 0 ), /* 579 noque */
- S_ST( 's', 3, 581, 576 ), /* 580 no */
- S_ST( 'e', 3, 585, 0 ), /* 581 nos */
- S_ST( 'l', 3, 583, 0 ), /* 582 nose */
- S_ST( 'e', 3, 584, 0 ), /* 583 nosel */
- S_ST( 'c', 3, 369, 0 ), /* 584 nosele */
- S_ST( 'r', 3, 586, 582 ), /* 585 nose */
- S_ST( 'v', 3, 370, 0 ), /* 586 noser */
- S_ST( 't', 3, 588, 580 ), /* 587 no */
- S_ST( 'r', 3, 590, 0 ), /* 588 not */
- S_ST( 'a', 3, 371, 0 ), /* 589 notr */
- S_ST( 'u', 3, 591, 589 ), /* 590 notr */
- S_ST( 's', 3, 372, 0 ), /* 591 notru */
- S_ST( 't', 3, 373, 551 ), /* 592 n */
- S_ST( 'p', 3, 594, 0 ), /* 593 ntp */
- S_ST( 'o', 3, 595, 0 ), /* 594 ntpp */
- S_ST( 'r', 3, 374, 0 ), /* 595 ntppo */
- S_ST( 's', 3, 597, 593 ), /* 596 ntp */
- S_ST( 'i', 3, 598, 0 ), /* 597 ntps */
- S_ST( 'g', 3, 599, 0 ), /* 598 ntpsi */
- S_ST( 'n', 3, 600, 0 ), /* 599 ntpsig */
- S_ST( 'd', 3, 601, 0 ), /* 600 ntpsign */
- S_ST( 's', 3, 602, 0 ), /* 601 ntpsignd */
- S_ST( 'o', 3, 603, 0 ), /* 602 ntpsignds */
- S_ST( 'c', 3, 604, 0 ), /* 603 ntpsigndso */
- S_ST( 'k', 3, 605, 0 ), /* 604 ntpsigndsoc */
- S_ST( 'e', 3, 375, 0 ), /* 605 ntpsigndsock */
- S_ST( 'o', 3, 607, 549 ), /* 606 */
- S_ST( 'r', 3, 608, 0 ), /* 607 o */
- S_ST( 'p', 3, 609, 0 ), /* 608 or */
- S_ST( 'h', 3, 610, 0 ), /* 609 orp */
- S_ST( 'a', 3, 376, 0 ), /* 610 orph */
- S_ST( 'w', 3, 612, 0 ), /* 611 orphan */
- S_ST( 'a', 3, 613, 0 ), /* 612 orphanw */
- S_ST( 'i', 3, 377, 0 ), /* 613 orphanwa */
- S_ST( 'p', 3, 389, 606 ), /* 614 */
- S_ST( 'a', 3, 616, 0 ), /* 615 p */
- S_ST( 'n', 3, 617, 0 ), /* 616 pa */
- S_ST( 'i', 3, 378, 0 ), /* 617 pan */
- S_ST( 'e', 3, 619, 615 ), /* 618 p */
- S_ST( 'e', 3, 379, 0 ), /* 619 pe */
- S_ST( 's', 3, 621, 0 ), /* 620 peer */
- S_ST( 't', 3, 622, 0 ), /* 621 peers */
- S_ST( 'a', 3, 623, 0 ), /* 622 peerst */
- S_ST( 't', 3, 380, 0 ), /* 623 peersta */
- S_ST( 'h', 3, 625, 618 ), /* 624 p */
- S_ST( 'o', 3, 626, 0 ), /* 625 ph */
- S_ST( 'n', 3, 381, 0 ), /* 626 pho */
- S_ST( 'i', 3, 382, 624 ), /* 627 p */
- S_ST( 'f', 3, 629, 0 ), /* 628 pid */
- S_ST( 'i', 3, 630, 0 ), /* 629 pidf */
- S_ST( 'l', 3, 383, 0 ), /* 630 pidfi */
- S_ST( 'o', 3, 633, 627 ), /* 631 p */
- S_ST( 'o', 3, 384, 0 ), /* 632 po */
- S_ST( 'r', 3, 385, 632 ), /* 633 po */
- S_ST( 'r', 3, 641, 631 ), /* 634 p */
- S_ST( 'e', 3, 639, 0 ), /* 635 pr */
- S_ST( 'e', 3, 637, 0 ), /* 636 pre */
- S_ST( 'm', 3, 638, 0 ), /* 637 pree */
- S_ST( 'p', 3, 386, 0 ), /* 638 preem */
- S_ST( 'f', 3, 640, 636 ), /* 639 pre */
- S_ST( 'e', 3, 387, 0 ), /* 640 pref */
- S_ST( 'o', 3, 654, 635 ), /* 641 pr */
- S_ST( 'c', 3, 643, 0 ), /* 642 pro */
- S_ST( '_', 3, 644, 0 ), /* 643 proc */
- S_ST( 'd', 3, 645, 0 ), /* 644 proc_ */
- S_ST( 'e', 3, 646, 0 ), /* 645 proc_d */
- S_ST( 'l', 3, 647, 0 ), /* 646 proc_de */
- S_ST( 'a', 3, 444, 0 ), /* 647 proc_del */
- S_ST( 'p', 3, 649, 642 ), /* 648 pro */
- S_ST( '_', 3, 650, 0 ), /* 649 prop */
- S_ST( 'd', 3, 651, 0 ), /* 650 prop_ */
- S_ST( 'e', 3, 652, 0 ), /* 651 prop_d */
- S_ST( 'l', 3, 653, 0 ), /* 652 prop_de */
- S_ST( 'a', 3, 443, 0 ), /* 653 prop_del */
- S_ST( 't', 3, 655, 648 ), /* 654 pro */
- S_ST( 'o', 3, 656, 0 ), /* 655 prot */
- S_ST( 's', 3, 657, 0 ), /* 656 proto */
- S_ST( 't', 3, 658, 0 ), /* 657 protos */
- S_ST( 'a', 3, 659, 0 ), /* 658 protost */
- S_ST( 't', 3, 388, 0 ), /* 659 protosta */
- S_ST( 'r', 3, 691, 614 ), /* 660 */
- S_ST( 'a', 3, 667, 0 ), /* 661 r */
- S_ST( 'n', 3, 663, 0 ), /* 662 ra */
- S_ST( 'd', 3, 664, 0 ), /* 663 ran */
- S_ST( 'f', 3, 665, 0 ), /* 664 rand */
- S_ST( 'i', 3, 666, 0 ), /* 665 randf */
- S_ST( 'l', 3, 390, 0 ), /* 666 randfi */
- S_ST( 'w', 3, 668, 662 ), /* 667 ra */
- S_ST( 's', 3, 669, 0 ), /* 668 raw */
- S_ST( 't', 3, 670, 0 ), /* 669 raws */
- S_ST( 'a', 3, 671, 0 ), /* 670 rawst */
- S_ST( 't', 3, 391, 0 ), /* 671 rawsta */
- S_ST( 'e', 3, 688, 661 ), /* 672 r */
- S_ST( 'f', 3, 674, 0 ), /* 673 re */
- S_ST( 'i', 3, 392, 0 ), /* 674 ref */
- S_ST( 'q', 3, 676, 673 ), /* 675 re */
- S_ST( 'u', 3, 677, 0 ), /* 676 req */
- S_ST( 'e', 3, 678, 0 ), /* 677 requ */
- S_ST( 's', 3, 679, 0 ), /* 678 reque */
- S_ST( 't', 3, 680, 0 ), /* 679 reques */
- S_ST( 'k', 3, 681, 0 ), /* 680 request */
- S_ST( 'e', 3, 393, 0 ), /* 681 requestk */
- S_ST( 's', 3, 684, 675 ), /* 682 re */
- S_ST( 'e', 3, 394, 0 ), /* 683 res */
- S_ST( 't', 3, 685, 683 ), /* 684 res */
- S_ST( 'r', 3, 686, 0 ), /* 685 rest */
- S_ST( 'i', 3, 687, 0 ), /* 686 restr */
- S_ST( 'c', 3, 395, 0 ), /* 687 restri */
- S_ST( 'v', 3, 689, 682 ), /* 688 re */
- S_ST( 'o', 3, 690, 0 ), /* 689 rev */
- S_ST( 'k', 3, 396, 0 ), /* 690 revo */
- S_ST( 'l', 3, 692, 672 ), /* 691 r */
- S_ST( 'i', 3, 693, 0 ), /* 692 rl */
- S_ST( 'm', 3, 694, 0 ), /* 693 rli */
- S_ST( 'i', 3, 397, 0 ), /* 694 rlim */
- S_ST( 's', 3, 763, 660 ), /* 695 */
- S_ST( 'a', 3, 697, 0 ), /* 696 s */
- S_ST( 'v', 3, 698, 0 ), /* 697 sa */
- S_ST( 'e', 3, 699, 0 ), /* 698 sav */
- S_ST( 'c', 3, 700, 0 ), /* 699 save */
- S_ST( 'o', 3, 701, 0 ), /* 700 savec */
- S_ST( 'n', 3, 702, 0 ), /* 701 saveco */
- S_ST( 'f', 3, 703, 0 ), /* 702 savecon */
- S_ST( 'i', 3, 704, 0 ), /* 703 saveconf */
- S_ST( 'g', 3, 705, 0 ), /* 704 saveconfi */
- S_ST( 'd', 3, 706, 0 ), /* 705 saveconfig */
- S_ST( 'i', 3, 398, 0 ), /* 706 saveconfigd */
- S_ST( 'e', 3, 717, 696 ), /* 707 s */
- S_ST( 'r', 3, 709, 0 ), /* 708 se */
- S_ST( 'v', 3, 710, 0 ), /* 709 ser */
- S_ST( 'e', 3, 399, 0 ), /* 710 serv */
- S_ST( '_', 3, 712, 0 ), /* 711 server */
- S_ST( 'o', 3, 713, 0 ), /* 712 server_ */
- S_ST( 'f', 3, 714, 0 ), /* 713 server_o */
- S_ST( 'f', 3, 715, 0 ), /* 714 server_of */
- S_ST( 's', 3, 716, 0 ), /* 715 server_off */
- S_ST( 'e', 3, 438, 0 ), /* 716 server_offs */
- S_ST( 't', 3, 718, 708 ), /* 717 se */
- S_ST( 'v', 3, 719, 0 ), /* 718 set */
- S_ST( 'a', 3, 400, 0 ), /* 719 setv */
- S_ST( 'i', 3, 721, 707 ), /* 720 s */
- S_ST( 'm', 3, 722, 0 ), /* 721 si */
- S_ST( 'u', 3, 723, 0 ), /* 722 sim */
- S_ST( 'l', 3, 724, 0 ), /* 723 simu */
- S_ST( 'a', 3, 725, 0 ), /* 724 simul */
- S_ST( 't', 3, 726, 0 ), /* 725 simula */
- S_ST( 'i', 3, 727, 435 ), /* 726 simulat */
- S_ST( 'o', 3, 728, 0 ), /* 727 simulati */
- S_ST( 'n', 3, 729, 0 ), /* 728 simulatio */
- S_ST( '_', 3, 730, 0 ), /* 729 simulation */
- S_ST( 'd', 3, 731, 0 ), /* 730 simulation_ */
- S_ST( 'u', 3, 732, 0 ), /* 731 simulation_d */
- S_ST( 'r', 3, 733, 0 ), /* 732 simulation_du */
- S_ST( 'a', 3, 734, 0 ), /* 733 simulation_dur */
- S_ST( 't', 3, 735, 0 ), /* 734 simulation_dura */
- S_ST( 'i', 3, 736, 0 ), /* 735 simulation_durat */
- S_ST( 'o', 3, 437, 0 ), /* 736 simulation_durati */
- S_ST( 'o', 3, 738, 720 ), /* 737 s */
- S_ST( 'u', 3, 739, 0 ), /* 738 so */
- S_ST( 'r', 3, 740, 0 ), /* 739 sou */
- S_ST( 'c', 3, 401, 0 ), /* 740 sour */
- S_ST( 't', 3, 759, 737 ), /* 741 s */
- S_ST( 'a', 3, 748, 0 ), /* 742 st */
- S_ST( 'c', 3, 744, 0 ), /* 743 sta */
- S_ST( 'k', 3, 745, 0 ), /* 744 stac */
- S_ST( 's', 3, 746, 0 ), /* 745 stack */
- S_ST( 'i', 3, 747, 0 ), /* 746 stacks */
- S_ST( 'z', 3, 402, 0 ), /* 747 stacksi */
- S_ST( 't', 3, 404, 743 ), /* 748 sta */
- S_ST( 'i', 3, 750, 0 ), /* 749 stat */
- S_ST( 's', 3, 751, 0 ), /* 750 stati */
- S_ST( 't', 3, 752, 0 ), /* 751 statis */
- S_ST( 'i', 3, 753, 0 ), /* 752 statist */
- S_ST( 'c', 3, 403, 0 ), /* 753 statisti */
- S_ST( 'd', 3, 755, 0 ), /* 754 stats */
- S_ST( 'i', 3, 405, 0 ), /* 755 statsd */
- S_ST( 'e', 3, 406, 742 ), /* 756 st */
- S_ST( 'o', 3, 758, 0 ), /* 757 step */
- S_ST( 'u', 3, 407, 0 ), /* 758 stepo */
- S_ST( 'r', 3, 760, 756 ), /* 759 st */
- S_ST( 'a', 3, 761, 0 ), /* 760 str */
- S_ST( 't', 3, 762, 0 ), /* 761 stra */
- S_ST( 'u', 3, 408, 0 ), /* 762 strat */
- S_ST( 'y', 3, 410, 741 ), /* 763 s */
- S_ST( 's', 3, 765, 0 ), /* 764 sys */
- S_ST( 't', 3, 766, 0 ), /* 765 syss */
- S_ST( 'a', 3, 767, 0 ), /* 766 sysst */
- S_ST( 't', 3, 411, 0 ), /* 767 syssta */
- S_ST( 't', 3, 794, 695 ), /* 768 */
- S_ST( 'i', 3, 780, 0 ), /* 769 t */
- S_ST( 'c', 3, 412, 0 ), /* 770 ti */
- S_ST( 'm', 3, 773, 770 ), /* 771 ti */
- S_ST( 'e', 3, 415, 0 ), /* 772 tim */
- S_ST( 'i', 3, 774, 772 ), /* 773 tim */
- S_ST( 'n', 3, 775, 0 ), /* 774 timi */
- S_ST( 'g', 3, 776, 0 ), /* 775 timin */
- S_ST( 's', 3, 777, 0 ), /* 776 timing */
- S_ST( 't', 3, 778, 0 ), /* 777 timings */
- S_ST( 'a', 3, 779, 0 ), /* 778 timingst */
- S_ST( 't', 3, 416, 0 ), /* 779 timingsta */
- S_ST( 'n', 3, 781, 771 ), /* 780 ti */
- S_ST( 'k', 3, 782, 0 ), /* 781 tin */
- S_ST( 'e', 3, 417, 0 ), /* 782 tink */
- S_ST( 'o', 3, 418, 769 ), /* 783 t */
- S_ST( 'r', 3, 786, 783 ), /* 784 t */
- S_ST( 'a', 3, 419, 0 ), /* 785 tr */
- S_ST( 'u', 3, 787, 785 ), /* 786 tr */
- S_ST( 's', 3, 788, 420 ), /* 787 tru */
- S_ST( 't', 3, 789, 0 ), /* 788 trus */
- S_ST( 'e', 3, 790, 0 ), /* 789 trust */
- S_ST( 'd', 3, 791, 0 ), /* 790 truste */
- S_ST( 'k', 3, 792, 0 ), /* 791 trusted */
- S_ST( 'e', 3, 421, 0 ), /* 792 trustedk */
- S_ST( 't', 3, 422, 784 ), /* 793 t */
- S_ST( 'y', 3, 795, 793 ), /* 794 t */
- S_ST( 'p', 3, 423, 0 ), /* 795 ty */
- S_ST( 'u', 3, 797, 768 ), /* 796 */
- S_ST( 'n', 3, 803, 0 ), /* 797 u */
- S_ST( 'c', 3, 799, 0 ), /* 798 un */
- S_ST( 'o', 3, 800, 0 ), /* 799 unc */
- S_ST( 'n', 3, 801, 0 ), /* 800 unco */
- S_ST( 'f', 3, 802, 0 ), /* 801 uncon */
- S_ST( 'i', 3, 425, 0 ), /* 802 unconf */
- S_ST( 'p', 3, 804, 798 ), /* 803 un */
- S_ST( 'e', 3, 805, 0 ), /* 804 unp */
- S_ST( 'e', 3, 426, 0 ), /* 805 unpe */
- S_ST( 'v', 3, 807, 796 ), /* 806 */
- S_ST( 'e', 3, 808, 0 ), /* 807 v */
- S_ST( 'r', 3, 809, 0 ), /* 808 ve */
- S_ST( 's', 3, 810, 0 ), /* 809 ver */
- S_ST( 'i', 3, 811, 0 ), /* 810 vers */
- S_ST( 'o', 3, 427, 0 ), /* 811 versi */
- S_ST( 'w', 3, 819, 806 ), /* 812 */
- S_ST( 'a', 3, 814, 0 ), /* 813 w */
- S_ST( 'n', 3, 815, 0 ), /* 814 wa */
- S_ST( 'd', 3, 816, 0 ), /* 815 wan */
- S_ST( 'e', 3, 441, 0 ), /* 816 wand */
- S_ST( 'e', 3, 818, 813 ), /* 817 w */
- S_ST( 'e', 3, 429, 0 ), /* 818 we */
- S_ST( 'i', 3, 820, 817 ), /* 819 w */
- S_ST( 'l', 3, 821, 0 ), /* 820 wi */
- S_ST( 'd', 3, 822, 0 ), /* 821 wil */
- S_ST( 'c', 3, 823, 0 ), /* 822 wild */
- S_ST( 'a', 3, 824, 0 ), /* 823 wildc */
- S_ST( 'r', 3, 430, 0 ), /* 824 wildca */
- S_ST( 'x', 3, 826, 812 ), /* 825 */
- S_ST( 'l', 3, 827, 0 ), /* 826 x */
- S_ST( 'e', 3, 828, 0 ), /* 827 xl */
- S_ST( 'a', 3, 829, 0 ), /* 828 xle */
- S_ST( 'v', 3, 431, 0 ), /* 829 xlea */
- S_ST( 'y', 3, 831, 825 ), /* 830 [initial state] */
- S_ST( 'e', 3, 832, 0 ), /* 831 y */
- S_ST( 'a', 3, 432, 0 ) /* 832 ye */
+ S_ST( 'p', 0, 764, 0 ), /* 406 T_Step */
+ S_ST( 'k', 0, 0, 0 ), /* 407 T_Stepback */
+ S_ST( 'd', 0, 0, 0 ), /* 408 T_Stepfwd */
+ S_ST( 't', 0, 0, 0 ), /* 409 T_Stepout */
+ S_ST( 'm', 0, 0, 0 ), /* 410 T_Stratum */
+ S_ST( 'l', 3, 334, 0 ), /* 411 logfi */
+ S_ST( 's', 0, 771, 0 ), /* 412 T_Sys */
+ S_ST( 's', 0, 0, 0 ), /* 413 T_Sysstats */
+ S_ST( 'k', 0, 0, 0 ), /* 414 T_Tick */
+ S_ST( '1', 0, 0, 0 ), /* 415 T_Time1 */
+ S_ST( '2', 0, 0, 415 ), /* 416 T_Time2 */
+ S_ST( 'r', 0, 0, 416 ), /* 417 T_Timer */
+ S_ST( 's', 0, 0, 0 ), /* 418 T_Timingstats */
+ S_ST( 'r', 0, 0, 0 ), /* 419 T_Tinker */
+ S_ST( 's', 0, 0, 0 ), /* 420 T_Tos */
+ S_ST( 'p', 1, 0, 0 ), /* 421 T_Trap */
+ S_ST( 'e', 0, 0, 0 ), /* 422 T_True */
+ S_ST( 'y', 0, 0, 0 ), /* 423 T_Trustedkey */
+ S_ST( 'l', 0, 0, 0 ), /* 424 T_Ttl */
+ S_ST( 'e', 0, 0, 0 ), /* 425 T_Type */
+ S_ST( 'o', 3, 430, 254 ), /* 426 lo */
+ S_ST( 'g', 1, 0, 0 ), /* 427 T_Unconfig */
+ S_ST( 'r', 1, 0, 0 ), /* 428 T_Unpeer */
+ S_ST( 'n', 0, 0, 0 ), /* 429 T_Version */
+ S_ST( 'p', 3, 435, 0 ), /* 430 loo */
+ S_ST( 'k', 0, 0, 0 ), /* 431 T_Week */
+ S_ST( 'd', 0, 0, 0 ), /* 432 T_Wildcard */
+ S_ST( 'e', 0, 0, 0 ), /* 433 T_Xleave */
+ S_ST( 'r', 0, 0, 0 ), /* 434 T_Year */
+ S_ST( 's', 3, 436, 0 ), /* 435 loop */
+ S_ST( 't', 3, 447, 0 ), /* 436 loops */
+ S_ST( 'e', 0, 0, 0 ), /* 437 T_Simulate */
+ S_ST( 'y', 0, 0, 0 ), /* 438 T_Beep_Delay */
+ S_ST( 'n', 0, 0, 0 ), /* 439 T_Sim_Duration */
+ S_ST( 't', 0, 0, 0 ), /* 440 T_Server_Offset */
+ S_ST( 'n', 0, 0, 0 ), /* 441 T_Duration */
+ S_ST( 't', 0, 0, 0 ), /* 442 T_Freq_Offset */
+ S_ST( 'r', 0, 0, 0 ), /* 443 T_Wander */
+ S_ST( 'r', 0, 0, 0 ), /* 444 T_Jitter */
+ S_ST( 'y', 0, 0, 0 ), /* 445 T_Prop_Delay */
+ S_ST( 'y', 0, 0, 0 ), /* 446 T_Proc_Delay */
+ S_ST( 'a', 3, 448, 0 ), /* 447 loopst */
+ S_ST( 't', 3, 335, 0 ), /* 448 loopsta */
+ S_ST( 'w', 3, 450, 426 ), /* 449 lo */
+ S_ST( 'p', 3, 451, 0 ), /* 450 low */
+ S_ST( 'r', 3, 452, 0 ), /* 451 lowp */
+ S_ST( 'i', 3, 453, 0 ), /* 452 lowpr */
+ S_ST( 'o', 3, 454, 0 ), /* 453 lowpri */
+ S_ST( 't', 3, 455, 0 ), /* 454 lowprio */
+ S_ST( 'r', 3, 456, 0 ), /* 455 lowpriot */
+ S_ST( 'a', 3, 336, 0 ), /* 456 lowpriotr */
+ S_ST( 'm', 3, 538, 237 ), /* 457 */
+ S_ST( 'a', 3, 476, 0 ), /* 458 m */
+ S_ST( 'n', 3, 460, 0 ), /* 459 ma */
+ S_ST( 'y', 3, 461, 0 ), /* 460 man */
+ S_ST( 'c', 3, 462, 0 ), /* 461 many */
+ S_ST( 'a', 3, 463, 0 ), /* 462 manyc */
+ S_ST( 's', 3, 464, 0 ), /* 463 manyca */
+ S_ST( 't', 3, 470, 0 ), /* 464 manycas */
+ S_ST( 'c', 3, 466, 0 ), /* 465 manycast */
+ S_ST( 'l', 3, 467, 0 ), /* 466 manycastc */
+ S_ST( 'i', 3, 468, 0 ), /* 467 manycastcl */
+ S_ST( 'e', 3, 469, 0 ), /* 468 manycastcli */
+ S_ST( 'n', 3, 337, 0 ), /* 469 manycastclie */
+ S_ST( 's', 3, 471, 465 ), /* 470 manycast */
+ S_ST( 'e', 3, 472, 0 ), /* 471 manycasts */
+ S_ST( 'r', 3, 473, 0 ), /* 472 manycastse */
+ S_ST( 'v', 3, 474, 0 ), /* 473 manycastser */
+ S_ST( 'e', 3, 338, 0 ), /* 474 manycastserv */
+ S_ST( 's', 3, 339, 459 ), /* 475 ma */
+ S_ST( 'x', 3, 491, 475 ), /* 476 ma */
+ S_ST( 'a', 3, 478, 0 ), /* 477 max */
+ S_ST( 'g', 3, 340, 0 ), /* 478 maxa */
+ S_ST( 'c', 3, 480, 477 ), /* 479 max */
+ S_ST( 'l', 3, 481, 0 ), /* 480 maxc */
+ S_ST( 'o', 3, 482, 0 ), /* 481 maxcl */
+ S_ST( 'c', 3, 341, 0 ), /* 482 maxclo */
+ S_ST( 'd', 3, 487, 479 ), /* 483 max */
+ S_ST( 'e', 3, 485, 0 ), /* 484 maxd */
+ S_ST( 'p', 3, 486, 0 ), /* 485 maxde */
+ S_ST( 't', 3, 342, 0 ), /* 486 maxdep */
+ S_ST( 'i', 3, 488, 484 ), /* 487 maxd */
+ S_ST( 's', 3, 343, 0 ), /* 488 maxdi */
+ S_ST( 'm', 3, 490, 483 ), /* 489 max */
+ S_ST( 'e', 3, 344, 0 ), /* 490 maxm */
+ S_ST( 'p', 3, 492, 489 ), /* 491 max */
+ S_ST( 'o', 3, 493, 0 ), /* 492 maxp */
+ S_ST( 'l', 3, 345, 0 ), /* 493 maxpo */
+ S_ST( 'd', 3, 495, 458 ), /* 494 m */
+ S_ST( 'n', 3, 496, 0 ), /* 495 md */
+ S_ST( 's', 3, 497, 0 ), /* 496 mdn */
+ S_ST( 't', 3, 498, 0 ), /* 497 mdns */
+ S_ST( 'r', 3, 499, 0 ), /* 498 mdnst */
+ S_ST( 'i', 3, 500, 0 ), /* 499 mdnstr */
+ S_ST( 'e', 3, 346, 0 ), /* 500 mdnstri */
+ S_ST( 'e', 3, 347, 494 ), /* 501 m */
+ S_ST( 'l', 3, 503, 0 ), /* 502 mem */
+ S_ST( 'o', 3, 504, 0 ), /* 503 meml */
+ S_ST( 'c', 3, 348, 0 ), /* 504 memlo */
+ S_ST( 'i', 3, 506, 501 ), /* 505 m */
+ S_ST( 'n', 3, 523, 0 ), /* 506 mi */
+ S_ST( 'c', 3, 508, 0 ), /* 507 min */
+ S_ST( 'l', 3, 509, 0 ), /* 508 minc */
+ S_ST( 'o', 3, 510, 0 ), /* 509 mincl */
+ S_ST( 'c', 3, 349, 0 ), /* 510 minclo */
+ S_ST( 'd', 3, 515, 507 ), /* 511 min */
+ S_ST( 'e', 3, 513, 0 ), /* 512 mind */
+ S_ST( 'p', 3, 514, 0 ), /* 513 minde */
+ S_ST( 't', 3, 350, 0 ), /* 514 mindep */
+ S_ST( 'i', 3, 516, 512 ), /* 515 mind */
+ S_ST( 's', 3, 351, 0 ), /* 516 mindi */
+ S_ST( 'i', 3, 518, 511 ), /* 517 min */
+ S_ST( 'm', 3, 519, 0 ), /* 518 mini */
+ S_ST( 'u', 3, 352, 0 ), /* 519 minim */
+ S_ST( 'p', 3, 521, 517 ), /* 520 min */
+ S_ST( 'o', 3, 522, 0 ), /* 521 minp */
+ S_ST( 'l', 3, 353, 0 ), /* 522 minpo */
+ S_ST( 's', 3, 524, 520 ), /* 523 min */
+ S_ST( 'a', 3, 525, 0 ), /* 524 mins */
+ S_ST( 'n', 3, 354, 0 ), /* 525 minsa */
+ S_ST( 'o', 3, 528, 505 ), /* 526 m */
+ S_ST( 'd', 3, 355, 0 ), /* 527 mo */
+ S_ST( 'n', 3, 532, 527 ), /* 528 mo */
+ S_ST( 'i', 3, 530, 0 ), /* 529 mon */
+ S_ST( 't', 3, 531, 0 ), /* 530 moni */
+ S_ST( 'o', 3, 357, 0 ), /* 531 monit */
+ S_ST( 't', 3, 358, 529 ), /* 532 mon */
+ S_ST( 'r', 3, 359, 526 ), /* 533 m */
+ S_ST( 's', 3, 535, 533 ), /* 534 m */
+ S_ST( 's', 3, 536, 0 ), /* 535 ms */
+ S_ST( 'n', 3, 537, 0 ), /* 536 mss */
+ S_ST( 't', 3, 328, 0 ), /* 537 mssn */
+ S_ST( 'u', 3, 539, 534 ), /* 538 m */
+ S_ST( 'l', 3, 540, 0 ), /* 539 mu */
+ S_ST( 't', 3, 541, 0 ), /* 540 mul */
+ S_ST( 'i', 3, 542, 0 ), /* 541 mult */
+ S_ST( 'c', 3, 543, 0 ), /* 542 multi */
+ S_ST( 'a', 3, 544, 0 ), /* 543 multic */
+ S_ST( 's', 3, 545, 0 ), /* 544 multica */
+ S_ST( 't', 3, 546, 0 ), /* 545 multicas */
+ S_ST( 'c', 3, 547, 0 ), /* 546 multicast */
+ S_ST( 'l', 3, 548, 0 ), /* 547 multicastc */
+ S_ST( 'i', 3, 549, 0 ), /* 548 multicastcl */
+ S_ST( 'e', 3, 550, 0 ), /* 549 multicastcli */
+ S_ST( 'n', 3, 360, 0 ), /* 550 multicastclie */
+ S_ST( 'n', 3, 594, 457 ), /* 551 */
+ S_ST( 'i', 3, 361, 0 ), /* 552 n */
+ S_ST( 'o', 3, 589, 552 ), /* 553 n */
+ S_ST( 'l', 3, 555, 0 ), /* 554 no */
+ S_ST( 'i', 3, 556, 0 ), /* 555 nol */
+ S_ST( 'n', 3, 362, 0 ), /* 556 noli */
+ S_ST( 'm', 3, 562, 554 ), /* 557 no */
+ S_ST( 'o', 3, 559, 0 ), /* 558 nom */
+ S_ST( 'd', 3, 560, 0 ), /* 559 nomo */
+ S_ST( 'i', 3, 561, 0 ), /* 560 nomod */
+ S_ST( 'f', 3, 363, 0 ), /* 561 nomodi */
+ S_ST( 'r', 3, 563, 558 ), /* 562 nom */
+ S_ST( 'u', 3, 564, 0 ), /* 563 nomr */
+ S_ST( 'l', 3, 565, 0 ), /* 564 nomru */
+ S_ST( 'i', 3, 566, 0 ), /* 565 nomrul */
+ S_ST( 's', 3, 364, 0 ), /* 566 nomruli */
+ S_ST( 'n', 3, 568, 557 ), /* 567 no */
+ S_ST( 'v', 3, 569, 365 ), /* 568 non */
+ S_ST( 'o', 3, 570, 0 ), /* 569 nonv */
+ S_ST( 'l', 3, 571, 0 ), /* 570 nonvo */
+ S_ST( 'a', 3, 572, 0 ), /* 571 nonvol */
+ S_ST( 't', 3, 573, 0 ), /* 572 nonvola */
+ S_ST( 'i', 3, 574, 0 ), /* 573 nonvolat */
+ S_ST( 'l', 3, 366, 0 ), /* 574 nonvolati */
+ S_ST( 'p', 3, 576, 567 ), /* 575 no */
+ S_ST( 'e', 3, 577, 0 ), /* 576 nop */
+ S_ST( 'e', 3, 367, 0 ), /* 577 nope */
+ S_ST( 'q', 3, 579, 575 ), /* 578 no */
+ S_ST( 'u', 3, 580, 0 ), /* 579 noq */
+ S_ST( 'e', 3, 581, 0 ), /* 580 noqu */
+ S_ST( 'r', 3, 368, 0 ), /* 581 noque */
+ S_ST( 's', 3, 583, 578 ), /* 582 no */
+ S_ST( 'e', 3, 587, 0 ), /* 583 nos */
+ S_ST( 'l', 3, 585, 0 ), /* 584 nose */
+ S_ST( 'e', 3, 586, 0 ), /* 585 nosel */
+ S_ST( 'c', 3, 369, 0 ), /* 586 nosele */
+ S_ST( 'r', 3, 588, 584 ), /* 587 nose */
+ S_ST( 'v', 3, 370, 0 ), /* 588 noser */
+ S_ST( 't', 3, 590, 582 ), /* 589 no */
+ S_ST( 'r', 3, 592, 0 ), /* 590 not */
+ S_ST( 'a', 3, 371, 0 ), /* 591 notr */
+ S_ST( 'u', 3, 593, 591 ), /* 592 notr */
+ S_ST( 's', 3, 372, 0 ), /* 593 notru */
+ S_ST( 't', 3, 373, 553 ), /* 594 n */
+ S_ST( 'p', 3, 596, 0 ), /* 595 ntp */
+ S_ST( 'o', 3, 597, 0 ), /* 596 ntpp */
+ S_ST( 'r', 3, 374, 0 ), /* 597 ntppo */
+ S_ST( 's', 3, 599, 595 ), /* 598 ntp */
+ S_ST( 'i', 3, 600, 0 ), /* 599 ntps */
+ S_ST( 'g', 3, 601, 0 ), /* 600 ntpsi */
+ S_ST( 'n', 3, 602, 0 ), /* 601 ntpsig */
+ S_ST( 'd', 3, 603, 0 ), /* 602 ntpsign */
+ S_ST( 's', 3, 604, 0 ), /* 603 ntpsignd */
+ S_ST( 'o', 3, 605, 0 ), /* 604 ntpsignds */
+ S_ST( 'c', 3, 606, 0 ), /* 605 ntpsigndso */
+ S_ST( 'k', 3, 607, 0 ), /* 606 ntpsigndsoc */
+ S_ST( 'e', 3, 375, 0 ), /* 607 ntpsigndsock */
+ S_ST( 'o', 3, 609, 551 ), /* 608 */
+ S_ST( 'r', 3, 610, 0 ), /* 609 o */
+ S_ST( 'p', 3, 611, 0 ), /* 610 or */
+ S_ST( 'h', 3, 612, 0 ), /* 611 orp */
+ S_ST( 'a', 3, 376, 0 ), /* 612 orph */
+ S_ST( 'w', 3, 614, 0 ), /* 613 orphan */
+ S_ST( 'a', 3, 615, 0 ), /* 614 orphanw */
+ S_ST( 'i', 3, 377, 0 ), /* 615 orphanwa */
+ S_ST( 'p', 3, 389, 608 ), /* 616 */
+ S_ST( 'a', 3, 618, 0 ), /* 617 p */
+ S_ST( 'n', 3, 619, 0 ), /* 618 pa */
+ S_ST( 'i', 3, 378, 0 ), /* 619 pan */
+ S_ST( 'e', 3, 621, 617 ), /* 620 p */
+ S_ST( 'e', 3, 379, 0 ), /* 621 pe */
+ S_ST( 's', 3, 623, 0 ), /* 622 peer */
+ S_ST( 't', 3, 624, 0 ), /* 623 peers */
+ S_ST( 'a', 3, 625, 0 ), /* 624 peerst */
+ S_ST( 't', 3, 380, 0 ), /* 625 peersta */
+ S_ST( 'h', 3, 627, 620 ), /* 626 p */
+ S_ST( 'o', 3, 628, 0 ), /* 627 ph */
+ S_ST( 'n', 3, 381, 0 ), /* 628 pho */
+ S_ST( 'i', 3, 382, 626 ), /* 629 p */
+ S_ST( 'f', 3, 631, 0 ), /* 630 pid */
+ S_ST( 'i', 3, 632, 0 ), /* 631 pidf */
+ S_ST( 'l', 3, 383, 0 ), /* 632 pidfi */
+ S_ST( 'o', 3, 635, 629 ), /* 633 p */
+ S_ST( 'o', 3, 384, 0 ), /* 634 po */
+ S_ST( 'r', 3, 385, 634 ), /* 635 po */
+ S_ST( 'r', 3, 643, 633 ), /* 636 p */
+ S_ST( 'e', 3, 641, 0 ), /* 637 pr */
+ S_ST( 'e', 3, 639, 0 ), /* 638 pre */
+ S_ST( 'm', 3, 640, 0 ), /* 639 pree */
+ S_ST( 'p', 3, 386, 0 ), /* 640 preem */
+ S_ST( 'f', 3, 642, 638 ), /* 641 pre */
+ S_ST( 'e', 3, 387, 0 ), /* 642 pref */
+ S_ST( 'o', 3, 656, 637 ), /* 643 pr */
+ S_ST( 'c', 3, 645, 0 ), /* 644 pro */
+ S_ST( '_', 3, 646, 0 ), /* 645 proc */
+ S_ST( 'd', 3, 647, 0 ), /* 646 proc_ */
+ S_ST( 'e', 3, 648, 0 ), /* 647 proc_d */
+ S_ST( 'l', 3, 649, 0 ), /* 648 proc_de */
+ S_ST( 'a', 3, 446, 0 ), /* 649 proc_del */
+ S_ST( 'p', 3, 651, 644 ), /* 650 pro */
+ S_ST( '_', 3, 652, 0 ), /* 651 prop */
+ S_ST( 'd', 3, 653, 0 ), /* 652 prop_ */
+ S_ST( 'e', 3, 654, 0 ), /* 653 prop_d */
+ S_ST( 'l', 3, 655, 0 ), /* 654 prop_de */
+ S_ST( 'a', 3, 445, 0 ), /* 655 prop_del */
+ S_ST( 't', 3, 657, 650 ), /* 656 pro */
+ S_ST( 'o', 3, 658, 0 ), /* 657 prot */
+ S_ST( 's', 3, 659, 0 ), /* 658 proto */
+ S_ST( 't', 3, 660, 0 ), /* 659 protos */
+ S_ST( 'a', 3, 661, 0 ), /* 660 protost */
+ S_ST( 't', 3, 388, 0 ), /* 661 protosta */
+ S_ST( 'r', 3, 693, 616 ), /* 662 */
+ S_ST( 'a', 3, 669, 0 ), /* 663 r */
+ S_ST( 'n', 3, 665, 0 ), /* 664 ra */
+ S_ST( 'd', 3, 666, 0 ), /* 665 ran */
+ S_ST( 'f', 3, 667, 0 ), /* 666 rand */
+ S_ST( 'i', 3, 668, 0 ), /* 667 randf */
+ S_ST( 'l', 3, 390, 0 ), /* 668 randfi */
+ S_ST( 'w', 3, 670, 664 ), /* 669 ra */
+ S_ST( 's', 3, 671, 0 ), /* 670 raw */
+ S_ST( 't', 3, 672, 0 ), /* 671 raws */
+ S_ST( 'a', 3, 673, 0 ), /* 672 rawst */
+ S_ST( 't', 3, 391, 0 ), /* 673 rawsta */
+ S_ST( 'e', 3, 690, 663 ), /* 674 r */
+ S_ST( 'f', 3, 676, 0 ), /* 675 re */
+ S_ST( 'i', 3, 392, 0 ), /* 676 ref */
+ S_ST( 'q', 3, 678, 675 ), /* 677 re */
+ S_ST( 'u', 3, 679, 0 ), /* 678 req */
+ S_ST( 'e', 3, 680, 0 ), /* 679 requ */
+ S_ST( 's', 3, 681, 0 ), /* 680 reque */
+ S_ST( 't', 3, 682, 0 ), /* 681 reques */
+ S_ST( 'k', 3, 683, 0 ), /* 682 request */
+ S_ST( 'e', 3, 393, 0 ), /* 683 requestk */
+ S_ST( 's', 3, 686, 677 ), /* 684 re */
+ S_ST( 'e', 3, 394, 0 ), /* 685 res */
+ S_ST( 't', 3, 687, 685 ), /* 686 res */
+ S_ST( 'r', 3, 688, 0 ), /* 687 rest */
+ S_ST( 'i', 3, 689, 0 ), /* 688 restr */
+ S_ST( 'c', 3, 395, 0 ), /* 689 restri */
+ S_ST( 'v', 3, 691, 684 ), /* 690 re */
+ S_ST( 'o', 3, 692, 0 ), /* 691 rev */
+ S_ST( 'k', 3, 396, 0 ), /* 692 revo */
+ S_ST( 'l', 3, 694, 674 ), /* 693 r */
+ S_ST( 'i', 3, 695, 0 ), /* 694 rl */
+ S_ST( 'm', 3, 696, 0 ), /* 695 rli */
+ S_ST( 'i', 3, 397, 0 ), /* 696 rlim */
+ S_ST( 's', 3, 770, 662 ), /* 697 */
+ S_ST( 'a', 3, 699, 0 ), /* 698 s */
+ S_ST( 'v', 3, 700, 0 ), /* 699 sa */
+ S_ST( 'e', 3, 701, 0 ), /* 700 sav */
+ S_ST( 'c', 3, 702, 0 ), /* 701 save */
+ S_ST( 'o', 3, 703, 0 ), /* 702 savec */
+ S_ST( 'n', 3, 704, 0 ), /* 703 saveco */
+ S_ST( 'f', 3, 705, 0 ), /* 704 savecon */
+ S_ST( 'i', 3, 706, 0 ), /* 705 saveconf */
+ S_ST( 'g', 3, 707, 0 ), /* 706 saveconfi */
+ S_ST( 'd', 3, 708, 0 ), /* 707 saveconfig */
+ S_ST( 'i', 3, 398, 0 ), /* 708 saveconfigd */
+ S_ST( 'e', 3, 719, 698 ), /* 709 s */
+ S_ST( 'r', 3, 711, 0 ), /* 710 se */
+ S_ST( 'v', 3, 712, 0 ), /* 711 ser */
+ S_ST( 'e', 3, 399, 0 ), /* 712 serv */
+ S_ST( '_', 3, 714, 0 ), /* 713 server */
+ S_ST( 'o', 3, 715, 0 ), /* 714 server_ */
+ S_ST( 'f', 3, 716, 0 ), /* 715 server_o */
+ S_ST( 'f', 3, 717, 0 ), /* 716 server_of */
+ S_ST( 's', 3, 718, 0 ), /* 717 server_off */
+ S_ST( 'e', 3, 440, 0 ), /* 718 server_offs */
+ S_ST( 't', 3, 720, 710 ), /* 719 se */
+ S_ST( 'v', 3, 721, 0 ), /* 720 set */
+ S_ST( 'a', 3, 400, 0 ), /* 721 setv */
+ S_ST( 'i', 3, 723, 709 ), /* 722 s */
+ S_ST( 'm', 3, 724, 0 ), /* 723 si */
+ S_ST( 'u', 3, 725, 0 ), /* 724 sim */
+ S_ST( 'l', 3, 726, 0 ), /* 725 simu */
+ S_ST( 'a', 3, 727, 0 ), /* 726 simul */
+ S_ST( 't', 3, 728, 0 ), /* 727 simula */
+ S_ST( 'i', 3, 729, 437 ), /* 728 simulat */
+ S_ST( 'o', 3, 730, 0 ), /* 729 simulati */
+ S_ST( 'n', 3, 731, 0 ), /* 730 simulatio */
+ S_ST( '_', 3, 732, 0 ), /* 731 simulation */
+ S_ST( 'd', 3, 733, 0 ), /* 732 simulation_ */
+ S_ST( 'u', 3, 734, 0 ), /* 733 simulation_d */
+ S_ST( 'r', 3, 735, 0 ), /* 734 simulation_du */
+ S_ST( 'a', 3, 736, 0 ), /* 735 simulation_dur */
+ S_ST( 't', 3, 737, 0 ), /* 736 simulation_dura */
+ S_ST( 'i', 3, 738, 0 ), /* 737 simulation_durat */
+ S_ST( 'o', 3, 439, 0 ), /* 738 simulation_durati */
+ S_ST( 'o', 3, 740, 722 ), /* 739 s */
+ S_ST( 'u', 3, 741, 0 ), /* 740 so */
+ S_ST( 'r', 3, 742, 0 ), /* 741 sou */
+ S_ST( 'c', 3, 401, 0 ), /* 742 sour */
+ S_ST( 't', 3, 766, 739 ), /* 743 s */
+ S_ST( 'a', 3, 750, 0 ), /* 744 st */
+ S_ST( 'c', 3, 746, 0 ), /* 745 sta */
+ S_ST( 'k', 3, 747, 0 ), /* 746 stac */
+ S_ST( 's', 3, 748, 0 ), /* 747 stack */
+ S_ST( 'i', 3, 749, 0 ), /* 748 stacks */
+ S_ST( 'z', 3, 402, 0 ), /* 749 stacksi */
+ S_ST( 't', 3, 404, 745 ), /* 750 sta */
+ S_ST( 'i', 3, 752, 0 ), /* 751 stat */
+ S_ST( 's', 3, 753, 0 ), /* 752 stati */
+ S_ST( 't', 3, 754, 0 ), /* 753 statis */
+ S_ST( 'i', 3, 755, 0 ), /* 754 statist */
+ S_ST( 'c', 3, 403, 0 ), /* 755 statisti */
+ S_ST( 'd', 3, 757, 0 ), /* 756 stats */
+ S_ST( 'i', 3, 405, 0 ), /* 757 statsd */
+ S_ST( 'e', 3, 406, 744 ), /* 758 st */
+ S_ST( 'b', 3, 760, 0 ), /* 759 step */
+ S_ST( 'a', 3, 761, 0 ), /* 760 stepb */
+ S_ST( 'c', 3, 407, 0 ), /* 761 stepba */
+ S_ST( 'f', 3, 763, 759 ), /* 762 step */
+ S_ST( 'w', 3, 408, 0 ), /* 763 stepf */
+ S_ST( 'o', 3, 765, 762 ), /* 764 step */
+ S_ST( 'u', 3, 409, 0 ), /* 765 stepo */
+ S_ST( 'r', 3, 767, 758 ), /* 766 st */
+ S_ST( 'a', 3, 768, 0 ), /* 767 str */
+ S_ST( 't', 3, 769, 0 ), /* 768 stra */
+ S_ST( 'u', 3, 410, 0 ), /* 769 strat */
+ S_ST( 'y', 3, 412, 743 ), /* 770 s */
+ S_ST( 's', 3, 772, 0 ), /* 771 sys */
+ S_ST( 't', 3, 773, 0 ), /* 772 syss */
+ S_ST( 'a', 3, 774, 0 ), /* 773 sysst */
+ S_ST( 't', 3, 413, 0 ), /* 774 syssta */
+ S_ST( 't', 3, 801, 697 ), /* 775 */
+ S_ST( 'i', 3, 787, 0 ), /* 776 t */
+ S_ST( 'c', 3, 414, 0 ), /* 777 ti */
+ S_ST( 'm', 3, 780, 777 ), /* 778 ti */
+ S_ST( 'e', 3, 417, 0 ), /* 779 tim */
+ S_ST( 'i', 3, 781, 779 ), /* 780 tim */
+ S_ST( 'n', 3, 782, 0 ), /* 781 timi */
+ S_ST( 'g', 3, 783, 0 ), /* 782 timin */
+ S_ST( 's', 3, 784, 0 ), /* 783 timing */
+ S_ST( 't', 3, 785, 0 ), /* 784 timings */
+ S_ST( 'a', 3, 786, 0 ), /* 785 timingst */
+ S_ST( 't', 3, 418, 0 ), /* 786 timingsta */
+ S_ST( 'n', 3, 788, 778 ), /* 787 ti */
+ S_ST( 'k', 3, 789, 0 ), /* 788 tin */
+ S_ST( 'e', 3, 419, 0 ), /* 789 tink */
+ S_ST( 'o', 3, 420, 776 ), /* 790 t */
+ S_ST( 'r', 3, 793, 790 ), /* 791 t */
+ S_ST( 'a', 3, 421, 0 ), /* 792 tr */
+ S_ST( 'u', 3, 794, 792 ), /* 793 tr */
+ S_ST( 's', 3, 795, 422 ), /* 794 tru */
+ S_ST( 't', 3, 796, 0 ), /* 795 trus */
+ S_ST( 'e', 3, 797, 0 ), /* 796 trust */
+ S_ST( 'd', 3, 798, 0 ), /* 797 truste */
+ S_ST( 'k', 3, 799, 0 ), /* 798 trusted */
+ S_ST( 'e', 3, 423, 0 ), /* 799 trustedk */
+ S_ST( 't', 3, 424, 791 ), /* 800 t */
+ S_ST( 'y', 3, 802, 800 ), /* 801 t */
+ S_ST( 'p', 3, 425, 0 ), /* 802 ty */
+ S_ST( 'u', 3, 804, 775 ), /* 803 */
+ S_ST( 'n', 3, 810, 0 ), /* 804 u */
+ S_ST( 'c', 3, 806, 0 ), /* 805 un */
+ S_ST( 'o', 3, 807, 0 ), /* 806 unc */
+ S_ST( 'n', 3, 808, 0 ), /* 807 unco */
+ S_ST( 'f', 3, 809, 0 ), /* 808 uncon */
+ S_ST( 'i', 3, 427, 0 ), /* 809 unconf */
+ S_ST( 'p', 3, 811, 805 ), /* 810 un */
+ S_ST( 'e', 3, 812, 0 ), /* 811 unp */
+ S_ST( 'e', 3, 428, 0 ), /* 812 unpe */
+ S_ST( 'v', 3, 814, 803 ), /* 813 */
+ S_ST( 'e', 3, 815, 0 ), /* 814 v */
+ S_ST( 'r', 3, 816, 0 ), /* 815 ve */
+ S_ST( 's', 3, 817, 0 ), /* 816 ver */
+ S_ST( 'i', 3, 818, 0 ), /* 817 vers */
+ S_ST( 'o', 3, 429, 0 ), /* 818 versi */
+ S_ST( 'w', 3, 826, 813 ), /* 819 */
+ S_ST( 'a', 3, 821, 0 ), /* 820 w */
+ S_ST( 'n', 3, 822, 0 ), /* 821 wa */
+ S_ST( 'd', 3, 823, 0 ), /* 822 wan */
+ S_ST( 'e', 3, 443, 0 ), /* 823 wand */
+ S_ST( 'e', 3, 825, 820 ), /* 824 w */
+ S_ST( 'e', 3, 431, 0 ), /* 825 we */
+ S_ST( 'i', 3, 827, 824 ), /* 826 w */
+ S_ST( 'l', 3, 828, 0 ), /* 827 wi */
+ S_ST( 'd', 3, 829, 0 ), /* 828 wil */
+ S_ST( 'c', 3, 830, 0 ), /* 829 wild */
+ S_ST( 'a', 3, 831, 0 ), /* 830 wildc */
+ S_ST( 'r', 3, 432, 0 ), /* 831 wildca */
+ S_ST( 'x', 3, 833, 819 ), /* 832 */
+ S_ST( 'l', 3, 834, 0 ), /* 833 x */
+ S_ST( 'e', 3, 835, 0 ), /* 834 xl */
+ S_ST( 'a', 3, 836, 0 ), /* 835 xle */
+ S_ST( 'v', 3, 433, 0 ), /* 836 xlea */
+ S_ST( 'y', 3, 838, 832 ), /* 837 [initial state] */
+ S_ST( 'e', 3, 839, 0 ), /* 838 y */
+ S_ST( 'a', 3, 434, 0 ) /* 839 ye */
};
diff --git a/contrib/ntp/ntpd/ntp_leapsec.c b/contrib/ntp/ntpd/ntp_leapsec.c
index ec42a97..eeef89f 100644
--- a/contrib/ntp/ntpd/ntp_leapsec.c
+++ b/contrib/ntp/ntpd/ntp_leapsec.c
@@ -787,7 +787,7 @@ leapsec_add(
const vint64 * now64 ,
int insert)
{
- vint64 ttime, stime;
+ vint64 ttime, starttime;
struct calendar fts;
leap_info_t li;
@@ -815,12 +815,12 @@ leapsec_add(
fts.hour = 0;
fts.minute = 0;
fts.second = 0;
- stime = ntpcal_date_to_ntp64(&fts);
+ starttime = ntpcal_date_to_ntp64(&fts);
fts.month++;
ttime = ntpcal_date_to_ntp64(&fts);
li.ttime = ttime;
- li.stime = ttime.D_s.lo - stime.D_s.lo;
+ li.stime = ttime.D_s.lo - starttime.D_s.lo;
li.taiof = (pt->head.size ? pt->info[0].taiof : pt->head.base_tai)
+ (insert ? 1 : -1);
li.dynls = 1;
@@ -839,7 +839,7 @@ leapsec_raw(
int taiof,
int dynls)
{
- vint64 stime;
+ vint64 starttime;
struct calendar fts;
leap_info_t li;
@@ -856,9 +856,9 @@ leapsec_raw(
return FALSE;
}
fts.month--; /* was in range 1..12, no overflow here! */
- stime = ntpcal_date_to_ntp64(&fts);
+ starttime = ntpcal_date_to_ntp64(&fts);
li.ttime = *ttime;
- li.stime = ttime->D_s.lo - stime.D_s.lo;
+ li.stime = ttime->D_s.lo - starttime.D_s.lo;
li.taiof = (int16_t)taiof;
li.dynls = (dynls != 0);
return add_range(pt, &li);
diff --git a/contrib/ntp/ntpd/ntp_loopfilter.c b/contrib/ntp/ntpd/ntp_loopfilter.c
index 82ff163..e47f83b 100644
--- a/contrib/ntp/ntpd/ntp_loopfilter.c
+++ b/contrib/ntp/ntpd/ntp_loopfilter.c
@@ -46,7 +46,7 @@
#define CLOCK_LIMIT 30 /* poll-adjust threshold */
#define CLOCK_PGATE 4. /* poll-adjust gate */
#define PPS_MAXAGE 120 /* kernel pps signal timeout (s) */
-#define FREQTOD(x) ((x) / 65536e6) /* NTP to double */
+#define FREQTOD(x) ((x) / 65536e6) /* NTP to double */
#define DTOFREQ(x) ((int32)((x) * 65536e6)) /* double to NTP */
/*
@@ -106,7 +106,8 @@
/*
* Program variables that can be tinkered.
*/
-double clock_max = CLOCK_MAX; /* step threshold */
+double clock_max_back = CLOCK_MAX; /* step threshold */
+double clock_max_fwd = CLOCK_MAX; /* step threshold */
double clock_minstep = CLOCK_MINSTEP; /* stepout threshold */
double clock_panic = CLOCK_PANIC; /* panic threshold */
double clock_phi = CLOCK_PHI; /* dispersion rate (s/s) */
@@ -152,8 +153,10 @@ int kern_enable = TRUE; /* kernel support enabled */
int hardpps_enable; /* kernel PPS discipline enabled */
int ext_enable; /* external clock enabled */
int pps_stratum; /* pps stratum */
-int allow_panic = FALSE; /* allow panic correction */
-int mode_ntpdate = FALSE; /* exit on first clock set */
+int kernel_status; /* from ntp_adjtime */
+int allow_panic = FALSE; /* allow panic correction (-g) */
+int force_step_once = FALSE; /* always step time once at startup (-G) */
+int mode_ntpdate = FALSE; /* exit on first clock set (-q) */
int freq_cnt; /* initial frequency clamp */
int freq_set; /* initial set frequency switch */
@@ -279,47 +282,69 @@ ntp_adjtime_error_handler(
}
break;
#ifdef TIME_OK
- case TIME_OK: /* 0 no leap second warning */
- /* OK means OK */
+ case TIME_OK: /* 0: synchronized, no leap second warning */
+ /* msyslog(LOG_INFO, "kernel reports time is synchronized normally"); */
break;
+#else
+# warning TIME_OK is not defined
#endif
#ifdef TIME_INS
- case TIME_INS: /* 1 positive leap second warning */
- msyslog(LOG_INFO, "%s: %s line %d: kernel reports positive leap second warning state",
- caller, file_name(), line
- );
+ case TIME_INS: /* 1: positive leap second warning */
+ msyslog(LOG_INFO, "kernel reports leap second insertion scheduled");
break;
+#else
+# warning TIME_INS is not defined
#endif
#ifdef TIME_DEL
- case TIME_DEL: /* 2 negative leap second warning */
- msyslog(LOG_INFO, "%s: %s line %d: kernel reports negative leap second warning state",
- caller, file_name(), line
- );
+ case TIME_DEL: /* 2: negative leap second warning */
+ msyslog(LOG_INFO, "kernel reports leap second deletion scheduled");
break;
+#else
+# warning TIME_DEL is not defined
#endif
#ifdef TIME_OOP
- case TIME_OOP: /* 3 leap second in progress */
- msyslog(LOG_INFO, "%s: %s line %d: kernel reports leap second in progress",
- caller, file_name(), line
- );
+ case TIME_OOP: /* 3: leap second in progress */
+ msyslog(LOG_INFO, "kernel reports leap second in progress");
break;
+#else
+# warning TIME_OOP is not defined
#endif
#ifdef TIME_WAIT
- case TIME_WAIT: /* 4 leap second has occured */
- msyslog(LOG_INFO, "%s: %s line %d: kernel reports leap second has occured",
- caller, file_name(), line
- );
+ case TIME_WAIT: /* 4: leap second has occured */
+ msyslog(LOG_INFO, "kernel reports leap second has occurred");
break;
+#else
+# warning TIME_WAIT is not defined
#endif
#ifdef TIME_ERROR
- case TIME_ERROR: /* loss of synchronization */
+ case TIME_ERROR: /* 5: unsynchronized, or loss of synchronization */
+ /* error (see status word) */
if (pps_call && !(ptimex->status & STA_PPSSIGNAL))
report_event(EVNT_KERN, NULL,
"PPS no signal");
errno = saved_errno;
DPRINTF(1, ("kernel loop status (%s) %d %m\n",
k_st_flags(ptimex->status), errno));
+ /*
+ * This code may be returned when ntp_adjtime() has just
+ * been called for the first time, quite a while after
+ * startup, when ntpd just starts to discipline the kernel
+ * time. In this case the occurrence of this message
+ * can be pretty confusing.
+ *
+ * HMS: How about a message when we begin kernel processing:
+ * Determining kernel clock state...
+ * so an initial TIME_ERROR message is less confising,
+ * or skipping the first message (ugh),
+ * or ???
+ * msyslog(LOG_INFO, "kernel reports time synchronization lost");
+ */
+ errno = saved_errno; /* may not be needed */
+ msyslog(LOG_INFO, "kernel reports TIME_ERROR: %#x: %s %m",
+ ptimex->status, k_st_flags(ptimex->status));
break;
+#else
+# warning TIME_ERROR is not defined
#endif
default:
msyslog(LOG_NOTICE, "%s: %s line %d: unhandled return value %d from ntp_adjtime in %s at line %d",
@@ -403,7 +428,8 @@ local_clock(
* directly to the terminal.
*/
if (mode_ntpdate) {
- if (fabs(fp_offset) > clock_max && clock_max > 0) {
+ if ( ( fp_offset > clock_max_fwd && clock_max_fwd > 0)
+ || (-fp_offset > clock_max_back && clock_max_back > 0)) {
step_systime(fp_offset);
msyslog(LOG_NOTICE, "ntpd: time set %+.6f s",
fp_offset);
@@ -452,10 +478,10 @@ local_clock(
* threshold (128 ms) and when it does not. Under certain
* conditions updates are suspended until the stepout theshold
* (900 s) is exceeded. See the documentation on how these
- * thresholds interact with commands and command line options.
+ * thresholds interact with commands and command line options.
*
* Note the kernel is disabled if step is disabled or greater
- * than 0.5 s or in ntpdate mode.
+ * than 0.5 s or in ntpdate mode.
*/
osys_poll = sys_poll;
if (sys_poll < peer->minpoll)
@@ -465,7 +491,14 @@ local_clock(
mu = current_time - clock_epoch;
clock_frequency = drift_comp;
rval = 1;
- if (fabs(fp_offset) > clock_max && clock_max > 0) {
+ if ( ( fp_offset > clock_max_fwd && clock_max_fwd > 0)
+ || (-fp_offset > clock_max_back && clock_max_back > 0)
+ || force_step_once ) {
+ if (force_step_once) {
+ force_step_once = FALSE; /* we want this only once after startup */
+ msyslog(LOG_NOTICE, "Doing intital time step" );
+ }
+
switch (state) {
/*
@@ -525,7 +558,7 @@ local_clock(
* threshold. Note that a single spike greater than the
* step threshold is always suppressed, even with a
* long time constant.
- */
+ */
default:
snprintf(tbuf, sizeof(tbuf), "%+.6f s",
fp_offset);
@@ -543,7 +576,6 @@ local_clock(
}
rstclock(EVNT_SYNC, 0);
} else {
-
/*
* The offset is less than the step threshold. Calculate
* the jitter as the exponentially weighted offset
@@ -605,9 +637,9 @@ local_clock(
/*
* The PLL frequency gain (numerator) depends on
* the minimum of the update interval and Allan
- * intercept. This reduces the PLL gain when the
+ * intercept. This reduces the PLL gain when the
* FLL becomes effective.
- */
+ */
etemp = min(ULOGTOD(allan_xpt), mu);
dtemp = 4 * CLOCK_PLL * ULOGTOD(sys_poll);
clock_frequency += fp_offset * etemp / (dtemp *
@@ -706,8 +738,13 @@ local_clock(
* the pps. In any case, fetch the kernel offset,
* frequency and jitter.
*/
- if ((ntp_adj_ret = ntp_adjtime(&ntv)) != 0) {
- ntp_adjtime_error_handler(__func__, &ntv, ntp_adj_ret, errno, hardpps_enable, 0, __LINE__ - 1);
+ ntp_adj_ret = ntp_adjtime(&ntv);
+ /*
+ * A squeal is a return status < 0, or a state change.
+ */
+ if ((0 > ntp_adj_ret) || (ntp_adj_ret != kernel_status)) {
+ kernel_status = ntp_adj_ret;
+ ntp_adjtime_error_handler(__func__, &ntv, ntp_adj_ret, errno, hardpps_enable, 0, __LINE__ - 1);
}
pll_status = ntv.status;
#ifdef STA_NANO
@@ -888,7 +925,7 @@ adj_host_clock(
clock_offset -= offset_adj;
/*
* Windows port adj_systime() must be called each second,
- * even if the argument is zero, to ease emulation of
+ * even if the argument is zero, to ease emulation of
* adjtime() using Windows' slew API which controls the rate
* but does not automatically stop slewing when an offset
* has decayed to zero.
@@ -917,7 +954,7 @@ rstclock(
report_event(trans, NULL, NULL);
state = trans;
last_offset = clock_offset = offset;
- clock_epoch = current_time;
+ clock_epoch = current_time;
}
@@ -1190,12 +1227,12 @@ loop_config(
case LOOP_CODEC: /* audio codec frequency (codec) */
clock_codec = freq / 1e6;
break;
-
+
case LOOP_PHI: /* dispersion threshold (dispersion) */
clock_phi = freq / 1e6;
break;
- case LOOP_FREQ: /* initial frequency (freq) */
+ case LOOP_FREQ: /* initial frequency (freq) */
init_drift_comp = freq;
freq_set++;
break;
@@ -1216,8 +1253,27 @@ loop_config(
break;
case LOOP_MAX: /* step threshold (step) */
- clock_max = freq;
- if (clock_max == 0 || clock_max > 0.5)
+ clock_max_fwd = clock_max_back = freq;
+ if (freq == 0 || freq > 0.5)
+ select_loop(FALSE);
+ break;
+
+ case LOOP_MAX_BACK: /* step threshold (step) */
+ clock_max_back = freq;
+ /*
+ * Leave using the kernel discipline code unless both
+ * limits are massive. This assumes the reason to stop
+ * using it is that it's pointless, not that it goes wrong.
+ */
+ if ( (clock_max_back == 0 || clock_max_back > 0.5)
+ || (clock_max_fwd == 0 || clock_max_fwd > 0.5))
+ select_loop(FALSE);
+ break;
+
+ case LOOP_MAX_FWD: /* step threshold (step) */
+ clock_max_fwd = freq;
+ if ( (clock_max_back == 0 || clock_max_back > 0.5)
+ || (clock_max_fwd == 0 || clock_max_fwd > 0.5))
select_loop(FALSE);
break;
@@ -1225,7 +1281,7 @@ loop_config(
if (freq < CLOCK_MINSTEP)
clock_minstep = CLOCK_MINSTEP;
else
- clock_minstep = freq;
+ clock_minstep = freq;
break;
case LOOP_TICK: /* tick increment (tick) */
diff --git a/contrib/ntp/ntpd/ntp_parser.c b/contrib/ntp/ntpd/ntp_parser.c
index de3d73c..0cf5519 100644
--- a/contrib/ntp/ntpd/ntp_parser.c
+++ b/contrib/ntp/ntpd/ntp_parser.c
@@ -280,44 +280,46 @@ extern int yydebug;
T_Stats = 404,
T_Statsdir = 405,
T_Step = 406,
- T_Stepout = 407,
- T_Stratum = 408,
- T_String = 409,
- T_Sys = 410,
- T_Sysstats = 411,
- T_Tick = 412,
- T_Time1 = 413,
- T_Time2 = 414,
- T_Timer = 415,
- T_Timingstats = 416,
- T_Tinker = 417,
- T_Tos = 418,
- T_Trap = 419,
- T_True = 420,
- T_Trustedkey = 421,
- T_Ttl = 422,
- T_Type = 423,
- T_U_int = 424,
- T_Unconfig = 425,
- T_Unpeer = 426,
- T_Version = 427,
- T_WanderThreshold = 428,
- T_Week = 429,
- T_Wildcard = 430,
- T_Xleave = 431,
- T_Year = 432,
- T_Flag = 433,
- T_EOC = 434,
- T_Simulate = 435,
- T_Beep_Delay = 436,
- T_Sim_Duration = 437,
- T_Server_Offset = 438,
- T_Duration = 439,
- T_Freq_Offset = 440,
- T_Wander = 441,
- T_Jitter = 442,
- T_Prop_Delay = 443,
- T_Proc_Delay = 444
+ T_Stepback = 407,
+ T_Stepfwd = 408,
+ T_Stepout = 409,
+ T_Stratum = 410,
+ T_String = 411,
+ T_Sys = 412,
+ T_Sysstats = 413,
+ T_Tick = 414,
+ T_Time1 = 415,
+ T_Time2 = 416,
+ T_Timer = 417,
+ T_Timingstats = 418,
+ T_Tinker = 419,
+ T_Tos = 420,
+ T_Trap = 421,
+ T_True = 422,
+ T_Trustedkey = 423,
+ T_Ttl = 424,
+ T_Type = 425,
+ T_U_int = 426,
+ T_Unconfig = 427,
+ T_Unpeer = 428,
+ T_Version = 429,
+ T_WanderThreshold = 430,
+ T_Week = 431,
+ T_Wildcard = 432,
+ T_Xleave = 433,
+ T_Year = 434,
+ T_Flag = 435,
+ T_EOC = 436,
+ T_Simulate = 437,
+ T_Beep_Delay = 438,
+ T_Sim_Duration = 439,
+ T_Server_Offset = 440,
+ T_Duration = 441,
+ T_Freq_Offset = 442,
+ T_Wander = 443,
+ T_Jitter = 444,
+ T_Prop_Delay = 445,
+ T_Proc_Delay = 446
};
#endif
/* Tokens. */
@@ -470,44 +472,46 @@ extern int yydebug;
#define T_Stats 404
#define T_Statsdir 405
#define T_Step 406
-#define T_Stepout 407
-#define T_Stratum 408
-#define T_String 409
-#define T_Sys 410
-#define T_Sysstats 411
-#define T_Tick 412
-#define T_Time1 413
-#define T_Time2 414
-#define T_Timer 415
-#define T_Timingstats 416
-#define T_Tinker 417
-#define T_Tos 418
-#define T_Trap 419
-#define T_True 420
-#define T_Trustedkey 421
-#define T_Ttl 422
-#define T_Type 423
-#define T_U_int 424
-#define T_Unconfig 425
-#define T_Unpeer 426
-#define T_Version 427
-#define T_WanderThreshold 428
-#define T_Week 429
-#define T_Wildcard 430
-#define T_Xleave 431
-#define T_Year 432
-#define T_Flag 433
-#define T_EOC 434
-#define T_Simulate 435
-#define T_Beep_Delay 436
-#define T_Sim_Duration 437
-#define T_Server_Offset 438
-#define T_Duration 439
-#define T_Freq_Offset 440
-#define T_Wander 441
-#define T_Jitter 442
-#define T_Prop_Delay 443
-#define T_Proc_Delay 444
+#define T_Stepback 407
+#define T_Stepfwd 408
+#define T_Stepout 409
+#define T_Stratum 410
+#define T_String 411
+#define T_Sys 412
+#define T_Sysstats 413
+#define T_Tick 414
+#define T_Time1 415
+#define T_Time2 416
+#define T_Timer 417
+#define T_Timingstats 418
+#define T_Tinker 419
+#define T_Tos 420
+#define T_Trap 421
+#define T_True 422
+#define T_Trustedkey 423
+#define T_Ttl 424
+#define T_Type 425
+#define T_U_int 426
+#define T_Unconfig 427
+#define T_Unpeer 428
+#define T_Version 429
+#define T_WanderThreshold 430
+#define T_Week 431
+#define T_Wildcard 432
+#define T_Xleave 433
+#define T_Year 434
+#define T_Flag 435
+#define T_EOC 436
+#define T_Simulate 437
+#define T_Beep_Delay 438
+#define T_Sim_Duration 439
+#define T_Server_Offset 440
+#define T_Duration 441
+#define T_Freq_Offset 442
+#define T_Wander 443
+#define T_Jitter 444
+#define T_Prop_Delay 445
+#define T_Proc_Delay 446
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
@@ -533,7 +537,7 @@ union YYSTYPE
script_info * Sim_script;
script_info_fifo * Sim_script_fifo;
-#line 537 "ntp_parser.c" /* yacc.c:355 */
+#line 541 "ntp_parser.c" /* yacc.c:355 */
};
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
@@ -548,7 +552,7 @@ int yyparse (struct FILE_INFO *ip_file);
/* Copy the second part of user declarations. */
-#line 552 "ntp_parser.c" /* yacc.c:358 */
+#line 556 "ntp_parser.c" /* yacc.c:358 */
#ifdef short
# undef short
@@ -788,23 +792,23 @@ union yyalloc
#endif /* !YYCOPY_NEEDED */
/* YYFINAL -- State number of the termination state. */
-#define YYFINAL 205
+#define YYFINAL 207
/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 634
+#define YYLAST 622
/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 195
+#define YYNTOKENS 197
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 104
/* YYNRULES -- Number of rules. */
-#define YYNRULES 308
+#define YYNRULES 310
/* YYNSTATES -- Number of states. */
-#define YYNSTATES 413
+#define YYNSTATES 415
/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2
-#define YYMAXUTOK 444
+#define YYMAXUTOK 446
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -817,15 +821,15 @@ static const yytype_uint8 yytranslate[] =
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 191, 192, 2, 2, 2, 2, 2, 2, 2, 2,
+ 193, 194, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 190, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 192, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 193, 2, 194, 2, 2, 2, 2,
+ 2, 2, 2, 195, 2, 196, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -857,44 +861,45 @@ static const yytype_uint8 yytranslate[] =
155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
165, 166, 167, 168, 169, 170, 171, 172, 173, 174,
175, 176, 177, 178, 179, 180, 181, 182, 183, 184,
- 185, 186, 187, 188, 189
+ 185, 186, 187, 188, 189, 190, 191
};
#if YYDEBUG
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 364, 364, 368, 369, 370, 384, 385, 386, 387,
- 388, 389, 390, 391, 392, 393, 394, 395, 396, 397,
- 405, 415, 416, 417, 418, 419, 423, 424, 429, 434,
- 436, 442, 443, 451, 452, 453, 457, 462, 463, 464,
- 465, 466, 467, 468, 469, 473, 475, 480, 481, 482,
- 483, 484, 485, 489, 494, 503, 513, 514, 524, 526,
- 528, 530, 541, 548, 550, 555, 557, 559, 561, 563,
- 572, 578, 579, 587, 589, 601, 602, 603, 604, 605,
- 614, 619, 624, 632, 634, 636, 641, 642, 643, 644,
- 645, 646, 650, 651, 652, 653, 662, 664, 673, 683,
- 688, 696, 697, 698, 699, 700, 701, 702, 703, 708,
- 709, 717, 727, 736, 751, 756, 757, 761, 762, 766,
- 767, 768, 769, 770, 771, 772, 781, 785, 789, 797,
- 805, 813, 828, 843, 856, 857, 865, 866, 867, 868,
- 869, 870, 871, 872, 873, 874, 875, 876, 877, 878,
- 879, 883, 888, 896, 901, 902, 903, 907, 912, 920,
- 925, 926, 927, 928, 929, 930, 931, 932, 940, 950,
- 955, 963, 965, 967, 969, 971, 976, 977, 981, 982,
- 983, 984, 992, 997, 1002, 1010, 1015, 1016, 1017, 1026,
- 1028, 1033, 1038, 1046, 1048, 1065, 1066, 1067, 1068, 1069,
- 1070, 1074, 1075, 1083, 1088, 1093, 1101, 1106, 1107, 1108,
- 1109, 1110, 1111, 1112, 1113, 1122, 1123, 1124, 1131, 1138,
- 1154, 1173, 1178, 1180, 1182, 1184, 1186, 1193, 1198, 1199,
- 1200, 1204, 1205, 1206, 1210, 1211, 1215, 1222, 1232, 1241,
- 1246, 1248, 1253, 1254, 1262, 1264, 1272, 1277, 1285, 1310,
- 1317, 1327, 1328, 1332, 1333, 1334, 1335, 1339, 1340, 1341,
- 1345, 1350, 1355, 1363, 1364, 1365, 1366, 1367, 1368, 1369,
- 1379, 1384, 1392, 1397, 1405, 1407, 1411, 1416, 1421, 1429,
- 1434, 1442, 1451, 1452, 1456, 1457, 1466, 1484, 1488, 1493,
- 1501, 1506, 1507, 1511, 1516, 1524, 1529, 1534, 1539, 1544,
- 1552, 1557, 1562, 1570, 1575, 1576, 1577, 1578, 1579
+ 0, 366, 366, 370, 371, 372, 386, 387, 388, 389,
+ 390, 391, 392, 393, 394, 395, 396, 397, 398, 399,
+ 407, 417, 418, 419, 420, 421, 425, 426, 431, 436,
+ 438, 444, 445, 453, 454, 455, 459, 464, 465, 466,
+ 467, 468, 469, 470, 471, 475, 477, 482, 483, 484,
+ 485, 486, 487, 491, 496, 505, 515, 516, 526, 528,
+ 530, 532, 543, 550, 552, 557, 559, 561, 563, 565,
+ 574, 580, 581, 589, 591, 603, 604, 605, 606, 607,
+ 616, 621, 626, 634, 636, 638, 643, 644, 645, 646,
+ 647, 648, 652, 653, 654, 655, 664, 666, 675, 685,
+ 690, 698, 699, 700, 701, 702, 703, 704, 705, 710,
+ 711, 719, 729, 738, 753, 758, 759, 763, 764, 768,
+ 769, 770, 771, 772, 773, 774, 783, 787, 791, 799,
+ 807, 815, 830, 845, 858, 859, 867, 868, 869, 870,
+ 871, 872, 873, 874, 875, 876, 877, 878, 879, 880,
+ 881, 885, 890, 898, 903, 904, 905, 909, 914, 922,
+ 927, 928, 929, 930, 931, 932, 933, 934, 942, 952,
+ 957, 965, 967, 969, 971, 973, 978, 979, 983, 984,
+ 985, 986, 994, 999, 1004, 1012, 1017, 1018, 1019, 1028,
+ 1030, 1035, 1040, 1048, 1050, 1067, 1068, 1069, 1070, 1071,
+ 1072, 1076, 1077, 1085, 1090, 1095, 1103, 1108, 1109, 1110,
+ 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1126, 1127, 1128,
+ 1135, 1142, 1158, 1177, 1182, 1184, 1186, 1188, 1190, 1197,
+ 1202, 1203, 1204, 1208, 1209, 1210, 1214, 1215, 1219, 1226,
+ 1236, 1245, 1250, 1252, 1257, 1258, 1266, 1268, 1276, 1281,
+ 1289, 1314, 1321, 1331, 1332, 1336, 1337, 1338, 1339, 1343,
+ 1344, 1345, 1349, 1354, 1359, 1367, 1368, 1369, 1370, 1371,
+ 1372, 1373, 1383, 1388, 1396, 1401, 1409, 1411, 1415, 1420,
+ 1425, 1433, 1438, 1446, 1455, 1456, 1460, 1461, 1470, 1488,
+ 1492, 1497, 1505, 1510, 1511, 1515, 1520, 1528, 1533, 1538,
+ 1543, 1548, 1556, 1561, 1566, 1574, 1579, 1580, 1581, 1582,
+ 1583
};
#endif
@@ -932,31 +937,32 @@ static const char *const yytname[] =
"T_Rawstats", "T_Refid", "T_Requestkey", "T_Reset", "T_Restrict",
"T_Revoke", "T_Rlimit", "T_Saveconfigdir", "T_Server", "T_Setvar",
"T_Source", "T_Stacksize", "T_Statistics", "T_Stats", "T_Statsdir",
- "T_Step", "T_Stepout", "T_Stratum", "T_String", "T_Sys", "T_Sysstats",
- "T_Tick", "T_Time1", "T_Time2", "T_Timer", "T_Timingstats", "T_Tinker",
- "T_Tos", "T_Trap", "T_True", "T_Trustedkey", "T_Ttl", "T_Type",
- "T_U_int", "T_Unconfig", "T_Unpeer", "T_Version", "T_WanderThreshold",
- "T_Week", "T_Wildcard", "T_Xleave", "T_Year", "T_Flag", "T_EOC",
- "T_Simulate", "T_Beep_Delay", "T_Sim_Duration", "T_Server_Offset",
- "T_Duration", "T_Freq_Offset", "T_Wander", "T_Jitter", "T_Prop_Delay",
- "T_Proc_Delay", "'='", "'('", "')'", "'{'", "'}'", "$accept",
- "configuration", "command_list", "command", "server_command",
- "client_type", "address", "ip_address", "address_fam", "option_list",
- "option", "option_flag", "option_flag_keyword", "option_int",
- "option_int_keyword", "option_str", "option_str_keyword",
- "unpeer_command", "unpeer_keyword", "other_mode_command",
- "authentication_command", "crypto_command_list", "crypto_command",
- "crypto_str_keyword", "orphan_mode_command", "tos_option_list",
- "tos_option", "tos_option_int_keyword", "tos_option_dbl_keyword",
- "monitoring_command", "stats_list", "stat", "filegen_option_list",
- "filegen_option", "link_nolink", "enable_disable", "filegen_type",
- "access_control_command", "ac_flag_list", "access_control_flag",
- "discard_option_list", "discard_option", "discard_option_keyword",
- "mru_option_list", "mru_option", "mru_option_keyword", "fudge_command",
- "fudge_factor_list", "fudge_factor", "fudge_factor_dbl_keyword",
- "fudge_factor_bool_keyword", "rlimit_command", "rlimit_option_list",
- "rlimit_option", "rlimit_option_keyword", "system_option_command",
- "system_option_list", "system_option", "system_option_flag_keyword",
+ "T_Step", "T_Stepback", "T_Stepfwd", "T_Stepout", "T_Stratum",
+ "T_String", "T_Sys", "T_Sysstats", "T_Tick", "T_Time1", "T_Time2",
+ "T_Timer", "T_Timingstats", "T_Tinker", "T_Tos", "T_Trap", "T_True",
+ "T_Trustedkey", "T_Ttl", "T_Type", "T_U_int", "T_Unconfig", "T_Unpeer",
+ "T_Version", "T_WanderThreshold", "T_Week", "T_Wildcard", "T_Xleave",
+ "T_Year", "T_Flag", "T_EOC", "T_Simulate", "T_Beep_Delay",
+ "T_Sim_Duration", "T_Server_Offset", "T_Duration", "T_Freq_Offset",
+ "T_Wander", "T_Jitter", "T_Prop_Delay", "T_Proc_Delay", "'='", "'('",
+ "')'", "'{'", "'}'", "$accept", "configuration", "command_list",
+ "command", "server_command", "client_type", "address", "ip_address",
+ "address_fam", "option_list", "option", "option_flag",
+ "option_flag_keyword", "option_int", "option_int_keyword", "option_str",
+ "option_str_keyword", "unpeer_command", "unpeer_keyword",
+ "other_mode_command", "authentication_command", "crypto_command_list",
+ "crypto_command", "crypto_str_keyword", "orphan_mode_command",
+ "tos_option_list", "tos_option", "tos_option_int_keyword",
+ "tos_option_dbl_keyword", "monitoring_command", "stats_list", "stat",
+ "filegen_option_list", "filegen_option", "link_nolink", "enable_disable",
+ "filegen_type", "access_control_command", "ac_flag_list",
+ "access_control_flag", "discard_option_list", "discard_option",
+ "discard_option_keyword", "mru_option_list", "mru_option",
+ "mru_option_keyword", "fudge_command", "fudge_factor_list",
+ "fudge_factor", "fudge_factor_dbl_keyword", "fudge_factor_bool_keyword",
+ "rlimit_command", "rlimit_option_list", "rlimit_option",
+ "rlimit_option_keyword", "system_option_command", "system_option_list",
+ "system_option", "system_option_flag_keyword",
"system_option_local_flag_keyword", "tinker_command",
"tinker_option_list", "tinker_option", "tinker_option_keyword",
"miscellaneous_command", "misc_cmd_dbl_keyword", "misc_cmd_str_keyword",
@@ -998,14 +1004,14 @@ static const yytype_uint16 yytoknum[] =
415, 416, 417, 418, 419, 420, 421, 422, 423, 424,
425, 426, 427, 428, 429, 430, 431, 432, 433, 434,
435, 436, 437, 438, 439, 440, 441, 442, 443, 444,
- 61, 40, 41, 123, 125
+ 445, 446, 61, 40, 41, 123, 125
};
# endif
-#define YYPACT_NINF -180
+#define YYPACT_NINF -182
#define yypact_value_is_default(Yystate) \
- (!!((Yystate) == (-180)))
+ (!!((Yystate) == (-182)))
#define YYTABLE_NINF -7
@@ -1016,48 +1022,48 @@ static const yytype_uint16 yytoknum[] =
STATE-NUM. */
static const yytype_int16 yypact[] =
{
- 26, -147, -9, -180, -180, -180, -6, -180, 222, 9,
- -96, 222, -180, 276, -41, -180, -93, -180, -90, -86,
- -180, -84, -180, -180, -41, 0, 443, -41, -180, -180,
- -83, -180, -82, -180, -180, 20, 27, -20, 21, -19,
- -180, -180, -68, 276, -66, -180, 221, 328, -65, -55,
- 38, -180, -180, -180, 99, 188, -69, -180, -41, -180,
- -41, -180, -180, -180, -180, -180, -180, -180, -180, -180,
- -180, -3, -40, -39, -180, -4, -180, -180, -77, -180,
- -180, -180, 254, -180, -180, -180, -180, -180, -180, -180,
- -180, 222, -180, -180, -180, -180, -180, -180, 9, -180,
- 47, 90, -180, 222, -180, -180, -180, -180, -180, -180,
- -180, -180, -180, -180, -180, -180, 98, -180, -31, 347,
- -180, -180, -180, -84, -180, -180, -41, -180, -180, -180,
- -180, -180, -180, -180, -180, -180, 443, -180, 61, -41,
- -180, -180, -30, -180, -180, -180, -180, -180, -180, -180,
- -180, 27, -180, -180, 102, 106, -180, -180, 55, -180,
- -180, -180, -180, -19, -180, 87, -42, -180, 276, -180,
- -180, -180, -180, -180, -180, -180, -180, -180, -180, 221,
- -180, -3, -180, -180, -27, -180, -180, -180, -180, -180,
- -180, -180, -180, 328, -180, 91, -3, -180, -180, 93,
- -55, -180, -180, -180, 96, -180, -21, -180, -180, -180,
- -180, -180, -180, -180, -180, -180, -180, -180, 3, -144,
- -180, -180, -180, -180, -180, 100, -180, -5, -180, -180,
- -180, -180, -23, 5, -180, -180, -180, -180, 7, 103,
- -180, -180, 98, -180, -3, -27, -180, -180, -180, -180,
- -180, -180, -180, -180, 462, -180, -180, 462, 462, -65,
- -180, -180, 8, -180, -180, -180, -180, -180, -180, -180,
- -180, -180, -180, -47, 138, -180, -180, -180, 425, -180,
- -180, -180, -180, -180, -180, -180, -180, -105, -2, -15,
- -180, -180, -180, -180, 25, -180, -180, 17, -180, -180,
- -180, -180, -180, -180, -180, -180, -180, -180, -180, -180,
- -180, -180, -180, -180, -180, -180, -180, -180, -180, -180,
- -180, -180, -180, 462, 462, -180, 154, -65, 124, -180,
- 125, -180, -180, -180, -180, -180, -180, -180, -180, -180,
- -180, -180, -180, -180, -180, -180, -180, -180, -180, -180,
- -51, -180, 32, 10, 16, -116, -180, 6, -180, -3,
- -180, -180, -180, -180, -180, -180, -180, -180, -180, 462,
- -180, -180, -180, -180, 15, -180, -180, -180, -41, -180,
- -180, -180, 18, -180, -180, -180, 22, 24, -3, 23,
- -169, -180, 36, -3, -180, -180, -180, 29, -94, -180,
- -180, -180, -180, -180, 89, 37, 30, -180, 40, -180,
- -3, -180, -180
+ 18, -161, -18, -182, -182, -182, -10, -182, 189, 11,
+ -103, 189, -182, 7, -49, -182, -100, -182, -97, -90,
+ -182, -84, -182, -182, -49, 13, 365, -49, -182, -182,
+ -81, -182, -80, -182, -182, 20, 86, 104, 21, -33,
+ -182, -182, -73, 7, -72, -182, 51, 500, -71, -54,
+ 26, -182, -182, -182, 90, 205, -83, -182, -49, -182,
+ -49, -182, -182, -182, -182, -182, -182, -182, -182, -182,
+ -182, -8, -65, -51, -182, -9, -182, -182, -91, -182,
+ -182, -182, -15, -182, -182, -182, -182, -182, -182, -182,
+ -182, 189, -182, -182, -182, -182, -182, -182, 11, -182,
+ 46, 85, -182, 189, -182, -182, -182, -182, -182, -182,
+ -182, -182, -182, -182, -182, -182, 92, -182, -35, 366,
+ -182, -182, -182, -84, -182, -182, -49, -182, -182, -182,
+ -182, -182, -182, -182, -182, -182, 365, -182, 68, -49,
+ -182, -182, -23, -182, -182, -182, -182, -182, -182, -182,
+ -182, 86, -182, -182, 114, 121, -182, -182, 67, -182,
+ -182, -182, -182, -33, -182, 93, -28, -182, 7, -182,
+ -182, -182, -182, -182, -182, -182, -182, -182, -182, -182,
+ -182, 51, -182, -8, -182, -182, -17, -182, -182, -182,
+ -182, -182, -182, -182, -182, 500, -182, 107, -8, -182,
+ -182, 112, -54, -182, -182, -182, 113, -182, 8, -182,
+ -182, -182, -182, -182, -182, -182, -182, -182, -182, -182,
+ -2, -147, -182, -182, -182, -182, -182, 128, -182, 25,
+ -182, -182, -182, -182, 116, 37, -182, -182, -182, -182,
+ 38, 135, -182, -182, 92, -182, -8, -17, -182, -182,
+ -182, -182, -182, -182, -182, -182, 445, -182, -182, 445,
+ 445, -71, -182, -182, 40, -182, -182, -182, -182, -182,
+ -182, -182, -182, -182, -182, -52, 163, -182, -182, -182,
+ 261, -182, -182, -182, -182, -182, -182, -182, -182, -114,
+ 27, 14, -182, -182, -182, -182, 55, -182, -182, 0,
+ -182, -182, -182, -182, -182, -182, -182, -182, -182, -182,
+ -182, -182, -182, -182, -182, -182, -182, -182, -182, -182,
+ -182, -182, -182, -182, -182, 445, 445, -182, 185, -71,
+ 153, -182, 156, -182, -182, -182, -182, -182, -182, -182,
+ -182, -182, -182, -182, -182, -182, -182, -182, -182, -182,
+ -182, -182, -53, -182, 61, 30, 43, -133, -182, 23,
+ -182, -8, -182, -182, -182, -182, -182, -182, -182, -182,
+ -182, 445, -182, -182, -182, -182, 32, -182, -182, -182,
+ -49, -182, -182, -182, 45, -182, -182, -182, 41, 50,
+ -8, 47, -157, -182, 56, -8, -182, -182, -182, 49,
+ 130, -182, -182, -182, -182, -182, 110, 59, 54, -182,
+ 70, -182, -8, -182, -182
};
/* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -1065,80 +1071,80 @@ static const yytype_int16 yypact[] =
means the default is an error. */
static const yytype_uint16 yydefact[] =
{
- 0, 0, 0, 24, 58, 228, 0, 71, 0, 0,
- 238, 0, 221, 0, 0, 231, 0, 251, 0, 0,
- 232, 0, 234, 25, 0, 0, 0, 0, 252, 229,
- 0, 23, 0, 233, 22, 0, 0, 0, 0, 0,
- 235, 21, 0, 0, 0, 230, 0, 0, 0, 0,
- 0, 56, 57, 287, 0, 2, 0, 7, 0, 8,
+ 0, 0, 0, 24, 58, 230, 0, 71, 0, 0,
+ 240, 0, 223, 0, 0, 233, 0, 253, 0, 0,
+ 234, 0, 236, 25, 0, 0, 0, 0, 254, 231,
+ 0, 23, 0, 235, 22, 0, 0, 0, 0, 0,
+ 237, 21, 0, 0, 0, 232, 0, 0, 0, 0,
+ 0, 56, 57, 289, 0, 2, 0, 7, 0, 8,
0, 9, 10, 13, 11, 12, 14, 15, 16, 17,
- 18, 0, 0, 0, 215, 0, 216, 19, 0, 5,
+ 18, 0, 0, 0, 217, 0, 218, 19, 0, 5,
62, 63, 64, 195, 196, 197, 198, 201, 199, 200,
202, 190, 192, 193, 194, 154, 155, 156, 126, 152,
- 0, 236, 222, 189, 101, 102, 103, 104, 108, 105,
+ 0, 238, 224, 189, 101, 102, 103, 104, 108, 105,
106, 107, 109, 29, 30, 28, 0, 26, 0, 6,
- 65, 66, 248, 223, 247, 280, 59, 61, 160, 161,
+ 65, 66, 250, 225, 249, 282, 59, 61, 160, 161,
162, 163, 164, 165, 166, 167, 127, 158, 0, 60,
- 70, 278, 224, 67, 263, 264, 265, 266, 267, 268,
- 269, 260, 262, 134, 29, 30, 134, 134, 26, 68,
- 188, 186, 187, 182, 184, 0, 0, 225, 96, 100,
- 97, 207, 208, 209, 210, 211, 212, 213, 214, 203,
- 205, 0, 91, 86, 0, 87, 95, 93, 94, 92,
- 90, 88, 89, 80, 82, 0, 0, 242, 274, 0,
- 69, 273, 275, 271, 227, 1, 0, 4, 31, 55,
- 285, 284, 217, 218, 219, 259, 258, 257, 0, 0,
- 79, 75, 76, 77, 78, 0, 72, 0, 191, 151,
- 153, 237, 98, 0, 178, 179, 180, 181, 0, 0,
- 176, 177, 168, 170, 0, 0, 27, 220, 246, 279,
- 157, 159, 277, 261, 130, 134, 134, 133, 128, 0,
- 183, 185, 0, 99, 204, 206, 283, 281, 282, 85,
- 81, 83, 84, 226, 0, 272, 270, 3, 20, 253,
- 254, 255, 250, 256, 249, 291, 292, 0, 0, 0,
- 74, 73, 118, 117, 0, 115, 116, 0, 110, 113,
- 114, 174, 175, 173, 169, 171, 172, 136, 137, 138,
- 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
- 149, 150, 135, 131, 132, 134, 241, 0, 0, 243,
- 0, 37, 38, 39, 54, 47, 49, 48, 51, 40,
- 41, 42, 43, 50, 52, 44, 32, 33, 36, 34,
- 0, 35, 0, 0, 0, 0, 294, 0, 289, 0,
- 111, 125, 121, 123, 119, 120, 122, 124, 112, 129,
- 240, 239, 245, 244, 0, 45, 46, 53, 0, 288,
- 286, 293, 0, 290, 276, 297, 0, 0, 0, 0,
- 0, 299, 0, 0, 295, 298, 296, 0, 0, 304,
- 305, 306, 307, 308, 0, 0, 0, 300, 0, 302,
- 0, 301, 303
+ 70, 280, 226, 67, 265, 266, 267, 268, 269, 270,
+ 271, 262, 264, 134, 29, 30, 134, 134, 26, 68,
+ 188, 186, 187, 182, 184, 0, 0, 227, 96, 100,
+ 97, 207, 208, 209, 210, 211, 212, 213, 214, 215,
+ 216, 203, 205, 0, 91, 86, 0, 87, 95, 93,
+ 94, 92, 90, 88, 89, 80, 82, 0, 0, 244,
+ 276, 0, 69, 275, 277, 273, 229, 1, 0, 4,
+ 31, 55, 287, 286, 219, 220, 221, 261, 260, 259,
+ 0, 0, 79, 75, 76, 77, 78, 0, 72, 0,
+ 191, 151, 153, 239, 98, 0, 178, 179, 180, 181,
+ 0, 0, 176, 177, 168, 170, 0, 0, 27, 222,
+ 248, 281, 157, 159, 279, 263, 130, 134, 134, 133,
+ 128, 0, 183, 185, 0, 99, 204, 206, 285, 283,
+ 284, 85, 81, 83, 84, 228, 0, 274, 272, 3,
+ 20, 255, 256, 257, 252, 258, 251, 293, 294, 0,
+ 0, 0, 74, 73, 118, 117, 0, 115, 116, 0,
+ 110, 113, 114, 174, 175, 173, 169, 171, 172, 136,
+ 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
+ 147, 148, 149, 150, 135, 131, 132, 134, 243, 0,
+ 0, 245, 0, 37, 38, 39, 54, 47, 49, 48,
+ 51, 40, 41, 42, 43, 50, 52, 44, 32, 33,
+ 36, 34, 0, 35, 0, 0, 0, 0, 296, 0,
+ 291, 0, 111, 125, 121, 123, 119, 120, 122, 124,
+ 112, 129, 242, 241, 247, 246, 0, 45, 46, 53,
+ 0, 290, 288, 295, 0, 292, 278, 299, 0, 0,
+ 0, 0, 0, 301, 0, 0, 297, 300, 298, 0,
+ 0, 306, 307, 308, 309, 310, 0, 0, 0, 302,
+ 0, 304, 0, 303, 305
};
/* YYPGOTO[NTERM-NUM]. */
static const yytype_int16 yypgoto[] =
{
- -180, -180, -180, -37, -180, -180, -14, -36, -180, -180,
- -180, -180, -180, -180, -180, -180, -180, -180, -180, -180,
- -180, -180, -180, -180, -180, -180, 33, -180, -180, -180,
- -180, -33, -180, -180, -180, -180, -180, -180, -153, -180,
- -180, 131, -180, -180, 97, -180, -180, -180, -10, -180,
- -180, -180, -180, 73, -180, -180, 227, -72, -180, -180,
- -180, -180, 60, -180, -180, -180, -180, -180, -180, -180,
- -180, -180, -180, -180, 119, -180, -180, -180, -180, -180,
- -180, 92, -180, -180, 44, -180, -180, 218, 1, -179,
- -180, -180, -180, -34, -180, -180, -107, -180, -180, -180,
- -140, -180, -150, -180
+ -182, -182, -182, -45, -182, -182, -14, -36, -182, -182,
+ -182, -182, -182, -182, -182, -182, -182, -182, -182, -182,
+ -182, -182, -182, -182, -182, -182, 60, -182, -182, -182,
+ -182, -38, -182, -182, -182, -182, -182, -182, -142, -182,
+ -182, 134, -182, -182, 120, -182, -182, -182, 5, -182,
+ -182, -182, -182, 96, -182, -182, 250, -42, -182, -182,
+ -182, -182, 81, -182, -182, -182, -182, -182, -182, -182,
+ -182, -182, -182, -182, 140, -182, -182, -182, -182, -182,
+ -182, 117, -182, -182, 63, -182, -182, 240, 22, -181,
+ -182, -182, -182, -16, -182, -182, -86, -182, -182, -182,
+ -120, -182, -132, -182
};
/* YYDEFGOTO[NTERM-NUM]. */
static const yytype_int16 yydefgoto[] =
{
- -1, 54, 55, 56, 57, 58, 125, 117, 118, 278,
- 346, 347, 348, 349, 350, 351, 352, 59, 60, 61,
- 62, 82, 226, 227, 63, 193, 194, 195, 196, 64,
- 168, 112, 232, 298, 299, 300, 368, 65, 254, 322,
- 98, 99, 100, 136, 137, 138, 66, 242, 243, 244,
- 245, 67, 163, 164, 165, 68, 91, 92, 93, 94,
- 69, 179, 180, 181, 70, 71, 72, 73, 102, 167,
- 371, 273, 329, 123, 124, 74, 75, 284, 218, 76,
- 151, 152, 204, 200, 201, 202, 142, 126, 269, 212,
- 77, 78, 287, 288, 289, 355, 356, 387, 357, 390,
- 391, 404, 405, 406
+ -1, 54, 55, 56, 57, 58, 125, 117, 118, 280,
+ 348, 349, 350, 351, 352, 353, 354, 59, 60, 61,
+ 62, 82, 228, 229, 63, 195, 196, 197, 198, 64,
+ 168, 112, 234, 300, 301, 302, 370, 65, 256, 324,
+ 98, 99, 100, 136, 137, 138, 66, 244, 245, 246,
+ 247, 67, 163, 164, 165, 68, 91, 92, 93, 94,
+ 69, 181, 182, 183, 70, 71, 72, 73, 102, 167,
+ 373, 275, 331, 123, 124, 74, 75, 286, 220, 76,
+ 151, 152, 206, 202, 203, 204, 142, 126, 271, 214,
+ 77, 78, 289, 290, 291, 357, 358, 389, 359, 392,
+ 393, 406, 407, 408
};
/* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
@@ -1146,138 +1152,136 @@ static const yytype_int16 yydefgoto[] =
number is the opposite. If YYTABLE_NINF, syntax error. */
static const yytype_int16 yytable[] =
{
- 116, 158, 265, 257, 258, 198, 292, 153, 279, 375,
- 169, 266, 197, 293, 327, 389, 294, 272, 206, 228,
- 95, 361, 160, 157, 113, 394, 114, 1, 353, 210,
- 215, 228, 79, 267, 144, 145, 2, 285, 286, 353,
- 3, 4, 5, 362, 208, 154, 209, 155, 6, 7,
- 216, 80, 146, 295, 81, 8, 9, 211, 101, 10,
- 127, 119, 11, 12, 120, 305, 13, 280, 121, 281,
- 122, 140, 141, 217, 161, 14, 285, 286, 380, 15,
- 143, 159, 247, 328, 296, 16, 166, 17, 170, 115,
- 147, 399, 400, 401, 402, 403, 18, 19, 203, 205,
- 20, 233, 323, 324, 21, 22, 96, 230, 23, 24,
- 207, 97, 249, 115, 213, 214, 219, 25, 376, 148,
- 363, 251, 231, 246, 252, 249, 156, 364, 162, 255,
- 26, 27, 28, 256, 115, 263, 199, 29, 268, 259,
- 234, 235, 236, 237, 365, 297, 30, 261, 262, 291,
- 31, 271, 32, 274, 33, 34, 276, 282, 277, 301,
- 290, 302, 326, 303, 35, 36, 37, 38, 39, 40,
- 41, 42, 369, 330, 43, 359, 44, 358, 283, 360,
- 383, 370, 149, 45, 373, 374, 377, 150, 46, 47,
- 48, 366, 49, 50, 367, 379, 51, 52, 2, 382,
- 378, 386, 3, 4, 5, -6, 53, 384, 389, 392,
- 6, 7, 388, 393, 397, 396, 409, 8, 9, 411,
- 410, 10, 398, 325, 11, 12, 270, 171, 13, 229,
- 83, 412, 304, 250, 84, 238, 260, 14, 103, 264,
- 85, 15, 248, 253, 275, 139, 306, 16, 381, 17,
- 395, 239, 172, 354, 408, 0, 240, 241, 18, 19,
- 0, 0, 20, 0, 0, 0, 21, 22, 0, 173,
- 23, 24, 174, 0, 399, 400, 401, 402, 403, 25,
- 0, 0, 220, 407, 0, 0, 0, 0, 0, 0,
- 86, 372, 26, 27, 28, 0, 104, 0, 0, 29,
- 105, 0, 0, 0, 221, 0, 0, 222, 30, 0,
- 0, 0, 31, 0, 32, 0, 33, 34, 0, 0,
- 0, 0, 0, 87, 88, 0, 35, 36, 37, 38,
- 39, 40, 41, 42, 0, 0, 43, 0, 44, 0,
- 89, 182, 0, 0, 175, 45, 0, 183, 0, 184,
- 46, 47, 48, 0, 49, 50, 106, 2, 51, 52,
- 0, 3, 4, 5, 385, 0, 0, -6, 53, 6,
- 7, 90, 176, 177, 0, 185, 8, 9, 178, 0,
- 10, 0, 0, 11, 12, 0, 0, 13, 223, 224,
- 0, 0, 0, 0, 0, 225, 14, 0, 0, 0,
- 15, 107, 0, 0, 0, 0, 16, 0, 17, 108,
- 0, 0, 109, 0, 186, 0, 187, 18, 19, 0,
- 0, 20, 188, 0, 189, 21, 22, 190, 0, 23,
- 24, 0, 110, 0, 331, 0, 0, 111, 25, 0,
- 0, 0, 332, 0, 0, 0, 0, 0, 0, 191,
- 192, 26, 27, 28, 0, 0, 0, 0, 29, 0,
- 0, 0, 0, 0, 0, 0, 0, 30, 0, 0,
- 0, 31, 0, 32, 0, 33, 34, 333, 334, 0,
- 0, 0, 0, 0, 0, 35, 36, 37, 38, 39,
- 40, 41, 42, 0, 335, 43, 0, 44, 128, 129,
- 130, 131, 0, 0, 45, 0, 0, 0, 307, 46,
- 47, 48, 0, 49, 50, 336, 308, 51, 52, 0,
- 0, 0, 0, 337, 0, 338, 0, 53, 132, 0,
- 133, 0, 134, 0, 309, 310, 0, 311, 135, 339,
- 0, 0, 0, 312, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 340, 341, 0, 0,
+ 116, 158, 267, 281, 363, 169, 200, 377, 160, 329,
+ 208, 355, 199, 222, 259, 260, 113, 274, 114, 1,
+ 79, 268, 95, 157, 212, 217, 364, 104, 2, 391,
+ 355, 105, 3, 4, 5, 223, 287, 288, 224, 396,
+ 6, 7, 80, 269, 210, 218, 211, 8, 9, 230,
+ 81, 10, 213, 101, 11, 12, 119, 171, 13, 120,
+ 161, 230, 282, 382, 283, 307, 121, 14, 219, 287,
+ 288, 15, 122, 127, 249, 140, 141, 16, 330, 17,
+ 143, 159, 172, 166, 170, 115, 205, 106, 18, 19,
+ 207, 215, 20, 144, 145, 235, 21, 22, 209, 173,
+ 23, 24, 174, 365, 221, 216, 232, 115, 96, 25,
+ 366, 146, 251, 97, 162, 325, 326, 233, 378, 225,
+ 226, 248, 26, 27, 28, 251, 227, 367, 253, 29,
+ 265, 153, 107, 254, 236, 237, 238, 239, 30, 201,
+ 108, 257, 31, 109, 32, 294, 33, 34, 258, 147,
+ 270, 261, 295, 263, 284, 296, 35, 36, 37, 38,
+ 39, 40, 41, 42, 264, 110, 43, 273, 44, 154,
+ 111, 155, 276, 278, 175, 285, 368, 45, 148, 369,
+ 385, 293, 46, 47, 48, 371, 49, 50, 292, 279,
+ 51, 52, 297, 303, 304, 305, 328, 83, 332, -6,
+ 53, 84, 176, 177, 178, 179, 361, 85, 360, 394,
+ 180, 362, 372, 375, 399, 2, 376, 379, 384, 3,
+ 4, 5, 380, 298, 381, 327, 386, 6, 7, 240,
+ 388, 414, 231, 390, 8, 9, 391, 398, 10, 395,
+ 411, 11, 12, 149, 400, 13, 412, 241, 150, 306,
+ 156, 413, 242, 243, 14, 272, 252, 86, 15, 262,
+ 115, 103, 266, 250, 16, 277, 17, 139, 255, 308,
+ 333, 383, 397, 356, 410, 18, 19, 0, 334, 20,
+ 0, 0, 0, 21, 22, 0, 299, 23, 24, 0,
+ 87, 88, 0, 374, 0, 0, 25, 401, 402, 403,
+ 404, 405, 0, 0, 0, 0, 409, 89, 0, 26,
+ 27, 28, 0, 335, 336, 0, 29, 401, 402, 403,
+ 404, 405, 0, 0, 0, 30, 0, 0, 0, 31,
+ 337, 32, 0, 33, 34, 0, 0, 0, 90, 0,
+ 0, 0, 0, 35, 36, 37, 38, 39, 40, 41,
+ 42, 338, 0, 43, 0, 44, 0, 0, 0, 339,
+ 0, 340, 0, 0, 45, 0, 387, 0, 0, 46,
+ 47, 48, 0, 49, 50, 341, 2, 51, 52, 0,
+ 3, 4, 5, 0, 0, 0, -6, 53, 6, 7,
+ 0, 0, 342, 343, 0, 8, 9, 0, 0, 10,
+ 0, 0, 11, 12, 0, 0, 13, 0, 0, 0,
+ 0, 0, 0, 0, 0, 14, 0, 0, 0, 15,
+ 128, 129, 130, 131, 0, 16, 0, 17, 344, 0,
+ 345, 0, 0, 0, 0, 346, 18, 19, 0, 347,
+ 20, 0, 0, 0, 21, 22, 0, 0, 23, 24,
+ 132, 0, 133, 0, 134, 0, 0, 25, 0, 0,
+ 135, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 26, 27, 28, 0, 0, 0, 0, 29, 0, 0,
+ 0, 0, 0, 0, 0, 0, 30, 0, 0, 0,
+ 31, 309, 32, 0, 33, 34, 0, 0, 0, 310,
+ 0, 0, 0, 0, 35, 36, 37, 38, 39, 40,
+ 41, 42, 0, 184, 43, 0, 44, 311, 312, 185,
+ 313, 186, 0, 0, 0, 45, 314, 0, 0, 0,
+ 46, 47, 48, 0, 49, 50, 0, 0, 51, 52,
+ 0, 0, 0, 0, 0, 0, 0, 187, 53, 0,
+ 0, 0, 0, 315, 316, 0, 0, 317, 318, 0,
+ 319, 320, 321, 0, 322, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 313, 314, 0, 0, 315, 316, 0, 317, 318, 319,
- 0, 320, 0, 0, 0, 0, 0, 0, 0, 0,
- 342, 0, 343, 0, 0, 0, 0, 344, 0, 0,
- 0, 345, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 188, 0, 189, 0,
+ 0, 0, 0, 0, 190, 0, 191, 0, 0, 192,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 321
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 323,
+ 0, 193, 194
};
static const yytype_int16 yycheck[] =
{
- 14, 37, 181, 156, 157, 60, 29, 27, 5, 60,
- 43, 38, 48, 36, 61, 184, 39, 196, 55, 91,
- 11, 4, 41, 37, 65, 194, 67, 1, 144, 32,
- 34, 103, 179, 60, 7, 8, 10, 181, 182, 144,
- 14, 15, 16, 26, 58, 65, 60, 67, 22, 23,
- 54, 60, 25, 76, 60, 29, 30, 60, 154, 33,
- 60, 154, 36, 37, 154, 244, 40, 64, 154, 66,
- 154, 154, 154, 77, 93, 49, 181, 182, 194, 53,
- 60, 60, 119, 130, 107, 59, 154, 61, 154, 154,
- 63, 185, 186, 187, 188, 189, 70, 71, 60, 0,
- 74, 3, 255, 256, 78, 79, 97, 60, 82, 83,
- 179, 102, 126, 154, 154, 154, 193, 91, 169, 92,
- 103, 60, 32, 154, 154, 139, 146, 110, 147, 27,
- 104, 105, 106, 27, 154, 168, 191, 111, 165, 84,
- 42, 43, 44, 45, 127, 168, 120, 60, 190, 154,
- 124, 60, 126, 60, 128, 129, 60, 154, 179, 154,
- 60, 154, 154, 60, 138, 139, 140, 141, 142, 143,
- 144, 145, 325, 35, 148, 190, 150, 179, 175, 154,
- 359, 27, 155, 157, 60, 60, 154, 160, 162, 163,
- 164, 174, 166, 167, 177, 179, 170, 171, 10, 193,
- 190, 183, 14, 15, 16, 179, 180, 192, 184, 388,
- 22, 23, 190, 190, 393, 179, 179, 29, 30, 179,
- 190, 33, 193, 259, 36, 37, 193, 6, 40, 98,
- 8, 410, 242, 136, 12, 137, 163, 49, 11, 179,
- 18, 53, 123, 151, 200, 27, 245, 59, 355, 61,
- 390, 153, 31, 287, 404, -1, 158, 159, 70, 71,
- -1, -1, 74, -1, -1, -1, 78, 79, -1, 48,
- 82, 83, 51, -1, 185, 186, 187, 188, 189, 91,
- -1, -1, 28, 194, -1, -1, -1, -1, -1, -1,
- 68, 327, 104, 105, 106, -1, 20, -1, -1, 111,
- 24, -1, -1, -1, 50, -1, -1, 53, 120, -1,
- -1, -1, 124, -1, 126, -1, 128, 129, -1, -1,
- -1, -1, -1, 101, 102, -1, 138, 139, 140, 141,
- 142, 143, 144, 145, -1, -1, 148, -1, 150, -1,
- 118, 13, -1, -1, 123, 157, -1, 19, -1, 21,
- 162, 163, 164, -1, 166, 167, 80, 10, 170, 171,
- -1, 14, 15, 16, 378, -1, -1, 179, 180, 22,
- 23, 149, 151, 152, -1, 47, 29, 30, 157, -1,
- 33, -1, -1, 36, 37, -1, -1, 40, 134, 135,
- -1, -1, -1, -1, -1, 141, 49, -1, -1, -1,
- 53, 125, -1, -1, -1, -1, 59, -1, 61, 133,
- -1, -1, 136, -1, 86, -1, 88, 70, 71, -1,
- -1, 74, 94, -1, 96, 78, 79, 99, -1, 82,
- 83, -1, 156, -1, 9, -1, -1, 161, 91, -1,
- -1, -1, 17, -1, -1, -1, -1, -1, -1, 121,
- 122, 104, 105, 106, -1, -1, -1, -1, 111, -1,
- -1, -1, -1, -1, -1, -1, -1, 120, -1, -1,
- -1, 124, -1, 126, -1, 128, 129, 52, 53, -1,
- -1, -1, -1, -1, -1, 138, 139, 140, 141, 142,
- 143, 144, 145, -1, 69, 148, -1, 150, 55, 56,
- 57, 58, -1, -1, 157, -1, -1, -1, 46, 162,
- 163, 164, -1, 166, 167, 90, 54, 170, 171, -1,
- -1, -1, -1, 98, -1, 100, -1, 180, 85, -1,
- 87, -1, 89, -1, 72, 73, -1, 75, 95, 114,
- -1, -1, -1, 81, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, 131, 132, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- 108, 109, -1, -1, 112, 113, -1, 115, 116, 117,
- -1, 119, -1, -1, -1, -1, -1, -1, -1, -1,
- 165, -1, 167, -1, -1, -1, -1, 172, -1, -1,
- -1, 176, -1, -1, -1, -1, -1, -1, -1, -1,
+ 14, 37, 183, 5, 4, 43, 60, 60, 41, 61,
+ 55, 144, 48, 28, 156, 157, 65, 198, 67, 1,
+ 181, 38, 11, 37, 32, 34, 26, 20, 10, 186,
+ 144, 24, 14, 15, 16, 50, 183, 184, 53, 196,
+ 22, 23, 60, 60, 58, 54, 60, 29, 30, 91,
+ 60, 33, 60, 156, 36, 37, 156, 6, 40, 156,
+ 93, 103, 64, 196, 66, 246, 156, 49, 77, 183,
+ 184, 53, 156, 60, 119, 156, 156, 59, 130, 61,
+ 60, 60, 31, 156, 156, 156, 60, 80, 70, 71,
+ 0, 156, 74, 7, 8, 3, 78, 79, 181, 48,
+ 82, 83, 51, 103, 195, 156, 60, 156, 97, 91,
+ 110, 25, 126, 102, 147, 257, 258, 32, 171, 134,
+ 135, 156, 104, 105, 106, 139, 141, 127, 60, 111,
+ 168, 27, 125, 156, 42, 43, 44, 45, 120, 193,
+ 133, 27, 124, 136, 126, 29, 128, 129, 27, 63,
+ 167, 84, 36, 60, 156, 39, 138, 139, 140, 141,
+ 142, 143, 144, 145, 192, 158, 148, 60, 150, 65,
+ 163, 67, 60, 60, 123, 177, 176, 159, 92, 179,
+ 361, 156, 164, 165, 166, 327, 168, 169, 60, 181,
+ 172, 173, 76, 156, 156, 60, 156, 8, 35, 181,
+ 182, 12, 151, 152, 153, 154, 192, 18, 181, 390,
+ 159, 156, 27, 60, 395, 10, 60, 156, 195, 14,
+ 15, 16, 192, 107, 181, 261, 194, 22, 23, 137,
+ 185, 412, 98, 192, 29, 30, 186, 181, 33, 192,
+ 181, 36, 37, 157, 195, 40, 192, 155, 162, 244,
+ 146, 181, 160, 161, 49, 195, 136, 68, 53, 163,
+ 156, 11, 181, 123, 59, 202, 61, 27, 151, 247,
+ 9, 357, 392, 289, 406, 70, 71, -1, 17, 74,
+ -1, -1, -1, 78, 79, -1, 170, 82, 83, -1,
+ 101, 102, -1, 329, -1, -1, 91, 187, 188, 189,
+ 190, 191, -1, -1, -1, -1, 196, 118, -1, 104,
+ 105, 106, -1, 52, 53, -1, 111, 187, 188, 189,
+ 190, 191, -1, -1, -1, 120, -1, -1, -1, 124,
+ 69, 126, -1, 128, 129, -1, -1, -1, 149, -1,
+ -1, -1, -1, 138, 139, 140, 141, 142, 143, 144,
+ 145, 90, -1, 148, -1, 150, -1, -1, -1, 98,
+ -1, 100, -1, -1, 159, -1, 380, -1, -1, 164,
+ 165, 166, -1, 168, 169, 114, 10, 172, 173, -1,
+ 14, 15, 16, -1, -1, -1, 181, 182, 22, 23,
+ -1, -1, 131, 132, -1, 29, 30, -1, -1, 33,
+ -1, -1, 36, 37, -1, -1, 40, -1, -1, -1,
+ -1, -1, -1, -1, -1, 49, -1, -1, -1, 53,
+ 55, 56, 57, 58, -1, 59, -1, 61, 167, -1,
+ 169, -1, -1, -1, -1, 174, 70, 71, -1, 178,
+ 74, -1, -1, -1, 78, 79, -1, -1, 82, 83,
+ 85, -1, 87, -1, 89, -1, -1, 91, -1, -1,
+ 95, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 104, 105, 106, -1, -1, -1, -1, 111, -1, -1,
+ -1, -1, -1, -1, -1, -1, 120, -1, -1, -1,
+ 124, 46, 126, -1, 128, 129, -1, -1, -1, 54,
+ -1, -1, -1, -1, 138, 139, 140, 141, 142, 143,
+ 144, 145, -1, 13, 148, -1, 150, 72, 73, 19,
+ 75, 21, -1, -1, -1, 159, 81, -1, -1, -1,
+ 164, 165, 166, -1, 168, 169, -1, -1, 172, 173,
+ -1, -1, -1, -1, -1, -1, -1, 47, 182, -1,
+ -1, -1, -1, 108, 109, -1, -1, 112, 113, -1,
+ 115, 116, 117, -1, 119, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 86, -1, 88, -1,
+ -1, -1, -1, -1, 94, -1, 96, -1, -1, 99,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, 172
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 174,
+ -1, 121, 122
};
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@@ -1288,80 +1292,81 @@ static const yytype_uint16 yystos[] =
33, 36, 37, 40, 49, 53, 59, 61, 70, 71,
74, 78, 79, 82, 83, 91, 104, 105, 106, 111,
120, 124, 126, 128, 129, 138, 139, 140, 141, 142,
- 143, 144, 145, 148, 150, 157, 162, 163, 164, 166,
- 167, 170, 171, 180, 196, 197, 198, 199, 200, 212,
- 213, 214, 215, 219, 224, 232, 241, 246, 250, 255,
- 259, 260, 261, 262, 270, 271, 274, 285, 286, 179,
- 60, 60, 216, 8, 12, 18, 68, 101, 102, 118,
- 149, 251, 252, 253, 254, 11, 97, 102, 235, 236,
- 237, 154, 263, 251, 20, 24, 80, 125, 133, 136,
- 156, 161, 226, 65, 67, 154, 201, 202, 203, 154,
- 154, 154, 154, 268, 269, 201, 282, 60, 55, 56,
- 57, 58, 85, 87, 89, 95, 238, 239, 240, 282,
- 154, 154, 281, 60, 7, 8, 25, 63, 92, 155,
- 160, 275, 276, 27, 65, 67, 146, 201, 202, 60,
- 41, 93, 147, 247, 248, 249, 154, 264, 225, 226,
- 154, 6, 31, 48, 51, 123, 151, 152, 157, 256,
- 257, 258, 13, 19, 21, 47, 86, 88, 94, 96,
- 99, 121, 122, 220, 221, 222, 223, 202, 60, 191,
- 278, 279, 280, 60, 277, 0, 198, 179, 201, 201,
- 32, 60, 284, 154, 154, 34, 54, 77, 273, 193,
- 28, 50, 53, 134, 135, 141, 217, 218, 252, 236,
- 60, 32, 227, 3, 42, 43, 44, 45, 137, 153,
- 158, 159, 242, 243, 244, 245, 154, 198, 269, 201,
- 239, 60, 154, 276, 233, 27, 27, 233, 233, 84,
- 248, 60, 190, 226, 257, 284, 38, 60, 165, 283,
- 221, 60, 284, 266, 60, 279, 60, 179, 204, 5,
- 64, 66, 154, 175, 272, 181, 182, 287, 288, 289,
- 60, 154, 29, 36, 39, 76, 107, 168, 228, 229,
- 230, 154, 154, 60, 243, 284, 283, 46, 54, 72,
- 73, 75, 81, 108, 109, 112, 113, 115, 116, 117,
- 119, 172, 234, 233, 233, 202, 154, 61, 130, 267,
- 35, 9, 17, 52, 53, 69, 90, 98, 100, 114,
- 131, 132, 165, 167, 172, 176, 205, 206, 207, 208,
- 209, 210, 211, 144, 288, 290, 291, 293, 179, 190,
- 154, 4, 26, 103, 110, 127, 174, 177, 231, 233,
- 27, 265, 202, 60, 60, 60, 169, 154, 190, 179,
- 194, 291, 193, 284, 192, 201, 183, 292, 190, 184,
- 294, 295, 284, 190, 194, 295, 179, 284, 193, 185,
- 186, 187, 188, 189, 296, 297, 298, 194, 297, 179,
- 190, 179, 284
+ 143, 144, 145, 148, 150, 159, 164, 165, 166, 168,
+ 169, 172, 173, 182, 198, 199, 200, 201, 202, 214,
+ 215, 216, 217, 221, 226, 234, 243, 248, 252, 257,
+ 261, 262, 263, 264, 272, 273, 276, 287, 288, 181,
+ 60, 60, 218, 8, 12, 18, 68, 101, 102, 118,
+ 149, 253, 254, 255, 256, 11, 97, 102, 237, 238,
+ 239, 156, 265, 253, 20, 24, 80, 125, 133, 136,
+ 158, 163, 228, 65, 67, 156, 203, 204, 205, 156,
+ 156, 156, 156, 270, 271, 203, 284, 60, 55, 56,
+ 57, 58, 85, 87, 89, 95, 240, 241, 242, 284,
+ 156, 156, 283, 60, 7, 8, 25, 63, 92, 157,
+ 162, 277, 278, 27, 65, 67, 146, 203, 204, 60,
+ 41, 93, 147, 249, 250, 251, 156, 266, 227, 228,
+ 156, 6, 31, 48, 51, 123, 151, 152, 153, 154,
+ 159, 258, 259, 260, 13, 19, 21, 47, 86, 88,
+ 94, 96, 99, 121, 122, 222, 223, 224, 225, 204,
+ 60, 193, 280, 281, 282, 60, 279, 0, 200, 181,
+ 203, 203, 32, 60, 286, 156, 156, 34, 54, 77,
+ 275, 195, 28, 50, 53, 134, 135, 141, 219, 220,
+ 254, 238, 60, 32, 229, 3, 42, 43, 44, 45,
+ 137, 155, 160, 161, 244, 245, 246, 247, 156, 200,
+ 271, 203, 241, 60, 156, 278, 235, 27, 27, 235,
+ 235, 84, 250, 60, 192, 228, 259, 286, 38, 60,
+ 167, 285, 223, 60, 286, 268, 60, 281, 60, 181,
+ 206, 5, 64, 66, 156, 177, 274, 183, 184, 289,
+ 290, 291, 60, 156, 29, 36, 39, 76, 107, 170,
+ 230, 231, 232, 156, 156, 60, 245, 286, 285, 46,
+ 54, 72, 73, 75, 81, 108, 109, 112, 113, 115,
+ 116, 117, 119, 174, 236, 235, 235, 204, 156, 61,
+ 130, 269, 35, 9, 17, 52, 53, 69, 90, 98,
+ 100, 114, 131, 132, 167, 169, 174, 178, 207, 208,
+ 209, 210, 211, 212, 213, 144, 290, 292, 293, 295,
+ 181, 192, 156, 4, 26, 103, 110, 127, 176, 179,
+ 233, 235, 27, 267, 204, 60, 60, 60, 171, 156,
+ 192, 181, 196, 293, 195, 286, 194, 203, 185, 294,
+ 192, 186, 296, 297, 286, 192, 196, 297, 181, 286,
+ 195, 187, 188, 189, 190, 191, 298, 299, 300, 196,
+ 299, 181, 192, 181, 286
};
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
static const yytype_uint16 yyr1[] =
{
- 0, 195, 196, 197, 197, 197, 198, 198, 198, 198,
- 198, 198, 198, 198, 198, 198, 198, 198, 198, 198,
- 199, 200, 200, 200, 200, 200, 201, 201, 202, 203,
- 203, 204, 204, 205, 205, 205, 206, 207, 207, 207,
- 207, 207, 207, 207, 207, 208, 208, 209, 209, 209,
- 209, 209, 209, 210, 211, 212, 213, 213, 214, 214,
- 214, 214, 215, 215, 215, 215, 215, 215, 215, 215,
- 215, 216, 216, 217, 217, 218, 218, 218, 218, 218,
- 219, 220, 220, 221, 221, 221, 222, 222, 222, 222,
- 222, 222, 223, 223, 223, 223, 224, 224, 224, 225,
- 225, 226, 226, 226, 226, 226, 226, 226, 226, 227,
- 227, 228, 228, 228, 228, 229, 229, 230, 230, 231,
- 231, 231, 231, 231, 231, 231, 232, 232, 232, 232,
- 232, 232, 232, 232, 233, 233, 234, 234, 234, 234,
- 234, 234, 234, 234, 234, 234, 234, 234, 234, 234,
- 234, 235, 235, 236, 237, 237, 237, 238, 238, 239,
- 240, 240, 240, 240, 240, 240, 240, 240, 241, 242,
- 242, 243, 243, 243, 243, 243, 244, 244, 245, 245,
- 245, 245, 246, 247, 247, 248, 249, 249, 249, 250,
- 250, 251, 251, 252, 252, 253, 253, 253, 253, 253,
- 253, 254, 254, 255, 256, 256, 257, 258, 258, 258,
- 258, 258, 258, 258, 258, 259, 259, 259, 259, 259,
- 259, 259, 259, 259, 259, 259, 259, 259, 260, 260,
- 260, 261, 261, 261, 262, 262, 263, 263, 263, 264,
- 265, 265, 266, 266, 267, 267, 268, 268, 269, 270,
- 270, 271, 271, 272, 272, 272, 272, 273, 273, 273,
- 274, 275, 275, 276, 276, 276, 276, 276, 276, 276,
- 277, 277, 278, 278, 279, 279, 280, 281, 281, 282,
- 282, 283, 283, 283, 284, 284, 285, 286, 287, 287,
- 288, 289, 289, 290, 290, 291, 292, 293, 294, 294,
- 295, 296, 296, 297, 298, 298, 298, 298, 298
+ 0, 197, 198, 199, 199, 199, 200, 200, 200, 200,
+ 200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
+ 201, 202, 202, 202, 202, 202, 203, 203, 204, 205,
+ 205, 206, 206, 207, 207, 207, 208, 209, 209, 209,
+ 209, 209, 209, 209, 209, 210, 210, 211, 211, 211,
+ 211, 211, 211, 212, 213, 214, 215, 215, 216, 216,
+ 216, 216, 217, 217, 217, 217, 217, 217, 217, 217,
+ 217, 218, 218, 219, 219, 220, 220, 220, 220, 220,
+ 221, 222, 222, 223, 223, 223, 224, 224, 224, 224,
+ 224, 224, 225, 225, 225, 225, 226, 226, 226, 227,
+ 227, 228, 228, 228, 228, 228, 228, 228, 228, 229,
+ 229, 230, 230, 230, 230, 231, 231, 232, 232, 233,
+ 233, 233, 233, 233, 233, 233, 234, 234, 234, 234,
+ 234, 234, 234, 234, 235, 235, 236, 236, 236, 236,
+ 236, 236, 236, 236, 236, 236, 236, 236, 236, 236,
+ 236, 237, 237, 238, 239, 239, 239, 240, 240, 241,
+ 242, 242, 242, 242, 242, 242, 242, 242, 243, 244,
+ 244, 245, 245, 245, 245, 245, 246, 246, 247, 247,
+ 247, 247, 248, 249, 249, 250, 251, 251, 251, 252,
+ 252, 253, 253, 254, 254, 255, 255, 255, 255, 255,
+ 255, 256, 256, 257, 258, 258, 259, 260, 260, 260,
+ 260, 260, 260, 260, 260, 260, 260, 261, 261, 261,
+ 261, 261, 261, 261, 261, 261, 261, 261, 261, 261,
+ 262, 262, 262, 263, 263, 263, 264, 264, 265, 265,
+ 265, 266, 267, 267, 268, 268, 269, 269, 270, 270,
+ 271, 272, 272, 273, 273, 274, 274, 274, 274, 275,
+ 275, 275, 276, 277, 277, 278, 278, 278, 278, 278,
+ 278, 278, 279, 279, 280, 280, 281, 281, 282, 283,
+ 283, 284, 284, 285, 285, 285, 286, 286, 287, 288,
+ 289, 289, 290, 291, 291, 292, 292, 293, 294, 295,
+ 296, 296, 297, 298, 298, 299, 300, 300, 300, 300,
+ 300
};
/* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
@@ -1388,16 +1393,17 @@ static const yytype_uint8 yyr2[] =
1, 1, 2, 2, 1, 2, 1, 1, 1, 2,
2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 2, 2, 1, 2, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
- 3, 1, 2, 2, 2, 2, 3, 2, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 2, 0, 4,
- 1, 0, 0, 2, 2, 2, 2, 1, 1, 3,
- 3, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 1, 2, 1, 1, 1, 5, 2, 1, 2,
- 1, 1, 1, 1, 1, 1, 5, 1, 3, 2,
- 3, 1, 1, 2, 1, 5, 4, 3, 2, 1,
- 6, 3, 2, 3, 1, 1, 1, 1, 1
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
+ 2, 2, 3, 1, 2, 2, 2, 2, 3, 2,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
+ 0, 4, 1, 0, 0, 2, 2, 2, 2, 1,
+ 1, 3, 3, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 2, 2, 1, 1, 1, 1, 1, 1,
+ 1, 1, 2, 1, 2, 1, 1, 1, 5, 2,
+ 1, 2, 1, 1, 1, 1, 1, 1, 5, 1,
+ 3, 2, 3, 1, 1, 2, 1, 5, 4, 3,
+ 2, 1, 6, 3, 2, 3, 1, 1, 1, 1,
+ 1
};
@@ -2076,7 +2082,7 @@ yyreduce:
switch (yyn)
{
case 5:
-#line 371 "ntp_parser.y" /* yacc.c:1646 */
+#line 373 "ntp_parser.y" /* yacc.c:1646 */
{
/* I will need to incorporate much more fine grained
* error messages. The following should suffice for
@@ -2088,85 +2094,85 @@ yyreduce:
ip_file->err_line_no,
ip_file->err_col_no);
}
-#line 2092 "ntp_parser.c" /* yacc.c:1646 */
+#line 2098 "ntp_parser.c" /* yacc.c:1646 */
break;
case 20:
-#line 406 "ntp_parser.y" /* yacc.c:1646 */
+#line 408 "ntp_parser.y" /* yacc.c:1646 */
{
peer_node *my_node;
my_node = create_peer_node((yyvsp[-2].Integer), (yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo));
APPEND_G_FIFO(cfgt.peers, my_node);
}
-#line 2103 "ntp_parser.c" /* yacc.c:1646 */
+#line 2109 "ntp_parser.c" /* yacc.c:1646 */
break;
case 27:
-#line 425 "ntp_parser.y" /* yacc.c:1646 */
+#line 427 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Address_node) = create_address_node((yyvsp[0].String), (yyvsp[-1].Integer)); }
-#line 2109 "ntp_parser.c" /* yacc.c:1646 */
+#line 2115 "ntp_parser.c" /* yacc.c:1646 */
break;
case 28:
-#line 430 "ntp_parser.y" /* yacc.c:1646 */
+#line 432 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Address_node) = create_address_node((yyvsp[0].String), AF_UNSPEC); }
-#line 2115 "ntp_parser.c" /* yacc.c:1646 */
+#line 2121 "ntp_parser.c" /* yacc.c:1646 */
break;
case 29:
-#line 435 "ntp_parser.y" /* yacc.c:1646 */
+#line 437 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Integer) = AF_INET; }
-#line 2121 "ntp_parser.c" /* yacc.c:1646 */
+#line 2127 "ntp_parser.c" /* yacc.c:1646 */
break;
case 30:
-#line 437 "ntp_parser.y" /* yacc.c:1646 */
+#line 439 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Integer) = AF_INET6; }
-#line 2127 "ntp_parser.c" /* yacc.c:1646 */
+#line 2133 "ntp_parser.c" /* yacc.c:1646 */
break;
case 31:
-#line 442 "ntp_parser.y" /* yacc.c:1646 */
+#line 444 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val_fifo) = NULL; }
-#line 2133 "ntp_parser.c" /* yacc.c:1646 */
+#line 2139 "ntp_parser.c" /* yacc.c:1646 */
break;
case 32:
-#line 444 "ntp_parser.y" /* yacc.c:1646 */
+#line 446 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2142 "ntp_parser.c" /* yacc.c:1646 */
+#line 2148 "ntp_parser.c" /* yacc.c:1646 */
break;
case 36:
-#line 458 "ntp_parser.y" /* yacc.c:1646 */
+#line 460 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); }
-#line 2148 "ntp_parser.c" /* yacc.c:1646 */
+#line 2154 "ntp_parser.c" /* yacc.c:1646 */
break;
case 45:
-#line 474 "ntp_parser.y" /* yacc.c:1646 */
+#line 476 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 2154 "ntp_parser.c" /* yacc.c:1646 */
+#line 2160 "ntp_parser.c" /* yacc.c:1646 */
break;
case 46:
-#line 476 "ntp_parser.y" /* yacc.c:1646 */
+#line 478 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_uval((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 2160 "ntp_parser.c" /* yacc.c:1646 */
+#line 2166 "ntp_parser.c" /* yacc.c:1646 */
break;
case 53:
-#line 490 "ntp_parser.y" /* yacc.c:1646 */
+#line 492 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); }
-#line 2166 "ntp_parser.c" /* yacc.c:1646 */
+#line 2172 "ntp_parser.c" /* yacc.c:1646 */
break;
case 55:
-#line 504 "ntp_parser.y" /* yacc.c:1646 */
+#line 506 "ntp_parser.y" /* yacc.c:1646 */
{
unpeer_node *my_node;
@@ -2174,85 +2180,85 @@ yyreduce:
if (my_node)
APPEND_G_FIFO(cfgt.unpeers, my_node);
}
-#line 2178 "ntp_parser.c" /* yacc.c:1646 */
+#line 2184 "ntp_parser.c" /* yacc.c:1646 */
break;
case 58:
-#line 525 "ntp_parser.y" /* yacc.c:1646 */
+#line 527 "ntp_parser.y" /* yacc.c:1646 */
{ cfgt.broadcastclient = 1; }
-#line 2184 "ntp_parser.c" /* yacc.c:1646 */
+#line 2190 "ntp_parser.c" /* yacc.c:1646 */
break;
case 59:
-#line 527 "ntp_parser.y" /* yacc.c:1646 */
+#line 529 "ntp_parser.y" /* yacc.c:1646 */
{ CONCAT_G_FIFOS(cfgt.manycastserver, (yyvsp[0].Address_fifo)); }
-#line 2190 "ntp_parser.c" /* yacc.c:1646 */
+#line 2196 "ntp_parser.c" /* yacc.c:1646 */
break;
case 60:
-#line 529 "ntp_parser.y" /* yacc.c:1646 */
+#line 531 "ntp_parser.y" /* yacc.c:1646 */
{ CONCAT_G_FIFOS(cfgt.multicastclient, (yyvsp[0].Address_fifo)); }
-#line 2196 "ntp_parser.c" /* yacc.c:1646 */
+#line 2202 "ntp_parser.c" /* yacc.c:1646 */
break;
case 61:
-#line 531 "ntp_parser.y" /* yacc.c:1646 */
+#line 533 "ntp_parser.y" /* yacc.c:1646 */
{ cfgt.mdnstries = (yyvsp[0].Integer); }
-#line 2202 "ntp_parser.c" /* yacc.c:1646 */
+#line 2208 "ntp_parser.c" /* yacc.c:1646 */
break;
case 62:
-#line 542 "ntp_parser.y" /* yacc.c:1646 */
+#line 544 "ntp_parser.y" /* yacc.c:1646 */
{
attr_val *atrv;
atrv = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer));
APPEND_G_FIFO(cfgt.vars, atrv);
}
-#line 2213 "ntp_parser.c" /* yacc.c:1646 */
+#line 2219 "ntp_parser.c" /* yacc.c:1646 */
break;
case 63:
-#line 549 "ntp_parser.y" /* yacc.c:1646 */
+#line 551 "ntp_parser.y" /* yacc.c:1646 */
{ cfgt.auth.control_key = (yyvsp[0].Integer); }
-#line 2219 "ntp_parser.c" /* yacc.c:1646 */
+#line 2225 "ntp_parser.c" /* yacc.c:1646 */
break;
case 64:
-#line 551 "ntp_parser.y" /* yacc.c:1646 */
+#line 553 "ntp_parser.y" /* yacc.c:1646 */
{
cfgt.auth.cryptosw++;
CONCAT_G_FIFOS(cfgt.auth.crypto_cmd_list, (yyvsp[0].Attr_val_fifo));
}
-#line 2228 "ntp_parser.c" /* yacc.c:1646 */
+#line 2234 "ntp_parser.c" /* yacc.c:1646 */
break;
case 65:
-#line 556 "ntp_parser.y" /* yacc.c:1646 */
+#line 558 "ntp_parser.y" /* yacc.c:1646 */
{ cfgt.auth.keys = (yyvsp[0].String); }
-#line 2234 "ntp_parser.c" /* yacc.c:1646 */
+#line 2240 "ntp_parser.c" /* yacc.c:1646 */
break;
case 66:
-#line 558 "ntp_parser.y" /* yacc.c:1646 */
+#line 560 "ntp_parser.y" /* yacc.c:1646 */
{ cfgt.auth.keysdir = (yyvsp[0].String); }
-#line 2240 "ntp_parser.c" /* yacc.c:1646 */
+#line 2246 "ntp_parser.c" /* yacc.c:1646 */
break;
case 67:
-#line 560 "ntp_parser.y" /* yacc.c:1646 */
+#line 562 "ntp_parser.y" /* yacc.c:1646 */
{ cfgt.auth.request_key = (yyvsp[0].Integer); }
-#line 2246 "ntp_parser.c" /* yacc.c:1646 */
+#line 2252 "ntp_parser.c" /* yacc.c:1646 */
break;
case 68:
-#line 562 "ntp_parser.y" /* yacc.c:1646 */
+#line 564 "ntp_parser.y" /* yacc.c:1646 */
{ cfgt.auth.revoke = (yyvsp[0].Integer); }
-#line 2252 "ntp_parser.c" /* yacc.c:1646 */
+#line 2258 "ntp_parser.c" /* yacc.c:1646 */
break;
case 69:
-#line 564 "ntp_parser.y" /* yacc.c:1646 */
+#line 566 "ntp_parser.y" /* yacc.c:1646 */
{
cfgt.auth.trusted_key_list = (yyvsp[0].Attr_val_fifo);
@@ -2261,38 +2267,38 @@ yyreduce:
// else
// LINK_SLIST(cfgt.auth.trusted_key_list, $2, link);
}
-#line 2265 "ntp_parser.c" /* yacc.c:1646 */
+#line 2271 "ntp_parser.c" /* yacc.c:1646 */
break;
case 70:
-#line 573 "ntp_parser.y" /* yacc.c:1646 */
+#line 575 "ntp_parser.y" /* yacc.c:1646 */
{ cfgt.auth.ntp_signd_socket = (yyvsp[0].String); }
-#line 2271 "ntp_parser.c" /* yacc.c:1646 */
+#line 2277 "ntp_parser.c" /* yacc.c:1646 */
break;
case 71:
-#line 578 "ntp_parser.y" /* yacc.c:1646 */
+#line 580 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val_fifo) = NULL; }
-#line 2277 "ntp_parser.c" /* yacc.c:1646 */
+#line 2283 "ntp_parser.c" /* yacc.c:1646 */
break;
case 72:
-#line 580 "ntp_parser.y" /* yacc.c:1646 */
+#line 582 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2286 "ntp_parser.c" /* yacc.c:1646 */
+#line 2292 "ntp_parser.c" /* yacc.c:1646 */
break;
case 73:
-#line 588 "ntp_parser.y" /* yacc.c:1646 */
+#line 590 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); }
-#line 2292 "ntp_parser.c" /* yacc.c:1646 */
+#line 2298 "ntp_parser.c" /* yacc.c:1646 */
break;
case 74:
-#line 590 "ntp_parser.y" /* yacc.c:1646 */
+#line 592 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val) = NULL;
cfgt.auth.revoke = (yyvsp[0].Integer);
@@ -2301,59 +2307,59 @@ yyreduce:
"please use 'revoke %d' instead.",
cfgt.auth.revoke, cfgt.auth.revoke);
}
-#line 2305 "ntp_parser.c" /* yacc.c:1646 */
+#line 2311 "ntp_parser.c" /* yacc.c:1646 */
break;
case 80:
-#line 615 "ntp_parser.y" /* yacc.c:1646 */
+#line 617 "ntp_parser.y" /* yacc.c:1646 */
{ CONCAT_G_FIFOS(cfgt.orphan_cmds, (yyvsp[0].Attr_val_fifo)); }
-#line 2311 "ntp_parser.c" /* yacc.c:1646 */
+#line 2317 "ntp_parser.c" /* yacc.c:1646 */
break;
case 81:
-#line 620 "ntp_parser.y" /* yacc.c:1646 */
+#line 622 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2320 "ntp_parser.c" /* yacc.c:1646 */
+#line 2326 "ntp_parser.c" /* yacc.c:1646 */
break;
case 82:
-#line 625 "ntp_parser.y" /* yacc.c:1646 */
+#line 627 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2329 "ntp_parser.c" /* yacc.c:1646 */
+#line 2335 "ntp_parser.c" /* yacc.c:1646 */
break;
case 83:
-#line 633 "ntp_parser.y" /* yacc.c:1646 */
+#line 635 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (double)(yyvsp[0].Integer)); }
-#line 2335 "ntp_parser.c" /* yacc.c:1646 */
+#line 2341 "ntp_parser.c" /* yacc.c:1646 */
break;
case 84:
-#line 635 "ntp_parser.y" /* yacc.c:1646 */
+#line 637 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); }
-#line 2341 "ntp_parser.c" /* yacc.c:1646 */
+#line 2347 "ntp_parser.c" /* yacc.c:1646 */
break;
case 85:
-#line 637 "ntp_parser.y" /* yacc.c:1646 */
+#line 639 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (double)(yyvsp[0].Integer)); }
-#line 2347 "ntp_parser.c" /* yacc.c:1646 */
+#line 2353 "ntp_parser.c" /* yacc.c:1646 */
break;
case 96:
-#line 663 "ntp_parser.y" /* yacc.c:1646 */
+#line 665 "ntp_parser.y" /* yacc.c:1646 */
{ CONCAT_G_FIFOS(cfgt.stats_list, (yyvsp[0].Int_fifo)); }
-#line 2353 "ntp_parser.c" /* yacc.c:1646 */
+#line 2359 "ntp_parser.c" /* yacc.c:1646 */
break;
case 97:
-#line 665 "ntp_parser.y" /* yacc.c:1646 */
+#line 667 "ntp_parser.y" /* yacc.c:1646 */
{
if (input_from_file) {
cfgt.stats_dir = (yyvsp[0].String);
@@ -2362,55 +2368,55 @@ yyreduce:
yyerror(ip_file, "statsdir remote configuration ignored");
}
}
-#line 2366 "ntp_parser.c" /* yacc.c:1646 */
+#line 2372 "ntp_parser.c" /* yacc.c:1646 */
break;
case 98:
-#line 674 "ntp_parser.y" /* yacc.c:1646 */
+#line 676 "ntp_parser.y" /* yacc.c:1646 */
{
filegen_node *fgn;
fgn = create_filegen_node((yyvsp[-1].Integer), (yyvsp[0].Attr_val_fifo));
APPEND_G_FIFO(cfgt.filegen_opts, fgn);
}
-#line 2377 "ntp_parser.c" /* yacc.c:1646 */
+#line 2383 "ntp_parser.c" /* yacc.c:1646 */
break;
case 99:
-#line 684 "ntp_parser.y" /* yacc.c:1646 */
+#line 686 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Int_fifo) = (yyvsp[-1].Int_fifo);
APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer)));
}
-#line 2386 "ntp_parser.c" /* yacc.c:1646 */
+#line 2392 "ntp_parser.c" /* yacc.c:1646 */
break;
case 100:
-#line 689 "ntp_parser.y" /* yacc.c:1646 */
+#line 691 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Int_fifo) = NULL;
APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer)));
}
-#line 2395 "ntp_parser.c" /* yacc.c:1646 */
+#line 2401 "ntp_parser.c" /* yacc.c:1646 */
break;
case 109:
-#line 708 "ntp_parser.y" /* yacc.c:1646 */
+#line 710 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val_fifo) = NULL; }
-#line 2401 "ntp_parser.c" /* yacc.c:1646 */
+#line 2407 "ntp_parser.c" /* yacc.c:1646 */
break;
case 110:
-#line 710 "ntp_parser.y" /* yacc.c:1646 */
+#line 712 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2410 "ntp_parser.c" /* yacc.c:1646 */
+#line 2416 "ntp_parser.c" /* yacc.c:1646 */
break;
case 111:
-#line 718 "ntp_parser.y" /* yacc.c:1646 */
+#line 720 "ntp_parser.y" /* yacc.c:1646 */
{
if (input_from_file) {
(yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String));
@@ -2420,11 +2426,11 @@ yyreduce:
yyerror(ip_file, "filegen file remote config ignored");
}
}
-#line 2424 "ntp_parser.c" /* yacc.c:1646 */
+#line 2430 "ntp_parser.c" /* yacc.c:1646 */
break;
case 112:
-#line 728 "ntp_parser.y" /* yacc.c:1646 */
+#line 730 "ntp_parser.y" /* yacc.c:1646 */
{
if (input_from_file) {
(yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer));
@@ -2433,11 +2439,11 @@ yyreduce:
yyerror(ip_file, "filegen type remote config ignored");
}
}
-#line 2437 "ntp_parser.c" /* yacc.c:1646 */
+#line 2443 "ntp_parser.c" /* yacc.c:1646 */
break;
case 113:
-#line 737 "ntp_parser.y" /* yacc.c:1646 */
+#line 739 "ntp_parser.y" /* yacc.c:1646 */
{
const char *err;
@@ -2452,33 +2458,33 @@ yyreduce:
yyerror(ip_file, err);
}
}
-#line 2456 "ntp_parser.c" /* yacc.c:1646 */
+#line 2462 "ntp_parser.c" /* yacc.c:1646 */
break;
case 114:
-#line 752 "ntp_parser.y" /* yacc.c:1646 */
+#line 754 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); }
-#line 2462 "ntp_parser.c" /* yacc.c:1646 */
+#line 2468 "ntp_parser.c" /* yacc.c:1646 */
break;
case 126:
-#line 782 "ntp_parser.y" /* yacc.c:1646 */
+#line 784 "ntp_parser.y" /* yacc.c:1646 */
{
CONCAT_G_FIFOS(cfgt.discard_opts, (yyvsp[0].Attr_val_fifo));
}
-#line 2470 "ntp_parser.c" /* yacc.c:1646 */
+#line 2476 "ntp_parser.c" /* yacc.c:1646 */
break;
case 127:
-#line 786 "ntp_parser.y" /* yacc.c:1646 */
+#line 788 "ntp_parser.y" /* yacc.c:1646 */
{
CONCAT_G_FIFOS(cfgt.mru_opts, (yyvsp[0].Attr_val_fifo));
}
-#line 2478 "ntp_parser.c" /* yacc.c:1646 */
+#line 2484 "ntp_parser.c" /* yacc.c:1646 */
break;
case 128:
-#line 790 "ntp_parser.y" /* yacc.c:1646 */
+#line 792 "ntp_parser.y" /* yacc.c:1646 */
{
restrict_node *rn;
@@ -2486,11 +2492,11 @@ yyreduce:
ip_file->line_no);
APPEND_G_FIFO(cfgt.restrict_opts, rn);
}
-#line 2490 "ntp_parser.c" /* yacc.c:1646 */
+#line 2496 "ntp_parser.c" /* yacc.c:1646 */
break;
case 129:
-#line 798 "ntp_parser.y" /* yacc.c:1646 */
+#line 800 "ntp_parser.y" /* yacc.c:1646 */
{
restrict_node *rn;
@@ -2498,11 +2504,11 @@ yyreduce:
ip_file->line_no);
APPEND_G_FIFO(cfgt.restrict_opts, rn);
}
-#line 2502 "ntp_parser.c" /* yacc.c:1646 */
+#line 2508 "ntp_parser.c" /* yacc.c:1646 */
break;
case 130:
-#line 806 "ntp_parser.y" /* yacc.c:1646 */
+#line 808 "ntp_parser.y" /* yacc.c:1646 */
{
restrict_node *rn;
@@ -2510,11 +2516,11 @@ yyreduce:
ip_file->line_no);
APPEND_G_FIFO(cfgt.restrict_opts, rn);
}
-#line 2514 "ntp_parser.c" /* yacc.c:1646 */
+#line 2520 "ntp_parser.c" /* yacc.c:1646 */
break;
case 131:
-#line 814 "ntp_parser.y" /* yacc.c:1646 */
+#line 816 "ntp_parser.y" /* yacc.c:1646 */
{
restrict_node *rn;
@@ -2529,11 +2535,11 @@ yyreduce:
ip_file->line_no);
APPEND_G_FIFO(cfgt.restrict_opts, rn);
}
-#line 2533 "ntp_parser.c" /* yacc.c:1646 */
+#line 2539 "ntp_parser.c" /* yacc.c:1646 */
break;
case 132:
-#line 829 "ntp_parser.y" /* yacc.c:1646 */
+#line 831 "ntp_parser.y" /* yacc.c:1646 */
{
restrict_node *rn;
@@ -2548,11 +2554,11 @@ yyreduce:
ip_file->line_no);
APPEND_G_FIFO(cfgt.restrict_opts, rn);
}
-#line 2552 "ntp_parser.c" /* yacc.c:1646 */
+#line 2558 "ntp_parser.c" /* yacc.c:1646 */
break;
case 133:
-#line 844 "ntp_parser.y" /* yacc.c:1646 */
+#line 846 "ntp_parser.y" /* yacc.c:1646 */
{
restrict_node * rn;
@@ -2561,199 +2567,199 @@ yyreduce:
NULL, NULL, (yyvsp[0].Int_fifo), ip_file->line_no);
APPEND_G_FIFO(cfgt.restrict_opts, rn);
}
-#line 2565 "ntp_parser.c" /* yacc.c:1646 */
+#line 2571 "ntp_parser.c" /* yacc.c:1646 */
break;
case 134:
-#line 856 "ntp_parser.y" /* yacc.c:1646 */
+#line 858 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Int_fifo) = NULL; }
-#line 2571 "ntp_parser.c" /* yacc.c:1646 */
+#line 2577 "ntp_parser.c" /* yacc.c:1646 */
break;
case 135:
-#line 858 "ntp_parser.y" /* yacc.c:1646 */
+#line 860 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Int_fifo) = (yyvsp[-1].Int_fifo);
APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer)));
}
-#line 2580 "ntp_parser.c" /* yacc.c:1646 */
+#line 2586 "ntp_parser.c" /* yacc.c:1646 */
break;
case 151:
-#line 884 "ntp_parser.y" /* yacc.c:1646 */
+#line 886 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2589 "ntp_parser.c" /* yacc.c:1646 */
+#line 2595 "ntp_parser.c" /* yacc.c:1646 */
break;
case 152:
-#line 889 "ntp_parser.y" /* yacc.c:1646 */
+#line 891 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2598 "ntp_parser.c" /* yacc.c:1646 */
+#line 2604 "ntp_parser.c" /* yacc.c:1646 */
break;
case 153:
-#line 897 "ntp_parser.y" /* yacc.c:1646 */
+#line 899 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 2604 "ntp_parser.c" /* yacc.c:1646 */
+#line 2610 "ntp_parser.c" /* yacc.c:1646 */
break;
case 157:
-#line 908 "ntp_parser.y" /* yacc.c:1646 */
+#line 910 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2613 "ntp_parser.c" /* yacc.c:1646 */
+#line 2619 "ntp_parser.c" /* yacc.c:1646 */
break;
case 158:
-#line 913 "ntp_parser.y" /* yacc.c:1646 */
+#line 915 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2622 "ntp_parser.c" /* yacc.c:1646 */
+#line 2628 "ntp_parser.c" /* yacc.c:1646 */
break;
case 159:
-#line 921 "ntp_parser.y" /* yacc.c:1646 */
+#line 923 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 2628 "ntp_parser.c" /* yacc.c:1646 */
+#line 2634 "ntp_parser.c" /* yacc.c:1646 */
break;
case 168:
-#line 941 "ntp_parser.y" /* yacc.c:1646 */
+#line 943 "ntp_parser.y" /* yacc.c:1646 */
{
addr_opts_node *aon;
aon = create_addr_opts_node((yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo));
APPEND_G_FIFO(cfgt.fudge, aon);
}
-#line 2639 "ntp_parser.c" /* yacc.c:1646 */
+#line 2645 "ntp_parser.c" /* yacc.c:1646 */
break;
case 169:
-#line 951 "ntp_parser.y" /* yacc.c:1646 */
+#line 953 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2648 "ntp_parser.c" /* yacc.c:1646 */
+#line 2654 "ntp_parser.c" /* yacc.c:1646 */
break;
case 170:
-#line 956 "ntp_parser.y" /* yacc.c:1646 */
+#line 958 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2657 "ntp_parser.c" /* yacc.c:1646 */
+#line 2663 "ntp_parser.c" /* yacc.c:1646 */
break;
case 171:
-#line 964 "ntp_parser.y" /* yacc.c:1646 */
+#line 966 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); }
-#line 2663 "ntp_parser.c" /* yacc.c:1646 */
+#line 2669 "ntp_parser.c" /* yacc.c:1646 */
break;
case 172:
-#line 966 "ntp_parser.y" /* yacc.c:1646 */
+#line 968 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 2669 "ntp_parser.c" /* yacc.c:1646 */
+#line 2675 "ntp_parser.c" /* yacc.c:1646 */
break;
case 173:
-#line 968 "ntp_parser.y" /* yacc.c:1646 */
+#line 970 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 2675 "ntp_parser.c" /* yacc.c:1646 */
+#line 2681 "ntp_parser.c" /* yacc.c:1646 */
break;
case 174:
-#line 970 "ntp_parser.y" /* yacc.c:1646 */
+#line 972 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); }
-#line 2681 "ntp_parser.c" /* yacc.c:1646 */
+#line 2687 "ntp_parser.c" /* yacc.c:1646 */
break;
case 175:
-#line 972 "ntp_parser.y" /* yacc.c:1646 */
+#line 974 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String)); }
-#line 2687 "ntp_parser.c" /* yacc.c:1646 */
+#line 2693 "ntp_parser.c" /* yacc.c:1646 */
break;
case 182:
-#line 993 "ntp_parser.y" /* yacc.c:1646 */
+#line 995 "ntp_parser.y" /* yacc.c:1646 */
{ CONCAT_G_FIFOS(cfgt.rlimit, (yyvsp[0].Attr_val_fifo)); }
-#line 2693 "ntp_parser.c" /* yacc.c:1646 */
+#line 2699 "ntp_parser.c" /* yacc.c:1646 */
break;
case 183:
-#line 998 "ntp_parser.y" /* yacc.c:1646 */
+#line 1000 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2702 "ntp_parser.c" /* yacc.c:1646 */
+#line 2708 "ntp_parser.c" /* yacc.c:1646 */
break;
case 184:
-#line 1003 "ntp_parser.y" /* yacc.c:1646 */
+#line 1005 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2711 "ntp_parser.c" /* yacc.c:1646 */
+#line 2717 "ntp_parser.c" /* yacc.c:1646 */
break;
case 185:
-#line 1011 "ntp_parser.y" /* yacc.c:1646 */
+#line 1013 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 2717 "ntp_parser.c" /* yacc.c:1646 */
+#line 2723 "ntp_parser.c" /* yacc.c:1646 */
break;
case 189:
-#line 1027 "ntp_parser.y" /* yacc.c:1646 */
+#line 1029 "ntp_parser.y" /* yacc.c:1646 */
{ CONCAT_G_FIFOS(cfgt.enable_opts, (yyvsp[0].Attr_val_fifo)); }
-#line 2723 "ntp_parser.c" /* yacc.c:1646 */
+#line 2729 "ntp_parser.c" /* yacc.c:1646 */
break;
case 190:
-#line 1029 "ntp_parser.y" /* yacc.c:1646 */
+#line 1031 "ntp_parser.y" /* yacc.c:1646 */
{ CONCAT_G_FIFOS(cfgt.disable_opts, (yyvsp[0].Attr_val_fifo)); }
-#line 2729 "ntp_parser.c" /* yacc.c:1646 */
+#line 2735 "ntp_parser.c" /* yacc.c:1646 */
break;
case 191:
-#line 1034 "ntp_parser.y" /* yacc.c:1646 */
+#line 1036 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2738 "ntp_parser.c" /* yacc.c:1646 */
+#line 2744 "ntp_parser.c" /* yacc.c:1646 */
break;
case 192:
-#line 1039 "ntp_parser.y" /* yacc.c:1646 */
+#line 1041 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2747 "ntp_parser.c" /* yacc.c:1646 */
+#line 2753 "ntp_parser.c" /* yacc.c:1646 */
break;
case 193:
-#line 1047 "ntp_parser.y" /* yacc.c:1646 */
+#line 1049 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer)); }
-#line 2753 "ntp_parser.c" /* yacc.c:1646 */
+#line 2759 "ntp_parser.c" /* yacc.c:1646 */
break;
case 194:
-#line 1049 "ntp_parser.y" /* yacc.c:1646 */
+#line 1051 "ntp_parser.y" /* yacc.c:1646 */
{
if (input_from_file) {
(yyval.Attr_val) = create_attr_ival(T_Flag, (yyvsp[0].Integer));
@@ -2767,63 +2773,63 @@ yyreduce:
yyerror(ip_file, err_str);
}
}
-#line 2771 "ntp_parser.c" /* yacc.c:1646 */
+#line 2777 "ntp_parser.c" /* yacc.c:1646 */
break;
case 203:
-#line 1084 "ntp_parser.y" /* yacc.c:1646 */
+#line 1086 "ntp_parser.y" /* yacc.c:1646 */
{ CONCAT_G_FIFOS(cfgt.tinker, (yyvsp[0].Attr_val_fifo)); }
-#line 2777 "ntp_parser.c" /* yacc.c:1646 */
+#line 2783 "ntp_parser.c" /* yacc.c:1646 */
break;
case 204:
-#line 1089 "ntp_parser.y" /* yacc.c:1646 */
+#line 1091 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2786 "ntp_parser.c" /* yacc.c:1646 */
+#line 2792 "ntp_parser.c" /* yacc.c:1646 */
break;
case 205:
-#line 1094 "ntp_parser.y" /* yacc.c:1646 */
+#line 1096 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2795 "ntp_parser.c" /* yacc.c:1646 */
+#line 2801 "ntp_parser.c" /* yacc.c:1646 */
break;
case 206:
-#line 1102 "ntp_parser.y" /* yacc.c:1646 */
+#line 1104 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double)); }
-#line 2801 "ntp_parser.c" /* yacc.c:1646 */
+#line 2807 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 217:
-#line 1125 "ntp_parser.y" /* yacc.c:1646 */
+ case 219:
+#line 1129 "ntp_parser.y" /* yacc.c:1646 */
{
attr_val *av;
av = create_attr_dval((yyvsp[-1].Integer), (yyvsp[0].Double));
APPEND_G_FIFO(cfgt.vars, av);
}
-#line 2812 "ntp_parser.c" /* yacc.c:1646 */
+#line 2818 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 218:
-#line 1132 "ntp_parser.y" /* yacc.c:1646 */
+ case 220:
+#line 1136 "ntp_parser.y" /* yacc.c:1646 */
{
attr_val *av;
av = create_attr_sval((yyvsp[-1].Integer), (yyvsp[0].String));
APPEND_G_FIFO(cfgt.vars, av);
}
-#line 2823 "ntp_parser.c" /* yacc.c:1646 */
+#line 2829 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 219:
-#line 1139 "ntp_parser.y" /* yacc.c:1646 */
+ case 221:
+#line 1143 "ntp_parser.y" /* yacc.c:1646 */
{
char error_text[64];
attr_val *av;
@@ -2839,11 +2845,11 @@ yyreduce:
yyerror(ip_file, error_text);
}
}
-#line 2843 "ntp_parser.c" /* yacc.c:1646 */
+#line 2849 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 220:
-#line 1155 "ntp_parser.y" /* yacc.c:1646 */
+ case 222:
+#line 1159 "ntp_parser.y" /* yacc.c:1646 */
{
if (!input_from_file) {
yyerror(ip_file, "remote includefile ignored");
@@ -2862,72 +2868,72 @@ yyreduce:
}
}
}
-#line 2866 "ntp_parser.c" /* yacc.c:1646 */
+#line 2872 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 221:
-#line 1174 "ntp_parser.y" /* yacc.c:1646 */
+ case 223:
+#line 1178 "ntp_parser.y" /* yacc.c:1646 */
{
while (curr_include_level != -1)
FCLOSE(fp[curr_include_level--]);
}
-#line 2875 "ntp_parser.c" /* yacc.c:1646 */
+#line 2881 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 222:
-#line 1179 "ntp_parser.y" /* yacc.c:1646 */
+ case 224:
+#line 1183 "ntp_parser.y" /* yacc.c:1646 */
{ /* see drift_parm below for actions */ }
-#line 2881 "ntp_parser.c" /* yacc.c:1646 */
+#line 2887 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 223:
-#line 1181 "ntp_parser.y" /* yacc.c:1646 */
+ case 225:
+#line 1185 "ntp_parser.y" /* yacc.c:1646 */
{ CONCAT_G_FIFOS(cfgt.logconfig, (yyvsp[0].Attr_val_fifo)); }
-#line 2887 "ntp_parser.c" /* yacc.c:1646 */
+#line 2893 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 224:
-#line 1183 "ntp_parser.y" /* yacc.c:1646 */
+ case 226:
+#line 1187 "ntp_parser.y" /* yacc.c:1646 */
{ CONCAT_G_FIFOS(cfgt.phone, (yyvsp[0].String_fifo)); }
-#line 2893 "ntp_parser.c" /* yacc.c:1646 */
+#line 2899 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 225:
-#line 1185 "ntp_parser.y" /* yacc.c:1646 */
+ case 227:
+#line 1189 "ntp_parser.y" /* yacc.c:1646 */
{ APPEND_G_FIFO(cfgt.setvar, (yyvsp[0].Set_var)); }
-#line 2899 "ntp_parser.c" /* yacc.c:1646 */
+#line 2905 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 226:
-#line 1187 "ntp_parser.y" /* yacc.c:1646 */
+ case 228:
+#line 1191 "ntp_parser.y" /* yacc.c:1646 */
{
addr_opts_node *aon;
aon = create_addr_opts_node((yyvsp[-1].Address_node), (yyvsp[0].Attr_val_fifo));
APPEND_G_FIFO(cfgt.trap, aon);
}
-#line 2910 "ntp_parser.c" /* yacc.c:1646 */
+#line 2916 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 227:
-#line 1194 "ntp_parser.y" /* yacc.c:1646 */
+ case 229:
+#line 1198 "ntp_parser.y" /* yacc.c:1646 */
{ CONCAT_G_FIFOS(cfgt.ttl, (yyvsp[0].Attr_val_fifo)); }
-#line 2916 "ntp_parser.c" /* yacc.c:1646 */
+#line 2922 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 236:
-#line 1216 "ntp_parser.y" /* yacc.c:1646 */
+ case 238:
+#line 1220 "ntp_parser.y" /* yacc.c:1646 */
{
attr_val *av;
av = create_attr_sval(T_Driftfile, (yyvsp[0].String));
APPEND_G_FIFO(cfgt.vars, av);
}
-#line 2927 "ntp_parser.c" /* yacc.c:1646 */
+#line 2933 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 237:
-#line 1223 "ntp_parser.y" /* yacc.c:1646 */
+ case 239:
+#line 1227 "ntp_parser.y" /* yacc.c:1646 */
{
attr_val *av;
@@ -2936,82 +2942,82 @@ yyreduce:
av = create_attr_dval(T_WanderThreshold, (yyvsp[0].Double));
APPEND_G_FIFO(cfgt.vars, av);
}
-#line 2940 "ntp_parser.c" /* yacc.c:1646 */
+#line 2946 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 238:
-#line 1232 "ntp_parser.y" /* yacc.c:1646 */
+ case 240:
+#line 1236 "ntp_parser.y" /* yacc.c:1646 */
{
attr_val *av;
av = create_attr_sval(T_Driftfile, "");
APPEND_G_FIFO(cfgt.vars, av);
}
-#line 2951 "ntp_parser.c" /* yacc.c:1646 */
+#line 2957 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 239:
-#line 1242 "ntp_parser.y" /* yacc.c:1646 */
+ case 241:
+#line 1246 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Set_var) = create_setvar_node((yyvsp[-3].String), (yyvsp[-1].String), (yyvsp[0].Integer)); }
-#line 2957 "ntp_parser.c" /* yacc.c:1646 */
+#line 2963 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 241:
-#line 1248 "ntp_parser.y" /* yacc.c:1646 */
+ case 243:
+#line 1252 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Integer) = 0; }
-#line 2963 "ntp_parser.c" /* yacc.c:1646 */
+#line 2969 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 242:
-#line 1253 "ntp_parser.y" /* yacc.c:1646 */
+ case 244:
+#line 1257 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val_fifo) = NULL; }
-#line 2969 "ntp_parser.c" /* yacc.c:1646 */
+#line 2975 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 243:
-#line 1255 "ntp_parser.y" /* yacc.c:1646 */
+ case 245:
+#line 1259 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 2978 "ntp_parser.c" /* yacc.c:1646 */
+#line 2984 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 244:
-#line 1263 "ntp_parser.y" /* yacc.c:1646 */
+ case 246:
+#line 1267 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_ival((yyvsp[-1].Integer), (yyvsp[0].Integer)); }
-#line 2984 "ntp_parser.c" /* yacc.c:1646 */
+#line 2990 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 245:
-#line 1265 "ntp_parser.y" /* yacc.c:1646 */
+ case 247:
+#line 1269 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val) = create_attr_sval((yyvsp[-1].Integer), estrdup((yyvsp[0].Address_node)->address));
destroy_address_node((yyvsp[0].Address_node));
}
-#line 2993 "ntp_parser.c" /* yacc.c:1646 */
+#line 2999 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 246:
-#line 1273 "ntp_parser.y" /* yacc.c:1646 */
+ case 248:
+#line 1277 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3002 "ntp_parser.c" /* yacc.c:1646 */
+#line 3008 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 247:
-#line 1278 "ntp_parser.y" /* yacc.c:1646 */
+ case 249:
+#line 1282 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3011 "ntp_parser.c" /* yacc.c:1646 */
+#line 3017 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 248:
-#line 1286 "ntp_parser.y" /* yacc.c:1646 */
+ case 250:
+#line 1290 "ntp_parser.y" /* yacc.c:1646 */
{
char prefix;
char * type;
@@ -3033,141 +3039,141 @@ yyreduce:
(yyval.Attr_val) = create_attr_sval(prefix, estrdup(type));
YYFREE((yyvsp[0].String));
}
-#line 3037 "ntp_parser.c" /* yacc.c:1646 */
+#line 3043 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 249:
-#line 1311 "ntp_parser.y" /* yacc.c:1646 */
+ case 251:
+#line 1315 "ntp_parser.y" /* yacc.c:1646 */
{
nic_rule_node *nrn;
nrn = create_nic_rule_node((yyvsp[0].Integer), NULL, (yyvsp[-1].Integer));
APPEND_G_FIFO(cfgt.nic_rules, nrn);
}
-#line 3048 "ntp_parser.c" /* yacc.c:1646 */
+#line 3054 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 250:
-#line 1318 "ntp_parser.y" /* yacc.c:1646 */
+ case 252:
+#line 1322 "ntp_parser.y" /* yacc.c:1646 */
{
nic_rule_node *nrn;
nrn = create_nic_rule_node(0, (yyvsp[0].String), (yyvsp[-1].Integer));
APPEND_G_FIFO(cfgt.nic_rules, nrn);
}
-#line 3059 "ntp_parser.c" /* yacc.c:1646 */
+#line 3065 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 260:
-#line 1346 "ntp_parser.y" /* yacc.c:1646 */
+ case 262:
+#line 1350 "ntp_parser.y" /* yacc.c:1646 */
{ CONCAT_G_FIFOS(cfgt.reset_counters, (yyvsp[0].Int_fifo)); }
-#line 3065 "ntp_parser.c" /* yacc.c:1646 */
+#line 3071 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 261:
-#line 1351 "ntp_parser.y" /* yacc.c:1646 */
+ case 263:
+#line 1355 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Int_fifo) = (yyvsp[-1].Int_fifo);
APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer)));
}
-#line 3074 "ntp_parser.c" /* yacc.c:1646 */
+#line 3080 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 262:
-#line 1356 "ntp_parser.y" /* yacc.c:1646 */
+ case 264:
+#line 1360 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Int_fifo) = NULL;
APPEND_G_FIFO((yyval.Int_fifo), create_int_node((yyvsp[0].Integer)));
}
-#line 3083 "ntp_parser.c" /* yacc.c:1646 */
+#line 3089 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 270:
-#line 1380 "ntp_parser.y" /* yacc.c:1646 */
+ case 272:
+#line 1384 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[0].Integer)));
}
-#line 3092 "ntp_parser.c" /* yacc.c:1646 */
+#line 3098 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 271:
-#line 1385 "ntp_parser.y" /* yacc.c:1646 */
+ case 273:
+#line 1389 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), create_int_node((yyvsp[0].Integer)));
}
-#line 3101 "ntp_parser.c" /* yacc.c:1646 */
+#line 3107 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 272:
-#line 1393 "ntp_parser.y" /* yacc.c:1646 */
+ case 274:
+#line 1397 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = (yyvsp[-1].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3110 "ntp_parser.c" /* yacc.c:1646 */
+#line 3116 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 273:
-#line 1398 "ntp_parser.y" /* yacc.c:1646 */
+ case 275:
+#line 1402 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[0].Attr_val));
}
-#line 3119 "ntp_parser.c" /* yacc.c:1646 */
+#line 3125 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 274:
-#line 1406 "ntp_parser.y" /* yacc.c:1646 */
+ case 276:
+#line 1410 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_ival('i', (yyvsp[0].Integer)); }
-#line 3125 "ntp_parser.c" /* yacc.c:1646 */
+#line 3131 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 276:
-#line 1412 "ntp_parser.y" /* yacc.c:1646 */
+ case 278:
+#line 1416 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_rangeval('-', (yyvsp[-3].Integer), (yyvsp[-1].Integer)); }
-#line 3131 "ntp_parser.c" /* yacc.c:1646 */
+#line 3137 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 277:
-#line 1417 "ntp_parser.y" /* yacc.c:1646 */
+ case 279:
+#line 1421 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.String_fifo) = (yyvsp[-1].String_fifo);
APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[0].String)));
}
-#line 3140 "ntp_parser.c" /* yacc.c:1646 */
+#line 3146 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 278:
-#line 1422 "ntp_parser.y" /* yacc.c:1646 */
+ case 280:
+#line 1426 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.String_fifo) = NULL;
APPEND_G_FIFO((yyval.String_fifo), create_string_node((yyvsp[0].String)));
}
-#line 3149 "ntp_parser.c" /* yacc.c:1646 */
+#line 3155 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 279:
-#line 1430 "ntp_parser.y" /* yacc.c:1646 */
+ case 281:
+#line 1434 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Address_fifo) = (yyvsp[-1].Address_fifo);
APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[0].Address_node));
}
-#line 3158 "ntp_parser.c" /* yacc.c:1646 */
+#line 3164 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 280:
-#line 1435 "ntp_parser.y" /* yacc.c:1646 */
+ case 282:
+#line 1439 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Address_fifo) = NULL;
APPEND_G_FIFO((yyval.Address_fifo), (yyvsp[0].Address_node));
}
-#line 3167 "ntp_parser.c" /* yacc.c:1646 */
+#line 3173 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 281:
-#line 1443 "ntp_parser.y" /* yacc.c:1646 */
+ case 283:
+#line 1447 "ntp_parser.y" /* yacc.c:1646 */
{
if ((yyvsp[0].Integer) != 0 && (yyvsp[0].Integer) != 1) {
yyerror(ip_file, "Integer value is not boolean (0 or 1). Assuming 1");
@@ -3176,29 +3182,29 @@ yyreduce:
(yyval.Integer) = (yyvsp[0].Integer);
}
}
-#line 3180 "ntp_parser.c" /* yacc.c:1646 */
- break;
-
- case 282:
-#line 1451 "ntp_parser.y" /* yacc.c:1646 */
- { (yyval.Integer) = 1; }
#line 3186 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 283:
-#line 1452 "ntp_parser.y" /* yacc.c:1646 */
- { (yyval.Integer) = 0; }
+ case 284:
+#line 1455 "ntp_parser.y" /* yacc.c:1646 */
+ { (yyval.Integer) = 1; }
#line 3192 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 284:
+ case 285:
#line 1456 "ntp_parser.y" /* yacc.c:1646 */
- { (yyval.Double) = (double)(yyvsp[0].Integer); }
+ { (yyval.Integer) = 0; }
#line 3198 "ntp_parser.c" /* yacc.c:1646 */
break;
case 286:
-#line 1467 "ntp_parser.y" /* yacc.c:1646 */
+#line 1460 "ntp_parser.y" /* yacc.c:1646 */
+ { (yyval.Double) = (double)(yyvsp[0].Integer); }
+#line 3204 "ntp_parser.c" /* yacc.c:1646 */
+ break;
+
+ case 288:
+#line 1471 "ntp_parser.y" /* yacc.c:1646 */
{
sim_node *sn;
@@ -3208,125 +3214,125 @@ yyreduce:
/* Revert from ; to \n for end-of-command */
old_config_style = 1;
}
-#line 3212 "ntp_parser.c" /* yacc.c:1646 */
+#line 3218 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 287:
-#line 1484 "ntp_parser.y" /* yacc.c:1646 */
+ case 289:
+#line 1488 "ntp_parser.y" /* yacc.c:1646 */
{ old_config_style = 0; }
-#line 3218 "ntp_parser.c" /* yacc.c:1646 */
+#line 3224 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 288:
-#line 1489 "ntp_parser.y" /* yacc.c:1646 */
+ case 290:
+#line 1493 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = (yyvsp[-2].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val));
}
-#line 3227 "ntp_parser.c" /* yacc.c:1646 */
+#line 3233 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 289:
-#line 1494 "ntp_parser.y" /* yacc.c:1646 */
+ case 291:
+#line 1498 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val));
}
-#line 3236 "ntp_parser.c" /* yacc.c:1646 */
+#line 3242 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 290:
-#line 1502 "ntp_parser.y" /* yacc.c:1646 */
+ case 292:
+#line 1506 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_dval((yyvsp[-2].Integer), (yyvsp[0].Double)); }
-#line 3242 "ntp_parser.c" /* yacc.c:1646 */
+#line 3248 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 293:
-#line 1512 "ntp_parser.y" /* yacc.c:1646 */
+ case 295:
+#line 1516 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Sim_server_fifo) = (yyvsp[-1].Sim_server_fifo);
APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[0].Sim_server));
}
-#line 3251 "ntp_parser.c" /* yacc.c:1646 */
+#line 3257 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 294:
-#line 1517 "ntp_parser.y" /* yacc.c:1646 */
+ case 296:
+#line 1521 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Sim_server_fifo) = NULL;
APPEND_G_FIFO((yyval.Sim_server_fifo), (yyvsp[0].Sim_server));
}
-#line 3260 "ntp_parser.c" /* yacc.c:1646 */
+#line 3266 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 295:
-#line 1525 "ntp_parser.y" /* yacc.c:1646 */
+ case 297:
+#line 1529 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Sim_server) = ONLY_SIM(create_sim_server((yyvsp[-4].Address_node), (yyvsp[-2].Double), (yyvsp[-1].Sim_script_fifo))); }
-#line 3266 "ntp_parser.c" /* yacc.c:1646 */
+#line 3272 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 296:
-#line 1530 "ntp_parser.y" /* yacc.c:1646 */
+ case 298:
+#line 1534 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Double) = (yyvsp[-1].Double); }
-#line 3272 "ntp_parser.c" /* yacc.c:1646 */
+#line 3278 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 297:
-#line 1535 "ntp_parser.y" /* yacc.c:1646 */
+ case 299:
+#line 1539 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Address_node) = (yyvsp[0].Address_node); }
-#line 3278 "ntp_parser.c" /* yacc.c:1646 */
+#line 3284 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 298:
-#line 1540 "ntp_parser.y" /* yacc.c:1646 */
+ case 300:
+#line 1544 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Sim_script_fifo) = (yyvsp[-1].Sim_script_fifo);
APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[0].Sim_script));
}
-#line 3287 "ntp_parser.c" /* yacc.c:1646 */
+#line 3293 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 299:
-#line 1545 "ntp_parser.y" /* yacc.c:1646 */
+ case 301:
+#line 1549 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Sim_script_fifo) = NULL;
APPEND_G_FIFO((yyval.Sim_script_fifo), (yyvsp[0].Sim_script));
}
-#line 3296 "ntp_parser.c" /* yacc.c:1646 */
+#line 3302 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 300:
-#line 1553 "ntp_parser.y" /* yacc.c:1646 */
+ case 302:
+#line 1557 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Sim_script) = ONLY_SIM(create_sim_script_info((yyvsp[-3].Double), (yyvsp[-1].Attr_val_fifo))); }
-#line 3302 "ntp_parser.c" /* yacc.c:1646 */
+#line 3308 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 301:
-#line 1558 "ntp_parser.y" /* yacc.c:1646 */
+ case 303:
+#line 1562 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = (yyvsp[-2].Attr_val_fifo);
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val));
}
-#line 3311 "ntp_parser.c" /* yacc.c:1646 */
+#line 3317 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 302:
-#line 1563 "ntp_parser.y" /* yacc.c:1646 */
+ case 304:
+#line 1567 "ntp_parser.y" /* yacc.c:1646 */
{
(yyval.Attr_val_fifo) = NULL;
APPEND_G_FIFO((yyval.Attr_val_fifo), (yyvsp[-1].Attr_val));
}
-#line 3320 "ntp_parser.c" /* yacc.c:1646 */
+#line 3326 "ntp_parser.c" /* yacc.c:1646 */
break;
- case 303:
-#line 1571 "ntp_parser.y" /* yacc.c:1646 */
+ case 305:
+#line 1575 "ntp_parser.y" /* yacc.c:1646 */
{ (yyval.Attr_val) = create_attr_dval((yyvsp[-2].Integer), (yyvsp[0].Double)); }
-#line 3326 "ntp_parser.c" /* yacc.c:1646 */
+#line 3332 "ntp_parser.c" /* yacc.c:1646 */
break;
-#line 3330 "ntp_parser.c" /* yacc.c:1646 */
+#line 3336 "ntp_parser.c" /* yacc.c:1646 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -3554,7 +3560,7 @@ yyreturn:
#endif
return yyresult;
}
-#line 1582 "ntp_parser.y" /* yacc.c:1906 */
+#line 1586 "ntp_parser.y" /* yacc.c:1906 */
void
diff --git a/contrib/ntp/ntpd/ntp_parser.h b/contrib/ntp/ntpd/ntp_parser.h
index fc2e971..2804e54 100644
--- a/contrib/ntp/ntpd/ntp_parser.h
+++ b/contrib/ntp/ntpd/ntp_parser.h
@@ -194,44 +194,46 @@ extern int yydebug;
T_Stats = 404,
T_Statsdir = 405,
T_Step = 406,
- T_Stepout = 407,
- T_Stratum = 408,
- T_String = 409,
- T_Sys = 410,
- T_Sysstats = 411,
- T_Tick = 412,
- T_Time1 = 413,
- T_Time2 = 414,
- T_Timer = 415,
- T_Timingstats = 416,
- T_Tinker = 417,
- T_Tos = 418,
- T_Trap = 419,
- T_True = 420,
- T_Trustedkey = 421,
- T_Ttl = 422,
- T_Type = 423,
- T_U_int = 424,
- T_Unconfig = 425,
- T_Unpeer = 426,
- T_Version = 427,
- T_WanderThreshold = 428,
- T_Week = 429,
- T_Wildcard = 430,
- T_Xleave = 431,
- T_Year = 432,
- T_Flag = 433,
- T_EOC = 434,
- T_Simulate = 435,
- T_Beep_Delay = 436,
- T_Sim_Duration = 437,
- T_Server_Offset = 438,
- T_Duration = 439,
- T_Freq_Offset = 440,
- T_Wander = 441,
- T_Jitter = 442,
- T_Prop_Delay = 443,
- T_Proc_Delay = 444
+ T_Stepback = 407,
+ T_Stepfwd = 408,
+ T_Stepout = 409,
+ T_Stratum = 410,
+ T_String = 411,
+ T_Sys = 412,
+ T_Sysstats = 413,
+ T_Tick = 414,
+ T_Time1 = 415,
+ T_Time2 = 416,
+ T_Timer = 417,
+ T_Timingstats = 418,
+ T_Tinker = 419,
+ T_Tos = 420,
+ T_Trap = 421,
+ T_True = 422,
+ T_Trustedkey = 423,
+ T_Ttl = 424,
+ T_Type = 425,
+ T_U_int = 426,
+ T_Unconfig = 427,
+ T_Unpeer = 428,
+ T_Version = 429,
+ T_WanderThreshold = 430,
+ T_Week = 431,
+ T_Wildcard = 432,
+ T_Xleave = 433,
+ T_Year = 434,
+ T_Flag = 435,
+ T_EOC = 436,
+ T_Simulate = 437,
+ T_Beep_Delay = 438,
+ T_Sim_Duration = 439,
+ T_Server_Offset = 440,
+ T_Duration = 441,
+ T_Freq_Offset = 442,
+ T_Wander = 443,
+ T_Jitter = 444,
+ T_Prop_Delay = 445,
+ T_Proc_Delay = 446
};
#endif
/* Tokens. */
@@ -384,44 +386,46 @@ extern int yydebug;
#define T_Stats 404
#define T_Statsdir 405
#define T_Step 406
-#define T_Stepout 407
-#define T_Stratum 408
-#define T_String 409
-#define T_Sys 410
-#define T_Sysstats 411
-#define T_Tick 412
-#define T_Time1 413
-#define T_Time2 414
-#define T_Timer 415
-#define T_Timingstats 416
-#define T_Tinker 417
-#define T_Tos 418
-#define T_Trap 419
-#define T_True 420
-#define T_Trustedkey 421
-#define T_Ttl 422
-#define T_Type 423
-#define T_U_int 424
-#define T_Unconfig 425
-#define T_Unpeer 426
-#define T_Version 427
-#define T_WanderThreshold 428
-#define T_Week 429
-#define T_Wildcard 430
-#define T_Xleave 431
-#define T_Year 432
-#define T_Flag 433
-#define T_EOC 434
-#define T_Simulate 435
-#define T_Beep_Delay 436
-#define T_Sim_Duration 437
-#define T_Server_Offset 438
-#define T_Duration 439
-#define T_Freq_Offset 440
-#define T_Wander 441
-#define T_Jitter 442
-#define T_Prop_Delay 443
-#define T_Proc_Delay 444
+#define T_Stepback 407
+#define T_Stepfwd 408
+#define T_Stepout 409
+#define T_Stratum 410
+#define T_String 411
+#define T_Sys 412
+#define T_Sysstats 413
+#define T_Tick 414
+#define T_Time1 415
+#define T_Time2 416
+#define T_Timer 417
+#define T_Timingstats 418
+#define T_Tinker 419
+#define T_Tos 420
+#define T_Trap 421
+#define T_True 422
+#define T_Trustedkey 423
+#define T_Ttl 424
+#define T_Type 425
+#define T_U_int 426
+#define T_Unconfig 427
+#define T_Unpeer 428
+#define T_Version 429
+#define T_WanderThreshold 430
+#define T_Week 431
+#define T_Wildcard 432
+#define T_Xleave 433
+#define T_Year 434
+#define T_Flag 435
+#define T_EOC 436
+#define T_Simulate 437
+#define T_Beep_Delay 438
+#define T_Sim_Duration 439
+#define T_Server_Offset 440
+#define T_Duration 441
+#define T_Freq_Offset 442
+#define T_Wander 443
+#define T_Jitter 444
+#define T_Prop_Delay 445
+#define T_Proc_Delay 446
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
@@ -447,7 +451,7 @@ union YYSTYPE
script_info * Sim_script;
script_info_fifo * Sim_script_fifo;
-#line 451 "ntp_parser.h" /* yacc.c:1909 */
+#line 455 "ntp_parser.h" /* yacc.c:1909 */
};
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
diff --git a/contrib/ntp/ntpd/ntp_peer.c b/contrib/ntp/ntpd/ntp_peer.c
index 495ee30..d42d804 100644
--- a/contrib/ntp/ntpd/ntp_peer.c
+++ b/contrib/ntp/ntpd/ntp_peer.c
@@ -92,6 +92,7 @@ int peer_free_count; /* count of free structures */
* value every time an association is mobilized.
*/
static associd_t current_association_ID; /* association ID */
+static associd_t initial_association_ID; /* association ID */
/*
* Memory allocation watermarks.
@@ -147,6 +148,7 @@ init_peer(void)
do
current_association_ID = ntp_random() & ASSOCID_MAX;
while (!current_association_ID);
+ initial_association_ID = current_association_ID;
}
@@ -1036,3 +1038,21 @@ findmanycastpeer(
return peer;
}
+
+/* peer_cleanup - clean peer list prior to shutdown */
+void peer_cleanup(void)
+{
+ struct peer *peer;
+ associd_t assoc;
+
+ for (assoc = initial_association_ID; assoc != current_association_ID; assoc++) {
+ if (assoc != 0U) {
+ peer = findpeerbyassoc(assoc);
+ if (peer != NULL)
+ unpeer(peer);
+ }
+ }
+ peer = findpeerbyassoc(current_association_ID);
+ if (peer != NULL)
+ unpeer(peer);
+}
diff --git a/contrib/ntp/ntpd/ntp_proto.c b/contrib/ntp/ntpd/ntp_proto.c
index 37c3f03..577b5fb 100644
--- a/contrib/ntp/ntpd/ntp_proto.c
+++ b/contrib/ntp/ntpd/ntp_proto.c
@@ -245,7 +245,7 @@ transmit(
/*
* Update the reachability status. If not heard for
* three consecutive polls, stuff infinity in the clock
- * filter.
+ * filter.
*/
oreach = peer->reach;
peer->outdate = current_time;
@@ -290,7 +290,7 @@ transmit(
* If preemptible and we have more peers than maxclock,
* and this peer has the minimum score of preemptibles,
* demobilize.
- */
+ */
if (peer->unreach >= NTP_UNREACH) {
hpoll++;
/* ephemeral: no FLAG_CONFIG nor FLAG_PREEMPT */
@@ -335,7 +335,7 @@ transmit(
peer->retry--;
/*
- * Do not transmit if in broadcast client mode.
+ * Do not transmit if in broadcast client mode.
*/
if (peer->hmode != MODE_BCLIENT)
peer_xmit(peer);
@@ -442,7 +442,7 @@ receive(
return; /* no flakeway */
}
}
-
+
/*
* Version check must be after the query packets, since they
* intentionally use an early version.
@@ -659,7 +659,7 @@ receive(
* If the signature is 20 bytes long, the last 16 of
* which are zero, then this is a Microsoft client
* wanting AD-style authentication of the server's
- * reply.
+ * reply.
*
* This is described in Microsoft's WSPP docs, in MS-SNTP:
* http://msdn.microsoft.com/en-us/library/cc212930.aspx
@@ -680,7 +680,7 @@ receive(
* broadcast or unicast address as appropriate.
*/
if (crypto_flags && skeyid > NTP_MAXKEY) {
-
+
/*
* More on the autokey dance (AKD). A cookie is
* constructed from public and private values.
@@ -874,7 +874,7 @@ receive(
* curious and could be an intruder attempting to clog, so we
* just ignore it.
*
- * If the packet is authentic and the manycastclient or pool
+ * If the packet is authentic and the manycastclient or pool
* association is found, we mobilize a client association and
* copy pertinent variables from the manycastclient or pool
* association to the new client association. If not, just
@@ -1256,16 +1256,6 @@ receive(
}
/*
- * Update the state variables.
- */
- if (peer->flip == 0) {
- if (hismode != MODE_BROADCAST)
- peer->rec = p_xmt;
- peer->dst = rbufp->recv_time;
- }
- peer->xmt = p_xmt;
-
- /*
* If this is a crypto_NAK, the server cannot authenticate a
* client packet. The server might have just changed keys. Clear
* the association and restart the protocol.
@@ -1284,19 +1274,21 @@ receive(
#endif /* AUTOKEY */
return;
- /*
- * If the digest fails, the client cannot authenticate a server
+ /*
+ * If the digest fails or it's missing for authenticated
+ * associations, the client cannot authenticate a server
* reply to a client packet previously sent. The loopback check
* is designed to avoid a bait-and-switch attack, which was
* possible in past versions. If symmetric modes, return a
* crypto-NAK. The peer should restart the protocol.
*/
- } else if (!AUTH(has_mac || (restrict_mask & RES_DONTTRUST),
- is_authentic)) {
+ } else if (!AUTH(peer->keyid || has_mac ||
+ (restrict_mask & RES_DONTTRUST), is_authentic)) {
report_event(PEVNT_AUTH, peer, "digest");
peer->flash |= TEST5; /* bad auth */
peer->badauth++;
- if (hismode == MODE_ACTIVE || hismode == MODE_PASSIVE)
+ if (has_mac &&
+ (hismode == MODE_ACTIVE || hismode == MODE_PASSIVE))
fast_xmit(rbufp, MODE_ACTIVE, 0, restrict_mask);
if (peer->flags & FLAG_PREEMPT) {
unpeer(peer);
@@ -1310,6 +1302,16 @@ receive(
}
/*
+ * Update the state variables.
+ */
+ if (peer->flip == 0) {
+ if (hismode != MODE_BROADCAST)
+ peer->rec = p_xmt;
+ peer->dst = rbufp->recv_time;
+ }
+ peer->xmt = p_xmt;
+
+ /*
* Set the peer ppoll to the maximum of the packet ppoll and the
* peer minpoll. If a kiss-o'-death, set the peer minpoll to
* this maximum and advance the headway to give the sender some
@@ -1577,7 +1579,7 @@ process_packet(
/*
* If the peer was previously unreachable, raise a trap. In any
* case, mark it reachable.
- */
+ */
if (!peer->reach) {
report_event(PEVNT_REACH, peer, NULL);
peer->timereachable = current_time;
@@ -1644,8 +1646,8 @@ process_packet(
* Interleaved broadcast mode. Use interleaved timestamps.
* t1 = peer->borg, t2 = p_org, t3 = p_org, t4 = aorg
*/
- if (peer->flags & FLAG_XB) {
- ci = p_org; /* delay */
+ if (peer->flags & FLAG_XB) {
+ ci = p_org; /* delay */
L_SUB(&ci, &peer->aorg);
LFPTOD(&ci, t34);
ci = p_org; /* t2 - t1 */
@@ -1774,7 +1776,7 @@ process_packet(
p_del, peer->r21 / 1e3, peer->r34 / 1e3,
td);
#endif
- }
+ }
#endif /* ASSYM */
/*
@@ -2240,7 +2242,7 @@ clock_filter(
for (i = NTP_SHIFT - 1; i >= 0; i--) {
if (i != 0)
peer->filter_disp[j] += dtemp;
- if (peer->filter_disp[j] >= MAXDISPERSE) {
+ if (peer->filter_disp[j] >= MAXDISPERSE) {
peer->filter_disp[j] = MAXDISPERSE;
dst[i] = MAXDISPERSE;
} else if (peer->update - peer->filter_epoch[j] >
@@ -2255,7 +2257,7 @@ clock_filter(
}
/*
- * If the clock has stabilized, sort the samples by distance.
+ * If the clock has stabilized, sort the samples by distance.
*/
if (freq_cnt == 0) {
for (i = 1; i < NTP_SHIFT; i++) {
@@ -2289,7 +2291,7 @@ clock_filter(
continue;
m++;
}
-
+
/*
* Compute the dispersion and jitter. The dispersion is weighted
* exponentially by NTP_FWEIGHT (0.5) so it is normalized close
@@ -2493,9 +2495,9 @@ clock_select(void)
/*
* If this peer could have the orphan parent
* as a synchronization ancestor, exclude it
- * from selection to avoid forming a
+ * from selection to avoid forming a
* synchronization loop within the orphan mesh,
- * triggering stratum climb to infinity
+ * triggering stratum climb to infinity
* instability. Peers at stratum higher than
* the orphan stratum could have the orphan
* parent in ancestry so are excluded.
@@ -2603,7 +2605,7 @@ clock_select(void)
for (allow = 0; 2 * allow < nlist; allow++) {
/*
- * Bound the interval (low, high) as the smallest
+ * Bound the interval (low, high) as the smallest
* interval containing points from the most sources.
*/
n = 0;
@@ -2639,7 +2641,7 @@ clock_select(void)
* We assert the correct time is contained in the interval, but
* the best offset estimate for the interval might not be
* contained in the interval. For this purpose, a truechimer is
- * defined as the midpoint of an interval that overlaps the
+ * defined as the midpoint of an interval that overlaps the
* intersection interval.
*/
j = 0;
@@ -2659,9 +2661,10 @@ clock_select(void)
* include any of them in the cluster population.
*/
if (peer->flags & FLAG_PPS) {
- if (typepps == NULL)
+ if (typepps == NULL)
typepps = peer;
- continue;
+ if (!(peer->flags & FLAG_TSTAMP_PPS))
+ continue;
}
#endif /* REFCLOCK */
@@ -2672,7 +2675,7 @@ clock_select(void)
nlist = j;
/*
- * If no survivors remain at this point, check if the modem
+ * If no survivors remain at this point, check if the modem
* driver, local driver or orphan parent in that order. If so,
* nominate the first one found as the only survivor.
* Otherwise, give up and leave the island to the rats.
@@ -2709,7 +2712,7 @@ clock_select(void)
* by root distance. Continue voting as long as there are more
* than sys_minclock survivors and the select jitter of the peer
* with the worst metric is greater than the minimum peer
- * jitter. Stop if we are about to discard a TRUE or PREFER
+ * jitter. Stop if we are about to discard a TRUE or PREFER
* peer, who of course have the immunity idol.
*/
while (1) {
@@ -2815,7 +2818,7 @@ clock_select(void)
typesystem = peers[speer].peer;
if (osys_peer == NULL || osys_peer == typesystem) {
- sys_clockhop = 0;
+ sys_clockhop = 0;
} else if ((x = fabs(typesystem->offset -
osys_peer->offset)) < sys_mindisp) {
if (sys_clockhop == 0)
@@ -3113,7 +3116,7 @@ peer_xmit(
* the session key is generated.
*/
while (1) {
-
+
/*
* Allocate and initialize a keylist if not
* already done. Then, use the list in inverse
@@ -3165,7 +3168,7 @@ peer_xmit(
break;
/*
- * In symmetric modes the parameter, certificate,
+ * In symmetric modes the parameter, certificate,
* identity, cookie and autokey exchanges are
* required. The leapsecond exchange is optional. But, a
* peer will not believe the other peer until the other
@@ -3324,7 +3327,7 @@ peer_xmit(
session_key(&peer->dstadr->sin, &peer->srcadr,
xkeyid, 0, 2);
}
- }
+ }
#endif /* AUTOKEY */
/*
@@ -3619,7 +3622,7 @@ pool_xmit(
return; /* out of addresses, re-query DNS next poll */
restrict_mask = restrictions(rmtadr);
if (RES_FLAGS & restrict_mask)
- restrict_source(rmtadr, 0,
+ restrict_source(rmtadr, 0,
current_time + POOL_SOLICIT_WINDOW + 1);
lcladr = findinterface(rmtadr);
memset(&xpkt, 0, sizeof(xpkt));
diff --git a/contrib/ntp/ntpd/ntpd-opts.c b/contrib/ntp/ntpd/ntpd-opts.c
index 953f397..910689d 100644
--- a/contrib/ntp/ntpd/ntpd-opts.c
+++ b/contrib/ntp/ntpd/ntpd-opts.c
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (ntpd-opts.c)
*
- * It has been AutoGen-ed February 4, 2015 at 02:39:17 AM by AutoGen 5.18.5pre4
+ * It has been AutoGen-ed April 7, 2015 at 04:23:14 AM by AutoGen 5.18.5pre4
* From the definitions ntpd-opts.def
* and the template file options
*
@@ -74,8 +74,8 @@ extern FILE * option_usage_fp;
/**
* static const strings for ntpd options
*/
-static char const ntpd_opt_strs[3061] =
-/* 0 */ "ntpd 4.2.8p1\n"
+static char const ntpd_opt_strs[3129] =
+/* 0 */ "ntpd 4.2.8p2\n"
"Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n"
"This is free software. It is licensed for use, modification and\n"
"redistribution under the terms of the NTP License, copies of which\n"
@@ -122,92 +122,95 @@ static char const ntpd_opt_strs[3061] =
/* 1460 */ "Allow the first adjustment to be Big\0"
/* 1497 */ "PANICGATE\0"
/* 1507 */ "panicgate\0"
-/* 1517 */ "Jail directory\0"
-/* 1532 */ "JAILDIR\0"
-/* 1540 */ "jaildir\0"
-/* 1548 */ "built without --enable-clockctl or --enable-linuxcaps or --enable-solarisprivs\0"
-/* 1627 */ "Listen on an interface name or address\0"
-/* 1666 */ "INTERFACE\0"
-/* 1676 */ "interface\0"
-/* 1686 */ "path to symmetric keys\0"
-/* 1709 */ "KEYFILE\0"
-/* 1717 */ "keyfile\0"
-/* 1725 */ "path to the log file\0"
-/* 1746 */ "LOGFILE\0"
-/* 1754 */ "logfile\0"
-/* 1762 */ "Do not listen to virtual interfaces\0"
-/* 1798 */ "NOVIRTUALIPS\0"
-/* 1811 */ "novirtualips\0"
-/* 1824 */ "Modify Multimedia Timer (Windows only)\0"
-/* 1863 */ "MODIFYMMTIMER\0"
-/* 1877 */ "modifymmtimer\0"
-/* 1891 */ "Do not fork\0"
-/* 1903 */ "NOFORK\0"
-/* 1910 */ "nofork\0"
-/* 1917 */ "Run at high priority\0"
-/* 1938 */ "NICE\0"
-/* 1943 */ "nice\0"
-/* 1948 */ "path to the PID file\0"
-/* 1969 */ "PIDFILE\0"
-/* 1977 */ "pidfile\0"
-/* 1985 */ "Process priority\0"
-/* 2002 */ "PRIORITY\0"
-/* 2011 */ "priority\0"
-/* 2020 */ "Set the time and quit\0"
-/* 2042 */ "QUIT\0"
-/* 2047 */ "quit\0"
-/* 2052 */ "Broadcast/propagation delay\0"
-/* 2080 */ "PROPAGATIONDELAY\0"
-/* 2097 */ "propagationdelay\0"
-/* 2114 */ "Save parsed configuration and quit\0"
-/* 2149 */ "SAVECONFIGQUIT\0"
-/* 2164 */ "saveconfigquit\0"
-/* 2179 */ "Statistics file location\0"
-/* 2204 */ "STATSDIR\0"
-/* 2213 */ "statsdir\0"
-/* 2222 */ "Trusted key number\0"
-/* 2241 */ "TRUSTEDKEY\0"
-/* 2252 */ "trustedkey\0"
-/* 2263 */ "Run as userid (or userid:groupid)\0"
-/* 2297 */ "USER\0"
-/* 2302 */ "user\0"
-/* 2307 */ "interval in seconds between scans for new or dropped interfaces\0"
-/* 2371 */ "UPDATEINTERVAL\0"
-/* 2386 */ "updateinterval\0"
-/* 2401 */ "make ARG an ntp variable (RW)\0"
-/* 2431 */ "VAR\0"
-/* 2435 */ "var\0"
-/* 2439 */ "make ARG an ntp variable (RW|DEF)\0"
-/* 2473 */ "DVAR\0"
-/* 2478 */ "dvar\0"
-/* 2483 */ "Seconds to wait for first clock sync\0"
-/* 2520 */ "WAIT_SYNC\0"
-/* 2530 */ "wait-sync\0"
-/* 2540 */ "Slew up to 600 seconds\0"
-/* 2563 */ "SLEW\0"
-/* 2568 */ "slew\0"
-/* 2573 */ "Use CPU cycle counter (Windows only)\0"
-/* 2610 */ "USEPCC\0"
-/* 2617 */ "usepcc\0"
-/* 2624 */ "Force CPU cycle counter use (Windows only)\0"
-/* 2667 */ "PCCFREQ\0"
-/* 2675 */ "pccfreq\0"
-/* 2683 */ "Register with mDNS as a NTP server\0"
-/* 2718 */ "MDNS\0"
-/* 2723 */ "mdns\0"
-/* 2728 */ "display extended usage information and exit\0"
-/* 2772 */ "help\0"
-/* 2777 */ "extended usage information passed thru pager\0"
-/* 2822 */ "more-help\0"
-/* 2832 */ "output version information and exit\0"
-/* 2868 */ "version\0"
-/* 2876 */ "NTPD\0"
-/* 2881 */ "ntpd - NTP daemon program - Ver. 4.2.8p1\n"
+/* 1517 */ "Step any initial offset correction.\0"
+/* 1553 */ "FORCE_STEP_ONCE\0"
+/* 1569 */ "force-step-once\0"
+/* 1585 */ "Jail directory\0"
+/* 1600 */ "JAILDIR\0"
+/* 1608 */ "jaildir\0"
+/* 1616 */ "built without --enable-clockctl or --enable-linuxcaps or --enable-solarisprivs\0"
+/* 1695 */ "Listen on an interface name or address\0"
+/* 1734 */ "INTERFACE\0"
+/* 1744 */ "interface\0"
+/* 1754 */ "path to symmetric keys\0"
+/* 1777 */ "KEYFILE\0"
+/* 1785 */ "keyfile\0"
+/* 1793 */ "path to the log file\0"
+/* 1814 */ "LOGFILE\0"
+/* 1822 */ "logfile\0"
+/* 1830 */ "Do not listen to virtual interfaces\0"
+/* 1866 */ "NOVIRTUALIPS\0"
+/* 1879 */ "novirtualips\0"
+/* 1892 */ "Modify Multimedia Timer (Windows only)\0"
+/* 1931 */ "MODIFYMMTIMER\0"
+/* 1945 */ "modifymmtimer\0"
+/* 1959 */ "Do not fork\0"
+/* 1971 */ "NOFORK\0"
+/* 1978 */ "nofork\0"
+/* 1985 */ "Run at high priority\0"
+/* 2006 */ "NICE\0"
+/* 2011 */ "nice\0"
+/* 2016 */ "path to the PID file\0"
+/* 2037 */ "PIDFILE\0"
+/* 2045 */ "pidfile\0"
+/* 2053 */ "Process priority\0"
+/* 2070 */ "PRIORITY\0"
+/* 2079 */ "priority\0"
+/* 2088 */ "Set the time and quit\0"
+/* 2110 */ "QUIT\0"
+/* 2115 */ "quit\0"
+/* 2120 */ "Broadcast/propagation delay\0"
+/* 2148 */ "PROPAGATIONDELAY\0"
+/* 2165 */ "propagationdelay\0"
+/* 2182 */ "Save parsed configuration and quit\0"
+/* 2217 */ "SAVECONFIGQUIT\0"
+/* 2232 */ "saveconfigquit\0"
+/* 2247 */ "Statistics file location\0"
+/* 2272 */ "STATSDIR\0"
+/* 2281 */ "statsdir\0"
+/* 2290 */ "Trusted key number\0"
+/* 2309 */ "TRUSTEDKEY\0"
+/* 2320 */ "trustedkey\0"
+/* 2331 */ "Run as userid (or userid:groupid)\0"
+/* 2365 */ "USER\0"
+/* 2370 */ "user\0"
+/* 2375 */ "interval in seconds between scans for new or dropped interfaces\0"
+/* 2439 */ "UPDATEINTERVAL\0"
+/* 2454 */ "updateinterval\0"
+/* 2469 */ "make ARG an ntp variable (RW)\0"
+/* 2499 */ "VAR\0"
+/* 2503 */ "var\0"
+/* 2507 */ "make ARG an ntp variable (RW|DEF)\0"
+/* 2541 */ "DVAR\0"
+/* 2546 */ "dvar\0"
+/* 2551 */ "Seconds to wait for first clock sync\0"
+/* 2588 */ "WAIT_SYNC\0"
+/* 2598 */ "wait-sync\0"
+/* 2608 */ "Slew up to 600 seconds\0"
+/* 2631 */ "SLEW\0"
+/* 2636 */ "slew\0"
+/* 2641 */ "Use CPU cycle counter (Windows only)\0"
+/* 2678 */ "USEPCC\0"
+/* 2685 */ "usepcc\0"
+/* 2692 */ "Force CPU cycle counter use (Windows only)\0"
+/* 2735 */ "PCCFREQ\0"
+/* 2743 */ "pccfreq\0"
+/* 2751 */ "Register with mDNS as a NTP server\0"
+/* 2786 */ "MDNS\0"
+/* 2791 */ "mdns\0"
+/* 2796 */ "display extended usage information and exit\0"
+/* 2840 */ "help\0"
+/* 2845 */ "extended usage information passed thru pager\0"
+/* 2890 */ "more-help\0"
+/* 2900 */ "output version information and exit\0"
+/* 2936 */ "version\0"
+/* 2944 */ "NTPD\0"
+/* 2949 */ "ntpd - NTP daemon program - Ver. 4.2.8p2\n"
"Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n"
"\t\t[ <server1> ... <serverN> ]\n\0"
-/* 3012 */ "http://bugs.ntp.org, bugs@ntp.org\0"
-/* 3046 */ "\n\0"
-/* 3048 */ "ntpd 4.2.8p1";
+/* 3080 */ "http://bugs.ntp.org, bugs@ntp.org\0"
+/* 3114 */ "\n\0"
+/* 3116 */ "ntpd 4.2.8p2";
/**
* ipv4 option description with
@@ -349,15 +352,27 @@ static int const aAuthnoreqCantList[] = {
#define PANICGATE_FLAGS (OPTST_DISABLED)
/**
+ * force_step_once option description:
+ */
+/** Descriptive text for the force_step_once option */
+#define FORCE_STEP_ONCE_DESC (ntpd_opt_strs+1517)
+/** Upper-cased name for the force_step_once option */
+#define FORCE_STEP_ONCE_NAME (ntpd_opt_strs+1553)
+/** Name string for the force_step_once option */
+#define FORCE_STEP_ONCE_name (ntpd_opt_strs+1569)
+/** Compiled in flag settings for the force_step_once option */
+#define FORCE_STEP_ONCE_FLAGS (OPTST_DISABLED)
+
+/**
* jaildir option description:
*/
#ifdef HAVE_DROPROOT
/** Descriptive text for the jaildir option */
-#define JAILDIR_DESC (ntpd_opt_strs+1517)
+#define JAILDIR_DESC (ntpd_opt_strs+1585)
/** Upper-cased name for the jaildir option */
-#define JAILDIR_NAME (ntpd_opt_strs+1532)
+#define JAILDIR_NAME (ntpd_opt_strs+1600)
/** Name string for the jaildir option */
-#define JAILDIR_name (ntpd_opt_strs+1540)
+#define JAILDIR_name (ntpd_opt_strs+1608)
/** Compiled in flag settings for the jaildir option */
#define JAILDIR_FLAGS (OPTST_DISABLED \
| OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
@@ -366,19 +381,19 @@ static int const aAuthnoreqCantList[] = {
#define JAILDIR_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
#define JAILDIR_NAME NULL
/** Descriptive text for the jaildir option */
-#define JAILDIR_DESC (ntpd_opt_strs+1548)
-#define JAILDIR_name (ntpd_opt_strs+1540)
+#define JAILDIR_DESC (ntpd_opt_strs+1616)
+#define JAILDIR_name (ntpd_opt_strs+1608)
#endif /* HAVE_DROPROOT */
/**
* interface option description:
*/
/** Descriptive text for the interface option */
-#define INTERFACE_DESC (ntpd_opt_strs+1627)
+#define INTERFACE_DESC (ntpd_opt_strs+1695)
/** Upper-cased name for the interface option */
-#define INTERFACE_NAME (ntpd_opt_strs+1666)
+#define INTERFACE_NAME (ntpd_opt_strs+1734)
/** Name string for the interface option */
-#define INTERFACE_name (ntpd_opt_strs+1676)
+#define INTERFACE_name (ntpd_opt_strs+1744)
/** Compiled in flag settings for the interface option */
#define INTERFACE_FLAGS (OPTST_DISABLED | OPTST_STACKED \
| OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
@@ -387,11 +402,11 @@ static int const aAuthnoreqCantList[] = {
* keyfile option description:
*/
/** Descriptive text for the keyfile option */
-#define KEYFILE_DESC (ntpd_opt_strs+1686)
+#define KEYFILE_DESC (ntpd_opt_strs+1754)
/** Upper-cased name for the keyfile option */
-#define KEYFILE_NAME (ntpd_opt_strs+1709)
+#define KEYFILE_NAME (ntpd_opt_strs+1777)
/** Name string for the keyfile option */
-#define KEYFILE_name (ntpd_opt_strs+1717)
+#define KEYFILE_name (ntpd_opt_strs+1785)
/** Compiled in flag settings for the keyfile option */
#define KEYFILE_FLAGS (OPTST_DISABLED \
| OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
@@ -400,11 +415,11 @@ static int const aAuthnoreqCantList[] = {
* logfile option description:
*/
/** Descriptive text for the logfile option */
-#define LOGFILE_DESC (ntpd_opt_strs+1725)
+#define LOGFILE_DESC (ntpd_opt_strs+1793)
/** Upper-cased name for the logfile option */
-#define LOGFILE_NAME (ntpd_opt_strs+1746)
+#define LOGFILE_NAME (ntpd_opt_strs+1814)
/** Name string for the logfile option */
-#define LOGFILE_name (ntpd_opt_strs+1754)
+#define LOGFILE_name (ntpd_opt_strs+1822)
/** Compiled in flag settings for the logfile option */
#define LOGFILE_FLAGS (OPTST_DISABLED \
| OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
@@ -413,11 +428,11 @@ static int const aAuthnoreqCantList[] = {
* novirtualips option description:
*/
/** Descriptive text for the novirtualips option */
-#define NOVIRTUALIPS_DESC (ntpd_opt_strs+1762)
+#define NOVIRTUALIPS_DESC (ntpd_opt_strs+1830)
/** Upper-cased name for the novirtualips option */
-#define NOVIRTUALIPS_NAME (ntpd_opt_strs+1798)
+#define NOVIRTUALIPS_NAME (ntpd_opt_strs+1866)
/** Name string for the novirtualips option */
-#define NOVIRTUALIPS_name (ntpd_opt_strs+1811)
+#define NOVIRTUALIPS_name (ntpd_opt_strs+1879)
/** Compiled in flag settings for the novirtualips option */
#define NOVIRTUALIPS_FLAGS (OPTST_DISABLED)
@@ -426,11 +441,11 @@ static int const aAuthnoreqCantList[] = {
*/
#ifdef SYS_WINNT
/** Descriptive text for the modifymmtimer option */
-#define MODIFYMMTIMER_DESC (ntpd_opt_strs+1824)
+#define MODIFYMMTIMER_DESC (ntpd_opt_strs+1892)
/** Upper-cased name for the modifymmtimer option */
-#define MODIFYMMTIMER_NAME (ntpd_opt_strs+1863)
+#define MODIFYMMTIMER_NAME (ntpd_opt_strs+1931)
/** Name string for the modifymmtimer option */
-#define MODIFYMMTIMER_name (ntpd_opt_strs+1877)
+#define MODIFYMMTIMER_name (ntpd_opt_strs+1945)
/** Compiled in flag settings for the modifymmtimer option */
#define MODIFYMMTIMER_FLAGS (OPTST_DISABLED)
@@ -446,11 +461,11 @@ static int const aAuthnoreqCantList[] = {
* "Must also have options" and "Incompatible options":
*/
/** Descriptive text for the nofork option */
-#define NOFORK_DESC (ntpd_opt_strs+1891)
+#define NOFORK_DESC (ntpd_opt_strs+1959)
/** Upper-cased name for the nofork option */
-#define NOFORK_NAME (ntpd_opt_strs+1903)
+#define NOFORK_NAME (ntpd_opt_strs+1971)
/** Name string for the nofork option */
-#define NOFORK_name (ntpd_opt_strs+1910)
+#define NOFORK_name (ntpd_opt_strs+1978)
/** Other options that appear in conjunction with the nofork option */
static int const aNoforkCantList[] = {
INDEX_OPT_WAIT_SYNC, NO_EQUIVALENT };
@@ -461,11 +476,11 @@ static int const aNoforkCantList[] = {
* nice option description:
*/
/** Descriptive text for the nice option */
-#define NICE_DESC (ntpd_opt_strs+1917)
+#define NICE_DESC (ntpd_opt_strs+1985)
/** Upper-cased name for the nice option */
-#define NICE_NAME (ntpd_opt_strs+1938)
+#define NICE_NAME (ntpd_opt_strs+2006)
/** Name string for the nice option */
-#define NICE_name (ntpd_opt_strs+1943)
+#define NICE_name (ntpd_opt_strs+2011)
/** Compiled in flag settings for the nice option */
#define NICE_FLAGS (OPTST_DISABLED)
@@ -473,11 +488,11 @@ static int const aNoforkCantList[] = {
* pidfile option description:
*/
/** Descriptive text for the pidfile option */
-#define PIDFILE_DESC (ntpd_opt_strs+1948)
+#define PIDFILE_DESC (ntpd_opt_strs+2016)
/** Upper-cased name for the pidfile option */
-#define PIDFILE_NAME (ntpd_opt_strs+1969)
+#define PIDFILE_NAME (ntpd_opt_strs+2037)
/** Name string for the pidfile option */
-#define PIDFILE_name (ntpd_opt_strs+1977)
+#define PIDFILE_name (ntpd_opt_strs+2045)
/** Compiled in flag settings for the pidfile option */
#define PIDFILE_FLAGS (OPTST_DISABLED \
| OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
@@ -486,11 +501,11 @@ static int const aNoforkCantList[] = {
* priority option description:
*/
/** Descriptive text for the priority option */
-#define PRIORITY_DESC (ntpd_opt_strs+1985)
+#define PRIORITY_DESC (ntpd_opt_strs+2053)
/** Upper-cased name for the priority option */
-#define PRIORITY_NAME (ntpd_opt_strs+2002)
+#define PRIORITY_NAME (ntpd_opt_strs+2070)
/** Name string for the priority option */
-#define PRIORITY_name (ntpd_opt_strs+2011)
+#define PRIORITY_name (ntpd_opt_strs+2079)
/** Compiled in flag settings for the priority option */
#define PRIORITY_FLAGS (OPTST_DISABLED \
| OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
@@ -500,11 +515,11 @@ static int const aNoforkCantList[] = {
* "Must also have options" and "Incompatible options":
*/
/** Descriptive text for the quit option */
-#define QUIT_DESC (ntpd_opt_strs+2020)
+#define QUIT_DESC (ntpd_opt_strs+2088)
/** Upper-cased name for the quit option */
-#define QUIT_NAME (ntpd_opt_strs+2042)
+#define QUIT_NAME (ntpd_opt_strs+2110)
/** Name string for the quit option */
-#define QUIT_name (ntpd_opt_strs+2047)
+#define QUIT_name (ntpd_opt_strs+2115)
/** Other options that appear in conjunction with the quit option */
static int const aQuitCantList[] = {
INDEX_OPT_SAVECONFIGQUIT,
@@ -516,11 +531,11 @@ static int const aQuitCantList[] = {
* propagationdelay option description:
*/
/** Descriptive text for the propagationdelay option */
-#define PROPAGATIONDELAY_DESC (ntpd_opt_strs+2052)
+#define PROPAGATIONDELAY_DESC (ntpd_opt_strs+2120)
/** Upper-cased name for the propagationdelay option */
-#define PROPAGATIONDELAY_NAME (ntpd_opt_strs+2080)
+#define PROPAGATIONDELAY_NAME (ntpd_opt_strs+2148)
/** Name string for the propagationdelay option */
-#define PROPAGATIONDELAY_name (ntpd_opt_strs+2097)
+#define PROPAGATIONDELAY_name (ntpd_opt_strs+2165)
/** Compiled in flag settings for the propagationdelay option */
#define PROPAGATIONDELAY_FLAGS (OPTST_DISABLED \
| OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
@@ -531,11 +546,11 @@ static int const aQuitCantList[] = {
*/
#ifdef SAVECONFIG
/** Descriptive text for the saveconfigquit option */
-#define SAVECONFIGQUIT_DESC (ntpd_opt_strs+2114)
+#define SAVECONFIGQUIT_DESC (ntpd_opt_strs+2182)
/** Upper-cased name for the saveconfigquit option */
-#define SAVECONFIGQUIT_NAME (ntpd_opt_strs+2149)
+#define SAVECONFIGQUIT_NAME (ntpd_opt_strs+2217)
/** Name string for the saveconfigquit option */
-#define SAVECONFIGQUIT_name (ntpd_opt_strs+2164)
+#define SAVECONFIGQUIT_name (ntpd_opt_strs+2232)
/** Other options that appear in conjunction with the saveconfigquit option */
static int const aSaveconfigquitCantList[] = {
INDEX_OPT_QUIT,
@@ -556,11 +571,11 @@ static int const aSaveconfigquitCantList[] = {
* statsdir option description:
*/
/** Descriptive text for the statsdir option */
-#define STATSDIR_DESC (ntpd_opt_strs+2179)
+#define STATSDIR_DESC (ntpd_opt_strs+2247)
/** Upper-cased name for the statsdir option */
-#define STATSDIR_NAME (ntpd_opt_strs+2204)
+#define STATSDIR_NAME (ntpd_opt_strs+2272)
/** Name string for the statsdir option */
-#define STATSDIR_name (ntpd_opt_strs+2213)
+#define STATSDIR_name (ntpd_opt_strs+2281)
/** Compiled in flag settings for the statsdir option */
#define STATSDIR_FLAGS (OPTST_DISABLED \
| OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
@@ -569,11 +584,11 @@ static int const aSaveconfigquitCantList[] = {
* trustedkey option description:
*/
/** Descriptive text for the trustedkey option */
-#define TRUSTEDKEY_DESC (ntpd_opt_strs+2222)
+#define TRUSTEDKEY_DESC (ntpd_opt_strs+2290)
/** Upper-cased name for the trustedkey option */
-#define TRUSTEDKEY_NAME (ntpd_opt_strs+2241)
+#define TRUSTEDKEY_NAME (ntpd_opt_strs+2309)
/** Name string for the trustedkey option */
-#define TRUSTEDKEY_name (ntpd_opt_strs+2252)
+#define TRUSTEDKEY_name (ntpd_opt_strs+2320)
/** Compiled in flag settings for the trustedkey option */
#define TRUSTEDKEY_FLAGS (OPTST_DISABLED | OPTST_STACKED \
| OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
@@ -583,11 +598,11 @@ static int const aSaveconfigquitCantList[] = {
*/
#ifdef HAVE_DROPROOT
/** Descriptive text for the user option */
-#define USER_DESC (ntpd_opt_strs+2263)
+#define USER_DESC (ntpd_opt_strs+2331)
/** Upper-cased name for the user option */
-#define USER_NAME (ntpd_opt_strs+2297)
+#define USER_NAME (ntpd_opt_strs+2365)
/** Name string for the user option */
-#define USER_name (ntpd_opt_strs+2302)
+#define USER_name (ntpd_opt_strs+2370)
/** Compiled in flag settings for the user option */
#define USER_FLAGS (OPTST_DISABLED \
| OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
@@ -596,19 +611,19 @@ static int const aSaveconfigquitCantList[] = {
#define USER_FLAGS (OPTST_OMITTED | OPTST_NO_INIT)
#define USER_NAME NULL
/** Descriptive text for the user option */
-#define USER_DESC (ntpd_opt_strs+1548)
-#define USER_name (ntpd_opt_strs+2302)
+#define USER_DESC (ntpd_opt_strs+1616)
+#define USER_name (ntpd_opt_strs+2370)
#endif /* HAVE_DROPROOT */
/**
* updateinterval option description:
*/
/** Descriptive text for the updateinterval option */
-#define UPDATEINTERVAL_DESC (ntpd_opt_strs+2307)
+#define UPDATEINTERVAL_DESC (ntpd_opt_strs+2375)
/** Upper-cased name for the updateinterval option */
-#define UPDATEINTERVAL_NAME (ntpd_opt_strs+2371)
+#define UPDATEINTERVAL_NAME (ntpd_opt_strs+2439)
/** Name string for the updateinterval option */
-#define UPDATEINTERVAL_name (ntpd_opt_strs+2386)
+#define UPDATEINTERVAL_name (ntpd_opt_strs+2454)
/** Compiled in flag settings for the updateinterval option */
#define UPDATEINTERVAL_FLAGS (OPTST_DISABLED \
| OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
@@ -617,11 +632,11 @@ static int const aSaveconfigquitCantList[] = {
* var option description:
*/
/** Descriptive text for the var option */
-#define VAR_DESC (ntpd_opt_strs+2401)
+#define VAR_DESC (ntpd_opt_strs+2469)
/** Upper-cased name for the var option */
-#define VAR_NAME (ntpd_opt_strs+2431)
+#define VAR_NAME (ntpd_opt_strs+2499)
/** Name string for the var option */
-#define VAR_name (ntpd_opt_strs+2435)
+#define VAR_name (ntpd_opt_strs+2503)
/** Compiled in flag settings for the var option */
#define VAR_FLAGS (OPTST_DISABLED | OPTST_STACKED \
| OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
@@ -630,11 +645,11 @@ static int const aSaveconfigquitCantList[] = {
* dvar option description:
*/
/** Descriptive text for the dvar option */
-#define DVAR_DESC (ntpd_opt_strs+2439)
+#define DVAR_DESC (ntpd_opt_strs+2507)
/** Upper-cased name for the dvar option */
-#define DVAR_NAME (ntpd_opt_strs+2473)
+#define DVAR_NAME (ntpd_opt_strs+2541)
/** Name string for the dvar option */
-#define DVAR_name (ntpd_opt_strs+2478)
+#define DVAR_name (ntpd_opt_strs+2546)
/** Compiled in flag settings for the dvar option */
#define DVAR_FLAGS (OPTST_DISABLED | OPTST_STACKED \
| OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
@@ -645,11 +660,11 @@ static int const aSaveconfigquitCantList[] = {
*/
#ifdef HAVE_WORKING_FORK
/** Descriptive text for the wait-sync option */
-#define WAIT_SYNC_DESC (ntpd_opt_strs+2483)
+#define WAIT_SYNC_DESC (ntpd_opt_strs+2551)
/** Upper-cased name for the wait-sync option */
-#define WAIT_SYNC_NAME (ntpd_opt_strs+2520)
+#define WAIT_SYNC_NAME (ntpd_opt_strs+2588)
/** Name string for the wait-sync option */
-#define WAIT_SYNC_name (ntpd_opt_strs+2530)
+#define WAIT_SYNC_name (ntpd_opt_strs+2598)
/** Other options that appear in conjunction with the wait-sync option */
static int const aWait_SyncCantList[] = {
INDEX_OPT_NOFORK,
@@ -671,11 +686,11 @@ static int const aWait_SyncCantList[] = {
* slew option description:
*/
/** Descriptive text for the slew option */
-#define SLEW_DESC (ntpd_opt_strs+2540)
+#define SLEW_DESC (ntpd_opt_strs+2608)
/** Upper-cased name for the slew option */
-#define SLEW_NAME (ntpd_opt_strs+2563)
+#define SLEW_NAME (ntpd_opt_strs+2631)
/** Name string for the slew option */
-#define SLEW_name (ntpd_opt_strs+2568)
+#define SLEW_name (ntpd_opt_strs+2636)
/** Compiled in flag settings for the slew option */
#define SLEW_FLAGS (OPTST_DISABLED)
@@ -684,11 +699,11 @@ static int const aWait_SyncCantList[] = {
*/
#ifdef SYS_WINNT
/** Descriptive text for the usepcc option */
-#define USEPCC_DESC (ntpd_opt_strs+2573)
+#define USEPCC_DESC (ntpd_opt_strs+2641)
/** Upper-cased name for the usepcc option */
-#define USEPCC_NAME (ntpd_opt_strs+2610)
+#define USEPCC_NAME (ntpd_opt_strs+2678)
/** Name string for the usepcc option */
-#define USEPCC_name (ntpd_opt_strs+2617)
+#define USEPCC_name (ntpd_opt_strs+2685)
/** Compiled in flag settings for the usepcc option */
#define USEPCC_FLAGS (OPTST_DISABLED)
@@ -704,11 +719,11 @@ static int const aWait_SyncCantList[] = {
*/
#ifdef SYS_WINNT
/** Descriptive text for the pccfreq option */
-#define PCCFREQ_DESC (ntpd_opt_strs+2624)
+#define PCCFREQ_DESC (ntpd_opt_strs+2692)
/** Upper-cased name for the pccfreq option */
-#define PCCFREQ_NAME (ntpd_opt_strs+2667)
+#define PCCFREQ_NAME (ntpd_opt_strs+2735)
/** Name string for the pccfreq option */
-#define PCCFREQ_name (ntpd_opt_strs+2675)
+#define PCCFREQ_name (ntpd_opt_strs+2743)
/** Compiled in flag settings for the pccfreq option */
#define PCCFREQ_FLAGS (OPTST_DISABLED \
| OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
@@ -725,11 +740,11 @@ static int const aWait_SyncCantList[] = {
*/
#ifdef HAVE_DNSREGISTRATION
/** Descriptive text for the mdns option */
-#define MDNS_DESC (ntpd_opt_strs+2683)
+#define MDNS_DESC (ntpd_opt_strs+2751)
/** Upper-cased name for the mdns option */
-#define MDNS_NAME (ntpd_opt_strs+2718)
+#define MDNS_NAME (ntpd_opt_strs+2786)
/** Name string for the mdns option */
-#define MDNS_name (ntpd_opt_strs+2723)
+#define MDNS_name (ntpd_opt_strs+2791)
/** Compiled in flag settings for the mdns option */
#define MDNS_FLAGS (OPTST_DISABLED)
@@ -743,11 +758,11 @@ static int const aWait_SyncCantList[] = {
/*
* Help/More_Help/Version option descriptions:
*/
-#define HELP_DESC (ntpd_opt_strs+2728)
-#define HELP_name (ntpd_opt_strs+2772)
+#define HELP_DESC (ntpd_opt_strs+2796)
+#define HELP_name (ntpd_opt_strs+2840)
#ifdef HAVE_WORKING_FORK
-#define MORE_HELP_DESC (ntpd_opt_strs+2777)
-#define MORE_HELP_name (ntpd_opt_strs+2822)
+#define MORE_HELP_DESC (ntpd_opt_strs+2845)
+#define MORE_HELP_name (ntpd_opt_strs+2890)
#define MORE_HELP_FLAGS (OPTST_IMM | OPTST_NO_INIT)
#else
#define MORE_HELP_DESC HELP_DESC
@@ -760,8 +775,8 @@ static int const aWait_SyncCantList[] = {
# define VER_FLAGS (OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT)
#endif
-#define VER_DESC (ntpd_opt_strs+2832)
-#define VER_name (ntpd_opt_strs+2868)
+#define VER_DESC (ntpd_opt_strs+2900)
+#define VER_name (ntpd_opt_strs+2936)
/**
* Declare option callback procedures
*/
@@ -901,8 +916,20 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ PANICGATE_DESC, PANICGATE_NAME, PANICGATE_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 10, VALUE_OPT_JAILDIR,
- /* equiv idx, value */ 10, VALUE_OPT_JAILDIR,
+ { /* entry idx, value */ 10, VALUE_OPT_FORCE_STEP_ONCE,
+ /* equiv idx, value */ 10, VALUE_OPT_FORCE_STEP_ONCE,
+ /* equivalenced to */ NO_EQUIVALENT,
+ /* min, max, act ct */ 0, 1, 0,
+ /* opt state flags */ FORCE_STEP_ONCE_FLAGS, 0,
+ /* last opt argumnt */ { NULL }, /* --force_step_once */
+ /* arg list/cookie */ NULL,
+ /* must/cannot opts */ NULL, NULL,
+ /* option proc */ NULL,
+ /* desc, NAME, name */ FORCE_STEP_ONCE_DESC, FORCE_STEP_ONCE_NAME, FORCE_STEP_ONCE_name,
+ /* disablement strs */ NULL, NULL },
+
+ { /* entry idx, value */ 11, VALUE_OPT_JAILDIR,
+ /* equiv idx, value */ 11, VALUE_OPT_JAILDIR,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ JAILDIR_FLAGS, 0,
@@ -913,8 +940,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ JAILDIR_DESC, JAILDIR_NAME, JAILDIR_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 11, VALUE_OPT_INTERFACE,
- /* equiv idx, value */ 11, VALUE_OPT_INTERFACE,
+ { /* entry idx, value */ 12, VALUE_OPT_INTERFACE,
+ /* equiv idx, value */ 12, VALUE_OPT_INTERFACE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, NOLIMIT, 0,
/* opt state flags */ INTERFACE_FLAGS, 0,
@@ -925,8 +952,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ INTERFACE_DESC, INTERFACE_NAME, INTERFACE_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 12, VALUE_OPT_KEYFILE,
- /* equiv idx, value */ 12, VALUE_OPT_KEYFILE,
+ { /* entry idx, value */ 13, VALUE_OPT_KEYFILE,
+ /* equiv idx, value */ 13, VALUE_OPT_KEYFILE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ KEYFILE_FLAGS, 0,
@@ -937,8 +964,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ KEYFILE_DESC, KEYFILE_NAME, KEYFILE_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 13, VALUE_OPT_LOGFILE,
- /* equiv idx, value */ 13, VALUE_OPT_LOGFILE,
+ { /* entry idx, value */ 14, VALUE_OPT_LOGFILE,
+ /* equiv idx, value */ 14, VALUE_OPT_LOGFILE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ LOGFILE_FLAGS, 0,
@@ -949,8 +976,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ LOGFILE_DESC, LOGFILE_NAME, LOGFILE_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 14, VALUE_OPT_NOVIRTUALIPS,
- /* equiv idx, value */ 14, VALUE_OPT_NOVIRTUALIPS,
+ { /* entry idx, value */ 15, VALUE_OPT_NOVIRTUALIPS,
+ /* equiv idx, value */ 15, VALUE_OPT_NOVIRTUALIPS,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ NOVIRTUALIPS_FLAGS, 0,
@@ -961,8 +988,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ NOVIRTUALIPS_DESC, NOVIRTUALIPS_NAME, NOVIRTUALIPS_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 15, VALUE_OPT_MODIFYMMTIMER,
- /* equiv idx, value */ 15, VALUE_OPT_MODIFYMMTIMER,
+ { /* entry idx, value */ 16, VALUE_OPT_MODIFYMMTIMER,
+ /* equiv idx, value */ 16, VALUE_OPT_MODIFYMMTIMER,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ MODIFYMMTIMER_FLAGS, 0,
@@ -973,8 +1000,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ MODIFYMMTIMER_DESC, MODIFYMMTIMER_NAME, MODIFYMMTIMER_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 16, VALUE_OPT_NOFORK,
- /* equiv idx, value */ 16, VALUE_OPT_NOFORK,
+ { /* entry idx, value */ 17, VALUE_OPT_NOFORK,
+ /* equiv idx, value */ 17, VALUE_OPT_NOFORK,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ NOFORK_FLAGS, 0,
@@ -985,8 +1012,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ NOFORK_DESC, NOFORK_NAME, NOFORK_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 17, VALUE_OPT_NICE,
- /* equiv idx, value */ 17, VALUE_OPT_NICE,
+ { /* entry idx, value */ 18, VALUE_OPT_NICE,
+ /* equiv idx, value */ 18, VALUE_OPT_NICE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ NICE_FLAGS, 0,
@@ -997,8 +1024,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ NICE_DESC, NICE_NAME, NICE_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 18, VALUE_OPT_PIDFILE,
- /* equiv idx, value */ 18, VALUE_OPT_PIDFILE,
+ { /* entry idx, value */ 19, VALUE_OPT_PIDFILE,
+ /* equiv idx, value */ 19, VALUE_OPT_PIDFILE,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ PIDFILE_FLAGS, 0,
@@ -1009,8 +1036,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ PIDFILE_DESC, PIDFILE_NAME, PIDFILE_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 19, VALUE_OPT_PRIORITY,
- /* equiv idx, value */ 19, VALUE_OPT_PRIORITY,
+ { /* entry idx, value */ 20, VALUE_OPT_PRIORITY,
+ /* equiv idx, value */ 20, VALUE_OPT_PRIORITY,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ PRIORITY_FLAGS, 0,
@@ -1021,8 +1048,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ PRIORITY_DESC, PRIORITY_NAME, PRIORITY_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 20, VALUE_OPT_QUIT,
- /* equiv idx, value */ 20, VALUE_OPT_QUIT,
+ { /* entry idx, value */ 21, VALUE_OPT_QUIT,
+ /* equiv idx, value */ 21, VALUE_OPT_QUIT,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ QUIT_FLAGS, 0,
@@ -1033,8 +1060,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ QUIT_DESC, QUIT_NAME, QUIT_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 21, VALUE_OPT_PROPAGATIONDELAY,
- /* equiv idx, value */ 21, VALUE_OPT_PROPAGATIONDELAY,
+ { /* entry idx, value */ 22, VALUE_OPT_PROPAGATIONDELAY,
+ /* equiv idx, value */ 22, VALUE_OPT_PROPAGATIONDELAY,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ PROPAGATIONDELAY_FLAGS, 0,
@@ -1045,8 +1072,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ PROPAGATIONDELAY_DESC, PROPAGATIONDELAY_NAME, PROPAGATIONDELAY_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 22, VALUE_OPT_SAVECONFIGQUIT,
- /* equiv idx, value */ 22, VALUE_OPT_SAVECONFIGQUIT,
+ { /* entry idx, value */ 23, VALUE_OPT_SAVECONFIGQUIT,
+ /* equiv idx, value */ 23, VALUE_OPT_SAVECONFIGQUIT,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ SAVECONFIGQUIT_FLAGS, 0,
@@ -1057,8 +1084,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ SAVECONFIGQUIT_DESC, SAVECONFIGQUIT_NAME, SAVECONFIGQUIT_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 23, VALUE_OPT_STATSDIR,
- /* equiv idx, value */ 23, VALUE_OPT_STATSDIR,
+ { /* entry idx, value */ 24, VALUE_OPT_STATSDIR,
+ /* equiv idx, value */ 24, VALUE_OPT_STATSDIR,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ STATSDIR_FLAGS, 0,
@@ -1069,8 +1096,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ STATSDIR_DESC, STATSDIR_NAME, STATSDIR_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 24, VALUE_OPT_TRUSTEDKEY,
- /* equiv idx, value */ 24, VALUE_OPT_TRUSTEDKEY,
+ { /* entry idx, value */ 25, VALUE_OPT_TRUSTEDKEY,
+ /* equiv idx, value */ 25, VALUE_OPT_TRUSTEDKEY,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, NOLIMIT, 0,
/* opt state flags */ TRUSTEDKEY_FLAGS, 0,
@@ -1081,8 +1108,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ TRUSTEDKEY_DESC, TRUSTEDKEY_NAME, TRUSTEDKEY_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 25, VALUE_OPT_USER,
- /* equiv idx, value */ 25, VALUE_OPT_USER,
+ { /* entry idx, value */ 26, VALUE_OPT_USER,
+ /* equiv idx, value */ 26, VALUE_OPT_USER,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ USER_FLAGS, 0,
@@ -1093,8 +1120,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ USER_DESC, USER_NAME, USER_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 26, VALUE_OPT_UPDATEINTERVAL,
- /* equiv idx, value */ 26, VALUE_OPT_UPDATEINTERVAL,
+ { /* entry idx, value */ 27, VALUE_OPT_UPDATEINTERVAL,
+ /* equiv idx, value */ 27, VALUE_OPT_UPDATEINTERVAL,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ UPDATEINTERVAL_FLAGS, 0,
@@ -1105,8 +1132,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ UPDATEINTERVAL_DESC, UPDATEINTERVAL_NAME, UPDATEINTERVAL_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 27, VALUE_OPT_VAR,
- /* equiv idx, value */ 27, VALUE_OPT_VAR,
+ { /* entry idx, value */ 28, VALUE_OPT_VAR,
+ /* equiv idx, value */ 28, VALUE_OPT_VAR,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, NOLIMIT, 0,
/* opt state flags */ VAR_FLAGS, 0,
@@ -1117,8 +1144,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ VAR_DESC, VAR_NAME, VAR_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 28, VALUE_OPT_DVAR,
- /* equiv idx, value */ 28, VALUE_OPT_DVAR,
+ { /* entry idx, value */ 29, VALUE_OPT_DVAR,
+ /* equiv idx, value */ 29, VALUE_OPT_DVAR,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, NOLIMIT, 0,
/* opt state flags */ DVAR_FLAGS, 0,
@@ -1129,8 +1156,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ DVAR_DESC, DVAR_NAME, DVAR_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 29, VALUE_OPT_WAIT_SYNC,
- /* equiv idx, value */ 29, VALUE_OPT_WAIT_SYNC,
+ { /* entry idx, value */ 30, VALUE_OPT_WAIT_SYNC,
+ /* equiv idx, value */ 30, VALUE_OPT_WAIT_SYNC,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ WAIT_SYNC_FLAGS, 0,
@@ -1141,8 +1168,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ WAIT_SYNC_DESC, WAIT_SYNC_NAME, WAIT_SYNC_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 30, VALUE_OPT_SLEW,
- /* equiv idx, value */ 30, VALUE_OPT_SLEW,
+ { /* entry idx, value */ 31, VALUE_OPT_SLEW,
+ /* equiv idx, value */ 31, VALUE_OPT_SLEW,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ SLEW_FLAGS, 0,
@@ -1153,8 +1180,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ SLEW_DESC, SLEW_NAME, SLEW_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 31, VALUE_OPT_USEPCC,
- /* equiv idx, value */ 31, VALUE_OPT_USEPCC,
+ { /* entry idx, value */ 32, VALUE_OPT_USEPCC,
+ /* equiv idx, value */ 32, VALUE_OPT_USEPCC,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ USEPCC_FLAGS, 0,
@@ -1165,8 +1192,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ USEPCC_DESC, USEPCC_NAME, USEPCC_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 32, VALUE_OPT_PCCFREQ,
- /* equiv idx, value */ 32, VALUE_OPT_PCCFREQ,
+ { /* entry idx, value */ 33, VALUE_OPT_PCCFREQ,
+ /* equiv idx, value */ 33, VALUE_OPT_PCCFREQ,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ PCCFREQ_FLAGS, 0,
@@ -1177,8 +1204,8 @@ static tOptDesc optDesc[OPTION_CT] = {
/* desc, NAME, name */ PCCFREQ_DESC, PCCFREQ_NAME, PCCFREQ_name,
/* disablement strs */ NULL, NULL },
- { /* entry idx, value */ 33, VALUE_OPT_MDNS,
- /* equiv idx, value */ 33, VALUE_OPT_MDNS,
+ { /* entry idx, value */ 34, VALUE_OPT_MDNS,
+ /* equiv idx, value */ 34, VALUE_OPT_MDNS,
/* equivalenced to */ NO_EQUIVALENT,
/* min, max, act ct */ 0, 1, 0,
/* opt state flags */ MDNS_FLAGS, 0,
@@ -1231,21 +1258,21 @@ static tOptDesc optDesc[OPTION_CT] = {
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/** Reference to the upper cased version of ntpd. */
-#define zPROGNAME (ntpd_opt_strs+2876)
+#define zPROGNAME (ntpd_opt_strs+2944)
/** Reference to the title line for ntpd usage. */
-#define zUsageTitle (ntpd_opt_strs+2881)
+#define zUsageTitle (ntpd_opt_strs+2949)
/** There is no ntpd configuration file. */
#define zRcName NULL
/** There are no directories to search for ntpd config files. */
#define apzHomeList NULL
/** The ntpd program bug email address. */
-#define zBugsAddr (ntpd_opt_strs+3012)
+#define zBugsAddr (ntpd_opt_strs+3080)
/** Clarification/explanation of what ntpd does. */
-#define zExplain (ntpd_opt_strs+3046)
+#define zExplain (ntpd_opt_strs+3114)
/** Extra detail explaining what ntpd does. */
#define zDetail (NULL)
/** The full version string for ntpd. */
-#define zFullVersion (ntpd_opt_strs+3048)
+#define zFullVersion (ntpd_opt_strs+3116)
/* extracted from optcode.tlib near line 364 */
#if defined(ENABLE_NLS)
@@ -1367,7 +1394,7 @@ tOptions ntpdOptions = {
NO_EQUIVALENT, /* '-#' option index */
NO_EQUIVALENT /* index of default opt */
},
- 37 /* full option count */, 34 /* user option count */,
+ 38 /* full option count */, 35 /* user option count */,
ntpd_full_usage, ntpd_short_usage,
NULL, NULL,
PKGDATADIR, ntpd_packager_info
@@ -1502,7 +1529,7 @@ static void bogus_function(void) {
translate option names.
*/
/* referenced via ntpdOptions.pzCopyright */
- puts(_("ntpd 4.2.8p1\n\
+ puts(_("ntpd 4.2.8p2\n\
Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n\
This is free software. It is licensed for use, modification and\n\
redistribution under the terms of the NTP License, copies of which\n\
@@ -1553,6 +1580,9 @@ implied warranty.\n"));
puts(_("Allow the first adjustment to be Big"));
/* referenced via ntpdOptions.pOptDesc->pzText */
+ puts(_("Step any initial offset correction."));
+
+ /* referenced via ntpdOptions.pOptDesc->pzText */
puts(_("Jail directory"));
/* referenced via ntpdOptions.pOptDesc->pzText */
@@ -1640,7 +1670,7 @@ implied warranty.\n"));
puts(_("output version information and exit"));
/* referenced via ntpdOptions.pzUsageTitle */
- puts(_("ntpd - NTP daemon program - Ver. 4.2.8p1\n\
+ puts(_("ntpd - NTP daemon program - Ver. 4.2.8p2\n\
Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
\t\t[ <server1> ... <serverN> ]\n"));
@@ -1648,7 +1678,7 @@ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
puts(_("\n"));
/* referenced via ntpdOptions.pzFullVersion */
- puts(_("ntpd 4.2.8p1"));
+ puts(_("ntpd 4.2.8p2"));
/* referenced via ntpdOptions.pzFullUsage */
puts(_("<<<NOT-FOUND>>>"));
diff --git a/contrib/ntp/ntpd/ntpd-opts.h b/contrib/ntp/ntpd/ntpd-opts.h
index f4eb47b..682aebd 100644
--- a/contrib/ntp/ntpd/ntpd-opts.h
+++ b/contrib/ntp/ntpd/ntpd-opts.h
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (ntpd-opts.h)
*
- * It has been AutoGen-ed February 4, 2015 at 02:39:16 AM by AutoGen 5.18.5pre4
+ * It has been AutoGen-ed April 7, 2015 at 04:23:13 AM by AutoGen 5.18.5pre4
* From the definitions ntpd-opts.def
* and the template file options
*
@@ -74,40 +74,41 @@ typedef enum {
INDEX_OPT_SET_DEBUG_LEVEL = 7,
INDEX_OPT_DRIFTFILE = 8,
INDEX_OPT_PANICGATE = 9,
- INDEX_OPT_JAILDIR = 10,
- INDEX_OPT_INTERFACE = 11,
- INDEX_OPT_KEYFILE = 12,
- INDEX_OPT_LOGFILE = 13,
- INDEX_OPT_NOVIRTUALIPS = 14,
- INDEX_OPT_MODIFYMMTIMER = 15,
- INDEX_OPT_NOFORK = 16,
- INDEX_OPT_NICE = 17,
- INDEX_OPT_PIDFILE = 18,
- INDEX_OPT_PRIORITY = 19,
- INDEX_OPT_QUIT = 20,
- INDEX_OPT_PROPAGATIONDELAY = 21,
- INDEX_OPT_SAVECONFIGQUIT = 22,
- INDEX_OPT_STATSDIR = 23,
- INDEX_OPT_TRUSTEDKEY = 24,
- INDEX_OPT_USER = 25,
- INDEX_OPT_UPDATEINTERVAL = 26,
- INDEX_OPT_VAR = 27,
- INDEX_OPT_DVAR = 28,
- INDEX_OPT_WAIT_SYNC = 29,
- INDEX_OPT_SLEW = 30,
- INDEX_OPT_USEPCC = 31,
- INDEX_OPT_PCCFREQ = 32,
- INDEX_OPT_MDNS = 33,
- INDEX_OPT_VERSION = 34,
- INDEX_OPT_HELP = 35,
- INDEX_OPT_MORE_HELP = 36
+ INDEX_OPT_FORCE_STEP_ONCE = 10,
+ INDEX_OPT_JAILDIR = 11,
+ INDEX_OPT_INTERFACE = 12,
+ INDEX_OPT_KEYFILE = 13,
+ INDEX_OPT_LOGFILE = 14,
+ INDEX_OPT_NOVIRTUALIPS = 15,
+ INDEX_OPT_MODIFYMMTIMER = 16,
+ INDEX_OPT_NOFORK = 17,
+ INDEX_OPT_NICE = 18,
+ INDEX_OPT_PIDFILE = 19,
+ INDEX_OPT_PRIORITY = 20,
+ INDEX_OPT_QUIT = 21,
+ INDEX_OPT_PROPAGATIONDELAY = 22,
+ INDEX_OPT_SAVECONFIGQUIT = 23,
+ INDEX_OPT_STATSDIR = 24,
+ INDEX_OPT_TRUSTEDKEY = 25,
+ INDEX_OPT_USER = 26,
+ INDEX_OPT_UPDATEINTERVAL = 27,
+ INDEX_OPT_VAR = 28,
+ INDEX_OPT_DVAR = 29,
+ INDEX_OPT_WAIT_SYNC = 30,
+ INDEX_OPT_SLEW = 31,
+ INDEX_OPT_USEPCC = 32,
+ INDEX_OPT_PCCFREQ = 33,
+ INDEX_OPT_MDNS = 34,
+ INDEX_OPT_VERSION = 35,
+ INDEX_OPT_HELP = 36,
+ INDEX_OPT_MORE_HELP = 37
} teOptIndex;
/** count of all options for ntpd */
-#define OPTION_CT 37
+#define OPTION_CT 38
/** ntpd version */
-#define NTPD_VERSION "4.2.8p1"
+#define NTPD_VERSION "4.2.8p2"
/** Full ntpd version text */
-#define NTPD_FULL_VERSION "ntpd 4.2.8p1"
+#define NTPD_FULL_VERSION "ntpd 4.2.8p2"
/**
* Interface defines for all options. Replace "n" with the UPPER_CASED
@@ -199,6 +200,10 @@ typedef enum {
# warning undefining PANICGATE due to option name conflict
# undef PANICGATE
# endif
+# ifdef FORCE_STEP_ONCE
+# warning undefining FORCE_STEP_ONCE due to option name conflict
+# undef FORCE_STEP_ONCE
+# endif
# ifdef JAILDIR
# warning undefining JAILDIR due to option name conflict
# undef JAILDIR
@@ -306,6 +311,7 @@ typedef enum {
# undef SET_DEBUG_LEVEL
# undef DRIFTFILE
# undef PANICGATE
+# undef FORCE_STEP_ONCE
# undef JAILDIR
# undef INTERFACE
# undef KEYFILE
@@ -348,6 +354,7 @@ typedef enum {
#define OPT_VALUE_SET_DEBUG_LEVEL (DESC(SET_DEBUG_LEVEL).optArg.argInt)
#define VALUE_OPT_DRIFTFILE 'f'
#define VALUE_OPT_PANICGATE 'g'
+#define VALUE_OPT_FORCE_STEP_ONCE 'G'
#define VALUE_OPT_JAILDIR 'i'
#define VALUE_OPT_INTERFACE 'I'
#define VALUE_OPT_KEYFILE 'k'
diff --git a/contrib/ntp/ntpd/ntpd.1ntpdman b/contrib/ntp/ntpd/ntpd.1ntpdman
index 4b37913..5ded89b 100644
--- a/contrib/ntp/ntpd/ntpd.1ntpdman
+++ b/contrib/ntp/ntpd/ntpd.1ntpdman
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntpd 1ntpdman "04 Feb 2015" "4.2.8p1" "User Commands"
+.TH ntpd 1ntpdman "07 Apr 2015" "4.2.8p2" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-YYaqWo/ag-.YaiVo)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-TQays3/ag-5Qaqr3)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:41:54 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:25:45 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpd-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
@@ -175,7 +175,7 @@ The name and path of the frequency file,
by default.
This is the same operation as the
\fBdriftfile\fP \fIdriftfile\fP
-configuration specification in the
+configuration specification in the
\fI/etc/ntp.conf\fP
file.
.TP
@@ -196,6 +196,20 @@ See the
\fBtinker\fP
configuration file directive for other options.
.TP
+.NOP \f\*[B-Font]\-G\f[], \f\*[B-Font]\-\-force\-step\-once\f[]
+Step any initial offset correction..
+.sp
+Normally,
+\fBntpd\fP
+steps the time if the time offset exceeds the step threshold,
+which is 128 ms by default, and otherwise slews the time.
+This option forces the initial offset correction to be stepped,
+so the highest time accuracy can be achieved quickly.
+However, this may also cause the time to be stepped back
+so this option must not be used if
+applications requiring monotonic time are running.
+See the \fBtinker\fP configuration file directive for other options.
+.TP
.NOP \f\*[B-Font]\-i\f[] \f\*[I-Font]string\f[], \f\*[B-Font]\-\-jaildir\f[]=\f\*[I-Font]string\f[]
Jail directory.
.sp
@@ -220,7 +234,7 @@ Open the network address given, or all the addresses associated with the
given interface name. This option may appear multiple times. This option
also implies not opening other addresses, except wildcard and localhost.
This option is deprecated. Please consider using the configuration file
-\fBinterface\fP command, which is more versatile.
+\fBinterface\fP command, which is more versatile.
.TP
.NOP \f\*[B-Font]\-k\f[] \f\*[I-Font]string\f[], \f\*[B-Font]\-\-keyfile\f[]=\f\*[I-Font]string\f[]
path to symmetric keys.
diff --git a/contrib/ntp/ntpd/ntpd.1ntpdmdoc b/contrib/ntp/ntpd/ntpd.1ntpdmdoc
index 96d77e9..14b38e4 100644
--- a/contrib/ntp/ntpd/ntpd.1ntpdmdoc
+++ b/contrib/ntp/ntpd/ntpd.1ntpdmdoc
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTPD 1ntpdmdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpd-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:42:12 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:26:02 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpd-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
@@ -144,7 +144,7 @@ The name and path of the frequency file,
by default.
This is the same operation as the
\fBdriftfile\fP \fIdriftfile\fP
-configuration specification in the
+configuration specification in the
\fI/etc/ntp.conf\fP
file.
.It Fl g , Fl \-panicgate
@@ -163,6 +163,19 @@ options.
See the
\fBtinker\fP
configuration file directive for other options.
+.It Fl G , Fl \-force\-step\-once
+Step any initial offset correction..
+.sp
+Normally,
+\fBntpd\fP
+steps the time if the time offset exceeds the step threshold,
+which is 128 ms by default, and otherwise slews the time.
+This option forces the initial offset correction to be stepped,
+so the highest time accuracy can be achieved quickly.
+However, this may also cause the time to be stepped back
+so this option must not be used if
+applications requiring monotonic time are running.
+See the \fBtinker\fP configuration file directive for other options.
.It Fl i Ar string , Fl \-jaildir Ns = Ns Ar string
Jail directory.
.sp
@@ -186,7 +199,7 @@ Open the network address given, or all the addresses associated with the
given interface name. This option may appear multiple times. This option
also implies not opening other addresses, except wildcard and localhost.
This option is deprecated. Please consider using the configuration file
-\fBinterface\fP command, which is more versatile.
+\fBinterface\fP command, which is more versatile.
.It Fl k Ar string , Fl \-keyfile Ns = Ns Ar string
path to symmetric keys.
.sp
diff --git a/contrib/ntp/ntpd/ntpd.c b/contrib/ntp/ntpd/ntpd.c
index c017ef3..529e6ce 100644
--- a/contrib/ntp/ntpd/ntpd.c
+++ b/contrib/ntp/ntpd/ntpd.c
@@ -1262,6 +1262,7 @@ finish(
if (mdns != NULL)
DNSServiceRefDeallocate(mdns);
# endif
+ peer_cleanup();
exit(0);
}
#endif /* !SIM && SIGDIE1 */
diff --git a/contrib/ntp/ntpd/ntpd.html b/contrib/ntp/ntpd/ntpd.html
index fe00030..8919ee9 100644
--- a/contrib/ntp/ntpd/ntpd.html
+++ b/contrib/ntp/ntpd/ntpd.html
@@ -39,7 +39,7 @@ The program can operate in any of several modes, including client/server,
symmetric and broadcast modes, and with both symmetric-key and public-key
cryptography.
- <p>This document applies to version 4.2.8p1 of <code>ntpd</code>.
+ <p>This document applies to version 4.2.8p2 of <code>ntpd</code>.
<ul class="menu">
<li><a accesskey="1" href="#ntpd-Description">ntpd Description</a>: Description
@@ -169,7 +169,8 @@ This software is released under the NTP license, &lt;http://ntp.org/license&gt;.
<li><a accesskey="6" href="#ntpd-configfile">ntpd configfile</a>: configfile option (-c)
<li><a accesskey="7" href="#ntpd-driftfile">ntpd driftfile</a>: driftfile option (-f)
<li><a accesskey="8" href="#ntpd-panicgate">ntpd panicgate</a>: panicgate option (-g)
-<li><a accesskey="9" href="#ntpd-jaildir">ntpd jaildir</a>: jaildir option (-i)
+<li><a accesskey="9" href="#ntpd-force_002dstep_002donce">ntpd force-step-once</a>: force-step-once option (-G)
+<li><a href="#ntpd-jaildir">ntpd jaildir</a>: jaildir option (-i)
<li><a href="#ntpd-interface">ntpd interface</a>: interface option (-I)
<li><a href="#ntpd-keyfile">ntpd keyfile</a>: keyfile option (-k)
<li><a href="#ntpd-logfile">ntpd logfile</a>: logfile option (-l)
@@ -219,7 +220,7 @@ the usage text by passing it through a pager program.
used to select the program, defaulting to <span class="file">more</span>. Both will exit
with a status code of 0.
-<pre class="example">ntpd - NTP daemon program - Ver. 4.2.8p1-RC2
+<pre class="example">ntpd - NTP daemon program - Ver. 4.2.8p2-RC3
Usage: ntpd [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... \
[ &lt;server1&gt; ... &lt;serverN&gt; ]
Flg Arg Option-Name Description
@@ -240,6 +241,7 @@ Usage: ntpd [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ].
-f Str driftfile frequency drift file name
-g no panicgate Allow the first adjustment to be Big
- may appear multiple times
+ -G no force-step-once Step any initial offset correction.
-i Str jaildir Jail directory
-I Str interface Listen on an interface name or address
- may appear multiple times
@@ -413,7 +415,7 @@ configuration specification in the
file.
<div class="node">
<p><hr>
-<a name="ntpd-panicgate"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#ntpd-jaildir">ntpd jaildir</a>,
+<a name="ntpd-panicgate"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#ntpd-force_002dstep_002donce">ntpd force-step-once</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#ntpd-driftfile">ntpd driftfile</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<br>
@@ -443,15 +445,37 @@ See the
configuration file directive for other options.
<div class="node">
<p><hr>
-<a name="ntpd-jaildir"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#ntpd-interface">ntpd interface</a>,
+<a name="ntpd-force_002dstep_002donce"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#ntpd-jaildir">ntpd jaildir</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="#ntpd-panicgate">ntpd panicgate</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<br>
</div>
+<h4 class="subsection">force-step-once option (-G)</h4>
+
+<p><a name="index-ntpd_002dforce_002dstep_002donce-11"></a>
+This is the &ldquo;step any initial offset correction.&rdquo; option.
+Normally,
+<code>ntpd</code>
+steps the time if the time offset exceeds the step threshold,
+which is 128 ms by default, and otherwise slews the time.
+This option forces the initial offset correction to be stepped,
+so the highest time accuracy can be achieved quickly.
+However, this may also cause the time to be stepped back
+so this option must not be used if
+applications requiring monotonic time are running.
+See the <code>tinker</code> configuration file directive for other options.
+<div class="node">
+<p><hr>
+<a name="ntpd-jaildir"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#ntpd-interface">ntpd interface</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#ntpd-force_002dstep_002donce">ntpd force-step-once</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
+<br>
+</div>
+
<h4 class="subsection">jaildir option (-i)</h4>
-<p><a name="index-ntpd_002djaildir-11"></a>
+<p><a name="index-ntpd_002djaildir-12"></a>
This is the &ldquo;jail directory&rdquo; option.
This option takes a string argument.
@@ -482,7 +506,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">interface option (-I)</h4>
-<p><a name="index-ntpd_002dinterface-12"></a>
+<p><a name="index-ntpd_002dinterface-13"></a>
This is the &ldquo;listen on an interface name or address&rdquo; option.
This option takes a string argument <span class="file">iface</span>.
@@ -506,7 +530,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">keyfile option (-k)</h4>
-<p><a name="index-ntpd_002dkeyfile-13"></a>
+<p><a name="index-ntpd_002dkeyfile-14"></a>
This is the &ldquo;path to symmetric keys&rdquo; option.
This option takes a string argument.
Specify the name and path of the symmetric key file.
@@ -525,7 +549,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">logfile option (-l)</h4>
-<p><a name="index-ntpd_002dlogfile-14"></a>
+<p><a name="index-ntpd_002dlogfile-15"></a>
This is the &ldquo;path to the log file&rdquo; option.
This option takes a string argument.
Specify the name and path of the log file.
@@ -543,7 +567,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">novirtualips option (-L)</h4>
-<p><a name="index-ntpd_002dnovirtualips-15"></a>
+<p><a name="index-ntpd_002dnovirtualips-16"></a>
This is the &ldquo;do not listen to virtual interfaces&rdquo; option.
Do not listen to virtual interfaces, defined as those with
names containing a colon. This option is deprecated. Please
@@ -559,7 +583,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">modifymmtimer option (-M)</h4>
-<p><a name="index-ntpd_002dmodifymmtimer-16"></a>
+<p><a name="index-ntpd_002dmodifymmtimer-17"></a>
This is the &ldquo;modify multimedia timer (windows only)&rdquo; option.
<p class="noindent">This option has some usage constraints. It:
@@ -580,7 +604,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">nice option (-N)</h4>
-<p><a name="index-ntpd_002dnice-17"></a>
+<p><a name="index-ntpd_002dnice-18"></a>
This is the &ldquo;run at high priority&rdquo; option.
To the extent permitted by the operating system, run
<code>ntpd</code>
@@ -595,7 +619,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">pidfile option (-p)</h4>
-<p><a name="index-ntpd_002dpidfile-18"></a>
+<p><a name="index-ntpd_002dpidfile-19"></a>
This is the &ldquo;path to the pid file&rdquo; option.
This option takes a string argument.
Specify the name and path of the file used to record
@@ -614,7 +638,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">priority option (-P)</h4>
-<p><a name="index-ntpd_002dpriority-19"></a>
+<p><a name="index-ntpd_002dpriority-20"></a>
This is the &ldquo;process priority&rdquo; option.
This option takes a number argument.
To the extent permitted by the operating system, run
@@ -632,7 +656,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">quit option (-q)</h4>
-<p><a name="index-ntpd_002dquit-20"></a>
+<p><a name="index-ntpd_002dquit-21"></a>
This is the &ldquo;set the time and quit&rdquo; option.
<p class="noindent">This option has some usage constraints. It:
@@ -662,7 +686,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">propagationdelay option (-r)</h4>
-<p><a name="index-ntpd_002dpropagationdelay-21"></a>
+<p><a name="index-ntpd_002dpropagationdelay-22"></a>
This is the &ldquo;broadcast/propagation delay&rdquo; option.
This option takes a string argument.
Specify the default propagation delay from the broadcast/multicast server to this client. This is necessary only if the delay cannot be computed automatically by the protocol.
@@ -676,7 +700,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">saveconfigquit option</h4>
-<p><a name="index-ntpd_002dsaveconfigquit-22"></a>
+<p><a name="index-ntpd_002dsaveconfigquit-23"></a>
This is the &ldquo;save parsed configuration and quit&rdquo; option.
This option takes a string argument.
@@ -700,7 +724,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">statsdir option (-s)</h4>
-<p><a name="index-ntpd_002dstatsdir-23"></a>
+<p><a name="index-ntpd_002dstatsdir-24"></a>
This is the &ldquo;statistics file location&rdquo; option.
This option takes a string argument.
Specify the directory path for files created by the statistics facility.
@@ -717,7 +741,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">trustedkey option (-t)</h4>
-<p><a name="index-ntpd_002dtrustedkey-24"></a>
+<p><a name="index-ntpd_002dtrustedkey-25"></a>
This is the &ldquo;trusted key number&rdquo; option.
This option takes a string argument <span class="file">tkey</span>.
@@ -737,7 +761,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">user option (-u)</h4>
-<p><a name="index-ntpd_002duser-25"></a>
+<p><a name="index-ntpd_002duser-26"></a>
This is the &ldquo;run as userid (or userid:groupid)&rdquo; option.
This option takes a string argument.
@@ -762,7 +786,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">updateinterval option (-U)</h4>
-<p><a name="index-ntpd_002dupdateinterval-26"></a>
+<p><a name="index-ntpd_002dupdateinterval-27"></a>
This is the &ldquo;interval in seconds between scans for new or dropped interfaces&rdquo; option.
This option takes a number argument.
Give the time in seconds between two scans for new or dropped interfaces.
@@ -779,7 +803,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">wait-sync option (-w)</h4>
-<p><a name="index-ntpd_002dwait_002dsync-27"></a>
+<p><a name="index-ntpd_002dwait_002dsync-28"></a>
This is the &ldquo;seconds to wait for first clock sync&rdquo; option.
This option takes a number argument.
@@ -808,7 +832,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">slew option (-x)</h4>
-<p><a name="index-ntpd_002dslew-28"></a>
+<p><a name="index-ntpd_002dslew-29"></a>
This is the &ldquo;slew up to 600 seconds&rdquo; option.
Normally, the time is slewed if the offset is less than the step threshold, which is 128 ms by default, and stepped if above the threshold.
This option sets the threshold to 600 s, which is well within the accuracy window to set the clock manually.
@@ -833,7 +857,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">usepcc option</h4>
-<p><a name="index-ntpd_002dusepcc-29"></a>
+<p><a name="index-ntpd_002dusepcc-30"></a>
This is the &ldquo;use cpu cycle counter (windows only)&rdquo; option.
<p class="noindent">This option has some usage constraints. It:
@@ -855,7 +879,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">pccfreq option</h4>
-<p><a name="index-ntpd_002dpccfreq-30"></a>
+<p><a name="index-ntpd_002dpccfreq-31"></a>
This is the &ldquo;force cpu cycle counter use (windows only)&rdquo; option.
This option takes a string argument.
@@ -877,7 +901,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#ntpd-Invocation">ntpd Invocation</a>
<h4 class="subsection">mdns option (-m)</h4>
-<p><a name="index-ntpd_002dmdns-31"></a>
+<p><a name="index-ntpd_002dmdns-32"></a>
This is the &ldquo;register with mdns as a ntp server&rdquo; option.
<p class="noindent">This option has some usage constraints. It:
diff --git a/contrib/ntp/ntpd/ntpd.man.in b/contrib/ntp/ntpd/ntpd.man.in
index a540308..d9497a3 100644
--- a/contrib/ntp/ntpd/ntpd.man.in
+++ b/contrib/ntp/ntpd/ntpd.man.in
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntpd @NTPD_MS@ "04 Feb 2015" "4.2.8p1" "User Commands"
+.TH ntpd @NTPD_MS@ "07 Apr 2015" "4.2.8p2" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-YYaqWo/ag-.YaiVo)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-TQays3/ag-5Qaqr3)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:41:54 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:25:45 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpd-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
@@ -175,7 +175,7 @@ The name and path of the frequency file,
by default.
This is the same operation as the
\fBdriftfile\fP \fIdriftfile\fP
-configuration specification in the
+configuration specification in the
\fI/etc/ntp.conf\fP
file.
.TP
@@ -196,6 +196,20 @@ See the
\fBtinker\fP
configuration file directive for other options.
.TP
+.NOP \f\*[B-Font]\-G\f[], \f\*[B-Font]\-\-force\-step\-once\f[]
+Step any initial offset correction..
+.sp
+Normally,
+\fBntpd\fP
+steps the time if the time offset exceeds the step threshold,
+which is 128 ms by default, and otherwise slews the time.
+This option forces the initial offset correction to be stepped,
+so the highest time accuracy can be achieved quickly.
+However, this may also cause the time to be stepped back
+so this option must not be used if
+applications requiring monotonic time are running.
+See the \fBtinker\fP configuration file directive for other options.
+.TP
.NOP \f\*[B-Font]\-i\f[] \f\*[I-Font]string\f[], \f\*[B-Font]\-\-jaildir\f[]=\f\*[I-Font]string\f[]
Jail directory.
.sp
@@ -220,7 +234,7 @@ Open the network address given, or all the addresses associated with the
given interface name. This option may appear multiple times. This option
also implies not opening other addresses, except wildcard and localhost.
This option is deprecated. Please consider using the configuration file
-\fBinterface\fP command, which is more versatile.
+\fBinterface\fP command, which is more versatile.
.TP
.NOP \f\*[B-Font]\-k\f[] \f\*[I-Font]string\f[], \f\*[B-Font]\-\-keyfile\f[]=\f\*[I-Font]string\f[]
path to symmetric keys.
diff --git a/contrib/ntp/ntpd/ntpd.mdoc.in b/contrib/ntp/ntpd/ntpd.mdoc.in
index 3017dc8..4458532 100644
--- a/contrib/ntp/ntpd/ntpd.mdoc.in
+++ b/contrib/ntp/ntpd/ntpd.mdoc.in
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTPD @NTPD_MS@ User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpd-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:42:12 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:26:02 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpd-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
@@ -144,7 +144,7 @@ The name and path of the frequency file,
by default.
This is the same operation as the
\fBdriftfile\fP \fIdriftfile\fP
-configuration specification in the
+configuration specification in the
\fI/etc/ntp.conf\fP
file.
.It Fl g , Fl \-panicgate
@@ -163,6 +163,19 @@ options.
See the
\fBtinker\fP
configuration file directive for other options.
+.It Fl G , Fl \-force\-step\-once
+Step any initial offset correction..
+.sp
+Normally,
+\fBntpd\fP
+steps the time if the time offset exceeds the step threshold,
+which is 128 ms by default, and otherwise slews the time.
+This option forces the initial offset correction to be stepped,
+so the highest time accuracy can be achieved quickly.
+However, this may also cause the time to be stepped back
+so this option must not be used if
+applications requiring monotonic time are running.
+See the \fBtinker\fP configuration file directive for other options.
.It Fl i Ar string , Fl \-jaildir Ns = Ns Ar string
Jail directory.
.sp
@@ -186,7 +199,7 @@ Open the network address given, or all the addresses associated with the
given interface name. This option may appear multiple times. This option
also implies not opening other addresses, except wildcard and localhost.
This option is deprecated. Please consider using the configuration file
-\fBinterface\fP command, which is more versatile.
+\fBinterface\fP command, which is more versatile.
.It Fl k Ar string , Fl \-keyfile Ns = Ns Ar string
path to symmetric keys.
.sp
diff --git a/contrib/ntp/ntpd/ntpdbase-opts.def b/contrib/ntp/ntpd/ntpdbase-opts.def
index 110504e..66b9535 100644
--- a/contrib/ntp/ntpd/ntpdbase-opts.def
+++ b/contrib/ntp/ntpd/ntpdbase-opts.def
@@ -87,7 +87,7 @@ flag = {
by default.
This is the same operation as the
@code{driftfile} @kbd{driftfile}
- configuration specification in the
+ configuration specification in the
@file{/etc/ntp.conf}
file.
_EndOfDoc_;
@@ -115,6 +115,24 @@ flag = {
};
flag = {
+ name = force_step_once;
+ value = G;
+ descrip = "Step any initial offset correction.";
+ doc = <<- _EndOfDoc_
+ Normally,
+ @code{ntpd}
+ steps the time if the time offset exceeds the step threshold,
+ which is 128 ms by default, and otherwise slews the time.
+ This option forces the initial offset correction to be stepped,
+ so the highest time accuracy can be achieved quickly.
+ However, this may also cause the time to be stepped back
+ so this option must not be used if
+ applications requiring monotonic time are running.
+ See the @code{tinker} configuration file directive for other options.
+ _EndOfDoc_;
+};
+
+flag = {
ifdef = HAVE_DROPROOT;
name = jaildir;
value = i;
@@ -150,7 +168,7 @@ flag = {
given interface name. This option may appear multiple times. This option
also implies not opening other addresses, except wildcard and localhost.
This option is deprecated. Please consider using the configuration file
- @code{interface} command, which is more versatile.
+ @code{interface} command, which is more versatile.
_EndOfDoc_;
};
diff --git a/contrib/ntp/ntpd/refclock_palisade.c b/contrib/ntp/ntpd/refclock_palisade.c
index 2b396d8..0520311 100644
--- a/contrib/ntp/ntpd/refclock_palisade.c
+++ b/contrib/ntp/ntpd/refclock_palisade.c
@@ -584,7 +584,10 @@ TSIP_decode (
break;
}
- if (up->leap_status & PALISADE_LEAP_PENDING) {
+ up->month = mb(15);
+ if ( (up->leap_status & PALISADE_LEAP_PENDING) &&
+ /* Avoid early announce: https://bugs.ntp.org/2773 */
+ (6 == up->month || 12 == up->month) ) {
if (up->leap_status & PALISADE_UTC_TIME)
pp->leap = LEAP_ADDSECOND;
else
@@ -615,6 +618,7 @@ TSIP_decode (
pp->hour = mb(11);
pp->minute = mb(12);
pp->second = mb(13);
+ up->month = mb(14); /* Save for LEAP check */
#ifdef DEBUG
if (debug > 1)
@@ -645,7 +649,9 @@ TSIP_decode (
printf("TSIP_decode: unit %d\n", up->unit);
}
#endif
- if (getint((u_char *) &mb(10)) & 0x80)
+ if ( (getint((u_char *) &mb(10)) & 0x80) &&
+ /* Avoid early announce: https://bugs.ntp.org/2773 */
+ (6 == up->month || 12 == up->month) )
pp->leap = LEAP_ADDSECOND; /* we ASSUME addsecond */
else
pp->leap = LEAP_NOWARNING;
diff --git a/contrib/ntp/ntpd/refclock_palisade.h b/contrib/ntp/ntpd/refclock_palisade.h
index 4f1ab26..3782a5e 100644
--- a/contrib/ntp/ntpd/refclock_palisade.h
+++ b/contrib/ntp/ntpd/refclock_palisade.h
@@ -169,6 +169,7 @@ struct palisade_unit {
short rpt_cnt; /* TSIP packet length so far */
char rpt_buf[BMAX]; /* packet assembly buffer */
int type; /* Clock mode type */
+ int month; /* for LEAP filter */
};
/*
diff --git a/contrib/ntp/ntpd/refclock_parse.c b/contrib/ntp/ntpd/refclock_parse.c
index aa4be60..195ec39 100644
--- a/contrib/ntp/ntpd/refclock_parse.c
+++ b/contrib/ntp/ntpd/refclock_parse.c
@@ -54,36 +54,36 @@
/*
* This driver currently provides the support for
- * - Meinberg receiver DCF77 PZF 535 (TCXO version) (DCF)
- * - Meinberg receiver DCF77 PZF 535 (OCXO version) (DCF)
- * - Meinberg receiver DCF77 PZF 509 (DCF)
+ * - Meinberg receiver DCF77 PZF535 (TCXO version) (DCF)
+ * - Meinberg receiver DCF77 PZF535 (OCXO version) (DCF)
+ * - Meinberg receiver DCF77 PZF509 (DCF)
* - Meinberg receiver DCF77 AM receivers (e.g. C51) (DCF)
* - IGEL CLOCK (DCF)
* - ELV DCF7000 (DCF)
* - Schmid clock (DCF)
* - Conrad DCF77 receiver module (DCF)
* - FAU DCF77 NTP receiver (TimeBrick) (DCF)
- * - WHARTON 400A Series clock (DCF)
+ * - WHARTON 400A Series clock (DCF)
*
- * - Meinberg GPS166/GPS167 (GPS)
+ * - Meinberg GPS receivers (GPS)
* - Trimble (TSIP and TAIP protocol) (GPS)
*
* - RCC8000 MSF Receiver (MSF)
- * - VARITEXT clock (MSF)
+ * - VARITEXT clock (MSF)
*/
/*
* Meinberg receivers are usually connected via a
- * 9600 baud serial line
+ * 9600/7E1 or 19200/8N1 serial line.
*
* The Meinberg GPS receivers also have a special NTP time stamp
* format. The firmware release is Uni-Erlangen.
*
* Meinberg generic receiver setup:
- * output time code every second
- * Baud rate 9600 7E2S
+ * output time code every second
+ * Baud rate 9600 7E2S
*
- * Meinberg GPS16x setup:
+ * Meinberg GPS receiver setup:
* output time code every second
* Baudrate 19200 8N1
*
@@ -91,7 +91,9 @@
* in Meinberg receivers.
*
* Special software versions are only sensible for the
- * GPS 16x family of receivers.
+ * oldest GPS receiver, GPS16x. For newer receiver types
+ * the output string format can be configured at the device,
+ * and the device name is generally GPSxxx instead of GPS16x.
*
* Meinberg can be reached via: http://www.meinberg.de/
*/
@@ -156,13 +158,13 @@
# endif
#endif
-#define BUFFER_SIZE(_BUF, _PTR) ((_BUF) + sizeof(_BUF) - (_PTR))
-#define BUFFER_SIZES(_BUF, _PTR, _SZ) ((_BUF) + (_SZ) - (_PTR))
+# define BUFFER_SIZE(_BUF, _PTR) ((int)((_BUF) + sizeof(_BUF) - (_PTR)))
+# define BUFFER_SIZES(_BUF, _PTR, _SZ) ((int)((_BUF) + (_SZ) - (_PTR)))
/*
* document type of PPS interfacing - copy of ifdef mechanism in local_input()
*/
-#undef PPS_METHOD
+#undef PPS_METHOD
#ifdef HAVE_PPSAPI
#define PPS_METHOD "PPS API"
@@ -181,6 +183,18 @@
#endif /* TIOCDCDTIMESTAMP */
#endif /* HAVE_PPSAPI */
+/*
+ * COND_DEF can be conditionally defined as DEF or 0. If defined as DEF
+ * then some more parse-specific variables are flagged to be printed with
+ * "ntpq -c cv <assid>". This can be lengthy, so by default COND_DEF
+ * should be defined as 0.
+ */
+#if 0
+# define COND_DEF DEF // enable this for testing
+#else
+# define COND_DEF 0 // enable this by default
+#endif
+
#include "ntp_io.h"
#include "ntp_stdlib.h"
@@ -382,7 +396,7 @@ struct parseunit
* PARSE io
*/
bind_t *binding; /* io handling binding */
-
+
/*
* parse state
*/
@@ -450,23 +464,23 @@ typedef struct poll_info
#define DCF_P_ID "DCFp" /* psuedo random phase shift */
#define GPS_ID "GPS" /* GPS receiver */
-#define NOCLOCK_ROOTDELAY 0.0
-#define NOCLOCK_BASEDELAY 0.0
-#define NOCLOCK_DESCRIPTION 0
+#define NOCLOCK_ROOTDELAY 0.0
+#define NOCLOCK_BASEDELAY 0.0
+#define NOCLOCK_DESCRIPTION 0
#define NOCLOCK_MAXUNSYNC 0
#define NOCLOCK_CFLAG 0
#define NOCLOCK_IFLAG 0
#define NOCLOCK_OFLAG 0
#define NOCLOCK_LFLAG 0
-#define NOCLOCK_ID "TILT"
-#define NOCLOCK_POLL NO_POLL
-#define NOCLOCK_INIT NO_INIT
-#define NOCLOCK_END NO_END
-#define NOCLOCK_DATA NO_LCLDATA
-#define NOCLOCK_FORMAT ""
-#define NOCLOCK_TYPE CTL_SST_TS_UNSPEC
-#define NOCLOCK_SAMPLES 0
-#define NOCLOCK_KEEP 0
+#define NOCLOCK_ID "TILT"
+#define NOCLOCK_POLL NO_POLL
+#define NOCLOCK_INIT NO_INIT
+#define NOCLOCK_END NO_END
+#define NOCLOCK_DATA NO_LCLDATA
+#define NOCLOCK_FORMAT ""
+#define NOCLOCK_TYPE CTL_SST_TS_UNSPEC
+#define NOCLOCK_SAMPLES 0
+#define NOCLOCK_KEEP 0
#define DCF_TYPE CTL_SST_TS_LF
#define GPS_TYPE CTL_SST_TS_UHF
@@ -536,14 +550,14 @@ typedef struct poll_info
#define DCFPZF535OCXO_FORMAT "Meinberg Standard"
/*
- * Meinberg GPS16X receiver
+ * Meinberg GPS receivers
*/
static void gps16x_message (struct parseunit *, parsetime_t *);
static int gps16x_poll_init (struct parseunit *);
#define GPS16X_ROOTDELAY 0.0 /* nothing here */
#define GPS16X_BASEDELAY 0.001968 /* XXX to be fixed ! 1.968ms +- 104us (oscilloscope) - relative to start (end of STX) */
-#define GPS16X_DESCRIPTION "Meinberg GPS16x receiver"
+#define GPS16X_DESCRIPTION "Meinberg GPS receiver"
#define GPS16X_MAXUNSYNC 60*60*96 /* only trust clock for 4 days
* @ 5e-9df/f we have accumulated
* at most an error of 1.73 ms
@@ -745,9 +759,9 @@ static void trimbletsip_event (struct parseunit *, int);
#define TRIMBLETAIP_INIT trimbletaip_init
#define TRIMBLETSIP_INIT trimbletsip_init
-#define TRIMBLETAIP_EVENT trimbletaip_event
+#define TRIMBLETAIP_EVENT trimbletaip_event
-#define TRIMBLETSIP_EVENT trimbletsip_event
+#define TRIMBLETSIP_EVENT trimbletsip_event
#define TRIMBLETSIP_MESSAGE trimbletsip_message
#define TRIMBLETAIP_END 0
@@ -804,7 +818,7 @@ static poll_info_t rcc8000_pollinfo = { RCC_POLLRATE, RCC_POLLCMD, RCC_CMDSIZE }
#define RCC8000_KEEP 3
/*
- * Hopf Radio clock 6021 Format
+ * Hopf Radio clock 6021 Format
*
*/
#define HOPF6021_ROOTDELAY 0.0
@@ -1200,7 +1214,7 @@ static struct parse_clockinfo
},
{ /* mode 12 */
HOPF6021_FLAGS,
- NO_POLL,
+ NO_POLL,
NO_INIT,
NO_EVENT,
NO_END,
@@ -1576,7 +1590,7 @@ list_err(
if (do_it)
err->err_cnt++;
-
+
if (err->err_stage->err_count &&
(err->err_cnt >= err->err_stage->err_count))
{
@@ -1600,7 +1614,7 @@ list_err(
l_mktime(current_time - err->err_started));
err->err_suppressed = 0;
}
-
+
return do_it;
}
@@ -1715,7 +1729,7 @@ static int stream_setfmt (struct parseunit *, parsectl_t *);
static int stream_timecode (struct parseunit *, parsectl_t *);
static void stream_receive (struct recvbuf *);
#endif
-
+
static int local_init (struct parseunit *);
static void local_end (struct parseunit *);
static int local_nop (struct parseunit *);
@@ -1796,7 +1810,7 @@ ppsclock_init(
{
static char m1[] = "ppsclocd";
static char m2[] = "ppsclock";
-
+
/*
* now push the parse streams module
* it will ensure exclusive access to the device
@@ -1885,7 +1899,7 @@ stream_setcs(
)
{
struct strioctl strioc;
-
+
strioc.ic_cmd = PARSEIOC_SETCS;
strioc.ic_timout = 0;
strioc.ic_dp = (char *)tcl;
@@ -1908,7 +1922,7 @@ stream_enable(
)
{
struct strioctl strioc;
-
+
strioc.ic_cmd = PARSEIOC_ENABLE;
strioc.ic_timout = 0;
strioc.ic_dp = (char *)0;
@@ -1932,7 +1946,7 @@ stream_disable(
)
{
struct strioctl strioc;
-
+
strioc.ic_cmd = PARSEIOC_DISABLE;
strioc.ic_timout = 0;
strioc.ic_dp = (char *)0;
@@ -1957,7 +1971,7 @@ stream_getfmt(
)
{
struct strioctl strioc;
-
+
strioc.ic_cmd = PARSEIOC_GETFMT;
strioc.ic_timout = 0;
strioc.ic_dp = (char *)tcl;
@@ -1980,7 +1994,7 @@ stream_setfmt(
)
{
struct strioctl strioc;
-
+
strioc.ic_cmd = PARSEIOC_SETFMT;
strioc.ic_timout = 0;
strioc.ic_dp = (char *)tcl;
@@ -2005,12 +2019,12 @@ stream_timecode(
)
{
struct strioctl strioc;
-
+
strioc.ic_cmd = PARSEIOC_TIMECODE;
strioc.ic_timout = 0;
strioc.ic_dp = (char *)tcl;
strioc.ic_len = sizeof (*tcl);
-
+
if (ioctl(parse->generic->io.fd, I_STR, (caddr_t)&strioc) == -1)
{
ERR(ERR_INTERNAL)
@@ -2045,7 +2059,7 @@ stream_receive(
return;
}
clear_err(parse, ERR_BADIO);
-
+
memmove((caddr_t)&parsetime,
(caddr_t)rbufp->recv_buffer,
sizeof(parsetime_t));
@@ -2211,7 +2225,7 @@ local_input(
{
struct timespec pps_timeout;
pps_info_t pps_info;
-
+
pps_timeout.tv_sec = 0;
pps_timeout.tv_nsec = 0;
@@ -2232,9 +2246,9 @@ local_input(
else
pts = pps_info.assert_timestamp;
- parse->parseio.parse_dtime.parse_ptime.fp.l_ui = pts.tv_sec + JAN_1970;
+ parse->parseio.parse_dtime.parse_ptime.fp.l_ui = (uint32_t) (pts.tv_sec + JAN_1970);
- dtemp = pts.tv_nsec / 1e9;
+ dtemp = (double) pts.tv_nsec / 1e9;
if (dtemp < 0.) {
dtemp += 1;
parse->parseio.parse_dtime.parse_ptime.fp.l_ui--;
@@ -2243,9 +2257,9 @@ local_input(
dtemp -= 1;
parse->parseio.parse_dtime.parse_ptime.fp.l_ui++;
}
- parse->parseio.parse_dtime.parse_ptime.fp.l_uf = dtemp * FRAC;
+ parse->parseio.parse_dtime.parse_ptime.fp.l_uf = (uint32_t)(dtemp * FRAC);
- parse->parseio.parse_dtime.parse_state |= PARSEB_PPS|PARSEB_S_PPS;
+ parse->parseio.parse_dtime.parse_state |= PARSEB_PPS|PARSEB_S_PPS;
#ifdef DEBUG
if (debug > 3)
{
@@ -2287,11 +2301,11 @@ local_input(
#else
#ifdef TIOCDCDTIMESTAMP
struct timeval dcd_time;
-
+
if (ioctl(parse->ppsfd, TIOCDCDTIMESTAMP, &dcd_time) != -1)
{
l_fp tstmp;
-
+
TVTOTS(&dcd_time, &tstmp);
tstmp.l_ui += JAN_1970;
L_SUB(&ts.fp, &tstmp);
@@ -2413,7 +2427,7 @@ local_receive(
return;
}
clear_err(parse, ERR_BADIO);
-
+
memmove((caddr_t)&parsetime,
(caddr_t)rbufp->recv_buffer,
sizeof(parsetime_t));
@@ -2511,7 +2525,7 @@ parsestate(
{ PARSEB_LEAPADD, "LEAP ADD WARNING" },
{ PARSEB_LEAPDEL, "LEAP DELETE WARNING" },
{ PARSEB_LEAPSECOND, "LEAP SECOND" },
- { PARSEB_ALTERNATE, "ALTERNATE ANTENNA" },
+ { PARSEB_CALLBIT, "CALL BIT" },
{ PARSEB_TIMECODE, "TIME CODE" },
{ PARSEB_PPS, "PPS" },
{ PARSEB_POSITION, "POSITION" },
@@ -2566,7 +2580,7 @@ parsestate(
{
t = ap(buffer, size, t, "; ");
}
-
+
t = ap(buffer, size, t, "%s",
sflagstrings[i].name);
}
@@ -2808,7 +2822,7 @@ parse_shutdown(
{
parse->parse_type->cl_end(parse);
}
-
+
/*
* cleanup before leaving this world
*/
@@ -2821,7 +2835,7 @@ parse_shutdown(
io_closeclock(&parse->generic->io);
free_varlist(parse->kv);
-
+
NLOG(NLOG_CLOCKINFO) /* conditional if clause for conditional syslog */
msyslog(LOG_INFO, "PARSE receiver #%d: reference clock \"%s\" removed",
CLK_UNIT(parse->peer), parse->parse_type->cl_description);
@@ -2847,14 +2861,14 @@ parse_hardpps(
if (CLK_PPS(parse->peer) && (parse->flags & PARSE_PPSKERNEL)) {
int i = 0;
- if (mode == PARSE_HARDPPS_ENABLE)
+ if (mode == PARSE_HARDPPS_ENABLE)
{
if (parse->flags & PARSE_CLEAR)
i = PPS_CAPTURECLEAR;
else
i = PPS_CAPTUREASSERT;
}
-
+
if (time_pps_kcbind(parse->atom.handle, PPS_KC_HARDPPS, i,
PPS_TSFMT_TSPEC) < 0) {
msyslog(LOG_ERR, "PARSE receiver #%d: time_pps_kcbind failed: %m",
@@ -2884,8 +2898,8 @@ parse_ppsapi(
{
int cap, mode_ppsoffset;
const char *cp;
-
- parse->flags &= ~PARSE_PPSCLOCK;
+
+ parse->flags &= (u_char) (~PARSE_PPSCLOCK);
/*
* collect PPSAPI offset capability - should move into generic handling
@@ -2893,7 +2907,7 @@ parse_ppsapi(
if (time_pps_getcap(parse->atom.handle, &cap) < 0) {
msyslog(LOG_ERR, "PARSE receiver #%d: parse_ppsapi: time_pps_getcap failed: %m",
CLK_UNIT(parse->peer));
-
+
return 0;
}
@@ -2927,19 +2941,19 @@ parse_ppsapi(
CLK_UNIT(parse->peer), cp, cap);
mode_ppsoffset = 0;
} else {
- if (mode_ppsoffset == PPS_OFFSETCLEAR)
- {
- parse->atom.pps_params.clear_offset.tv_sec = -parse->ppsphaseadjust;
- parse->atom.pps_params.clear_offset.tv_nsec = -1e9*(parse->ppsphaseadjust - (long)parse->ppsphaseadjust);
+ if (mode_ppsoffset == PPS_OFFSETCLEAR)
+ {
+ parse->atom.pps_params.clear_offset.tv_sec = (time_t)(-parse->ppsphaseadjust);
+ parse->atom.pps_params.clear_offset.tv_nsec = (long)(-1e9*(parse->ppsphaseadjust - (double)(long)parse->ppsphaseadjust));
}
-
+
if (mode_ppsoffset == PPS_OFFSETASSERT)
- {
- parse->atom.pps_params.assert_offset.tv_sec = -parse->ppsphaseadjust;
- parse->atom.pps_params.assert_offset.tv_nsec = -1e9*(parse->ppsphaseadjust - (long)parse->ppsphaseadjust);
+ {
+ parse->atom.pps_params.assert_offset.tv_sec = (time_t)(-parse->ppsphaseadjust);
+ parse->atom.pps_params.assert_offset.tv_nsec = (long)(-1e9*(parse->ppsphaseadjust - (double)(long)parse->ppsphaseadjust));
}
}
-
+
parse->atom.pps_params.mode |= mode_ppsoffset;
if (time_pps_setparams(parse->atom.handle, &parse->atom.pps_params) < 0) {
@@ -3043,9 +3057,9 @@ parse_start(
parse->kv = (struct ctl_var *)0;
clear_err(parse, ERR_ALL);
-
+
parse->parse_type = &parse_clockinfo[type];
-
+
parse->maxunsync = parse->parse_type->cl_maxunsync;
parse->generic->fudgetime1 = parse->parse_type->cl_basedelay;
@@ -3058,16 +3072,16 @@ parse_start(
peer->rootdelay = parse->parse_type->cl_rootdelay;
peer->sstclktype = parse->parse_type->cl_type;
peer->precision = sys_precision;
-
+
peer->stratum = STRATUM_REFCLOCK;
if (peer->stratum <= 1)
memmove((char *)&parse->generic->refid, parse->parse_type->cl_id, 4);
else
parse->generic->refid = htonl(PARSEHSREFID);
-
+
parse->generic->io.fd = fd232;
-
+
parse->peer = peer; /* marks it also as busy */
/*
@@ -3110,15 +3124,15 @@ parse_start(
}
#endif
- tio.c_cflag = parse_clockinfo[type].cl_cflag;
- tio.c_iflag = parse_clockinfo[type].cl_iflag;
- tio.c_oflag = parse_clockinfo[type].cl_oflag;
- tio.c_lflag = parse_clockinfo[type].cl_lflag;
-
+ tio.c_cflag = (tcflag_t) parse_clockinfo[type].cl_cflag;
+ tio.c_iflag = (tcflag_t) parse_clockinfo[type].cl_iflag;
+ tio.c_oflag = (tcflag_t) parse_clockinfo[type].cl_oflag;
+ tio.c_lflag = (tcflag_t) parse_clockinfo[type].cl_lflag;
+
#ifdef HAVE_TERMIOS
- if ((cfsetospeed(&tio, parse_clockinfo[type].cl_speed) == -1) ||
- (cfsetispeed(&tio, parse_clockinfo[type].cl_speed) == -1))
+ if ((cfsetospeed(&tio, (speed_t) parse_clockinfo[type].cl_speed) == -1) ||
+ (cfsetispeed(&tio, (speed_t) parse_clockinfo[type].cl_speed) == -1))
{
msyslog(LOG_ERR, "PARSE receiver #%d: parse_start: tcset{i,o}speed(&tio, speed): %m", unit);
parse_shutdown(CLK_UNIT(parse->peer), peer); /* let our cleaning staff do the work */
@@ -3178,7 +3192,7 @@ parse_start(
if (CLK_PPS(parse->peer))
{
int i = 1;
-
+
if (ioctl(parse->ppsfd, TIOCSPPS, (caddr_t)&i) == 0)
{
parse->flags |= PARSE_PPSCLOCK;
@@ -3217,7 +3231,7 @@ parse_start(
*/
parse->generic->io.srcclock = peer;
parse->generic->io.datalen = 0;
-
+
parse->binding = init_iobinding(parse);
if (parse->binding == (bind_t *)0)
@@ -3263,9 +3277,9 @@ parse_start(
parse_shutdown(CLK_UNIT(parse->peer), peer); /* let our cleaning staff do the work */
return 0; /* well, ok - special initialisation broke */
}
-
+
strlcpy(tmp_ctl.parseformat.parse_buffer, parse->parse_type->cl_format, sizeof(tmp_ctl.parseformat.parse_buffer));
- tmp_ctl.parseformat.parse_count = strlen(tmp_ctl.parseformat.parse_buffer);
+ tmp_ctl.parseformat.parse_count = (u_short) strlen(tmp_ctl.parseformat.parse_buffer);
if (!PARSE_SETFMT(parse, &tmp_ctl))
{
@@ -3273,7 +3287,7 @@ parse_start(
parse_shutdown(CLK_UNIT(parse->peer), peer); /* let our cleaning staff do the work */
return 0; /* well, ok - special initialisation broke */
}
-
+
/*
* get rid of all IO accumulated so far
*/
@@ -3300,7 +3314,7 @@ parse_start(
return 0; /* well, ok - special initialisation broke */
}
}
-
+
/*
* Insert in async io device list.
*/
@@ -3365,8 +3379,8 @@ parse_ctl(
{
if (in->haveflags & (CLK_HAVEFLAG1|CLK_HAVEFLAG2|CLK_HAVEFLAG3|CLK_HAVEFLAG4))
{
- parse->flags = (parse->flags & ~(CLK_FLAG1|CLK_FLAG2|CLK_FLAG3|CLK_FLAG4)) |
- (in->flags & (CLK_FLAG1|CLK_FLAG2|CLK_FLAG3|CLK_FLAG4));
+ u_char mask = CLK_FLAG1|CLK_FLAG2|CLK_FLAG3|CLK_FLAG4;
+ parse->flags = (parse->flags & (u_char)(~mask)) | (in->flags & mask);
#if defined(HAVE_PPSAPI)
if (CLK_PPS(parse->peer))
{
@@ -3374,7 +3388,7 @@ parse_ctl(
}
#endif
}
-
+
if (in->haveflags & CLK_HAVETIME1)
{
parse->generic->fudgetime1 = in->fudgetime1;
@@ -3382,11 +3396,11 @@ parse_ctl(
CLK_UNIT(parse->peer),
parse->generic->fudgetime1);
}
-
+
if (in->haveflags & CLK_HAVETIME2)
{
parse->generic->fudgetime2 = in->fudgetime2;
- if (parse->flags & PARSE_TRUSTTIME)
+ if (parse->flags & PARSE_TRUSTTIME)
{
parse->maxunsync = (u_long)ABS(in->fudgetime2);
msyslog(LOG_INFO, "PARSE receiver #%d: new trust time %s",
@@ -3434,7 +3448,7 @@ parse_poll(
*/
parse->generic->polls++;
- if (parse->pollneeddata &&
+ if (parse->pollneeddata &&
((int)(current_time - parse->pollneeddata) > (1<<(max(min(parse->peer->hpoll, parse->peer->ppoll), parse->peer->minpoll)))))
{
/*
@@ -3443,7 +3457,7 @@ parse_poll(
*/
parse->lastmissed = current_time;
parse_event(parse, CEVNT_TIMEOUT);
-
+
ERR(ERR_NODATA)
msyslog(LOG_WARNING, "PARSE receiver #%d: no data from device within poll interval (check receiver / wiring)", CLK_UNIT(parse->peer));
}
@@ -3501,7 +3515,7 @@ parse_control(
* handle changes
*/
parse_ctl(parse, in);
-
+
/*
* supply data
*/
@@ -3587,9 +3601,9 @@ parse_control(
tmpctl.parsegettc.parse_buffer, (unsigned)(tmpctl.parsegettc.parse_count));
}
-
+
tmpctl.parseformat.parse_format = tmpctl.parsegettc.parse_format;
-
+
if (!PARSE_GETFMT(parse, &tmpctl))
{
ERR(ERR_INTERNAL)
@@ -3603,7 +3617,7 @@ parse_control(
tt = ap(start, 80, tt, "refclock_format=\"");
if (count > 0) {
- tt = ap(start, 80, tt, "%*.*s",
+ tt = ap(start, 80, tt, "%*.*s",
count,
count,
tmpctl.parseformat.parse_buffer);
@@ -3632,7 +3646,7 @@ parse_control(
percent /= 10;
d /= 10;
}
-
+
if (d)
percent = (percent * 10000) / d;
else
@@ -3642,14 +3656,14 @@ parse_control(
{
char item[80];
int count;
-
+
snprintf(item, 80, "%s%s%s: %s (%d.%02d%%)",
sum ? "; " : "",
(parse->generic->currentstatus == i) ? "*" : "",
clockstatus((unsigned int)i),
l_mktime(s_time),
(int)(percent / 100), (int)(percent % 100));
- if ((count = strlen(item)) < (LEN_STATES - 40 - (tt - start)))
+ if ((count = (int) strlen(item)) < (LEN_STATES - 40 - (tt - start)))
{
tt = ap(start, LEN_STATES, tt,
"%s", item);
@@ -3657,22 +3671,22 @@ parse_control(
sum += s_time;
}
}
-
+
tt = ap(start, LEN_STATES, tt,
"; running time: %s\"", l_mktime(sum));
-
+
tt = add_var(&out->kv_list, 32, RO);
snprintf(tt, 32, "refclock_id=\"%s\"", parse->parse_type->cl_id);
-
+
tt = add_var(&out->kv_list, 80, RO);
snprintf(tt, 80, "refclock_iomode=\"%s\"", parse->binding->bd_description);
tt = add_var(&out->kv_list, 128, RO);
snprintf(tt, 128, "refclock_driver_version=\"%s\"", rcsid);
-
+
{
struct ctl_var *k;
-
+
k = parse->kv;
while (k && !(k->flags & EOV))
{
@@ -3680,8 +3694,8 @@ parse_control(
k++;
}
}
-
- out->lencode = strlen(outstatus);
+
+ out->lencode = (u_short) strlen(outstatus);
out->p_lastcode = outstatus;
}
}
@@ -3730,7 +3744,7 @@ parse_process(
{
l_fp off, rectime, reftime;
double fudge;
-
+
/* silence warning: 'off.Ul_i.Xl_i' may be used uninitialized in this function */
ZERO(off);
@@ -3743,11 +3757,11 @@ parse_process(
(parse->timedata.parse_status != parsetime->parse_status))
{
char buffer[400];
-
+
NLOG(NLOG_CLOCKINFO) /* conditional if clause for conditional syslog */
msyslog(LOG_WARNING, "PARSE receiver #%d: conversion status \"%s\"",
CLK_UNIT(parse->peer), parsestatus(parsetime->parse_status, buffer, sizeof(buffer)));
-
+
if ((parsetime->parse_status & CVT_MASK) == CVT_FAIL)
{
/*
@@ -3756,7 +3770,7 @@ parse_process(
* the time code might be overwritten by the next packet
*/
parsectl_t tmpctl;
-
+
if (!PARSE_GETTIMECODE(parse, &tmpctl))
{
ERR(ERR_INTERNAL)
@@ -3794,7 +3808,7 @@ parse_process(
parse->timedata.parse_ptime = parsetime->parse_ptime;
}
break; /* well, still waiting - timeout is handled at higher levels */
-
+
case CVT_FAIL:
if (parsetime->parse_status & CVT_BADFMT)
{
@@ -3825,7 +3839,7 @@ parse_process(
if (parse->lastformat != parsetime->parse_format)
{
parsectl_t tmpctl;
-
+
tmpctl.parseformat.parse_format = parsetime->parse_format;
if (!PARSE_GETFMT(parse, &tmpctl))
@@ -3853,10 +3867,10 @@ parse_process(
/*
* something happend - except for PPS events
*/
-
+
(void) parsestate(parsetime->parse_state, tmp1, sizeof(tmp1));
(void) parsestate(parse->timedata.parse_state, tmp2, sizeof(tmp2));
-
+
NLOG(NLOG_CLOCKINFO) /* conditional if clause for conditional syslog */
msyslog(LOG_INFO,"PARSE receiver #%d: STATE CHANGE: %s -> %s",
CLK_UNIT(parse->peer), tmp2, tmp1);
@@ -3959,12 +3973,12 @@ parse_process(
}
fudge = parse->generic->fudgetime1; /* standard RS232 Fudgefactor */
-
+
if (PARSE_TIMECODE(parsetime->parse_state))
{
rectime = parsetime->parse_stime.fp;
off = reftime = parsetime->parse_time.fp;
-
+
L_SUB(&off, &rectime); /* prepare for PPS adjustments logic */
#ifdef DEBUG
@@ -4009,7 +4023,7 @@ parse_process(
M_ISGEQ(0, 0x7fffffff, off.l_i, off.l_uf))
{
fudge = ppsphaseadjust; /* pick PPS fudge factor */
-
+
/*
* RS232 offsets within [-0.5..0.5[ - take PPS offsets
*/
@@ -4021,7 +4035,7 @@ parse_process(
reftime.l_ui++;
reftime.l_uf = 0;
-
+
/*
* implied on second offset
*/
@@ -4087,7 +4101,7 @@ parse_process(
rectime = reftime;
L_SUB(&rectime, &off); /* just to keep the ntp interface happy */
-
+
#ifdef DEBUG
if (debug > 3)
printf("PARSE receiver #%d: calculated Reftime %s, Recvtime %s\n",
@@ -4112,14 +4126,14 @@ parse_process(
clear_err(parse, ERR_BADDATA);
clear_err(parse, ERR_NODATA);
clear_err(parse, ERR_INTERNAL);
-
+
/*
* and now stick it into the clock machine
* samples are only valid iff lastsync is not too old and
* we have seen the clock in sync at least once
* after the last time we didn't see an expected data telegram
* at startup being not in sync is also bad just like
- * POWERUP state unless PARSE_F_POWERUPTRUST is set
+ * POWERUP state unless PARSE_F_POWERUPTRUST is set
* see the clock states section above for more reasoning
*/
if (((current_time - parse->lastsync) > parse->maxunsync) ||
@@ -4159,9 +4173,9 @@ parse_process(
* only good/trusted samples are interesting
*/
#ifdef DEBUG
- if (debug > 2)
- {
- printf("PARSE receiver #%d: refclock_process_offset(reftime=%s, rectime=%s, Fudge=%f)\n",
+ if (debug > 2)
+ {
+ printf("PARSE receiver #%d: refclock_process_offset(reftime=%s, rectime=%s, Fudge=%f)\n",
CLK_UNIT(parse->peer),
prettydate(&reftime),
prettydate(&rectime),
@@ -4169,7 +4183,7 @@ parse_process(
}
#endif
parse->generic->lastref = reftime;
-
+
refclock_process_offset(parse->generic, reftime, rectime, fudge);
#ifdef HAVE_PPSAPI
@@ -4177,18 +4191,18 @@ parse_process(
* pass PPS information on to PPS clock
*/
if (PARSE_PPS(parsetime->parse_state) && CLK_PPS(parse->peer))
- {
- parse->peer->flags |= FLAG_PPS;
+ {
+ parse->peer->flags |= (FLAG_PPS | FLAG_TSTAMP_PPS);
parse_hardpps(parse, PARSE_HARDPPS_ENABLE);
}
#endif
} else {
- parse_hardpps(parse, PARSE_HARDPPS_DISABLE);
- parse->peer->flags &= ~FLAG_PPS;
+ parse_hardpps(parse, PARSE_HARDPPS_DISABLE);
+ parse->peer->flags &= ~(FLAG_PPS | FLAG_TSTAMP_PPS);
}
/*
- * ready, unless the machine wants a sample or
+ * ready, unless the machine wants a sample or
* we are in fast startup mode (peer->dist > MAXDISTANCE)
*/
if (!parse->pollneeddata && parse->peer->disp <= MAXDISTANCE)
@@ -4200,56 +4214,71 @@ parse_process(
refclock_receive(parse->peer);
}
-
+
/**===========================================================================
** special code for special clocks
**/
static void
mk_utcinfo(
- char *t,
+ char *t, // pointer to the output string buffer
int wnt,
int wnlsf,
int dn,
int dtls,
int dtlsf,
- int size
+ int size // size of the output string buffer
)
{
- l_fp leapdate;
- char *start = t;
-
- snprintf(t, size, "current correction %d sec", dtls);
- t += strlen(t);
-
- if (wnlsf < 990)
- wnlsf += 1024;
-
- if (wnt < 990)
- wnt += 1024;
-
- gpstolfp((unsigned short)wnlsf, (unsigned short)dn, 0, &leapdate);
-
- if ((dtlsf != dtls) &&
- ((wnlsf - wnt) < 52))
- {
- snprintf(t, BUFFER_SIZES(start, t, size), ", next correction %d sec on %s, new GPS-UTC offset %d",
- dtlsf - dtls, gmprettydate(&leapdate), dtlsf);
- }
- else
- {
- snprintf(t, BUFFER_SIZES(start, t, size), ", last correction on %s",
- gmprettydate(&leapdate));
- }
+ /*
+ * The week number transmitted by the GPS satellites for the leap date
+ * is truncated to 8 bits only. If the nearest leap second date is off
+ * the current date by more than +/- 128 weeks then conversion to a
+ * calendar date is ambiguous. On the other hand, if a leap second is
+ * currently being announced (i.e. dtlsf != dtls) then the week number
+ * wnlsf is close enough, and we can unambiguously determine the date
+ * for which the leap second is scheduled.
+ */
+ if ( dtlsf != dtls )
+ {
+ time_t t_ls;
+ struct tm *tm;
+ int n = 0;
+
+ if (wnlsf < GPSWRAP)
+ wnlsf += GPSWEEKS;
+
+ if (wnt < GPSWRAP)
+ wnt += GPSWEEKS;
+
+ t_ls = (time_t) wnlsf * SECSPERWEEK
+ + (time_t) dn * SECSPERDAY
+ + GPS_SEC_BIAS - 1;
+
+ tm = gmtime( &t_ls );
+ if (tm == NULL) // gmtime() failed
+ {
+ snprintf( t, size, "** (gmtime() failed in mk_utcinfo())" );
+ return;
+ }
+
+ n += snprintf( t, size, "UTC offset transition from %is to %is due to leap second %s",
+ dtls, dtlsf, ( dtls < dtlsf ) ? "insertion" : "deletion" );
+ n += snprintf( t + n, size - n, " at UTC midnight at the end of %s, %04i-%02i-%02i",
+ daynames[tm->tm_wday], tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday );
+ }
+ else
+ snprintf( t, size, "UTC offset parameter: %is, no leap second announced.\n", dtls );
+
}
#ifdef CLOCK_MEINBERG
/**===========================================================================
- ** Meinberg GPS166/GPS167 support
+ ** Meinberg GPS receiver support
**/
/*------------------------------------------------------------
- * gps16x_message - process GPS16x messages
+ * gps16x_message - process messages from Meinberg GPS receiver
*/
static void
gps16x_message(
@@ -4261,12 +4290,12 @@ gps16x_message(
{
GPS_MSG_HDR header;
unsigned char *bufp = (unsigned char *)parsetime->parse_msg + 1;
-
+
#ifdef DEBUG
if (debug > 2)
{
char msgbuffer[600];
-
+
mkreadable(msgbuffer, sizeof(msgbuffer), (char *)parsetime->parse_msg, parsetime->parse_msglen, 1);
printf("PARSE receiver #%d: received message (%d bytes) >%s<\n",
CLK_UNIT(parse->peer),
@@ -4275,21 +4304,21 @@ gps16x_message(
}
#endif
get_mbg_header(&bufp, &header);
- if (header.gps_hdr_csum == mbg_csum(parsetime->parse_msg + 1, 6) &&
- (header.gps_len == 0 ||
- (header.gps_len < sizeof(parsetime->parse_msg) &&
- header.gps_data_csum == mbg_csum(bufp, header.gps_len))))
+ if (header.hdr_csum == mbg_csum(parsetime->parse_msg + 1, 6) &&
+ (header.len == 0 ||
+ (header.len < sizeof(parsetime->parse_msg) &&
+ header.data_csum == mbg_csum(bufp, header.len))))
{
/*
* clean message
*/
- switch (header.gps_cmd)
+ switch (header.cmd)
{
case GPS_SW_REV:
{
char buffer[64];
SW_REV gps_sw_rev;
-
+
get_mbg_sw_rev(&bufp, &gps_sw_rev);
snprintf(buffer, sizeof(buffer), "meinberg_gps_version=\"%x.%02x%s%s\"",
(gps_sw_rev.code >> 8) & 0xFF,
@@ -4300,33 +4329,35 @@ gps16x_message(
}
break;
- case GPS_STAT:
+ case GPS_BVAR_STAT:
{
static struct state
{
- unsigned short flag; /* status flag */
- unsigned const char *string; /* bit name */
+ BVAR_STAT flag; /* status flag */
+ const char *string; /* bit name */
} states[] =
{
- { TM_ANT_DISCONN, (const unsigned char *)"ANTENNA FAULTY" },
- { TM_SYN_FLAG, (const unsigned char *)"NO SYNC SIGNAL" },
- { TM_NO_SYNC, (const unsigned char *)"NO SYNC POWERUP" },
- { TM_NO_POS, (const unsigned char *)"NO POSITION" },
- { 0, (const unsigned char *)"" }
+ { BVAR_CFGH_INVALID, "Configuration/Health" },
+ { BVAR_ALM_NOT_COMPLETE, "Almanachs" },
+ { BVAR_UTC_INVALID, "UTC Correction" },
+ { BVAR_IONO_INVALID, "Ionospheric Correction" },
+ { BVAR_RCVR_POS_INVALID, "Receiver Position" },
+ { 0, "" }
};
- unsigned short status;
+ BVAR_STAT status;
struct state *s = states;
char buffer[512];
char *p, *b;
-
- status = get_lsb_short(&bufp);
+
+ status = (BVAR_STAT) get_lsb_short(&bufp);
p = b = buffer;
p = ap(buffer, sizeof(buffer), p,
"meinberg_gps_status=\"[0x%04x] ",
status);
-
+
if (status)
{
+ p = ap(buffer, sizeof(buffer), p, "incomplete buffered data: ");
b = p;
while (s->flag)
{
@@ -4336,7 +4367,7 @@ gps16x_message(
{
p = ap(buffer, sizeof(buffer), p, ", ");
}
-
+
p = ap(buffer, sizeof(buffer), p, "%s", (const char *)s->string);
}
s++;
@@ -4345,9 +4376,9 @@ gps16x_message(
}
else
{
- p = ap(buffer, sizeof(buffer), p, "<OK>\"");
+ p = ap(buffer, sizeof(buffer), p, "<all buffered data complete>\"");
}
-
+
set_var(&parse->kv, buffer, strlen(buffer)+1, RO|DEF);
}
break;
@@ -4356,228 +4387,204 @@ gps16x_message(
{
XYZ xyz;
char buffer[256];
-
+
get_mbg_xyz(&bufp, xyz);
snprintf(buffer, sizeof(buffer), "gps_position(XYZ)=\"%s m, %s m, %s m\"",
mfptoa(xyz[XP].l_ui, xyz[XP].l_uf, 1),
mfptoa(xyz[YP].l_ui, xyz[YP].l_uf, 1),
mfptoa(xyz[ZP].l_ui, xyz[ZP].l_uf, 1));
-
+
set_var(&parse->kv, buffer, sizeof(buffer), RO|DEF);
}
break;
-
+
case GPS_POS_LLA:
{
LLA lla;
char buffer[256];
-
+
get_mbg_lla(&bufp, lla);
-
+
snprintf(buffer, sizeof(buffer), "gps_position(LLA)=\"%s deg, %s deg, %s m\"",
mfptoa(lla[LAT].l_ui, lla[LAT].l_uf, 4),
- mfptoa(lla[LON].l_ui, lla[LON].l_uf, 4),
+ mfptoa(lla[LON].l_ui, lla[LON].l_uf, 4),
mfptoa(lla[ALT].l_ui, lla[ALT].l_uf, 1));
-
+
set_var(&parse->kv, buffer, sizeof(buffer), RO|DEF);
}
break;
-
+
case GPS_TZDL:
break;
-
+
case GPS_PORT_PARM:
break;
-
+
case GPS_SYNTH:
break;
-
+
case GPS_ANT_INFO:
{
ANT_INFO antinfo;
char buffer[512];
char *p, *q;
-
+
get_mbg_antinfo(&bufp, &antinfo);
p = buffer;
p = ap(buffer, sizeof(buffer), p, "meinberg_antenna_status=\"");
switch (antinfo.status)
{
- case ANT_INVALID:
+ case ANT_INVALID: // No other fields valid since antenna has not yet been disconnected
p = ap(buffer, sizeof(buffer),
p, "<OK>");
break;
-
- case ANT_DISCONN:
+
+ case ANT_DISCONN: // Antenna is disconnected, tm_reconn and delta_t not yet set
q = ap(buffer, sizeof(buffer),
p, "DISCONNECTED since ");
NLOG(NLOG_CLOCKSTATUS)
ERR(ERR_BADSTATUS)
msyslog(LOG_ERR,"PARSE receiver #%d: ANTENNA FAILURE: %s",
CLK_UNIT(parse->peer), p);
-
+
p = q;
- mbg_tm_str(&p, &antinfo.tm_disconn, BUFFER_SIZE(buffer, p));
+ mbg_tm_str(&p, &antinfo.tm_disconn, BUFFER_SIZE(buffer, p), 0);
*p = '\0';
break;
-
- case ANT_RECONN:
+
+ case ANT_RECONN: // Antenna had been disconnect, but receiver sync. after reconnect, so all fields valid
p = ap(buffer, sizeof(buffer),
- p, "RECONNECTED on ");
- mbg_tm_str(&p, &antinfo.tm_reconn, BUFFER_SIZE(buffer, p));
+ p, "SYNC AFTER RECONNECT on ");
+ mbg_tm_str(&p, &antinfo.tm_reconn, BUFFER_SIZE(buffer, p), 0);
p = ap(buffer, sizeof(buffer),
- p, ", reconnect clockoffset %c%ld.%07ld s, disconnect time ",
+ p, ", clock offset at reconnect %c%ld.%07ld s, disconnect time ",
(antinfo.delta_t < 0) ? '-' : '+',
- ABS(antinfo.delta_t) / 10000,
- ABS(antinfo.delta_t) % 10000);
- mbg_tm_str(&p, &antinfo.tm_disconn, BUFFER_SIZE(buffer, p));
+ (long) ABS(antinfo.delta_t) / 10000,
+ (long) ABS(antinfo.delta_t) % 10000);
+ mbg_tm_str(&p, &antinfo.tm_disconn, BUFFER_SIZE(buffer, p), 0);
*p = '\0';
break;
-
+
default:
p = ap(buffer, sizeof(buffer),
p, "bad status 0x%04x",
antinfo.status);
break;
}
-
+
p = ap(buffer, sizeof(buffer), p, "\"");
-
+
set_var(&parse->kv, buffer, sizeof(buffer), RO|DEF);
}
break;
-
+
case GPS_UCAP:
break;
-
+
case GPS_CFGH:
{
CFGH cfgh;
char buffer[512];
char *p;
-
+
get_mbg_cfgh(&bufp, &cfgh);
if (cfgh.valid)
{
+ const char *cp;
+ uint16_t tmp_val;
int i;
-
+
p = buffer;
p = ap(buffer, sizeof(buffer),
p, "gps_tot_51=\"");
mbg_tgps_str(&p, &cfgh.tot_51, BUFFER_SIZE(buffer, p));
p = ap(buffer, sizeof(buffer),
p, "\"");
- set_var(&parse->kv, buffer, sizeof(buffer), RO);
-
+ set_var(&parse->kv, buffer, sizeof(buffer), RO|COND_DEF);
+
p = buffer;
p = ap(buffer, sizeof(buffer),
p, "gps_tot_63=\"");
mbg_tgps_str(&p, &cfgh.tot_63, BUFFER_SIZE(buffer, p));
p = ap(buffer, sizeof(buffer),
p, "\"");
- set_var(&parse->kv, buffer, sizeof(buffer), RO);
-
+ set_var(&parse->kv, buffer, sizeof(buffer), RO|COND_DEF);
+
p = buffer;
p = ap(buffer, sizeof(buffer),
p, "gps_t0a=\"");
mbg_tgps_str(&p, &cfgh.t0a, BUFFER_SIZE(buffer, p));
p = ap(buffer, sizeof(buffer),
p, "\"");
- set_var(&parse->kv, buffer, sizeof(buffer), RO);
-
- for (i = MIN_SVNO; i < MAX_SVNO; i++)
+ set_var(&parse->kv, buffer, sizeof(buffer), RO|COND_DEF);
+
+ for (i = 0; i < N_SVNO_GPS; i++)
{
p = buffer;
- p = ap(buffer, sizeof(buffer), p, "gps_cfg[%d]=\"[0x%x] ", i, cfgh.cfg[i]);
- switch (cfgh.cfg[i] & 0x7)
- {
- case 0:
- p = ap(buffer, sizeof(buffer), p, "BLOCK I");
- break;
- case 1:
- p = ap(buffer, sizeof(buffer), p, "BLOCK II");
- break;
- default:
- p = ap(buffer, sizeof(buffer), p, "bad CFG");
- break;
- }
- p = ap(buffer, sizeof(buffer), p, "\"");
- set_var(&parse->kv, buffer, sizeof(buffer), RO);
-
- p = buffer;
- p = ap(buffer, sizeof(buffer), p, "gps_health[%d]=\"[0x%x] ", i, cfgh.health[i]);
- switch ((cfgh.health[i] >> 5) & 0x7 )
- {
- case 0:
- p = ap(buffer, sizeof(buffer), p, "OK;");
- break;
- case 1:
- p = ap(buffer, sizeof(buffer), p, "PARITY;");
- break;
- case 2:
- p = ap(buffer, sizeof(buffer), p, "TLM/HOW;");
- break;
- case 3:
- p = ap(buffer, sizeof(buffer), p, "Z-COUNT;");
- break;
- case 4:
- p = ap(buffer, sizeof(buffer), p, "SUBFRAME 1,2,3;");
- break;
- case 5:
- p = ap(buffer, sizeof(buffer), p, "SUBFRAME 4,5;");
- break;
- case 6:
- p = ap(buffer, sizeof(buffer), p, "UPLOAD BAD;");
- break;
- case 7:
- p = ap(buffer, sizeof(buffer), p, "DATA BAD;");
- break;
+ p = ap(buffer, sizeof(buffer), p, "sv_info[%d]=\"PRN%d", i, i + N_SVNO_GPS);
+
+ tmp_val = cfgh.health[i]; /* a 6 bit SV health code */
+ p = ap(buffer, sizeof(buffer), p, "; health=0x%02x (", tmp_val);
+ /* "All Ones" has a special meaning" */
+ if (tmp_val == 0x3F) /* satellite is unusable or doesn't even exist */
+ cp = "SV UNAVAILABLE";
+ else {
+ /* The MSB contains a summary of the 3 MSBs of the 8 bit health code,
+ * indicating if the data sent by the satellite is OK or not. */
+ p = ap(buffer, sizeof(buffer), p, "DATA %s, ", (tmp_val & 0x20) ? "BAD" : "OK" );
+
+ /* The 5 LSBs contain the status of the different signals sent by the satellite. */
+ switch (tmp_val & 0x1F)
+ {
+ case 0x00: cp = "SIGNAL OK"; break;
+ /* codes 0x01 through 0x1B indicate that one or more
+ * specific signal components are weak or dead.
+ * We don't decode this here in detail. */
+ case 0x1C: cp = "SV IS TEMP OUT"; break;
+ case 0x1D: cp = "SV WILL BE TEMP OUT"; break;
+ default: cp = "TRANSMISSION PROBLEMS"; break;
+ }
}
-
- switch (cfgh.health[i] & 0x1F)
+ p = ap(buffer, sizeof(buffer), p, "%s)", cp );
+
+ tmp_val = cfgh.cfg[i]; /* a 4 bit SV configuration/type code */
+ p = ap(buffer, sizeof(buffer), p, "; cfg=0x%02x (", tmp_val);
+ switch (tmp_val & 0x7)
{
- case 0:
- p = ap(buffer, sizeof(buffer), p, "SIGNAL OK");
- break;
- case 0x1C:
- p = ap(buffer, sizeof(buffer), p, "SV TEMP OUT");
- break;
- case 0x1D:
- p = ap(buffer, sizeof(buffer), p, "SV WILL BE TEMP OUT");
- break;
- case 0x1E:
- break;
- case 0x1F:
- p = ap(buffer, sizeof(buffer), p, "MULTIPLE ERRS");
- break;
- default:
- p = ap(buffer, sizeof(buffer), p, "TRANSMISSION PROBLEMS");
- break;
+ case 0x00: cp = "(reserved)"; break;
+ case 0x01: cp = "BLOCK II/IIA/IIR"; break;
+ case 0x02: cp = "BLOCK IIR-M"; break;
+ case 0x03: cp = "BLOCK IIF"; break;
+ case 0x04: cp = "BLOCK III"; break;
+ default: cp = "unknown SV type"; break;
}
-
- p = ap(buffer, sizeof(buffer), p, "\"");
- set_var(&parse->kv, buffer, sizeof(buffer), RO);
+ p = ap(buffer, sizeof(buffer), p, "%s", cp );
+ if (tmp_val & 0x08) /* A-S is on, P-code is encrypted */
+ p = ap( buffer, sizeof(buffer), p, ", A-S on" );
+
+ p = ap(buffer, sizeof(buffer), p, ")\"");
+ set_var(&parse->kv, buffer, sizeof(buffer), RO|COND_DEF);
}
}
}
break;
-
+
case GPS_ALM:
break;
-
+
case GPS_EPH:
break;
-
+
case GPS_UTC:
{
UTC utc;
char buffer[512];
char *p;
-
+
p = buffer;
-
+
get_mbg_utc(&bufp, &utc);
-
+
if (utc.valid)
{
p = ap(buffer, sizeof(buffer), p, "gps_utc_correction=\"");
@@ -4592,46 +4599,47 @@ gps16x_message(
set_var(&parse->kv, buffer, sizeof(buffer), RO|DEF);
}
break;
-
+
case GPS_IONO:
break;
-
+
case GPS_ASCII_MSG:
{
ASCII_MSG gps_ascii_msg;
char buffer[128];
-
+
get_mbg_ascii_msg(&bufp, &gps_ascii_msg);
-
+
if (gps_ascii_msg.valid)
{
char buffer1[128];
mkreadable(buffer1, sizeof(buffer1), gps_ascii_msg.s, strlen(gps_ascii_msg.s), (int)0);
-
+
snprintf(buffer, sizeof(buffer), "gps_message=\"%s\"", buffer1);
}
else
snprintf(buffer, sizeof(buffer), "gps_message=<NONE>");
-
+
set_var(&parse->kv, buffer, sizeof(buffer), RO|DEF);
}
-
+
break;
-
+
default:
break;
}
}
else
{
- msyslog(LOG_DEBUG, "PARSE receiver #%d: gps16x_message: message checksum error: hdr_csum = 0x%x (expected 0x%lx), data_len = %d, data_csum = 0x%x (expected 0x%lx)",
+ msyslog(LOG_DEBUG, "PARSE receiver #%d: gps16x_message: message checksum error: hdr_csum = 0x%x (expected 0x%x), "
+ "data_len = %d, data_csum = 0x%x (expected 0x%x)",
CLK_UNIT(parse->peer),
- header.gps_hdr_csum, mbg_csum(parsetime->parse_msg + 1, 6),
- header.gps_len,
- header.gps_data_csum, mbg_csum(bufp, (unsigned)((header.gps_len < sizeof(parsetime->parse_msg)) ? header.gps_len : 0)));
+ header.hdr_csum, mbg_csum(parsetime->parse_msg + 1, 6),
+ header.len,
+ header.data_csum, mbg_csum(bufp, (unsigned)((header.len < sizeof(parsetime->parse_msg)) ? header.len : 0)));
}
}
-
+
return;
}
@@ -4644,11 +4652,11 @@ gps16x_poll(
)
{
struct parseunit *parse = peer->procptr->unitptr;
-
- static GPS_MSG_HDR sequence[] =
+
+ static GPS_MSG_HDR sequence[] =
{
{ GPS_SW_REV, 0, 0, 0 },
- { GPS_STAT, 0, 0, 0 },
+ { GPS_BVAR_STAT, 0, 0, 0 },
{ GPS_UTC, 0, 0, 0 },
{ GPS_ASCII_MSG, 0, 0, 0 },
{ GPS_ANT_INFO, 0, 0, 0 },
@@ -4662,41 +4670,41 @@ gps16x_poll(
unsigned char cmd_buffer[64];
unsigned char *outp = cmd_buffer;
GPS_MSG_HDR *header;
-
+
if (((poll_info_t *)parse->parse_type->cl_data)->rate)
{
parse->peer->procptr->nextaction = current_time + ((poll_info_t *)parse->parse_type->cl_data)->rate;
}
- if (sequence[parse->localstate].gps_cmd == (unsigned short)~0)
+ if (sequence[parse->localstate].cmd == (unsigned short)~0)
parse->localstate = 0;
-
+
header = sequence + parse->localstate++;
-
+
*outp++ = SOH; /* start command */
-
+
put_mbg_header(&outp, header);
outp = cmd_buffer + 1;
-
- header->gps_hdr_csum = (short)mbg_csum(outp, 6);
+
+ header->hdr_csum = (short)mbg_csum(outp, 6);
put_mbg_header(&outp, header);
-
+
#ifdef DEBUG
if (debug > 2)
{
char buffer[128];
-
+
mkreadable(buffer, sizeof(buffer), (char *)cmd_buffer, (unsigned)(outp - cmd_buffer), 1);
printf("PARSE receiver #%d: transmitted message #%ld (%d bytes) >%s<\n",
CLK_UNIT(parse->peer),
parse->localstate - 1,
(int)(outp - cmd_buffer),
- buffer);
+ buffer);
}
#endif
-
- rtc = write(parse->generic->io.fd, cmd_buffer, (unsigned long)(outp - cmd_buffer));
-
+
+ rtc = (int) write(parse->generic->io.fd, cmd_buffer, (unsigned long)(outp - cmd_buffer));
+
if (rtc < 0)
{
ERR(ERR_BADIO)
@@ -4745,7 +4753,7 @@ gps16x_poll_init(
return 1;
}
#endif /* CLOCK_MEINBERG */
-
+
/**===========================================================================
** clock polling support
**/
@@ -4758,11 +4766,11 @@ poll_dpoll(
struct parseunit *parse
)
{
- int rtc;
+ long rtc;
const char *ps = ((poll_info_t *)parse->parse_type->cl_data)->string;
- int ct = ((poll_info_t *)parse->parse_type->cl_data)->count;
+ long ct = ((poll_info_t *)parse->parse_type->cl_data)->count;
- rtc = write(parse->generic->io.fd, ps, (unsigned long)ct);
+ rtc = write(parse->generic->io.fd, ps, ct);
if (rtc < 0)
{
ERR(ERR_BADIO)
@@ -4772,7 +4780,7 @@ poll_dpoll(
if (rtc != ct)
{
ERR(ERR_BADIO)
- msyslog(LOG_ERR, "PARSE receiver #%d: poll_dpoll: failed to send cmd incomplete (%d of %d bytes sent)", CLK_UNIT(parse->peer), rtc, ct);
+ msyslog(LOG_ERR, "PARSE receiver #%d: poll_dpoll: failed to send cmd incomplete (%ld of %ld bytes sent)", CLK_UNIT(parse->peer), rtc, ct);
}
clear_err(parse, ERR_BADIO);
}
@@ -4786,7 +4794,7 @@ poll_poll(
)
{
struct parseunit *parse = peer->procptr->unitptr;
-
+
if (parse->parse_type->cl_poll)
parse->parse_type->cl_poll(parse);
@@ -4812,7 +4820,7 @@ poll_init(
return 0;
}
-
+
/**===========================================================================
** Trimble support
**/
@@ -4842,7 +4850,7 @@ trimbletaip_init(
else
{
tio.c_cc[VEOL] = TRIMBLETAIP_EOL;
-
+
if (TTY_SETATTR(parse->generic->io.fd, &tio) == -1)
{
msyslog(LOG_ERR, "PARSE receiver #%d: trimbletaip_init: tcsetattr(fd, &tio): %m", CLK_UNIT(parse->peer));
@@ -4861,7 +4869,7 @@ static const char *taipinit[] = {
">FTM00020001<",
(char *)0
};
-
+
static void
trimbletaip_event(
struct parseunit *parse,
@@ -4878,7 +4886,7 @@ trimbletaip_event(
iv = taipinit;
while (*iv)
{
- int rtc = write(parse->generic->io.fd, *iv, strlen(*iv));
+ int rtc = (int) write(parse->generic->io.fd, *iv, strlen(*iv));
if (rtc < 0)
{
msyslog(LOG_ERR, "PARSE receiver #%d: trimbletaip_event: failed to send cmd to clock: %m", CLK_UNIT(parse->peer));
@@ -5006,19 +5014,19 @@ union uval {
float fv;
double dv;
};
-
+
struct txbuf
{
short idx; /* index to first unused byte */
u_char *txt; /* pointer to actual data buffer */
};
-void sendcmd (struct txbuf *buf, int c);
-void sendbyte (struct txbuf *buf, int b);
-void sendetx (struct txbuf *buf, struct parseunit *parse);
-void sendint (struct txbuf *buf, int a);
-void sendflt (struct txbuf *buf, double a);
-
+void sendcmd (struct txbuf *buf, int c);
+void sendbyte (struct txbuf *buf, int b);
+void sendetx (struct txbuf *buf, struct parseunit *parse);
+void sendint (struct txbuf *buf, int a);
+void sendflt (struct txbuf *buf, double a);
+
void
sendcmd(
struct txbuf *buf,
@@ -5030,12 +5038,12 @@ sendcmd(
buf->idx = 2;
}
-void sendcmd (struct txbuf *buf, int c);
-void sendbyte (struct txbuf *buf, int b);
-void sendetx (struct txbuf *buf, struct parseunit *parse);
-void sendint (struct txbuf *buf, int a);
-void sendflt (struct txbuf *buf, double a);
-
+void sendcmd (struct txbuf *buf, int c);
+void sendbyte (struct txbuf *buf, int b);
+void sendetx (struct txbuf *buf, struct parseunit *parse);
+void sendint (struct txbuf *buf, int a);
+void sendflt (struct txbuf *buf, double a);
+
void
sendbyte(
struct txbuf *buf,
@@ -5067,18 +5075,18 @@ sendetx(
if (debug > 2)
{
char buffer[256];
-
+
mkreadable(buffer, sizeof(buffer), (char *)buf->txt, (unsigned)buf->idx, 1);
printf("PARSE receiver #%d: transmitted message (%d bytes) >%s<\n",
CLK_UNIT(parse->peer),
- buf->idx, buffer);
+ buf->idx, buffer);
}
#endif
clear_err(parse, ERR_BADIO);
}
}
-void
+void
sendint(
struct txbuf *buf,
int a
@@ -5098,7 +5106,7 @@ sendflt(
int i;
union uval uval;
- uval.fv = a;
+ uval.fv = (float) a;
#ifdef WORDS_BIGENDIAN
for (i=0; i<=3; i++)
#else
@@ -5130,12 +5138,12 @@ trimbletsip_setup(
if (t)
t->last_reset = current_time;
-
+
buf.txt = buffer;
-
+
sendcmd(&buf, CMD_CVERSION); /* request software versions */
sendetx(&buf, parse);
-
+
sendcmd(&buf, CMD_COPERPARAM); /* set operating parameters */
sendbyte(&buf, 4); /* static */
sendflt(&buf, 5.0*D2R); /* elevation angle mask = 10 deg XXX */
@@ -5143,25 +5151,25 @@ trimbletsip_setup(
sendflt(&buf, 12.0); /* PDOP mask = 12 */
sendflt(&buf, 8.0); /* PDOP switch level = 8 */
sendetx(&buf, parse);
-
+
sendcmd(&buf, CMD_CMODESEL); /* fix mode select */
sendbyte(&buf, 1); /* time transfer mode */
sendetx(&buf, parse);
-
+
sendcmd(&buf, CMD_CMESSAGE); /* request system message */
sendetx(&buf, parse);
-
+
sendcmd(&buf, CMD_CSUPER); /* superpacket fix */
sendbyte(&buf, 0x2); /* binary mode */
sendetx(&buf, parse);
-
+
sendcmd(&buf, CMD_CIOOPTIONS); /* set I/O options */
sendbyte(&buf, TRIM_POS_OPT); /* position output */
sendbyte(&buf, 0x00); /* no velocity output */
sendbyte(&buf, TRIM_TIME_OPT); /* UTC, compute on seconds */
sendbyte(&buf, 0x00); /* no raw measurements */
sendetx(&buf, parse);
-
+
sendcmd(&buf, CMD_CUTCPARAM); /* request UTC correction data */
sendetx(&buf, parse);
@@ -5185,7 +5193,7 @@ trimble_check(
u_char buffer[256];
struct txbuf buf;
buf.txt = buffer;
-
+
if (t)
{
if (current_time > t->last_msg + TRIMBLETSIP_IDLE_TIME)
@@ -5193,18 +5201,18 @@ trimble_check(
}
poll_poll(parse->peer); /* emit query string and re-arm timer */
-
+
if (t && t->qtracking)
{
u_long oldsats = t->ltrack & ~t->ctrack;
-
+
t->qtracking = 0;
t->ltrack = t->ctrack;
-
+
if (oldsats)
{
int i;
-
+
for (i = 0; oldsats; i++) {
if (oldsats & (1 << i))
{
@@ -5215,7 +5223,7 @@ trimble_check(
oldsats &= ~(1 << i);
}
}
-
+
sendcmd(&buf, CMD_CSTATTRACK);
sendbyte(&buf, 0x00); /* current tracking set */
sendetx(&buf, parse);
@@ -5230,7 +5238,7 @@ trimbletsip_end(
struct parseunit *parse
)
{ trimble_t *t = parse->localdata;
-
+
if (t)
{
free(t);
@@ -5261,9 +5269,9 @@ trimbletsip_init(
if (!parse->localdata)
{
trimble_t *t;
-
+
t = (trimble_t *)(parse->localdata = emalloc(sizeof(trimble_t)));
-
+
if (t)
{
memset((char *)t, 0, sizeof(trimble_t));
@@ -5343,7 +5351,7 @@ getflt(
)
{
union uval uval;
-
+
#ifdef WORDS_BIGENDIAN
uval.bd[0] = *bp++;
uval.bd[1] = *bp++;
@@ -5364,7 +5372,7 @@ getdbl(
)
{
union uval uval;
-
+
#ifdef WORDS_BIGENDIAN
uval.bd[0] = *bp++;
uval.bd[1] = *bp++;
@@ -5392,7 +5400,7 @@ getshort(
unsigned char *p
)
{
- return get_msb_short(&p);
+ return (int) get_msb_short(&p);
}
/*--------------------------------------------------
@@ -5409,7 +5417,7 @@ trimbletsip_message(
{
unsigned char *buffer = parsetime->parse_msg;
unsigned int size = parsetime->parse_msglen;
-
+
if ((size < 4) ||
(buffer[0] != DLE) ||
(buffer[size-1] != ETX) ||
@@ -5431,13 +5439,13 @@ trimbletsip_message(
}
else
{
- int var_flag;
+ u_short var_flag;
trimble_t *tr = parse->localdata;
unsigned int cmd = buffer[1];
char pbuffer[200];
char *t = pbuffer;
cmd_info_t *s;
-
+
#ifdef DEBUG
if (debug > 3) {
size_t i;
@@ -5453,9 +5461,9 @@ trimbletsip_message(
if (tr)
tr->last_msg = current_time;
-
+
s = trimble_convert(cmd, trimble_rcmds);
-
+
if (s)
{
t = ap(pbuffer, sizeof(pbuffer), t, "%s=\"", s->varname);
@@ -5466,7 +5474,7 @@ trimbletsip_message(
return;
}
- var_flag = s->varmode;
+ var_flag = (u_short) s->varmode;
switch(cmd)
{
@@ -5475,7 +5483,7 @@ trimbletsip_message(
getflt((unsigned char *)&mb(0)), getshort((unsigned char *)&mb(4)),
getflt((unsigned char *)&mb(6)));
break;
-
+
case CMD_RBEST4:
t = ap(pbuffer, sizeof(pbuffer), t, "mode: ");
switch (mb(0) & 0xF)
@@ -5488,11 +5496,11 @@ trimbletsip_message(
case 1:
t = ap(pbuffer, sizeof(pbuffer), t, "0D");
break;
-
+
case 3:
t = ap(pbuffer, sizeof(pbuffer), t, "2D");
break;
-
+
case 4:
t = ap(pbuffer, sizeof(pbuffer), t, "3D");
break;
@@ -5501,7 +5509,7 @@ trimbletsip_message(
t = ap(pbuffer, sizeof(pbuffer), t, "-MANUAL, ");
else
t = ap(pbuffer, sizeof(pbuffer), t, "-AUTO, ");
-
+
t = ap(pbuffer, sizeof(pbuffer), t, "satellites %02d %02d %02d %02d, PDOP %.2f, HDOP %.2f, VDOP %.2f, TDOP %.2f",
mb(1), mb(2), mb(3), mb(4),
getflt((unsigned char *)&mb(5)),
@@ -5510,12 +5518,12 @@ trimbletsip_message(
getflt((unsigned char *)&mb(17)));
break;
-
+
case CMD_RVERSION:
t = ap(pbuffer, sizeof(pbuffer), t, "%d.%d (%d/%d/%d)",
mb(0)&0xff, mb(1)&0xff, 1900+(mb(4)&0xff), mb(2)&0xff, mb(3)&0xff);
break;
-
+
case CMD_RRECVHEALTH:
{
static const char *msgs[] =
@@ -5529,9 +5537,9 @@ trimbletsip_message(
"<BIT 6>",
"<BIT 7>"
};
-
+
int i, bits;
-
+
switch (mb(0) & 0xFF)
{
default:
@@ -5564,7 +5572,7 @@ trimbletsip_message(
}
bits = mb(1) & 0xFF;
-
+
for (i = 0; i < 8; i++)
if (bits & (0x1<<i))
{
@@ -5572,11 +5580,11 @@ trimbletsip_message(
}
}
break;
-
+
case CMD_RMESSAGE:
mkreadable(t, (int)BUFFER_SIZE(pbuffer, t), (char *)&mb(0), (unsigned)(size - 2 - (&mb(0) - buffer)), 0);
break;
-
+
case CMD_RMACHSTAT:
{
static const char *msgs[] =
@@ -5590,12 +5598,12 @@ trimbletsip_message(
"<BIT 6>",
"<BIT 7>"
};
-
+
int i, bits;
t = ap(pbuffer, sizeof(pbuffer), t, "machine id 0x%02x", mb(0) & 0xFF);
bits = mb(1) & 0xFF;
-
+
for (i = 0; i < 8; i++)
if (bits & (0x1<<i))
{
@@ -5605,21 +5613,21 @@ trimbletsip_message(
t = ap(pbuffer, sizeof(pbuffer), t, ", Superpackets %ssupported", (mb(2) & 0xFF) ? "" :"un" );
}
break;
-
+
case CMD_ROPERPARAM:
t = ap(pbuffer, sizeof(pbuffer), t, "%2x %.1f %.1f %.1f %.1f",
mb(0), getflt((unsigned char *)&mb(1)), getflt((unsigned char *)&mb(5)),
getflt((unsigned char *)&mb(9)), getflt((unsigned char *)&mb(13)));
break;
-
+
case CMD_RUTCPARAM:
{
float t0t = getflt((unsigned char *)&mb(14));
- short wnt = getshort((unsigned char *)&mb(18));
- short dtls = getshort((unsigned char *)&mb(12));
- short wnlsf = getshort((unsigned char *)&mb(20));
- short dn = getshort((unsigned char *)&mb(22));
- short dtlsf = getshort((unsigned char *)&mb(24));
+ short wnt = (short) getshort((unsigned char *)&mb(18));
+ short dtls = (short) getshort((unsigned char *)&mb(12));
+ short wnlsf = (short) getshort((unsigned char *)&mb(20));
+ short dn = (short) getshort((unsigned char *)&mb(22));
+ short dtlsf = (short) getshort((unsigned char *)&mb(24));
if ((int)t0t != 0)
{
@@ -5648,14 +5656,14 @@ trimbletsip_message(
}
}
break;
-
+
case CMD_RSPOSXYZ:
{
double x = getflt((unsigned char *)&mb(0));
double y = getflt((unsigned char *)&mb(4));
double z = getflt((unsigned char *)&mb(8));
double f = getflt((unsigned char *)&mb(12));
-
+
if (f > 0.0)
t = ap(pbuffer, sizeof(pbuffer), t, "x= %.1fm, y= %.1fm, z= %.1fm, time_of_fix= %f sec",
x, y, z,
@@ -5670,7 +5678,7 @@ trimbletsip_message(
double lat = getflt((unsigned char *)&mb(0));
double lng = getflt((unsigned char *)&mb(4));
double f = getflt((unsigned char *)&mb(12));
-
+
if (f > 0.0)
t = ap(pbuffer, sizeof(pbuffer), t, "lat %f %c, long %f %c, alt %.2fm",
((lat < 0.0) ? (-lat) : (lat))*RTOD, (lat < 0.0 ? 'S' : 'N'),
@@ -5690,7 +5698,7 @@ trimbletsip_message(
x, y, z);
}
break;
-
+
case CMD_RDOUBLELLA:
{
double lat = getdbl((unsigned char *)&mb(0));
@@ -5705,7 +5713,7 @@ trimbletsip_message(
case CMD_RALLINVIEW:
{
int i, sats;
-
+
t = ap(pbuffer, sizeof(pbuffer), t, "mode: ");
switch (mb(0) & 0x7)
{
@@ -5716,7 +5724,7 @@ trimbletsip_message(
case 3:
t = ap(pbuffer, sizeof(pbuffer), t, "2D");
break;
-
+
case 4:
t = ap(pbuffer, sizeof(pbuffer), t, "3D");
break;
@@ -5725,9 +5733,9 @@ trimbletsip_message(
t = ap(pbuffer, sizeof(pbuffer), t, "-MANUAL, ");
else
t = ap(pbuffer, sizeof(pbuffer), t, "-AUTO, ");
-
+
sats = (mb(0)>>4) & 0xF;
-
+
t = ap(pbuffer, sizeof(pbuffer), t, "PDOP %.2f, HDOP %.2f, VDOP %.2f, TDOP %.2f, %d satellite%s in view: ",
getflt((unsigned char *)&mb(1)),
getflt((unsigned char *)&mb(5)),
@@ -5748,17 +5756,17 @@ trimbletsip_message(
}
}
break;
-
+
case CMD_RSTATTRACK:
{
t = ap(pbuffer, sizeof(pbuffer), t-2, "[%02d]=\"", mb(0)); /* add index to var name */
if (getflt((unsigned char *)&mb(4)) < 0.0)
{
t = ap(pbuffer, sizeof(pbuffer), t, "<NO MEASUREMENTS>");
- var_flag &= ~DEF;
+ var_flag &= (u_short)(~DEF);
}
else
- {
+ {
t = ap(pbuffer, sizeof(pbuffer), t, "ch=%d, acq=%s, eph=%d, signal_level= %5.2f, elevation= %5.2f, azimuth= %6.2f",
(mb(1) & 0xFF)>>3,
mb(2) ? ((mb(2) == 1) ? "ACQ" : "SRCH") : "NEVER",
@@ -5768,7 +5776,7 @@ trimbletsip_message(
getflt((unsigned char *)&mb(16)) * RTOD);
if (mb(20))
{
- var_flag &= ~DEF;
+ var_flag &= (u_short)(~DEF);
t = ap(pbuffer, sizeof(pbuffer), t, ", OLD");
}
if (mb(22))
@@ -5784,18 +5792,18 @@ trimbletsip_message(
}
}
break;
-
+
default:
t = ap(pbuffer, sizeof(pbuffer), t, "<UNDECODED>");
break;
}
- t = ap(pbuffer, sizeof(pbuffer), t,"\"");
+ t = ap(pbuffer, sizeof(pbuffer), t, "\"");
set_var(&parse->kv, pbuffer, sizeof(pbuffer), var_flag);
}
}
-
+
/**============================================================
** RAWDCF support
**/
diff --git a/contrib/ntp/ntpdate/Makefile.in b/contrib/ntp/ntpdate/Makefile.in
index e0e0ec2..0dcac19 100644
--- a/contrib/ntp/ntpdate/Makefile.in
+++ b/contrib/ntp/ntpdate/Makefile.in
@@ -48,8 +48,7 @@ subdir = ntpdate
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -78,6 +77,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -329,6 +330,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/ntpdc/Makefile.in b/contrib/ntp/ntpdc/Makefile.in
index 0837bac..0bb1e30 100644
--- a/contrib/ntp/ntpdc/Makefile.in
+++ b/contrib/ntp/ntpdc/Makefile.in
@@ -50,8 +50,7 @@ subdir = ntpdc
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -80,6 +79,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -363,6 +364,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/ntpdc/invoke-ntpdc.texi b/contrib/ntp/ntpdc/invoke-ntpdc.texi
index 8a9eb27..246e51e 100644
--- a/contrib/ntp/ntpdc/invoke-ntpdc.texi
+++ b/contrib/ntp/ntpdc/invoke-ntpdc.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntpdc.texi)
#
-# It has been AutoGen-ed February 4, 2015 at 02:42:41 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:26:32 AM by AutoGen 5.18.5pre4
# From the definitions ntpdc-opts.def
# and the template file agtexi-cmd.tpl
@end ignore
@@ -76,7 +76,7 @@ with a status code of 0.
@exampleindent 0
@example
-ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p1
+ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p2
Usage: ntpdc [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... [ host ...]
Flg Arg Option-Name Description
-4 no ipv4 Force IPv4 DNS name resolution
diff --git a/contrib/ntp/ntpdc/ntpdc-opts.c b/contrib/ntp/ntpdc/ntpdc-opts.c
index 070501d..94ccea7 100644
--- a/contrib/ntp/ntpdc/ntpdc-opts.c
+++ b/contrib/ntp/ntpdc/ntpdc-opts.c
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (ntpdc-opts.c)
*
- * It has been AutoGen-ed February 4, 2015 at 02:42:23 AM by AutoGen 5.18.5pre4
+ * It has been AutoGen-ed April 7, 2015 at 04:26:14 AM by AutoGen 5.18.5pre4
* From the definitions ntpdc-opts.def
* and the template file options
*
@@ -69,7 +69,7 @@ extern FILE * option_usage_fp;
* static const strings for ntpdc options
*/
static char const ntpdc_opt_strs[1911] =
-/* 0 */ "ntpdc 4.2.8p1\n"
+/* 0 */ "ntpdc 4.2.8p2\n"
"Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n"
"This is free software. It is licensed for use, modification and\n"
"redistribution under the terms of the NTP License, copies of which\n"
@@ -128,14 +128,14 @@ static char const ntpdc_opt_strs[1911] =
/* 1694 */ "no-load-opts\0"
/* 1707 */ "no\0"
/* 1710 */ "NTPDC\0"
-/* 1716 */ "ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p1\n"
+/* 1716 */ "ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p2\n"
"Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n\0"
/* 1846 */ "$HOME\0"
/* 1852 */ ".\0"
/* 1854 */ ".ntprc\0"
/* 1861 */ "http://bugs.ntp.org, bugs@ntp.org\0"
/* 1895 */ "\n\0"
-/* 1897 */ "ntpdc 4.2.8p1";
+/* 1897 */ "ntpdc 4.2.8p2";
/**
* ipv4 option description with
@@ -796,7 +796,7 @@ static void bogus_function(void) {
translate option names.
*/
/* referenced via ntpdcOptions.pzCopyright */
- puts(_("ntpdc 4.2.8p1\n\
+ puts(_("ntpdc 4.2.8p2\n\
Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n\
This is free software. It is licensed for use, modification and\n\
redistribution under the terms of the NTP License, copies of which\n\
@@ -862,14 +862,14 @@ implied warranty.\n"));
puts(_("load options from a config file"));
/* referenced via ntpdcOptions.pzUsageTitle */
- puts(_("ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p1\n\
+ puts(_("ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p2\n\
Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n"));
/* referenced via ntpdcOptions.pzExplain */
puts(_("\n"));
/* referenced via ntpdcOptions.pzFullVersion */
- puts(_("ntpdc 4.2.8p1"));
+ puts(_("ntpdc 4.2.8p2"));
/* referenced via ntpdcOptions.pzFullUsage */
puts(_("<<<NOT-FOUND>>>"));
diff --git a/contrib/ntp/ntpdc/ntpdc-opts.h b/contrib/ntp/ntpdc/ntpdc-opts.h
index e9a3f2c..8476359 100644
--- a/contrib/ntp/ntpdc/ntpdc-opts.h
+++ b/contrib/ntp/ntpdc/ntpdc-opts.h
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (ntpdc-opts.h)
*
- * It has been AutoGen-ed February 4, 2015 at 02:42:23 AM by AutoGen 5.18.5pre4
+ * It has been AutoGen-ed April 7, 2015 at 04:26:14 AM by AutoGen 5.18.5pre4
* From the definitions ntpdc-opts.def
* and the template file options
*
@@ -83,9 +83,9 @@ typedef enum {
/** count of all options for ntpdc */
#define OPTION_CT 15
/** ntpdc version */
-#define NTPDC_VERSION "4.2.8p1"
+#define NTPDC_VERSION "4.2.8p2"
/** Full ntpdc version text */
-#define NTPDC_FULL_VERSION "ntpdc 4.2.8p1"
+#define NTPDC_FULL_VERSION "ntpdc 4.2.8p2"
/**
* Interface defines for all options. Replace "n" with the UPPER_CASED
diff --git a/contrib/ntp/ntpdc/ntpdc.1ntpdcman b/contrib/ntp/ntpdc/ntpdc.1ntpdcman
index 5a9e253..ecff16b 100644
--- a/contrib/ntp/ntpdc/ntpdc.1ntpdcman
+++ b/contrib/ntp/ntpdc/ntpdc.1ntpdcman
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntpdc 1ntpdcman "04 Feb 2015" "4.2.8p1" "User Commands"
+.TH ntpdc 1ntpdcman "07 Apr 2015" "4.2.8p2" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-DnaiLq/ag-QnaaKq)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-dXaWh5/ag-rXaOg5)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:42:37 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:26:27 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpdc-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/ntpdc/ntpdc.1ntpdcmdoc b/contrib/ntp/ntpdc/ntpdc.1ntpdcmdoc
index c1681b0..7f0c363 100644
--- a/contrib/ntp/ntpdc/ntpdc.1ntpdcmdoc
+++ b/contrib/ntp/ntpdc/ntpdc.1ntpdcmdoc
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTPDC 1ntpdcmdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpdc-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:42:44 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:26:34 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpdc-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/ntpdc/ntpdc.html b/contrib/ntp/ntpdc/ntpdc.html
index 1b6260b..37e195c 100644
--- a/contrib/ntp/ntpdc/ntpdc.html
+++ b/contrib/ntp/ntpdc/ntpdc.html
@@ -36,7 +36,7 @@ display the time offset of the system clock relative to the server
clock. Run as root, it can correct the system clock to this offset as
well. It can be run as an interactive command or from a cron job.
- <p>This document applies to version 4.2.8p1 of <code>ntpdc</code>.
+ <p>This document applies to version 4.2.8p2 of <code>ntpdc</code>.
<p>The program implements the SNTP protocol as defined by RFC 5905, the NTPv4
IETF specification.
@@ -152,7 +152,7 @@ the usage text by passing it through a pager program.
used to select the program, defaulting to <span class="file">more</span>. Both will exit
with a status code of 0.
-<pre class="example">ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p1
+<pre class="example">ntpdc - vendor-specific NTPD control program - Ver. 4.2.8p2
Usage: ntpdc [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... [ host ...]
Flg Arg Option-Name Description
-4 no ipv4 Force IPv4 DNS name resolution
diff --git a/contrib/ntp/ntpdc/ntpdc.man.in b/contrib/ntp/ntpdc/ntpdc.man.in
index 281727e..71aa128 100644
--- a/contrib/ntp/ntpdc/ntpdc.man.in
+++ b/contrib/ntp/ntpdc/ntpdc.man.in
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntpdc @NTPDC_MS@ "04 Feb 2015" "4.2.8p1" "User Commands"
+.TH ntpdc @NTPDC_MS@ "07 Apr 2015" "4.2.8p2" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-DnaiLq/ag-QnaaKq)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-dXaWh5/ag-rXaOg5)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:42:37 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:26:27 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpdc-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/ntpdc/ntpdc.mdoc.in b/contrib/ntp/ntpdc/ntpdc.mdoc.in
index d6f3feb..8a89e48 100644
--- a/contrib/ntp/ntpdc/ntpdc.mdoc.in
+++ b/contrib/ntp/ntpdc/ntpdc.mdoc.in
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTPDC @NTPDC_MS@ User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpdc-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:42:44 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:26:34 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpdc-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/ntpq/Makefile.in b/contrib/ntp/ntpq/Makefile.in
index a58363c..fad9001 100644
--- a/contrib/ntp/ntpq/Makefile.in
+++ b/contrib/ntp/ntpq/Makefile.in
@@ -50,8 +50,7 @@ subdir = ntpq
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -80,6 +79,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -370,6 +371,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/ntpq/invoke-ntpq.texi b/contrib/ntp/ntpq/invoke-ntpq.texi
index 7a1b895..505bb23 100644
--- a/contrib/ntp/ntpq/invoke-ntpq.texi
+++ b/contrib/ntp/ntpq/invoke-ntpq.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntpq.texi)
#
-# It has been AutoGen-ed February 4, 2015 at 02:43:17 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:27:07 AM by AutoGen 5.18.5pre4
# From the definitions ntpq-opts.def
# and the template file agtexi-cmd.tpl
@end ignore
@@ -835,7 +835,7 @@ with a status code of 0.
@exampleindent 0
@example
-ntpq - standard NTP query program - Ver. 4.2.8p1
+ntpq - standard NTP query program - Ver. 4.2.8p2
Usage: ntpq [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... [ host ...]
Flg Arg Option-Name Description
-4 no ipv4 Force IPv4 DNS name resolution
diff --git a/contrib/ntp/ntpq/ntpq-opts.c b/contrib/ntp/ntpq/ntpq-opts.c
index 9c4de55..74f3d3d 100644
--- a/contrib/ntp/ntpq/ntpq-opts.c
+++ b/contrib/ntp/ntpq/ntpq-opts.c
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (ntpq-opts.c)
*
- * It has been AutoGen-ed February 4, 2015 at 02:42:46 AM by AutoGen 5.18.5pre4
+ * It has been AutoGen-ed April 7, 2015 at 04:26:37 AM by AutoGen 5.18.5pre4
* From the definitions ntpq-opts.def
* and the template file options
*
@@ -69,7 +69,7 @@ extern FILE * option_usage_fp;
* static const strings for ntpq options
*/
static char const ntpq_opt_strs[1925] =
-/* 0 */ "ntpq 4.2.8p1\n"
+/* 0 */ "ntpq 4.2.8p2\n"
"Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n"
"This is free software. It is licensed for use, modification and\n"
"redistribution under the terms of the NTP License, copies of which\n"
@@ -129,13 +129,13 @@ static char const ntpq_opt_strs[1925] =
/* 1723 */ "no-load-opts\0"
/* 1736 */ "no\0"
/* 1739 */ "NTPQ\0"
-/* 1744 */ "ntpq - standard NTP query program - Ver. 4.2.8p1\n"
+/* 1744 */ "ntpq - standard NTP query program - Ver. 4.2.8p2\n"
"Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n\0"
/* 1863 */ "$HOME\0"
/* 1869 */ ".\0"
/* 1871 */ ".ntprc\0"
/* 1878 */ "http://bugs.ntp.org, bugs@ntp.org\0"
-/* 1912 */ "ntpq 4.2.8p1";
+/* 1912 */ "ntpq 4.2.8p2";
/**
* ipv4 option description with
@@ -786,7 +786,7 @@ static void bogus_function(void) {
translate option names.
*/
/* referenced via ntpqOptions.pzCopyright */
- puts(_("ntpq 4.2.8p1\n\
+ puts(_("ntpq 4.2.8p2\n\
Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n\
This is free software. It is licensed for use, modification and\n\
redistribution under the terms of the NTP License, copies of which\n\
@@ -852,11 +852,11 @@ implied warranty.\n"));
puts(_("load options from a config file"));
/* referenced via ntpqOptions.pzUsageTitle */
- puts(_("ntpq - standard NTP query program - Ver. 4.2.8p1\n\
+ puts(_("ntpq - standard NTP query program - Ver. 4.2.8p2\n\
Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n"));
/* referenced via ntpqOptions.pzFullVersion */
- puts(_("ntpq 4.2.8p1"));
+ puts(_("ntpq 4.2.8p2"));
/* referenced via ntpqOptions.pzFullUsage */
puts(_("<<<NOT-FOUND>>>"));
diff --git a/contrib/ntp/ntpq/ntpq-opts.h b/contrib/ntp/ntpq/ntpq-opts.h
index 0dfe3dd..43301b9 100644
--- a/contrib/ntp/ntpq/ntpq-opts.h
+++ b/contrib/ntp/ntpq/ntpq-opts.h
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (ntpq-opts.h)
*
- * It has been AutoGen-ed February 4, 2015 at 02:42:46 AM by AutoGen 5.18.5pre4
+ * It has been AutoGen-ed April 7, 2015 at 04:26:37 AM by AutoGen 5.18.5pre4
* From the definitions ntpq-opts.def
* and the template file options
*
@@ -83,9 +83,9 @@ typedef enum {
/** count of all options for ntpq */
#define OPTION_CT 15
/** ntpq version */
-#define NTPQ_VERSION "4.2.8p1"
+#define NTPQ_VERSION "4.2.8p2"
/** Full ntpq version text */
-#define NTPQ_FULL_VERSION "ntpq 4.2.8p1"
+#define NTPQ_FULL_VERSION "ntpq 4.2.8p2"
/**
* Interface defines for all options. Replace "n" with the UPPER_CASED
diff --git a/contrib/ntp/ntpq/ntpq-subs.c b/contrib/ntp/ntpq/ntpq-subs.c
index 56bc228..8bd4fdb 100644
--- a/contrib/ntp/ntpq/ntpq-subs.c
+++ b/contrib/ntp/ntpq/ntpq-subs.c
@@ -330,7 +330,7 @@ typedef struct var_display_collection_tag {
l_fp lfp; /* NTP_LFP */
} v; /* retrieved value */
} vdc;
-#if !defined(MISSING_C99_STYLE_INIT)
+#if !defined(MISSING_C99_STRUCT_INIT)
# define VDC_INIT(a, b, c) { .tag = a, .display = b, .type = c }
#else
# define VDC_INIT(a, b, c) { a, b, c }
diff --git a/contrib/ntp/ntpq/ntpq.1ntpqman b/contrib/ntp/ntpq/ntpq.1ntpqman
index a92f61e..444a91f 100644
--- a/contrib/ntp/ntpq/ntpq.1ntpqman
+++ b/contrib/ntp/ntpq/ntpq.1ntpqman
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntpq 1ntpqman "04 Feb 2015" "4.2.8p1" "User Commands"
+.TH ntpq 1ntpqman "07 Apr 2015" "4.2.8p2" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-oaaWVr/ag-CaaOUr)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-SOays6/ag-4Oaqr6)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:43:13 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:27:03 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpq-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/ntpq/ntpq.1ntpqmdoc b/contrib/ntp/ntpq/ntpq.1ntpqmdoc
index c55a532..d28b09e 100644
--- a/contrib/ntp/ntpq/ntpq.1ntpqmdoc
+++ b/contrib/ntp/ntpq/ntpq.1ntpqmdoc
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTPQ 1ntpqmdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpq-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:43:19 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:27:09 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpq-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/ntpq/ntpq.html b/contrib/ntp/ntpq/ntpq.html
index 757dd2b..5d7a8f3 100644
--- a/contrib/ntp/ntpq/ntpq.html
+++ b/contrib/ntp/ntpq/ntpq.html
@@ -44,7 +44,7 @@ monitor the operational status
and determine the performance of
<code>ntpd</code>, the NTP daemon.
- <p>This document applies to version 4.2.8p1 of <code>ntpq</code>.
+ <p>This document applies to version 4.2.8p2 of <code>ntpq</code>.
<ul class="menu">
<li><a accesskey="1" href="#ntpq-Description">ntpq Description</a>
@@ -759,7 +759,7 @@ the usage text by passing it through a pager program.
used to select the program, defaulting to <span class="file">more</span>. Both will exit
with a status code of 0.
-<pre class="example">ntpq - standard NTP query program - Ver. 4.2.8p1-RC2
+<pre class="example">ntpq - standard NTP query program - Ver. 4.2.8p2-RC3
Usage: ntpq [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... [ host ...]
Flg Arg Option-Name Description
-4 no ipv4 Force IPv4 DNS name resolution
diff --git a/contrib/ntp/ntpq/ntpq.man.in b/contrib/ntp/ntpq/ntpq.man.in
index f6d28cc..c5b9fb5 100644
--- a/contrib/ntp/ntpq/ntpq.man.in
+++ b/contrib/ntp/ntpq/ntpq.man.in
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntpq @NTPQ_MS@ "04 Feb 2015" "4.2.8p1" "User Commands"
+.TH ntpq @NTPQ_MS@ "07 Apr 2015" "4.2.8p2" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-oaaWVr/ag-CaaOUr)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-SOays6/ag-4Oaqr6)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:43:13 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:27:03 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpq-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/ntpq/ntpq.mdoc.in b/contrib/ntp/ntpq/ntpq.mdoc.in
index 23fe102..32224f2 100644
--- a/contrib/ntp/ntpq/ntpq.mdoc.in
+++ b/contrib/ntp/ntpq/ntpq.mdoc.in
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTPQ @NTPQ_MS@ User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpq-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:43:19 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:27:09 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpq-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/ntpsnmpd/Makefile.in b/contrib/ntp/ntpsnmpd/Makefile.in
index 2532f07..de2a81c 100644
--- a/contrib/ntp/ntpsnmpd/Makefile.in
+++ b/contrib/ntp/ntpsnmpd/Makefile.in
@@ -48,8 +48,7 @@ subdir = ntpsnmpd
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -78,6 +77,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -358,6 +359,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/ntpsnmpd/invoke-ntpsnmpd.texi b/contrib/ntp/ntpsnmpd/invoke-ntpsnmpd.texi
index 513d70c..addadab 100644
--- a/contrib/ntp/ntpsnmpd/invoke-ntpsnmpd.texi
+++ b/contrib/ntp/ntpsnmpd/invoke-ntpsnmpd.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntpsnmpd.texi)
#
-# It has been AutoGen-ed February 4, 2015 at 02:43:32 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:27:22 AM by AutoGen 5.18.5pre4
# From the definitions ntpsnmpd-opts.def
# and the template file agtexi-cmd.tpl
@end ignore
@@ -47,7 +47,7 @@ with a status code of 0.
@exampleindent 0
@example
-ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p1
+ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p2
Usage: ntpsnmpd [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]...
Flg Arg Option-Name Description
-n no nofork Do not fork
diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.c b/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.c
index 0f8622e..7e0d34c 100644
--- a/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.c
+++ b/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.c
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (ntpsnmpd-opts.c)
*
- * It has been AutoGen-ed February 4, 2015 at 02:43:22 AM by AutoGen 5.18.5pre4
+ * It has been AutoGen-ed April 7, 2015 at 04:27:12 AM by AutoGen 5.18.5pre4
* From the definitions ntpsnmpd-opts.def
* and the template file options
*
@@ -61,7 +61,7 @@ extern FILE * option_usage_fp;
* static const strings for ntpsnmpd options
*/
static char const ntpsnmpd_opt_strs[1610] =
-/* 0 */ "ntpsnmpd 4.2.8p1\n"
+/* 0 */ "ntpsnmpd 4.2.8p2\n"
"Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n"
"This is free software. It is licensed for use, modification and\n"
"redistribution under the terms of the NTP License, copies of which\n"
@@ -101,14 +101,14 @@ static char const ntpsnmpd_opt_strs[1610] =
/* 1414 */ "no-load-opts\0"
/* 1427 */ "no\0"
/* 1430 */ "NTPSNMPD\0"
-/* 1439 */ "ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p1\n"
+/* 1439 */ "ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p2\n"
"Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n\0"
/* 1542 */ "$HOME\0"
/* 1548 */ ".\0"
/* 1550 */ ".ntprc\0"
/* 1557 */ "http://bugs.ntp.org, bugs@ntp.org\0"
/* 1591 */ "\n\0"
-/* 1593 */ "ntpsnmpd 4.2.8p1";
+/* 1593 */ "ntpsnmpd 4.2.8p2";
/**
* nofork option description:
@@ -554,7 +554,7 @@ static void bogus_function(void) {
translate option names.
*/
/* referenced via ntpsnmpdOptions.pzCopyright */
- puts(_("ntpsnmpd 4.2.8p1\n\
+ puts(_("ntpsnmpd 4.2.8p2\n\
Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n\
This is free software. It is licensed for use, modification and\n\
redistribution under the terms of the NTP License, copies of which\n\
@@ -599,14 +599,14 @@ implied warranty.\n"));
puts(_("load options from a config file"));
/* referenced via ntpsnmpdOptions.pzUsageTitle */
- puts(_("ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p1\n\
+ puts(_("ntpsnmpd - NTP SNMP MIB agent - Ver. 4.2.8p2\n\
Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n"));
/* referenced via ntpsnmpdOptions.pzExplain */
puts(_("\n"));
/* referenced via ntpsnmpdOptions.pzFullVersion */
- puts(_("ntpsnmpd 4.2.8p1"));
+ puts(_("ntpsnmpd 4.2.8p2"));
/* referenced via ntpsnmpdOptions.pzFullUsage */
puts(_("<<<NOT-FOUND>>>"));
diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.h b/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.h
index 9b92041..5469615 100644
--- a/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.h
+++ b/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.h
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (ntpsnmpd-opts.h)
*
- * It has been AutoGen-ed February 4, 2015 at 02:43:21 AM by AutoGen 5.18.5pre4
+ * It has been AutoGen-ed April 7, 2015 at 04:27:12 AM by AutoGen 5.18.5pre4
* From the definitions ntpsnmpd-opts.def
* and the template file options
*
@@ -76,9 +76,9 @@ typedef enum {
/** count of all options for ntpsnmpd */
#define OPTION_CT 8
/** ntpsnmpd version */
-#define NTPSNMPD_VERSION "4.2.8p1"
+#define NTPSNMPD_VERSION "4.2.8p2"
/** Full ntpsnmpd version text */
-#define NTPSNMPD_FULL_VERSION "ntpsnmpd 4.2.8p1"
+#define NTPSNMPD_FULL_VERSION "ntpsnmpd 4.2.8p2"
/**
* Interface defines for all options. Replace "n" with the UPPER_CASED
diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdman b/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdman
index 1c44243..9724e26e 100644
--- a/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdman
+++ b/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdman
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntpsnmpd 1ntpsnmpdman "04 Feb 2015" "4.2.8p1" "User Commands"
+.TH ntpsnmpd 1ntpsnmpdman "07 Apr 2015" "4.2.8p2" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-T1aO3s/ag-51aG2s)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-wFai4a/ag-JFaa3a)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:43:29 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:27:19 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpsnmpd-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc b/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc
index 9374142..7326bee 100644
--- a/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc
+++ b/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTPSNMPD 1ntpsnmpdmdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpsnmpd-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:43:34 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:27:25 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpsnmpd-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd.html b/contrib/ntp/ntpsnmpd/ntpsnmpd.html
index 983b6de..9d570bb 100644
--- a/contrib/ntp/ntpsnmpd/ntpsnmpd.html
+++ b/contrib/ntp/ntpsnmpd/ntpsnmpd.html
@@ -42,7 +42,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>
<p>The <code>ntpsnmpd</code> utility program is used to monitor NTP daemon <code>ntpd</code>
operations and determine performance. It uses the standard NTP mode 6 control
- <p>This document applies to version 4.2.8p1 of <code>ntpsnmpd</code>.
+ <p>This document applies to version 4.2.8p2 of <code>ntpsnmpd</code>.
<ul class="menu">
<li><a accesskey="1" href="#ntpsnmpd-Description">ntpsnmpd Description</a>: Description
diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd.man.in b/contrib/ntp/ntpsnmpd/ntpsnmpd.man.in
index f0de336..15ee8a2 100644
--- a/contrib/ntp/ntpsnmpd/ntpsnmpd.man.in
+++ b/contrib/ntp/ntpsnmpd/ntpsnmpd.man.in
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntpsnmpd @NTPSNMPD_MS@ "04 Feb 2015" "4.2.8p1" "User Commands"
+.TH ntpsnmpd @NTPSNMPD_MS@ "07 Apr 2015" "4.2.8p2" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-T1aO3s/ag-51aG2s)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-wFai4a/ag-JFaa3a)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:43:29 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:27:19 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpsnmpd-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/ntpsnmpd/ntpsnmpd.mdoc.in b/contrib/ntp/ntpsnmpd/ntpsnmpd.mdoc.in
index d8d183d..5bf8bb9 100644
--- a/contrib/ntp/ntpsnmpd/ntpsnmpd.mdoc.in
+++ b/contrib/ntp/ntpsnmpd/ntpsnmpd.mdoc.in
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTPSNMPD @NTPSNMPD_MS@ User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpsnmpd-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:43:34 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:27:25 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpsnmpd-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/packageinfo.sh b/contrib/ntp/packageinfo.sh
index f3b727e..81106fe 100644
--- a/contrib/ntp/packageinfo.sh
+++ b/contrib/ntp/packageinfo.sh
@@ -41,7 +41,7 @@
# To see what UpdatePoint will do without modifying packageinfo.sh as it
# does by default, use the -t/--test option before the repo type:
#
-# shell# scripts/UpdatePoint -t stable
+# shell# scripts/build/UpdatePoint -t stable
#
# repotype must be stable or dev
@@ -83,7 +83,7 @@ CLTAG=NTP_4_2_0
# - Numeric values increment
# - empty 'increments' to 1
# - NEW 'increments' to empty
-point=1
+point=2
### betapoint is normally modified by script.
# ntp-stable Beta number (betapoint)
diff --git a/contrib/ntp/parseutil/Makefile.in b/contrib/ntp/parseutil/Makefile.in
index e741a93..999f4f1 100644
--- a/contrib/ntp/parseutil/Makefile.in
+++ b/contrib/ntp/parseutil/Makefile.in
@@ -41,8 +41,7 @@ subdir = parseutil
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -71,6 +70,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -324,6 +325,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/parseutil/dcfd.c b/contrib/ntp/parseutil/dcfd.c
index 0db94c0..652b375 100644
--- a/contrib/ntp/parseutil/dcfd.c
+++ b/contrib/ntp/parseutil/dcfd.c
@@ -1,6 +1,6 @@
/*
* /src/NTP/REPOSITORY/ntp4-dev/parseutil/dcfd.c,v 4.18 2005/10/07 22:08:18 kardel RELEASE_20051008_A
- *
+ *
* dcfd.c,v 4.18 2005/10/07 22:08:18 kardel RELEASE_20051008_A
*
* DCF77 100/200ms pulse synchronisation daemon program (via 50Baud serial line)
@@ -14,7 +14,7 @@
* Leap second handling (at that level you should switch to NTP Version 4 - really!)
*
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -198,7 +198,7 @@ static char skip_adjust = 1; /* discard first adjustment (bad samples) */
#define DCFB_ANNOUNCE 0x0001 /* switch time zone warning (DST switch) */
#define DCFB_DST 0x0002 /* DST in effect */
#define DCFB_LEAP 0x0004 /* LEAP warning (1 hour prior to occurrence) */
-#define DCFB_ALTERNATE 0x0008 /* alternate antenna used */
+#define DCFB_CALLBIT 0x0008 /* "call bit" used to signalize irregularities in the control facilities */
struct clocktime /* clock time broken up from time code */
{
@@ -219,9 +219,16 @@ typedef struct clocktime clocktime_t;
/*
* (usually) quick constant multiplications
*/
+#ifndef TIMES10
#define TIMES10(_X_) (((_X_) << 3) + ((_X_) << 1)) /* *8 + *2 */
+#endif
+#ifndef TIMES24
#define TIMES24(_X_) (((_X_) << 4) + ((_X_) << 3)) /* *16 + *8 */
+#endif
+#ifndef TIMES60
#define TIMES60(_X_) ((((_X_) << 4) - (_X_)) << 2) /* *(16 - 1) *4 */
+#endif
+
/*
* generic l_abs() function
*/
@@ -260,7 +267,8 @@ typedef struct clocktime clocktime_t;
* Second Contents
* 0 - 10 AM: free, FM: 0
* 11 - 14 free
- * 15 R - alternate antenna
+ * 15 R - "call bit" used to signalize irregularities in the control facilities
+ * (until 2003 indicated transmission via alternate antenna)
* 16 A1 - expect zone change (1 hour before)
* 17 - 18 Z1,Z2 - time zone
* 0 0 illegal
@@ -294,7 +302,7 @@ typedef struct clocktime clocktime_t;
* while the length is given as the difference between the start index and
* the start index of the following field.
*/
-static struct rawdcfcode
+static struct rawdcfcode
{
char offset; /* start bit */
} rawdcfcode[] =
@@ -361,7 +369,7 @@ static struct dcfparam
{
unsigned char onebits[60];
unsigned char zerobits[60];
-} dcfparam =
+} dcfparam =
{
"###############RADMLS1248124P124812P1248121241248112481248P", /* 'ONE' representation */
"--------------------s-------p------p----------------------p" /* 'ZERO' representation */
@@ -384,7 +392,7 @@ ext_bf(
register int i, first;
first = rawdcfcode[idx].offset;
-
+
for (i = rawdcfcode[idx+1].offset - 1; i >= first; i--)
{
sum <<= 1;
@@ -438,7 +446,7 @@ convert_rawdcf(
PRINTF("%-30s", "*** INCOMPLETE");
return CVT_NONE;
}
-
+
/*
* check Start and Parity bits
*/
@@ -495,7 +503,7 @@ convert_rawdcf(
clock_time->flags |= DCFB_LEAP;
if (ext_bf(buffer, DCF_R))
- clock_time->flags |= DCFB_ALTERNATE;
+ clock_time->flags |= DCFB_CALLBIT;
return CVT_OK;
}
@@ -739,7 +747,7 @@ cvt_rawdcf(
* if everything went well so far return the result of the symbolic
* conversion routine else just the accumulated errors
*/
- if (rtc != CVT_NONE)
+ if (rtc != CVT_NONE)
{
PRINTF("%-30s", "*** BAD DATA");
}
@@ -758,13 +766,13 @@ dcf_to_unixtime(
)
{
#define SETRTC(_X_) { if (cvtrtc) *cvtrtc = (_X_); }
- static int days_of_month[] =
+ static int days_of_month[] =
{
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
register int i;
time_t t;
-
+
/*
* map 2 digit years to 19xx (DCF77 is a 20th century item)
*/
@@ -847,7 +855,7 @@ dcf_to_unixtime(
*/
t = TIMES60(t) + clock_time->minute;
/* sec */
-
+
/*
* calculate UTC in minutes
*/
@@ -1247,7 +1255,7 @@ usage(
*/
static int
check_y2k( void )
-{
+{
int year; /* current working year */
int year0 = 1900; /* sarting year for NTP time */
int yearend; /* ending year we test for NTP time.
@@ -1306,7 +1314,7 @@ check_y2k( void )
* *a minor difference to arg2 type */
if ( ct.year != year )
{
- fprintf( stdout,
+ fprintf( stdout,
"%04d: dcf_to_unixtime(,%d) CORRUPTED ct.year: was %d\n",
(int)year, (int)Flag, (int)ct.year );
Error(year);
@@ -1316,9 +1324,9 @@ check_y2k( void )
Expected = t * 24 * 60 * 60;
if ( Observed != Expected || Flag )
{ /* time difference */
- fprintf( stdout,
+ fprintf( stdout,
"%04d: dcf_to_unixtime(,%d) FAILURE: was=%lu s/b=%lu (%ld)\n",
- year, (int)Flag,
+ year, (int)Flag,
(unsigned long)Observed, (unsigned long)Expected,
((long)Observed - (long)Expected) );
Error(year);
@@ -1344,7 +1352,7 @@ rawdcf_init(
* Here a voltage between the DTR and the RTS line is used. Unfortunately
* the name has changed from CIOCM_DTR to TIOCM_DTR recently.
*/
-
+
#ifdef TIOCM_DTR
int sl232 = TIOCM_DTR; /* turn on DTR for power supply */
#else
@@ -1438,7 +1446,7 @@ main(
errs=1;
}
break;
-
+
case 'd':
if (ac > 1)
{
@@ -1451,8 +1459,8 @@ main(
errs=1;
}
break;
-
- case 'Y':
+
+ case 'Y':
errs=check_y2k();
exit( errs ? 1 : 0 );
@@ -1519,7 +1527,7 @@ main(
unsigned int rtc = CVT_NONE;
rawdcf_init(fd);
-
+
timeout.tv_sec = 1;
timeout.tv_usec = 500000;
@@ -1560,7 +1568,7 @@ main(
*/
if (!interactive)
detach();
-
+
/*
* get syslog() initialized
*/
@@ -1618,7 +1626,7 @@ main(
it.it_interval.tv_usec = 0;
it.it_value.tv_sec = 1<<ADJINTERVAL;
it.it_value.tv_usec = 0;
-
+
if (setitimer(ITIMER_REAL, &it, (struct itimerval *)0) == -1)
{
syslog(LOG_ERR, "setitimer: %m");
@@ -1797,7 +1805,7 @@ main(
wday[clock_time.wday],
clock_time.hour, clock_time.minute, i, clock_time.day, clock_time.month,
clock_time.year,
- (clock_time.flags & DCFB_ALTERNATE) ? "R" : "_",
+ (clock_time.flags & DCFB_CALLBIT) ? "R" : "_",
(clock_time.flags & DCFB_ANNOUNCE) ? "A" : "_",
(clock_time.flags & DCFB_DST) ? "D" : "_",
(clock_time.flags & DCFB_LEAP) ? "L" : "_",
@@ -1829,7 +1837,7 @@ main(
fflush(stdout);
}
} while ((rrc == -1) && (errno == EINTR));
-
+
/*
* lost IO - sorry guys
*/
@@ -1839,7 +1847,7 @@ main(
}
closelog();
-
+
return 0;
}
diff --git a/contrib/ntp/parseutil/testdcf.c b/contrib/ntp/parseutil/testdcf.c
index c78c242..00bf059 100644
--- a/contrib/ntp/parseutil/testdcf.c
+++ b/contrib/ntp/parseutil/testdcf.c
@@ -2,11 +2,11 @@
* /src/NTP/ntp4-dev/parseutil/testdcf.c,v 4.10 2005/08/06 14:18:43 kardel RELEASE_20050806_A
*
* testdcf.c,v 4.10 2005/08/06 14:18:43 kardel RELEASE_20050806_A
- *
+ *
* simple DCF77 100/200ms pulse test program (via 50Baud serial line)
*
* Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
- * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universitaet Erlangen-Nuernberg, Germany
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -46,10 +46,10 @@
/*
* state flags
*/
-#define DCFB_ANNOUNCE 0x0001 /* switch time zone warning (DST switch) */
-#define DCFB_DST 0x0002 /* DST in effect */
-#define DCFB_LEAP 0x0004 /* LEAP warning (1 hour prior to occurrence) */
-#define DCFB_ALTERNATE 0x0008 /* alternate antenna used */
+#define DCFB_ANNOUNCE 0x0001 /* switch time zone warning (DST switch) */
+#define DCFB_DST 0x0002 /* DST in effect */
+#define DCFB_LEAP 0x0004 /* LEAP warning (1 hour prior to occurrence) */
+#define DCFB_CALLBIT 0x0008 /* "call bit" used to signalize irregularities in the control facilities */
struct clocktime /* clock time broken up from time code */
{
@@ -102,7 +102,8 @@ static char type(unsigned int);
* Second Contents
* 0 - 10 AM: free, FM: 0
* 11 - 14 free
- * 15 R - alternate antenna
+ * 15 R - "call bit" used to signalize irregularities in the control facilities
+ * (until 2003 indicated transmission via alternate antenna)
* 16 A1 - expect zone change (1 hour before)
* 17 - 18 Z1,Z2 - time zone
* 0 0 illegal
@@ -130,7 +131,7 @@ static char type(unsigned int);
static char revision[] = "4.10";
-static struct rawdcfcode
+static struct rawdcfcode
{
char offset; /* start bit */
} rawdcfcode[] =
@@ -185,7 +186,7 @@ ext_bf(
register int i, first;
first = rawdcfcode[idx].offset;
-
+
for (i = rawdcfcode[idx+1].offset - 1; i >= first; i--)
{
sum <<= 1;
@@ -223,7 +224,7 @@ convert_rawdcf(
printf("%-30s", "*** INCOMPLETE");
return CVT_NONE;
}
-
+
/*
* check Start and Parity bits
*/
@@ -274,7 +275,7 @@ convert_rawdcf(
clock_time->flags |= DCFB_LEAP;
if (ext_bf(buffer, DCF_R))
- clock_time->flags |= DCFB_ALTERNATE;
+ clock_time->flags |= DCFB_CALLBIT;
return CVT_OK;
}
@@ -490,7 +491,7 @@ main(
wday[clock_time.wday],
(int)clock_time.hour, (int)clock_time.minute, (int)i, (int)clock_time.day, (int)clock_time.month,
(int)clock_time.year,
- (clock_time.flags & DCFB_ALTERNATE) ? "R" : "_",
+ (clock_time.flags & DCFB_CALLBIT) ? "R" : "_",
(clock_time.flags & DCFB_ANNOUNCE) ? "A" : "_",
(clock_time.flags & DCFB_DST) ? "D" : "_",
(clock_time.flags & DCFB_LEAP) ? "L" : "_"
diff --git a/contrib/ntp/scripts/Makefile.am b/contrib/ntp/scripts/Makefile.am
index 7ddf424..2664bef 100644
--- a/contrib/ntp/scripts/Makefile.am
+++ b/contrib/ntp/scripts/Makefile.am
@@ -6,6 +6,7 @@ SUBDIRS= \
ntpsweep \
ntptrace \
lib \
+ update-leap \
$(NULL)
man1_MANS=
diff --git a/contrib/ntp/scripts/Makefile.in b/contrib/ntp/scripts/Makefile.in
index 2222f3b..c0ff722 100644
--- a/contrib/ntp/scripts/Makefile.in
+++ b/contrib/ntp/scripts/Makefile.in
@@ -42,8 +42,7 @@ DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -72,6 +71,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -356,6 +357,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
@@ -422,6 +428,7 @@ SUBDIRS = \
ntpsweep \
ntptrace \
lib \
+ update-leap \
$(NULL)
man1_MANS =
diff --git a/contrib/ntp/scripts/build/Makefile.in b/contrib/ntp/scripts/build/Makefile.in
index 13e9011..2f6b026 100644
--- a/contrib/ntp/scripts/build/Makefile.in
+++ b/contrib/ntp/scripts/build/Makefile.in
@@ -40,8 +40,7 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -70,6 +69,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -287,6 +288,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/scripts/calc_tickadj/Makefile.in b/contrib/ntp/scripts/calc_tickadj/Makefile.in
index 197f484..154e4a3 100644
--- a/contrib/ntp/scripts/calc_tickadj/Makefile.in
+++ b/contrib/ntp/scripts/calc_tickadj/Makefile.in
@@ -42,8 +42,7 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -72,6 +71,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -318,6 +319,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjman b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjman
index 4d3ce1a..e5008cc 100644
--- a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjman
+++ b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjman
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH calc_tickadj 1calc_tickadjman "04 Feb 2015" "ntp (4.2.8p1)" "User Commands"
+.TH calc_tickadj 1calc_tickadjman "07 Apr 2015" "ntp (4.2.8p2)" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-1GaySe/ag-cHaGRe)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-_1aOBS/ag-n2aWAS)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:11 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:04 AM by AutoGen 5.18.5pre4
.\" From the definitions calc_tickadj-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc
index ac992ab..7135beb 100644
--- a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc
+++ b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt CALC_TICKADJ 1calc_tickadjmdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (calc_tickadj-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:14 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:08 AM by AutoGen 5.18.5pre4
.\" From the definitions calc_tickadj-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.html b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.html
index 0b68e58..b64096d9 100644
--- a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.html
+++ b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.html
@@ -31,7 +31,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>
<h2 class="unnumbered">calc_tickadj User's Manual</h2>
<p>This document describes the use of the NTP Project's <code>calc_tickadj</code> program.
-This document applies to version 4.2.8p1 of <code>calc_tickadj</code>.
+This document applies to version 4.2.8p2 of <code>calc_tickadj</code>.
<div class="shortcontents">
<h2>Short Contents</h2>
diff --git a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.man.in b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.man.in
index 4d3ce1a..e5008cc 100644
--- a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.man.in
+++ b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.man.in
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH calc_tickadj 1calc_tickadjman "04 Feb 2015" "ntp (4.2.8p1)" "User Commands"
+.TH calc_tickadj 1calc_tickadjman "07 Apr 2015" "ntp (4.2.8p2)" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-1GaySe/ag-cHaGRe)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-_1aOBS/ag-n2aWAS)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:11 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:04 AM by AutoGen 5.18.5pre4
.\" From the definitions calc_tickadj-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.mdoc.in b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.mdoc.in
index ac992ab..7135beb 100644
--- a/contrib/ntp/scripts/calc_tickadj/calc_tickadj.mdoc.in
+++ b/contrib/ntp/scripts/calc_tickadj/calc_tickadj.mdoc.in
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt CALC_TICKADJ 1calc_tickadjmdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (calc_tickadj-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:14 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:08 AM by AutoGen 5.18.5pre4
.\" From the definitions calc_tickadj-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/scripts/calc_tickadj/invoke-calc_tickadj.texi b/contrib/ntp/scripts/calc_tickadj/invoke-calc_tickadj.texi
index 1633801..c9e44b8 100644
--- a/contrib/ntp/scripts/calc_tickadj/invoke-calc_tickadj.texi
+++ b/contrib/ntp/scripts/calc_tickadj/invoke-calc_tickadj.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-calc_tickadj.texi)
#
-# It has been AutoGen-ed February 4, 2015 at 02:37:16 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:21:09 AM by AutoGen 5.18.5pre4
# From the definitions calc_tickadj-opts.def
# and the template file agtexi-cmd.tpl
@end ignore
diff --git a/contrib/ntp/scripts/invoke-plot_summary.texi b/contrib/ntp/scripts/invoke-plot_summary.texi
index 6f482f8..48ea5b4 100644
--- a/contrib/ntp/scripts/invoke-plot_summary.texi
+++ b/contrib/ntp/scripts/invoke-plot_summary.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-plot_summary.texi)
#
-# It has been AutoGen-ed February 4, 2015 at 02:37:53 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:21:51 AM by AutoGen 5.18.5pre4
# From the definitions plot_summary-opts.def
# and the template file agtexi-cmd.tpl
@end ignore
@@ -41,7 +41,7 @@ with a status code of 0.
@exampleindent 0
@example
-plot_summary - plot statistics generated by summary script - Ver. 4.2.8p1
+plot_summary - plot statistics generated by summary script - Ver. 4.2.8p2
USAGE: plot_summary [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]...
--directory=str Where the summary files are
diff --git a/contrib/ntp/scripts/invoke-summary.texi b/contrib/ntp/scripts/invoke-summary.texi
index cfac1b1..16fc222 100644
--- a/contrib/ntp/scripts/invoke-summary.texi
+++ b/contrib/ntp/scripts/invoke-summary.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-summary.texi)
#
-# It has been AutoGen-ed February 4, 2015 at 02:37:59 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:21:57 AM by AutoGen 5.18.5pre4
# From the definitions summary-opts.def
# and the template file agtexi-cmd.tpl
@end ignore
@@ -42,7 +42,7 @@ with a status code of 0.
@exampleindent 0
@example
-summary - compute various stastics from NTP stat files - Ver. 4.2.8p1
+summary - compute various stastics from NTP stat files - Ver. 4.2.8p2
USAGE: summary [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]...
--directory=str Directory containing stat files
diff --git a/contrib/ntp/scripts/lib/Makefile.in b/contrib/ntp/scripts/lib/Makefile.in
index c1437a4..2b0f097 100644
--- a/contrib/ntp/scripts/lib/Makefile.in
+++ b/contrib/ntp/scripts/lib/Makefile.in
@@ -39,8 +39,7 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -69,6 +68,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -308,6 +309,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/scripts/lib/NTP/Util.pm b/contrib/ntp/scripts/lib/NTP/Util.pm
index 66f2453..cd2f9e5 100644
--- a/contrib/ntp/scripts/lib/NTP/Util.pm
+++ b/contrib/ntp/scripts/lib/NTP/Util.pm
@@ -93,18 +93,27 @@ sub do_dns {
sub ntp_peers {
my ($host) = @_;
- my $cmd = "$ntpq_path -np $host |";
+ $host ||= '';
+ my $cmd = "$ntpq_path -npw $host |";
open my $fh, $cmd or croak "Could not start ntpq: $!";
<$fh> for 1 .. 2;
- my @columns = qw(remote refid st t when poll reach delay offset jitter);
+ my @columns = qw(tally host refid st t when poll reach delay offset jitter);
my @peers;
while (<$fh>) {
- if (/(?:[\w\.\*-]+\s*){10}/) {
+ if (/^([ x+#*o-])((?:[\w.*:-]+\s+){10}|([\w.*:-]+\s+))$/) {
my $col = 0;
- push @peers, { map {; $columns[ $col++ ] => $_ } split /(?<=.)\s+/ };
+ my @line = ($1, split /\s+/, $2);
+ if( @line == 2 ) {
+ defined ($_ = <$fh>) or last;
+ s/^\s+//;
+ push @line, split /\s+/;
+ }
+ my $r = { map {; $columns[ $col++ ] => $_ } @line };
+ $r->{remote} = $r->{tally} . $r->{host};
+ push @peers, $r;
}
else {
#TODO return error (but not needed anywhere now)
@@ -135,3 +144,5 @@ sub ntp_sntp_line {
close $fh or croak "running sntp failed: $! (exit status $?)";
return ($offset, $stratum);
}
+
+1;
diff --git a/contrib/ntp/scripts/ntp-wait/Makefile.in b/contrib/ntp/scripts/ntp-wait/Makefile.in
index 4b2c58f..a18414d 100644
--- a/contrib/ntp/scripts/ntp-wait/Makefile.in
+++ b/contrib/ntp/scripts/ntp-wait/Makefile.in
@@ -41,8 +41,7 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -71,6 +70,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -317,6 +318,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/scripts/ntp-wait/invoke-ntp-wait.texi b/contrib/ntp/scripts/ntp-wait/invoke-ntp-wait.texi
index 19f3953..9053e8a 100644
--- a/contrib/ntp/scripts/ntp-wait/invoke-ntp-wait.texi
+++ b/contrib/ntp/scripts/ntp-wait/invoke-ntp-wait.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntp-wait.texi)
#
-# It has been AutoGen-ed February 4, 2015 at 02:37:23 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:21:17 AM by AutoGen 5.18.5pre4
# From the definitions ntp-wait-opts.def
# and the template file agtexi-cmd.tpl
@end ignore
@@ -61,7 +61,7 @@ with a status code of 0.
@exampleindent 0
@example
-ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p1
+ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p2
USAGE: ntp-wait [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]...
-n, --tries=num Number of times to check ntpd
diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait-opts b/contrib/ntp/scripts/ntp-wait/ntp-wait-opts
index b8f8325..ff99fe5 100644
--- a/contrib/ntp/scripts/ntp-wait/ntp-wait-opts
+++ b/contrib/ntp/scripts/ntp-wait/ntp-wait-opts
@@ -1,6 +1,6 @@
# EDIT THIS FILE WITH CAUTION (ntp-wait-opts)
#
-# It has been AutoGen-ed February 4, 2015 at 02:37:18 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:21:11 AM by AutoGen 5.18.5pre4
# From the definitions ntp-wait-opts.def
# and the template file perlopt
@@ -40,7 +40,7 @@ sub processOptions {
'help|?', 'more-help'));
$usage = <<'USAGE';
-ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p1
+ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p2
USAGE: ntp-wait [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
-n, --tries=num Number of times to check ntpd
diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitman b/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitman
index 4d41ede..65a97fd 100644
--- a/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitman
+++ b/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitman
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntp-wait 1ntp-waitman "04 Feb 2015" "ntp (4.2.8p1)" "User Commands"
+.TH ntp-wait 1ntp-waitman "07 Apr 2015" "ntp (4.2.8p2)" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-yXaGgg/ag-LXaOfg)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-CkaW1T/ag-Oka40T)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:20 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:13 AM by AutoGen 5.18.5pre4
.\" From the definitions ntp-wait-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitmdoc b/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitmdoc
index 9720e45..1340e5a 100644
--- a/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitmdoc
+++ b/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitmdoc
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTP_WAIT 1ntp-waitmdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntp-wait-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:26 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:20 AM by AutoGen 5.18.5pre4
.\" From the definitions ntp-wait-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait.html b/contrib/ntp/scripts/ntp-wait/ntp-wait.html
index 01840fd..7cc8b99 100644
--- a/contrib/ntp/scripts/ntp-wait/ntp-wait.html
+++ b/contrib/ntp/scripts/ntp-wait/ntp-wait.html
@@ -39,7 +39,7 @@ until the system's time has stabilized and synchronized,
and only then start any applicaitons (like database servers) that require
accurate and stable time.
- <p>This document applies to version 4.2.8p1 of <code>ntp-wait</code>.
+ <p>This document applies to version 4.2.8p2 of <code>ntp-wait</code>.
<div class="shortcontents">
<h2>Short Contents</h2>
@@ -114,7 +114,7 @@ the usage text by passing it through a pager program.
used to select the program, defaulting to <span class="file">more</span>. Both will exit
with a status code of 0.
-<pre class="example">ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p1
+<pre class="example">ntp-wait - Wait for ntpd to stabilize the system clock - Ver. 4.2.8p2
USAGE: ntp-wait [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]...
-n, --tries=num Number of times to check ntpd
diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait.man.in b/contrib/ntp/scripts/ntp-wait/ntp-wait.man.in
index 8d569c0..a4edec4 100644
--- a/contrib/ntp/scripts/ntp-wait/ntp-wait.man.in
+++ b/contrib/ntp/scripts/ntp-wait/ntp-wait.man.in
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntp-wait @NTP_WAIT_MS@ "04 Feb 2015" "ntp (4.2.8p1)" "User Commands"
+.TH ntp-wait @NTP_WAIT_MS@ "07 Apr 2015" "ntp (4.2.8p2)" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-yXaGgg/ag-LXaOfg)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-CkaW1T/ag-Oka40T)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:20 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:13 AM by AutoGen 5.18.5pre4
.\" From the definitions ntp-wait-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/scripts/ntp-wait/ntp-wait.mdoc.in b/contrib/ntp/scripts/ntp-wait/ntp-wait.mdoc.in
index 43514a0..c61340d 100644
--- a/contrib/ntp/scripts/ntp-wait/ntp-wait.mdoc.in
+++ b/contrib/ntp/scripts/ntp-wait/ntp-wait.mdoc.in
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTP_WAIT @NTP_WAIT_MS@ User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntp-wait-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:26 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:20 AM by AutoGen 5.18.5pre4
.\" From the definitions ntp-wait-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/scripts/ntpsweep/Makefile.in b/contrib/ntp/scripts/ntpsweep/Makefile.in
index e0d1dc6..38af36a 100644
--- a/contrib/ntp/scripts/ntpsweep/Makefile.in
+++ b/contrib/ntp/scripts/ntpsweep/Makefile.in
@@ -41,8 +41,7 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -71,6 +70,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -318,6 +319,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/scripts/ntpsweep/invoke-ntpsweep.texi b/contrib/ntp/scripts/ntpsweep/invoke-ntpsweep.texi
index fef89ae..207577a 100644
--- a/contrib/ntp/scripts/ntpsweep/invoke-ntpsweep.texi
+++ b/contrib/ntp/scripts/ntpsweep/invoke-ntpsweep.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntpsweep.texi)
#
-# It has been AutoGen-ed February 4, 2015 at 02:37:33 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:21:23 AM by AutoGen 5.18.5pre4
# From the definitions ntpsweep-opts.def
# and the template file agtexi-cmd.tpl
@end ignore
@@ -45,7 +45,7 @@ with a status code of 0.
@exampleindent 0
@example
-ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p1
+ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p2
USAGE: ntpsweep [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... [hostfile]
-l, --host-list=str Host to execute actions on
diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep-opts b/contrib/ntp/scripts/ntpsweep/ntpsweep-opts
index cacc78b..b833b08 100644
--- a/contrib/ntp/scripts/ntpsweep/ntpsweep-opts
+++ b/contrib/ntp/scripts/ntpsweep/ntpsweep-opts
@@ -1,6 +1,6 @@
# EDIT THIS FILE WITH CAUTION (ntpsweep-opts)
#
-# It has been AutoGen-ed February 4, 2015 at 02:37:31 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:21:21 AM by AutoGen 5.18.5pre4
# From the definitions ntpsweep-opts.def
# and the template file perlopt
@@ -43,7 +43,7 @@ sub processOptions {
'help|?', 'more-help'));
$usage = <<'USAGE';
-ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p1
+ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p2
USAGE: ntpsweep [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [hostfile]
-l, --host-list=str Host to execute actions on
diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepman b/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepman
index 6248844..9ba9683 100644
--- a/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepman
+++ b/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepman
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntpsweep 1ntpsweepman "04 Feb 2015" "ntp (4.2.8p1)" "User Commands"
+.TH ntpsweep 1ntpsweepman "07 Apr 2015" "ntp (4.2.8p2)" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-8JaOIh/ag-jKaWHh)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-pka4rV/ag-CkaarV)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:35 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:25 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpsweep-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepmdoc b/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepmdoc
index d51cd45..d933c83 100644
--- a/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepmdoc
+++ b/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepmdoc
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTPSWEEP 1ntpsweepmdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpsweep-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:39 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:29 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpsweep-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep.html b/contrib/ntp/scripts/ntpsweep/ntpsweep.html
index 453899b..1fc5f54 100644
--- a/contrib/ntp/scripts/ntpsweep/ntpsweep.html
+++ b/contrib/ntp/scripts/ntpsweep/ntpsweep.html
@@ -30,7 +30,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>
<p>This document describes the use of the NTP Project's <code>ntpsweep</code> program.
- <p>This document applies to version 4.2.8p1 of <code>ntpsweep</code>.
+ <p>This document applies to version 4.2.8p2 of <code>ntpsweep</code>.
<div class="shortcontents">
<h2>Short Contents</h2>
@@ -90,7 +90,7 @@ the usage text by passing it through a pager program.
used to select the program, defaulting to <span class="file">more</span>. Both will exit
with a status code of 0.
-<pre class="example">ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p1
+<pre class="example">ntpsweep - Print various informations about given ntp servers - Ver. 4.2.8p2
USAGE: ntpsweep [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... [hostfile]
-l, --host-list=str Host to execute actions on
diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep.man.in b/contrib/ntp/scripts/ntpsweep/ntpsweep.man.in
index 6248844..9ba9683 100644
--- a/contrib/ntp/scripts/ntpsweep/ntpsweep.man.in
+++ b/contrib/ntp/scripts/ntpsweep/ntpsweep.man.in
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntpsweep 1ntpsweepman "04 Feb 2015" "ntp (4.2.8p1)" "User Commands"
+.TH ntpsweep 1ntpsweepman "07 Apr 2015" "ntp (4.2.8p2)" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-8JaOIh/ag-jKaWHh)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-pka4rV/ag-CkaarV)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:35 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:25 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpsweep-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/scripts/ntpsweep/ntpsweep.mdoc.in b/contrib/ntp/scripts/ntpsweep/ntpsweep.mdoc.in
index d51cd45..d933c83 100644
--- a/contrib/ntp/scripts/ntpsweep/ntpsweep.mdoc.in
+++ b/contrib/ntp/scripts/ntpsweep/ntpsweep.mdoc.in
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTPSWEEP 1ntpsweepmdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntpsweep-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:39 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:29 AM by AutoGen 5.18.5pre4
.\" From the definitions ntpsweep-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/scripts/ntptrace/Makefile.in b/contrib/ntp/scripts/ntptrace/Makefile.in
index f123f16..8d7db40 100644
--- a/contrib/ntp/scripts/ntptrace/Makefile.in
+++ b/contrib/ntp/scripts/ntptrace/Makefile.in
@@ -41,8 +41,7 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -71,6 +70,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -317,6 +318,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/scripts/ntptrace/invoke-ntptrace.texi b/contrib/ntp/scripts/ntptrace/invoke-ntptrace.texi
index b3792dd..58548c1 100644
--- a/contrib/ntp/scripts/ntptrace/invoke-ntptrace.texi
+++ b/contrib/ntp/scripts/ntptrace/invoke-ntptrace.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntptrace.texi)
#
-# It has been AutoGen-ed February 4, 2015 at 02:37:46 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:21:36 AM by AutoGen 5.18.5pre4
# From the definitions ntptrace-opts.def
# and the template file agtexi-cmd.tpl
@end ignore
@@ -62,7 +62,7 @@ with a status code of 0.
@exampleindent 0
@example
-ntptrace - Trace peers of an NTP server - Ver. 4.2.8p1
+ntptrace - Trace peers of an NTP server - Ver. 4.2.8p2
USAGE: ntptrace [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... [host]
-n, --numeric Print IP addresses instead of hostnames
diff --git a/contrib/ntp/scripts/ntptrace/ntptrace-opts b/contrib/ntp/scripts/ntptrace/ntptrace-opts
index 7bbdeb3..3012392 100644
--- a/contrib/ntp/scripts/ntptrace/ntptrace-opts
+++ b/contrib/ntp/scripts/ntptrace/ntptrace-opts
@@ -1,6 +1,6 @@
# EDIT THIS FILE WITH CAUTION (ntptrace-opts)
#
-# It has been AutoGen-ed February 4, 2015 at 02:37:40 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:21:31 AM by AutoGen 5.18.5pre4
# From the definitions ntptrace-opts.def
# and the template file perlopt
@@ -40,7 +40,7 @@ sub processOptions {
'help|?', 'more-help'));
$usage = <<'USAGE';
-ntptrace - Trace peers of an NTP server - Ver. 4.2.8p1
+ntptrace - Trace peers of an NTP server - Ver. 4.2.8p2
USAGE: ntptrace [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [host]
-n, --numeric Print IP addresses instead of hostnames
diff --git a/contrib/ntp/scripts/ntptrace/ntptrace.1ntptraceman b/contrib/ntp/scripts/ntptrace/ntptrace.1ntptraceman
index 82bc037..ff02de0 100644
--- a/contrib/ntp/scripts/ntptrace/ntptrace.1ntptraceman
+++ b/contrib/ntp/scripts/ntptrace/ntptrace.1ntptraceman
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntptrace 1ntptraceman "04 Feb 2015" "ntp (4.2.8p1)" "User Commands"
+.TH ntptrace 1ntptraceman "07 Apr 2015" "ntp (4.2.8p2)" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-nrai1i/ag-Araq0i)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-j_aqKW/ag-w_ayJW)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:42 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:33 AM by AutoGen 5.18.5pre4
.\" From the definitions ntptrace-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/scripts/ntptrace/ntptrace.1ntptracemdoc b/contrib/ntp/scripts/ntptrace/ntptrace.1ntptracemdoc
index 5528eea..352b659 100644
--- a/contrib/ntp/scripts/ntptrace/ntptrace.1ntptracemdoc
+++ b/contrib/ntp/scripts/ntptrace/ntptrace.1ntptracemdoc
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTPTRACE 1ntptracemdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntptrace-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:48 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:38 AM by AutoGen 5.18.5pre4
.\" From the definitions ntptrace-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/scripts/ntptrace/ntptrace.html b/contrib/ntp/scripts/ntptrace/ntptrace.html
index 291b9e9..86e1a9b 100644
--- a/contrib/ntp/scripts/ntptrace/ntptrace.html
+++ b/contrib/ntp/scripts/ntptrace/ntptrace.html
@@ -31,7 +31,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>
<h2 class="unnumbered">Simple Network Time Protocol User Manual</h2>
<p>This document describes the use of the NTP Project's <code>ntptrace</code> program.
-This document applies to version 4.2.8p1 of <code>ntptrace</code>.
+This document applies to version 4.2.8p2 of <code>ntptrace</code>.
<div class="shortcontents">
<h2>Short Contents</h2>
@@ -107,7 +107,7 @@ the usage text by passing it through a pager program.
used to select the program, defaulting to <span class="file">more</span>. Both will exit
with a status code of 0.
-<pre class="example">ntptrace - Trace peers of an NTP server - Ver. 4.2.8p1
+<pre class="example">ntptrace - Trace peers of an NTP server - Ver. 4.2.8p2
USAGE: ntptrace [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... [host]
-n, --numeric Print IP addresses instead of hostnames
diff --git a/contrib/ntp/scripts/ntptrace/ntptrace.man.in b/contrib/ntp/scripts/ntptrace/ntptrace.man.in
index c308597..f48a071 100644
--- a/contrib/ntp/scripts/ntptrace/ntptrace.man.in
+++ b/contrib/ntp/scripts/ntptrace/ntptrace.man.in
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntptrace @NTPTRACE_MS@ "04 Feb 2015" "ntp (4.2.8p1)" "User Commands"
+.TH ntptrace @NTPTRACE_MS@ "07 Apr 2015" "ntp (4.2.8p2)" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-nrai1i/ag-Araq0i)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-j_aqKW/ag-w_ayJW)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:42 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:33 AM by AutoGen 5.18.5pre4
.\" From the definitions ntptrace-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/scripts/ntptrace/ntptrace.mdoc.in b/contrib/ntp/scripts/ntptrace/ntptrace.mdoc.in
index c8fffcf..c06e718 100644
--- a/contrib/ntp/scripts/ntptrace/ntptrace.mdoc.in
+++ b/contrib/ntp/scripts/ntptrace/ntptrace.mdoc.in
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTPTRACE @NTPTRACE_MS@ User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntptrace-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:48 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:38 AM by AutoGen 5.18.5pre4
.\" From the definitions ntptrace-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/scripts/plot_summary-opts b/contrib/ntp/scripts/plot_summary-opts
index ed27025..3f03890 100644
--- a/contrib/ntp/scripts/plot_summary-opts
+++ b/contrib/ntp/scripts/plot_summary-opts
@@ -1,6 +1,6 @@
# EDIT THIS FILE WITH CAUTION (plot_summary-opts)
#
-# It has been AutoGen-ed February 4, 2015 at 02:37:49 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:21:47 AM by AutoGen 5.18.5pre4
# From the definitions plot_summary-opts.def
# and the template file perlopt
@@ -46,7 +46,7 @@ sub processOptions {
'help|?', 'more-help'));
$usage = <<'USAGE';
-plot_summary - plot statistics generated by summary script - Ver. 4.2.8p1
+plot_summary - plot statistics generated by summary script - Ver. 4.2.8p2
USAGE: plot_summary [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
--directory=str Where the summary files are
diff --git a/contrib/ntp/scripts/plot_summary.1plot_summaryman b/contrib/ntp/scripts/plot_summary.1plot_summaryman
index dd3d842..03dc6c5 100644
--- a/contrib/ntp/scripts/plot_summary.1plot_summaryman
+++ b/contrib/ntp/scripts/plot_summary.1plot_summaryman
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH plot_summary 1plot_summaryman "04 Feb 2015" "ntp (4.2.8p1)" "User Commands"
+.TH plot_summary 1plot_summaryman "07 Apr 2015" "ntp (4.2.8p2)" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-GxaG3k/ag-VxaO2k)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-48aGzZ/ag-f9aOyZ)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:55 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:53 AM by AutoGen 5.18.5pre4
.\" From the definitions plot_summary-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/scripts/plot_summary.1plot_summarymdoc b/contrib/ntp/scripts/plot_summary.1plot_summarymdoc
index 1d6ba70..4d7f492 100644
--- a/contrib/ntp/scripts/plot_summary.1plot_summarymdoc
+++ b/contrib/ntp/scripts/plot_summary.1plot_summarymdoc
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt PLOT_SUMMARY 1plot_summarymdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (plot_summary-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:57 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:55 AM by AutoGen 5.18.5pre4
.\" From the definitions plot_summary-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/scripts/plot_summary.html b/contrib/ntp/scripts/plot_summary.html
index d4a0235..b2fbc66 100644
--- a/contrib/ntp/scripts/plot_summary.html
+++ b/contrib/ntp/scripts/plot_summary.html
@@ -31,7 +31,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>
<h2 class="unnumbered">Plot_summary User Manual</h2>
<p>This document describes the use of the NTP Project's <code>plot_summary</code> program.
-This document applies to version 4.2.8p1 of <code>plot_summary</code>.
+This document applies to version 4.2.8p2 of <code>plot_summary</code>.
<div class="shortcontents">
<h2>Short Contents</h2>
@@ -89,7 +89,7 @@ the usage text by passing it through a pager program.
used to select the program, defaulting to <span class="file">more</span>. Both will exit
with a status code of 0.
-<pre class="example">plot_summary - plot statistics generated by summary script - Ver. 4.2.8p1
+<pre class="example">plot_summary - plot statistics generated by summary script - Ver. 4.2.8p2
USAGE: plot_summary [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]...
--directory=str Where the summary files are
diff --git a/contrib/ntp/scripts/plot_summary.man.in b/contrib/ntp/scripts/plot_summary.man.in
index dd3d842..03dc6c5 100644
--- a/contrib/ntp/scripts/plot_summary.man.in
+++ b/contrib/ntp/scripts/plot_summary.man.in
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH plot_summary 1plot_summaryman "04 Feb 2015" "ntp (4.2.8p1)" "User Commands"
+.TH plot_summary 1plot_summaryman "07 Apr 2015" "ntp (4.2.8p2)" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-GxaG3k/ag-VxaO2k)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-48aGzZ/ag-f9aOyZ)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:55 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:53 AM by AutoGen 5.18.5pre4
.\" From the definitions plot_summary-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/scripts/plot_summary.mdoc.in b/contrib/ntp/scripts/plot_summary.mdoc.in
index 1d6ba70..4d7f492 100644
--- a/contrib/ntp/scripts/plot_summary.mdoc.in
+++ b/contrib/ntp/scripts/plot_summary.mdoc.in
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt PLOT_SUMMARY 1plot_summarymdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (plot_summary-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:37:57 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:55 AM by AutoGen 5.18.5pre4
.\" From the definitions plot_summary-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/scripts/summary-opts b/contrib/ntp/scripts/summary-opts
index 5f6921b..adb228d 100644
--- a/contrib/ntp/scripts/summary-opts
+++ b/contrib/ntp/scripts/summary-opts
@@ -1,6 +1,6 @@
# EDIT THIS FILE WITH CAUTION (summary-opts)
#
-# It has been AutoGen-ed February 4, 2015 at 02:37:51 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:21:49 AM by AutoGen 5.18.5pre4
# From the definitions summary-opts.def
# and the template file perlopt
@@ -44,7 +44,7 @@ sub processOptions {
'help|?', 'more-help'));
$usage = <<'USAGE';
-summary - compute various stastics from NTP stat files - Ver. 4.2.8p1
+summary - compute various stastics from NTP stat files - Ver. 4.2.8p2
USAGE: summary [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
--directory=str Directory containing stat files
diff --git a/contrib/ntp/scripts/summary.1summaryman b/contrib/ntp/scripts/summary.1summaryman
index 5f3cf6b..d1eeb48 100644
--- a/contrib/ntp/scripts/summary.1summaryman
+++ b/contrib/ntp/scripts/summary.1summaryman
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH summary 1summaryman "04 Feb 2015" "ntp (4.2.8p1)" "User Commands"
+.TH summary 1summaryman "07 Apr 2015" "ntp (4.2.8p2)" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-kPaifl/ag-xPaqel)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-jpaiNZ/ag-wpaqMZ)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:38:00 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:58 AM by AutoGen 5.18.5pre4
.\" From the definitions summary-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/scripts/summary.1summarymdoc b/contrib/ntp/scripts/summary.1summarymdoc
index 8fc7836..3c77a8c 100644
--- a/contrib/ntp/scripts/summary.1summarymdoc
+++ b/contrib/ntp/scripts/summary.1summarymdoc
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt SUMMARY 1summarymdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (summary-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:38:02 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:22:00 AM by AutoGen 5.18.5pre4
.\" From the definitions summary-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/scripts/summary.html b/contrib/ntp/scripts/summary.html
index 8108096..5326c6a 100644
--- a/contrib/ntp/scripts/summary.html
+++ b/contrib/ntp/scripts/summary.html
@@ -31,7 +31,7 @@ Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>
<h2 class="unnumbered">Summary User Manual</h2>
<p>This document describes the use of the NTP Project's <code>summary</code> program.
-This document applies to version 4.2.8p1 of <code>summary</code>.
+This document applies to version 4.2.8p2 of <code>summary</code>.
<div class="shortcontents">
<h2>Short Contents</h2>
@@ -88,7 +88,7 @@ the usage text by passing it through a pager program.
used to select the program, defaulting to <span class="file">more</span>. Both will exit
with a status code of 0.
-<pre class="example">summary - compute various stastics from NTP stat files - Ver. 4.2.8p1
+<pre class="example">summary - compute various stastics from NTP stat files - Ver. 4.2.8p2
USAGE: summary [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]...
--directory=str Directory containing stat files
diff --git a/contrib/ntp/scripts/summary.man.in b/contrib/ntp/scripts/summary.man.in
index 5f3cf6b..d1eeb48 100644
--- a/contrib/ntp/scripts/summary.man.in
+++ b/contrib/ntp/scripts/summary.man.in
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH summary 1summaryman "04 Feb 2015" "ntp (4.2.8p1)" "User Commands"
+.TH summary 1summaryman "07 Apr 2015" "ntp (4.2.8p2)" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-kPaifl/ag-xPaqel)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-jpaiNZ/ag-wpaqMZ)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:38:00 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:58 AM by AutoGen 5.18.5pre4
.\" From the definitions summary-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/scripts/summary.mdoc.in b/contrib/ntp/scripts/summary.mdoc.in
index 8fc7836..3c77a8c 100644
--- a/contrib/ntp/scripts/summary.mdoc.in
+++ b/contrib/ntp/scripts/summary.mdoc.in
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt SUMMARY 1summarymdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (summary-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:38:02 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:22:00 AM by AutoGen 5.18.5pre4
.\" From the definitions summary-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/scripts/update-leap/Makefile.am b/contrib/ntp/scripts/update-leap/Makefile.am
new file mode 100644
index 0000000..1638102
--- /dev/null
+++ b/contrib/ntp/scripts/update-leap/Makefile.am
@@ -0,0 +1,97 @@
+NULL=
+run_ag= cd $(srcdir) && env PATH="$(abs_builddir):$(PATH)" PERL5LIB="$(abs_top_srcdir)/scripts/lib" AUTOGEN_DNE_DATE=-D \
+ autogen -L ../../sntp/include -L ../../sntp/ag-tpl \
+ --writable
+std_def_list = \
+ $(top_srcdir)/sntp/include/debug-opt.def \
+ $(top_srcdir)/sntp/include/autogen-version.def \
+ $(top_srcdir)/sntp/include/copyright.def \
+ $(top_srcdir)/sntp/include/homerc.def \
+ $(top_srcdir)/sntp/include/ntp.lic \
+ $(top_srcdir)/sntp/include/version.def \
+ $(NULL)
+
+bin_SCRIPTS= $(UPDATE_LEAP_DB)
+sbin_SCRIPTS= $(UPDATE_LEAP_DS)
+libexec_SCRIPTS= $(UPDATE_LEAP_DL)
+noinst_SCRIPTS= $(UPDATE_LEAP_NI)
+EXTRA_SCRIPTS= update-leap
+
+man1_MANS=
+man8_MANS=
+if INSTALL_UPDATE_LEAP
+man_MANS= update-leap.$(UPDATE_LEAP_MS)
+else
+noinst_MANS= update-leap.$(UPDATE_LEAP_MS)
+endif
+
+EXTRA_DIST = \
+ invoke-update-leap.menu \
+ invoke-update-leap.texi \
+ update-leap \
+ update-leap-opts.def \
+ update-leap-opts \
+ update-leap.1update-leapman \
+ update-leap.1update-leapmdoc \
+ update-leap.man.in \
+ update-leap.mdoc.in \
+ update-leap.texi \
+ update-leap.html \
+ $(NULL)
+
+html_DATA = update-leap.html
+
+#CLEANFILES = update-leap.1
+DISTCLEANFILES = config.log $(man_MANS) $(noinst_MANS)
+
+noinst_DATA = \
+ invoke-update-leap.menu \
+ invoke-update-leap.texi \
+ update-leap.man.in \
+ update-leap.mdoc.in \
+ update-leap-opts \
+ $(NULL)
+
+$(srcdir)/update-leap: $(srcdir)/update-leap-opts
+ @: do-nothing action to avoid default SCCS get
+
+$(srcdir)/update-leap-opts: update-leap-opts.def $(std_def_list)
+ $(run_ag) update-leap-opts.def
+
+### Man
+
+$(srcdir)/update-leap.1update-leapman: $(srcdir)/update-leap-opts.def $(std_def_list)
+ $(run_ag) -DMAN_SECTION=1update-leapman -Tagman-cmd.tpl update-leap-opts.def
+
+$(srcdir)/update-leap.man.in: $(srcdir)/update-leap.1update-leapman $(top_srcdir)/sntp/scripts/mansec2subst.sed
+ sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/update-leap.1update-leapman > $(srcdir)/update-leap.man.in+
+ mv $(srcdir)/update-leap.man.in+ $(srcdir)/update-leap.man.in
+
+### Mdoc
+
+$(srcdir)/update-leap.1update-leapmdoc: $(srcdir)/update-leap-opts.def $(std_def_list)
+ $(run_ag) -DMAN_SECTION=1update-leapmdoc -Tagmdoc-cmd.tpl update-leap-opts.def
+
+$(srcdir)/update-leap.mdoc.in: $(srcdir)/update-leap.1update-leapmdoc $(top_srcdir)/sntp/scripts/mansec2subst.sed
+ sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/update-leap.1update-leapmdoc > $(srcdir)/update-leap.mdoc.in+
+ mv $(srcdir)/update-leap.mdoc.in+ $(srcdir)/update-leap.mdoc.in
+
+### Manpage
+
+update-leap.$(UPDATE_LEAP_MS): $(srcdir)/update-leap.$(MANTAGFMT).in $(top_builddir)/config.status
+ $(top_builddir)/config.status --file=update-leap.$(UPDATE_LEAP_MS)+:$(srcdir)/update-leap.$(MANTAGFMT).in
+ mv update-leap.$(UPDATE_LEAP_MS)+ update-leap.$(UPDATE_LEAP_MS)
+
+### Texinfo
+
+$(srcdir)/invoke-update-leap.menu: $(srcdir)/invoke-update-leap.texi
+ @: do-nothing action to avoid default SCCS get, .menu built with .texi
+
+$(srcdir)/invoke-update-leap.texi: $(srcdir)/update-leap-opts.def $(std_def_list)
+ $(run_ag) -Tagtexi-cmd.tpl -DLEVEL=section update-leap-opts.def
+ $(top_srcdir)/scripts/build/check--help $@
+
+### HTML
+
+$(srcdir)/update-leap.html: $(srcdir)/update-leap.texi $(top_srcdir)/sntp/include/version.texi
+ cd $(srcdir) && ( makeinfo --force --html --no-split -I ../sntp -o update-leap.html update-leap.texi || true )
diff --git a/contrib/ntp/scripts/update-leap/Makefile.in b/contrib/ntp/scripts/update-leap/Makefile.in
new file mode 100644
index 0000000..3ac6ac6
--- /dev/null
+++ b/contrib/ntp/scripts/update-leap/Makefile.in
@@ -0,0 +1,887 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = scripts/update-leap
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
+ $(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
+ $(top_srcdir)/sntp/m4/define_dir.m4 \
+ $(top_srcdir)/sntp/m4/hms_search_lib.m4 \
+ $(top_srcdir)/sntp/m4/libtool.m4 \
+ $(top_srcdir)/sntp/m4/ltoptions.m4 \
+ $(top_srcdir)/sntp/m4/ltsugar.m4 \
+ $(top_srcdir)/sntp/m4/ltversion.m4 \
+ $(top_srcdir)/sntp/m4/lt~obsolete.m4 \
+ $(top_srcdir)/sntp/m4/ntp_cacheversion.m4 \
+ $(top_srcdir)/sntp/m4/ntp_compiler.m4 \
+ $(top_srcdir)/sntp/m4/ntp_crosscompile.m4 \
+ $(top_srcdir)/sntp/m4/ntp_crypto_rand.m4 \
+ $(top_srcdir)/sntp/m4/ntp_debug.m4 \
+ $(top_srcdir)/sntp/m4/ntp_dir_sep.m4 \
+ $(top_srcdir)/sntp/m4/ntp_facilitynames.m4 \
+ $(top_srcdir)/sntp/m4/ntp_googletest.m4 \
+ $(top_srcdir)/sntp/m4/ntp_ipv6.m4 \
+ $(top_srcdir)/sntp/m4/ntp_lib_m.m4 \
+ $(top_srcdir)/sntp/m4/ntp_libevent.m4 \
+ $(top_srcdir)/sntp/m4/ntp_libntp.m4 \
+ $(top_srcdir)/sntp/m4/ntp_lineeditlibs.m4 \
+ $(top_srcdir)/sntp/m4/ntp_locinfo.m4 \
+ $(top_srcdir)/sntp/m4/ntp_openssl.m4 \
+ $(top_srcdir)/sntp/m4/ntp_pkg_config.m4 \
+ $(top_srcdir)/sntp/m4/ntp_prog_cc.m4 \
+ $(top_srcdir)/sntp/m4/ntp_rlimit.m4 \
+ $(top_srcdir)/sntp/m4/ntp_sntp.m4 \
+ $(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
+ $(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/os_cflags.m4 \
+ $(top_srcdir)/sntp/m4/snprintf.m4 \
+ $(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libexecdir)" \
+ "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man1dir)" \
+ "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(htmldir)"
+SCRIPTS = $(bin_SCRIPTS) $(libexec_SCRIPTS) $(noinst_SCRIPTS) \
+ $(sbin_SCRIPTS)
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+man1dir = $(mandir)/man1
+man8dir = $(mandir)/man8
+NROFF = nroff
+MANS = $(man1_MANS) $(man8_MANS) $(man_MANS)
+DATA = $(html_DATA) $(noinst_DATA)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CALC_TICKADJ_DB = @CALC_TICKADJ_DB@
+CALC_TICKADJ_DL = @CALC_TICKADJ_DL@
+CALC_TICKADJ_DS = @CALC_TICKADJ_DS@
+CALC_TICKADJ_MS = @CALC_TICKADJ_MS@
+CALC_TICKADJ_NI = @CALC_TICKADJ_NI@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CFLAGS_NTP = @CFLAGS_NTP@
+CHUTEST = @CHUTEST@
+CONFIG_SHELL = @CONFIG_SHELL@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPFLAGS_LIBEVENT = @CPPFLAGS_LIBEVENT@
+CPPFLAGS_NTP = @CPPFLAGS_NTP@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EDITLINE_LIBS = @EDITLINE_LIBS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+GTEST_CONFIG = @GTEST_CONFIG@
+GTEST_CPPFLAGS = @GTEST_CPPFLAGS@
+GTEST_CXXFLAGS = @GTEST_CXXFLAGS@
+GTEST_LDFLAGS = @GTEST_LDFLAGS@
+GTEST_LIBS = @GTEST_LIBS@
+HAVE_INLINE = @HAVE_INLINE@
+HAVE_RLIMIT_MEMLOCK = @HAVE_RLIMIT_MEMLOCK@
+HAVE_RLIMIT_STACK = @HAVE_RLIMIT_STACK@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDADD_LIBEVENT = @LDADD_LIBEVENT@
+LDADD_LIBNTP = @LDADD_LIBNTP@
+LDADD_LIBUTIL = @LDADD_LIBUTIL@
+LDADD_NLIST = @LDADD_NLIST@
+LDADD_NTP = @LDADD_NTP@
+LDFLAGS = @LDFLAGS@
+LDFLAGS_NTP = @LDFLAGS_NTP@
+LIBISC_PTHREADS_NOTHREADS = @LIBISC_PTHREADS_NOTHREADS@
+LIBM = @LIBM@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBTOOL_DEPS = @LIBTOOL_DEPS@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPSNMPD = @MAKE_NTPSNMPD@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MANTAGFMT = @MANTAGFMT@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+NTPDATE_DB = @NTPDATE_DB@
+NTPDATE_DL = @NTPDATE_DL@
+NTPDATE_DS = @NTPDATE_DS@
+NTPDATE_MS = @NTPDATE_MS@
+NTPDATE_NI = @NTPDATE_NI@
+NTPDC_DB = @NTPDC_DB@
+NTPDC_DL = @NTPDC_DL@
+NTPDC_DS = @NTPDC_DS@
+NTPDC_MS = @NTPDC_MS@
+NTPDC_NI = @NTPDC_NI@
+NTPDSIM_DB = @NTPDSIM_DB@
+NTPDSIM_DL = @NTPDSIM_DL@
+NTPDSIM_DS = @NTPDSIM_DS@
+NTPDSIM_MS = @NTPDSIM_MS@
+NTPDSIM_NI = @NTPDSIM_NI@
+NTPD_DB = @NTPD_DB@
+NTPD_DL = @NTPD_DL@
+NTPD_DS = @NTPD_DS@
+NTPD_MS = @NTPD_MS@
+NTPD_NI = @NTPD_NI@
+NTPQ_DB = @NTPQ_DB@
+NTPQ_DL = @NTPQ_DL@
+NTPQ_DS = @NTPQ_DS@
+NTPQ_MS = @NTPQ_MS@
+NTPQ_NI = @NTPQ_NI@
+NTPSNMPD_DB = @NTPSNMPD_DB@
+NTPSNMPD_DL = @NTPSNMPD_DL@
+NTPSNMPD_DS = @NTPSNMPD_DS@
+NTPSNMPD_MS = @NTPSNMPD_MS@
+NTPSNMPD_NI = @NTPSNMPD_NI@
+NTPSWEEP_DB = @NTPSWEEP_DB@
+NTPSWEEP_DL = @NTPSWEEP_DL@
+NTPSWEEP_DS = @NTPSWEEP_DS@
+NTPSWEEP_MS = @NTPSWEEP_MS@
+NTPSWEEP_NI = @NTPSWEEP_NI@
+NTPTIME_DB = @NTPTIME_DB@
+NTPTIME_DL = @NTPTIME_DL@
+NTPTIME_DS = @NTPTIME_DS@
+NTPTIME_MS = @NTPTIME_MS@
+NTPTIME_NI = @NTPTIME_NI@
+NTPTRACE_DB = @NTPTRACE_DB@
+NTPTRACE_DL = @NTPTRACE_DL@
+NTPTRACE_DS = @NTPTRACE_DS@
+NTPTRACE_MS = @NTPTRACE_MS@
+NTPTRACE_NI = @NTPTRACE_NI@
+NTP_KEYGEN_DB = @NTP_KEYGEN_DB@
+NTP_KEYGEN_DL = @NTP_KEYGEN_DL@
+NTP_KEYGEN_DS = @NTP_KEYGEN_DS@
+NTP_KEYGEN_MS = @NTP_KEYGEN_MS@
+NTP_KEYGEN_NI = @NTP_KEYGEN_NI@
+NTP_KEYSDIR = @NTP_KEYSDIR@
+NTP_WAIT_DB = @NTP_WAIT_DB@
+NTP_WAIT_DL = @NTP_WAIT_DL@
+NTP_WAIT_DS = @NTP_WAIT_DS@
+NTP_WAIT_MS = @NTP_WAIT_MS@
+NTP_WAIT_NI = @NTP_WAIT_NI@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_NET_SNMP_CONFIG = @PATH_NET_SNMP_CONFIG@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_TEST = @PATH_TEST@
+PERLLIBDIR = @PERLLIBDIR@
+PKG_CONFIG = @PKG_CONFIG@
+POSIX_SHELL = @POSIX_SHELL@
+PROPDELAY = @PROPDELAY@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SNMP_CFLAGS = @SNMP_CFLAGS@
+SNMP_CPPFLAGS = @SNMP_CPPFLAGS@
+SNMP_LIBS = @SNMP_LIBS@
+SNTP = @SNTP@
+SNTP_DB = @SNTP_DB@
+SNTP_DL = @SNTP_DL@
+SNTP_DS = @SNTP_DS@
+SNTP_MS = @SNTP_MS@
+SNTP_NI = @SNTP_NI@
+STDNORETURN_H = @STDNORETURN_H@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+TICKADJ_DB = @TICKADJ_DB@
+TICKADJ_DL = @TICKADJ_DL@
+TICKADJ_DS = @TICKADJ_DS@
+TICKADJ_MS = @TICKADJ_MS@
+TICKADJ_NI = @TICKADJ_NI@
+TIMETRIM_DB = @TIMETRIM_DB@
+TIMETRIM_DL = @TIMETRIM_DL@
+TIMETRIM_DS = @TIMETRIM_DS@
+TIMETRIM_MS = @TIMETRIM_MS@
+TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
+VERSION = @VERSION@
+VER_SUFFIX = @VER_SUFFIX@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+NULL =
+run_ag = cd $(srcdir) && env PATH="$(abs_builddir):$(PATH)" PERL5LIB="$(abs_top_srcdir)/scripts/lib" AUTOGEN_DNE_DATE=-D \
+ autogen -L ../../sntp/include -L ../../sntp/ag-tpl \
+ --writable
+
+std_def_list = \
+ $(top_srcdir)/sntp/include/debug-opt.def \
+ $(top_srcdir)/sntp/include/autogen-version.def \
+ $(top_srcdir)/sntp/include/copyright.def \
+ $(top_srcdir)/sntp/include/homerc.def \
+ $(top_srcdir)/sntp/include/ntp.lic \
+ $(top_srcdir)/sntp/include/version.def \
+ $(NULL)
+
+bin_SCRIPTS = $(UPDATE_LEAP_DB)
+sbin_SCRIPTS = $(UPDATE_LEAP_DS)
+libexec_SCRIPTS = $(UPDATE_LEAP_DL)
+noinst_SCRIPTS = $(UPDATE_LEAP_NI)
+EXTRA_SCRIPTS = update-leap
+man1_MANS =
+man8_MANS =
+@INSTALL_UPDATE_LEAP_TRUE@man_MANS = update-leap.$(UPDATE_LEAP_MS)
+@INSTALL_UPDATE_LEAP_FALSE@noinst_MANS = update-leap.$(UPDATE_LEAP_MS)
+EXTRA_DIST = \
+ invoke-update-leap.menu \
+ invoke-update-leap.texi \
+ update-leap \
+ update-leap-opts.def \
+ update-leap-opts \
+ update-leap.1update-leapman \
+ update-leap.1update-leapmdoc \
+ update-leap.man.in \
+ update-leap.mdoc.in \
+ update-leap.texi \
+ update-leap.html \
+ $(NULL)
+
+html_DATA = update-leap.html
+
+#CLEANFILES = update-leap.1
+DISTCLEANFILES = config.log $(man_MANS) $(noinst_MANS)
+noinst_DATA = \
+ invoke-update-leap.menu \
+ invoke-update-leap.texi \
+ update-leap.man.in \
+ update-leap.mdoc.in \
+ update-leap-opts \
+ $(NULL)
+
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign scripts/update-leap/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign scripts/update-leap/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-binSCRIPTS: $(bin_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n' \
+ -e 'h;s|.*|.|' \
+ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+ if (++n[d] == $(am__install_max)) { \
+ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+ else { print "f", d "/" $$4, $$1 } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-binSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 's,.*/,,;$(transform)'`; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(bindir)" && rm -f $$files
+install-libexecSCRIPTS: $(libexec_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ test -z "$(libexecdir)" || $(MKDIR_P) "$(DESTDIR)$(libexecdir)"
+ @list='$(libexec_SCRIPTS)'; test -n "$(libexecdir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n' \
+ -e 'h;s|.*|.|' \
+ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+ if (++n[d] == $(am__install_max)) { \
+ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+ else { print "f", d "/" $$4, $$1 } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(libexecdir)$$dir'"; \
+ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(libexecdir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-libexecSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(libexec_SCRIPTS)'; test -n "$(libexecdir)" || exit 0; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 's,.*/,,;$(transform)'`; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(libexecdir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(libexecdir)" && rm -f $$files
+install-sbinSCRIPTS: $(sbin_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)"
+ @list='$(sbin_SCRIPTS)'; test -n "$(sbindir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n' \
+ -e 'h;s|.*|.|' \
+ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+ if (++n[d] == $(am__install_max)) { \
+ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+ else { print "f", d "/" $$4, $$1 } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(sbindir)$$dir'"; \
+ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-sbinSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(sbin_SCRIPTS)'; test -n "$(sbindir)" || exit 0; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 's,.*/,,;$(transform)'`; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(sbindir)" && rm -f $$files
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-man1: $(man1_MANS) $(man_MANS)
+ @$(NORMAL_INSTALL)
+ test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
+ @list='$(man1_MANS)'; test -n "$(man1dir)" || exit 0; \
+ { for i in $$list; do echo "$$i"; done; \
+ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+ sed -n '/\.1[a-z]*$$/p'; \
+ } | while read p; do \
+ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; echo "$$p"; \
+ done | \
+ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+ sed 'N;N;s,\n, ,g' | { \
+ list=; while read file base inst; do \
+ if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
+ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
+ fi; \
+ done; \
+ for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+ while read files; do \
+ test -z "$$files" || { \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
+ done; }
+
+uninstall-man1:
+ @$(NORMAL_UNINSTALL)
+ @list='$(man1_MANS)'; test -n "$(man1dir)" || exit 0; \
+ files=`{ for i in $$list; do echo "$$i"; done; \
+ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+ sed -n '/\.1[a-z]*$$/p'; \
+ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+ test -z "$$files" || { \
+ echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(man1dir)" && rm -f $$files; }
+install-man8: $(man8_MANS) $(man_MANS)
+ @$(NORMAL_INSTALL)
+ test -z "$(man8dir)" || $(MKDIR_P) "$(DESTDIR)$(man8dir)"
+ @list='$(man8_MANS)'; test -n "$(man8dir)" || exit 0; \
+ { for i in $$list; do echo "$$i"; done; \
+ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+ sed -n '/\.8[a-z]*$$/p'; \
+ } | while read p; do \
+ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; echo "$$p"; \
+ done | \
+ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+ sed 'N;N;s,\n, ,g' | { \
+ list=; while read file base inst; do \
+ if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \
+ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst" || exit $$?; \
+ fi; \
+ done; \
+ for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+ while read files; do \
+ test -z "$$files" || { \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man8dir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(man8dir)" || exit $$?; }; \
+ done; }
+
+uninstall-man8:
+ @$(NORMAL_UNINSTALL)
+ @list='$(man8_MANS)'; test -n "$(man8dir)" || exit 0; \
+ files=`{ for i in $$list; do echo "$$i"; done; \
+ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+ sed -n '/\.8[a-z]*$$/p'; \
+ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+ test -z "$$files" || { \
+ echo " ( cd '$(DESTDIR)$(man8dir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(man8dir)" && rm -f $$files; }
+install-htmlDATA: $(html_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(htmldir)" || $(MKDIR_P) "$(DESTDIR)$(htmldir)"
+ @list='$(html_DATA)'; test -n "$(htmldir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(htmldir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(htmldir)" || exit $$?; \
+ done
+
+uninstall-htmlDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(html_DATA)'; test -n "$(htmldir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ test -n "$$files" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(htmldir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(htmldir)" && rm -f $$files
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+ @list='$(MANS)'; if test -n "$$list"; then \
+ list=`for p in $$list; do \
+ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+ if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
+ if test -n "$$list" && \
+ grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
+ echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
+ grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \
+ echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \
+ echo " typically \`make maintainer-clean' will remove them" >&2; \
+ exit 1; \
+ else :; fi; \
+ else :; fi
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(SCRIPTS) $(MANS) $(DATA)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(sbindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(htmldir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+ -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-htmlDATA install-man
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binSCRIPTS install-libexecSCRIPTS \
+ install-sbinSCRIPTS
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man: install-man1 install-man8
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binSCRIPTS uninstall-htmlDATA \
+ uninstall-libexecSCRIPTS uninstall-man uninstall-sbinSCRIPTS
+
+uninstall-man: uninstall-man1 uninstall-man8
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ distclean distclean-generic distclean-libtool distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-binSCRIPTS install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-htmlDATA install-info install-info-am \
+ install-libexecSCRIPTS install-man install-man1 install-man8 \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-sbinSCRIPTS install-strip installcheck installcheck-am \
+ installdirs maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
+ ps ps-am uninstall uninstall-am uninstall-binSCRIPTS \
+ uninstall-htmlDATA uninstall-libexecSCRIPTS uninstall-man \
+ uninstall-man1 uninstall-man8 uninstall-sbinSCRIPTS
+
+
+$(srcdir)/update-leap: $(srcdir)/update-leap-opts
+ @: do-nothing action to avoid default SCCS get
+
+$(srcdir)/update-leap-opts: update-leap-opts.def $(std_def_list)
+ $(run_ag) update-leap-opts.def
+
+### Man
+
+$(srcdir)/update-leap.1update-leapman: $(srcdir)/update-leap-opts.def $(std_def_list)
+ $(run_ag) -DMAN_SECTION=1update-leapman -Tagman-cmd.tpl update-leap-opts.def
+
+$(srcdir)/update-leap.man.in: $(srcdir)/update-leap.1update-leapman $(top_srcdir)/sntp/scripts/mansec2subst.sed
+ sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/update-leap.1update-leapman > $(srcdir)/update-leap.man.in+
+ mv $(srcdir)/update-leap.man.in+ $(srcdir)/update-leap.man.in
+
+### Mdoc
+
+$(srcdir)/update-leap.1update-leapmdoc: $(srcdir)/update-leap-opts.def $(std_def_list)
+ $(run_ag) -DMAN_SECTION=1update-leapmdoc -Tagmdoc-cmd.tpl update-leap-opts.def
+
+$(srcdir)/update-leap.mdoc.in: $(srcdir)/update-leap.1update-leapmdoc $(top_srcdir)/sntp/scripts/mansec2subst.sed
+ sed -f $(top_srcdir)/sntp/scripts/mansec2subst.sed $(srcdir)/update-leap.1update-leapmdoc > $(srcdir)/update-leap.mdoc.in+
+ mv $(srcdir)/update-leap.mdoc.in+ $(srcdir)/update-leap.mdoc.in
+
+### Manpage
+
+update-leap.$(UPDATE_LEAP_MS): $(srcdir)/update-leap.$(MANTAGFMT).in $(top_builddir)/config.status
+ $(top_builddir)/config.status --file=update-leap.$(UPDATE_LEAP_MS)+:$(srcdir)/update-leap.$(MANTAGFMT).in
+ mv update-leap.$(UPDATE_LEAP_MS)+ update-leap.$(UPDATE_LEAP_MS)
+
+### Texinfo
+
+$(srcdir)/invoke-update-leap.menu: $(srcdir)/invoke-update-leap.texi
+ @: do-nothing action to avoid default SCCS get, .menu built with .texi
+
+$(srcdir)/invoke-update-leap.texi: $(srcdir)/update-leap-opts.def $(std_def_list)
+ $(run_ag) -Tagtexi-cmd.tpl -DLEVEL=section update-leap-opts.def
+ $(top_srcdir)/scripts/build/check--help $@
+
+### HTML
+
+$(srcdir)/update-leap.html: $(srcdir)/update-leap.texi $(top_srcdir)/sntp/include/version.texi
+ cd $(srcdir) && ( makeinfo --force --html --no-split -I ../sntp -o update-leap.html update-leap.texi || true )
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/contrib/ntp/scripts/update-leap/invoke-update-leap.menu b/contrib/ntp/scripts/update-leap/invoke-update-leap.menu
new file mode 100644
index 0000000..e27e349
--- /dev/null
+++ b/contrib/ntp/scripts/update-leap/invoke-update-leap.menu
@@ -0,0 +1 @@
+* update-leap Invocation:: Invoking update-leap
diff --git a/contrib/ntp/scripts/update-leap/invoke-update-leap.texi b/contrib/ntp/scripts/update-leap/invoke-update-leap.texi
new file mode 100644
index 0000000..8fc25db
--- /dev/null
+++ b/contrib/ntp/scripts/update-leap/invoke-update-leap.texi
@@ -0,0 +1,170 @@
+@node update-leap Invocation
+@section Invoking update-leap
+@pindex update-leap
+@cindex leap-seconds file manager/updater
+@ignore
+#
+# EDIT THIS FILE WITH CAUTION (invoke-update-leap.texi)
+#
+# It has been AutoGen-ed April 7, 2015 at 04:21:44 AM by AutoGen 5.18.5pre4
+# From the definitions update-leap-opts.def
+# and the template file agtexi-cmd.tpl
+@end ignore
+
+
+
+@code{update-leap}
+will validate the file currently on the local system
+and if necessary, updates leap-second definition file.
+
+Ordinarily, the file is found using the "leapfile" directive in
+@code{ntp.conf(5)}.
+However, an alternate location can be specified on the command line.
+
+If the file does not exist, is not valid, has expired, or is expiring soon,
+a new copy will be downloaded. If the new copy validates, it is installed and
+NTP is (optionally) restarted.
+
+If the current file is acceptable, no download or restart occurs.
+
+-c can also be used to invoke another script to perform administrative
+functions, e.g. to copy the file to other local systems.
+.PP
+This can be run as a cron job. As the file is rarely updated, and leap
+seconds are announced at least one month in advance (usually longer), it
+need not be run more frequently than about once every three weeks.
+.PP
+For cron-friendly behavior, define CRONJOB=1 in the crontab.
+.PP
+This script depends on$REQUIREDCMDS
+
+This section was generated by @strong{AutoGen},
+using the @code{agtexi-cmd} template and the option descriptions for the @code{update-leap} program.
+
+@menu
+* update-leap usage:: update-leap help/usage (@option{--help})
+* update-leap source-url:: source-url option (-s)
+* update-leap ipv4:: ipv4 option (-4)
+* update-leap destination:: destination option (-d)
+* update-leap expiration:: expiration option (-e)
+* update-leap ntp-conf-file:: ntp-conf-file option (-f)
+* update-leap force-update:: force-update option (-F)
+* update-leap exit status:: exit status
+* update-leap Usage:: Usage
+* update-leap Authors:: Authors
+@end menu
+
+@node update-leap usage
+@subsection update-leap help/usage (@option{--help})
+@cindex update-leap help
+
+This is the automatically generated usage text for update-leap.
+
+The text printed is the same whether selected with the @code{help} option
+(@option{--help}) or the @code{more-help} option (@option{--more-help}). @code{more-help} will print
+the usage text by passing it through a pager program.
+@code{more-help} is disabled on platforms without a working
+@code{fork(2)} function. The @code{PAGER} environment variable is
+used to select the program, defaulting to @file{more}. Both will exit
+with a status code of 0.
+
+@exampleindent 0
+@example
+/bin/bash: line 136: ./update-leap: Permission denied
+@end example
+@exampleindent 4
+
+@node update-leap source-url
+@subsection source-url option (-s)
+@cindex update-leap-source-url
+
+This is the ``the url of the master copy of the leapseconds file'' option.
+This option takes a string argument.
+Specify the URL of the master copy to download
+$LEAPSRC
+@node update-leap ipv4
+@subsection ipv4 option (-4)
+@cindex update-leap-ipv4
+
+This is the ``use only ipv4 addresses for dns name resolution'' option.
+
+@noindent
+This option has some usage constraints. It:
+@itemize @bullet
+@item
+must not appear in combination with any of the following options:
+ipv6.
+@end itemize
+
+ Force DNS resolution of following host names on the command line
+ to the IPv4 namespace.
+ _EndOfDoc_;
+};
+
+flag = {
+ name = ipv6;
+ flags-cant = ipv4, prefer;
+ value = 6;
+ descrip = "Use only IPv6 addresses for DNS name resolution";
+ doc = <<- _EndOfDoc_
+ Force DNS resolution of following host names on the command line
+ to the IPv6 namespace.
+ _EndOfDoc_;
+};
+
+flag = {
+ name = prefer;
+ flags-cant = ipv4, ipv6;
+ value = p;
+ arg-type = keyword;
+ keyword = 4, 6;
+ descrip = 'Prefer IPv4 or IPv6 (as specified) addresses, but use either';
+ doc = <<- _EndOfDoc_
+Prefer IPv4 or IPv6 (as specified) addresses, but use either.
+@node update-leap destination
+@subsection destination option (-d)
+@cindex update-leap-destination
+
+This is the ``filename on the local system'' option.
+This option takes a string argument @file{float}.
+The name to use to store the leapfile on the local system.
+$LEAPFILE
+@node update-leap expiration
+@subsection expiration option (-e)
+@cindex update-leap-expiration
+
+This is the ``refresh the leapfile this long before it expires'' option.
+This option takes a string argument.
+Specify how long before expiration the file is to be refreshed
+Units are required, e.g. "-e 60 days" Note that larger values
+imply more frequent refreshes.
+"$PREFETCH"
+@node update-leap ntp-conf-file
+@subsection ntp-conf-file option (-f)
+@cindex update-leap-ntp-conf-file
+
+This is the ``location of the ntp.conf file'' option.
+This option takes a string argument.
+Specify location of ntp.conf (used to make sure leapfile directive is
+present and to default leapfile)
+/etc/ntp.conf
+@node update-leap force-update
+@subsection force-update option (-F)
+@cindex update-leap-force-update
+
+This is the ``force update of the leapfile'' option.
+Force update even if current file is OK and not close to expiring.
+@node update-leap exit status
+@subsection update-leap exit status
+
+One of the following exit values will be returned:
+@table @samp
+@item 0 (EXIT_SUCCESS)
+Successful program execution.
+@item 1 (EXIT_FAILURE)
+The operation failed or the command syntax was not valid.
+@end table
+@node update-leap Usage
+@subsection update-leap Usage
+@node update-leap Authors
+@subsection update-leap Authors
diff --git a/contrib/ntp/scripts/update-leap/update-leap b/contrib/ntp/scripts/update-leap/update-leap
new file mode 100644
index 0000000..2dab4ec
--- /dev/null
+++ b/contrib/ntp/scripts/update-leap/update-leap
@@ -0,0 +1,434 @@
+#!/bin/bash
+
+# Copyright (C) 2014 Timothe Litt litt at acm dot org
+
+# This script may be freely copied, used and modified providing that
+# this notice and the copyright statement are included in all copies
+# and derivative works. No warranty is offered, and use is entirely at
+# your own risk. Bugfixes and improvements would be appreciated by the
+# author.
+
+VERSION="1.003"
+
+# leap-seconds file manager/updater
+
+# Depends on:
+# wget sed, tr, shasum, logger
+
+# ########## Default configuration ##########
+#
+# Where to get the file
+LEAPSRC="ftp://time.nist.gov/pub/leap-seconds.list"
+
+# How many times to try to download new file
+MAXTRIES=6
+INTERVAL=10
+
+# Where to find ntp config file
+NTPCONF=/etc/ntp.conf
+
+# How long before expiration to get updated file
+PREFETCH="60 days"
+
+# How to restart NTP - older NTP: service ntpd? try-restart | condrestart
+# Recent NTP checks for new file daily, so there's nothing to do
+RESTART=
+
+# Where to put temporary copy before it's validated
+TMPFILE="/tmp/leap-seconds.$$.tmp"
+
+# Syslog facility
+LOGFAC=daemon
+# ###########################################
+
+# Places to look for commands. Allows for CRON having path to
+# old utilities on embedded systems
+
+PATHLIST="/opt/sbin:/opt/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:"
+
+REQUIREDCMDS=" wget logger tr sed shasum"
+
+SELF="`basename $0`"
+
+function displayHelp {
+ cat <<EOF
+Usage: $SELF [options] [leapfile]
+
+Verifies and if necessary, updates leap-second definition file
+
+All arguments are optional: Default (or current value) shown:
+ -s Specify the URL of the master copy to download
+ $LEAPSRC
+ -4 Use only IPv4
+ -6 Use only IPv6
+ -p 4|6
+ Prefer IPv4 or IPv6 (as specified) addresses, but use either
+ -d Specify the filename on the local system
+ $LEAPFILE
+ -e Specify how long before expiration the file is to be refreshed
+ Units are required, e.g. "-e 60 days" Note that larger values
+ imply more frequent refreshes.
+ "$PREFETCH"
+ -f Specify location of ntp.conf (used to make sure leapfile directive is
+ present and to default leapfile)
+ $NTPCONF
+ -F Force update even if current file is OK and not close to expiring.
+ -c Command to restart NTP after installing a new file
+ <none> - ntpd checks file daily
+ -r Specify number of times to retry on get failure
+ $MAXTRIES
+ -i Specify number of minutes between retries
+ $INTERVAL
+ -l Use syslog for output (Implied if CRONJOB is set)
+ -L Don't use syslog for output
+ -P Specify the syslog facility for logging
+ $LOGFAC
+ -t Name of temporary file used in validation
+ $TMPFILE
+ -q Only report errors to stdout
+ -v Verbose output
+ -z Specify path for utilities
+ $PATHLIST
+ -Z Only use system path
+
+$SELF will validate the file currently on the local system
+
+Ordinarily, the file is found using the "leapfile" directive in $NTPCONF.
+However, an alternate location can be specified on the command line.
+
+If the file does not exist, is not valid, has expired, or is expiring soon,
+a new copy will be downloaded. If the new copy validates, it is installed and
+NTP is (optionally) restarted.
+
+If the current file is acceptable, no download or restart occurs.
+
+-c can also be used to invoke another script to perform administrative
+functions, e.g. to copy the file to other local systems.
+
+This can be run as a cron job. As the file is rarely updated, and leap
+seconds are announced at least one month in advance (usually longer), it
+need not be run more frequently than about once every three weeks.
+
+For cron-friendly behavior, define CRONJOB=1 in the crontab.
+
+This script depends on$REQUIREDCMDS
+
+Version $VERSION
+EOF
+ return 0
+}
+
+# Default: Use syslog for logging if running under cron
+
+SYSLOG="$CRONJOB"
+
+if [ "$1" = "--help" ]; then
+ displayHelp
+ exit 0
+fi
+
+# Parse options
+
+while getopts 46p:P:s:e:f:Fc:r:i:lLt:hqvz:Z opt; do
+ case $opt in
+ 4)
+ PROTO="-4"
+ ;;
+ 6)
+ PROTO="-6"
+ ;;
+ p)
+ if [ "$OPTARG" = '4' -o "$OPTARG" = '6' ]; then
+ PREFER="--prefer-family=IPv$OPTARG"
+ else
+ echo "Invalid -p $OPTARG" >&2
+ exit 1;
+ fi
+ ;;
+ P)
+ LOGFAC="$OPTARG"
+ ;;
+ s)
+ LEAPSRC="$OPTARG"
+ ;;
+ e)
+ PREFETCH="$OPTARG"
+ ;;
+ f)
+ NTPCONF="$OPTARG"
+ ;;
+ F)
+ FORCE="Y"
+ ;;
+ c)
+ RESTART="$OPTARG"
+ ;;
+ r)
+ MAXTRIES="$OPTARG"
+ ;;
+ i)
+ INTERVAL="$OPTARG"
+ ;;
+ t)
+ TMPFILE="$OPTARG"
+ ;;
+ l)
+ SYSLOG="y"
+ ;;
+ L)
+ SYSLOG=
+ ;;
+ h)
+ displayHelp
+ exit 0
+ ;;
+ q)
+ QUIET="Y"
+ ;;
+ v)
+ VERBOSE="Y"
+ ;;
+ z)
+ PATHLIST="$OPTARG:"
+ ;;
+ Z)
+ PATHLIST=
+ ;;
+ *)
+ echo "$SELF -h for usage" >&2
+ exit 1
+ ;;
+ esac
+done
+shift $((OPTIND-1))
+
+export PATH="$PATHLIST$PATH"
+
+# Add to path to deal with embedded systems
+#
+for P in $REQUIREDCMDS ; do
+ if >/dev/null 2>&1 which "$P" ; then
+ continue
+ fi
+ [ "$P" = "logger" ] && continue
+ echo "FATAL: missing $P command, please install"
+ exit 1
+done
+
+# Handle logging
+
+if ! LOGGER="`2>/dev/null which logger`" ; then
+ LOGGER=
+fi
+
+function log {
+ # "priority" "message"
+ #
+ # Stdout unless syslog specified or logger isn't available
+ #
+ if [ -z "$SYSLOG" -o -z "$LOGGER" ]; then
+ if [ -n "$QUIET" -a \( "$1" = "info" -o "$1" = "notice" -o "$1" = "debug" \) ]; then
+ return 0
+ fi
+ echo "`echo \"$1\" | tr a-z A-Z`: $2"
+ return 0
+ fi
+
+ # Also log to stdout if cron job && notice or higher
+ local S
+ if [ -n "$CRONJOB" -a \( "$1" != "info" \) -a \( "$1" != "debug" \) ] || [ -n "$VERBOSE" ]; then
+ S="-s"
+ fi
+ $LOGGER $S -t "$SELF[$$]" -p "$LOGFAC.$1" "$2"
+}
+
+# Verify interval
+INTERVAL=$(( $INTERVAL *1 ))
+
+# Validate a leap-seconds file checksum
+#
+# File format: (full description in files)
+# # marks comments, except:
+# #$ number : the NTP date of the last update
+# #@ number : the NTP date that the file expires
+# Date (seconds since 1900) leaps : leaps is the # of seconds to add for times >= Date
+# Date lines have comments.
+# #h hex hex hex hex hex is the SHA-1 checksum of the data & dates, excluding whitespace w/o leading zeroes
+
+function verifySHA {
+
+ if [ ! -f "$1" ]; then
+ return 1
+ fi
+
+ # Remove comments, except those that are markers for last update, expires and hash
+
+ local RAW="`sed $1 -e'/^\\([0-9]\\|#[\$@h]\)/!d' -e'/^#[\$@h]/!s/#.*\$//g'`"
+
+ # Extract just the data, removing all whitespace
+
+ local DATA="`echo \"$RAW\" | sed -e'/^#h/d' -e's/^#[\$@]//g' | tr -d '[:space:]'`"
+
+ # Compute the SHA hash of the data, removing the marker and filename
+ # Computed in binary mode, which shouldn't matter since whitespace has been removed
+ # shasum comes in several flavors; a portable one is available in Perl (with Digest::SHA)
+
+ local DSHA="`echo -n \"$DATA\" | shasum | sed -e's/[? *].*$//'`"
+
+ # Extract the file's hash. Restore any leading zeroes in hash segments.
+
+ # The sed [] includes a tab (\t) and space; #h is followed by a tab and space
+ local FSHA="`echo \"$RAW\" | sed -e'/^#h/!d' -e's/^#h//' -e's/[ ] */ 0x/g'`"
+ FSHA=`printf '%08x%08x%08x%08x%08x' $FSHA`
+
+ if [ -n "$FSHA" -a \( "$FSHA" = "$DSHA" \) ]; then
+ if [ -n "$2" ]; then
+ log "info" "Checksum of $1 validated"
+ fi
+ else
+ log "error" "Checksum of $1 is invalid:"
+ [ -z "$FSHA" ] && FSHA="(no checksum record found in file)"
+ log "error" "EXPECTED: $FSHA"
+ log "error" "COMPUTED: $DSHA"
+ return 1
+ fi
+
+ # Check the expiration date, converting NTP epoch to Unix epoch used by date
+
+ EXPIRES="`echo \"$RAW\" | sed -e'/^#@/!d' -e's/^#@//' | tr -d '[:space:]'`"
+ EXPIRES="$(($EXPIRES - 2208988800 ))"
+
+ if [ $EXPIRES -lt `date -u +%s` ]; then
+ log "notice" "File expired on `date -u -d \"Jan 1, 1970 00:00:00 +0000 + $EXPIRES seconds\"`"
+ return 2
+ fi
+
+}
+
+# Verify ntp.conf
+
+if ! [ -f "$NTPCONF" ]; then
+ log "critical" "Missing ntp configuration $NTPCONF"
+ exit 1
+fi
+
+# Parse ntp.conf for leapfile directive
+
+LEAPFILE="`sed $NTPCONF -e'/^ *leapfile *.*$/!d' -e's/^ *leapfile *//'`"
+if [ -z "$LEAPFILE" ]; then
+ log "error" "$NTPCONF does not specify a leapfile"
+fi
+
+# Allow placing the file someplace else - testing
+
+if [ -n "$1" ]; then
+ if [ "$1" != "$LEAPFILE" ]; then
+ log "notice" "Requested install to $1, but $NTPCONF specifies $LEAPFILE"
+ fi
+ LEAPFILE="$1"
+fi
+
+# Verify the current file
+# If it is missing, doesn't validate or expired
+# Or is expiring soon
+# Download a new one
+
+if [ -n "$FORCE" ] || ! verifySHA $LEAPFILE "$VERBOSE" || [ $EXPIRES -lt `date -d "NOW + $PREFETCH" +%s` ] ; then
+ TRY=0
+ while true; do
+ TRY=$(( $TRY + 1 ))
+ if [ -n "$VERBOSE" ]; then
+ log "info" "Attempting download from $LEAPSRC, try $TRY.."
+ fi
+ if wget $PROTO $PREFER -o ${TMPFILE}.log $LEAPSRC -O $TMPFILE ; then
+ log "info" "Download of $LEAPSRC succeeded"
+ if [ -n "$VERBOSE" ]; then
+ cat ${TMPFILE}.log
+ fi
+
+ if ! verifySHA $TMPFILE "$VERBOSE" ; then
+ # There is no point in retrying, as the file on the server is almost
+ # certainly corrupt.
+
+ log "warning" "Downloaded file $TMPFILE rejected -- saved for diagnosis"
+ cat ${TMPFILE}.log
+ rm -f ${TMPFILE}.log
+ exit 1
+ fi
+ rm -f ${TMPFILE}.log
+
+ # Set correct permissions on temporary file
+
+ REFFILE="$LEAPFILE"
+ if [ ! -f $LEAPFILE ]; then
+ log "notice" "$LEAPFILE was missing, creating new copy - check permissions"
+ touch $LEAPFILE
+ # Can't copy permissions from old file, copy from NTPCONF instead
+ REFFILE="$NTPCONF"
+ fi
+ chmod --reference $REFFILE $TMPFILE
+ chown --reference $REFFILE $TMPFILE
+ ( which selinuxenabled && selinuxenabled && which chcon ) >/dev/null 2>&1
+ if [ $? == 0 ] ; then
+ chcon --reference $REFFILE $TMPFILE
+ fi
+
+ # Replace current file with validated new one
+
+ if mv -f $TMPFILE $LEAPFILE ; then
+ log "notice" "Installed new $LEAPFILE from $LEAPSRC"
+ else
+ log "error" "Install $TMPFILE => $LEAPFILE failed -- saved for diagnosis"
+ exit 1
+ fi
+
+ # Restart NTP (or whatever else is specified)
+
+ if [ -n "$RESTART" ]; then
+ if [ -n "$VERBOSE" ]; then
+ log "info" "Attempting restart action: $RESTART"
+ fi
+ R="$( 2>&1 $RESTART )"
+ if [ $? -eq 0 ]; then
+ log "notice" "Restart action succeeded"
+ if [ -n "$VERBOSE" -a -n "$R" ]; then
+ log "info" "$R"
+ fi
+ else
+ log "error" "Restart action failed"
+ if [ -n "$R" ]; then
+ log "error" "$R"
+ fi
+ exit 2
+ fi
+ fi
+ exit 0
+ fi
+
+ # Failed to download. See about trying again
+
+ rm -f $TMPFILE
+ if [ $TRY -ge $MAXTRIES ]; then
+ break;
+ fi
+ if [ -n "$VERBOSE" ]; then
+ cat ${TMPFILE}.log
+ log "info" "Waiting $INTERVAL minutes before retrying..."
+ fi
+ sleep $(( $INTERVAL * 60))
+ done
+
+ # Failed and out of retries
+
+ log "warning" "Download from $LEAPSRC failed after $TRY attempts"
+ if [ -f ${TMPFILE}.log ]; then
+ cat ${TMPFILE}.log
+ rm -f ${TMPFILE}.log $TMPFILE
+ fi
+ exit 1
+fi
+log "info" "Not time to replace $LEAPFILE"
+
+exit 0
+
+# EOF \ No newline at end of file
diff --git a/contrib/ntp/scripts/update-leap/update-leap-opts b/contrib/ntp/scripts/update-leap/update-leap-opts
new file mode 100644
index 0000000..69dba65
--- /dev/null
+++ b/contrib/ntp/scripts/update-leap/update-leap-opts
@@ -0,0 +1,72 @@
+# EDIT THIS FILE WITH CAUTION (update-leap-opts)
+#
+# It has been AutoGen-ed April 7, 2015 at 04:21:40 AM by AutoGen 5.18.5pre4
+# From the definitions update-leap-opts.def
+# and the template file perlopt
+
+use Getopt::Long qw(GetOptionsFromArray);
+Getopt::Long::Configure(qw(no_auto_abbrev no_ignore_case_always));
+
+my $usage;
+
+sub usage {
+ my ($ret) = @_;
+ print STDERR $usage;
+ exit $ret;
+}
+
+sub paged_usage {
+ my ($ret) = @_;
+ my $pager = $ENV{PAGER} || '(less || more)';
+
+ open STDOUT, "| $pager" or die "Can't fork a pager: $!";
+ print $usage;
+
+ exit $ret;
+}
+
+sub processOptions {
+ my $args = shift;
+
+ my $opts = {
+ 'source-url' => '',
+ 'ipv4' => '',
+ 'destination' => '',
+ 'expiration' => '',
+ 'ntp-conf-file' => '',
+ 'force-update' => '',
+ 'dont-wait' => '',
+ 'help' => '', 'more-help' => ''
+ };
+ my $argument = '';
+ my $ret = GetOptionsFromArray($args, $opts, (
+ 'source-url|s=s', 'ipv4|4', 'destination|d=f',
+ 'expiration|e=s', 'ntp-conf-file|f=s', 'force-update|F',
+ 'dont-wait',
+ 'help|?', 'more-help'));
+
+ $usage = <<'USAGE';
+update-leap - leap-seconds file manager/updater - Ver. 4.2.8p2
+USAGE: update-leap [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
+
+ -s, --source-url=str The URL of the master copy of the leapseconds file
+ -4, --ipv4 Use only IPv4 addresses for DNS name resolution
+ -d, --destination=float Filename on the local system
+ -e, --expiration=str Refresh the leapfile this long before it expires
+ -f, --ntp-conf-file=str Location of the ntp.conf file
+ -F, --force-update Force update of the leapfile
+ --dont-wait Don't wait for keystroke between plots
+ -?, --help Display usage information and exit
+ --more-help Pass the extended usage text through a pager
+
+Options are specified by doubled hyphens and their name or by a single
+hyphen and the flag character.
+USAGE
+
+ usage(0) if $opts->{'help'};
+ paged_usage(0) if $opts->{'more-help'};
+ $_[0] = $opts;
+ return $ret;
+}
+
+END { close STDOUT };
diff --git a/contrib/ntp/scripts/update-leap/update-leap-opts.def b/contrib/ntp/scripts/update-leap/update-leap-opts.def
new file mode 100644
index 0000000..9e73916
--- /dev/null
+++ b/contrib/ntp/scripts/update-leap/update-leap-opts.def
@@ -0,0 +1,163 @@
+/* -*- Mode: Text -*- */
+autogen definitions perlopt;
+
+#include autogen-version.def
+
+prog-name = 'update-leap';
+prog-title = 'leap-seconds file manager/updater';
+package = ntp;
+#include version.def
+
+long-opts;
+gnu-usage;
+
+flag = {
+ name = source-url;
+ value = s;
+ arg-type = string;
+ descrip = 'The URL of the master copy of the leapseconds file';
+ doc = <<- _EndOfDoc_
+ Specify the URL of the master copy to download
+ $LEAPSRC
+ _EndOfDoc_;
+};
+flag = {
+ name = ipv4;
+ flags-cant = ipv6;
+ value = 4;
+ descrip = "Use only IPv4 addresses for DNS name resolution";
+ doc = <<- _EndOfDoc_
+ Force DNS resolution of following host names on the command line
+ to the IPv4 namespace.
+ _EndOfDoc_;
+};
+
+flag = {
+ name = ipv6;
+ flags-cant = ipv4, prefer;
+ value = 6;
+ descrip = "Use only IPv6 addresses for DNS name resolution";
+ doc = <<- _EndOfDoc_
+ Force DNS resolution of following host names on the command line
+ to the IPv6 namespace.
+ _EndOfDoc_;
+};
+
+flag = {
+ name = prefer;
+ flags-cant = ipv4, ipv6;
+ value = p;
+ arg-type = keyword;
+ keyword = 4, 6;
+ descrip = 'Prefer IPv4 or IPv6 (as specified) addresses, but use either';
+ doc = <<- _EndOfDoc_
+ Prefer IPv4 or IPv6 (as specified) addresses, but use either.
+ _EndOfDoc_;
+};
+
+flag = {
+ name = destination;
+ value = d;
+ arg-type = string;
+ arg-name = float;
+ descrip = 'Filename on the local system';
+ doc = <<- _EndOfDoc_
+ The name to use to store the leapfile on the local system.
+ $LEAPFILE
+ _EndOfDoc_;
+};
+
+flag = {
+ name = expiration;
+ value = e;
+ arg-type = string;
+ descrip = 'Refresh the leapfile this long before it expires';
+ doc = <<- _EndOfDoc_
+ Specify how long before expiration the file is to be refreshed
+ Units are required, e.g. "-e 60 days" Note that larger values
+ imply more frequent refreshes.
+ "$PREFETCH"
+ _EndOfDoc_;
+};
+
+flag = {
+ name = ntp-conf-file;
+ value = f;
+ arg-type = string;
+ descrip = 'Location of the ntp.conf file';
+ doc = <<- _EndOfDoc_
+ Specify location of ntp.conf (used to make sure leapfile directive is
+ present and to default leapfile)
+ /etc/ntp.conf
+ _EndOfDoc_;
+};
+
+flag = {
+ name = force-update;
+ value = F;
+ descrip = 'Force update of the leapfile';
+ doc = <<- _EndOfDoc_
+ Force update even if current file is OK and not close to expiring.
+ _EndOfDoc_;
+};
+
+flag = {
+ name = dont-wait;
+ descrip = "Don't wait for keystroke between plots";
+ doc = <<- _EndOfDoc_
+ _EndOfDoc_;
+};
+
+/* explain: Additional information whenever the usage routine is invoked */
+explain = <<- _END_EXPLAIN
+ _END_EXPLAIN;
+
+doc-section = {
+ ds-type = 'DESCRIPTION';
+ ds-format = 'mdoc';
+ ds-text = <<- _END_PROG_MDOC_DESCRIP
+.Nm
+will validate the file currently on the local system
+and if necessary, updates leap-second definition file.
+.Pp
+Ordinarily, the file is found using the "leapfile" directive in
+.Xr ntp.conf 5 .
+However, an alternate location can be specified on the command line.
+.Pp
+If the file does not exist, is not valid, has expired, or is expiring soon,
+a new copy will be downloaded. If the new copy validates, it is installed and
+NTP is (optionally) restarted.
+.Pp
+If the current file is acceptable, no download or restart occurs.
+.Pp
+-c can also be used to invoke another script to perform administrative
+functions, e.g. to copy the file to other local systems.
+.PP
+This can be run as a cron job. As the file is rarely updated, and leap
+seconds are announced at least one month in advance (usually longer), it
+need not be run more frequently than about once every three weeks.
+.PP
+For cron-friendly behavior, define CRONJOB=1 in the crontab.
+.PP
+This script depends on$REQUIREDCMDS
+ _END_PROG_MDOC_DESCRIP;
+};
+
+
+doc-section = {
+ ds-type = 'USAGE';
+ ds-format = 'mdoc';
+ ds-text = <<- _END_MDOC_USAGE
+
+Usage stuff
+
+ _END_MDOC_USAGE;
+};
+
+doc-section = {
+ ds-type = 'AUTHORS';
+ ds-format = 'mdoc';
+ ds-text = <<- _END_MDOC_AUTHORS
+.An "Timothe Litt"
+ _END_MDOC_AUTHORS;
+};
diff --git a/contrib/ntp/scripts/update-leap/update-leap.1update-leapman b/contrib/ntp/scripts/update-leap/update-leap.1update-leapman
new file mode 100644
index 0000000..a164347
--- /dev/null
+++ b/contrib/ntp/scripts/update-leap/update-leap.1update-leapman
@@ -0,0 +1,169 @@
+.de1 NOP
+. it 1 an-trap
+. if \\n[.$] \,\\$*\/
+..
+.ie t \
+.ds B-Font [CB]
+.ds I-Font [CI]
+.ds R-Font [CR]
+.el \
+.ds B-Font B
+.ds I-Font I
+.ds R-Font R
+.TH update-leap 1update-leapman "07 Apr 2015" "ntp (4.2.8p2)" "User Commands"
+.\"
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-E0ayAX/ag-R0aGzX)
+.\"
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:40 AM by AutoGen 5.18.5pre4
+.\" From the definitions update-leap-opts.def
+.\" and the template file agman-cmd.tpl
+.SH NAME
+\f\*[B-Font]update-leap\fP
+\- leap-seconds file manager/updater
+.SH SYNOPSIS
+\f\*[B-Font]update-leap\fP
+.\" Mixture of short (flag) options and long options
+[\f\*[B-Font]\-flags\f[]]
+[\f\*[B-Font]\-flag\f[] [\f\*[I-Font]value\f[]]]
+[\f\*[B-Font]\-\-option-name\f[][[=| ]\f\*[I-Font]value\f[]]]
+.sp \n(Ppu
+.ne 2
+
+All arguments must be options.
+.sp \n(Ppu
+.ne 2
+
+.SH DESCRIPTION
+\f\*[B-Font]update-leap\fP
+will validate the file currently on the local system
+and if necessary, updates leap-second definition file.
+.sp \n(Ppu
+.ne 2
+
+Ordinarily, the file is found using the "leapfile" directive in
+\fCntp.conf\fR(5)\f[].
+However, an alternate location can be specified on the command line.
+.sp \n(Ppu
+.ne 2
+
+If the file does not exist, is not valid, has expired, or is expiring soon,
+a new copy will be downloaded. If the new copy validates, it is installed and
+NTP is (optionally) restarted.
+.sp \n(Ppu
+.ne 2
+
+If the current file is acceptable, no download or restart occurs.
+.sp \n(Ppu
+.ne 2
+
+-c can also be used to invoke another script to perform administrative
+functions, e.g. to copy the file to other local systems.
+.PP
+This can be run as a cron job. As the file is rarely updated, and leap
+seconds are announced at least one month in advance (usually longer), it
+need not be run more frequently than about once every three weeks.
+.PP
+For cron-friendly behavior, define CRONJOB=1 in the crontab.
+.PP
+This script depends on$REQUIREDCMDS
+.SH "OPTIONS"
+.TP
+.NOP \f\*[B-Font]\-s\f[] \f\*[I-Font]string\f[], \f\*[B-Font]\-\-source\-url\f[]=\f\*[I-Font]string\f[]
+The URL of the master copy of the leapseconds file.
+.sp
+Specify the URL of the master copy to download
+$LEAPSRC
+.TP
+.NOP \f\*[B-Font]\-4\f[], \f\*[B-Font]\-\-ipv4\f[]
+Use only IPv4 addresses for DNS name resolution.
+This option must not appear in combination with any of the following options:
+ipv6.
+.sp
+ Force DNS resolution of following host names on the command line
+ to the IPv4 namespace.
+ _EndOfDoc_;
+};
+.sp
+flag = {
+ name = ipv6;
+ flags-cant = ipv4, prefer;
+ value = 6;
+ descrip = "Use only IPv6 addresses for DNS name resolution";
+ doc = <<- _EndOfDoc_
+ Force DNS resolution of following host names on the command line
+ to the IPv6 namespace.
+ _EndOfDoc_;
+};
+.sp
+flag = {
+ name = prefer;
+ flags-cant = ipv4, ipv6;
+ value = p;
+ arg-type = keyword;
+ keyword = 4, 6;
+ descrip = 'Prefer IPv4 or IPv6 (as specified) addresses, but use either';
+ doc = <<- _EndOfDoc_
+Prefer IPv4 or IPv6 (as specified) addresses, but use either.
+.TP
+.NOP \f\*[B-Font]\-d\f[] \f\*[I-Font]float\f[], \f\*[B-Font]\-\-destination\f[]=\f\*[I-Font]float\f[]
+Filename on the local system.
+.sp
+The name to use to store the leapfile on the local system.
+$LEAPFILE
+.TP
+.NOP \f\*[B-Font]\-e\f[] \f\*[I-Font]string\f[], \f\*[B-Font]\-\-expiration\f[]=\f\*[I-Font]string\f[]
+Refresh the leapfile this long before it expires.
+.sp
+Specify how long before expiration the file is to be refreshed
+Units are required, e.g. "-e 60 days" Note that larger values
+imply more frequent refreshes.
+"$PREFETCH"
+.TP
+.NOP \f\*[B-Font]\-f\f[] \f\*[I-Font]string\f[], \f\*[B-Font]\-\-ntp\-conf\-file\f[]=\f\*[I-Font]string\f[]
+Location of the ntp.conf file.
+.sp
+Specify location of ntp.conf (used to make sure leapfile directive is
+present and to default leapfile)
+/etc/ntp.conf
+.TP
+.NOP \f\*[B-Font]\-F\f[], \f\*[B-Font]\-\-force\-update\f[]
+Force update of the leapfile.
+.sp
+Force update even if current file is OK and not close to expiring.
+.TP
+.NOP \f\*[B-Font]\-\-dont\-wait\f[]
+Don't wait for keystroke between plots.
+.sp
+.TP
+.NOP \f\*[B-Font]\-\&?\f[], \f\*[B-Font]\-\-help\f[]
+Display usage information and exit.
+.TP
+.NOP \f\*[B-Font]\-\&!\f[], \f\*[B-Font]\-\-more-help\f[]
+Pass the extended usage information through a pager.
+.TP
+.NOP \f\*[B-Font]\-v\f[] [{\f\*[I-Font]v|c|n\f[] \f\*[B-Font]\-\-version\f[] [{\f\*[I-Font]v|c|n\f[]}]}]
+Output version of program and exit. The default mode is `v', a simple
+version. The `c' mode will print copyright information and `n' will
+print the full copyright notice.
+.PP
+.SH USAGE
+Usage stuff
+.SH "EXIT STATUS"
+One of the following exit values will be returned:
+.TP
+.NOP 0 " (EXIT_SUCCESS)"
+Successful program execution.
+.TP
+.NOP 1 " (EXIT_FAILURE)"
+The operation failed or the command syntax was not valid.
+.TP
+.NOP 70 " (EX_SOFTWARE)"
+libopts had an internal operational error. Please report
+it to autogen-users@lists.sourceforge.net. Thank you.
+.PP
+.SH AUTHORS
+.NOP "Timothe Litt"
+.br
+.SH "NOTES"
+This manual page was \fIAutoGen\fP-erated from the \fBupdate-leap\fP
+option definitions.
diff --git a/contrib/ntp/scripts/update-leap/update-leap.1update-leapmdoc b/contrib/ntp/scripts/update-leap/update-leap.1update-leapmdoc
new file mode 100644
index 0000000..9fb3a12
--- /dev/null
+++ b/contrib/ntp/scripts/update-leap/update-leap.1update-leapmdoc
@@ -0,0 +1,134 @@
+.Dd April 7 2015
+.Dt UPDATE_LEAP 1update-leapmdoc User Commands
+.Os
+.\" EDIT THIS FILE WITH CAUTION (update-leap-opts.mdoc)
+.\"
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:46 AM by AutoGen 5.18.5pre4
+.\" From the definitions update-leap-opts.def
+.\" and the template file agmdoc-cmd.tpl
+.Sh NAME
+.Nm update-leap
+.Nd leap-seconds file manager/updater
+.Sh SYNOPSIS
+.Nm
+.\" Mixture of short (flag) options and long options
+.Op Fl flags
+.Op Fl flag Op Ar value
+.Op Fl \-option\-name Ns Oo Oo Ns "=| " Oc Ns Ar value Oc
+.Pp
+All arguments must be options.
+.Pp
+.Sh DESCRIPTION
+.Nm
+will validate the file currently on the local system
+and if necessary, updates leap\-second definition file.
+.Pp
+Ordinarily, the file is found using the "leapfile" directive in
+.Xr ntp.conf 5 .
+However, an alternate location can be specified on the command line.
+.Pp
+If the file does not exist, is not valid, has expired, or is expiring soon,
+a new copy will be downloaded. If the new copy validates, it is installed and
+NTP is (optionally) restarted.
+.Pp
+If the current file is acceptable, no download or restart occurs.
+.Pp
+-c can also be used to invoke another script to perform administrative
+functions, e.g. to copy the file to other local systems.
+.PP
+This can be run as a cron job. As the file is rarely updated, and leap
+seconds are announced at least one month in advance (usually longer), it
+need not be run more frequently than about once every three weeks.
+.PP
+For cron\-friendly behavior, define CRONJOB=1 in the crontab.
+.PP
+This script depends on$REQUIREDCMDS
+.Sh "OPTIONS"
+.Bl -tag
+.It Fl s Ar string , Fl \-source\-url Ns = Ns Ar string
+The URL of the master copy of the leapseconds file.
+.sp
+Specify the URL of the master copy to download
+$LEAPSRC
+.It Fl 4 , Fl \-ipv4
+Use only IPv4 addresses for DNS name resolution.
+This option must not appear in combination with any of the following options:
+ipv6.
+.sp
+ Force DNS resolution of following host names on the command line
+ to the IPv4 namespace.
+ _EndOfDoc_;
+};
+.sp
+flag = {
+ name = ipv6;
+ flags\-cant = ipv4, prefer;
+ value = 6;
+ descrip = "Use only IPv6 addresses for DNS name resolution";
+ doc = <<\- _EndOfDoc_
+ Force DNS resolution of following host names on the command line
+ to the IPv6 namespace.
+ _EndOfDoc_;
+};
+.sp
+flag = {
+ name = prefer;
+ flags\-cant = ipv4, ipv6;
+ value = p;
+ arg\-type = keyword;
+ keyword = 4, 6;
+ descrip = 'Prefer IPv4 or IPv6 (as specified) addresses, but use either';
+ doc = <<\- _EndOfDoc_
+Prefer IPv4 or IPv6 (as specified) addresses, but use either.
+.It Fl d Ar float , Fl \-destination Ns = Ns Ar float
+Filename on the local system.
+.sp
+The name to use to store the leapfile on the local system.
+$LEAPFILE
+.It Fl e Ar string , Fl \-expiration Ns = Ns Ar string
+Refresh the leapfile this long before it expires.
+.sp
+Specify how long before expiration the file is to be refreshed
+Units are required, e.g. "\-e 60 days" Note that larger values
+imply more frequent refreshes.
+"$PREFETCH"
+.It Fl f Ar string , Fl \-ntp\-conf\-file Ns = Ns Ar string
+Location of the ntp.conf file.
+.sp
+Specify location of ntp.conf (used to make sure leapfile directive is
+present and to default leapfile)
+/etc/ntp.conf
+.It Fl F , Fl \-force\-update
+Force update of the leapfile.
+.sp
+Force update even if current file is OK and not close to expiring.
+.It Fl \-dont\-wait
+Don't wait for keystroke between plots.
+.sp
+.It Fl \&? , Fl \-help
+Display usage information and exit.
+.It Fl \&! , Fl \-more\-help
+Pass the extended usage information through a pager.
+.It Fl v Op Brq Ar v|c|n Fl \-version Op Brq Ar v|c|n
+Output version of program and exit. The default mode is `v', a simple
+version. The `c' mode will print copyright information and `n' will
+print the full copyright notice.
+.El
+.Sh USAGE
+Usage stuff
+.Sh "EXIT STATUS"
+One of the following exit values will be returned:
+.Bl -tag
+.It 0 " (EXIT_SUCCESS)"
+Successful program execution.
+.It 1 " (EXIT_FAILURE)"
+The operation failed or the command syntax was not valid.
+.It 70 " (EX_SOFTWARE)"
+libopts had an internal operational error. Please report
+it to autogen\-users@lists.sourceforge.net. Thank you.
+.El
+.Sh AUTHORS
+.An "Timothe Litt"
+.Sh "NOTES"
+This manual page was \fIAutoGen\fP\-erated from the \fBupdate\-leap\fP
+option definitions.
diff --git a/contrib/ntp/scripts/update-leap/update-leap.html b/contrib/ntp/scripts/update-leap/update-leap.html
new file mode 100644
index 0000000..3a731ac
--- /dev/null
+++ b/contrib/ntp/scripts/update-leap/update-leap.html
@@ -0,0 +1,274 @@
+<html lang="en">
+<head>
+<title>update-leap User's Manual</title>
+<meta http-equiv="Content-Type" content="text/html">
+<meta name="description" content="update-leap User's Manual">
+<meta name="generator" content="makeinfo 4.7">
+<link title="Top" rel="top" href="#Top">
+<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
+<meta http-equiv="Content-Style-Type" content="text/css">
+<style type="text/css"><!--
+ pre.display { font-family:inherit }
+ pre.format { font-family:inherit }
+ pre.smalldisplay { font-family:inherit; font-size:smaller }
+ pre.smallformat { font-family:inherit; font-size:smaller }
+ pre.smallexample { font-size:smaller }
+ pre.smalllisp { font-size:smaller }
+ span.sc { font-variant:small-caps }
+ span.roman { font-family: serif; font-weight: normal; }
+--></style>
+</head>
+<body>
+<h1 class="settitle">update-leap User's Manual</h1>
+<div class="node">
+<p><hr>
+<a name="Top"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-Description">update-leap Description</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#dir">(dir)</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#dir">(dir)</a>
+<br>
+</div>
+
+ <p>This document describes the use of the NTP Project's <code>update-leap</code> program.
+
+ <p>This document applies to version 4.2.8p2 of <code>update-leap</code>.
+
+<div class="shortcontents">
+<h2>Short Contents</h2>
+<ul>
+</ul>
+</div>
+
+<ul class="menu">
+<li><a accesskey="1" href="#update_002dleap-Description">update-leap Description</a>: Description
+<li><a accesskey="2" href="#update_002dleap-Invocation">update-leap Invocation</a>: Invoking update-leap
+</ul>
+
+<div class="node">
+<p><hr>
+<a name="update_002dleap-Invocation"></a>
+<br>
+</div>
+
+<h3 class="section">0.1 Invoking update-leap</h3>
+
+<p><a name="index-update_002dleap-1"></a><a name="index-leap_002dseconds-file-manager_002fupdater-2"></a>
+
+ <p><code>update-leap</code>
+will validate the file currently on the local system
+and if necessary, updates leap-second definition file.
+
+ <p>Ordinarily, the file is found using the "leapfile" directive in
+<code>ntp.conf(5)</code>.
+However, an alternate location can be specified on the command line.
+
+ <p>If the file does not exist, is not valid, has expired, or is expiring soon,
+a new copy will be downloaded. If the new copy validates, it is installed and
+NTP is (optionally) restarted.
+
+ <p>If the current file is acceptable, no download or restart occurs.
+
+ <p>-c can also be used to invoke another script to perform administrative
+functions, e.g. to copy the file to other local systems.
+.PP
+This can be run as a cron job. As the file is rarely updated, and leap
+seconds are announced at least one month in advance (usually longer), it
+need not be run more frequently than about once every three weeks.
+.PP
+For cron-friendly behavior, define CRONJOB=1 in the crontab.
+.PP
+This script depends on$REQUIREDCMDS
+
+ <p>This section was generated by <strong>AutoGen</strong>,
+using the <code>agtexi-cmd</code> template and the option descriptions for the <code>update-leap</code> program.
+
+<ul class="menu">
+<li><a accesskey="1" href="#update_002dleap-usage">update-leap usage</a>: update-leap help/usage (<span class="option">--help</span>)
+<li><a accesskey="2" href="#update_002dleap-source_002durl">update-leap source-url</a>: source-url option (-s)
+<li><a accesskey="3" href="#update_002dleap-ipv4">update-leap ipv4</a>: ipv4 option (-4)
+<li><a accesskey="4" href="#update_002dleap-destination">update-leap destination</a>: destination option (-d)
+<li><a accesskey="5" href="#update_002dleap-expiration">update-leap expiration</a>: expiration option (-e)
+<li><a accesskey="6" href="#update_002dleap-ntp_002dconf_002dfile">update-leap ntp-conf-file</a>: ntp-conf-file option (-f)
+<li><a accesskey="7" href="#update_002dleap-force_002dupdate">update-leap force-update</a>: force-update option (-F)
+<li><a accesskey="8" href="#update_002dleap-exit-status">update-leap exit status</a>: exit status
+<li><a accesskey="9" href="#update_002dleap-Usage">update-leap Usage</a>: Usage
+<li><a href="#update_002dleap-Authors">update-leap Authors</a>: Authors
+</ul>
+
+<div class="node">
+<p><hr>
+<a name="update_002dleap-usage"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-source_002durl">update-leap source-url</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+<br>
+</div>
+
+<h4 class="subsection">0.1.1 update-leap help/usage (<span class="option">--help</span>)</h4>
+
+<p><a name="index-update_002dleap-help-3"></a>
+This is the automatically generated usage text for update-leap.
+
+ <p>The text printed is the same whether selected with the <code>help</code> option
+(<span class="option">--help</span>) or the <code>more-help</code> option (<span class="option">--more-help</span>). <code>more-help</code> will print
+the usage text by passing it through a pager program.
+<code>more-help</code> is disabled on platforms without a working
+<code>fork(2)</code> function. The <code>PAGER</code> environment variable is
+used to select the program, defaulting to <span class="file">more</span>. Both will exit
+with a status code of 0.
+
+<pre class="example">/bin/bash: line 136: ./update-leap: Permission denied
+</pre>
+ <div class="node">
+<p><hr>
+<a name="update_002dleap-source_002durl"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-ipv4">update-leap ipv4</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-usage">update-leap usage</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+<br>
+</div>
+
+<h4 class="subsection">0.1.2 source-url option (-s)</h4>
+
+<p><a name="index-update_002dleap_002dsource_002durl-4"></a>
+This is the &ldquo;the url of the master copy of the leapseconds file&rdquo; option.
+This option takes a string argument.
+Specify the URL of the master copy to download
+$LEAPSRC
+<div class="node">
+<p><hr>
+<a name="update_002dleap-ipv4"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-destination">update-leap destination</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-source_002durl">update-leap source-url</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+<br>
+</div>
+
+<h4 class="subsection">0.1.3 ipv4 option (-4)</h4>
+
+<p><a name="index-update_002dleap_002dipv4-5"></a>
+This is the &ldquo;use only ipv4 addresses for dns name resolution&rdquo; option.
+
+<p class="noindent">This option has some usage constraints. It:
+ <ul>
+<li>must not appear in combination with any of the following options:
+ipv6.
+</ul>
+
+ <p>Force DNS resolution of following host names on the command line
+ to the IPv4 namespace.
+ _EndOfDoc_;
+;
+
+ <p>flag =
+ name = ipv6;
+ flags-cant = ipv4, prefer;
+ value = 6;
+ descrip = "Use only IPv6 addresses for DNS name resolution";
+ doc = &lt;&lt;- _EndOfDoc_
+ Force DNS resolution of following host names on the command line
+ to the IPv6 namespace.
+ _EndOfDoc_;
+;
+
+ <p>flag =
+ name = prefer;
+ flags-cant = ipv4, ipv6;
+ value = p;
+ arg-type = keyword;
+ keyword = 4, 6;
+ descrip = 'Prefer IPv4 or IPv6 (as specified) addresses, but use either';
+ doc = &lt;&lt;- _EndOfDoc_
+Prefer IPv4 or IPv6 (as specified) addresses, but use either.
+<div class="node">
+<p><hr>
+<a name="update_002dleap-destination"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-expiration">update-leap expiration</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-ipv4">update-leap ipv4</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+<br>
+</div>
+
+<h4 class="subsection">0.1.4 destination option (-d)</h4>
+
+<p><a name="index-update_002dleap_002ddestination-6"></a>
+This is the &ldquo;filename on the local system&rdquo; option.
+This option takes a string argument <span class="file">float</span>.
+The name to use to store the leapfile on the local system.
+$LEAPFILE
+<div class="node">
+<p><hr>
+<a name="update_002dleap-expiration"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-ntp_002dconf_002dfile">update-leap ntp-conf-file</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-destination">update-leap destination</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+<br>
+</div>
+
+<h4 class="subsection">0.1.5 expiration option (-e)</h4>
+
+<p><a name="index-update_002dleap_002dexpiration-7"></a>
+This is the &ldquo;refresh the leapfile this long before it expires&rdquo; option.
+This option takes a string argument.
+Specify how long before expiration the file is to be refreshed
+Units are required, e.g. "-e 60 days" Note that larger values
+imply more frequent refreshes.
+"$PREFETCH"
+<div class="node">
+<p><hr>
+<a name="update_002dleap-ntp_002dconf_002dfile"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-force_002dupdate">update-leap force-update</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-expiration">update-leap expiration</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+<br>
+</div>
+
+<h4 class="subsection">0.1.6 ntp-conf-file option (-f)</h4>
+
+<p><a name="index-update_002dleap_002dntp_002dconf_002dfile-8"></a>
+This is the &ldquo;location of the ntp.conf file&rdquo; option.
+This option takes a string argument.
+Specify location of ntp.conf (used to make sure leapfile directive is
+present and to default leapfile)
+/etc/ntp.conf
+<div class="node">
+<p><hr>
+<a name="update_002dleap-force_002dupdate"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-exit-status">update-leap exit status</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-ntp_002dconf_002dfile">update-leap ntp-conf-file</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+<br>
+</div>
+
+<h4 class="subsection">0.1.7 force-update option (-F)</h4>
+
+<p><a name="index-update_002dleap_002dforce_002dupdate-9"></a>
+This is the &ldquo;force update of the leapfile&rdquo; option.
+Force update even if current file is OK and not close to expiring.
+<div class="node">
+<p><hr>
+<a name="update_002dleap-exit-status"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-Usage">update-leap Usage</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-force_002dupdate">update-leap force-update</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+<br>
+</div>
+
+<h4 class="subsection">0.1.8 update-leap exit status</h4>
+
+<p>One of the following exit values will be returned:
+ <dl>
+<dt><span class="samp">0 (EXIT_SUCCESS)</span><dd>Successful program execution.
+<br><dt><span class="samp">1 (EXIT_FAILURE)</span><dd>The operation failed or the command syntax was not valid.
+</dl>
+ <div class="node">
+<p><hr>
+<a name="update_002dleap-Usage"></a>Next:&nbsp;<a rel="next" accesskey="n" href="#update_002dleap-Authors">update-leap Authors</a>,
+Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-exit-status">update-leap exit status</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+<br>
+</div>
+
+<h4 class="subsection">0.1.9 update-leap Usage</h4>
+
+<div class="node">
+<p><hr>
+<a name="update_002dleap-Authors"></a>Previous:&nbsp;<a rel="previous" accesskey="p" href="#update_002dleap-Usage">update-leap Usage</a>,
+Up:&nbsp;<a rel="up" accesskey="u" href="#update_002dleap-Invocation">update-leap Invocation</a>
+<br>
+</div>
+
+<h4 class="subsection">0.1.10 update-leap Authors</h4>
+
+</body></html>
+
diff --git a/contrib/ntp/scripts/update-leap/update-leap.man.in b/contrib/ntp/scripts/update-leap/update-leap.man.in
new file mode 100644
index 0000000..a164347
--- /dev/null
+++ b/contrib/ntp/scripts/update-leap/update-leap.man.in
@@ -0,0 +1,169 @@
+.de1 NOP
+. it 1 an-trap
+. if \\n[.$] \,\\$*\/
+..
+.ie t \
+.ds B-Font [CB]
+.ds I-Font [CI]
+.ds R-Font [CR]
+.el \
+.ds B-Font B
+.ds I-Font I
+.ds R-Font R
+.TH update-leap 1update-leapman "07 Apr 2015" "ntp (4.2.8p2)" "User Commands"
+.\"
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-E0ayAX/ag-R0aGzX)
+.\"
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:40 AM by AutoGen 5.18.5pre4
+.\" From the definitions update-leap-opts.def
+.\" and the template file agman-cmd.tpl
+.SH NAME
+\f\*[B-Font]update-leap\fP
+\- leap-seconds file manager/updater
+.SH SYNOPSIS
+\f\*[B-Font]update-leap\fP
+.\" Mixture of short (flag) options and long options
+[\f\*[B-Font]\-flags\f[]]
+[\f\*[B-Font]\-flag\f[] [\f\*[I-Font]value\f[]]]
+[\f\*[B-Font]\-\-option-name\f[][[=| ]\f\*[I-Font]value\f[]]]
+.sp \n(Ppu
+.ne 2
+
+All arguments must be options.
+.sp \n(Ppu
+.ne 2
+
+.SH DESCRIPTION
+\f\*[B-Font]update-leap\fP
+will validate the file currently on the local system
+and if necessary, updates leap-second definition file.
+.sp \n(Ppu
+.ne 2
+
+Ordinarily, the file is found using the "leapfile" directive in
+\fCntp.conf\fR(5)\f[].
+However, an alternate location can be specified on the command line.
+.sp \n(Ppu
+.ne 2
+
+If the file does not exist, is not valid, has expired, or is expiring soon,
+a new copy will be downloaded. If the new copy validates, it is installed and
+NTP is (optionally) restarted.
+.sp \n(Ppu
+.ne 2
+
+If the current file is acceptable, no download or restart occurs.
+.sp \n(Ppu
+.ne 2
+
+-c can also be used to invoke another script to perform administrative
+functions, e.g. to copy the file to other local systems.
+.PP
+This can be run as a cron job. As the file is rarely updated, and leap
+seconds are announced at least one month in advance (usually longer), it
+need not be run more frequently than about once every three weeks.
+.PP
+For cron-friendly behavior, define CRONJOB=1 in the crontab.
+.PP
+This script depends on$REQUIREDCMDS
+.SH "OPTIONS"
+.TP
+.NOP \f\*[B-Font]\-s\f[] \f\*[I-Font]string\f[], \f\*[B-Font]\-\-source\-url\f[]=\f\*[I-Font]string\f[]
+The URL of the master copy of the leapseconds file.
+.sp
+Specify the URL of the master copy to download
+$LEAPSRC
+.TP
+.NOP \f\*[B-Font]\-4\f[], \f\*[B-Font]\-\-ipv4\f[]
+Use only IPv4 addresses for DNS name resolution.
+This option must not appear in combination with any of the following options:
+ipv6.
+.sp
+ Force DNS resolution of following host names on the command line
+ to the IPv4 namespace.
+ _EndOfDoc_;
+};
+.sp
+flag = {
+ name = ipv6;
+ flags-cant = ipv4, prefer;
+ value = 6;
+ descrip = "Use only IPv6 addresses for DNS name resolution";
+ doc = <<- _EndOfDoc_
+ Force DNS resolution of following host names on the command line
+ to the IPv6 namespace.
+ _EndOfDoc_;
+};
+.sp
+flag = {
+ name = prefer;
+ flags-cant = ipv4, ipv6;
+ value = p;
+ arg-type = keyword;
+ keyword = 4, 6;
+ descrip = 'Prefer IPv4 or IPv6 (as specified) addresses, but use either';
+ doc = <<- _EndOfDoc_
+Prefer IPv4 or IPv6 (as specified) addresses, but use either.
+.TP
+.NOP \f\*[B-Font]\-d\f[] \f\*[I-Font]float\f[], \f\*[B-Font]\-\-destination\f[]=\f\*[I-Font]float\f[]
+Filename on the local system.
+.sp
+The name to use to store the leapfile on the local system.
+$LEAPFILE
+.TP
+.NOP \f\*[B-Font]\-e\f[] \f\*[I-Font]string\f[], \f\*[B-Font]\-\-expiration\f[]=\f\*[I-Font]string\f[]
+Refresh the leapfile this long before it expires.
+.sp
+Specify how long before expiration the file is to be refreshed
+Units are required, e.g. "-e 60 days" Note that larger values
+imply more frequent refreshes.
+"$PREFETCH"
+.TP
+.NOP \f\*[B-Font]\-f\f[] \f\*[I-Font]string\f[], \f\*[B-Font]\-\-ntp\-conf\-file\f[]=\f\*[I-Font]string\f[]
+Location of the ntp.conf file.
+.sp
+Specify location of ntp.conf (used to make sure leapfile directive is
+present and to default leapfile)
+/etc/ntp.conf
+.TP
+.NOP \f\*[B-Font]\-F\f[], \f\*[B-Font]\-\-force\-update\f[]
+Force update of the leapfile.
+.sp
+Force update even if current file is OK and not close to expiring.
+.TP
+.NOP \f\*[B-Font]\-\-dont\-wait\f[]
+Don't wait for keystroke between plots.
+.sp
+.TP
+.NOP \f\*[B-Font]\-\&?\f[], \f\*[B-Font]\-\-help\f[]
+Display usage information and exit.
+.TP
+.NOP \f\*[B-Font]\-\&!\f[], \f\*[B-Font]\-\-more-help\f[]
+Pass the extended usage information through a pager.
+.TP
+.NOP \f\*[B-Font]\-v\f[] [{\f\*[I-Font]v|c|n\f[] \f\*[B-Font]\-\-version\f[] [{\f\*[I-Font]v|c|n\f[]}]}]
+Output version of program and exit. The default mode is `v', a simple
+version. The `c' mode will print copyright information and `n' will
+print the full copyright notice.
+.PP
+.SH USAGE
+Usage stuff
+.SH "EXIT STATUS"
+One of the following exit values will be returned:
+.TP
+.NOP 0 " (EXIT_SUCCESS)"
+Successful program execution.
+.TP
+.NOP 1 " (EXIT_FAILURE)"
+The operation failed or the command syntax was not valid.
+.TP
+.NOP 70 " (EX_SOFTWARE)"
+libopts had an internal operational error. Please report
+it to autogen-users@lists.sourceforge.net. Thank you.
+.PP
+.SH AUTHORS
+.NOP "Timothe Litt"
+.br
+.SH "NOTES"
+This manual page was \fIAutoGen\fP-erated from the \fBupdate-leap\fP
+option definitions.
diff --git a/contrib/ntp/scripts/update-leap/update-leap.mdoc.in b/contrib/ntp/scripts/update-leap/update-leap.mdoc.in
new file mode 100644
index 0000000..9fb3a12
--- /dev/null
+++ b/contrib/ntp/scripts/update-leap/update-leap.mdoc.in
@@ -0,0 +1,134 @@
+.Dd April 7 2015
+.Dt UPDATE_LEAP 1update-leapmdoc User Commands
+.Os
+.\" EDIT THIS FILE WITH CAUTION (update-leap-opts.mdoc)
+.\"
+.\" It has been AutoGen-ed April 7, 2015 at 04:21:46 AM by AutoGen 5.18.5pre4
+.\" From the definitions update-leap-opts.def
+.\" and the template file agmdoc-cmd.tpl
+.Sh NAME
+.Nm update-leap
+.Nd leap-seconds file manager/updater
+.Sh SYNOPSIS
+.Nm
+.\" Mixture of short (flag) options and long options
+.Op Fl flags
+.Op Fl flag Op Ar value
+.Op Fl \-option\-name Ns Oo Oo Ns "=| " Oc Ns Ar value Oc
+.Pp
+All arguments must be options.
+.Pp
+.Sh DESCRIPTION
+.Nm
+will validate the file currently on the local system
+and if necessary, updates leap\-second definition file.
+.Pp
+Ordinarily, the file is found using the "leapfile" directive in
+.Xr ntp.conf 5 .
+However, an alternate location can be specified on the command line.
+.Pp
+If the file does not exist, is not valid, has expired, or is expiring soon,
+a new copy will be downloaded. If the new copy validates, it is installed and
+NTP is (optionally) restarted.
+.Pp
+If the current file is acceptable, no download or restart occurs.
+.Pp
+-c can also be used to invoke another script to perform administrative
+functions, e.g. to copy the file to other local systems.
+.PP
+This can be run as a cron job. As the file is rarely updated, and leap
+seconds are announced at least one month in advance (usually longer), it
+need not be run more frequently than about once every three weeks.
+.PP
+For cron\-friendly behavior, define CRONJOB=1 in the crontab.
+.PP
+This script depends on$REQUIREDCMDS
+.Sh "OPTIONS"
+.Bl -tag
+.It Fl s Ar string , Fl \-source\-url Ns = Ns Ar string
+The URL of the master copy of the leapseconds file.
+.sp
+Specify the URL of the master copy to download
+$LEAPSRC
+.It Fl 4 , Fl \-ipv4
+Use only IPv4 addresses for DNS name resolution.
+This option must not appear in combination with any of the following options:
+ipv6.
+.sp
+ Force DNS resolution of following host names on the command line
+ to the IPv4 namespace.
+ _EndOfDoc_;
+};
+.sp
+flag = {
+ name = ipv6;
+ flags\-cant = ipv4, prefer;
+ value = 6;
+ descrip = "Use only IPv6 addresses for DNS name resolution";
+ doc = <<\- _EndOfDoc_
+ Force DNS resolution of following host names on the command line
+ to the IPv6 namespace.
+ _EndOfDoc_;
+};
+.sp
+flag = {
+ name = prefer;
+ flags\-cant = ipv4, ipv6;
+ value = p;
+ arg\-type = keyword;
+ keyword = 4, 6;
+ descrip = 'Prefer IPv4 or IPv6 (as specified) addresses, but use either';
+ doc = <<\- _EndOfDoc_
+Prefer IPv4 or IPv6 (as specified) addresses, but use either.
+.It Fl d Ar float , Fl \-destination Ns = Ns Ar float
+Filename on the local system.
+.sp
+The name to use to store the leapfile on the local system.
+$LEAPFILE
+.It Fl e Ar string , Fl \-expiration Ns = Ns Ar string
+Refresh the leapfile this long before it expires.
+.sp
+Specify how long before expiration the file is to be refreshed
+Units are required, e.g. "\-e 60 days" Note that larger values
+imply more frequent refreshes.
+"$PREFETCH"
+.It Fl f Ar string , Fl \-ntp\-conf\-file Ns = Ns Ar string
+Location of the ntp.conf file.
+.sp
+Specify location of ntp.conf (used to make sure leapfile directive is
+present and to default leapfile)
+/etc/ntp.conf
+.It Fl F , Fl \-force\-update
+Force update of the leapfile.
+.sp
+Force update even if current file is OK and not close to expiring.
+.It Fl \-dont\-wait
+Don't wait for keystroke between plots.
+.sp
+.It Fl \&? , Fl \-help
+Display usage information and exit.
+.It Fl \&! , Fl \-more\-help
+Pass the extended usage information through a pager.
+.It Fl v Op Brq Ar v|c|n Fl \-version Op Brq Ar v|c|n
+Output version of program and exit. The default mode is `v', a simple
+version. The `c' mode will print copyright information and `n' will
+print the full copyright notice.
+.El
+.Sh USAGE
+Usage stuff
+.Sh "EXIT STATUS"
+One of the following exit values will be returned:
+.Bl -tag
+.It 0 " (EXIT_SUCCESS)"
+Successful program execution.
+.It 1 " (EXIT_FAILURE)"
+The operation failed or the command syntax was not valid.
+.It 70 " (EX_SOFTWARE)"
+libopts had an internal operational error. Please report
+it to autogen\-users@lists.sourceforge.net. Thank you.
+.El
+.Sh AUTHORS
+.An "Timothe Litt"
+.Sh "NOTES"
+This manual page was \fIAutoGen\fP\-erated from the \fBupdate\-leap\fP
+option definitions.
diff --git a/contrib/ntp/scripts/update-leap/update-leap.texi b/contrib/ntp/scripts/update-leap/update-leap.texi
new file mode 100644
index 0000000..1a96ae0
--- /dev/null
+++ b/contrib/ntp/scripts/update-leap/update-leap.texi
@@ -0,0 +1,43 @@
+\input texinfo @c -*-texinfo-*-
+@c %**start of header
+@setfilename update-leap.info
+@settitle update-leap User's Manual
+@include ../../sntp/include/version.texi
+@paragraphindent 2
+@c %**end of header
+
+@ifinfo
+This file documents the use of @code{update-leap},
+a program from
+the NTP Project,
+that is used to wait until @code{ntpd} has been able to
+synchronize and stabilize the time on the current host.
+@end ifinfo
+
+@direntry
+* update-leap: (update-leap). Check the leapfile and update it if needed.
+@end direntry
+
+@titlepage
+@title update-leap User's Manual
+@subtitle update-leap, version @value{VERSION}, @value{UPDATED}
+@c @author Max @email{foo@ntp.org}
+@end titlepage
+
+@c @page
+@c @vskip 0pt plus 1filll
+
+@node Top, update-leap Description, (dir), (dir)
+
+This document describes the use of the NTP Project's @code{update-leap} program.
+
+This document applies to version @value{VERSION} of @code{update-leap}.
+
+@shortcontents
+
+@menu
+* update-leap Description:: Description
+* update-leap Invocation:: Invoking update-leap
+@end menu
+
+@include invoke-update-leap.texi
diff --git a/contrib/ntp/sntp/Makefile.in b/contrib/ntp/sntp/Makefile.in
index f587005..fac19cc 100644
--- a/contrib/ntp/sntp/Makefile.in
+++ b/contrib/ntp/sntp/Makefile.in
@@ -61,8 +61,6 @@ subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
$(top_srcdir)/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/libevent/m4/openldap.m4 \
$(top_srcdir)/m4/hms_search_lib.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
@@ -82,8 +80,10 @@ am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
$(top_srcdir)/m4/ntp_prog_cc.m4 $(top_srcdir)/m4/ntp_sntp.m4 \
$(top_srcdir)/m4/ntp_sysexits.m4 \
$(top_srcdir)/m4/ntp_ver_suffix.m4 \
- $(top_srcdir)/m4/os_cflags.m4 $(top_srcdir)/m4/snprintf.m4 \
- $(top_srcdir)/m4/version.m4 $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/m4/openldap.m4 $(top_srcdir)/m4/os_cflags.m4 \
+ $(top_srcdir)/m4/snprintf.m4 $(top_srcdir)/m4/version.m4 \
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
@@ -394,6 +394,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
abs_builddir = @abs_builddir@
diff --git a/contrib/ntp/sntp/aclocal.m4 b/contrib/ntp/sntp/aclocal.m4
index aff791b..5d30c42 100644
--- a/contrib/ntp/sntp/aclocal.m4
+++ b/contrib/ntp/sntp/aclocal.m4
@@ -1132,8 +1132,6 @@ AC_SUBST([am__untar])
m4_include([libopts/m4/libopts.m4])
m4_include([libopts/m4/stdnoreturn.m4])
-m4_include([libevent/m4/openldap-thread-check.m4])
-m4_include([libevent/m4/openldap.m4])
m4_include([m4/hms_search_lib.m4])
m4_include([m4/libtool.m4])
m4_include([m4/ltoptions.m4])
@@ -1159,5 +1157,7 @@ m4_include([m4/ntp_prog_cc.m4])
m4_include([m4/ntp_sntp.m4])
m4_include([m4/ntp_sysexits.m4])
m4_include([m4/ntp_ver_suffix.m4])
+m4_include([m4/openldap-thread-check.m4])
+m4_include([m4/openldap.m4])
m4_include([m4/os_cflags.m4])
m4_include([m4/snprintf.m4])
diff --git a/contrib/ntp/sntp/configure b/contrib/ntp/sntp/configure
index b4c66f7..76bdd28 100755
--- a/contrib/ntp/sntp/configure
+++ b/contrib/ntp/sntp/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for sntp 4.2.8p1.
+# Generated by GNU Autoconf 2.68 for sntp 4.2.8p2.
#
# Report bugs to <http://bugs.ntp.org./>.
#
@@ -570,8 +570,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='sntp'
PACKAGE_TARNAME='sntp'
-PACKAGE_VERSION='4.2.8p1'
-PACKAGE_STRING='sntp 4.2.8p1'
+PACKAGE_VERSION='4.2.8p2'
+PACKAGE_STRING='sntp 4.2.8p2'
PACKAGE_BUGREPORT='http://bugs.ntp.org./'
PACKAGE_URL='http://www.ntp.org./'
@@ -686,6 +686,13 @@ SED
LDADD_LIBNTP
NTP_CROSSCOMPILE_FALSE
NTP_CROSSCOMPILE_TRUE
+INSTALL_UPDATE_LEAP_FALSE
+INSTALL_UPDATE_LEAP_TRUE
+UPDATE_LEAP_NI
+UPDATE_LEAP_MS
+UPDATE_LEAP_DS
+UPDATE_LEAP_DL
+UPDATE_LEAP_DB
TIMETRIM_NI
TIMETRIM_MS
TIMETRIM_DS
@@ -1457,7 +1464,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures sntp 4.2.8p1 to adapt to many kinds of systems.
+\`configure' configures sntp 4.2.8p2 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1527,7 +1534,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of sntp 4.2.8p1:";;
+ short | recursive ) echo "Configuration of sntp 4.2.8p2:";;
esac
cat <<\_ACEOF
@@ -1670,7 +1677,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-sntp configure 4.2.8p1
+sntp configure 4.2.8p2
generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
@@ -2495,7 +2502,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by sntp $as_me 4.2.8p1, which was
+It was created by sntp $as_me 4.2.8p2, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@
@@ -3438,7 +3445,7 @@ fi
# Define the identity of the package.
PACKAGE='sntp'
- VERSION='4.2.8p1'
+ VERSION='4.2.8p2'
cat >>confdefs.h <<_ACEOF
@@ -7032,6 +7039,19 @@ fi
+ if test -z "$UPDATE_LEAP_NI" ; then
+ INSTALL_UPDATE_LEAP_TRUE=
+ INSTALL_UPDATE_LEAP_FALSE='#'
+else
+ INSTALL_UPDATE_LEAP_TRUE='#'
+ INSTALL_UPDATE_LEAP_FALSE=
+fi
+
+
+
+
+
+
# Expose a cross-compilation indicator to makefiles
@@ -30185,6 +30205,10 @@ if test -z "${INSTALL_NTPSWEEP_TRUE}" && test -z "${INSTALL_NTPSWEEP_FALSE}"; th
as_fn_error $? "conditional \"INSTALL_NTPSWEEP\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${INSTALL_UPDATE_LEAP_TRUE}" && test -z "${INSTALL_UPDATE_LEAP_FALSE}"; then
+ as_fn_error $? "conditional \"INSTALL_UPDATE_LEAP\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${NTP_CROSSCOMPILE_TRUE}" && test -z "${NTP_CROSSCOMPILE_FALSE}"; then
as_fn_error $? "conditional \"NTP_CROSSCOMPILE\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -30630,7 +30654,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by sntp $as_me 4.2.8p1, which was
+This file was extended by sntp $as_me 4.2.8p2, which was
generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -30697,7 +30721,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-sntp config.status 4.2.8p1
+sntp config.status 4.2.8p2
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"
diff --git a/contrib/ntp/sntp/include/Makefile.in b/contrib/ntp/sntp/include/Makefile.in
index 9f5c92a..31db061 100644
--- a/contrib/ntp/sntp/include/Makefile.in
+++ b/contrib/ntp/sntp/include/Makefile.in
@@ -40,8 +40,6 @@ DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
$(top_srcdir)/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/libevent/m4/openldap.m4 \
$(top_srcdir)/m4/hms_search_lib.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
@@ -61,8 +59,10 @@ am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
$(top_srcdir)/m4/ntp_prog_cc.m4 $(top_srcdir)/m4/ntp_sntp.m4 \
$(top_srcdir)/m4/ntp_sysexits.m4 \
$(top_srcdir)/m4/ntp_ver_suffix.m4 \
- $(top_srcdir)/m4/os_cflags.m4 $(top_srcdir)/m4/snprintf.m4 \
- $(top_srcdir)/m4/version.m4 $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/m4/openldap.m4 $(top_srcdir)/m4/os_cflags.m4 \
+ $(top_srcdir)/m4/snprintf.m4 $(top_srcdir)/m4/version.m4 \
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
@@ -249,6 +249,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
abs_builddir = @abs_builddir@
diff --git a/contrib/ntp/sntp/include/version.def b/contrib/ntp/sntp/include/version.def
index 47e57c8..c315fe8 100644
--- a/contrib/ntp/sntp/include/version.def
+++ b/contrib/ntp/sntp/include/version.def
@@ -1 +1 @@
-version = '4.2.8p1';
+version = '4.2.8p2';
diff --git a/contrib/ntp/sntp/include/version.texi b/contrib/ntp/sntp/include/version.texi
index bc3cc06..d5ea0c0 100644
--- a/contrib/ntp/sntp/include/version.texi
+++ b/contrib/ntp/sntp/include/version.texi
@@ -1,3 +1,3 @@
-@set UPDATED 04 February 2015
-@set EDITION 4.2.8p1
-@set VERSION 4.2.8p1
+@set UPDATED 07 April 2015
+@set EDITION 4.2.8p2
+@set VERSION 4.2.8p2
diff --git a/contrib/ntp/sntp/invoke-sntp.texi b/contrib/ntp/sntp/invoke-sntp.texi
index e9be80c..bed49ec 100644
--- a/contrib/ntp/sntp/invoke-sntp.texi
+++ b/contrib/ntp/sntp/invoke-sntp.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-sntp.texi)
#
-# It has been AutoGen-ed February 4, 2015 at 02:34:17 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:18:04 AM by AutoGen 5.18.5pre4
# From the definitions sntp-opts.def
# and the template file agtexi-cmd.tpl
@end ignore
@@ -56,7 +56,8 @@ Otherwise, only the
is displayed.
Finally, the
@emph{stratum}
-of the host is reported.
+of the host is reported
+and the leap indicator is decoded and displayed.
This section was generated by @strong{AutoGen},
using the @code{agtexi-cmd} template and the option descriptions for the @code{sntp} program.
@@ -100,7 +101,7 @@ with a status code of 0.
@exampleindent 0
@example
-sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p1
+sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p2
Usage: sntp [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... \
[ hostname-or-IP ...]
Flg Arg Option-Name Description
diff --git a/contrib/ntp/sntp/libevent/ChangeLog b/contrib/ntp/sntp/libevent/ChangeLog
index 8bb76ca..1499637 100644
--- a/contrib/ntp/sntp/libevent/ChangeLog
+++ b/contrib/ntp/sntp/libevent/ChangeLog
@@ -1,23 +1,282 @@
-Changes in version 2.1.4-beta (?? Dec 2013)
+Changes in version 2.1.5-beta (5 January 2015)
- (As of 735d838b0a537ae04f1e6a2e9cbc5f3f45ebb541)
+ Security Fixes (evbuffers)
+ o Avoid integer overflow bugs in evbuffer_add() and related functions. See CVE-2014-6272 advisory for more information. (d49bc0e88b81a5812116074dc007f1db0ca1eecd)
+ New APIs (evconnlistener)
+ o Provide support for SO_REUSEPORT through LEV_OPT_REUSABLE_PORT (b625361 Maciej Soltysiak)
+
+ Bugfixes (core)
+ o Fix use-after-free error in EV_CLOSURE_EVENT callback (3cc0eac John Ohl)
+ o Fix race caused by event_active (3c7d6fc vjpai)
+
+ Bugfixes (evbuffer)
+ o Fix evbuffer_peek() with len==-1 and start_at non-NULL. (ba59923)
+ o Consistently check for failure from evbuffer_pullup() (60f8f72)
+ o Fix evbuffer_peek() with len==-1 and start_at non-NULL. (fb7e76a)
+
+ Bugfixes (windows, IOCP)
+ o be async: avoid double close() (f133b86 Azat Khuzhin)
+
+ Bugfixes (bufferevents)
+ o Fix issue #127, double free for filterevents that use BEV_OPT_CLOSE_ON_FREE (2c82aa0 John Ohl)
+ o make bufferevent_getwatermark api more robust (a21e510 ufo2243)
+ o [Bugfix] fix bufferevent setwatermark suspend_read (b34e4ac ufo2243)
+ o bufferevent_openssl: reset fd_is_set when setfd with -1 is called (3da84c2 Azat Khuzhin)
+ o Fix compilation for older OpenSSL versions. (5c7282f Joakim Soderberg)
+
+ New APIs (evhttp)
+ o Add evhttp_connection_set_family() to set addrinfo->family for DNS requests (12c29b0 Azat Khuzhin)
+ o Implement interface that provides the ability to have an outbound evhttp_connection free itself once all requests have completed (2b9ec4c,10fe4f John Ohl)
+
+ New APIs (core)
+ o Implement new/free for struct evutil_monotonic_timer and export monotonic time functions (f2645f8 Andrea Shepard)
+
+ Bugfixes (evdns)
+ o Load hosts file on Windows. (a0b247c Vilmos Nebehaj)
+ o Don't truncate hosts file path on Windows. (d0dc861 Vilmos Nebehaj)
+ o Fix a crash in evdns related to shutting down evdns (9f39c88,e8fe749)
+ o evdns: avoid read-after-free in evdns_request_timeout_callback() (61262a0 Azat Khuzhin)
+ o Correctly handle allocation failures in evdns_getaddrinfo (6a53d15)
+ o evdns: fix EVDNS_BASE_DISABLE_WHEN_INACTIVE in case retransmit/retry (74d0eee Azat Khuzhin)
+ o evdns: add retry/reissue tests for EVDNS_BASE_DISABLE_WHEN_INACTIVE (3ca9d43 Azat Khuzhin)
+ o evdns: fail ns after we are failing/retrasmitting request (97c750d Azat Khuzhin)
+
+ Bugfixes (evhttp)
+ o http: reset connection before installing retry timer (fix http retries handling) (bc79cc5 Azat Khuzhin)
+
+
+ Testing
+ o regress_dns: fix leaks in getaddrinfo_async{,_cancel_stress} tests (2fdc5f2 Azat Khuzhin)
+ o test: add family argument for http_connection_test_() (177b8a7 Azat Khuzhin)
+ o test: add regress for evhttp_connection_set_family() with AF_INET and AF_UNSPEC (42aefeb Azat Khuzhin)
+ o test/http: add regress test for set family to AF_INET6 (3fbf3cc Azat Khuzhin)
+ o Update to a more recent tinytest_macros. (8da5a18)
+ o test/regress: add simplestsignal: to track reorder bugs separately (b897bef Azat Khuzhin)
+ o test/evbuffer_peek: add regress in case we have first buffer greater (e2d139d Azat Khuzhin)
+ o More evbuffer_peek() test cases (154006a)
+ o use correct tt macro for pointer compare (08c88ea)
+ o regress_buffer: fix 'memcmp' compare size (79800df Maks Naumov)
+ o Fix a use-after-free in unit tests. CID 752027 (3739057)
+ o Fix a dead-code warning in unit tests. CID 1193548 (c119f24)
+ o Use evutil_weakrand() in unit tests. (a677b72, 364c110)
+ o Use a more precise calculation for max in time-ratelim.c (ca5b5c7)
+ o Make a buffer larger in the tests to avoid a scary evbuffer_copyout_from() (fb57b8b)
+ o Fix several memory leaks in the unit tests. (89c1a3b)
+ o Add test for evhttp_connection_free_on_completion (b0e9924 John Ohl)
+ o Fix annoying heisenbug in test-time.c (cb73704)
+
+ Sample code
+ o Make http-server.c output into good html5 (6d72bdc)
+ o Use FindClose for handle from FindFirstFile in http-server.c (6466e88)
+ o https-client: add -retries argument, for connection retries (d9da844 Azat Khuzhin)
+
+ Bugfixes (build)
+ o Add missing headerfile for cmake (15d90cc Trond Norbye)
+ o ignore one more test binary (b6593aa Michael Richardson)
+ o ignore config.cache/test-driver files (c83f333 Mike Frysinger)
+ o add a --disable-samples configure flag (0c492b3 Mike Frysinger)
+ o Add a few files created by "make verify" to .gitignore. (1a8295a Pierre Phaneuf)
+ o updates in cmake build (27bd9fa Sergey Nikulov)
+ o Fix cmake error when the Module path has more than one entry. (befbd13 Acer Yang)
+ o Fix CMake shared library build (e69d910 Nobuaki Sukegawa)
+ o Fix warnings when compiling with clang 3.5 (f5b4765 John Ohl)
+ o Fix mixed declarations and code (forbidden by ISO C90) (8afbdbc Thomas Bernard)
+
+ Bugfixes (miscellaneous)
+ o tree.h: drop duplicated content of tree.h (6193187 Azat Khuzhin)
+ o evdns: disable probing with EVDNS_BASE_DISABLE_WHEN_INACTIVE (610410b,ad0493e,fea86a6,d83b337,5ca9e97 Azat Khuzhin)
+ o [Bugfix] fix grammer error (3a4d249 ufo2243)
+ o Change return type of evutil_load_windows_system_library_ to HMODULE (f691389)
+ o Fix a c90 warning (76643dd)
+ o Fix a typo in a doxygen comment. Reported by 亦得. (be1aeff)
+ o remove trailing comma from enum (b361b8a Jean-Philippe Ouellet)
+
+ Bugfixes (FreeBSD)
+ o Handle ENOTCAPABLE from FreeBSD - this is returned if an event in the changelist is for an FD that has been closed. (6fd7394 Adrian Chadd)
+
+
+
+Changes in version 2.1.4-alpha (21 Mar 2014)
+
+ Libevent 2.1.4-alpha adds a number of new miscellaneous APIs to make
+ Libevent more useful, including support for early close detection with
+ epoll via EPOLLRDHUP, triggering bufferevent callbacks, adding more
+ evhttp callbacks, and more. There are also numerous bugfixes, including
+ a number for finalize-related issues from 2.1.3-alpha; and an
+ alternative (non-primary!) cmake-based build mechanism.
+
+ New APIs (core)
+ o Added event_base_get_num_events() (0fa107d Mobai Zhang)
+ o New event_base_active_by_fd API (865a142 Greg Hazel, 5c9da9a, 87fa2b0)
+ o Add event_base_active_by_signal by analogy (4865943)
+ o Add access to max event count stats (5173bef, efbd3dc, 26230a2
+ Andrew Sweeney)
+ o Implemented EV_CLOSED event for epoll backend
+ (EPOLLRDHUP). (b1b69ac Diego Giagio, 53d2793, 43ffcf6, dfe1e52
+ Marcin Juszkiewicz, ff26633 Joakim Soderberg, 3908a5e)
+
+ New APIs (evutil_secure_rng)
+ o Add evutil_secure_rng_set_urandom_device_file (2bbb5d7)
+
+ New APIs (bufferevents)
+ o Add function to fetch underlying ratelimit cfg (4b3d5af Mark Ellzey)
+ o Pass and return const for bufferevent_get_token_bucket_cfg (1c77fbb
+ Mark Ellzey)
+ o Add watermark introspection (4ce242b Ondřej Kuzník)
+ o Add an option to trigger bufferevent I/O callbacks (61ee18b Ondřej Kuzník)
+ o Add an option to trigger bufferevent event callbacks (a7384c7
+ Ondřej Kuzník)
+ o Clarifications in response to merge req. comments (bd41947 Ondřej
+ Kuzník)
+ o Minor optimizations on bufferevent_trigger options (a3172a4)
+
+ New APIs (evhttp)
+ o Add evhttp_connection_get_server(). (a7f82a3 Maxime Henrion)
+ o add a http default content type option (5a5acd9 Nicolas Martyanoff)
+ o http: implement new evhttp_connection_get_addr() api. (0c7f040 Azat
+ Khuzhin)
+ o Add a variant of evhttp_send_reply_chunk() with a callback on
+ evhttp_write_buffer() (8d8decf Julien BLACHE)
+ o Allow registering callback for parsing HTTP headers (b0bd7fe Balint Reczey)
+ o Provide on request complete callback facility (b083ca0 Andrew Sweeney)
+ o evhttp_request_set_on_complete_cb to be more specific about what
+ the function actually does and usage (da86dda Andrew Sweeney)
+ o Update unit test to make sure that the callback happens after the
+ output data is written (b85f398 Andrew Sweeney)
+
+ Features (evdns)
+ o bug fix for issues #293 evdns_base_load_hosts doesn't remove
+ outdated addresses (954d2f9, f03d353, 45eba6f Kuldeep Gupta)
+
+ Features: (cmake build support)
+ o Initial CMake commit. (e415196 Joakim Soderberg)
+ o Add all tests and benchmarks to CMake project. (e9fc014 Joakim Soderberg)
+ o More work on adding tests to CMake project (99c1dc3 Joakim Soderberg)
+ o Generate a dummy evconfig-private.h so things build
+ properly. (ce14def Joakim Soderberg)
+ o Link libm on unix platforms. (58fcd42 Joakim Soderberg)
+ o Added some GCC specific options. (19222e5 Joakim Soderberg)
+ o Use evutil_closesocket instead. (dbf2b51 Joakim Soderberg)
+ o Add copyright and licensing files for CMake modules. (c259d53
+ Joakim Soderberg)
+ o Only include WIN32 getopt where it is used. (9bbce0b Joakim Soderberg)
+ o Fix bench_cascade program on Windows. (78da644 Joakim Soderberg)
+ o Don't segfault on no found event backend. (8f2af50 Joakim Soderberg)
+ o Only test the event backends available on the system. (7ea4159
+ Joakim Soderberg)
+ o Added a "make verify" target. (e053c4f Joakim Soderberg)
+ o Fix the make "verify" target on Windows. (67e5d74 Joakim Soderberg)
+ o Get rid of deprecation warnings for OpenSSL on OSX 10.7+ (69c3516
+ Joakim Söderberg)
+ o Fix kqueue support. (a831f2f Joakim Söderberg)
+ o Added a test for testing if kqueue works with pipes. (2799b35
+ Joakim Söderberg)
+ o Change the BSD license from 4 to 3-clause. (86df3ed Joakim Soderberg)
+ o Minimum required python version is 2.4. (968e97b Joakim Soderberg)
+ o Get rid of unknown pragma warnings. (0ef1d04 Joakim Soderberg)
+ o Add a "make verify_coverage" target generation coverage
+ info. (f2483f8 Joakim Soderberg)
+ o Fix the "make verify" target on NetBSD (4ac086a Joakim Soderberg)
+ o Only look for ZLib when it is used (if tests are
+ included). (f780593 Joakim Soderberg)
+ o Added EVENT__ENABLE_GCC_WARNINGS, turns all warnings into
+ errors. (dd413bd Joakim Soderberg)
+ o Add CMake config and install targets. (f3446ed Joakim Soderberg)
+ o Fix typo (4b754df Joakim Soderberg)
+ o Some work on making it possible to simply do add_subdirectory() on
+ the project. (49ab363 Joakim Soderberg)
+ o Set USE_DEBUG=1 on EVENT__ENABLE_VERBOSE_DEBUG (fd42e70 Joakim Soderberg)
+ o Fix so that old nmake project still builds. (24d6466 Joakim
+ Soderberg)
+ o Rename README to README.md and use markdown to format. (d2bc39a
+ Joakim Soderberg)
+ o Update README with CMake build instructions. (604b8cc Joakim Soderberg)
+ o Clean up the README some. (8d4cb35 JoakimSoderberg)
+ o Forgotten headers for old nmake project compatability. (8697b99
+ Joakim Soderberg)
+ o Change all uses of WIN32 to _WIN32 (4e14395 Joakim Söderberg)
+ o Fix include bug. (2024467 Joakim Söderberg)
+ o Check if we're on OSX before disabling deprecation in le-proxy
+ (8b40a5b Joakim Söderberg)
+ o Fix broken autotools build. (ae1bd82 Joakim Söderberg)
+ o Disclaimerize cmake a little in the README (d03b5bf)
+ o Fix CMake compile when OpenSSL is disabled. (e423d42 Joakim
+ Söderberg)
+ o CMake: Get rid of python not found warning when regress tests
+ turned off. (d38d798 Joakim Söderberg)
+ o Fix https-client compilation on Windows. (d7be788 Joakim Soderberg)
+ o Guard against EVENT_NOWIN32 being set during testing. (f1715b4
+ Joakim Soderberg)
+ o Check for OSX when checking for clang. (e212c54 Joakim Soderberg)
+ o Added a Travis-CI configuration file. (8c0f0a9 Joakim Soderberg)
+ o Added -Qunused-arguments for clang on macosx (ed99d92 Trond Norbye)
+ o Rename event_extras to event_extra (a0dd5df Trond Norbye)
+ o Add option to build shared library (4545fa9 Trond Norbye)
+ o Add -Qunused-arguments for clang on macos (b56611d Trond Norbye)
+ o Add cmake-related files to .gitignore (e061321 Trond Norbye)
+ o Export event_extra not event_extras. (2b41bcf Joakim Söderberg)
+
+ Bugfixes (core)
+ o If evsel->del() fails, don't leave the evmap in an inconsistent
+ state (9b5a527 Maxime Henrion)
+ o Move event_debug_note_teardown_ before mm_free. (69b5c64)
+ o Check CLOCK_MONOTONIC_* at runtime if needed. (911abf3)
+ o Fix reinit of fds with EV_WRITE but not EV_READ. (ebfd8a8 maksqwe)
+ o Tweaked callbacks to prevent race condition
+ (https://github.com/libevent/libevent/issues/104) (40830f1, 2ea15ed
+ John Ohl)
+ o Move assert(ev) to before we use ev in EV_CLOSURE_EVENT_FINALIZE
+ case (9805972)
+
+ Bugfixes (evhttp)
+ o Fix a double close() bug in evhttp when the underlying bufferevent uses
+ BEV_OPT_CLOSE_ON_FREE. (31db8a0 Maxime Henrion)
+ o Fix an unlikely but possible error case for http connections (f22049e)
+ o Avoid racy bufferevent activation (5eb1788 Nate Rosenblum)
+
+ Bugfixes on 2.0 (Windows)
+ o Use windows vsnprintf fixup logic on all windows environments (e826f19)
+ o libevent/win32_dealloc() : fix sizeof(pointer) vs sizeof(*pointer)
+ (b8f5980 Frank Denis)
+
+ Bugfixes (evutil_secure_rng)
+ o When we seed from /proc/sys/kernel/random/uuid, count it as success
+ (e35b540)
+ o We should return after arc4random_buf() (1ea1f26 Makoto Kato)
+ o Avoid other RNG initialization FS reads when urandom file is
+ specified (9695e9c)
+ o Really remove RNG seeds from the stack (f5ced88)
+ o Fix another arc4random_buf-related warning (e64a2b0)
+
+ Bugfixes (bufferevents)
+ o Initialize async bufferevent timeout CBs unconditionally (af9b2a7)
Bugfixes (evdns)
o Checking request nameserver for NULL, before using it. (5c710c0
Belobrov Andrey)
- o Fix SEGFAULT after evdns_base_resume if no nameservers installed. (14971a8
- Azat Khuzhin)
+ o Fix SEGFAULT after evdns_base_resume if no nameservers
+ installed. (14971a8 Azat Khuzhin)
o Actually use the log facility for reporting evdns problems. (e1766a1)
- o Fix SEGFAULT after evdns_base_resume if no nameservers installed. (f8d7df8 Azat Khuzhin)
+ o Fix SEGFAULT after evdns_base_resume if no nameservers
+ installed. (f8d7df8 Azat Khuzhin)
+ o fix for ServFail from RIPE Atlas release (62f596b Antony Antony)
- Bugfixes (compilatin)
+ Bugfixes (compilation)
o Fix test compilation with nmake: add the gdi.lib dependency (5ba8ab7)
o Whoops. It is gdi.lib, not gdi32.lib. (github issue #61) (8ab612e)
- o Don't use return since return type is void and build error occurs using clang (838161d Makoto Kato)
+ o Don't use return since return type is void and build error occurs
+ using clang (838161d Makoto Kato)
o Use void casts to suppress some "unchecked return value" warns (7080d55)
- o rpcgen: Generate regress.gen.[c,h] in build rather than src dir (243386c Ross Lagerwall)
- o Fix a compiler warning when checking for arc4random_buf linker breakage. (5cb3865)
+ o rpcgen: Generate regress.gen.[c,h] in build rather than src dir
+ (243386c Ross Lagerwall)
+ o Fix a compiler warning when checking for arc4random_buf linker
+ breakage. (5cb3865)
+ o Fix 'make distcheck' by adding regress.gen.[ch] to DISTCLEANFILES
+ (239d834)
+
+ o Fix a c90 warning (c207682)
+ o Fix consts in WIN32-Code/getopt*.[ch] (57abb35)
Bugfixes (locks, synchronization)
o Missed lock acquire/release in event_base_cancel_single_callback_()
@@ -30,7 +289,8 @@ Changes in version 2.1.4-beta (?? Dec 2013)
Testing
o Add tests for evdns_base_resume(). (1cd9ff5 Azat Khuzhin)
o Fix dns/leak_resume_send_err test. (7e876df Azat Khuzhin)
- o Add checks for evhttp_connection_get_server() in unit tests. (fbc323b Maxime Henrion)
+ o Add checks for evhttp_connection_get_server() in unit
+ tests. (fbc323b Maxime Henrion)
o Fix a (failure-only) null dereference in the unit tests (1104d0b)
o Fix a logic error in test_evbuffer_freeze (7765884)
o Add missing check to test_evbuffer_file_segment_add_cleanup_cb (eba4506)
@@ -38,15 +298,12 @@ Changes in version 2.1.4-beta (?? Dec 2013)
o DNS tests: add a missing check (f314900)
o Finalize tests: add a missing check (82b6956)
o test_evutil_rtrim: add another missing check. (e193c95)
- o regress_main: logging all if env EVENT_DEBUG_LOGGING_ALL isset (611e28b Azat Khuzhin)
- o regress_http: add tests for evhttp_connection_get_addr() (4dd500c Azat Khuzhin)
-
- Bugfixes (core)
- o If evsel->del() fails, don't leave the evmap in an inconsistent state
- (9b5a527 Maxime Henrion)
- o Move event_debug_note_teardown_ before mm_free. (69b5c64)
- o Check CLOCK_MONOTONIC_* at runtime if needed. (911abf3)
- o Fix reinit of fds with EV_WRITE but not EV_READ. (ebfd8a8 maksqwe)
+ o regress_main: logging all if env EVENT_DEBUG_LOGGING_ALL isset
+ (611e28b Azat Khuzhin)
+ o regress_http: add tests for evhttp_connection_get_addr() (4dd500c
+ Azat Khuzhin)
+ o Update to the latest version of tinytest (7a80476)
+ o Heap-allocate zlib data structure in regress_zlib tests (4947c18)
Performance tweaks (core)
o Avoid redundant syscall to make a nonblocking socket nonblocking
@@ -54,56 +311,42 @@ Changes in version 2.1.4-beta (?? Dec 2013)
o Avoid redundant syscall if making a socket cloexec twice (1f29b18)
o Avoid redundant invocations of init_extension_functions for IOCP (3b77d62)
- Bugfixes (evhttp)
- o Fix a double close() bug in evhttp when the underlying bufferevent uses
- BEV_OPT_CLOSE_ON_FREE. (31db8a0 Maxime Henrion)
- o Fix an unlikely but possible error case for http connections (f22049e)
- o Avoid racy bufferevent activation (5eb1788 Nate Rosenblum)
-
- Bugfixes on 2.0 (Windows)
- o Use windows vsnprintf fixup logic on all windows environments (e826f19)
- o libevent/win32_dealloc() : fix sizeof(pointer) vs sizeof(*pointer) (b8f5980 Frank Denis)
-
- Bugfixes (evutil_secure_rng)
- o When we seed from /proc/sys/kernel/random/uuid, count it as success (e35b540)
- o We should return after arc4random_buf() (1ea1f26 Makoto Kato)
- o Avoid other RNG initialization FS reads when urandom file is specified (9695e9c)
- o Really remove RNG seeds from the stack (f5ced88)
- o Fix another arc4random_buf-related warning (e64a2b0)
-
- New APIs (core)
- o Added event_base_get_num_events() (0fa107d Mobai Zhang)
- o Add function to fetch underlying ratelimit cfg (4b3d5af Mark Ellzey)
- o Pass and return const for bufferevent_get_token_bucket_cfg (1c77fbb Mark Ellzey)
-
- New APIs (evhttp)
- o Add evhttp_connection_get_server(). (a7f82a3 Maxime Henrion)
- o add a http default content type option (5a5acd9 Nicolas Martyanoff)
- o http: implement new evhttp_connection_get_addr() api. (0c7f040 Azat Khuzhin)
-
-
Documentation
o Document that arc4random is not a great cryptographic PRNG. (6e49696)
o Small doxygen tweaks (6e67b51)
o Try another doxygen tweak (ccf432b)
-
- New APIs (evutil_secure_rng)
- o Add evutil_secure_rng_set_urandom_device_file (2bbb5d7)
+ o Clarify event_base_loop exit conditions (031a803)
+ o Fix a typo (be7bf2c Ondřej Kuzník)
+ o Document deferred eventcb behaviour (13a9a02 Ondřej Kuzník)
+ o Typo fixes from Linus Nordberg (cec62cb, 8cd695b)
+ o Fix duplicate paragraph in evbuffer_ptr documentation (58408ee)
+
+ Code Improvements (coverity)
+ o Fix a pile of coverity warnings in the unit tests (867f401)
+ o Fix coverity warnings in benchmark tools. (ff7f739)
+ o Whoops; fix compilation in bench.c (544cf88)
+ o Remove spurious checks in evrpc.c error cases (coverity) (991b362)
+ o Fix a couple of compilation warnings in regress_http.c (860767e)
+ o Fix even more coverity warnings. (d240328)
+ o Stop checking for inet_aton; we don't use it. (f665d5c)
+ o Add an include to evrpc-internal to fix openbsd compilation warning
+ (5e161c6)
Cleanups
o Remove an unreachable return statement in minheap-internal.h (e639a9e)
+ o Refactor evmap_{io,signal}_active_() to tolerate bad inputs (974c60e)
+ o Fix needless bufferevent includes in evdns.c (254c04e)
+ o Fix a couple of "#ifdef WIN32" instances (88ecda3)
+ o Remove unneeded declaration in bufferevent-internal.h (4c8ebcd)
Sample code
- o sample/le-proxy: Fail more gracefully if opening listener fails (44b2491)
- o sample: drop uri_root from base_url in http-server. (6171e1c Azat Khuzhin)
-
-
-
-
-
-
-
-
+ o le-proxy: Fail more gracefully if opening listener fails (44b2491)
+ o http-server: drop uri_root from base_url in http-server. (6171e1c Azat Khuzhin)
+ o https-client: POST supported, args supported (c5887f7 Alexey Ozeritsky)
+ o https-client: code cleanup (29af65e Alexey Ozeritsky)
+ o https-client: Small tweaks to https-client.c (90786eb)
+ o https-client: Set hostname for SNI extension (by f69m) (d1976f8)
+ o https-client: add a cast to https-client.c (462e6b6)
@@ -377,6 +620,429 @@ INFRASTRUCTURE (Active-later events):
o Refactor event_persist_closure: raise and extract some common logic
(bec22b4)
o Remove the unused bits from EVLIST_ALL (9889a3d)
+||||||| merged common ancestors
+Changes in version 2.0.22-stable (?? Dec 2013)
+
+ (As of 3b77d62829c4393bda6f9105a5d3b73b48a64b71.)
+
+BUGFIXES (evhttp)
+ o fix #73 and fix http_connection_fail_test to catch it (crash fix) (b618204 Greg Hazel)
+ o Avoid racy bufferevent activation (5eb1788 Nate Rosenblum)
+
+BUGFIXES (compilation and portability)
+ o Fix compilation with WIN32_HAVE_CONDITION_VARIABLES enabled (7e45739)
+ o Fix missing AC_PROG_SED on older Autoconfs (9ab2b3f Tay Ray Chuan)
+ o Backport libevent to vanilla Autoconf 2.59 (as used in RHEL5) (74d4c44 Kevin Bowling)
+ o Use AC_CONFIG_HEADERS in place of AM_CONFIG_HEADERS for autmake 1.13 compat (817ea36)
+ o Rename configure.in to configure.ac to appease newer autoconfs (0c79787)
+ o Avoid using top_srcdir in TESTS: new automakes do not like this (a55514e)
+ o Use windows vsnprintf fixup logic on all windows environments (e826f19)
+ o Fix a compiler warning when checking for arc4random_buf linker breakage. (5cb3865)
+ o Fix another arc4random_buf-related warning (e64a2b0)
+
+BUGFIXES (resource leaks/lock errors on error)
+ o Avoid leaking fds on evconnlistener with no callback set (69db261)
+ o Avoid double-close on getsockname error in evutil_ersatz_socketpair (0a822a6)
+ o Fix a locking error in bufferevent_socket_get_dns_error. (0a5eb2e)
+ o libevent/win32_dealloc() : fix sizeof(pointer) vs sizeof(*pointer) (b8f5980 Frank Denis)
+
+BUGFIXES (miscellaneous)
+ o Avoid other RNG initialization FS reads when urandom file is specified (9695e9c, bb52471)
+ o Avoid redundant invocations of init_extension_functions for IOCP (3b77d62)
+
+BUFGIXES (evdns)
+ o Checking request nameserver for NULL, before using it. (5c710c0 Belobrov Andrey)
+ o Fix SEGFAULT after evdns_base_resume if no nameservers installed. (f8d7df8 Azat Khuzhin)
+
+BUGFIXES (evutil_secure_random)
+ o When we seed from /proc/sys/kernel/random/uuid, count it as success (e35b540)
+ o Document that arc4random is not a great cryptographic PRNG. (6e49696)
+ o Add evutil_secure_rng_set_urandom_device_file (2bbb5d7)
+ o Really remove RNG seeds from the stack (f5ced88)
+
+
+DOCUMENTATION FIXES
+ o Fix a mistake in evbuffer_remove() arguments in example http server code (c322c20 Gyepi Sam)
+ o Fix a typo in a comment in buffer.h. Spotted by Alt_F4 (773b0a5)
+
+
+
+Changes in version 2.0.21-stable (18 Nov 2012)
+BUGFIXES:
+ o ssl: Don't discard SSL read event when timeout and read come close together (576b29f)
+ o ssl: Stop looping in "consider_reading" if reading is suspended. (f719b8a Joachim Bauch)
+ o ssl: No need to reserve space if reading is suspended. (1acf2eb Joachim Bauch)
+ o dns: Avoid a memory-leak on OOM in evdns. (73e85dd, f2bff75 George Danchev)
+ o build: Use python2 rather than python (0eb0109 Ross Lagerwall)
+ o build: Compile without warnings on mingw64 (94866c2)
+ o build: Fix compilation on mingw64 with -DUSE_DEBUG (62bd2c4)
+ o build: Make rpcgen_wrapper.sh work on systems without a "python2" binary (f3009e4)
+ o iocp: Close IOCP listener socket on free when LEV_OPT_CLOSE_ON_FREE is set (cb853ea Juan Pablo Fernandez)
+ o core: Avoid crash when event_pending() called with no event_base set on event (e3cccf3)
+ o misc: remove stray 'x' so print_err will compile when uncommented (ac35650 Patrick Pelletier)
+ o tests: Fix renegotiation test to work around openssl 1.0.1 bug (c2f3086)
+ o tests: Warn when openssl version in unit test mismatches compiled version. (ac009f9)
+
+
+Changes in version 2.0.20-stable (23 Aug 2012)
+BUGFIXES:
+ o core: Make event_pending() threadsafe. (be7a95c Simon Liu)
+ o win32: avoid crash when waiting forever on zero fds. (160e58b)
+ o evhttp: Fix a memory leak on error in evhttp_uriencode (11c8b31)
+ o evbuffer: Avoid possible needless call to writev. Found by coverity. (6a4ec5c)
+ o evdns: memset sockaddr_in before using it. Found by coverity. (a1a0e67)
+ o evhttp: Check more setsockopt return values when binding sockets. Found by coverity (a0912e3)
+ o evdns: Avoid segfault on weird timeout during name lookup. (dc32077 Greg Hazel)
+ o bufferevent_ssl: Correctly invoke callbacks when a SSL bufferevent reads some and then blocks. (606ac43)
+
+
+PORTABILITY FIXES:
+ o check for arc4random_buf at runtime, on OS X (bff5f94 Greg Hazel)
+ o Correctly check for arc4random_buf (fcec3e8 Sebastian Hahn)
+ o Add explicit AC_PROG_SED to configure.in so all autoconfs will expose $(SED) (ca80ea6)
+
+BUILD FIXES:
+ o Add GCC annotations so that the vsprintf functions get checked properly (117e327)
+ o Fix an unused variable warning on *BSD. (c0720c1)
+
+UNIT TEST FIXES:
+ o Fix a couple of memory leaks (found with Valgrind). (3b2529a Ross Lagerwall)
+ o Remove deadcode in http regression tests. Found by coverity. (5553346)
+ o Fix possible uninitialized read in dns regression tests. Found by coverity. (2259777)
+ o Set umask before calling mkstemp in unit tests. Found by coverity (f1ce15d)
+ o Fix various check-after-dereference issues in unit tests: found by coverity (4f3732d)
+ o Fix resource leaks in the unit tests; found by coverity (270f279)
+ o Add some missing null checks to unit tests; found by coverity (f021c3d)
+ o Avoid more crashes/bad calls in unit tests; found by coverity (3cde5bf)
+ o Remove unused variable; spotted by coverity (6355b2a)
+ o Add checks to various return values in unit tests. Found by coverity (b9e7329)
+ o Move assignment outside tt_assert in ssl unit tests. Appeases coverity. (a2006c0)
+
+
+
+Changes in version 2.0.19-stable (3 May 2012)
+BUGFIXES (CORE):
+ o Refactor event_persist_closure: raise and extract some common logic (bec22b4)
+ o If time has jumped so we'd reschedule a periodic event in the past, schedule it for the future instead (dfd808c)
+ o If a higher-priority event becomes active, don't continue running events of the current priority. (2bfda40)
+
+BUGFIXES (SSL):
+ o Fixed potential double-readcb execution with openssl bufferevents. (4e62cd1 Mark Ellzey)
+
+BUGFIXES (DNS):
+ o Cancel a probe request when the server is freed, and ignore cancelled probe callbacks (94d2336 Greg Hazel)
+ o Remove redundant DNS_ERR_CANCEL check, move comment (46b8060 Greg Hazel)
+ o When retransmitting a timed-out DNS request, pick a fresh nameserver. (3d9e52a)
+
+DOCUMENTATION FIXES:
+ o Fix a typo in the bufferevent documentation (98e9119)
+ o Add missing ) to changelog; spotted by rransom (4c7ee6b)
+ o Fix the website URL in the readme (f775521)
+
+COMPILATION FIXES:
+ o Fix a compilation error with MSVC 2005 due to use of mode_t (336dcae)
+ o Configure with gcc older than 2.95 (4a6fd43 Sebastian Hahn)
+ o Generate event-config.h with a single sed script (30b6f88 Zack Weinberg)
+
+FORWARD-COMPATIBILITY:
+ o Backport: provide EVENT_LOG_* names, and deprecate _EVENT_LOG_* (d1a03b2)
+
+TESTING/DEBUGGING SUPPORT:
+ o dns-example.c can now take a resolv.conf file on the commandline (6610fa5)
+ o Make some evdns.c debug logs more verbose (d873d67)
+ o Work-around a stupid gcov-breaking bug in OSX 10.6 (b3887cd)
+
+
+
+Changes in version 2.0.18-stable (22 Mar 2012)
+BUGFIXES (core):
+ o Make uses of open() close-on-exec safe by introducing an internal evutil_open_closeonexec. (d2b5f72 Ross Lagerwall, 03dce42)
+
+BUGFIXES (kqueue):
+ o Properly zero the kevent in kq_setup_kevent() (c2c7b39 Sebastian Hahn)
+
+BUILD FIXES:
+ o Added OPENSSL_LDFLAGS env variable which is appended to SSL checks. (9278196 Mark Ellzey)
+ o Changed OPENSSL_LDFLAGS to OPENSSL_LIBADD (2d67b63 Mark Ellzey)
+ o Don't do clang version detection when disabling some flags (083296b Sebastian Hahn)
+
+BUGFIXES (dns):
+ o Stop crashing in evdns when nameserver probes give a weird error (bec5068)
+
+
+Changes in version 2.0.17-stable (10 Feb 2012)
+
+BUGFIXES (core):
+ o Be absolutely sure to clear pncalls before leaving event_signal_closure (11f36a5)
+ o check for sysctl before we use it (358c745 Mike Frysinger)
+ o Remove bogus casts of socket to int before calling ev_callback (f032516)
+ o Make evconnlistener work around bug in older Linux when getting nmapped (ecfc720)
+ o Fix a list corruption bug when using event_reinit() with signals present (6e41cdc)
+ o Fix a fd leak in event_reinit() (3f18ad1)
+ o Do a memberwise comparison of threading function tables (c94a5f2 Nate R)
+ o Use C-style comments in C source files (for compatibility with compilers such as xlc on AIX). (d84d917 Greg Hewgill)
+ o Avoid crash when freeing event_iocp and using event_set_mem_functions (19715a6)
+ o In the kqueue backend, do not report EBADF as an EV_READ (5d7bfa1 Nicholas Marriott)
+
+BUGFIXES (evbuffer and bufferevents):
+ o Fix behavior of evbuffer_peek(buf,-1,NULL,NULL,0) (c986f23 Zack Weinberg)
+ o Loop on filtering SSL reads until we are blocked or exhausted. (5b4b812)
+
+BUGFIXES (evhttp):
+ o Force strict validation of HTTP version in response. (790f6b3 Catalin Patulea)
+
+BUGFIXES (evdns):
+ o evdns: fix a bug in circular-queue implementation (d6094b1)
+
+BUILD FIXES:
+ o Fix a silly compilation error with the sun compiler (1927776 Colin Watt)
+ o Suppress a gcc warning from ignoring fwrite return in http-sample.c (7206e8c)
+
+DOCUMENTATION FIXES:
+ o Slightly clarify evbuffer_peek documentation (7bbf6ca)
+ o Update copyright notices to 2012 (e49e289)
+
+NEW APIS:
+ o Backport evhttp_connection_get_bufferevent to Libevent 2.0 (da70fa7 Arno Bakker)
+
+TESTS AND TEST FIXES:
+ o Fix a race condition in the dns/bufferevent_connect_hostname test. (cba48c7)
+ o Add function to check referential integrity of an event_base (27737d5)
+ o Check event_base correctness at end of each unit test (3312b02)
+ o Workaround in the unit tests for an apparent epoll bug in Linux 3.2 (dab9187)
+ o Better workaround for Linux 3.2 edge-triggered epoll bug (9f9e259)
+
+Changes in version 2.0.16-stable (18 Nov 2011)
+BUGFIXES (core):
+ o More detailed message in case of libevent self-debugging failure. (9e6a4ef Leonid Evdokimov)
+ o epoll: close fd on alloc fail at initialization (1aee718 Jamie Iles)
+ o Fix compile warning from saying event2/*.h inside a comment (447b0ba)
+ o Warn when unable to construct base because of failing make_base_notifiable (4e797f3)
+ o Don't try to make notifiable event_base when no threading fns are configured (e787413)
+
+BUGFIXES (evbuffer):
+ o unit test for remove_buffer bug (90bd620 Greg Hazel)
+ o Fix an evbuffer crash in evbuffer_remove_buffer() (c37069c)
+
+BUGFIXES (bufferevent_openssl):
+ o Refactor amount-to-read calculations in buffervent_ssl consider_reading() (a186e73 Mark Ellzey)
+ o Move SSL rate-limit enforcement into bytes_to_read() (96c562f)
+ o Avoid spinning on OpenSSL reads (2aa036f Mark Ellzey)
+
+BUGFIXES (dns)
+ o Empty DNS reply with OK status is another way to say NODATA. (21a08d6 Leonid Evdokimov)
+
+TESTING:
+ o Tests for 94fba5b and f72e8f6 (d58c15e Leonid Evdokimov)
+ o Test for commit aff6ba1 (f7841bf Leonid Evdokimov)
+ o Style and comment tweaks for dns/leak* tests (5e42202)
+ o improve test to remove at least one buffer from src (7eb52eb Greg Hazel)
+
+DOCUMENTATION:
+ o Add note about evhttp_send_reply_end to its doxygen (724bfb5)
+ o Update copyright dates to 2011. (3c824bd)
+ o Fix typo in whatsnew-2.0.txt (674bc6a Mansour Moufid)
+ o Improve win32 behavior of dns-sample.c code (a3f320e Gisle Vanem)
+
+
+
+Changes in version 2.0.15-stable (12 Oct 2011)
+BUGFIXES (DNS):
+ o DNS: add ttl for negative answers using RFC 2308 idea. (f72e8f6 Leonid Evdokimov)
+ o Add DNS_ERR_NODATA error code to handle empty replies. (94fba5b Leonid Evdokimov)
+
+BUFGIXES (bufferevents and evbuffers):
+ o Make evbuffer callbacks get the right n_added value after evbuffer_add (1ef1f68 Alex)
+ o Prefer mmap to sendfile unless a DRAINS_TO_FD flag is set. Allows add_file to work with SSL. (0ba0af9)
+
+BUGFIXES (event loop):
+ o When a signal callback is activated to run multiple times, allow event_base_loopbreak to work even before they all have run. (4e8eb6a)
+
+DOCUMENTATION FIXES:
+ o Fix docstring in dns.h (2b6eae5 Leonid Evdokimov)
+ o refer to non-deprecated evdns functions in comments (ba5c27d Greg Hazel)
+
+BUILD AND TESTING FIXES:
+ o le-proxy and regress depend on openssl directly (9ae061a Sergey Avseyev)
+ o Use _SOURCES, not _sources, in sample/Makefile.am (7f82382)
+ o Fixed compiler warnings for unchecked read/write calls. (c3b62fd Mark Ellzey)
+ o Make write-checking fixes use tt_fail_perror (2b76847)
+ o Fix some "value never used" warnings with gcc 4.6.1 (39c0cf7)
+
+
+
+Changes in version 2.0.14-stable (31 Aug 2011)
+BUGFIXES (bufferevents and evbuffers):
+ o Propagate errors on the underlying bufferevent to the user. (4a34394 Joachim Bauch)
+ o Ignore OpenSSL deprecation warnings on OS X (5d1b255 Sebastian Hahn)
+ o Fix handling of group rate limits under 64 bytes of burst (6d5440e)
+ o Solaris sendfile: correctly detect amount of data sent (643922e Michael Herf)
+ o Make rate limiting work with common_timeout logic (5b18f13)
+ o clear read watermark on underlying bufferevent when creating filtering bev to fix potentially failing fragmented ssl handshakes (54f7e61 Joachim Bauch)
+
+BUGFIXES (IOCP):
+ o IOCP: don't launch reads or writes on an unconnected socket (495c227)
+ o Make IOCP rate-limiting group support stricter and less surprising. (a98da7b)
+ o Have test-ratelim.c support IOCP (0ff2c5a)
+ o Make overlapped reads result in evbuffer callbacks getting invoked (6acfbdd)
+ o Correctly terminate IO on an async bufferevent on bufferevent_free (e6af35d)
+
+BUGFIXES (other):
+ o Fix evsig_dealloc memory leak with debugging turned on. (9b724b2 Leonid Evdokimov)
+ o Fix request_finished memory leak with debugging turned on. (aff6ba1 Leonid Evdokimov)
+
+BUILD AND TESTING FIXES:
+ o Allow OS-neutral builds for platforms where some versions have arc4random_buf (b442302 Mitchell Livingston)
+ o Try to fix 'make distcheck' errors when building out-of-tree (04656ea Dave Hart)
+ o Clean up some problems identified by Coverity. (7c11e51 Harlan Stenn)
+
+
+Changes in version 2.0.13-stable (18 Jul 2011)
+BUGFIXES
+ o Avoid race-condition when initializing global locks (b683cae)
+ o Fix bug in SSL bufferevents backed by a bev with a write high-watermarks (e050703 Joachim Bauch)
+ o Speed up invoke_callbacks on evbuffers when there are no callbacks (f87f568 Mark Ellzey)
+ o Avoid a segfault when all methods are disabled or broken (27ce38b)
+ o Fix incorrect results from evbuffer_search_eol(EOL_LF) (4461f1a)
+ o Add some missing checks for mm_calloc failures (89d5e09)
+ o Replace an assertion for event_base_free(NULL) with a check-and-warn (09fe97d)
+ o Report kqueue ebadf, epipe, and eperm as EV_READ events (1fd34ab)
+ o Check if the `evhttp_new_object' function in `http.c' returns NULL. (446cc7a Mansour Moufid)
+ o Use the correct printf args when formatting size_t (3203f88)
+ o Complain if the caller tries to change threading cbs after setting them (cb6ecee)
+
+DOCUMENTATION FIXES AND IMPROVEMENTS
+ o Revise the event/evbuffer/bufferevent doxygen for clarity and accuracy (2888fac)
+ o Update Doxyfile to produce more useful output (aea0555)
+
+TEST FIXES
+ o Fix up test_evutil_snprintf (caf695a)
+ o Fix tinytest invocation from windows shell (57def34 Ed Day)
+
+BUILD FIXES
+ o Use AM_CPPFLAGS in sample/Makefile.am, not AM_CFLAGS (4a5c82d)
+ o Fix select.c compilation on systems with no NFDBITS (49d1136)
+ o Fix a few warnings on OpenBSD (8ee9f9c Nicholas Marriott)
+ o Don't break when building tests from git without python installed (b031adf)
+ o Don't install event_rpcgen.py when --disable-libevent-install is used (e23cda3 Harlan Stenn)
+ o Fix AIX build issue with TAILQ_FOREACH definition (e934096)
+
+
+Changes in version 2.0.12-stable (4 Jun 2011)
+BUGFIXES
+ o Fix a warn-and-fail bug in kqueue by providing kevent() room to report errors (28317a0)
+ o Fix an assert-inducing fencepost bug in the select backend (d90149d)
+ o Fix failing http assertion introducd in commit 0d6622e (0848814 Kevin Ko)
+ o Fix a bug that prevented us from configuring IPv6 nameservers. (74760f1)
+ o Prevent size_t overflow in evhttp_htmlescape. (06c51cd Mansour Moufid)
+ o Added several checks for under/overflow conditions in evhttp_handle_chunked_read (a279272 Mark Ellzey)
+ o Added overflow checks in evhttp_read_body and evhttp_get_body (84560fc Mark Ellzey)
+
+DOCUMENTATION:
+ o Add missing words to EVLOOP_NONBLOCK documentation (9556a7d)
+
+BUILD FIXES
+ o libssl depends on libcrypto, not the other way around. (274dd03 Peter Rosin)
+ o Libtool brings in the dependencies of libevent_openssl.la automatically (7b819f2 Peter Rosin)
+ o Use OPENSSL_LIBS in Makefile.am (292092e Sebastian Hahn)
+ o Move the win32 detection in configure.in (ceb03b9 Sebastian Hahn)
+ o Correctly detect openssl on windows (6619385 Sebastian Hahn)
+ o Fix a compile warning with zlib 1.2.4 and 1.2.5 (5786b91 Sebastian Hahn)
+ o Fix compilation with GCC 2, which had no __builtin_expect (09d39a1 Dave Hart)
+ o Fix new warnings from GCC 4.6 (06a714f)
+ o Link with -lshell32 and -ladvapi32 on Win32. (86090ee Peter Rosin)
+ o Make the tests build when OpenSSL is not available. (07c41be Peter Rosin)
+ o Bring in the compile script from automake, if needed. (f3c7a4c Peter Rosin)
+ o MSVC does not provide S_ISDIR, so provide it manually. (70be7d1 Peter Rosin)
+ o unistd.h and sys/time.h might not exist. (fe93022 Peter Rosin)
+ o Make sure TINYTEST_LOCAL is defined when building tinytest.c (8fa030c Peter Rosin)
+ o Fix winsock2.h #include issues with MSVC (3d768dc Peter Rosin)
+ o Use evutil_gettimeofday instead of relying on the system gettimeofday. (0de87fe Peter Rosin)
+ o Always use evutil_snprintf, even if OS provides it (d1b2d11 Sebastian Hahn)
+ o InitializeCriticalSectionAndSpinCount requires _WIN32_WINNT >= 0x0403. (816115a Peter Rosin)
+ o cygwin: make it possible to build DLLs (d54d3fc)
+
+
+
+Changes in version 2.0.11-stable (27 Apr 2011)
+ [Autogenerated from the Git log, sorted and cleaned by hand.]
+BUGFIXES:
+ o Fix evport handling of POLLHUP and POLLERR (b42ce4b)
+ o Fix compilation on Windows with NDEBUG (cb8059d)
+ o Check for POLLERR, POLLHUP and POLLNVAL for Solaris event ports (0144886 Trond Norbye)
+ o Detect and handle more allocation failures. (666b096 Jardel Weyrich)
+ o Use event_err() only if the failure is truly unrecoverable. (3f8d22a Jardel Weyrich)
+ o Handle resize failures in the select backend better. (83e805a)
+ o Correctly free selectop fields when select_resize fails in select_init (0c0ec0b)
+ o Make --enable-gcc-warnings a no-op if not using gcc (3267703)
+ o Fix a type error in our (unused) arc4random_stir() (f736198)
+ o Correctly detect and stop non-chunked http requests when the body is too long (63a715e)
+ o Have event_base_gettimeofday_cached() always return wall-clock time (a459ef7)
+ o Workaround for http crash bug 3078187 (5dc5662 Tomash Brechko)
+ o Fix incorrect assertions and possible use-after-free in evrpc_free() (4b8f02f Christophe Fillot)
+ o Reset outgoing http connection when read data in idle state. (272823f Tomash Brechko)
+ o Fix subtle recursion in evhttp_connection_cb_cleanup(). (218cf19 Tomash Brechko)
+ o Fix the case when failed evhttp_make_request() leaved request in the queue. (0d6622e Tomash Brechko)
+ o Fix a crash bug in evdns server circular list code (00e91b3)
+ o Handle calloc failure in evdns. (Found by Dave Hart) (364291e)
+ o Fix a memory leak on win32 socket->event map. (b4f89f0)
+ o Add a forgotten NULL check to evhttp_parse_headers (12311ff Sebastian Hahn)
+ o Fix possible NULL-deref in evdns_cancel_request (5208544 Sebastian Hahn)
+
+PORTABILITY:
+ o Fall back to sscanf if we have no other way to implement strtoll (453317b)
+ o Build correctly on platforms without sockaddr_storage (9184563)
+ o Try to build correctly on platforms with no IPv6 support (713c254)
+ o Build on systems without AI_PASSIVE (cb92113)
+ o Fix http unit test on non-windows platforms without getaddrinfo (6092f12)
+ o Do not check for gethostbyname_r versions if we have getaddrinfo (c1260b0)
+ o Include arpa/inet.h as needed on HPUX (10c834c Harlan Stenn)
+ o Include util-internal.h as needed to build on platforms with no sockaddr_storage (bbf5515 Harlan Stenn)
+ o Check for getservbyname even if not on win32. (af08a94 Harlan Stenn)
+ o Add -D_OSF_SOURCE to fix hpux builds (0b33479 Harlan Stenn)
+ o Check for allocation failures in apply_socktype_protocol_hack (637d17a)
+ o Fix the check for multicast or broadcast addresses in evutil_check_interfaces (1a21d7b)
+ o Avoid a free(NULL) if out-of-memory in evdns_getaddrinfo. Found by Dave Hart (3417f68)
+
+DEFENSIVE PROGRAMMING:
+ o Add compile-time check for AF_UNSPEC==PF_UNSPEC (3c8f4e7)
+
+BUGS IN TESTS:
+ o Fix test.sh output on solaris (b4f89b6 Dave Hart)
+ o Make test-eof fail with a timeout if we never get an eof. (05a2c22 Harlan Stenn)
+ o Use %s with printf in test.sh (039b9bd)
+ o Add an assert to appease clang's static analyzer (b0ff7eb Sebastian Hahn)
+ o Add a forgotten return value check in the unit tests (3819b62 Sebastian Hahn)
+ o Actually send NULL request in http_bad_request_test (b693c32 Sebastian Hahn)
+ o add some (void) casts for unused variables (65707d7 Sebastian Hahn)
+ o Refactor test_getaddrinfo_async_cancel_stress() (48c44a6 Sebastian Hahn)
+ o Be nice and "handle" error return values in sample code (4bac793 Sebastian Hahn)
+ o Check return value of evbuffer_add_cb in tests (93a1abb Sebastian Hahn)
+ o Remote some dead code from dns-example.c (744c745 Sebastian Hahn)
+ o Zero a struct sockaddr_in before using it (646f9fe Sebastian Hahn)
+
+BUILD FIXES:
+ o Fix warnings about AC_LANG_PROGRAM usage (f663112 Sebastian Hahn)
+ o Skip check for zlib if we have no zlib.h (a317c06 Harlan Stenn)
+ o Fix autoconf bracket issues; make check for getaddrinfo include netdb.h (833e5e9 Harlan Stenn)
+ o Correct an AM_CFLAGS to an AM_CPPFLAGS in test/Makefile.am (9c469db Dave Hart)
+ o Fix make distcheck & installation of libevent 1 headers (b5a1f9f Dave Hart)
+ o Fix compilation under LLVM/clang with --enable-gcc-warnings (ad9ff58 Sebastian Hahn)
+
+FEATURES:
+ o Make URI parser able to tolerate nonconformant URIs. (95060b5)
+
+DOCUMENTATION:
+ o Clarify event_set_mem_functions doc (926f816)
+ o Correct evhttp_del_accept_socket documentation on whether socket is closed (f665924)
+ o fix spelling mistake in whatsnew-2.0.txt (deb2f73)
+ o Fix sample/http-server ipv6 fixes (eb692be)
+ o Comment internal headers used in sample code. (4eb281c)
+ o Be explicit about how long event loops run in event.h documentation (f95bafb)
+ o Add comment to configure.in to explain gc-sections test logic (c621359)
+ o Fix a couple of memory leaks in samples/http-server.c. Found by Dave Hart. (2e9f665)
+
+
BUILD IMPROVEMENTS:
Libevent 2.1.2-alpha modernizes Libevent's use of autotools, and makes
diff --git a/contrib/ntp/sntp/libevent/Makefile.am b/contrib/ntp/sntp/libevent/Makefile.am
index 58f1f01..3053cc0 100644
--- a/contrib/ntp/sntp/libevent/Makefile.am
+++ b/contrib/ntp/sntp/libevent/Makefile.am
@@ -38,7 +38,7 @@ RELEASE = -release 2.1
#
# Once an RC is out, DO NOT MAKE ANY ABI-BREAKING CHANGES IN THAT SERIES
# UNLESS YOU REALLY REALLY HAVE TO.
-VERSION_INFO = 3:0:0
+VERSION_INFO = 5:0:0
# History: RELEASE VERSION_INFO
# 2.0.1-alpha -- 2.0 1:0:0
@@ -67,6 +67,8 @@ VERSION_INFO = 3:0:0
# 2.1.1-alpha -- 2.1 1:0:0
# 2.1.2-alpha -- 2.1 1:0:0 (should have been 2:0:1)
# 2.1.3-alpha -- 2.1 3:0:0 (ABI changed slightly)
+# 2.1.4-alpha -- 2.1 4:0:0 (ABI changed slightly)
+# 2.1.5-beta -- 2.1 5:0:0 (ABI changed slightly)
# ABI version history for this package effectively restarts every time
# we change RELEASE. Version 1.4.x had RELEASE of 1.4.
diff --git a/contrib/ntp/sntp/libevent/Makefile.in b/contrib/ntp/sntp/libevent/Makefile.in
index 463ae8c..4caff8f 100644
--- a/contrib/ntp/sntp/libevent/Makefile.in
+++ b/contrib/ntp/sntp/libevent/Makefile.in
@@ -66,15 +66,14 @@ host_triplet = @host@
@PTHREADS_TRUE@am__append_2 = libevent_pthreads.pc
@OPENSSL_TRUE@am__append_3 = libevent_openssl.la
@OPENSSL_TRUE@am__append_4 = libevent_openssl.pc
-noinst_PROGRAMS = $(am__EXEEXT_3) $(am__EXEEXT_5)
+noinst_PROGRAMS = $(am__EXEEXT_4) $(am__EXEEXT_6)
EXTRA_PROGRAMS = $(am__EXEEXT_1)
-DIST_COMMON = README $(am__configure_deps) \
- $(am__dist_bin_SCRIPTS_DIST) $(am__include_HEADERS_DIST) \
- $(am__include_event2_HEADERS_DIST) $(am__noinst_HEADERS_DIST) \
- $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
- $(srcdir)/config.h.in $(srcdir)/evconfig-private.h.in \
- $(srcdir)/include/include.am $(srcdir)/libevent.pc.in \
- $(srcdir)/libevent_openssl.pc.in \
+DIST_COMMON = $(am__configure_deps) $(am__dist_bin_SCRIPTS_DIST) \
+ $(am__include_HEADERS_DIST) $(am__include_event2_HEADERS_DIST) \
+ $(am__noinst_HEADERS_DIST) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in $(srcdir)/config.h.in \
+ $(srcdir)/evconfig-private.h.in $(srcdir)/include/include.am \
+ $(srcdir)/libevent.pc.in $(srcdir)/libevent_openssl.pc.in \
$(srcdir)/libevent_pthreads.pc.in $(srcdir)/sample/include.am \
$(srcdir)/test/include.am $(top_srcdir)/configure ChangeLog \
build-aux/compile build-aux/config.guess build-aux/config.sub \
@@ -86,33 +85,33 @@ DIST_COMMON = README $(am__configure_deps) \
@OPENSSL_TRUE@ sample/hostcheck.h \
@OPENSSL_TRUE@ sample/openssl_hostname_validation.h
-@BUILD_REGRESS_TRUE@am__append_8 = $(TESTPROGRAMS)
-@BUILD_REGRESS_TRUE@am__append_9 = test/regress
-@BUILD_REGRESS_TRUE@am__append_10 = test/regress.gen.c test/regress.gen.h
-@PTHREADS_TRUE@am__append_11 = libevent_pthreads.la
-@BUILD_WIN32_TRUE@am__append_12 = test/regress_iocp.c
-@OPENSSL_TRUE@am__append_13 = test/regress_ssl.c
-@OPENSSL_TRUE@am__append_14 = $(OPENSSL_INCS)
-@OPENSSL_TRUE@am__append_15 = libevent_openssl.la $(OPENSSL_LIBS) ${OPENSSL_LIBADD}
-@STRLCPY_IMPL_TRUE@am__append_16 = strlcpy.c
-@SELECT_BACKEND_TRUE@am__append_17 = select.c
-@POLL_BACKEND_TRUE@am__append_18 = poll.c
-@DEVPOLL_BACKEND_TRUE@am__append_19 = devpoll.c
-@KQUEUE_BACKEND_TRUE@am__append_20 = kqueue.c
-@EPOLL_BACKEND_TRUE@am__append_21 = epoll.c
-@EVPORT_BACKEND_TRUE@am__append_22 = evport.c
-@SIGNAL_SUPPORT_TRUE@am__append_23 = signal.c
-@INSTALL_LIBEVENT_FALSE@am__append_24 = $(EVENT1_HDRS)
+@BUILD_SAMPLES_TRUE@am__append_8 = $(SAMPLES)
+@BUILD_REGRESS_TRUE@am__append_9 = $(TESTPROGRAMS)
+@BUILD_REGRESS_TRUE@am__append_10 = test/regress
+@BUILD_REGRESS_TRUE@am__append_11 = test/regress.gen.c test/regress.gen.h
+@PTHREADS_TRUE@am__append_12 = libevent_pthreads.la
+@BUILD_WIN32_TRUE@am__append_13 = test/regress_iocp.c
+@OPENSSL_TRUE@am__append_14 = test/regress_ssl.c
+@OPENSSL_TRUE@am__append_15 = $(OPENSSL_INCS)
+@OPENSSL_TRUE@am__append_16 = libevent_openssl.la $(OPENSSL_LIBS) ${OPENSSL_LIBADD}
+@STRLCPY_IMPL_TRUE@am__append_17 = strlcpy.c
+@SELECT_BACKEND_TRUE@am__append_18 = select.c
+@POLL_BACKEND_TRUE@am__append_19 = poll.c
+@DEVPOLL_BACKEND_TRUE@am__append_20 = devpoll.c
+@KQUEUE_BACKEND_TRUE@am__append_21 = kqueue.c
+@EPOLL_BACKEND_TRUE@am__append_22 = epoll.c
+@EVPORT_BACKEND_TRUE@am__append_23 = evport.c
+@SIGNAL_SUPPORT_TRUE@am__append_24 = signal.c
+@INSTALL_LIBEVENT_FALSE@am__append_25 = $(EVENT1_HDRS)
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ac_backport_259_ssizet.m4 \
+ $(top_srcdir)/m4/acx_pthread.m4 \
$(top_srcdir)/m4/libevent_openssl.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 \
- $(top_srcdir)/m4/ntp_pkg_config.m4 \
- $(top_srcdir)/m4/openldap-thread-check.m4 \
- $(top_srcdir)/m4/openldap.m4 $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/ntp_pkg_config.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
@@ -250,14 +249,15 @@ am__EXEEXT_3 = sample/dns-example$(EXEEXT) \
sample/event-read-fifo$(EXEEXT) sample/hello-world$(EXEEXT) \
sample/http-server$(EXEEXT) sample/signal-test$(EXEEXT) \
sample/time-test$(EXEEXT) $(am__EXEEXT_2)
-am__EXEEXT_4 = test/bench$(EXEEXT) test/bench_cascade$(EXEEXT) \
+@BUILD_SAMPLES_TRUE@am__EXEEXT_4 = $(am__EXEEXT_3)
+am__EXEEXT_5 = test/bench$(EXEEXT) test/bench_cascade$(EXEEXT) \
test/bench_http$(EXEEXT) test/bench_httpclient$(EXEEXT) \
test/test-changelist$(EXEEXT) test/test-dumpevents$(EXEEXT) \
test/test-eof$(EXEEXT) test/test-closed$(EXEEXT) \
test/test-fdleak$(EXEEXT) test/test-init$(EXEEXT) \
test/test-ratelim$(EXEEXT) test/test-time$(EXEEXT) \
test/test-weof$(EXEEXT) test/regress$(EXEEXT)
-@BUILD_REGRESS_TRUE@am__EXEEXT_5 = $(am__EXEEXT_4)
+@BUILD_REGRESS_TRUE@am__EXEEXT_6 = $(am__EXEEXT_5)
PROGRAMS = $(noinst_PROGRAMS)
am__dirstamp = $(am__leading_dot)dirstamp
am_sample_dns_example_OBJECTS = sample/dns-example.$(OBJEXT)
@@ -343,7 +343,7 @@ am_test_regress_OBJECTS = test/test_regress-regress.$(OBJEXT) \
test/test_regress-tinytest.$(OBJEXT) $(am__objects_12) \
$(am__objects_13) $(am__objects_14) $(am__objects_15)
test_regress_OBJECTS = $(am_test_regress_OBJECTS)
-am__DEPENDENCIES_3 = $(am__append_11)
+am__DEPENDENCIES_3 = $(am__append_12)
@OPENSSL_TRUE@am__DEPENDENCIES_4 = libevent_openssl.la \
@OPENSSL_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
test_regress_DEPENDENCIES = $(am__DEPENDENCIES_1) libevent.la \
@@ -568,8 +568,9 @@ PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
+PTHREAD_CC = @PTHREAD_CC@
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
-PTHREAD_LIBS = @PTHREAD_LIBS@ $(am__append_11)
+PTHREAD_LIBS = @PTHREAD_LIBS@ $(am__append_12)
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
@@ -584,6 +585,7 @@ abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
@@ -663,7 +665,7 @@ RELEASE = -release 2.1
#
# Once an RC is out, DO NOT MAKE ANY ABI-BREAKING CHANGES IN THAT SERIES
# UNLESS YOU REALLY REALLY HAVE TO.
-VERSION_INFO = 3:0:0
+VERSION_INFO = 5:0:0
# History: RELEASE VERSION_INFO
# 2.0.1-alpha -- 2.0 1:0:0
@@ -692,6 +694,8 @@ VERSION_INFO = 3:0:0
# 2.1.1-alpha -- 2.1 1:0:0
# 2.1.2-alpha -- 2.1 1:0:0 (should have been 2:0:1)
# 2.1.3-alpha -- 2.1 3:0:0 (ABI changed slightly)
+# 2.1.4-alpha -- 2.1 4:0:0 (ABI changed slightly)
+# 2.1.5-beta -- 2.1 5:0:0 (ABI changed slightly)
# ABI version history for this package effectively restarts every time
# we change RELEASE. Version 1.4.x had RELEASE of 1.4.
@@ -744,12 +748,12 @@ noinst_HEADERS = $(am__append_5) $(am__append_7) test/regress.h \
iocp-internal.h ipv6-internal.h kqueue-internal.h \
log-internal.h minheap-internal.h mm-internal.h \
ratelim-internal.h ratelim-internal.h strlcpy-internal.h \
- time-internal.h util-internal.h $(am__append_24)
+ time-internal.h util-internal.h $(am__append_25)
CLEANFILES = test/rpcgen-attempted
DISTCLEANFILES = test/test-script.sh test/regress.gen.c \
test/regress.gen.h *~ libevent.pc \
./include/event2/event-config.h
-BUILT_SOURCES = $(am__append_10) include/event2/event-config.h
+BUILT_SOURCES = $(am__append_11) include/event2/event-config.h
include_event2dir = $(includedir)/event2
EVENT2_EXPORT = \
include/event2/buffer.h \
@@ -853,14 +857,14 @@ test_regress_SOURCES = test/regress.c test/regress.gen.c \
test/regress_minheap.c test/regress_rpc.c \
test/regress_testutils.c test/regress_testutils.h \
test/regress_util.c test/tinytest.c $(regress_thread_SOURCES) \
- $(regress_zlib_SOURCES) $(am__append_12) $(am__append_13)
+ $(regress_zlib_SOURCES) $(am__append_13) $(am__append_14)
@BUILD_WIN32_TRUE@regress_thread_SOURCES = test/regress_thread.c
@PTHREADS_TRUE@regress_thread_SOURCES = test/regress_thread.c
@ZLIB_REGRESS_TRUE@regress_zlib_SOURCES = test/regress_zlib.c
test_regress_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la \
- $(PTHREAD_LIBS) $(ZLIB_LIBS) $(am__append_15)
+ $(PTHREAD_LIBS) $(ZLIB_LIBS) $(am__append_16)
test_regress_CPPFLAGS = $(AM_CPPFLAGS) $(PTHREAD_CFLAGS) \
- $(ZLIB_CFLAGS) -Itest $(am__append_14)
+ $(ZLIB_CFLAGS) -Itest $(am__append_15)
test_regress_LDFLAGS = $(PTHREAD_CFLAGS)
test_bench_SOURCES = test/bench.c
test_bench_LDADD = $(LIBEVENT_GC_SECTIONS) libevent.la
@@ -872,17 +876,17 @@ test_bench_httpclient_SOURCES = test/bench_httpclient.c
test_bench_httpclient_LDADD = $(LIBEVENT_GC_SECTIONS) libevent_core.la
@BUILD_WIN32_FALSE@SYS_LIBS =
@BUILD_WIN32_TRUE@SYS_LIBS = -lws2_32 -lshell32 -ladvapi32
-@BUILD_WIN32_FALSE@SYS_SRC = $(am__append_16) $(am__append_17) \
-@BUILD_WIN32_FALSE@ $(am__append_18) $(am__append_19) \
-@BUILD_WIN32_FALSE@ $(am__append_20) $(am__append_21) \
-@BUILD_WIN32_FALSE@ $(am__append_22) $(am__append_23)
+@BUILD_WIN32_FALSE@SYS_SRC = $(am__append_17) $(am__append_18) \
+@BUILD_WIN32_FALSE@ $(am__append_19) $(am__append_20) \
+@BUILD_WIN32_FALSE@ $(am__append_21) $(am__append_22) \
+@BUILD_WIN32_FALSE@ $(am__append_23) $(am__append_24)
@BUILD_WIN32_TRUE@SYS_SRC = win32select.c evthread_win32.c \
@BUILD_WIN32_TRUE@ buffer_iocp.c event_iocp.c \
-@BUILD_WIN32_TRUE@ bufferevent_async.c $(am__append_16) \
-@BUILD_WIN32_TRUE@ $(am__append_17) $(am__append_18) \
-@BUILD_WIN32_TRUE@ $(am__append_19) $(am__append_20) \
-@BUILD_WIN32_TRUE@ $(am__append_21) $(am__append_22) \
-@BUILD_WIN32_TRUE@ $(am__append_23)
+@BUILD_WIN32_TRUE@ bufferevent_async.c $(am__append_17) \
+@BUILD_WIN32_TRUE@ $(am__append_18) $(am__append_19) \
+@BUILD_WIN32_TRUE@ $(am__append_20) $(am__append_21) \
+@BUILD_WIN32_TRUE@ $(am__append_22) $(am__append_23) \
+@BUILD_WIN32_TRUE@ $(am__append_24)
@BUILD_WIN32_FALSE@SYS_INCLUDES =
@BUILD_WIN32_TRUE@SYS_INCLUDES = -IWIN32-Code -IWIN32-Code/nmake
CORE_SRC = \
diff --git a/contrib/ntp/sntp/libevent/README b/contrib/ntp/sntp/libevent/README
deleted file mode 100644
index 2723a2c..0000000
--- a/contrib/ntp/sntp/libevent/README
+++ /dev/null
@@ -1,218 +0,0 @@
-0. BUILDING AND INSTALLATION (Briefly)
-
-$ ./configure
-$ make
-$ make verify # (optional)
-$ sudo make install
-
-1. BUILDING AND INSTALLATION (In Depth)
-
-To build libevent, type
-
-$ ./configure && make
-
- (If you got libevent from the git repository, you will
- first need to run the included "autogen.sh" script in order to
- generate the configure script.)
-
-You can run the regression tests by running
-
-$ make verify
-
-Install as root via
-
-# make install
-
-Before reporting any problems, please run the regression tests.
-
-To enable the low-level tracing build the library as:
-
- CFLAGS=-DUSE_DEBUG ./configure [...]
-
-Standard configure flags should work. In particular, see:
-
- --disable-shared Only build static libraries
- --prefix Install all files relative to this directory.
-
-
-The configure script also supports the following flags:
-
- --enable-gcc-warnings Enable extra compiler checking with GCC.
- --disable-malloc-replacement
- Don't let applications replace our memory
- management functions
- --disable-openssl Disable support for OpenSSL encryption.
- --disable-thread-support Don't support multithreaded environments.
-
-2. USEFUL LINKS:
-
-For the latest released version of Libevent, see the official website at
-http://libevent.org/ .
-
-There's a pretty good work-in-progress manual up at
- http://www.wangafu.net/~nickm/libevent-book/ .
-
-For the latest development versions of Libevent, access our Git repository
-via
- "git clone git://levent.git.sourceforge.net/gitroot/levent/libevent"
-
-You can browse the git repository online at
-http://levent.git.sourceforge.net/git/gitweb-index.cgi .
-
-To report bugs, request features, or submit patches to Libevent,
-use the Sourceforge trackers at
-https://sourceforge.net/tracker/?group_id=50884 .
-
-There's also a libevent-users mailing list for talking about Libevent
-use and development: http://archives.seul.org/libevent/users/
-
-3. ACKNOWLEDGMENTS
-
-The following people have helped with suggestions, ideas, code or
-fixing bugs:
-
- Samy Al Bahra
- Jacob Appelbaum
- Arno Bakker
- Weston Andros Adamson
- William Ahern
- Ivan Andropov
- Sergey Avseyev
- Avi Bab
- Joachim Bauch
- Gilad Benjamini
- Stas Bekman
- Denis Bilenko
- Julien Blache
- Kevin Bowling
- Tomash Brechko
- Kelly Brock
- Ralph Castain
- Adrian Chadd
- Lawnstein Chan
- Shuo Chen
- Ka-Hing Cheung
- Andrew Cox
- Paul Croome
- George Danchev
- Andrew Danforth
- Ed Day
- Christopher Davis
- Mike Davis
- Antony Dovgal
- Mihai Draghicioiu
- Alexander Drozdov
- Mark Ellzey
- Shie Erlich
- Leonid Evdokimov
- Juan Pablo Fernandez
- Christophe Fillot
- Mike Frysinger
- Remi Gacogne
- Artem Germanov
- Alexander von Gernler
- Artur Grabowski
- Diwaker Gupta
- Sebastian Hahn
- Dave Hart
- Greg Hazel
- Michael Herf
- Sebastian Hahn
- Savg He
- Mark Heily
- Michael Herf
- Greg Hewgill
- Andrew Hochhaus
- Aaron Hopkins
- Tani Hosokawa
- Jamie Iles
- Claudio Jeker
- Evan Jones
- George Kadianakis
- Phua Keat
- Azat Khuzhin
- Alexander Klauer
- Kevin Ko
- Brian Koehmstedt
- Marko Kreen
- Valery Kyholodov
- Ross Lagerwall
- Scott Lamb
- Christopher Layne
- Adam Langley
- Graham Leggett
- Philip Lewis
- Zhou Li
- David Libenzi
- Yan Lin
- Moshe Litvin
- Simon Liu
- Mitchell Livingston
- Hagne Mahre
- Lubomir Marinov
- Abilio Marques
- Abel Mathew
- Nick Mathewson
- James Mansion
- Nicholas Marriott
- Andrey Matveev
- Caitlin Mercer
- Dagobert Michelsen
- Andrea Montefusco
- Mansour Moufid
- Mina Naguib
- Felix Nawothnig
- Trond Norbye
- Linus Nordberg
- Richard Nyberg
- Jon Oberheide
- Phil Oleson
- Dave Pacheco
- Derrick Pallas
- Tassilo von Parseval
- Catalin Patulea
- Patrick Pelletier
- Simon Perreault
- Pierre Phaneuf
- Amarin Phaosawasdi
- Ryan Phillips
- Dimitre Piskyulev
- Pavel Plesov
- Jon Poland
- Roman Puls
- Nate R
- Robert Ransom
- Bert JW Regeer
- Peter Rosin
- Maseeb Abdul Qadir
- Wang Qin
- Alex S
- Hanna Schroeter
- Ralf Schmitt
- Mike Smellie
- Kevin Springborn
- Nir Soffer
- Harlan Stenn
- Steve Snyder
- Dug Song
- Dongsheng Song
- Hannes Sowa
- Ferenc Szalai
- Brodie Thiesfield
- Jason Toffaletti
- Gisle Vanem
- Bas Verhoeven
- Constantine Verutin
- Colin Watt
- Zack Weinberg
- Jardel Weyrich
- Jay R. Wren
- Zack Weinberg
- Alejo
- Alex
- Taral
- propanbutan
- mmadia
- yangacer
-
-If we have forgotten your name, please contact us.
diff --git a/contrib/ntp/sntp/libevent/WIN32-Code/nmake/event2/event-config.h b/contrib/ntp/sntp/libevent/WIN32-Code/nmake/event2/event-config.h
index da55028..8cbf190 100644
--- a/contrib/ntp/sntp/libevent/WIN32-Code/nmake/event2/event-config.h
+++ b/contrib/ntp/sntp/libevent/WIN32-Code/nmake/event2/event-config.h
@@ -274,7 +274,7 @@
/* #undef EVENT__HAVE_WORKING_KQUEUE */
/* Numeric representation of the version */
-#define EVENT__NUMERIC_VERSION 0x02010301
+#define EVENT__NUMERIC_VERSION 0x02010500
/* Name of package */
#define EVENT__PACKAGE "libevent"
@@ -331,7 +331,7 @@
#define EVENT__TIME_WITH_SYS_TIME 1
/* Version number of package */
-#define EVENT__VERSION "2.1.3-alpha-dev"
+#define EVENT__VERSION "2.1.5-beta"
/* Define to appropriate substitue if compiler doesnt have __func__ */
#define EVENT____func__ __FUNCTION__
diff --git a/contrib/ntp/sntp/libevent/WIN32-Code/tree.h b/contrib/ntp/sntp/libevent/WIN32-Code/tree.h
index 585618d..2ccfbf2 100644
--- a/contrib/ntp/sntp/libevent/WIN32-Code/tree.h
+++ b/contrib/ntp/sntp/libevent/WIN32-Code/tree.h
@@ -675,680 +675,3 @@ name##_RB_MINMAX(struct name *head, int val) \
(x) = name##_RB_NEXT(x))
#endif /* _SYS_TREE_H_ */
-/* $OpenBSD: tree.h,v 1.7 2002/10/17 21:51:54 art Exp $ */
-/*
- * Copyright 2002 Niels Provos <provos@citi.umich.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.
- *
- * 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 _SYS_TREE_H_
-#define _SYS_TREE_H_
-
-/*
- * This file defines data structures for different types of trees:
- * splay trees and red-black trees.
- *
- * A splay tree is a self-organizing data structure. Every operation
- * on the tree causes a splay to happen. The splay moves the requested
- * node to the root of the tree and partly rebalances it.
- *
- * This has the benefit that request locality causes faster lookups as
- * the requested nodes move to the top of the tree. On the other hand,
- * every lookup causes memory writes.
- *
- * The Balance Theorem bounds the total access time for m operations
- * and n inserts on an initially empty tree as O((m + n)lg n). The
- * amortized cost for a sequence of m accesses to a splay tree is O(lg n);
- *
- * A red-black tree is a binary search tree with the node color as an
- * extra attribute. It fulfills a set of conditions:
- * - every search path from the root to a leaf consists of the
- * same number of black nodes,
- * - each red node (except for the root) has a black parent,
- * - each leaf node is black.
- *
- * Every operation on a red-black tree is bounded as O(lg n).
- * The maximum height of a red-black tree is 2lg (n+1).
- */
-
-#define SPLAY_HEAD(name, type) \
-struct name { \
- struct type *sph_root; /* root of the tree */ \
-}
-
-#define SPLAY_INITIALIZER(root) \
- { NULL }
-
-#define SPLAY_INIT(root) do { \
- (root)->sph_root = NULL; \
-} while (0)
-
-#define SPLAY_ENTRY(type) \
-struct { \
- struct type *spe_left; /* left element */ \
- struct type *spe_right; /* right element */ \
-}
-
-#define SPLAY_LEFT(elm, field) (elm)->field.spe_left
-#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right
-#define SPLAY_ROOT(head) (head)->sph_root
-#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL)
-
-/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */
-#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \
- SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \
- SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
- (head)->sph_root = tmp; \
-} while (0)
-
-#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \
- SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \
- SPLAY_LEFT(tmp, field) = (head)->sph_root; \
- (head)->sph_root = tmp; \
-} while (0)
-
-#define SPLAY_LINKLEFT(head, tmp, field) do { \
- SPLAY_LEFT(tmp, field) = (head)->sph_root; \
- tmp = (head)->sph_root; \
- (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \
-} while (0)
-
-#define SPLAY_LINKRIGHT(head, tmp, field) do { \
- SPLAY_RIGHT(tmp, field) = (head)->sph_root; \
- tmp = (head)->sph_root; \
- (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \
-} while (0)
-
-#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \
- SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \
- SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\
- SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \
- SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \
-} while (0)
-
-/* Generates prototypes and inline functions */
-
-#define SPLAY_PROTOTYPE(name, type, field, cmp) \
-void name##_SPLAY(struct name *, struct type *); \
-void name##_SPLAY_MINMAX(struct name *, int); \
-struct type *name##_SPLAY_INSERT(struct name *, struct type *); \
-struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \
- \
-/* Finds the node with the same key as elm */ \
-static __inline struct type * \
-name##_SPLAY_FIND(struct name *head, struct type *elm) \
-{ \
- if (SPLAY_EMPTY(head)) \
- return(NULL); \
- name##_SPLAY(head, elm); \
- if ((cmp)(elm, (head)->sph_root) == 0) \
- return (head->sph_root); \
- return (NULL); \
-} \
- \
-static __inline struct type * \
-name##_SPLAY_NEXT(struct name *head, struct type *elm) \
-{ \
- name##_SPLAY(head, elm); \
- if (SPLAY_RIGHT(elm, field) != NULL) { \
- elm = SPLAY_RIGHT(elm, field); \
- while (SPLAY_LEFT(elm, field) != NULL) { \
- elm = SPLAY_LEFT(elm, field); \
- } \
- } else \
- elm = NULL; \
- return (elm); \
-} \
- \
-static __inline struct type * \
-name##_SPLAY_MIN_MAX(struct name *head, int val) \
-{ \
- name##_SPLAY_MINMAX(head, val); \
- return (SPLAY_ROOT(head)); \
-}
-
-/* Main splay operation.
- * Moves node close to the key of elm to top
- */
-#define SPLAY_GENERATE(name, type, field, cmp) \
-struct type * \
-name##_SPLAY_INSERT(struct name *head, struct type *elm) \
-{ \
- if (SPLAY_EMPTY(head)) { \
- SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \
- } else { \
- int __comp; \
- name##_SPLAY(head, elm); \
- __comp = (cmp)(elm, (head)->sph_root); \
- if(__comp < 0) { \
- SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\
- SPLAY_RIGHT(elm, field) = (head)->sph_root; \
- SPLAY_LEFT((head)->sph_root, field) = NULL; \
- } else if (__comp > 0) { \
- SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\
- SPLAY_LEFT(elm, field) = (head)->sph_root; \
- SPLAY_RIGHT((head)->sph_root, field) = NULL; \
- } else \
- return ((head)->sph_root); \
- } \
- (head)->sph_root = (elm); \
- return (NULL); \
-} \
- \
-struct type * \
-name##_SPLAY_REMOVE(struct name *head, struct type *elm) \
-{ \
- struct type *__tmp; \
- if (SPLAY_EMPTY(head)) \
- return (NULL); \
- name##_SPLAY(head, elm); \
- if ((cmp)(elm, (head)->sph_root) == 0) { \
- if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \
- (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\
- } else { \
- __tmp = SPLAY_RIGHT((head)->sph_root, field); \
- (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\
- name##_SPLAY(head, elm); \
- SPLAY_RIGHT((head)->sph_root, field) = __tmp; \
- } \
- return (elm); \
- } \
- return (NULL); \
-} \
- \
-void \
-name##_SPLAY(struct name *head, struct type *elm) \
-{ \
- struct type __node, *__left, *__right, *__tmp; \
- int __comp; \
-\
- SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
- __left = __right = &__node; \
-\
- while ((__comp = (cmp)(elm, (head)->sph_root))) { \
- if (__comp < 0) { \
- __tmp = SPLAY_LEFT((head)->sph_root, field); \
- if (__tmp == NULL) \
- break; \
- if ((cmp)(elm, __tmp) < 0){ \
- SPLAY_ROTATE_RIGHT(head, __tmp, field); \
- if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
- break; \
- } \
- SPLAY_LINKLEFT(head, __right, field); \
- } else if (__comp > 0) { \
- __tmp = SPLAY_RIGHT((head)->sph_root, field); \
- if (__tmp == NULL) \
- break; \
- if ((cmp)(elm, __tmp) > 0){ \
- SPLAY_ROTATE_LEFT(head, __tmp, field); \
- if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
- break; \
- } \
- SPLAY_LINKRIGHT(head, __left, field); \
- } \
- } \
- SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
-} \
- \
-/* Splay with either the minimum or the maximum element \
- * Used to find minimum or maximum element in tree. \
- */ \
-void name##_SPLAY_MINMAX(struct name *head, int __comp) \
-{ \
- struct type __node, *__left, *__right, *__tmp; \
-\
- SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
- __left = __right = &__node; \
-\
- while (1) { \
- if (__comp < 0) { \
- __tmp = SPLAY_LEFT((head)->sph_root, field); \
- if (__tmp == NULL) \
- break; \
- if (__comp < 0){ \
- SPLAY_ROTATE_RIGHT(head, __tmp, field); \
- if (SPLAY_LEFT((head)->sph_root, field) == NULL)\
- break; \
- } \
- SPLAY_LINKLEFT(head, __right, field); \
- } else if (__comp > 0) { \
- __tmp = SPLAY_RIGHT((head)->sph_root, field); \
- if (__tmp == NULL) \
- break; \
- if (__comp > 0) { \
- SPLAY_ROTATE_LEFT(head, __tmp, field); \
- if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\
- break; \
- } \
- SPLAY_LINKRIGHT(head, __left, field); \
- } \
- } \
- SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \
-}
-
-#define SPLAY_NEGINF -1
-#define SPLAY_INF 1
-
-#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y)
-#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y)
-#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y)
-#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y)
-#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \
- : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF))
-#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \
- : name##_SPLAY_MIN_MAX(x, SPLAY_INF))
-
-#define SPLAY_FOREACH(x, name, head) \
- for ((x) = SPLAY_MIN(name, head); \
- (x) != NULL; \
- (x) = SPLAY_NEXT(name, head, x))
-
-/* Macros that define a red-back tree */
-#define RB_HEAD(name, type) \
-struct name { \
- struct type *rbh_root; /* root of the tree */ \
-}
-
-#define RB_INITIALIZER(root) \
- { NULL }
-
-#define RB_INIT(root) do { \
- (root)->rbh_root = NULL; \
-} while (0)
-
-#define RB_BLACK 0
-#define RB_RED 1
-#define RB_ENTRY(type) \
-struct { \
- struct type *rbe_left; /* left element */ \
- struct type *rbe_right; /* right element */ \
- struct type *rbe_parent; /* parent element */ \
- int rbe_color; /* node color */ \
-}
-
-#define RB_LEFT(elm, field) (elm)->field.rbe_left
-#define RB_RIGHT(elm, field) (elm)->field.rbe_right
-#define RB_PARENT(elm, field) (elm)->field.rbe_parent
-#define RB_COLOR(elm, field) (elm)->field.rbe_color
-#define RB_ROOT(head) (head)->rbh_root
-#define RB_EMPTY(head) (RB_ROOT(head) == NULL)
-
-#define RB_SET(elm, parent, field) do { \
- RB_PARENT(elm, field) = parent; \
- RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \
- RB_COLOR(elm, field) = RB_RED; \
-} while (0)
-
-#define RB_SET_BLACKRED(black, red, field) do { \
- RB_COLOR(black, field) = RB_BLACK; \
- RB_COLOR(red, field) = RB_RED; \
-} while (0)
-
-#ifndef RB_AUGMENT
-#define RB_AUGMENT(x)
-#endif
-
-#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \
- (tmp) = RB_RIGHT(elm, field); \
- if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field))) { \
- RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \
- } \
- RB_AUGMENT(elm); \
- if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) { \
- if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
- RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
- else \
- RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
- } else \
- (head)->rbh_root = (tmp); \
- RB_LEFT(tmp, field) = (elm); \
- RB_PARENT(elm, field) = (tmp); \
- RB_AUGMENT(tmp); \
- if ((RB_PARENT(tmp, field))) \
- RB_AUGMENT(RB_PARENT(tmp, field)); \
-} while (0)
-
-#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \
- (tmp) = RB_LEFT(elm, field); \
- if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field))) { \
- RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \
- } \
- RB_AUGMENT(elm); \
- if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) { \
- if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
- RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
- else \
- RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
- } else \
- (head)->rbh_root = (tmp); \
- RB_RIGHT(tmp, field) = (elm); \
- RB_PARENT(elm, field) = (tmp); \
- RB_AUGMENT(tmp); \
- if ((RB_PARENT(tmp, field))) \
- RB_AUGMENT(RB_PARENT(tmp, field)); \
-} while (0)
-
-/* Generates prototypes and inline functions */
-#define RB_PROTOTYPE(name, type, field, cmp) \
-void name##_RB_INSERT_COLOR(struct name *, struct type *); \
-void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\
-struct type *name##_RB_REMOVE(struct name *, struct type *); \
-struct type *name##_RB_INSERT(struct name *, struct type *); \
-struct type *name##_RB_FIND(struct name *, struct type *); \
-struct type *name##_RB_NEXT(struct type *); \
-struct type *name##_RB_MINMAX(struct name *, int); \
- \
-
-/* Main rb operation.
- * Moves node close to the key of elm to top
- */
-#define RB_GENERATE(name, type, field, cmp) \
-void \
-name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \
-{ \
- struct type *parent, *gparent, *tmp; \
- while ((parent = RB_PARENT(elm, field)) && \
- RB_COLOR(parent, field) == RB_RED) { \
- gparent = RB_PARENT(parent, field); \
- if (parent == RB_LEFT(gparent, field)) { \
- tmp = RB_RIGHT(gparent, field); \
- if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
- RB_COLOR(tmp, field) = RB_BLACK; \
- RB_SET_BLACKRED(parent, gparent, field);\
- elm = gparent; \
- continue; \
- } \
- if (RB_RIGHT(parent, field) == elm) { \
- RB_ROTATE_LEFT(head, parent, tmp, field);\
- tmp = parent; \
- parent = elm; \
- elm = tmp; \
- } \
- RB_SET_BLACKRED(parent, gparent, field); \
- RB_ROTATE_RIGHT(head, gparent, tmp, field); \
- } else { \
- tmp = RB_LEFT(gparent, field); \
- if (tmp && RB_COLOR(tmp, field) == RB_RED) { \
- RB_COLOR(tmp, field) = RB_BLACK; \
- RB_SET_BLACKRED(parent, gparent, field);\
- elm = gparent; \
- continue; \
- } \
- if (RB_LEFT(parent, field) == elm) { \
- RB_ROTATE_RIGHT(head, parent, tmp, field);\
- tmp = parent; \
- parent = elm; \
- elm = tmp; \
- } \
- RB_SET_BLACKRED(parent, gparent, field); \
- RB_ROTATE_LEFT(head, gparent, tmp, field); \
- } \
- } \
- RB_COLOR(head->rbh_root, field) = RB_BLACK; \
-} \
- \
-void \
-name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \
-{ \
- struct type *tmp; \
- while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \
- elm != RB_ROOT(head)) { \
- if (RB_LEFT(parent, field) == elm) { \
- tmp = RB_RIGHT(parent, field); \
- if (RB_COLOR(tmp, field) == RB_RED) { \
- RB_SET_BLACKRED(tmp, parent, field); \
- RB_ROTATE_LEFT(head, parent, tmp, field);\
- tmp = RB_RIGHT(parent, field); \
- } \
- if ((RB_LEFT(tmp, field) == NULL || \
- RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\
- (RB_RIGHT(tmp, field) == NULL || \
- RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\
- RB_COLOR(tmp, field) = RB_RED; \
- elm = parent; \
- parent = RB_PARENT(elm, field); \
- } else { \
- if (RB_RIGHT(tmp, field) == NULL || \
- RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\
- struct type *oleft; \
- if ((oleft = RB_LEFT(tmp, field)))\
- RB_COLOR(oleft, field) = RB_BLACK;\
- RB_COLOR(tmp, field) = RB_RED; \
- RB_ROTATE_RIGHT(head, tmp, oleft, field);\
- tmp = RB_RIGHT(parent, field); \
- } \
- RB_COLOR(tmp, field) = RB_COLOR(parent, field);\
- RB_COLOR(parent, field) = RB_BLACK; \
- if (RB_RIGHT(tmp, field)) \
- RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK;\
- RB_ROTATE_LEFT(head, parent, tmp, field);\
- elm = RB_ROOT(head); \
- break; \
- } \
- } else { \
- tmp = RB_LEFT(parent, field); \
- if (RB_COLOR(tmp, field) == RB_RED) { \
- RB_SET_BLACKRED(tmp, parent, field); \
- RB_ROTATE_RIGHT(head, parent, tmp, field);\
- tmp = RB_LEFT(parent, field); \
- } \
- if ((RB_LEFT(tmp, field) == NULL || \
- RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\
- (RB_RIGHT(tmp, field) == NULL || \
- RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\
- RB_COLOR(tmp, field) = RB_RED; \
- elm = parent; \
- parent = RB_PARENT(elm, field); \
- } else { \
- if (RB_LEFT(tmp, field) == NULL || \
- RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\
- struct type *oright; \
- if ((oright = RB_RIGHT(tmp, field)))\
- RB_COLOR(oright, field) = RB_BLACK;\
- RB_COLOR(tmp, field) = RB_RED; \
- RB_ROTATE_LEFT(head, tmp, oright, field);\
- tmp = RB_LEFT(parent, field); \
- } \
- RB_COLOR(tmp, field) = RB_COLOR(parent, field);\
- RB_COLOR(parent, field) = RB_BLACK; \
- if (RB_LEFT(tmp, field)) \
- RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK;\
- RB_ROTATE_RIGHT(head, parent, tmp, field);\
- elm = RB_ROOT(head); \
- break; \
- } \
- } \
- } \
- if (elm) \
- RB_COLOR(elm, field) = RB_BLACK; \
-} \
- \
-struct type * \
-name##_RB_REMOVE(struct name *head, struct type *elm) \
-{ \
- struct type *child, *parent, *old = elm; \
- int color; \
- if (RB_LEFT(elm, field) == NULL) \
- child = RB_RIGHT(elm, field); \
- else if (RB_RIGHT(elm, field) == NULL) \
- child = RB_LEFT(elm, field); \
- else { \
- struct type *left; \
- elm = RB_RIGHT(elm, field); \
- while ((left = RB_LEFT(elm, field))) \
- elm = left; \
- child = RB_RIGHT(elm, field); \
- parent = RB_PARENT(elm, field); \
- color = RB_COLOR(elm, field); \
- if (child) \
- RB_PARENT(child, field) = parent; \
- if (parent) { \
- if (RB_LEFT(parent, field) == elm) \
- RB_LEFT(parent, field) = child; \
- else \
- RB_RIGHT(parent, field) = child; \
- RB_AUGMENT(parent); \
- } else \
- RB_ROOT(head) = child; \
- if (RB_PARENT(elm, field) == old) \
- parent = elm; \
- (elm)->field = (old)->field; \
- if (RB_PARENT(old, field)) { \
- if (RB_LEFT(RB_PARENT(old, field), field) == old)\
- RB_LEFT(RB_PARENT(old, field), field) = elm;\
- else \
- RB_RIGHT(RB_PARENT(old, field), field) = elm;\
- RB_AUGMENT(RB_PARENT(old, field)); \
- } else \
- RB_ROOT(head) = elm; \
- RB_PARENT(RB_LEFT(old, field), field) = elm; \
- if (RB_RIGHT(old, field)) \
- RB_PARENT(RB_RIGHT(old, field), field) = elm; \
- if (parent) { \
- left = parent; \
- do { \
- RB_AUGMENT(left); \
- } while ((left = RB_PARENT(left, field))); \
- } \
- goto color; \
- } \
- parent = RB_PARENT(elm, field); \
- color = RB_COLOR(elm, field); \
- if (child) \
- RB_PARENT(child, field) = parent; \
- if (parent) { \
- if (RB_LEFT(parent, field) == elm) \
- RB_LEFT(parent, field) = child; \
- else \
- RB_RIGHT(parent, field) = child; \
- RB_AUGMENT(parent); \
- } else \
- RB_ROOT(head) = child; \
-color: \
- if (color == RB_BLACK) \
- name##_RB_REMOVE_COLOR(head, parent, child); \
- return (old); \
-} \
- \
-/* Inserts a node into the RB tree */ \
-struct type * \
-name##_RB_INSERT(struct name *head, struct type *elm) \
-{ \
- struct type *tmp; \
- struct type *parent = NULL; \
- int comp = 0; \
- tmp = RB_ROOT(head); \
- while (tmp) { \
- parent = tmp; \
- comp = (cmp)(elm, parent); \
- if (comp < 0) \
- tmp = RB_LEFT(tmp, field); \
- else if (comp > 0) \
- tmp = RB_RIGHT(tmp, field); \
- else \
- return (tmp); \
- } \
- RB_SET(elm, parent, field); \
- if (parent != NULL) { \
- if (comp < 0) \
- RB_LEFT(parent, field) = elm; \
- else \
- RB_RIGHT(parent, field) = elm; \
- RB_AUGMENT(parent); \
- } else \
- RB_ROOT(head) = elm; \
- name##_RB_INSERT_COLOR(head, elm); \
- return (NULL); \
-} \
- \
-/* Finds the node with the same key as elm */ \
-struct type * \
-name##_RB_FIND(struct name *head, struct type *elm) \
-{ \
- struct type *tmp = RB_ROOT(head); \
- int comp; \
- while (tmp) { \
- comp = cmp(elm, tmp); \
- if (comp < 0) \
- tmp = RB_LEFT(tmp, field); \
- else if (comp > 0) \
- tmp = RB_RIGHT(tmp, field); \
- else \
- return (tmp); \
- } \
- return (NULL); \
-} \
- \
-struct type * \
-name##_RB_NEXT(struct type *elm) \
-{ \
- if (RB_RIGHT(elm, field)) { \
- elm = RB_RIGHT(elm, field); \
- while (RB_LEFT(elm, field)) \
- elm = RB_LEFT(elm, field); \
- } else { \
- if (RB_PARENT(elm, field) && \
- (elm == RB_LEFT(RB_PARENT(elm, field), field))) \
- elm = RB_PARENT(elm, field); \
- else { \
- while (RB_PARENT(elm, field) && \
- (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\
- elm = RB_PARENT(elm, field); \
- elm = RB_PARENT(elm, field); \
- } \
- } \
- return (elm); \
-} \
- \
-struct type * \
-name##_RB_MINMAX(struct name *head, int val) \
-{ \
- struct type *tmp = RB_ROOT(head); \
- struct type *parent = NULL; \
- while (tmp) { \
- parent = tmp; \
- if (val < 0) \
- tmp = RB_LEFT(tmp, field); \
- else \
- tmp = RB_RIGHT(tmp, field); \
- } \
- return (parent); \
-}
-
-#define RB_NEGINF -1
-#define RB_INF 1
-
-#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y)
-#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y)
-#define RB_FIND(name, x, y) name##_RB_FIND(x, y)
-#define RB_NEXT(name, x, y) name##_RB_NEXT(y)
-#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF)
-#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF)
-
-#define RB_FOREACH(x, name, head) \
- for ((x) = RB_MIN(name, head); \
- (x) != NULL; \
- (x) = name##_RB_NEXT(x))
-
-#endif /* _SYS_TREE_H_ */
diff --git a/contrib/ntp/sntp/libevent/aclocal.m4 b/contrib/ntp/sntp/libevent/aclocal.m4
index 3bba486..4c1c849 100644
--- a/contrib/ntp/sntp/libevent/aclocal.m4
+++ b/contrib/ntp/sntp/libevent/aclocal.m4
@@ -1131,6 +1131,7 @@ AC_SUBST([am__untar])
]) # _AM_PROG_TAR
m4_include([m4/ac_backport_259_ssizet.m4])
+m4_include([m4/acx_pthread.m4])
m4_include([m4/libevent_openssl.m4])
m4_include([m4/libtool.m4])
m4_include([m4/ltoptions.m4])
@@ -1138,5 +1139,3 @@ m4_include([m4/ltsugar.m4])
m4_include([m4/ltversion.m4])
m4_include([m4/lt~obsolete.m4])
m4_include([m4/ntp_pkg_config.m4])
-m4_include([m4/openldap-thread-check.m4])
-m4_include([m4/openldap.m4])
diff --git a/contrib/ntp/sntp/libevent/buffer.c b/contrib/ntp/sntp/libevent/buffer.c
index e603be8..a1a2b98 100644
--- a/contrib/ntp/sntp/libevent/buffer.c
+++ b/contrib/ntp/sntp/libevent/buffer.c
@@ -158,12 +158,20 @@ evbuffer_chain_new(size_t size)
struct evbuffer_chain *chain;
size_t to_alloc;
+ if (size > EVBUFFER_CHAIN_MAX - EVBUFFER_CHAIN_SIZE)
+ return (NULL);
+
size += EVBUFFER_CHAIN_SIZE;
/* get the next largest memory that can hold the buffer */
- to_alloc = MIN_BUFFER_SIZE;
- while (to_alloc < size)
- to_alloc <<= 1;
+ if (size < EVBUFFER_CHAIN_MAX / 2) {
+ to_alloc = MIN_BUFFER_SIZE;
+ while (to_alloc < size) {
+ to_alloc <<= 1;
+ }
+ } else {
+ to_alloc = size;
+ }
/* we get everything in one chunk */
if ((chain = mm_malloc(to_alloc)) == NULL)
@@ -1133,6 +1141,7 @@ evbuffer_drain(struct evbuffer *buf, size_t len)
}
buf->first = chain;
+ EVUTIL_ASSERT(chain && remaining <= chain->off);
chain->misalign += remaining;
chain->off -= remaining;
}
@@ -1181,6 +1190,10 @@ evbuffer_copyout_from(struct evbuffer *buf, const struct evbuffer_ptr *pos,
EVBUFFER_LOCK(buf);
if (pos) {
+ if (datlen > (size_t)(EV_SSIZE_MAX - pos->pos)) {
+ result = -1;
+ goto done;
+ }
chain = pos->internal_.chain;
pos_in_chain = pos->internal_.pos_in_chain;
if (datlen + pos->pos > buf->total_len)
@@ -1218,6 +1231,8 @@ evbuffer_copyout_from(struct evbuffer *buf, const struct evbuffer_ptr *pos,
if (datlen) {
EVUTIL_ASSERT(chain);
+ EVUTIL_ASSERT(datlen+pos_in_chain <= chain->off);
+
memcpy(data, chain->buffer + chain->misalign + pos_in_chain,
datlen);
}
@@ -1712,6 +1727,10 @@ evbuffer_add(struct evbuffer *buf, const void *data_in, size_t datlen)
if (buf->freeze_end) {
goto done;
}
+ /* Prevent buf->total_len overflow */
+ if (datlen > EV_SIZE_MAX - buf->total_len) {
+ goto done;
+ }
chain = buf->last;
@@ -1725,7 +1744,10 @@ evbuffer_add(struct evbuffer *buf, const void *data_in, size_t datlen)
}
if ((chain->flags & EVBUFFER_IMMUTABLE) == 0) {
- remain = (size_t)(chain->buffer_len - chain->misalign - chain->off);
+ /* Always true for mutable buffers */
+ EVUTIL_ASSERT(chain->misalign >= 0 &&
+ (ev_uint64_t)chain->misalign <= EVBUFFER_CHAIN_MAX);
+ remain = chain->buffer_len - (size_t)chain->misalign - chain->off;
if (remain >= datlen) {
/* there's enough space to hold all the data in the
* current last chain */
@@ -1796,6 +1818,9 @@ evbuffer_prepend(struct evbuffer *buf, const void *data, size_t datlen)
if (buf->freeze_start) {
goto done;
}
+ if (datlen > EV_SIZE_MAX - buf->total_len) {
+ goto done;
+ }
chain = buf->first;
@@ -1808,6 +1833,10 @@ evbuffer_prepend(struct evbuffer *buf, const void *data, size_t datlen)
/* we cannot touch immutable buffers */
if ((chain->flags & EVBUFFER_IMMUTABLE) == 0) {
+ /* Always true for mutable buffers */
+ EVUTIL_ASSERT(chain->misalign >= 0 &&
+ (ev_uint64_t)chain->misalign <= EVBUFFER_CHAIN_MAX);
+
/* If this chain is empty, we can treat it as
* 'empty at the beginning' rather than 'empty at the end' */
if (chain->off == 0)
@@ -1845,6 +1874,7 @@ evbuffer_prepend(struct evbuffer *buf, const void *data, size_t datlen)
tmp->next = chain;
tmp->off = datlen;
+ EVUTIL_ASSERT(datlen <= tmp->buffer_len);
tmp->misalign = tmp->buffer_len - datlen;
memcpy(tmp->buffer + tmp->misalign, data, datlen);
@@ -1943,7 +1973,9 @@ evbuffer_expand_singlechain(struct evbuffer *buf, size_t datlen)
/* Would expanding this chunk be affordable and worthwhile? */
if (CHAIN_SPACE_LEN(chain) < chain->buffer_len / 8 ||
- chain->off > MAX_TO_COPY_IN_EXPAND) {
+ chain->off > MAX_TO_COPY_IN_EXPAND ||
+ (datlen < EVBUFFER_CHAIN_MAX &&
+ EVBUFFER_CHAIN_MAX - datlen >= chain->off)) {
/* It's not worth resizing this chain. Can the next one be
* used? */
if (chain->next && CHAIN_SPACE_LEN(chain->next) >= datlen) {
@@ -2071,6 +2103,8 @@ evbuffer_expand_fast_(struct evbuffer *buf, size_t datlen, int n)
rmv_all = 1;
avail = 0;
} else {
+ /* can't overflow, since only mutable chains have
+ * huge misaligns. */
avail = (size_t) CHAIN_SPACE_LEN(chain);
chain = chain->next;
}
@@ -2081,6 +2115,7 @@ evbuffer_expand_fast_(struct evbuffer *buf, size_t datlen, int n)
EVUTIL_ASSERT(chain->off == 0);
evbuffer_chain_free(chain);
}
+ EVUTIL_ASSERT(datlen >= avail);
tmp = evbuffer_chain_new(datlen - avail);
if (tmp == NULL) {
if (rmv_all) {
@@ -2210,6 +2245,7 @@ get_n_bytes_readable_on_socket(evutil_socket_t fd)
unsigned long lng = EVBUFFER_MAX_READ;
if (ioctlsocket(fd, FIONREAD, &lng) < 0)
return -1;
+ /* Can overflow, but mostly harmlessly. XXXX */
return (int)lng;
#elif defined(FIONREAD)
int n = EVBUFFER_MAX_READ;
@@ -2322,8 +2358,14 @@ evbuffer_read(struct evbuffer *buf, evutil_socket_t fd, int howmuch)
#ifdef USE_IOVEC_IMPL
remaining = n;
for (i=0; i < nvecs; ++i) {
- ev_ssize_t space = (ev_ssize_t) CHAIN_SPACE_LEN(*chainp);
- if (space < remaining) {
+ /* can't overflow, since only mutable chains have
+ * huge misaligns. */
+ size_t space = (size_t) CHAIN_SPACE_LEN(*chainp);
+ /* XXXX This is a kludge that can waste space in perverse
+ * situations. */
+ if (space > EVBUFFER_CHAIN_MAX)
+ space = EVBUFFER_CHAIN_MAX;
+ if ((ev_ssize_t)space < remaining) {
(*chainp)->off += space;
remaining -= (int)space;
} else {
@@ -2485,9 +2527,11 @@ evbuffer_write_atmost(struct evbuffer *buffer, evutil_socket_t fd,
/* XXX(nickm) Don't disable this code until we know if
* the WSARecv code above works. */
void *p = evbuffer_pullup(buffer, howmuch);
+ EVUTIL_ASSERT(p || !howmuch);
n = send(fd, p, howmuch, 0);
#else
void *p = evbuffer_pullup(buffer, howmuch);
+ EVUTIL_ASSERT(p || !howmuch);
n = write(fd, p, howmuch);
#endif
#ifdef USE_SENDFILE
@@ -2538,6 +2582,8 @@ static int
evbuffer_ptr_subtract(struct evbuffer *buf, struct evbuffer_ptr *pos,
size_t howfar)
{
+ if (pos->pos < 0)
+ return -1;
if (howfar > (size_t)pos->pos)
return -1;
if (pos->internal_.chain && howfar <= pos->internal_.pos_in_chain) {
@@ -2571,12 +2617,17 @@ evbuffer_ptr_set(struct evbuffer *buf, struct evbuffer_ptr *pos,
case EVBUFFER_PTR_ADD:
/* this avoids iterating over all previous chains if
we just want to advance the position */
+ if (pos->pos < 0 || EV_SIZE_MAX - position < (size_t)pos->pos) {
+ EVBUFFER_UNLOCK(buf);
+ return -1;
+ }
chain = pos->internal_.chain;
pos->pos += position;
position = pos->internal_.pos_in_chain;
break;
}
+ EVUTIL_ASSERT(EV_SIZE_MAX - left >= position);
while (chain && position + left >= chain->off) {
left -= chain->off - position;
chain = chain->next;
@@ -2613,7 +2664,9 @@ evbuffer_ptr_memcmp(const struct evbuffer *buf, const struct evbuffer_ptr *pos,
ASSERT_EVBUFFER_LOCKED(buf);
- if (pos->pos + len > buf->total_len)
+ if (pos->pos < 0 ||
+ EV_SIZE_MAX - len < (size_t)pos->pos ||
+ pos->pos + len > buf->total_len)
return -1;
chain = pos->internal_.chain;
@@ -2740,7 +2793,10 @@ evbuffer_peek(struct evbuffer *buffer, ev_ssize_t len,
if (n_vec == 0 && len < 0) {
/* If no vectors are provided and they asked for "everything",
* pretend they asked for the actual available amount. */
- len = buffer->total_len - len_so_far;
+ len = buffer->total_len;
+ if (start_at) {
+ len -= start_at->pos;
+ }
}
while (chain) {
@@ -2804,6 +2860,9 @@ evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap)
if (sz < 0)
goto done;
+ if (INT_MAX >= EVBUFFER_CHAIN_MAX &&
+ (size_t)sz >= EVBUFFER_CHAIN_MAX)
+ goto done;
if ((size_t)sz < space) {
chain->off += sz;
buf->total_len += sz;
@@ -2913,6 +2972,11 @@ evbuffer_file_segment_new(
}
seg->length = length;
+ if (offset < 0 || length < 0 ||
+ ((ev_uint64_t)length > EVBUFFER_CHAIN_MAX) ||
+ (ev_uint64_t)offset > (ev_uint64_t)(EVBUFFER_CHAIN_MAX - length))
+ goto err;
+
#if defined(USE_SENDFILE)
if (!(flags & EVBUF_FS_DISABLE_SENDFILE)) {
seg->can_sendfile = 1;
@@ -3201,7 +3265,7 @@ evbuffer_add_file_segment(struct evbuffer *buf,
return 0;
err:
EVBUFFER_UNLOCK(buf);
- evbuffer_file_segment_free(seg);
+ evbuffer_file_segment_free(seg); /* Lowers the refcount */
return -1;
}
diff --git a/contrib/ntp/sntp/libevent/bufferevent.c b/contrib/ntp/sntp/libevent/bufferevent.c
index 588461a..d298d0b 100644
--- a/contrib/ntp/sntp/libevent/bufferevent.c
+++ b/contrib/ntp/sntp/libevent/bufferevent.c
@@ -599,7 +599,7 @@ bufferevent_setwatermark(struct bufferevent *bufev, short events,
bufev_private->read_watermarks_cb,
EVBUFFER_CB_ENABLED|EVBUFFER_CB_NODEFER);
- if (evbuffer_get_length(bufev->input) > highmark)
+ if (evbuffer_get_length(bufev->input) >= highmark)
bufferevent_wm_suspend_read(bufev);
else if (evbuffer_get_length(bufev->input) < highmark)
bufferevent_wm_unsuspend_read(bufev);
@@ -615,25 +615,30 @@ bufferevent_setwatermark(struct bufferevent *bufev, short events,
BEV_UNLOCK(bufev);
}
-void
+int
bufferevent_getwatermark(struct bufferevent *bufev, short events,
size_t *lowmark, size_t *highmark)
{
- BEV_LOCK(bufev);
if (events == EV_WRITE) {
+ BEV_LOCK(bufev);
if (lowmark)
*lowmark = bufev->wm_write.low;
if (highmark)
*highmark = bufev->wm_write.high;
+ BEV_UNLOCK(bufev);
+ return 0;
}
if (events == EV_READ) {
+ BEV_LOCK(bufev);
if (lowmark)
*lowmark = bufev->wm_read.low;
if (highmark)
*highmark = bufev->wm_read.high;
+ BEV_UNLOCK(bufev);
+ return 0;
}
- BEV_UNLOCK(bufev);
+ return -1;
}
int
diff --git a/contrib/ntp/sntp/libevent/bufferevent_async.c b/contrib/ntp/sntp/libevent/bufferevent_async.c
index 137ad24..6395e57 100644
--- a/contrib/ntp/sntp/libevent/bufferevent_async.c
+++ b/contrib/ntp/sntp/libevent/bufferevent_async.c
@@ -381,9 +381,10 @@ be_async_destruct(struct bufferevent *bev)
bev_async_del_write(bev_async);
fd = evbuffer_overlapped_get_fd_(bev->input);
- if (bev_p->options & BEV_OPT_CLOSE_ON_FREE) {
- /* XXXX possible double-close */
+ if (fd != (evutil_socket_t)INVALID_SOCKET &&
+ (bev_p->options & BEV_OPT_CLOSE_ON_FREE)) {
evutil_closesocket(fd);
+ evbuffer_overlapped_set_fd_(bev->input, INVALID_SOCKET);
}
}
@@ -564,9 +565,9 @@ bufferevent_async_new_(struct event_base *base,
event_overlapped_init_(&bev_a->read_overlapped, read_complete);
event_overlapped_init_(&bev_a->write_overlapped, write_complete);
+ bufferevent_init_generic_timeout_cbs_(bev);
+
bev_a->ok = fd >= 0;
- if (bev_a->ok)
- bufferevent_init_generic_timeout_cbs_(bev);
return bev;
err:
@@ -671,6 +672,7 @@ be_async_ctrl(struct bufferevent *bev, enum bufferevent_ctrl_op op,
if (fd != (evutil_socket_t)INVALID_SOCKET &&
(bev_a->bev.options & BEV_OPT_CLOSE_ON_FREE)) {
closesocket(fd);
+ evbuffer_overlapped_set_fd_(bev->input, INVALID_SOCKET);
}
bev_a->ok = 0;
return 0;
diff --git a/contrib/ntp/sntp/libevent/bufferevent_filter.c b/contrib/ntp/sntp/libevent/bufferevent_filter.c
index af71ebe..4d9be43 100644
--- a/contrib/ntp/sntp/libevent/bufferevent_filter.c
+++ b/contrib/ntp/sntp/libevent/bufferevent_filter.c
@@ -425,26 +425,34 @@ be_filter_readcb(struct bufferevent *underlying, void *me_)
enum bufferevent_filter_result res;
enum bufferevent_flush_mode state;
struct bufferevent *bufev = downcast(bevf);
+ struct bufferevent_private *bufev_private = BEV_UPCAST(bufev);
int processed_any = 0;
- bufferevent_incref_and_lock_(bufev);
+ BEV_LOCK(bufev);
- if (bevf->got_eof)
- state = BEV_FINISHED;
- else
- state = BEV_NORMAL;
+ // It's possible our refcount is 0 at this point if another thread free'd our filterevent
+ EVUTIL_ASSERT(bufev_private->refcnt >= 0);
- /* XXXX use return value */
- res = be_filter_process_input(bevf, state, &processed_any);
- (void)res;
+ // If our refcount is > 0
+ if (bufev_private->refcnt > 0) {
- /* XXX This should be in process_input, not here. There are
- * other places that can call process-input, and they should
- * force readcb calls as needed. */
- if (processed_any)
- bufferevent_trigger_nolock_(bufev, EV_READ, 0);
+ if (bevf->got_eof)
+ state = BEV_FINISHED;
+ else
+ state = BEV_NORMAL;
- bufferevent_decref_and_unlock_(bufev);
+ /* XXXX use return value */
+ res = be_filter_process_input(bevf, state, &processed_any);
+ (void)res;
+
+ /* XXX This should be in process_input, not here. There are
+ * other places that can call process-input, and they should
+ * force readcb calls as needed. */
+ if (processed_any)
+ bufferevent_trigger_nolock_(bufev, EV_READ, 0);
+ }
+
+ BEV_UNLOCK(bufev);
}
/* Called when the underlying socket has drained enough that we can write to
@@ -454,11 +462,20 @@ be_filter_writecb(struct bufferevent *underlying, void *me_)
{
struct bufferevent_filtered *bevf = me_;
struct bufferevent *bev = downcast(bevf);
+ struct bufferevent_private *bufev_private = BEV_UPCAST(bev);
int processed_any = 0;
- bufferevent_incref_and_lock_(bev);
- be_filter_process_output(bevf, BEV_NORMAL, &processed_any);
- bufferevent_decref_and_unlock_(bev);
+ BEV_LOCK(bev);
+
+ // It's possible our refcount is 0 at this point if another thread free'd our filterevent
+ EVUTIL_ASSERT(bufev_private->refcnt >= 0);
+
+ // If our refcount is > 0
+ if (bufev_private->refcnt > 0) {
+ be_filter_process_output(bevf, BEV_NORMAL, &processed_any);
+ }
+
+ BEV_UNLOCK(bev);
}
/* Called when the underlying socket has given us an error */
@@ -467,11 +484,21 @@ be_filter_eventcb(struct bufferevent *underlying, short what, void *me_)
{
struct bufferevent_filtered *bevf = me_;
struct bufferevent *bev = downcast(bevf);
+ struct bufferevent_private *bufev_private = BEV_UPCAST(bev);
+
+ BEV_LOCK(bev);
+
+ // It's possible our refcount is 0 at this point if another thread free'd our filterevent
+ EVUTIL_ASSERT(bufev_private->refcnt >= 0);
+
+ // If our refcount is > 0
+ if (bufev_private->refcnt > 0) {
+
+ /* All we can really to is tell our own eventcb. */
+ bufferevent_run_eventcb_(bev, what, 0);
+ }
- bufferevent_incref_and_lock_(bev);
- /* All we can really to is tell our own eventcb. */
- bufferevent_run_eventcb_(bev, what, 0);
- bufferevent_decref_and_unlock_(bev);
+ BEV_UNLOCK(bev);
}
static int
diff --git a/contrib/ntp/sntp/libevent/bufferevent_openssl.c b/contrib/ntp/sntp/libevent/bufferevent_openssl.c
index 423b34f..b30f90f 100644
--- a/contrib/ntp/sntp/libevent/bufferevent_openssl.c
+++ b/contrib/ntp/sntp/libevent/bufferevent_openssl.c
@@ -1276,6 +1276,8 @@ be_openssl_ctrl(struct bufferevent *bev,
SSL_set_bio(bev_ssl->ssl, bio, bio);
bev_ssl->fd_is_set = 1;
}
+ if (data->fd == -1)
+ bev_ssl->fd_is_set = 0;
if (bev_ssl->state == BUFFEREVENT_SSL_OPEN)
return set_open_callbacks(bev_ssl, data->fd);
else {
diff --git a/contrib/ntp/sntp/libevent/bufferevent_pair.c b/contrib/ntp/sntp/libevent/bufferevent_pair.c
index 4340f23..8154e17 100644
--- a/contrib/ntp/sntp/libevent/bufferevent_pair.c
+++ b/contrib/ntp/sntp/libevent/bufferevent_pair.c
@@ -45,6 +45,8 @@
struct bufferevent_pair {
struct bufferevent_private bev;
struct bufferevent_pair *partner;
+ /* For ->destruct() lock checking */
+ struct bufferevent_pair *unlinked_partner;
};
@@ -265,11 +267,40 @@ be_pair_unlink(struct bufferevent *bev)
struct bufferevent_pair *bev_p = upcast(bev);
if (bev_p->partner) {
+ bev_p->unlinked_partner = bev_p->partner;
bev_p->partner->partner = NULL;
bev_p->partner = NULL;
}
}
+/* Free *shared* lock in the latest be (since we share it between two of them). */
+static void
+be_pair_destruct(struct bufferevent *bev)
+{
+ struct bufferevent_pair *bev_p = upcast(bev);
+
+ /* Transfer ownership of the lock into partner, otherwise we will use
+ * already free'd lock during freeing second bev, see next example:
+ *
+ * bev1->own_lock = 1
+ * bev2->own_lock = 0
+ * bev2->lock = bev1->lock
+ *
+ * bufferevent_free(bev1) # refcnt == 0 -> unlink
+ * bufferevent_free(bev2) # refcnt == 0 -> unlink
+ *
+ * event_base_free() -> finilizers -> EVTHREAD_FREE_LOCK(bev1->lock)
+ * -> BEV_LOCK(bev2->lock) <-- already freed
+ *
+ * Where bev1 == pair[0], bev2 == pair[1].
+ */
+ if (bev_p->unlinked_partner && bev_p->bev.own_lock) {
+ bev_p->unlinked_partner->bev.own_lock = 1;
+ bev_p->bev.own_lock = 0;
+ }
+ bev_p->unlinked_partner = NULL;
+}
+
static int
be_pair_flush(struct bufferevent *bev, short iotype,
enum bufferevent_flush_mode mode)
@@ -320,7 +351,7 @@ const struct bufferevent_ops bufferevent_ops_pair = {
be_pair_enable,
be_pair_disable,
be_pair_unlink,
- NULL, /* be_pair_destruct, */
+ be_pair_destruct,
bufferevent_generic_adj_timeouts_,
be_pair_flush,
NULL, /* ctrl */
diff --git a/contrib/ntp/sntp/libevent/config.h.in b/contrib/ntp/sntp/libevent/config.h.in
index 7446676..946b11a 100644
--- a/contrib/ntp/sntp/libevent/config.h.in
+++ b/contrib/ntp/sntp/libevent/config.h.in
@@ -24,9 +24,6 @@
/* Define to 1 if you have the `clock_gettime' function. */
#undef HAVE_CLOCK_GETTIME
-/* Define to 1 if you have the <cthreads.h> header file. */
-#undef HAVE_CTHREADS_H
-
/* Define to 1 if you have the declaration of `CTL_KERN', and to 0 if you
don't. */
#undef HAVE_DECL_CTL_KERN
@@ -109,9 +106,6 @@
/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
-/* if you have GNU Pth */
-#undef HAVE_GNU_PTH
-
/* Define to 1 if you have the <ifaddrs.h> header file. */
#undef HAVE_IFADDRS_H
@@ -133,24 +127,9 @@
/* Define if the system has zlib */
#undef HAVE_LIBZ
-/* if you have LinuxThreads */
-#undef HAVE_LINUX_THREADS
-
-/* if you have SunOS LWP package */
-#undef HAVE_LWP
-
-/* Define to 1 if you have the <lwp/lwp.h> header file. */
-#undef HAVE_LWP_LWP_H
-
/* Define to 1 if you have the `mach_absolute_time' function. */
#undef HAVE_MACH_ABSOLUTE_TIME
-/* define if you have Mach Cthreads */
-#undef HAVE_MACH_CTHREADS
-
-/* Define to 1 if you have the <mach/cthreads.h> header file. */
-#undef HAVE_MACH_CTHREADS_H
-
/* Define to 1 if you have the <mach/mach_time.h> header file. */
#undef HAVE_MACH_MACH_TIME_H
@@ -175,15 +154,6 @@
/* Define to 1 if you have the <netinet/tcp.h> header file. */
#undef HAVE_NETINET_TCP_H
-/* if you have NT Event Log */
-#undef HAVE_NT_EVENT_LOG
-
-/* if you have NT Service Manager */
-#undef HAVE_NT_SERVICE_MANAGER
-
-/* if you have NT Threads */
-#undef HAVE_NT_THREADS
-
/* Define if the system has openssl */
#undef HAVE_OPENSSL
@@ -208,48 +178,15 @@
/* Define if you have POSIX threads libraries and header files. */
#undef HAVE_PTHREAD
-/* define to pthreads API spec revision */
+/* Define if we have pthreads on this system */
#undef HAVE_PTHREADS
-/* define if you have pthread_detach function */
-#undef HAVE_PTHREAD_DETACH
-
-/* Define to 1 if you have the `pthread_getconcurrency' function. */
-#undef HAVE_PTHREAD_GETCONCURRENCY
-
-/* Define to 1 if you have the <pthread.h> header file. */
-#undef HAVE_PTHREAD_H
-
-/* Define to 1 if you have the `pthread_kill' function. */
-#undef HAVE_PTHREAD_KILL
-
-/* Define to 1 if you have the `pthread_kill_other_threads_np' function. */
-#undef HAVE_PTHREAD_KILL_OTHER_THREADS_NP
-
-/* define if you have pthread_rwlock_destroy function */
-#undef HAVE_PTHREAD_RWLOCK_DESTROY
-
-/* Define to 1 if you have the `pthread_setconcurrency' function. */
-#undef HAVE_PTHREAD_SETCONCURRENCY
-
-/* Define to 1 if you have the `pthread_yield' function. */
-#undef HAVE_PTHREAD_YIELD
-
-/* Define to 1 if you have the <pth.h> header file. */
-#undef HAVE_PTH_H
-
/* Define to 1 if you have the `putenv' function. */
#undef HAVE_PUTENV
/* Define to 1 if the system has the type `sa_family_t'. */
#undef HAVE_SA_FAMILY_T
-/* Define to 1 if you have the <sched.h> header file. */
-#undef HAVE_SCHED_H
-
-/* Define to 1 if you have the `sched_yield' function. */
-#undef HAVE_SCHED_YIELD
-
/* Define to 1 if you have the `select' function. */
#undef HAVE_SELECT
@@ -337,9 +274,6 @@
/* Define to 1 if the system has the type `struct so_linger'. */
#undef HAVE_STRUCT_SO_LINGER
-/* Define to 1 if you have the <synch.h> header file. */
-#undef HAVE_SYNCH_H
-
/* Define to 1 if you have the `sysctl' function. */
#undef HAVE_SYSCTL
@@ -403,21 +337,6 @@
/* Define if TAILQ_FOREACH is defined in <sys/queue.h> */
#undef HAVE_TAILQFOREACH
-/* if you have Solaris LWP (thr) package */
-#undef HAVE_THR
-
-/* Define to 1 if you have the <thread.h> header file. */
-#undef HAVE_THREAD_H
-
-/* Define to 1 if you have the `thr_getconcurrency' function. */
-#undef HAVE_THR_GETCONCURRENCY
-
-/* Define to 1 if you have the `thr_setconcurrency' function. */
-#undef HAVE_THR_SETCONCURRENCY
-
-/* Define to 1 if you have the `thr_yield' function. */
-#undef HAVE_THR_YIELD
-
/* Define if timeradd is defined in <sys/time.h> */
#undef HAVE_TIMERADD
@@ -466,15 +385,9 @@
/* Define if kqueue works correctly with pipes */
#undef HAVE_WORKING_KQUEUE
-/* define if select implicitly yields */
-#undef HAVE_YIELDING_SELECT
-
/* Define to 1 if you have the <zlib.h> header file. */
#undef HAVE_ZLIB_H
-/* define to 1 if library is thread safe */
-#undef LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE
-
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
@@ -482,9 +395,6 @@
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
-/* define if you have (or want) no threads */
-#undef NO_THREADS
-
/* Numeric representation of the version */
#undef NUMERIC_VERSION
@@ -509,11 +419,9 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
-/* enable thread safety */
-#undef REENTRANT
-
-/* define if sched_yield yields the entire process */
-#undef REPLACE_BROKEN_YIELD
+/* Define to necessary symbol if this constant uses a non-standard name on
+ your system. */
+#undef PTHREAD_CREATE_JOINABLE
/* The size of `int', as computed by sizeof. */
#undef SIZEOF_INT
@@ -542,12 +450,6 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
-/* enable thread safety */
-#undef THREADSAFE
-
-/* enable thread safety */
-#undef THREAD_SAFE
-
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
@@ -570,18 +472,6 @@
/* Define to 1 if you need to in order for `stat' and other things to work. */
#undef _POSIX_SOURCE
-/* enable thread safety */
-#undef _REENTRANT
-
-/* enable thread safety */
-#undef _SGI_MP_SOURCE
-
-/* enable thread safety */
-#undef _THREADSAFE
-
-/* enable thread safety */
-#undef _THREAD_SAFE
-
/* Define to 500 only on HP-UX. */
#undef _XOPEN_SOURCE
diff --git a/contrib/ntp/sntp/libevent/configure b/contrib/ntp/sntp/libevent/configure
index 09d6eed..d2c0780 100755
--- a/contrib/ntp/sntp/libevent/configure
+++ b/contrib/ntp/sntp/libevent/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for libevent 2.1.3-alpha-dev.
+# Generated by GNU Autoconf 2.68 for libevent 2.1.5-beta.
#
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -567,8 +567,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='libevent'
PACKAGE_TARNAME='libevent'
-PACKAGE_VERSION='2.1.3-alpha-dev'
-PACKAGE_STRING='libevent 2.1.3-alpha-dev'
+PACKAGE_VERSION='2.1.5-beta'
+PACKAGE_STRING='libevent 2.1.5-beta'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -619,6 +619,8 @@ PTHREADS_FALSE
PTHREADS_TRUE
PTHREAD_CFLAGS
PTHREAD_LIBS
+PTHREAD_CC
+acx_pthread_config
SIGNAL_SUPPORT_FALSE
SIGNAL_SUPPORT_TRUE
EVPORT_BACKEND_FALSE
@@ -655,6 +657,8 @@ ZLIB_REGRESS_TRUE
ZLIB_LIBS
BUILD_REGRESS_FALSE
BUILD_REGRESS_TRUE
+BUILD_SAMPLES_FALSE
+BUILD_SAMPLES_TRUE
LIBTOOL_DEPS
OTOOL64
OTOOL
@@ -778,6 +782,7 @@ enable_openssl
enable_debug_mode
enable_libevent_install
enable_libevent_regress
+enable_samples
enable_function_sections
enable_verbose_debug
enable_shared
@@ -788,8 +793,6 @@ with_gnu_ld
with_sysroot
enable_libtool_lock
enable_largefile
-with_threads
-with_yielding_select
'
ac_precious_vars='build_alias
host_alias
@@ -1342,7 +1345,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures libevent 2.1.3-alpha-dev to adapt to many kinds of systems.
+\`configure' configures libevent 2.1.5-beta to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1412,7 +1415,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of libevent 2.1.3-alpha-dev:";;
+ short | recursive ) echo "Configuration of libevent 2.1.5-beta:";;
esac
cat <<\_ACEOF
@@ -1437,6 +1440,8 @@ Optional Features:
--disable-libevent-regress, skip regress in make check
+ --disable-samples, skip building of sample programs
+
--enable-function-sections, make static library allow smaller binaries with --gc-sections
--enable-verbose-debug, verbose debug logging
@@ -1456,8 +1461,6 @@ Optional Packages:
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-sysroot=DIR Search for dependent libraries within DIR
(or the compiler's sysroot if not specified).
- --with-threads with threads [auto]
- --with-yielding-select with yielding select [auto]
Some influential environment variables:
CC C compiler command
@@ -1535,7 +1538,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-libevent configure 2.1.3-alpha-dev
+libevent configure 2.1.5-beta
generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
@@ -2235,7 +2238,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by libevent $as_me 2.1.3-alpha-dev, which was
+It was created by libevent $as_me 2.1.5-beta, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@
@@ -2616,7 +2619,6 @@ ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
-
am__api_version='1.11'
# Find a good install program. We prefer a C program (faster),
@@ -3055,7 +3057,7 @@ fi
# Define the identity of the package.
PACKAGE='libevent'
- VERSION='2.1.3-alpha-dev'
+ VERSION='2.1.5-beta'
cat >>confdefs.h <<_ACEOF
@@ -3110,7 +3112,7 @@ AM_BACKSLASH='\'
ac_config_headers="$ac_config_headers config.h evconfig-private.h:evconfig-private.h.in"
-$as_echo "#define NUMERIC_VERSION 0x02010301" >>confdefs.h
+$as_echo "#define NUMERIC_VERSION 0x02010500" >>confdefs.h
if test "$prefix" = "NONE"; then
@@ -5004,6 +5006,13 @@ else
enable_libevent_regress=yes
fi
+# Check whether --enable-samples was given.
+if test "${enable_samples+set}" = set; then :
+ enableval=$enable_samples;
+else
+ enable_samples=yes
+fi
+
# Check whether --enable-function-sections was given.
if test "${enable_function_sections+set}" = set; then :
enableval=$enable_function_sections;
@@ -12071,6 +12080,14 @@ CC="$lt_save_CC"
+ if test "$enable_samples" = "yes"; then
+ BUILD_SAMPLES_TRUE=
+ BUILD_SAMPLES_FALSE='#'
+else
+ BUILD_SAMPLES_TRUE='#'
+ BUILD_SAMPLES_FALSE=
+fi
+
if test "$enable_libevent_regress" = "yes"; then
BUILD_REGRESS_TRUE=
BUILD_REGRESS_FALSE='#'
@@ -14825,58 +14842,127 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
-# OpenLDAP --with-threads
-
-# Check whether --with-threads was given.
-if test "${with_threads+set}" = set; then :
- withval=$with_threads;
- ol_arg=invalid
- for ol_val in auto nt posix mach pth lwp yes no manual ; do
- if test "$withval" = "$ol_val" ; then
- ol_arg="$ol_val"
- fi
- done
- if test "$ol_arg" = "invalid" ; then
- as_fn_error $? "bad value $withval for --with-threads" "$LINENO" 5
- fi
- ol_with_threads="$ol_arg"
+acx_pthread_ok=no
+
+# We used to check for pthread.h first, but this fails if pthread.h
+# requires special compiler flags (e.g. on True64 or Sequent).
+# It gets checked for in the link test anyway.
+
+# First of all, check if the user has set any of the PTHREAD_LIBS,
+# etcetera environment variables, and if threads linking works using
+# them:
+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5
+$as_echo_n "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... " >&6; }
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
-else
- ol_with_threads="auto"
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pthread_join ();
+int
+main ()
+{
+return pthread_join ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ acx_pthread_ok=yes
fi
-# end --with-threads
-
-
-case "$ol_with_threads$host" in
- auto*-*-solaris2.[0-6])
- ol_with_threads=no
- ;;
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5
+$as_echo "$acx_pthread_ok" >&6; }
+ if test x"$acx_pthread_ok" = xno; then
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
+ fi
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+fi
+
+# We must check for the threads library under a number of different
+# names; the ordering is very important because some systems
+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+# libraries is broken (non-POSIX).
+
+# Create a list of thread flags to try. Items starting with a "-" are
+# C compiler flags, and other items are library names, except for "none"
+# which indicates that we try without any flags at all, and "pthread-config"
+# which is a program returning the flags for the Pth emulation library.
+
+acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+
+# The ordering *is* (sometimes) important. Some notes on the
+# individual items follow:
+
+# pthreads: AIX (must check this before -lpthread)
+# none: in case threads are in libc; should be tried before -Kthread and
+# other compiler flags to prevent continual compiler warnings
+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
+# -pthreads: Solaris/gcc
+# -mthreads: Mingw32/gcc, Lynx/gcc
+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+# doesn't hurt to check since this sometimes defines pthreads too;
+# also defines -D_REENTRANT)
+# ... -mt is also the pthreads flag for HP/aCC
+# pthread: Linux, etcetera
+# --thread-safe: KAI C++
+# pthread-config: use pthread-config program (for GNU Pth library)
+
+case "${host_cpu}-${host_os}" in
+ *solaris*)
+
+ # On Solaris (at least, for some versions), libc contains stubbed
+ # (non-functional) versions of the pthreads routines, so link-based
+ # tests will erroneously succeed. (We need to link with -pthreads/-mt/
+ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
+ # a function called by this macro, so we could check for that, but
+ # who knows whether they'll stub that too in a future libc.) So,
+ # we'll just look for -pthreads and -lpthread first:
+
+ acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
+ ;;
esac
+if test x"$acx_pthread_ok" = xno; then
+for flag in $acx_pthread_flags; do
-ol_aix_threads=no
-case "$host" in
-*-*-aix*) if test -z "$CC" ; then
- case "$ol_with_threads" in
- auto | yes | posix) ol_aix_threads=yes ;;
- esac
- fi
-;;
-esac
+ case $flag in
+ none)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work without any flags" >&5
+$as_echo_n "checking whether pthreads work without any flags... " >&6; }
+ ;;
-if test $ol_aix_threads = yes ; then
- if test -z "${CC}" ; then
- for ac_prog in cc_r xlc_r cc
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
+ -*)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $flag" >&5
+$as_echo_n "checking whether pthreads work with $flag... " >&6; }
+ PTHREAD_CFLAGS="$flag"
+ ;;
+
+ pthread-config)
+ # Extract the first word of "pthread-config", so it can be a program name with args.
+set dummy pthread-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
+if ${ac_cv_prog_acx_pthread_config+:} false; then :
$as_echo_n "(cached) " >&6
else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
+ if test -n "$acx_pthread_config"; then
+ ac_cv_prog_acx_pthread_config="$acx_pthread_config" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
@@ -14885,7 +14971,7 @@ do
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_prog_CC="$ac_prog"
+ ac_cv_prog_acx_pthread_config="yes"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
@@ -14893,4378 +14979,210 @@ done
done
IFS=$as_save_IFS
+ test -z "$ac_cv_prog_acx_pthread_config" && ac_cv_prog_acx_pthread_config="no"
fi
fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
+acx_pthread_config=$ac_cv_prog_acx_pthread_config
+if test -n "$acx_pthread_config"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_config" >&5
+$as_echo "$acx_pthread_config" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
- test -n "$CC" && break
-done
-
-
- if test "$CC" = cc ; then
- if test $ol_with_threads != auto ; then
- as_fn_error $? "--with-threads requires cc_r (or other suitable compiler) on AIX" "$LINENO" 5
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: disabling threads, no cc_r on AIX" >&5
-$as_echo "$as_me: WARNING: disabling threads, no cc_r on AIX" >&2;}
- fi
- ol_with_threads=no
- fi
- fi
-
- case ${CC} in cc_r | xlc_r)
- ol_with_threads=posix
- ol_cv_pthread_create=yes
+ if test x"$acx_pthread_config" = xno; then continue; fi
+ PTHREAD_CFLAGS="`pthread-config --cflags`"
+ PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
;;
- esac
-fi
-
-ol_link_threads=no
-# OpenLDAP --with-yielding_select
-
-# Check whether --with-yielding_select was given.
-if test "${with_yielding_select+set}" = set; then :
- withval=$with_yielding_select;
- ol_arg=invalid
- for ol_val in auto yes no manual ; do
- if test "$withval" = "$ol_val" ; then
- ol_arg="$ol_val"
- fi
- done
- if test "$ol_arg" = "invalid" ; then
- as_fn_error $? "bad value $withval for --with-yielding_select" "$LINENO" 5
- fi
- ol_with_yielding_select="$ol_arg"
-
-else
- ol_with_yielding_select="auto"
-fi
-# end --with-yielding_select
-
-
-case $ol_with_threads in auto | yes | nt)
-
-
- ac_fn_c_check_func "$LINENO" "_beginthread" "ac_cv_func__beginthread"
-if test "x$ac_cv_func__beginthread" = xyes; then :
-
-fi
-
-
- if test $ac_cv_func__beginthread = yes ; then
-
-$as_echo "#define HAVE_NT_THREADS 1" >>confdefs.h
-
- ol_cv_nt_threads=yes
- fi
-
-
- if test "$ol_cv_nt_threads" = yes ; then
- ol_link_threads=nt
- ol_with_threads=found
- ol_with_yielding_select=yes
-
-
-$as_echo "#define HAVE_NT_SERVICE_MANAGER 1" >>confdefs.h
-
-
-$as_echo "#define HAVE_NT_EVENT_LOG 1" >>confdefs.h
-
- fi
-
- if test $ol_with_threads = nt ; then
- as_fn_error $? "could not locate NT Threads" "$LINENO" 5
- fi
- ;;
-esac
-
-case $ol_with_threads in auto | yes | posix)
-
- for ac_header in pthread.h
-do :
- ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default"
-if test "x$ac_cv_header_pthread_h" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_PTHREAD_H 1
-_ACEOF
-
-fi
-
-done
-
-
- if test $ac_cv_header_pthread_h = yes ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking POSIX thread version" >&5
-$as_echo_n "checking POSIX thread version... " >&6; }
-if ${ol_cv_pthread_version+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-# include <pthread.h>
-
-int
-main ()
-{
-
- int i = PTHREAD_CREATE_JOINABLE;
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <pthread.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "pthread_detach" >/dev/null 2>&1; then :
- ol_cv_pthread_version=10
-else
- ol_cv_pthread_version=8
-fi
-rm -f conftest*
-
-else
-
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-# include <pthread.h>
-# ifdef PTHREAD_CREATE_UNDETACHED
- draft7
-# endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "draft7" >/dev/null 2>&1; then :
- ol_cv_pthread_version=7
-else
-
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <pthread.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "pthread_attr_init" >/dev/null 2>&1; then :
- ol_cv_pthread_version=6
-else
-
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-# include <pthread.h>
-#ifdef PTHREAD_MUTEX_INITIALIZER
- draft5
-#endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "draft5" >/dev/null 2>&1; then :
- ol_cv_pthread_version=5
-else
- ol_cv_pthread_version=4
-fi
-rm -f conftest*
-
-fi
-rm -f conftest*
-
-fi
-rm -f conftest*
-
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_version" >&5
-$as_echo "$ol_cv_pthread_version" >&6; }
-
-
- if test $ol_cv_pthread_version != 0 ; then
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_PTHREADS $ol_cv_pthread_version
-_ACEOF
-
- else
- as_fn_error $? "unknown pthread version" "$LINENO" 5
- fi
-
- # consider threads found
- ol_with_threads=found
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LinuxThreads pthread.h" >&5
-$as_echo_n "checking for LinuxThreads pthread.h... " >&6; }
-if ${ol_cv_header_linux_threads+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <pthread.h>
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "pthread_kill_other_threads_np" >/dev/null 2>&1; then :
- ol_cv_header_linux_threads=yes
-else
- ol_cv_header_linux_threads=no
-fi
-rm -f conftest*
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_header_linux_threads" >&5
-$as_echo "$ol_cv_header_linux_threads" >&6; }
- if test $ol_cv_header_linux_threads = yes; then
-
-$as_echo "#define HAVE_LINUX_THREADS 1" >>confdefs.h
-
- fi
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU Pth pthread.h" >&5
-$as_echo_n "checking for GNU Pth pthread.h... " >&6; }
-if ${ol_cv_header_gnu_pth_pthread_h+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <pthread.h>
-#ifdef _POSIX_THREAD_IS_GNU_PTH
- __gnu_pth__;
-#endif
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "__gnu_pth__" >/dev/null 2>&1; then :
- ol_cv_header_gnu_pth_pthread_h=yes
-else
- ol_cv_header_gnu_pth_pthread_h=no
-fi
-rm -f conftest*
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_header_gnu_pth_pthread_h" >&5
-$as_echo "$ol_cv_header_gnu_pth_pthread_h" >&6; }
-
-
- if test $ol_cv_header_gnu_pth_pthread_h = no ; then
- for ac_header in sched.h
-do :
- ac_fn_c_check_header_mongrel "$LINENO" "sched.h" "ac_cv_header_sched_h" "$ac_includes_default"
-if test "x$ac_cv_header_sched_h" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_SCHED_H 1
-_ACEOF
-
-fi
-
-done
-
- fi
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in default libraries" >&5
-$as_echo_n "checking for pthread_create in default libraries... " >&6; }
-if ${ol_cv_pthread_create+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-int
-main ()
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_pthread_create=yes
-else
- ol_cv_pthread_create=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_create=yes
-else
- ol_cv_pthread_create=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_create" >&5
-$as_echo "$ol_cv_pthread_create" >&6; }
-
- if test $ol_cv_pthread_create != no ; then
- ol_link_threads=posix
- ol_link_pthreads=""
- fi
-
- # Pthread try link: -kthread (ol_cv_pthread_kthread)
-if test "$ol_link_threads" = no ; then
- # try -kthread
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread link with -kthread" >&5
-$as_echo_n "checking for pthread link with -kthread... " >&6; }
-if ${ol_cv_pthread_kthread+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- # save the flags
- ol_LIBS="$LIBS"
- LIBS="-kthread $LIBS"
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-int
-main ()
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_pthread_kthread=yes
-else
- ol_cv_pthread_kthread=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_kthread=yes
-else
- ol_cv_pthread_kthread=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
- # restore the LIBS
- LIBS="$ol_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_kthread" >&5
-$as_echo "$ol_cv_pthread_kthread" >&6; }
-
- if test $ol_cv_pthread_kthread = yes ; then
- ol_link_pthreads="-kthread"
- ol_link_threads=posix
- fi
-fi
-
- # Pthread try link: -pthread (ol_cv_pthread_pthread)
-if test "$ol_link_threads" = no ; then
- # try -pthread
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread link with -pthread" >&5
-$as_echo_n "checking for pthread link with -pthread... " >&6; }
-if ${ol_cv_pthread_pthread+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- # save the flags
- ol_LIBS="$LIBS"
- LIBS="-pthread $LIBS"
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-int
-main ()
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_pthread_pthread=yes
-else
- ol_cv_pthread_pthread=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_pthread=yes
-else
- ol_cv_pthread_pthread=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
- # restore the LIBS
- LIBS="$ol_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_pthread" >&5
-$as_echo "$ol_cv_pthread_pthread" >&6; }
-
- if test $ol_cv_pthread_pthread = yes ; then
- ol_link_pthreads="-pthread"
- ol_link_threads=posix
- fi
-fi
-
- # Pthread try link: -pthreads (ol_cv_pthread_pthreads)
-if test "$ol_link_threads" = no ; then
- # try -pthreads
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread link with -pthreads" >&5
-$as_echo_n "checking for pthread link with -pthreads... " >&6; }
-if ${ol_cv_pthread_pthreads+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- # save the flags
- ol_LIBS="$LIBS"
- LIBS="-pthreads $LIBS"
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-int
-main ()
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_pthread_pthreads=yes
-else
- ol_cv_pthread_pthreads=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_pthreads=yes
-else
- ol_cv_pthread_pthreads=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
- # restore the LIBS
- LIBS="$ol_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_pthreads" >&5
-$as_echo "$ol_cv_pthread_pthreads" >&6; }
-
- if test $ol_cv_pthread_pthreads = yes ; then
- ol_link_pthreads="-pthreads"
- ol_link_threads=posix
- fi
-fi
-
- # Pthread try link: -mthreads (ol_cv_pthread_mthreads)
-if test "$ol_link_threads" = no ; then
- # try -mthreads
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread link with -mthreads" >&5
-$as_echo_n "checking for pthread link with -mthreads... " >&6; }
-if ${ol_cv_pthread_mthreads+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- # save the flags
- ol_LIBS="$LIBS"
- LIBS="-mthreads $LIBS"
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-int
-main ()
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_pthread_mthreads=yes
-else
- ol_cv_pthread_mthreads=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_mthreads=yes
-else
- ol_cv_pthread_mthreads=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
- # restore the LIBS
- LIBS="$ol_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_mthreads" >&5
-$as_echo "$ol_cv_pthread_mthreads" >&6; }
-
- if test $ol_cv_pthread_mthreads = yes ; then
- ol_link_pthreads="-mthreads"
- ol_link_threads=posix
- fi
-fi
-
- # Pthread try link: -thread (ol_cv_pthread_thread)
-if test "$ol_link_threads" = no ; then
- # try -thread
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread link with -thread" >&5
-$as_echo_n "checking for pthread link with -thread... " >&6; }
-if ${ol_cv_pthread_thread+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- # save the flags
- ol_LIBS="$LIBS"
- LIBS="-thread $LIBS"
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ *)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$flag" >&5
+$as_echo_n "checking for the pthreads library -l$flag... " >&6; }
+ PTHREAD_LIBS="-l$flag"
+ ;;
+ esac
+
+ save_LIBS="$LIBS"
+ save_CFLAGS="$CFLAGS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+ # Check for various functions. We must include pthread.h,
+ # since some functions may be macros. (On the Sequent, we
+ # need a special flag -Kthread to make this header compile.)
+ # We check for pthread_join because it is in -lpthread on IRIX
+ # while pthread_create is in libc. We check for pthread_attr_init
+ # due to DEC craziness with -lpthreads. We check for
+ # pthread_cleanup_push because it is one of the few pthread
+ # functions on Solaris that doesn't have a non-functional libc stub.
+ # We try pthread_create on general principles.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-/* pthread test headers */
#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
int
main ()
{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
+pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0);
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_pthread_thread=yes
-else
- ol_cv_pthread_thread=no
+ acx_pthread_ok=yes
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_thread=yes
-else
- ol_cv_pthread_thread=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
- # restore the LIBS
- LIBS="$ol_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_thread" >&5
-$as_echo "$ol_cv_pthread_thread" >&6; }
-
- if test $ol_cv_pthread_thread = yes ; then
- ol_link_pthreads="-thread"
- ol_link_threads=posix
- fi
-fi
-
-
- # Pthread try link: -lpthread -lmach -lexc -lc_r (ol_cv_pthread_lpthread_lmach_lexc_lc_r)
-if test "$ol_link_threads" = no ; then
- # try -lpthread -lmach -lexc -lc_r
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread link with -lpthread -lmach -lexc -lc_r" >&5
-$as_echo_n "checking for pthread link with -lpthread -lmach -lexc -lc_r... " >&6; }
-if ${ol_cv_pthread_lpthread_lmach_lexc_lc_r+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- # save the flags
- ol_LIBS="$LIBS"
- LIBS="-lpthread -lmach -lexc -lc_r $LIBS"
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-int
-main ()
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_pthread_lpthread_lmach_lexc_lc_r=yes
-else
- ol_cv_pthread_lpthread_lmach_lexc_lc_r=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_lpthread_lmach_lexc_lc_r=yes
-else
- ol_cv_pthread_lpthread_lmach_lexc_lc_r=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
- # restore the LIBS
- LIBS="$ol_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_lpthread_lmach_lexc_lc_r" >&5
-$as_echo "$ol_cv_pthread_lpthread_lmach_lexc_lc_r" >&6; }
-
- if test $ol_cv_pthread_lpthread_lmach_lexc_lc_r = yes ; then
- ol_link_pthreads="-lpthread -lmach -lexc -lc_r"
- ol_link_threads=posix
- fi
-fi
-
- # Pthread try link: -lpthread -lmach -lexc (ol_cv_pthread_lpthread_lmach_lexc)
-if test "$ol_link_threads" = no ; then
- # try -lpthread -lmach -lexc
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread link with -lpthread -lmach -lexc" >&5
-$as_echo_n "checking for pthread link with -lpthread -lmach -lexc... " >&6; }
-if ${ol_cv_pthread_lpthread_lmach_lexc+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- # save the flags
- ol_LIBS="$LIBS"
- LIBS="-lpthread -lmach -lexc $LIBS"
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-int
-main ()
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_pthread_lpthread_lmach_lexc=yes
-else
- ol_cv_pthread_lpthread_lmach_lexc=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_lpthread_lmach_lexc=yes
-else
- ol_cv_pthread_lpthread_lmach_lexc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
- # restore the LIBS
- LIBS="$ol_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_lpthread_lmach_lexc" >&5
-$as_echo "$ol_cv_pthread_lpthread_lmach_lexc" >&6; }
-
- if test $ol_cv_pthread_lpthread_lmach_lexc = yes ; then
- ol_link_pthreads="-lpthread -lmach -lexc"
- ol_link_threads=posix
- fi
-fi
-
-
- # Pthread try link: -lpthread -Wl,-woff,85 (ol_cv_pthread_lib_lpthread_woff)
-if test "$ol_link_threads" = no ; then
- # try -lpthread -Wl,-woff,85
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread link with -lpthread -Wl,-woff,85" >&5
-$as_echo_n "checking for pthread link with -lpthread -Wl,-woff,85... " >&6; }
-if ${ol_cv_pthread_lib_lpthread_woff+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- # save the flags
- ol_LIBS="$LIBS"
- LIBS="-lpthread -Wl,-woff,85 $LIBS"
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-int
-main ()
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_pthread_lib_lpthread_woff=yes
-else
- ol_cv_pthread_lib_lpthread_woff=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_lib_lpthread_woff=yes
-else
- ol_cv_pthread_lib_lpthread_woff=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
- # restore the LIBS
- LIBS="$ol_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_lib_lpthread_woff" >&5
-$as_echo "$ol_cv_pthread_lib_lpthread_woff" >&6; }
-
- if test $ol_cv_pthread_lib_lpthread_woff = yes ; then
- ol_link_pthreads="-lpthread -Wl,-woff,85"
- ol_link_threads=posix
- fi
-fi
-
-
- # Pthread try link: -lpthread (ol_cv_pthread_lpthread)
-if test "$ol_link_threads" = no ; then
- # try -lpthread
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread link with -lpthread" >&5
-$as_echo_n "checking for pthread link with -lpthread... " >&6; }
-if ${ol_cv_pthread_lpthread+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- # save the flags
- ol_LIBS="$LIBS"
- LIBS="-lpthread $LIBS"
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-int
-main ()
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_pthread_lpthread=yes
-else
- ol_cv_pthread_lpthread=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_lpthread=yes
-else
- ol_cv_pthread_lpthread=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
- # restore the LIBS
- LIBS="$ol_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_lpthread" >&5
-$as_echo "$ol_cv_pthread_lpthread" >&6; }
-
- if test $ol_cv_pthread_lpthread = yes ; then
- ol_link_pthreads="-lpthread"
- ol_link_threads=posix
- fi
-fi
-
- # Pthread try link: -lc_r (ol_cv_pthread_lc_r)
-if test "$ol_link_threads" = no ; then
- # try -lc_r
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread link with -lc_r" >&5
-$as_echo_n "checking for pthread link with -lc_r... " >&6; }
-if ${ol_cv_pthread_lc_r+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- # save the flags
- ol_LIBS="$LIBS"
- LIBS="-lc_r $LIBS"
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-int
-main ()
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_pthread_lc_r=yes
-else
- ol_cv_pthread_lc_r=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_lc_r=yes
-else
- ol_cv_pthread_lc_r=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
- # restore the LIBS
- LIBS="$ol_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_lc_r" >&5
-$as_echo "$ol_cv_pthread_lc_r" >&6; }
-
- if test $ol_cv_pthread_lc_r = yes ; then
- ol_link_pthreads="-lc_r"
- ol_link_threads=posix
- fi
-fi
-
-
- # Pthread try link: -threads (ol_cv_pthread_threads)
-if test "$ol_link_threads" = no ; then
- # try -threads
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread link with -threads" >&5
-$as_echo_n "checking for pthread link with -threads... " >&6; }
-if ${ol_cv_pthread_threads+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- # save the flags
- ol_LIBS="$LIBS"
- LIBS="-threads $LIBS"
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-int
-main ()
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_pthread_threads=yes
-else
- ol_cv_pthread_threads=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_threads=yes
-else
- ol_cv_pthread_threads=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
- # restore the LIBS
- LIBS="$ol_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_threads" >&5
-$as_echo "$ol_cv_pthread_threads" >&6; }
-
- if test $ol_cv_pthread_threads = yes ; then
- ol_link_pthreads="-threads"
- ol_link_threads=posix
- fi
-fi
-
-
- # Pthread try link: -lpthreads -lmach -lexc -lc_r (ol_cv_pthread_lpthreads_lmach_lexc_lc_r)
-if test "$ol_link_threads" = no ; then
- # try -lpthreads -lmach -lexc -lc_r
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread link with -lpthreads -lmach -lexc -lc_r" >&5
-$as_echo_n "checking for pthread link with -lpthreads -lmach -lexc -lc_r... " >&6; }
-if ${ol_cv_pthread_lpthreads_lmach_lexc_lc_r+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- # save the flags
- ol_LIBS="$LIBS"
- LIBS="-lpthreads -lmach -lexc -lc_r $LIBS"
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-int
-main ()
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_pthread_lpthreads_lmach_lexc_lc_r=yes
-else
- ol_cv_pthread_lpthreads_lmach_lexc_lc_r=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_lpthreads_lmach_lexc_lc_r=yes
-else
- ol_cv_pthread_lpthreads_lmach_lexc_lc_r=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
- # restore the LIBS
- LIBS="$ol_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_lpthreads_lmach_lexc_lc_r" >&5
-$as_echo "$ol_cv_pthread_lpthreads_lmach_lexc_lc_r" >&6; }
-
- if test $ol_cv_pthread_lpthreads_lmach_lexc_lc_r = yes ; then
- ol_link_pthreads="-lpthreads -lmach -lexc -lc_r"
- ol_link_threads=posix
- fi
-fi
-
- # Pthread try link: -lpthreads -lmach -lexc (ol_cv_pthread_lpthreads_lmach_lexc)
-if test "$ol_link_threads" = no ; then
- # try -lpthreads -lmach -lexc
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread link with -lpthreads -lmach -lexc" >&5
-$as_echo_n "checking for pthread link with -lpthreads -lmach -lexc... " >&6; }
-if ${ol_cv_pthread_lpthreads_lmach_lexc+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- # save the flags
- ol_LIBS="$LIBS"
- LIBS="-lpthreads -lmach -lexc $LIBS"
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-int
-main ()
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_pthread_lpthreads_lmach_lexc=yes
-else
- ol_cv_pthread_lpthreads_lmach_lexc=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_lpthreads_lmach_lexc=yes
-else
- ol_cv_pthread_lpthreads_lmach_lexc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
- # restore the LIBS
- LIBS="$ol_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_lpthreads_lmach_lexc" >&5
-$as_echo "$ol_cv_pthread_lpthreads_lmach_lexc" >&6; }
-
- if test $ol_cv_pthread_lpthreads_lmach_lexc = yes ; then
- ol_link_pthreads="-lpthreads -lmach -lexc"
- ol_link_threads=posix
- fi
-fi
-
- # Pthread try link: -lpthreads -lexc (ol_cv_pthread_lpthreads_lexc)
-if test "$ol_link_threads" = no ; then
- # try -lpthreads -lexc
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread link with -lpthreads -lexc" >&5
-$as_echo_n "checking for pthread link with -lpthreads -lexc... " >&6; }
-if ${ol_cv_pthread_lpthreads_lexc+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- # save the flags
- ol_LIBS="$LIBS"
- LIBS="-lpthreads -lexc $LIBS"
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-int
-main ()
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_pthread_lpthreads_lexc=yes
-else
- ol_cv_pthread_lpthreads_lexc=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_lpthreads_lexc=yes
-else
- ol_cv_pthread_lpthreads_lexc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
- # restore the LIBS
- LIBS="$ol_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_lpthreads_lexc" >&5
-$as_echo "$ol_cv_pthread_lpthreads_lexc" >&6; }
-
- if test $ol_cv_pthread_lpthreads_lexc = yes ; then
- ol_link_pthreads="-lpthreads -lexc"
- ol_link_threads=posix
- fi
-fi
-
-
- # Pthread try link: -lpthreads (ol_cv_pthread_lib_lpthreads)
-if test "$ol_link_threads" = no ; then
- # try -lpthreads
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread link with -lpthreads" >&5
-$as_echo_n "checking for pthread link with -lpthreads... " >&6; }
-if ${ol_cv_pthread_lib_lpthreads+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- # save the flags
- ol_LIBS="$LIBS"
- LIBS="-lpthreads $LIBS"
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-int
-main ()
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_pthread_lib_lpthreads=yes
-else
- ol_cv_pthread_lib_lpthreads=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_lib_lpthreads=yes
-else
- ol_cv_pthread_lib_lpthreads=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
- # restore the LIBS
- LIBS="$ol_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_lib_lpthreads" >&5
-$as_echo "$ol_cv_pthread_lib_lpthreads" >&6; }
-
- if test $ol_cv_pthread_lib_lpthreads = yes ; then
- ol_link_pthreads="-lpthreads"
- ol_link_threads=posix
- fi
-fi
-
-
- if test $ol_link_threads != no ; then
- LTHREAD_LIBS="$LTHREAD_LIBS $ol_link_pthreads"
-
- save_CPPFLAGS="$CPPFLAGS"
- save_LIBS="$LIBS"
- LIBS="$LTHREAD_LIBS $LIBS"
-
- for ac_func in sched_yield pthread_yield thr_yield
-do :
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-
- if test $ac_cv_func_sched_yield = no &&
- test $ac_cv_func_pthread_yield = no &&
- test $ac_cv_func_thr_yield = no ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sched_yield in -lrt" >&5
-$as_echo_n "checking for sched_yield in -lrt... " >&6; }
-if ${ac_cv_lib_rt_sched_yield+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lrt $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char sched_yield ();
-int
-main ()
-{
-return sched_yield ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_rt_sched_yield=yes
-else
- ac_cv_lib_rt_sched_yield=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_sched_yield" >&5
-$as_echo "$ac_cv_lib_rt_sched_yield" >&6; }
-if test "x$ac_cv_lib_rt_sched_yield" = xyes; then :
- LTHREAD_LIBS="$LTHREAD_LIBS -lrt"
-
-$as_echo "#define HAVE_SCHED_YIELD 1" >>confdefs.h
-
- ac_cv_func_sched_yield=yes
-else
- ac_cv_func_sched_yield=no
-fi
-
- fi
- if test $ac_cv_func_sched_yield = no &&
- test $ac_cv_func_pthread_yield = no &&
- test "$ac_cv_func_thr_yield" = no ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not locate sched_yield() or pthread_yield()" >&5
-$as_echo "$as_me: WARNING: could not locate sched_yield() or pthread_yield()" >&2;}
- fi
-
- for ac_func in pthread_kill
-do :
- ac_fn_c_check_func "$LINENO" "pthread_kill" "ac_cv_func_pthread_kill"
-if test "x$ac_cv_func_pthread_kill" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_PTHREAD_KILL 1
-_ACEOF
-
-fi
-done
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_rwlock_destroy with <pthread.h>" >&5
-$as_echo_n "checking for pthread_rwlock_destroy with <pthread.h>... " >&6; }
-if ${ol_cv_func_pthread_rwlock_destroy+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-#include <pthread.h>
-pthread_rwlock_t rwlock;
-
-int
-main ()
-{
-pthread_rwlock_destroy(&rwlock);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_func_pthread_rwlock_destroy=yes
-else
- ol_cv_func_pthread_rwlock_destroy=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_func_pthread_rwlock_destroy" >&5
-$as_echo "$ol_cv_func_pthread_rwlock_destroy" >&6; }
- if test $ol_cv_func_pthread_rwlock_destroy = yes ; then
-
-$as_echo "#define HAVE_PTHREAD_RWLOCK_DESTROY 1" >>confdefs.h
-
- fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_detach with <pthread.h>" >&5
-$as_echo_n "checking for pthread_detach with <pthread.h>... " >&6; }
-if ${ol_cv_func_pthread_detach+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-#include <pthread.h>
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-int
-main ()
-{
-pthread_detach(NULL);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_func_pthread_detach=yes
-else
- ol_cv_func_pthread_detach=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_func_pthread_detach" >&5
-$as_echo "$ol_cv_func_pthread_detach" >&6; }
-
- if test $ol_cv_func_pthread_detach = no ; then
- as_fn_error $? "could not locate pthread_detach()" "$LINENO" 5
- fi
-
-
-$as_echo "#define HAVE_PTHREAD_DETACH 1" >>confdefs.h
-
-
- for ac_func in \
- pthread_setconcurrency \
- pthread_getconcurrency \
- thr_setconcurrency \
- thr_getconcurrency \
-
-do :
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
-
-
- for ac_func in pthread_kill_other_threads_np
-do :
- ac_fn_c_check_func "$LINENO" "pthread_kill_other_threads_np" "ac_cv_func_pthread_kill_other_threads_np"
-if test "x$ac_cv_func_pthread_kill_other_threads_np" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_PTHREAD_KILL_OTHER_THREADS_NP 1
-_ACEOF
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5
+$as_echo "$acx_pthread_ok" >&6; }
+ if test "x$acx_pthread_ok" = xyes; then
+ break;
+ fi
-fi
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
done
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LinuxThreads implementation" >&5
-$as_echo_n "checking for LinuxThreads implementation... " >&6; }
-if ${ol_cv_sys_linux_threads+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ol_cv_sys_linux_threads=$ac_cv_func_pthread_kill_other_threads_np
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_sys_linux_threads" >&5
-$as_echo "$ol_cv_sys_linux_threads" >&6; }
-
-
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LinuxThreads consistency" >&5
-$as_echo_n "checking for LinuxThreads consistency... " >&6; }
-if ${ol_cv_linux_threads+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- if test $ol_cv_header_linux_threads = yes &&
- test $ol_cv_sys_linux_threads = yes; then
- ol_cv_linux_threads=yes
- elif test $ol_cv_header_linux_threads = no &&
- test $ol_cv_sys_linux_threads = no; then
- ol_cv_linux_threads=no
- else
- ol_cv_linux_threads=error
- fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_linux_threads" >&5
-$as_echo "$ol_cv_linux_threads" >&6; }
-
-
- if test $ol_cv_linux_threads = error; then
- as_fn_error $? "LinuxThreads header/library mismatch" "$LINENO" 5;
- fi
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking if pthread_create() works" >&5
-$as_echo_n "checking if pthread_create() works... " >&6; }
-if ${ol_cv_pthread_create_works+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- if test "$cross_compiling" = yes; then :
- ol_cv_pthread_create_works=yes
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-
-/* pthread test headers */
-#include <pthread.h>
-#if HAVE_PTHREADS < 7
-#include <errno.h>
-#endif
-#ifndef NULL
-#define NULL (void*)0
-#endif
-
-static void *task(p)
- void *p;
-{
- return (void *) (p == NULL);
-}
-
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
-
- /* pthread test function */
-#ifndef PTHREAD_CREATE_DETACHED
-#define PTHREAD_CREATE_DETACHED 1
-#endif
- pthread_t t;
- int status;
- int detach = PTHREAD_CREATE_DETACHED;
-
-#if HAVE_PTHREADS > 4
- /* Final pthreads */
- pthread_attr_t attr;
-
- status = pthread_attr_init(&attr);
- if( status ) return status;
-
-#if HAVE_PTHREADS < 7
- status = pthread_attr_setdetachstate(&attr, &detach);
- if( status < 0 ) status = errno;
-#else
- status = pthread_attr_setdetachstate(&attr, detach);
-#endif
- if( status ) return status;
- status = pthread_create( &t, &attr, task, NULL );
-#if HAVE_PTHREADS < 7
- if( status < 0 ) status = errno;
-#endif
- if( status ) return status;
-#else
- /* Draft 4 pthreads */
- status = pthread_create( &t, pthread_attr_default, task, NULL );
- if( status ) return errno;
-
- /* give thread a chance to complete */
- /* it should remain joinable and hence detachable */
- sleep( 1 );
-
- status = pthread_detach( &t );
- if( status ) return errno;
-#endif
-
-#ifdef HAVE_LINUX_THREADS
- pthread_kill_other_threads_np();
-#endif
-
- return 0;
-
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_create_works=yes
-else
- ol_cv_pthread_create_works=no
fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_create_works" >&5
-$as_echo "$ol_cv_pthread_create_works" >&6; }
-
- if test $ol_cv_pthread_create_works = no ; then
- as_fn_error $? "pthread_create is not usable, check environment settings" "$LINENO" 5
- fi
-
- ol_replace_broken_yield=no
-
- if test $ol_replace_broken_yield = yes ; then
-
-$as_echo "#define REPLACE_BROKEN_YIELD 1" >>confdefs.h
- fi
+# Various other checks:
+if test "x$acx_pthread_ok" = xyes; then
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
- if test x$ol_with_yielding_select = xauto ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking if select yields when using pthreads" >&5
-$as_echo_n "checking if select yields when using pthreads... " >&6; }
-if ${ol_cv_pthread_select_yields+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- if test "$cross_compiling" = yes; then :
- ol_cv_pthread_select_yields=cross
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5
+$as_echo_n "checking for joinable pthread attribute... " >&6; }
+ attr_name=unknown
+ for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <unistd.h>
#include <pthread.h>
-#ifndef NULL
-#define NULL (void*) 0
-#endif
-
-static int fildes[2];
-
-static void *task(p)
- void *p;
-{
- int i;
- struct timeval tv;
-
- fd_set rfds;
-
- tv.tv_sec=10;
- tv.tv_usec=0;
-
- FD_ZERO(&rfds);
- FD_SET(fildes[0], &rfds);
-
- /* we're not interested in any fds */
- i = select(FD_SETSIZE, &rfds, NULL, NULL, &tv);
-
- if(i < 0) {
- perror("select");
- exit(10);
- }
-
- exit(0); /* if we exit here, the select blocked the whole process */
-}
-
-int main(argc, argv)
- int argc;
- char **argv;
-{
- pthread_t t;
-
- /* create a pipe to select */
- if(pipe(&fildes[0])) {
- perror("select");
- exit(1);
- }
-
-#ifdef HAVE_PTHREAD_SETCONCURRENCY
- (void) pthread_setconcurrency(2);
-#else
-#ifdef HAVE_THR_SETCONCURRENCY
- /* Set Solaris LWP concurrency to 2 */
- thr_setconcurrency(2);
-#endif
-#endif
-
-#if HAVE_PTHREADS < 6
- pthread_create(&t, pthread_attr_default, task, NULL);
-#else
- pthread_create(&t, NULL, task, NULL);
-#endif
-
- /* make sure task runs first */
-#ifdef HAVE_THR_YIELD
- thr_yield();
-#elif defined( HAVE_SCHED_YIELD )
- sched_yield();
-#elif defined( HAVE_PTHREAD_YIELD )
- pthread_yield();
-#endif
-
- exit(2);
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- ol_cv_pthread_select_yields=no
-else
- ol_cv_pthread_select_yields=yes
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_pthread_select_yields" >&5
-$as_echo "$ol_cv_pthread_select_yields" >&6; }
-
- if test $ol_cv_pthread_select_yields = cross ; then
- as_fn_error $? "crossing compiling: use --with-yielding-select=yes|no|manual" "$LINENO" 5
- fi
-
- if test $ol_cv_pthread_select_yields = yes ; then
- ol_with_yielding_select=yes
- fi
- fi
-
- CPPFLAGS="$save_CPPFLAGS"
- LIBS="$save_LIBS"
- else
- as_fn_error $? "could not locate usable POSIX Threads" "$LINENO" 5
- fi
- fi
-
- if test $ol_with_threads = posix ; then
- as_fn_error $? "could not locate POSIX Threads" "$LINENO" 5
- fi
- ;;
-esac
-
-case $ol_with_threads in auto | yes | mach)
-
- for ac_header in mach/cthreads.h cthreads.h
-do :
- as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
- if test $ac_cv_header_mach_cthreads_h = yes ; then
- ol_with_threads=found
-
- ac_fn_c_check_func "$LINENO" "cthread_fork" "ac_cv_func_cthread_fork"
-if test "x$ac_cv_func_cthread_fork" = xyes; then :
- ol_link_threads=yes
-fi
-
-
- if test $ol_link_threads = no ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cthread_fork with -all_load" >&5
-$as_echo_n "checking for cthread_fork with -all_load... " >&6; }
-if ${ol_cv_cthread_all_load+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- save_LIBS="$LIBS"
- LIBS="-all_load $LIBS"
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <mach/cthreads.h>
int
main ()
{
-
- cthread_fork((void *)0, (void *)0);
-
+int attr=$attr; return attr;
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_cthread_all_load=yes
-else
- ol_cv_cthread_all_load=no
+ attr_name=$attr; break
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- LIBS="$save_LIBS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_cthread_all_load" >&5
-$as_echo "$ol_cv_cthread_all_load" >&6; }
-
- if test $ol_cv_cthread_all_load = yes ; then
- LTHREAD_LIBS="$LTHREAD_LIBS -all_load"
- ol_link_threads=mach
- ol_with_threads=found
- fi
- fi
-
- elif test $ac_cv_header_cthreads_h = yes ; then
-
- ol_with_threads=found
-
- save_LIBS="$LIBS"
- LIBS="$LIBS -lthreads"
- ac_fn_c_check_func "$LINENO" "cthread_fork" "ac_cv_func_cthread_fork"
-if test "x$ac_cv_func_cthread_fork" = xyes; then :
- ol_link_threads=yes
-fi
-
- LIBS="$save_LIBS"
-
- if test $ol_link_threads = yes ; then
- LTHREAD_LIBS="-lthreads"
- ol_link_threads=mach
- ol_with_threads=found
- else
- as_fn_error $? "could not link with Mach CThreads" "$LINENO" 5
- fi
-
- elif test $ol_with_threads = mach ; then
- as_fn_error $? "could not locate Mach CThreads" "$LINENO" 5
- fi
-
- if test $ol_link_threads = mach ; then
-
-$as_echo "#define HAVE_MACH_CTHREADS 1" >>confdefs.h
-
- elif test $ol_with_threads = found ; then
- as_fn_error $? "could not link with Mach CThreads" "$LINENO" 5
- fi
- ;;
-esac
-
-case $ol_with_threads in auto | yes | pth)
-
- for ac_header in pth.h
-do :
- ac_fn_c_check_header_mongrel "$LINENO" "pth.h" "ac_cv_header_pth_h" "$ac_includes_default"
-if test "x$ac_cv_header_pth_h" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_PTH_H 1
-_ACEOF
-
-fi
-
-done
-
-
- if test $ac_cv_header_pth_h = yes ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pth_version in -lpth" >&5
-$as_echo_n "checking for pth_version in -lpth... " >&6; }
-if ${ac_cv_lib_pth_pth_version+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lpth $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
+ done
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $attr_name" >&5
+$as_echo "$attr_name" >&6; }
+ if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char pth_version ();
-int
-main ()
-{
-return pth_version ();
- ;
- return 0;
-}
+cat >>confdefs.h <<_ACEOF
+#define PTHREAD_CREATE_JOINABLE $attr_name
_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_pth_pth_version=yes
-else
- ac_cv_lib_pth_pth_version=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pth_pth_version" >&5
-$as_echo "$ac_cv_lib_pth_pth_version" >&6; }
-if test "x$ac_cv_lib_pth_pth_version" = xyes; then :
- have_pth=yes
-else
- have_pth=no
-fi
-
-
- if test $have_pth = yes ; then
-$as_echo "#define HAVE_GNU_PTH 1" >>confdefs.h
-
- LTHREAD_LIBS="$LTHREAD_LIBS -lpth"
- ol_link_threads=pth
- ol_with_threads=found
-
- if test x$ol_with_yielding_select = xauto ; then
- ol_with_yielding_select=yes
- fi
- fi
- fi
- ;;
-esac
-
-case $ol_with_threads in auto | yes | lwp)
-
- for ac_header in thread.h synch.h
-do :
- as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
+ fi
-fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5
+$as_echo_n "checking if more special flags are required for pthreads... " >&6; }
+ flag=no
+ case "${host_cpu}-${host_os}" in
+ *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
+ *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
+ esac
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${flag}" >&5
+$as_echo "${flag}" >&6; }
+ if test "x$flag" != xno; then
+ PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
+ fi
-done
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
- if test $ac_cv_header_thread_h = yes &&
- test $ac_cv_header_synch_h = yes ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for thr_create in -lthread" >&5
-$as_echo_n "checking for thr_create in -lthread... " >&6; }
-if ${ac_cv_lib_thread_thr_create+:} false; then :
+ # More AIX lossage: must compile with xlc_r or cc_r
+ if test x"$GCC" != xyes; then
+ for ac_prog in xlc_r cc_r
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_PTHREAD_CC+:} false; then :
$as_echo_n "(cached) " >&6
else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lthread $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char thr_create ();
-int
-main ()
-{
-return thr_create ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_thread_thr_create=yes
-else
- ac_cv_lib_thread_thr_create=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_thread_thr_create" >&5
-$as_echo "$ac_cv_lib_thread_thr_create" >&6; }
-if test "x$ac_cv_lib_thread_thr_create" = xyes; then :
- have_thr=yes
+ if test -n "$PTHREAD_CC"; then
+ ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test.
else
- have_thr=no
-fi
-
-
- if test $have_thr = yes ; then
-
-$as_echo "#define HAVE_THR 1" >>confdefs.h
-
- LTHREAD_LIBS="$LTHREAD_LIBS -lthread"
- ol_link_threads=thr
-
- if test x$ol_with_yielding_select = xauto ; then
- ol_with_yielding_select=yes
- fi
-
- for ac_func in \
- thr_setconcurrency \
- thr_getconcurrency \
-
-do :
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-done
-
- fi
- fi
-
- for ac_header in lwp/lwp.h
-do :
- ac_fn_c_check_header_mongrel "$LINENO" "lwp/lwp.h" "ac_cv_header_lwp_lwp_h" "$ac_includes_default"
-if test "x$ac_cv_header_lwp_lwp_h" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LWP_LWP_H 1
-_ACEOF
-
-fi
-
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_PTHREAD_CC="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
done
+ done
+IFS=$as_save_IFS
- if test $ac_cv_header_lwp_lwp_h = yes ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lwp_create in -llwp" >&5
-$as_echo_n "checking for lwp_create in -llwp... " >&6; }
-if ${ac_cv_lib_lwp_lwp_create+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-llwp $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char lwp_create ();
-int
-main ()
-{
-return lwp_create ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_lwp_lwp_create=yes
-else
- ac_cv_lib_lwp_lwp_create=no
fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lwp_lwp_create" >&5
-$as_echo "$ac_cv_lib_lwp_lwp_create" >&6; }
-if test "x$ac_cv_lib_lwp_lwp_create" = xyes; then :
- have_lwp=yes
+PTHREAD_CC=$ac_cv_prog_PTHREAD_CC
+if test -n "$PTHREAD_CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CC" >&5
+$as_echo "$PTHREAD_CC" >&6; }
else
- have_lwp=no
-fi
-
-
- if test $have_lwp = yes ; then
-
-$as_echo "#define HAVE_LWP 1" >>confdefs.h
-
- LTHREAD_LIBS="$LTHREAD_LIBS -llwp"
- ol_link_threads=lwp
-
- if test x$ol_with_yielding_select = xauto ; then
- ol_with_yielding_select=no
- fi
- fi
- fi
- ;;
-esac
-
-if test $ol_with_yielding_select = yes ; then
-
-$as_echo "#define HAVE_YIELDING_SELECT 1" >>confdefs.h
-
-fi
-
-if test $ol_with_threads = manual ; then
- ol_link_threads=yes
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: thread defines and link options must be set manually" >&5
-$as_echo "$as_me: WARNING: thread defines and link options must be set manually" >&2;}
-
- for ac_header in pthread.h sched.h
-do :
- as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
fi
-done
-
- for ac_func in sched_yield pthread_yield
-do :
- as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
-fi
+ test -n "$PTHREAD_CC" && break
done
+test -n "$PTHREAD_CC" || PTHREAD_CC="${CC}"
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LinuxThreads pthread.h" >&5
-$as_echo_n "checking for LinuxThreads pthread.h... " >&6; }
-if ${ol_cv_header_linux_threads+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <pthread.h>
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "pthread_kill_other_threads_np" >/dev/null 2>&1; then :
- ol_cv_header_linux_threads=yes
-else
- ol_cv_header_linux_threads=no
-fi
-rm -f conftest*
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_header_linux_threads" >&5
-$as_echo "$ol_cv_header_linux_threads" >&6; }
- if test $ol_cv_header_linux_threads = yes; then
-
-$as_echo "#define HAVE_LINUX_THREADS 1" >>confdefs.h
-
+ else
+ PTHREAD_CC=$CC
fi
-
-
- for ac_header in mach/cthreads.h
-do :
- ac_fn_c_check_header_mongrel "$LINENO" "mach/cthreads.h" "ac_cv_header_mach_cthreads_h" "$ac_includes_default"
-if test "x$ac_cv_header_mach_cthreads_h" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_MACH_CTHREADS_H 1
-_ACEOF
-
-fi
-
-done
-
- for ac_header in lwp/lwp.h
-do :
- ac_fn_c_check_header_mongrel "$LINENO" "lwp/lwp.h" "ac_cv_header_lwp_lwp_h" "$ac_includes_default"
-if test "x$ac_cv_header_lwp_lwp_h" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LWP_LWP_H 1
-_ACEOF
-
-fi
-
-done
-
- for ac_header in thread.h synch.h
-do :
- as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
- cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
-
-fi
-
-done
-
-fi
-
-if test $ol_link_threads != no && test $ol_link_threads != nt ; then
-
-$as_echo "#define REENTRANT 1" >>confdefs.h
-
-
-$as_echo "#define _REENTRANT 1" >>confdefs.h
-
-
-$as_echo "#define THREAD_SAFE 1" >>confdefs.h
-
-
-$as_echo "#define _THREAD_SAFE 1" >>confdefs.h
-
-
-$as_echo "#define THREADSAFE 1" >>confdefs.h
-
-
-$as_echo "#define _THREADSAFE 1" >>confdefs.h
-
-
-$as_echo "#define _SGI_MP_SOURCE 1" >>confdefs.h
-
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for thread specific errno" >&5
-$as_echo_n "checking for thread specific errno... " >&6; }
-if ${ol_cv_errno_thread_specific+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <errno.h>
-int
-main ()
-{
-errno = 0;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_errno_thread_specific=yes
else
- ol_cv_errno_thread_specific=no
+ PTHREAD_CC="$CC"
fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_errno_thread_specific" >&5
-$as_echo "$ol_cv_errno_thread_specific" >&6; }
-
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for thread specific h_errno" >&5
-$as_echo_n "checking for thread specific h_errno... " >&6; }
-if ${ol_cv_h_errno_thread_specific+:} false; then :
- $as_echo_n "(cached) " >&6
-else
-
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <netdb.h>
-int
-main ()
-{
-h_errno = 0;
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ol_cv_h_errno_thread_specific=yes
-else
- ol_cv_h_errno_thread_specific=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ol_cv_h_errno_thread_specific" >&5
-$as_echo "$ol_cv_h_errno_thread_specific" >&6; }
- if test $ol_cv_errno_thread_specific != yes ||
- test $ol_cv_h_errno_thread_specific != yes ; then
- LIBS="$LTHREAD_LIBS $LIBS"
- LTHREAD_LIBS=""
- fi
-fi
-if test $ol_link_threads = no ; then
- if test $ol_with_threads = yes ; then
- as_fn_error $? "no suitable thread support" "$LINENO" 5
- fi
- if test $ol_with_threads = auto ; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: no suitable thread support, disabling threads" >&5
-$as_echo "$as_me: WARNING: no suitable thread support, disabling threads" >&2;}
- ol_with_threads=no
- fi
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+if test x"$acx_pthread_ok" = xyes; then
-$as_echo "#define NO_THREADS 1" >>confdefs.h
+$as_echo "#define HAVE_PTHREADS 1" >>confdefs.h
- LTHREAD_LIBS=""
- BUILD_THREAD=no
+ have_pthreads=yes
+ :
else
- BUILD_THREAD=yes
-fi
-
-if test $ol_link_threads != no ; then
-
-$as_echo "#define LDAP_API_FEATURE_X_OPENLDAP_THREAD_SAFE 1" >>confdefs.h
+ acx_pthread_ok=no
fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
-# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
-case "$ol_with_threads" in
- no)
- ol_pthread_ok=no
-
- ;;
- *)
- have_pthreads=yes
- PTHREAD_LIBS="$LTHREAD_LIBS"
- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
- # The cast to long int works around a bug in the HP C Compiler
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+ # The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
@@ -19273,10 +15191,8 @@ $as_echo_n "checking size of pthread_t... " >&6; }
if ${ac_cv_sizeof_pthread_t+:} false; then :
$as_echo_n "(cached) " >&6
else
- if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (pthread_t))" "ac_cv_sizeof_pthread_t" "
- $ac_includes_default
- #include <pthread.h>
-
+ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (pthread_t))" "ac_cv_sizeof_pthread_t" "$ac_includes_default
+ #include <pthread.h>
"; then :
@@ -19302,20 +15218,7 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
-
- ;;
-esac
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
fi
-
-
if test "$have_pthreads" != "no" && test "$enable_thread_support" != "no"; then
PTHREADS_TRUE=
PTHREADS_FALSE='#'
@@ -19712,6 +15615,10 @@ if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${BUILD_SAMPLES_TRUE}" && test -z "${BUILD_SAMPLES_FALSE}"; then
+ as_fn_error $? "conditional \"BUILD_SAMPLES\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${BUILD_REGRESS_TRUE}" && test -z "${BUILD_REGRESS_FALSE}"; then
as_fn_error $? "conditional \"BUILD_REGRESS\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -20189,7 +16096,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by libevent $as_me 2.1.3-alpha-dev, which was
+This file was extended by libevent $as_me 2.1.5-beta, which was
generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -20255,7 +16162,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-libevent config.status 2.1.3-alpha-dev
+libevent config.status 2.1.5-beta
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"
diff --git a/contrib/ntp/sntp/libevent/configure.ac b/contrib/ntp/sntp/libevent/configure.ac
index c60c7ac..2cdc74f 100644
--- a/contrib/ntp/sntp/libevent/configure.ac
+++ b/contrib/ntp/sntp/libevent/configure.ac
@@ -5,18 +5,17 @@ dnl See LICENSE for copying information.
dnl
dnl Original version Dug Song <dugsong@monkey.org>
-AC_INIT(libevent,2.1.3-alpha-dev)
+AC_INIT(libevent,2.1.5-beta)
AC_PREREQ(2.59)
AC_CONFIG_SRCDIR(event.c)
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux])
-
AM_INIT_AUTOMAKE
dnl AM_SILENT_RULES req. automake 1.11. [no] defaults V=1
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_CONFIG_HEADERS(config.h evconfig-private.h:evconfig-private.h.in)
-AC_DEFINE(NUMERIC_VERSION, 0x02010301, [Numeric representation of the version])
+AC_DEFINE(NUMERIC_VERSION, 0x02010500, [Numeric representation of the version])
dnl Initialize prefix.
if test "$prefix" = "NONE"; then
@@ -113,6 +112,9 @@ AC_ARG_ENABLE([libevent-install],
AC_ARG_ENABLE([libevent-regress],
AS_HELP_STRING([--disable-libevent-regress, skip regress in make check]),
[], [enable_libevent_regress=yes])
+AC_ARG_ENABLE([samples],
+ AS_HELP_STRING([--disable-samples, skip building of sample programs]),
+ [], [enable_samples=yes])
AC_ARG_ENABLE([function-sections],
AS_HELP_STRING([--enable-function-sections, make static library allow smaller binaries with --gc-sections]),
[], [enable_function_sections=no])
@@ -129,6 +131,7 @@ dnl the command line with --enable-shared and --disable-shared.
dnl AC_DISABLE_SHARED
AC_SUBST(LIBTOOL_DEPS)
+AM_CONDITIONAL([BUILD_SAMPLES], [test "$enable_samples" = "yes"])
AM_CONDITIONAL([BUILD_REGRESS], [test "$enable_libevent_regress" = "yes"])
dnl Checks for libraries.
@@ -724,22 +727,16 @@ AC_TRY_COMPILE([],
# check if we can compile with pthreads
have_pthreads=no
if test x$bwin32 != xtrue && test "$enable_thread_support" != "no"; then
- OL_THREAD_CHECK([
- have_pthreads=yes
- PTHREAD_LIBS="$LTHREAD_LIBS"
- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
- AC_CHECK_SIZEOF(
- [pthread_t],
- [],
- [
- AC_INCLUDES_DEFAULT()
- #include <pthread.h>
- ]
- )
- ])
+ ACX_PTHREAD([
+ AC_DEFINE(HAVE_PTHREADS, 1,
+ [Define if we have pthreads on this system])
+ have_pthreads=yes])
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+ AC_CHECK_SIZEOF(pthread_t, ,
+ [AC_INCLUDES_DEFAULT()
+ #include <pthread.h> ]
+ )
fi
-AC_SUBST([PTHREAD_LIBS])
-AC_SUBST([PTHREAD_CFLAGS])
AM_CONDITIONAL([PTHREADS], [test "$have_pthreads" != "no" && test "$enable_thread_support" != "no"])
# check if we should compile locking into the library
diff --git a/contrib/ntp/sntp/libevent/evbuffer-internal.h b/contrib/ntp/sntp/libevent/evbuffer-internal.h
index fb67ec0..cf4bddc 100644
--- a/contrib/ntp/sntp/libevent/evbuffer-internal.h
+++ b/contrib/ntp/sntp/libevent/evbuffer-internal.h
@@ -155,6 +155,18 @@ struct evbuffer {
struct bufferevent *parent;
};
+#if EVENT__SIZEOF_OFF_T < EVENT__SIZEOF_SIZE_T
+typedef ev_ssize_t ev_misalign_t;
+#define EVBUFFER_CHAIN_MAX ((size_t)EV_SSIZE_MAX)
+#else
+typedef ev_off_t ev_misalign_t;
+#if EVENT__SIZEOF_OFF_T > EVENT__SIZEOF_SIZE_T
+#define EVBUFFER_CHAIN_MAX EV_SIZE_MAX
+#else
+#define EVBUFFER_CHAIN_MAX ((size_t)EV_SSIZE_MAX)
+#endif
+#endif
+
/** A single item in an evbuffer. */
struct evbuffer_chain {
/** points to next buffer in the chain */
@@ -165,7 +177,7 @@ struct evbuffer_chain {
/** unused space at the beginning of buffer or an offset into a
* file for sendfile buffers. */
- ev_off_t misalign;
+ ev_misalign_t misalign;
/** Offset into buffer + misalign at which to start writing.
* In other words, the total number of bytes actually stored
diff --git a/contrib/ntp/sntp/libevent/evdns.c b/contrib/ntp/sntp/libevent/evdns.c
index 59c3abe..60f4db5 100644
--- a/contrib/ntp/sntp/libevent/evdns.c
+++ b/contrib/ntp/sntp/libevent/evdns.c
@@ -541,6 +541,17 @@ nameserver_probe_failed(struct nameserver *const ns) {
}
}
+static void
+request_swap_ns(struct request *req, struct nameserver *ns) {
+ if (ns && req->ns != ns) {
+ EVUTIL_ASSERT(req->ns->requests_inflight > 0);
+ req->ns->requests_inflight--;
+ ns->requests_inflight++;
+
+ req->ns = ns;
+ }
+}
+
/* called when a nameserver has been deemed to have failed. For example, too */
/* many packets have timed out etc */
static void
@@ -595,7 +606,7 @@ nameserver_failed(struct nameserver *const ns, const char *msg) {
if (req->tx_count == 0 && req->ns == ns) {
/* still waiting to go out, can be moved */
/* to another server */
- req->ns = nameserver_pick(base);
+ request_swap_ns(req, nameserver_pick(base));
}
req = req->next;
} while (req != started_at);
@@ -659,6 +670,7 @@ request_finished(struct request *const req, struct request **head, int free_hand
req->ns->requests_inflight == 0 &&
req->base->disable_when_inactive) {
event_del(&req->ns->event);
+ evtimer_del(&req->ns->timeout_event);
}
if (!req->request_appended) {
@@ -707,7 +719,7 @@ request_reissue(struct request *req) {
/* the last nameserver should have been marked as failing */
/* by the caller of this function, therefore pick will try */
/* not to return it */
- req->ns = nameserver_pick(req->base);
+ request_swap_ns(req, nameserver_pick(req->base));
if (req->ns == last_ns) {
/* ... but pick did return it */
/* not a lot of point in trying again with the */
@@ -2158,29 +2170,30 @@ evdns_request_timeout_callback(evutil_socket_t fd, short events, void *arg) {
log(EVDNS_LOG_DEBUG, "Request %p timed out", arg);
EVDNS_LOCK(base);
- req->ns->timedout++;
- if (req->ns->timedout > req->base->global_max_nameserver_timeout) {
- req->ns->timedout = 0;
- nameserver_failed(req->ns, "request timed out.");
- }
-
if (req->tx_count >= req->base->global_max_retransmits) {
+ struct nameserver *ns = req->ns;
/* this request has failed */
log(EVDNS_LOG_DEBUG, "Giving up on request %p; tx_count==%d",
arg, req->tx_count);
reply_schedule_callback(req, 0, DNS_ERR_TIMEOUT, NULL);
+
request_finished(req, &REQ_HEAD(req->base, req->trans_id), 1);
+ nameserver_failed(ns, "request timed out.");
} else {
/* retransmit it */
- struct nameserver *new_ns;
log(EVDNS_LOG_DEBUG, "Retransmitting request %p; tx_count==%d",
arg, req->tx_count);
(void) evtimer_del(&req->timeout_event);
- new_ns = nameserver_pick(base);
- if (new_ns)
- req->ns = new_ns;
+ request_swap_ns(req, nameserver_pick(base));
evdns_request_transmit(req);
+
+ req->ns->timedout++;
+ if (req->ns->timedout > req->base->global_max_nameserver_timeout) {
+ req->ns->timedout = 0;
+ nameserver_failed(req->ns, "request timed out.");
+ }
}
+
EVDNS_UNLOCK(base);
}
@@ -2639,6 +2652,34 @@ evdns_base_nameserver_sockaddr_add(struct evdns_base *base,
return res;
}
+int
+evdns_base_get_nameserver_addr(struct evdns_base *base, int idx,
+ struct sockaddr *sa, ev_socklen_t len)
+{
+ int result = -1;
+ int i;
+ struct nameserver *server;
+ EVDNS_LOCK(base);
+ server = base->server_head;
+ for (i = 0; i < idx && server; ++i, server = server->next) {
+ if (server->next == base->server_head)
+ goto done;
+ }
+ if (! server)
+ goto done;
+
+ if (server->addrlen > len) {
+ result = (int) server->addrlen;
+ goto done;
+ }
+
+ memcpy(sa, &server->address, server->addrlen);
+ result = (int) server->addrlen;
+done:
+ EVDNS_UNLOCK(base);
+ return result;
+}
+
/* remove from the queue */
static void
evdns_request_remove(struct request *req, struct request **head)
@@ -3311,7 +3352,7 @@ strtoint(const char *const str)
/* Parse a number of seconds into a timeval; return -1 on error. */
static int
-strtotimeval(const char *const str, struct timeval *out)
+evdns_strtotimeval(const char *const str, struct timeval *out)
{
double d;
char *endptr;
@@ -3414,13 +3455,13 @@ evdns_base_set_option_impl(struct evdns_base *base,
base->global_search_state->ndots = ndots;
} else if (str_matches_option(option, "timeout:")) {
struct timeval tv;
- if (strtotimeval(val, &tv) == -1) return -1;
+ if (evdns_strtotimeval(val, &tv) == -1) return -1;
if (!(flags & DNS_OPTION_MISC)) return 0;
log(EVDNS_LOG_DEBUG, "Setting timeout to %s", val);
memcpy(&base->global_timeout, &tv, sizeof(struct timeval));
} else if (str_matches_option(option, "getaddrinfo-allow-skew:")) {
struct timeval tv;
- if (strtotimeval(val, &tv) == -1) return -1;
+ if (evdns_strtotimeval(val, &tv) == -1) return -1;
if (!(flags & DNS_OPTION_MISC)) return 0;
log(EVDNS_LOG_DEBUG, "Setting getaddrinfo-allow-skew to %s",
val);
@@ -3462,7 +3503,7 @@ evdns_base_set_option_impl(struct evdns_base *base,
base->global_outgoing_addrlen = len;
} else if (str_matches_option(option, "initial-probe-timeout:")) {
struct timeval tv;
- if (strtotimeval(val, &tv) == -1) return -1;
+ if (evdns_strtotimeval(val, &tv) == -1) return -1;
if (tv.tv_sec > 3600)
tv.tv_sec = 3600;
if (!(flags & DNS_OPTION_MISC)) return 0;
@@ -3555,8 +3596,8 @@ evdns_get_default_hosts_filename(void)
if (! SHGetSpecialFolderPathA(NULL, path, CSIDL_SYSTEM, 0))
return NULL;
- len_out = strlen(path)+strlen(hostfile);
- path_out = mm_malloc(len_out+1);
+ len_out = strlen(path)+strlen(hostfile)+1;
+ path_out = mm_malloc(len_out);
evutil_snprintf(path_out, len_out, "%s%s", path, hostfile);
return path_out;
#else
@@ -3826,17 +3867,18 @@ evdns_base_config_windows_nameservers(struct evdns_base *base)
if (base == NULL)
return -1;
EVDNS_LOCK(base);
+ fname = evdns_get_default_hosts_filename();
+ log(EVDNS_LOG_DEBUG, "Loading hosts entries from %s", fname);
+ evdns_base_load_hosts(base, fname);
+ if (fname)
+ mm_free(fname);
+
if (load_nameservers_with_getnetworkparams(base) == 0) {
EVDNS_UNLOCK(base);
return 0;
}
r = load_nameservers_from_registry(base);
- fname = evdns_get_default_hosts_filename();
- evdns_base_load_hosts(base, fname);
- if (fname)
- mm_free(fname);
-
EVDNS_UNLOCK(base);
return r;
}
@@ -3973,6 +4015,10 @@ evdns_nameserver_free(struct nameserver *server)
event_debug_unassign(&server->event);
if (server->state == 0)
(void) event_del(&server->timeout_event);
+ if (server->probe_request) {
+ evdns_cancel_request(server->base, server->probe_request);
+ server->probe_request = NULL;
+ }
event_debug_unassign(&server->timeout_event);
mm_free(server);
}
@@ -3988,6 +4034,15 @@ evdns_base_free_and_unlock(struct evdns_base *base, int fail_requests)
/* TODO(nickm) we might need to refcount here. */
+ for (server = base->server_head; server; server = server_next) {
+ server_next = server->next;
+ evdns_nameserver_free(server);
+ if (server_next == base->server_head)
+ break;
+ }
+ base->server_head = NULL;
+ base->global_good_nameservers = 0;
+
for (i = 0; i < base->n_req_heads; ++i) {
while (base->req_heads[i]) {
if (fail_requests)
@@ -4002,14 +4057,6 @@ evdns_base_free_and_unlock(struct evdns_base *base, int fail_requests)
}
base->global_requests_inflight = base->global_requests_waiting = 0;
- for (server = base->server_head; server; server = server_next) {
- server_next = server->next;
- evdns_nameserver_free(server);
- if (server_next == base->server_head)
- break;
- }
- base->server_head = NULL;
- base->global_good_nameservers = 0;
if (base->global_search_state) {
for (dom = base->global_search_state->head; dom; dom = dom_next) {
@@ -4663,7 +4710,7 @@ evdns_getaddrinfo(struct evdns_base *dns_base,
data->ipv4_request.r = evdns_base_resolve_ipv4(dns_base,
nodename, 0, evdns_getaddrinfo_gotresolve,
&data->ipv4_request);
- if (want_cname)
+ if (want_cname && data->ipv4_request.r)
data->ipv4_request.r->current_req->put_cname_in_ptr =
&data->cname_result;
}
@@ -4674,7 +4721,7 @@ evdns_getaddrinfo(struct evdns_base *dns_base,
data->ipv6_request.r = evdns_base_resolve_ipv6(dns_base,
nodename, 0, evdns_getaddrinfo_gotresolve,
&data->ipv6_request);
- if (want_cname)
+ if (want_cname && data->ipv6_request.r)
data->ipv6_request.r->current_req->put_cname_in_ptr =
&data->cname_result;
}
diff --git a/contrib/ntp/sntp/libevent/event.c b/contrib/ntp/sntp/libevent/event.c
index 01f0e14..af4a6e0 100644
--- a/contrib/ntp/sntp/libevent/event.c
+++ b/contrib/ntp/sntp/libevent/event.c
@@ -526,22 +526,24 @@ event_enable_debug_mode(void)
#endif
}
-#if 0
void
event_disable_debug_mode(void)
{
+#ifndef EVENT__DISABLE_DEBUG_MODE
struct event_debug_entry **ent, *victim;
EVLOCK_LOCK(event_debug_map_lock_, 0);
for (ent = HT_START(event_debug_map, &global_debug_map); ent; ) {
victim = *ent;
- ent = HT_NEXT_RMV(event_debug_map,&global_debug_map, ent);
+ ent = HT_NEXT_RMV(event_debug_map, &global_debug_map, ent);
mm_free(victim);
}
HT_CLEAR(event_debug_map, &global_debug_map);
EVLOCK_UNLOCK(event_debug_map_lock_ , 0);
-}
+
+ event_debug_mode_on_ = 0;
#endif
+}
struct event_base *
event_base_new_with_config(const struct event_config *cfg)
@@ -993,6 +995,21 @@ done:
return (res);
}
+/* Get the monotonic time for this event_base' timer */
+int
+event_gettime_monotonic(struct event_base *base, struct timeval *tv)
+{
+ int rv = -1;
+
+ if (base && tv) {
+ EVBASE_ACQUIRE_LOCK(base, th_base_lock);
+ rv = evutil_gettime_monotonic_(&(base->monotonic_timer), tv);
+ EVBASE_RELEASE_LOCK(base, th_base_lock);
+ }
+
+ return rv;
+}
+
const char **
event_get_supported_methods(void)
{
@@ -1454,10 +1471,13 @@ done:
static inline void
event_persist_closure(struct event_base *base, struct event *ev)
{
-
- // Define our callback, we use this to store our callback before it's executed
void (*evcb_callback)(evutil_socket_t, short, void *);
+ // Other fields of *ev that must be stored before executing
+ evutil_socket_t evcb_fd;
+ short evcb_res;
+ void *evcb_arg;
+
/* reschedule the persistent event if we have a timeout. */
if (ev->ev_io_timeout.tv_sec || ev->ev_io_timeout.tv_usec) {
/* If there was a timeout, we want it to run at an interval of
@@ -1501,13 +1521,16 @@ event_persist_closure(struct event_base *base, struct event *ev)
}
// Save our callback before we release the lock
- evcb_callback = *ev->ev_callback;
+ evcb_callback = ev->ev_callback;
+ evcb_fd = ev->ev_fd;
+ evcb_res = ev->ev_res;
+ evcb_arg = ev->ev_arg;
// Release the lock
EVBASE_RELEASE_LOCK(base, th_base_lock);
// Execute the callback
- (evcb_callback)(ev->ev_fd, ev->ev_res, ev->ev_arg);
+ (evcb_callback)(evcb_fd, evcb_res, evcb_arg);
}
/*
@@ -1569,8 +1592,9 @@ event_process_active_single_queue(struct event_base *base,
event_persist_closure(base, ev);
break;
case EV_CLOSURE_EVENT: {
+ void (*evcb_callback)(evutil_socket_t, short, void *);
EVUTIL_ASSERT(ev != NULL);
- void (*evcb_callback)(evutil_socket_t, short, void *) = *ev->ev_callback;
+ evcb_callback = *ev->ev_callback;
EVBASE_RELEASE_LOCK(base, th_base_lock);
evcb_callback(ev->ev_fd, ev->ev_res, ev->ev_arg);
}
@@ -1583,14 +1607,16 @@ event_process_active_single_queue(struct event_base *base,
break;
case EV_CLOSURE_EVENT_FINALIZE:
case EV_CLOSURE_EVENT_FINALIZE_FREE: {
+ void (*evcb_evfinalize)(struct event *, void *);
+ int evcb_closure = evcb->evcb_closure;
EVUTIL_ASSERT(ev != NULL);
- void (*evcb_evfinalize)(struct event *, void *) = ev->ev_evcallback.evcb_cb_union.evcb_evfinalize;
base->current_event = NULL;
+ evcb_evfinalize = ev->ev_evcallback.evcb_cb_union.evcb_evfinalize;
EVUTIL_ASSERT((evcb->evcb_flags & EVLIST_FINALIZING));
EVBASE_RELEASE_LOCK(base, th_base_lock);
evcb_evfinalize(ev, ev->ev_arg);
event_debug_note_teardown_(ev);
- if (evcb->evcb_closure == EV_CLOSURE_EVENT_FINALIZE_FREE)
+ if (evcb_closure == EV_CLOSURE_EVENT_FINALIZE_FREE)
mm_free(ev);
}
break;
@@ -3739,6 +3765,7 @@ event_free_debug_globals_locks(void)
if (event_debug_map_lock_ != NULL) {
EVTHREAD_FREE_LOCK(event_debug_map_lock_, 0);
event_debug_map_lock_ = NULL;
+ evthreadimpl_disable_lock_debugging_();
}
#endif /* EVENT__DISABLE_DEBUG_MODE */
#endif /* EVENT__DISABLE_THREAD_SUPPORT */
@@ -3774,6 +3801,7 @@ event_free_globals(void)
void
libevent_global_shutdown(void)
{
+ event_disable_debug_mode();
event_free_globals();
}
diff --git a/contrib/ntp/sntp/libevent/event_tagging.c b/contrib/ntp/sntp/libevent/event_tagging.c
index 7edd3da..64b100b 100644
--- a/contrib/ntp/sntp/libevent/event_tagging.c
+++ b/contrib/ntp/sntp/libevent/event_tagging.c
@@ -207,10 +207,19 @@ decode_tag_internal(ev_uint32_t *ptag, struct evbuffer *evbuf, int dodrain)
*/
data = evbuffer_pullup(
evbuf, len < sizeof(number) + 1 ? len : sizeof(number) + 1);
+ if (!data)
+ return (-1);
while (count++ < len) {
ev_uint8_t lower = *data++;
- number |= (lower & 0x7f) << shift;
+ if (shift >= 28) {
+ /* Make sure it fits into 32 bits */
+ if (shift > 28)
+ return (-1);
+ if ((lower & 0x7f) > 15)
+ return (-1);
+ }
+ number |= (lower & (unsigned)0x7f) << shift;
shift += 7;
if (!(lower & 0x80)) {
@@ -313,6 +322,8 @@ do { \
\
/* XXX(niels): faster? */ \
data = evbuffer_pullup(evbuf, offset + 1) + offset; \
+ if (!data) \
+ return (-1); \
\
nibbles = ((data[0] & 0xf0) >> 4) + 1; \
if (nibbles > maxnibbles || (nibbles >> 1) + 1 > len) \
@@ -320,6 +331,8 @@ do { \
len = (nibbles >> 1) + 1; \
\
data = evbuffer_pullup(evbuf, offset + len) + offset; \
+ if (!data) \
+ return (-1); \
\
while (nibbles > 0) { \
number <<= 4; \
diff --git a/contrib/ntp/sntp/libevent/evrpc-internal.h b/contrib/ntp/sntp/libevent/evrpc-internal.h
index e53d06e..9eb3763 100644
--- a/contrib/ntp/sntp/libevent/evrpc-internal.h
+++ b/contrib/ntp/sntp/libevent/evrpc-internal.h
@@ -27,6 +27,7 @@
#ifndef EVRPC_INTERNAL_H_INCLUDED_
#define EVRPC_INTERNAL_H_INCLUDED_
+#include "event2/http.h"
#include "http-internal.h"
struct evrpc;
diff --git a/contrib/ntp/sntp/libevent/evthread-internal.h b/contrib/ntp/sntp/libevent/evthread-internal.h
index 346b2bb..efdecf8 100644
--- a/contrib/ntp/sntp/libevent/evthread-internal.h
+++ b/contrib/ntp/sntp/libevent/evthread-internal.h
@@ -376,6 +376,13 @@ int evsig_global_setup_locks_(const int enable_locks);
int evutil_global_setup_locks_(const int enable_locks);
int evutil_secure_rng_global_setup_locks_(const int enable_locks);
+/** Return current evthread_lock_callbacks */
+struct evthread_lock_callbacks *evthread_get_lock_callbacks(void);
+/** Return current evthread_condition_callbacks */
+struct evthread_condition_callbacks *evthread_get_condition_callbacks(void);
+/** Disable locking for internal usage (like global shutdown) */
+void evthreadimpl_disable_lock_debugging_(void);
+
#endif
#ifdef __cplusplus
diff --git a/contrib/ntp/sntp/libevent/evthread.c b/contrib/ntp/sntp/libevent/evthread.c
index 4da5d24..02dab7a 100644
--- a/contrib/ntp/sntp/libevent/evthread.c
+++ b/contrib/ntp/sntp/libevent/evthread.c
@@ -69,12 +69,25 @@ evthread_set_id_callback(unsigned long (*id_fn)(void))
evthread_id_fn_ = id_fn;
}
+struct evthread_lock_callbacks *evthread_get_lock_callbacks()
+{
+ return evthread_lock_debugging_enabled_
+ ? &original_lock_fns_ : &evthread_lock_fns_;
+}
+struct evthread_condition_callbacks *evthread_get_condition_callbacks()
+{
+ return evthread_lock_debugging_enabled_
+ ? &original_cond_fns_ : &evthread_cond_fns_;
+}
+void evthreadimpl_disable_lock_debugging_(void)
+{
+ evthread_lock_debugging_enabled_ = 0;
+}
+
int
evthread_set_lock_callbacks(const struct evthread_lock_callbacks *cbs)
{
- struct evthread_lock_callbacks *target =
- evthread_lock_debugging_enabled_
- ? &original_lock_fns_ : &evthread_lock_fns_;
+ struct evthread_lock_callbacks *target = evthread_get_lock_callbacks();
if (!cbs) {
if (target->alloc)
@@ -109,9 +122,7 @@ evthread_set_lock_callbacks(const struct evthread_lock_callbacks *cbs)
int
evthread_set_condition_callbacks(const struct evthread_condition_callbacks *cbs)
{
- struct evthread_condition_callbacks *target =
- evthread_lock_debugging_enabled_
- ? &original_cond_fns_ : &evthread_cond_fns_;
+ struct evthread_condition_callbacks *target = evthread_get_condition_callbacks();
if (!cbs) {
if (target->alloc_condition)
diff --git a/contrib/ntp/sntp/libevent/evutil.c b/contrib/ntp/sntp/libevent/evutil.c
index c28cade..3d72e40 100644
--- a/contrib/ntp/sntp/libevent/evutil.c
+++ b/contrib/ntp/sntp/libevent/evutil.c
@@ -368,6 +368,20 @@ evutil_make_listen_socket_reuseable(evutil_socket_t sock)
}
int
+evutil_make_listen_socket_reuseable_port(evutil_socket_t sock)
+{
+#if defined __linux__ && defined(SO_REUSEPORT)
+ int one = 1;
+ /* REUSEPORT on Linux 3.9+ means, "Multiple servers (processes or
+ * threads) can bind to the same port if they each set the option. */
+ return setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (void*) &one,
+ (ev_socklen_t)sizeof(one));
+#else
+ return 0;
+#endif
+}
+
+int
evutil_make_tcp_listen_socket_deferred(evutil_socket_t sock)
{
#if defined(EVENT__HAVE_NETINET_TCP_H) && defined(TCP_DEFER_ACCEPT)
@@ -652,7 +666,7 @@ evutil_check_ifaddrs(void)
"GetAdaptersInfo", but that's deprecated; let's just try
GetAdaptersAddresses and fall back to connect+getsockname.
*/
- HANDLE lib = evutil_load_windows_system_library_(TEXT("ihplapi.dll"));
+ HMODULE lib = evutil_load_windows_system_library_(TEXT("ihplapi.dll"));
GetAdaptersAddresses_fn_t fn;
ULONG size, res;
IP_ADAPTER_ADDRESSES *addresses = NULL, *address;
@@ -1918,15 +1932,15 @@ evutil_inet_pton(int af, const char *src, void *dst)
return inet_pton(af, src, dst);
#else
if (af == AF_INET) {
- int a,b,c,d;
+ unsigned a,b,c,d;
char more;
struct in_addr *addr = dst;
- if (sscanf(src, "%d.%d.%d.%d%c", &a,&b,&c,&d,&more) != 4)
+ if (sscanf(src, "%u.%u.%u.%u%c", &a,&b,&c,&d,&more) != 4)
return 0;
- if (a < 0 || a > 255) return 0;
- if (b < 0 || b > 255) return 0;
- if (c < 0 || c > 255) return 0;
- if (d < 0 || d > 255) return 0;
+ if (a > 255) return 0;
+ if (b > 255) return 0;
+ if (c > 255) return 0;
+ if (d > 255) return 0;
addr->s_addr = htonl((a<<24) | (b<<16) | (c<<8) | d);
return 1;
#ifdef AF_INET6
@@ -1941,7 +1955,7 @@ evutil_inet_pton(int af, const char *src, void *dst)
else if (!dot)
eow = src+strlen(src);
else {
- int byte1,byte2,byte3,byte4;
+ unsigned byte1,byte2,byte3,byte4;
char more;
for (eow = dot-1; eow >= src && EVUTIL_ISDIGIT_(*eow); --eow)
;
@@ -1949,14 +1963,14 @@ evutil_inet_pton(int af, const char *src, void *dst)
/* We use "scanf" because some platform inet_aton()s are too lax
* about IPv4 addresses of the form "1.2.3" */
- if (sscanf(eow, "%d.%d.%d.%d%c",
+ if (sscanf(eow, "%u.%u.%u.%u%c",
&byte1,&byte2,&byte3,&byte4,&more) != 4)
return 0;
- if (byte1 > 255 || byte1 < 0 ||
- byte2 > 255 || byte2 < 0 ||
- byte3 > 255 || byte3 < 0 ||
- byte4 > 255 || byte4 < 0)
+ if (byte1 > 255 ||
+ byte2 > 255 ||
+ byte3 > 255 ||
+ byte4 > 255)
return 0;
words[6] = (byte1<<8) | byte2;
@@ -2453,7 +2467,7 @@ evutil_hex_char_to_int_(char c)
}
#ifdef _WIN32
-HANDLE
+HMODULE
evutil_load_windows_system_library_(const TCHAR *library_name)
{
TCHAR path[MAX_PATH];
diff --git a/contrib/ntp/sntp/libevent/evutil_time.c b/contrib/ntp/sntp/libevent/evutil_time.c
index e433043..8f53c66 100644
--- a/contrib/ntp/sntp/libevent/evutil_time.c
+++ b/contrib/ntp/sntp/libevent/evutil_time.c
@@ -54,6 +54,7 @@
#include "event2/util.h"
#include "util-internal.h"
#include "log-internal.h"
+#include "mm-internal.h"
#ifndef EVENT__HAVE_GETTIMEOFDAY
/* No gettimeofday; this must be windows. */
@@ -160,6 +161,55 @@ adjust_monotonic_time(struct evutil_monotonic_timer *base,
base->last_time = *tv;
}
+/*
+ Allocate a new struct evutil_monotonic_timer
+ */
+struct evutil_monotonic_timer *
+evutil_monotonic_timer_new(void)
+{
+ struct evutil_monotonic_timer *p = NULL;
+
+ p = mm_malloc(sizeof(*p));
+ if (!p) goto done;
+
+ memset(p, 0, sizeof(*p));
+
+ done:
+ return p;
+}
+
+/*
+ Free a struct evutil_monotonic_timer
+ */
+void
+evutil_monotonic_timer_free(struct evutil_monotonic_timer *timer)
+{
+ if (timer) {
+ mm_free(timer);
+ }
+}
+
+/*
+ Set up a struct evutil_monotonic_timer for initial use
+ */
+int
+evutil_configure_monotonic_time(struct evutil_monotonic_timer *timer,
+ int flags)
+{
+ return evutil_configure_monotonic_time_(timer, flags);
+}
+
+/*
+ Query the current monotonic time
+ */
+int
+evutil_gettime_monotonic(struct evutil_monotonic_timer *timer,
+ struct timeval *tp)
+{
+ return evutil_gettime_monotonic_(timer, tp);
+}
+
+
#if defined(HAVE_POSIX_MONOTONIC)
/* =====
The POSIX clock_gettime() interface provides a few ways to get at a
diff --git a/contrib/ntp/sntp/libevent/ht-internal.h b/contrib/ntp/sntp/libevent/ht-internal.h
index 8842f4c..50375bb 100644
--- a/contrib/ntp/sntp/libevent/ht-internal.h
+++ b/contrib/ntp/sntp/libevent/ht-internal.h
@@ -380,7 +380,6 @@ ht_string_hash_(const char *s)
{ \
if (head->hth_table) \
freefn(head->hth_table); \
- head->hth_table_length = 0; \
name##_HT_INIT(head); \
} \
/* Debugging helper: return false iff the representation of 'head' is \
diff --git a/contrib/ntp/sntp/libevent/http-internal.h b/contrib/ntp/sntp/libevent/http-internal.h
index 82dd402..a83160c 100644
--- a/contrib/ntp/sntp/libevent/http-internal.h
+++ b/contrib/ntp/sntp/libevent/http-internal.h
@@ -74,6 +74,7 @@ struct evhttp_connection {
#define EVHTTP_CON_INCOMING 0x0001 /* only one request on it ever */
#define EVHTTP_CON_OUTGOING 0x0002 /* multiple requests possible */
#define EVHTTP_CON_CLOSEDETECT 0x0004 /* detecting if persistent close */
+#define EVHTTP_CON_AUTOFREE 0x0008 /* set when we want to auto free the connection */
struct timeval timeout; /* timeout for events */
int retry_cnt; /* retry count */
@@ -99,6 +100,7 @@ struct evhttp_connection {
struct event_base *base;
struct evdns_base *dns_base;
+ int ai_family;
/* Saved conn_addr, to extract IP address from it.
*
diff --git a/contrib/ntp/sntp/libevent/http.c b/contrib/ntp/sntp/libevent/http.c
index 5147022..dd8c9cf 100644
--- a/contrib/ntp/sntp/libevent/http.c
+++ b/contrib/ntp/sntp/libevent/http.c
@@ -769,6 +769,7 @@ evhttp_connection_done(struct evhttp_connection *evcon)
{
struct evhttp_request *req = TAILQ_FIRST(&evcon->requests);
int con_outgoing = evcon->flags & EVHTTP_CON_OUTGOING;
+ int free_evcon = 0;
if (con_outgoing) {
/* idle or close the connection */
@@ -801,6 +802,12 @@ evhttp_connection_done(struct evhttp_connection *evcon)
* need to detect if the other side closes it.
*/
evhttp_connection_start_detectclose(evcon);
+ } else if ((evcon->flags & EVHTTP_CON_AUTOFREE)) {
+ /*
+ * If we have no more requests that need completion
+ * and we're not waiting for the connection to close
+ */
+ free_evcon = 1;
}
} else {
/*
@@ -819,6 +826,16 @@ evhttp_connection_done(struct evhttp_connection *evcon)
if (con_outgoing && ((req->flags & EVHTTP_USER_OWNED) == 0)) {
evhttp_request_free(req);
}
+
+ /* If this was the last request of an outgoing connection and we're
+ * not waiting to receive a connection close event and we want to
+ * automatically free the connection. We check to ensure our request
+ * list is empty one last time just in case our callback added a
+ * new request.
+ */
+ if (free_evcon && TAILQ_FIRST(&evcon->requests) == NULL) {
+ evhttp_connection_free(evcon);
+ }
}
/*
@@ -1175,6 +1192,11 @@ evhttp_connection_free(struct evhttp_connection *evcon)
}
void
+evhttp_connection_free_on_completion(struct evhttp_connection *evcon) {
+ evcon->flags |= EVHTTP_CON_AUTOFREE;
+}
+
+void
evhttp_connection_set_local_address(struct evhttp_connection *evcon,
const char *address)
{
@@ -1243,6 +1265,7 @@ evhttp_connection_reset_(struct evhttp_connection *evcon)
shutdown(evcon->fd, EVUTIL_SHUT_WR);
evutil_closesocket(evcon->fd);
+ bufferevent_setfd(evcon->bufev, -1);
evcon->fd = -1;
}
@@ -1285,6 +1308,7 @@ evhttp_connection_cb_cleanup(struct evhttp_connection *evcon)
{
struct evcon_requestq requests;
+ evhttp_connection_reset_(evcon);
if (evcon->retry_max < 0 || evcon->retry_cnt < evcon->retry_max) {
struct timeval tv_retry = evcon->initial_retry_timeout;
int i;
@@ -1306,7 +1330,6 @@ evhttp_connection_cb_cleanup(struct evhttp_connection *evcon)
evcon->retry_cnt++;
return;
}
- evhttp_connection_reset_(evcon);
/*
* User callback can do evhttp_make_request() on the same
@@ -1385,6 +1408,17 @@ evhttp_error_cb(struct bufferevent *bufev, short what, void *arg)
*/
EVUTIL_ASSERT(evcon->state == EVCON_IDLE);
evhttp_connection_reset_(evcon);
+
+ /*
+ * If we have no more requests that need completion
+ * and we want to auto-free the connection when all
+ * requests have been completed.
+ */
+ if (TAILQ_FIRST(&evcon->requests) == NULL
+ && (evcon->flags & EVHTTP_CON_OUTGOING)
+ && (evcon->flags & EVHTTP_CON_AUTOFREE)) {
+ evhttp_connection_free(evcon);
+ }
return;
}
@@ -2267,6 +2301,7 @@ evhttp_connection_base_bufferevent_new(struct event_base *base, struct evdns_bas
evhttp_deferred_read_cb, evcon);
evcon->dns_base = dnsbase;
+ evcon->ai_family = AF_UNSPEC;
return (evcon);
@@ -2294,6 +2329,12 @@ evhttp_connection_base_new(struct event_base *base, struct evdns_base *dnsbase,
return evhttp_connection_base_bufferevent_new(base, dnsbase, NULL, address, port);
}
+void evhttp_connection_set_family(struct evhttp_connection *evcon,
+ int family)
+{
+ evcon->ai_family = family;
+}
+
void
evhttp_connection_set_base(struct evhttp_connection *evcon,
struct event_base *base)
@@ -2419,7 +2460,7 @@ evhttp_connection_connect_(struct evhttp_connection *evcon)
evcon->state = EVCON_CONNECTING;
if (bufferevent_socket_connect_hostname(evcon->bufev, evcon->dns_base,
- AF_UNSPEC, evcon->address, evcon->port) < 0) {
+ evcon->ai_family, evcon->address, evcon->port) < 0) {
evcon->state = old_state;
event_sock_warn(evcon->fd, "%s: connection to \"%s\" failed",
__func__, evcon->address);
@@ -4289,6 +4330,8 @@ parse_port(const char *s, const char *eos)
portnum = (portnum * 10) + (*s - '0');
if (portnum < 0)
return -1;
+ if (portnum > 65535)
+ return -1;
++s;
}
return portnum;
diff --git a/contrib/ntp/sntp/libevent/include/event2/buffer.h b/contrib/ntp/sntp/libevent/include/event2/buffer.h
index 839d6e7..468588b 100644
--- a/contrib/ntp/sntp/libevent/include/event2/buffer.h
+++ b/contrib/ntp/sntp/libevent/include/event2/buffer.h
@@ -105,13 +105,8 @@ struct evbuffer
Used when repeatedly searching through a buffer. Calling any function
that modifies or re-packs the buffer contents may invalidate all
- evbuffer_ptrs for that buffer. Do not modify these values except with
- evbuffer_ptr_set.
-
- Used when repeatedly searching through a buffer. Calls to any function
- that modifies or re-packs the buffer contents may invalidate all
- evbuffer_ptrs for that buffer. Do not modify these values except with
- evbuffer_ptr_set.
+ evbuffer_ptrs for that buffer. Do not modify or contruct these values
+ except with evbuffer_ptr_set.
An evbuffer_ptr can represent any position from the start of a buffer up
to a position immediately after the end of a buffer.
@@ -787,7 +782,7 @@ enum evbuffer_ptr_how {
There are two ways to use this function: you can call
evbuffer_ptr_set(buf, &pos, N, EVBUFFER_PTR_SET)
to move 'pos' to a position 'N' bytes after the start of the buffer, or
- evbuffer_ptr_set(buf, &pos, N, EVBUFFER_PTR_SET)
+ evbuffer_ptr_set(buf, &pos, N, EVBUFFER_PTR_ADD)
to move 'pos' forward by 'N' bytes.
If evbuffer_ptr is not initialized, this function can only be called
diff --git a/contrib/ntp/sntp/libevent/include/event2/bufferevent.h b/contrib/ntp/sntp/libevent/include/event2/bufferevent.h
index 46203b0..fe8a74d 100644
--- a/contrib/ntp/sntp/libevent/include/event2/bufferevent.h
+++ b/contrib/ntp/sntp/libevent/include/event2/bufferevent.h
@@ -535,8 +535,9 @@ void bufferevent_setwatermark(struct bufferevent *bufev, short events,
size_t lowmark, size_t highmark);
/**
- Retrieves the watermarks for read or write events. Result is undefined if
- events contains both EV_READ and EV_WRITE.
+ Retrieves the watermarks for read or write events.
+ Returns non-zero if events contains not only EV_READ or EV_WRITE.
+ Returns zero if events equal EV_READ or EV_WRITE
@param bufev the bufferevent to be examined
@param events EV_READ or EV_WRITE
@@ -544,7 +545,7 @@ void bufferevent_setwatermark(struct bufferevent *bufev, short events,
@param highmark receives the high watermark if not NULL
*/
EVENT2_EXPORT_SYMBOL
-void bufferevent_getwatermark(struct bufferevent *bufev, short events,
+int bufferevent_getwatermark(struct bufferevent *bufev, short events,
size_t *lowmark, size_t *highmark);
/**
@@ -598,7 +599,7 @@ enum bufferevent_trigger_options {
BEV_TRIG_IGNORE_WATERMARKS = (1<<16),
/** defer even if the callbacks are not */
- BEV_TRIG_DEFER_CALLBACKS = BEV_OPT_DEFER_CALLBACKS,
+ BEV_TRIG_DEFER_CALLBACKS = BEV_OPT_DEFER_CALLBACKS
/* (Note: for internal reasons, these need to be disjoint from
* bufferevent_options, except when they mean the same thing. */
diff --git a/contrib/ntp/sntp/libevent/include/event2/dns.h b/contrib/ntp/sntp/libevent/include/event2/dns.h
index a00c83e..17cd86a 100644
--- a/contrib/ntp/sntp/libevent/include/event2/dns.h
+++ b/contrib/ntp/sntp/libevent/include/event2/dns.h
@@ -453,7 +453,7 @@ int evdns_base_set_option(struct evdns_base *base, const char *option, const cha
@param base the evdns_base to which to apply this operation
@param flags any of DNS_OPTION_NAMESERVERS|DNS_OPTION_SEARCH|DNS_OPTION_MISC|
- DNS_OPTIONS_HOSTSFILE|DNS_OPTIONS_ALL
+ DNS_OPTION_HOSTSFILE|DNS_OPTIONS_ALL
@param filename the path to the resolv.conf file
@return 0 if successful, or various positive error codes if an error
occurred (see above)
@@ -694,6 +694,22 @@ struct evdns_getaddrinfo_request *evdns_getaddrinfo(
EVENT2_EXPORT_SYMBOL
void evdns_getaddrinfo_cancel(struct evdns_getaddrinfo_request *req);
+/**
+ Retrieve the address of the 'idx'th configured nameserver.
+
+ @param base The evdns_base to examine.
+ @param idx The index of the nameserver to get the address of.
+ @param sa A location to receive the server's address.
+ @param len The number of bytes available at sa.
+
+ @return the number of bytes written into sa on success. On failure, returns
+ -1 if idx is greater than the number of configured nameservers, or a
+ value greater than 'len' if len was not high enough.
+ */
+EVENT2_EXPORT_SYMBOL
+int evdns_base_get_nameserver_addr(struct evdns_base *base, int idx,
+ struct sockaddr *sa, ev_socklen_t len);
+
#ifdef __cplusplus
}
#endif
diff --git a/contrib/ntp/sntp/libevent/include/event2/event.h b/contrib/ntp/sntp/libevent/include/event2/event.h
index 6e2b884..570031f 100644
--- a/contrib/ntp/sntp/libevent/include/event2/event.h
+++ b/contrib/ntp/sntp/libevent/include/event2/event.h
@@ -396,6 +396,12 @@ const char *event_base_get_method(const struct event_base *);
EVENT2_EXPORT_SYMBOL
const char **event_get_supported_methods(void);
+/** Query the current monotonic time from a the timer for a struct
+ * event_base.
+ */
+EVENT2_EXPORT_SYMBOL
+int event_gettime_monotonic(struct event_base *base, struct timeval *tp);
+
/**
@name event type flag
@@ -771,6 +777,10 @@ void event_set_fatal_callback(event_fatal_cb cb);
EVENT2_EXPORT_SYMBOL
void event_enable_debug_logging(ev_uint32_t which);
+EVENT2_EXPORT_SYMBOL
+void
+event_disable_debug_mode(void);
+
/**
Associate a different event base with an event.
diff --git a/contrib/ntp/sntp/libevent/include/event2/http.h b/contrib/ntp/sntp/libevent/include/event2/http.h
index 81f44b8..4284d5f 100644
--- a/contrib/ntp/sntp/libevent/include/event2/http.h
+++ b/contrib/ntp/sntp/libevent/include/event2/http.h
@@ -630,6 +630,12 @@ struct evhttp_connection *evhttp_connection_base_new(
struct event_base *base, struct evdns_base *dnsbase,
const char *address, unsigned short port);
+/**
+ * Set family hint for DNS requests.
+ */
+void evhttp_connection_set_family(struct evhttp_connection *evcon,
+ int family);
+
/** Takes ownership of the request object
*
* Can be used in a request callback to keep onto the request until
@@ -669,6 +675,14 @@ void evhttp_connection_set_max_body_size(struct evhttp_connection* evcon,
EVENT2_EXPORT_SYMBOL
void evhttp_connection_free(struct evhttp_connection *evcon);
+/** Disowns a given connection object
+ *
+ * Can be used to tell libevent to free the connection object after
+ * the last request has completed or failed.
+ */
+EVENT2_EXPORT_SYMBOL
+void evhttp_connection_free_on_completion(struct evhttp_connection *evcon);
+
/** sets the ip address from which http connections are made */
EVENT2_EXPORT_SYMBOL
void evhttp_connection_set_local_address(struct evhttp_connection *evcon,
diff --git a/contrib/ntp/sntp/libevent/include/event2/listener.h b/contrib/ntp/sntp/libevent/include/event2/listener.h
index 8c77803..84b4da0 100644
--- a/contrib/ntp/sntp/libevent/include/event2/listener.h
+++ b/contrib/ntp/sntp/libevent/include/event2/listener.h
@@ -88,6 +88,15 @@ typedef void (*evconnlistener_errorcb)(struct evconnlistener *, void *);
* to use the option before it is actually bound.
*/
#define LEV_OPT_DEFERRED_ACCEPT (1u<<6)
+/** Flag: Indicates that we ask to allow multiple servers (processes or
+ * threads) to bind to the same port if they each set the option.
+ *
+ * SO_REUSEPORT is what most people would expect SO_REUSEADDR to be, however
+ * SO_REUSEPORT does not imply SO_REUSEADDR.
+ *
+ * This is only available on Linux and kernel 3.9+
+ */
+#define LEV_OPT_REUSEABLE_PORT (1u<<7)
/**
Allocate a new evconnlistener object to listen for incoming TCP connections
diff --git a/contrib/ntp/sntp/libevent/include/event2/util.h b/contrib/ntp/sntp/libevent/include/event2/util.h
index 14c6a25..b152a4b 100644
--- a/contrib/ntp/sntp/libevent/include/event2/util.h
+++ b/contrib/ntp/sntp/libevent/include/event2/util.h
@@ -292,6 +292,62 @@ extern "C" {
#define evutil_socket_t int
#endif
+/**
+ * Structure to hold information about a monotonic timer
+ *
+ * Use this with evutil_configure_monotonic_time() and
+ * evutil_gettime_monotonic().
+ *
+ * This is an opaque structure; you can allocate one using
+ * evutil_monotonic_timer_new().
+ *
+ * @see evutil_monotonic_timer_new(), evutil_monotonic_timer_free(),
+ * evutil_configure_monotonic_time(), evutil_gettime_monotonic()
+ */
+struct evutil_monotonic_timer
+#ifdef EVENT_IN_DOXYGEN_
+{/*Empty body so that doxygen will generate documentation here.*/}
+#endif
+;
+
+#define EV_MONOT_PRECISE 1
+#define EV_MONOT_FALLBACK 2
+
+/** Allocate a new struct evutil_monotonic_timer for use with the
+ * evutil_configure_monotonic_time() and evutil_gettime_monotonic()
+ * functions. You must configure the timer with
+ * evutil_configure_monotonic_time() before using it.
+ */
+EVENT2_EXPORT_SYMBOL
+struct evutil_monotonic_timer * evutil_monotonic_timer_new(void);
+
+/** Free a struct evutil_monotonic_timer that was allocated using
+ * evutil_monotonic_timer_new().
+ */
+EVENT2_EXPORT_SYMBOL
+void evutil_monotonic_timer_free(struct evutil_monotonic_timer *timer);
+
+/** Set up a struct evutil_monotonic_timer; flags can include
+ * EV_MONOT_PRECISE and EV_MONOT_FALLBACK.
+ */
+EVENT2_EXPORT_SYMBOL
+int evutil_configure_monotonic_time(struct evutil_monotonic_timer *timer,
+ int flags);
+
+/** Query the current monotonic time from a struct evutil_monotonic_timer
+ * previously configured with evutil_configure_monotonic_time(). Monotonic
+ * time is guaranteed never to run in reverse, but is not necessarily epoch-
+ * based, or relative to any other definite point. Use it to make reliable
+ * measurements of elapsed time between events even when the system time
+ * may be changed.
+ *
+ * It is not safe to use this funtion on the same timer from multiple
+ * threads.
+ */
+EVENT2_EXPORT_SYMBOL
+int evutil_gettime_monotonic(struct evutil_monotonic_timer *timer,
+ struct timeval *tp);
+
/** Create two new sockets that are connected to each other.
On Unix, this simply calls socketpair(). On Windows, it uses the
@@ -327,6 +383,19 @@ int evutil_make_socket_nonblocking(evutil_socket_t sock);
EVENT2_EXPORT_SYMBOL
int evutil_make_listen_socket_reuseable(evutil_socket_t sock);
+/** Do platform-specific operations to make a listener port reusable.
+
+ Specifically, we want to make sure that multiple programs which also
+ set the same socket option will be able to bind, listen at the same time.
+
+ This is a feature available only to Linux 3.9+
+
+ @param sock The socket to make reusable
+ @return 0 on success, -1 on failure
+ */
+EVENT2_EXPORT_SYMBOL
+int evutil_make_listen_socket_reuseable_port(evutil_socket_t sock);
+
/** Do platform-specific operations as needed to close a socket upon a
successful execution of one of the exec*() functions.
diff --git a/contrib/ntp/sntp/libevent/kqueue.c b/contrib/ntp/sntp/libevent/kqueue.c
index 3933467..a6578df 100644
--- a/contrib/ntp/sntp/libevent/kqueue.c
+++ b/contrib/ntp/sntp/libevent/kqueue.c
@@ -332,6 +332,23 @@ kq_dispatch(struct event_base *base, struct timeval *tv)
* on FreeBSD. */
case EINVAL:
continue;
+#if defined(__FreeBSD__) && defined(ENOTCAPABLE)
+ /*
+ * This currently occurs if an FD is closed
+ * before the EV_DELETE makes it out via kevent().
+ * The FreeBSD capabilities code sees the blank
+ * capability set and rejects the request to
+ * modify an event.
+ *
+ * To be strictly correct - when an FD is closed,
+ * all the registered events are also removed.
+ * Queuing EV_DELETE to a closed FD is wrong.
+ * The event(s) should just be deleted from
+ * the pending changelist.
+ */
+ case ENOTCAPABLE:
+ continue;
+#endif
/* Can occur on a delete if the fd is closed. */
case EBADF:
diff --git a/contrib/ntp/sntp/libevent/listener.c b/contrib/ntp/sntp/libevent/listener.c
index 3272c40..172d292 100644
--- a/contrib/ntp/sntp/libevent/listener.c
+++ b/contrib/ntp/sntp/libevent/listener.c
@@ -235,6 +235,11 @@ evconnlistener_new_bind(struct event_base *base, evconnlistener_cb cb,
goto err;
}
+ if (flags & LEV_OPT_REUSEABLE_PORT) {
+ if (evutil_make_listen_socket_reuseable_port(fd) < 0)
+ goto err;
+ }
+
if (flags & LEV_OPT_DEFERRED_ACCEPT) {
if (evutil_make_tcp_listen_socket_deferred(fd) < 0)
goto err;
diff --git a/contrib/ntp/sntp/libevent/m4/acx_pthread.m4 b/contrib/ntp/sntp/libevent/m4/acx_pthread.m4
new file mode 100644
index 0000000..d2b1169
--- /dev/null
+++ b/contrib/ntp/sntp/libevent/m4/acx_pthread.m4
@@ -0,0 +1,279 @@
+##### http://autoconf-archive.cryp.to/acx_pthread.html
+#
+# SYNOPSIS
+#
+# ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+#
+# DESCRIPTION
+#
+# This macro figures out how to build C programs using POSIX threads.
+# It sets the PTHREAD_LIBS output variable to the threads library and
+# linker flags, and the PTHREAD_CFLAGS output variable to any special
+# C compiler flags that are needed. (The user can also force certain
+# compiler flags/libs to be tested by setting these environment
+# variables.)
+#
+# Also sets PTHREAD_CC to any special C compiler that is needed for
+# multi-threaded programs (defaults to the value of CC otherwise).
+# (This is necessary on AIX to use the special cc_r compiler alias.)
+#
+# NOTE: You are assumed to not only compile your program with these
+# flags, but also link it with them as well. e.g. you should link
+# with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
+# $LIBS
+#
+# If you are only building threads programs, you may wish to use
+# these variables in your default LIBS, CFLAGS, and CC:
+#
+# LIBS="$PTHREAD_LIBS $LIBS"
+# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+# CC="$PTHREAD_CC"
+#
+# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
+# constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
+# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
+#
+# ACTION-IF-FOUND is a list of shell commands to run if a threads
+# library is found, and ACTION-IF-NOT-FOUND is a list of commands to
+# run it if it is not found. If ACTION-IF-FOUND is not specified, the
+# default action will define HAVE_PTHREAD.
+#
+# Please let the authors know if this macro fails on any platform, or
+# if you have any other suggestions or comments. This macro was based
+# on work by SGJ on autoconf scripts for FFTW (http://www.fftw.org/)
+# (with help from M. Frigo), as well as ac_pthread and hb_pthread
+# macros posted by Alejandro Forero Cuervo to the autoconf macro
+# repository. We are also grateful for the helpful feedback of
+# numerous users.
+#
+# LAST MODIFICATION
+#
+# 2007-07-29
+#
+# COPYLEFT
+#
+# Copyright (c) 2007 Steven G. Johnson <stevenj@alum.mit.edu>
+#
+# 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 3 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, see
+# <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright
+# owner gives unlimited permission to copy, distribute and modify the
+# configure scripts that are the output of Autoconf when processing
+# the Macro. You need not follow the terms of the GNU General Public
+# License when using or distributing such scripts, even though
+# portions of the text of the Macro appear in them. The GNU General
+# Public License (GPL) does govern all other use of the material that
+# constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the
+# Autoconf Macro released by the Autoconf Macro Archive. When you
+# make and distribute a modified version of the Autoconf Macro, you
+# may extend this special exception to the GPL to apply to your
+# modified version as well.
+
+AC_DEFUN([ACX_PTHREAD], [
+AC_REQUIRE([AC_CANONICAL_HOST])
+AC_LANG_SAVE
+AC_LANG_C
+acx_pthread_ok=no
+
+# We used to check for pthread.h first, but this fails if pthread.h
+# requires special compiler flags (e.g. on True64 or Sequent).
+# It gets checked for in the link test anyway.
+
+# First of all, check if the user has set any of the PTHREAD_LIBS,
+# etcetera environment variables, and if threads linking works using
+# them:
+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
+ AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
+ AC_MSG_RESULT($acx_pthread_ok)
+ if test x"$acx_pthread_ok" = xno; then
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
+ fi
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+fi
+
+# We must check for the threads library under a number of different
+# names; the ordering is very important because some systems
+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+# libraries is broken (non-POSIX).
+
+# Create a list of thread flags to try. Items starting with a "-" are
+# C compiler flags, and other items are library names, except for "none"
+# which indicates that we try without any flags at all, and "pthread-config"
+# which is a program returning the flags for the Pth emulation library.
+
+acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+
+# The ordering *is* (sometimes) important. Some notes on the
+# individual items follow:
+
+# pthreads: AIX (must check this before -lpthread)
+# none: in case threads are in libc; should be tried before -Kthread and
+# other compiler flags to prevent continual compiler warnings
+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
+# -pthreads: Solaris/gcc
+# -mthreads: Mingw32/gcc, Lynx/gcc
+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+# doesn't hurt to check since this sometimes defines pthreads too;
+# also defines -D_REENTRANT)
+# ... -mt is also the pthreads flag for HP/aCC
+# pthread: Linux, etcetera
+# --thread-safe: KAI C++
+# pthread-config: use pthread-config program (for GNU Pth library)
+
+case "${host_cpu}-${host_os}" in
+ *solaris*)
+
+ # On Solaris (at least, for some versions), libc contains stubbed
+ # (non-functional) versions of the pthreads routines, so link-based
+ # tests will erroneously succeed. (We need to link with -pthreads/-mt/
+ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
+ # a function called by this macro, so we could check for that, but
+ # who knows whether they'll stub that too in a future libc.) So,
+ # we'll just look for -pthreads and -lpthread first:
+
+ acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
+ ;;
+esac
+
+if test x"$acx_pthread_ok" = xno; then
+for flag in $acx_pthread_flags; do
+
+ case $flag in
+ none)
+ AC_MSG_CHECKING([whether pthreads work without any flags])
+ ;;
+
+ -*)
+ AC_MSG_CHECKING([whether pthreads work with $flag])
+ PTHREAD_CFLAGS="$flag"
+ ;;
+
+ pthread-config)
+ AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
+ if test x"$acx_pthread_config" = xno; then continue; fi
+ PTHREAD_CFLAGS="`pthread-config --cflags`"
+ PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
+ ;;
+
+ *)
+ AC_MSG_CHECKING([for the pthreads library -l$flag])
+ PTHREAD_LIBS="-l$flag"
+ ;;
+ esac
+
+ save_LIBS="$LIBS"
+ save_CFLAGS="$CFLAGS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+ # Check for various functions. We must include pthread.h,
+ # since some functions may be macros. (On the Sequent, we
+ # need a special flag -Kthread to make this header compile.)
+ # We check for pthread_join because it is in -lpthread on IRIX
+ # while pthread_create is in libc. We check for pthread_attr_init
+ # due to DEC craziness with -lpthreads. We check for
+ # pthread_cleanup_push because it is one of the few pthread
+ # functions on Solaris that doesn't have a non-functional libc stub.
+ # We try pthread_create on general principles.
+ AC_TRY_LINK([#include <pthread.h>],
+ [pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
+ [acx_pthread_ok=yes])
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ AC_MSG_RESULT($acx_pthread_ok)
+ if test "x$acx_pthread_ok" = xyes; then
+ break;
+ fi
+
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
+done
+fi
+
+# Various other checks:
+if test "x$acx_pthread_ok" = xyes; then
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+ # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
+ AC_MSG_CHECKING([for joinable pthread attribute])
+ attr_name=unknown
+ for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+ AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
+ [attr_name=$attr; break])
+ done
+ AC_MSG_RESULT($attr_name)
+ if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
+ AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
+ [Define to necessary symbol if this constant
+ uses a non-standard name on your system.])
+ fi
+
+ AC_MSG_CHECKING([if more special flags are required for pthreads])
+ flag=no
+ case "${host_cpu}-${host_os}" in
+ *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
+ *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
+ esac
+ AC_MSG_RESULT(${flag})
+ if test "x$flag" != xno; then
+ PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
+ fi
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ # More AIX lossage: must compile with xlc_r or cc_r
+ if test x"$GCC" != xyes; then
+ AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
+ else
+ PTHREAD_CC=$CC
+ fi
+else
+ PTHREAD_CC="$CC"
+fi
+
+AC_SUBST(PTHREAD_LIBS)
+AC_SUBST(PTHREAD_CFLAGS)
+AC_SUBST(PTHREAD_CC)
+
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+if test x"$acx_pthread_ok" = xyes; then
+ ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
+ :
+else
+ acx_pthread_ok=no
+ $2
+fi
+AC_LANG_RESTORE
+])dnl ACX_PTHREAD
diff --git a/contrib/ntp/sntp/libevent/sample/http-server.c b/contrib/ntp/sntp/libevent/sample/http-server.c
index 1cb89bc..cbb9c91 100644
--- a/contrib/ntp/sntp/libevent/sample/http-server.c
+++ b/contrib/ntp/sntp/libevent/sample/http-server.c
@@ -246,7 +246,10 @@ send_document_cb(struct evhttp_request *req, void *arg)
goto err;
#endif
- evbuffer_add_printf(evb, "<html>\n <head>\n"
+ evbuffer_add_printf(evb,
+ "<!DOCTYPE html>\n"
+ "<html>\n <head>\n"
+ " <meta charset='utf-8'>\n"
" <title>%s</title>\n"
" <base href='%s%s'>\n"
" </head>\n"
@@ -274,7 +277,7 @@ send_document_cb(struct evhttp_request *req, void *arg)
#endif
evbuffer_add_printf(evb, "</ul></body></html>\n");
#ifdef _WIN32
- CloseHandle(d);
+ FindClose(d);
#else
closedir(d);
#endif
diff --git a/contrib/ntp/sntp/libevent/sample/https-client.c b/contrib/ntp/sntp/libevent/sample/https-client.c
index e13ac4b..fbd5de8 100644
--- a/contrib/ntp/sntp/libevent/sample/https-client.c
+++ b/contrib/ntp/sntp/libevent/sample/https-client.c
@@ -96,7 +96,7 @@ static void
syntax(void)
{
fputs("Syntax:\n", stderr);
- fputs(" https-client -url <https-url> [-data data-file.bin] [-ignore-cert]\n", stderr);
+ fputs(" https-client -url <https-url> [-data data-file.bin] [-ignore-cert] [-retries num]\n", stderr);
fputs("Example:\n", stderr);
fputs(" https-client -url https://ip.appspot.com/\n", stderr);
@@ -195,6 +195,7 @@ main(int argc, char **argv)
const char *scheme, *host, *path, *query;
char uri[256];
int port;
+ int retries = 0;
SSL_CTX *ssl_ctx;
SSL *ssl;
@@ -221,6 +222,12 @@ main(int argc, char **argv)
} else {
syntax();
}
+ } else if (!strcmp("-retries", argv[i])) {
+ if (i < argc - 1) {
+ retries = atoi(argv[i + 1]);
+ } else {
+ syntax();
+ }
} else if (!strcmp("-help", argv[i])) {
syntax();
}
@@ -346,8 +353,10 @@ main(int argc, char **argv)
die_openssl("SSL_new()");
}
+ #ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
// Set hostname for SNI extension
SSL_set_tlsext_host_name(ssl, host);
+ #endif
if (strcasecmp(scheme, "http") == 0) {
bev = bufferevent_socket_new(base, -1, BEV_OPT_CLOSE_ON_FREE);
@@ -373,6 +382,10 @@ main(int argc, char **argv)
return 1;
}
+ if (retries > 0) {
+ evhttp_connection_set_retries(evcon, retries);
+ }
+
// Fire off the request
req = evhttp_request_new(http_request_done, bev);
if (req == NULL) {
@@ -402,7 +415,7 @@ main(int argc, char **argv)
evbuffer_add(output_buffer, buf, s);
bytes += s;
}
- evutil_snprintf(buf, sizeof(buf)-1, "%lu", bytes);
+ evutil_snprintf(buf, sizeof(buf)-1, "%lu", (unsigned long)bytes);
evhttp_add_header(output_headers, "Content-Length", buf);
fclose(f);
}
diff --git a/contrib/ntp/sntp/libevent/sample/include.am b/contrib/ntp/sntp/libevent/sample/include.am
index 81980ac..75f87c7 100644
--- a/contrib/ntp/sntp/libevent/sample/include.am
+++ b/contrib/ntp/sntp/libevent/sample/include.am
@@ -30,7 +30,9 @@ noinst_HEADERS += \
sample/openssl_hostname_validation.h
endif
+if BUILD_SAMPLES
noinst_PROGRAMS += $(SAMPLES)
+endif
$(SAMPLES) : libevent.la
diff --git a/contrib/ntp/sntp/libevent/test/include.am b/contrib/ntp/sntp/libevent/test/include.am
index ca36da4..4cd49ef 100644
--- a/contrib/ntp/sntp/libevent/test/include.am
+++ b/contrib/ntp/sntp/libevent/test/include.am
@@ -49,7 +49,8 @@ TESTS = test/test-script.sh
test/test-script.sh: test/test.sh
cp $(top_srcdir)/test/test.sh $@
-DISTCLEANFILES += test/test-script.sh test/regress.gen.c test/regress.gen.h
+DISTCLEANFILES += test/test-script.sh
+DISTCLEANFILES += test/regress.gen.c test/regress.gen.h
if BUILD_REGRESS
BUILT_SOURCES += test/regress.gen.c test/regress.gen.h
diff --git a/contrib/ntp/sntp/libevent/test/regress.c b/contrib/ntp/sntp/libevent/test/regress.c
index 4d17b67..399ba2f 100644
--- a/contrib/ntp/sntp/libevent/test/regress.c
+++ b/contrib/ntp/sntp/libevent/test/regress.c
@@ -944,17 +944,18 @@ signal_cb(evutil_socket_t fd, short event, void *arg)
}
static void
-test_simplesignal(void)
+test_simplesignal_impl(int find_reorder)
{
struct event ev;
struct itimerval itv;
- setup_test("Simple signal: ");
evsignal_set(&ev, SIGALRM, signal_cb, &ev);
evsignal_add(&ev, NULL);
/* find bugs in which operations are re-ordered */
- evsignal_del(&ev);
- evsignal_add(&ev, NULL);
+ if (find_reorder) {
+ evsignal_del(&ev);
+ evsignal_add(&ev, NULL);
+ }
memset(&itv, 0, sizeof(itv));
itv.it_value.tv_sec = 0;
@@ -971,6 +972,20 @@ test_simplesignal(void)
}
static void
+test_simplestsignal(void)
+{
+ setup_test("Simplest one signal: ");
+ test_simplesignal_impl(0);
+}
+
+static void
+test_simplesignal(void)
+{
+ setup_test("Simple signal: ");
+ test_simplesignal_impl(1);
+}
+
+static void
test_multiplesignal(void)
{
struct event ev_one, ev_two;
@@ -1658,7 +1673,7 @@ static void
test_active_later(void *ptr)
{
struct basic_test_data *data = ptr;
- struct event *ev1, *ev2;
+ struct event *ev1 = NULL, *ev2 = NULL;
struct event ev3, ev4;
struct timeval qsec = {0, 100000};
ev1 = event_new(data->base, data->pair[0], EV_READ|EV_PERSIST, read_and_drain_cb, NULL);
@@ -1693,10 +1708,15 @@ test_active_later(void *ptr)
* it. */
event_active_later_(&ev3, EV_READ);
event_base_assert_ok_(data->base);
+
+end:
+ if (ev1)
+ event_free(ev1);
+ if (ev2)
+ event_free(ev2);
+
event_base_free(data->base);
data->base = NULL;
-end:
- ;
}
@@ -2281,7 +2301,7 @@ evtag_fuzz(void *ptr)
for (j = 0; j < 100; j++) {
for (i = 0; i < (int)sizeof(buffer); i++)
- buffer[i] = rand();
+ buffer[i] = test_weakrand();
evbuffer_drain(tmp, -1);
evbuffer_add(tmp, buffer, sizeof(buffer));
@@ -3294,6 +3314,7 @@ struct testcase_t evtag_testcases[] = {
struct testcase_t signal_testcases[] = {
#ifndef _WIN32
+ LEGACY(simplestsignal, TT_ISOLATED),
LEGACY(simplesignal, TT_ISOLATED),
LEGACY(multiplesignal, TT_ISOLATED),
LEGACY(immediatesignal, TT_ISOLATED),
diff --git a/contrib/ntp/sntp/libevent/test/regress.h b/contrib/ntp/sntp/libevent/test/regress.h
index a9892b0..bbfefe6 100644
--- a/contrib/ntp/sntp/libevent/test/regress.h
+++ b/contrib/ntp/sntp/libevent/test/regress.h
@@ -53,6 +53,10 @@ extern struct testcase_t listener_testcases[];
extern struct testcase_t listener_iocp_testcases[];
extern struct testcase_t thread_testcases[];
+extern struct evutil_weakrand_state test_weakrand_state;
+
+#define test_weakrand() (evutil_weakrand_(&test_weakrand_state))
+
void regress_threads(void *);
void test_bufferevent_zlib(void *);
@@ -114,7 +118,7 @@ int test_ai_eq_(const struct evutil_addrinfo *ai, const char *sockaddr_port,
} while (0)
#define test_timeval_diff_leq(tv1, tv2, diff, tolerance) \
- tt_int_op(abs(timeval_msec_diff((tv1), (tv2)) - diff), <=, tolerance)
+ tt_int_op(labs(timeval_msec_diff((tv1), (tv2)) - diff), <=, tolerance)
#define test_timeval_diff_eq(tv1, tv2, diff) \
test_timeval_diff_leq((tv1), (tv2), (diff), 50)
diff --git a/contrib/ntp/sntp/libevent/test/regress_buffer.c b/contrib/ntp/sntp/libevent/test/regress_buffer.c
index ccb1487..4d6a5de 100644
--- a/contrib/ntp/sntp/libevent/test/regress_buffer.c
+++ b/contrib/ntp/sntp/libevent/test/regress_buffer.c
@@ -246,7 +246,7 @@ test_evbuffer(void *ptr)
if (memcmp(evbuffer_pullup(
evb, -1), buffer, sizeof(buffer) / 2) != 0 ||
memcmp(evbuffer_pullup(
- evb_two, -1), buffer, sizeof(buffer) != 0))
+ evb_two, -1), buffer, sizeof(buffer)) != 0)
tt_abort_msg("Pullup did not preserve content");
evbuffer_validate(evb);
@@ -863,6 +863,10 @@ test_evbuffer_add_file(void *ptr)
evutil_closesocket(pair[0]);
if (pair[1] >= 0)
evutil_closesocket(pair[1]);
+ if (wev)
+ event_free(wev);
+ if (rev)
+ event_free(rev);
if (tmpfilename) {
unlink(tmpfilename);
free(tmpfilename);
@@ -1534,9 +1538,9 @@ test_evbuffer_callbacks(void *ptr)
tt_assert(!evbuffer_remove_cb(buf, log_change_callback, buf_out2));
evbuffer_validate(buf);
- tt_str_op(evbuffer_pullup(buf_out1, -1), ==,
+ tt_str_op((const char *) evbuffer_pullup(buf_out1, -1), ==,
"0->36; 36->26; 26->31; 31->38; ");
- tt_str_op(evbuffer_pullup(buf_out2, -1), ==,
+ tt_str_op((const char *) evbuffer_pullup(buf_out2, -1), ==,
"0->36; 31->38; 38->0; 0->1; ");
evbuffer_drain(buf_out1, evbuffer_get_length(buf_out1));
evbuffer_drain(buf_out2, evbuffer_get_length(buf_out2));
@@ -1552,7 +1556,7 @@ test_evbuffer_callbacks(void *ptr)
tt_uint_op(evbuffer_get_length(buf_out2), ==, 0);
evbuffer_setcb(buf, NULL, NULL);
evbuffer_add_printf(buf, "This will not.");
- tt_str_op(evbuffer_pullup(buf, -1), ==, "This will not.");
+ tt_str_op((const char *) evbuffer_pullup(buf, -1), ==, "This will not.");
evbuffer_validate(buf);
evbuffer_drain(buf, evbuffer_get_length(buf));
evbuffer_validate(buf);
@@ -1660,7 +1664,7 @@ test_evbuffer_add_reference(void *ptr)
evbuffer_add(buf1, "You shake and shake the ", 24);
evbuffer_add_reference(buf1, "ketchup bottle", 14, ref_done_cb,
(void*)3333);
- evbuffer_add(buf1, ". Nothing comes and then a lot'll.", 42);
+ evbuffer_add(buf1, ". Nothing comes and then a lot'll.", 35);
evbuffer_free(buf1);
buf1 = NULL;
tt_int_op(ref_done_cb_called_count, ==, 3);
@@ -1840,6 +1844,42 @@ end:
}
static void
+test_evbuffer_peek_first_gt(void *info)
+{
+ struct evbuffer *buf = NULL, *tmp_buf = NULL;
+ struct evbuffer_ptr ptr;
+ struct evbuffer_iovec v[2];
+
+ buf = evbuffer_new();
+ tmp_buf = evbuffer_new();
+ evbuffer_add_printf(tmp_buf, "Contents of chunk 100\n");
+ evbuffer_add_buffer(buf, tmp_buf);
+ evbuffer_add_printf(tmp_buf, "Contents of chunk 1\n");
+ evbuffer_add_buffer(buf, tmp_buf);
+
+ evbuffer_ptr_set(buf, &ptr, 0, EVBUFFER_PTR_SET);
+
+ /** The only case that matters*/
+ tt_int_op(evbuffer_peek(buf, -1, &ptr, NULL, 0), ==, 2);
+ /** Just in case */
+ tt_int_op(evbuffer_peek(buf, -1, &ptr, v, 2), ==, 2);
+
+ evbuffer_ptr_set(buf, &ptr, 20, EVBUFFER_PTR_ADD);
+ tt_int_op(evbuffer_peek(buf, -1, &ptr, NULL, 0), ==, 2);
+ tt_int_op(evbuffer_peek(buf, -1, &ptr, v, 2), ==, 2);
+ tt_int_op(evbuffer_peek(buf, 2, &ptr, NULL, 0), ==, 1);
+ tt_int_op(evbuffer_peek(buf, 2, &ptr, v, 2), ==, 1);
+ tt_int_op(evbuffer_peek(buf, 3, &ptr, NULL, 0), ==, 2);
+ tt_int_op(evbuffer_peek(buf, 3, &ptr, v, 2), ==, 2);
+
+end:
+ if (buf)
+ evbuffer_free(buf);
+ if (tmp_buf)
+ evbuffer_free(tmp_buf);
+}
+
+static void
test_evbuffer_peek(void *info)
{
struct evbuffer *buf = NULL, *tmp_buf = NULL;
@@ -2096,7 +2136,7 @@ test_evbuffer_copyout(void *dummy)
"When the rich Allobrogenses never kept amanuenses, "
"And our only plots were piled in lakes at Berne.";
/* -- Kipling, "In The Neolithic Age" */
- char tmp[256];
+ char tmp[1024];
struct evbuffer_ptr ptr;
struct evbuffer *buf;
@@ -2206,6 +2246,7 @@ struct testcase_t evbuffer_testcases[] = {
{ "multicast_drain", test_evbuffer_multicast_drain, 0, NULL, NULL },
{ "prepend", test_evbuffer_prepend, TT_FORK, NULL, NULL },
{ "peek", test_evbuffer_peek, 0, NULL, NULL },
+ { "peek_first_gt", test_evbuffer_peek_first_gt, 0, NULL, NULL },
{ "freeze_start", test_evbuffer_freeze, 0, &nil_setup, (void*)"start" },
{ "freeze_end", test_evbuffer_freeze, 0, &nil_setup, (void*)"end" },
{ "add_iovec", test_evbuffer_add_iovec, 0, NULL, NULL},
diff --git a/contrib/ntp/sntp/libevent/test/regress_bufferevent.c b/contrib/ntp/sntp/libevent/test/regress_bufferevent.c
index 4ec2dcc..a1998ba 100644
--- a/contrib/ntp/sntp/libevent/test/regress_bufferevent.c
+++ b/contrib/ntp/sntp/libevent/test/regress_bufferevent.c
@@ -75,6 +75,7 @@
#include "event2/util.h"
#include "bufferevent-internal.h"
+#include "evthread-internal.h"
#include "util-internal.h"
#ifdef _WIN32
#include "iocp-internal.h"
@@ -173,9 +174,9 @@ test_bufferevent_impl(int use_pair)
event_dispatch();
- bufferevent_free(bev1);
- tt_ptr_op(bufferevent_pair_get_partner(bev2), ==, NULL);
bufferevent_free(bev2);
+ tt_ptr_op(bufferevent_pair_get_partner(bev1), ==, NULL);
+ bufferevent_free(bev1);
if (test_ok != 2)
test_ok = 0;
@@ -195,6 +196,143 @@ test_bufferevent_pair(void)
test_bufferevent_impl(1);
}
+#if defined(EVTHREAD_USE_PTHREADS_IMPLEMENTED)
+/**
+ * Trace lock/unlock/alloc/free for locks.
+ * (More heavier then evthread_debug*)
+ */
+typedef struct
+{
+ void *lock;
+ enum {
+ ALLOC, FREE,
+ } status;
+ size_t locked /** allow recursive locking */;
+} lock_wrapper;
+struct lock_unlock_base
+{
+ /* Original callbacks */
+ struct evthread_lock_callbacks cbs;
+ /* Map of locks */
+ lock_wrapper *locks;
+ size_t nr_locks;
+} lu_base = {
+ .locks = NULL,
+};
+
+static lock_wrapper *lu_find(void *lock_)
+{
+ size_t i;
+ for (i = 0; i < lu_base.nr_locks; ++i) {
+ lock_wrapper *lock = &lu_base.locks[i];
+ if (lock->lock == lock_)
+ return lock;
+ }
+ return NULL;
+}
+
+static void *trace_lock_alloc(unsigned locktype)
+{
+ ++lu_base.nr_locks;
+ lu_base.locks = realloc(lu_base.locks,
+ sizeof(lock_wrapper) * lu_base.nr_locks);
+ void *lock = lu_base.cbs.alloc(locktype);
+ lu_base.locks[lu_base.nr_locks - 1] = (lock_wrapper){ lock, ALLOC, 0 };
+ return lock;
+}
+static void trace_lock_free(void *lock_, unsigned locktype)
+{
+ lock_wrapper *lock = lu_find(lock_);
+ if (!lock || lock->status == FREE || lock->locked) {
+ __asm__("int3");
+ TT_FAIL(("lock: free error"));
+ } else {
+ lock->status = FREE;
+ lu_base.cbs.free(lock_, locktype);
+ }
+}
+static int trace_lock_lock(unsigned mode, void *lock_)
+{
+ lock_wrapper *lock = lu_find(lock_);
+ if (!lock || lock->status == FREE) {
+ TT_FAIL(("lock: lock error"));
+ return -1;
+ } else {
+ ++lock->locked;
+ return lu_base.cbs.lock(mode, lock_);
+ }
+}
+static int trace_lock_unlock(unsigned mode, void *lock_)
+{
+ lock_wrapper *lock = lu_find(lock_);
+ if (!lock || lock->status == FREE || !lock->locked) {
+ TT_FAIL(("lock: unlock error"));
+ return -1;
+ } else {
+ --lock->locked;
+ return lu_base.cbs.unlock(mode, lock_);
+ }
+}
+static void lock_unlock_free_thread_cbs()
+{
+ event_base_free(NULL);
+
+ /** drop immutable flag */
+ evthread_set_lock_callbacks(NULL);
+ /** avoid calling of event_global_setup_locks_() for new cbs */
+ libevent_global_shutdown();
+ /** drop immutable flag for non-debug ops (since called after shutdown) */
+ evthread_set_lock_callbacks(NULL);
+}
+
+static int use_lock_unlock_profiler(void)
+{
+ struct evthread_lock_callbacks cbs = {
+ EVTHREAD_LOCK_API_VERSION,
+ EVTHREAD_LOCKTYPE_RECURSIVE,
+ trace_lock_alloc,
+ trace_lock_free,
+ trace_lock_lock,
+ trace_lock_unlock,
+ };
+ memcpy(&lu_base.cbs, evthread_get_lock_callbacks(),
+ sizeof(lu_base.cbs));
+ {
+ lock_unlock_free_thread_cbs();
+
+ evthread_set_lock_callbacks(&cbs);
+ /** re-create debug locks correctly */
+ evthread_enable_lock_debugging();
+
+ event_init();
+ }
+ return 0;
+}
+static void free_lock_unlock_profiler(struct basic_test_data *data)
+{
+ lock_unlock_free_thread_cbs();
+ free(lu_base.locks);
+ data->base = NULL;
+}
+
+static void test_bufferevent_pair_release_lock(void *arg)
+{
+ struct basic_test_data *data = arg;
+ use_lock_unlock_profiler();
+ {
+ struct bufferevent *pair[2];
+ if (!bufferevent_pair_new(NULL, BEV_OPT_THREADSAFE, pair)) {
+ bufferevent_free(pair[0]);
+ bufferevent_free(pair[1]);
+ } else
+ tt_abort_perror("bufferevent_pair_new");
+ }
+ free_lock_unlock_profiler(data);
+end:
+ ;
+}
+#endif
+
/*
* test watermarks and bufferevent
*/
@@ -287,6 +425,11 @@ test_bufferevent_watermarks_impl(int use_pair)
tt_int_op(low, ==, 100);
tt_int_op(high, ==, 2000);
+ {
+ int r = bufferevent_getwatermark(bev1, EV_WRITE | EV_READ, &low, &high);
+ tt_int_op(r, !=, 0);
+ }
+
bufferevent_write(bev1, buffer, sizeof(buffer));
event_dispatch();
@@ -944,6 +1087,11 @@ struct testcase_t bufferevent_testcases[] = {
LEGACY(bufferevent, TT_ISOLATED),
LEGACY(bufferevent_pair, TT_ISOLATED),
+#if defined(EVTHREAD_USE_PTHREADS_IMPLEMENTED)
+ { "bufferevent_pair_release_lock", test_bufferevent_pair_release_lock,
+ TT_FORK|TT_ISOLATED|TT_NEED_THREADS|TT_NEED_BASE|TT_LEGACY,
+ &basic_setup, NULL },
+#endif
LEGACY(bufferevent_watermarks, TT_ISOLATED),
LEGACY(bufferevent_pair_watermarks, TT_ISOLATED),
LEGACY(bufferevent_filters, TT_ISOLATED),
diff --git a/contrib/ntp/sntp/libevent/test/regress_dns.c b/contrib/ntp/sntp/libevent/test/regress_dns.c
index 338c4ee..6d6b484 100644
--- a/contrib/ntp/sntp/libevent/test/regress_dns.c
+++ b/contrib/ntp/sntp/libevent/test/regress_dns.c
@@ -406,6 +406,22 @@ dns_server(void)
* the only nameserver. */
evdns_base_nameserver_sockaddr_add(base, (struct sockaddr*)&ss, slen, 0);
tt_int_op(evdns_base_count_nameservers(base), ==, 1);
+ {
+ struct sockaddr_storage ss2;
+ int slen2;
+
+ memset(&ss2, 0, sizeof(ss2));
+
+ slen2 = evdns_base_get_nameserver_addr(base, 0, (struct sockaddr *)&ss2, 3);
+ tt_int_op(slen2, ==, slen);
+ tt_int_op(ss2.ss_family, ==, 0);
+ slen2 = evdns_base_get_nameserver_addr(base, 0, (struct sockaddr *)&ss2, sizeof(ss2));
+ tt_int_op(slen2, ==, slen);
+ tt_mem_op(&ss2, ==, &ss, slen);
+
+ slen2 = evdns_base_get_nameserver_addr(base, 1, (struct sockaddr *)&ss2, sizeof(ss2));
+ tt_int_op(-1, ==, slen2);
+ }
/* Send some queries. */
evdns_base_resolve_ipv4(base, "zz.example.com", DNS_QUERY_NO_SEARCH,
@@ -443,6 +459,7 @@ end:
static int n_replies_left;
static struct event_base *exit_base;
+static struct evdns_server_port *exit_port;
struct generic_dns_callback_result {
int result;
@@ -483,8 +500,14 @@ generic_dns_callback(int result, char type, int count, int ttl, void *addresses,
res->addrs = res->addrs_buf;
}
- if (--n_replies_left == 0)
- event_base_loopexit(exit_base, NULL);
+ --n_replies_left;
+ if (n_replies_left == 0) {
+ if (exit_port) {
+ evdns_close_server_port(exit_port);
+ exit_port = NULL;
+ } else
+ event_base_loopexit(exit_base, NULL);
+ }
}
static struct regress_dns_server_table search_table[] = {
@@ -664,7 +687,7 @@ end:
}
static void
-dns_retry_test(void *arg)
+dns_retry_test_impl(void *arg, int flags)
{
struct basic_test_data *data = arg;
struct event_base *base = data->base;
@@ -681,7 +704,7 @@ dns_retry_test(void *arg)
tt_assert(port);
evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", (int)portnum);
- dns = evdns_base_new(base, 0);
+ dns = evdns_base_new(base, flags);
tt_assert(!evdns_base_nameserver_ip_add(dns, buf));
tt_assert(! evdns_base_set_option(dns, "timeout", "0.2"));
tt_assert(! evdns_base_set_option(dns, "max-timeouts:", "10"));
@@ -736,6 +759,16 @@ end:
if (port)
evdns_close_server_port(port);
}
+static void
+dns_retry_test(void *arg)
+{
+ dns_retry_test_impl(arg, 0);
+}
+static void
+dns_retry_disable_when_inactive_test(void *arg)
+{
+ dns_retry_test_impl(arg, EVDNS_BASE_DISABLE_WHEN_INACTIVE);
+}
static struct regress_dns_server_table internal_error_table[] = {
/* Error 4 (NOTIMPL) makes us reissue the request to another server
@@ -753,7 +786,7 @@ static struct regress_dns_server_table reissue_table[] = {
};
static void
-dns_reissue_test(void *arg)
+dns_reissue_test_impl(void *arg, int flags)
{
struct basic_test_data *data = arg;
struct event_base *base = data->base;
@@ -772,7 +805,7 @@ dns_reissue_test(void *arg)
evutil_snprintf(buf1, sizeof(buf1), "127.0.0.1:%d", (int)portnum1);
evutil_snprintf(buf2, sizeof(buf2), "127.0.0.1:%d", (int)portnum2);
- dns = evdns_base_new(base, 0);
+ dns = evdns_base_new(base, flags);
tt_assert(!evdns_base_nameserver_ip_add(dns, buf1));
tt_assert(! evdns_base_set_option(dns, "timeout:", "0.3"));
tt_assert(! evdns_base_set_option(dns, "max-timeouts:", "2"));
@@ -805,6 +838,16 @@ end:
if (port2)
evdns_close_server_port(port2);
}
+static void
+dns_reissue_test(void *arg)
+{
+ dns_reissue_test_impl(arg, 0);
+}
+static void
+dns_reissue_disable_when_inactive_test(void *arg)
+{
+ dns_reissue_test_impl(arg, EVDNS_BASE_DISABLE_WHEN_INACTIVE);
+}
#if 0
static void
@@ -819,21 +862,29 @@ dumb_bytes_fn(char *p, size_t n)
#endif
static void
-dns_inflight_test(void *arg)
+dns_inflight_test_impl(void *arg, int flags)
{
struct basic_test_data *data = arg;
struct event_base *base = data->base;
struct evdns_base *dns = NULL;
+ struct evdns_server_port *dns_port = NULL;
ev_uint16_t portnum = 0;
char buf[64];
+ int disable_when_inactive = flags & EVDNS_BASE_DISABLE_WHEN_INACTIVE;
struct generic_dns_callback_result r[20];
int i;
- tt_assert(regress_dnsserver(base, &portnum, reissue_table));
+ dns_port = regress_get_dnsserver(base, &portnum, NULL,
+ regress_dns_server_cb, reissue_table);
+ tt_assert(dns_port);
+ if (disable_when_inactive) {
+ exit_port = dns_port;
+ }
+
evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", (int)portnum);
- dns = evdns_base_new(base, 0);
+ dns = evdns_base_new(base, flags);
tt_assert(!evdns_base_nameserver_ip_add(dns, buf));
tt_assert(! evdns_base_set_option(dns, "max-inflight:", "3"));
tt_assert(! evdns_base_set_option(dns, "randomize-case:", "0"));
@@ -855,7 +906,65 @@ dns_inflight_test(void *arg)
end:
if (dns)
evdns_base_free(dns, 0);
+ if (exit_port) {
+ evdns_close_server_port(exit_port);
+ exit_port = NULL;
+ } else if (! disable_when_inactive) {
+ evdns_close_server_port(dns_port);
+ }
+}
+
+static void
+dns_inflight_test(void *arg)
+{
+ dns_inflight_test_impl(arg, 0);
+}
+
+static void
+dns_disable_when_inactive_test(void *arg)
+{
+ dns_inflight_test_impl(arg, EVDNS_BASE_DISABLE_WHEN_INACTIVE);
+}
+
+static void
+dns_disable_when_inactive_no_ns_test(void *arg)
+{
+ struct basic_test_data *data = arg;
+ struct event_base *base = data->base, *inactive_base;
+ struct evdns_base *dns = NULL;
+ ev_uint16_t portnum = 0;
+ char buf[64];
+ struct generic_dns_callback_result r;
+
+ inactive_base = event_base_new();
+ tt_assert(inactive_base);
+
+ /** Create dns server with inactive base, to avoid replying to clients */
+ tt_assert(regress_dnsserver(inactive_base, &portnum, search_table));
+ evutil_snprintf(buf, sizeof(buf), "127.0.0.1:%d", (int)portnum);
+
+ dns = evdns_base_new(base, EVDNS_BASE_DISABLE_WHEN_INACTIVE);
+ tt_assert(!evdns_base_nameserver_ip_add(dns, buf));
+ tt_assert(! evdns_base_set_option(dns, "timeout:", "0.1"));
+
+ evdns_base_resolve_ipv4(dns, "foof.example.com", 0, generic_dns_callback, &r);
+ n_replies_left = 1;
+ exit_base = base;
+
+ event_base_dispatch(base);
+
+ tt_int_op(n_replies_left, ==, 0);
+
+ tt_int_op(r.result, ==, DNS_ERR_TIMEOUT);
+ tt_int_op(r.count, ==, 0);
+ tt_ptr_op(r.addrs, ==, NULL);
+
+end:
+ if (dns)
+ evdns_base_free(dns, 0);
regress_clean_dnsserver();
+ if (inactive_base)
+ event_base_free(inactive_base);
}
/* === Test for bufferevent_socket_connect_hostname */
@@ -1563,7 +1672,8 @@ test_getaddrinfo_async(void *arg)
end:
if (local_outcome.ai)
evutil_freeaddrinfo(local_outcome.ai);
- for (i=0;i<10;++i) {
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
+ for (i=0;i<(int)ARRAY_SIZE(a_out);++i) {
if (a_out[i].ai)
evutil_freeaddrinfo(a_out[i].ai);
}
@@ -1694,9 +1804,15 @@ testleak_setup(const struct testcase_t *testcase)
struct testleak_env_t *env;
allocated_chunks = 0;
+
+ /* Reset allocation counter, to start allocations from the very beginning.
+ * (this will avoid false-positive negative numbers for allocated_chunks)
+ */
+ libevent_global_shutdown();
+
event_set_mem_functions(cnt_malloc, cnt_realloc, cnt_free);
- if (!libevent_tests_running_in_debug_mode)
- event_enable_debug_mode();
+
+ event_enable_debug_mode();
/* not mm_calloc: we don't want to mess with the count. */
env = calloc(1, sizeof(struct testleak_env_t));
@@ -1717,8 +1833,8 @@ testleak_cleanup(const struct testcase_t *testcase, void *env_)
#ifdef EVENT__DISABLE_DEBUG_MODE
tt_int_op(allocated_chunks, ==, 0);
#else
- /* FIXME: that's `1' because of event_debug_map_HT_GROW */
- tt_int_op(allocated_chunks, ==, 1);
+ libevent_global_shutdown();
+ tt_int_op(allocated_chunks, ==, 0);
#endif
ok = 1;
end:
@@ -1791,6 +1907,7 @@ dbg_leak_resume(void *env_, int cancel, int send_err_shutdown)
end:
evdns_base_free(env->dns_base, send_err_shutdown);
env->dns_base = 0;
+
event_base_free(env->base);
env->base = 0;
}
@@ -1875,6 +1992,8 @@ end:
evdns_base_free(dns_base, 1);
if (server)
evdns_close_server_port(server);
+ if (base)
+ event_base_free(base);
if (fd >= 0)
evutil_closesocket(fd);
}
@@ -1894,10 +2013,18 @@ struct testcase_t dns_testcases[] = {
{ "search_cancel", dns_search_cancel_test,
TT_FORK|TT_NEED_BASE, &basic_setup, NULL },
{ "retry", dns_retry_test, TT_FORK|TT_NEED_BASE|TT_NO_LOGS, &basic_setup, NULL },
+ { "retry_disable_when_inactive", dns_retry_disable_when_inactive_test,
+ TT_FORK|TT_NEED_BASE|TT_NO_LOGS, &basic_setup, NULL },
{ "reissue", dns_reissue_test, TT_FORK|TT_NEED_BASE|TT_NO_LOGS, &basic_setup, NULL },
+ { "reissue_disable_when_inactive", dns_reissue_disable_when_inactive_test,
+ TT_FORK|TT_NEED_BASE|TT_NO_LOGS, &basic_setup, NULL },
{ "inflight", dns_inflight_test, TT_FORK|TT_NEED_BASE, &basic_setup, NULL },
{ "bufferevent_connect_hostname", test_bufferevent_connect_hostname,
TT_FORK|TT_NEED_BASE, &basic_setup, NULL },
+ { "disable_when_inactive", dns_disable_when_inactive_test,
+ TT_FORK|TT_NEED_BASE, &basic_setup, NULL },
+ { "disable_when_inactive_no_ns", dns_disable_when_inactive_no_ns_test,
+ TT_FORK|TT_NEED_BASE, &basic_setup, NULL },
{ "getaddrinfo_async", test_getaddrinfo_async,
TT_FORK|TT_NEED_BASE, &basic_setup, (char*)"" },
diff --git a/contrib/ntp/sntp/libevent/test/regress_finalize.c b/contrib/ntp/sntp/libevent/test/regress_finalize.c
index 61a6313..552210f 100644
--- a/contrib/ntp/sntp/libevent/test/regress_finalize.c
+++ b/contrib/ntp/sntp/libevent/test/regress_finalize.c
@@ -25,6 +25,7 @@
*/
#include "event2/event-config.h"
+#include "evconfig-private.h"
#include "tinytest.h"
#include "tinytest_macros.h"
#include <stdlib.h>
diff --git a/contrib/ntp/sntp/libevent/test/regress_http.c b/contrib/ntp/sntp/libevent/test/regress_http.c
index ca7d515..35f6dd7 100644
--- a/contrib/ntp/sntp/libevent/test/regress_http.c
+++ b/contrib/ntp/sntp/libevent/test/regress_http.c
@@ -105,8 +105,12 @@ http_bind(struct evhttp *myhttp, ev_uint16_t *pport, int ipv6)
else
sock = evhttp_bind_socket_with_handle(myhttp, "127.0.0.1", *pport);
- if (sock == NULL)
- event_errx(1, "Could not start web server");
+ if (sock == NULL) {
+ if (ipv6)
+ return -1;
+ else
+ event_errx(1, "Could not start web server");
+ }
port = regress_get_socket_port(evhttp_bound_socket_get_fd(sock));
if (port < 0)
@@ -395,7 +399,7 @@ http_basic_test(void *arg)
{
struct basic_test_data *data = arg;
struct timeval tv;
- struct bufferevent *bev;
+ struct bufferevent *bev = NULL;
evutil_socket_t fd;
const char *http_request;
ev_uint16_t port = 0, port2 = 0;
@@ -480,7 +484,8 @@ http_basic_test(void *arg)
evhttp_free(http);
end:
- ;
+ if (bev)
+ bufferevent_free(bev);
}
@@ -714,6 +719,7 @@ http_delete_test(void *arg)
http = http_setup(&port, data->base, 0);
+ tt_assert(http);
fd = http_connect("127.0.0.1", port);
tt_int_op(fd, >=, 0);
@@ -734,6 +740,7 @@ http_delete_test(void *arg)
bufferevent_free(bev);
evutil_closesocket(fd);
+ fd = -1;
evhttp_free(http);
@@ -953,7 +960,8 @@ static void http_request_done(struct evhttp_request *, void *);
static void http_request_empty_done(struct evhttp_request *, void *);
static void
-http_connection_test_(struct basic_test_data *data, int persistent, const char *address, struct evdns_base *dnsbase, int ipv6)
+http_connection_test_(struct basic_test_data *data, int persistent,
+ const char *address, struct evdns_base *dnsbase, int ipv6, int family)
{
ev_uint16_t port = 0;
struct evhttp_connection *evcon = NULL;
@@ -962,9 +970,14 @@ http_connection_test_(struct basic_test_data *data, int persistent, const char *
test_ok = 0;
http = http_setup(&port, data->base, ipv6);
+ if (!http && ipv6) {
+ tt_skip();
+ }
+ tt_assert(http);
evcon = evhttp_connection_base_new(data->base, dnsbase, address, port);
tt_assert(evcon);
+ evhttp_connection_set_family(evcon, family);
tt_assert(evhttp_connection_get_base(evcon) == data->base);
@@ -1038,12 +1051,12 @@ http_connection_test_(struct basic_test_data *data, int persistent, const char *
static void
http_connection_test(void *arg)
{
- http_connection_test_(arg, 0, "127.0.0.1", NULL, 0);
+ http_connection_test_(arg, 0, "127.0.0.1", NULL, 0, AF_UNSPEC);
}
static void
http_persist_connection_test(void *arg)
{
- http_connection_test_(arg, 1, "127.0.0.1", NULL, 0);
+ http_connection_test_(arg, 1, "127.0.0.1", NULL, 0, AF_UNSPEC);
}
static struct regress_dns_server_table search_table[] = {
@@ -1147,6 +1160,63 @@ http_connection_async_test(void *arg)
}
static void
+http_autofree_connection_test(void *arg)
+{
+ struct basic_test_data *data = arg;
+ ev_uint16_t port = 0;
+ struct evhttp_connection *evcon = NULL;
+ struct evhttp_request *req[2] = { NULL };
+
+ test_ok = 0;
+ http = http_setup(&port, data->base, 0);
+
+ evcon = evhttp_connection_base_new(data->base, NULL, "127.0.0.1", port);
+ tt_assert(evcon);
+
+ /*
+ * At this point, we want to schedule two request to the HTTP
+ * server using our make request method.
+ */
+ req[0] = evhttp_request_new(http_request_empty_done, data->base);
+ req[1] = evhttp_request_new(http_request_empty_done, data->base);
+
+ /* Add the information that we care about */
+ evhttp_add_header(evhttp_request_get_output_headers(req[0]), "Host", "somehost");
+ evhttp_add_header(evhttp_request_get_output_headers(req[0]), "Connection", "close");
+ evhttp_add_header(evhttp_request_get_output_headers(req[0]), "Empty", "itis");
+ evhttp_add_header(evhttp_request_get_output_headers(req[1]), "Host", "somehost");
+ evhttp_add_header(evhttp_request_get_output_headers(req[1]), "Connection", "close");
+ evhttp_add_header(evhttp_request_get_output_headers(req[1]), "Empty", "itis");
+
+ /* We give ownership of the request to the connection */
+ if (evhttp_make_request(evcon, req[0], EVHTTP_REQ_GET, "/test") == -1) {
+ tt_abort_msg("couldn't make request");
+ }
+ if (evhttp_make_request(evcon, req[1], EVHTTP_REQ_GET, "/test") == -1) {
+ tt_abort_msg("couldn't make request");
+ }
+
+ /*
+ * Tell libevent to free the connection when the request completes
+ * We then set the evcon pointer to NULL since we don't want to free it
+ * when this function ends.
+ */
+ evhttp_connection_free_on_completion(evcon);
+ evcon = NULL;
+
+ event_base_dispatch(data->base);
+
+ /* at this point, the http server should have no connection */
+ tt_assert(TAILQ_FIRST(&http->connections) == NULL);
+
+ end:
+ if (evcon)
+ evhttp_connection_free(evcon);
+ if (http)
+ evhttp_free(http);
+}
+
+static void
http_request_never_call(struct evhttp_request *req, void *arg)
{
fprintf(stdout, "FAILED\n");
@@ -2743,6 +2813,7 @@ http_incomplete_test_(struct basic_test_data *data, int use_timeout)
bufferevent_free(bev);
if (use_timeout) {
evutil_closesocket(fd);
+ fd = -1;
}
evhttp_free(http);
@@ -3748,7 +3819,7 @@ static struct regress_dns_server_table ipv6_search_table[] = {
};
static void
-http_ipv6_for_domain_test(void *arg)
+http_ipv6_for_domain_test_impl(void *arg, int family)
{
struct basic_test_data *data = arg;
struct evdns_base *dns_base = NULL;
@@ -3765,13 +3836,19 @@ http_ipv6_for_domain_test(void *arg)
evutil_snprintf(address, sizeof(address), "127.0.0.1:%d", portnum);
evdns_base_nameserver_ip_add(dns_base, address);
- http_connection_test_(arg, 0 /* not persistent */, "localhost", dns_base, 1 /* ipv6 */);
+ http_connection_test_(arg, 0 /* not persistent */, "localhost", dns_base,
+ 1 /* ipv6 */, family);
end:
if (dns_base)
evdns_base_free(dns_base, 0);
regress_clean_dnsserver();
}
+static void
+http_ipv6_for_domain_test(void *arg)
+{
+ http_ipv6_for_domain_test_impl(arg, AF_UNSPEC);
+}
static void
http_request_get_addr_on_close(struct evhttp_connection *evcon, void *arg)
@@ -3836,6 +3913,22 @@ http_get_addr_test(void *arg)
evhttp_free(http);
}
+static void
+http_set_family_test(void *arg)
+{
+ http_connection_test_(arg, 0, "127.0.0.1", NULL, 0, AF_UNSPEC);
+}
+static void
+http_set_family_ipv4_test(void *arg)
+{
+ http_connection_test_(arg, 0, "127.0.0.1", NULL, 0, AF_INET);
+}
+static void
+http_set_family_ipv6_test(void *arg)
+{
+ http_ipv6_for_domain_test_impl(arg, AF_INET6);
+}
+
#define HTTP_LEGACY(name) \
{ #name, run_legacy_test_fn, TT_ISOLATED|TT_LEGACY, &legacy_setup, \
http_##name##_test }
@@ -3861,6 +3954,7 @@ struct testcase_t http_testcases[] = {
HTTP(failure),
HTTP(connection),
HTTP(persist_connection),
+ HTTP(autofree_connection),
HTTP(connection_async),
HTTP(close_detection),
HTTP(close_detection_delay),
@@ -3888,6 +3982,10 @@ struct testcase_t http_testcases[] = {
HTTP(ipv6_for_domain),
HTTP(get_addr),
+ HTTP(set_family),
+ HTTP(set_family_ipv4),
+ HTTP(set_family_ipv6),
+
END_OF_TESTCASES
};
diff --git a/contrib/ntp/sntp/libevent/test/regress_main.c b/contrib/ntp/sntp/libevent/test/regress_main.c
index 58cbe5f..3198ced 100644
--- a/contrib/ntp/sntp/libevent/test/regress_main.c
+++ b/contrib/ntp/sntp/libevent/test/regress_main.c
@@ -90,6 +90,8 @@
#include "../iocp-internal.h"
#include "../event-internal.h"
+struct evutil_weakrand_state test_weakrand_state;
+
long
timeval_msec_diff(const struct timeval *start, const struct timeval *end)
{
@@ -452,6 +454,8 @@ main(int argc, const char **argv)
tinytest_set_aliases(testaliases);
+ evutil_weakrand_seed_(&test_weakrand_state, 0);
+
if (tinytest_main(argc,argv,testgroups))
return 1;
diff --git a/contrib/ntp/sntp/libevent/test/regress_minheap.c b/contrib/ntp/sntp/libevent/test/regress_minheap.c
index a1f554e..05db32e 100644
--- a/contrib/ntp/sntp/libevent/test/regress_minheap.c
+++ b/contrib/ntp/sntp/libevent/test/regress_minheap.c
@@ -30,12 +30,13 @@
#include "tinytest.h"
#include "tinytest_macros.h"
+#include "regress.h"
static void
set_random_timeout(struct event *ev)
{
- ev->ev_timeout.tv_sec = rand();
- ev->ev_timeout.tv_usec = rand() & 0xfffff;
+ ev->ev_timeout.tv_sec = test_weakrand();
+ ev->ev_timeout.tv_usec = test_weakrand() & 0xfffff;
ev->ev_timeout_pos.min_heap_idx = -1;
}
diff --git a/contrib/ntp/sntp/libevent/test/regress_ssl.c b/contrib/ntp/sntp/libevent/test/regress_ssl.c
index c211341..bf9b46b 100644
--- a/contrib/ntp/sntp/libevent/test/regress_ssl.c
+++ b/contrib/ntp/sntp/libevent/test/regress_ssl.c
@@ -194,6 +194,7 @@ respond_to_number(struct bufferevent *bev, void *ctx)
n = atoi(line);
if (n <= 0)
TT_FAIL(("Bad number: %s", line));
+ free(line);
TT_BLATHER(("The number was %d", n));
if (n == 1001) {
++test_is_done;
diff --git a/contrib/ntp/sntp/libevent/test/regress_thread.c b/contrib/ntp/sntp/libevent/test/regress_thread.c
index 612bf1d..c42668e 100644
--- a/contrib/ntp/sntp/libevent/test/regress_thread.c
+++ b/contrib/ntp/sntp/libevent/test/regress_thread.c
@@ -361,7 +361,7 @@ thread_conditions_simple(void *arg)
&tv_signal);
diff2 = timeval_msec_diff(&actual_delay,
&tv_broadcast);
- if (abs(diff1) < abs(diff2)) {
+ if (labs(diff1) < labs(diff2)) {
TT_BLATHER(("%d looks like a signal\n", i));
target_delay = &tv_signal;
++n_signal;
@@ -382,7 +382,8 @@ thread_conditions_simple(void *arg)
tt_int_op(n_signal, ==, 1);
end:
- ;
+ EVTHREAD_FREE_LOCK(cond.lock, EVTHREAD_LOCKTYPE_RECURSIVE);
+ EVTHREAD_FREE_COND(cond.cond);
}
#define CB_COUNT 128
diff --git a/contrib/ntp/sntp/libevent/test/regress_util.c b/contrib/ntp/sntp/libevent/test/regress_util.c
index d64d002..60f085b 100644
--- a/contrib/ntp/sntp/libevent/test/regress_util.c
+++ b/contrib/ntp/sntp/libevent/test/regress_util.c
@@ -179,10 +179,10 @@ regress_ipv6_parse(void *ptr)
for (j = 0; j < 4; ++j) {
/* Can't use s6_addr32 here; some don't have it. */
ev_uint32_t u =
- (in6.s6_addr[j*4 ] << 24) |
- (in6.s6_addr[j*4+1] << 16) |
- (in6.s6_addr[j*4+2] << 8) |
- (in6.s6_addr[j*4+3]);
+ ((ev_uint32_t)in6.s6_addr[j*4 ] << 24) |
+ ((ev_uint32_t)in6.s6_addr[j*4+1] << 16) |
+ ((ev_uint32_t)in6.s6_addr[j*4+2] << 8) |
+ ((ev_uint32_t)in6.s6_addr[j*4+3]);
if (u != ent->res[j]) {
TT_FAIL(("%s did not parse as expected.", ent->addr));
continue;
@@ -726,46 +726,48 @@ test_evutil_integers(void *arg)
tt_assert(u64 > 0);
tt_assert(i64 > 0);
u64++;
- i64++;
+/* i64++; */
tt_assert(u64 == 0);
- tt_assert(i64 == EV_INT64_MIN);
- tt_assert(i64 < 0);
+/* tt_assert(i64 == EV_INT64_MIN); */
+/* tt_assert(i64 < 0); */
u32 = EV_UINT32_MAX;
i32 = EV_INT32_MAX;
tt_assert(u32 > 0);
tt_assert(i32 > 0);
u32++;
- i32++;
+/* i32++; */
tt_assert(u32 == 0);
- tt_assert(i32 == EV_INT32_MIN);
- tt_assert(i32 < 0);
+/* tt_assert(i32 == EV_INT32_MIN); */
+/* tt_assert(i32 < 0); */
u16 = EV_UINT16_MAX;
i16 = EV_INT16_MAX;
tt_assert(u16 > 0);
tt_assert(i16 > 0);
u16++;
- i16++;
+/* i16++; */
tt_assert(u16 == 0);
- tt_assert(i16 == EV_INT16_MIN);
- tt_assert(i16 < 0);
+/* tt_assert(i16 == EV_INT16_MIN); */
+/* tt_assert(i16 < 0); */
u8 = EV_UINT8_MAX;
i8 = EV_INT8_MAX;
tt_assert(u8 > 0);
tt_assert(i8 > 0);
u8++;
- i8++;
+/* i8++;*/
tt_assert(u8 == 0);
- tt_assert(i8 == EV_INT8_MIN);
- tt_assert(i8 < 0);
+/* tt_assert(i8 == EV_INT8_MIN); */
+/* tt_assert(i8 < 0); */
+/*
ssize = EV_SSIZE_MAX;
tt_assert(ssize > 0);
ssize++;
tt_assert(ssize < 0);
tt_assert(ssize == EV_SSIZE_MIN);
+*/
ptr = &ssize;
iptr = (ev_intptr_t)ptr;
@@ -1119,7 +1121,7 @@ end:
static void
test_evutil_loadsyslib(void *arg)
{
- HANDLE h=NULL;
+ HMODULE h=NULL;
h = evutil_load_windows_system_library_(TEXT("kernel32.dll"));
tt_assert(h);
diff --git a/contrib/ntp/sntp/libevent/test/regress_zlib.c b/contrib/ntp/sntp/libevent/test/regress_zlib.c
index 9339397..8406676 100644
--- a/contrib/ntp/sntp/libevent/test/regress_zlib.c
+++ b/contrib/ntp/sntp/libevent/test/regress_zlib.c
@@ -56,6 +56,7 @@
#include "event2/bufferevent.h"
#include "regress.h"
+#include "mm-internal.h"
/* zlib 1.2.4 and 1.2.5 do some "clever" things with macros. Instead of
saying "(defined(FOO) ? FOO : 0)" they like to say "FOO-0", on the theory
@@ -95,6 +96,7 @@ zlib_deflate_free(void *ctx)
z_streamp p = ctx;
assert(deflateEnd(p) == Z_OK);
+ mm_free(p);
}
static void
@@ -103,6 +105,7 @@ zlib_inflate_free(void *ctx)
z_streamp p = ctx;
assert(inflateEnd(p) == Z_OK);
+ mm_free(p);
}
static int
@@ -275,7 +278,7 @@ test_bufferevent_zlib(void *arg)
{
struct bufferevent *bev1=NULL, *bev2=NULL;
char buffer[8333];
- z_stream z_input, z_output;
+ z_stream *z_input, *z_output;
int i, r;
evutil_socket_t pair[2] = {-1, -1};
(void)arg;
@@ -293,18 +296,18 @@ test_bufferevent_zlib(void *arg)
bev1 = bufferevent_socket_new(NULL, pair[0], 0);
bev2 = bufferevent_socket_new(NULL, pair[1], 0);
- memset(&z_output, 0, sizeof(z_output));
- r = deflateInit(&z_output, Z_DEFAULT_COMPRESSION);
+ z_output = mm_calloc(sizeof(*z_output), 1);
+ r = deflateInit(z_output, Z_DEFAULT_COMPRESSION);
tt_int_op(r, ==, Z_OK);
- memset(&z_input, 0, sizeof(z_input));
- r = inflateInit(&z_input);
+ z_input = mm_calloc(sizeof(*z_input), 1);
+ r = inflateInit(z_input);
tt_int_op(r, ==, Z_OK);
/* initialize filters */
bev1 = bufferevent_filter_new(bev1, NULL, zlib_output_filter,
- BEV_OPT_CLOSE_ON_FREE, zlib_deflate_free, &z_output);
+ BEV_OPT_CLOSE_ON_FREE, zlib_deflate_free, z_output);
bev2 = bufferevent_filter_new(bev2, zlib_input_filter,
- NULL, BEV_OPT_CLOSE_ON_FREE, zlib_inflate_free, &z_input);
+ NULL, BEV_OPT_CLOSE_ON_FREE, zlib_inflate_free, z_input);
bufferevent_setcb(bev1, readcb, writecb, errorcb, NULL);
bufferevent_setcb(bev2, readcb, writecb, errorcb, NULL);
diff --git a/contrib/ntp/sntp/libevent/test/test-fdleak.c b/contrib/ntp/sntp/libevent/test/test-fdleak.c
index ee2432b..4c4eba2 100644
--- a/contrib/ntp/sntp/libevent/test/test-fdleak.c
+++ b/contrib/ntp/sntp/libevent/test/test-fdleak.c
@@ -57,7 +57,7 @@
#endif
/* Provide storage for the address, both for the server & the clients */
-static struct sockaddr_in sin;
+static struct sockaddr_in saddr;
/* Number of sucessful requests so far */
static int num_requests;
@@ -131,7 +131,7 @@ start_loop(void)
listener = evconnlistener_new_bind(base, listener_accept_cb, NULL,
LEV_OPT_CLOSE_ON_FREE|LEV_OPT_REUSEABLE,
- -1, (struct sockaddr *)&sin, sizeof(sin));
+ -1, (struct sockaddr *)&saddr, sizeof(saddr));
if (listener == NULL) {
my_perror("Could not create listener!");
exit(1);
@@ -145,8 +145,8 @@ start_loop(void)
my_perror("getsockname()");
exit(1);
}
- memcpy(&sin, &ss, sizeof(sin));
- if (sin.sin_family != AF_INET) {
+ memcpy(&saddr, &ss, sizeof(saddr));
+ if (saddr.sin_family != AF_INET) {
puts("AF mismatch from getsockname().");
exit(1);
}
@@ -208,8 +208,8 @@ start_client(struct event_base *base)
BEV_OPT_CLOSE_ON_FREE);
bufferevent_setcb(bev, client_read_cb, NULL, client_event_cb, NULL);
- if (bufferevent_socket_connect(bev, (struct sockaddr *)&sin,
- sizeof(sin)) < 0) {
+ if (bufferevent_socket_connect(bev, (struct sockaddr *)&saddr,
+ sizeof(saddr)) < 0) {
my_perror("Could not connect!");
bufferevent_free(bev);
exit(2);
@@ -236,10 +236,10 @@ main(int argc, char **argv)
#endif
/* Set up an address, used by both client & server. */
- memset(&sin, 0, sizeof(sin));
- sin.sin_family = AF_INET;
- sin.sin_addr.s_addr = htonl(0x7f000001);
- sin.sin_port = 0; /* Tell the implementation to pick a port. */
+ memset(&saddr, 0, sizeof(saddr));
+ saddr.sin_family = AF_INET;
+ saddr.sin_addr.s_addr = htonl(0x7f000001);
+ saddr.sin_port = 0; /* Tell the implementation to pick a port. */
start_loop();
diff --git a/contrib/ntp/sntp/libevent/test/test-ratelim.c b/contrib/ntp/sntp/libevent/test/test-ratelim.c
index 27649b8..17babfd 100644
--- a/contrib/ntp/sntp/libevent/test/test-ratelim.c
+++ b/contrib/ntp/sntp/libevent/test/test-ratelim.c
@@ -50,6 +50,7 @@
#include "event2/listener.h"
#include "event2/thread.h"
+static struct evutil_weakrand_state weakrand_state;
static int cfg_verbose = 0;
static int cfg_help = 0;
@@ -113,11 +114,7 @@ loud_writecb(struct bufferevent *bev, void *ctx)
struct client_state *cs = ctx;
struct evbuffer *output = bufferevent_get_output(bev);
char buf[1024];
-#ifdef _WIN32
- int r = rand() % 256;
-#else
- int r = random() % 256;
-#endif
+ int r = evutil_weakrand_(&weakrand_state);
memset(buf, r, sizeof(buf));
while (evbuffer_get_length(output) < 8192) {
evbuffer_add(output, buf, sizeof(buf));
@@ -223,7 +220,7 @@ check_bucket_levels_cb(evutil_socket_t fd, short events, void *arg)
#undef B
total_n_bev_checks++;
- if (total_n_bev_checks >= .8 * (cfg_duration / cfg_tick_msec) * cfg_n_connections) {
+ if (total_n_bev_checks >= .8 * ((double)cfg_duration / cfg_tick_msec) * cfg_n_connections) {
event_free(event_base_get_running_event(bufferevent_get_base(bev)));
}
}
@@ -553,6 +550,8 @@ main(int argc, char **argv)
(void) WSAStartup(wVersionRequested, &wsaData);
#endif
+ evutil_weakrand_seed_(&weakrand_state, 0);
+
#ifndef _WIN32
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
return 1;
diff --git a/contrib/ntp/sntp/libevent/test/test-time.c b/contrib/ntp/sntp/libevent/test/test-time.c
index dcd6639..bcc7086 100644
--- a/contrib/ntp/sntp/libevent/test/test-time.c
+++ b/contrib/ntp/sntp/libevent/test/test-time.c
@@ -41,6 +41,7 @@
#include "event2/event.h"
#include "event2/event_compat.h"
#include "event2/event_struct.h"
+#include "util-internal.h"
int called = 0;
@@ -48,14 +49,12 @@ int called = 0;
struct event *ev[NEVENT];
+struct evutil_weakrand_state weakrand_state;
+
static int
rand_int(int n)
{
-#ifdef _WIN32
- return (int)(rand() % n);
-#else
- return (int)(random() % n);
-#endif
+ return evutil_weakrand_(&weakrand_state) % n;
}
static void
@@ -71,7 +70,7 @@ time_cb(evutil_socket_t fd, short event, void *arg)
j = rand_int(NEVENT);
tv.tv_sec = 0;
tv.tv_usec = rand_int(50000);
- if (tv.tv_usec % 2)
+ if (tv.tv_usec % 2 || called < NEVENT)
evtimer_add(ev[j], &tv);
else
evtimer_del(ev[j]);
@@ -93,6 +92,8 @@ main(int argc, char **argv)
(void) WSAStartup(wVersionRequested, &wsaData);
#endif
+ evutil_weakrand_seed_(&weakrand_state, 0);
+
/* Initalize the event library */
event_init();
@@ -108,6 +109,8 @@ main(int argc, char **argv)
event_dispatch();
+
+ printf("%d, %d\n", called, NEVENT);
return (called < NEVENT);
}
diff --git a/contrib/ntp/sntp/libevent/test/tinytest.c b/contrib/ntp/sntp/libevent/test/tinytest.c
index 36b3a62..3a8e331 100644
--- a/contrib/ntp/sntp/libevent/test/tinytest.c
+++ b/contrib/ntp/sntp/libevent/test/tinytest.c
@@ -31,6 +31,8 @@
#include <string.h>
#include <assert.h>
+#ifndef NO_FORKING
+
#ifdef _WIN32
#include <windows.h>
#else
@@ -48,6 +50,8 @@
#endif
#endif
+#endif /* !NO_FORKING */
+
#ifndef __GNUC__
#define __attribute__(x)
#endif
@@ -111,6 +115,8 @@ testcase_run_bare_(const struct testcase_t *testcase)
#define MAGIC_EXITCODE 42
+#ifndef NO_FORKING
+
static enum outcome
testcase_run_forked_(const struct testgroup_t *group,
const struct testcase_t *testcase)
@@ -211,6 +217,8 @@ testcase_run_forked_(const struct testgroup_t *group,
#endif
}
+#endif /* !NO_FORKING */
+
int
testcase_run_one(const struct testgroup_t *group,
const struct testcase_t *testcase)
@@ -234,9 +242,13 @@ testcase_run_one(const struct testgroup_t *group,
cur_test_name = testcase->name;
}
+#ifndef NO_FORKING
if ((testcase->flags & TT_FORK) && !(opt_forked||opt_nofork)) {
outcome = testcase_run_forked_(group, testcase);
} else {
+#else
+ {
+#endif
outcome = testcase_run_bare_(testcase);
}
@@ -411,7 +423,9 @@ tinytest_main(int c, const char **v, struct testgroup_t *groups)
if (!n)
tinytest_set_flag_(groups, "..", 1, TT_ENABLED_);
+#ifdef _IONBF
setvbuf(stdout, NULL, _IONBF, 0);
+#endif
++in_tinytest_main;
for (i=0; groups[i].prefix; ++i)
@@ -458,3 +472,22 @@ tinytest_set_test_skipped_(void)
cur_test_outcome = SKIP;
}
+char *
+tinytest_format_hex_(const void *val_, unsigned long len)
+{
+ const unsigned char *val = val_;
+ char *result, *cp;
+ size_t i;
+
+ if (!val)
+ return strdup("null");
+ if (!(result = malloc(len*2+1)))
+ return strdup("<allocation failure>");
+ cp = result;
+ for (i=0;i<len;++i) {
+ *cp++ = "0123456789ABCDEF"[val[i] >> 4];
+ *cp++ = "0123456789ABCDEF"[val[i] & 0x0f];
+ }
+ *cp = 0;
+ return result;
+}
diff --git a/contrib/ntp/sntp/libevent/test/tinytest.h b/contrib/ntp/sntp/libevent/test/tinytest.h
index dff440e..ed07b26 100644
--- a/contrib/ntp/sntp/libevent/test/tinytest.h
+++ b/contrib/ntp/sntp/libevent/test/tinytest.h
@@ -81,6 +81,8 @@ int tinytest_get_verbosity_(void);
/** Implementation: Set a flag on tests matching a name; returns number
* of tests that matched. */
int tinytest_set_flag_(struct testgroup_t *, const char *, int set, unsigned long);
+/** Implementation: Put a chunk of memory into hex. */
+char *tinytest_format_hex_(const void *, unsigned long);
/** Set all tests in 'groups' matching the name 'named' to be skipped. */
#define tinytest_skip(groups, named) \
diff --git a/contrib/ntp/sntp/libevent/test/tinytest_macros.h b/contrib/ntp/sntp/libevent/test/tinytest_macros.h
index 9ff69b1..c3728d1 100644
--- a/contrib/ntp/sntp/libevent/test/tinytest_macros.h
+++ b/contrib/ntp/sntp/libevent/test/tinytest_macros.h
@@ -113,8 +113,8 @@
#define tt_assert_test_fmt_type(a,b,str_test,type,test,printf_type,printf_fmt, \
setup_block,cleanup_block,die_on_fail) \
TT_STMT_BEGIN \
- type val1_ = (type)(a); \
- type val2_ = (type)(b); \
+ type val1_ = (a); \
+ type val2_ = (b); \
int tt_status_ = (test); \
if (!tt_status_ || tinytest_get_verbosity_()>1) { \
printf_type print_; \
@@ -144,6 +144,10 @@
tt_assert_test_fmt_type(a,b,str_test,type,test,type,fmt, \
{print_=value_;},{},die_on_fail)
+#define tt_assert_test_type_opt(a,b,str_test,type,test,fmt,die_on_fail) \
+ tt_assert_test_fmt_type(a,b,str_test,type,test,type,fmt, \
+ {print_=value_?value_:"<NULL>";},{},die_on_fail)
+
/* Helper: assert that a op b, when cast to type. Format the values with
* printf format fmt on failure. */
#define tt_assert_op_type(a,op,b,type,fmt) \
@@ -159,12 +163,23 @@
(val1_ op val2_),"%lu",TT_EXIT_TEST_FUNCTION)
#define tt_ptr_op(a,op,b) \
- tt_assert_test_type(a,b,#a" "#op" "#b,void*, \
+ tt_assert_test_type(a,b,#a" "#op" "#b,const void*, \
(val1_ op val2_),"%p",TT_EXIT_TEST_FUNCTION)
#define tt_str_op(a,op,b) \
- tt_assert_test_type(a,b,#a" "#op" "#b,const char *, \
- (strcmp(val1_,val2_) op 0),"<%s>",TT_EXIT_TEST_FUNCTION)
+ tt_assert_test_type_opt(a,b,#a" "#op" "#b,const char *, \
+ (val1_ && val2_ && strcmp(val1_,val2_) op 0),"<%s>", \
+ TT_EXIT_TEST_FUNCTION)
+
+#define tt_mem_op(expr1, op, expr2, len) \
+ tt_assert_test_fmt_type(expr1,expr2,#expr1" "#op" "#expr2, \
+ const void *, \
+ (val1_ && val2_ && memcmp(val1_, val2_, len) op 0), \
+ char *, "%s", \
+ { print_ = tinytest_format_hex_(value_, (len)); }, \
+ { if (print_) free(print_); }, \
+ TT_EXIT_TEST_FUNCTION \
+ );
#define tt_want_int_op(a,op,b) \
tt_assert_test_type(a,b,#a" "#op" "#b,long,(val1_ op val2_),"%ld",(void)0)
@@ -174,7 +189,7 @@
(val1_ op val2_),"%lu",(void)0)
#define tt_want_ptr_op(a,op,b) \
- tt_assert_test_type(a,b,#a" "#op" "#b,void*, \
+ tt_assert_test_type(a,b,#a" "#op" "#b,const void*, \
(val1_ op val2_),"%p",(void)0)
#define tt_want_str_op(a,op,b) \
diff --git a/contrib/ntp/sntp/libevent/time-internal.h b/contrib/ntp/sntp/libevent/time-internal.h
index daf20f4..2c584fa 100644
--- a/contrib/ntp/sntp/libevent/time-internal.h
+++ b/contrib/ntp/sntp/libevent/time-internal.h
@@ -86,9 +86,6 @@ struct evutil_monotonic_timer {
struct timeval last_time;
};
-#define EV_MONOT_PRECISE 1
-#define EV_MONOT_FALLBACK 2
-
int evutil_configure_monotonic_time_(struct evutil_monotonic_timer *mt,
int flags);
int evutil_gettime_monotonic_(struct evutil_monotonic_timer *mt, struct timeval *tv);
diff --git a/contrib/ntp/sntp/libevent/util-internal.h b/contrib/ntp/sntp/libevent/util-internal.h
index 5866dbc..4fdedea 100644
--- a/contrib/ntp/sntp/libevent/util-internal.h
+++ b/contrib/ntp/sntp/libevent/util-internal.h
@@ -392,7 +392,7 @@ void evutil_free_secure_rng_globals_(void);
void evutil_free_globals_(void);
#ifdef _WIN32
-HANDLE evutil_load_windows_system_library_(const TCHAR *library_name);
+HMODULE evutil_load_windows_system_library_(const TCHAR *library_name);
#endif
#ifndef EV_SIZE_FMT
diff --git a/contrib/ntp/sntp/libevent/whatsnew-2.1.txt b/contrib/ntp/sntp/libevent/whatsnew-2.1.txt
index c0ee7cf..0be54ae 100644
--- a/contrib/ntp/sntp/libevent/whatsnew-2.1.txt
+++ b/contrib/ntp/sntp/libevent/whatsnew-2.1.txt
@@ -41,7 +41,7 @@
We don't try to do binary compatibility except within stable release
series, so binaries linked against any version of Libevent 2.0 will
- probably need to be recompiled against Libevent 2.1.3-alpha if you
+ probably need to be recompiled against Libevent 2.1.4-alpha if you
want to use it. It is probable that we'll break binary compatibility
again before Libevent 2.1 is stable.
@@ -63,6 +63,9 @@
surrounded with appropriate #ifdef lines to keep your IDE from getting
upset.
+ There is now an alternative cmake-based build process; cmake users
+ should see the relevant sections in the README.
+
1.2. New functions for events and the event loop
@@ -146,6 +149,19 @@
that's a no-op in past versions of Libevent, and we don't want to
break compatibility.)
+ You can use the new event_base_get_num_events() function to find the
+ number of events active or pending on an event_base. To find the
+ largest number of events that there have been since the last call, use
+ event_base_get_max_events().
+
+ You can now activate all the events waiting for a given fd or signal
+ using the event_base_active_by_fd() and event_base_active_by_signal()
+ APIs.
+
+ On backends that support it (currently epoll), there is now an
+ EV_CLOSED flag that programs can use to detect when a socket has
+ closed without having to read all the bytes until receiving an EOF.
+
1.3. Event finalization
[NOTE: This is an experimental feature in Libevent 2.1.3-alpha. Though
@@ -325,6 +341,13 @@
You can find the priority at which a bufferevent runs with
bufferevent_get_priority().
+ The function bufferevent_get_token_bucket_cfg() can retrieve the
+ rate-limit settings for a bufferevent; bufferevent_getwatermark() can
+ return a bufferevent's current watermark settings.
+
+ You can manually trigger a bufferevent's callbacks via
+ bufferevent_trigger() and bufferevent_trigger_event().
+
1.7. New functions and features: evdns
The previous evdns interface used an "open a test UDP socket" trick in
@@ -340,6 +363,9 @@
flag, which tells the evdns_base that it should not prevent Libevent from
exiting while it has no DNS requests in progress.
+ There is a new evdns_base_clear_host_addresses() function to remove
+ all the /etc/hosts addresses registered with an evdns instance.
+
1.8. New functions and features: evconnlistener
Libevent 2.1 adds the following evconnlistener flags:
@@ -392,6 +418,31 @@
and actually reports the error code and lets you figure out which request
failed.
+ You can navigate from an evhttp_connection back to its evhttp with the
+ new evhttp_connection_get_server() function.
+
+ You can override the default HTTP Content-Type with the new
+ evhttp_set_default_content_type() function
+
+ There's a new evhttp_connection_get_addr() API to return the peer
+ address of an evhttp_connection.
+
+ The new evhttp_send_reply_chunk_with_cb() is a variant of
+ evhttp_send_reply_chunk() with a callback to be invoked when the
+ chunk is sent.
+
+ The evhttp_request_set_header_cb() facility adds a callback to be
+ invoked while parsing headers.
+
+ The evhttp_request_set_on_complete_cb() facility adds a callback to be
+ invoked on request completion.
+
+1.10. New functions and features: evutil
+
+ There's a function "evutil_secure_rng_set_urandom_device_file()" that
+ you can use to override the default file that Libevent uses to seed
+ its (sort-of) secure RNG.
+
2. Cross-platform performance improvements
2.1. Better data structures
diff --git a/contrib/ntp/sntp/libopts/Makefile.in b/contrib/ntp/sntp/libopts/Makefile.in
index 3b107c7..feb2e0f 100644
--- a/contrib/ntp/sntp/libopts/Makefile.in
+++ b/contrib/ntp/sntp/libopts/Makefile.in
@@ -39,8 +39,6 @@ DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
$(top_srcdir)/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/libevent/m4/openldap.m4 \
$(top_srcdir)/m4/hms_search_lib.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
@@ -60,8 +58,10 @@ am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
$(top_srcdir)/m4/ntp_prog_cc.m4 $(top_srcdir)/m4/ntp_sntp.m4 \
$(top_srcdir)/m4/ntp_sysexits.m4 \
$(top_srcdir)/m4/ntp_ver_suffix.m4 \
- $(top_srcdir)/m4/os_cflags.m4 $(top_srcdir)/m4/snprintf.m4 \
- $(top_srcdir)/m4/version.m4 $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/m4/openldap.m4 $(top_srcdir)/m4/os_cflags.m4 \
+ $(top_srcdir)/m4/snprintf.m4 $(top_srcdir)/m4/version.m4 \
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
@@ -303,6 +303,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
abs_builddir = @abs_builddir@
diff --git a/contrib/ntp/sntp/libopts/m4/libopts.m4 b/contrib/ntp/sntp/libopts/m4/libopts.m4
index 4a4ca18..352098b 100644
--- a/contrib/ntp/sntp/libopts/m4/libopts.m4
+++ b/contrib/ntp/sntp/libopts/m4/libopts.m4
@@ -216,7 +216,7 @@ AC_DEFUN([LIBOPTS_WITHLIB_REGEX],[
LIBREGEX_LIBS=""
AC_MSG_CHECKING([whether libregex functions properly])
AC_CACHE_VAL([libopts_cv_with_libregex],[
- AC_RUN_IFELSE([@%:@include <stdio.h>
+ AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <stdio.h>
@%:@include <stdlib.h>
@%:@include <sys/types.h>
@%:@include REGEX_HEADER
@@ -235,7 +235,7 @@ int main() {
fputs( "error: regex -->.<-- did not match\n", stderr );
return 1;
}
- return 0; }],
+ return 0; }])],
[libopts_cv_with_libregex=yes], [libopts_cv_with_libregex=no],
[libopts_cv_with_libregex=no]) # end of AC_RUN_IFELSE
]) # end of AC_CACHE_VAL for libopts_cv_with_libregex
@@ -260,12 +260,12 @@ libopts_cv_with_libregex=no
AC_DEFUN([LIBOPTS_RUN_PATHFIND],[
AC_MSG_CHECKING([whether pathfind(3) works])
AC_CACHE_VAL([libopts_cv_run_pathfind],[
- AC_RUN_IFELSE([@%:@include <string.h>
+ AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <string.h>
@%:@include <stdlib.h>
int main (int argc, char** argv) {
char* pz = pathfind( getenv( "PATH" ), "sh", "x" );
return (pz == 0) ? 1 : 0;
-}],
+}])],
[libopts_cv_run_pathfind=yes],[libopts_cv_run_pathfind=no],[libopts_cv_run_pathfind=no]
) # end of RUN_IFELSE
]) # end of AC_CACHE_VAL for libopts_cv_run_pathfind
@@ -303,7 +303,7 @@ echo ${dzero}`
AC_DEFUN([LIBOPTS_RUN_REALPATH],[
AC_MSG_CHECKING([whether we have a functional realpath(3C)])
AC_CACHE_VAL([libopts_cv_run_realpath],[
- AC_RUN_IFELSE([@%:@include <limits.h>
+ AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <limits.h>
@%:@include <stdlib.h>
int main (int argc, char** argv) {
@%:@ifndef PATH_MAX
@@ -313,7 +313,7 @@ choke me!!
@%:@endif
char *pz = realpath(argv@<:@0@:>@, zPath);
return (pz == zPath) ? 0 : 1;
-}],
+}])],
[libopts_cv_run_realpath=yes],[libopts_cv_run_realpath=no],[libopts_cv_run_realpath=no]
) # end of RUN_IFELSE
]) # end of AC_CACHE_VAL for libopts_cv_run_realpath
@@ -330,7 +330,7 @@ choke me!!
AC_DEFUN([LIBOPTS_RUN_STRFTIME],[
AC_MSG_CHECKING([whether strftime() works])
AC_CACHE_VAL([libopts_cv_run_strftime],[
- AC_RUN_IFELSE([@%:@include <time.h>
+ AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <time.h>
@%:@include <string.h>
char t_buf@<:@ 64 @:>@;
int main() {
@@ -346,7 +346,7 @@ int main() {
tm.tm_yday = 239; /* days since January 1 @<:@0, 365@:>@ */
tm.tm_isdst = 1; /* flag for daylight savings time */
strftime( t_buf, sizeof( t_buf ), "%A %b %d %j", &tm );
- return (strcmp( t_buf, z ) != 0); }],
+ return (strcmp( t_buf, z ) != 0); }])],
[libopts_cv_run_strftime=yes],[libopts_cv_run_strftime=no],[libopts_cv_run_strftime=no]
) # end of RUN_IFELSE
]) # end of AC_CACHE_VAL for libopts_cv_run_strftime
@@ -363,10 +363,10 @@ int main() {
AC_DEFUN([LIBOPTS_RUN_FOPEN_BINARY],[
AC_MSG_CHECKING([whether fopen accepts "b" mode])
AC_CACHE_VAL([libopts_cv_run_fopen_binary],[
- AC_RUN_IFELSE([@%:@include <stdio.h>
+ AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <stdio.h>
int main (int argc, char** argv) {
FILE* fp = fopen("conftest.@S|@ac_ext", "rb");
-return (fp == NULL) ? 1 : fclose(fp); }],
+return (fp == NULL) ? 1 : fclose(fp); }])],
[libopts_cv_run_fopen_binary=yes],[libopts_cv_run_fopen_binary=no],[libopts_cv_run_fopen_binary=no]
) # end of RUN_IFELSE
]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_binary
@@ -386,10 +386,10 @@ return (fp == NULL) ? 1 : fclose(fp); }],
AC_DEFUN([LIBOPTS_RUN_FOPEN_TEXT],[
AC_MSG_CHECKING([whether fopen accepts "t" mode])
AC_CACHE_VAL([libopts_cv_run_fopen_text],[
- AC_RUN_IFELSE([@%:@include <stdio.h>
+ AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <stdio.h>
int main (int argc, char** argv) {
FILE* fp = fopen("conftest.@S|@ac_ext", "rt");
-return (fp == NULL) ? 1 : fclose(fp); }],
+return (fp == NULL) ? 1 : fclose(fp); }])],
[libopts_cv_run_fopen_text=yes],[libopts_cv_run_fopen_text=no],[libopts_cv_run_fopen_text=no]
) # end of RUN_IFELSE
]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_text
diff --git a/contrib/ntp/sntp/loc/darwin b/contrib/ntp/sntp/loc/darwin
index c902860..37d2dca 100644
--- a/contrib/ntp/sntp/loc/darwin
+++ b/contrib/ntp/sntp/loc/darwin
@@ -12,3 +12,4 @@ ntpsweep,noinst,8
ntptime,sbin,8
ntptrace,sbin,8
sntp,bin,8
+update-leap,sbin,8
diff --git a/contrib/ntp/sntp/loc/debian b/contrib/ntp/sntp/loc/debian
index 7bc895a..1242fdf 100644
--- a/contrib/ntp/sntp/loc/debian
+++ b/contrib/ntp/sntp/loc/debian
@@ -15,3 +15,4 @@ ntptrace,bin,1
sntp,bin,1
tickadj,sbin,8
timetrim,sbin,8
+update-leap,sbin,8
diff --git a/contrib/ntp/sntp/loc/freebsd b/contrib/ntp/sntp/loc/freebsd
index 7759e31..587f998 100644
--- a/contrib/ntp/sntp/loc/freebsd
+++ b/contrib/ntp/sntp/loc/freebsd
@@ -12,3 +12,4 @@ ntptime,sbin,8
ntpsweep,noinst,8
ntptrace,sbin,8
sntp,sbin,8
+update-leap,sbin,8
diff --git a/contrib/ntp/sntp/loc/legacy b/contrib/ntp/sntp/loc/legacy
index 46c63a2..5412971 100644
--- a/contrib/ntp/sntp/loc/legacy
+++ b/contrib/ntp/sntp/loc/legacy
@@ -15,3 +15,4 @@ ntptrace,bin,1
sntp,bin,1
tickadj,bin,1
timetrim,bin,1
+update-leap,bin,1
diff --git a/contrib/ntp/sntp/loc/netbsd b/contrib/ntp/sntp/loc/netbsd
index fa79340..200de2b 100644
--- a/contrib/ntp/sntp/loc/netbsd
+++ b/contrib/ntp/sntp/loc/netbsd
@@ -12,3 +12,4 @@ ntpsweep,noinst,8
ntptime,sbin,8
ntptrace,sbin,8
sntp,sbin,1
+update-leap,sbin,8
diff --git a/contrib/ntp/sntp/loc/solaris b/contrib/ntp/sntp/loc/solaris
index eca1438..a9b3853 100644
--- a/contrib/ntp/sntp/loc/solaris
+++ b/contrib/ntp/sntp/loc/solaris
@@ -14,3 +14,4 @@ ntptime,sbin,1m
ntptrace,sbin,1m
sntp,sbin,1m
tickadj,sbin,1m
+update-leap,sbin,1m
diff --git a/contrib/ntp/sntp/m4/ax_c99_struct_init.m4 b/contrib/ntp/sntp/m4/ax_c99_struct_init.m4
new file mode 100644
index 0000000..44a2db3
--- /dev/null
+++ b/contrib/ntp/sntp/m4/ax_c99_struct_init.m4
@@ -0,0 +1,59 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_c99_struct_init.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_C99_STRUCT_INIT
+#
+# DESCRIPTION
+#
+# This macro defines MISSING_C99_STRUCT_INIT if the C compiler does not
+# supports the C99 tagged structure initialization.
+#
+# Given: struct foo_s {int i1; int i2; int i3;};
+# one can write:
+# #if !define(MISSING_C99_STRUCT_INIT)
+# # define FOO_INIT(a, b, c) { .i1 = a, .i2 = b, .i3 = c }
+# #else
+# # define FOO_INIT(a, b, c) { a, b, c }
+#
+# static struct foo_s foo[] = {
+# FOO_INIT(1, 1, 1),
+# FOO_INIT(2, 2, 2),
+# FOO_INIT(0, 0, 0)
+# };
+#
+# LICENSE
+#
+# Copyright (c) 2015 Network Time Foundation
+#
+# Author: Harlan Stenn <stenn@nwtime.org>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 1
+
+AC_DEFUN([AX_C99_STRUCT_INIT], [
+ AC_MSG_CHECKING([whether the compiler supports C99 structure initialization])
+ AC_REQUIRE([AC_PROG_CC_C99])
+
+ AC_LANG_PUSH([C])
+
+ dnl AC_LINK_IFELSE?
+ AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([[
+ struct foo_s {int i1; int i2;};
+ int main() { struct foo_s foo[] = { { .i1 = 1, .i2 = 1 }, { .i1 = 2, .i2 = 2 }, { .i1 = 0, .i2 = 0 } }; }
+ ]])],
+ AC_MSG_RESULT([yes]),
+ AC_MSG_RESULT([no])
+ AC_DEFINE([MISSING_C99_STRUCT_INIT], [1],
+ [Define to 1 if the compiler does not support C99's structure initialization.]),
+ )
+
+ AC_LANG_POP([C])
+ ]);
diff --git a/contrib/ntp/sntp/m4/ntp_libntp.m4 b/contrib/ntp/sntp/m4/ntp_libntp.m4
index 8842c4a..3aa3dff 100644
--- a/contrib/ntp/sntp/m4/ntp_libntp.m4
+++ b/contrib/ntp/sntp/m4/ntp_libntp.m4
@@ -878,13 +878,13 @@ AC_CACHE_CHECK(
[for SIGIO],
[ntp_cv_hdr_def_sigio],
[AC_PREPROC_IFELSE(
- [
+ [AC_LANG_SOURCE([
#include <signal.h>
#ifndef SIGIO
# error
#endif
- ],
+ ])],
[ntp_cv_hdr_def_sigio=yes],
[ntp_cv_hdr_def_sigio=no]
)]
@@ -947,13 +947,13 @@ AC_CACHE_CHECK(
[for SIGPOLL],
[ntp_cv_hdr_def_sigpoll],
[AC_PREPROC_IFELSE(
- [
+ [AC_LANG_SOURCE([
#include <signal.h>
#ifndef SIGPOLL
# error
#endif
- ],
+ ])],
[ntp_cv_hdr_def_sigpoll=yes],
[ntp_cv_hdr_def_sigpoll=no]
)]
diff --git a/contrib/ntp/sntp/m4/ntp_locinfo.m4 b/contrib/ntp/sntp/m4/ntp_locinfo.m4
index f045ac2..6701ba0 100644
--- a/contrib/ntp/sntp/m4/ntp_locinfo.m4
+++ b/contrib/ntp/sntp/m4/ntp_locinfo.m4
@@ -124,6 +124,12 @@ AC_SUBST([TIMETRIM_DL])
AC_SUBST([TIMETRIM_DS])
AC_SUBST([TIMETRIM_MS])
AC_SUBST([TIMETRIM_NI])
+AC_SUBST([UPDATE_LEAP_DB])
+AC_SUBST([UPDATE_LEAP_DL])
+AC_SUBST([UPDATE_LEAP_DS])
+AC_SUBST([UPDATE_LEAP_MS])
+AC_SUBST([UPDATE_LEAP_NI])
+AM_CONDITIONAL([INSTALL_UPDATE_LEAP], [test -z "$UPDATE_LEAP_NI" ])
])dnl
dnl ======================================================================
diff --git a/contrib/ntp/sntp/libevent/m4/openldap-thread-check.m4 b/contrib/ntp/sntp/m4/openldap-thread-check.m4
index 33f9199..33f9199 100644
--- a/contrib/ntp/sntp/libevent/m4/openldap-thread-check.m4
+++ b/contrib/ntp/sntp/m4/openldap-thread-check.m4
diff --git a/contrib/ntp/sntp/libevent/m4/openldap.m4 b/contrib/ntp/sntp/m4/openldap.m4
index 49ffb87..49ffb87 100644
--- a/contrib/ntp/sntp/libevent/m4/openldap.m4
+++ b/contrib/ntp/sntp/m4/openldap.m4
diff --git a/contrib/ntp/sntp/m4/version.m4 b/contrib/ntp/sntp/m4/version.m4
index 06f9676..945d9cb 100644
--- a/contrib/ntp/sntp/m4/version.m4
+++ b/contrib/ntp/sntp/m4/version.m4
@@ -1 +1 @@
-m4_define([VERSION_NUMBER],[4.2.8p1])
+m4_define([VERSION_NUMBER],[4.2.8p2])
diff --git a/contrib/ntp/sntp/main.c b/contrib/ntp/sntp/main.c
index c271c8c..20e27f0 100644
--- a/contrib/ntp/sntp/main.c
+++ b/contrib/ntp/sntp/main.c
@@ -1161,6 +1161,7 @@ handle_pkt(
int stratum;
char * ref;
char * ts_str;
+ char * leaptxt;
double offset;
double precision;
double synch_distance;
@@ -1256,9 +1257,28 @@ handle_pkt(
disptxt[0] = '\0';
}
- msyslog(LOG_INFO, "%s %+.*f%s %s s%d%s", ts_str,
+ switch (PKT_LEAP(rpkt->li_vn_mode)) {
+ case LEAP_NOWARNING:
+ leaptxt = "no-leap";
+ break;
+ case LEAP_ADDSECOND:
+ leaptxt = "add-leap";
+ break;
+ case LEAP_DELSECOND:
+ leaptxt = "del-leap";
+ break;
+ case LEAP_NOTINSYNC:
+ leaptxt = "unsync";
+ break;
+ default:
+ leaptxt = "LEAP-ERROR";
+ break;
+ }
+
+ msyslog(LOG_INFO, "%s %+.*f%s %s s%d %s%s", ts_str,
digits, offset, disptxt,
hostnameaddr(hostname, host), stratum,
+ leaptxt,
(time_adjusted)
? " [excess]"
: "");
diff --git a/contrib/ntp/sntp/scripts/Makefile.in b/contrib/ntp/sntp/scripts/Makefile.in
index 26c3591..73025d0 100644
--- a/contrib/ntp/sntp/scripts/Makefile.in
+++ b/contrib/ntp/sntp/scripts/Makefile.in
@@ -38,8 +38,6 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
$(top_srcdir)/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/libevent/m4/openldap.m4 \
$(top_srcdir)/m4/hms_search_lib.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
@@ -59,8 +57,10 @@ am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
$(top_srcdir)/m4/ntp_prog_cc.m4 $(top_srcdir)/m4/ntp_sntp.m4 \
$(top_srcdir)/m4/ntp_sysexits.m4 \
$(top_srcdir)/m4/ntp_ver_suffix.m4 \
- $(top_srcdir)/m4/os_cflags.m4 $(top_srcdir)/m4/snprintf.m4 \
- $(top_srcdir)/m4/version.m4 $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/m4/openldap.m4 $(top_srcdir)/m4/os_cflags.m4 \
+ $(top_srcdir)/m4/snprintf.m4 $(top_srcdir)/m4/version.m4 \
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
@@ -246,6 +246,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
abs_builddir = @abs_builddir@
diff --git a/contrib/ntp/sntp/sntp-opts.c b/contrib/ntp/sntp/sntp-opts.c
index a9e3645..ce28d65 100644
--- a/contrib/ntp/sntp/sntp-opts.c
+++ b/contrib/ntp/sntp/sntp-opts.c
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (sntp-opts.c)
*
- * It has been AutoGen-ed February 4, 2015 at 02:33:35 AM by AutoGen 5.18.5pre4
+ * It has been AutoGen-ed April 7, 2015 at 04:17:23 AM by AutoGen 5.18.5pre4
* From the definitions sntp-opts.def
* and the template file options
*
@@ -70,7 +70,7 @@ extern FILE * option_usage_fp;
* static const strings for sntp options
*/
static char const sntp_opt_strs[2549] =
-/* 0 */ "sntp 4.2.8p1\n"
+/* 0 */ "sntp 4.2.8p2\n"
"Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n"
"This is free software. It is licensed for use, modification and\n"
"redistribution under the terms of the NTP License, copies of which\n"
@@ -155,7 +155,7 @@ static char const sntp_opt_strs[2549] =
/* 2298 */ "LOAD_OPTS\0"
/* 2308 */ "no-load-opts\0"
/* 2321 */ "SNTP\0"
-/* 2326 */ "sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p1\n"
+/* 2326 */ "sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p2\n"
"Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n"
"\t\t[ hostname-or-IP ...]\n\0"
/* 2485 */ "$HOME\0"
@@ -163,7 +163,7 @@ static char const sntp_opt_strs[2549] =
/* 2493 */ ".ntprc\0"
/* 2500 */ "http://bugs.ntp.org, bugs@ntp.org\0"
/* 2534 */ "\n\0"
-/* 2536 */ "sntp 4.2.8p1";
+/* 2536 */ "sntp 4.2.8p2";
/**
* ipv4 option description with
@@ -1173,7 +1173,7 @@ static void bogus_function(void) {
translate option names.
*/
/* referenced via sntpOptions.pzCopyright */
- puts(_("sntp 4.2.8p1\n\
+ puts(_("sntp 4.2.8p2\n\
Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n\
This is free software. It is licensed for use, modification and\n\
redistribution under the terms of the NTP License, copies of which\n\
@@ -1263,7 +1263,7 @@ implied warranty.\n"));
puts(_("load options from a config file"));
/* referenced via sntpOptions.pzUsageTitle */
- puts(_("sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p1\n\
+ puts(_("sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p2\n\
Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
\t\t[ hostname-or-IP ...]\n"));
@@ -1271,7 +1271,7 @@ Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \\\n\
puts(_("\n"));
/* referenced via sntpOptions.pzFullVersion */
- puts(_("sntp 4.2.8p1"));
+ puts(_("sntp 4.2.8p2"));
/* referenced via sntpOptions.pzFullUsage */
puts(_("<<<NOT-FOUND>>>"));
diff --git a/contrib/ntp/sntp/sntp-opts.def b/contrib/ntp/sntp/sntp-opts.def
index c94d5e9..fcfeaaf 100644
--- a/contrib/ntp/sntp/sntp-opts.def
+++ b/contrib/ntp/sntp/sntp-opts.def
@@ -281,7 +281,8 @@ Otherwise, only the
is displayed.
Finally, the
.Em stratum
-of the host is reported.
+of the host is reported
+and the leap indicator is decoded and displayed.
_END_PROG_MDOC_DESCRIP;
};
diff --git a/contrib/ntp/sntp/sntp-opts.h b/contrib/ntp/sntp/sntp-opts.h
index d0407aa..8f1a5df 100644
--- a/contrib/ntp/sntp/sntp-opts.h
+++ b/contrib/ntp/sntp/sntp-opts.h
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (sntp-opts.h)
*
- * It has been AutoGen-ed February 4, 2015 at 02:33:34 AM by AutoGen 5.18.5pre4
+ * It has been AutoGen-ed April 7, 2015 at 04:17:22 AM by AutoGen 5.18.5pre4
* From the definitions sntp-opts.def
* and the template file options
*
@@ -91,9 +91,9 @@ typedef enum {
/** count of all options for sntp */
#define OPTION_CT 23
/** sntp version */
-#define SNTP_VERSION "4.2.8p1"
+#define SNTP_VERSION "4.2.8p2"
/** Full sntp version text */
-#define SNTP_FULL_VERSION "sntp 4.2.8p1"
+#define SNTP_FULL_VERSION "sntp 4.2.8p2"
/**
* Interface defines for all options. Replace "n" with the UPPER_CASED
diff --git a/contrib/ntp/sntp/sntp.1sntpman b/contrib/ntp/sntp/sntp.1sntpman
index 36bdfbd..1b636e9 100644
--- a/contrib/ntp/sntp/sntp.1sntpman
+++ b/contrib/ntp/sntp/sntp.1sntpman
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH sntp 1sntpman "04 Feb 2015" "4.2.8p1" "User Commands"
+.TH sntp 1sntpman "07 Apr 2015" "4.2.8p2" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-apayaT/ag-zpaq_S)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-E6aqmA/ag-76ailA)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:34:13 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:18:00 AM by AutoGen 5.18.5pre4
.\" From the definitions sntp-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
@@ -72,7 +72,8 @@ Otherwise, only the
is displayed.
Finally, the
\fIstratum\f[]
-of the host is reported.
+of the host is reported
+and the leap indicator is decoded and displayed.
.SH "OPTIONS"
.TP
.NOP \f\*[B-Font]\-4\f[], \f\*[B-Font]\-\-ipv4\f[]
diff --git a/contrib/ntp/sntp/sntp.1sntpmdoc b/contrib/ntp/sntp/sntp.1sntpmdoc
index 26444f5..5a84a80 100644
--- a/contrib/ntp/sntp/sntp.1sntpmdoc
+++ b/contrib/ntp/sntp/sntp.1sntpmdoc
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt SNTP 1sntpmdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (sntp-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:34:20 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:18:06 AM by AutoGen 5.18.5pre4
.\" From the definitions sntp-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
@@ -57,7 +57,8 @@ Otherwise, only the
is displayed.
Finally, the
.Em stratum
-of the host is reported.
+of the host is reported
+and the leap indicator is decoded and displayed.
.Sh "OPTIONS"
.Bl -tag
.It Fl 4 , Fl \-ipv4
diff --git a/contrib/ntp/sntp/sntp.html b/contrib/ntp/sntp/sntp.html
index cac641a..5b41a7f 100644
--- a/contrib/ntp/sntp/sntp.html
+++ b/contrib/ntp/sntp/sntp.html
@@ -36,7 +36,7 @@ display the time offset of the system clock relative to the server
clock. Run as root, it can correct the system clock to this offset as
well. It can be run as an interactive command or from a cron job.
- <p>This document applies to version 4.2.8p1 of <code>sntp</code>.
+ <p>This document applies to version 4.2.8p2 of <code>sntp</code>.
<p>The program implements the SNTP protocol as defined by RFC 5905, the NTPv4
IETF specification.
@@ -127,7 +127,8 @@ Otherwise, only the
is displayed.
Finally, the
<em>stratum</em>
-of the host is reported.
+of the host is reported
+and the leap indicator is decoded and displayed.
<p>This section was generated by <strong>AutoGen</strong>,
using the <code>agtexi-cmd</code> template and the option descriptions for the <code>sntp</code> program.
@@ -175,7 +176,7 @@ the usage text by passing it through a pager program.
used to select the program, defaulting to <span class="file">more</span>. Both will exit
with a status code of 0.
-<pre class="example">sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p1
+<pre class="example">sntp - standard Simple Network Time Protocol client program - Ver. 4.2.8p2
Usage: sntp [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]... \
[ hostname-or-IP ...]
Flg Arg Option-Name Description
diff --git a/contrib/ntp/sntp/sntp.man.in b/contrib/ntp/sntp/sntp.man.in
index 3a6f9c5..a1a3e07 100644
--- a/contrib/ntp/sntp/sntp.man.in
+++ b/contrib/ntp/sntp/sntp.man.in
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH sntp @SNTP_MS@ "04 Feb 2015" "4.2.8p1" "User Commands"
+.TH sntp @SNTP_MS@ "07 Apr 2015" "4.2.8p2" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-apayaT/ag-zpaq_S)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-E6aqmA/ag-76ailA)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:34:13 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:18:00 AM by AutoGen 5.18.5pre4
.\" From the definitions sntp-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
@@ -72,7 +72,8 @@ Otherwise, only the
is displayed.
Finally, the
\fIstratum\f[]
-of the host is reported.
+of the host is reported
+and the leap indicator is decoded and displayed.
.SH "OPTIONS"
.TP
.NOP \f\*[B-Font]\-4\f[], \f\*[B-Font]\-\-ipv4\f[]
diff --git a/contrib/ntp/sntp/sntp.mdoc.in b/contrib/ntp/sntp/sntp.mdoc.in
index 9b66208..31a4268 100644
--- a/contrib/ntp/sntp/sntp.mdoc.in
+++ b/contrib/ntp/sntp/sntp.mdoc.in
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt SNTP @SNTP_MS@ User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (sntp-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:34:20 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:18:06 AM by AutoGen 5.18.5pre4
.\" From the definitions sntp-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
@@ -57,7 +57,8 @@ Otherwise, only the
is displayed.
Finally, the
.Em stratum
-of the host is reported.
+of the host is reported
+and the leap indicator is decoded and displayed.
.Sh "OPTIONS"
.Bl -tag
.It Fl 4 , Fl \-ipv4
diff --git a/contrib/ntp/sntp/tests/Makefile.in b/contrib/ntp/sntp/tests/Makefile.in
index 73b78da..194af0f 100644
--- a/contrib/ntp/sntp/tests/Makefile.in
+++ b/contrib/ntp/sntp/tests/Makefile.in
@@ -44,8 +44,6 @@ subdir = tests
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
$(top_srcdir)/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/libevent/m4/openldap.m4 \
$(top_srcdir)/m4/hms_search_lib.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
@@ -65,8 +63,10 @@ am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
$(top_srcdir)/m4/ntp_prog_cc.m4 $(top_srcdir)/m4/ntp_sntp.m4 \
$(top_srcdir)/m4/ntp_sysexits.m4 \
$(top_srcdir)/m4/ntp_ver_suffix.m4 \
- $(top_srcdir)/m4/os_cflags.m4 $(top_srcdir)/m4/snprintf.m4 \
- $(top_srcdir)/m4/version.m4 $(top_srcdir)/configure.ac
+ $(top_srcdir)/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/m4/openldap.m4 $(top_srcdir)/m4/os_cflags.m4 \
+ $(top_srcdir)/m4/snprintf.m4 $(top_srcdir)/m4/version.m4 \
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
@@ -295,6 +295,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
abs_builddir = @abs_builddir@
diff --git a/contrib/ntp/tests/Makefile.in b/contrib/ntp/tests/Makefile.in
index 6647856..0b88e40 100644
--- a/contrib/ntp/tests/Makefile.in
+++ b/contrib/ntp/tests/Makefile.in
@@ -42,8 +42,7 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -72,6 +71,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -328,6 +329,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/tests/libntp/Makefile.in b/contrib/ntp/tests/libntp/Makefile.in
index b5b667b..233c3ef 100644
--- a/contrib/ntp/tests/libntp/Makefile.in
+++ b/contrib/ntp/tests/libntp/Makefile.in
@@ -44,8 +44,7 @@ subdir = tests/libntp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -74,6 +73,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -342,6 +343,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/tests/ntpd/Makefile.in b/contrib/ntp/tests/ntpd/Makefile.in
index a9975b4..bb51457 100644
--- a/contrib/ntp/tests/ntpd/Makefile.in
+++ b/contrib/ntp/tests/ntpd/Makefile.in
@@ -44,8 +44,7 @@ subdir = tests/ntpd
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -74,6 +73,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -345,6 +346,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
diff --git a/contrib/ntp/util/Makefile.am b/contrib/ntp/util/Makefile.am
index 88bf7cb..8a47a3c 100644
--- a/contrib/ntp/util/Makefile.am
+++ b/contrib/ntp/util/Makefile.am
@@ -112,7 +112,7 @@ $(srcdir)/ntp-keygen.html: $(srcdir)/ntp-keygen.texi $(top_srcdir)/sntp/include/
cd $(srcdir) && ( makeinfo --force --html --no-split -o ntp-keygen.html ntp-keygen.texi || true )
-jitter_SOURCES= jitter.c jitter.h
+jitter_SOURCES= jitter.c
jitter_LDADD=
kern.o: kern.c
diff --git a/contrib/ntp/util/Makefile.in b/contrib/ntp/util/Makefile.in
index 0325e44..f4fc712 100644
--- a/contrib/ntp/util/Makefile.in
+++ b/contrib/ntp/util/Makefile.in
@@ -52,8 +52,7 @@ subdir = util
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/libopts/m4/stdnoreturn.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap-thread-check.m4 \
- $(top_srcdir)/sntp/libevent/m4/openldap.m4 \
+ $(top_srcdir)/sntp/m4/ax_c99_struct_init.m4 \
$(top_srcdir)/sntp/m4/define_dir.m4 \
$(top_srcdir)/sntp/m4/hms_search_lib.m4 \
$(top_srcdir)/sntp/m4/libtool.m4 \
@@ -82,6 +81,8 @@ am__aclocal_m4_deps = $(top_srcdir)/sntp/libopts/m4/libopts.m4 \
$(top_srcdir)/sntp/m4/ntp_sntp.m4 \
$(top_srcdir)/sntp/m4/ntp_ver_suffix.m4 \
$(top_srcdir)/sntp/m4/ntp_vpathhack.m4 \
+ $(top_srcdir)/sntp/m4/openldap-thread-check.m4 \
+ $(top_srcdir)/sntp/m4/openldap.m4 \
$(top_srcdir)/sntp/m4/os_cflags.m4 \
$(top_srcdir)/sntp/m4/snprintf.m4 \
$(top_srcdir)/sntp/m4/version.m4 $(top_srcdir)/configure.ac
@@ -436,6 +437,11 @@ TIMETRIM_DL = @TIMETRIM_DL@
TIMETRIM_DS = @TIMETRIM_DS@
TIMETRIM_MS = @TIMETRIM_MS@
TIMETRIM_NI = @TIMETRIM_NI@
+UPDATE_LEAP_DB = @UPDATE_LEAP_DB@
+UPDATE_LEAP_DL = @UPDATE_LEAP_DL@
+UPDATE_LEAP_DS = @UPDATE_LEAP_DS@
+UPDATE_LEAP_MS = @UPDATE_LEAP_MS@
+UPDATE_LEAP_NI = @UPDATE_LEAP_NI@
VERSION = @VERSION@
VER_SUFFIX = @VER_SUFFIX@
YACC = @YACC@
@@ -554,7 +560,7 @@ std_def_list = \
$(top_srcdir)/sntp/include/version.def \
$(NULL)
-jitter_SOURCES = jitter.c jitter.h
+jitter_SOURCES = jitter.c
jitter_LDADD =
NTP_INCS = -I$(top_srcdir)/include -I$(top_srcdir)/lib/isc/include \
-I$(top_srcdir)/lib/isc/$(LIBISC_PTHREADS_NOTHREADS)/include \
diff --git a/contrib/ntp/util/invoke-ntp-keygen.texi b/contrib/ntp/util/invoke-ntp-keygen.texi
index 808757d..0412485 100644
--- a/contrib/ntp/util/invoke-ntp-keygen.texi
+++ b/contrib/ntp/util/invoke-ntp-keygen.texi
@@ -6,7 +6,7 @@
#
# EDIT THIS FILE WITH CAUTION (invoke-ntp-keygen.texi)
#
-# It has been AutoGen-ed February 4, 2015 at 02:43:59 AM by AutoGen 5.18.5pre4
+# It has been AutoGen-ed April 7, 2015 at 04:27:46 AM by AutoGen 5.18.5pre4
# From the definitions ntp-keygen-opts.def
# and the template file agtexi-cmd.tpl
@end ignore
@@ -886,7 +886,7 @@ with a status code of 0.
@exampleindent 0
@example
-ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p1
+ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p2
Usage: ntp-keygen [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]...
Flg Arg Option-Name Description
-b Num imbits identity modulus bits
diff --git a/contrib/ntp/util/jitter.c b/contrib/ntp/util/jitter.c
index 62a84ad..c0050fc 100644
--- a/contrib/ntp/util/jitter.c
+++ b/contrib/ntp/util/jitter.c
@@ -14,10 +14,9 @@
#include <stdio.h>
#include <sys/time.h>
#include <stdlib.h>
-#include "jitter.h"
+#include "ntp_fp.h"
#define NBUF 800002
-#define FRAC 4294967296. /* a bbbbillion */
#define JAN_1970 2208988800UL /* Unix base epoch */
#define CLOCK_GETTIME /* Solaris hires clock */
diff --git a/contrib/ntp/util/jitter.h b/contrib/ntp/util/jitter.h
deleted file mode 100644
index 1431406..0000000
--- a/contrib/ntp/util/jitter.h
+++ /dev/null
@@ -1,401 +0,0 @@
-/*
- * ntp_types.h - defines how int32 and u_int32 are treated.
- * For 64 bit systems like the DEC Alpha, they have to be defined
- * as int and u_int.
- * For 32 bit systems, define them as long and u_long
- */
-#define SIZEOF_INT 4
-
-/*
- * VMS DECC (v4.1), {u_char,u_short,u_long} are only in SOCKET.H,
- * and u_int isn't defined anywhere
- */
-#if defined(VMS)
-#include <socket.h>
-typedef unsigned int u_int;
-/*
- * Note: VMS DECC has long == int (even on __alpha),
- * so the distinction below doesn't matter
- */
-#endif /* VMS */
-
-#if (SIZEOF_INT == 4)
-# ifndef int32
-# define int32 int
-# endif
-# ifndef u_int32
-# define u_int32 unsigned int
-# endif
-#else /* not sizeof(int) == 4 */
-# if (SIZEOF_LONG == 4)
-# else /* not sizeof(long) == 4 */
-# ifndef int32
-# define int32 long
-# endif
-# ifndef u_int32
-# define u_int32 unsigned long
-# endif
-# endif /* not sizeof(long) == 4 */
-# include "Bletch: what's 32 bits on this machine?"
-#endif /* not sizeof(int) == 4 */
-
-typedef unsigned short associd_t; /* association ID */
-typedef u_int32 keyid_t; /* cryptographic key ID */
-typedef u_int32 tstamp_t; /* NTP seconds timestamp */
-
-/*
- * NTP uses two fixed point formats. The first (l_fp) is the "long"
- * format and is 64 bits long with the decimal between bits 31 and 32.
- * This is used for time stamps in the NTP packet header (in network
- * byte order) and for internal computations of offsets (in local host
- * byte order). We use the same structure for both signed and unsigned
- * values, which is a big hack but saves rewriting all the operators
- * twice. Just to confuse this, we also sometimes just carry the
- * fractional part in calculations, in both signed and unsigned forms.
- * Anyway, an l_fp looks like:
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Integral Part |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Fractional Part |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- */
-typedef struct {
- union {
- u_int32 Xl_ui;
- int32 Xl_i;
- } Ul_i;
- union {
- u_int32 Xl_uf;
- int32 Xl_f;
- } Ul_f;
-} l_fp;
-
-#define l_ui Ul_i.Xl_ui /* unsigned integral part */
-#define l_i Ul_i.Xl_i /* signed integral part */
-#define l_uf Ul_f.Xl_uf /* unsigned fractional part */
-#define l_f Ul_f.Xl_f /* signed fractional part */
-
-/*
- * Fractional precision (of an l_fp) is actually the number of
- * bits in a long.
- */
-#define FRACTION_PREC (32)
-
-
-/*
- * The second fixed point format is 32 bits, with the decimal between
- * bits 15 and 16. There is a signed version (s_fp) and an unsigned
- * version (u_fp). This is used to represent synchronizing distance
- * and synchronizing dispersion in the NTP packet header (again, in
- * network byte order) and internally to hold both distance and
- * dispersion values (in local byte order). In network byte order
- * it looks like:
- *
- * 0 1 2 3
- * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- * | Integer Part | Fraction Part |
- * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *
- */
-typedef int32 s_fp;
-typedef u_int32 u_fp;
-
-/*
- * A unit second in fp format. Actually 2**(half_the_bits_in_a_long)
- */
-#define FP_SECOND (0x10000)
-
-/*
- * Byte order conversions
- */
-#define HTONS_FP(x) (htonl(x))
-#define HTONL_FP(h, n) do { (n)->l_ui = htonl((h)->l_ui); \
- (n)->l_uf = htonl((h)->l_uf); } while (0)
-#define NTOHS_FP(x) (ntohl(x))
-#define NTOHL_FP(n, h) do { (h)->l_ui = ntohl((n)->l_ui); \
- (h)->l_uf = ntohl((n)->l_uf); } while (0)
-#define NTOHL_MFP(ni, nf, hi, hf) \
- do { (hi) = ntohl(ni); (hf) = ntohl(nf); } while (0)
-#define HTONL_MFP(hi, hf, ni, nf) \
- do { (ni) = ntohl(hi); (nf) = ntohl(hf); } while (0)
-
-/* funny ones. Converts ts fractions to net order ts */
-#define HTONL_UF(uf, nts) \
- do { (nts)->l_ui = 0; (nts)->l_uf = htonl(uf); } while (0)
-#define HTONL_F(f, nts) do { (nts)->l_uf = htonl(f); \
- if ((f) & 0x80000000) \
- (nts)->l_i = -1; \
- else \
- (nts)->l_i = 0; \
- } while (0)
-
-/*
- * Conversions between the two fixed point types
- */
-#define MFPTOFP(x_i, x_f) (((int)(x_i) >= 0x00010000) ? 0x7fffffff : \
- (((int)(x_i) <= -0x00010000) ? 0x80000000 : \
- (u_int)(((x_i)<<16) | (((x_f)>>16)&0xffff))))
-#define LFPTOFP(v) MFPTOFP((v)->l_i, (v)->l_f)
-
-#define UFPTOLFP(x, v) ((v)->l_ui = (u_fp)(x)>>16, (v)->l_uf = (x)<<16)
-#define FPTOLFP(x, v) (UFPTOLFP((x), (v)), (x) < 0 ? (v)->l_ui -= 0x10000 : 0)
-
-#define MAXLFP(v) ((v)->l_ui = 0x7fffffff, (v)->l_uf = 0xffffffff)
-#define MINLFP(v) ((v)->l_ui = 0x80000000, (v)->l_uf = 0)
-
-/*
- * Primitive operations on long fixed point values. If these are
- * reminiscent of assembler op codes it's only because some may
- * be replaced by inline assembler for particular machines someday.
- * These are the (kind of inefficient) run-anywhere versions.
- */
-#define M_NEG(v_i, v_f) /* v = -v */ \
- do { \
- if ((v_f) == 0) \
- (v_i) = -((s_fp)(v_i)); \
- else { \
- (v_f) = -((s_fp)(v_f)); \
- (v_i) = ~(v_i); \
- } \
- } while(0)
-
-#define M_NEGM(r_i, r_f, a_i, a_f) /* r = -a */ \
- do { \
- if ((a_f) == 0) { \
- (r_f) = 0; \
- (r_i) = -(a_i); \
- } else { \
- (r_f) = -(a_f); \
- (r_i) = ~(a_i); \
- } \
- } while(0)
-
-#define M_ADD(r_i, r_f, a_i, a_f) /* r += a */ \
- do { \
- register u_int32 lo_tmp; \
- register u_int32 hi_tmp; \
- \
- lo_tmp = ((r_f) & 0xffff) + ((a_f) & 0xffff); \
- hi_tmp = (((r_f) >> 16) & 0xffff) + (((a_f) >> 16) & 0xffff); \
- if (lo_tmp & 0x10000) \
- hi_tmp++; \
- (r_f) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \
- \
- (r_i) += (a_i); \
- if (hi_tmp & 0x10000) \
- (r_i)++; \
- } while (0)
-
-#define M_ADD3(r_ovr, r_i, r_f, a_ovr, a_i, a_f) /* r += a, three word */ \
- do { \
- register u_int32 lo_tmp; \
- register u_int32 hi_tmp; \
- \
- lo_tmp = ((r_f) & 0xffff) + ((a_f) & 0xffff); \
- hi_tmp = (((r_f) >> 16) & 0xffff) + (((a_f) >> 16) & 0xffff); \
- if (lo_tmp & 0x10000) \
- hi_tmp++; \
- (r_f) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \
- \
- lo_tmp = ((r_i) & 0xffff) + ((a_i) & 0xffff); \
- if (hi_tmp & 0x10000) \
- lo_tmp++; \
- hi_tmp = (((r_i) >> 16) & 0xffff) + (((a_i) >> 16) & 0xffff); \
- if (lo_tmp & 0x10000) \
- hi_tmp++; \
- (r_i) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \
- \
- (r_ovr) += (a_ovr); \
- if (hi_tmp & 0x10000) \
- (r_ovr)++; \
- } while (0)
-
-#define M_SUB(r_i, r_f, a_i, a_f) /* r -= a */ \
- do { \
- register u_int32 lo_tmp; \
- register u_int32 hi_tmp; \
- \
- if ((a_f) == 0) { \
- (r_i) -= (a_i); \
- } else { \
- lo_tmp = ((r_f) & 0xffff) + ((-((s_fp)(a_f))) & 0xffff); \
- hi_tmp = (((r_f) >> 16) & 0xffff) \
- + (((-((s_fp)(a_f))) >> 16) & 0xffff); \
- if (lo_tmp & 0x10000) \
- hi_tmp++; \
- (r_f) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \
- \
- (r_i) += ~(a_i); \
- if (hi_tmp & 0x10000) \
- (r_i)++; \
- } \
- } while (0)
-
-#define M_RSHIFTU(v_i, v_f) /* v >>= 1, v is unsigned */ \
- do { \
- (v_f) = (u_int32)(v_f) >> 1; \
- if ((v_i) & 01) \
- (v_f) |= 0x80000000; \
- (v_i) = (u_int32)(v_i) >> 1; \
- } while (0)
-
-#define M_RSHIFT(v_i, v_f) /* v >>= 1, v is signed */ \
- do { \
- (v_f) = (u_int32)(v_f) >> 1; \
- if ((v_i) & 01) \
- (v_f) |= 0x80000000; \
- if ((v_i) & 0x80000000) \
- (v_i) = ((v_i) >> 1) | 0x80000000; \
- else \
- (v_i) = (v_i) >> 1; \
- } while (0)
-
-#define M_LSHIFT(v_i, v_f) /* v <<= 1 */ \
- do { \
- (v_i) <<= 1; \
- if ((v_f) & 0x80000000) \
- (v_i) |= 0x1; \
- (v_f) <<= 1; \
- } while (0)
-
-#define M_LSHIFT3(v_ovr, v_i, v_f) /* v <<= 1, with overflow */ \
- do { \
- (v_ovr) <<= 1; \
- if ((v_i) & 0x80000000) \
- (v_ovr) |= 0x1; \
- (v_i) <<= 1; \
- if ((v_f) & 0x80000000) \
- (v_i) |= 0x1; \
- (v_f) <<= 1; \
- } while (0)
-
-#define M_ADDUF(r_i, r_f, uf) /* r += uf, uf is u_int32 fraction */ \
- M_ADD((r_i), (r_f), 0, (uf)) /* let optimizer worry about it */
-
-#define M_SUBUF(r_i, r_f, uf) /* r -= uf, uf is u_int32 fraction */ \
- M_SUB((r_i), (r_f), 0, (uf)) /* let optimizer worry about it */
-
-#define M_ADDF(r_i, r_f, f) /* r += f, f is a int32 fraction */ \
- do { \
- if ((f) > 0) \
- M_ADD((r_i), (r_f), 0, (f)); \
- else if ((f) < 0) \
- M_ADD((r_i), (r_f), (-1), (f));\
- } while(0)
-
-#define M_ISNEG(v_i, v_f) /* v < 0 */ \
- (((v_i) & 0x80000000) != 0)
-
-#define M_ISHIS(a_i, a_f, b_i, b_f) /* a >= b unsigned */ \
- (((u_int32)(a_i)) > ((u_int32)(b_i)) || \
- ((a_i) == (b_i) && ((u_int32)(a_f)) >= ((u_int32)(b_f))))
-
-#define M_ISGEQ(a_i, a_f, b_i, b_f) /* a >= b signed */ \
- (((int32)(a_i)) > ((int32)(b_i)) || \
- ((a_i) == (b_i) && ((u_int32)(a_f)) >= ((u_int32)(b_f))))
-
-#define M_ISEQU(a_i, a_f, b_i, b_f) /* a == b unsigned */ \
- ((a_i) == (b_i) && (a_f) == (b_f))
-
-/*
- * Operations on the long fp format
- */
-#define L_ADD(r, a) M_ADD((r)->l_ui, (r)->l_uf, (a)->l_ui, (a)->l_uf)
-#define L_SUB(r, a) M_SUB((r)->l_ui, (r)->l_uf, (a)->l_ui, (a)->l_uf)
-#define L_NEG(v) M_NEG((v)->l_ui, (v)->l_uf)
-#define L_ADDUF(r, uf) M_ADDUF((r)->l_ui, (r)->l_uf, (uf))
-#define L_SUBUF(r, uf) M_SUBUF((r)->l_ui, (r)->l_uf, (uf))
-#define L_ADDF(r, f) M_ADDF((r)->l_ui, (r)->l_uf, (f))
-#define L_RSHIFT(v) M_RSHIFT((v)->l_i, (v)->l_uf)
-#define L_RSHIFTU(v) M_RSHIFT((v)->l_ui, (v)->l_uf)
-#define L_LSHIFT(v) M_LSHIFT((v)->l_ui, (v)->l_uf)
-#define L_CLR(v) ((v)->l_ui = (v)->l_uf = 0)
-
-#define L_ISNEG(v) (((v)->l_ui & 0x80000000) != 0)
-#define L_ISZERO(v) ((v)->l_ui == 0 && (v)->l_uf == 0)
-#define L_ISHIS(a, b) ((a)->l_ui > (b)->l_ui || \
- ((a)->l_ui == (b)->l_ui && (a)->l_uf >= (b)->l_uf))
-#define L_ISGEQ(a, b) ((a)->l_i > (b)->l_i || \
- ((a)->l_i == (b)->l_i && (a)->l_uf >= (b)->l_uf))
-#define L_ISEQU(a, b) M_ISEQU((a)->l_ui, (a)->l_uf, (b)->l_ui, (b)->l_uf)
-
-/*
- * s_fp/double and u_fp/double conversions
- */
-#define FRIC 65536. /* 2^16 as a double */
-#define DTOFP(r) ((s_fp)((r) * FRIC))
-#define DTOUFP(r) ((u_fp)((r) * FRIC))
-#define FPTOD(r) ((double)(r) / FRIC)
-
-/*
- * l_fp/double conversions
- */
-#define FRAC 4294967296. /* 2^32 as a double */
-#define M_DTOLFP(d, r_i, r_uf) /* double to l_fp */ \
- do { \
- register double d_tmp; \
- \
- d_tmp = (d); \
- if (d_tmp < 0) { \
- d_tmp = -d_tmp; \
- (r_i) = (int32)(d_tmp); \
- (r_uf) = (u_int32)(((d_tmp) - (double)(r_i)) * FRAC); \
- M_NEG((r_i), (r_uf)); \
- } else { \
- (r_i) = (int32)(d_tmp); \
- (r_uf) = (u_int32)(((d_tmp) - (double)(r_i)) * FRAC); \
- } \
- } while (0)
-#define M_LFPTOD(r_i, r_uf, d) /* l_fp to double */ \
- do { \
- register l_fp l_tmp; \
- \
- l_tmp.l_i = (r_i); \
- l_tmp.l_f = (r_uf); \
- if (l_tmp.l_i < 0) { \
- M_NEG(l_tmp.l_i, l_tmp.l_uf); \
- (d) = -((double)l_tmp.l_i + ((double)l_tmp.l_uf) / FRAC); \
- } else { \
- (d) = (double)l_tmp.l_i + ((double)l_tmp.l_uf) / FRAC; \
- } \
- } while (0)
-#define DTOLFP(d, v) M_DTOLFP((d), (v)->l_ui, (v)->l_uf)
-#define LFPTOD(v, d) M_LFPTOD((v)->l_ui, (v)->l_uf, (d))
-
-/*
- * Prototypes
- */
-#if 0
-extern char * dofptoa (u_fp, int, short, int);
-extern char * dolfptoa (u_long, u_long, int, short, int);
-#endif
-
-extern int atolfp (const char *, l_fp *);
-extern int buftvtots (const char *, l_fp *);
-extern char * fptoa (s_fp, short);
-extern char * fptoms (s_fp, short);
-extern int hextolfp (const char *, l_fp *);
-extern void gpstolfp (int, int, unsigned long, l_fp *);
-extern int mstolfp (const char *, l_fp *);
-extern char * prettydate (l_fp *);
-extern char * gmprettydate (l_fp *);
-extern char * uglydate (l_fp *);
-extern void mfp_mul (int32 *, u_int32 *, int32, u_int32, int32, u_int32);
-
-extern void get_systime (l_fp *);
-extern int step_systime (double);
-extern int adj_systime (double);
-
-#define lfptoa(_fpv, _ndec) mfptoa((_fpv)->l_ui, (_fpv)->l_uf, (_ndec))
-#define lfptoms(_fpv, _ndec) mfptoms((_fpv)->l_ui, (_fpv)->l_uf, (_ndec))
-
-#define ufptoa(_fpv, _ndec) dofptoa((_fpv), 0, (_ndec), 0)
-#define ufptoms(_fpv, _ndec) dofptoa((_fpv), 0, (_ndec), 1)
-#define ulfptoa(_fpv, _ndec) dolfptoa((_fpv)->l_ui, (_fpv)->l_uf, 0, (_ndec), 0)
-#define ulfptoms(_fpv, _ndec) dolfptoa((_fpv)->l_ui, (_fpv)->l_uf, 0, (_ndec), 1)
-#define umfptoa(_fpi, _fpf, _ndec) dolfptoa((_fpi), (_fpf), 0, (_ndec), 0)
diff --git a/contrib/ntp/util/ntp-keygen-opts.c b/contrib/ntp/util/ntp-keygen-opts.c
index aff2d01..8521861 100644
--- a/contrib/ntp/util/ntp-keygen-opts.c
+++ b/contrib/ntp/util/ntp-keygen-opts.c
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (ntp-keygen-opts.c)
*
- * It has been AutoGen-ed February 4, 2015 at 02:43:42 AM by AutoGen 5.18.5pre4
+ * It has been AutoGen-ed April 7, 2015 at 04:27:30 AM by AutoGen 5.18.5pre4
* From the definitions ntp-keygen-opts.def
* and the template file options
*
@@ -72,7 +72,7 @@ extern FILE * option_usage_fp;
* static const strings for ntp-keygen options
*/
static char const ntp_keygen_opt_strs[2419] =
-/* 0 */ "ntp-keygen (ntp) 4.2.8p1\n"
+/* 0 */ "ntp-keygen (ntp) 4.2.8p2\n"
"Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n"
"This is free software. It is licensed for use, modification and\n"
"redistribution under the terms of the NTP License, copies of which\n"
@@ -164,14 +164,14 @@ static char const ntp_keygen_opt_strs[2419] =
/* 2202 */ "no-load-opts\0"
/* 2215 */ "no\0"
/* 2218 */ "NTP_KEYGEN\0"
-/* 2229 */ "ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p1\n"
+/* 2229 */ "ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p2\n"
"Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n\0"
/* 2343 */ "$HOME\0"
/* 2349 */ ".\0"
/* 2351 */ ".ntprc\0"
/* 2358 */ "http://bugs.ntp.org, bugs@ntp.org\0"
/* 2392 */ "\n\0"
-/* 2394 */ "ntp-keygen (ntp) 4.2.8p1";
+/* 2394 */ "ntp-keygen (ntp) 4.2.8p2";
/**
* imbits option description:
@@ -1309,7 +1309,7 @@ static void bogus_function(void) {
translate option names.
*/
/* referenced via ntp_keygenOptions.pzCopyright */
- puts(_("ntp-keygen (ntp) 4.2.8p1\n\
+ puts(_("ntp-keygen (ntp) 4.2.8p2\n\
Copyright (C) 1992-2015 The University of Delaware and Network Time Foundation, all rights reserved.\n\
This is free software. It is licensed for use, modification and\n\
redistribution under the terms of the NTP License, copies of which\n\
@@ -1408,14 +1408,14 @@ implied warranty.\n"));
puts(_("load options from a config file"));
/* referenced via ntp_keygenOptions.pzUsageTitle */
- puts(_("ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p1\n\
+ puts(_("ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p2\n\
Usage: %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n"));
/* referenced via ntp_keygenOptions.pzExplain */
puts(_("\n"));
/* referenced via ntp_keygenOptions.pzFullVersion */
- puts(_("ntp-keygen (ntp) 4.2.8p1"));
+ puts(_("ntp-keygen (ntp) 4.2.8p2"));
/* referenced via ntp_keygenOptions.pzFullUsage */
puts(_("<<<NOT-FOUND>>>"));
diff --git a/contrib/ntp/util/ntp-keygen-opts.h b/contrib/ntp/util/ntp-keygen-opts.h
index 4848999..54f1ac4 100644
--- a/contrib/ntp/util/ntp-keygen-opts.h
+++ b/contrib/ntp/util/ntp-keygen-opts.h
@@ -1,7 +1,7 @@
/*
* EDIT THIS FILE WITH CAUTION (ntp-keygen-opts.h)
*
- * It has been AutoGen-ed February 4, 2015 at 02:43:41 AM by AutoGen 5.18.5pre4
+ * It has been AutoGen-ed April 7, 2015 at 04:27:29 AM by AutoGen 5.18.5pre4
* From the definitions ntp-keygen-opts.def
* and the template file options
*
@@ -94,9 +94,9 @@ typedef enum {
/** count of all options for ntp-keygen */
#define OPTION_CT 26
/** ntp-keygen version */
-#define NTP_KEYGEN_VERSION "4.2.8p1"
+#define NTP_KEYGEN_VERSION "4.2.8p2"
/** Full ntp-keygen version text */
-#define NTP_KEYGEN_FULL_VERSION "ntp-keygen (ntp) 4.2.8p1"
+#define NTP_KEYGEN_FULL_VERSION "ntp-keygen (ntp) 4.2.8p2"
/**
* Interface defines for all options. Replace "n" with the UPPER_CASED
diff --git a/contrib/ntp/util/ntp-keygen.1ntp-keygenman b/contrib/ntp/util/ntp-keygen.1ntp-keygenman
index 46bbad8..b600ed4 100644
--- a/contrib/ntp/util/ntp-keygen.1ntp-keygenman
+++ b/contrib/ntp/util/ntp-keygen.1ntp-keygenman
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntp-keygen 1ntp-keygenman "04 Feb 2015" "ntp (4.2.8p1)" "User Commands"
+.TH ntp-keygen 1ntp-keygenman "07 Apr 2015" "ntp (4.2.8p2)" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-Xkaqsu/ag-9kairu)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-Kfaqzc/ag-Wfaiyc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:43:55 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:27:42 AM by AutoGen 5.18.5pre4
.\" From the definitions ntp-keygen-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/util/ntp-keygen.1ntp-keygenmdoc b/contrib/ntp/util/ntp-keygen.1ntp-keygenmdoc
index d70ca2c..ad8a96d 100644
--- a/contrib/ntp/util/ntp-keygen.1ntp-keygenmdoc
+++ b/contrib/ntp/util/ntp-keygen.1ntp-keygenmdoc
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTP_KEYGEN 1ntp-keygenmdoc User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntp-keygen-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:44:02 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:27:49 AM by AutoGen 5.18.5pre4
.\" From the definitions ntp-keygen-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/ntp/util/ntp-keygen.c b/contrib/ntp/util/ntp-keygen.c
index c169021..494bedb 100644
--- a/contrib/ntp/util/ntp-keygen.c
+++ b/contrib/ntp/util/ntp-keygen.c
@@ -827,24 +827,24 @@ gen_md5(
str = fheader("MD5key", id, groupname);
for (i = 1; i <= MD5KEYS; i++) {
for (j = 0; j < MD5SIZE; j++) {
- int temp;
+ u_char temp;
while (1) {
int rc;
- rc = ntp_crypto_random_buf(&temp, 1);
+ rc = ntp_crypto_random_buf(
+ &temp, sizeof(temp));
if (-1 == rc) {
fprintf(stderr, "ntp_crypto_random_buf() failed.\n");
exit (-1);
}
- temp &= 0xff;
if (temp == '#')
continue;
if (temp > 0x20 && temp < 0x7f)
break;
}
- md5key[j] = (u_char)temp;
+ md5key[j] = temp;
}
md5key[j] = '\0';
fprintf(str, "%2d MD5 %s # MD5 key\n", i,
@@ -2170,15 +2170,29 @@ fheader (
FILE *str; /* file handle */
char linkname[MAXFILENAME]; /* link name */
int temp;
-
+#ifdef HAVE_UMASK
+ mode_t orig_umask;
+#endif
+
snprintf(filename, sizeof(filename), "ntpkey_%s_%s.%u", file,
owner, fstamp);
- if ((str = fopen(filename, "w")) == NULL) {
+#ifdef HAVE_UMASK
+ orig_umask = umask( S_IWGRP | S_IRWXO );
+ str = fopen(filename, "w");
+ (void) umask(orig_umask);
+#else
+ str = fopen(filename, "w");
+#endif
+ if (str == NULL) {
perror("Write");
exit (-1);
}
- snprintf(linkname, sizeof(linkname), "ntpkey_%s_%s", ulink,
- hostname);
+ if (strcmp(ulink, "md5") == 0) {
+ strcpy(linkname,"ntp.keys");
+ } else {
+ snprintf(linkname, sizeof(linkname), "ntpkey_%s_%s", ulink,
+ hostname);
+ }
(void)remove(linkname); /* The symlink() line below matters */
temp = symlink(filename, linkname);
if (temp < 0)
diff --git a/contrib/ntp/util/ntp-keygen.html b/contrib/ntp/util/ntp-keygen.html
index 3b950ec..1aad39b 100644
--- a/contrib/ntp/util/ntp-keygen.html
+++ b/contrib/ntp/util/ntp-keygen.html
@@ -70,7 +70,7 @@ All other files are in PEM-encoded
printable ASCII format so they can be embedded as MIME attachments in
mail to other sites.
- <p>This document applies to version 4.2.8p1 of <code>ntp-keygen</code>.
+ <p>This document applies to version 4.2.8p2 of <code>ntp-keygen</code>.
<div class="node">
<p><hr>
@@ -1085,7 +1085,7 @@ the usage text by passing it through a pager program.
used to select the program, defaulting to <span class="file">more</span>. Both will exit
with a status code of 0.
-<pre class="example">ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p1-RC2
+<pre class="example">ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.8p2-RC3
Usage: ntp-keygen [ -&lt;flag&gt; [&lt;val&gt;] | --&lt;name&gt;[{=| }&lt;val&gt;] ]...
Flg Arg Option-Name Description
-b Num imbits identity modulus bits
diff --git a/contrib/ntp/util/ntp-keygen.man.in b/contrib/ntp/util/ntp-keygen.man.in
index 6242382..b47691b 100644
--- a/contrib/ntp/util/ntp-keygen.man.in
+++ b/contrib/ntp/util/ntp-keygen.man.in
@@ -10,11 +10,11 @@
.ds B-Font B
.ds I-Font I
.ds R-Font R
-.TH ntp-keygen @NTP_KEYGEN_MS@ "04 Feb 2015" "ntp (4.2.8p1)" "User Commands"
+.TH ntp-keygen @NTP_KEYGEN_MS@ "07 Apr 2015" "ntp (4.2.8p2)" "User Commands"
.\"
-.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-Xkaqsu/ag-9kairu)
+.\" EDIT THIS FILE WITH CAUTION (/tmp/.ag-Kfaqzc/ag-Wfaiyc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:43:55 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:27:42 AM by AutoGen 5.18.5pre4
.\" From the definitions ntp-keygen-opts.def
.\" and the template file agman-cmd.tpl
.SH NAME
diff --git a/contrib/ntp/util/ntp-keygen.mdoc.in b/contrib/ntp/util/ntp-keygen.mdoc.in
index da99a8d..540ff4f 100644
--- a/contrib/ntp/util/ntp-keygen.mdoc.in
+++ b/contrib/ntp/util/ntp-keygen.mdoc.in
@@ -1,9 +1,9 @@
-.Dd February 4 2015
+.Dd April 7 2015
.Dt NTP_KEYGEN @NTP_KEYGEN_MS@ User Commands
.Os
.\" EDIT THIS FILE WITH CAUTION (ntp-keygen-opts.mdoc)
.\"
-.\" It has been AutoGen-ed February 4, 2015 at 02:44:02 AM by AutoGen 5.18.5pre4
+.\" It has been AutoGen-ed April 7, 2015 at 04:27:49 AM by AutoGen 5.18.5pre4
.\" From the definitions ntp-keygen-opts.def
.\" and the template file agmdoc-cmd.tpl
.Sh NAME
diff --git a/contrib/openresolv/GNUmakefile b/contrib/openresolv/GNUmakefile
new file mode 100644
index 0000000..4bc845a
--- /dev/null
+++ b/contrib/openresolv/GNUmakefile
@@ -0,0 +1,4 @@
+# Nasty hack so that make clean works without configure being run
+CONFIG_MK?=$(shell test -e config.mk && echo config.mk || echo config-null.mk)
+
+include Makefile
diff --git a/contrib/openresolv/Makefile b/contrib/openresolv/Makefile
index e4e3498..aca2cb5 100644
--- a/contrib/openresolv/Makefile
+++ b/contrib/openresolv/Makefile
@@ -1,8 +1,19 @@
-include config.mk
+PKG= openresolv
+VERSION= 3.7.0
-NAME= openresolv
-VERSION= 3.4.1
-PKG= ${NAME}-${VERSION}
+# Nasty hack so that make clean works without configure being run
+_CONFIG_MK!= test -e config.mk && echo config.mk || echo config-null.mk
+CONFIG_MK?= ${_CONFIG_MK}
+include ${CONFIG_MK}
+
+SBINDIR?= /sbin
+SYSCONFDIR?= /etc
+LIBEXECDIR?= /libexec/resolvconf
+VARDIR?= /var/run/resolvconf
+RCDIR?= /etc/rc.d
+RESTARTCMD?= if ${RCDIR}/\1 status >/dev/null 2>\&1; then \
+ ${RCDIR}/\1 restart; \
+ fi
INSTALL?= install
SED?= sed
@@ -17,31 +28,36 @@ TARGET= ${RESOLVCONF} ${SUBSCRIBERS}
SRCS= ${TARGET:C,$,.in,} # pmake
SRCS:= ${TARGET:=.in} # gmake
-SED_PREFIX= -e 's:@PREFIX@:${PREFIX}:g'
+SED_SBINDIR= -e 's:@SBINDIR@:${SBINDIR}:g'
SED_SYSCONFDIR= -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g'
SED_LIBEXECDIR= -e 's:@LIBEXECDIR@:${LIBEXECDIR}:g'
SED_VARDIR= -e 's:@VARDIR@:${VARDIR}:g'
SED_RCDIR= -e 's:@RCDIR@:${RCDIR}:g'
SED_RESTARTCMD= -e 's:@RESTARTCMD \(.*\)@:${RESTARTCMD}:g'
+DISTPREFIX?= ${PKG}-${VERSION}
+DISTFILEGZ?= ${DISTPREFIX}.tar.gz
+DISTFILE?= ${DISTPREFIX}.tar.bz2
+FOSSILID?= current
+
.SUFFIXES: .in
all: ${TARGET}
.in:
- ${SED} ${SED_PREFIX} ${SED_SYSCONFDIR} ${SED_LIBEXECDIR} \
+ ${SED} ${SED_SBINDIR} ${SED_SYSCONFDIR} ${SED_LIBEXECDIR} \
${SED_VARDIR} ${SED_RCDIR} ${SED_RESTARTCMD} \
$< > $@
clean:
- rm -f ${TARGET} openresolv-${VERSION}.tar.bz2
+ rm -f ${TARGET}
distclean: clean
- rm -f config.mk
+ rm -f config.mk ${DISTFILE}
installdirs:
-install: ${TARGET}
+proginstall: ${TARGET}
${INSTALL} -d ${DESTDIR}${SBINDIR}
${INSTALL} -m ${BINMODE} resolvconf ${DESTDIR}${SBINDIR}
${INSTALL} -d ${DESTDIR}${SYSCONFDIR}
@@ -49,18 +65,21 @@ install: ${TARGET}
${INSTALL} -m ${DOCMODE} resolvconf.conf ${DESTDIR}${SYSCONFDIR}
${INSTALL} -d ${DESTDIR}${LIBEXECDIR}
${INSTALL} -m ${DOCMODE} ${SUBSCRIBERS} ${DESTDIR}${LIBEXECDIR}
+
+maninstall:
${INSTALL} -d ${DESTDIR}${MANDIR}/man8
${INSTALL} -m ${MANMODE} resolvconf.8 ${DESTDIR}${MANDIR}/man8
${INSTALL} -d ${DESTDIR}${MANDIR}/man5
${INSTALL} -m ${MANMODE} resolvconf.conf.5 ${DESTDIR}${MANDIR}/man5
+install: proginstall maninstall
+
import:
- rm -rf /tmp/${PKG}
- ${INSTALL} -d /tmp/${PKG}
- cp README ${SRCS} /tmp/${PKG}
-
-dist: import
- cp configure Makefile resolvconf.conf /tmp/${PKG}
- tar cvjpf ${PKG}.tar.bz2 -C /tmp ${PKG}
- rm -rf /tmp/${PKG}
- ls -l ${PKG}.tar.bz2
+ rm -rf /tmp/${DISTPREFIX}
+ ${INSTALL} -d /tmp/${DISTPREFIX}
+ cp README ${SRCS} /tmp/${DISPREFIX}
+
+dist:
+ fossil tarball --name ${DISTPREFIX} ${FOSSILID} ${DISTFILEGZ}
+ gunzip -c ${DISTFILEGZ} | bzip2 >${DISTFILE}
+ rm ${DISTFILEGZ}
diff --git a/contrib/openresolv/config-null.mk b/contrib/openresolv/config-null.mk
new file mode 100644
index 0000000..6bf701d
--- /dev/null
+++ b/contrib/openresolv/config-null.mk
@@ -0,0 +1 @@
+# This space left intentionally blank
diff --git a/contrib/openresolv/configure b/contrib/openresolv/configure
index 39bdddb..190ee71 100644
--- a/contrib/openresolv/configure
+++ b/contrib/openresolv/configure
@@ -9,7 +9,7 @@ TARGET=
RESTARTCMD=
RCDIR=
-for x; do
+for x do
opt=${x%%=*}
var=${x#*=}
case "$opt" in
@@ -18,7 +18,7 @@ for x; do
--debug) DEBUG=$var;;
--disable-debug) DEBUG=no;;
--enable-debug) DEBUG=yes;;
- --prefix) prefix=$var;;
+ --prefix) PREFIX=$var;;
--sysconfdir) SYSCONFDIR=$var;;
--bindir|--sbindir) SBINDIR=$var;;
--libexecdir) LIBEXECDIR=$var;;
@@ -41,68 +41,76 @@ for x; do
esac
done
+if [ -z "$LIBEXECDIR" ]; then
+ printf "Checking for directory /libexec ... "
+ if [ -d /libexec ]; then
+ echo "yes"
+ LIBEXECDIR=$PREFIX/libexec/resolvconf
+ else
+ echo "no"
+ LIBEXECDIR=$PREFIX/lib/resolvconf
+ fi
+fi
+if [ -z "$RUNDIR" ]; then
+ printf "Checking for directory /run ... "
+ if [ -d /run ]; then
+ echo "yes"
+ RUNDIR=/run
+ else
+ echo "no"
+ RUNDIR=/var/run
+ fi
+fi
+
: ${SED:=sed}
-: ${PREFIX:=$prefix}
: ${SYSCONFDIR:=$PREFIX/etc}
: ${SBINDIR:=$PREFIX/sbin}
-: ${LIBEXECDIR:=$PREFIX/libexec}
+: ${LIBEXECDIR:=$PREFIX/libexec/resolvconf}
: ${STATEDIR:=/var}
: ${RUNDIR:=$STATEDIR/run}
: ${MANDIR:=${PREFIX:-/usr}/share/man}
eval SYSCONFDIR="$SYSCONFDIR"
eval SBINDIR="$SBINDIR"
-eval LIBEXECDIR="$LIBEXECDIR/resolvconf"
+eval LIBEXECDIR="$LIBEXECDIR"
eval VARDIR="$RUNDIR/resolvconf"
eval MANDIR="$MANDIR"
CONFIG_MK=config.mk
if [ -z "$BUILD" ]; then
- BUILD=`uname -m`-`uname -s | tr '[:upper:]' '[:lower:]'`
-fi
-if [ -z "$HOST" ]; then
- [ -z "$TARGET" ] && TARGET=$BUILD
- HOST=$TARGET
-fi
-if [ -z "$TARGET" ]; then
- [ -z "$HOST" ] && HOST=$BUILD
- TARGET=$HOST
-fi
-
-# Debian and Slackware have linux in different places when dealing with
-# autoconf, so we deal with that here.
-if [ -z "$OS" ]; then
- case "$TARGET" in
- *-linux-*|linux-*|*-linux|linux) OS=linux;;
- esac
+ # autoconf target triplet: cpu-vendor-os
+ BUILD=$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]')
fi
+: ${HOST:=$BUILD}
if [ -z "$OS" ]; then
- # Derive OS from cpu-manufacturer-os-kernel
- CPU=${TARGET%%-*}
- REST=${TARGET#*-}
+ echo "Deriving operating system from ... $HOST"
+ # Derive OS from cpu-vendor-[kernel-]os
+ CPU=${HOST%%-*}
+ REST=${HOST#*-}
if [ "$CPU" != "$REST" ]; then
- MANU=${REST%%-*}
+ VENDOR=${REST%%-*}
REST=${REST#*-}
- if [ "$MANU" != "$REST" ]; then
+ if [ "$VENDOR" != "$REST" ]; then
+ # Use kernel if given, otherwise os
OS=${REST%%-*}
- REST=${REST#*-}
- if [ "$OS" != "$REST" ]; then
- KERNEL=${REST%%-*}
- else
- # 3 tupple
- KERNEL=$OS
- OS=$MANU
- MANU=
- fi
else
# 2 tupple
- OS=$MANU
- MANU=
+ OS=$VENDOR
+ VENDOR=
fi
fi
+
+ # Work with cpu-kernel-os, ie Debian
+ case "$VENDOR" in
+ linux*|kfreebsd*) OS=$VENDOR; VENDOR= ;;
+ esac
+ # Special case
+ case "$OS" in
+ gnu*) OS=hurd;; # No HURD support as yet
+ esac
fi
echo "Configuring openresolv for ... $OS"
@@ -118,17 +126,36 @@ for x in SYSCONFDIR SBINDIR LIBEXECDIR VARDIR MANDIR; do
echo "$x=$t $v" >>$CONFIG_MK
done
-if [ -e /etc/arch-release -a -d /etc/rc.d ]; then
- echo "Overriding service status check for Arch Linux"
- RCDIR=/etc/rc.d
- RESTARTCMD="[ -e /var/run/daemons/\1 ] \&\& /etc/rc.d/\1 restart"
- echo "yes"
+if [ -z "$RESTARTCMD" ]; then
+ printf "Checking for systemd ... "
+ if [ -x /bin/systemctl ]; then
+ RESTARTCMD="/bin/systemctl try-restart \1"
+ echo "yes"
+ elif [ -x /usr/bin/systemctl ]; then
+ RESTARTCMD="/usr/bin/systemctl try-restart \1"
+ echo "yes"
+ else
+ echo "no"
+ fi
+fi
+
+# Arch upgraded to systemd, so this check has to be just after systemd
+# but higher than the others
+if [ -z "$RESTARTCMD" ]; then
+ printf "Checking for Arch ... "
+ if [ -e /etc/arch-release -a -d /etc/rc.d ]; then
+ RCDIR=/etc/rc.d
+ RESTARTCMD="[ -e /var/run/daemons/\1 ] \&\& /etc/rc.d/\1 restart"
+ echo "yes"
+ else
+ echo "no"
+ fi
fi
if [ -z "$RESTARTCMD" ]; then
printf "Checking for OpenRC ... "
if [ -x /sbin/rc-service ]; then
- RESTARTCMD="/sbin/rc-service -e \1 \&\& /sbin/rc-service \1 -- -Ds restart"
+ RESTARTCMD="if /sbin/rc-service -e \1; then /sbin/rc-service \1 -- -Ds restart; fi"
echo "yes"
else
echo "no"
@@ -138,7 +165,7 @@ if [ -z "$RESTARTCMD" ]; then
printf "Checking for invoke-rc.d ... "
if [ -x /usr/sbin/invoke-rc.d ]; then
RCDIR=/etc/init.d
- RESTARTCMD="/usr/sbin/invoke-rc.d --quiet \1 status >/dev/null 2>\&1 \&\& /usr/sbin/invoke-rc.d \1 restart"
+ RESTARTCMD="if /usr/sbin/invoke-rc.d --quiet \1 status >/dev/null 2>\&1; then /usr/sbin/invoke-rc.d \1 restart; fi"
echo "yes"
else
echo "no"
@@ -148,7 +175,19 @@ if [ -z "$RESTARTCMD" ]; then
printf "Checking for service ... "
if [ -x /sbin/service ]; then
RCDIR=/etc/init.d
- RESTARTCMD="/sbin/service \1 \&\& /sbin/service \1 restart"
+ RESTARTCMD="if /sbin/service \1; then /sbin/service \1 restart; fi"
+ echo "yes"
+ else
+ echo "no"
+ fi
+fi
+if [ -z "$RESTARTCMD" ]; then
+ printf "Checking for runit... "
+ if [ -x /bin/sv ]; then
+ RESTARTCMD="/bin/sv try-restart \1"
+ echo "yes"
+ elif [ -x /usr/bin/sv ]; then
+ RESTARTCMD="/usr/bin/sv try-restart \1"
echo "yes"
else
echo "no"
@@ -159,7 +198,7 @@ if [ -z "$RESTARTCMD" ]; then
printf "Checking for $x ... "
if [ -d $x ]; then
RCDIR=$x
- RESTARTCMD="$x/\1 status >/dev/null 2>\&1 \&\& $x/\1 restart"
+ RESTARTCMD="if $x/\1 status >/dev/null 2>\&1; then $x/\1 restart; fi"
echo "yes"
break
else
@@ -169,7 +208,7 @@ if [ -z "$RESTARTCMD" ]; then
fi
if [ -z "$RESTARTCMD" ]; then
- echo "WARNING! No means of interacting with system services detected!"
+ echo "$0: WARNING: No means of interacting with system services detected!"
exit 1
fi
diff --git a/contrib/openresolv/dnsmasq.in b/contrib/openresolv/dnsmasq.in
index 178f4dd..1b6ad16 100644
--- a/contrib/openresolv/dnsmasq.in
+++ b/contrib/openresolv/dnsmasq.in
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (c) 2007-2009 Roy Marples
+# Copyright (c) 2007-2012 Roy Marples
# All rights reserved
# dnsmasq subscriber for resolvconf
@@ -29,12 +29,13 @@
[ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
. "@SYSCONFDIR@/resolvconf.conf" || exit 1
[ -z "$dnsmasq_conf" -a -z "$dnsmasq_resolv" ] && exit 0
-[ -z "$RESOLVCONF" ] && eval "$(@PREFIX@/sbin/resolvconf -v)"
+[ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)"
NL="
"
: ${dnsmasq_pid:=/var/run/dnsmasq.pid}
[ -s "$dnsmasq_pid" ] || dnsmasq_pid=/var/run/dnsmasq/dnsmasq.pid
+[ -s "$dnsmasq_pid" ] || unset dnsmasq_pid
: ${dnsmasq_service:=dnsmasq}
: ${dnsmasq_restart:=@RESTARTCMD ${dnsmasq_service}@}
newconf="# Generated by resolvconf$NL"
@@ -46,21 +47,18 @@ newresolv="$newconf"
# so we need to validate a few things first.
# Check for DBus support in the binary
dbus=false
-: ${dbus_pid:=/var/run/dbus/dbus.pid}
-[ -s "$dbus_pid" ] || dbus_pid=/var/run/dbus.pid
-[ -s "$dbus_pid" ] || dbus_pid=/var/run/dbus/pid
-if [ -s "$dbus_pid" -a -s "$dnsmasq_pid" ]; then
- if dnsmasq --version 2>/dev/null | \
- grep -q "^Compile time options.*[[:space:]]DBus[[:space:]]"
+dbus_ex=false
+dbus_introspect=$(dbus-send --print-reply --system \
+ --dest=uk.org.thekelleys.dnsmasq \
+ /uk/org/thekelleys/dnsmasq \
+ org.freedesktop.DBus.Introspectable.Introspect \
+ 2>/dev/null)
+if [ $? = 0 ]; then
+ dbus=true
+ if printf %s "$dbus_introspect" | \
+ grep -q '<method name="SetDomainServers">'
then
- # Sanity - check that dnsmasq and dbus are running
- if kill -0 $(cat "$dbus_pid") 2>/dev/null && \
- kill -0 $(cat "$dnsmasq_pid") 2>/dev/null
- then
- dbus=true
- newconf="$newconf$NL# Domain specific servers will"
- newconf="$newconf be sent over dbus${NL}enable-dbus$NL"
- fi
+ dbus_ex=true
fi
fi
@@ -69,30 +67,97 @@ for n in $NAMESERVERS; do
done
dbusdest=
+dbusdest_ex=
+conf=
for d in $DOMAINS; do
dn="${d%%:*}"
ns="${d#*:}"
while [ -n "$ns" ]; do
- if $dbus; then
- SIFS=${IFS-y} OIFS=$IFS
- IFS=.
- set -- ${ns%%,*}
- num="0x$(printf %02x $1 $2 $3 $4)"
- if [ "$SIFS" = yi ]; then
- unset IFS
- else
- IFS=$OIFS
- fi
- dbusdest="$dbusdest uint32:$(printf %u $num)"
- dbusdest="$dbusdest string:$dn"
- else
- newconf="${newconf}server=/$dn/${ns%%,*}$NL"
+ n="${ns%%,*}"
+ if $dbus && ! $dbus_ex; then
+ case "$n" in
+ *.*.*.*)
+ SIFS=${IFS-y} OIFS=$IFS
+ IFS=.
+ set -- $n
+ num="0x$(printf %02x $1 $2 $3 $4)"
+ if [ "$SIFS" = y ]; then
+ unset IFS
+ else
+ IFS=$OIFS
+ fi
+ dbusdest="$dbusdest uint32:$(printf %u $num)"
+ dbusdest="$dbusdest string:$dn"
+ ;;
+ *:*%*)
+ # This version of dnsmasq won't accept
+ # scoped IPv6 addresses
+ dbus=false
+ ;;
+ *:*)
+ SIFS=${IFS-y} OIFS=$IFS bytes= front= back=
+ empty=false i=0
+ IFS=:
+ set -- $n
+ while [ -n "$1" -o -n "$2" ]; do
+ addr="$1"
+ shift
+ if [ -z "$addr" ]; then
+ empty=true
+ continue
+ fi
+ i=$(($i + 1))
+ while [ ${#addr} -lt 4 ]; do
+ addr="0${addr}"
+ done
+ byte1="$(printf %d 0x${addr%??})"
+ byte2="$(printf %d 0x${addr#??})"
+ if $empty; then
+ back="$back byte:$byte1 byte:$byte2"
+ else
+ front="$front byte:$byte1 byte:$byte2"
+ fi
+ done
+ while [ $i != 8 ]; do
+ i=$(($i + 1))
+ front="$front byte:0 byte:0"
+ done
+ front="${front}$back"
+ if [ "$SIFS" = y ]; then
+ unset IFS
+ else
+ IFS=$OIFS
+ fi
+ dbusdest="${dbusdest}$front string:$dn"
+ ;;
+ *)
+ if ! $dbus_ex; then
+ dbus=false
+ fi
+ ;;
+ esac
fi
+ dbusdest_ex="$dbusdest_ex${dbusdest_ex:+,}/$dn/$n"
+ conf="${conf}server=/$dn/$n$NL"
[ "$ns" = "${ns#*,}" ] && break
ns="${ns#*,}"
done
done
+if $dbus; then
+ newconf="$newconf$NL# Domain specific servers will"
+ newconf="$newconf be sent over dbus${NL}"
+else
+ newconf="$newconf$conf"
+fi
+
+# Try to ensure that config dirs exist
+if type config_mkdirs >/dev/null 2>&1; then
+ config_mkdirs "$dnsmasq_conf" "$dnsmasq_resolv"
+else
+ @SBINDIR@/resolvconf -D "$dnsmasq_conf" "$dnsmasq_resolv"
+fi
+
changed=false
if [ -n "$dnsmasq_conf" ]; then
if [ ! -f "$dnsmasq_conf" ] || \
@@ -103,14 +168,13 @@ if [ -n "$dnsmasq_conf" ]; then
fi
fi
if [ -n "$dnsmasq_resolv" ]; then
+ # dnsmasq polls this file so no need to set changed=true
if [ -f "$dnsmasq_resolv" ]; then
if [ "$(cat "$dnsmasq_resolv")" != "$(printf %s "$newresolv")" ]
then
- changed=true
printf %s "$newresolv" >"$dnsmasq_resolv"
fi
else
- # dnsmasq polls this file so no need to set changed=true
printf %s "$newresolv" >"$dnsmasq_resolv"
fi
fi
@@ -119,9 +183,20 @@ if $changed; then
eval $dnsmasq_restart
fi
if $dbus; then
- $changed || kill -HUP $(cat "$dnsmasq_pid")
+ if [ -s "$dnsmasq_pid" ]; then
+ $changed || kill -HUP $(cat "$dnsmasq_pid")
+ fi
# Send even if empty so old servers are cleared
+ if $dbus_ex; then
+ method=SetDomainServers
+ if [ -n "$dbusdest_ex" ]; then
+ dbusdest_ex="array:string:$dbusdest_ex"
+ fi
+ dbusdest="$dbusdest_ex"
+ else
+ method=SetServers
+ fi
dbus-send --system --dest=uk.org.thekelleys.dnsmasq \
- /uk/org/thekelleys/dnsmasq uk.org.thekelleys.SetServers \
+ /uk/org/thekelleys/dnsmasq uk.org.thekelleys.$method \
$dbusdest
fi
diff --git a/contrib/openresolv/libc.in b/contrib/openresolv/libc.in
index cf0323e..d4f6cc9 100644
--- a/contrib/openresolv/libc.in
+++ b/contrib/openresolv/libc.in
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (c) 2007-2009 Roy Marples
+# Copyright (c) 2007-2014 Roy Marples
# All rights reserved
# libc subscriber for resolvconf
@@ -36,18 +36,18 @@ NL="
# sed may not be available, and this is faster on small files
key_get_value()
{
- local key="$1" value= x= line=
+ local key="$1" x= line=
shift
if [ $# -eq 0 ]; then
- while read line; do
+ while read -r line; do
case "$line" in
"$key"*) echo "${line##$key}";;
esac
done
else
- for x; do
- while read line; do
+ for x do
+ while read -r line; do
case "$line" in
"$key"*) echo "${line##$key}";;
esac
@@ -56,6 +56,24 @@ key_get_value()
fi
}
+keys_remove()
+{
+ local key x line found
+
+ while read -r line; do
+ found=false
+ for key do
+ case "$line" in
+ "$key"*|"#"*|" "*|" "*|"") found=true;;
+ esac
+ $found && break
+ done
+ $found || echo "$line"
+ done
+}
+
+local_nameservers="127.* 0.0.0.0 255.255.255.255 ::1"
+
# Support original resolvconf configuration layout
# as well as the openresolv config file
if [ -f "$SYSCONFDIR"/resolvconf.conf ]; then
@@ -64,12 +82,11 @@ elif [ -d "$SYSCONFDIR"/resolvconf ]; then
SYSCONFDIR="$SYSCONFDIR/resolvconf/resolv.conf.d"
base="$SYSCONFDIR/resolv.conf.d/base"
if [ -f "$base" ]; then
- name_servers="$(key_get_value "nameserver " "$base")"
- search_domains="$(key_get_value "search " "$base")"
- if [ -z "$search_domains" ]; then
- search_domains="$(key_get_value "domain " "$base")"
- fi
+ prepend_nameservers="$(key_get_value "nameserver " "$base")"
+ domain="$(key_get_value "domain " "$base")"
+ prepend_search="$(key_get_value "search " "$base")"
resolv_conf_options="$(key_get_value "options " "$base")"
+ resolv_conf_sortlist="$(key_get_value "sortlist " "$base")"
fi
if [ -f "$SYSCONFDIR"/resolv.conf.d/head ]; then
resolv_conf_head="$(cat "${SYSCONFDIR}"/resolv.conf.d/head)"
@@ -81,7 +98,7 @@ fi
: ${resolv_conf:=/etc/resolv.conf}
: ${libc_service:=nscd}
: ${libc_restart:=@RESTARTCMD ${libc_service}@}
-: ${list_resolv:=@PREFIX@/sbin/resolvconf -l}
+: ${list_resolv:=@SBINDIR@/resolvconf -l}
if [ "${resolv_conf_head-x}" = x -a -f "$SYSCONFDIR"/resolv.conf.head ]; then
resolv_conf_head="$(cat "${SYSCONFDIR}"/resolv.conf.head)"
fi
@@ -89,6 +106,9 @@ if [ "${resolv_conf_tail-x}" = x -a -f "$SYSCONFDIR"/resolv.conf.tail ]; then
resolv_conf_tail="$(cat "$SYSCONFDIR"/resolv.conf.tail)"
fi
+backup=true
+signature="# Generated by resolvconf"
+
uniqify()
{
local result=
@@ -104,6 +124,7 @@ uniqify()
case "${resolv_conf_passthrough:-NO}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+ backup=false
newest=
for conf in "$IFACEDIR"/*; do
if [ -z "$newest" -o "$conf" -nt "$newest" ]; then
@@ -113,31 +134,70 @@ case "${resolv_conf_passthrough:-NO}" in
[ -z "$newest" ] && exit 0
newconf="$(cat "$newest")$NL"
;;
+/dev/null|[Nn][Uu][Ll][Ll])
+ : ${resolv_conf_local_only:=NO}
+ if [ "$local_nameservers" = "127.* 0.0.0.0 255.255.255.255 ::1" ]; then
+ local_nameservers=
+ fi
+ # Need to overwrite our variables.
+ eval "$(@SBINDIR@/resolvconf -V)"
+ ;;
+
+*)
+ [ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)"
+ ;;
+esac
+case "${resolv_conf_passthrough:-NO}" in
+[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) ;;
*)
- [ -z "$RESOLVCONF" ] && eval "$(@PREFIX@/sbin/resolvconf -v)"
- newsearch="$(uniqify $search_domains $SEARCH $search_domains_append)"
+ : ${domain:=$DOMAIN}
+ newsearch="$(uniqify $prepend_search $SEARCH $append_search)"
NS="$LOCALNAMESERVERS $NAMESERVERS"
- newns="$(uniqify $name_servers $NS $name_servers_append)"
+ newns=
+ gotlocal=false
+ for n in $(uniqify $prepend_nameservers $NS $append_nameservers); do
+ add=true
+ islocal=false
+ for l in $local_nameservers; do
+ case "$n" in
+ $l) islocal=true; gotlocal=true; break;;
+ esac
+ done
+ if ! $islocal; then
+ case "${resolv_conf_local_only:-YES}" in
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+ $gotlocal && add=false;;
+ esac
+ fi
+ $add && newns="$newns $n"
+ done
# Hold our new resolv.conf in a variable to save on temporary files
- newconf="# Generated by resolvconf$NL"
+ newconf="$signature$NL"
if [ -n "$resolv_conf_head" ]; then
newconf="$newconf$resolv_conf_head$NL"
fi
- [ -n "$newsearch" ] && newconf="${newconf}search $newsearch$NL"
+
+ [ -n "$domain" ] && newconf="${newconf}domain $domain$NL"
+ if [ -n "$newsearch" -a "$newsearch" != "$domain" ]; then
+ newconf="${newconf}search $newsearch$NL"
+ fi
for n in $newns; do
newconf="${newconf}nameserver $n$NL"
done
- # Now get any configured options
- opts="$resolv_conf_options${resolv_conf_options:+ }"
- opts="$opts$($list_resolv | key_get_value "options ")"
- if [ -n "$opts" ]; then
- newconf="${newconf}options"
- for opt in $(uniqify $opts); do
- newconf="${newconf} $opt"
- done
- newconf="$newconf$NL"
+ # Now add anything we don't care about such as sortlist and options
+ stuff="$($list_resolv | keys_remove nameserver domain search)"
+ if [ -n "$stuff" ]; then
+ newconf="$newconf$stuff$NL"
+ fi
+
+ # Append any user defined ones
+ if [ -n "$resolv_conf_options" ]; then
+ newconf="${newconf}options $resolv_conf_options$NL"
+ fi
+ if [ -n "$resolv_conf_sortlist" ]; then
+ newconf="${newconf}sortlist $resolv_conf_sortlist$NL"
fi
if [ -n "$resolv_conf_tail" ]; then
@@ -151,6 +211,22 @@ if [ -e "$resolv_conf" ]; then
[ "$(cat "$resolv_conf")" = "$(printf %s "$newconf")" ] && exit 0
fi
+# Change is good.
+# If the old file does not have our signature, back it up.
+# If the new file just has our signature, restore the backup.
+if $backup; then
+ if [ "$newconf" = "$signature$NL" ]; then
+ if [ -e "$resolv_conf.bak" ]; then
+ newconf="$(cat "$resolv_conf.bak")"
+ fi
+ elif [ -e "$resolv_conf" ]; then
+ read line <"$resolv_conf"
+ if [ "$line" != "$signature" ]; then
+ cp "$resolv_conf" "$resolv_conf.bak"
+ fi
+ fi
+fi
+
# Create our resolv.conf now
(umask 022; echo "$newconf" >"$resolv_conf")
eval $libc_restart
@@ -162,7 +238,7 @@ for script in "$LIBEXECDIR"/libc.d/*; do
if [ -x "$script" ]; then
"$script" "$@"
else
- (. "$script" "$@")
+ (. "$script")
fi
retval=$(($retval + $?))
fi
diff --git a/contrib/openresolv/named.in b/contrib/openresolv/named.in
index 47b10e0..43ceabb 100644
--- a/contrib/openresolv/named.in
+++ b/contrib/openresolv/named.in
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (c) 2007-2009 Roy Marples
+# Copyright (c) 2007-2012 Roy Marples
# All rights reserved
# named subscriber for resolvconf
@@ -29,7 +29,7 @@
[ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
. "@SYSCONFDIR@/resolvconf.conf" || exit 1
[ -z "$named_zones" -a -z "$named_options" ] && exit 0
-[ -z "$RESOLVCONF" ] && eval "$(@PREFIX@/sbin/resolvconf -v)"
+[ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)"
NL="
"
@@ -40,6 +40,9 @@ then
if [ -x "@RCDIR@"/bind9 ]; then
# Debian and derivatives
named_service=bind9
+ elif [ -x "@RCDIR@"/rc.bind ]; then
+ # Slackware
+ named_service=rc.bind
fi
fi
: ${named_service:=named}
@@ -71,6 +74,13 @@ for d in $DOMAINS; do
newzones="$newzones };$NL};$NL"
done
+# Try to ensure that config dirs exist
+if type config_mkdirs >/dev/null 2>&1; then
+ config_mkdirs "$named_options" "$named_zones"
+else
+ @SBINDIR@/resolvconf -D "$named_options" "$named_zones"
+fi
+
# No point in changing files or reloading bind if the end result has not
# changed
changed=false
diff --git a/contrib/openresolv/pdns_recursor.in b/contrib/openresolv/pdns_recursor.in
new file mode 100644
index 0000000..2919e7d
--- /dev/null
+++ b/contrib/openresolv/pdns_recursor.in
@@ -0,0 +1,72 @@
+#!/bin/sh
+# Copyright (c) 2009-2011 Roy Marples
+# All rights reserved
+
+# PowerDNS Recursor subscriber for resolvconf
+
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this 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 HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED 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
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+[ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
+. "@SYSCONFDIR@/resolvconf.conf" || exit 1
+[ -z "$pdns_zones" ] && exit 0
+[ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)"
+NL="
+"
+
+: ${pdns_service:=pdns_recursor}
+: ${pdns_restart:=@RESTARTCMD ${pdns_service}@}
+
+newzones=
+
+# pds_recursor does not present support global forward servers, which
+# does limit it's usefulness somewhat.
+# If it did, the below code can be enabled, or something like it.
+#for n in $NAMESERVERS; do
+# newzones="$newzones${newzones:+,}$n"
+#done
+#[ -n "$newzones" ] && newzones=".=$newzones$NL"
+
+for d in $DOMAINS; do
+ newns=
+ ns="${d#*:}"
+ while [ -n "$ns" ]; do
+ newns="$newns${newns:+,}${ns%%,*}"
+ [ "$ns" = "${ns#*,}" ] && break
+ ns="${ns#*,}"
+ done
+ [ -n "$newns" ] && newzones="$newzones${d%%:*}=$newns$NL"
+done
+
+# Try to ensure that config dirs exist
+if type config_mkdirs >/dev/null 2>&1; then
+ config_mkdirs "$pdnsd_zones"
+else
+ @SBINDIR@/resolvconf -D "$pdnsd_zones"
+fi
+
+if [ ! -f "$pdns_zones" ] || \
+ [ "$(cat "$pdns_zones")" != "$(printf %s "$newzones")" ]
+then
+ printf %s "$newzones" >"$pdns_zones"
+ eval $pdns_restart
+fi
diff --git a/contrib/openresolv/pdnsd.in b/contrib/openresolv/pdnsd.in
index 61dc5e1..59a4755 100644
--- a/contrib/openresolv/pdnsd.in
+++ b/contrib/openresolv/pdnsd.in
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (c) 2010 Roy Marples
+# Copyright (c) 2010-2013 Roy Marples
# All rights reserved
# pdnsd subscriber for resolvconf
@@ -29,7 +29,9 @@
[ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
. "@SYSCONFDIR@/resolvconf.conf" || exit 1
[ -z "$pdnsd_conf" -a -z "$pdnsd_resolv" ] && exit 0
-[ -z "$RESOLVCONF" ] && eval "$(@PREFIX@/sbin/resolvconf -v)"
+[ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)"
+NL="
+"
: ${pdnsd_restart:=pdnsd-ctl config $pdnsd_conf}
signature="# Generated by resolvconf"
@@ -46,7 +48,7 @@ remove_markers()
sed "/^$m1/,/^$m2/d" $@
else
for x; do
- while read line; do
+ while read -r line; do
case "$line" in
"$m1"*) in_marker=1;;
"$m2"*) in_marker=0;;
@@ -80,24 +82,32 @@ change_file()
return 0
}
-newresolv="# Generated by resolvconf\n"
+newresolv="# Generated by resolvconf$NL"
changed=false
+# Try to ensure that config dirs exist
+if type config_mkdirs >/dev/null 2>&1; then
+ config_mkdirs "$pdnsd_resolv" "$pdnsd_conf"
+else
+ @SBINDIR@/resolvconf -D "$pdnsd_resolv" "$pdnsd_conf"
+fi
+
if [ -n "$pdnsd_resolv" ]; then
for n in $NAMESERVERS; do
- newresolv="${newresolv}nameserver $n\n"
+ newresolv="${newresolv}nameserver $n$NL"
done
fi
-if [ -n "$pdnsd_conf" ]; then
+# Only modify the configuration if it exists and we can write to it
+if [ -w "$pdnsd_conf" ]; then
cf="$pdnsd_conf.new"
newconf=
if [ -z "$pdnsd_resolv" ]; then
- newconf="${newconf}server {\n"
- newconf="${newconf}\tlabel=resolvconf;\n"
+ newconf="${newconf}server {$NL"
+ newconf="${newconf} label=resolvconf;$NL"
if [ -n "$NAMESERVERS" ]; then
- newconf="${newconf}\tip="
+ newconf="${newconf} ip="
first=true
for n in $NAMESERVERS; do
if $first; then
@@ -107,16 +117,16 @@ if [ -n "$pdnsd_conf" ]; then
fi
newconf="$newconf$n"
done
- newconf="${newconf};\n"
+ newconf="${newconf};$NL"
fi
- newconf="${newconf}}\n"
+ newconf="${newconf}}$NL"
fi
for d in $DOMAINS; do
- newconf="${newconf}server {\n"
- newconf="${newconf}\tinclude=.${d%%:*}.;\n"
- newconf="${newconf}\tpolicy=excluded;\n"
- newconf="${newconf}\tip="
+ newconf="${newconf}server {$NL"
+ newconf="${newconf} include=.${d%%:*}.;$NL"
+ newconf="${newconf} policy=excluded;$NL"
+ newconf="${newconf} ip="
ns="${d#*:}"
while [ -n "$ns" ]; do
newconf="${newconf}${ns%%,*}"
@@ -124,7 +134,7 @@ if [ -n "$pdnsd_conf" ]; then
ns="${ns#*,}"
newconf="${newconf},"
done
- newconf="${newconf};\n}\n"
+ newconf="${newconf};$NL}$NL"
done
rm -f "$cf"
@@ -136,7 +146,7 @@ if [ -n "$pdnsd_conf" ]; then
fi
if change_file "$pdnsd_conf" "$cf"; then
changed=true
- fi
+ fi
fi
if [ -n "$pdnsd_resolv" ]; then
diff --git a/contrib/openresolv/resolvconf.8.in b/contrib/openresolv/resolvconf.8.in
index 4e6f59a..10dcf5d 100644
--- a/contrib/openresolv/resolvconf.8.in
+++ b/contrib/openresolv/resolvconf.8.in
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2007-2009 Roy Marples
+.\" Copyright (c) 2007-2015 Roy Marples
.\" All rights reserved
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -22,8 +22,8 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd December 3, 2009
-.Dt RESOLVCONF 8 SMM
+.Dd April 27, 2014
+.Dt RESOLVCONF 8
.Os
.Sh NAME
.Nm resolvconf
@@ -34,11 +34,14 @@
.Nm
.Op Fl m Ar metric
.Op Fl p
-.Fl a Ar interface No < Ns Pa file
+.Op Fl x
+.Fl a Ar interface Ns Op Ar .protocol
+.No < Ns Pa file
.Nm
.Op Fl f
-.Fl d Ar interface
+.Fl d Ar interface Ns Op Ar .protocol
.Nm
+.Op Fl x
.Fl il Ar pattern
.Nm
.Fl u
@@ -63,7 +66,7 @@ file to
via
.Xr stdin 3
with the argument
-.Fl a Ar interface
+.Fl a Ar interface Ns Op Ar .protocol
instead of the filesystem.
.Nm
then updates
@@ -78,6 +81,20 @@ then
will supply files that the resolver should be configured to include.
.Pp
.Nm
+assumes it has a job to do.
+In some situations
+.Nm
+needs to act as a deterrent to writing to
+.Pa /etc/resolv.conf .
+Where this file cannot be made immutable or you just need to toggle this
+behaviour,
+.Nm
+can be disabled by adding
+.Sy resolvconf Ns = Ns NO
+to
+.Xr resolvconf.conf 5 .
+.Pp
+.Nm
can mark an interfaces
.Pa resolv.conf
as private.
@@ -91,13 +108,21 @@ for how to configure
.Nm
to use a local name server.
.Pp
+.Nm
+can mark an interfaces
+.Pa resolv.conf
+as exclusive.
+Only the latest exclusive interface is used for processing, otherwise all are.
+.Pp
When an interface goes down, it should then call
.Nm
with
-.Fl d Ar interface
+.Fl d Ar interface.*
arguments to delete the
.Pa resolv.conf
-file for the
+file(s) for all the
+.Ar protocols
+on the
.Ar interface .
.Pp
Here are some more options that
@@ -119,7 +144,7 @@ is used to add interfaces.
Ignore non existant interfaces.
Only really useful for deleting interfaces.
.It Fl i Ar pattern
-List the interfaces, optionally matching
+List the interfaces and protocols, optionally matching
.Ar pattern ,
we have
.Pa resolv.conf
@@ -130,7 +155,8 @@ List the
files we have.
If
.Ar pattern
-is specified then we list the files for the interfaces that match it.
+is specified then we list the files for the interfaces and protocols
+that match it.
.It Fl m Ar metric
Set the metric of the interface when adding it, default of 0.
Lower metrics take precedence.
@@ -142,18 +168,28 @@ as private.
.It Fl u
Force
.Nm
-to update all it's subscribers.
+to update all its subscribers.
.Nm
does not update the subscribers when adding a resolv.conf that matches
what it already has for that interface.
+.It Fl x
+Mark the interface
+.Pa resolv.conf
+as exclusive when adding, otherwise only use the latest exclusive interface.
.El
.Pp
.Nm
-also has some options designed to be used by it's subscribers:-
+also has some options designed to be used by its subscribers:-
.Bl -tag -width indent
.It Fl v
Echo variables DOMAINS, SEARCH and NAMESERVERS so that the subscriber can
configure the resolver easily.
+.It Fl V
+Same as
+.Fl v
+except that only the information configured in
+.Xr resolvconf.conf 5
+is set.
.El
.Sh INTERFACE ORDERING
For
@@ -170,6 +206,29 @@ the operating systems lexical order.
See
.Xr resolvconf.conf 5
for details on these lists.
+.Sh PROTOCOLS
+Here are some suggested protocol tags to use for each
+.Pa resolv.conf
+file registered on an
+.Ar interface Ns No :-
+.Bl -tag -width indent
+.It dhcp
+Dynamic Host Configuration Protocol.
+Initial versions of
+.Nm
+did not recommend a
+.Ar protocol
+tag be appended to the
+.Ar interface
+name.
+When the protocol is absent, it is assumed to be the DHCP protocol.
+.It ppp
+Point-to-Point Protocol.
+.It ra
+IPv6 Router Advertisement.
+.It dhcp6
+Dynamic Host Configuration Protocol, version 6.
+.El
.Sh IMPLEMENTATION NOTES
If a subscriber has the executable bit then it is executed otherwise it is
assumed to be a shell script and sourced into the current environment in a
@@ -197,9 +256,15 @@ for the metric.
Marks the interface
.Pa resolv.conf
as private.
+.It Va IF_EXCLUSIVE
+Marks the interface
+.Pa resolv.conf
+as exclusive.
.El
.Sh FILES
.Bl -ohang
+.It Pa /etc/resolv.conf.bak
+Backup file of the original resolv.conf.
.It Pa @SYSCONFDIR@/resolvconf.conf
Configuration file for
.Nm .
@@ -218,7 +283,17 @@ This implementation of
.Nm
is called openresolv and is fully command line compatible with Debian's
resolvconf, as written by Thomas Hood.
+.Sh SEE ALSO
+.Xr resolv.conf 5 ,
+.Xr resolvconf.conf 5 ,
+.Xr resolver 3 ,
+.Xr stdin 3
+.Sh AUTHORS
+.An Roy Marples Aq Mt roy@marples.name
.Sh BUGS
+Please report them to
+.Lk http://roy.marples.name/projects/openresolv
+.Pp
.Nm
does not validate any of the files given to it.
.Pp
@@ -229,12 +304,3 @@ will generate.
You should consult
.Xr resolvconf.conf 5
for instructions on how to configure your resolver.
-.Sh SEE ALSO
-.Xr resolv.conf 5 ,
-.Xr resolvconf.conf 5 ,
-.Xr resolver 3 ,
-.Xr stdin 3
-.Sh AUTHORS
-.An Roy Marples Aq roy@marples.name
-.Sh BUGS
-Please report them to http://roy.marples.name/projects/openresolv
diff --git a/contrib/openresolv/resolvconf.conf.5.in b/contrib/openresolv/resolvconf.conf.5.in
index 454aac5..d4f6543 100644
--- a/contrib/openresolv/resolvconf.conf.5.in
+++ b/contrib/openresolv/resolvconf.conf.5.in
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2009-2010 Roy Marples
+.\" Copyright (c) 2009-2015 Roy Marples
.\" All rights reserved
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -22,8 +22,8 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd October 29, 2010
-.Dt RESOLVCONF.CONF 5 SMM
+.Dd March 20, 2015
+.Dt RESOLVCONF.CONF 5
.Os
.Sh NAME
.Nm resolvconf.conf
@@ -42,12 +42,22 @@ must contain valid shell commands.
Listed below are the standard
.Nm
variables that may be set.
+If the values contain white space for special shell characters,
+ensure they are quoted and escaped correctly.
.Pp
After updating this file, you may wish to run
.Nm resolvconf -u
to apply the new configuration.
+.Pp
+When a dynamically generated list is appended or prepended to, the whole
+is made unique where left-most wins.
.Sh RESOLVCONF OPTIONS
.Bl -tag -width indent
+.It Sy resolvconf
+Set to NO to disable
+.Nm resolvconf
+from running any subscribers.
+Defaults to YES.
.It Sy interface_order
These interfaces will always be processed first.
If unset, defaults to the following:-
@@ -56,16 +66,27 @@ If unset, defaults to the following:-
These interfaces will be processed next, unless they have a metric.
If unset, defaults to the following:-
.D1 tap[0-9]* tun[0-9]* vpn vpn[0-9]* ppp[0-9]* ippp[0-9]*
+.It Sy local_nameservers
+If unset, defaults to the following:-
+.D1 127.* 0.0.0.0 255.255.255.255 ::1
.It Sy search_domains
Prepend search domains to the dynamically generated list.
.It Sy search_domains_append
Append search domains to the dynamically generated list.
+.It Sy domain_blacklist
+A list of domains to be removed from consideration.
+To remove a domain, you can use foo.*
+To remove a sub domain, you can use *.bar
.It Sy name_servers
Prepend name servers to the dynamically generated list.
You should set this to 127.0.0.1 if you use a local name server other than
libc.
.It Sy name_servers_append
Append name servers to the dynamically generated list.
+.It Sy name_server_blacklist
+A list of name servers to be removed from consideration.
+The default is 0.0.0.0 as some faulty routers send it via DHCP.
+To remove a block, you can use 192.168.*
.It Sy private_interfaces
These interfaces name servers will only be queried for the domains listed
in their resolv.conf.
@@ -73,6 +94,34 @@ Useful for VPN domains.
This is equivalent to the
.Nm resolvconf -p
option.
+.It Sy replace
+Is a space separated list of replacement keywords. The syntax is this:
+.Va $keyword Ns / Ns Va $match Ns / Ns Va $replacement
+.Pp
+Example, given this resolv.conf:
+.D1 domain foo.org
+.D1 search foo.org dead.beef
+.D1 nameserver 1.2.3.4
+.D1 nameserver 2.3.4.5
+and this configuaration:
+.D1 replace="search/foo*/bar.com nameserver/1.2.3.4/5.6.7.8 nameserver/2.3.4.5/"
+you would get this resolv.conf instead:
+.D1 domain foo.org
+.D1 search bar.com
+.D1 nameserver 5.6.7.8
+.It Sy replace_sub
+Works the same way as
+.Sy replace
+except it works on each space separated value rather than the whole line,
+so it's useful for the replacing a single domain within the search directive.
+Using the same example resolv.conf and changing
+.Sy replace
+to
+.Sy replace_sub ,
+you would get this resolv.conf instead:
+.D1 domain foo.org
+.D1 search bar.com dead.beef
+.D1 nameserver 5.6.7.8
.It Sy state_dir
Override the default state directory of
.Pa @VARDIR@ .
@@ -96,6 +145,32 @@ A list of libc resolver options, as specified in
When set to YES the latest resolv.conf is written to
.Sy resolv_conf
without any alteration.
+When set to /dev/null or NULL,
+.Sy resolv_conf_local_only
+is defaulted to NO,
+.Sy local_nameservers
+is unset unless overriden and only the information set in
+.Nm
+is written to
+.Sy resolv_conf .
+.It Sy resolv_conf_sortlist
+A libc resolver sortlist, as specified in
+.Xr resolv.conf 5 .
+.It Sy resolv_conf_local_only
+If a local name server is configured then the default is just to specify that
+and ignore all other entries as they will be configured for the local
+name server.
+Set this to NO to also list non-local nameservers.
+This will give you working DNS even if the local nameserver stops functioning
+at the expense of duplicated server queries.
+.It Sy append_nameservers
+Append name servers to the dynamically generated list.
+.It Sy prepend_nameservers
+Prepend name servers to the dynamically generated list.
+.It Sy append_search
+Append search domains to the dynamically generated list.
+.It Sy prepend_search
+Prepend search domains to the dynamically generated list.
.El
.Sh SUBSCRIBER OPTIONS
openresolv ships with subscribers for the name servers
@@ -106,11 +181,15 @@ and
.Xr unbound 8 .
Each subscriber can create configuration files which should be included in
in the subscribers main configuration file.
+.Pp
+To disable a subscriber, simply set it's name to NO.
+For example, to disable the libc subscriber you would set:
+.D1 libc=NO
.Bl -tag -width indent
.It Sy dnsmasq_conf
-This file tells dnsmasq which nameservers to use for specific domains.
+This file tells dnsmasq which name servers to use for specific domains.
.It Sy dnsmasq_resolv
-This file tells dnsmasq which nameservers to use for global lookups.
+This file tells dnsmasq which name servers to use for global lookups.
.Pp
Example resolvconf.conf for dnsmasq:
.D1 name_servers=127.0.0.1
@@ -119,14 +198,17 @@ Example resolvconf.conf for dnsmasq:
.Pp
Example dnsmasq.conf:
.D1 listen-address=127.0.0.1
+.D1 # If dnsmasq is compiled for DBus then we can take
+.D1 # advantage of not having to restart dnsmasq.
+.D1 enable-dbus
.D1 conf-file=/etc/dnsmasq-conf.conf
.D1 resolv-file=/etc/dnsmasq-resolv.conf
.It Sy named_options
Include this file in the named options block.
-This file tells named which nameservers to use for global lookups.
+This file tells named which name servers to use for global lookups.
.It Sy named_zones
Include this file in the named global scope, after the options block.
-This file tells named which nameservers to use for specific domains.
+This file tells named which name servers to use for specific domains.
.Pp
Example resolvconf.conf for named:
.D1 name_servers=127.0.0.1
@@ -147,7 +229,7 @@ setup to read
.Pa pdnsd_resolv
as documented below.
.It Sy pdnsd_resolv
-This file tells pdnsd about global nameservers.
+This file tells pdnsd about global name servers.
If this variable is not set then it's written to
.Pa pdnsd_conf .
.Pp
@@ -168,7 +250,9 @@ Example pdnsd.conf:
.D1 # file="/etc/pdnsd-resolv.conf";
.D1 }
.It Sy unbound_conf
-This file tells unbound about specific and global nameservers.
+This file tells unbound about specific and global name servers.
+.It Sy unbound_insecure
+When set to YES, unbound marks the domains as insecure, thus ignoring DNSSEC.
.Pp
Example resolvconf.conf for unbound:
.D1 name_servers=127.0.0.1
@@ -177,11 +261,53 @@ Example resolvconf.conf for unbound:
Example unbound.conf:
.D1 include: /etc/unbound-resolvconf.conf
.El
+.Sh SUBSCRIBER INTEGRATION
+Not all distributions store the files the subscribers need in the same
+locations.
+For example, named service scripts have been called named, bind and rc.bind
+and they could be located in a directory called /etc/rc.d, /etc/init.d or
+similar.
+Each subscriber attempts to automatically configure itself, but not every
+distribution has been catered for.
+Also, users could equally want to use a different version from the one
+installed by default, such as bind8 and bind9.
+To accomodate this, the subscribers have these files in configurable
+variables, documented below.
+.Pp
+.Bl -tag -width indent
+.It Sy dnsmasq_service
+Location of the dnsmasq service.
+.It Sy dnsmasq_restart
+Command to restart the dnsmasq service.
+.It Sy dnsmasq_pid
+Location of the dnsmasq pidfile.
+.It Sy libc_service
+Location of the libc service.
+.It Sy libc_restart
+Command to restart the libc service.
+.It Sy named_service
+Location of the named service.
+.It Sy named_restart
+Command to restart the named service.
+.It Sy pdnsd_restart
+Command to restart the pdnsd service.
+.It Sy unbound_service
+Location of the unbound service.
+.It Sy unbound_restart
+Command to restart the unbound service.
+.It Sy unbound_pid
+Location of the unbound pidfile.
+.El
.Sh SEE ALSO
-.Xr resolv.conf 5
+.Xr resolv.conf 5 ,
+.Xr resolvconf 8
and
-.Xr resolvconf 8 .
+.Xr sh 1 .
.Sh AUTHORS
-.An Roy Marples Aq roy@marples.name
+.An Roy Marples Aq Mt roy@marples.name
.Sh BUGS
-Please report them to http://roy.marples.name/projects/openresolv
+Each distribution is a special snowflake and likes to name the same thing
+differently, namely the named service script.
+.Pp
+Please report them to
+.Lk http://roy.marples.name/projects/openresolv
diff --git a/contrib/openresolv/resolvconf.in b/contrib/openresolv/resolvconf.in
index 8a608d3..3b2b0f5 100644
--- a/contrib/openresolv/resolvconf.in
+++ b/contrib/openresolv/resolvconf.in
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (c) 2007-2009 Roy Marples
+# Copyright (c) 2007-2015 Roy Marples
# All rights reserved
# Redistribution and use in source and binary forms, with or without
@@ -28,6 +28,17 @@ RESOLVCONF="$0"
SYSCONFDIR=@SYSCONFDIR@
LIBEXECDIR=@LIBEXECDIR@
VARDIR=@VARDIR@
+
+# Disregard dhcpcd setting
+unset interface_order state_dir
+
+# If you change this, change the test in VFLAG and libc.in as well
+local_nameservers="127.* 0.0.0.0 255.255.255.255 ::1"
+
+dynamic_order="tap[0-9]* tun[0-9]* vpn vpn[0-9]* ppp[0-9]* ippp[0-9]*"
+interface_order="lo lo[0-9]*"
+name_server_blacklist="0.0.0.0"
+
# Support original resolvconf configuration layout
# as well as the openresolv config file
if [ -f "$SYSCONFDIR"/resolvconf.conf ]; then
@@ -39,12 +50,17 @@ elif [ -d "$SYSCONFDIR/resolvconf" ]; then
interface_order="$(cat "$SYSCONFDIR"/interface-order)"
fi
fi
+TMPDIR="$VARDIR/tmp"
IFACEDIR="$VARDIR/interfaces"
METRICDIR="$VARDIR/metrics"
PRIVATEDIR="$VARDIR/private"
+EXCLUSIVEDIR="$VARDIR/exclusive"
+LOCKDIR="$VARDIR/lock"
-: ${dynamic_order:=tap[0-9]* tun[0-9]* vpn vpn[0-9]* ppp[0-9]* ippp[0-9]*}
-: ${interface_order:=lo lo[0-9]*}
+warn()
+{
+ echo "$*" >&2
+}
error_exit()
{
@@ -64,6 +80,7 @@ usage()
(DNS supplied via stdin in resolv.conf format)
-m metric Give the added DNS information a metric
-p Mark the interface as private
+ -x Mark the interface as exclusive
-d \$INTERFACE Delete DNS information from the specified interface
-f Ignore non existant interfaces
-I Init the state dir
@@ -84,16 +101,23 @@ usage()
echo_resolv()
{
- local line=
- [ -n "$1" -a -e "$IFACEDIR/$1" ] || return 1
+ local line= OIFS="$IFS"
+
+ [ -n "$1" -a -f "$IFACEDIR/$1" ] || return 1
echo "# resolv.conf from $1"
# Our variable maker works of the fact each resolv.conf per interface
# is separated by blank lines.
# So we remove them when echoing them.
- while read line; do
- [ -n "$line" ] && echo "$line"
+ while read -r line; do
+ IFS="$OIFS"
+ if [ -n "$line" ]; then
+ # We need to set IFS here to preserve any whitespace
+ IFS=''
+ printf "%s\n" "$line"
+ fi
done < "$IFACEDIR/$1"
echo
+ IFS="$OIFS"
}
# Parse resolv.conf's and make variables
@@ -101,22 +125,11 @@ echo_resolv()
parse_resolv()
{
local line= ns= ds= search= d= n= newns=
- local new=true iface= private=false p=
+ local new=true iface= private=false p= domain= l= islocal=
- echo "DOMAINS="
- echo "SEARCH=\"$search_domains\""
- # let our subscribers know about global nameservers
- for n in $name_servers; do
- case "$n" in
- 127.*|0.0.0.0|255.255.255.255|::1) :;;
- *) newns="$newns${newns:+ }$n";;
- esac
- done
- echo "NAMESERVERS=\"$newns\""
- echo "LOCALNAMESERVERS="
newns=
- while read line; do
+ while read -r line; do
case "$line" in
"# resolv.conf from "*)
if ${new}; then
@@ -129,24 +142,34 @@ parse_resolv()
cd "$IFACEDIR"
private=false
for p in $private_interfaces; do
- if [ "$p" = "$iface" ]; then
- private=true
- break
- fi
+ case "$iface" in
+ "$p"|"$p":*) private=true; break;;
+ esac
done
fi
fi
;;
"nameserver "*)
- case "${line#* }" in
- 127.*|0.0.0.0|255.255.255.255|::1)
- echo "LOCALNAMESERVERS=\"\$LOCALNAMESERVERS ${line#* }\""
- continue
- ;;
- esac
- ns="$ns${line#* } "
+ islocal=false
+ for l in $local_nameservers; do
+ case "${line#* }" in
+ $l)
+ islocal=true
+ echo "LOCALNAMESERVERS=\"\$LOCALNAMESERVERS ${line#* }\""
+ break
+ ;;
+ esac
+ done
+ $islocal || ns="$ns${line#* } "
;;
- "domain "*|"search "*)
+ "domain "*)
+ if [ -z "$domain" ]; then
+ domain="${line#* }"
+ echo "DOMAIN=\"$domain\""
+ fi
+ search="${line#* }"
+ ;;
+ "search "*)
search="${line#* }"
;;
*)
@@ -187,70 +210,243 @@ uniqify()
echo "${result# *}"
}
+dirname()
+{
+ local dir= OIFS="$IFS"
+ local IFS=/
+ set -- $@
+ IFS="$OIFS"
+ if [ -n "$1" ]; then
+ printf %s .
+ else
+ shift
+ fi
+ while [ -n "$2" ]; do
+ printf "/%s" "$1"
+ shift
+ done
+ printf "\n"
+}
+
+config_mkdirs()
+{
+ local e=0 f d
+ for f; do
+ [ -n "$f" ] || continue
+ d="$(dirname "$f")"
+ if [ ! -d "$d" ]; then
+ if type install >/dev/null 2>&1; then
+ install -d "$d" || e=$?
+ else
+ mkdir "$d" || e=$?
+ fi
+ fi
+ done
+ return $e
+}
+
list_resolv()
{
[ -d "$IFACEDIR" ] || return 0
- local report=false list= retval=0 cmd="$1"
+ local report=false list= retval=0 cmd="$1" excl=
shift
+ case "$IF_EXCLUSIVE" in
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+ if [ -d "$EXCLUSIVEDIR" ]; then
+ cd "$EXCLUSIVEDIR"
+ for i in *; do
+ if [ -f "$i" ]; then
+ list="${i#* }"
+ break
+ fi
+ done
+ fi
+ excl=true
+ ;;
+ *)
+ excl=false
+ ;;
+ esac
+
# If we have an interface ordering list, then use that.
# It works by just using pathname expansion in the interface directory.
if [ -n "$1" ]; then
- list="$@"
+ list="$*"
$force || report=true
- else
+ elif ! $excl; then
cd "$IFACEDIR"
for i in $interface_order; do
- [ -e "$i" ] && list="$list $i"
+ [ -f "$i" ] && list="$list $i"
+ for ii in "$i":* "$i".*; do
+ [ -f "$ii" ] && list="$list $ii"
+ done
done
for i in $dynamic_order; do
if [ -e "$i" -a ! -e "$METRICDIR/"*" $i" ]; then
list="$list $i"
fi
+ for ii in "$i":* "$i".*; do
+ if [ -f "$ii" -a ! -e "$METRICDIR/"*" $ii" ]; then
+ list="$list $ii"
+ fi
+ done
done
if [ -d "$METRICDIR" ]; then
cd "$METRICDIR"
for i in *; do
- list="$list ${i#* }"
+ [ -f "$i" ] && list="$list ${i#* }"
done
fi
list="$list *"
fi
cd "$IFACEDIR"
+ retval=1
for i in $(uniqify $list); do
# Only list interfaces which we really have
- if ! [ -e "$i" ]; then
+ if ! [ -f "$i" ]; then
if $report; then
echo "No resolv.conf for interface $i" >&2
- retval=$(($retval + 1))
+ retval=2
fi
continue
fi
if [ "$cmd" = i -o "$cmd" = "-i" ]; then
- printf "$i "
+ printf %s "$i "
else
echo_resolv "$i"
fi
+ [ $? = 0 -a "$retval" = 1 ] && retval=0
done
[ "$cmd" = i -o "$cmd" = "-i" ] && echo
return $retval
}
+list_remove() {
+ local list= e= l= result= found= retval=0
+
+ [ -z "$2" ] && return 0
+ eval list=\"\$$1\"
+ shift
+
+ set -f
+ for e; do
+ found=false
+ for l in $list; do
+ case "$e" in
+ $l) found=true;;
+ esac
+ $found && break
+ done
+ if $found; then
+ retval=$(($retval + 1))
+ else
+ result="$result $e"
+ fi
+ done
+ set +f
+ echo "${result# *}"
+ return $retval
+}
+
+echo_prepend()
+{
+ echo "# Generated by resolvconf"
+ if [ -n "$search_domains" ]; then
+ echo "search $search_domains"
+ fi
+ for n in $name_servers; do
+ echo "nameserver $n"
+ done
+ echo
+}
+
+echo_append()
+{
+ echo "# Generated by resolvconf"
+ if [ -n "$search_domains_append" ]; then
+ echo "search $search_domains_append"
+ fi
+ for n in $name_servers_append; do
+ echo "nameserver $n"
+ done
+ echo
+}
+
+replace()
+{
+ local r= k= f= v= val= sub=
+
+ while read -r keyword value; do
+ for r in $replace; do
+ k="${r%%/*}"
+ r="${r#*/}"
+ f="${r%%/*}"
+ r="${r#*/}"
+ v="${r%%/*}"
+ case "$keyword" in
+ $k)
+ case "$value" in
+ $f) value="$v";;
+ esac
+ ;;
+ esac
+ done
+ val=
+ for sub in $value; do
+ for r in $replace_sub; do
+ k="${r%%/*}"
+ r="${r#*/}"
+ f="${r%%/*}"
+ r="${r#*/}"
+ v="${r%%/*}"
+ case "$keyword" in
+ $k)
+ case "$sub" in
+ $f) sub="$v";;
+ esac
+ ;;
+ esac
+ done
+ val="$val${val:+ }$sub"
+ done
+ printf "%s %s\n" "$keyword" "$val"
+ done
+}
+
make_vars()
{
- eval "$(list_resolv -l "$@" | parse_resolv)"
+ local newdomains= d= dn= newns= ns=
+
+ # Clear variables
+ DOMAIN=
+ DOMAINS=
+ SEARCH=
+ NAMESERVERS=
+ LOCALNAMESERVERS=
+
+ if [ -n "$name_servers" -o -n "$search_domains" ]; then
+ eval "$(echo_prepend | parse_resolv)"
+ fi
+ if [ -z "$VFLAG" ]; then
+ IF_EXCLUSIVE=1
+ list_resolv -i "$@" >/dev/null || IF_EXCLUSIVE=0
+ eval "$(list_resolv -l "$@" | replace | parse_resolv)"
+ fi
+ if [ -n "$name_servers_append" -o -n "$search_domains_append" ]; then
+ eval "$(echo_append | parse_resolv)"
+ fi
# Ensure that we only list each domain once
- newdomains=
for d in $DOMAINS; do
dn="${d%%:*}"
+ list_remove domain_blacklist "$dn" >/dev/null || continue
case " $newdomains" in
*" ${dn}:"*) continue;;
esac
- newdomains="$newdomains${newdomains:+ }$dn:"
newns=
for nd in $DOMAINS; do
if [ "$dn" = "${nd%%:*}" ]; then
@@ -258,34 +454,56 @@ make_vars()
while [ -n "$ns" ]; do
case ",$newns," in
*,${ns%%,*},*) ;;
- *) newns="$newns${newns:+,}${ns%%,*}";;
+ *) list_remove name_server_blacklist \
+ "${ns%%,*}" >/dev/null \
+ && newns="$newns${newns:+,}${ns%%,*}";;
esac
[ "$ns" = "${ns#*,}" ] && break
ns="${ns#*,}"
done
fi
done
- newdomains="$newdomains$newns"
+ if [ -n "$newns" ]; then
+ newdomains="$newdomains${newdomains:+ }$dn:$newns"
+ fi
done
+ DOMAIN="$(list_remove domain_blacklist $DOMAIN)"
+ SEARCH="$(uniqify $SEARCH)"
+ SEARCH="$(list_remove domain_blacklist $SEARCH)"
+ NAMESERVERS="$(uniqify $NAMESERVERS)"
+ NAMESERVERS="$(list_remove name_server_blacklist $NAMESERVERS)"
+ LOCALNAMESERVERS="$(uniqify $LOCALNAMESERVERS)"
+ LOCALNAMESERVERS="$(list_remove name_server_blacklist $LOCALNAMESERVERS)"
+ echo "DOMAIN='$DOMAIN'"
+ echo "SEARCH='$SEARCH'"
+ echo "NAMESERVERS='$NAMESERVERS'"
+ echo "LOCALNAMESERVERS='$LOCALNAMESERVERS'"
echo "DOMAINS='$newdomains'"
- echo "SEARCH='$(uniqify $SEARCH)'"
- echo "NAMESERVERS='$(uniqify $NAMESERVERS)'"
- echo "LOCALNAMESERVERS='$(uniqify $LOCALNAMESERVERS)'"
}
force=false
-while getopts a:d:fhIilm:puv OPT; do
+VFLAG=
+while getopts a:Dd:fhIilm:puvVx OPT; do
case "$OPT" in
f) force=true;;
h) usage;;
m) IF_METRIC="$OPTARG";;
p) IF_PRIVATE=1;;
+ V)
+ VFLAG=1
+ if [ "$local_nameservers" = \
+ "127.* 0.0.0.0 255.255.255.255 ::1" ]
+ then
+ local_nameservers=
+ fi
+ ;;
+ x) IF_EXCLUSIVE=1;;
'?') ;;
*) cmd="$OPT"; iface="$OPTARG";;
esac
done
shift $(($OPTIND - 1))
-args="$iface${iface:+ }$@"
+args="$iface${iface:+ }$*"
# -I inits the state dir
if [ "$cmd" = I ]; then
@@ -295,6 +513,12 @@ if [ "$cmd" = I ]; then
exit $?
fi
+# -D ensures that the listed config file base dirs exist
+if [ "$cmd" = D ]; then
+ config_mkdirs "$@"
+ exit $?
+fi
+
# -l lists our resolv files, optionally for a specific interface
if [ "$cmd" = l -o "$cmd" = i ]; then
list_resolv "$cmd" "$args"
@@ -302,7 +526,7 @@ if [ "$cmd" = l -o "$cmd" = i ]; then
fi
# Not normally needed, but subscribers should be able to run independently
-if [ "$cmd" = v ]; then
+if [ "$cmd" = v -o -n "$VFLAG" ]; then
make_vars "$iface"
exit $?
fi
@@ -316,6 +540,7 @@ elif [ "$cmd" != u ]; then
[ -n "$cmd" -a "$cmd" != h ] && usage "Unknown option $cmd"
usage
fi
+
if [ "$cmd" = a ]; then
for x in '/' \\ ' ' '*'; do
case "$iface" in
@@ -331,78 +556,198 @@ if [ "$cmd" = a ]; then
[ "$cmd" = a -a -t 0 ] && error_exit "No file given via stdin"
fi
-if [ ! -d "$IFACEDIR" ]; then
- if [ ! -d "$VARDIR" ]; then
- if [ -L "$VARDIR" ]; then
- dir="$(readlink "$VARDIR")"
- # link maybe relative
- cd "${VARDIR%/*}"
- if ! mkdir -m 0755 -p "$dir"; then
- error_exit "Failed to create needed" \
- "directory $dir"
- fi
- else
- if ! mkdir -m 0755 -p "$VARDIR"; then
- error_exit "Failed to create needed" \
- "directory $VARDIR"
- fi
+if [ ! -d "$VARDIR" ]; then
+ if [ -L "$VARDIR" ]; then
+ dir="$(readlink "$VARDIR")"
+ # link maybe relative
+ cd "${VARDIR%/*}"
+ if ! mkdir -m 0755 -p "$dir"; then
+ error_exit "Failed to create needed" \
+ "directory $dir"
+ fi
+ else
+ if ! mkdir -m 0755 -p "$VARDIR"; then
+ error_exit "Failed to create needed" \
+ "directory $VARDIR"
fi
fi
+fi
+
+if [ ! -d "$IFACEDIR" ]; then
mkdir -m 0755 -p "$IFACEDIR" || \
error_exit "Failed to create needed directory $IFACEDIR"
-else
- # Delete any existing information about the interface
if [ "$cmd" = d ]; then
- cd "$IFACEDIR"
- for i in $args; do
- if [ "$cmd" = d -a ! -e "$i" ]; then
- $force && continue
- error_exit "No resolv.conf for" \
- "interface $i"
- fi
- rm -f "$i" "$METRICDIR/"*" $i" \
- "$PRIVATEDIR/$i" || exit $?
- done
+ # Provide the same error messages as below
+ if ! ${force}; then
+ cd "$IFACEDIR"
+ for i in $args; do
+ warn "No resolv.conf for interface $i"
+ done
+ fi
+ ${force}
+ exit $?
fi
fi
-if [ "$cmd" = a ]; then
+# An interface was added, changed, deleted or a general update was called.
+# Due to exclusivity we need to ensure that this is an atomic operation.
+# Our subscribers *may* need this as well if the init system is sub par.
+# As such we spinlock at this point as best we can.
+# We don't use flock(1) because it's not widely available and normally resides
+# in /usr which we do our very best to operate without.
+[ -w "$VARDIR" ] || error_exit "Cannot write to $LOCKDIR"
+: ${lock_timeout:=10}
+while true; do
+ if mkdir "$LOCKDIR" 2>/dev/null; then
+ trap 'rm -rf "$LOCKDIR";' EXIT
+ trap 'rm -rf "$LOCKDIR"; exit 1' INT QUIT ABRT SEGV ALRM TERM
+ echo $$ >"$LOCKDIR/pid"
+ break
+ fi
+ pid=$(cat "$LOCKDIR/pid")
+ if ! kill -0 "$pid"; then
+ warn "clearing stale lock pid $pid"
+ rm -rf "$LOCKDIR"
+ continue
+ fi
+ lock_timeout=$(($lock_timeout - 1))
+ if [ "$lock_timeout" -le 0 ]; then
+ error_exit "timed out waiting for lock from pid $pid"
+ fi
+ sleep 1
+done
+
+case "$cmd" in
+a)
# Read resolv.conf from stdin
resolv="$(cat)"
+ changed=false
+ changedfile=false
# If what we are given matches what we have, then do nothing
if [ -e "$IFACEDIR/$iface" ]; then
- if [ "$(echo "$resolv")" = \
+ if [ "$(echo "$resolv")" != \
"$(cat "$IFACEDIR/$iface")" ]
then
- exit 0
+ changed=true
+ changedfile=true
fi
- rm "$IFACEDIR/$iface"
+ else
+ changed=true
+ changedfile=true
fi
- echo "$resolv" >"$IFACEDIR/$iface" || exit $?
+
+ # Set metric and private before creating the interface resolv.conf file
+ # to ensure that it will have the correct flags
[ ! -d "$METRICDIR" ] && mkdir "$METRICDIR"
- rm -f "$METRICDIR/"*" $iface"
+ oldmetric="$METRICDIR/"*" $iface"
+ newmetric=
if [ -n "$IF_METRIC" ]; then
# Pad metric to 6 characters, so 5 is less than 10
while [ ${#IF_METRIC} -le 6 ]; do
IF_METRIC="0$IF_METRIC"
done
- echo " " >"$METRICDIR/$IF_METRIC $iface"
+ newmetric="$METRICDIR/$IF_METRIC $iface"
fi
+ rm -f "$METRICDIR/"*" $iface"
+ [ "$oldmetric" != "$newmetric" -a \
+ "$oldmetric" != "$METRICDIR/* $iface" ] &&
+ changed=true
+ [ -n "$newmetric" ] && echo " " >"$newmetric"
+
case "$IF_PRIVATE" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
if [ ! -d "$PRIVATEDIR" ]; then
[ -e "$PRIVATEDIR" ] && rm "$PRIVATEDIR"
mkdir "$PRIVATEDIR"
fi
+ [ -e "$PRIVATEDIR/$iface" ] || changed=true
[ -d "$PRIVATEDIR" ] && echo " " >"$PRIVATEDIR/$iface"
;;
*)
if [ -e "$PRIVATEDIR/$iface" ]; then
rm -f "$PRIVATEDIR/$iface"
+ changed=true
fi
;;
esac
-fi
+
+ oldexcl=
+ for x in "$EXCLUSIVEDIR/"*" $iface"; do
+ if [ -f "$x" ]; then
+ oldexcl="$x"
+ break
+ fi
+ done
+ case "$IF_EXCLUSIVE" in
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+ if [ ! -d "$EXCLUSIVEDIR" ]; then
+ [ -e "$EXCLUSIVEDIR" ] && rm "$EXCLUSIVEDIR"
+ mkdir "$EXCLUSIVEDIR"
+ fi
+ cd "$EXCLUSIVEDIR"
+ for x in *; do
+ [ -f "$x" ] && break
+ done
+ if [ "${x#* }" != "$iface" ]; then
+ if [ "$x" = "${x% *}" ]; then
+ x=10000000
+ else
+ x="${x% *}"
+ fi
+ if [ "$x" = "0000000" ]; then
+ warn "exclusive underflow"
+ else
+ x=$(($x - 1))
+ fi
+ if [ -d "$EXCLUSIVEDIR" ]; then
+ echo " " >"$EXCLUSIVEDIR/$x $iface"
+ fi
+ changed=true
+ fi
+ ;;
+ *)
+ if [ -f "$oldexcl" ]; then
+ rm -f "$oldexcl"
+ changed=true
+ fi
+ ;;
+ esac
+
+ if $changedfile; then
+ printf "%s\n" "$resolv" >"$IFACEDIR/$iface" || exit $?
+ elif ! $changed; then
+ exit 0
+ fi
+ unset changed changedfile oldmetric newmetric x oldexcl
+ ;;
+
+d)
+ # Delete any existing information about the interface
+ cd "$IFACEDIR"
+ changed=false
+ for i in $args; do
+ if [ -e "$i" ]; then
+ changed=true
+ elif ! ${force}; then
+ warn "No resolv.conf for interface $i"
+ fi
+ rm -f "$i" "$METRICDIR/"*" $i" \
+ "$PRIVATEDIR/$i" \
+ "$EXCLUSIVEDIR/"*" $i" || exit $?
+ done
+ if ! ${changed}; then
+ # Set the return code based on the forced flag
+ ${force}
+ exit $?
+ fi
+ unset changed i
+ ;;
+esac
+
+case "${resolvconf:-YES}" in
+[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) ;;
+*) exit 0;;
+esac
eval "$(make_vars)"
export RESOLVCONF DOMAINS SEARCH NAMESERVERS LOCALNAMESERVERS
@@ -410,10 +755,15 @@ export RESOLVCONF DOMAINS SEARCH NAMESERVERS LOCALNAMESERVERS
retval=0
for script in "$LIBEXECDIR"/*; do
if [ -f "$script" ]; then
+ eval script_enabled="\$${script##*/}"
+ case "${script_enabled:-YES}" in
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) ;;
+ *) continue;;
+ esac
if [ -x "$script" ]; then
"$script" "$cmd" "$iface"
else
- (. "$script" "$cmd" "$iface")
+ (set -- "$cmd" "$iface"; . "$script")
fi
retval=$(($retval + $?))
fi
diff --git a/contrib/openresolv/unbound.in b/contrib/openresolv/unbound.in
index aa04a31..5752e6f 100644
--- a/contrib/openresolv/unbound.in
+++ b/contrib/openresolv/unbound.in
@@ -1,5 +1,5 @@
#!/bin/sh
-# Copyright (c) 2009 Roy Marples
+# Copyright (c) 2009-2014 Roy Marples
# All rights reserved
# unbound subscriber for resolvconf
@@ -26,10 +26,12 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+unbound_insecure=
+
[ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
. "@SYSCONFDIR@/resolvconf.conf" || exit 1
[ -z "$unbound_conf" ] && exit 0
-[ -z "$RESOLVCONF" ] && eval "$(@PREFIX@/sbin/resolvconf -v)"
+[ -z "$RESOLVCONF" ] && eval "$(@SBINDIR@/resolvconf -v)"
NL="
"
@@ -41,6 +43,11 @@ newconf="# Generated by resolvconf$NL"
for d in $DOMAINS; do
dn="${d%%:*}"
ns="${d#*:}"
+ case "$unbound_insecure" in
+ [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+ newconf="$newconf${NL}domain-insecure: \"$dn\""
+ ;;
+ esac
newconf="$newconf${NL}forward-zone:$NL name: \"$dn\"$NL"
while [ -n "$ns" ]; do
newconf="$newconf forward-addr: ${ns%%,*}$NL"
@@ -56,6 +63,13 @@ if [ -n "$NAMESERVERS" ]; then
done
fi
+# Try to ensure that config dirs exist
+if type config_mkdirs >/dev/null 2>&1; then
+ config_mkdirs "$unbound_conf"
+else
+ @SBINDIR@/resolvconf -D "$unbound_conf"
+fi
+
if [ ! -f "$unbound_conf" ] || \
[ "$(cat "$unbound_conf")" != "$(printf %s "$newconf")" ]
then
diff --git a/contrib/sqlite3/configure b/contrib/sqlite3/configure
index d2db900..91f22b2 100755
--- a/contrib/sqlite3/configure
+++ b/contrib/sqlite3/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for sqlite 3.8.7.2.
+# Generated by GNU Autoconf 2.69 for sqlite 3.8.9.
#
# Report bugs to <http://www.sqlite.org>.
#
@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='sqlite'
PACKAGE_TARNAME='sqlite'
-PACKAGE_VERSION='3.8.7.2'
-PACKAGE_STRING='sqlite 3.8.7.2'
+PACKAGE_VERSION='3.8.9'
+PACKAGE_STRING='sqlite 3.8.9'
PACKAGE_BUGREPORT='http://www.sqlite.org'
PACKAGE_URL=''
@@ -1313,7 +1313,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures sqlite 3.8.7.2 to adapt to many kinds of systems.
+\`configure' configures sqlite 3.8.9 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1383,7 +1383,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of sqlite 3.8.7.2:";;
+ short | recursive ) echo "Configuration of sqlite 3.8.9:";;
esac
cat <<\_ACEOF
@@ -1489,7 +1489,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-sqlite configure 3.8.7.2
+sqlite configure 3.8.9
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1813,7 +1813,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by sqlite $as_me 3.8.7.2, which was
+It was created by sqlite $as_me 3.8.9, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2631,7 +2631,7 @@ fi
# Define the identity of the package.
PACKAGE='sqlite'
- VERSION='3.8.7.2'
+ VERSION='3.8.9'
cat >>confdefs.h <<_ACEOF
@@ -13196,7 +13196,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by sqlite $as_me 3.8.7.2, which was
+This file was extended by sqlite $as_me 3.8.9, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -13253,7 +13253,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-sqlite config.status 3.8.7.2
+sqlite config.status 3.8.9
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/contrib/sqlite3/configure.ac b/contrib/sqlite3/configure.ac
index c21506a..a78a3cb 100644
--- a/contrib/sqlite3/configure.ac
+++ b/contrib/sqlite3/configure.ac
@@ -8,7 +8,7 @@
#
AC_PREREQ(2.61)
-AC_INIT(sqlite, 3.8.7.2, http://www.sqlite.org)
+AC_INIT(sqlite, 3.8.9, http://www.sqlite.org)
AC_CONFIG_SRCDIR([sqlite3.c])
# Use automake.
diff --git a/contrib/sqlite3/shell.c b/contrib/sqlite3/shell.c
index 3ca4b09..7ff3eb6 100644
--- a/contrib/sqlite3/shell.c
+++ b/contrib/sqlite3/shell.c
@@ -18,6 +18,20 @@
#endif
/*
+** If requested, include the SQLite compiler options file for MSVC.
+*/
+#if defined(INCLUDE_MSVC_H)
+#include "msvc.h"
+#endif
+
+/*
+** No support for loadable extensions in VxWorks.
+*/
+#if (defined(__RTP__) || defined(_WRS_KERNEL)) && !SQLITE_OMIT_LOAD_EXTENSION
+# define SQLITE_OMIT_LOAD_EXTENSION 1
+#endif
+
+/*
** Enable large-file support for fopen() and friends on unix.
*/
#ifndef SQLITE_DISABLE_LFS
@@ -48,23 +62,42 @@
# include <sys/types.h>
#endif
-#if defined(HAVE_READLINE) && HAVE_READLINE!=0
+#if HAVE_READLINE
# include <readline/readline.h>
# include <readline/history.h>
-#else
-# undef HAVE_READLINE
#endif
-#if defined(HAVE_EDITLINE) && !defined(HAVE_READLINE)
-# define HAVE_READLINE 1
+
+#if HAVE_EDITLINE
# include <editline/readline.h>
#endif
-#if !defined(HAVE_READLINE)
-# define add_history(X)
-# define read_history(X)
-# define write_history(X)
-# define stifle_history(X)
+
+#if HAVE_EDITLINE || HAVE_READLINE
+
+# define shell_add_history(X) add_history(X)
+# define shell_read_history(X) read_history(X)
+# define shell_write_history(X) write_history(X)
+# define shell_stifle_history(X) stifle_history(X)
+# define shell_readline(X) readline(X)
+
+#elif HAVE_LINENOISE
+
+# include "linenoise.h"
+# define shell_add_history(X) linenoiseHistoryAdd(X)
+# define shell_read_history(X) linenoiseHistoryLoad(X)
+# define shell_write_history(X) linenoiseHistorySave(X)
+# define shell_stifle_history(X) linenoiseHistorySetMaxLen(X)
+# define shell_readline(X) linenoise(X)
+
+#else
+
+# define shell_read_history(X)
+# define shell_write_history(X)
+# define shell_stifle_history(X)
+
+# define SHELL_USE_LOCAL_GETLINE 1
#endif
+
#if defined(_WIN32) || defined(WIN32)
# include <io.h>
# include <fcntl.h>
@@ -81,10 +114,15 @@
*/
extern int isatty(int);
-/* popen and pclose are not C89 functions and so are sometimes omitted from
-** the <stdio.h> header */
-extern FILE *popen(const char*,const char*);
-extern int pclose(FILE*);
+#if !defined(__RTP__) && !defined(_WRS_KERNEL)
+ /* popen and pclose are not C89 functions and so are sometimes omitted from
+ ** the <stdio.h> header */
+ extern FILE *popen(const char*,const char*);
+ extern int pclose(FILE*);
+#else
+# define SQLITE_OMIT_POPEN 1
+#endif
+
#endif
#if defined(_WIN32_WCE)
@@ -100,6 +138,26 @@ extern int pclose(FILE*);
#define IsDigit(X) isdigit((unsigned char)X)
#define ToLower(X) (char)tolower((unsigned char)X)
+/* On Windows, we normally run with output mode of TEXT so that \n characters
+** are automatically translated into \r\n. However, this behavior needs
+** to be disabled in some cases (ex: when generating CSV output and when
+** rendering quoted strings that contain \n characters). The following
+** routines take care of that.
+*/
+#if defined(_WIN32) || defined(WIN32)
+static void setBinaryMode(FILE *out){
+ fflush(out);
+ _setmode(_fileno(out), _O_BINARY);
+}
+static void setTextMode(FILE *out){
+ fflush(out);
+ _setmode(_fileno(out), _O_TEXT);
+}
+#else
+# define setBinaryMode(X)
+# define setTextMode(X)
+#endif
+
/* True if the timer is enabled */
static int enableTimer = 0;
@@ -119,11 +177,19 @@ static sqlite3_int64 timeOfDay(void){
return t;
}
-#if !defined(_WIN32) && !defined(WIN32) && !defined(_WRS_KERNEL) \
- && !defined(__minux)
+#if !defined(_WIN32) && !defined(WIN32) && !defined(__minux)
#include <sys/time.h>
#include <sys/resource.h>
+/* VxWorks does not support getrusage() as far as we can determine */
+#if defined(_WRS_KERNEL) || defined(__RTP__)
+struct rusage {
+ struct timeval ru_utime; /* user CPU time used */
+ struct timeval ru_stime; /* system CPU time used */
+};
+#define getrusage(A,B) memset(B,0,sizeof(*B))
+#endif
+
/* Saved resource information for the beginning of an operation */
static struct rusage sBegin; /* CPU time at start */
static sqlite3_int64 iBegin; /* Wall-clock time at start */
@@ -149,8 +215,8 @@ static double timeDiff(struct timeval *pStart, struct timeval *pEnd){
*/
static void endTimer(void){
if( enableTimer ){
- struct rusage sEnd;
sqlite3_int64 iEnd = timeOfDay();
+ struct rusage sEnd;
getrusage(RUSAGE_SELF, &sEnd);
printf("Run Time: real %.3f user %f sys %f\n",
(iEnd - iBegin)*0.001,
@@ -172,7 +238,8 @@ static HANDLE hProcess;
static FILETIME ftKernelBegin;
static FILETIME ftUserBegin;
static sqlite3_int64 ftWallBegin;
-typedef BOOL (WINAPI *GETPROCTIMES)(HANDLE, LPFILETIME, LPFILETIME, LPFILETIME, LPFILETIME);
+typedef BOOL (WINAPI *GETPROCTIMES)(HANDLE, LPFILETIME, LPFILETIME,
+ LPFILETIME, LPFILETIME);
static GETPROCTIMES getProcessTimesAddr = NULL;
/*
@@ -183,15 +250,16 @@ static int hasTimer(void){
if( getProcessTimesAddr ){
return 1;
} else {
- /* GetProcessTimes() isn't supported in WIN95 and some other Windows versions.
- ** See if the version we are running on has it, and if it does, save off
- ** a pointer to it and the current process handle.
+ /* GetProcessTimes() isn't supported in WIN95 and some other Windows
+ ** versions. See if the version we are running on has it, and if it
+ ** does, save off a pointer to it and the current process handle.
*/
hProcess = GetCurrentProcess();
if( hProcess ){
HINSTANCE hinstLib = LoadLibrary(TEXT("Kernel32.dll"));
if( NULL != hinstLib ){
- getProcessTimesAddr = (GETPROCTIMES) GetProcAddress(hinstLib, "GetProcessTimes");
+ getProcessTimesAddr =
+ (GETPROCTIMES) GetProcAddress(hinstLib, "GetProcessTimes");
if( NULL != getProcessTimesAddr ){
return 1;
}
@@ -208,7 +276,8 @@ static int hasTimer(void){
static void beginTimer(void){
if( enableTimer && getProcessTimesAddr ){
FILETIME ftCreation, ftExit;
- getProcessTimesAddr(hProcess, &ftCreation, &ftExit, &ftKernelBegin, &ftUserBegin);
+ getProcessTimesAddr(hProcess,&ftCreation,&ftExit,
+ &ftKernelBegin,&ftUserBegin);
ftWallBegin = timeOfDay();
}
}
@@ -227,7 +296,7 @@ static void endTimer(void){
if( enableTimer && getProcessTimesAddr){
FILETIME ftCreation, ftExit, ftKernelEnd, ftUserEnd;
sqlite3_int64 ftWallEnd = timeOfDay();
- getProcessTimesAddr(hProcess, &ftCreation, &ftExit, &ftKernelEnd, &ftUserEnd);
+ getProcessTimesAddr(hProcess,&ftCreation,&ftExit,&ftKernelEnd,&ftUserEnd);
printf("Run Time: real %.3f user %f sys %f\n",
(ftWallEnd - ftWallBegin)*0.001,
timeDiff(&ftUserBegin, &ftUserEnd),
@@ -301,7 +370,7 @@ static FILE *iotrace = 0;
** is written to iotrace.
*/
#ifdef SQLITE_ENABLE_IOTRACE
-static void iotracePrintf(const char *zFormat, ...){
+static void SQLITE_CDECL iotracePrintf(const char *zFormat, ...){
va_list ap;
char *z;
if( iotrace==0 ) return;
@@ -422,14 +491,14 @@ static char *one_input_line(FILE *in, char *zPrior, int isContinuation){
zResult = local_getline(zPrior, in);
}else{
zPrompt = isContinuation ? continuePrompt : mainPrompt;
-#if defined(HAVE_READLINE)
- free(zPrior);
- zResult = readline(zPrompt);
- if( zResult && *zResult ) add_history(zResult);
-#else
+#if SHELL_USE_LOCAL_GETLINE
printf("%s", zPrompt);
fflush(stdout);
zResult = local_getline(zPrior, stdin);
+#else
+ free(zPrior);
+ zResult = shell_readline(zPrompt);
+ if( zResult && *zResult ) shell_add_history(zResult);
#endif
}
return zResult;
@@ -457,6 +526,7 @@ struct ShellState {
int echoOn; /* True to echo input commands */
int autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */
int statsOn; /* True to display memory stats before each finalize */
+ int scanstatsOn; /* True to display scan stats before each finalize */
int outCount; /* Revert to stdout when reaching zero */
int cnt; /* Number of records displayed so far */
FILE *out; /* Write results here */
@@ -467,11 +537,11 @@ struct ShellState {
int showHeader; /* True to show column names in List or Column mode */
unsigned shellFlgs; /* Various flags */
char *zDestTable; /* Name of destination table when MODE_Insert */
- char separator[20]; /* Separator character for MODE_List */
- char newline[20]; /* Record separator in MODE_Csv */
+ char colSeparator[20]; /* Column separator character for several modes */
+ char rowSeparator[20]; /* Row separator character for MODE_Ascii */
int colWidth[100]; /* Requested width of each column when in column mode*/
int actualWidth[100]; /* Actual width of each column */
- char nullvalue[20]; /* The text to print when a NULL comes back from
+ char nullValue[20]; /* The text to print when a NULL comes back from
** the database */
SavedModeInfo normalMode;/* Holds the mode just before .explain ON */
char outfile[FILENAME_MAX]; /* Filename for *out */
@@ -504,6 +574,7 @@ struct ShellState {
#define MODE_Tcl 6 /* Generate ANSI-C or TCL quoted elements */
#define MODE_Csv 7 /* Quote strings, numbers are plain */
#define MODE_Explain 8 /* Like MODE_Column, but do not truncate data */
+#define MODE_Ascii 9 /* Use ASCII unit and record separators (0x1F/0x1E) */
static const char *modeDescr[] = {
"line",
@@ -515,9 +586,23 @@ static const char *modeDescr[] = {
"tcl",
"csv",
"explain",
+ "ascii",
};
/*
+** These are the column/row/line separators used by the various
+** import/export modes.
+*/
+#define SEP_Column "|"
+#define SEP_Row "\n"
+#define SEP_Tab "\t"
+#define SEP_Space " "
+#define SEP_Comma ","
+#define SEP_CrLf "\r\n"
+#define SEP_Unit "\x1F"
+#define SEP_Record "\x1E"
+
+/*
** Number of elements in an array
*/
#define ArraySize(X) (int)(sizeof(X)/sizeof(X[0]))
@@ -559,6 +644,7 @@ static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){
static void output_quoted_string(FILE *out, const char *z){
int i;
int nSingle = 0;
+ setBinaryMode(out);
for(i=0; z[i]; i++){
if( z[i]=='\'' ) nSingle++;
}
@@ -581,6 +667,7 @@ static void output_quoted_string(FILE *out, const char *z){
}
fprintf(out,"'");
}
+ setTextMode(out);
}
/*
@@ -673,22 +760,22 @@ static const char needCsvQuote[] = {
};
/*
-** Output a single term of CSV. Actually, p->separator is used for
-** the separator, which may or may not be a comma. p->nullvalue is
+** Output a single term of CSV. Actually, p->colSeparator is used for
+** the separator, which may or may not be a comma. p->nullValue is
** the null value. Strings are quoted if necessary. The separator
** is only issued if bSep is true.
*/
static void output_csv(ShellState *p, const char *z, int bSep){
FILE *out = p->out;
if( z==0 ){
- fprintf(out,"%s",p->nullvalue);
+ fprintf(out,"%s",p->nullValue);
}else{
int i;
- int nSep = strlen30(p->separator);
+ int nSep = strlen30(p->colSeparator);
for(i=0; z[i]; i++){
if( needCsvQuote[((unsigned char*)z)[i]]
- || (z[i]==p->separator[0] &&
- (nSep==1 || memcmp(z, p->separator, nSep)==0)) ){
+ || (z[i]==p->colSeparator[0] &&
+ (nSep==1 || memcmp(z, p->colSeparator, nSep)==0)) ){
i = 0;
break;
}
@@ -705,7 +792,7 @@ static void output_csv(ShellState *p, const char *z, int bSep){
}
}
if( bSep ){
- fprintf(p->out, "%s", p->separator);
+ fprintf(p->out, "%s", p->colSeparator);
}
}
@@ -725,7 +812,13 @@ static void interrupt_handler(int NotUsed){
** This is the callback routine that the shell
** invokes for each row of a query result.
*/
-static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int *aiType){
+static int shell_callback(
+ void *pArg,
+ int nArg, /* Number of result columns */
+ char **azArg, /* Text of each result column */
+ char **azCol, /* Column names */
+ int *aiType /* Column types */
+){
int i;
ShellState *p = (ShellState*)pArg;
@@ -737,10 +830,10 @@ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int
int len = strlen30(azCol[i] ? azCol[i] : "");
if( len>w ) w = len;
}
- if( p->cnt++>0 ) fprintf(p->out,"\n");
+ if( p->cnt++>0 ) fprintf(p->out, "%s", p->rowSeparator);
for(i=0; i<nArg; i++){
- fprintf(p->out,"%*s = %s\n", w, azCol[i],
- azArg[i] ? azArg[i] : p->nullvalue);
+ fprintf(p->out,"%*s = %s%s", w, azCol[i],
+ azArg[i] ? azArg[i] : p->nullValue, p->rowSeparator);
}
break;
}
@@ -757,7 +850,7 @@ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int
if( w==0 ){
w = strlen30(azCol[i] ? azCol[i] : "");
if( w<10 ) w = 10;
- n = strlen30(azArg && azArg[i] ? azArg[i] : p->nullvalue);
+ n = strlen30(azArg && azArg[i] ? azArg[i] : p->nullValue);
if( w<n ) w = n;
}
if( i<ArraySize(p->actualWidth) ){
@@ -765,9 +858,11 @@ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int
}
if( p->showHeader ){
if( w<0 ){
- fprintf(p->out,"%*.*s%s",-w,-w,azCol[i], i==nArg-1 ? "\n": " ");
+ fprintf(p->out,"%*.*s%s",-w,-w,azCol[i],
+ i==nArg-1 ? p->rowSeparator : " ");
}else{
- fprintf(p->out,"%-*.*s%s",w,w,azCol[i], i==nArg-1 ? "\n": " ");
+ fprintf(p->out,"%-*.*s%s",w,w,azCol[i],
+ i==nArg-1 ? p->rowSeparator : " ");
}
}
}
@@ -782,7 +877,7 @@ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int
}
fprintf(p->out,"%-*.*s%s",w,w,"-----------------------------------"
"----------------------------------------------------------",
- i==nArg-1 ? "\n": " ");
+ i==nArg-1 ? p->rowSeparator : " ");
}
}
}
@@ -805,10 +900,12 @@ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int
}
if( w<0 ){
fprintf(p->out,"%*.*s%s",-w,-w,
- azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? "\n": " ");
+ azArg[i] ? azArg[i] : p->nullValue,
+ i==nArg-1 ? p->rowSeparator : " ");
}else{
fprintf(p->out,"%-*.*s%s",w,w,
- azArg[i] ? azArg[i] : p->nullvalue, i==nArg-1 ? "\n": " ");
+ azArg[i] ? azArg[i] : p->nullValue,
+ i==nArg-1 ? p->rowSeparator : " ");
}
}
break;
@@ -817,20 +914,21 @@ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int
case MODE_List: {
if( p->cnt++==0 && p->showHeader ){
for(i=0; i<nArg; i++){
- fprintf(p->out,"%s%s",azCol[i], i==nArg-1 ? "\n" : p->separator);
+ fprintf(p->out,"%s%s",azCol[i],
+ i==nArg-1 ? p->rowSeparator : p->colSeparator);
}
}
if( azArg==0 ) break;
for(i=0; i<nArg; i++){
char *z = azArg[i];
- if( z==0 ) z = p->nullvalue;
+ if( z==0 ) z = p->nullValue;
fprintf(p->out, "%s", z);
if( i<nArg-1 ){
- fprintf(p->out, "%s", p->separator);
+ fprintf(p->out, "%s", p->colSeparator);
}else if( p->mode==MODE_Semi ){
- fprintf(p->out, ";\n");
+ fprintf(p->out, ";%s", p->rowSeparator);
}else{
- fprintf(p->out, "\n");
+ fprintf(p->out, "%s", p->rowSeparator);
}
}
break;
@@ -849,7 +947,7 @@ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int
fprintf(p->out,"<TR>");
for(i=0; i<nArg; i++){
fprintf(p->out,"<TD>");
- output_html_string(p->out, azArg[i] ? azArg[i] : p->nullvalue);
+ output_html_string(p->out, azArg[i] ? azArg[i] : p->nullValue);
fprintf(p->out,"</TD>\n");
}
fprintf(p->out,"</TR>\n");
@@ -859,39 +957,33 @@ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int
if( p->cnt++==0 && p->showHeader ){
for(i=0; i<nArg; i++){
output_c_string(p->out,azCol[i] ? azCol[i] : "");
- if(i<nArg-1) fprintf(p->out, "%s", p->separator);
+ if(i<nArg-1) fprintf(p->out, "%s", p->colSeparator);
}
- fprintf(p->out,"\n");
+ fprintf(p->out, "%s", p->rowSeparator);
}
if( azArg==0 ) break;
for(i=0; i<nArg; i++){
- output_c_string(p->out, azArg[i] ? azArg[i] : p->nullvalue);
- if(i<nArg-1) fprintf(p->out, "%s", p->separator);
+ output_c_string(p->out, azArg[i] ? azArg[i] : p->nullValue);
+ if(i<nArg-1) fprintf(p->out, "%s", p->colSeparator);
}
- fprintf(p->out,"\n");
+ fprintf(p->out, "%s", p->rowSeparator);
break;
}
case MODE_Csv: {
-#if defined(WIN32) || defined(_WIN32)
- fflush(p->out);
- _setmode(_fileno(p->out), _O_BINARY);
-#endif
+ setBinaryMode(p->out);
if( p->cnt++==0 && p->showHeader ){
for(i=0; i<nArg; i++){
output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1);
}
- fprintf(p->out,"%s",p->newline);
+ fprintf(p->out, "%s", p->rowSeparator);
}
- if( azArg>0 ){
+ if( nArg>0 ){
for(i=0; i<nArg; i++){
output_csv(p, azArg[i], i<nArg-1);
}
- fprintf(p->out,"%s",p->newline);
+ fprintf(p->out, "%s", p->rowSeparator);
}
-#if defined(WIN32) || defined(_WIN32)
- fflush(p->out);
- _setmode(_fileno(p->out), _O_TEXT);
-#endif
+ setTextMode(p->out);
break;
}
case MODE_Insert: {
@@ -923,6 +1015,22 @@ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int
fprintf(p->out,");\n");
break;
}
+ case MODE_Ascii: {
+ if( p->cnt++==0 && p->showHeader ){
+ for(i=0; i<nArg; i++){
+ if( i>0 ) fprintf(p->out, "%s", p->colSeparator);
+ fprintf(p->out,"%s",azCol[i] ? azCol[i] : "");
+ }
+ fprintf(p->out, "%s", p->rowSeparator);
+ }
+ if( azArg==0 ) break;
+ for(i=0; i<nArg; i++){
+ if( i>0 ) fprintf(p->out, "%s", p->colSeparator);
+ fprintf(p->out,"%s",azArg[i] ? azArg[i] : p->nullValue);
+ }
+ fprintf(p->out, "%s", p->rowSeparator);
+ break;
+ }
}
return 0;
}
@@ -1104,57 +1212,77 @@ static int display_stats(
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset);
- fprintf(pArg->out, "Memory Used: %d (max %d) bytes\n", iCur, iHiwtr);
+ fprintf(pArg->out,
+ "Memory Used: %d (max %d) bytes\n",
+ iCur, iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset);
- fprintf(pArg->out, "Number of Outstanding Allocations: %d (max %d)\n", iCur, iHiwtr);
+ fprintf(pArg->out, "Number of Outstanding Allocations: %d (max %d)\n",
+ iCur, iHiwtr);
if( pArg->shellFlgs & SHFLG_Pagecache ){
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset);
- fprintf(pArg->out, "Number of Pcache Pages Used: %d (max %d) pages\n", iCur, iHiwtr);
+ fprintf(pArg->out,
+ "Number of Pcache Pages Used: %d (max %d) pages\n",
+ iCur, iHiwtr);
}
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset);
- fprintf(pArg->out, "Number of Pcache Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr);
+ fprintf(pArg->out,
+ "Number of Pcache Overflow Bytes: %d (max %d) bytes\n",
+ iCur, iHiwtr);
if( pArg->shellFlgs & SHFLG_Scratch ){
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &iCur, &iHiwtr, bReset);
- fprintf(pArg->out, "Number of Scratch Allocations Used: %d (max %d)\n", iCur, iHiwtr);
+ fprintf(pArg->out, "Number of Scratch Allocations Used: %d (max %d)\n",
+ iCur, iHiwtr);
}
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHiwtr, bReset);
- fprintf(pArg->out, "Number of Scratch Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr);
+ fprintf(pArg->out,
+ "Number of Scratch Overflow Bytes: %d (max %d) bytes\n",
+ iCur, iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset);
- fprintf(pArg->out, "Largest Allocation: %d bytes\n", iHiwtr);
+ fprintf(pArg->out, "Largest Allocation: %d bytes\n",
+ iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, bReset);
- fprintf(pArg->out, "Largest Pcache Allocation: %d bytes\n", iHiwtr);
+ fprintf(pArg->out, "Largest Pcache Allocation: %d bytes\n",
+ iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_SCRATCH_SIZE, &iCur, &iHiwtr, bReset);
- fprintf(pArg->out, "Largest Scratch Allocation: %d bytes\n", iHiwtr);
+ fprintf(pArg->out, "Largest Scratch Allocation: %d bytes\n",
+ iHiwtr);
#ifdef YYTRACKMAXSTACKDEPTH
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_PARSER_STACK, &iCur, &iHiwtr, bReset);
- fprintf(pArg->out, "Deepest Parser Stack: %d (max %d)\n", iCur, iHiwtr);
+ fprintf(pArg->out, "Deepest Parser Stack: %d (max %d)\n",
+ iCur, iHiwtr);
#endif
}
if( pArg && pArg->out && db ){
if( pArg->shellFlgs & SHFLG_Lookaside ){
iHiwtr = iCur = -1;
- sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, bReset);
- fprintf(pArg->out, "Lookaside Slots Used: %d (max %d)\n", iCur, iHiwtr);
- sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, bReset);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED,
+ &iCur, &iHiwtr, bReset);
+ fprintf(pArg->out, "Lookaside Slots Used: %d (max %d)\n",
+ iCur, iHiwtr);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT,
+ &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Successful lookaside attempts: %d\n", iHiwtr);
- sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur, &iHiwtr, bReset);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE,
+ &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Lookaside failures due to size: %d\n", iHiwtr);
- sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur, &iHiwtr, bReset);
+ sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL,
+ &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Lookaside failures due to OOM: %d\n", iHiwtr);
}
iHiwtr = iCur = -1;
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset);
- fprintf(pArg->out, "Pager Heap Usage: %d bytes\n", iCur); iHiwtr = iCur = -1;
+ fprintf(pArg->out, "Pager Heap Usage: %d bytes\n",iCur);
+ iHiwtr = iCur = -1;
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1);
fprintf(pArg->out, "Page cache hits: %d\n", iCur);
iHiwtr = iCur = -1;
@@ -1165,18 +1293,19 @@ static int display_stats(
fprintf(pArg->out, "Page cache writes: %d\n", iCur);
iHiwtr = iCur = -1;
sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset);
- fprintf(pArg->out, "Schema Heap Usage: %d bytes\n", iCur);
+ fprintf(pArg->out, "Schema Heap Usage: %d bytes\n",iCur);
iHiwtr = iCur = -1;
sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset);
- fprintf(pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n", iCur);
+ fprintf(pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n",iCur);
}
if( pArg && pArg->out && db && pArg->pStmt ){
- iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP, bReset);
+ iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP,
+ bReset);
fprintf(pArg->out, "Fullscan Steps: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_SORT, bReset);
fprintf(pArg->out, "Sort Operations: %d\n", iCur);
- iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX, bReset);
+ iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_AUTOINDEX,bReset);
fprintf(pArg->out, "Autoindex Inserts: %d\n", iCur);
iCur = sqlite3_stmt_status(pArg->pStmt, SQLITE_STMTSTATUS_VM_STEP, bReset);
fprintf(pArg->out, "Virtual Machine Steps: %d\n", iCur);
@@ -1186,6 +1315,51 @@ static int display_stats(
}
/*
+** Display scan stats.
+*/
+static void display_scanstats(
+ sqlite3 *db, /* Database to query */
+ ShellState *pArg /* Pointer to ShellState */
+){
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
+ int i, k, n, mx;
+ fprintf(pArg->out, "-------- scanstats --------\n");
+ mx = 0;
+ for(k=0; k<=mx; k++){
+ double rEstLoop = 1.0;
+ for(i=n=0; 1; i++){
+ sqlite3_stmt *p = pArg->pStmt;
+ sqlite3_int64 nLoop, nVisit;
+ double rEst;
+ int iSid;
+ const char *zExplain;
+ if( sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NLOOP, (void*)&nLoop) ){
+ break;
+ }
+ sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_SELECTID, (void*)&iSid);
+ if( iSid>mx ) mx = iSid;
+ if( iSid!=k ) continue;
+ if( n==0 ){
+ rEstLoop = (double)nLoop;
+ if( k>0 ) fprintf(pArg->out, "-------- subquery %d -------\n", k);
+ }
+ n++;
+ sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NVISIT, (void*)&nVisit);
+ sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EST, (void*)&rEst);
+ sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EXPLAIN, (void*)&zExplain);
+ fprintf(pArg->out, "Loop %2d: %s\n", n, zExplain);
+ rEstLoop *= rEst;
+ fprintf(pArg->out,
+ " nLoop=%-8lld nRow=%-8lld estRow=%-8lld estRow/Loop=%-8g\n",
+ nLoop, nVisit, (sqlite3_int64)(rEstLoop+0.5), rEst
+ );
+ }
+ }
+ fprintf(pArg->out, "---------------------------\n");
+#endif
+}
+
+/*
** Parameter azArray points to a zero-terminated array of strings. zStr
** points to a single nul-terminated string. Return non-zero if zStr
** is equal, according to strcmp(), to any of the strings in the array.
@@ -1226,7 +1400,8 @@ static void explain_data_prepare(ShellState *p, sqlite3_stmt *pSql){
const char *azNext[] = { "Next", "Prev", "VPrev", "VNext", "SorterNext",
"NextIfOpen", "PrevIfOpen", 0 };
- const char *azYield[] = { "Yield", "SeekLT", "SeekGT", "RowSetRead", "Rewind", 0 };
+ const char *azYield[] = { "Yield", "SeekLT", "SeekGT", "RowSetRead",
+ "Rewind", 0 };
const char *azGoto[] = { "Goto", 0 };
/* Try to figure out if this is really an EXPLAIN statement. If this
@@ -1339,7 +1514,8 @@ static int shell_exec(
/* Show the EXPLAIN QUERY PLAN if .eqp is on */
if( pArg && pArg->autoEQP ){
sqlite3_stmt *pExplain;
- char *zEQP = sqlite3_mprintf("EXPLAIN QUERY PLAN %s", sqlite3_sql(pStmt));
+ char *zEQP = sqlite3_mprintf("EXPLAIN QUERY PLAN %s",
+ sqlite3_sql(pStmt));
rc = sqlite3_prepare_v2(db, zEQP, -1, &pExplain, 0);
if( rc==SQLITE_OK ){
while( sqlite3_step(pExplain)==SQLITE_ROW ){
@@ -1423,6 +1599,11 @@ static int shell_exec(
display_stats(db, pArg, 0);
}
+ /* print loop-counters if required */
+ if( pArg && pArg->scanstatsOn ){
+ display_scanstats(db, pArg);
+ }
+
/* Finalize the statement just executed. If this fails, save a
** copy of the error message. Otherwise, set zSql to point to the
** next statement to execute. */
@@ -1592,6 +1773,7 @@ static char zHelp[] =
".bail on|off Stop after hitting an error. Default OFF\n"
".clone NEWDB Clone data into NEWDB from the existing database\n"
".databases List names and files of attached databases\n"
+ ".dbinfo ?DB? Show status information about the database\n"
".dump ?TABLE? ... Dump the database in an SQL text format\n"
" If TABLE specified, only dump tables matching\n"
" LIKE pattern TABLE.\n"
@@ -1604,8 +1786,8 @@ static char zHelp[] =
".headers on|off Turn display of headers on or off\n"
".help Show this message\n"
".import FILE TABLE Import data from FILE into TABLE\n"
- ".indices ?TABLE? Show names of all indices\n"
- " If TABLE specified, only show indices for tables\n"
+ ".indexes ?TABLE? Show names of all indexes\n"
+ " If TABLE specified, only show indexes for tables\n"
" matching LIKE pattern TABLE.\n"
#ifdef SQLITE_ENABLE_IOTRACE
".iotrace FILE Enable I/O diagnostic logging to FILE\n"
@@ -1615,12 +1797,13 @@ static char zHelp[] =
#endif
".log FILE|off Turn logging on or off. FILE can be stderr/stdout\n"
".mode MODE ?TABLE? Set output mode where MODE is one of:\n"
+ " ascii Columns/rows delimited by 0x1F and 0x1E\n"
" csv Comma-separated values\n"
" column Left-aligned columns. (See .width)\n"
" html HTML <table> code\n"
" insert SQL insert statements for TABLE\n"
" line One value per line\n"
- " list Values delimited by .separator string\n"
+ " list Values delimited by .separator strings\n"
" tabs Tab-separated values\n"
" tcl TCL list elements\n"
".nullvalue STRING Use STRING in place of NULL values\n"
@@ -1633,11 +1816,12 @@ static char zHelp[] =
".read FILENAME Execute SQL in FILENAME\n"
".restore ?DB? FILE Restore content of DB (default \"main\") from FILE\n"
".save FILE Write in-memory database into FILE\n"
+ ".scanstats on|off Turn sqlite3_stmt_scanstatus() metrics on or off\n"
".schema ?TABLE? Show the CREATE statements\n"
" If TABLE specified, only show tables matching\n"
" LIKE pattern TABLE.\n"
- ".separator STRING ?NL? Change separator used by output mode and .import\n"
- " NL is the end-of-line mark for CSV\n"
+ ".separator COL ?ROW? Change the column separator and optionally the row\n"
+ " separator for both the output mode and .import\n"
".shell CMD ARGS... Run CMD ARGS... in a system shell\n"
".show Show the current values for various settings\n"
".stats on|off Turn stats on or off\n"
@@ -1918,10 +2102,10 @@ static void test_breakpoint(void){
}
/*
-** An object used to read a CSV file
+** An object used to read a CSV and other files for import.
*/
-typedef struct CSVReader CSVReader;
-struct CSVReader {
+typedef struct ImportCtx ImportCtx;
+struct ImportCtx {
const char *zFile; /* Name of the input file */
FILE *in; /* Read the CSV text from this input stream */
char *z; /* Accumulated text for a field */
@@ -1929,11 +2113,12 @@ struct CSVReader {
int nAlloc; /* Space allocated for z[] */
int nLine; /* Current line number */
int cTerm; /* Character that terminated the most recent field */
- int cSeparator; /* The separator character. (Usually ",") */
+ int cColSep; /* The column separator character. (Usually ",") */
+ int cRowSep; /* The row separator character. (Usually "\n") */
};
/* Append a single byte to z[] */
-static void csv_append_char(CSVReader *p, int c){
+static void import_append_char(ImportCtx *p, int c){
if( p->n+1>=p->nAlloc ){
p->nAlloc += p->nAlloc + 100;
p->z = sqlite3_realloc(p->z, p->nAlloc);
@@ -1951,15 +2136,17 @@ static void csv_append_char(CSVReader *p, int c){
** + Input comes from p->in.
** + Store results in p->z of length p->n. Space to hold p->z comes
** from sqlite3_malloc().
-** + Use p->cSep as the separator. The default is ",".
+** + Use p->cSep as the column separator. The default is ",".
+** + Use p->rSep as the row separator. The default is "\n".
** + Keep track of the line number in p->nLine.
** + Store the character that terminates the field in p->cTerm. Store
** EOF on end-of-file.
** + Report syntax errors on stderr
*/
-static char *csv_read_one_field(CSVReader *p){
- int c, pc, ppc;
- int cSep = p->cSeparator;
+static char *SQLITE_CDECL csv_read_one_field(ImportCtx *p){
+ int c;
+ int cSep = p->cColSep;
+ int rSep = p->cRowSep;
p->n = 0;
c = fgetc(p->in);
if( c==EOF || seenInterrupt ){
@@ -1967,12 +2154,13 @@ static char *csv_read_one_field(CSVReader *p){
return 0;
}
if( c=='"' ){
+ int pc, ppc;
int startLine = p->nLine;
int cQuote = c;
pc = ppc = 0;
while( 1 ){
c = fgetc(p->in);
- if( c=='\n' ) p->nLine++;
+ if( c==rSep ) p->nLine++;
if( c==cQuote ){
if( pc==cQuote ){
pc = 0;
@@ -1980,8 +2168,8 @@ static char *csv_read_one_field(CSVReader *p){
}
}
if( (c==cSep && pc==cQuote)
- || (c=='\n' && pc==cQuote)
- || (c=='\n' && pc=='\r' && ppc==cQuote)
+ || (c==rSep && pc==cQuote)
+ || (c==rSep && pc=='\r' && ppc==cQuote)
|| (c==EOF && pc==cQuote)
){
do{ p->n--; }while( p->z[p->n]!=cQuote );
@@ -1995,19 +2183,19 @@ static char *csv_read_one_field(CSVReader *p){
if( c==EOF ){
fprintf(stderr, "%s:%d: unterminated %c-quoted field\n",
p->zFile, startLine, cQuote);
- p->cTerm = EOF;
+ p->cTerm = c;
break;
}
- csv_append_char(p, c);
+ import_append_char(p, c);
ppc = pc;
pc = c;
}
}else{
- while( c!=EOF && c!=cSep && c!='\n' ){
- csv_append_char(p, c);
+ while( c!=EOF && c!=cSep && c!=rSep ){
+ import_append_char(p, c);
c = fgetc(p->in);
}
- if( c=='\n' ){
+ if( c==rSep ){
p->nLine++;
if( p->n>0 && p->z[p->n-1]=='\r' ) p->n--;
}
@@ -2017,6 +2205,40 @@ static char *csv_read_one_field(CSVReader *p){
return p->z;
}
+/* Read a single field of ASCII delimited text.
+**
+** + Input comes from p->in.
+** + Store results in p->z of length p->n. Space to hold p->z comes
+** from sqlite3_malloc().
+** + Use p->cSep as the column separator. The default is "\x1F".
+** + Use p->rSep as the row separator. The default is "\x1E".
+** + Keep track of the row number in p->nLine.
+** + Store the character that terminates the field in p->cTerm. Store
+** EOF on end-of-file.
+** + Report syntax errors on stderr
+*/
+static char *SQLITE_CDECL ascii_read_one_field(ImportCtx *p){
+ int c;
+ int cSep = p->cColSep;
+ int rSep = p->cRowSep;
+ p->n = 0;
+ c = fgetc(p->in);
+ if( c==EOF || seenInterrupt ){
+ p->cTerm = EOF;
+ return 0;
+ }
+ while( c!=EOF && c!=cSep && c!=rSep ){
+ import_append_char(p, c);
+ c = fgetc(p->in);
+ }
+ if( c==rSep ){
+ p->nLine++;
+ }
+ p->cTerm = c;
+ if( p->z ) p->z[p->n] = 0;
+ return p->z;
+}
+
/*
** Try to transfer data for table zTable. If an error is seen while
** moving forward, try to go backwards. The backwards movement won't
@@ -2237,7 +2459,9 @@ static void tryToClone(ShellState *p, const char *zNewDb){
*/
static void output_reset(ShellState *p){
if( p->outfile[0]=='|' ){
+#ifndef SQLITE_OMIT_POPEN
pclose(p->out);
+#endif
}else{
output_file_close(p->out);
}
@@ -2246,6 +2470,115 @@ static void output_reset(ShellState *p){
}
/*
+** Run an SQL command and return the single integer result.
+*/
+static int db_int(ShellState *p, const char *zSql){
+ sqlite3_stmt *pStmt;
+ int res = 0;
+ sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
+ if( pStmt && sqlite3_step(pStmt)==SQLITE_ROW ){
+ res = sqlite3_column_int(pStmt,0);
+ }
+ sqlite3_finalize(pStmt);
+ return res;
+}
+
+/*
+** Convert a 2-byte or 4-byte big-endian integer into a native integer
+*/
+unsigned int get2byteInt(unsigned char *a){
+ return (a[0]<<8) + a[1];
+}
+unsigned int get4byteInt(unsigned char *a){
+ return (a[0]<<24) + (a[1]<<16) + (a[2]<<8) + a[3];
+}
+
+/*
+** Implementation of the ".info" command.
+**
+** Return 1 on error, 2 to exit, and 0 otherwise.
+*/
+static int shell_dbinfo_command(ShellState *p, int nArg, char **azArg){
+ static const struct { const char *zName; int ofst; } aField[] = {
+ { "file change counter:", 24 },
+ { "database page count:", 28 },
+ { "freelist page count:", 36 },
+ { "schema cookie:", 40 },
+ { "schema format:", 44 },
+ { "default cache size:", 48 },
+ { "autovacuum top root:", 52 },
+ { "incremental vacuum:", 64 },
+ { "text encoding:", 56 },
+ { "user version:", 60 },
+ { "application id:", 68 },
+ { "software version:", 96 },
+ };
+ static const struct { const char *zName; const char *zSql; } aQuery[] = {
+ { "number of tables:",
+ "SELECT count(*) FROM %s WHERE type='table'" },
+ { "number of indexes:",
+ "SELECT count(*) FROM %s WHERE type='index'" },
+ { "number of triggers:",
+ "SELECT count(*) FROM %s WHERE type='trigger'" },
+ { "number of views:",
+ "SELECT count(*) FROM %s WHERE type='view'" },
+ { "schema size:",
+ "SELECT total(length(sql)) FROM %s" },
+ };
+ sqlite3_file *pFile;
+ int i;
+ char *zSchemaTab;
+ char *zDb = nArg>=2 ? azArg[1] : "main";
+ unsigned char aHdr[100];
+ open_db(p, 0);
+ if( p->db==0 ) return 1;
+ sqlite3_file_control(p->db, zDb, SQLITE_FCNTL_FILE_POINTER, &pFile);
+ if( pFile==0 || pFile->pMethods==0 || pFile->pMethods->xRead==0 ){
+ return 1;
+ }
+ i = pFile->pMethods->xRead(pFile, aHdr, 100, 0);
+ if( i!=SQLITE_OK ){
+ fprintf(stderr, "unable to read database header\n");
+ return 1;
+ }
+ i = get2byteInt(aHdr+16);
+ if( i==1 ) i = 65536;
+ fprintf(p->out, "%-20s %d\n", "database page size:", i);
+ fprintf(p->out, "%-20s %d\n", "write format:", aHdr[18]);
+ fprintf(p->out, "%-20s %d\n", "read format:", aHdr[19]);
+ fprintf(p->out, "%-20s %d\n", "reserved bytes:", aHdr[20]);
+ for(i=0; i<sizeof(aField)/sizeof(aField[0]); i++){
+ int ofst = aField[i].ofst;
+ unsigned int val = get4byteInt(aHdr + ofst);
+ fprintf(p->out, "%-20s %u", aField[i].zName, val);
+ switch( ofst ){
+ case 56: {
+ if( val==1 ) fprintf(p->out, " (utf8)");
+ if( val==2 ) fprintf(p->out, " (utf16le)");
+ if( val==3 ) fprintf(p->out, " (utf16be)");
+ }
+ }
+ fprintf(p->out, "\n");
+ }
+ if( zDb==0 ){
+ zSchemaTab = sqlite3_mprintf("main.sqlite_master");
+ }else if( strcmp(zDb,"temp")==0 ){
+ zSchemaTab = sqlite3_mprintf("%s", "sqlite_temp_master");
+ }else{
+ zSchemaTab = sqlite3_mprintf("\"%w\".sqlite_master", zDb);
+ }
+ for(i=0; i<sizeof(aQuery)/sizeof(aQuery[0]); i++){
+ char *zSql = sqlite3_mprintf(aQuery[i].zSql, zSchemaTab);
+ int val = db_int(p, zSql);
+ sqlite3_free(zSql);
+ fprintf(p->out, "%-20s %d\n", aQuery[i].zName, val);
+ }
+ sqlite3_free(zSchemaTab);
+ return 0;
+}
+
+
+/*
** If an input line begins with "." then invoke this routine to
** process that line.
**
@@ -2387,6 +2720,10 @@ static int do_meta_command(char *zLine, ShellState *p){
}
}else
+ if( c=='d' && strncmp(azArg[0], "dbinfo", n)==0 ){
+ rc = shell_dbinfo_command(p, nArg, azArg);
+ }else
+
if( c=='d' && strncmp(azArg[0], "dump", n)==0 ){
open_db(p, 0);
/* When playing back a "dump", the content might appear in an order
@@ -2571,10 +2908,11 @@ static int do_meta_command(char *zLine, ShellState *p){
int nByte; /* Number of bytes in an SQL string */
int i, j; /* Loop counters */
int needCommit; /* True to COMMIT or ROLLBACK at end */
- int nSep; /* Number of bytes in p->separator[] */
+ int nSep; /* Number of bytes in p->colSeparator[] */
char *zSql; /* An SQL statement */
- CSVReader sCsv; /* Reader context */
- int (*xCloser)(FILE*); /* Procedure to close th3 connection */
+ ImportCtx sCtx; /* Reader context */
+ char *(SQLITE_CDECL *xRead)(ImportCtx*); /* Func to read one value */
+ int (SQLITE_CDECL *xCloser)(FILE*); /* Func to close file */
if( nArg!=3 ){
fprintf(stderr, "Usage: .import FILE TABLE\n");
@@ -2583,55 +2921,84 @@ static int do_meta_command(char *zLine, ShellState *p){
zFile = azArg[1];
zTable = azArg[2];
seenInterrupt = 0;
- memset(&sCsv, 0, sizeof(sCsv));
+ memset(&sCtx, 0, sizeof(sCtx));
open_db(p, 0);
- nSep = strlen30(p->separator);
+ nSep = strlen30(p->colSeparator);
if( nSep==0 ){
- fprintf(stderr, "Error: non-null separator required for import\n");
+ fprintf(stderr, "Error: non-null column separator required for import\n");
return 1;
}
if( nSep>1 ){
- fprintf(stderr, "Error: multi-character separators not allowed"
+ fprintf(stderr, "Error: multi-character column separators not allowed"
" for import\n");
return 1;
}
- sCsv.zFile = zFile;
- sCsv.nLine = 1;
- if( sCsv.zFile[0]=='|' ){
- sCsv.in = popen(sCsv.zFile+1, "r");
- sCsv.zFile = "<pipe>";
+ nSep = strlen30(p->rowSeparator);
+ if( nSep==0 ){
+ fprintf(stderr, "Error: non-null row separator required for import\n");
+ return 1;
+ }
+ if( nSep==2 && p->mode==MODE_Csv && strcmp(p->rowSeparator, SEP_CrLf)==0 ){
+ /* When importing CSV (only), if the row separator is set to the
+ ** default output row separator, change it to the default input
+ ** row separator. This avoids having to maintain different input
+ ** and output row separators. */
+ sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Row);
+ nSep = strlen30(p->rowSeparator);
+ }
+ if( nSep>1 ){
+ fprintf(stderr, "Error: multi-character row separators not allowed"
+ " for import\n");
+ return 1;
+ }
+ sCtx.zFile = zFile;
+ sCtx.nLine = 1;
+ if( sCtx.zFile[0]=='|' ){
+#ifdef SQLITE_OMIT_POPEN
+ fprintf(stderr, "Error: pipes are not supported in this OS\n");
+ return 1;
+#else
+ sCtx.in = popen(sCtx.zFile+1, "r");
+ sCtx.zFile = "<pipe>";
xCloser = pclose;
+#endif
}else{
- sCsv.in = fopen(sCsv.zFile, "rb");
+ sCtx.in = fopen(sCtx.zFile, "rb");
xCloser = fclose;
}
- if( sCsv.in==0 ){
+ if( p->mode==MODE_Ascii ){
+ xRead = ascii_read_one_field;
+ }else{
+ xRead = csv_read_one_field;
+ }
+ if( sCtx.in==0 ){
fprintf(stderr, "Error: cannot open \"%s\"\n", zFile);
return 1;
}
- sCsv.cSeparator = p->separator[0];
+ sCtx.cColSep = p->colSeparator[0];
+ sCtx.cRowSep = p->rowSeparator[0];
zSql = sqlite3_mprintf("SELECT * FROM %s", zTable);
if( zSql==0 ){
fprintf(stderr, "Error: out of memory\n");
- xCloser(sCsv.in);
+ xCloser(sCtx.in);
return 1;
}
nByte = strlen30(zSql);
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
- csv_append_char(&sCsv, 0); /* To ensure sCsv.z is allocated */
+ import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */
if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(db))==0 ){
char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable);
char cSep = '(';
- while( csv_read_one_field(&sCsv) ){
- zCreate = sqlite3_mprintf("%z%c\n \"%s\" TEXT", zCreate, cSep, sCsv.z);
+ while( xRead(&sCtx) ){
+ zCreate = sqlite3_mprintf("%z%c\n \"%s\" TEXT", zCreate, cSep, sCtx.z);
cSep = ',';
- if( sCsv.cTerm!=sCsv.cSeparator ) break;
+ if( sCtx.cTerm!=sCtx.cColSep ) break;
}
if( cSep=='(' ){
sqlite3_free(zCreate);
- sqlite3_free(sCsv.z);
- xCloser(sCsv.in);
- fprintf(stderr,"%s: empty file\n", sCsv.zFile);
+ sqlite3_free(sCtx.z);
+ xCloser(sCtx.in);
+ fprintf(stderr,"%s: empty file\n", sCtx.zFile);
return 1;
}
zCreate = sqlite3_mprintf("%z\n)", zCreate);
@@ -2640,8 +3007,8 @@ static int do_meta_command(char *zLine, ShellState *p){
if( rc ){
fprintf(stderr, "CREATE TABLE %s(...) failed: %s\n", zTable,
sqlite3_errmsg(db));
- sqlite3_free(sCsv.z);
- xCloser(sCsv.in);
+ sqlite3_free(sCtx.z);
+ xCloser(sCtx.in);
return 1;
}
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
@@ -2650,7 +3017,7 @@ static int do_meta_command(char *zLine, ShellState *p){
if( rc ){
if (pStmt) sqlite3_finalize(pStmt);
fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db));
- xCloser(sCsv.in);
+ xCloser(sCtx.in);
return 1;
}
nCol = sqlite3_column_count(pStmt);
@@ -2660,7 +3027,7 @@ static int do_meta_command(char *zLine, ShellState *p){
zSql = sqlite3_malloc( nByte*2 + 20 + nCol*2 );
if( zSql==0 ){
fprintf(stderr, "Error: out of memory\n");
- xCloser(sCsv.in);
+ xCloser(sCtx.in);
return 1;
}
sqlite3_snprintf(nByte+20, zSql, "INSERT INTO \"%w\" VALUES(?", zTable);
@@ -2676,51 +3043,62 @@ static int do_meta_command(char *zLine, ShellState *p){
if( rc ){
fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db));
if (pStmt) sqlite3_finalize(pStmt);
- xCloser(sCsv.in);
+ xCloser(sCtx.in);
return 1;
}
needCommit = sqlite3_get_autocommit(db);
if( needCommit ) sqlite3_exec(db, "BEGIN", 0, 0, 0);
do{
- int startLine = sCsv.nLine;
+ int startLine = sCtx.nLine;
for(i=0; i<nCol; i++){
- char *z = csv_read_one_field(&sCsv);
+ char *z = xRead(&sCtx);
+ /*
+ ** Did we reach end-of-file before finding any columns?
+ ** If so, stop instead of NULL filling the remaining columns.
+ */
if( z==0 && i==0 ) break;
+ /*
+ ** Did we reach end-of-file OR end-of-line before finding any
+ ** columns in ASCII mode? If so, stop instead of NULL filling
+ ** the remaining columns.
+ */
+ if( p->mode==MODE_Ascii && (z==0 || z[0]==0) && i==0 ) break;
sqlite3_bind_text(pStmt, i+1, z, -1, SQLITE_TRANSIENT);
- if( i<nCol-1 && sCsv.cTerm!=sCsv.cSeparator ){
+ if( i<nCol-1 && sCtx.cTerm!=sCtx.cColSep ){
fprintf(stderr, "%s:%d: expected %d columns but found %d - "
"filling the rest with NULL\n",
- sCsv.zFile, startLine, nCol, i+1);
- i++;
+ sCtx.zFile, startLine, nCol, i+1);
+ i += 2;
while( i<=nCol ){ sqlite3_bind_null(pStmt, i); i++; }
}
}
- if( sCsv.cTerm==sCsv.cSeparator ){
+ if( sCtx.cTerm==sCtx.cColSep ){
do{
- csv_read_one_field(&sCsv);
+ xRead(&sCtx);
i++;
- }while( sCsv.cTerm==sCsv.cSeparator );
+ }while( sCtx.cTerm==sCtx.cColSep );
fprintf(stderr, "%s:%d: expected %d columns but found %d - "
"extras ignored\n",
- sCsv.zFile, startLine, nCol, i);
+ sCtx.zFile, startLine, nCol, i);
}
if( i>=nCol ){
sqlite3_step(pStmt);
rc = sqlite3_reset(pStmt);
if( rc!=SQLITE_OK ){
- fprintf(stderr, "%s:%d: INSERT failed: %s\n", sCsv.zFile, startLine,
+ fprintf(stderr, "%s:%d: INSERT failed: %s\n", sCtx.zFile, startLine,
sqlite3_errmsg(db));
}
}
- }while( sCsv.cTerm!=EOF );
+ }while( sCtx.cTerm!=EOF );
- xCloser(sCsv.in);
- sqlite3_free(sCsv.z);
+ xCloser(sCtx.in);
+ sqlite3_free(sCtx.z);
sqlite3_finalize(pStmt);
if( needCommit ) sqlite3_exec(db, "COMMIT", 0, 0, 0);
}else
- if( c=='i' && strncmp(azArg[0], "indices", n)==0 ){
+ if( c=='i' && (strncmp(azArg[0], "indices", n)==0
+ || strncmp(azArg[0], "indexes", n)==0) ){
ShellState data;
char *zErrMsg = 0;
open_db(p, 0);
@@ -2750,7 +3128,7 @@ static int do_meta_command(char *zLine, ShellState *p){
);
zShellStatic = 0;
}else{
- fprintf(stderr, "Usage: .indices ?LIKE-PATTERN?\n");
+ fprintf(stderr, "Usage: .indexes ?LIKE-PATTERN?\n");
rc = 1;
goto meta_command_exit;
}
@@ -2766,7 +3144,7 @@ static int do_meta_command(char *zLine, ShellState *p){
#ifdef SQLITE_ENABLE_IOTRACE
if( c=='i' && strncmp(azArg[0], "iotrace", n)==0 ){
- extern void (*sqlite3IoTrace)(const char*, ...);
+ SQLITE_API extern void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...);
if( iotrace && iotrace!=stdout ) fclose(iotrace);
iotrace = 0;
if( nArg<2 ){
@@ -2833,28 +3211,32 @@ static int do_meta_command(char *zLine, ShellState *p){
p->mode = MODE_Html;
}else if( c2=='t' && strncmp(azArg[1],"tcl",n2)==0 ){
p->mode = MODE_Tcl;
- sqlite3_snprintf(sizeof(p->separator), p->separator, " ");
+ sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Space);
}else if( c2=='c' && strncmp(azArg[1],"csv",n2)==0 ){
p->mode = MODE_Csv;
- sqlite3_snprintf(sizeof(p->separator), p->separator, ",");
- sqlite3_snprintf(sizeof(p->newline), p->newline, "\r\n");
+ sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Comma);
+ sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_CrLf);
}else if( c2=='t' && strncmp(azArg[1],"tabs",n2)==0 ){
p->mode = MODE_List;
- sqlite3_snprintf(sizeof(p->separator), p->separator, "\t");
+ sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Tab);
}else if( c2=='i' && strncmp(azArg[1],"insert",n2)==0 ){
p->mode = MODE_Insert;
set_table_name(p, nArg>=3 ? azArg[2] : "table");
+ }else if( c2=='a' && strncmp(azArg[1],"ascii",n2)==0 ){
+ p->mode = MODE_Ascii;
+ sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator, SEP_Unit);
+ sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator, SEP_Record);
}else {
fprintf(stderr,"Error: mode should be one of: "
- "column csv html insert line list tabs tcl\n");
+ "ascii column csv html insert line list tabs tcl\n");
rc = 1;
}
}else
if( c=='n' && strncmp(azArg[0], "nullvalue", n)==0 ){
if( nArg==2 ){
- sqlite3_snprintf(sizeof(p->nullvalue), p->nullvalue,
- "%.*s", (int)ArraySize(p->nullvalue)-1, azArg[1]);
+ sqlite3_snprintf(sizeof(p->nullValue), p->nullValue,
+ "%.*s", (int)ArraySize(p->nullValue)-1, azArg[1]);
}else{
fprintf(stderr, "Usage: .nullvalue STRING\n");
rc = 1;
@@ -2902,6 +3284,11 @@ static int do_meta_command(char *zLine, ShellState *p){
}
output_reset(p);
if( zFile[0]=='|' ){
+#ifdef SQLITE_OMIT_POPEN
+ fprintf(stderr,"Error: pipes are not supported in this OS\n");
+ rc = 1;
+ p->out = stdout;
+#else
p->out = popen(zFile + 1, "w");
if( p->out==0 ){
fprintf(stderr,"Error: cannot open pipe \"%s\"\n", zFile + 1);
@@ -2910,6 +3297,7 @@ static int do_meta_command(char *zLine, ShellState *p){
}else{
sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", zFile);
}
+#endif
}else{
p->out = output_file_open(zFile);
if( p->out==0 ){
@@ -3014,6 +3402,19 @@ static int do_meta_command(char *zLine, ShellState *p){
sqlite3_close(pSrc);
}else
+
+ if( c=='s' && strncmp(azArg[0], "scanstats", n)==0 ){
+ if( nArg==2 ){
+ p->scanstatsOn = booleanValue(azArg[1]);
+#ifndef SQLITE_ENABLE_STMT_SCANSTATUS
+ fprintf(stderr, "Warning: .scanstats not available in this build.\n");
+#endif
+ }else{
+ fprintf(stderr, "Usage: .scanstats on|off\n");
+ rc = 1;
+ }
+ }else
+
if( c=='s' && strncmp(azArg[0], "schema", n)==0 ){
ShellState data;
char *zErrMsg = 0;
@@ -3096,7 +3497,7 @@ static int do_meta_command(char *zLine, ShellState *p){
#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE)
if( c=='s' && n==11 && strncmp(azArg[0], "selecttrace", n)==0 ){
extern int sqlite3SelectTrace;
- sqlite3SelectTrace = nArg>=2 ? booleanValue(azArg[1]) : 0xff;
+ sqlite3SelectTrace = integerValue(azArg[1]);
}else
#endif
@@ -3126,14 +3527,16 @@ static int do_meta_command(char *zLine, ShellState *p){
if( c=='s' && strncmp(azArg[0], "separator", n)==0 ){
if( nArg<2 || nArg>3 ){
- fprintf(stderr, "Usage: .separator SEPARATOR ?NEWLINE?\n");
+ fprintf(stderr, "Usage: .separator COL ?ROW?\n");
rc = 1;
}
if( nArg>=2 ){
- sqlite3_snprintf(sizeof(p->separator), p->separator, azArg[1]);
+ sqlite3_snprintf(sizeof(p->colSeparator), p->colSeparator,
+ "%.*s", (int)ArraySize(p->colSeparator)-1, azArg[1]);
}
if( nArg>=3 ){
- sqlite3_snprintf(sizeof(p->newline), p->newline, azArg[2]);
+ sqlite3_snprintf(sizeof(p->rowSeparator), p->rowSeparator,
+ "%.*s", (int)ArraySize(p->rowSeparator)-1, azArg[2]);
}
}else
@@ -3164,23 +3567,24 @@ static int do_meta_command(char *zLine, ShellState *p){
rc = 1;
goto meta_command_exit;
}
- fprintf(p->out,"%9.9s: %s\n","echo", p->echoOn ? "on" : "off");
- fprintf(p->out,"%9.9s: %s\n","eqp", p->autoEQP ? "on" : "off");
+ fprintf(p->out,"%12.12s: %s\n","echo", p->echoOn ? "on" : "off");
+ fprintf(p->out,"%12.12s: %s\n","eqp", p->autoEQP ? "on" : "off");
fprintf(p->out,"%9.9s: %s\n","explain", p->normalMode.valid ? "on" :"off");
- fprintf(p->out,"%9.9s: %s\n","headers", p->showHeader ? "on" : "off");
- fprintf(p->out,"%9.9s: %s\n","mode", modeDescr[p->mode]);
- fprintf(p->out,"%9.9s: ", "nullvalue");
- output_c_string(p->out, p->nullvalue);
+ fprintf(p->out,"%12.12s: %s\n","headers", p->showHeader ? "on" : "off");
+ fprintf(p->out,"%12.12s: %s\n","mode", modeDescr[p->mode]);
+ fprintf(p->out,"%12.12s: ", "nullvalue");
+ output_c_string(p->out, p->nullValue);
fprintf(p->out, "\n");
- fprintf(p->out,"%9.9s: %s\n","output",
+ fprintf(p->out,"%12.12s: %s\n","output",
strlen30(p->outfile) ? p->outfile : "stdout");
- fprintf(p->out,"%9.9s: ", "separator");
- output_c_string(p->out, p->separator);
- fprintf(p->out," ");
- output_c_string(p->out, p->newline);
+ fprintf(p->out,"%12.12s: ", "colseparator");
+ output_c_string(p->out, p->colSeparator);
+ fprintf(p->out, "\n");
+ fprintf(p->out,"%12.12s: ", "rowseparator");
+ output_c_string(p->out, p->rowSeparator);
fprintf(p->out, "\n");
- fprintf(p->out,"%9.9s: %s\n","stats", p->statsOn ? "on" : "off");
- fprintf(p->out,"%9.9s: ","width");
+ fprintf(p->out,"%12.12s: %s\n","stats", p->statsOn ? "on" : "off");
+ fprintf(p->out,"%12.12s: ","width");
for (i=0;i<(int)ArraySize(p->colWidth) && p->colWidth[i] != 0;i++) {
fprintf(p->out,"%d ",p->colWidth[i]);
}
@@ -3271,7 +3675,7 @@ static int do_meta_command(char *zLine, ShellState *p){
for(i=0; i<nPrintRow; i++){
for(j=i; j<nRow; j+=nPrintRow){
char *zSp = j<nPrintRow ? "" : " ";
- fprintf(p->out, "%s%-*s", zSp, maxlen, azResult[j] ? azResult[j] : "");
+ fprintf(p->out, "%s%-*s", zSp, maxlen, azResult[j] ? azResult[j]:"");
}
fprintf(p->out, "\n");
}
@@ -3299,6 +3703,8 @@ static int do_meta_command(char *zLine, ShellState *p){
{ "iskeyword", SQLITE_TESTCTRL_ISKEYWORD },
{ "scratchmalloc", SQLITE_TESTCTRL_SCRATCHMALLOC },
{ "byteorder", SQLITE_TESTCTRL_BYTEORDER },
+ { "never_corrupt", SQLITE_TESTCTRL_NEVER_CORRUPT },
+ { "imposter", SQLITE_TESTCTRL_IMPOSTER },
};
int testctrl = -1;
int rc = 0;
@@ -3365,7 +3771,8 @@ static int do_meta_command(char *zLine, ShellState *p){
/* sqlite3_test_control(int, int) */
case SQLITE_TESTCTRL_ASSERT:
- case SQLITE_TESTCTRL_ALWAYS:
+ case SQLITE_TESTCTRL_ALWAYS:
+ case SQLITE_TESTCTRL_NEVER_CORRUPT:
if( nArg==3 ){
int opt = booleanValue(azArg[2]);
rc = sqlite3_test_control(testctrl, opt);
@@ -3390,6 +3797,18 @@ static int do_meta_command(char *zLine, ShellState *p){
break;
#endif
+ case SQLITE_TESTCTRL_IMPOSTER:
+ if( nArg==5 ){
+ rc = sqlite3_test_control(testctrl, p->db,
+ azArg[2],
+ integerValue(azArg[3]),
+ integerValue(azArg[4]));
+ fprintf(p->out, "%d (0x%08x)\n", rc, rc);
+ }else{
+ fprintf(stderr,"Usage: .testctrl imposter dbName onoff tnum\n");
+ }
+ break;
+
case SQLITE_TESTCTRL_BITVEC_TEST:
case SQLITE_TESTCTRL_FAULT_INSTALL:
case SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS:
@@ -3422,12 +3841,12 @@ static int do_meta_command(char *zLine, ShellState *p){
if( c=='t' && strncmp(azArg[0], "trace", n)==0 ){
open_db(p, 0);
- output_file_close(p->traceOut);
if( nArg!=2 ){
fprintf(stderr, "Usage: .trace FILE|off\n");
rc = 1;
goto meta_command_exit;
}
+ output_file_close(p->traceOut);
p->traceOut = output_file_open(azArg[1]);
#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
if( p->traceOut==0 ){
@@ -3741,7 +4160,8 @@ static char *find_home_dir(void){
static char *home_dir = NULL;
if( home_dir ) return home_dir;
-#if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) && !defined(__RTP__) && !defined(_WRS_KERNEL)
+#if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) \
+ && !defined(__RTP__) && !defined(_WRS_KERNEL)
{
struct passwd *pwent;
uid_t uid = getuid();
@@ -3802,7 +4222,7 @@ static char *find_home_dir(void){
**
** Returns the number of errors.
*/
-static int process_sqliterc(
+static void process_sqliterc(
ShellState *p, /* Configuration data */
const char *sqliterc_override /* Name of config file. NULL to use default */
){
@@ -3810,15 +4230,13 @@ static int process_sqliterc(
const char *sqliterc = sqliterc_override;
char *zBuf = 0;
FILE *in = NULL;
- int rc = 0;
if (sqliterc == NULL) {
home_dir = find_home_dir();
if( home_dir==0 ){
-#if !defined(__RTP__) && !defined(_WRS_KERNEL)
- fprintf(stderr,"%s: Error: cannot locate your home directory\n", Argv0);
-#endif
- return 1;
+ fprintf(stderr, "-- warning: cannot find home directory;"
+ " cannot read ~/.sqliterc\n");
+ return;
}
sqlite3_initialize();
zBuf = sqlite3_mprintf("%s/.sqliterc",home_dir);
@@ -3829,17 +4247,17 @@ static int process_sqliterc(
if( stdin_is_interactive ){
fprintf(stderr,"-- Loading resources from %s\n",sqliterc);
}
- rc = process_input(p,in);
+ process_input(p,in);
fclose(in);
}
sqlite3_free(zBuf);
- return rc;
}
/*
** Show available command line options
*/
static const char zOptions[] =
+ " -ascii set output mode to 'ascii'\n"
" -bail stop after hitting an error\n"
" -batch force batch I/O\n"
" -column set output mode to 'column'\n"
@@ -3861,11 +4279,11 @@ static const char zOptions[] =
#ifdef SQLITE_ENABLE_MULTIPLEX
" -multiplex enable the multiplexor VFS\n"
#endif
- " -newline SEP set newline character(s) for CSV\n"
+ " -newline SEP set output row separator. Default: '\\n'\n"
" -nullvalue TEXT set text string for NULL values. Default ''\n"
" -pagecache SIZE N use N slots of SZ bytes each for page cache memory\n"
" -scratch SIZE N use N slots of SZ bytes each for scratch memory\n"
- " -separator SEP set output field separator. Default: '|'\n"
+ " -separator SEP set output column separator. Default: '|'\n"
" -stats print memory stats before each finalize\n"
" -version show SQLite version\n"
" -vfs NAME use NAME as the default VFS\n"
@@ -3892,8 +4310,8 @@ static void usage(int showDetail){
static void main_init(ShellState *data) {
memset(data, 0, sizeof(*data));
data->mode = MODE_List;
- memcpy(data->separator,"|", 2);
- memcpy(data->newline,"\r\n", 3);
+ memcpy(data->colSeparator,SEP_Column, 2);
+ memcpy(data->rowSeparator,SEP_Row, 2);
data->showHeader = 0;
data->shellFlgs = SHFLG_Lookaside;
sqlite3_config(SQLITE_CONFIG_URI, 1);
@@ -3936,14 +4354,16 @@ static char *cmdline_option_value(int argc, char **argv, int i){
return argv[i];
}
-int main(int argc, char **argv){
+int SQLITE_CDECL main(int argc, char **argv){
char *zErrMsg = 0;
ShellState data;
const char *zInitFile = 0;
- char *zFirstCmd = 0;
int i;
int rc = 0;
int warnInmemoryDb = 0;
+ int readStdin = 1;
+ int nCmd = 0;
+ char **azCmd = 0;
#if USE_SYSTEM_SQLITE+0!=1
if( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)!=0 ){
@@ -3952,6 +4372,8 @@ int main(int argc, char **argv){
exit(1);
}
#endif
+ setBinaryMode(stdin);
+ setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */
Argv0 = argv[0];
main_init(&data);
stdin_is_interactive = isatty(0);
@@ -3963,6 +4385,18 @@ int main(int argc, char **argv){
signal(SIGINT, interrupt_handler);
#endif
+#ifdef SQLITE_SHELL_DBNAME_PROC
+ {
+ /* If the SQLITE_SHELL_DBNAME_PROC macro is defined, then it is the name
+ ** of a C-function that will provide the name of the database file. Use
+ ** this compile-time option to embed this shell program in larger
+ ** applications. */
+ extern void SQLITE_SHELL_DBNAME_PROC(const char**);
+ SQLITE_SHELL_DBNAME_PROC(&data.zDbFilename);
+ warnInmemoryDb = 0;
+ }
+#endif
+
/* Do an initial pass through the command-line argument to locate
** the name of the database file, the name of the initialization file,
** the size of the alternative malloc heap,
@@ -3974,15 +4408,18 @@ int main(int argc, char **argv){
if( z[0]!='-' ){
if( data.zDbFilename==0 ){
data.zDbFilename = z;
- continue;
- }
- if( zFirstCmd==0 ){
- zFirstCmd = z;
- continue;
+ }else{
+ /* Excesss arguments are interpreted as SQL (or dot-commands) and
+ ** mean that nothing is read from stdin */
+ readStdin = 0;
+ nCmd++;
+ azCmd = realloc(azCmd, sizeof(azCmd[0])*nCmd);
+ if( azCmd==0 ){
+ fprintf(stderr, "out of memory\n");
+ exit(1);
+ }
+ azCmd[nCmd-1] = z;
}
- fprintf(stderr,"%s: Error: too many options: \"%s\"\n", Argv0, argv[i]);
- fprintf(stderr,"Use -help for a list of options.\n");
- return 1;
}
if( z[1]=='-' ) z++;
if( strcmp(z,"-separator")==0
@@ -4073,11 +4510,6 @@ int main(int argc, char **argv){
fprintf(stderr,"%s: Error: no database filename specified\n", Argv0);
return 1;
#endif
-#ifdef SQLITE_SHELL_DBNAME_PROC
- { extern void SQLITE_SHELL_DBNAME_PROC(const char**);
- SQLITE_SHELL_DBNAME_PROC(&data.zDbFilename);
- warnInmemoryDb = 0; }
-#endif
}
data.out = stdout;
@@ -4094,10 +4526,7 @@ int main(int argc, char **argv){
** is given on the command line, look for a file named ~/.sqliterc and
** try to process it.
*/
- rc = process_sqliterc(&data,zInitFile);
- if( rc>0 ){
- return rc;
- }
+ process_sqliterc(&data,zInitFile);
/* Make a second pass through the command-line argument and set
** options. This second pass is delayed until after the initialization
@@ -4120,15 +4549,21 @@ int main(int argc, char **argv){
data.mode = MODE_Column;
}else if( strcmp(z,"-csv")==0 ){
data.mode = MODE_Csv;
- memcpy(data.separator,",",2);
+ memcpy(data.colSeparator,",",2);
+ }else if( strcmp(z,"-ascii")==0 ){
+ data.mode = MODE_Ascii;
+ sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,
+ SEP_Unit);
+ sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator,
+ SEP_Record);
}else if( strcmp(z,"-separator")==0 ){
- sqlite3_snprintf(sizeof(data.separator), data.separator,
+ sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,
"%s",cmdline_option_value(argc,argv,++i));
}else if( strcmp(z,"-newline")==0 ){
- sqlite3_snprintf(sizeof(data.newline), data.newline,
+ sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator,
"%s",cmdline_option_value(argc,argv,++i));
}else if( strcmp(z,"-nullvalue")==0 ){
- sqlite3_snprintf(sizeof(data.nullvalue), data.nullvalue,
+ sqlite3_snprintf(sizeof(data.nullValue), data.nullValue,
"%s",cmdline_option_value(argc,argv,++i));
}else if( strcmp(z,"-header")==0 ){
data.showHeader = 1;
@@ -4140,6 +4575,8 @@ int main(int argc, char **argv){
data.autoEQP = 1;
}else if( strcmp(z,"-stats")==0 ){
data.statsOn = 1;
+ }else if( strcmp(z,"-scanstats")==0 ){
+ data.scanstatsOn = 1;
}else if( strcmp(z,"-bail")==0 ){
bail_on_error = 1;
}else if( strcmp(z,"-version")==0 ){
@@ -4172,6 +4609,10 @@ int main(int argc, char **argv){
}else if( strcmp(z,"-help")==0 ){
usage(1);
}else if( strcmp(z,"-cmd")==0 ){
+ /* Run commands that follow -cmd first and separately from commands
+ ** that simply appear on the command-line. This seems goofy. It would
+ ** be better if all commands ran in the order that they appear. But
+ ** we retain the goofy behavior for historical compatibility. */
if( i==argc-1 ) break;
z = cmdline_option_value(argc,argv,++i);
if( z[0]=='.' ){
@@ -4195,23 +4636,28 @@ int main(int argc, char **argv){
}
}
- if( zFirstCmd ){
- /* Run just the command that follows the database name
+ if( !readStdin ){
+ /* Run all arguments that do not begin with '-' as if they were separate
+ ** command-line inputs, except for the argToSkip argument which contains
+ ** the database filename.
*/
- if( zFirstCmd[0]=='.' ){
- rc = do_meta_command(zFirstCmd, &data);
- if( rc==2 ) rc = 0;
- }else{
- open_db(&data, 0);
- rc = shell_exec(data.db, zFirstCmd, shell_callback, &data, &zErrMsg);
- if( zErrMsg!=0 ){
- fprintf(stderr,"Error: %s\n", zErrMsg);
- return rc!=0 ? rc : 1;
- }else if( rc!=0 ){
- fprintf(stderr,"Error: unable to process SQL \"%s\"\n", zFirstCmd);
- return rc;
+ for(i=0; i<nCmd; i++){
+ if( azCmd[i][0]=='.' ){
+ rc = do_meta_command(azCmd[i], &data);
+ if( rc ) return rc==2 ? 0 : rc;
+ }else{
+ open_db(&data, 0);
+ rc = shell_exec(data.db, azCmd[i], shell_callback, &data, &zErrMsg);
+ if( zErrMsg!=0 ){
+ fprintf(stderr,"Error: %s\n", zErrMsg);
+ return rc!=0 ? rc : 1;
+ }else if( rc!=0 ){
+ fprintf(stderr,"Error: unable to process SQL: %s\n", azCmd[i]);
+ return rc;
+ }
}
}
+ free(azCmd);
}else{
/* Run commands received from standard input
*/
@@ -4237,13 +4683,11 @@ int main(int argc, char **argv){
sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
}
}
-#if defined(HAVE_READLINE)
- if( zHistory ) read_history(zHistory);
-#endif
+ if( zHistory ) shell_read_history(zHistory);
rc = process_input(&data, 0);
if( zHistory ){
- stifle_history(100);
- write_history(zHistory);
+ shell_stifle_history(100);
+ shell_write_history(zHistory);
free(zHistory);
}
}else{
diff --git a/contrib/sqlite3/sqlite3.1 b/contrib/sqlite3/sqlite3.1
index 02df7f4..80353b0 100644
--- a/contrib/sqlite3/sqlite3.1
+++ b/contrib/sqlite3/sqlite3.1
@@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
-.TH SQLITE3 1 "Mon Jan 31 11:14:00 2014"
+.TH SQLITE3 1 "Fri Oct 31 10:41:31 EDT 2014"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@@ -49,7 +49,7 @@ a table named "memos" and insert a couple of records into that table:
$
.B sqlite3 mydata.db
.br
-SQLite version 3.8.3
+SQLite version 3.8.8
.br
Enter ".help" for instructions
.br
@@ -107,26 +107,29 @@ the '.help' command. For example:
sqlite>
.B .help
.nf
-.cc |
-.backup ?DB? FILE Backup DB (default "main") to FILE
-.bail ON|OFF Stop after hitting an error. Default OFF
-.databases List names and files of attached databases
-.dump ?TABLE? ... Dump the database in an SQL text format
+.tr %.
+%backup ?DB? FILE Backup DB (default "main") to FILE
+%bail on|off Stop after hitting an error. Default OFF
+%clone NEWDB Clone data into NEWDB from the existing database
+%databases List names and files of attached databases
+%dump ?TABLE? ... Dump the database in an SQL text format
If TABLE specified, only dump tables matching
LIKE pattern TABLE.
-.echo ON|OFF Turn command echo on or off
-.exit Exit this program
-.explain ?ON|OFF? Turn output mode suitable for EXPLAIN on or off.
+%echo on|off Turn command echo on or off
+%eqp on|off Enable or disable automatic EXPLAIN QUERY PLAN
+%exit Exit this program
+%explain ?on|off? Turn output mode suitable for EXPLAIN on or off.
With no args, it turns EXPLAIN on.
-.header(s) ON|OFF Turn display of headers on or off
-.help Show this message
-.import FILE TABLE Import data from FILE into TABLE
-.indices ?TABLE? Show names of all indices
+%fullschema Show schema and the content of sqlite_stat tables
+%headers on|off Turn display of headers on or off
+%help Show this message
+%import FILE TABLE Import data from FILE into TABLE
+%indices ?TABLE? Show names of all indices
If TABLE specified, only show indices for tables
matching LIKE pattern TABLE.
-.load FILE ?ENTRY? Load an extension library
-.log FILE|off Turn logging on or off. FILE can be stderr/stdout
-.mode MODE ?TABLE? Set output mode where MODE is one of:
+%load FILE ?ENTRY? Load an extension library
+%log FILE|off Turn logging on or off. FILE can be stderr/stdout
+%mode MODE ?TABLE? Set output mode where MODE is one of:
csv Comma-separated values
column Left-aligned columns. (See .width)
html HTML <table> code
@@ -135,31 +138,35 @@ sqlite>
list Values delimited by .separator string
tabs Tab-separated values
tcl TCL list elements
-.nullvalue STRING Use STRING in place of NULL values
-.open ?FILENAME? Close existing database and reopen FILENAME
-.output FILENAME Send output to FILENAME
-.output stdout Send output to the screen
-.print STRING... Print literal STRING
-.prompt MAIN CONTINUE Replace the standard prompts
-.quit Exit this program
-.read FILENAME Execute SQL in FILENAME
-.restore ?DB? FILE Restore content of DB (default "main") from FILE
-.schema ?TABLE? Show the CREATE statements
+%nullvalue STRING Use STRING in place of NULL values
+%once FILENAME Output for the next SQL command only to FILENAME
+%open ?FILENAME? Close existing database and reopen FILENAME
+%output ?FILENAME? Send output to FILENAME or stdout
+%print STRING... Print literal STRING
+%prompt MAIN CONTINUE Replace the standard prompts
+%quit Exit this program
+%read FILENAME Execute SQL in FILENAME
+%restore ?DB? FILE Restore content of DB (default "main") from FILE
+%save FILE Write in-memory database into FILE
+%schema ?TABLE? Show the CREATE statements
If TABLE specified, only show tables matching
LIKE pattern TABLE.
-.separator STRING Change separator used by output mode and .import
-.show Show the current values for various settings
-.stats ON|OFF Turn stats on or off
-.tables ?TABLE? List names of tables
+%separator STRING ?NL? Change separator used by output mode and .import
+ NL is the end-of-line mark for CSV
+%shell CMD ARGS... Run CMD ARGS... in a system shell
+%show Show the current values for various settings
+%stats on|off Turn stats on or off
+%system CMD ARGS... Run CMD ARGS... in a system shell
+%tables ?TABLE? List names of tables
If TABLE specified, only list tables matching
LIKE pattern TABLE.
-.timeout MS Try opening locked tables for MS milliseconds
-.trace FILE|off Output each SQL statement as it is run
-.vfsname ?AUX? Print the name of the VFS stack
-.width NUM1 NUM2 ... Set column widths for "column" mode
-.timer ON|OFF Turn the CPU timer measurement on or off
+%timeout MS Try opening locked tables for MS milliseconds
+%timer on|off Turn SQL timer on or off
+%trace FILE|off Output each SQL statement as it is run
+%vfsname ?AUX? Print the name of the VFS stack
+%width NUM1 NUM2 ... Set column widths for "column" mode
+ Negative values right-justify
sqlite>
-|cc .
.sp
.fi
.SH OPTIONS
@@ -269,7 +276,7 @@ o If the -init option is present, the specified file is processed.
o All other command line options are processed.
.SH SEE ALSO
-http://www.sqlite.org/
+http://www.sqlite.org/cli.html
.br
The sqlite3-doc package.
.SH AUTHOR
diff --git a/contrib/sqlite3/sqlite3.c b/contrib/sqlite3/sqlite3.c
index 9a8a0ea..a8922e4 100644
--- a/contrib/sqlite3/sqlite3.c
+++ b/contrib/sqlite3/sqlite3.c
@@ -1,6 +1,6 @@
/******************************************************************************
** This file is an amalgamation of many separate C source files from SQLite
-** version 3.8.7.2. By combining all the individual C code files into this
+** version 3.8.9. By combining all the individual C code files into this
** single large file, the entire code can be compiled as a single translation
** unit. This allows many compilers to do optimizations that would not be
** possible if the files were compiled separately. Performance improvements
@@ -22,9 +22,6 @@
#ifndef SQLITE_PRIVATE
# define SQLITE_PRIVATE static
#endif
-#ifndef SQLITE_API
-# define SQLITE_API
-#endif
/************** Begin file sqliteInt.h ***************************************/
/*
** 2001 September 15
@@ -44,6 +41,91 @@
#define _SQLITEINT_H_
/*
+** Include the header file used to customize the compiler options for MSVC.
+** This should be done first so that it can successfully prevent spurious
+** compiler warnings due to subsequent content in this file and other files
+** that are included by this file.
+*/
+/************** Include msvc.h in the middle of sqliteInt.h ******************/
+/************** Begin file msvc.h ********************************************/
+/*
+** 2015 January 12
+**
+** The author disclaims copyright to this source code. In place of
+** a legal notice, here is a blessing:
+**
+** May you do good and not evil.
+** May you find forgiveness for yourself and forgive others.
+** May you share freely, never taking more than you give.
+**
+******************************************************************************
+**
+** This file contains code that is specific to MSVC.
+*/
+#ifndef _MSVC_H_
+#define _MSVC_H_
+
+#if defined(_MSC_VER)
+#pragma warning(disable : 4054)
+#pragma warning(disable : 4055)
+#pragma warning(disable : 4100)
+#pragma warning(disable : 4127)
+#pragma warning(disable : 4152)
+#pragma warning(disable : 4189)
+#pragma warning(disable : 4206)
+#pragma warning(disable : 4210)
+#pragma warning(disable : 4232)
+#pragma warning(disable : 4244)
+#pragma warning(disable : 4305)
+#pragma warning(disable : 4306)
+#pragma warning(disable : 4702)
+#pragma warning(disable : 4706)
+#endif /* defined(_MSC_VER) */
+
+#endif /* _MSVC_H_ */
+
+/************** End of msvc.h ************************************************/
+/************** Continuing where we left off in sqliteInt.h ******************/
+
+/*
+** Special setup for VxWorks
+*/
+/************** Include vxworks.h in the middle of sqliteInt.h ***************/
+/************** Begin file vxworks.h *****************************************/
+/*
+** 2015-03-02
+**
+** The author disclaims copyright to this source code. In place of
+** a legal notice, here is a blessing:
+**
+** May you do good and not evil.
+** May you find forgiveness for yourself and forgive others.
+** May you share freely, never taking more than you give.
+**
+******************************************************************************
+**
+** This file contains code that is specific to Wind River's VxWorks
+*/
+#if defined(__RTP__) || defined(_WRS_KERNEL)
+/* This is VxWorks. Set up things specially for that OS
+*/
+#include <vxWorks.h>
+#include <pthread.h> /* amalgamator: dontcache */
+#define OS_VXWORKS 1
+#define SQLITE_OS_OTHER 0
+#define SQLITE_HOMEGROWN_RECURSIVE_MUTEX 1
+#define SQLITE_OMIT_LOAD_EXTENSION 1
+#define SQLITE_ENABLE_LOCKING_STYLE 0
+#define HAVE_UTIME 1
+#else
+/* This is not VxWorks. */
+#define OS_VXWORKS 0
+#endif /* defined(_WRS_KERNEL) */
+
+/************** End of vxworks.h *********************************************/
+/************** Continuing where we left off in sqliteInt.h ******************/
+
+/*
** These #defines should enable >2GB file support on POSIX if the
** underlying operating system supports it. If the OS lacks
** large file support, or if the OS is windows, these should be no-ops.
@@ -167,21 +249,25 @@ extern "C" {
/*
-** Add the ability to override 'extern'
+** Provide the ability to override linkage features of the interface.
*/
#ifndef SQLITE_EXTERN
# define SQLITE_EXTERN extern
#endif
-
#ifndef SQLITE_API
# define SQLITE_API
#endif
-
+#ifndef SQLITE_CDECL
+# define SQLITE_CDECL
+#endif
+#ifndef SQLITE_STDCALL
+# define SQLITE_STDCALL
+#endif
/*
** These no-op macros are used in front of interfaces to mark those
** interfaces as either deprecated or experimental. New applications
-** should not use deprecated interfaces - they are support for backwards
+** should not use deprecated interfaces - they are supported for backwards
** compatibility only. Application writers should be aware that
** experimental interfaces are subject to change in point releases.
**
@@ -231,9 +317,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
-#define SQLITE_VERSION "3.8.7.2"
-#define SQLITE_VERSION_NUMBER 3008007
-#define SQLITE_SOURCE_ID "2014-11-18 20:57:56 2ab564bf9655b7c7b97ab85cafc8a48329b27f93"
+#define SQLITE_VERSION "3.8.9"
+#define SQLITE_VERSION_NUMBER 3008009
+#define SQLITE_SOURCE_ID "2015-04-08 12:16:33 8a8ffc862e96f57aa698f93de10dee28e69f6e09"
/*
** CAPI3REF: Run-Time Library Version Numbers
@@ -266,9 +352,9 @@ extern "C" {
** See also: [sqlite_version()] and [sqlite_source_id()].
*/
SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
-SQLITE_API const char *sqlite3_libversion(void);
-SQLITE_API const char *sqlite3_sourceid(void);
-SQLITE_API int sqlite3_libversion_number(void);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void);
+SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void);
/*
** CAPI3REF: Run-Time Library Compilation Options Diagnostics
@@ -293,8 +379,8 @@ SQLITE_API int sqlite3_libversion_number(void);
** [sqlite_compileoption_get()] and the [compile_options pragma].
*/
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
-SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
-SQLITE_API const char *sqlite3_compileoption_get(int N);
+SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N);
#endif
/*
@@ -325,7 +411,7 @@ SQLITE_API const char *sqlite3_compileoption_get(int N);
** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
** can be fully or partially disabled using a call to [sqlite3_config()]
** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
-** or [SQLITE_CONFIG_MUTEX]. ^(The return value of the
+** or [SQLITE_CONFIG_SERIALIZED]. ^(The return value of the
** sqlite3_threadsafe() function shows only the compile-time setting of
** thread safety, not any run-time changes to that setting made by
** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
@@ -333,7 +419,7 @@ SQLITE_API const char *sqlite3_compileoption_get(int N);
**
** See the [threading mode] documentation for additional information.
*/
-SQLITE_API int sqlite3_threadsafe(void);
+SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void);
/*
** CAPI3REF: Database Connection Handle
@@ -429,8 +515,8 @@ typedef sqlite_uint64 sqlite3_uint64;
** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
** argument is a harmless no-op.
*/
-SQLITE_API int sqlite3_close(sqlite3*);
-SQLITE_API int sqlite3_close_v2(sqlite3*);
+SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3*);
+SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3*);
/*
** The type for a callback function.
@@ -500,7 +586,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**);
** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
** </ul>
*/
-SQLITE_API int sqlite3_exec(
+SQLITE_API int SQLITE_STDCALL sqlite3_exec(
sqlite3*, /* An open database */
const char *sql, /* SQL to be evaluated */
int (*callback)(void*,int,char**,char**), /* Callback function */
@@ -880,14 +966,16 @@ struct sqlite3_io_methods {
** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
** interface.
**
+** <ul>
+** <li>[[SQLITE_FCNTL_LOCKSTATE]]
** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This
** opcode causes the xFileControl method to write the current state of
** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
** into an integer that the pArg argument points to. This capability
-** is used during testing and only needs to be supported when SQLITE_TEST
-** is defined.
-** <ul>
+** is used during testing and is only available when the SQLITE_TEST
+** compile-time option is used.
+**
** <li>[[SQLITE_FCNTL_SIZE_HINT]]
** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
** layer a hint of how large the database file will grow to be during the
@@ -1012,7 +1100,9 @@ struct sqlite3_io_methods {
** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA]
** file control returns [SQLITE_OK], then the parser assumes that the
** VFS has handled the PRAGMA itself and the parser generates a no-op
-** prepared statement. ^If the [SQLITE_FCNTL_PRAGMA] file control returns
+** prepared statement if result string is NULL, or that returns a copy
+** of the result string if the string is non-NULL.
+** ^If the [SQLITE_FCNTL_PRAGMA] file control returns
** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
** that the VFS encountered an error while handling the [PRAGMA] and the
** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA]
@@ -1070,12 +1160,19 @@ struct sqlite3_io_methods {
** pointed to by the pArg argument. This capability is used during testing
** and only needs to be supported when SQLITE_TEST is defined.
**
+** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
+** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
+** be advantageous to block on the next WAL lock if the lock is not immediately
+** available. The WAL subsystem issues this signal during rare
+** circumstances in order to fix a problem with priority inversion.
+** Applications should <em>not</em> use this file-control.
+**
** </ul>
*/
#define SQLITE_FCNTL_LOCKSTATE 1
-#define SQLITE_GET_LOCKPROXYFILE 2
-#define SQLITE_SET_LOCKPROXYFILE 3
-#define SQLITE_LAST_ERRNO 4
+#define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
+#define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
+#define SQLITE_FCNTL_LAST_ERRNO 4
#define SQLITE_FCNTL_SIZE_HINT 5
#define SQLITE_FCNTL_CHUNK_SIZE 6
#define SQLITE_FCNTL_FILE_POINTER 7
@@ -1094,6 +1191,13 @@ struct sqlite3_io_methods {
#define SQLITE_FCNTL_SYNC 21
#define SQLITE_FCNTL_COMMIT_PHASETWO 22
#define SQLITE_FCNTL_WIN32_SET_HANDLE 23
+#define SQLITE_FCNTL_WAL_BLOCK 24
+
+/* deprecated names */
+#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
+#define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
+#define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
+
/*
** CAPI3REF: Mutex Handle
@@ -1345,7 +1449,7 @@ struct sqlite3_vfs {
** </ul>
**
** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
-** was given no the corresponding lock.
+** was given on the corresponding lock.
**
** The xShmLock method can transition between unlocked and SHARED or
** between unlocked and EXCLUSIVE. It cannot transition between SHARED
@@ -1442,10 +1546,10 @@ struct sqlite3_vfs {
** must return [SQLITE_OK] on success and some other [error code] upon
** failure.
*/
-SQLITE_API int sqlite3_initialize(void);
-SQLITE_API int sqlite3_shutdown(void);
-SQLITE_API int sqlite3_os_init(void);
-SQLITE_API int sqlite3_os_end(void);
+SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void);
+SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void);
+SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void);
+SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void);
/*
** CAPI3REF: Configuring The SQLite Library
@@ -1476,7 +1580,7 @@ SQLITE_API int sqlite3_os_end(void);
** ^If the option is unknown or SQLite is unable to set the option
** then this routine returns a non-zero [error code].
*/
-SQLITE_API int sqlite3_config(int, ...);
+SQLITE_API int SQLITE_CDECL sqlite3_config(int, ...);
/*
** CAPI3REF: Configure database connections
@@ -1494,7 +1598,7 @@ SQLITE_API int sqlite3_config(int, ...);
** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
** the call is considered successful.
*/
-SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
+SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3*, int op, ...);
/*
** CAPI3REF: Memory Allocation Routines
@@ -1628,31 +1732,33 @@ struct sqlite3_mem_methods {
** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
**
** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>
-** <dd> ^(This option takes a single argument which is a pointer to an
-** instance of the [sqlite3_mem_methods] structure. The argument specifies
+** <dd> ^(The SQLITE_CONFIG_MALLOC option takes a single argument which is
+** a pointer to an instance of the [sqlite3_mem_methods] structure.
+** The argument specifies
** alternative low-level memory allocation routines to be used in place of
** the memory allocation routines built into SQLite.)^ ^SQLite makes
** its own private copy of the content of the [sqlite3_mem_methods] structure
** before the [sqlite3_config()] call returns.</dd>
**
** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>
-** <dd> ^(This option takes a single argument which is a pointer to an
-** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods]
+** <dd> ^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which
+** is a pointer to an instance of the [sqlite3_mem_methods] structure.
+** The [sqlite3_mem_methods]
** structure is filled with the currently defined memory allocation routines.)^
** This option can be used to overload the default memory allocation
** routines with a wrapper that simulations memory allocation failure or
** tracks memory usage, for example. </dd>
**
** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>
-** <dd> ^This option takes single argument of type int, interpreted as a
-** boolean, which enables or disables the collection of memory allocation
-** statistics. ^(When memory allocation statistics are disabled, the
-** following SQLite interfaces become non-operational:
+** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
+** interpreted as a boolean, which enables or disables the collection of
+** memory allocation statistics. ^(When memory allocation statistics are
+** disabled, the following SQLite interfaces become non-operational:
** <ul>
** <li> [sqlite3_memory_used()]
** <li> [sqlite3_memory_highwater()]
** <li> [sqlite3_soft_heap_limit64()]
-** <li> [sqlite3_status()]
+** <li> [sqlite3_status64()]
** </ul>)^
** ^Memory allocation statistics are enabled by default unless SQLite is
** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
@@ -1660,53 +1766,67 @@ struct sqlite3_mem_methods {
** </dd>
**
** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>
-** <dd> ^This option specifies a static memory buffer that SQLite can use for
-** scratch memory. There are three arguments: A pointer an 8-byte
+** <dd> ^The SQLITE_CONFIG_SCRATCH option specifies a static memory buffer
+** that SQLite can use for scratch memory. ^(There are three arguments
+** to SQLITE_CONFIG_SCRATCH: A pointer an 8-byte
** aligned memory buffer from which the scratch allocations will be
** drawn, the size of each scratch allocation (sz),
-** and the maximum number of scratch allocations (N). The sz
-** argument must be a multiple of 16.
+** and the maximum number of scratch allocations (N).)^
** The first argument must be a pointer to an 8-byte aligned buffer
** of at least sz*N bytes of memory.
-** ^SQLite will use no more than two scratch buffers per thread. So
-** N should be set to twice the expected maximum number of threads.
-** ^SQLite will never require a scratch buffer that is more than 6
-** times the database page size. ^If SQLite needs needs additional
+** ^SQLite will not use more than one scratch buffers per thread.
+** ^SQLite will never request a scratch buffer that is more than 6
+** times the database page size.
+** ^If SQLite needs needs additional
** scratch memory beyond what is provided by this configuration option, then
-** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
+** [sqlite3_malloc()] will be used to obtain the memory needed.<p>
+** ^When the application provides any amount of scratch memory using
+** SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary large
+** [sqlite3_malloc|heap allocations].
+** This can help [Robson proof|prevent memory allocation failures] due to heap
+** fragmentation in low-memory embedded systems.
+** </dd>
**
** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
-** <dd> ^This option specifies a static memory buffer that SQLite can use for
-** the database page cache with the default page cache implementation.
+** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a static memory buffer
+** that SQLite can use for the database page cache with the default page
+** cache implementation.
** This configuration should not be used if an application-define page
-** cache implementation is loaded using the SQLITE_CONFIG_PCACHE2 option.
-** There are three arguments to this option: A pointer to 8-byte aligned
+** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2]
+** configuration option.
+** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
+** 8-byte aligned
** memory, the size of each page buffer (sz), and the number of pages (N).
** The sz argument should be the size of the largest database page
-** (a power of two between 512 and 32768) plus a little extra for each
-** page header. ^The page header size is 20 to 40 bytes depending on
-** the host architecture. ^It is harmless, apart from the wasted memory,
-** to make sz a little too large. The first
-** argument should point to an allocation of at least sz*N bytes of memory.
+** (a power of two between 512 and 65536) plus some extra bytes for each
+** page header. ^The number of extra bytes needed by the page header
+** can be determined using the [SQLITE_CONFIG_PCACHE_HDRSZ] option
+** to [sqlite3_config()].
+** ^It is harmless, apart from the wasted memory,
+** for the sz parameter to be larger than necessary. The first
+** argument should pointer to an 8-byte aligned block of memory that
+** is at least sz*N bytes of memory, otherwise subsequent behavior is
+** undefined.
** ^SQLite will use the memory provided by the first argument to satisfy its
** memory needs for the first N pages that it adds to cache. ^If additional
** page cache memory is needed beyond what is provided by this option, then
-** SQLite goes to [sqlite3_malloc()] for the additional storage space.
-** The pointer in the first argument must
-** be aligned to an 8-byte boundary or subsequent behavior of SQLite
-** will be undefined.</dd>
+** SQLite goes to [sqlite3_malloc()] for the additional storage space.</dd>
**
** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>
-** <dd> ^This option specifies a static memory buffer that SQLite will use
-** for all of its dynamic memory allocation needs beyond those provided
-** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
-** There are three arguments: An 8-byte aligned pointer to the memory,
+** <dd> ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer
+** that SQLite will use for all of its dynamic memory allocation needs
+** beyond those provided for by [SQLITE_CONFIG_SCRATCH] and
+** [SQLITE_CONFIG_PAGECACHE].
+** ^The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled
+** with either [SQLITE_ENABLE_MEMSYS3] or [SQLITE_ENABLE_MEMSYS5] and returns
+** [SQLITE_ERROR] if invoked otherwise.
+** ^There are three arguments to SQLITE_CONFIG_HEAP:
+** An 8-byte aligned pointer to the memory,
** the number of bytes in the memory buffer, and the minimum allocation size.
** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
** to using its default memory allocator (the system malloc() implementation),
** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the
-** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
-** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
+** memory pointer is not NULL then the alternative memory
** allocator is engaged to handle all of SQLites memory allocation needs.
** The first pointer (the memory pointer) must be aligned to an 8-byte
** boundary or subsequent behavior of SQLite will be undefined.
@@ -1714,11 +1834,11 @@ struct sqlite3_mem_methods {
** for the minimum allocation size are 2**5 through 2**8.</dd>
**
** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>
-** <dd> ^(This option takes a single argument which is a pointer to an
-** instance of the [sqlite3_mutex_methods] structure. The argument specifies
-** alternative low-level mutex routines to be used in place
-** the mutex routines built into SQLite.)^ ^SQLite makes a copy of the
-** content of the [sqlite3_mutex_methods] structure before the call to
+** <dd> ^(The SQLITE_CONFIG_MUTEX option takes a single argument which is a
+** pointer to an instance of the [sqlite3_mutex_methods] structure.
+** The argument specifies alternative low-level mutex routines to be used
+** in place the mutex routines built into SQLite.)^ ^SQLite makes a copy of
+** the content of the [sqlite3_mutex_methods] structure before the call to
** [sqlite3_config()] returns. ^If SQLite is compiled with
** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
** the entire mutexing subsystem is omitted from the build and hence calls to
@@ -1726,8 +1846,8 @@ struct sqlite3_mem_methods {
** return [SQLITE_ERROR].</dd>
**
** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>
-** <dd> ^(This option takes a single argument which is a pointer to an
-** instance of the [sqlite3_mutex_methods] structure. The
+** <dd> ^(The SQLITE_CONFIG_GETMUTEX option takes a single argument which
+** is a pointer to an instance of the [sqlite3_mutex_methods] structure. The
** [sqlite3_mutex_methods]
** structure is filled with the currently defined mutex routines.)^
** This option can be used to overload the default mutex allocation
@@ -1739,25 +1859,25 @@ struct sqlite3_mem_methods {
** return [SQLITE_ERROR].</dd>
**
** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
-** <dd> ^(This option takes two arguments that determine the default
-** memory allocation for the lookaside memory allocator on each
-** [database connection]. The first argument is the
+** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
+** the default size of lookaside memory on each [database connection].
+** The first argument is the
** size of each lookaside buffer slot and the second is the number of
-** slots allocated to each database connection.)^ ^(This option sets the
-** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
-** verb to [sqlite3_db_config()] can be used to change the lookaside
+** slots allocated to each database connection.)^ ^(SQLITE_CONFIG_LOOKASIDE
+** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
+** option to [sqlite3_db_config()] can be used to change the lookaside
** configuration on individual connections.)^ </dd>
**
** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
-** <dd> ^(This option takes a single argument which is a pointer to
-** an [sqlite3_pcache_methods2] object. This object specifies the interface
-** to a custom page cache implementation.)^ ^SQLite makes a copy of the
-** object and uses it for page cache memory allocations.</dd>
+** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is
+** a pointer to an [sqlite3_pcache_methods2] object. This object specifies
+** the interface to a custom page cache implementation.)^
+** ^SQLite makes a copy of the [sqlite3_pcache_methods2] object.</dd>
**
** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>
-** <dd> ^(This option takes a single argument which is a pointer to an
-** [sqlite3_pcache_methods2] object. SQLite copies of the current
-** page cache implementation into that object.)^ </dd>
+** <dd> ^(The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which
+** is a pointer to an [sqlite3_pcache_methods2] object. SQLite copies of
+** the current page cache implementation into that object.)^ </dd>
**
** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>
** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite
@@ -1780,10 +1900,11 @@ struct sqlite3_mem_methods {
** function must be threadsafe. </dd>
**
** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
-** <dd>^(This option takes a single argument of type int. If non-zero, then
-** URI handling is globally enabled. If the parameter is zero, then URI handling
-** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
-** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
+** <dd>^(The SQLITE_CONFIG_URI option takes a single argument of type int.
+** If non-zero, then URI handling is globally enabled. If the parameter is zero,
+** then URI handling is globally disabled.)^ ^If URI handling is globally
+** enabled, all filenames passed to [sqlite3_open()], [sqlite3_open_v2()],
+** [sqlite3_open16()] or
** specified as part of [ATTACH] commands are interpreted as URIs, regardless
** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
** connection is opened. ^If it is globally disabled, filenames are
@@ -1793,9 +1914,10 @@ struct sqlite3_mem_methods {
** [SQLITE_USE_URI] symbol defined.)^
**
** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
-** <dd>^This option takes a single integer argument which is interpreted as
-** a boolean in order to enable or disable the use of covering indices for
-** full table scans in the query optimizer. ^The default setting is determined
+** <dd>^The SQLITE_CONFIG_COVERING_INDEX_SCAN option takes a single integer
+** argument which is interpreted as a boolean in order to enable or disable
+** the use of covering indices for full table scans in the query optimizer.
+** ^The default setting is determined
** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
** if that compile-time option is omitted.
** The ability to disable the use of covering indices for full table scans
@@ -1835,18 +1957,37 @@ struct sqlite3_mem_methods {
** ^The default setting can be overridden by each database connection using
** either the [PRAGMA mmap_size] command, or by using the
** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size
-** cannot be changed at run-time. Nor may the maximum allowed mmap size
-** exceed the compile-time maximum mmap size set by the
+** will be silently truncated if necessary so that it does not exceed the
+** compile-time maximum mmap size set by the
** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
** ^If either argument to this option is negative, then that argument is
** changed to its compile-time default.
**
** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]
** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
-** <dd>^This option is only available if SQLite is compiled for Windows
-** with the [SQLITE_WIN32_MALLOC] pre-processor macro defined.
-** SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
+** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is
+** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro
+** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
** that specifies the maximum size of the created heap.
+**
+** [[SQLITE_CONFIG_PCACHE_HDRSZ]]
+** <dt>SQLITE_CONFIG_PCACHE_HDRSZ
+** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which
+** is a pointer to an integer and writes into that integer the number of extra
+** bytes per page required for each page in [SQLITE_CONFIG_PAGECACHE].
+** The amount of extra space required can change depending on the compiler,
+** target platform, and SQLite version.
+**
+** [[SQLITE_CONFIG_PMASZ]]
+** <dt>SQLITE_CONFIG_PMASZ
+** <dd>^The SQLITE_CONFIG_PMASZ option takes a single parameter which
+** is an unsigned integer and sets the "Minimum PMA Size" for the multithreaded
+** sorter to that integer. The default minimum PMA Size is set by the
+** [SQLITE_SORTER_PMASZ] compile-time option. New threads are launched
+** to help with sort operations when multithreaded sorting
+** is enabled (using the [PRAGMA threads] command) and the amount of content
+** to be sorted exceeds the page size times the minimum of the
+** [PRAGMA cache_size] setting and this value.
** </dl>
*/
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
@@ -1872,6 +2013,8 @@ struct sqlite3_mem_methods {
#define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
#define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */
#define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */
+#define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */
+#define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */
/*
** CAPI3REF: Database Connection Configuration Options
@@ -1943,7 +2086,7 @@ struct sqlite3_mem_methods {
** [extended result codes] feature of SQLite. ^The extended result
** codes are disabled by default for historical compatibility.
*/
-SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3*, int onoff);
/*
** CAPI3REF: Last Insert Rowid
@@ -1994,52 +2137,50 @@ SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
** unpredictable and might not equal either the old or the new
** last insert [rowid].
*/
-SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3*);
/*
** CAPI3REF: Count The Number Of Rows Modified
**
-** ^This function returns the number of database rows that were changed
-** or inserted or deleted by the most recently completed SQL statement
-** on the [database connection] specified by the first parameter.
-** ^(Only changes that are directly specified by the [INSERT], [UPDATE],
-** or [DELETE] statement are counted. Auxiliary changes caused by
-** triggers or [foreign key actions] are not counted.)^ Use the
-** [sqlite3_total_changes()] function to find the total number of changes
-** including changes caused by triggers and foreign key actions.
-**
-** ^Changes to a view that are simulated by an [INSTEAD OF trigger]
-** are not counted. Only real table changes are counted.
-**
-** ^(A "row change" is a change to a single row of a single table
-** caused by an INSERT, DELETE, or UPDATE statement. Rows that
-** are changed as side effects of [REPLACE] constraint resolution,
-** rollback, ABORT processing, [DROP TABLE], or by any other
-** mechanisms do not count as direct row changes.)^
-**
-** A "trigger context" is a scope of execution that begins and
-** ends with the script of a [CREATE TRIGGER | trigger].
-** Most SQL statements are
-** evaluated outside of any trigger. This is the "top level"
-** trigger context. If a trigger fires from the top level, a
-** new trigger context is entered for the duration of that one
-** trigger. Subtriggers create subcontexts for their duration.
-**
-** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
-** not create a new trigger context.
-**
-** ^This function returns the number of direct row changes in the
-** most recent INSERT, UPDATE, or DELETE statement within the same
-** trigger context.
-**
-** ^Thus, when called from the top level, this function returns the
-** number of changes in the most recent INSERT, UPDATE, or DELETE
-** that also occurred at the top level. ^(Within the body of a trigger,
-** the sqlite3_changes() interface can be called to find the number of
-** changes in the most recently completed INSERT, UPDATE, or DELETE
-** statement within the body of the same trigger.
-** However, the number returned does not include changes
-** caused by subtriggers since those have their own context.)^
+** ^This function returns the number of rows modified, inserted or
+** deleted by the most recently completed INSERT, UPDATE or DELETE
+** statement on the database connection specified by the only parameter.
+** ^Executing any other type of SQL statement does not modify the value
+** returned by this function.
+**
+** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
+** considered - auxiliary changes caused by [CREATE TRIGGER | triggers],
+** [foreign key actions] or [REPLACE] constraint resolution are not counted.
+**
+** Changes to a view that are intercepted by
+** [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value
+** returned by sqlite3_changes() immediately after an INSERT, UPDATE or
+** DELETE statement run on a view is always zero. Only changes made to real
+** tables are counted.
+**
+** Things are more complicated if the sqlite3_changes() function is
+** executed while a trigger program is running. This may happen if the
+** program uses the [changes() SQL function], or if some other callback
+** function invokes sqlite3_changes() directly. Essentially:
+**
+** <ul>
+** <li> ^(Before entering a trigger program the value returned by
+** sqlite3_changes() function is saved. After the trigger program
+** has finished, the original value is restored.)^
+**
+** <li> ^(Within a trigger program each INSERT, UPDATE and DELETE
+** statement sets the value returned by sqlite3_changes()
+** upon completion as normal. Of course, this value will not include
+** any changes performed by sub-triggers, as the sqlite3_changes()
+** value will be saved and restored after each sub-trigger has run.)^
+** </ul>
+**
+** ^This means that if the changes() SQL function (or similar) is used
+** by the first INSERT, UPDATE or DELETE statement within a trigger, it
+** returns the value as set when the calling statement began executing.
+** ^If it is used by the second or subsequent such statement within a trigger
+** program, the value returned reflects the number of rows modified by the
+** previous INSERT, UPDATE or DELETE statement within the same trigger.
**
** See also the [sqlite3_total_changes()] interface, the
** [count_changes pragma], and the [changes() SQL function].
@@ -2048,25 +2189,22 @@ SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
** while [sqlite3_changes()] is running then the value returned
** is unpredictable and not meaningful.
*/
-SQLITE_API int sqlite3_changes(sqlite3*);
+SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3*);
/*
** CAPI3REF: Total Number Of Rows Modified
**
-** ^This function returns the number of row changes caused by [INSERT],
-** [UPDATE] or [DELETE] statements since the [database connection] was opened.
-** ^(The count returned by sqlite3_total_changes() includes all changes
-** from all [CREATE TRIGGER | trigger] contexts and changes made by
-** [foreign key actions]. However,
-** the count does not include changes used to implement [REPLACE] constraints,
-** do rollbacks or ABORT processing, or [DROP TABLE] processing. The
-** count does not include rows of views that fire an [INSTEAD OF trigger],
-** though if the INSTEAD OF trigger makes changes of its own, those changes
-** are counted.)^
-** ^The sqlite3_total_changes() function counts the changes as soon as
-** the statement that makes them is completed (when the statement handle
-** is passed to [sqlite3_reset()] or [sqlite3_finalize()]).
-**
+** ^This function returns the total number of rows inserted, modified or
+** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
+** since the database connection was opened, including those executed as
+** part of trigger programs. ^Executing any other type of SQL statement
+** does not affect the value returned by sqlite3_total_changes().
+**
+** ^Changes made as part of [foreign key actions] are included in the
+** count, but those made as part of REPLACE constraint resolution are
+** not. ^Changes to a view that are intercepted by INSTEAD OF triggers
+** are not counted.
+**
** See also the [sqlite3_changes()] interface, the
** [count_changes pragma], and the [total_changes() SQL function].
**
@@ -2074,7 +2212,7 @@ SQLITE_API int sqlite3_changes(sqlite3*);
** while [sqlite3_total_changes()] is running then the value
** returned is unpredictable and not meaningful.
*/
-SQLITE_API int sqlite3_total_changes(sqlite3*);
+SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3*);
/*
** CAPI3REF: Interrupt A Long-Running Query
@@ -2113,7 +2251,7 @@ SQLITE_API int sqlite3_total_changes(sqlite3*);
** If the database connection closes while [sqlite3_interrupt()]
** is running then bad things will likely happen.
*/
-SQLITE_API void sqlite3_interrupt(sqlite3*);
+SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3*);
/*
** CAPI3REF: Determine If An SQL Statement Is Complete
@@ -2148,11 +2286,12 @@ SQLITE_API void sqlite3_interrupt(sqlite3*);
** The input to [sqlite3_complete16()] must be a zero-terminated
** UTF-16 string in native byte order.
*/
-SQLITE_API int sqlite3_complete(const char *sql);
-SQLITE_API int sqlite3_complete16(const void *sql);
+SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *sql);
+SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *sql);
/*
** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
+** KEYWORDS: {busy-handler callback} {busy handler}
**
** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X
** that might be invoked with argument P whenever
@@ -2169,7 +2308,7 @@ SQLITE_API int sqlite3_complete16(const void *sql);
** ^The first argument to the busy handler is a copy of the void* pointer which
** is the third argument to sqlite3_busy_handler(). ^The second argument to
** the busy handler callback is the number of times that the busy handler has
-** been invoked for the same locking event. ^If the
+** been invoked previously for the same locking event. ^If the
** busy callback returns 0, then no additional attempts are made to
** access the database and [SQLITE_BUSY] is returned
** to the application.
@@ -2208,7 +2347,7 @@ SQLITE_API int sqlite3_complete16(const void *sql);
** A busy handler must not close the database connection
** or [prepared statement] that invoked the busy handler.
*/
-SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
/*
** CAPI3REF: Set A Busy Timeout
@@ -2230,7 +2369,7 @@ SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
**
** See also: [PRAGMA busy_timeout]
*/
-SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3*, int ms);
/*
** CAPI3REF: Convenience Routines For Running Queries
@@ -2304,7 +2443,7 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
** reflected in subsequent calls to [sqlite3_errcode()] or
** [sqlite3_errmsg()].
*/
-SQLITE_API int sqlite3_get_table(
+SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
sqlite3 *db, /* An open database */
const char *zSql, /* SQL to be evaluated */
char ***pazResult, /* Results of the query */
@@ -2312,13 +2451,17 @@ SQLITE_API int sqlite3_get_table(
int *pnColumn, /* Number of result columns written here */
char **pzErrmsg /* Error msg written here */
);
-SQLITE_API void sqlite3_free_table(char **result);
+SQLITE_API void SQLITE_STDCALL sqlite3_free_table(char **result);
/*
** CAPI3REF: Formatted String Printing Functions
**
** These routines are work-alikes of the "printf()" family of functions
** from the standard C library.
+** These routines understand most of the common K&R formatting options,
+** plus some additional non-standard formats, detailed below.
+** Note that some of the more obscure formatting options from recent
+** C-library standards are omitted from this implementation.
**
** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
** results into memory obtained from [sqlite3_malloc()].
@@ -2351,7 +2494,7 @@ SQLITE_API void sqlite3_free_table(char **result);
** These routines all implement some additional formatting
** options that are useful for constructing SQL statements.
** All of the usual printf() formatting options apply. In addition, there
-** is are "%q", "%Q", and "%z" options.
+** is are "%q", "%Q", "%w" and "%z" options.
**
** ^(The %q option works like %s in that it substitutes a nul-terminated
** string from the argument list. But %q also doubles every '\'' character.
@@ -2404,14 +2547,20 @@ SQLITE_API void sqlite3_free_table(char **result);
** The code above will render a correct SQL statement in the zSQL
** variable even if the zText variable is a NULL pointer.
**
+** ^(The "%w" formatting option is like "%q" except that it expects to
+** be contained within double-quotes instead of single quotes, and it
+** escapes the double-quote character instead of the single-quote
+** character.)^ The "%w" formatting option is intended for safely inserting
+** table and column names into a constructed SQL statement.
+**
** ^(The "%z" formatting option works like "%s" but with the
** addition that after the string has been read and copied into
** the result, [sqlite3_free()] is called on the input string.)^
*/
-SQLITE_API char *sqlite3_mprintf(const char*,...);
-SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
-SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
-SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
+SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char*,...);
+SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char*, va_list);
+SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int,char*,const char*, ...);
+SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int,char*,const char*, va_list);
/*
** CAPI3REF: Memory Allocation Subsystem
@@ -2501,12 +2650,12 @@ SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
** a block of memory after it has been released using
** [sqlite3_free()] or [sqlite3_realloc()].
*/
-SQLITE_API void *sqlite3_malloc(int);
-SQLITE_API void *sqlite3_malloc64(sqlite3_uint64);
-SQLITE_API void *sqlite3_realloc(void*, int);
-SQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64);
-SQLITE_API void sqlite3_free(void*);
-SQLITE_API sqlite3_uint64 sqlite3_msize(void*);
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int);
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64);
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void*, int);
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void*, sqlite3_uint64);
+SQLITE_API void SQLITE_STDCALL sqlite3_free(void*);
+SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void*);
/*
** CAPI3REF: Memory Allocator Statistics
@@ -2531,8 +2680,8 @@ SQLITE_API sqlite3_uint64 sqlite3_msize(void*);
** by [sqlite3_memory_highwater(1)] is the high-water mark
** prior to the reset.
*/
-SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
-SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void);
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag);
/*
** CAPI3REF: Pseudo-Random Number Generator
@@ -2544,17 +2693,18 @@ SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
** applications to access the same PRNG for other purposes.
**
** ^A call to this routine stores N bytes of randomness into buffer P.
-** ^If N is less than one, then P can be a NULL pointer.
+** ^The P parameter can be a NULL pointer.
**
** ^If this routine has not been previously called or if the previous
-** call had N less than one, then the PRNG is seeded using randomness
-** obtained from the xRandomness method of the default [sqlite3_vfs] object.
-** ^If the previous call to this routine had an N of 1 or more then
-** the pseudo-randomness is generated
+** call had N less than one or a NULL pointer for P, then the PRNG is
+** seeded using randomness obtained from the xRandomness method of
+** the default [sqlite3_vfs] object.
+** ^If the previous call to this routine had an N of 1 or more and a
+** non-NULL P then the pseudo-randomness is generated
** internally and without recourse to the [sqlite3_vfs] xRandomness
** method.
*/
-SQLITE_API void sqlite3_randomness(int N, void *P);
+SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *P);
/*
** CAPI3REF: Compile-Time Authorization Callbacks
@@ -2636,7 +2786,7 @@ SQLITE_API void sqlite3_randomness(int N, void *P);
** as stated in the previous paragraph, sqlite3_step() invokes
** sqlite3_prepare_v2() to reprepare a statement after a schema change.
*/
-SQLITE_API int sqlite3_set_authorizer(
+SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
sqlite3*,
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
void *pUserData
@@ -2740,8 +2890,8 @@ SQLITE_API int sqlite3_set_authorizer(
** sqlite3_profile() function is considered experimental and is
** subject to change in future versions of SQLite.
*/
-SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
-SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
+SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
+SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
/*
@@ -2775,7 +2925,7 @@ SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
** database connections for the meaning of "modify" in this paragraph.
**
*/
-SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
+SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
/*
** CAPI3REF: Opening A New Database Connection
@@ -3003,15 +3153,15 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
**
** See also: [sqlite3_temp_directory]
*/
-SQLITE_API int sqlite3_open(
+SQLITE_API int SQLITE_STDCALL sqlite3_open(
const char *filename, /* Database filename (UTF-8) */
sqlite3 **ppDb /* OUT: SQLite db handle */
);
-SQLITE_API int sqlite3_open16(
+SQLITE_API int SQLITE_STDCALL sqlite3_open16(
const void *filename, /* Database filename (UTF-16) */
sqlite3 **ppDb /* OUT: SQLite db handle */
);
-SQLITE_API int sqlite3_open_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
const char *filename, /* Database filename (UTF-8) */
sqlite3 **ppDb, /* OUT: SQLite db handle */
int flags, /* Flags */
@@ -3057,19 +3207,21 @@ SQLITE_API int sqlite3_open_v2(
** VFS method, then the behavior of this routine is undefined and probably
** undesirable.
*/
-SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
-SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
-SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam);
+SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
/*
** CAPI3REF: Error Codes And Messages
**
-** ^The sqlite3_errcode() interface returns the numeric [result code] or
-** [extended result code] for the most recent failed sqlite3_* API call
-** associated with a [database connection]. If a prior API call failed
-** but the most recent API call succeeded, the return value from
-** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode()
+** ^If the most recent sqlite3_* API call associated with
+** [database connection] D failed, then the sqlite3_errcode(D) interface
+** returns the numeric [result code] or [extended result code] for that
+** API call.
+** If the most recent API call was successful,
+** then the return value from sqlite3_errcode() is undefined.
+** ^The sqlite3_extended_errcode()
** interface is the same except that it always returns the
** [extended result code] even when extended result codes are
** disabled.
@@ -3100,11 +3252,11 @@ SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int
** was invoked incorrectly by the application. In that case, the
** error code and message may or may not be set.
*/
-SQLITE_API int sqlite3_errcode(sqlite3 *db);
-SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
-SQLITE_API const char *sqlite3_errmsg(sqlite3*);
-SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
-SQLITE_API const char *sqlite3_errstr(int);
+SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db);
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3*);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3*);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int);
/*
** CAPI3REF: SQL Statement Object
@@ -3171,7 +3323,7 @@ typedef struct sqlite3_stmt sqlite3_stmt;
**
** New run-time limit categories may be added in future releases.
*/
-SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
+SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3*, int id, int newVal);
/*
** CAPI3REF: Run-Time Limit Categories
@@ -3258,16 +3410,14 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
** use UTF-16.
**
-** ^If the nByte argument is less than zero, then zSql is read up to the
-** first zero terminator. ^If nByte is non-negative, then it is the maximum
-** number of bytes read from zSql. ^When nByte is non-negative, the
-** zSql string ends at either the first '\000' or '\u0000' character or
-** the nByte-th byte, whichever comes first. If the caller knows
-** that the supplied string is nul-terminated, then there is a small
-** performance advantage to be gained by passing an nByte parameter that
-** is equal to the number of bytes in the input string <i>including</i>
-** the nul-terminator bytes as this saves SQLite from having to
-** make a copy of the input string.
+** ^If the nByte argument is negative, then zSql is read up to the
+** first zero terminator. ^If nByte is positive, then it is the
+** number of bytes read from zSql. ^If nByte is zero, then no prepared
+** statement is generated.
+** If the caller knows that the supplied string is nul-terminated, then
+** there is a small performance advantage to passing an nByte parameter that
+** is the number of bytes in the input string <i>including</i>
+** the nul-terminator.
**
** ^If pzTail is not NULL then *pzTail is made to point to the first byte
** past the end of the first SQL statement in zSql. These routines only
@@ -3323,28 +3473,28 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
** </li>
** </ol>
*/
-SQLITE_API int sqlite3_prepare(
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
sqlite3 *db, /* Database handle */
const char *zSql, /* SQL statement, UTF-8 encoded */
int nByte, /* Maximum length of zSql in bytes. */
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
const char **pzTail /* OUT: Pointer to unused portion of zSql */
);
-SQLITE_API int sqlite3_prepare_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
sqlite3 *db, /* Database handle */
const char *zSql, /* SQL statement, UTF-8 encoded */
int nByte, /* Maximum length of zSql in bytes. */
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
const char **pzTail /* OUT: Pointer to unused portion of zSql */
);
-SQLITE_API int sqlite3_prepare16(
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
sqlite3 *db, /* Database handle */
const void *zSql, /* SQL statement, UTF-16 encoded */
int nByte, /* Maximum length of zSql in bytes. */
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
const void **pzTail /* OUT: Pointer to unused portion of zSql */
);
-SQLITE_API int sqlite3_prepare16_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
sqlite3 *db, /* Database handle */
const void *zSql, /* SQL statement, UTF-16 encoded */
int nByte, /* Maximum length of zSql in bytes. */
@@ -3359,7 +3509,7 @@ SQLITE_API int sqlite3_prepare16_v2(
** SQL text used to create a [prepared statement] if that statement was
** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
*/
-SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
/*
** CAPI3REF: Determine If An SQL Statement Writes The Database
@@ -3390,7 +3540,7 @@ SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
** change the configuration of a database connection, they do not make
** changes to the content of the database files on disk.
*/
-SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
/*
** CAPI3REF: Determine If A Prepared Statement Has Been Reset
@@ -3409,7 +3559,7 @@ SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
** for example, in diagnostic routines to search for prepared
** statements that are holding a transaction open.
*/
-SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt*);
/*
** CAPI3REF: Dynamically Typed Value Object
@@ -3570,19 +3720,19 @@ typedef struct sqlite3_context sqlite3_context;
** See also: [sqlite3_bind_parameter_count()],
** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
*/
-SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
-SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
void(*)(void*));
-SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
-SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
-SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
-SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
-SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
-SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
-SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt*, int, double);
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt*, int, int);
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt*, int);
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
void(*)(void*), unsigned char encoding);
-SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
-SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
/*
** CAPI3REF: Number Of SQL Parameters
@@ -3602,7 +3752,7 @@ SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
** [sqlite3_bind_parameter_name()], and
** [sqlite3_bind_parameter_index()].
*/
-SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt*);
/*
** CAPI3REF: Name Of A Host Parameter
@@ -3629,7 +3779,7 @@ SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
** [sqlite3_bind_parameter_count()], and
** [sqlite3_bind_parameter_index()].
*/
-SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt*, int);
/*
** CAPI3REF: Index Of A Parameter With A Given Name
@@ -3645,7 +3795,7 @@ SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
** [sqlite3_bind_parameter_count()], and
** [sqlite3_bind_parameter_index()].
*/
-SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
/*
** CAPI3REF: Reset All Bindings On A Prepared Statement
@@ -3654,7 +3804,7 @@ SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
** the [sqlite3_bind_blob | bindings] on a [prepared statement].
** ^Use this routine to reset all host parameters to NULL.
*/
-SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
+SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt*);
/*
** CAPI3REF: Number Of Columns In A Result Set
@@ -3665,7 +3815,7 @@ SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
**
** See also: [sqlite3_data_count()]
*/
-SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
+SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt);
/*
** CAPI3REF: Column Names In A Result Set
@@ -3693,8 +3843,8 @@ SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
** then the name of the column is unspecified and may change from
** one release of SQLite to the next.
*/
-SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
-SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt*, int N);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt*, int N);
/*
** CAPI3REF: Source Of Data In A Query Result
@@ -3741,12 +3891,12 @@ SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
** for the same [prepared statement] and result column
** at the same time then the results are undefined.
*/
-SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
-SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
-SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
-SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
-SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
-SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt*,int);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt*,int);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt*,int);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt*,int);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt*,int);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt*,int);
/*
** CAPI3REF: Declared Datatype Of A Query Result
@@ -3777,8 +3927,8 @@ SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
** is associated with individual values, not with the containers
** used to hold those values.
*/
-SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
-SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt*,int);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt*,int);
/*
** CAPI3REF: Evaluate An SQL Statement
@@ -3857,7 +4007,7 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
** then the more specific [error codes] are returned directly
** by sqlite3_step(). The use of the "v2" interface is recommended.
*/
-SQLITE_API int sqlite3_step(sqlite3_stmt*);
+SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt*);
/*
** CAPI3REF: Number of columns in a result set
@@ -3877,7 +4027,7 @@ SQLITE_API int sqlite3_step(sqlite3_stmt*);
**
** See also: [sqlite3_column_count()]
*/
-SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
+SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt);
/*
** CAPI3REF: Fundamental Datatypes
@@ -4073,16 +4223,16 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** pointer. Subsequent calls to [sqlite3_errcode()] will return
** [SQLITE_NOMEM].)^
*/
-SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
-SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
-SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
-SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
-SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
-SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
-SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
-SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
-SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
-SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt*, int iCol);
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol);
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
+SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt*, int iCol);
+SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt*, int iCol);
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt*, int iCol);
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt*, int iCol);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt*, int iCol);
+SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt*, int iCol);
+SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt*, int iCol);
/*
** CAPI3REF: Destroy A Prepared Statement Object
@@ -4109,7 +4259,7 @@ SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
** statement after it has been finalized can result in undefined and
** undesirable behavior such as segfaults and heap corruption.
*/
-SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
+SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt);
/*
** CAPI3REF: Reset A Prepared Statement Object
@@ -4135,7 +4285,7 @@ SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
** ^The [sqlite3_reset(S)] interface does not change the values
** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
*/
-SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
+SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt);
/*
** CAPI3REF: Create Or Redefine SQL Functions
@@ -4234,7 +4384,7 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
** close the database connection nor finalize or reset the prepared
** statement in which the function is running.
*/
-SQLITE_API int sqlite3_create_function(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
sqlite3 *db,
const char *zFunctionName,
int nArg,
@@ -4244,7 +4394,7 @@ SQLITE_API int sqlite3_create_function(
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*)
);
-SQLITE_API int sqlite3_create_function16(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
sqlite3 *db,
const void *zFunctionName,
int nArg,
@@ -4254,7 +4404,7 @@ SQLITE_API int sqlite3_create_function16(
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*)
);
-SQLITE_API int sqlite3_create_function_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
sqlite3 *db,
const char *zFunctionName,
int nArg,
@@ -4272,9 +4422,9 @@ SQLITE_API int sqlite3_create_function_v2(
** These constant define integer codes that represent the various
** text encodings supported by SQLite.
*/
-#define SQLITE_UTF8 1
-#define SQLITE_UTF16LE 2
-#define SQLITE_UTF16BE 3
+#define SQLITE_UTF8 1 /* IMP: R-37514-35566 */
+#define SQLITE_UTF16LE 2 /* IMP: R-03371-37637 */
+#define SQLITE_UTF16BE 3 /* IMP: R-51971-34154 */
#define SQLITE_UTF16 4 /* Use native byte order */
#define SQLITE_ANY 5 /* Deprecated */
#define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */
@@ -4296,16 +4446,16 @@ SQLITE_API int sqlite3_create_function_v2(
** These functions are [deprecated]. In order to maintain
** backwards compatibility with older code, these functions continue
** to be supported. However, new applications should avoid
-** the use of these functions. To help encourage people to avoid
-** using these functions, we are not going to tell you what they do.
+** the use of these functions. To encourage programmers to avoid
+** these functions, we will not explain what they do.
*/
#ifndef SQLITE_OMIT_DEPRECATED
-SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
-SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
-SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
-SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
-SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
-SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*);
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*);
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_global_recover(void);
+SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_thread_cleanup(void);
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
void*,sqlite3_int64);
#endif
@@ -4354,18 +4504,18 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
** These routines must be called from the same thread as
** the SQL function that supplied the [sqlite3_value*] parameters.
*/
-SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
-SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
-SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
-SQLITE_API double sqlite3_value_double(sqlite3_value*);
-SQLITE_API int sqlite3_value_int(sqlite3_value*);
-SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
-SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
-SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
-SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
-SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
-SQLITE_API int sqlite3_value_type(sqlite3_value*);
-SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value*);
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*);
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*);
+SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value*);
+SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value*);
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value*);
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value*);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value*);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value*);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value*);
+SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value*);
+SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value*);
/*
** CAPI3REF: Obtain Aggregate Function Context
@@ -4409,7 +4559,7 @@ SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
** This routine must be called from the same thread in which
** the aggregate SQL function is running.
*/
-SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
+SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context*, int nBytes);
/*
** CAPI3REF: User Data For Functions
@@ -4423,7 +4573,7 @@ SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
** This routine must be called from the same thread in which
** the application-defined function is running.
*/
-SQLITE_API void *sqlite3_user_data(sqlite3_context*);
+SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context*);
/*
** CAPI3REF: Database Connection For Functions
@@ -4434,7 +4584,7 @@ SQLITE_API void *sqlite3_user_data(sqlite3_context*);
** and [sqlite3_create_function16()] routines that originally
** registered the application defined function.
*/
-SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context*);
/*
** CAPI3REF: Function Auxiliary Data
@@ -4486,8 +4636,8 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
** These routines must be called from the same thread in which
** the SQL function is running.
*/
-SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
-SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
+SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context*, int N);
+SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
/*
@@ -4622,25 +4772,26 @@ typedef void (*sqlite3_destructor_type)(void*);
** than the one containing the application-defined function that received
** the [sqlite3_context] pointer, the results are undefined.
*/
-SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
-SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,sqlite3_uint64,void(*)(void*));
-SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
-SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
-SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
-SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
-SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
-SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
-SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
-SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
-SQLITE_API void sqlite3_result_null(sqlite3_context*);
-SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
-SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(sqlite3_context*,const void*,
+ sqlite3_uint64,void(*)(void*));
+SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context*, double);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context*, const char*, int);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context*, const void*, int);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context*);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context*);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context*, int);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context*, int);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context*);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
void(*)(void*), unsigned char encoding);
-SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
-SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
-SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
-SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
-SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
+SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context*, sqlite3_value*);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context*, int n);
/*
** CAPI3REF: Define New Collating Sequences
@@ -4721,14 +4872,14 @@ SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
**
** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
*/
-SQLITE_API int sqlite3_create_collation(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
sqlite3*,
const char *zName,
int eTextRep,
void *pArg,
int(*xCompare)(void*,int,const void*,int,const void*)
);
-SQLITE_API int sqlite3_create_collation_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
sqlite3*,
const char *zName,
int eTextRep,
@@ -4736,7 +4887,7 @@ SQLITE_API int sqlite3_create_collation_v2(
int(*xCompare)(void*,int,const void*,int,const void*),
void(*xDestroy)(void*)
);
-SQLITE_API int sqlite3_create_collation16(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
sqlite3*,
const void *zName,
int eTextRep,
@@ -4770,12 +4921,12 @@ SQLITE_API int sqlite3_create_collation16(
** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
** [sqlite3_create_collation_v2()].
*/
-SQLITE_API int sqlite3_collation_needed(
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
sqlite3*,
void*,
void(*)(void*,sqlite3*,int eTextRep,const char*)
);
-SQLITE_API int sqlite3_collation_needed16(
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
sqlite3*,
void*,
void(*)(void*,sqlite3*,int eTextRep,const void*)
@@ -4789,11 +4940,11 @@ SQLITE_API int sqlite3_collation_needed16(
** The code to implement this API is not available in the public release
** of SQLite.
*/
-SQLITE_API int sqlite3_key(
+SQLITE_API int SQLITE_STDCALL sqlite3_key(
sqlite3 *db, /* Database to be rekeyed */
const void *pKey, int nKey /* The key */
);
-SQLITE_API int sqlite3_key_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_key_v2(
sqlite3 *db, /* Database to be rekeyed */
const char *zDbName, /* Name of the database */
const void *pKey, int nKey /* The key */
@@ -4807,11 +4958,11 @@ SQLITE_API int sqlite3_key_v2(
** The code to implement this API is not available in the public release
** of SQLite.
*/
-SQLITE_API int sqlite3_rekey(
+SQLITE_API int SQLITE_STDCALL sqlite3_rekey(
sqlite3 *db, /* Database to be rekeyed */
const void *pKey, int nKey /* The new key */
);
-SQLITE_API int sqlite3_rekey_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_rekey_v2(
sqlite3 *db, /* Database to be rekeyed */
const char *zDbName, /* Name of the database */
const void *pKey, int nKey /* The new key */
@@ -4821,7 +4972,7 @@ SQLITE_API int sqlite3_rekey_v2(
** Specify the activation key for a SEE database. Unless
** activated, none of the SEE routines will work.
*/
-SQLITE_API void sqlite3_activate_see(
+SQLITE_API void SQLITE_STDCALL sqlite3_activate_see(
const char *zPassPhrase /* Activation phrase */
);
#endif
@@ -4831,7 +4982,7 @@ SQLITE_API void sqlite3_activate_see(
** Specify the activation key for a CEROD database. Unless
** activated, none of the CEROD routines will work.
*/
-SQLITE_API void sqlite3_activate_cerod(
+SQLITE_API void SQLITE_STDCALL sqlite3_activate_cerod(
const char *zPassPhrase /* Activation phrase */
);
#endif
@@ -4853,7 +5004,7 @@ SQLITE_API void sqlite3_activate_cerod(
** all, then the behavior of sqlite3_sleep() may deviate from the description
** in the previous paragraphs.
*/
-SQLITE_API int sqlite3_sleep(int);
+SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int);
/*
** CAPI3REF: Name Of The Folder Holding Temporary Files
@@ -4971,7 +5122,7 @@ SQLITE_API char *sqlite3_data_directory;
** connection while this routine is running, then the return value
** is undefined.
*/
-SQLITE_API int sqlite3_get_autocommit(sqlite3*);
+SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3*);
/*
** CAPI3REF: Find The Database Handle Of A Prepared Statement
@@ -4983,7 +5134,7 @@ SQLITE_API int sqlite3_get_autocommit(sqlite3*);
** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
** create the statement in the first place.
*/
-SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt*);
/*
** CAPI3REF: Return The Filename For A Database Connection
@@ -4999,7 +5150,7 @@ SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
** will be an absolute pathname, even if the filename used
** to open the database originally was a URI or relative pathname.
*/
-SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName);
/*
** CAPI3REF: Determine if a database is read-only
@@ -5008,7 +5159,7 @@ SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
** of connection D is read-only, 0 if it is read/write, or -1 if N is not
** the name of a database on connection D.
*/
-SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
+SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
/*
** CAPI3REF: Find the next prepared statement
@@ -5023,7 +5174,7 @@ SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
** [sqlite3_next_stmt(D,S)] must refer to an open database
** connection and in particular must not be a NULL pointer.
*/
-SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
+SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
/*
** CAPI3REF: Commit And Rollback Notification Callbacks
@@ -5071,8 +5222,8 @@ SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
**
** See also the [sqlite3_update_hook()] interface.
*/
-SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
-SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
+SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
+SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
/*
** CAPI3REF: Data Change Notification Callbacks
@@ -5122,7 +5273,7 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
** interfaces.
*/
-SQLITE_API void *sqlite3_update_hook(
+SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
sqlite3*,
void(*)(void *,int ,char const *,char const *,sqlite3_int64),
void*
@@ -5152,12 +5303,17 @@ SQLITE_API void *sqlite3_update_hook(
** future releases of SQLite. Applications that care about shared
** cache setting should set it explicitly.
**
+** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0
+** and will always return SQLITE_MISUSE. On those systems,
+** shared cache mode should be enabled per-database connection via
+** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].
+**
** This interface is threadsafe on processors where writing a
** 32-bit integer is atomic.
**
** See Also: [SQLite Shared-Cache Mode]
*/
-SQLITE_API int sqlite3_enable_shared_cache(int);
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int);
/*
** CAPI3REF: Attempt To Free Heap Memory
@@ -5173,7 +5329,7 @@ SQLITE_API int sqlite3_enable_shared_cache(int);
**
** See also: [sqlite3_db_release_memory()]
*/
-SQLITE_API int sqlite3_release_memory(int);
+SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int);
/*
** CAPI3REF: Free Memory Used By A Database Connection
@@ -5186,7 +5342,7 @@ SQLITE_API int sqlite3_release_memory(int);
**
** See also: [sqlite3_release_memory()]
*/
-SQLITE_API int sqlite3_db_release_memory(sqlite3*);
+SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3*);
/*
** CAPI3REF: Impose A Limit On Heap Size
@@ -5238,7 +5394,7 @@ SQLITE_API int sqlite3_db_release_memory(sqlite3*);
** The circumstances under which SQLite will enforce the soft heap limit may
** changes in future releases of SQLite.
*/
-SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 N);
/*
** CAPI3REF: Deprecated Soft Heap Limit Interface
@@ -5249,26 +5405,33 @@ SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
** only. All new applications should use the
** [sqlite3_soft_heap_limit64()] interface rather than this one.
*/
-SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
+SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N);
/*
** CAPI3REF: Extract Metadata About A Column Of A Table
**
-** ^This routine returns metadata about a specific column of a specific
-** database table accessible using the [database connection] handle
-** passed as the first function argument.
+** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
+** information about column C of table T in database D
+** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
+** interface returns SQLITE_OK and fills in the non-NULL pointers in
+** the final five arguments with appropriate values if the specified
+** column exists. ^The sqlite3_table_column_metadata() interface returns
+** SQLITE_ERROR and if the specified column does not exist.
+** ^If the column-name parameter to sqlite3_table_column_metadata() is a
+** NULL pointer, then this routine simply checks for the existance of the
+** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
+** does not.
**
** ^The column is identified by the second, third and fourth parameters to
-** this function. ^The second parameter is either the name of the database
+** this function. ^(The second parameter is either the name of the database
** (i.e. "main", "temp", or an attached database) containing the specified
-** table or NULL. ^If it is NULL, then all attached databases are searched
+** table or NULL.)^ ^If it is NULL, then all attached databases are searched
** for the table using the same algorithm used by the database engine to
** resolve unqualified table references.
**
** ^The third and fourth parameters to this function are the table and column
-** name of the desired column, respectively. Neither of these parameters
-** may be NULL.
+** name of the desired column, respectively.
**
** ^Metadata is returned by writing to the memory locations passed as the 5th
** and subsequent parameters to this function. ^Any of these arguments may be
@@ -5287,16 +5450,17 @@ SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
** </blockquote>)^
**
** ^The memory pointed to by the character pointers returned for the
-** declaration type and collation sequence is valid only until the next
+** declaration type and collation sequence is valid until the next
** call to any SQLite API function.
**
** ^If the specified table is actually a view, an [error code] is returned.
**
-** ^If the specified column is "rowid", "oid" or "_rowid_" and an
+** ^If the specified column is "rowid", "oid" or "_rowid_" and the table
+** is not a [WITHOUT ROWID] table and an
** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
** parameters are set for the explicitly declared column. ^(If there is no
-** explicitly declared [INTEGER PRIMARY KEY] column, then the output
-** parameters are set as follows:
+** [INTEGER PRIMARY KEY] column, then the outputs
+** for the [rowid] are set as follows:
**
** <pre>
** data type: "INTEGER"
@@ -5306,15 +5470,11 @@ SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
** auto increment: 0
** </pre>)^
**
-** ^(This function may load one or more schemas from database files. If an
-** error occurs during this process, or if the requested table or column
-** cannot be found, an [error code] is returned and an error message left
-** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
-**
-** ^This API is only available if the library was compiled with the
-** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
+** ^This function causes all database schemas to be read from disk and
+** parsed, if that has not already been done, and returns an error if
+** any errors are encountered while loading the schema.
*/
-SQLITE_API int sqlite3_table_column_metadata(
+SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
sqlite3 *db, /* Connection handle */
const char *zDbName, /* Database name or NULL */
const char *zTableName, /* Table name */
@@ -5360,7 +5520,7 @@ SQLITE_API int sqlite3_table_column_metadata(
**
** See also the [load_extension() SQL function].
*/
-SQLITE_API int sqlite3_load_extension(
+SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
sqlite3 *db, /* Load the extension into this database connection */
const char *zFile, /* Name of the shared library containing extension */
const char *zProc, /* Entry point. Derived from zFile if 0 */
@@ -5380,7 +5540,7 @@ SQLITE_API int sqlite3_load_extension(
** to turn extension loading on and call it with onoff==0 to turn
** it back off again.
*/
-SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff);
/*
** CAPI3REF: Automatically Load Statically Linked Extensions
@@ -5418,7 +5578,7 @@ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
** See also: [sqlite3_reset_auto_extension()]
** and [sqlite3_cancel_auto_extension()]
*/
-SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
+SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
/*
** CAPI3REF: Cancel Automatic Extension Loading
@@ -5430,7 +5590,7 @@ SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
** unregistered and it returns 0 if X was not on the list of initialization
** routines.
*/
-SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
+SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
/*
** CAPI3REF: Reset Automatic Extension Loading
@@ -5438,7 +5598,7 @@ SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
** ^This interface disables all automatic extensions previously
** registered using [sqlite3_auto_extension()].
*/
-SQLITE_API void sqlite3_reset_auto_extension(void);
+SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void);
/*
** The interface to the virtual-table mechanism is currently considered
@@ -5641,13 +5801,13 @@ struct sqlite3_index_info {
** interface is equivalent to sqlite3_create_module_v2() with a NULL
** destructor.
*/
-SQLITE_API int sqlite3_create_module(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
sqlite3 *db, /* SQLite connection to register module with */
const char *zName, /* Name of the module */
const sqlite3_module *p, /* Methods for the module */
void *pClientData /* Client data for xCreate/xConnect */
);
-SQLITE_API int sqlite3_create_module_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
sqlite3 *db, /* SQLite connection to register module with */
const char *zName, /* Name of the module */
const sqlite3_module *p, /* Methods for the module */
@@ -5675,7 +5835,7 @@ SQLITE_API int sqlite3_create_module_v2(
*/
struct sqlite3_vtab {
const sqlite3_module *pModule; /* The module for this virtual table */
- int nRef; /* NO LONGER USED */
+ int nRef; /* Number of open cursors */
char *zErrMsg; /* Error message from sqlite3_mprintf() */
/* Virtual table implementations will typically add additional fields */
};
@@ -5710,7 +5870,7 @@ struct sqlite3_vtab_cursor {
** to declare the format (the names and datatypes of the columns) of
** the virtual tables they implement.
*/
-SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
+SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3*, const char *zSQL);
/*
** CAPI3REF: Overload A Function For A Virtual Table
@@ -5728,7 +5888,7 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
** purpose is to be a placeholder function that can be overloaded
** by a [virtual table].
*/
-SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
+SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
/*
** The interface to the virtual-table mechanism defined above (back up
@@ -5765,26 +5925,42 @@ typedef struct sqlite3_blob sqlite3_blob;
** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
** </pre>)^
**
+** ^(Parameter zDb is not the filename that contains the database, but
+** rather the symbolic name of the database. For attached databases, this is
+** the name that appears after the AS keyword in the [ATTACH] statement.
+** For the main database file, the database name is "main". For TEMP
+** tables, the database name is "temp".)^
+**
** ^If the flags parameter is non-zero, then the BLOB is opened for read
-** and write access. ^If it is zero, the BLOB is opened for read access.
-** ^It is not possible to open a column that is part of an index or primary
-** key for writing. ^If [foreign key constraints] are enabled, it is
-** not possible to open a column that is part of a [child key] for writing.
-**
-** ^Note that the database name is not the filename that contains
-** the database but rather the symbolic name of the database that
-** appears after the AS keyword when the database is connected using [ATTACH].
-** ^For the main database file, the database name is "main".
-** ^For TEMP tables, the database name is "temp".
-**
-** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
-** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set
-** to be a null pointer.)^
-** ^This function sets the [database connection] error code and message
-** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related
-** functions. ^Note that the *ppBlob variable is always initialized in a
-** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob
-** regardless of the success or failure of this routine.
+** and write access. ^If the flags parameter is zero, the BLOB is opened for
+** read-only access.
+**
+** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is stored
+** in *ppBlob. Otherwise an [error code] is returned and, unless the error
+** code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided
+** the API is not misused, it is always safe to call [sqlite3_blob_close()]
+** on *ppBlob after this function it returns.
+**
+** This function fails with SQLITE_ERROR if any of the following are true:
+** <ul>
+** <li> ^(Database zDb does not exist)^,
+** <li> ^(Table zTable does not exist within database zDb)^,
+** <li> ^(Table zTable is a WITHOUT ROWID table)^,
+** <li> ^(Column zColumn does not exist)^,
+** <li> ^(Row iRow is not present in the table)^,
+** <li> ^(The specified column of row iRow contains a value that is not
+** a TEXT or BLOB value)^,
+** <li> ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE
+** constraint and the blob is being opened for read/write access)^,
+** <li> ^([foreign key constraints | Foreign key constraints] are enabled,
+** column zColumn is part of a [child key] definition and the blob is
+** being opened for read/write access)^.
+** </ul>
+**
+** ^Unless it returns SQLITE_MISUSE, this function sets the
+** [database connection] error code and message accessible via
+** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions.
+**
**
** ^(If the row that a BLOB handle points to is modified by an
** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects
@@ -5802,18 +5978,14 @@ typedef struct sqlite3_blob sqlite3_blob;
** interface. Use the [UPDATE] SQL command to change the size of a
** blob.
**
-** ^The [sqlite3_blob_open()] interface will fail for a [WITHOUT ROWID]
-** table. Incremental BLOB I/O is not possible on [WITHOUT ROWID] tables.
-**
** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
-** and the built-in [zeroblob] SQL function can be used, if desired,
-** to create an empty, zero-filled blob in which to read or write using
-** this interface.
+** and the built-in [zeroblob] SQL function may be used to create a
+** zero-filled blob to read or write using the incremental-blob interface.
**
** To avoid a resource leak, every open [BLOB handle] should eventually
** be released by a call to [sqlite3_blob_close()].
*/
-SQLITE_API int sqlite3_blob_open(
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
sqlite3*,
const char *zDb,
const char *zTable,
@@ -5845,31 +6017,29 @@ SQLITE_API int sqlite3_blob_open(
**
** ^This function sets the database handle error code and message.
*/
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
+SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
/*
** CAPI3REF: Close A BLOB Handle
**
-** ^Closes an open [BLOB handle].
-**
-** ^Closing a BLOB shall cause the current transaction to commit
-** if there are no other BLOBs, no pending prepared statements, and the
-** database connection is in [autocommit mode].
-** ^If any writes were made to the BLOB, they might be held in cache
-** until the close operation if they will fit.
-**
-** ^(Closing the BLOB often forces the changes
-** out to disk and so if any I/O errors occur, they will likely occur
-** at the time when the BLOB is closed. Any errors that occur during
-** closing are reported as a non-zero return value.)^
+** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
+** unconditionally. Even if this routine returns an error code, the
+** handle is still closed.)^
**
-** ^(The BLOB is closed unconditionally. Even if this routine returns
-** an error code, the BLOB is still closed.)^
+** ^If the blob handle being closed was opened for read-write access, and if
+** the database is in auto-commit mode and there are no other open read-write
+** blob handles or active write statements, the current transaction is
+** committed. ^If an error occurs while committing the transaction, an error
+** code is returned and the transaction rolled back.
**
-** ^Calling this routine with a null pointer (such as would be returned
-** by a failed call to [sqlite3_blob_open()]) is a harmless no-op.
+** Calling this function with an argument that is not a NULL pointer or an
+** open blob handle results in undefined behaviour. ^Calling this routine
+** with a null pointer (such as would be returned by a failed call to
+** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
+** is passed a valid open blob handle, the values returned by the
+** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
*/
-SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *);
/*
** CAPI3REF: Return The Size Of An Open BLOB
@@ -5884,7 +6054,7 @@ SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
** to this routine results in undefined and probably undesirable behavior.
*/
-SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *);
/*
** CAPI3REF: Read Data From A BLOB Incrementally
@@ -5912,26 +6082,32 @@ SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
**
** See also: [sqlite3_blob_write()].
*/
-SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
/*
** CAPI3REF: Write Data Into A BLOB Incrementally
**
-** ^This function is used to write data into an open [BLOB handle] from a
-** caller-supplied buffer. ^N bytes of data are copied from the buffer Z
-** into the open BLOB, starting at offset iOffset.
+** ^(This function is used to write data into an open [BLOB handle] from a
+** caller-supplied buffer. N bytes of data are copied from the buffer Z
+** into the open BLOB, starting at offset iOffset.)^
+**
+** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
+** Otherwise, an [error code] or an [extended error code] is returned.)^
+** ^Unless SQLITE_MISUSE is returned, this function sets the
+** [database connection] error code and message accessible via
+** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions.
**
** ^If the [BLOB handle] passed as the first argument was not opened for
** writing (the flags parameter to [sqlite3_blob_open()] was zero),
** this function returns [SQLITE_READONLY].
**
-** ^This function may only modify the contents of the BLOB; it is
+** This function may only modify the contents of the BLOB; it is
** not possible to increase the size of a BLOB using this API.
** ^If offset iOffset is less than N bytes from the end of the BLOB,
-** [SQLITE_ERROR] is returned and no data is written. ^If N is
-** less than zero [SQLITE_ERROR] is returned and no data is written.
-** The size of the BLOB (and hence the maximum value of N+iOffset)
-** can be determined using the [sqlite3_blob_bytes()] interface.
+** [SQLITE_ERROR] is returned and no data is written. The size of the
+** BLOB (and hence the maximum value of N+iOffset) can be determined
+** using the [sqlite3_blob_bytes()] interface. ^If N or iOffset are less
+** than zero [SQLITE_ERROR] is returned and no data is written.
**
** ^An attempt to write to an expired [BLOB handle] fails with an
** error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred
@@ -5940,9 +6116,6 @@ SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
** have been overwritten by the statement that expired the BLOB handle
** or by other independent statements.
**
-** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
-** Otherwise, an [error code] or an [extended error code] is returned.)^
-**
** This routine only works on a [BLOB handle] which has been created
** by a prior successful call to [sqlite3_blob_open()] and which has not
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
@@ -5950,7 +6123,7 @@ SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
**
** See also: [sqlite3_blob_read()].
*/
-SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
/*
** CAPI3REF: Virtual File System Objects
@@ -5981,9 +6154,9 @@ SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOff
** ^(If the default VFS is unregistered, another VFS is chosen as
** the default. The choice for the new VFS is arbitrary.)^
*/
-SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
-SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
-SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
+SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfsName);
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs*);
/*
** CAPI3REF: Mutexes
@@ -5995,34 +6168,34 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
**
** The SQLite source code contains multiple implementations
** of these mutex routines. An appropriate implementation
-** is selected automatically at compile-time. ^(The following
+** is selected automatically at compile-time. The following
** implementations are available in the SQLite core:
**
** <ul>
** <li> SQLITE_MUTEX_PTHREADS
** <li> SQLITE_MUTEX_W32
** <li> SQLITE_MUTEX_NOOP
-** </ul>)^
+** </ul>
**
-** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
+** The SQLITE_MUTEX_NOOP implementation is a set of routines
** that does no real locking and is appropriate for use in
-** a single-threaded application. ^The SQLITE_MUTEX_PTHREADS and
+** a single-threaded application. The SQLITE_MUTEX_PTHREADS and
** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix
** and Windows.
**
-** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
+** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
** implementation is included with the library. In this case the
** application must supply a custom mutex implementation using the
** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
** before calling sqlite3_initialize() or any other public sqlite3_
-** function that calls sqlite3_initialize().)^
+** function that calls sqlite3_initialize().
**
** ^The sqlite3_mutex_alloc() routine allocates a new
-** mutex and returns a pointer to it. ^If it returns NULL
-** that means that a mutex could not be allocated. ^SQLite
-** will unwind its stack and return an error. ^(The argument
-** to sqlite3_mutex_alloc() is one of these integer constants:
+** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()
+** routine returns NULL if it is unable to allocate the requested
+** mutex. The argument to sqlite3_mutex_alloc() must one of these
+** integer constants:
**
** <ul>
** <li> SQLITE_MUTEX_FAST
@@ -6035,7 +6208,8 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
** <li> SQLITE_MUTEX_STATIC_PMEM
** <li> SQLITE_MUTEX_STATIC_APP1
** <li> SQLITE_MUTEX_STATIC_APP2
-** </ul>)^
+** <li> SQLITE_MUTEX_STATIC_APP3
+** </ul>
**
** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)
** cause sqlite3_mutex_alloc() to create
@@ -6043,14 +6217,14 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
** The mutex implementation does not need to make a distinction
** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
-** not want to. ^SQLite will only request a recursive mutex in
-** cases where it really needs one. ^If a faster non-recursive mutex
+** not want to. SQLite will only request a recursive mutex in
+** cases where it really needs one. If a faster non-recursive mutex
** implementation is available on the host platform, the mutex subsystem
** might return such a mutex in response to SQLITE_MUTEX_FAST.
**
** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other
** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return
-** a pointer to a static preexisting mutex. ^Six static mutexes are
+** a pointer to a static preexisting mutex. ^Nine static mutexes are
** used by the current version of SQLite. Future versions of SQLite
** may add additional static mutexes. Static mutexes are for internal
** use by SQLite only. Applications that use SQLite mutexes should
@@ -6059,16 +6233,13 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
**
** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
-** returns a different mutex on every call. ^But for the static
+** returns a different mutex on every call. ^For the static
** mutex types, the same mutex is returned on every call that has
** the same type number.
**
** ^The sqlite3_mutex_free() routine deallocates a previously
-** allocated dynamic mutex. ^SQLite is careful to deallocate every
-** dynamic mutex that it allocates. The dynamic mutexes must not be in
-** use when they are deallocated. Attempting to deallocate a static
-** mutex results in undefined behavior. ^SQLite never deallocates
-** a static mutex.
+** allocated dynamic mutex. Attempting to deallocate a static
+** mutex results in undefined behavior.
**
** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
** to enter a mutex. ^If another thread is already within the mutex,
@@ -6076,23 +6247,21 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
** SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK]
** upon successful entry. ^(Mutexes created using
** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
-** In such cases the,
+** In such cases, the
** mutex must be exited an equal number of times before another thread
-** can enter.)^ ^(If the same thread tries to enter any other
-** kind of mutex more than once, the behavior is undefined.
-** SQLite will never exhibit
-** such behavior in its own use of mutexes.)^
+** can enter.)^ If the same thread tries to enter any mutex other
+** than an SQLITE_MUTEX_RECURSIVE more than once, the behavior is undefined.
**
** ^(Some systems (for example, Windows 95) do not support the operation
** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try()
-** will always return SQLITE_BUSY. The SQLite core only ever uses
-** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^
+** will always return SQLITE_BUSY. The SQLite core only ever uses
+** sqlite3_mutex_try() as an optimization so this is acceptable
+** behavior.)^
**
** ^The sqlite3_mutex_leave() routine exits a mutex that was
-** previously entered by the same thread. ^(The behavior
+** previously entered by the same thread. The behavior
** is undefined if the mutex is not currently entered by the
-** calling thread or is not currently allocated. SQLite will
-** never do either.)^
+** calling thread or is not currently allocated.
**
** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
** sqlite3_mutex_leave() is a NULL pointer, then all three routines
@@ -6100,11 +6269,11 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
**
** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
*/
-SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);
-SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);
-SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
-SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
-SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int);
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex*);
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex*);
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex*);
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex*);
/*
** CAPI3REF: Mutex Methods Object
@@ -6113,9 +6282,9 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
** used to allocate and use mutexes.
**
** Usually, the default mutex implementations provided by SQLite are
-** sufficient, however the user has the option of substituting a custom
+** sufficient, however the application has the option of substituting a custom
** implementation for specialized deployments or systems for which SQLite
-** does not provide a suitable implementation. In this case, the user
+** does not provide a suitable implementation. In this case, the application
** creates and populates an instance of this structure to pass
** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.
** Additionally, an instance of this structure can be used as an
@@ -6156,13 +6325,13 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
** (i.e. it is acceptable to provide an implementation that segfaults if
** it is passed a NULL pointer).
**
-** The xMutexInit() method must be threadsafe. ^It must be harmless to
+** The xMutexInit() method must be threadsafe. It must be harmless to
** invoke xMutexInit() multiple times within the same process and without
** intervening calls to xMutexEnd(). Second and subsequent calls to
** xMutexInit() must be no-ops.
**
-** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
-** and its associates). ^Similarly, xMutexAlloc() must not use SQLite memory
+** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
+** and its associates). Similarly, xMutexAlloc() must not use SQLite memory
** allocation for a static mutex. ^However xMutexAlloc() may use SQLite
** memory allocation for a fast or recursive mutex.
**
@@ -6188,34 +6357,34 @@ struct sqlite3_mutex_methods {
** CAPI3REF: Mutex Verification Routines
**
** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
-** are intended for use inside assert() statements. ^The SQLite core
+** are intended for use inside assert() statements. The SQLite core
** never uses these routines except inside an assert() and applications
-** are advised to follow the lead of the core. ^The SQLite core only
+** are advised to follow the lead of the core. The SQLite core only
** provides implementations for these routines when it is compiled
-** with the SQLITE_DEBUG flag. ^External mutex implementations
+** with the SQLITE_DEBUG flag. External mutex implementations
** are only required to provide these routines if SQLITE_DEBUG is
** defined and if NDEBUG is not defined.
**
-** ^These routines should return true if the mutex in their argument
+** These routines should return true if the mutex in their argument
** is held or not held, respectively, by the calling thread.
**
-** ^The implementation is not required to provide versions of these
+** The implementation is not required to provide versions of these
** routines that actually work. If the implementation does not provide working
** versions of these routines, it should at least provide stubs that always
** return true so that one does not get spurious assertion failures.
**
-** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
+** If the argument to sqlite3_mutex_held() is a NULL pointer then
** the routine should return 1. This seems counter-intuitive since
** clearly the mutex cannot be held if it does not exist. But
** the reason the mutex does not exist is because the build is not
** using mutexes. And we do not want the assert() containing the
** call to sqlite3_mutex_held() to fail, so a non-zero return is
-** the appropriate thing to do. ^The sqlite3_mutex_notheld()
+** the appropriate thing to do. The sqlite3_mutex_notheld()
** interface should also return 1 when given a NULL pointer.
*/
#ifndef NDEBUG
-SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
-SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex*);
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex*);
#endif
/*
@@ -6251,7 +6420,7 @@ SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
** ^If the [threading mode] is Single-thread or Multi-thread then this
** routine returns a NULL pointer.
*/
-SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3*);
/*
** CAPI3REF: Low-Level Control Of Database Files
@@ -6285,7 +6454,7 @@ SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
**
** See also: [SQLITE_FCNTL_LOCKSTATE]
*/
-SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
+SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
/*
** CAPI3REF: Testing Interface
@@ -6304,7 +6473,7 @@ SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*
** Unlike most of the SQLite API, this function is not guaranteed to
** operate consistently from one release to the next.
*/
-SQLITE_API int sqlite3_test_control(int op, ...);
+SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...);
/*
** CAPI3REF: Testing Interface Operation Codes
@@ -6338,12 +6507,13 @@ SQLITE_API int sqlite3_test_control(int op, ...);
#define SQLITE_TESTCTRL_BYTEORDER 22
#define SQLITE_TESTCTRL_ISINIT 23
#define SQLITE_TESTCTRL_SORTER_MMAP 24
-#define SQLITE_TESTCTRL_LAST 24
+#define SQLITE_TESTCTRL_IMPOSTER 25
+#define SQLITE_TESTCTRL_LAST 25
/*
** CAPI3REF: SQLite Runtime Status
**
-** ^This interface is used to retrieve runtime status information
+** ^These interfaces are used to retrieve runtime status information
** about the performance of SQLite, and optionally to reset various
** highwater marks. ^The first argument is an integer code for
** the specific parameter to measure. ^(Recognized integer codes
@@ -6357,19 +6527,22 @@ SQLITE_API int sqlite3_test_control(int op, ...);
** ^(Other parameters record only the highwater mark and not the current
** value. For these latter parameters nothing is written into *pCurrent.)^
**
-** ^The sqlite3_status() routine returns SQLITE_OK on success and a
-** non-zero [error code] on failure.
+** ^The sqlite3_status() and sqlite3_status64() routines return
+** SQLITE_OK on success and a non-zero [error code] on failure.
**
-** This routine is threadsafe but is not atomic. This routine can be
-** called while other threads are running the same or different SQLite
-** interfaces. However the values returned in *pCurrent and
-** *pHighwater reflect the status of SQLite at different points in time
-** and it is possible that another thread might change the parameter
-** in between the times when *pCurrent and *pHighwater are written.
+** If either the current value or the highwater mark is too large to
+** be represented by a 32-bit integer, then the values returned by
+** sqlite3_status() are undefined.
**
** See also: [sqlite3_db_status()]
*/
-SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
+SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
+SQLITE_API int SQLITE_STDCALL sqlite3_status64(
+ int op,
+ sqlite3_int64 *pCurrent,
+ sqlite3_int64 *pHighwater,
+ int resetFlag
+);
/*
@@ -6487,7 +6660,7 @@ SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetF
**
** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
*/
-SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
+SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
/*
** CAPI3REF: Status Parameters for database connections
@@ -6616,7 +6789,7 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r
**
** See also: [sqlite3_status()] and [sqlite3_db_status()].
*/
-SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
/*
** CAPI3REF: Status Parameters for prepared statements
@@ -6943,6 +7116,10 @@ typedef struct sqlite3_backup sqlite3_backup;
** must be different or else sqlite3_backup_init(D,N,S,M) will fail with
** an error.
**
+** ^A call to sqlite3_backup_init() will fail, returning SQLITE_ERROR, if
+** there is already a read or read-write transaction open on the
+** destination database.
+**
** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is
** returned and an error code and error message are stored in the
** destination [database connection] D.
@@ -7035,20 +7212,20 @@ typedef struct sqlite3_backup sqlite3_backup;
** is not a permanent error and does not affect the return value of
** sqlite3_backup_finish().
**
-** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]]
+** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]]
** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>
**
-** ^Each call to sqlite3_backup_step() sets two values inside
-** the [sqlite3_backup] object: the number of pages still to be backed
-** up and the total number of pages in the source database file.
-** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
-** retrieve these two values, respectively.
-**
-** ^The values returned by these functions are only updated by
-** sqlite3_backup_step(). ^If the source database is modified during a backup
-** operation, then the values are not updated to account for any extra
-** pages that need to be updated or the size of the source database file
-** changing.
+** ^The sqlite3_backup_remaining() routine returns the number of pages still
+** to be backed up at the conclusion of the most recent sqlite3_backup_step().
+** ^The sqlite3_backup_pagecount() routine returns the total number of pages
+** in the source database at the conclusion of the most recent
+** sqlite3_backup_step().
+** ^(The values returned by these functions are only updated by
+** sqlite3_backup_step(). If the source database is modified in a way that
+** changes the size of the source database or the number of pages remaining,
+** those changes are not reflected in the output of sqlite3_backup_pagecount()
+** and sqlite3_backup_remaining() until after the next
+** sqlite3_backup_step().)^
**
** <b>Concurrent Usage of Database Handles</b>
**
@@ -7081,16 +7258,16 @@ typedef struct sqlite3_backup sqlite3_backup;
** same time as another thread is invoking sqlite3_backup_step() it is
** possible that they return invalid values.
*/
-SQLITE_API sqlite3_backup *sqlite3_backup_init(
+SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
sqlite3 *pDest, /* Destination database handle */
const char *zDestName, /* Destination database name */
sqlite3 *pSource, /* Source database handle */
const char *zSourceName /* Source database name */
);
-SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);
-SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);
-SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);
-SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage);
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p);
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p);
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p);
/*
** CAPI3REF: Unlock Notification
@@ -7206,7 +7383,7 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
** the special "DROP TABLE/INDEX" case, the extended error code is just
** SQLITE_LOCKED.)^
*/
-SQLITE_API int sqlite3_unlock_notify(
+SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
sqlite3 *pBlocked, /* Waiting connection */
void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
void *pNotifyArg /* Argument to pass to xNotify */
@@ -7221,8 +7398,8 @@ SQLITE_API int sqlite3_unlock_notify(
** strings in a case-independent fashion, using the same definition of "case
** independence" that SQLite uses internally when comparing identifiers.
*/
-SQLITE_API int sqlite3_stricmp(const char *, const char *);
-SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
+SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *, const char *);
+SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *, const char *, int);
/*
** CAPI3REF: String Globbing
@@ -7237,7 +7414,7 @@ SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
** Note that this routine returns zero on a match and non-zero if the strings
** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
*/
-SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
+SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlob, const char *zStr);
/*
** CAPI3REF: Error Logging Interface
@@ -7260,18 +7437,16 @@ SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
** a few hundred characters, it will be truncated to the length of the
** buffer.
*/
-SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
+SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...);
/*
** CAPI3REF: Write-Ahead Log Commit Hook
**
** ^The [sqlite3_wal_hook()] function is used to register a callback that
-** will be invoked each time a database connection commits data to a
-** [write-ahead log] (i.e. whenever a transaction is committed in
-** [journal_mode | journal_mode=WAL mode]).
+** is invoked each time data is committed to a database in wal mode.
**
-** ^The callback is invoked by SQLite after the commit has taken place and
-** the associated write-lock on the database released, so the implementation
+** ^(The callback is invoked by SQLite after the commit has taken place and
+** the associated write-lock on the database released)^, so the implementation
** may read, write or [checkpoint] the database as required.
**
** ^The first parameter passed to the callback function when it is invoked
@@ -7297,7 +7472,7 @@ SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
** those overwrite any prior [sqlite3_wal_hook()] settings.
*/
-SQLITE_API void *sqlite3_wal_hook(
+SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
sqlite3*,
int(*)(void *,sqlite3*,const char*,int),
void*
@@ -7331,104 +7506,121 @@ SQLITE_API void *sqlite3_wal_hook(
** is only necessary if the default setting is found to be suboptimal
** for a particular application.
*/
-SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
/*
** CAPI3REF: Checkpoint a database
**
-** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X
-** on [database connection] D to be [checkpointed]. ^If X is NULL or an
-** empty string, then a checkpoint is run on all databases of
-** connection D. ^If the database connection D is not in
-** [WAL | write-ahead log mode] then this interface is a harmless no-op.
-** ^The [sqlite3_wal_checkpoint(D,X)] interface initiates a
-** [sqlite3_wal_checkpoint_v2|PASSIVE] checkpoint.
-** Use the [sqlite3_wal_checkpoint_v2()] interface to get a FULL
-** or RESET checkpoint.
+** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
+** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^
**
-** ^The [wal_checkpoint pragma] can be used to invoke this interface
-** from SQL. ^The [sqlite3_wal_autocheckpoint()] interface and the
-** [wal_autocheckpoint pragma] can be used to cause this interface to be
-** run whenever the WAL reaches a certain size threshold.
+** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the
+** [write-ahead log] for database X on [database connection] D to be
+** transferred into the database file and for the write-ahead log to
+** be reset. See the [checkpointing] documentation for addition
+** information.
**
-** See also: [sqlite3_wal_checkpoint_v2()]
+** This interface used to be the only way to cause a checkpoint to
+** occur. But then the newer and more powerful [sqlite3_wal_checkpoint_v2()]
+** interface was added. This interface is retained for backwards
+** compatibility and as a convenience for applications that need to manually
+** start a callback but which do not need the full power (and corresponding
+** complication) of [sqlite3_wal_checkpoint_v2()].
*/
-SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
/*
** CAPI3REF: Checkpoint a database
**
-** Run a checkpoint operation on WAL database zDb attached to database
-** handle db. The specific operation is determined by the value of the
-** eMode parameter:
+** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
+** operation on database X of [database connection] D in mode M. Status
+** information is written back into integers pointed to by L and C.)^
+** ^(The M parameter must be a valid [checkpoint mode]:)^
**
** <dl>
** <dt>SQLITE_CHECKPOINT_PASSIVE<dd>
-** Checkpoint as many frames as possible without waiting for any database
-** readers or writers to finish. Sync the db file if all frames in the log
-** are checkpointed. This mode is the same as calling
-** sqlite3_wal_checkpoint(). The [sqlite3_busy_handler|busy-handler callback]
-** is never invoked.
+** ^Checkpoint as many frames as possible without waiting for any database
+** readers or writers to finish, then sync the database file if all frames
+** in the log were checkpointed. ^The [busy-handler callback]
+** is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode.
+** ^On the other hand, passive mode might leave the checkpoint unfinished
+** if there are concurrent readers or writers.
**
** <dt>SQLITE_CHECKPOINT_FULL<dd>
-** This mode blocks (it invokes the
+** ^This mode blocks (it invokes the
** [sqlite3_busy_handler|busy-handler callback]) until there is no
** database writer and all readers are reading from the most recent database
-** snapshot. It then checkpoints all frames in the log file and syncs the
-** database file. This call blocks database writers while it is running,
-** but not database readers.
+** snapshot. ^It then checkpoints all frames in the log file and syncs the
+** database file. ^This mode blocks new database writers while it is pending,
+** but new database readers are allowed to continue unimpeded.
**
** <dt>SQLITE_CHECKPOINT_RESTART<dd>
-** This mode works the same way as SQLITE_CHECKPOINT_FULL, except after
-** checkpointing the log file it blocks (calls the
-** [sqlite3_busy_handler|busy-handler callback])
-** until all readers are reading from the database file only. This ensures
-** that the next client to write to the database file restarts the log file
-** from the beginning. This call blocks database writers while it is running,
-** but not database readers.
+** ^This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition
+** that after checkpointing the log file it blocks (calls the
+** [busy-handler callback])
+** until all readers are reading from the database file only. ^This ensures
+** that the next writer will restart the log file from the beginning.
+** ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new
+** database writer attempts while it is pending, but does not impede readers.
+**
+** <dt>SQLITE_CHECKPOINT_TRUNCATE<dd>
+** ^This mode works the same way as SQLITE_CHECKPOINT_RESTART with the
+** addition that it also truncates the log file to zero bytes just prior
+** to a successful return.
** </dl>
**
-** If pnLog is not NULL, then *pnLog is set to the total number of frames in
-** the log file before returning. If pnCkpt is not NULL, then *pnCkpt is set to
-** the total number of checkpointed frames (including any that were already
-** checkpointed when this function is called). *pnLog and *pnCkpt may be
-** populated even if sqlite3_wal_checkpoint_v2() returns other than SQLITE_OK.
-** If no values are available because of an error, they are both set to -1
-** before returning to communicate this to the caller.
-**
-** All calls obtain an exclusive "checkpoint" lock on the database file. If
+** ^If pnLog is not NULL, then *pnLog is set to the total number of frames in
+** the log file or to -1 if the checkpoint could not run because
+** of an error or because the database is not in [WAL mode]. ^If pnCkpt is not
+** NULL,then *pnCkpt is set to the total number of checkpointed frames in the
+** log file (including any that were already checkpointed before the function
+** was called) or to -1 if the checkpoint could not run due to an error or
+** because the database is not in WAL mode. ^Note that upon successful
+** completion of an SQLITE_CHECKPOINT_TRUNCATE, the log file will have been
+** truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero.
+**
+** ^All calls obtain an exclusive "checkpoint" lock on the database file. ^If
** any other process is running a checkpoint operation at the same time, the
-** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a
+** lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a
** busy-handler configured, it will not be invoked in this case.
**
-** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive
-** "writer" lock on the database file. If the writer lock cannot be obtained
-** immediately, and a busy-handler is configured, it is invoked and the writer
-** lock retried until either the busy-handler returns 0 or the lock is
-** successfully obtained. The busy-handler is also invoked while waiting for
-** database readers as described above. If the busy-handler returns 0 before
+** ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the
+** exclusive "writer" lock on the database file. ^If the writer lock cannot be
+** obtained immediately, and a busy-handler is configured, it is invoked and
+** the writer lock retried until either the busy-handler returns 0 or the lock
+** is successfully obtained. ^The busy-handler is also invoked while waiting for
+** database readers as described above. ^If the busy-handler returns 0 before
** the writer lock is obtained or while waiting for database readers, the
** checkpoint operation proceeds from that point in the same way as
** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible
-** without blocking any further. SQLITE_BUSY is returned in this case.
+** without blocking any further. ^SQLITE_BUSY is returned in this case.
**
-** If parameter zDb is NULL or points to a zero length string, then the
-** specified operation is attempted on all WAL databases. In this case the
-** values written to output parameters *pnLog and *pnCkpt are undefined. If
+** ^If parameter zDb is NULL or points to a zero length string, then the
+** specified operation is attempted on all WAL databases [attached] to
+** [database connection] db. In this case the
+** values written to output parameters *pnLog and *pnCkpt are undefined. ^If
** an SQLITE_BUSY error is encountered when processing one or more of the
** attached WAL databases, the operation is still attempted on any remaining
-** attached databases and SQLITE_BUSY is returned to the caller. If any other
+** attached databases and SQLITE_BUSY is returned at the end. ^If any other
** error occurs while processing an attached database, processing is abandoned
-** and the error code returned to the caller immediately. If no error
+** and the error code is returned to the caller immediately. ^If no error
** (SQLITE_BUSY or otherwise) is encountered while processing the attached
** databases, SQLITE_OK is returned.
**
-** If database zDb is the name of an attached database that is not in WAL
-** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. If
+** ^If database zDb is the name of an attached database that is not in WAL
+** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. ^If
** zDb is not NULL (or a zero length string) and is not the name of any
** attached database, SQLITE_ERROR is returned to the caller.
+**
+** ^Unless it returns SQLITE_MISUSE,
+** the sqlite3_wal_checkpoint_v2() interface
+** sets the error information that is queried by
+** [sqlite3_errcode()] and [sqlite3_errmsg()].
+**
+** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
+** from SQL.
*/
-SQLITE_API int sqlite3_wal_checkpoint_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
sqlite3 *db, /* Database handle */
const char *zDb, /* Name of attached database (or NULL) */
int eMode, /* SQLITE_CHECKPOINT_* value */
@@ -7437,16 +7629,18 @@ SQLITE_API int sqlite3_wal_checkpoint_v2(
);
/*
-** CAPI3REF: Checkpoint operation parameters
+** CAPI3REF: Checkpoint Mode Values
+** KEYWORDS: {checkpoint mode}
**
-** These constants can be used as the 3rd parameter to
-** [sqlite3_wal_checkpoint_v2()]. See the [sqlite3_wal_checkpoint_v2()]
-** documentation for additional information about the meaning and use of
-** each of these values.
+** These constants define all valid values for the "checkpoint mode" passed
+** as the third parameter to the [sqlite3_wal_checkpoint_v2()] interface.
+** See the [sqlite3_wal_checkpoint_v2()] documentation for details on the
+** meaning of each of these checkpoint modes.
*/
-#define SQLITE_CHECKPOINT_PASSIVE 0
-#define SQLITE_CHECKPOINT_FULL 1
-#define SQLITE_CHECKPOINT_RESTART 2
+#define SQLITE_CHECKPOINT_PASSIVE 0 /* Do as much as possible w/o blocking */
+#define SQLITE_CHECKPOINT_FULL 1 /* Wait for writers, then checkpoint */
+#define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for for readers */
+#define SQLITE_CHECKPOINT_TRUNCATE 3 /* Like RESTART but also truncate WAL */
/*
** CAPI3REF: Virtual Table Interface Configuration
@@ -7462,7 +7656,7 @@ SQLITE_API int sqlite3_wal_checkpoint_v2(
** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options
** may be added in the future.
*/
-SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
+SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3*, int op, ...);
/*
** CAPI3REF: Virtual Table Configuration Options
@@ -7515,7 +7709,7 @@ SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
** of the SQL statement that triggered the call to the [xUpdate] method of the
** [virtual table].
*/
-SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
+SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *);
/*
** CAPI3REF: Conflict resolution modes
@@ -7535,6 +7729,106 @@ SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
/* #define SQLITE_ABORT 4 // Also an error code */
#define SQLITE_REPLACE 5
+/*
+** CAPI3REF: Prepared Statement Scan Status Opcodes
+** KEYWORDS: {scanstatus options}
+**
+** The following constants can be used for the T parameter to the
+** [sqlite3_stmt_scanstatus(S,X,T,V)] interface. Each constant designates a
+** different metric for sqlite3_stmt_scanstatus() to return.
+**
+** When the value returned to V is a string, space to hold that string is
+** managed by the prepared statement S and will be automatically freed when
+** S is finalized.
+**
+** <dl>
+** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>
+** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be
+** set to the total number of times that the X-th loop has run.</dd>
+**
+** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>
+** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set
+** to the total number of rows examined by all iterations of the X-th loop.</dd>
+**
+** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>
+** <dd>^The "double" variable pointed to by the T parameter will be set to the
+** query planner's estimate for the average number of rows output from each
+** iteration of the X-th loop. If the query planner's estimates was accurate,
+** then this value will approximate the quotient NVISIT/NLOOP and the
+** product of this value for all prior loops with the same SELECTID will
+** be the NLOOP value for the current loop.
+**
+** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>
+** <dd>^The "const char *" variable pointed to by the T parameter will be set
+** to a zero-terminated UTF-8 string containing the name of the index or table
+** used for the X-th loop.
+**
+** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>
+** <dd>^The "const char *" variable pointed to by the T parameter will be set
+** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]
+** description for the X-th loop.
+**
+** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>
+** <dd>^The "int" variable pointed to by the T parameter will be set to the
+** "select-id" for the X-th loop. The select-id identifies which query or
+** subquery the loop is part of. The main query has a select-id of zero.
+** The select-id is the same value as is output in the first column
+** of an [EXPLAIN QUERY PLAN] query.
+** </dl>
+*/
+#define SQLITE_SCANSTAT_NLOOP 0
+#define SQLITE_SCANSTAT_NVISIT 1
+#define SQLITE_SCANSTAT_EST 2
+#define SQLITE_SCANSTAT_NAME 3
+#define SQLITE_SCANSTAT_EXPLAIN 4
+#define SQLITE_SCANSTAT_SELECTID 5
+
+/*
+** CAPI3REF: Prepared Statement Scan Status
+**
+** This interface returns information about the predicted and measured
+** performance for pStmt. Advanced applications can use this
+** interface to compare the predicted and the measured performance and
+** issue warnings and/or rerun [ANALYZE] if discrepancies are found.
+**
+** Since this interface is expected to be rarely used, it is only
+** available if SQLite is compiled using the [SQLITE_ENABLE_STMT_SCANSTATUS]
+** compile-time option.
+**
+** The "iScanStatusOp" parameter determines which status information to return.
+** The "iScanStatusOp" must be one of the [scanstatus options] or the behavior
+** of this interface is undefined.
+** ^The requested measurement is written into a variable pointed to by
+** the "pOut" parameter.
+** Parameter "idx" identifies the specific loop to retrieve statistics for.
+** Loops are numbered starting from zero. ^If idx is out of range - less than
+** zero or greater than or equal to the total number of loops used to implement
+** the statement - a non-zero value is returned and the variable that pOut
+** points to is unchanged.
+**
+** ^Statistics might not be available for all loops in all statements. ^In cases
+** where there exist loops with no available statistics, this function behaves
+** as if the loop did not exist - it returns non-zero and leave the variable
+** that pOut points to unchanged.
+**
+** See also: [sqlite3_stmt_scanstatus_reset()]
+*/
+SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_stmt_scanstatus(
+ sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
+ int idx, /* Index of loop to report on */
+ int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
+ void *pOut /* Result written here */
+);
+
+/*
+** CAPI3REF: Zero Scan-Status Counters
+**
+** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
+**
+** This API is only available if the library is built with pre-processor
+** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
+*/
+SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
/*
@@ -7589,7 +7883,7 @@ typedef struct sqlite3_rtree_query_info sqlite3_rtree_query_info;
**
** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
*/
-SQLITE_API int sqlite3_rtree_geometry_callback(
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
sqlite3 *db,
const char *zGeom,
int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
@@ -7615,7 +7909,7 @@ struct sqlite3_rtree_geometry {
**
** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
*/
-SQLITE_API int sqlite3_rtree_query_callback(
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
sqlite3 *db,
const char *zQueryFunc,
int (*xQueryFunc)(sqlite3_rtree_query_info*),
@@ -7779,15 +8073,17 @@ struct sqlite3_rtree_query_info {
#endif
/*
-** The maximum number of in-memory pages to use for the main database
-** table and for temporary tables. The SQLITE_DEFAULT_CACHE_SIZE
+** The suggested maximum number of in-memory pages to use for
+** the main database table and for temporary tables.
+**
+** IMPLEMENTATION-OF: R-31093-59126 The default suggested cache size
+** is 2000 pages.
+** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be
+** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options.
*/
#ifndef SQLITE_DEFAULT_CACHE_SIZE
# define SQLITE_DEFAULT_CACHE_SIZE 2000
#endif
-#ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE
-# define SQLITE_DEFAULT_TEMP_CACHE_SIZE 500
-#endif
/*
** The default number of frames to accumulate in the log file before
@@ -7980,10 +8276,9 @@ struct sqlite3_rtree_query_info {
#endif
/*
-** The SQLITE_DEFAULT_MEMSTATUS macro must be defined as either 0 or 1.
-** It determines whether or not the features related to
-** SQLITE_CONFIG_MEMSTATUS are available by default or not. This value can
-** be overridden at runtime using the sqlite3_config() API.
+** EVIDENCE-OF: R-25715-37072 Memory allocation statistics are enabled by
+** default unless SQLite is compiled with SQLITE_DEFAULT_MEMSTATUS=0 in
+** which case memory allocation statistics are disabled by default.
*/
#if !defined(SQLITE_DEFAULT_MEMSTATUS)
# define SQLITE_DEFAULT_MEMSTATUS 1
@@ -8613,7 +8908,7 @@ typedef INT8_TYPE i8; /* 1-byte signed integer */
** gives a possible range of values of approximately 1.0e986 to 1e-986.
** But the allowed values are "grainy". Not every value is representable.
** For example, quantities 16 and 17 are both represented by a LogEst
-** of 40. However, since LogEst quantaties are suppose to be estimates,
+** of 40. However, since LogEst quantities are suppose to be estimates,
** not exact values, this imprecision is not a problem.
**
** "LogEst" is short for "Logarithmic Estimate".
@@ -8633,6 +8928,20 @@ typedef INT8_TYPE i8; /* 1-byte signed integer */
typedef INT16_TYPE LogEst;
/*
+** Set the SQLITE_PTRSIZE macro to the number of bytes in a pointer
+*/
+#ifndef SQLITE_PTRSIZE
+# if defined(__SIZEOF_POINTER__)
+# define SQLITE_PTRSIZE __SIZEOF_POINTER__
+# elif defined(i386) || defined(__i386__) || defined(_M_IX86) || \
+ defined(_M_ARM) || defined(__arm__) || defined(__x86)
+# define SQLITE_PTRSIZE 4
+# else
+# define SQLITE_PTRSIZE 8
+# endif
+#endif
+
+/*
** Macros to determine whether the machine is big or little endian,
** and whether or not that determination is run-time or compile-time.
**
@@ -8844,8 +9153,8 @@ struct BusyHandler {
#define SQLITE_WSD const
#define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))
#define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)
-SQLITE_API int sqlite3_wsd_init(int N, int J);
-SQLITE_API void *sqlite3_wsd_find(void *K, int L);
+SQLITE_API int SQLITE_STDCALL sqlite3_wsd_init(int N, int J);
+SQLITE_API void *SQLITE_STDCALL sqlite3_wsd_find(void *K, int L);
#else
#define SQLITE_WSD
#define GLOBAL(t,v) v
@@ -8949,7 +9258,7 @@ typedef struct With With;
/* TODO: This definition is just included so other modules compile. It
** needs to be revisited.
*/
-#define SQLITE_N_BTREE_META 10
+#define SQLITE_N_BTREE_META 16
/*
** If defined as non-zero, auto-vacuum is enabled by default. Otherwise
@@ -9003,10 +9312,8 @@ SQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree*);
SQLITE_PRIVATE int sqlite3BtreeMaxPageCount(Btree*,int);
SQLITE_PRIVATE u32 sqlite3BtreeLastPage(Btree*);
SQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree*,int);
-SQLITE_PRIVATE int sqlite3BtreeGetReserve(Btree*);
-#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_DEBUG)
+SQLITE_PRIVATE int sqlite3BtreeGetOptimalReserve(Btree*);
SQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p);
-#endif
SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int);
SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *);
SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree*,int);
@@ -9064,6 +9371,11 @@ SQLITE_PRIVATE int sqlite3BtreeNewDb(Btree *p);
** For example, the free-page-count field is located at byte offset 36 of
** the database file header. The incr-vacuum-flag field is located at
** byte offset 64 (== 36+4*7).
+**
+** The BTREE_DATA_VERSION value is not really a value stored in the header.
+** It is a read-only number computed by the pager. But we merge it with
+** the header value access routines since its access pattern is the same.
+** Call it a "virtual meta value".
*/
#define BTREE_FREE_PAGE_COUNT 0
#define BTREE_SCHEMA_VERSION 1
@@ -9074,12 +9386,23 @@ SQLITE_PRIVATE int sqlite3BtreeNewDb(Btree *p);
#define BTREE_USER_VERSION 6
#define BTREE_INCR_VACUUM 7
#define BTREE_APPLICATION_ID 8
+#define BTREE_DATA_VERSION 15 /* A virtual meta-value */
/*
** Values that may be OR'd together to form the second argument of an
** sqlite3BtreeCursorHints() call.
+**
+** The BTREE_BULKLOAD flag is set on index cursors when the index is going
+** to be filled with content that is already in sorted order.
+**
+** The BTREE_SEEK_EQ flag is set on cursors that will get OP_SeekGE or
+** OP_SeekLE opcodes for a range search, but where the range of entries
+** selected will all have the same key. In other words, the cursor will
+** be used only for equality key searches.
+**
*/
-#define BTREE_BULKLOAD 0x00000001
+#define BTREE_BULKLOAD 0x00000001 /* Used to full index in sorted order */
+#define BTREE_SEEK_EQ 0x00000002 /* EQ seeks only - no range seeks */
SQLITE_PRIVATE int sqlite3BtreeCursor(
Btree*, /* BTree containing table to open */
@@ -9125,7 +9448,11 @@ SQLITE_PRIVATE void sqlite3BtreeIncrblobCursor(BtCursor *);
SQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *);
SQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBt, int iVersion);
SQLITE_PRIVATE void sqlite3BtreeCursorHints(BtCursor *, unsigned int mask);
+#ifdef SQLITE_DEBUG
+SQLITE_PRIVATE int sqlite3BtreeCursorHasHint(BtCursor*, unsigned int mask);
+#endif
SQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *pBt);
+SQLITE_PRIVATE int sqlite3HeaderSizeBtree(void);
#ifndef NDEBUG
SQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*);
@@ -9490,23 +9817,25 @@ typedef struct VdbeOpList VdbeOpList;
#define OP_MemMax 136 /* synopsis: r[P1]=max(r[P1],r[P2]) */
#define OP_IfPos 137 /* synopsis: if r[P1]>0 goto P2 */
#define OP_IfNeg 138 /* synopsis: r[P1]+=P3, if r[P1]<0 goto P2 */
-#define OP_IfZero 139 /* synopsis: r[P1]+=P3, if r[P1]==0 goto P2 */
-#define OP_AggFinal 140 /* synopsis: accum=r[P1] N=P2 */
-#define OP_IncrVacuum 141
-#define OP_Expire 142
-#define OP_TableLock 143 /* synopsis: iDb=P1 root=P2 write=P3 */
-#define OP_VBegin 144
-#define OP_VCreate 145
-#define OP_VDestroy 146
-#define OP_VOpen 147
-#define OP_VColumn 148 /* synopsis: r[P3]=vcolumn(P2) */
-#define OP_VNext 149
-#define OP_VRename 150
-#define OP_Pagecount 151
-#define OP_MaxPgcnt 152
-#define OP_Init 153 /* synopsis: Start at P2 */
-#define OP_Noop 154
-#define OP_Explain 155
+#define OP_IfNotZero 139 /* synopsis: if r[P1]!=0 then r[P1]+=P3, goto P2 */
+#define OP_DecrJumpZero 140 /* synopsis: if (--r[P1])==0 goto P2 */
+#define OP_JumpZeroIncr 141 /* synopsis: if (r[P1]++)==0 ) goto P2 */
+#define OP_AggFinal 142 /* synopsis: accum=r[P1] N=P2 */
+#define OP_IncrVacuum 143
+#define OP_Expire 144
+#define OP_TableLock 145 /* synopsis: iDb=P1 root=P2 write=P3 */
+#define OP_VBegin 146
+#define OP_VCreate 147
+#define OP_VDestroy 148
+#define OP_VOpen 149
+#define OP_VColumn 150 /* synopsis: r[P3]=vcolumn(P2) */
+#define OP_VNext 151
+#define OP_VRename 152
+#define OP_Pagecount 153
+#define OP_MaxPgcnt 154
+#define OP_Init 155 /* synopsis: Start at P2 */
+#define OP_Noop 156
+#define OP_Explain 157
/* Properties such as "out2" or "jump" that are specified in
@@ -9538,9 +9867,9 @@ typedef struct VdbeOpList VdbeOpList;
/* 112 */ 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00,\
/* 120 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
/* 128 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x02, 0x00, 0x01,\
-/* 136 */ 0x08, 0x05, 0x05, 0x05, 0x00, 0x01, 0x00, 0x00,\
-/* 144 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02,\
-/* 152 */ 0x02, 0x01, 0x00, 0x00,}
+/* 136 */ 0x08, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00, 0x01,\
+/* 144 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,\
+/* 152 */ 0x00, 0x02, 0x02, 0x01, 0x00, 0x00,}
/************** End of opcodes.h *********************************************/
/************** Continuing where we left off in vdbe.h ***********************/
@@ -9668,6 +9997,12 @@ SQLITE_PRIVATE void sqlite3VdbeSetLineNumber(Vdbe*,int);
# define VDBE_OFFSET_LINENO(x) 0
#endif
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
+SQLITE_PRIVATE void sqlite3VdbeScanStatus(Vdbe*, int, int, int, LogEst, const char*);
+#else
+# define sqlite3VdbeScanStatus(a,b,c,d,e)
+#endif
+
#endif
/************** End of vdbe.h ************************************************/
@@ -9848,6 +10183,7 @@ SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager);
/* Functions used to query pager state and configuration. */
SQLITE_PRIVATE u8 sqlite3PagerIsreadonly(Pager*);
+SQLITE_PRIVATE u32 sqlite3PagerDataVersion(Pager*);
SQLITE_PRIVATE int sqlite3PagerRefcount(Pager*);
SQLITE_PRIVATE int sqlite3PagerMemUsed(Pager*);
SQLITE_PRIVATE const char *sqlite3PagerFilename(Pager*, int);
@@ -9864,6 +10200,8 @@ SQLITE_PRIVATE int sqlite3SectorSize(sqlite3_file *);
/* Functions used to truncate the database file. */
SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno);
+SQLITE_PRIVATE void sqlite3PagerRekey(DbPage*, Pgno, u16);
+
#if defined(SQLITE_HAS_CODEC) && !defined(SQLITE_OMIT_WAL)
SQLITE_PRIVATE void *sqlite3PagerCodec(DbPage *);
#endif
@@ -10051,6 +10389,10 @@ SQLITE_PRIVATE void sqlite3PcacheStats(int*,int*,int*,int*);
SQLITE_PRIVATE void sqlite3PCacheSetDefault(void);
+/* Return the header size */
+SQLITE_PRIVATE int sqlite3HeaderSizePcache(void);
+SQLITE_PRIVATE int sqlite3HeaderSizePcache1(void);
+
#endif /* _PCACHE_H_ */
/************** End of pcache.h **********************************************/
@@ -10583,6 +10925,7 @@ struct sqlite3 {
int errCode; /* Most recent error code (SQLITE_*) */
int errMask; /* & result codes with this before returning */
u16 dbOptFlags; /* Flags to enable/disable optimizations */
+ u8 enc; /* Text encoding */
u8 autoCommit; /* The auto-commit flag. */
u8 temp_store; /* 1: file 2: memory 0: default */
u8 mallocFailed; /* True if we have seen a malloc failure */
@@ -10602,11 +10945,13 @@ struct sqlite3 {
u8 iDb; /* Which db file is being initialized */
u8 busy; /* TRUE if currently initializing */
u8 orphanTrigger; /* Last statement is orphaned TEMP trigger */
+ u8 imposterTable; /* Building an imposter table */
} init;
int nVdbeActive; /* Number of VDBEs currently running */
int nVdbeRead; /* Number of active VDBEs that read or write */
int nVdbeWrite; /* Number of active VDBEs that read and write */
int nVdbeExec; /* Number of nested calls to VdbeExec() */
+ int nVDestroy; /* Number of active OP_VDestroy operations */
int nExtension; /* Number of loaded extensions */
void **aExtension; /* Array of shared library handles */
void (*xTrace)(void*,const char*); /* Trace function */
@@ -10684,7 +11029,8 @@ struct sqlite3 {
/*
** A macro to discover the encoding of a database.
*/
-#define ENC(db) ((db)->aDb[0].pSchema->enc)
+#define SCHEMA_ENC(db) ((db)->aDb[0].pSchema->enc)
+#define ENC(db) ((db)->enc)
/*
** Possible values for the sqlite3.flags.
@@ -10737,7 +11083,7 @@ struct sqlite3 {
#define SQLITE_SubqCoroutine 0x0100 /* Evaluate subqueries as coroutines */
#define SQLITE_Transitive 0x0200 /* Transitive constraints */
#define SQLITE_OmitNoopJoin 0x0400 /* Omit unused tables in joins */
-#define SQLITE_Stat3 0x0800 /* Use the SQLITE_STAT3 table */
+#define SQLITE_Stat34 0x0800 /* Use STAT3 or STAT4 data */
#define SQLITE_AllOpts 0xffff /* All optimizations */
/*
@@ -11308,7 +11654,6 @@ struct Index {
u8 *aSortOrder; /* for each column: True==DESC, False==ASC */
char **azColl; /* Array of collation sequence names for index */
Expr *pPartIdxWhere; /* WHERE clause for partial indices */
- KeyInfo *pKeyInfo; /* A KeyInfo object suitable for this index */
int tnum; /* DB Page containing root of this index */
LogEst szIdxRow; /* Estimated average row size in bytes */
u16 nKeyCol; /* Number of columns forming the key */
@@ -11319,12 +11664,14 @@ struct Index {
unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */
unsigned isResized:1; /* True if resizeIndexObject() has been called */
unsigned isCovering:1; /* True if this is a covering index */
+ unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
int nSample; /* Number of elements in aSample[] */
int nSampleCol; /* Size of IndexSample.anEq[] and so on */
tRowcnt *aAvgEq; /* Average nEq values for keys not in aSample */
IndexSample *aSample; /* Samples of the left-most key */
- tRowcnt *aiRowEst; /* Non-logarithmic stat1 data for this table */
+ tRowcnt *aiRowEst; /* Non-logarithmic stat1 data for this index */
+ tRowcnt nRowEst0; /* Non-logarithmic number of rows in the index */
#endif
};
@@ -11522,7 +11869,7 @@ struct Expr {
int iTable; /* TK_COLUMN: cursor number of table holding column
** TK_REGISTER: register number
** TK_TRIGGER: 1 -> new, 0 -> old
- ** EP_Unlikely: 1000 times likelihood */
+ ** EP_Unlikely: 134217728 times likelihood */
ynVar iColumn; /* TK_COLUMN: column index. -1 for rowid.
** TK_VARIABLE: variable number (always >= 1). */
i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
@@ -11537,7 +11884,7 @@ struct Expr {
/*
** The following are the meanings of bits in the Expr.flags field.
*/
-#define EP_FromJoin 0x000001 /* Originated in ON or USING clause of a join */
+#define EP_FromJoin 0x000001 /* Originates in ON/USING clause of outer join */
#define EP_Agg 0x000002 /* Contains one or more aggregate functions */
#define EP_Resolved 0x000004 /* IDs have been resolved to COLUMNs */
#define EP_Error 0x000008 /* Expression contains one or more errors */
@@ -11556,7 +11903,14 @@ struct Expr {
#define EP_MemToken 0x010000 /* Need to sqlite3DbFree() Expr.zToken */
#define EP_NoReduce 0x020000 /* Cannot EXPRDUP_REDUCE this Expr */
#define EP_Unlikely 0x040000 /* unlikely() or likelihood() function */
-#define EP_Constant 0x080000 /* Node is a constant */
+#define EP_ConstFunc 0x080000 /* Node is a SQLITE_FUNC_CONSTANT function */
+#define EP_CanBeNull 0x100000 /* Can be null despite NOT NULL constraint */
+#define EP_Subquery 0x200000 /* Tree contains a TK_SELECT operator */
+
+/*
+** Combinations of two or more EP_* flags
+*/
+#define EP_Propagate (EP_Collate|EP_Subquery) /* Propagate these bits up tree */
/*
** These macros can be used to test, set, or clear bits in the
@@ -11755,7 +12109,7 @@ struct SrcList {
#define WHERE_OMIT_OPEN_CLOSE 0x0010 /* Table cursors are already open */
#define WHERE_FORCE_TABLE 0x0020 /* Do not use an index-only search */
#define WHERE_ONETABLE_ONLY 0x0040 /* Only code the 1st table in pTabList */
- /* 0x0080 // not currently used */
+#define WHERE_NO_AUTOINDEX 0x0080 /* Disallow automatic indexes */
#define WHERE_GROUPBY 0x0100 /* pOrderBy is really a GROUP BY */
#define WHERE_DISTINCTBY 0x0200 /* pOrderby is really a DISTINCT clause */
#define WHERE_WANT_DISTINCT 0x0400 /* All output needs to be distinct */
@@ -11869,11 +12223,12 @@ struct Select {
#define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */
#define SF_Compound 0x0040 /* Part of a compound query */
#define SF_Values 0x0080 /* Synthesized from VALUES clause */
- /* 0x0100 NOT USED */
+#define SF_AllValues 0x0100 /* All terms of compound are VALUES */
#define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */
#define SF_MaybeConvert 0x0400 /* Need convertCompoundSelectToSubquery() */
#define SF_Recursive 0x0800 /* The recursive part of a recursive CTE */
#define SF_MinMaxAgg 0x1000 /* Aggregate containing min() or max() */
+#define SF_Converted 0x2000 /* By convertCompoundSelectToSubquery() */
/*
@@ -12192,7 +12547,8 @@ struct AuthContext {
#define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */
#define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */
#define OPFLAG_BULKCSR 0x01 /* OP_Open** used to open bulk cursor */
-#define OPFLAG_P2ISREG 0x02 /* P2 to OP_Open** is a register number */
+#define OPFLAG_SEEKEQ 0x02 /* OP_Open** cursor uses EQ seek only */
+#define OPFLAG_P2ISREG 0x04 /* P2 to OP_Open** is a register number */
#define OPFLAG_PERMUTE 0x01 /* OP_Compare: use the permutation */
/*
@@ -12359,6 +12715,7 @@ struct Sqlite3Config {
int nPage; /* Number of pages in pPage[] */
int mxParserStack; /* maximum depth of the parser stack */
int sharedCacheEnabled; /* true if shared-cache mode enabled */
+ u32 szPma; /* Maximum Sorter PMA size */
/* The above might be initialized to non-zero. The following need to always
** initially be zero, however. */
int isInit; /* True after initialization has finished */
@@ -12414,9 +12771,11 @@ struct Walker {
void (*xSelectCallback2)(Walker*,Select*);/* Second callback for SELECTs */
Parse *pParse; /* Parser context. */
int walkerDepth; /* Number of subqueries */
+ u8 eCode; /* A small processing code */
union { /* Extra data for callback */
NameContext *pNC; /* Naming context */
- int i; /* Integer value */
+ int n; /* A counter */
+ int iCur; /* A cursor number */
SrcList *pSrcList; /* FROM clause */
struct SrcCount *pSrcCount; /* Counting column references */
} u;
@@ -12494,7 +12853,7 @@ SQLITE_PRIVATE int sqlite3CantopenError(int);
** the SQLITE_ENABLE_FTS4 macro to serve as an alias for SQLITE_ENABLE_FTS3.
*/
#if defined(SQLITE_ENABLE_FTS4) && !defined(SQLITE_ENABLE_FTS3)
-# define SQLITE_ENABLE_FTS3
+# define SQLITE_ENABLE_FTS3 1
#endif
/*
@@ -12593,10 +12952,15 @@ SQLITE_PRIVATE int sqlite3MutexInit(void);
SQLITE_PRIVATE int sqlite3MutexEnd(void);
#endif
-SQLITE_PRIVATE int sqlite3StatusValue(int);
-SQLITE_PRIVATE void sqlite3StatusAdd(int, int);
+SQLITE_PRIVATE sqlite3_int64 sqlite3StatusValue(int);
+SQLITE_PRIVATE void sqlite3StatusUp(int, int);
+SQLITE_PRIVATE void sqlite3StatusDown(int, int);
SQLITE_PRIVATE void sqlite3StatusSet(int, int);
+/* Access to mutexes used by sqlite3_status() */
+SQLITE_PRIVATE sqlite3_mutex *sqlite3Pcache1Mutex(void);
+SQLITE_PRIVATE sqlite3_mutex *sqlite3MallocMutex(void);
+
#ifndef SQLITE_OMIT_FLOATING_POINT
SQLITE_PRIVATE int sqlite3IsNaN(double);
#else
@@ -12661,6 +13025,7 @@ SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,ExprSpan*);
SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);
+SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);
SQLITE_PRIVATE int sqlite3Init(sqlite3*, char**);
SQLITE_PRIVATE int sqlite3InitCallback(void*, int, char**, char**);
SQLITE_PRIVATE void sqlite3Pragma(Parse*,Token*,Token*,Token*,int);
@@ -12817,6 +13182,7 @@ SQLITE_PRIVATE void sqlite3LeaveMutexAndCloseZombie(sqlite3*);
SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr*);
SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr*);
SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr*, u8);
+SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr*,int);
SQLITE_PRIVATE int sqlite3ExprIsInteger(Expr*, int*);
SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr*);
SQLITE_PRIVATE int sqlite3ExprNeedsNoAffinityChange(const Expr*, char);
@@ -12974,7 +13340,7 @@ SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse);
SQLITE_PRIVATE CollSeq *sqlite3FindCollSeq(sqlite3*,u8 enc, const char*,int);
SQLITE_PRIVATE CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char*zName);
SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr);
-SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*);
+SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(Parse *pParse, Expr*, const Token*, int);
SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse*,Expr*,const char*);
SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);
SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);
@@ -13243,12 +13609,11 @@ SQLITE_PRIVATE void sqlite3MemJournalOpen(sqlite3_file *);
SQLITE_PRIVATE int sqlite3MemJournalSize(void);
SQLITE_PRIVATE int sqlite3IsMemJournal(sqlite3_file *);
+SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p);
#if SQLITE_MAX_EXPR_DEPTH>0
-SQLITE_PRIVATE void sqlite3ExprSetHeight(Parse *pParse, Expr *p);
SQLITE_PRIVATE int sqlite3SelectExprHeight(Select *);
SQLITE_PRIVATE int sqlite3ExprCheckHeight(Parse*, int);
#else
- #define sqlite3ExprSetHeight(x,y)
#define sqlite3SelectExprHeight(x) 0
#define sqlite3ExprCheckHeight(x,y)
#endif
@@ -13278,7 +13643,7 @@ SQLITE_PRIVATE void sqlite3ParserTrace(FILE*, char *);
#ifdef SQLITE_ENABLE_IOTRACE
# define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; }
SQLITE_PRIVATE void sqlite3VdbeIOTraceSql(Vdbe*);
-SQLITE_PRIVATE void (*sqlite3IoTrace)(const char*,...);
+SQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...);
#else
# define IOTRACE(A)
# define sqlite3VdbeIOTraceSql(X)
@@ -13385,16 +13750,16 @@ SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[] = {
48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 3x */
64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 4x */
80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 5x */
- 96, 97, 66, 67, 68, 69, 70, 71, 72, 73,106,107,108,109,110,111, /* 6x */
- 112, 81, 82, 83, 84, 85, 86, 87, 88, 89,122,123,124,125,126,127, /* 7x */
+ 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 6x */
+ 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 7x */
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143, /* 8x */
- 144,145,146,147,148,149,150,151,152,153,154,155,156,157,156,159, /* 9x */
+ 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159, /* 9x */
160,161,162,163,164,165,166,167,168,169,170,171,140,141,142,175, /* Ax */
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, /* Bx */
192,129,130,131,132,133,134,135,136,137,202,203,204,205,206,207, /* Cx */
208,145,146,147,148,149,150,151,152,153,218,219,220,221,222,223, /* Dx */
- 224,225,162,163,164,165,166,167,168,169,232,203,204,205,206,207, /* Ex */
- 239,240,241,242,243,244,245,246,247,248,249,219,220,221,222,255, /* Fx */
+ 224,225,162,163,164,165,166,167,168,169,234,235,236,237,238,239, /* Ex */
+ 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, /* Fx */
#endif
};
@@ -13474,15 +13839,30 @@ SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[256] = {
**
** EVIDENCE-OF: R-38799-08373 URI filenames can be enabled or disabled
** using the SQLITE_USE_URI=1 or SQLITE_USE_URI=0 compile-time options.
+**
+** EVIDENCE-OF: R-43642-56306 By default, URI handling is globally
+** disabled. The default value may be changed by compiling with the
+** SQLITE_USE_URI symbol defined.
*/
#ifndef SQLITE_USE_URI
# define SQLITE_USE_URI 0
#endif
+/* EVIDENCE-OF: R-38720-18127 The default setting is determined by the
+** SQLITE_ALLOW_COVERING_INDEX_SCAN compile-time option, or is "on" if
+** that compile-time option is omitted.
+*/
#ifndef SQLITE_ALLOW_COVERING_INDEX_SCAN
# define SQLITE_ALLOW_COVERING_INDEX_SCAN 1
#endif
+/* The minimum PMA size is set to this value multiplied by the database
+** page size in bytes.
+*/
+#ifndef SQLITE_SORTER_PMASZ
+# define SQLITE_SORTER_PMASZ 250
+#endif
+
/*
** The following singleton contains the global configuration for
** the SQLite library.
@@ -13513,6 +13893,7 @@ SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config = {
0, /* nPage */
0, /* mxParserStack */
0, /* sharedCacheEnabled */
+ SQLITE_SORTER_PMASZ, /* szPma */
/* All the rest should always be initialized to zero */
0, /* isInit */
0, /* inProgress */
@@ -13568,8 +13949,8 @@ SQLITE_PRIVATE const Token sqlite3IntTokens[] = {
**
** IMPORTANT: Changing the pending byte to any value other than
** 0x40000000 results in an incompatible database file format!
-** Changing the pending byte during operating results in undefined
-** and dileterious behavior.
+** Changing the pending byte during operation will result in undefined
+** and incorrect behavior.
*/
#ifndef SQLITE_OMIT_WSD
SQLITE_PRIVATE int sqlite3PendingByte = 0x40000000;
@@ -13619,88 +14000,91 @@ static const char * const azCompileOpt[] = {
#define CTIMEOPT_VAL_(opt) #opt
#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
-#ifdef SQLITE_32BIT_ROWID
+#if SQLITE_32BIT_ROWID
"32BIT_ROWID",
#endif
-#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
+#if SQLITE_4_BYTE_ALIGNED_MALLOC
"4_BYTE_ALIGNED_MALLOC",
#endif
-#ifdef SQLITE_CASE_SENSITIVE_LIKE
+#if SQLITE_CASE_SENSITIVE_LIKE
"CASE_SENSITIVE_LIKE",
#endif
-#ifdef SQLITE_CHECK_PAGES
+#if SQLITE_CHECK_PAGES
"CHECK_PAGES",
#endif
-#ifdef SQLITE_COVERAGE_TEST
+#if SQLITE_COVERAGE_TEST
"COVERAGE_TEST",
#endif
-#ifdef SQLITE_DEBUG
+#if SQLITE_DEBUG
"DEBUG",
#endif
-#ifdef SQLITE_DEFAULT_LOCKING_MODE
+#if SQLITE_DEFAULT_LOCKING_MODE
"DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
#endif
#if defined(SQLITE_DEFAULT_MMAP_SIZE) && !defined(SQLITE_DEFAULT_MMAP_SIZE_xc)
"DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
#endif
-#ifdef SQLITE_DISABLE_DIRSYNC
+#if SQLITE_DISABLE_DIRSYNC
"DISABLE_DIRSYNC",
#endif
-#ifdef SQLITE_DISABLE_LFS
+#if SQLITE_DISABLE_LFS
"DISABLE_LFS",
#endif
-#ifdef SQLITE_ENABLE_ATOMIC_WRITE
+#if SQLITE_ENABLE_API_ARMOR
+ "ENABLE_API_ARMOR",
+#endif
+#if SQLITE_ENABLE_ATOMIC_WRITE
"ENABLE_ATOMIC_WRITE",
#endif
-#ifdef SQLITE_ENABLE_CEROD
+#if SQLITE_ENABLE_CEROD
"ENABLE_CEROD",
#endif
-#ifdef SQLITE_ENABLE_COLUMN_METADATA
+#if SQLITE_ENABLE_COLUMN_METADATA
"ENABLE_COLUMN_METADATA",
#endif
-#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
+#if SQLITE_ENABLE_EXPENSIVE_ASSERT
"ENABLE_EXPENSIVE_ASSERT",
#endif
-#ifdef SQLITE_ENABLE_FTS1
+#if SQLITE_ENABLE_FTS1
"ENABLE_FTS1",
#endif
-#ifdef SQLITE_ENABLE_FTS2
+#if SQLITE_ENABLE_FTS2
"ENABLE_FTS2",
#endif
-#ifdef SQLITE_ENABLE_FTS3
+#if SQLITE_ENABLE_FTS3
"ENABLE_FTS3",
#endif
-#ifdef SQLITE_ENABLE_FTS3_PARENTHESIS
+#if SQLITE_ENABLE_FTS3_PARENTHESIS
"ENABLE_FTS3_PARENTHESIS",
#endif
-#ifdef SQLITE_ENABLE_FTS4
+#if SQLITE_ENABLE_FTS4
"ENABLE_FTS4",
#endif
-#ifdef SQLITE_ENABLE_ICU
+#if SQLITE_ENABLE_ICU
"ENABLE_ICU",
#endif
-#ifdef SQLITE_ENABLE_IOTRACE
+#if SQLITE_ENABLE_IOTRACE
"ENABLE_IOTRACE",
#endif
-#ifdef SQLITE_ENABLE_LOAD_EXTENSION
+#if SQLITE_ENABLE_LOAD_EXTENSION
"ENABLE_LOAD_EXTENSION",
#endif
-#ifdef SQLITE_ENABLE_LOCKING_STYLE
+#if SQLITE_ENABLE_LOCKING_STYLE
"ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
#endif
-#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
+#if SQLITE_ENABLE_MEMORY_MANAGEMENT
"ENABLE_MEMORY_MANAGEMENT",
#endif
-#ifdef SQLITE_ENABLE_MEMSYS3
+#if SQLITE_ENABLE_MEMSYS3
"ENABLE_MEMSYS3",
#endif
-#ifdef SQLITE_ENABLE_MEMSYS5
+#if SQLITE_ENABLE_MEMSYS5
"ENABLE_MEMSYS5",
#endif
-#ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK
+#if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
"ENABLE_OVERSIZE_CELL_CHECK",
#endif
-#ifdef SQLITE_ENABLE_RTREE
+#if SQLITE_ENABLE_RTREE
"ENABLE_RTREE",
#endif
#if defined(SQLITE_ENABLE_STAT4)
@@ -13708,31 +14092,31 @@ static const char * const azCompileOpt[] = {
#elif defined(SQLITE_ENABLE_STAT3)
"ENABLE_STAT3",
#endif
-#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
+#if SQLITE_ENABLE_UNLOCK_NOTIFY
"ENABLE_UNLOCK_NOTIFY",
#endif
-#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
+#if SQLITE_ENABLE_UPDATE_DELETE_LIMIT
"ENABLE_UPDATE_DELETE_LIMIT",
#endif
-#ifdef SQLITE_HAS_CODEC
+#if SQLITE_HAS_CODEC
"HAS_CODEC",
#endif
-#ifdef SQLITE_HAVE_ISNAN
+#if HAVE_ISNAN || SQLITE_HAVE_ISNAN
"HAVE_ISNAN",
#endif
-#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
+#if SQLITE_HOMEGROWN_RECURSIVE_MUTEX
"HOMEGROWN_RECURSIVE_MUTEX",
#endif
-#ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS
+#if SQLITE_IGNORE_AFP_LOCK_ERRORS
"IGNORE_AFP_LOCK_ERRORS",
#endif
-#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS
+#if SQLITE_IGNORE_FLOCK_LOCK_ERRORS
"IGNORE_FLOCK_LOCK_ERRORS",
#endif
#ifdef SQLITE_INT64_TYPE
"INT64_TYPE",
#endif
-#ifdef SQLITE_LOCK_TRACE
+#if SQLITE_LOCK_TRACE
"LOCK_TRACE",
#endif
#if defined(SQLITE_MAX_MMAP_SIZE) && !defined(SQLITE_MAX_MMAP_SIZE_xc)
@@ -13741,226 +14125,226 @@ static const char * const azCompileOpt[] = {
#ifdef SQLITE_MAX_SCHEMA_RETRY
"MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),
#endif
-#ifdef SQLITE_MEMDEBUG
+#if SQLITE_MEMDEBUG
"MEMDEBUG",
#endif
-#ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT
+#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT
"MIXED_ENDIAN_64BIT_FLOAT",
#endif
-#ifdef SQLITE_NO_SYNC
+#if SQLITE_NO_SYNC
"NO_SYNC",
#endif
-#ifdef SQLITE_OMIT_ALTERTABLE
+#if SQLITE_OMIT_ALTERTABLE
"OMIT_ALTERTABLE",
#endif
-#ifdef SQLITE_OMIT_ANALYZE
+#if SQLITE_OMIT_ANALYZE
"OMIT_ANALYZE",
#endif
-#ifdef SQLITE_OMIT_ATTACH
+#if SQLITE_OMIT_ATTACH
"OMIT_ATTACH",
#endif
-#ifdef SQLITE_OMIT_AUTHORIZATION
+#if SQLITE_OMIT_AUTHORIZATION
"OMIT_AUTHORIZATION",
#endif
-#ifdef SQLITE_OMIT_AUTOINCREMENT
+#if SQLITE_OMIT_AUTOINCREMENT
"OMIT_AUTOINCREMENT",
#endif
-#ifdef SQLITE_OMIT_AUTOINIT
+#if SQLITE_OMIT_AUTOINIT
"OMIT_AUTOINIT",
#endif
-#ifdef SQLITE_OMIT_AUTOMATIC_INDEX
+#if SQLITE_OMIT_AUTOMATIC_INDEX
"OMIT_AUTOMATIC_INDEX",
#endif
-#ifdef SQLITE_OMIT_AUTORESET
+#if SQLITE_OMIT_AUTORESET
"OMIT_AUTORESET",
#endif
-#ifdef SQLITE_OMIT_AUTOVACUUM
+#if SQLITE_OMIT_AUTOVACUUM
"OMIT_AUTOVACUUM",
#endif
-#ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION
+#if SQLITE_OMIT_BETWEEN_OPTIMIZATION
"OMIT_BETWEEN_OPTIMIZATION",
#endif
-#ifdef SQLITE_OMIT_BLOB_LITERAL
+#if SQLITE_OMIT_BLOB_LITERAL
"OMIT_BLOB_LITERAL",
#endif
-#ifdef SQLITE_OMIT_BTREECOUNT
+#if SQLITE_OMIT_BTREECOUNT
"OMIT_BTREECOUNT",
#endif
-#ifdef SQLITE_OMIT_BUILTIN_TEST
+#if SQLITE_OMIT_BUILTIN_TEST
"OMIT_BUILTIN_TEST",
#endif
-#ifdef SQLITE_OMIT_CAST
+#if SQLITE_OMIT_CAST
"OMIT_CAST",
#endif
-#ifdef SQLITE_OMIT_CHECK
+#if SQLITE_OMIT_CHECK
"OMIT_CHECK",
#endif
-#ifdef SQLITE_OMIT_COMPLETE
+#if SQLITE_OMIT_COMPLETE
"OMIT_COMPLETE",
#endif
-#ifdef SQLITE_OMIT_COMPOUND_SELECT
+#if SQLITE_OMIT_COMPOUND_SELECT
"OMIT_COMPOUND_SELECT",
#endif
-#ifdef SQLITE_OMIT_CTE
+#if SQLITE_OMIT_CTE
"OMIT_CTE",
#endif
-#ifdef SQLITE_OMIT_DATETIME_FUNCS
+#if SQLITE_OMIT_DATETIME_FUNCS
"OMIT_DATETIME_FUNCS",
#endif
-#ifdef SQLITE_OMIT_DECLTYPE
+#if SQLITE_OMIT_DECLTYPE
"OMIT_DECLTYPE",
#endif
-#ifdef SQLITE_OMIT_DEPRECATED
+#if SQLITE_OMIT_DEPRECATED
"OMIT_DEPRECATED",
#endif
-#ifdef SQLITE_OMIT_DISKIO
+#if SQLITE_OMIT_DISKIO
"OMIT_DISKIO",
#endif
-#ifdef SQLITE_OMIT_EXPLAIN
+#if SQLITE_OMIT_EXPLAIN
"OMIT_EXPLAIN",
#endif
-#ifdef SQLITE_OMIT_FLAG_PRAGMAS
+#if SQLITE_OMIT_FLAG_PRAGMAS
"OMIT_FLAG_PRAGMAS",
#endif
-#ifdef SQLITE_OMIT_FLOATING_POINT
+#if SQLITE_OMIT_FLOATING_POINT
"OMIT_FLOATING_POINT",
#endif
-#ifdef SQLITE_OMIT_FOREIGN_KEY
+#if SQLITE_OMIT_FOREIGN_KEY
"OMIT_FOREIGN_KEY",
#endif
-#ifdef SQLITE_OMIT_GET_TABLE
+#if SQLITE_OMIT_GET_TABLE
"OMIT_GET_TABLE",
#endif
-#ifdef SQLITE_OMIT_INCRBLOB
+#if SQLITE_OMIT_INCRBLOB
"OMIT_INCRBLOB",
#endif
-#ifdef SQLITE_OMIT_INTEGRITY_CHECK
+#if SQLITE_OMIT_INTEGRITY_CHECK
"OMIT_INTEGRITY_CHECK",
#endif
-#ifdef SQLITE_OMIT_LIKE_OPTIMIZATION
+#if SQLITE_OMIT_LIKE_OPTIMIZATION
"OMIT_LIKE_OPTIMIZATION",
#endif
-#ifdef SQLITE_OMIT_LOAD_EXTENSION
+#if SQLITE_OMIT_LOAD_EXTENSION
"OMIT_LOAD_EXTENSION",
#endif
-#ifdef SQLITE_OMIT_LOCALTIME
+#if SQLITE_OMIT_LOCALTIME
"OMIT_LOCALTIME",
#endif
-#ifdef SQLITE_OMIT_LOOKASIDE
+#if SQLITE_OMIT_LOOKASIDE
"OMIT_LOOKASIDE",
#endif
-#ifdef SQLITE_OMIT_MEMORYDB
+#if SQLITE_OMIT_MEMORYDB
"OMIT_MEMORYDB",
#endif
-#ifdef SQLITE_OMIT_OR_OPTIMIZATION
+#if SQLITE_OMIT_OR_OPTIMIZATION
"OMIT_OR_OPTIMIZATION",
#endif
-#ifdef SQLITE_OMIT_PAGER_PRAGMAS
+#if SQLITE_OMIT_PAGER_PRAGMAS
"OMIT_PAGER_PRAGMAS",
#endif
-#ifdef SQLITE_OMIT_PRAGMA
+#if SQLITE_OMIT_PRAGMA
"OMIT_PRAGMA",
#endif
-#ifdef SQLITE_OMIT_PROGRESS_CALLBACK
+#if SQLITE_OMIT_PROGRESS_CALLBACK
"OMIT_PROGRESS_CALLBACK",
#endif
-#ifdef SQLITE_OMIT_QUICKBALANCE
+#if SQLITE_OMIT_QUICKBALANCE
"OMIT_QUICKBALANCE",
#endif
-#ifdef SQLITE_OMIT_REINDEX
+#if SQLITE_OMIT_REINDEX
"OMIT_REINDEX",
#endif
-#ifdef SQLITE_OMIT_SCHEMA_PRAGMAS
+#if SQLITE_OMIT_SCHEMA_PRAGMAS
"OMIT_SCHEMA_PRAGMAS",
#endif
-#ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
+#if SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
"OMIT_SCHEMA_VERSION_PRAGMAS",
#endif
-#ifdef SQLITE_OMIT_SHARED_CACHE
+#if SQLITE_OMIT_SHARED_CACHE
"OMIT_SHARED_CACHE",
#endif
-#ifdef SQLITE_OMIT_SUBQUERY
+#if SQLITE_OMIT_SUBQUERY
"OMIT_SUBQUERY",
#endif
-#ifdef SQLITE_OMIT_TCL_VARIABLE
+#if SQLITE_OMIT_TCL_VARIABLE
"OMIT_TCL_VARIABLE",
#endif
-#ifdef SQLITE_OMIT_TEMPDB
+#if SQLITE_OMIT_TEMPDB
"OMIT_TEMPDB",
#endif
-#ifdef SQLITE_OMIT_TRACE
+#if SQLITE_OMIT_TRACE
"OMIT_TRACE",
#endif
-#ifdef SQLITE_OMIT_TRIGGER
+#if SQLITE_OMIT_TRIGGER
"OMIT_TRIGGER",
#endif
-#ifdef SQLITE_OMIT_TRUNCATE_OPTIMIZATION
+#if SQLITE_OMIT_TRUNCATE_OPTIMIZATION
"OMIT_TRUNCATE_OPTIMIZATION",
#endif
-#ifdef SQLITE_OMIT_UTF16
+#if SQLITE_OMIT_UTF16
"OMIT_UTF16",
#endif
-#ifdef SQLITE_OMIT_VACUUM
+#if SQLITE_OMIT_VACUUM
"OMIT_VACUUM",
#endif
-#ifdef SQLITE_OMIT_VIEW
+#if SQLITE_OMIT_VIEW
"OMIT_VIEW",
#endif
-#ifdef SQLITE_OMIT_VIRTUALTABLE
+#if SQLITE_OMIT_VIRTUALTABLE
"OMIT_VIRTUALTABLE",
#endif
-#ifdef SQLITE_OMIT_WAL
+#if SQLITE_OMIT_WAL
"OMIT_WAL",
#endif
-#ifdef SQLITE_OMIT_WSD
+#if SQLITE_OMIT_WSD
"OMIT_WSD",
#endif
-#ifdef SQLITE_OMIT_XFER_OPT
+#if SQLITE_OMIT_XFER_OPT
"OMIT_XFER_OPT",
#endif
-#ifdef SQLITE_PERFORMANCE_TRACE
+#if SQLITE_PERFORMANCE_TRACE
"PERFORMANCE_TRACE",
#endif
-#ifdef SQLITE_PROXY_DEBUG
+#if SQLITE_PROXY_DEBUG
"PROXY_DEBUG",
#endif
-#ifdef SQLITE_RTREE_INT_ONLY
+#if SQLITE_RTREE_INT_ONLY
"RTREE_INT_ONLY",
#endif
-#ifdef SQLITE_SECURE_DELETE
+#if SQLITE_SECURE_DELETE
"SECURE_DELETE",
#endif
-#ifdef SQLITE_SMALL_STACK
+#if SQLITE_SMALL_STACK
"SMALL_STACK",
#endif
-#ifdef SQLITE_SOUNDEX
+#if SQLITE_SOUNDEX
"SOUNDEX",
#endif
-#ifdef SQLITE_SYSTEM_MALLOC
+#if SQLITE_SYSTEM_MALLOC
"SYSTEM_MALLOC",
#endif
-#ifdef SQLITE_TCL
+#if SQLITE_TCL
"TCL",
#endif
#if defined(SQLITE_TEMP_STORE) && !defined(SQLITE_TEMP_STORE_xc)
"TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE),
#endif
-#ifdef SQLITE_TEST
+#if SQLITE_TEST
"TEST",
#endif
#if defined(SQLITE_THREADSAFE)
"THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
#endif
-#ifdef SQLITE_USE_ALLOCA
+#if SQLITE_USE_ALLOCA
"USE_ALLOCA",
#endif
-#ifdef SQLITE_USER_AUTHENTICATION
+#if SQLITE_USER_AUTHENTICATION
"USER_AUTHENTICATION",
#endif
-#ifdef SQLITE_WIN32_MALLOC
+#if SQLITE_WIN32_MALLOC
"WIN32_MALLOC",
#endif
-#ifdef SQLITE_ZERO_MALLOC
+#if SQLITE_ZERO_MALLOC
"ZERO_MALLOC"
#endif
};
@@ -13972,8 +14356,15 @@ static const char * const azCompileOpt[] = {
** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix
** is not required for a match.
*/
-SQLITE_API int sqlite3_compileoption_used(const char *zOptName){
+SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName){
int i, n;
+
+#if SQLITE_ENABLE_API_ARMOR
+ if( zOptName==0 ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
if( sqlite3StrNICmp(zOptName, "SQLITE_", 7)==0 ) zOptName += 7;
n = sqlite3Strlen30(zOptName);
@@ -13993,7 +14384,7 @@ SQLITE_API int sqlite3_compileoption_used(const char *zOptName){
** Return the N-th compile-time option string. If N is out of range,
** return a NULL pointer.
*/
-SQLITE_API const char *sqlite3_compileoption_get(int N){
+SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N){
if( N>=0 && N<ArraySize(azCompileOpt) ){
return azCompileOpt[N];
}
@@ -14155,6 +14546,7 @@ struct VdbeFrame {
Vdbe *v; /* VM this frame belongs to */
VdbeFrame *pParent; /* Parent of this frame, or NULL if parent is main */
Op *aOp; /* Program instructions for parent frame */
+ i64 *anExec; /* Event counters from parent frame */
Mem *aMem; /* Array of memory cells for parent frame */
u8 *aOnceFlag; /* Array of OP_Once flags for parent frame */
VdbeCursor **apCsr; /* Array of Vdbe cursors for parent frame */
@@ -14167,7 +14559,8 @@ struct VdbeFrame {
int nOnceFlag; /* Number of entries in aOnceFlag */
int nChildMem; /* Number of memory cells for child frame */
int nChildCsr; /* Number of cursors for child frame */
- int nChange; /* Statement changes (Vdbe.nChanges) */
+ int nChange; /* Statement changes (Vdbe.nChange) */
+ int nDbChange; /* Value of db->nChange */
};
#define VdbeFrameMem(p) ((Mem *)&((u8 *)p)[ROUND8(sizeof(VdbeFrame))])
@@ -14318,20 +14711,22 @@ struct Explain {
*/
typedef unsigned bft; /* Bit Field Type */
+typedef struct ScanStatus ScanStatus;
+struct ScanStatus {
+ int addrExplain; /* OP_Explain for loop */
+ int addrLoop; /* Address of "loops" counter */
+ int addrVisit; /* Address of "rows visited" counter */
+ int iSelectID; /* The "Select-ID" for this loop */
+ LogEst nEst; /* Estimated output rows per loop */
+ char *zName; /* Name of table or index */
+};
+
/*
** An instance of the virtual machine. This structure contains the complete
** state of the virtual machine.
**
** The "sqlite3_stmt" structure pointer that is returned by sqlite3_prepare()
** is really a pointer to an instance of this structure.
-**
-** The Vdbe.inVtabMethod variable is set to non-zero for the duration of
-** any virtual table method invocations made by the vdbe program. It is
-** set to 2 for xDestroy method calls and 1 for all other methods. This
-** variable is used for two purposes: to allow xDestroy methods to execute
-** "DROP TABLE" statements and to prevent some nasty side effects of
-** malloc failure when SQLite is invoked recursively by a virtual table
-** method function.
*/
struct Vdbe {
sqlite3 *db; /* The database connection that owns this statement */
@@ -14355,11 +14750,13 @@ struct Vdbe {
u32 cacheCtr; /* VdbeCursor row cache generation counter */
int pc; /* The program counter */
int rc; /* Value to return */
+#ifdef SQLITE_DEBUG
+ int rcApp; /* errcode set by sqlite3_result_error_code() */
+#endif
u16 nResColumn; /* Number of columns in one row of the result set */
u8 errorAction; /* Recovery action to do in case of an error */
u8 minWriteFileFormat; /* Minimum file format for writable database files */
bft explain:2; /* True if EXPLAIN present on SQL command */
- bft inVtabMethod:2; /* See comments above */
bft changeCntOn:1; /* True to update the change-counter */
bft expired:1; /* True if the VM needs to be recompiled */
bft runOnlyOnce:1; /* Automatically expire on reset */
@@ -14390,6 +14787,11 @@ struct Vdbe {
int nOnceFlag; /* Size of array aOnceFlag[] */
u8 *aOnceFlag; /* Flags for OP_Once */
AuxData *pAuxData; /* Linked list of auxdata allocations */
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
+ i64 *anExec; /* Number of times each op has been executed */
+ int nScan; /* Entries in aScan[] */
+ ScanStatus *aScan; /* Scan definitions for sqlite3_stmt_scanstatus() */
+#endif
};
/*
@@ -14514,10 +14916,32 @@ SQLITE_PRIVATE int sqlite3VdbeMemExpandBlob(Mem *);
*/
typedef struct sqlite3StatType sqlite3StatType;
static SQLITE_WSD struct sqlite3StatType {
- int nowValue[10]; /* Current value */
- int mxValue[10]; /* Maximum value */
+#if SQLITE_PTRSIZE>4
+ sqlite3_int64 nowValue[10]; /* Current value */
+ sqlite3_int64 mxValue[10]; /* Maximum value */
+#else
+ u32 nowValue[10]; /* Current value */
+ u32 mxValue[10]; /* Maximum value */
+#endif
} sqlite3Stat = { {0,}, {0,} };
+/*
+** Elements of sqlite3Stat[] are protected by either the memory allocator
+** mutex, or by the pcache1 mutex. The following array determines which.
+*/
+static const char statMutex[] = {
+ 0, /* SQLITE_STATUS_MEMORY_USED */
+ 1, /* SQLITE_STATUS_PAGECACHE_USED */
+ 1, /* SQLITE_STATUS_PAGECACHE_OVERFLOW */
+ 0, /* SQLITE_STATUS_SCRATCH_USED */
+ 0, /* SQLITE_STATUS_SCRATCH_OVERFLOW */
+ 0, /* SQLITE_STATUS_MALLOC_SIZE */
+ 0, /* SQLITE_STATUS_PARSER_STACK */
+ 1, /* SQLITE_STATUS_PAGECACHE_SIZE */
+ 0, /* SQLITE_STATUS_SCRATCH_SIZE */
+ 0, /* SQLITE_STATUS_MALLOC_COUNT */
+};
+
/* The "wsdStat" macro will resolve to the status information
** state vector. If writable static data is unsupported on the target,
@@ -14534,33 +14958,60 @@ static SQLITE_WSD struct sqlite3StatType {
#endif
/*
-** Return the current value of a status parameter.
+** Return the current value of a status parameter. The caller must
+** be holding the appropriate mutex.
*/
-SQLITE_PRIVATE int sqlite3StatusValue(int op){
+SQLITE_PRIVATE sqlite3_int64 sqlite3StatusValue(int op){
wsdStatInit;
assert( op>=0 && op<ArraySize(wsdStat.nowValue) );
+ assert( op>=0 && op<ArraySize(statMutex) );
+ assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()
+ : sqlite3MallocMutex()) );
return wsdStat.nowValue[op];
}
/*
-** Add N to the value of a status record. It is assumed that the
-** caller holds appropriate locks.
+** Add N to the value of a status record. The caller must hold the
+** appropriate mutex. (Locking is checked by assert()).
+**
+** The StatusUp() routine can accept positive or negative values for N.
+** The value of N is added to the current status value and the high-water
+** mark is adjusted if necessary.
+**
+** The StatusDown() routine lowers the current value by N. The highwater
+** mark is unchanged. N must be non-negative for StatusDown().
*/
-SQLITE_PRIVATE void sqlite3StatusAdd(int op, int N){
+SQLITE_PRIVATE void sqlite3StatusUp(int op, int N){
wsdStatInit;
assert( op>=0 && op<ArraySize(wsdStat.nowValue) );
+ assert( op>=0 && op<ArraySize(statMutex) );
+ assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()
+ : sqlite3MallocMutex()) );
wsdStat.nowValue[op] += N;
if( wsdStat.nowValue[op]>wsdStat.mxValue[op] ){
wsdStat.mxValue[op] = wsdStat.nowValue[op];
}
}
+SQLITE_PRIVATE void sqlite3StatusDown(int op, int N){
+ wsdStatInit;
+ assert( N>=0 );
+ assert( op>=0 && op<ArraySize(statMutex) );
+ assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()
+ : sqlite3MallocMutex()) );
+ assert( op>=0 && op<ArraySize(wsdStat.nowValue) );
+ wsdStat.nowValue[op] -= N;
+}
/*
-** Set the value of a status to X.
+** Set the value of a status to X. The highwater mark is adjusted if
+** necessary. The caller must hold the appropriate mutex.
*/
SQLITE_PRIVATE void sqlite3StatusSet(int op, int X){
wsdStatInit;
assert( op>=0 && op<ArraySize(wsdStat.nowValue) );
+ assert( op>=0 && op<ArraySize(statMutex) );
+ assert( sqlite3_mutex_held(statMutex[op] ? sqlite3Pcache1Mutex()
+ : sqlite3MallocMutex()) );
wsdStat.nowValue[op] = X;
if( wsdStat.nowValue[op]>wsdStat.mxValue[op] ){
wsdStat.mxValue[op] = wsdStat.nowValue[op];
@@ -14569,28 +15020,50 @@ SQLITE_PRIVATE void sqlite3StatusSet(int op, int X){
/*
** Query status information.
-**
-** This implementation assumes that reading or writing an aligned
-** 32-bit integer is an atomic operation. If that assumption is not true,
-** then this routine is not threadsafe.
*/
-SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){
+SQLITE_API int SQLITE_STDCALL sqlite3_status64(
+ int op,
+ sqlite3_int64 *pCurrent,
+ sqlite3_int64 *pHighwater,
+ int resetFlag
+){
+ sqlite3_mutex *pMutex;
wsdStatInit;
if( op<0 || op>=ArraySize(wsdStat.nowValue) ){
return SQLITE_MISUSE_BKPT;
}
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;
+#endif
+ pMutex = statMutex[op] ? sqlite3Pcache1Mutex() : sqlite3MallocMutex();
+ sqlite3_mutex_enter(pMutex);
*pCurrent = wsdStat.nowValue[op];
*pHighwater = wsdStat.mxValue[op];
if( resetFlag ){
wsdStat.mxValue[op] = wsdStat.nowValue[op];
}
+ sqlite3_mutex_leave(pMutex);
+ (void)pMutex; /* Prevent warning when SQLITE_THREADSAFE=0 */
return SQLITE_OK;
}
+SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){
+ sqlite3_int64 iCur, iHwtr;
+ int rc;
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;
+#endif
+ rc = sqlite3_status64(op, &iCur, &iHwtr, resetFlag);
+ if( rc==0 ){
+ *pCurrent = (int)iCur;
+ *pHighwater = (int)iHwtr;
+ }
+ return rc;
+}
/*
** Query status information for a single database connection
*/
-SQLITE_API int sqlite3_db_status(
+SQLITE_API int SQLITE_STDCALL sqlite3_db_status(
sqlite3 *db, /* The database connection whose status is desired */
int op, /* Status verb */
int *pCurrent, /* Write current value here */
@@ -14598,6 +15071,11 @@ SQLITE_API int sqlite3_db_status(
int resetFlag /* Reset high-water mark if true */
){
int rc = SQLITE_OK; /* Return code */
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) || pCurrent==0|| pHighwater==0 ){
+ return SQLITE_MISUSE_BKPT;
+ }
+#endif
sqlite3_mutex_enter(db->mutex);
switch( op ){
case SQLITE_DBSTATUS_LOOKASIDE_USED: {
@@ -14776,7 +15254,7 @@ SQLITE_API int sqlite3_db_status(
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
** All other code has file scope.
**
-** SQLite processes all times and dates as Julian Day numbers. The
+** SQLite processes all times and dates as julian day numbers. The
** dates and times are stored as the number of days since noon
** in Greenwich on November 24, 4714 B.C. according to the Gregorian
** calendar system.
@@ -14791,7 +15269,7 @@ SQLITE_API int sqlite3_db_status(
**
** The Gregorian calendar system is used for all dates and times,
** even those that predate the Gregorian calendar. Historians usually
-** use the Julian calendar for dates prior to 1582-10-15 and for some
+** use the julian calendar for dates prior to 1582-10-15 and for some
** dates afterwards, depending on locale. Beware of this difference.
**
** The conversion algorithms are implemented based on descriptions
@@ -15063,7 +15541,7 @@ static int setDateTimeToCurrent(sqlite3_context *context, DateTime *p){
}
/*
-** Attempt to parse the given string into a Julian Day Number. Return
+** Attempt to parse the given string into a julian day number. Return
** the number of errors.
**
** The following are acceptable forms for the input string:
@@ -15171,8 +15649,9 @@ static void clearYMD_HMS_TZ(DateTime *p){
** already, check for an MSVC build environment that provides
** localtime_s().
*/
-#if !defined(HAVE_LOCALTIME_R) && !defined(HAVE_LOCALTIME_S) && \
- defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)
+#if !HAVE_LOCALTIME_R && !HAVE_LOCALTIME_S \
+ && defined(_MSC_VER) && defined(_CRT_INSECURE_DEPRECATE)
+#undef HAVE_LOCALTIME_S
#define HAVE_LOCALTIME_S 1
#endif
@@ -15192,8 +15671,7 @@ static void clearYMD_HMS_TZ(DateTime *p){
*/
static int osLocaltime(time_t *t, struct tm *pTm){
int rc;
-#if (!defined(HAVE_LOCALTIME_R) || !HAVE_LOCALTIME_R) \
- && (!defined(HAVE_LOCALTIME_S) || !HAVE_LOCALTIME_S)
+#if !HAVE_LOCALTIME_R && !HAVE_LOCALTIME_S
struct tm *pX;
#if SQLITE_THREADSAFE>0
sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
@@ -15210,7 +15688,7 @@ static int osLocaltime(time_t *t, struct tm *pTm){
#ifndef SQLITE_OMIT_BUILTIN_TEST
if( sqlite3GlobalConfig.bLocaltimeFault ) return 1;
#endif
-#if defined(HAVE_LOCALTIME_R) && HAVE_LOCALTIME_R
+#if HAVE_LOCALTIME_R
rc = localtime_r(t, pTm)==0;
#else
rc = localtime_s(pTm, t);
@@ -15634,7 +16112,7 @@ static void dateFunc(
** %f ** fractional seconds SS.SSS
** %H hour 00-24
** %j day of year 000-366
-** %J ** Julian day number
+** %J ** julian day number
** %m month 01-12
** %M minute 00-59
** %s seconds since 1970-01-01
@@ -15654,8 +16132,10 @@ static void strftimeFunc(
size_t i,j;
char *z;
sqlite3 *db;
- const char *zFmt = (const char*)sqlite3_value_text(argv[0]);
+ const char *zFmt;
char zBuf[100];
+ if( argc==0 ) return;
+ zFmt = (const char*)sqlite3_value_text(argv[0]);
if( zFmt==0 || isDate(context, argc-1, argv+1, &x) ) return;
db = sqlite3_context_db_handle(context);
for(i=0, n=1; zFmt[i]; i++, n++){
@@ -15849,7 +16329,7 @@ static void currentTimeFunc(
iT = sqlite3StmtCurrentTime(context);
if( iT<=0 ) return;
t = iT/1000 - 10000*(sqlite3_int64)21086676;
-#ifdef HAVE_GMTIME_R
+#if HAVE_GMTIME_R
pTm = gmtime_r(&t, &sNow);
#else
sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
@@ -16207,7 +16687,7 @@ static sqlite3_vfs * SQLITE_WSD vfsList = 0;
** Locate a VFS by name. If no name is given, simply return the
** first VFS on the list.
*/
-SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){
+SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfs){
sqlite3_vfs *pVfs = 0;
#if SQLITE_THREADSAFE
sqlite3_mutex *mutex;
@@ -16253,12 +16733,16 @@ static void vfsUnlink(sqlite3_vfs *pVfs){
** VFS multiple times. The new VFS becomes the default if makeDflt is
** true.
*/
-SQLITE_API int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){
MUTEX_LOGIC(sqlite3_mutex *mutex;)
#ifndef SQLITE_OMIT_AUTOINIT
int rc = sqlite3_initialize();
if( rc ) return rc;
#endif
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( pVfs==0 ) return SQLITE_MISUSE_BKPT;
+#endif
+
MUTEX_LOGIC( mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )
sqlite3_mutex_enter(mutex);
vfsUnlink(pVfs);
@@ -16277,7 +16761,7 @@ SQLITE_API int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){
/*
** Unregister a VFS so that it is no longer accessible.
*/
-SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
#if SQLITE_THREADSAFE
sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
@@ -16519,9 +17003,9 @@ static malloc_zone_t* _sqliteZone_;
** The malloc.h header file is needed for malloc_usable_size() function
** on some systems (e.g. Linux).
*/
-#if defined(HAVE_MALLOC_H) && defined(HAVE_MALLOC_USABLE_SIZE)
-# define SQLITE_USE_MALLOC_H
-# define SQLITE_USE_MALLOC_USABLE_SIZE
+#if HAVE_MALLOC_H && HAVE_MALLOC_USABLE_SIZE
+# define SQLITE_USE_MALLOC_H 1
+# define SQLITE_USE_MALLOC_USABLE_SIZE 1
/*
** The MSVCRT has malloc_usable_size(), but it is called _msize(). The
** use of _msize() is automatic, but can be disabled by compiling with
@@ -18613,9 +19097,10 @@ SQLITE_PRIVATE int sqlite3MutexEnd(void){
/*
** Retrieve a pointer to a static mutex or allocate a new dynamic one.
*/
-SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int id){
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int id){
#ifndef SQLITE_OMIT_AUTOINIT
if( id<=SQLITE_MUTEX_RECURSIVE && sqlite3_initialize() ) return 0;
+ if( id>SQLITE_MUTEX_RECURSIVE && sqlite3MutexInit() ) return 0;
#endif
return sqlite3GlobalConfig.mutex.xMutexAlloc(id);
}
@@ -18631,7 +19116,7 @@ SQLITE_PRIVATE sqlite3_mutex *sqlite3MutexAlloc(int id){
/*
** Free a dynamic mutex.
*/
-SQLITE_API void sqlite3_mutex_free(sqlite3_mutex *p){
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex *p){
if( p ){
sqlite3GlobalConfig.mutex.xMutexFree(p);
}
@@ -18641,7 +19126,7 @@ SQLITE_API void sqlite3_mutex_free(sqlite3_mutex *p){
** Obtain the mutex p. If some other thread already has the mutex, block
** until it can be obtained.
*/
-SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex *p){
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex *p){
if( p ){
sqlite3GlobalConfig.mutex.xMutexEnter(p);
}
@@ -18651,7 +19136,7 @@ SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex *p){
** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another
** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY.
*/
-SQLITE_API int sqlite3_mutex_try(sqlite3_mutex *p){
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex *p){
int rc = SQLITE_OK;
if( p ){
return sqlite3GlobalConfig.mutex.xMutexTry(p);
@@ -18665,7 +19150,7 @@ SQLITE_API int sqlite3_mutex_try(sqlite3_mutex *p){
** is not currently entered. If a NULL pointer is passed as an argument
** this function is a no-op.
*/
-SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex *p){
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex *p){
if( p ){
sqlite3GlobalConfig.mutex.xMutexLeave(p);
}
@@ -18676,10 +19161,10 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex *p){
** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are
** intended for use inside assert() statements.
*/
-SQLITE_API int sqlite3_mutex_held(sqlite3_mutex *p){
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex *p){
return p==0 || sqlite3GlobalConfig.mutex.xMutexHeld(p);
}
-SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex *p){
return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);
}
#endif
@@ -18809,8 +19294,12 @@ static sqlite3_mutex *debugMutexAlloc(int id){
break;
}
default: {
- assert( id-2 >= 0 );
- assert( id-2 < (int)(sizeof(aStatic)/sizeof(aStatic[0])) );
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( id-2<0 || id-2>=ArraySize(aStatic) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
pNew = &aStatic[id-2];
pNew->id = id;
break;
@@ -18825,8 +19314,13 @@ static sqlite3_mutex *debugMutexAlloc(int id){
static void debugMutexFree(sqlite3_mutex *pX){
sqlite3_debug_mutex *p = (sqlite3_debug_mutex*)pX;
assert( p->cnt==0 );
- assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE );
- sqlite3_free(p);
+ if( p->id==SQLITE_MUTEX_RECURSIVE || p->id==SQLITE_MUTEX_FAST ){
+ sqlite3_free(p);
+ }else{
+#ifdef SQLITE_ENABLE_API_ARMOR
+ (void)SQLITE_MISUSE_BKPT;
+#endif
+ }
}
/*
@@ -18937,8 +19431,10 @@ SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
*/
struct sqlite3_mutex {
pthread_mutex_t mutex; /* Mutex controlling the lock */
-#if SQLITE_MUTEX_NREF
+#if SQLITE_MUTEX_NREF || defined(SQLITE_ENABLE_API_ARMOR)
int id; /* Mutex type */
+#endif
+#if SQLITE_MUTEX_NREF
volatile int nRef; /* Number of entrances */
volatile pthread_t owner; /* Thread that is within this mutex */
int trace; /* True to trace changes */
@@ -19055,32 +19551,30 @@ static sqlite3_mutex *pthreadMutexAlloc(int iType){
pthread_mutex_init(&p->mutex, &recursiveAttr);
pthread_mutexattr_destroy(&recursiveAttr);
#endif
-#if SQLITE_MUTEX_NREF
- p->id = iType;
-#endif
}
break;
}
case SQLITE_MUTEX_FAST: {
p = sqlite3MallocZero( sizeof(*p) );
if( p ){
-#if SQLITE_MUTEX_NREF
- p->id = iType;
-#endif
pthread_mutex_init(&p->mutex, 0);
}
break;
}
default: {
- assert( iType-2 >= 0 );
- assert( iType-2 < ArraySize(staticMutexes) );
- p = &staticMutexes[iType-2];
-#if SQLITE_MUTEX_NREF
- p->id = iType;
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( iType-2<0 || iType-2>=ArraySize(staticMutexes) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
#endif
+ p = &staticMutexes[iType-2];
break;
}
}
+#if SQLITE_MUTEX_NREF || defined(SQLITE_ENABLE_API_ARMOR)
+ if( p ) p->id = iType;
+#endif
return p;
}
@@ -19092,9 +19586,18 @@ static sqlite3_mutex *pthreadMutexAlloc(int iType){
*/
static void pthreadMutexFree(sqlite3_mutex *p){
assert( p->nRef==0 );
- assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE );
- pthread_mutex_destroy(&p->mutex);
- sqlite3_free(p);
+#if SQLITE_ENABLE_API_ARMOR
+ if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE )
+#endif
+ {
+ pthread_mutex_destroy(&p->mutex);
+ sqlite3_free(p);
+ }
+#ifdef SQLITE_ENABLE_API_ARMOR
+ else{
+ (void)SQLITE_MISUSE_BKPT;
+ }
+#endif
}
/*
@@ -19564,6 +20067,17 @@ SQLITE_API int sqlite3_open_file_count = 0;
# define SQLITE_WIN32_VOLATILE volatile
#endif
+/*
+** For some Windows sub-platforms, the _beginthreadex() / _endthreadex()
+** functions are not available (e.g. those not using MSVC, Cygwin, etc).
+*/
+#if SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && \
+ SQLITE_THREADSAFE>0 && !defined(__CYGWIN__)
+# define SQLITE_OS_WIN_THREADS 1
+#else
+# define SQLITE_OS_WIN_THREADS 0
+#endif
+
#endif /* _OS_WIN_H_ */
/************** End of os_win.h **********************************************/
@@ -19646,8 +20160,8 @@ static int winMutex_isNt = -1; /* <0 means "need to query" */
*/
static LONG SQLITE_WIN32_VOLATILE winMutex_lock = 0;
-SQLITE_API int sqlite3_win32_is_nt(void); /* os_win.c */
-SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */
+SQLITE_API int SQLITE_STDCALL sqlite3_win32_is_nt(void); /* os_win.c */
+SQLITE_API void SQLITE_STDCALL sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */
static int winMutexInit(void){
/* The first to increment to 1 does actual initialization */
@@ -19739,8 +20253,8 @@ static sqlite3_mutex *winMutexAlloc(int iType){
case SQLITE_MUTEX_RECURSIVE: {
p = sqlite3MallocZero( sizeof(*p) );
if( p ){
-#ifdef SQLITE_DEBUG
p->id = iType;
+#ifdef SQLITE_DEBUG
#ifdef SQLITE_WIN32_MUTEX_TRACE_DYNAMIC
p->trace = 1;
#endif
@@ -19754,12 +20268,15 @@ static sqlite3_mutex *winMutexAlloc(int iType){
break;
}
default: {
- assert( iType-2 >= 0 );
- assert( iType-2 < ArraySize(winMutex_staticMutexes) );
- assert( winMutex_isInit==1 );
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( iType-2<0 || iType-2>=ArraySize(winMutex_staticMutexes) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
p = &winMutex_staticMutexes[iType-2];
-#ifdef SQLITE_DEBUG
p->id = iType;
+#ifdef SQLITE_DEBUG
#ifdef SQLITE_WIN32_MUTEX_TRACE_STATIC
p->trace = 1;
#endif
@@ -19778,13 +20295,15 @@ static sqlite3_mutex *winMutexAlloc(int iType){
*/
static void winMutexFree(sqlite3_mutex *p){
assert( p );
-#ifdef SQLITE_DEBUG
assert( p->nRef==0 && p->owner==0 );
- assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE );
+ if( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ){
+ DeleteCriticalSection(&p->mutex);
+ sqlite3_free(p);
+ }else{
+#ifdef SQLITE_ENABLE_API_ARMOR
+ (void)SQLITE_MISUSE_BKPT;
#endif
- assert( winMutex_isInit==1 );
- DeleteCriticalSection(&p->mutex);
- sqlite3_free(p);
+ }
}
/*
@@ -19938,7 +20457,7 @@ SQLITE_PRIVATE sqlite3_mutex_methods const *sqlite3DefaultMutex(void){
** held by SQLite. An example of non-essential memory is memory used to
** cache database pages that are not currently in use.
*/
-SQLITE_API int sqlite3_release_memory(int n){
+SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int n){
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
return sqlite3PcacheReleaseMemory(n);
#else
@@ -19994,6 +20513,13 @@ static SQLITE_WSD struct Mem0Global {
#define mem0 GLOBAL(struct Mem0Global, mem0)
/*
+** Return the memory allocator mutex. sqlite3_status() needs it.
+*/
+SQLITE_PRIVATE sqlite3_mutex *sqlite3MallocMutex(void){
+ return mem0.mutex;
+}
+
+/*
** This routine runs when the memory allocator sees that the
** total memory allocation is about to exceed the soft heap
** limit.
@@ -20015,7 +20541,7 @@ static int sqlite3MemoryAlarm(
void *pArg,
sqlite3_int64 iThreshold
){
- int nUsed;
+ sqlite3_int64 nUsed;
sqlite3_mutex_enter(mem0.mutex);
mem0.alarmCallback = xCallback;
mem0.alarmArg = pArg;
@@ -20031,7 +20557,7 @@ static int sqlite3MemoryAlarm(
** Deprecated external interface. Internal/core SQLite code
** should call sqlite3MemoryAlarm.
*/
-SQLITE_API int sqlite3_memory_alarm(
+SQLITE_API int SQLITE_STDCALL sqlite3_memory_alarm(
void(*xCallback)(void *pArg, sqlite3_int64 used,int N),
void *pArg,
sqlite3_int64 iThreshold
@@ -20044,7 +20570,7 @@ SQLITE_API int sqlite3_memory_alarm(
** Set the soft heap-size limit for the library. Passing a zero or
** negative value indicates no limit.
*/
-SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 n){
sqlite3_int64 priorLimit;
sqlite3_int64 excess;
#ifndef SQLITE_OMIT_AUTOINIT
@@ -20064,7 +20590,7 @@ SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){
if( excess>0 ) sqlite3_release_memory((int)(excess & 0x7fffffff));
return priorLimit;
}
-SQLITE_API void sqlite3_soft_heap_limit(int n){
+SQLITE_API void SQLITE_STDCALL sqlite3_soft_heap_limit(int n){
if( n<0 ) n = 0;
sqlite3_soft_heap_limit64(n);
}
@@ -20073,6 +20599,7 @@ SQLITE_API void sqlite3_soft_heap_limit(int n){
** Initialize the memory allocation subsystem.
*/
SQLITE_PRIVATE int sqlite3MallocInit(void){
+ int rc;
if( sqlite3GlobalConfig.m.xMalloc==0 ){
sqlite3MemSetDefault();
}
@@ -20108,7 +20635,9 @@ SQLITE_PRIVATE int sqlite3MallocInit(void){
sqlite3GlobalConfig.szPage = 0;
sqlite3GlobalConfig.nPage = 0;
}
- return sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);
+ rc = sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);
+ if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0));
+ return rc;
}
/*
@@ -20133,7 +20662,7 @@ SQLITE_PRIVATE void sqlite3MallocEnd(void){
/*
** Return the amount of memory currently checked out.
*/
-SQLITE_API sqlite3_int64 sqlite3_memory_used(void){
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void){
int n, mx;
sqlite3_int64 res;
sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, 0);
@@ -20146,7 +20675,7 @@ SQLITE_API sqlite3_int64 sqlite3_memory_used(void){
** checked out since either the beginning of this process
** or since the most recent reset.
*/
-SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag){
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag){
int n, mx;
sqlite3_int64 res;
sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, resetFlag);
@@ -20184,7 +20713,7 @@ static int mallocWithAlarm(int n, void **pp){
nFull = sqlite3GlobalConfig.m.xRoundup(n);
sqlite3StatusSet(SQLITE_STATUS_MALLOC_SIZE, n);
if( mem0.alarmCallback!=0 ){
- int nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
+ sqlite3_int64 nUsed = sqlite3StatusValue(SQLITE_STATUS_MEMORY_USED);
if( nUsed >= mem0.alarmThreshold - nFull ){
mem0.nearlyFull = 1;
sqlite3MallocAlarm(nFull);
@@ -20201,8 +20730,8 @@ static int mallocWithAlarm(int n, void **pp){
#endif
if( p ){
nFull = sqlite3MallocSize(p);
- sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nFull);
- sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, 1);
+ sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nFull);
+ sqlite3StatusUp(SQLITE_STATUS_MALLOC_COUNT, 1);
}
*pp = p;
return nFull;
@@ -20237,13 +20766,13 @@ SQLITE_PRIVATE void *sqlite3Malloc(u64 n){
** First make sure the memory subsystem is initialized, then do the
** allocation.
*/
-SQLITE_API void *sqlite3_malloc(int n){
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int n){
#ifndef SQLITE_OMIT_AUTOINIT
if( sqlite3_initialize() ) return 0;
#endif
return n<=0 ? 0 : sqlite3Malloc(n);
}
-SQLITE_API void *sqlite3_malloc64(sqlite3_uint64 n){
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64 n){
#ifndef SQLITE_OMIT_AUTOINIT
if( sqlite3_initialize() ) return 0;
#endif
@@ -20279,14 +20808,14 @@ SQLITE_PRIVATE void *sqlite3ScratchMalloc(int n){
p = mem0.pScratchFree;
mem0.pScratchFree = mem0.pScratchFree->pNext;
mem0.nScratchFree--;
- sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, 1);
+ sqlite3StatusUp(SQLITE_STATUS_SCRATCH_USED, 1);
sqlite3_mutex_leave(mem0.mutex);
}else{
sqlite3_mutex_leave(mem0.mutex);
p = sqlite3Malloc(n);
if( sqlite3GlobalConfig.bMemstat && p ){
sqlite3_mutex_enter(mem0.mutex);
- sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, sqlite3MallocSize(p));
+ sqlite3StatusUp(SQLITE_STATUS_SCRATCH_OVERFLOW, sqlite3MallocSize(p));
sqlite3_mutex_leave(mem0.mutex);
}
sqlite3MemdebugSetType(p, MEMTYPE_SCRATCH);
@@ -20295,11 +20824,12 @@ SQLITE_PRIVATE void *sqlite3ScratchMalloc(int n){
#if SQLITE_THREADSAFE==0 && !defined(NDEBUG)
- /* Verify that no more than two scratch allocations per thread
- ** are outstanding at one time. (This is only checked in the
- ** single-threaded case since checking in the multi-threaded case
- ** would be much more complicated.) */
- assert( scratchAllocOut<=1 );
+ /* EVIDENCE-OF: R-12970-05880 SQLite will not use more than one scratch
+ ** buffers per thread.
+ **
+ ** This can only be checked in single-threaded mode.
+ */
+ assert( scratchAllocOut==0 );
if( p ) scratchAllocOut++;
#endif
@@ -20326,19 +20856,19 @@ SQLITE_PRIVATE void sqlite3ScratchFree(void *p){
mem0.pScratchFree = pSlot;
mem0.nScratchFree++;
assert( mem0.nScratchFree <= (u32)sqlite3GlobalConfig.nScratch );
- sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_USED, -1);
+ sqlite3StatusDown(SQLITE_STATUS_SCRATCH_USED, 1);
sqlite3_mutex_leave(mem0.mutex);
}else{
/* Release memory back to the heap */
assert( sqlite3MemdebugHasType(p, MEMTYPE_SCRATCH) );
- assert( sqlite3MemdebugNoType(p, ~MEMTYPE_SCRATCH) );
+ assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_SCRATCH) );
sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
if( sqlite3GlobalConfig.bMemstat ){
int iSize = sqlite3MallocSize(p);
sqlite3_mutex_enter(mem0.mutex);
- sqlite3StatusAdd(SQLITE_STATUS_SCRATCH_OVERFLOW, -iSize);
- sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -iSize);
- sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1);
+ sqlite3StatusDown(SQLITE_STATUS_SCRATCH_OVERFLOW, iSize);
+ sqlite3StatusDown(SQLITE_STATUS_MEMORY_USED, iSize);
+ sqlite3StatusDown(SQLITE_STATUS_MALLOC_COUNT, 1);
sqlite3GlobalConfig.m.xFree(p);
sqlite3_mutex_leave(mem0.mutex);
}else{
@@ -20369,7 +20899,7 @@ SQLITE_PRIVATE int sqlite3MallocSize(void *p){
}
SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){
if( db==0 ){
- assert( sqlite3MemdebugNoType(p, ~MEMTYPE_HEAP) );
+ assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
return sqlite3MallocSize(p);
}else{
@@ -20378,13 +20908,13 @@ SQLITE_PRIVATE int sqlite3DbMallocSize(sqlite3 *db, void *p){
return db->lookaside.sz;
}else{
assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
- assert( sqlite3MemdebugNoType(p, ~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
+ assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
return sqlite3GlobalConfig.m.xSize(p);
}
}
}
-SQLITE_API sqlite3_uint64 sqlite3_msize(void *p){
- assert( sqlite3MemdebugNoType(p, ~MEMTYPE_HEAP) );
+SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void *p){
+ assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
return (sqlite3_uint64)sqlite3GlobalConfig.m.xSize(p);
}
@@ -20392,14 +20922,14 @@ SQLITE_API sqlite3_uint64 sqlite3_msize(void *p){
/*
** Free memory previously obtained from sqlite3Malloc().
*/
-SQLITE_API void sqlite3_free(void *p){
+SQLITE_API void SQLITE_STDCALL sqlite3_free(void *p){
if( p==0 ) return; /* IMP: R-49053-54554 */
assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
- assert( sqlite3MemdebugNoType(p, ~MEMTYPE_HEAP) );
+ assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
if( sqlite3GlobalConfig.bMemstat ){
sqlite3_mutex_enter(mem0.mutex);
- sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, -sqlite3MallocSize(p));
- sqlite3StatusAdd(SQLITE_STATUS_MALLOC_COUNT, -1);
+ sqlite3StatusDown(SQLITE_STATUS_MEMORY_USED, sqlite3MallocSize(p));
+ sqlite3StatusDown(SQLITE_STATUS_MALLOC_COUNT, 1);
sqlite3GlobalConfig.m.xFree(p);
sqlite3_mutex_leave(mem0.mutex);
}else{
@@ -20440,7 +20970,7 @@ SQLITE_PRIVATE void sqlite3DbFree(sqlite3 *db, void *p){
}
}
assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
- assert( sqlite3MemdebugNoType(p, ~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
+ assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
assert( db!=0 || sqlite3MemdebugNoType(p, MEMTYPE_LOOKASIDE) );
sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
sqlite3_free(p);
@@ -20453,7 +20983,7 @@ SQLITE_PRIVATE void *sqlite3Realloc(void *pOld, u64 nBytes){
int nOld, nNew, nDiff;
void *pNew;
assert( sqlite3MemdebugHasType(pOld, MEMTYPE_HEAP) );
- assert( sqlite3MemdebugNoType(pOld, ~MEMTYPE_HEAP) );
+ assert( sqlite3MemdebugNoType(pOld, (u8)~MEMTYPE_HEAP) );
if( pOld==0 ){
return sqlite3Malloc(nBytes); /* IMP: R-04300-56712 */
}
@@ -20487,7 +21017,7 @@ SQLITE_PRIVATE void *sqlite3Realloc(void *pOld, u64 nBytes){
}
if( pNew ){
nNew = sqlite3MallocSize(pNew);
- sqlite3StatusAdd(SQLITE_STATUS_MEMORY_USED, nNew-nOld);
+ sqlite3StatusUp(SQLITE_STATUS_MEMORY_USED, nNew-nOld);
}
sqlite3_mutex_leave(mem0.mutex);
}else{
@@ -20501,14 +21031,14 @@ SQLITE_PRIVATE void *sqlite3Realloc(void *pOld, u64 nBytes){
** The public interface to sqlite3Realloc. Make sure that the memory
** subsystem is initialized prior to invoking sqliteRealloc.
*/
-SQLITE_API void *sqlite3_realloc(void *pOld, int n){
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void *pOld, int n){
#ifndef SQLITE_OMIT_AUTOINIT
if( sqlite3_initialize() ) return 0;
#endif
if( n<0 ) n = 0; /* IMP: R-26507-47431 */
return sqlite3Realloc(pOld, n);
}
-SQLITE_API void *sqlite3_realloc64(void *pOld, sqlite3_uint64 n){
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void *pOld, sqlite3_uint64 n){
#ifndef SQLITE_OMIT_AUTOINIT
if( sqlite3_initialize() ) return 0;
#endif
@@ -20620,7 +21150,7 @@ SQLITE_PRIVATE void *sqlite3DbRealloc(sqlite3 *db, void *p, u64 n){
}
}else{
assert( sqlite3MemdebugHasType(p, (MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
- assert( sqlite3MemdebugNoType(p, ~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
+ assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
sqlite3MemdebugSetType(p, MEMTYPE_HEAP);
pNew = sqlite3_realloc64(p, n);
if( !pNew ){
@@ -20750,17 +21280,6 @@ SQLITE_PRIVATE int sqlite3ApiExit(sqlite3* db, int rc){
*/
/*
-** If the strchrnul() library function is available, then set
-** HAVE_STRCHRNUL. If that routine is not available, this module
-** will supply its own. The built-in version is slower than
-** the glibc version so the glibc version is definitely preferred.
-*/
-#if !defined(HAVE_STRCHRNUL)
-# define HAVE_STRCHRNUL 0
-#endif
-
-
-/*
** Conversion types fall into various categories as defined by the
** following enumeration.
*/
@@ -21007,15 +21526,19 @@ SQLITE_PRIVATE void sqlite3VXPrintf(
}
if( width<0 ){
flag_leftjustify = 1;
- width = -width;
+ width = width >= -2147483647 ? -width : 0;
}
c = *++fmt;
}else{
+ unsigned wx = 0;
while( c>='0' && c<='9' ){
- width = width*10 + c - '0';
+ wx = wx*10 + c - '0';
c = *++fmt;
}
+ testcase( wx>0x7fffffff );
+ width = wx & 0x7fffffff;
}
+
/* Get the precision */
if( c=='.' ){
precision = 0;
@@ -21026,13 +21549,18 @@ SQLITE_PRIVATE void sqlite3VXPrintf(
}else{
precision = va_arg(ap,int);
}
- if( precision<0 ) precision = -precision;
c = *++fmt;
+ if( precision<0 ){
+ precision = precision >= -2147483647 ? -precision : -1;
+ }
}else{
+ unsigned px = 0;
while( c>='0' && c<='9' ){
- precision = precision*10 + c - '0';
+ px = px*10 + c - '0';
c = *++fmt;
}
+ testcase( px>0x7fffffff );
+ precision = px & 0x7fffffff;
}
}else{
precision = -1;
@@ -21196,7 +21724,8 @@ SQLITE_PRIVATE void sqlite3VXPrintf(
else prefix = 0;
}
if( xtype==etGENERIC && precision>0 ) precision--;
- for(idx=precision, rounder=0.5; idx>0; idx--, rounder*=0.1){}
+ testcase( precision>0xfff );
+ for(idx=precision&0xfff, rounder=0.5; idx>0; idx--, rounder*=0.1){}
if( xtype==etFLOAT ) realvalue += rounder;
/* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
exp = 0;
@@ -21251,8 +21780,9 @@ SQLITE_PRIVATE void sqlite3VXPrintf(
}else{
e2 = exp;
}
- if( MAX(e2,0)+precision+width > etBUFSIZE - 15 ){
- bufpt = zExtra = sqlite3Malloc( MAX(e2,0)+precision+width+15 );
+ if( MAX(e2,0)+(i64)precision+(i64)width > etBUFSIZE - 15 ){
+ bufpt = zExtra
+ = sqlite3Malloc( MAX(e2,0)+(i64)precision+(i64)width+15 );
if( bufpt==0 ){
setStrAccumError(pAccum, STRACCUM_NOMEM);
return;
@@ -21484,7 +22014,7 @@ SQLITE_PRIVATE void sqlite3VXPrintf(
*/
static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
char *zNew;
- assert( p->nChar+N >= p->nAlloc ); /* Only called if really needed */
+ assert( p->nChar+(i64)N >= p->nAlloc ); /* Only called if really needed */
if( p->accError ){
testcase(p->accError==STRACCUM_TOOBIG);
testcase(p->accError==STRACCUM_NOMEM);
@@ -21498,6 +22028,11 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
char *zOld = (p->zText==p->zBase ? 0 : p->zText);
i64 szNew = p->nChar;
szNew += N + 1;
+ if( szNew+p->nChar<=p->mxAlloc ){
+ /* Force exponential buffer size growth as long as it does not overflow,
+ ** to avoid having to call this routine too often */
+ szNew += p->nChar;
+ }
if( szNew > p->mxAlloc ){
sqlite3StrAccumReset(p);
setStrAccumError(p, STRACCUM_TOOBIG);
@@ -21514,6 +22049,7 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
assert( p->zText!=0 || p->nChar==0 );
if( zOld==0 && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar);
p->zText = zNew;
+ p->nAlloc = sqlite3DbMallocSize(p->db, zNew);
}else{
sqlite3StrAccumReset(p);
setStrAccumError(p, STRACCUM_NOMEM);
@@ -21527,7 +22063,10 @@ static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
** Append N copies of character c to the given string buffer.
*/
SQLITE_PRIVATE void sqlite3AppendChar(StrAccum *p, int N, char c){
- if( p->nChar+N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ) return;
+ testcase( p->nChar + (i64)N > 0x7fffffff );
+ if( p->nChar+(i64)N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ){
+ return;
+ }
while( (N--)>0 ) p->zText[p->nChar++] = c;
}
@@ -21679,10 +22218,17 @@ SQLITE_PRIVATE char *sqlite3MAppendf(sqlite3 *db, char *zStr, const char *zForma
** Print into memory obtained from sqlite3_malloc(). Omit the internal
** %-conversion extensions.
*/
-SQLITE_API char *sqlite3_vmprintf(const char *zFormat, va_list ap){
+SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char *zFormat, va_list ap){
char *z;
char zBase[SQLITE_PRINT_BUF_SIZE];
StrAccum acc;
+
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( zFormat==0 ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
#ifndef SQLITE_OMIT_AUTOINIT
if( sqlite3_initialize() ) return 0;
#endif
@@ -21697,7 +22243,7 @@ SQLITE_API char *sqlite3_vmprintf(const char *zFormat, va_list ap){
** Print into memory obtained from sqlite3_malloc()(). Omit the internal
** %-conversion extensions.
*/
-SQLITE_API char *sqlite3_mprintf(const char *zFormat, ...){
+SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char *zFormat, ...){
va_list ap;
char *z;
#ifndef SQLITE_OMIT_AUTOINIT
@@ -21722,15 +22268,22 @@ SQLITE_API char *sqlite3_mprintf(const char *zFormat, ...){
**
** sqlite3_vsnprintf() is the varargs version.
*/
-SQLITE_API char *sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){
+SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){
StrAccum acc;
if( n<=0 ) return zBuf;
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( zBuf==0 || zFormat==0 ) {
+ (void)SQLITE_MISUSE_BKPT;
+ if( zBuf ) zBuf[0] = 0;
+ return zBuf;
+ }
+#endif
sqlite3StrAccumInit(&acc, zBuf, n, 0);
acc.useMalloc = 0;
sqlite3VXPrintf(&acc, 0, zFormat, ap);
return sqlite3StrAccumFinish(&acc);
}
-SQLITE_API char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){
+SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){
char *z;
va_list ap;
va_start(ap,zFormat);
@@ -21762,7 +22315,7 @@ static void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){
/*
** Format and write a message to the log if logging is enabled.
*/
-SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...){
+SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...){
va_list ap; /* Vararg list */
if( sqlite3GlobalConfig.xLog ){
va_start(ap, zFormat);
@@ -21898,7 +22451,7 @@ static SQLITE_WSD struct sqlite3PrngType {
/*
** Return N random bytes.
*/
-SQLITE_API void sqlite3_randomness(int N, void *pBuf){
+SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *pBuf){
unsigned char t;
unsigned char *zBuf = pBuf;
@@ -21916,11 +22469,19 @@ SQLITE_API void sqlite3_randomness(int N, void *pBuf){
#endif
#if SQLITE_THREADSAFE
- sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG);
- sqlite3_mutex_enter(mutex);
+ sqlite3_mutex *mutex;
+#endif
+
+#ifndef SQLITE_OMIT_AUTOINIT
+ if( sqlite3_initialize() ) return;
+#endif
+
+#if SQLITE_THREADSAFE
+ mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG);
#endif
- if( N<=0 ){
+ sqlite3_mutex_enter(mutex);
+ if( N<=0 || pBuf==0 ){
wsdPrng.isInit = 0;
sqlite3_mutex_leave(mutex);
return;
@@ -22022,6 +22583,8 @@ SQLITE_PRIVATE void sqlite3PrngRestoreState(void){
** of multiple cores can do so, while also allowing applications to stay
** single-threaded if desired.
*/
+#if SQLITE_OS_WIN
+#endif
#if SQLITE_MAX_WORKER_THREADS>0
@@ -22094,7 +22657,7 @@ SQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){
/********************************* Win32 Threads ****************************/
-#if SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_THREADSAFE>0
+#if SQLITE_OS_WIN_THREADS
#define SQLITE_THREADS_IMPLEMENTED 1 /* Prevent the single-thread code below */
#include <process.h>
@@ -22187,7 +22750,7 @@ SQLITE_PRIVATE int sqlite3ThreadJoin(SQLiteThread *p, void **ppOut){
return (rc==WAIT_OBJECT_0) ? SQLITE_OK : SQLITE_ERROR;
}
-#endif /* SQLITE_OS_WIN && !SQLITE_OS_WINCE && !SQLITE_OS_WINRT */
+#endif /* SQLITE_OS_WIN_THREADS */
/******************************** End Win32 Threads *************************/
@@ -22808,7 +23371,7 @@ SQLITE_PRIVATE void sqlite3UtfSelfTest(void){
**
*/
/* #include <stdarg.h> */
-#ifdef SQLITE_HAVE_ISNAN
+#if HAVE_ISNAN || SQLITE_HAVE_ISNAN
# include <math.h>
#endif
@@ -22849,7 +23412,7 @@ SQLITE_PRIVATE int sqlite3FaultSim(int iTest){
*/
SQLITE_PRIVATE int sqlite3IsNaN(double x){
int rc; /* The value return */
-#if !defined(SQLITE_HAVE_ISNAN)
+#if !SQLITE_HAVE_ISNAN && !HAVE_ISNAN
/*
** Systems that support the isnan() library function should probably
** make use of it by compiling with -DSQLITE_HAVE_ISNAN. But we have
@@ -22879,9 +23442,9 @@ SQLITE_PRIVATE int sqlite3IsNaN(double x){
volatile double y = x;
volatile double z = y;
rc = (y!=z);
-#else /* if defined(SQLITE_HAVE_ISNAN) */
+#else /* if HAVE_ISNAN */
rc = isnan(x);
-#endif /* SQLITE_HAVE_ISNAN */
+#endif /* HAVE_ISNAN */
testcase( rc );
return rc;
}
@@ -23040,15 +23603,25 @@ SQLITE_PRIVATE int sqlite3Dequote(char *z){
** case-independent fashion, using the same definition of "case
** independence" that SQLite uses internally when comparing identifiers.
*/
-SQLITE_API int sqlite3_stricmp(const char *zLeft, const char *zRight){
+SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *zLeft, const char *zRight){
register unsigned char *a, *b;
+ if( zLeft==0 ){
+ return zRight ? -1 : 0;
+ }else if( zRight==0 ){
+ return 1;
+ }
a = (unsigned char *)zLeft;
b = (unsigned char *)zRight;
while( *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; }
return UpperToLower[*a] - UpperToLower[*b];
}
-SQLITE_API int sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){
+SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){
register unsigned char *a, *b;
+ if( zLeft==0 ){
+ return zRight ? -1 : 0;
+ }else if( zRight==0 ){
+ return 1;
+ }
a = (unsigned char *)zLeft;
b = (unsigned char *)zRight;
while( N-- > 0 && *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; }
@@ -24573,23 +25146,25 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
/* 136 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"),
/* 137 */ "IfPos" OpHelp("if r[P1]>0 goto P2"),
/* 138 */ "IfNeg" OpHelp("r[P1]+=P3, if r[P1]<0 goto P2"),
- /* 139 */ "IfZero" OpHelp("r[P1]+=P3, if r[P1]==0 goto P2"),
- /* 140 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
- /* 141 */ "IncrVacuum" OpHelp(""),
- /* 142 */ "Expire" OpHelp(""),
- /* 143 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
- /* 144 */ "VBegin" OpHelp(""),
- /* 145 */ "VCreate" OpHelp(""),
- /* 146 */ "VDestroy" OpHelp(""),
- /* 147 */ "VOpen" OpHelp(""),
- /* 148 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
- /* 149 */ "VNext" OpHelp(""),
- /* 150 */ "VRename" OpHelp(""),
- /* 151 */ "Pagecount" OpHelp(""),
- /* 152 */ "MaxPgcnt" OpHelp(""),
- /* 153 */ "Init" OpHelp("Start at P2"),
- /* 154 */ "Noop" OpHelp(""),
- /* 155 */ "Explain" OpHelp(""),
+ /* 139 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]+=P3, goto P2"),
+ /* 140 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"),
+ /* 141 */ "JumpZeroIncr" OpHelp("if (r[P1]++)==0 ) goto P2"),
+ /* 142 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
+ /* 143 */ "IncrVacuum" OpHelp(""),
+ /* 144 */ "Expire" OpHelp(""),
+ /* 145 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"),
+ /* 146 */ "VBegin" OpHelp(""),
+ /* 147 */ "VCreate" OpHelp(""),
+ /* 148 */ "VDestroy" OpHelp(""),
+ /* 149 */ "VOpen" OpHelp(""),
+ /* 150 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"),
+ /* 151 */ "VNext" OpHelp(""),
+ /* 152 */ "VRename" OpHelp(""),
+ /* 153 */ "Pagecount" OpHelp(""),
+ /* 154 */ "MaxPgcnt" OpHelp(""),
+ /* 155 */ "Init" OpHelp("Start at P2"),
+ /* 156 */ "Noop" OpHelp(""),
+ /* 157 */ "Explain" OpHelp(""),
};
return azName[i];
}
@@ -24670,18 +25245,6 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
#endif
/*
-** Define the OS_VXWORKS pre-processor macro to 1 if building on
-** vxworks, or 0 otherwise.
-*/
-#ifndef OS_VXWORKS
-# if defined(__RTP__) || defined(_WRS_KERNEL)
-# define OS_VXWORKS 1
-# else
-# define OS_VXWORKS 0
-# endif
-#endif
-
-/*
** standard include files.
*/
#include <sys/types.h>
@@ -24695,18 +25258,19 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
# include <sys/mman.h>
#endif
-#if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS
+#if SQLITE_ENABLE_LOCKING_STYLE
# include <sys/ioctl.h>
-# if OS_VXWORKS
-# include <semaphore.h>
-# include <limits.h>
-# else
-# include <sys/file.h>
-# include <sys/param.h>
-# endif
+# include <sys/file.h>
+# include <sys/param.h>
#endif /* SQLITE_ENABLE_LOCKING_STYLE */
-#if defined(__APPLE__) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
+#if OS_VXWORKS
+/* # include <sys/ioctl.h> */
+# include <semaphore.h>
+# include <limits.h>
+#endif /* OS_VXWORKS */
+
+#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE
# include <sys/mount.h>
#endif
@@ -24747,6 +25311,10 @@ SQLITE_PRIVATE const char *sqlite3OpcodeName(int i){
*/
#define MAX_PATHNAME 512
+/* Always cast the getpid() return type for compatibility with
+** kernel modules in VxWorks. */
+#define osGetpid(X) (pid_t)getpid()
+
/*
** Only set the lastErrno if the error code is a real error and not
** a normal expected return code of SQLITE_BUSY or SQLITE_OK
@@ -24835,7 +25403,7 @@ struct unixFile {
** method was called. If xOpen() is called from a different process id,
** indicating that a fork() has occurred, the PRNG will be reset.
*/
-static int randomnessPid = 0;
+static pid_t randomnessPid = 0;
/*
** Allowed values for the unixFile.ctrlFlags bitmask:
@@ -24852,7 +25420,8 @@ static int randomnessPid = 0;
#define UNIXFILE_DELETE 0x20 /* Delete on close */
#define UNIXFILE_URI 0x40 /* Filename might have query parameters */
#define UNIXFILE_NOLOCK 0x80 /* Do no file locking */
-#define UNIXFILE_WARNED 0x0100 /* verifyDbFile() warnings have been issued */
+#define UNIXFILE_WARNED 0x0100 /* verifyDbFile() warnings issued */
+#define UNIXFILE_BLOCK 0x0200 /* Next SHM lock might block */
/*
** Include code that is common to all os_*.c files
@@ -25191,7 +25760,7 @@ static struct unix_syscall {
{ "read", (sqlite3_syscall_ptr)read, 0 },
#define osRead ((ssize_t(*)(int,void*,size_t))aSyscall[8].pCurrent)
-#if defined(USE_PREAD) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
+#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE
{ "pread", (sqlite3_syscall_ptr)pread, 0 },
#else
{ "pread", (sqlite3_syscall_ptr)0, 0 },
@@ -25208,7 +25777,7 @@ static struct unix_syscall {
{ "write", (sqlite3_syscall_ptr)write, 0 },
#define osWrite ((ssize_t(*)(int,const void*,size_t))aSyscall[11].pCurrent)
-#if defined(USE_PREAD) || (SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS)
+#if defined(USE_PREAD) || SQLITE_ENABLE_LOCKING_STYLE
{ "pwrite", (sqlite3_syscall_ptr)pwrite, 0 },
#else
{ "pwrite", (sqlite3_syscall_ptr)0, 0 },
@@ -25523,9 +26092,9 @@ static int lockTrace(int fd, int op, struct flock *p){
/*
** Retry ftruncate() calls that fail due to EINTR
**
-** All calls to ftruncate() within this file should be made through this wrapper.
-** On the Android platform, bypassing the logic below could lead to a corrupt
-** database.
+** All calls to ftruncate() within this file should be made through
+** this wrapper. On the Android platform, bypassing the logic below
+** could lead to a corrupt database.
*/
static int robust_ftruncate(int h, sqlite3_int64 sz){
int rc;
@@ -25985,6 +26554,14 @@ static void robust_close(unixFile *pFile, int h, int lineno){
}
/*
+** Set the pFile->lastErrno. Do this in a subroutine as that provides
+** a convenient place to set a breakpoint.
+*/
+static void storeLastErrno(unixFile *pFile, int error){
+ pFile->lastErrno = error;
+}
+
+/*
** Close all file descriptors accumuated in the unixInodeInfo->pUnused list.
*/
static void closePendingFds(unixFile *pFile){
@@ -26057,7 +26634,7 @@ static int findInodeInfo(
fd = pFile->h;
rc = osFstat(fd, &statbuf);
if( rc!=0 ){
- pFile->lastErrno = errno;
+ storeLastErrno(pFile, errno);
#ifdef EOVERFLOW
if( pFile->lastErrno==EOVERFLOW ) return SQLITE_NOLFS;
#endif
@@ -26078,12 +26655,12 @@ static int findInodeInfo(
if( statbuf.st_size==0 && (pFile->fsFlags & SQLITE_FSFLAGS_IS_MSDOS)!=0 ){
do{ rc = osWrite(fd, "S", 1); }while( rc<0 && errno==EINTR );
if( rc!=1 ){
- pFile->lastErrno = errno;
+ storeLastErrno(pFile, errno);
return SQLITE_IOERR;
}
rc = osFstat(fd, &statbuf);
if( rc!=0 ){
- pFile->lastErrno = errno;
+ storeLastErrno(pFile, errno);
return SQLITE_IOERR;
}
}
@@ -26206,7 +26783,7 @@ static int unixCheckReservedLock(sqlite3_file *id, int *pResOut){
lock.l_type = F_WRLCK;
if( osFcntl(pFile->h, F_GETLK, &lock) ){
rc = SQLITE_IOERR_CHECKRESERVEDLOCK;
- pFile->lastErrno = errno;
+ storeLastErrno(pFile, errno);
} else if( lock.l_type!=F_UNLCK ){
reserved = 1;
}
@@ -26339,7 +26916,8 @@ static int unixLock(sqlite3_file *id, int eFileLock){
assert( pFile );
OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (unix)\n", pFile->h,
azFileLock(eFileLock), azFileLock(pFile->eFileLock),
- azFileLock(pFile->pInode->eFileLock), pFile->pInode->nShared , getpid()));
+ azFileLock(pFile->pInode->eFileLock), pFile->pInode->nShared,
+ osGetpid(0)));
/* If there is already a lock of this type or more restrictive on the
** unixFile, do nothing. Don't use the end_lock: exit path, as
@@ -26406,7 +26984,7 @@ static int unixLock(sqlite3_file *id, int eFileLock){
tErrno = errno;
rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
if( rc!=SQLITE_BUSY ){
- pFile->lastErrno = tErrno;
+ storeLastErrno(pFile, tErrno);
}
goto end_lock;
}
@@ -26441,7 +27019,7 @@ static int unixLock(sqlite3_file *id, int eFileLock){
if( rc ){
if( rc!=SQLITE_BUSY ){
- pFile->lastErrno = tErrno;
+ storeLastErrno(pFile, tErrno);
}
goto end_lock;
}else{
@@ -26474,7 +27052,7 @@ static int unixLock(sqlite3_file *id, int eFileLock){
tErrno = errno;
rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
if( rc!=SQLITE_BUSY ){
- pFile->lastErrno = tErrno;
+ storeLastErrno(pFile, tErrno);
}
}
}
@@ -26547,7 +27125,7 @@ static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){
assert( pFile );
OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (unix)\n", pFile->h, eFileLock,
pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
- getpid()));
+ osGetpid(0)));
assert( eFileLock<=SHARED_LOCK );
if( pFile->eFileLock<=eFileLock ){
@@ -26581,7 +27159,6 @@ static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){
** 4: [RRRR.]
*/
if( eFileLock==SHARED_LOCK ){
-
#if !defined(__APPLE__) || !SQLITE_ENABLE_LOCKING_STYLE
(void)handleNFSUnlock;
assert( handleNFSUnlock==0 );
@@ -26599,7 +27176,7 @@ static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){
tErrno = errno;
rc = SQLITE_IOERR_UNLOCK;
if( IS_LOCK_ERROR(rc) ){
- pFile->lastErrno = tErrno;
+ storeLastErrno(pFile, tErrno);
}
goto end_unlock;
}
@@ -26611,7 +27188,7 @@ static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){
tErrno = errno;
rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_RDLOCK);
if( IS_LOCK_ERROR(rc) ){
- pFile->lastErrno = tErrno;
+ storeLastErrno(pFile, tErrno);
}
goto end_unlock;
}
@@ -26623,7 +27200,7 @@ static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){
tErrno = errno;
rc = SQLITE_IOERR_UNLOCK;
if( IS_LOCK_ERROR(rc) ){
- pFile->lastErrno = tErrno;
+ storeLastErrno(pFile, tErrno);
}
goto end_unlock;
}
@@ -26642,7 +27219,7 @@ static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){
** SQLITE_BUSY would confuse the upper layer (in practice it causes
** an assert to fail). */
rc = SQLITE_IOERR_RDLOCK;
- pFile->lastErrno = errno;
+ storeLastErrno(pFile, errno);
goto end_unlock;
}
}
@@ -26655,7 +27232,7 @@ static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){
pInode->eFileLock = SHARED_LOCK;
}else{
rc = SQLITE_IOERR_UNLOCK;
- pFile->lastErrno = errno;
+ storeLastErrno(pFile, errno);
goto end_unlock;
}
}
@@ -26673,7 +27250,7 @@ static int posixUnlock(sqlite3_file *id, int eFileLock, int handleNFSUnlock){
pInode->eFileLock = NO_LOCK;
}else{
rc = SQLITE_IOERR_UNLOCK;
- pFile->lastErrno = errno;
+ storeLastErrno(pFile, errno);
pInode->eFileLock = NO_LOCK;
pFile->eFileLock = NO_LOCK;
}
@@ -26948,7 +27525,7 @@ static int dotlockLock(sqlite3_file *id, int eFileLock) {
} else {
rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
if( IS_LOCK_ERROR(rc) ){
- pFile->lastErrno = tErrno;
+ storeLastErrno(pFile, tErrno);
}
}
return rc;
@@ -26975,7 +27552,7 @@ static int dotlockUnlock(sqlite3_file *id, int eFileLock) {
assert( pFile );
OSTRACE(("UNLOCK %d %d was %d pid=%d (dotlock)\n", pFile->h, eFileLock,
- pFile->eFileLock, getpid()));
+ pFile->eFileLock, osGetpid(0)));
assert( eFileLock<=SHARED_LOCK );
/* no-op if possible */
@@ -27002,7 +27579,7 @@ static int dotlockUnlock(sqlite3_file *id, int eFileLock) {
rc = SQLITE_IOERR_UNLOCK;
}
if( IS_LOCK_ERROR(rc) ){
- pFile->lastErrno = tErrno;
+ storeLastErrno(pFile, tErrno);
}
return rc;
}
@@ -27038,10 +27615,9 @@ static int dotlockClose(sqlite3_file *id) {
** still works when you do this, but concurrency is reduced since
** only a single process can be reading the database at a time.
**
-** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off or if
-** compiling for VXWORKS.
+** Omit this section if SQLITE_ENABLE_LOCKING_STYLE is turned off
*/
-#if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS
+#if SQLITE_ENABLE_LOCKING_STYLE
/*
** Retry flock() calls that fail with EINTR
@@ -27089,7 +27665,7 @@ static int flockCheckReservedLock(sqlite3_file *id, int *pResOut){
/* unlock failed with an error */
lrc = SQLITE_IOERR_UNLOCK;
if( IS_LOCK_ERROR(lrc) ){
- pFile->lastErrno = tErrno;
+ storeLastErrno(pFile, tErrno);
rc = lrc;
}
}
@@ -27099,7 +27675,7 @@ static int flockCheckReservedLock(sqlite3_file *id, int *pResOut){
/* someone else might have it reserved */
lrc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
if( IS_LOCK_ERROR(lrc) ){
- pFile->lastErrno = tErrno;
+ storeLastErrno(pFile, tErrno);
rc = lrc;
}
}
@@ -27165,7 +27741,7 @@ static int flockLock(sqlite3_file *id, int eFileLock) {
/* didn't get, must be busy */
rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_LOCK);
if( IS_LOCK_ERROR(rc) ){
- pFile->lastErrno = tErrno;
+ storeLastErrno(pFile, tErrno);
}
} else {
/* got it, set the type and return ok */
@@ -27194,7 +27770,7 @@ static int flockUnlock(sqlite3_file *id, int eFileLock) {
assert( pFile );
OSTRACE(("UNLOCK %d %d was %d pid=%d (flock)\n", pFile->h, eFileLock,
- pFile->eFileLock, getpid()));
+ pFile->eFileLock, osGetpid(0)));
assert( eFileLock<=SHARED_LOCK );
/* no-op if possible */
@@ -27255,7 +27831,7 @@ static int flockClose(sqlite3_file *id) {
** to a non-zero value otherwise *pResOut is set to zero. The return value
** is set to SQLITE_OK unless an I/O error occurs during lock checking.
*/
-static int semCheckReservedLock(sqlite3_file *id, int *pResOut) {
+static int semXCheckReservedLock(sqlite3_file *id, int *pResOut) {
int rc = SQLITE_OK;
int reserved = 0;
unixFile *pFile = (unixFile*)id;
@@ -27277,7 +27853,7 @@ static int semCheckReservedLock(sqlite3_file *id, int *pResOut) {
int tErrno = errno;
if( EAGAIN != tErrno ){
rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_CHECKRESERVEDLOCK);
- pFile->lastErrno = tErrno;
+ storeLastErrno(pFile, tErrno);
} else {
/* someone else has the lock when we are in NO_LOCK */
reserved = (pFile->eFileLock < SHARED_LOCK);
@@ -27322,7 +27898,7 @@ static int semCheckReservedLock(sqlite3_file *id, int *pResOut) {
** This routine will only increase a lock. Use the sqlite3OsUnlock()
** routine to lower a locking level.
*/
-static int semLock(sqlite3_file *id, int eFileLock) {
+static int semXLock(sqlite3_file *id, int eFileLock) {
unixFile *pFile = (unixFile*)id;
sem_t *pSem = pFile->pInode->pSem;
int rc = SQLITE_OK;
@@ -27355,14 +27931,14 @@ static int semLock(sqlite3_file *id, int eFileLock) {
** If the locking level of the file descriptor is already at or below
** the requested locking level, this routine is a no-op.
*/
-static int semUnlock(sqlite3_file *id, int eFileLock) {
+static int semXUnlock(sqlite3_file *id, int eFileLock) {
unixFile *pFile = (unixFile*)id;
sem_t *pSem = pFile->pInode->pSem;
assert( pFile );
assert( pSem );
OSTRACE(("UNLOCK %d %d was %d pid=%d (sem)\n", pFile->h, eFileLock,
- pFile->eFileLock, getpid()));
+ pFile->eFileLock, osGetpid(0)));
assert( eFileLock<=SHARED_LOCK );
/* no-op if possible */
@@ -27381,7 +27957,7 @@ static int semUnlock(sqlite3_file *id, int eFileLock) {
int rc, tErrno = errno;
rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);
if( IS_LOCK_ERROR(rc) ){
- pFile->lastErrno = tErrno;
+ storeLastErrno(pFile, tErrno);
}
return rc;
}
@@ -27392,10 +27968,10 @@ static int semUnlock(sqlite3_file *id, int eFileLock) {
/*
** Close a file.
*/
-static int semClose(sqlite3_file *id) {
+static int semXClose(sqlite3_file *id) {
if( id ){
unixFile *pFile = (unixFile*)id;
- semUnlock(id, NO_LOCK);
+ semXUnlock(id, NO_LOCK);
assert( pFile );
unixEnterMutex();
releaseInodeInfo(pFile);
@@ -27483,7 +28059,7 @@ static int afpSetLock(
setLockFlag ? SQLITE_IOERR_LOCK : SQLITE_IOERR_UNLOCK);
#endif /* SQLITE_IGNORE_AFP_LOCK_ERRORS */
if( IS_LOCK_ERROR(rc) ){
- pFile->lastErrno = tErrno;
+ storeLastErrno(pFile, tErrno);
}
return rc;
} else {
@@ -27576,7 +28152,7 @@ static int afpLock(sqlite3_file *id, int eFileLock){
assert( pFile );
OSTRACE(("LOCK %d %s was %s(%s,%d) pid=%d (afp)\n", pFile->h,
azFileLock(eFileLock), azFileLock(pFile->eFileLock),
- azFileLock(pInode->eFileLock), pInode->nShared , getpid()));
+ azFileLock(pInode->eFileLock), pInode->nShared , osGetpid(0)));
/* If there is already a lock of this type or more restrictive on the
** unixFile, do nothing. Don't use the afp_end_lock: exit path, as
@@ -27666,7 +28242,7 @@ static int afpLock(sqlite3_file *id, int eFileLock){
lrc2 = afpSetLock(context->dbPath, pFile, PENDING_BYTE, 1, 0);
if( IS_LOCK_ERROR(lrc1) ) {
- pFile->lastErrno = lrc1Errno;
+ storeLastErrno(pFile, lrc1Errno);
rc = lrc1;
goto afp_end_lock;
} else if( IS_LOCK_ERROR(lrc2) ){
@@ -27762,7 +28338,7 @@ static int afpUnlock(sqlite3_file *id, int eFileLock) {
assert( pFile );
OSTRACE(("UNLOCK %d %d was %d(%d,%d) pid=%d (afp)\n", pFile->h, eFileLock,
pFile->eFileLock, pFile->pInode->eFileLock, pFile->pInode->nShared,
- getpid()));
+ osGetpid(0)));
assert( eFileLock<=SHARED_LOCK );
if( pFile->eFileLock<=eFileLock ){
@@ -27953,9 +28529,9 @@ static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){
SimulateIOError( newOffset-- );
if( newOffset!=offset ){
if( newOffset == -1 ){
- ((unixFile*)id)->lastErrno = errno;
+ storeLastErrno((unixFile*)id, errno);
}else{
- ((unixFile*)id)->lastErrno = 0;
+ storeLastErrno((unixFile*)id, 0);
}
return -1;
}
@@ -27965,7 +28541,7 @@ static int seekAndRead(unixFile *id, sqlite3_int64 offset, void *pBuf, int cnt){
if( got<0 ){
if( errno==EINTR ){ got = 1; continue; }
prior = 0;
- ((unixFile*)id)->lastErrno = errno;
+ storeLastErrno((unixFile*)id, errno);
break;
}else if( got>0 ){
cnt -= got;
@@ -28030,7 +28606,7 @@ static int unixRead(
/* lastErrno set by seekAndRead */
return SQLITE_IOERR_READ;
}else{
- pFile->lastErrno = 0; /* not a system error */
+ storeLastErrno(pFile, 0); /* not a system error */
/* Unread parts of the buffer must be zero-filled */
memset(&((char*)pBuf)[got], 0, amt-got);
return SQLITE_IOERR_SHORT_READ;
@@ -28059,9 +28635,9 @@ static int seekAndWriteFd(
TIMER_START;
#if defined(USE_PREAD)
- do{ rc = osPwrite(fd, pBuf, nBuf, iOff); }while( rc<0 && errno==EINTR );
+ do{ rc = (int)osPwrite(fd, pBuf, nBuf, iOff); }while( rc<0 && errno==EINTR );
#elif defined(USE_PREAD64)
- do{ rc = osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
+ do{ rc = (int)osPwrite64(fd, pBuf, nBuf, iOff);}while( rc<0 && errno==EINTR);
#else
do{
i64 iSeek = lseek(fd, iOff, SEEK_SET);
@@ -28171,7 +28747,7 @@ static int unixWrite(
/* lastErrno set by seekAndWrite */
return SQLITE_IOERR_WRITE;
}else{
- pFile->lastErrno = 0; /* not a system error */
+ storeLastErrno(pFile, 0); /* not a system error */
return SQLITE_FULL;
}
}
@@ -28192,9 +28768,9 @@ SQLITE_API int sqlite3_fullsync_count = 0;
** We do not trust systems to provide a working fdatasync(). Some do.
** Others do no. To be safe, we will stick with the (slightly slower)
** fsync(). If you know that your system does support fdatasync() correctly,
-** then simply compile with -Dfdatasync=fdatasync
+** then simply compile with -Dfdatasync=fdatasync or -DHAVE_FDATASYNC
*/
-#if !defined(fdatasync)
+#if !defined(fdatasync) && !HAVE_FDATASYNC
# define fdatasync fsync
#endif
@@ -28380,7 +28956,7 @@ static int unixSync(sqlite3_file *id, int flags){
rc = full_fsync(pFile->h, isFullsync, isDataOnly);
SimulateIOError( rc=1 );
if( rc ){
- pFile->lastErrno = errno;
+ storeLastErrno(pFile, errno);
return unixLogError(SQLITE_IOERR_FSYNC, "full_fsync", pFile->zPath);
}
@@ -28424,7 +29000,7 @@ static int unixTruncate(sqlite3_file *id, i64 nByte){
rc = robust_ftruncate(pFile->h, nByte);
if( rc ){
- pFile->lastErrno = errno;
+ storeLastErrno(pFile, errno);
return unixLogError(SQLITE_IOERR_TRUNCATE, "ftruncate", pFile->zPath);
}else{
#ifdef SQLITE_DEBUG
@@ -28464,7 +29040,7 @@ static int unixFileSize(sqlite3_file *id, i64 *pSize){
rc = osFstat(((unixFile*)id)->h, &buf);
SimulateIOError( rc=1 );
if( rc!=0 ){
- ((unixFile*)id)->lastErrno = errno;
+ storeLastErrno((unixFile*)id, errno);
return SQLITE_IOERR_FSTAT;
}
*pSize = buf.st_size;
@@ -28500,7 +29076,9 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
i64 nSize; /* Required file size */
struct stat buf; /* Used to hold return values of fstat() */
- if( osFstat(pFile->h, &buf) ) return SQLITE_IOERR_FSTAT;
+ if( osFstat(pFile->h, &buf) ){
+ return SQLITE_IOERR_FSTAT;
+ }
nSize = ((nByte+pFile->szChunk-1) / pFile->szChunk) * pFile->szChunk;
if( nSize>(i64)buf.st_size ){
@@ -28515,24 +29093,28 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
}while( err==EINTR );
if( err ) return SQLITE_IOERR_WRITE;
#else
- /* If the OS does not have posix_fallocate(), fake it. First use
- ** ftruncate() to set the file size, then write a single byte to
- ** the last byte in each block within the extended region. This
- ** is the same technique used by glibc to implement posix_fallocate()
- ** on systems that do not have a real fallocate() system call.
+ /* If the OS does not have posix_fallocate(), fake it. Write a
+ ** single byte to the last byte in each block that falls entirely
+ ** within the extended region. Then, if required, a single byte
+ ** at offset (nSize-1), to set the size of the file correctly.
+ ** This is a similar technique to that used by glibc on systems
+ ** that do not have a real fallocate() call.
*/
int nBlk = buf.st_blksize; /* File-system block size */
+ int nWrite = 0; /* Number of bytes written by seekAndWrite */
i64 iWrite; /* Next offset to write to */
- if( robust_ftruncate(pFile->h, nSize) ){
- pFile->lastErrno = errno;
- return unixLogError(SQLITE_IOERR_TRUNCATE, "ftruncate", pFile->zPath);
- }
iWrite = ((buf.st_size + 2*nBlk - 1)/nBlk)*nBlk-1;
- while( iWrite<nSize ){
- int nWrite = seekAndWrite(pFile, iWrite, "", 1);
+ assert( iWrite>=buf.st_size );
+ assert( (iWrite/nBlk)==((buf.st_size+nBlk-1)/nBlk) );
+ assert( ((iWrite+1)%nBlk)==0 );
+ for(/*no-op*/; iWrite<nSize; iWrite+=nBlk ){
+ nWrite = seekAndWrite(pFile, iWrite, "", 1);
+ if( nWrite!=1 ) return SQLITE_IOERR_WRITE;
+ }
+ if( nWrite==0 || (nSize%nBlk) ){
+ nWrite = seekAndWrite(pFile, nSize-1, "", 1);
if( nWrite!=1 ) return SQLITE_IOERR_WRITE;
- iWrite += nBlk;
}
#endif
}
@@ -28543,7 +29125,7 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
int rc;
if( pFile->szChunk<=0 ){
if( robust_ftruncate(pFile->h, nByte) ){
- pFile->lastErrno = errno;
+ storeLastErrno(pFile, errno);
return unixLogError(SQLITE_IOERR_TRUNCATE, "ftruncate", pFile->zPath);
}
}
@@ -28581,11 +29163,15 @@ static int unixGetTempname(int nBuf, char *zBuf);
static int unixFileControl(sqlite3_file *id, int op, void *pArg){
unixFile *pFile = (unixFile*)id;
switch( op ){
+ case SQLITE_FCNTL_WAL_BLOCK: {
+ /* pFile->ctrlFlags |= UNIXFILE_BLOCK; // Deferred feature */
+ return SQLITE_OK;
+ }
case SQLITE_FCNTL_LOCKSTATE: {
*(int*)pArg = pFile->eFileLock;
return SQLITE_OK;
}
- case SQLITE_LAST_ERRNO: {
+ case SQLITE_FCNTL_LAST_ERRNO: {
*(int*)pArg = pFile->lastErrno;
return SQLITE_OK;
}
@@ -28654,8 +29240,8 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){
}
#endif
#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
- case SQLITE_SET_LOCKPROXYFILE:
- case SQLITE_GET_LOCKPROXYFILE: {
+ case SQLITE_FCNTL_SET_LOCKPROXYFILE:
+ case SQLITE_FCNTL_GET_LOCKPROXYFILE: {
return proxyFileControl(id,op,pArg);
}
#endif /* SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__) */
@@ -28795,7 +29381,9 @@ static int unixDeviceCharacteristics(sqlite3_file *id){
** Instead, it should be called via macro osGetpagesize().
*/
static int unixGetpagesize(void){
-#if defined(_BSD_SOURCE)
+#if OS_VXWORKS
+ return 1024;
+#elif defined(_BSD_SOURCE)
return getpagesize();
#else
return (int)sysconf(_SC_PAGESIZE);
@@ -28888,15 +29476,17 @@ struct unixShm {
** otherwise.
*/
static int unixShmSystemLock(
- unixShmNode *pShmNode, /* Apply locks to this open shared-memory segment */
+ unixFile *pFile, /* Open connection to the WAL file */
int lockType, /* F_UNLCK, F_RDLCK, or F_WRLCK */
int ofst, /* First byte of the locking range */
int n /* Number of bytes to lock */
){
- struct flock f; /* The posix advisory locking structure */
- int rc = SQLITE_OK; /* Result code form fcntl() */
+ unixShmNode *pShmNode; /* Apply locks to this open shared-memory segment */
+ struct flock f; /* The posix advisory locking structure */
+ int rc = SQLITE_OK; /* Result code form fcntl() */
/* Access to the unixShmNode object is serialized by the caller */
+ pShmNode = pFile->pInode->pShmNode;
assert( sqlite3_mutex_held(pShmNode->mutex) || pShmNode->nRef==0 );
/* Shared locks never span more than one byte */
@@ -28906,6 +29496,7 @@ static int unixShmSystemLock(
assert( n>=1 && n<SQLITE_SHM_NLOCK );
if( pShmNode->h>=0 ){
+ int lkType;
/* Initialize the locking parameters */
memset(&f, 0, sizeof(f));
f.l_type = lockType;
@@ -28913,8 +29504,10 @@ static int unixShmSystemLock(
f.l_start = ofst;
f.l_len = n;
- rc = osFcntl(pShmNode->h, F_SETLK, &f);
+ lkType = (pFile->ctrlFlags & UNIXFILE_BLOCK)!=0 ? F_SETLKW : F_SETLK;
+ rc = osFcntl(pShmNode->h, lkType, &f);
rc = (rc!=(-1)) ? SQLITE_OK : SQLITE_BUSY;
+ pFile->ctrlFlags &= ~UNIXFILE_BLOCK;
}
/* Update the global lock state and do debug tracing */
@@ -29060,6 +29653,9 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
pShmNode = pInode->pShmNode;
if( pShmNode==0 ){
struct stat sStat; /* fstat() info for database file */
+#ifndef SQLITE_SHM_DIRECTORY
+ const char *zBasePath = pDbFd->zPath;
+#endif
/* Call fstat() to figure out the permissions on the database file. If
** a new *-shm file is created, an attempt will be made to create it
@@ -29073,7 +29669,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
#ifdef SQLITE_SHM_DIRECTORY
nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 31;
#else
- nShmFilename = 6 + (int)strlen(pDbFd->zPath);
+ nShmFilename = 6 + (int)strlen(zBasePath);
#endif
pShmNode = sqlite3_malloc( sizeof(*pShmNode) + nShmFilename );
if( pShmNode==0 ){
@@ -29087,7 +29683,7 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
SQLITE_SHM_DIRECTORY "/sqlite-shm-%x-%x",
(u32)sStat.st_ino, (u32)sStat.st_dev);
#else
- sqlite3_snprintf(nShmFilename, zShmFilename, "%s-shm", pDbFd->zPath);
+ sqlite3_snprintf(nShmFilename, zShmFilename, "%s-shm", zBasePath);
sqlite3FileSuffix3(pDbFd->zPath, zShmFilename);
#endif
pShmNode->h = -1;
@@ -29121,13 +29717,13 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
** If not, truncate the file to zero length.
*/
rc = SQLITE_OK;
- if( unixShmSystemLock(pShmNode, F_WRLCK, UNIX_SHM_DMS, 1)==SQLITE_OK ){
+ if( unixShmSystemLock(pDbFd, F_WRLCK, UNIX_SHM_DMS, 1)==SQLITE_OK ){
if( robust_ftruncate(pShmNode->h, 0) ){
rc = unixLogError(SQLITE_IOERR_SHMOPEN, "ftruncate", zShmFilename);
}
}
if( rc==SQLITE_OK ){
- rc = unixShmSystemLock(pShmNode, F_RDLCK, UNIX_SHM_DMS, 1);
+ rc = unixShmSystemLock(pDbFd, F_RDLCK, UNIX_SHM_DMS, 1);
}
if( rc ) goto shm_open_err;
}
@@ -29359,7 +29955,7 @@ static int unixShmLock(
/* Unlock the system-level locks */
if( (mask & allMask)==0 ){
- rc = unixShmSystemLock(pShmNode, F_UNLCK, ofst+UNIX_SHM_BASE, n);
+ rc = unixShmSystemLock(pDbFd, F_UNLCK, ofst+UNIX_SHM_BASE, n);
}else{
rc = SQLITE_OK;
}
@@ -29387,7 +29983,7 @@ static int unixShmLock(
/* Get shared locks at the system level, if necessary */
if( rc==SQLITE_OK ){
if( (allShared & mask)==0 ){
- rc = unixShmSystemLock(pShmNode, F_RDLCK, ofst+UNIX_SHM_BASE, n);
+ rc = unixShmSystemLock(pDbFd, F_RDLCK, ofst+UNIX_SHM_BASE, n);
}else{
rc = SQLITE_OK;
}
@@ -29412,7 +30008,7 @@ static int unixShmLock(
** also mark the local connection as being locked.
*/
if( rc==SQLITE_OK ){
- rc = unixShmSystemLock(pShmNode, F_WRLCK, ofst+UNIX_SHM_BASE, n);
+ rc = unixShmSystemLock(pDbFd, F_WRLCK, ofst+UNIX_SHM_BASE, n);
if( rc==SQLITE_OK ){
assert( (p->sharedMask & mask)==0 );
p->exclMask |= mask;
@@ -29421,7 +30017,7 @@ static int unixShmLock(
}
sqlite3_mutex_leave(pShmNode->mutex);
OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x\n",
- p->id, getpid(), p->sharedMask, p->exclMask));
+ p->id, osGetpid(0), p->sharedMask, p->exclMask));
return rc;
}
@@ -29480,7 +30076,9 @@ static int unixShmUnmap(
assert( pShmNode->nRef>0 );
pShmNode->nRef--;
if( pShmNode->nRef==0 ){
- if( deleteFlag && pShmNode->h>=0 ) osUnlink(pShmNode->zFilename);
+ if( deleteFlag && pShmNode->h>=0 ){
+ osUnlink(pShmNode->zFilename);
+ }
unixShmPurge(pDbFd);
}
unixLeaveMutex();
@@ -29757,7 +30355,7 @@ static int unixUnfetch(sqlite3_file *fd, i64 iOff, void *p){
** * An I/O method finder function called FINDER that returns a pointer
** to the METHOD object in the previous bullet.
*/
-#define IOMETHODS(FINDER, METHOD, VERSION, CLOSE, LOCK, UNLOCK, CKLOCK, SHMMAP) \
+#define IOMETHODS(FINDER,METHOD,VERSION,CLOSE,LOCK,UNLOCK,CKLOCK,SHMMAP) \
static const sqlite3_io_methods METHOD = { \
VERSION, /* iVersion */ \
CLOSE, /* xClose */ \
@@ -29822,7 +30420,7 @@ IOMETHODS(
0 /* xShmMap method */
)
-#if SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORKS
+#if SQLITE_ENABLE_LOCKING_STYLE
IOMETHODS(
flockIoFinder, /* Finder function name */
flockIoMethods, /* sqlite3_io_methods object name */
@@ -29840,10 +30438,10 @@ IOMETHODS(
semIoFinder, /* Finder function name */
semIoMethods, /* sqlite3_io_methods object name */
1, /* shared memory is disabled */
- semClose, /* xClose method */
- semLock, /* xLock method */
- semUnlock, /* xUnlock method */
- semCheckReservedLock, /* xCheckReservedLock method */
+ semXClose, /* xClose method */
+ semXLock, /* xLock method */
+ semXUnlock, /* xUnlock method */
+ semXCheckReservedLock, /* xCheckReservedLock method */
0 /* xShmMap method */
)
#endif
@@ -29967,15 +30565,13 @@ static const sqlite3_io_methods
#endif /* defined(__APPLE__) && SQLITE_ENABLE_LOCKING_STYLE */
-#if OS_VXWORKS && SQLITE_ENABLE_LOCKING_STYLE
-/*
-** This "finder" function attempts to determine the best locking strategy
-** for the database file "filePath". It then returns the sqlite3_io_methods
-** object that implements that strategy.
-**
-** This is for VXWorks only.
+#if OS_VXWORKS
+/*
+** This "finder" function for VxWorks checks to see if posix advisory
+** locking works. If it does, then that is what is used. If it does not
+** work, then fallback to named semaphore locking.
*/
-static const sqlite3_io_methods *autolockIoFinderImpl(
+static const sqlite3_io_methods *vxworksIoFinderImpl(
const char *filePath, /* name of the database file */
unixFile *pNew /* the open file object */
){
@@ -30001,9 +30597,9 @@ static const sqlite3_io_methods *autolockIoFinderImpl(
}
}
static const sqlite3_io_methods
- *(*const autolockIoFinder)(const char*,unixFile*) = autolockIoFinderImpl;
+ *(*const vxworksIoFinder)(const char*,unixFile*) = vxworksIoFinderImpl;
-#endif /* OS_VXWORKS && SQLITE_ENABLE_LOCKING_STYLE */
+#endif /* OS_VXWORKS */
/*
** An abstract type for a pointer to an IO method finder function:
@@ -30185,7 +30781,7 @@ static int fillInUnixFile(
}
#endif
- pNew->lastErrno = 0;
+ storeLastErrno(pNew, 0);
#if OS_VXWORKS
if( rc!=SQLITE_OK ){
if( h>=0 ) robust_close(pNew, h, __LINE__);
@@ -30516,8 +31112,8 @@ static int unixOpen(
** the same instant might all reset the PRNG. But multiple resets
** are harmless.
*/
- if( randomnessPid!=getpid() ){
- randomnessPid = getpid();
+ if( randomnessPid!=osGetpid(0) ){
+ randomnessPid = osGetpid(0);
sqlite3_randomness(0,0);
}
@@ -30633,13 +31229,16 @@ static int unixOpen(
#if defined(__APPLE__) || SQLITE_ENABLE_LOCKING_STYLE
if( fstatfs(fd, &fsInfo) == -1 ){
- ((unixFile*)pFile)->lastErrno = errno;
+ storeLastErrno(p, errno);
robust_close(p, fd, __LINE__);
return SQLITE_IOERR_ACCESS;
}
if (0 == strncmp("msdos", fsInfo.f_fstypename, 5)) {
((unixFile*)pFile)->fsFlags |= SQLITE_FSFLAGS_IS_MSDOS;
}
+ if (0 == strncmp("exfat", fsInfo.f_fstypename, 5)) {
+ ((unixFile*)pFile)->fsFlags |= SQLITE_FSFLAGS_IS_MSDOS;
+ }
#endif
/* Set up appropriate ctrlFlags */
@@ -30662,19 +31261,6 @@ static int unixOpen(
if( envforce!=NULL ){
useProxy = atoi(envforce)>0;
}else{
- if( statfs(zPath, &fsInfo) == -1 ){
- /* In theory, the close(fd) call is sub-optimal. If the file opened
- ** with fd is a database file, and there are other connections open
- ** on that file that are currently holding advisory locks on it,
- ** then the call to close() will cancel those locks. In practice,
- ** we're assuming that statfs() doesn't fail very often. At least
- ** not while other file descriptors opened by the same process on
- ** the same file are working. */
- p->lastErrno = errno;
- robust_close(p, fd, __LINE__);
- rc = SQLITE_IOERR_ACCESS;
- goto open_finished;
- }
useProxy = !(fsInfo.f_flags&MNT_LOCAL);
}
if( useProxy ){
@@ -30918,7 +31504,7 @@ static int unixRandomness(sqlite3_vfs *NotUsed, int nBuf, char *zBuf){
** tests repeatable.
*/
memset(zBuf, 0, nBuf);
- randomnessPid = getpid();
+ randomnessPid = osGetpid(0);
#if !defined(SQLITE_TEST)
{
int fd, got;
@@ -31100,9 +31686,10 @@ static int unixGetLastError(sqlite3_vfs *NotUsed, int NotUsed2, char *NotUsed3){
**
** C APIs
**
-** sqlite3_file_control(db, dbname, SQLITE_SET_LOCKPROXYFILE,
+** sqlite3_file_control(db, dbname, SQLITE_FCNTL_SET_LOCKPROXYFILE,
** <proxy_path> | ":auto:");
-** sqlite3_file_control(db, dbname, SQLITE_GET_LOCKPROXYFILE, &<proxy_path>);
+** sqlite3_file_control(db, dbname, SQLITE_FCNTL_GET_LOCKPROXYFILE,
+** &<proxy_path>);
**
**
** SQL pragmas
@@ -31195,7 +31782,7 @@ static int unixGetLastError(sqlite3_vfs *NotUsed, int NotUsed2, char *NotUsed3){
** setting the environment variable SQLITE_FORCE_PROXY_LOCKING to 1 will
** force proxy locking to be used for every database file opened, and 0
** will force automatic proxy locking to be disabled for all database
-** files (explicitly calling the SQLITE_SET_LOCKPROXYFILE pragma or
+** files (explicitly calling the SQLITE_FCNTL_SET_LOCKPROXYFILE pragma or
** sqlite_file_control API is not affected by SQLITE_FORCE_PROXY_LOCKING).
*/
@@ -31216,6 +31803,7 @@ struct proxyLockingContext {
char *lockProxyPath; /* Name of the proxy lock file */
char *dbPath; /* Name of the open file */
int conchHeld; /* 1 if the conch is held, -1 if lockless */
+ int nFails; /* Number of conch taking failures */
void *oldLockingContext; /* Original lockingcontext to restore on close */
sqlite3_io_methods const *pOldMethod; /* Original I/O methods for close */
};
@@ -31237,7 +31825,7 @@ static int proxyGetLockPath(const char *dbPath, char *lPath, size_t maxLen){
{
if( !confstr(_CS_DARWIN_USER_TEMP_DIR, lPath, maxLen) ){
OSTRACE(("GETLOCKPATH failed %s errno=%d pid=%d\n",
- lPath, errno, getpid()));
+ lPath, errno, osGetpid(0)));
return SQLITE_IOERR_LOCK;
}
len = strlcat(lPath, "sqliteplocks", maxLen);
@@ -31259,7 +31847,7 @@ static int proxyGetLockPath(const char *dbPath, char *lPath, size_t maxLen){
}
lPath[i+len]='\0';
strlcat(lPath, ":auto:", maxLen);
- OSTRACE(("GETLOCKPATH proxy lock path=%s pid=%d\n", lPath, getpid()));
+ OSTRACE(("GETLOCKPATH proxy lock path=%s pid=%d\n", lPath, osGetpid(0)));
return SQLITE_OK;
}
@@ -31286,7 +31874,7 @@ static int proxyCreateLockPath(const char *lockPath){
if( err!=EEXIST ) {
OSTRACE(("CREATELOCKPATH FAILED creating %s, "
"'%s' proxy lock path=%s pid=%d\n",
- buf, strerror(err), lockPath, getpid()));
+ buf, strerror(err), lockPath, osGetpid(0)));
return err;
}
}
@@ -31295,7 +31883,7 @@ static int proxyCreateLockPath(const char *lockPath){
}
buf[i] = lockPath[i];
}
- OSTRACE(("CREATELOCKPATH proxy lock path=%s pid=%d\n", lockPath, getpid()));
+ OSTRACE(("CREATELOCKPATH proxy lock path=%s pid=%d\n", lockPath, osGetpid(0)));
return 0;
}
@@ -31404,10 +31992,10 @@ extern int gethostuuid(uuid_t id, const struct timespec *wait);
static int proxyGetHostID(unsigned char *pHostID, int *pError){
assert(PROXY_HOSTIDLEN == sizeof(uuid_t));
memset(pHostID, 0, PROXY_HOSTIDLEN);
-#if defined(__MAX_OS_X_VERSION_MIN_REQUIRED)\
- && __MAC_OS_X_VERSION_MIN_REQUIRED<1050
+# if defined(__APPLE__) && ((__MAC_OS_X_VERSION_MIN_REQUIRED > 1050) || \
+ (__IPHONE_OS_VERSION_MIN_REQUIRED > 2000))
{
- static const struct timespec timeout = {1, 0}; /* 1 sec timeout */
+ struct timespec timeout = {1, 0}; /* 1 sec timeout */
if( gethostuuid(pHostID, &timeout) ){
int err = errno;
if( pError ){
@@ -31522,7 +32110,7 @@ static int proxyConchLock(unixFile *pFile, uuid_t myHostID, int lockType){
*/
struct stat buf;
if( osFstat(conchFile->h, &buf) ){
- pFile->lastErrno = errno;
+ storeLastErrno(pFile, errno);
return SQLITE_IOERR_LOCK;
}
@@ -31542,7 +32130,7 @@ static int proxyConchLock(unixFile *pFile, uuid_t myHostID, int lockType){
char tBuf[PROXY_MAXCONCHLEN];
int len = osPread(conchFile->h, tBuf, PROXY_MAXCONCHLEN, 0);
if( len<0 ){
- pFile->lastErrno = errno;
+ storeLastErrno(pFile, errno);
return SQLITE_IOERR_LOCK;
}
if( len>PROXY_PATHINDEX && tBuf[0]==(char)PROXY_CONCHVERSION){
@@ -31562,7 +32150,7 @@ static int proxyConchLock(unixFile *pFile, uuid_t myHostID, int lockType){
if( 0==proxyBreakConchLock(pFile, myHostID) ){
rc = SQLITE_OK;
if( lockType==EXCLUSIVE_LOCK ){
- rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, SHARED_LOCK);
+ rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, SHARED_LOCK);
}
if( !rc ){
rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, lockType);
@@ -31600,11 +32188,12 @@ static int proxyTakeConch(unixFile *pFile){
int forceNewLockPath = 0;
OSTRACE(("TAKECONCH %d for %s pid=%d\n", conchFile->h,
- (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"), getpid()));
+ (pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"),
+ osGetpid(0)));
rc = proxyGetHostID(myHostID, &pError);
if( (rc&0xff)==SQLITE_IOERR ){
- pFile->lastErrno = pError;
+ storeLastErrno(pFile, pError);
goto end_takeconch;
}
rc = proxyConchLock(pFile, myHostID, SHARED_LOCK);
@@ -31615,7 +32204,7 @@ static int proxyTakeConch(unixFile *pFile){
readLen = seekAndRead((unixFile*)conchFile, 0, readBuf, PROXY_MAXCONCHLEN);
if( readLen<0 ){
/* I/O error: lastErrno set by seekAndRead */
- pFile->lastErrno = conchFile->lastErrno;
+ storeLastErrno(pFile, conchFile->lastErrno);
rc = SQLITE_IOERR_READ;
goto end_takeconch;
}else if( readLen<=(PROXY_HEADERLEN+PROXY_HOSTIDLEN) ||
@@ -31688,7 +32277,7 @@ static int proxyTakeConch(unixFile *pFile){
rc = proxyConchLock(pFile, myHostID, EXCLUSIVE_LOCK);
}
}else{
- rc = conchFile->pMethod->xLock((sqlite3_file*)conchFile, EXCLUSIVE_LOCK);
+ rc = proxyConchLock(pFile, myHostID, EXCLUSIVE_LOCK);
}
if( rc==SQLITE_OK ){
char writeBuffer[PROXY_MAXCONCHLEN];
@@ -31697,7 +32286,8 @@ static int proxyTakeConch(unixFile *pFile){
writeBuffer[0] = (char)PROXY_CONCHVERSION;
memcpy(&writeBuffer[PROXY_HEADERLEN], myHostID, PROXY_HOSTIDLEN);
if( pCtx->lockProxyPath!=NULL ){
- strlcpy(&writeBuffer[PROXY_PATHINDEX], pCtx->lockProxyPath, MAXPATHLEN);
+ strlcpy(&writeBuffer[PROXY_PATHINDEX], pCtx->lockProxyPath,
+ MAXPATHLEN);
}else{
strlcpy(&writeBuffer[PROXY_PATHINDEX], tempLockPath, MAXPATHLEN);
}
@@ -31809,7 +32399,7 @@ static int proxyReleaseConch(unixFile *pFile){
conchFile = pCtx->conchFile;
OSTRACE(("RELEASECONCH %d for %s pid=%d\n", conchFile->h,
(pCtx->lockProxyPath ? pCtx->lockProxyPath : ":auto:"),
- getpid()));
+ osGetpid(0)));
if( pCtx->conchHeld>0 ){
rc = conchFile->pMethod->xUnlock((sqlite3_file*)conchFile, NO_LOCK);
}
@@ -31909,7 +32499,8 @@ static int proxyGetDbPathForUnixFile(unixFile *pFile, char *dbPath){
/* afp style keeps a reference to the db path in the filePath field
** of the struct */
assert( (int)strlen((char*)pFile->lockingContext)<=MAXPATHLEN );
- strlcpy(dbPath, ((afpLockingContext *)pFile->lockingContext)->dbPath, MAXPATHLEN);
+ strlcpy(dbPath, ((afpLockingContext *)pFile->lockingContext)->dbPath,
+ MAXPATHLEN);
} else
#endif
if( pFile->pMethod == &dotlockIoMethods ){
@@ -31950,7 +32541,7 @@ static int proxyTransformUnixFile(unixFile *pFile, const char *path) {
}
OSTRACE(("TRANSPROXY %d for %s pid=%d\n", pFile->h,
- (lockPath ? lockPath : ":auto:"), getpid()));
+ (lockPath ? lockPath : ":auto:"), osGetpid(0)));
pCtx = sqlite3_malloc( sizeof(*pCtx) );
if( pCtx==0 ){
@@ -32022,7 +32613,7 @@ static int proxyTransformUnixFile(unixFile *pFile, const char *path) {
*/
static int proxyFileControl(sqlite3_file *id, int op, void *pArg){
switch( op ){
- case SQLITE_GET_LOCKPROXYFILE: {
+ case SQLITE_FCNTL_GET_LOCKPROXYFILE: {
unixFile *pFile = (unixFile*)id;
if( pFile->pMethod == &proxyIoMethods ){
proxyLockingContext *pCtx = (proxyLockingContext*)pFile->lockingContext;
@@ -32037,13 +32628,16 @@ static int proxyFileControl(sqlite3_file *id, int op, void *pArg){
}
return SQLITE_OK;
}
- case SQLITE_SET_LOCKPROXYFILE: {
+ case SQLITE_FCNTL_SET_LOCKPROXYFILE: {
unixFile *pFile = (unixFile*)id;
int rc = SQLITE_OK;
int isProxyStyle = (pFile->pMethod == &proxyIoMethods);
if( pArg==NULL || (const char *)pArg==0 ){
if( isProxyStyle ){
- /* turn off proxy locking - not supported */
+ /* turn off proxy locking - not supported. If support is added for
+ ** switching proxy locking mode off then it will need to fail if
+ ** the journal mode is WAL mode.
+ */
rc = SQLITE_ERROR /*SQLITE_PROTOCOL? SQLITE_MISUSE?*/;
}else{
/* turn off proxy locking - already off - NOOP */
@@ -32234,7 +32828,7 @@ static int proxyClose(sqlite3_file *id) {
** necessarily been initialized when this routine is called, and so they
** should not be used.
*/
-SQLITE_API int sqlite3_os_init(void){
+SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){
/*
** The following macro defines an initializer for an sqlite3_vfs object.
** The name of the VFS is NAME. The pAppData is a pointer to a pointer
@@ -32288,8 +32882,10 @@ SQLITE_API int sqlite3_os_init(void){
** array cannot be const.
*/
static sqlite3_vfs aVfs[] = {
-#if SQLITE_ENABLE_LOCKING_STYLE && (OS_VXWORKS || defined(__APPLE__))
+#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
UNIXVFS("unix", autolockIoFinder ),
+#elif OS_VXWORKS
+ UNIXVFS("unix", vxworksIoFinder ),
#else
UNIXVFS("unix", posixIoFinder ),
#endif
@@ -32299,11 +32895,11 @@ SQLITE_API int sqlite3_os_init(void){
#if OS_VXWORKS
UNIXVFS("unix-namedsem", semIoFinder ),
#endif
-#if SQLITE_ENABLE_LOCKING_STYLE
+#if SQLITE_ENABLE_LOCKING_STYLE || OS_VXWORKS
UNIXVFS("unix-posix", posixIoFinder ),
-#if !OS_VXWORKS
- UNIXVFS("unix-flock", flockIoFinder ),
#endif
+#if SQLITE_ENABLE_LOCKING_STYLE
+ UNIXVFS("unix-flock", flockIoFinder ),
#endif
#if SQLITE_ENABLE_LOCKING_STYLE && defined(__APPLE__)
UNIXVFS("unix-afp", afpIoFinder ),
@@ -32331,7 +32927,7 @@ SQLITE_API int sqlite3_os_init(void){
** to release dynamically allocated objects. But not on unix.
** This routine is a no-op for unix.
*/
-SQLITE_API int sqlite3_os_end(void){
+SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){
return SQLITE_OK;
}
@@ -32581,6 +33177,11 @@ SQLITE_API int sqlite3_open_file_count = 0;
with SQLITE_OMIT_WAL."
#endif
+#if !SQLITE_OS_WINNT && SQLITE_MAX_MMAP_SIZE>0
+# error "Memory mapped files require support from the Windows NT kernel,\
+ compile with SQLITE_MAX_MMAP_SIZE=0."
+#endif
+
/*
** Are most of the Win32 ANSI APIs available (i.e. with certain exceptions
** based on the sub-platform)?
@@ -32710,10 +33311,11 @@ SQLITE_API int sqlite3_open_file_count = 0;
/*
** Do we need to manually define the Win32 file mapping APIs for use with WAL
-** mode (e.g. these APIs are available in the Windows CE SDK; however, they
-** are not present in the header file)?
+** mode or memory mapped files (e.g. these APIs are available in the Windows
+** CE SDK; however, they are not present in the header file)?
*/
-#if SQLITE_WIN32_FILEMAPPING_API && !defined(SQLITE_OMIT_WAL)
+#if SQLITE_WIN32_FILEMAPPING_API && \
+ (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
/*
** Two of the file mapping APIs are different under WinRT. Figure out which
** set we need.
@@ -32738,10 +33340,12 @@ WINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T);
#endif /* SQLITE_OS_WINRT */
/*
-** This file mapping API is common to both Win32 and WinRT.
+** These file mapping APIs are common to both Win32 and WinRT.
*/
+
+WINBASEAPI BOOL WINAPI FlushViewOfFile(LPCVOID, SIZE_T);
WINBASEAPI BOOL WINAPI UnmapViewOfFile(LPCVOID);
-#endif /* SQLITE_WIN32_FILEMAPPING_API && !defined(SQLITE_OMIT_WAL) */
+#endif /* SQLITE_WIN32_FILEMAPPING_API */
/*
** Some Microsoft compilers lack this definition.
@@ -33034,7 +33638,7 @@ static struct win_syscall {
LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[5].pCurrent)
#if (!SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_ANSI) && \
- !defined(SQLITE_OMIT_WAL))
+ (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0))
{ "CreateFileMappingA", (SYSCALL)CreateFileMappingA, 0 },
#else
{ "CreateFileMappingA", (SYSCALL)0, 0 },
@@ -33044,7 +33648,7 @@ static struct win_syscall {
DWORD,DWORD,DWORD,LPCSTR))aSyscall[6].pCurrent)
#if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \
- !defined(SQLITE_OMIT_WAL))
+ (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0))
{ "CreateFileMappingW", (SYSCALL)CreateFileMappingW, 0 },
#else
{ "CreateFileMappingW", (SYSCALL)0, 0 },
@@ -33384,7 +33988,8 @@ static struct win_syscall {
LPOVERLAPPED))aSyscall[48].pCurrent)
#endif
-#if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && !defined(SQLITE_OMIT_WAL))
+#if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && \
+ (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0))
{ "MapViewOfFile", (SYSCALL)MapViewOfFile, 0 },
#else
{ "MapViewOfFile", (SYSCALL)0, 0 },
@@ -33454,7 +34059,7 @@ static struct win_syscall {
#define osUnlockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \
LPOVERLAPPED))aSyscall[58].pCurrent)
-#if SQLITE_OS_WINCE || !defined(SQLITE_OMIT_WAL)
+#if SQLITE_OS_WINCE || !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0
{ "UnmapViewOfFile", (SYSCALL)UnmapViewOfFile, 0 },
#else
{ "UnmapViewOfFile", (SYSCALL)0, 0 },
@@ -33517,7 +34122,7 @@ static struct win_syscall {
#define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \
FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[66].pCurrent)
-#if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_WAL)
+#if SQLITE_OS_WINRT && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
{ "MapViewOfFileFromApp", (SYSCALL)MapViewOfFileFromApp, 0 },
#else
{ "MapViewOfFileFromApp", (SYSCALL)0, 0 },
@@ -33581,7 +34186,7 @@ static struct win_syscall {
#define osGetProcessHeap ((HANDLE(WINAPI*)(VOID))aSyscall[74].pCurrent)
-#if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_WAL)
+#if SQLITE_OS_WINRT && (!defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0)
{ "CreateFileMappingFromApp", (SYSCALL)CreateFileMappingFromApp, 0 },
#else
{ "CreateFileMappingFromApp", (SYSCALL)0, 0 },
@@ -33606,6 +34211,32 @@ static struct win_syscall {
SQLITE_WIN32_VOLATILE*, LONG,LONG))aSyscall[76].pCurrent)
#endif /* defined(InterlockedCompareExchange) */
+#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID
+ { "UuidCreate", (SYSCALL)UuidCreate, 0 },
+#else
+ { "UuidCreate", (SYSCALL)0, 0 },
+#endif
+
+#define osUuidCreate ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[77].pCurrent)
+
+#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID
+ { "UuidCreateSequential", (SYSCALL)UuidCreateSequential, 0 },
+#else
+ { "UuidCreateSequential", (SYSCALL)0, 0 },
+#endif
+
+#define osUuidCreateSequential \
+ ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[78].pCurrent)
+
+#if !defined(SQLITE_NO_SYNC) && SQLITE_MAX_MMAP_SIZE>0
+ { "FlushViewOfFile", (SYSCALL)FlushViewOfFile, 0 },
+#else
+ { "FlushViewOfFile", (SYSCALL)0, 0 },
+#endif
+
+#define osFlushViewOfFile \
+ ((BOOL(WINAPI*)(LPCVOID,SIZE_T))aSyscall[79].pCurrent)
+
}; /* End of the overrideable system calls */
/*
@@ -33699,7 +34330,7 @@ static const char *winNextSystemCall(sqlite3_vfs *p, const char *zName){
** "pnLargest" argument, if non-zero, will be used to return the size of the
** largest committed free block in the heap, in bytes.
*/
-SQLITE_API int sqlite3_win32_compact_heap(LPUINT pnLargest){
+SQLITE_API int SQLITE_STDCALL sqlite3_win32_compact_heap(LPUINT pnLargest){
int rc = SQLITE_OK;
UINT nLargest = 0;
HANDLE hHeap;
@@ -33739,12 +34370,12 @@ SQLITE_API int sqlite3_win32_compact_heap(LPUINT pnLargest){
** the sqlite3_memory_used() function does not return zero, SQLITE_BUSY will
** be returned and no changes will be made to the Win32 native heap.
*/
-SQLITE_API int sqlite3_win32_reset_heap(){
+SQLITE_API int SQLITE_STDCALL sqlite3_win32_reset_heap(){
int rc;
MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */
MUTEX_LOGIC( sqlite3_mutex *pMem; ) /* The memsys static mutex */
- MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )
- MUTEX_LOGIC( pMem = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); )
+ MUTEX_LOGIC( pMaster = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); )
+ MUTEX_LOGIC( pMem = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); )
sqlite3_mutex_enter(pMaster);
sqlite3_mutex_enter(pMem);
winMemAssertMagic();
@@ -33784,7 +34415,7 @@ SQLITE_API int sqlite3_win32_reset_heap(){
** (if available).
*/
-SQLITE_API void sqlite3_win32_write_debug(const char *zBuf, int nBuf){
+SQLITE_API void SQLITE_STDCALL sqlite3_win32_write_debug(const char *zBuf, int nBuf){
char zDbgBuf[SQLITE_WIN32_DBG_BUF_SIZE];
int nMin = MIN(nBuf, (SQLITE_WIN32_DBG_BUF_SIZE - 1)); /* may be negative. */
if( nMin<-1 ) nMin = -1; /* all negative values become -1. */
@@ -33824,7 +34455,7 @@ SQLITE_API void sqlite3_win32_write_debug(const char *zBuf, int nBuf){
static HANDLE sleepObj = NULL;
#endif
-SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds){
+SQLITE_API void SQLITE_STDCALL sqlite3_win32_sleep(DWORD milliseconds){
#if SQLITE_OS_WINRT
if ( sleepObj==NULL ){
sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET,
@@ -33873,7 +34504,7 @@ SQLITE_PRIVATE DWORD sqlite3Win32Wait(HANDLE hObject){
** This function determines if the machine is running a version of Windows
** based on the NT kernel.
*/
-SQLITE_API int sqlite3_win32_is_nt(void){
+SQLITE_API int SQLITE_STDCALL sqlite3_win32_is_nt(void){
#if SQLITE_OS_WINRT
/*
** NOTE: The WinRT sub-platform is always assumed to be based on the NT
@@ -34227,7 +34858,7 @@ static char *winUnicodeToMbcs(LPCWSTR zWideFilename){
** Convert multibyte character string to UTF-8. Space to hold the
** returned string is obtained from sqlite3_malloc().
*/
-SQLITE_API char *sqlite3_win32_mbcs_to_utf8(const char *zFilename){
+SQLITE_API char *SQLITE_STDCALL sqlite3_win32_mbcs_to_utf8(const char *zFilename){
char *zFilenameUtf8;
LPWSTR zTmpWide;
@@ -34244,7 +34875,7 @@ SQLITE_API char *sqlite3_win32_mbcs_to_utf8(const char *zFilename){
** Convert UTF-8 to multibyte character string. Space to hold the
** returned string is obtained from sqlite3_malloc().
*/
-SQLITE_API char *sqlite3_win32_utf8_to_mbcs(const char *zFilename){
+SQLITE_API char *SQLITE_STDCALL sqlite3_win32_utf8_to_mbcs(const char *zFilename){
char *zFilenameMbcs;
LPWSTR zTmpWide;
@@ -34264,7 +34895,7 @@ SQLITE_API char *sqlite3_win32_utf8_to_mbcs(const char *zFilename){
** argument is the name of the directory to use. The return value will be
** SQLITE_OK if successful.
*/
-SQLITE_API int sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){
+SQLITE_API int SQLITE_STDCALL sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){
char **ppDirectory = 0;
#ifndef SQLITE_OMIT_AUTOINIT
int rc = sqlite3_initialize();
@@ -34489,11 +35120,11 @@ static int winRetryIoerr(int *pnRetry, DWORD *pError){
/*
** Log a I/O error retry episode.
*/
-static void winLogIoerr(int nRetry){
+static void winLogIoerr(int nRetry, int lineno){
if( nRetry ){
- sqlite3_log(SQLITE_IOERR,
- "delayed %dms for lock/sharing conflict",
- winIoerrRetryDelay*nRetry*(nRetry+1)/2
+ sqlite3_log(SQLITE_NOTICE,
+ "delayed %dms for lock/sharing conflict at line %d",
+ winIoerrRetryDelay*nRetry*(nRetry+1)/2, lineno
);
}
}
@@ -34973,7 +35604,8 @@ static int winClose(sqlite3_file *id){
assert( pFile->pShm==0 );
#endif
assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );
- OSTRACE(("CLOSE file=%p\n", pFile->h));
+ OSTRACE(("CLOSE pid=%lu, pFile=%p, file=%p\n",
+ osGetCurrentProcessId(), pFile, pFile->h));
#if SQLITE_MAX_MMAP_SIZE>0
winUnmapfile(pFile);
@@ -35002,7 +35634,8 @@ static int winClose(sqlite3_file *id){
pFile->h = NULL;
}
OpenCounter(-1);
- OSTRACE(("CLOSE file=%p, rc=%s\n", pFile->h, rc ? "ok" : "failed"));
+ OSTRACE(("CLOSE pid=%lu, pFile=%p, file=%p, rc=%s\n",
+ osGetCurrentProcessId(), pFile, pFile->h, rc ? "ok" : "failed"));
return rc ? SQLITE_OK
: winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
"winClose", pFile->zPath);
@@ -35019,7 +35652,7 @@ static int winRead(
int amt, /* Number of bytes to read */
sqlite3_int64 offset /* Begin reading at this offset */
){
-#if !SQLITE_OS_WINCE
+#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)
OVERLAPPED overlapped; /* The offset for ReadFile. */
#endif
winFile *pFile = (winFile*)id; /* file handle */
@@ -35030,7 +35663,8 @@ static int winRead(
assert( amt>0 );
assert( offset>=0 );
SimulateIOError(return SQLITE_IOERR_READ);
- OSTRACE(("READ file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n",
+ OSTRACE(("READ pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, "
+ "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile,
pFile->h, pBuf, amt, offset, pFile->locktype));
#if SQLITE_MAX_MMAP_SIZE>0
@@ -35039,7 +35673,8 @@ static int winRead(
if( offset<pFile->mmapSize ){
if( offset+amt <= pFile->mmapSize ){
memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt);
- OSTRACE(("READ-MMAP file=%p, rc=SQLITE_OK\n", pFile->h));
+ OSTRACE(("READ-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
+ osGetCurrentProcessId(), pFile, pFile->h));
return SQLITE_OK;
}else{
int nCopy = (int)(pFile->mmapSize - offset);
@@ -35051,9 +35686,10 @@ static int winRead(
}
#endif
-#if SQLITE_OS_WINCE
+#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)
if( winSeekFile(pFile, offset) ){
- OSTRACE(("READ file=%p, rc=SQLITE_FULL\n", pFile->h));
+ OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\n",
+ osGetCurrentProcessId(), pFile, pFile->h));
return SQLITE_FULL;
}
while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
@@ -35067,19 +35703,22 @@ static int winRead(
DWORD lastErrno;
if( winRetryIoerr(&nRetry, &lastErrno) ) continue;
pFile->lastErrno = lastErrno;
- OSTRACE(("READ file=%p, rc=SQLITE_IOERR_READ\n", pFile->h));
+ OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_READ\n",
+ osGetCurrentProcessId(), pFile, pFile->h));
return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
"winRead", pFile->zPath);
}
- winLogIoerr(nRetry);
+ winLogIoerr(nRetry, __LINE__);
if( nRead<(DWORD)amt ){
/* Unread parts of the buffer must be zero-filled */
memset(&((char*)pBuf)[nRead], 0, amt-nRead);
- OSTRACE(("READ file=%p, rc=SQLITE_IOERR_SHORT_READ\n", pFile->h));
+ OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_SHORT_READ\n",
+ osGetCurrentProcessId(), pFile, pFile->h));
return SQLITE_IOERR_SHORT_READ;
}
- OSTRACE(("READ file=%p, rc=SQLITE_OK\n", pFile->h));
+ OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
+ osGetCurrentProcessId(), pFile, pFile->h));
return SQLITE_OK;
}
@@ -35102,7 +35741,8 @@ static int winWrite(
SimulateIOError(return SQLITE_IOERR_WRITE);
SimulateDiskfullError(return SQLITE_FULL);
- OSTRACE(("WRITE file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n",
+ OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, "
+ "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile,
pFile->h, pBuf, amt, offset, pFile->locktype));
#if SQLITE_MAX_MMAP_SIZE>0
@@ -35111,7 +35751,8 @@ static int winWrite(
if( offset<pFile->mmapSize ){
if( offset+amt <= pFile->mmapSize ){
memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);
- OSTRACE(("WRITE-MMAP file=%p, rc=SQLITE_OK\n", pFile->h));
+ OSTRACE(("WRITE-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
+ osGetCurrentProcessId(), pFile, pFile->h));
return SQLITE_OK;
}else{
int nCopy = (int)(pFile->mmapSize - offset);
@@ -35123,13 +35764,13 @@ static int winWrite(
}
#endif
-#if SQLITE_OS_WINCE
+#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)
rc = winSeekFile(pFile, offset);
if( rc==0 ){
#else
{
#endif
-#if !SQLITE_OS_WINCE
+#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)
OVERLAPPED overlapped; /* The offset for WriteFile. */
#endif
u8 *aRem = (u8 *)pBuf; /* Data yet to be written */
@@ -35137,14 +35778,14 @@ static int winWrite(
DWORD nWrite; /* Bytes written by each WriteFile() call */
DWORD lastErrno = NO_ERROR; /* Value returned by GetLastError() */
-#if !SQLITE_OS_WINCE
+#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)
memset(&overlapped, 0, sizeof(OVERLAPPED));
overlapped.Offset = (LONG)(offset & 0xffffffff);
overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
#endif
while( nRem>0 ){
-#if SQLITE_OS_WINCE
+#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)
if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, 0) ){
#else
if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, &overlapped) ){
@@ -35157,7 +35798,7 @@ static int winWrite(
lastErrno = osGetLastError();
break;
}
-#if !SQLITE_OS_WINCE
+#if !SQLITE_OS_WINCE && !defined(SQLITE_WIN32_NO_OVERLAPPED)
offset += nWrite;
overlapped.Offset = (LONG)(offset & 0xffffffff);
overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
@@ -35174,17 +35815,20 @@ static int winWrite(
if( rc ){
if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )
|| ( pFile->lastErrno==ERROR_DISK_FULL )){
- OSTRACE(("WRITE file=%p, rc=SQLITE_FULL\n", pFile->h));
+ OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\n",
+ osGetCurrentProcessId(), pFile, pFile->h));
return winLogError(SQLITE_FULL, pFile->lastErrno,
"winWrite1", pFile->zPath);
}
- OSTRACE(("WRITE file=%p, rc=SQLITE_IOERR_WRITE\n", pFile->h));
+ OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_WRITE\n",
+ osGetCurrentProcessId(), pFile, pFile->h));
return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,
"winWrite2", pFile->zPath);
}else{
- winLogIoerr(nRetry);
+ winLogIoerr(nRetry, __LINE__);
}
- OSTRACE(("WRITE file=%p, rc=SQLITE_OK\n", pFile->h));
+ OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
+ osGetCurrentProcessId(), pFile, pFile->h));
return SQLITE_OK;
}
@@ -35198,8 +35842,8 @@ static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
assert( pFile );
SimulateIOError(return SQLITE_IOERR_TRUNCATE);
- OSTRACE(("TRUNCATE file=%p, size=%lld, lock=%d\n",
- pFile->h, nByte, pFile->locktype));
+ OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, size=%lld, lock=%d\n",
+ osGetCurrentProcessId(), pFile, pFile->h, nByte, pFile->locktype));
/* If the user has configured a chunk-size for this file, truncate the
** file so that it consists of an integer number of chunks (i.e. the
@@ -35231,7 +35875,8 @@ static int winTruncate(sqlite3_file *id, sqlite3_int64 nByte){
}
#endif
- OSTRACE(("TRUNCATE file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
+ OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, rc=%s\n",
+ osGetCurrentProcessId(), pFile, pFile->h, sqlite3ErrName(rc)));
return rc;
}
@@ -35276,8 +35921,9 @@ static int winSync(sqlite3_file *id, int flags){
*/
SimulateDiskfullError( return SQLITE_FULL );
- OSTRACE(("SYNC file=%p, flags=%x, lock=%d\n",
- pFile->h, flags, pFile->locktype));
+ OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, flags=%x, lock=%d\n",
+ osGetCurrentProcessId(), pFile, pFile->h, flags,
+ pFile->locktype));
#ifndef SQLITE_TEST
UNUSED_PARAMETER(flags);
@@ -35292,19 +35938,38 @@ static int winSync(sqlite3_file *id, int flags){
** no-op
*/
#ifdef SQLITE_NO_SYNC
- OSTRACE(("SYNC-NOP file=%p, rc=SQLITE_OK\n", pFile->h));
+ OSTRACE(("SYNC-NOP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
+ osGetCurrentProcessId(), pFile, pFile->h));
return SQLITE_OK;
#else
+#if SQLITE_MAX_MMAP_SIZE>0
+ if( pFile->pMapRegion ){
+ if( osFlushViewOfFile(pFile->pMapRegion, 0) ){
+ OSTRACE(("SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, "
+ "rc=SQLITE_OK\n", osGetCurrentProcessId(),
+ pFile, pFile->pMapRegion));
+ }else{
+ pFile->lastErrno = osGetLastError();
+ OSTRACE(("SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, "
+ "rc=SQLITE_IOERR_MMAP\n", osGetCurrentProcessId(),
+ pFile, pFile->pMapRegion));
+ return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,
+ "winSync1", pFile->zPath);
+ }
+ }
+#endif
rc = osFlushFileBuffers(pFile->h);
SimulateIOError( rc=FALSE );
if( rc ){
- OSTRACE(("SYNC file=%p, rc=SQLITE_OK\n", pFile->h));
+ OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
+ osGetCurrentProcessId(), pFile, pFile->h));
return SQLITE_OK;
}else{
pFile->lastErrno = osGetLastError();
- OSTRACE(("SYNC file=%p, rc=SQLITE_IOERR_FSYNC\n", pFile->h));
+ OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_FSYNC\n",
+ osGetCurrentProcessId(), pFile, pFile->h));
return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,
- "winSync", pFile->zPath);
+ "winSync2", pFile->zPath);
}
#endif
}
@@ -36354,16 +37019,16 @@ static int winShmMap(
void volatile **pp /* OUT: Mapped memory */
){
winFile *pDbFd = (winFile*)fd;
- winShm *p = pDbFd->pShm;
+ winShm *pShm = pDbFd->pShm;
winShmNode *pShmNode;
int rc = SQLITE_OK;
- if( !p ){
+ if( !pShm ){
rc = winOpenSharedMemory(pDbFd);
if( rc!=SQLITE_OK ) return rc;
- p = pDbFd->pShm;
+ pShm = pDbFd->pShm;
}
- pShmNode = p->pShmNode;
+ pShmNode = pShm->pShmNode;
sqlite3_mutex_enter(pShmNode->mutex);
assert( szRegion==pShmNode->szRegion || pShmNode->nRegion==0 );
@@ -37275,7 +37940,7 @@ static int winOpen(
}
}
#endif
- winLogIoerr(cnt);
+ winLogIoerr(cnt, __LINE__);
OSTRACE(("OPEN file=%p, name=%s, access=%lx, rc=%s\n", h, zUtf8Name,
dwDesiredAccess, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
@@ -37459,7 +38124,7 @@ static int winDelete(
if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){
rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, "winDelete", zFilename);
}else{
- winLogIoerr(cnt);
+ winLogIoerr(cnt, __LINE__);
}
sqlite3_free(zConverted);
OSTRACE(("DELETE name=%s, rc=%s\n", zFilename, sqlite3ErrName(rc)));
@@ -37509,7 +38174,7 @@ static int winAccess(
attr = sAttrData.dwFileAttributes;
}
}else{
- winLogIoerr(cnt);
+ winLogIoerr(cnt, __LINE__);
if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){
sqlite3_free(zConverted);
return winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess",
@@ -37885,6 +38550,22 @@ static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
n += sizeof(i);
}
#endif
+#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID
+ if( sizeof(UUID)<=nBuf-n ){
+ UUID id;
+ memset(&id, 0, sizeof(UUID));
+ osUuidCreate(&id);
+ memcpy(zBuf, &id, sizeof(UUID));
+ n += sizeof(UUID);
+ }
+ if( sizeof(UUID)<=nBuf-n ){
+ UUID id;
+ memset(&id, 0, sizeof(UUID));
+ osUuidCreateSequential(&id);
+ memcpy(zBuf, &id, sizeof(UUID));
+ n += sizeof(UUID);
+ }
+#endif
return n;
}
@@ -38008,7 +38689,7 @@ static int winGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
/*
** Initialize and deinitialize the operating system interface.
*/
-SQLITE_API int sqlite3_os_init(void){
+SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){
static sqlite3_vfs winVfs = {
3, /* iVersion */
sizeof(winFile), /* szOsFile */
@@ -38062,7 +38743,7 @@ SQLITE_API int sqlite3_os_init(void){
/* Double-check that the aSyscall[] array has been constructed
** correctly. See ticket [bb3a86e890c8e96ab] */
- assert( ArraySize(aSyscall)==77 );
+ assert( ArraySize(aSyscall)==80 );
/* get memory map allocation granularity */
memset(&winSysInfo, 0, sizeof(SYSTEM_INFO));
@@ -38083,7 +38764,7 @@ SQLITE_API int sqlite3_os_init(void){
return SQLITE_OK;
}
-SQLITE_API int sqlite3_os_end(void){
+SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){
#if SQLITE_OS_WINRT
if( sleepObj!=NULL ){
osCloseHandle(sleepObj);
@@ -38538,18 +39219,6 @@ struct PCache {
PgHdr *pPage1; /* Reference to page 1 */
};
-/*
-** Some of the assert() macros in this code are too expensive to run
-** even during normal debugging. Use them only rarely on long-running
-** tests. Enable the expensive asserts using the
-** -DSQLITE_ENABLE_EXPENSIVE_ASSERT=1 compile-time option.
-*/
-#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
-# define expensive_assert(X) assert(X)
-#else
-# define expensive_assert(X)
-#endif
-
/********************************** Linked List Management ********************/
/* Allowed values for second argument to pcacheManageDirtyList() */
@@ -38633,12 +39302,20 @@ static void pcacheUnpin(PgHdr *p){
}
/*
-** Compute the number of pages of cache requested.
+** Compute the number of pages of cache requested. p->szCache is the
+** cache size requested by the "PRAGMA cache_size" statement.
+**
+**
*/
static int numberOfCachePages(PCache *p){
if( p->szCache>=0 ){
+ /* IMPLEMENTATION-OF: R-42059-47211 If the argument N is positive then the
+ ** suggested cache size is set to N. */
return p->szCache;
}else{
+ /* IMPLEMENTATION-OF: R-61436-13639 If the argument N is negative, then
+ ** the number of cache pages is adjusted to use approximately abs(N*1024)
+ ** bytes of memory. */
return (int)((-1024*(i64)p->szCache)/(p->szPage+p->szExtra));
}
}
@@ -38703,7 +39380,8 @@ SQLITE_PRIVATE int sqlite3PcacheSetPageSize(PCache *pCache, int szPage){
if( pCache->szPage ){
sqlite3_pcache *pNew;
pNew = sqlite3GlobalConfig.pcache2.xCreate(
- szPage, pCache->szExtra + sizeof(PgHdr), pCache->bPurgeable
+ szPage, pCache->szExtra + ROUND8(sizeof(PgHdr)),
+ pCache->bPurgeable
);
if( pNew==0 ) return SQLITE_NOMEM;
sqlite3GlobalConfig.pcache2.xCachesize(pNew, numberOfCachePages(pCache));
@@ -39158,6 +39836,13 @@ SQLITE_PRIVATE void sqlite3PcacheShrink(PCache *pCache){
sqlite3GlobalConfig.pcache2.xShrink(pCache->pCache);
}
+/*
+** Return the size of the header added by this middleware layer
+** in the page-cache hierarchy.
+*/
+SQLITE_PRIVATE int sqlite3HeaderSizePcache(void){ return ROUND8(sizeof(PgHdr)); }
+
+
#if defined(SQLITE_CHECK_PAGES) || defined(SQLITE_DEBUG)
/*
** For all dirty pages currently in the cache, invoke the specified
@@ -39370,7 +40055,6 @@ SQLITE_PRIVATE void sqlite3PCacheBufferSetup(void *pBuf, int sz, int n){
static void *pcache1Alloc(int nByte){
void *p = 0;
assert( sqlite3_mutex_notheld(pcache1.grp.mutex) );
- sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte);
if( nByte<=pcache1.szSlot ){
sqlite3_mutex_enter(pcache1.mutex);
p = (PgHdr1 *)pcache1.pFree;
@@ -39379,7 +40063,8 @@ static void *pcache1Alloc(int nByte){
pcache1.nFreeSlot--;
pcache1.bUnderPressure = pcache1.nFreeSlot<pcache1.nReserve;
assert( pcache1.nFreeSlot>=0 );
- sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, 1);
+ sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte);
+ sqlite3StatusUp(SQLITE_STATUS_PAGECACHE_USED, 1);
}
sqlite3_mutex_leave(pcache1.mutex);
}
@@ -39392,7 +40077,8 @@ static void *pcache1Alloc(int nByte){
if( p ){
int sz = sqlite3MallocSize(p);
sqlite3_mutex_enter(pcache1.mutex);
- sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz);
+ sqlite3StatusSet(SQLITE_STATUS_PAGECACHE_SIZE, nByte);
+ sqlite3StatusUp(SQLITE_STATUS_PAGECACHE_OVERFLOW, sz);
sqlite3_mutex_leave(pcache1.mutex);
}
#endif
@@ -39410,7 +40096,7 @@ static int pcache1Free(void *p){
if( p>=pcache1.pStart && p<pcache1.pEnd ){
PgFreeslot *pSlot;
sqlite3_mutex_enter(pcache1.mutex);
- sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_USED, -1);
+ sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_USED, 1);
pSlot = (PgFreeslot*)p;
pSlot->pNext = pcache1.pFree;
pcache1.pFree = pSlot;
@@ -39424,7 +40110,7 @@ static int pcache1Free(void *p){
nFreed = sqlite3MallocSize(p);
#ifndef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
sqlite3_mutex_enter(pcache1.mutex);
- sqlite3StatusAdd(SQLITE_STATUS_PAGECACHE_OVERFLOW, -nFreed);
+ sqlite3StatusDown(SQLITE_STATUS_PAGECACHE_OVERFLOW, nFreed);
sqlite3_mutex_leave(pcache1.mutex);
#endif
sqlite3_free(p);
@@ -39471,7 +40157,7 @@ static PgHdr1 *pcache1AllocPage(PCache1 *pCache){
pPg = 0;
}
#else
- pPg = pcache1Alloc(sizeof(PgHdr1) + pCache->szPage + pCache->szExtra);
+ pPg = pcache1Alloc(ROUND8(sizeof(PgHdr1)) + pCache->szPage + pCache->szExtra);
p = (PgHdr1 *)&((u8 *)pPg)[pCache->szPage];
#endif
pcache1EnterMutex(pCache->pGroup);
@@ -40156,6 +40842,19 @@ SQLITE_PRIVATE void sqlite3PCacheSetDefault(void){
sqlite3_config(SQLITE_CONFIG_PCACHE2, &defaultMethods);
}
+/*
+** Return the size of the header on each page of this PCACHE implementation.
+*/
+SQLITE_PRIVATE int sqlite3HeaderSizePcache1(void){ return ROUND8(sizeof(PgHdr1)); }
+
+/*
+** Return the global mutex used by this PCACHE implementation. The
+** sqlite3_status() routine needs access to this mutex.
+*/
+SQLITE_PRIVATE sqlite3_mutex *sqlite3Pcache1Mutex(void){
+ return pcache1.mutex;
+}
+
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
/*
** This function is called to free superfluous dynamically allocated memory
@@ -41512,6 +42211,8 @@ struct Pager {
u8 setMaster; /* True if a m-j name has been written to jrnl */
u8 doNotSpill; /* Do not spill the cache when non-zero */
u8 subjInMemory; /* True to use in-memory sub-journals */
+ u8 bUseFetch; /* True to use xFetch() */
+ u8 hasBeenUsed; /* True if any content previously read from this pager*/
Pgno dbSize; /* Number of pages in the database */
Pgno dbOrigSize; /* dbSize before the current transaction */
Pgno dbFileSize; /* Number of pages in the database file */
@@ -41529,9 +42230,9 @@ struct Pager {
sqlite3_backup *pBackup; /* Pointer to list of ongoing backup processes */
PagerSavepoint *aSavepoint; /* Array of active savepoints */
int nSavepoint; /* Number of elements in aSavepoint[] */
+ u32 iDataVersion; /* Changes whenever database content changes */
char dbFileVers[16]; /* Changes whenever database file changes */
- u8 bUseFetch; /* True to use xFetch() */
int nMmapOut; /* Number of mmap pages currently outstanding */
sqlite3_int64 szMmap; /* Desired maximum mmap size */
PgHdr *pMmapFreelist; /* List of free mmap page headers (pDirty) */
@@ -42547,11 +43248,20 @@ static int writeMasterJournal(Pager *pPager, const char *zMaster){
** Discard the entire contents of the in-memory page-cache.
*/
static void pager_reset(Pager *pPager){
+ pPager->iDataVersion++;
sqlite3BackupRestart(pPager->pBackup);
sqlite3PcacheClear(pPager->pPCache);
}
/*
+** Return the pPager->iDataVersion value
+*/
+SQLITE_PRIVATE u32 sqlite3PagerDataVersion(Pager *pPager){
+ assert( pPager->eState>PAGER_OPEN );
+ return pPager->iDataVersion;
+}
+
+/*
** Free all structures in the Pager.aSavepoint[] array and set both
** Pager.aSavepoint and Pager.nSavepoint to zero. Close the sub-journal
** if it is open and the pager is not in exclusive mode.
@@ -43765,7 +44475,7 @@ static int readDbPage(PgHdr *pPg, u32 iFrame){
**
** For an encrypted database, the situation is more complex: bytes
** 24..39 of the database are white noise. But the probability of
- ** white noising equaling 16 bytes of 0xff is vanishingly small so
+ ** white noise equaling 16 bytes of 0xff is vanishingly small so
** we should still be ok.
*/
memset(pPager->dbFileVers, 0xff, sizeof(pPager->dbFileVers));
@@ -44753,7 +45463,7 @@ static int pagerAcquireMapPage(
PgHdr **ppPage /* OUT: Acquired page object */
){
PgHdr *p; /* Memory mapped page to return */
-
+
if( pPager->pMmapFreelist ){
*ppPage = p = pPager->pMmapFreelist;
pPager->pMmapFreelist = p->pDirty;
@@ -45984,16 +46694,12 @@ SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager){
);
}
- if( !pPager->tempFile && (
- pPager->pBackup
- || sqlite3PcachePagecount(pPager->pPCache)>0
- || USEFETCH(pPager)
- )){
- /* The shared-lock has just been acquired on the database file
- ** and there are already pages in the cache (from a previous
- ** read or write transaction). Check to see if the database
- ** has been modified. If the database has changed, flush the
- ** cache.
+ if( !pPager->tempFile && pPager->hasBeenUsed ){
+ /* The shared-lock has just been acquired then check to
+ ** see if the database has been modified. If the database has changed,
+ ** flush the cache. The pPager->hasBeenUsed flag prevents this from
+ ** occurring on the very first access to a file, in order to save a
+ ** single unnecessary sqlite3OsRead() call at the start-up.
**
** Database changes is detected by looking at 15 bytes beginning
** at offset 24 into the file. The first 4 of these 16 bytes are
@@ -46158,6 +46864,7 @@ SQLITE_PRIVATE int sqlite3PagerAcquire(
if( pgno==0 ){
return SQLITE_CORRUPT_BKPT;
}
+ pPager->hasBeenUsed = 1;
/* If the pager is in the error state, return an error immediately.
** Otherwise, request the page from the PCache layer. */
@@ -46307,6 +47014,7 @@ SQLITE_PRIVATE DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno){
assert( pgno!=0 );
assert( pPager->pPCache!=0 );
pPage = sqlite3PcacheFetch(pPager->pPCache, pgno, 0);
+ assert( pPage==0 || pPager->hasBeenUsed );
return sqlite3PcacheFetchFinish(pPager->pPCache, pgno, pPage);
}
@@ -47173,6 +47881,7 @@ SQLITE_PRIVATE int sqlite3PagerCommitPhaseTwo(Pager *pPager){
}
PAGERTRACE(("COMMIT %d\n", PAGERID(pPager)));
+ pPager->iDataVersion++;
rc = pager_end_transaction(pPager, pPager->setMaster, 1);
return pager_error(pPager, rc);
}
@@ -47714,6 +48423,18 @@ SQLITE_PRIVATE int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno, i
#endif
/*
+** The page handle passed as the first argument refers to a dirty page
+** with a page number other than iNew. This function changes the page's
+** page number to iNew and sets the value of the PgHdr.flags field to
+** the value passed as the third parameter.
+*/
+SQLITE_PRIVATE void sqlite3PagerRekey(DbPage *pPg, Pgno iNew, u16 flags){
+ assert( pPg->pgno!=iNew );
+ pPg->flags = flags;
+ sqlite3PcacheMove(pPg, iNew);
+}
+
+/*
** Return a pointer to the data for the specified page.
*/
SQLITE_PRIVATE void *sqlite3PagerGetData(DbPage *pPg){
@@ -47929,7 +48650,8 @@ SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager, int eMode, int *pnLog,
int rc = SQLITE_OK;
if( pPager->pWal ){
rc = sqlite3WalCheckpoint(pPager->pWal, eMode,
- pPager->xBusyHandler, pPager->pBusyHandlerArg,
+ (eMode==SQLITE_CHECKPOINT_PASSIVE ? 0 : pPager->xBusyHandler),
+ pPager->pBusyHandlerArg,
pPager->ckptSyncFlags, pPager->pageSize, (u8 *)pPager->pTmpSpace,
pnLog, pnCkpt
);
@@ -48111,6 +48833,7 @@ SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager){
}
#endif
+
#endif /* SQLITE_OMIT_DISKIO */
/************** End of pager.c ***********************************************/
@@ -48904,9 +49627,10 @@ static void walUnlockShared(Wal *pWal, int lockIdx){
SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED);
WALTRACE(("WAL%p: release SHARED-%s\n", pWal, walLockName(lockIdx)));
}
-static int walLockExclusive(Wal *pWal, int lockIdx, int n){
+static int walLockExclusive(Wal *pWal, int lockIdx, int n, int fBlock){
int rc;
if( pWal->exclusiveMode ) return SQLITE_OK;
+ if( fBlock ) sqlite3OsFileControl(pWal->pDbFd, SQLITE_FCNTL_WAL_BLOCK, 0);
rc = sqlite3OsShmLock(pWal->pDbFd, lockIdx, n,
SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE);
WALTRACE(("WAL%p: acquire EXCLUSIVE-%s cnt=%d %s\n", pWal,
@@ -49192,7 +49916,7 @@ static int walIndexRecover(Wal *pWal){
assert( pWal->writeLock );
iLock = WAL_ALL_BUT_WRITE + pWal->ckptLock;
nLock = SQLITE_SHM_NLOCK - iLock;
- rc = walLockExclusive(pWal, iLock, nLock);
+ rc = walLockExclusive(pWal, iLock, nLock, 0);
if( rc ){
return rc;
}
@@ -49620,7 +50344,7 @@ static void walMergesort(
** Free an iterator allocated by walIteratorInit().
*/
static void walIteratorFree(WalIterator *p){
- sqlite3ScratchFree(p);
+ sqlite3_free(p);
}
/*
@@ -49655,7 +50379,7 @@ static int walIteratorInit(Wal *pWal, WalIterator **pp){
nByte = sizeof(WalIterator)
+ (nSegment-1)*sizeof(struct WalSegment)
+ iLast*sizeof(ht_slot);
- p = (WalIterator *)sqlite3ScratchMalloc(nByte);
+ p = (WalIterator *)sqlite3_malloc(nByte);
if( !p ){
return SQLITE_NOMEM;
}
@@ -49665,7 +50389,7 @@ static int walIteratorInit(Wal *pWal, WalIterator **pp){
/* Allocate temporary space used by the merge-sort routine. This block
** of memory will be freed before this function returns.
*/
- aTmp = (ht_slot *)sqlite3ScratchMalloc(
+ aTmp = (ht_slot *)sqlite3_malloc(
sizeof(ht_slot) * (iLast>HASHTABLE_NPAGE?HASHTABLE_NPAGE:iLast)
);
if( !aTmp ){
@@ -49702,7 +50426,7 @@ static int walIteratorInit(Wal *pWal, WalIterator **pp){
p->aSegment[i].aPgno = (u32 *)aPgno;
}
}
- sqlite3ScratchFree(aTmp);
+ sqlite3_free(aTmp);
if( rc!=SQLITE_OK ){
walIteratorFree(p);
@@ -49726,7 +50450,7 @@ static int walBusyLock(
){
int rc;
do {
- rc = walLockExclusive(pWal, lockIdx, n);
+ rc = walLockExclusive(pWal, lockIdx, n, 0);
}while( xBusy && rc==SQLITE_BUSY && xBusy(pBusyArg) );
return rc;
}
@@ -49740,6 +50464,38 @@ static int walPagesize(Wal *pWal){
}
/*
+** The following is guaranteed when this function is called:
+**
+** a) the WRITER lock is held,
+** b) the entire log file has been checkpointed, and
+** c) any existing readers are reading exclusively from the database
+** file - there are no readers that may attempt to read a frame from
+** the log file.
+**
+** This function updates the shared-memory structures so that the next
+** client to write to the database (which may be this one) does so by
+** writing frames into the start of the log file.
+**
+** The value of parameter salt1 is used as the aSalt[1] value in the
+** new wal-index header. It should be passed a pseudo-random value (i.e.
+** one obtained from sqlite3_randomness()).
+*/
+static void walRestartHdr(Wal *pWal, u32 salt1){
+ volatile WalCkptInfo *pInfo = walCkptInfo(pWal);
+ int i; /* Loop counter */
+ u32 *aSalt = pWal->hdr.aSalt; /* Big-endian salt values */
+ pWal->nCkpt++;
+ pWal->hdr.mxFrame = 0;
+ sqlite3Put4byte((u8*)&aSalt[0], 1 + sqlite3Get4byte((u8*)&aSalt[0]));
+ memcpy(&pWal->hdr.aSalt[1], &salt1, 4);
+ walIndexWriteHdr(pWal);
+ pInfo->nBackfill = 0;
+ pInfo->aReadMark[1] = 0;
+ for(i=2; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;
+ assert( pInfo->aReadMark[0]==0 );
+}
+
+/*
** Copy as much content as we can from the WAL back into the database file
** in response to an sqlite3_wal_checkpoint() request or the equivalent.
**
@@ -49773,12 +50529,12 @@ static int walPagesize(Wal *pWal){
static int walCheckpoint(
Wal *pWal, /* Wal connection */
int eMode, /* One of PASSIVE, FULL or RESTART */
- int (*xBusyCall)(void*), /* Function to call when busy */
+ int (*xBusy)(void*), /* Function to call when busy */
void *pBusyArg, /* Context argument for xBusyHandler */
int sync_flags, /* Flags for OsSync() (or 0) */
u8 *zBuf /* Temporary buffer to use */
){
- int rc; /* Return code */
+ int rc = SQLITE_OK; /* Return code */
int szPage; /* Database page-size */
WalIterator *pIter = 0; /* Wal iterator context */
u32 iDbpage = 0; /* Next database page to write */
@@ -49787,123 +50543,146 @@ static int walCheckpoint(
u32 mxPage; /* Max database page to write */
int i; /* Loop counter */
volatile WalCkptInfo *pInfo; /* The checkpoint status information */
- int (*xBusy)(void*) = 0; /* Function to call when waiting for locks */
szPage = walPagesize(pWal);
testcase( szPage<=32768 );
testcase( szPage>=65536 );
pInfo = walCkptInfo(pWal);
- if( pInfo->nBackfill>=pWal->hdr.mxFrame ) return SQLITE_OK;
+ if( pInfo->nBackfill<pWal->hdr.mxFrame ){
- /* Allocate the iterator */
- rc = walIteratorInit(pWal, &pIter);
- if( rc!=SQLITE_OK ){
- return rc;
- }
- assert( pIter );
+ /* Allocate the iterator */
+ rc = walIteratorInit(pWal, &pIter);
+ if( rc!=SQLITE_OK ){
+ return rc;
+ }
+ assert( pIter );
- if( eMode!=SQLITE_CHECKPOINT_PASSIVE ) xBusy = xBusyCall;
+ /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked
+ ** in the SQLITE_CHECKPOINT_PASSIVE mode. */
+ assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );
- /* Compute in mxSafeFrame the index of the last frame of the WAL that is
- ** safe to write into the database. Frames beyond mxSafeFrame might
- ** overwrite database pages that are in use by active readers and thus
- ** cannot be backfilled from the WAL.
- */
- mxSafeFrame = pWal->hdr.mxFrame;
- mxPage = pWal->hdr.nPage;
- for(i=1; i<WAL_NREADER; i++){
- u32 y = pInfo->aReadMark[i];
- if( mxSafeFrame>y ){
- assert( y<=pWal->hdr.mxFrame );
- rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
- if( rc==SQLITE_OK ){
- pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED);
- walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
- }else if( rc==SQLITE_BUSY ){
- mxSafeFrame = y;
- xBusy = 0;
- }else{
- goto walcheckpoint_out;
+ /* Compute in mxSafeFrame the index of the last frame of the WAL that is
+ ** safe to write into the database. Frames beyond mxSafeFrame might
+ ** overwrite database pages that are in use by active readers and thus
+ ** cannot be backfilled from the WAL.
+ */
+ mxSafeFrame = pWal->hdr.mxFrame;
+ mxPage = pWal->hdr.nPage;
+ for(i=1; i<WAL_NREADER; i++){
+ u32 y = pInfo->aReadMark[i];
+ if( mxSafeFrame>y ){
+ assert( y<=pWal->hdr.mxFrame );
+ rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
+ if( rc==SQLITE_OK ){
+ pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED);
+ walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1);
+ }else if( rc==SQLITE_BUSY ){
+ mxSafeFrame = y;
+ xBusy = 0;
+ }else{
+ goto walcheckpoint_out;
+ }
}
}
- }
-
- if( pInfo->nBackfill<mxSafeFrame
- && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0), 1))==SQLITE_OK
- ){
- i64 nSize; /* Current size of database file */
- u32 nBackfill = pInfo->nBackfill;
- /* Sync the WAL to disk */
- if( sync_flags ){
- rc = sqlite3OsSync(pWal->pWalFd, sync_flags);
- }
+ if( pInfo->nBackfill<mxSafeFrame
+ && (rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(0),1))==SQLITE_OK
+ ){
+ i64 nSize; /* Current size of database file */
+ u32 nBackfill = pInfo->nBackfill;
- /* If the database may grow as a result of this checkpoint, hint
- ** about the eventual size of the db file to the VFS layer.
- */
- if( rc==SQLITE_OK ){
- i64 nReq = ((i64)mxPage * szPage);
- rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);
- if( rc==SQLITE_OK && nSize<nReq ){
- sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);
+ /* Sync the WAL to disk */
+ if( sync_flags ){
+ rc = sqlite3OsSync(pWal->pWalFd, sync_flags);
}
- }
+ /* If the database may grow as a result of this checkpoint, hint
+ ** about the eventual size of the db file to the VFS layer.
+ */
+ if( rc==SQLITE_OK ){
+ i64 nReq = ((i64)mxPage * szPage);
+ rc = sqlite3OsFileSize(pWal->pDbFd, &nSize);
+ if( rc==SQLITE_OK && nSize<nReq ){
+ sqlite3OsFileControlHint(pWal->pDbFd, SQLITE_FCNTL_SIZE_HINT, &nReq);
+ }
+ }
- /* Iterate through the contents of the WAL, copying data to the db file. */
- while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
- i64 iOffset;
- assert( walFramePgno(pWal, iFrame)==iDbpage );
- if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ) continue;
- iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;
- /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */
- rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);
- if( rc!=SQLITE_OK ) break;
- iOffset = (iDbpage-1)*(i64)szPage;
- testcase( IS_BIG_INT(iOffset) );
- rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);
- if( rc!=SQLITE_OK ) break;
- }
- /* If work was actually accomplished... */
- if( rc==SQLITE_OK ){
- if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
- i64 szDb = pWal->hdr.nPage*(i64)szPage;
- testcase( IS_BIG_INT(szDb) );
- rc = sqlite3OsTruncate(pWal->pDbFd, szDb);
- if( rc==SQLITE_OK && sync_flags ){
- rc = sqlite3OsSync(pWal->pDbFd, sync_flags);
+ /* Iterate through the contents of the WAL, copying data to the db file */
+ while( rc==SQLITE_OK && 0==walIteratorNext(pIter, &iDbpage, &iFrame) ){
+ i64 iOffset;
+ assert( walFramePgno(pWal, iFrame)==iDbpage );
+ if( iFrame<=nBackfill || iFrame>mxSafeFrame || iDbpage>mxPage ){
+ continue;
}
+ iOffset = walFrameOffset(iFrame, szPage) + WAL_FRAME_HDRSIZE;
+ /* testcase( IS_BIG_INT(iOffset) ); // requires a 4GiB WAL file */
+ rc = sqlite3OsRead(pWal->pWalFd, zBuf, szPage, iOffset);
+ if( rc!=SQLITE_OK ) break;
+ iOffset = (iDbpage-1)*(i64)szPage;
+ testcase( IS_BIG_INT(iOffset) );
+ rc = sqlite3OsWrite(pWal->pDbFd, zBuf, szPage, iOffset);
+ if( rc!=SQLITE_OK ) break;
}
+
+ /* If work was actually accomplished... */
if( rc==SQLITE_OK ){
- pInfo->nBackfill = mxSafeFrame;
+ if( mxSafeFrame==walIndexHdr(pWal)->mxFrame ){
+ i64 szDb = pWal->hdr.nPage*(i64)szPage;
+ testcase( IS_BIG_INT(szDb) );
+ rc = sqlite3OsTruncate(pWal->pDbFd, szDb);
+ if( rc==SQLITE_OK && sync_flags ){
+ rc = sqlite3OsSync(pWal->pDbFd, sync_flags);
+ }
+ }
+ if( rc==SQLITE_OK ){
+ pInfo->nBackfill = mxSafeFrame;
+ }
}
- }
- /* Release the reader lock held while backfilling */
- walUnlockExclusive(pWal, WAL_READ_LOCK(0), 1);
- }
+ /* Release the reader lock held while backfilling */
+ walUnlockExclusive(pWal, WAL_READ_LOCK(0), 1);
+ }
- if( rc==SQLITE_BUSY ){
- /* Reset the return code so as not to report a checkpoint failure
- ** just because there are active readers. */
- rc = SQLITE_OK;
+ if( rc==SQLITE_BUSY ){
+ /* Reset the return code so as not to report a checkpoint failure
+ ** just because there are active readers. */
+ rc = SQLITE_OK;
+ }
}
- /* If this is an SQLITE_CHECKPOINT_RESTART operation, and the entire wal
- ** file has been copied into the database file, then block until all
- ** readers have finished using the wal file. This ensures that the next
- ** process to write to the database restarts the wal file.
+ /* If this is an SQLITE_CHECKPOINT_RESTART or TRUNCATE operation, and the
+ ** entire wal file has been copied into the database file, then block
+ ** until all readers have finished using the wal file. This ensures that
+ ** the next process to write to the database restarts the wal file.
*/
if( rc==SQLITE_OK && eMode!=SQLITE_CHECKPOINT_PASSIVE ){
assert( pWal->writeLock );
if( pInfo->nBackfill<pWal->hdr.mxFrame ){
rc = SQLITE_BUSY;
- }else if( eMode==SQLITE_CHECKPOINT_RESTART ){
- assert( mxSafeFrame==pWal->hdr.mxFrame );
+ }else if( eMode>=SQLITE_CHECKPOINT_RESTART ){
+ u32 salt1;
+ sqlite3_randomness(4, &salt1);
+ assert( pInfo->nBackfill==pWal->hdr.mxFrame );
rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(1), WAL_NREADER-1);
if( rc==SQLITE_OK ){
+ if( eMode==SQLITE_CHECKPOINT_TRUNCATE ){
+ /* IMPLEMENTATION-OF: R-44699-57140 This mode works the same way as
+ ** SQLITE_CHECKPOINT_RESTART with the addition that it also
+ ** truncates the log file to zero bytes just prior to a
+ ** successful return.
+ **
+ ** In theory, it might be safe to do this without updating the
+ ** wal-index header in shared memory, as all subsequent reader or
+ ** writer clients should see that the entire log file has been
+ ** checkpointed and behave accordingly. This seems unsafe though,
+ ** as it would leave the system in a state where the contents of
+ ** the wal-index header do not match the contents of the
+ ** file-system. To avoid this, update the wal-index header to
+ ** indicate that the log file contains zero valid frames. */
+ walRestartHdr(pWal, salt1);
+ rc = sqlite3OsTruncate(pWal->pWalFd, 0);
+ }
walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);
}
}
@@ -50104,7 +50883,7 @@ static int walIndexReadHdr(Wal *pWal, int *pChanged){
walUnlockShared(pWal, WAL_WRITE_LOCK);
rc = SQLITE_READONLY_RECOVERY;
}
- }else if( SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1)) ){
+ }else if( SQLITE_OK==(rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1, 1)) ){
pWal->writeLock = 1;
if( SQLITE_OK==(rc = walIndexPage(pWal, 0, &page0)) ){
badHdr = walIndexTryHdr(pWal, pChanged);
@@ -50310,7 +51089,7 @@ static int walTryBeginRead(Wal *pWal, int *pChanged, int useWal, int cnt){
&& (mxReadMark<pWal->hdr.mxFrame || mxI==0)
){
for(i=1; i<WAL_NREADER; i++){
- rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1);
+ rc = walLockExclusive(pWal, WAL_READ_LOCK(i), 1, 0);
if( rc==SQLITE_OK ){
mxReadMark = pInfo->aReadMark[i] = pWal->hdr.mxFrame;
mxI = i;
@@ -50476,7 +51255,7 @@ SQLITE_PRIVATE int sqlite3WalFindFrame(
for(iKey=walHash(pgno); aHash[iKey]; iKey=walNextHash(iKey)){
u32 iFrame = aHash[iKey] + iZero;
if( iFrame<=iLast && aPgno[aHash[iKey]]==pgno ){
- /* assert( iFrame>iRead ); -- not true if there is corruption */
+ assert( iFrame>iRead || CORRUPT_DB );
iRead = iFrame;
}
if( (nCollide--)==0 ){
@@ -50566,7 +51345,7 @@ SQLITE_PRIVATE int sqlite3WalBeginWriteTransaction(Wal *pWal){
/* Only one writer allowed at a time. Get the write lock. Return
** SQLITE_BUSY if unable.
*/
- rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1);
+ rc = walLockExclusive(pWal, WAL_WRITE_LOCK, 1, 0);
if( rc ){
return rc;
}
@@ -50689,7 +51468,6 @@ SQLITE_PRIVATE int sqlite3WalSavepointUndo(Wal *pWal, u32 *aWalData){
return rc;
}
-
/*
** This function is called just before writing a set of frames to the log
** file (see sqlite3WalFrames()). It checks to see if, instead of appending
@@ -50712,7 +51490,7 @@ static int walRestartLog(Wal *pWal){
if( pInfo->nBackfill>0 ){
u32 salt1;
sqlite3_randomness(4, &salt1);
- rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);
+ rc = walLockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1, 0);
if( rc==SQLITE_OK ){
/* If all readers are using WAL_READ_LOCK(0) (in other words if no
** readers are currently using the WAL), then the transactions
@@ -50722,20 +51500,8 @@ static int walRestartLog(Wal *pWal){
** In theory it would be Ok to update the cache of the header only
** at this point. But updating the actual wal-index header is also
** safe and means there is no special case for sqlite3WalUndo()
- ** to handle if this transaction is rolled back.
- */
- int i; /* Loop counter */
- u32 *aSalt = pWal->hdr.aSalt; /* Big-endian salt values */
-
- pWal->nCkpt++;
- pWal->hdr.mxFrame = 0;
- sqlite3Put4byte((u8*)&aSalt[0], 1 + sqlite3Get4byte((u8*)&aSalt[0]));
- aSalt[1] = salt1;
- walIndexWriteHdr(pWal);
- pInfo->nBackfill = 0;
- pInfo->aReadMark[1] = 0;
- for(i=2; i<WAL_NREADER; i++) pInfo->aReadMark[i] = READMARK_NOT_USED;
- assert( pInfo->aReadMark[0]==0 );
+ ** to handle if this transaction is rolled back. */
+ walRestartHdr(pWal, salt1);
walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1);
}else if( rc!=SQLITE_BUSY ){
return rc;
@@ -51023,7 +51789,7 @@ SQLITE_PRIVATE int sqlite3WalFrames(
*/
SQLITE_PRIVATE int sqlite3WalCheckpoint(
Wal *pWal, /* Wal connection */
- int eMode, /* PASSIVE, FULL or RESTART */
+ int eMode, /* PASSIVE, FULL, RESTART, or TRUNCATE */
int (*xBusy)(void*), /* Function to call when busy */
void *pBusyArg, /* Context argument for xBusyHandler */
int sync_flags, /* Flags to sync db file with (or 0) */
@@ -51035,29 +51801,42 @@ SQLITE_PRIVATE int sqlite3WalCheckpoint(
int rc; /* Return code */
int isChanged = 0; /* True if a new wal-index header is loaded */
int eMode2 = eMode; /* Mode to pass to walCheckpoint() */
+ int (*xBusy2)(void*) = xBusy; /* Busy handler for eMode2 */
assert( pWal->ckptLock==0 );
assert( pWal->writeLock==0 );
+ /* EVIDENCE-OF: R-62920-47450 The busy-handler callback is never invoked
+ ** in the SQLITE_CHECKPOINT_PASSIVE mode. */
+ assert( eMode!=SQLITE_CHECKPOINT_PASSIVE || xBusy==0 );
+
if( pWal->readOnly ) return SQLITE_READONLY;
WALTRACE(("WAL%p: checkpoint begins\n", pWal));
- rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1);
+
+ /* IMPLEMENTATION-OF: R-62028-47212 All calls obtain an exclusive
+ ** "checkpoint" lock on the database file. */
+ rc = walLockExclusive(pWal, WAL_CKPT_LOCK, 1, 0);
if( rc ){
- /* Usually this is SQLITE_BUSY meaning that another thread or process
- ** is already running a checkpoint, or maybe a recovery. But it might
- ** also be SQLITE_IOERR. */
+ /* EVIDENCE-OF: R-10421-19736 If any other process is running a
+ ** checkpoint operation at the same time, the lock cannot be obtained and
+ ** SQLITE_BUSY is returned.
+ ** EVIDENCE-OF: R-53820-33897 Even if there is a busy-handler configured,
+ ** it will not be invoked in this case.
+ */
+ testcase( rc==SQLITE_BUSY );
+ testcase( xBusy!=0 );
return rc;
}
pWal->ckptLock = 1;
- /* If this is a blocking-checkpoint, then obtain the write-lock as well
- ** to prevent any writers from running while the checkpoint is underway.
- ** This has to be done before the call to walIndexReadHdr() below.
+ /* IMPLEMENTATION-OF: R-59782-36818 The SQLITE_CHECKPOINT_FULL, RESTART and
+ ** TRUNCATE modes also obtain the exclusive "writer" lock on the database
+ ** file.
**
- ** If the writer lock cannot be obtained, then a passive checkpoint is
- ** run instead. Since the checkpointer is not holding the writer lock,
- ** there is no point in blocking waiting for any readers. Assuming no
- ** other error occurs, this function will return SQLITE_BUSY to the caller.
+ ** EVIDENCE-OF: R-60642-04082 If the writer lock cannot be obtained
+ ** immediately, and a busy-handler is configured, it is invoked and the
+ ** writer lock retried until either the busy-handler returns 0 or the
+ ** lock is successfully obtained.
*/
if( eMode!=SQLITE_CHECKPOINT_PASSIVE ){
rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_WRITE_LOCK, 1);
@@ -51065,6 +51844,7 @@ SQLITE_PRIVATE int sqlite3WalCheckpoint(
pWal->writeLock = 1;
}else if( rc==SQLITE_BUSY ){
eMode2 = SQLITE_CHECKPOINT_PASSIVE;
+ xBusy2 = 0;
rc = SQLITE_OK;
}
}
@@ -51082,7 +51862,7 @@ SQLITE_PRIVATE int sqlite3WalCheckpoint(
if( pWal->hdr.mxFrame && walPagesize(pWal)!=nBuf ){
rc = SQLITE_CORRUPT_BKPT;
}else{
- rc = walCheckpoint(pWal, eMode2, xBusy, pBusyArg, sync_flags, zBuf);
+ rc = walCheckpoint(pWal, eMode2, xBusy2, pBusyArg, sync_flags, zBuf);
}
/* If no error occurred, set the output variables. */
@@ -51510,6 +52290,7 @@ struct MemPage {
u8 hdrOffset; /* 100 for page 1. 0 otherwise */
u8 childPtrSize; /* 0 if leaf==1. 4 if leaf==0 */
u8 max1bytePayload; /* min(maxLocal,127) */
+ u8 bBusy; /* Prevent endless loops on corrupt database files */
u16 maxLocal; /* Copy of BtShared.maxLocal or BtShared.maxLeaf */
u16 minLocal; /* Copy of BtShared.minLocal or BtShared.minLeaf */
u16 cellOffset; /* Index in aData of first cell pointer */
@@ -51581,6 +52362,7 @@ struct Btree {
u8 locked; /* True if db currently has pBt locked */
int wantToLock; /* Number of nested calls to sqlite3BtreeEnter() */
int nBackup; /* Number of backup operations reading this btree */
+ u32 iDataVersion; /* Combines with pBt->pPager->iDataVersion */
Btree *pNext; /* List of other sharable Btrees from the same db */
Btree *pPrev; /* Back pointer of the same list */
#ifndef SQLITE_OMIT_SHARED_CACHE
@@ -51647,6 +52429,9 @@ struct BtShared {
#endif
u8 inTransaction; /* Transaction state */
u8 max1bytePayload; /* Maximum first byte of cell for a 1-byte payload */
+#ifdef SQLITE_HAS_CODEC
+ u8 optimalReserve; /* Desired amount of reserved space per page */
+#endif
u16 btsFlags; /* Boolean parameters. See BTS_* macros below */
u16 maxLocal; /* Maximum local payload in non-LEAFDATA tables */
u16 minLocal; /* Minimum local payload in non-LEAFDATA tables */
@@ -52033,6 +52818,7 @@ static void SQLITE_NOINLINE btreeLockCarefully(Btree *p){
** Exit the recursive mutex on a Btree.
*/
SQLITE_PRIVATE void sqlite3BtreeLeave(Btree *p){
+ assert( sqlite3_mutex_held(p->db->mutex) );
if( p->sharable ){
assert( p->wantToLock>0 );
p->wantToLock--;
@@ -52280,7 +53066,7 @@ static BtShared *SQLITE_WSD sqlite3SharedCacheList = 0;
** The shared cache setting effects only future calls to
** sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2().
*/
-SQLITE_API int sqlite3_enable_shared_cache(int enable){
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int enable){
sqlite3GlobalConfig.sharedCacheEnabled = enable;
return SQLITE_OK;
}
@@ -52369,6 +53155,12 @@ static int hasSharedCacheTableLock(
for(p=sqliteHashFirst(&pSchema->idxHash); p; p=sqliteHashNext(p)){
Index *pIdx = (Index *)sqliteHashData(p);
if( pIdx->tnum==(int)iRoot ){
+ if( iTab ){
+ /* Two or more indexes share the same root page. There must
+ ** be imposter tables. So just return true. The assert is not
+ ** useful in that case. */
+ return 1;
+ }
iTab = pIdx->pTable->tnum;
}
}
@@ -52788,10 +53580,15 @@ static void btreeReleaseAllCursorPages(BtCursor *pCur){
static int saveCursorPosition(BtCursor *pCur){
int rc;
- assert( CURSOR_VALID==pCur->eState );
+ assert( CURSOR_VALID==pCur->eState || CURSOR_SKIPNEXT==pCur->eState );
assert( 0==pCur->pKey );
assert( cursorHoldsMutex(pCur) );
+ if( pCur->eState==CURSOR_SKIPNEXT ){
+ pCur->eState = CURSOR_VALID;
+ }else{
+ pCur->skipNext = 0;
+ }
rc = sqlite3BtreeKeySize(pCur, &pCur->nKey);
assert( rc==SQLITE_OK ); /* KeySize() cannot fail */
@@ -52862,7 +53659,7 @@ static int SQLITE_NOINLINE saveCursorsOnList(
){
do{
if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ){
- if( p->eState==CURSOR_VALID ){
+ if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){
int rc = saveCursorPosition(p);
if( SQLITE_OK!=rc ){
return rc;
@@ -52934,17 +53731,19 @@ static int btreeMoveto(
*/
static int btreeRestoreCursorPosition(BtCursor *pCur){
int rc;
+ int skipNext;
assert( cursorHoldsMutex(pCur) );
assert( pCur->eState>=CURSOR_REQUIRESEEK );
if( pCur->eState==CURSOR_FAULT ){
return pCur->skipNext;
}
pCur->eState = CURSOR_INVALID;
- rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &pCur->skipNext);
+ rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &skipNext);
if( rc==SQLITE_OK ){
sqlite3_free(pCur->pKey);
pCur->pKey = 0;
assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );
+ pCur->skipNext |= skipNext;
if( pCur->skipNext && pCur->eState==CURSOR_VALID ){
pCur->eState = CURSOR_SKIPNEXT;
}
@@ -52996,9 +53795,10 @@ SQLITE_PRIVATE int sqlite3BtreeCursorRestore(BtCursor *pCur, int *pDifferentRow)
*pDifferentRow = 1;
return rc;
}
- if( pCur->eState!=CURSOR_VALID || NEVER(pCur->skipNext!=0) ){
+ if( pCur->eState!=CURSOR_VALID ){
*pDifferentRow = 1;
}else{
+ assert( pCur->skipNext==0 );
*pDifferentRow = 0;
}
return SQLITE_OK;
@@ -53333,6 +54133,11 @@ static void ptrmapPutOvflPtr(MemPage *pPage, u8 *pCell, int *pRC){
** end of the page and all free space is collected into one
** big FreeBlk that occurs in between the header and cell
** pointer array and the cell content area.
+**
+** EVIDENCE-OF: R-44582-60138 SQLite may from time to time reorganize a
+** b-tree page so that there are no freeblocks or fragment bytes, all
+** unused bytes are contained in the unallocated space region, and all
+** cells are packed tightly at the end of the page.
*/
static int defragmentPage(MemPage *pPage){
int i; /* Loop counter */
@@ -53345,6 +54150,7 @@ static int defragmentPage(MemPage *pPage){
int nCell; /* Number of cells on the page */
unsigned char *data; /* The page data */
unsigned char *temp; /* Temp area for cell content */
+ unsigned char *src; /* Source of content */
int iCellFirst; /* First allowable cell index */
int iCellLast; /* Last possible cell index */
@@ -53354,15 +54160,13 @@ static int defragmentPage(MemPage *pPage){
assert( pPage->pBt->usableSize <= SQLITE_MAX_PAGE_SIZE );
assert( pPage->nOverflow==0 );
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
- temp = sqlite3PagerTempSpace(pPage->pBt->pPager);
- data = pPage->aData;
+ temp = 0;
+ src = data = pPage->aData;
hdr = pPage->hdrOffset;
cellOffset = pPage->cellOffset;
nCell = pPage->nCell;
assert( nCell==get2byte(&data[hdr+3]) );
usableSize = pPage->pBt->usableSize;
- cbrk = get2byte(&data[hdr+5]);
- memcpy(&temp[cbrk], &data[cbrk], usableSize - cbrk);
cbrk = usableSize;
iCellFirst = cellOffset + 2*nCell;
iCellLast = usableSize - 4;
@@ -53381,7 +54185,7 @@ static int defragmentPage(MemPage *pPage){
}
#endif
assert( pc>=iCellFirst && pc<=iCellLast );
- size = cellSizePtr(pPage, &temp[pc]);
+ size = cellSizePtr(pPage, &src[pc]);
cbrk -= size;
#if defined(SQLITE_ENABLE_OVERSIZE_CELL_CHECK)
if( cbrk<iCellFirst ){
@@ -53395,8 +54199,16 @@ static int defragmentPage(MemPage *pPage){
assert( cbrk+size<=usableSize && cbrk>=iCellFirst );
testcase( cbrk+size==usableSize );
testcase( pc+size==usableSize );
- memcpy(&data[cbrk], &temp[pc], size);
put2byte(pAddr, cbrk);
+ if( temp==0 ){
+ int x;
+ if( cbrk==pc ) continue;
+ temp = sqlite3PagerTempSpace(pPage->pBt->pPager);
+ x = get2byte(&data[hdr+5]);
+ memcpy(&temp[x], &data[x], (cbrk+size) - x);
+ src = temp;
+ }
+ memcpy(&data[cbrk], &src[pc], size);
}
assert( cbrk>=iCellFirst );
put2byte(&data[hdr+5], cbrk);
@@ -53412,6 +54224,69 @@ static int defragmentPage(MemPage *pPage){
}
/*
+** Search the free-list on page pPg for space to store a cell nByte bytes in
+** size. If one can be found, return a pointer to the space and remove it
+** from the free-list.
+**
+** If no suitable space can be found on the free-list, return NULL.
+**
+** This function may detect corruption within pPg. If corruption is
+** detected then *pRc is set to SQLITE_CORRUPT and NULL is returned.
+**
+** If a slot of at least nByte bytes is found but cannot be used because
+** there are already at least 60 fragmented bytes on the page, return NULL.
+** In this case, if pbDefrag parameter is not NULL, set *pbDefrag to true.
+*/
+static u8 *pageFindSlot(MemPage *pPg, int nByte, int *pRc, int *pbDefrag){
+ const int hdr = pPg->hdrOffset;
+ u8 * const aData = pPg->aData;
+ int iAddr;
+ int pc;
+ int usableSize = pPg->pBt->usableSize;
+
+ for(iAddr=hdr+1; (pc = get2byte(&aData[iAddr]))>0; iAddr=pc){
+ int size; /* Size of the free slot */
+ /* EVIDENCE-OF: R-06866-39125 Freeblocks are always connected in order of
+ ** increasing offset. */
+ if( pc>usableSize-4 || pc<iAddr+4 ){
+ *pRc = SQLITE_CORRUPT_BKPT;
+ return 0;
+ }
+ /* EVIDENCE-OF: R-22710-53328 The third and fourth bytes of each
+ ** freeblock form a big-endian integer which is the size of the freeblock
+ ** in bytes, including the 4-byte header. */
+ size = get2byte(&aData[pc+2]);
+ if( size>=nByte ){
+ int x = size - nByte;
+ testcase( x==4 );
+ testcase( x==3 );
+ if( x<4 ){
+ /* EVIDENCE-OF: R-11498-58022 In a well-formed b-tree page, the total
+ ** number of bytes in fragments may not exceed 60. */
+ if( aData[hdr+7]>=60 ){
+ if( pbDefrag ) *pbDefrag = 1;
+ return 0;
+ }
+ /* Remove the slot from the free-list. Update the number of
+ ** fragmented bytes within the page. */
+ memcpy(&aData[iAddr], &aData[pc], 2);
+ aData[hdr+7] += (u8)x;
+ }else if( size+pc > usableSize ){
+ *pRc = SQLITE_CORRUPT_BKPT;
+ return 0;
+ }else{
+ /* The slot remains on the free-list. Reduce its size to account
+ ** for the portion used by the new allocation. */
+ put2byte(&aData[pc+2], x);
+ }
+ return &aData[pc + x];
+ }
+ }
+
+ return 0;
+}
+
+/*
** Allocate nByte bytes of space from within the B-Tree page passed
** as the first argument. Write into *pIdx the index into pPage->aData[]
** of the first byte of allocated space. Return either SQLITE_OK or
@@ -53428,9 +54303,8 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
const int hdr = pPage->hdrOffset; /* Local cache of pPage->hdrOffset */
u8 * const data = pPage->aData; /* Local cache of pPage->aData */
int top; /* First byte of cell content area */
+ int rc = SQLITE_OK; /* Integer return code */
int gap; /* First byte of gap between cell pointers and cell content */
- int rc; /* Integer return code */
- int usableSize; /* Usable size of the page */
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
assert( pPage->pBt );
@@ -53438,20 +54312,18 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
assert( nByte>=0 ); /* Minimum cell size is 4 */
assert( pPage->nFree>=nByte );
assert( pPage->nOverflow==0 );
- usableSize = pPage->pBt->usableSize;
- assert( nByte < usableSize-8 );
+ assert( nByte < (int)(pPage->pBt->usableSize-8) );
assert( pPage->cellOffset == hdr + 12 - 4*pPage->leaf );
gap = pPage->cellOffset + 2*pPage->nCell;
assert( gap<=65536 );
- top = get2byte(&data[hdr+5]);
- if( gap>top ){
- if( top==0 ){
- top = 65536;
- }else{
- return SQLITE_CORRUPT_BKPT;
- }
- }
+ /* EVIDENCE-OF: R-29356-02391 If the database uses a 65536-byte page size
+ ** and the reserved space is zero (the usual value for reserved space)
+ ** then the cell content offset of an empty page wants to be 65536.
+ ** However, that integer is too large to be stored in a 2-byte unsigned
+ ** integer, so a value of 0 is used in its place. */
+ top = get2byteNotZero(&data[hdr+5]);
+ if( gap>top ) return SQLITE_CORRUPT_BKPT;
/* If there is enough space between gap and top for one more cell pointer
** array entry offset, and if the freelist is not empty, then search the
@@ -53461,33 +54333,14 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
testcase( gap+1==top );
testcase( gap==top );
if( gap+2<=top && (data[hdr+1] || data[hdr+2]) ){
- int pc, addr;
- for(addr=hdr+1; (pc = get2byte(&data[addr]))>0; addr=pc){
- int size; /* Size of the free slot */
- if( pc>usableSize-4 || pc<addr+4 ){
- return SQLITE_CORRUPT_BKPT;
- }
- size = get2byte(&data[pc+2]);
- if( size>=nByte ){
- int x = size - nByte;
- testcase( x==4 );
- testcase( x==3 );
- if( x<4 ){
- if( data[hdr+7]>=60 ) goto defragment_page;
- /* Remove the slot from the free-list. Update the number of
- ** fragmented bytes within the page. */
- memcpy(&data[addr], &data[pc], 2);
- data[hdr+7] += (u8)x;
- }else if( size+pc > usableSize ){
- return SQLITE_CORRUPT_BKPT;
- }else{
- /* The slot remains on the free-list. Reduce its size to account
- ** for the portion used by the new allocation. */
- put2byte(&data[pc+2], x);
- }
- *pIdx = pc + x;
- return SQLITE_OK;
- }
+ int bDefrag = 0;
+ u8 *pSpace = pageFindSlot(pPage, nByte, &rc, &bDefrag);
+ if( rc ) return rc;
+ if( bDefrag ) goto defragment_page;
+ if( pSpace ){
+ assert( pSpace>=data && (pSpace - data)<65536 );
+ *pIdx = (int)(pSpace - data);
+ return SQLITE_OK;
}
}
@@ -53496,8 +54349,8 @@ static int allocateSpace(MemPage *pPage, int nByte, int *pIdx){
*/
testcase( gap+2+nByte==top );
if( gap+2+nByte>top ){
-defragment_page:
- testcase( pPage->nCell==0 );
+ defragment_page:
+ assert( pPage->nCell>0 || CORRUPT_DB );
rc = defragmentPage(pPage);
if( rc ) return rc;
top = get2byteNotZero(&data[hdr+5]);
@@ -53544,7 +54397,7 @@ static int freeSpace(MemPage *pPage, u16 iStart, u16 iSize){
assert( pPage->pBt!=0 );
assert( sqlite3PagerIswriteable(pPage->pDbPage) );
assert( iStart>=pPage->hdrOffset+6+pPage->childPtrSize );
- assert( iEnd <= pPage->pBt->usableSize );
+ assert( CORRUPT_DB || iEnd <= pPage->pBt->usableSize );
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
assert( iSize>=4 ); /* Minimum cell size is 4 */
assert( iStart<=iLast );
@@ -53639,18 +54492,32 @@ static int decodeFlags(MemPage *pPage, int flagByte){
pPage->childPtrSize = 4-4*pPage->leaf;
pBt = pPage->pBt;
if( flagByte==(PTF_LEAFDATA | PTF_INTKEY) ){
+ /* EVIDENCE-OF: R-03640-13415 A value of 5 means the page is an interior
+ ** table b-tree page. */
+ assert( (PTF_LEAFDATA|PTF_INTKEY)==5 );
+ /* EVIDENCE-OF: R-20501-61796 A value of 13 means the page is a leaf
+ ** table b-tree page. */
+ assert( (PTF_LEAFDATA|PTF_INTKEY|PTF_LEAF)==13 );
pPage->intKey = 1;
pPage->intKeyLeaf = pPage->leaf;
pPage->noPayload = !pPage->leaf;
pPage->maxLocal = pBt->maxLeaf;
pPage->minLocal = pBt->minLeaf;
}else if( flagByte==PTF_ZERODATA ){
+ /* EVIDENCE-OF: R-27225-53936 A value of 2 means the page is an interior
+ ** index b-tree page. */
+ assert( (PTF_ZERODATA)==2 );
+ /* EVIDENCE-OF: R-16571-11615 A value of 10 means the page is a leaf
+ ** index b-tree page. */
+ assert( (PTF_ZERODATA|PTF_LEAF)==10 );
pPage->intKey = 0;
pPage->intKeyLeaf = 0;
pPage->noPayload = 0;
pPage->maxLocal = pBt->maxLocal;
pPage->minLocal = pBt->minLocal;
}else{
+ /* EVIDENCE-OF: R-47608-56469 Any other value for the b-tree page type is
+ ** an error. */
return SQLITE_CORRUPT_BKPT;
}
pPage->max1bytePayload = pBt->max1bytePayload;
@@ -53690,21 +54557,33 @@ static int btreeInitPage(MemPage *pPage){
hdr = pPage->hdrOffset;
data = pPage->aData;
+ /* EVIDENCE-OF: R-28594-02890 The one-byte flag at offset 0 indicating
+ ** the b-tree page type. */
if( decodeFlags(pPage, data[hdr]) ) return SQLITE_CORRUPT_BKPT;
assert( pBt->pageSize>=512 && pBt->pageSize<=65536 );
pPage->maskPage = (u16)(pBt->pageSize - 1);
pPage->nOverflow = 0;
usableSize = pBt->usableSize;
- pPage->cellOffset = cellOffset = hdr + 12 - 4*pPage->leaf;
+ pPage->cellOffset = cellOffset = hdr + 8 + pPage->childPtrSize;
pPage->aDataEnd = &data[usableSize];
pPage->aCellIdx = &data[cellOffset];
+ /* EVIDENCE-OF: R-58015-48175 The two-byte integer at offset 5 designates
+ ** the start of the cell content area. A zero value for this integer is
+ ** interpreted as 65536. */
top = get2byteNotZero(&data[hdr+5]);
+ /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
+ ** number of cells on the page. */
pPage->nCell = get2byte(&data[hdr+3]);
if( pPage->nCell>MX_CELL(pBt) ){
/* To many cells for a single page. The page must be corrupt */
return SQLITE_CORRUPT_BKPT;
}
testcase( pPage->nCell==MX_CELL(pBt) );
+ /* EVIDENCE-OF: R-24089-57979 If a page contains no cells (which is only
+ ** possible for a root page of a table that contains no rows) then the
+ ** offset to the cell content area will equal the page size minus the
+ ** bytes of reserved space. */
+ assert( pPage->nCell>0 || top==usableSize || CORRUPT_DB );
/* A malformed database page might cause us to read past the end
** of page when parsing a cell.
@@ -53738,13 +54617,20 @@ static int btreeInitPage(MemPage *pPage){
}
#endif
- /* Compute the total free space on the page */
+ /* Compute the total free space on the page
+ ** EVIDENCE-OF: R-23588-34450 The two-byte integer at offset 1 gives the
+ ** start of the first freeblock on the page, or is zero if there are no
+ ** freeblocks. */
pc = get2byte(&data[hdr+1]);
- nFree = data[hdr+7] + top;
+ nFree = data[hdr+7] + top; /* Init nFree to non-freeblock free space */
while( pc>0 ){
u16 next, size;
if( pc<iCellFirst || pc>iCellLast ){
- /* Start of free block is off the page */
+ /* EVIDENCE-OF: R-55530-52930 In a well-formed b-tree page, there will
+ ** always be at least one cell before the first freeblock.
+ **
+ ** Or, the freeblock is off the end of the page
+ */
return SQLITE_CORRUPT_BKPT;
}
next = get2byte(&data[pc]);
@@ -54053,16 +54939,18 @@ SQLITE_PRIVATE int sqlite3BtreeOpen(
*/
if( isTempDb==0 && (isMemdb==0 || (vfsFlags&SQLITE_OPEN_URI)!=0) ){
if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){
+ int nFilename = sqlite3Strlen30(zFilename)+1;
int nFullPathname = pVfs->mxPathname+1;
- char *zFullPathname = sqlite3Malloc(nFullPathname);
+ char *zFullPathname = sqlite3Malloc(MAX(nFullPathname,nFilename));
MUTEX_LOGIC( sqlite3_mutex *mutexShared; )
+
p->sharable = 1;
if( !zFullPathname ){
sqlite3_free(p);
return SQLITE_NOMEM;
}
if( isMemdb ){
- memcpy(zFullPathname, zFilename, sqlite3Strlen30(zFilename)+1);
+ memcpy(zFullPathname, zFilename, nFilename);
}else{
rc = sqlite3OsFullPathname(pVfs, zFilename,
nFullPathname, zFullPathname);
@@ -54119,8 +55007,8 @@ SQLITE_PRIVATE int sqlite3BtreeOpen(
** the right size. This is to guard against size changes that result
** when compiling on a different architecture.
*/
- assert( sizeof(i64)==8 || sizeof(i64)==4 );
- assert( sizeof(u64)==8 || sizeof(u64)==4 );
+ assert( sizeof(i64)==8 );
+ assert( sizeof(u64)==8 );
assert( sizeof(u32)==4 );
assert( sizeof(u16)==2 );
assert( sizeof(Pgno)==4 );
@@ -54150,6 +55038,9 @@ SQLITE_PRIVATE int sqlite3BtreeOpen(
#ifdef SQLITE_SECURE_DELETE
pBt->btsFlags |= BTS_SECURE_DELETE;
#endif
+ /* EVIDENCE-OF: R-51873-39618 The page size for a database file is
+ ** determined by the 2-byte integer located at an offset of 16 bytes from
+ ** the beginning of the database file. */
pBt->pageSize = (zDbHeader[16]<<8) | (zDbHeader[17]<<16);
if( pBt->pageSize<512 || pBt->pageSize>SQLITE_MAX_PAGE_SIZE
|| ((pBt->pageSize-1)&pBt->pageSize)!=0 ){
@@ -54168,6 +55059,9 @@ SQLITE_PRIVATE int sqlite3BtreeOpen(
#endif
nReserve = 0;
}else{
+ /* EVIDENCE-OF: R-37497-42412 The size of the reserved region is
+ ** determined by the one-byte unsigned integer found at an offset of 20
+ ** into the database file header. */
nReserve = zDbHeader[20];
pBt->btsFlags |= BTS_PAGESIZE_FIXED;
#ifndef SQLITE_OMIT_AUTOVACUUM
@@ -54501,6 +55395,9 @@ SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int pageSize, int nReserve,
BtShared *pBt = p->pBt;
assert( nReserve>=-1 && nReserve<=255 );
sqlite3BtreeEnter(p);
+#if SQLITE_HAS_CODEC
+ if( nReserve>pBt->optimalReserve ) pBt->optimalReserve = (u8)nReserve;
+#endif
if( pBt->btsFlags & BTS_PAGESIZE_FIXED ){
sqlite3BtreeLeave(p);
return SQLITE_READONLY;
@@ -54530,7 +55427,6 @@ SQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree *p){
return p->pBt->pageSize;
}
-#if defined(SQLITE_HAS_CODEC) || defined(SQLITE_DEBUG)
/*
** This function is similar to sqlite3BtreeGetReserve(), except that it
** may only be called if it is guaranteed that the b-tree mutex is already
@@ -54543,25 +55439,33 @@ SQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree *p){
** database handle that owns *p, causing undefined behavior.
*/
SQLITE_PRIVATE int sqlite3BtreeGetReserveNoMutex(Btree *p){
+ int n;
assert( sqlite3_mutex_held(p->pBt->mutex) );
- return p->pBt->pageSize - p->pBt->usableSize;
+ n = p->pBt->pageSize - p->pBt->usableSize;
+ return n;
}
-#endif /* SQLITE_HAS_CODEC || SQLITE_DEBUG */
-#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) || !defined(SQLITE_OMIT_VACUUM)
/*
** Return the number of bytes of space at the end of every page that
** are intentually left unused. This is the "reserved" space that is
** sometimes used by extensions.
+**
+** If SQLITE_HAS_MUTEX is defined then the number returned is the
+** greater of the current reserved space and the maximum requested
+** reserve space.
*/
-SQLITE_PRIVATE int sqlite3BtreeGetReserve(Btree *p){
+SQLITE_PRIVATE int sqlite3BtreeGetOptimalReserve(Btree *p){
int n;
sqlite3BtreeEnter(p);
- n = p->pBt->pageSize - p->pBt->usableSize;
+ n = sqlite3BtreeGetReserveNoMutex(p);
+#ifdef SQLITE_HAS_CODEC
+ if( n<p->pBt->optimalReserve ) n = p->pBt->optimalReserve;
+#endif
sqlite3BtreeLeave(p);
return n;
}
+
/*
** Set the maximum page count for a database if mxPage is positive.
** No changes are made if mxPage is 0 or negative.
@@ -54592,7 +55496,6 @@ SQLITE_PRIVATE int sqlite3BtreeSecureDelete(Btree *p, int newFlag){
sqlite3BtreeLeave(p);
return b;
}
-#endif /* !defined(SQLITE_OMIT_PAGER_PRAGMAS) || !defined(SQLITE_OMIT_VACUUM) */
/*
** Change the 'auto-vacuum' property of the database. If the 'autoVacuum'
@@ -54677,6 +55580,9 @@ static int lockBtree(BtShared *pBt){
u32 usableSize;
u8 *page1 = pPage1->aData;
rc = SQLITE_NOTADB;
+ /* EVIDENCE-OF: R-43737-39999 Every valid SQLite database file begins
+ ** with the following 16 bytes (in hex): 53 51 4c 69 74 65 20 66 6f 72 6d
+ ** 61 74 20 33 00. */
if( memcmp(page1, zMagicHeader, 16)!=0 ){
goto page1_init_failed;
}
@@ -54717,15 +55623,21 @@ static int lockBtree(BtShared *pBt){
}
#endif
- /* The maximum embedded fraction must be exactly 25%. And the minimum
- ** embedded fraction must be 12.5% for both leaf-data and non-leaf-data.
+ /* EVIDENCE-OF: R-15465-20813 The maximum and minimum embedded payload
+ ** fractions and the leaf payload fraction values must be 64, 32, and 32.
+ **
** The original design allowed these amounts to vary, but as of
** version 3.6.0, we require them to be fixed.
*/
if( memcmp(&page1[21], "\100\040\040",3)!=0 ){
goto page1_init_failed;
}
+ /* EVIDENCE-OF: R-51873-39618 The page size for a database file is
+ ** determined by the 2-byte integer located at an offset of 16 bytes from
+ ** the beginning of the database file. */
pageSize = (page1[16]<<8) | (page1[17]<<16);
+ /* EVIDENCE-OF: R-25008-21688 The size of a page is a power of two
+ ** between 512 and 65536 inclusive. */
if( ((pageSize-1)&pageSize)!=0
|| pageSize>SQLITE_MAX_PAGE_SIZE
|| pageSize<=256
@@ -54733,6 +55645,13 @@ static int lockBtree(BtShared *pBt){
goto page1_init_failed;
}
assert( (pageSize & 7)==0 );
+ /* EVIDENCE-OF: R-59310-51205 The "reserved space" size in the 1-byte
+ ** integer at offset 20 is the number of bytes of space at the end of
+ ** each page to reserve for extensions.
+ **
+ ** EVIDENCE-OF: R-37497-42412 The size of the reserved region is
+ ** determined by the one-byte unsigned integer found at an offset of 20
+ ** into the database file header. */
usableSize = pageSize - page1[20];
if( (u32)pageSize!=pBt->pageSize ){
/* After reading the first page of the database assuming a page size
@@ -54753,6 +55672,9 @@ static int lockBtree(BtShared *pBt){
rc = SQLITE_CORRUPT_BKPT;
goto page1_init_failed;
}
+ /* EVIDENCE-OF: R-28312-64704 However, the usable size is not allowed to
+ ** be less than 480. In other words, if the page size is 512, then the
+ ** reserved space size cannot exceed 32. */
if( usableSize<480 ){
goto page1_init_failed;
}
@@ -55633,6 +56555,7 @@ SQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree *p, int bCleanup){
sqlite3BtreeLeave(p);
return rc;
}
+ p->iDataVersion--; /* Compensate for pPager->iDataVersion++; */
pBt->inTransaction = TRANS_READ;
btreeClearHasContent(pBt);
}
@@ -55692,7 +56615,7 @@ SQLITE_PRIVATE int sqlite3BtreeTripAllCursors(Btree *pBtree, int errCode, int wr
for(p=pBtree->pBt->pCursor; p; p=p->pNext){
int i;
if( writeOnly && (p->curFlags & BTCF_WriteFlag)==0 ){
- if( p->eState==CURSOR_VALID ){
+ if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){
rc = saveCursorPosition(p);
if( rc!=SQLITE_OK ){
(void)sqlite3BtreeTripAllCursors(pBtree, rc, 0);
@@ -55996,7 +56919,7 @@ SQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor *pCur){
releasePage(pCur->apPage[i]);
}
unlockBtreeIfUnused(pBt);
- sqlite3DbFree(pBtree->db, pCur->aOverflow);
+ sqlite3_free(pCur->aOverflow);
/* sqlite3_free(pCur); */
sqlite3BtreeLeave(pBtree);
}
@@ -56098,6 +57021,8 @@ SQLITE_PRIVATE int sqlite3BtreeKeySize(BtCursor *pCur, i64 *pSize){
SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
assert( cursorHoldsMutex(pCur) );
assert( pCur->eState==CURSOR_VALID );
+ assert( pCur->iPage>=0 );
+ assert( pCur->iPage<BTCURSOR_MAX_DEPTH );
assert( pCur->apPage[pCur->iPage]->intKeyLeaf==1 );
getCellInfo(pCur);
*pSize = pCur->info.nPayload;
@@ -56291,6 +57216,7 @@ static int accessPayload(
offset -= pCur->info.nLocal;
}
+
if( rc==SQLITE_OK && amt>0 ){
const u32 ovflSize = pBt->usableSize - 4; /* Bytes content per ovfl page */
Pgno nextPage;
@@ -56308,8 +57234,8 @@ static int accessPayload(
if( eOp!=2 && (pCur->curFlags & BTCF_ValidOvfl)==0 ){
int nOvfl = (pCur->info.nPayload-pCur->info.nLocal+ovflSize-1)/ovflSize;
if( nOvfl>pCur->nOvflAlloc ){
- Pgno *aNew = (Pgno*)sqlite3DbRealloc(
- pCur->pBtree->db, pCur->aOverflow, nOvfl*2*sizeof(Pgno)
+ Pgno *aNew = (Pgno*)sqlite3Realloc(
+ pCur->aOverflow, nOvfl*2*sizeof(Pgno)
);
if( aNew==0 ){
rc = SQLITE_NOMEM;
@@ -56356,6 +57282,7 @@ static int accessPayload(
*/
assert( eOp!=2 );
assert( pCur->curFlags & BTCF_ValidOvfl );
+ assert( pCur->pBtree->db==pBt->db );
if( pCur->aOverflow[iIdx+1] ){
nextPage = pCur->aOverflow[iIdx+1];
}else{
@@ -56574,7 +57501,7 @@ static int moveToChild(BtCursor *pCur, u32 newPgno){
return SQLITE_OK;
}
-#if 0
+#if SQLITE_DEBUG
/*
** Page pParent is an internal (non-leaf) tree page. This function
** asserts that page number iChild is the left-child if the iIdx'th
@@ -56583,6 +57510,8 @@ static int moveToChild(BtCursor *pCur, u32 newPgno){
** the page.
*/
static void assertParentIndex(MemPage *pParent, int iIdx, Pgno iChild){
+ if( CORRUPT_DB ) return; /* The conditions tested below might not be true
+ ** in a corrupt database */
assert( iIdx<=pParent->nCell );
if( iIdx==pParent->nCell ){
assert( get4byte(&pParent->aData[pParent->hdrOffset+8])==iChild );
@@ -56607,19 +57536,11 @@ static void moveToParent(BtCursor *pCur){
assert( pCur->eState==CURSOR_VALID );
assert( pCur->iPage>0 );
assert( pCur->apPage[pCur->iPage] );
-
- /* UPDATE: It is actually possible for the condition tested by the assert
- ** below to be untrue if the database file is corrupt. This can occur if
- ** one cursor has modified page pParent while a reference to it is held
- ** by a second cursor. Which can only happen if a single page is linked
- ** into more than one b-tree structure in a corrupt database. */
-#if 0
assertParentIndex(
pCur->apPage[pCur->iPage-1],
pCur->aiIdx[pCur->iPage-1],
pCur->apPage[pCur->iPage]->pgno
);
-#endif
testcase( pCur->aiIdx[pCur->iPage-1] > pCur->apPage[pCur->iPage-1]->nCell );
releasePage(pCur->apPage[pCur->iPage]);
@@ -57330,6 +58251,8 @@ static int allocateBtreePage(
assert( eMode==BTALLOC_ANY || (nearby>0 && IfNotOmitAV(pBt->autoVacuum)) );
pPage1 = pBt->pPage1;
mxPage = btreePagecount(pBt);
+ /* EVIDENCE-OF: R-05119-02637 The 4-byte big-endian integer at offset 36
+ ** stores stores the total number of pages on the freelist. */
n = get4byte(&pPage1->aData[36]);
testcase( n==mxPage-1 );
if( n>=mxPage ){
@@ -57376,8 +58299,14 @@ static int allocateBtreePage(
do {
pPrevTrunk = pTrunk;
if( pPrevTrunk ){
+ /* EVIDENCE-OF: R-01506-11053 The first integer on a freelist trunk page
+ ** is the page number of the next freelist trunk page in the list or
+ ** zero if this is the last freelist trunk page. */
iTrunk = get4byte(&pPrevTrunk->aData[0]);
}else{
+ /* EVIDENCE-OF: R-59841-13798 The 4-byte big-endian integer at offset 32
+ ** stores the page number of the first page of the freelist, or zero if
+ ** the freelist is empty. */
iTrunk = get4byte(&pPage1->aData[32]);
}
testcase( iTrunk==mxPage );
@@ -57392,8 +58321,9 @@ static int allocateBtreePage(
}
assert( pTrunk!=0 );
assert( pTrunk->aData!=0 );
-
- k = get4byte(&pTrunk->aData[4]); /* # of leaves on this trunk page */
+ /* EVIDENCE-OF: R-13523-04394 The second integer on a freelist trunk page
+ ** is the number of leaf page pointers to follow. */
+ k = get4byte(&pTrunk->aData[4]);
if( k==0 && !searchList ){
/* The trunk has no leaves and the list is not being searched.
** So extract the trunk page itself and use it as the newly
@@ -57711,6 +58641,11 @@ static int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){
** for now. At some point in the future (once everyone has upgraded
** to 3.6.0 or later) we should consider fixing the conditional above
** to read "usableSize/4-2" instead of "usableSize/4-8".
+ **
+ ** EVIDENCE-OF: R-19920-11576 However, newer versions of SQLite still
+ ** avoid using the last six entries in the freelist trunk page array in
+ ** order that database files created by newer versions of SQLite can be
+ ** read by older versions of SQLite.
*/
rc = sqlite3PagerWrite(pTrunk->pDbPage);
if( rc==SQLITE_OK ){
@@ -58062,9 +58997,17 @@ static void dropCell(MemPage *pPage, int idx, int sz, int *pRC){
return;
}
pPage->nCell--;
- memmove(ptr, ptr+2, 2*(pPage->nCell - idx));
- put2byte(&data[hdr+3], pPage->nCell);
- pPage->nFree += 2;
+ if( pPage->nCell==0 ){
+ memset(&data[hdr+1], 0, 4);
+ data[hdr+7] = 0;
+ put2byte(&data[hdr+5], pPage->pBt->usableSize);
+ pPage->nFree = pPage->pBt->usableSize - pPage->hdrOffset
+ - pPage->childPtrSize - 8;
+ }else{
+ memmove(ptr, ptr+2, 2*(pPage->nCell - idx));
+ put2byte(&data[hdr+3], pPage->nCell);
+ pPage->nFree += 2;
+ }
}
/*
@@ -58159,45 +59102,271 @@ static void insertCell(
}
/*
-** Add a list of cells to a page. The page should be initially empty.
-** The cells are guaranteed to fit on the page.
+** Array apCell[] contains pointers to nCell b-tree page cells. The
+** szCell[] array contains the size in bytes of each cell. This function
+** replaces the current contents of page pPg with the contents of the cell
+** array.
+**
+** Some of the cells in apCell[] may currently be stored in pPg. This
+** function works around problems caused by this by making a copy of any
+** such cells before overwriting the page data.
+**
+** The MemPage.nFree field is invalidated by this function. It is the
+** responsibility of the caller to set it correctly.
*/
-static void assemblePage(
- MemPage *pPage, /* The page to be assembled */
- int nCell, /* The number of cells to add to this page */
- u8 **apCell, /* Pointers to cell bodies */
- u16 *aSize /* Sizes of the cells */
+static void rebuildPage(
+ MemPage *pPg, /* Edit this page */
+ int nCell, /* Final number of cells on page */
+ u8 **apCell, /* Array of cells */
+ u16 *szCell /* Array of cell sizes */
){
- int i; /* Loop counter */
- u8 *pCellptr; /* Address of next cell pointer */
- int cellbody; /* Address of next cell body */
- u8 * const data = pPage->aData; /* Pointer to data for pPage */
- const int hdr = pPage->hdrOffset; /* Offset of header on pPage */
- const int nUsable = pPage->pBt->usableSize; /* Usable size of page */
+ const int hdr = pPg->hdrOffset; /* Offset of header on pPg */
+ u8 * const aData = pPg->aData; /* Pointer to data for pPg */
+ const int usableSize = pPg->pBt->usableSize;
+ u8 * const pEnd = &aData[usableSize];
+ int i;
+ u8 *pCellptr = pPg->aCellIdx;
+ u8 *pTmp = sqlite3PagerTempSpace(pPg->pBt->pPager);
+ u8 *pData;
- assert( pPage->nOverflow==0 );
- assert( sqlite3_mutex_held(pPage->pBt->mutex) );
- assert( nCell>=0 && nCell<=(int)MX_CELL(pPage->pBt)
- && (int)MX_CELL(pPage->pBt)<=10921);
- assert( sqlite3PagerIswriteable(pPage->pDbPage) );
+ i = get2byte(&aData[hdr+5]);
+ memcpy(&pTmp[i], &aData[i], usableSize - i);
+
+ pData = pEnd;
+ for(i=0; i<nCell; i++){
+ u8 *pCell = apCell[i];
+ if( pCell>aData && pCell<pEnd ){
+ pCell = &pTmp[pCell - aData];
+ }
+ pData -= szCell[i];
+ memcpy(pData, pCell, szCell[i]);
+ put2byte(pCellptr, (pData - aData));
+ pCellptr += 2;
+ assert( szCell[i]==cellSizePtr(pPg, pCell) );
+ }
- /* Check that the page has just been zeroed by zeroPage() */
- assert( pPage->nCell==0 );
- assert( get2byteNotZero(&data[hdr+5])==nUsable );
+ /* The pPg->nFree field is now set incorrectly. The caller will fix it. */
+ pPg->nCell = nCell;
+ pPg->nOverflow = 0;
- pCellptr = &pPage->aCellIdx[nCell*2];
- cellbody = nUsable;
- for(i=nCell-1; i>=0; i--){
- u16 sz = aSize[i];
- pCellptr -= 2;
- cellbody -= sz;
- put2byte(pCellptr, cellbody);
- memcpy(&data[cellbody], apCell[i], sz);
+ put2byte(&aData[hdr+1], 0);
+ put2byte(&aData[hdr+3], pPg->nCell);
+ put2byte(&aData[hdr+5], pData - aData);
+ aData[hdr+7] = 0x00;
+}
+
+/*
+** Array apCell[] contains nCell pointers to b-tree cells. Array szCell
+** contains the size in bytes of each such cell. This function attempts to
+** add the cells stored in the array to page pPg. If it cannot (because
+** the page needs to be defragmented before the cells will fit), non-zero
+** is returned. Otherwise, if the cells are added successfully, zero is
+** returned.
+**
+** Argument pCellptr points to the first entry in the cell-pointer array
+** (part of page pPg) to populate. After cell apCell[0] is written to the
+** page body, a 16-bit offset is written to pCellptr. And so on, for each
+** cell in the array. It is the responsibility of the caller to ensure
+** that it is safe to overwrite this part of the cell-pointer array.
+**
+** When this function is called, *ppData points to the start of the
+** content area on page pPg. If the size of the content area is extended,
+** *ppData is updated to point to the new start of the content area
+** before returning.
+**
+** Finally, argument pBegin points to the byte immediately following the
+** end of the space required by this page for the cell-pointer area (for
+** all cells - not just those inserted by the current call). If the content
+** area must be extended to before this point in order to accomodate all
+** cells in apCell[], then the cells do not fit and non-zero is returned.
+*/
+static int pageInsertArray(
+ MemPage *pPg, /* Page to add cells to */
+ u8 *pBegin, /* End of cell-pointer array */
+ u8 **ppData, /* IN/OUT: Page content -area pointer */
+ u8 *pCellptr, /* Pointer to cell-pointer area */
+ int nCell, /* Number of cells to add to pPg */
+ u8 **apCell, /* Array of cells */
+ u16 *szCell /* Array of cell sizes */
+){
+ int i;
+ u8 *aData = pPg->aData;
+ u8 *pData = *ppData;
+ const int bFreelist = aData[1] || aData[2];
+ assert( CORRUPT_DB || pPg->hdrOffset==0 ); /* Never called on page 1 */
+ for(i=0; i<nCell; i++){
+ int sz = szCell[i];
+ int rc;
+ u8 *pSlot;
+ if( bFreelist==0 || (pSlot = pageFindSlot(pPg, sz, &rc, 0))==0 ){
+ pData -= sz;
+ if( pData<pBegin ) return 1;
+ pSlot = pData;
+ }
+ memcpy(pSlot, apCell[i], sz);
+ put2byte(pCellptr, (pSlot - aData));
+ pCellptr += 2;
}
- put2byte(&data[hdr+3], nCell);
- put2byte(&data[hdr+5], cellbody);
- pPage->nFree -= (nCell*2 + nUsable - cellbody);
- pPage->nCell = (u16)nCell;
+ *ppData = pData;
+ return 0;
+}
+
+/*
+** Array apCell[] contains nCell pointers to b-tree cells. Array szCell
+** contains the size in bytes of each such cell. This function adds the
+** space associated with each cell in the array that is currently stored
+** within the body of pPg to the pPg free-list. The cell-pointers and other
+** fields of the page are not updated.
+**
+** This function returns the total number of cells added to the free-list.
+*/
+static int pageFreeArray(
+ MemPage *pPg, /* Page to edit */
+ int nCell, /* Cells to delete */
+ u8 **apCell, /* Array of cells */
+ u16 *szCell /* Array of cell sizes */
+){
+ u8 * const aData = pPg->aData;
+ u8 * const pEnd = &aData[pPg->pBt->usableSize];
+ u8 * const pStart = &aData[pPg->hdrOffset + 8 + pPg->childPtrSize];
+ int nRet = 0;
+ int i;
+ u8 *pFree = 0;
+ int szFree = 0;
+
+ for(i=0; i<nCell; i++){
+ u8 *pCell = apCell[i];
+ if( pCell>=pStart && pCell<pEnd ){
+ int sz = szCell[i];
+ if( pFree!=(pCell + sz) ){
+ if( pFree ){
+ assert( pFree>aData && (pFree - aData)<65536 );
+ freeSpace(pPg, (u16)(pFree - aData), szFree);
+ }
+ pFree = pCell;
+ szFree = sz;
+ if( pFree+sz>pEnd ) return 0;
+ }else{
+ pFree = pCell;
+ szFree += sz;
+ }
+ nRet++;
+ }
+ }
+ if( pFree ){
+ assert( pFree>aData && (pFree - aData)<65536 );
+ freeSpace(pPg, (u16)(pFree - aData), szFree);
+ }
+ return nRet;
+}
+
+/*
+** apCell[] and szCell[] contains pointers to and sizes of all cells in the
+** pages being balanced. The current page, pPg, has pPg->nCell cells starting
+** with apCell[iOld]. After balancing, this page should hold nNew cells
+** starting at apCell[iNew].
+**
+** This routine makes the necessary adjustments to pPg so that it contains
+** the correct cells after being balanced.
+**
+** The pPg->nFree field is invalid when this function returns. It is the
+** responsibility of the caller to set it correctly.
+*/
+static void editPage(
+ MemPage *pPg, /* Edit this page */
+ int iOld, /* Index of first cell currently on page */
+ int iNew, /* Index of new first cell on page */
+ int nNew, /* Final number of cells on page */
+ u8 **apCell, /* Array of cells */
+ u16 *szCell /* Array of cell sizes */
+){
+ u8 * const aData = pPg->aData;
+ const int hdr = pPg->hdrOffset;
+ u8 *pBegin = &pPg->aCellIdx[nNew * 2];
+ int nCell = pPg->nCell; /* Cells stored on pPg */
+ u8 *pData;
+ u8 *pCellptr;
+ int i;
+ int iOldEnd = iOld + pPg->nCell + pPg->nOverflow;
+ int iNewEnd = iNew + nNew;
+
+#ifdef SQLITE_DEBUG
+ u8 *pTmp = sqlite3PagerTempSpace(pPg->pBt->pPager);
+ memcpy(pTmp, aData, pPg->pBt->usableSize);
+#endif
+
+ /* Remove cells from the start and end of the page */
+ if( iOld<iNew ){
+ int nShift = pageFreeArray(
+ pPg, iNew-iOld, &apCell[iOld], &szCell[iOld]
+ );
+ memmove(pPg->aCellIdx, &pPg->aCellIdx[nShift*2], nCell*2);
+ nCell -= nShift;
+ }
+ if( iNewEnd < iOldEnd ){
+ nCell -= pageFreeArray(
+ pPg, iOldEnd-iNewEnd, &apCell[iNewEnd], &szCell[iNewEnd]
+ );
+ }
+
+ pData = &aData[get2byteNotZero(&aData[hdr+5])];
+ if( pData<pBegin ) goto editpage_fail;
+
+ /* Add cells to the start of the page */
+ if( iNew<iOld ){
+ int nAdd = MIN(nNew,iOld-iNew);
+ assert( (iOld-iNew)<nNew || nCell==0 || CORRUPT_DB );
+ pCellptr = pPg->aCellIdx;
+ memmove(&pCellptr[nAdd*2], pCellptr, nCell*2);
+ if( pageInsertArray(
+ pPg, pBegin, &pData, pCellptr,
+ nAdd, &apCell[iNew], &szCell[iNew]
+ ) ) goto editpage_fail;
+ nCell += nAdd;
+ }
+
+ /* Add any overflow cells */
+ for(i=0; i<pPg->nOverflow; i++){
+ int iCell = (iOld + pPg->aiOvfl[i]) - iNew;
+ if( iCell>=0 && iCell<nNew ){
+ pCellptr = &pPg->aCellIdx[iCell * 2];
+ memmove(&pCellptr[2], pCellptr, (nCell - iCell) * 2);
+ nCell++;
+ if( pageInsertArray(
+ pPg, pBegin, &pData, pCellptr,
+ 1, &apCell[iCell + iNew], &szCell[iCell + iNew]
+ ) ) goto editpage_fail;
+ }
+ }
+
+ /* Append cells to the end of the page */
+ pCellptr = &pPg->aCellIdx[nCell*2];
+ if( pageInsertArray(
+ pPg, pBegin, &pData, pCellptr,
+ nNew-nCell, &apCell[iNew+nCell], &szCell[iNew+nCell]
+ ) ) goto editpage_fail;
+
+ pPg->nCell = nNew;
+ pPg->nOverflow = 0;
+
+ put2byte(&aData[hdr+3], pPg->nCell);
+ put2byte(&aData[hdr+5], pData - aData);
+
+#ifdef SQLITE_DEBUG
+ for(i=0; i<nNew && !CORRUPT_DB; i++){
+ u8 *pCell = apCell[i+iNew];
+ int iOff = get2byte(&pPg->aCellIdx[i*2]);
+ if( pCell>=aData && pCell<&aData[pPg->pBt->usableSize] ){
+ pCell = &pTmp[pCell - aData];
+ }
+ assert( 0==memcmp(pCell, &aData[iOff], szCell[i+iNew]) );
+ }
+#endif
+
+ return;
+ editpage_fail:
+ /* Unable to edit this page. Rebuild it from scratch instead. */
+ rebuildPage(pPg, nNew, &apCell[iNew], &szCell[iNew]);
}
/*
@@ -58251,7 +59420,7 @@ static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){
assert( pPage->nOverflow==1 );
/* This error condition is now caught prior to reaching this function */
- if( pPage->nCell==0 ) return SQLITE_CORRUPT_BKPT;
+ if( NEVER(pPage->nCell==0) ) return SQLITE_CORRUPT_BKPT;
/* Allocate a new page. This page will become the right-sibling of
** pPage. Make the parent page writable, so that the new divider cell
@@ -58269,7 +59438,8 @@ static int balance_quick(MemPage *pParent, MemPage *pPage, u8 *pSpace){
assert( sqlite3PagerIswriteable(pNew->pDbPage) );
assert( pPage->aData[0]==(PTF_INTKEY|PTF_LEAFDATA|PTF_LEAF) );
zeroPage(pNew, PTF_INTKEY|PTF_LEAFDATA|PTF_LEAF);
- assemblePage(pNew, 1, &pCell, &szCell);
+ rebuildPage(pNew, 1, &pCell, &szCell);
+ pNew->nFree = pBt->usableSize - pNew->cellOffset - 2 - szCell;
/* If this is an auto-vacuum database, update the pointer map
** with entries for the new page, and any pointer from the
@@ -58488,17 +59658,22 @@ static int balance_nonroot(
int iOvflSpace = 0; /* First unused byte of aOvflSpace[] */
int szScratch; /* Size of scratch memory requested */
MemPage *apOld[NB]; /* pPage and up to two siblings */
- MemPage *apCopy[NB]; /* Private copies of apOld[] pages */
MemPage *apNew[NB+2]; /* pPage and up to NB siblings after balancing */
u8 *pRight; /* Location in parent of right-sibling pointer */
u8 *apDiv[NB-1]; /* Divider cells in pParent */
int cntNew[NB+2]; /* Index in aCell[] of cell after i-th page */
- int szNew[NB+2]; /* Combined size of cells place on i-th page */
+ int cntOld[NB+2]; /* Old index in aCell[] after i-th page */
+ int szNew[NB+2]; /* Combined size of cells placed on i-th page */
u8 **apCell = 0; /* All cells begin balanced */
u16 *szCell; /* Local size of all cells in apCell[] */
u8 *aSpace1; /* Space for copies of dividers cells */
Pgno pgno; /* Temp var to store a page number in */
+ u8 abDone[NB+2]; /* True after i'th new page is populated */
+ Pgno aPgno[NB+2]; /* Page numbers of new pages before shuffling */
+ Pgno aPgOrder[NB+2]; /* Copy of aPgno[] used for sorting pages */
+ u16 aPgFlags[NB+2]; /* flags field of new pages before shuffling */
+ memset(abDone, 0, sizeof(abDone));
pBt = pParent->pBt;
assert( sqlite3_mutex_held(pBt->mutex) );
assert( sqlite3PagerIswriteable(pParent->pDbPage) );
@@ -58607,12 +59782,14 @@ static int balance_nonroot(
/*
** Allocate space for memory structures
*/
- k = pBt->pageSize + ROUND8(sizeof(MemPage));
szScratch =
nMaxCells*sizeof(u8*) /* apCell */
+ nMaxCells*sizeof(u16) /* szCell */
- + pBt->pageSize /* aSpace1 */
- + k*nOld; /* Page copies (apCopy) */
+ + pBt->pageSize; /* aSpace1 */
+
+ /* EVIDENCE-OF: R-28375-38319 SQLite will never request a scratch buffer
+ ** that is more than 6 times the database page size. */
+ assert( szScratch<=6*(int)pBt->pageSize );
apCell = sqlite3ScratchMalloc( szScratch );
if( apCell==0 ){
rc = SQLITE_NOMEM;
@@ -58625,8 +59802,8 @@ static int balance_nonroot(
/*
** Load pointers to all cells on sibling pages and the divider cells
** into the local apCell[] array. Make copies of the divider cells
- ** into space obtained from aSpace1[] and remove the divider cells
- ** from pParent.
+ ** into space obtained from aSpace1[]. The divider cells have already
+ ** been removed from pParent.
**
** If the siblings are on leaf pages, then the child pointers of the
** divider cells are stripped from the cells before they are copied
@@ -58642,15 +59819,7 @@ static int balance_nonroot(
leafData = apOld[0]->intKeyLeaf;
for(i=0; i<nOld; i++){
int limit;
-
- /* Before doing anything else, take a copy of the i'th original sibling
- ** The rest of this function will use data from the copies rather
- ** that the original pages since the original pages will be in the
- ** process of being overwritten. */
- MemPage *pOld = apCopy[i] = (MemPage*)&aSpace1[pBt->pageSize + k*i];
- memcpy(pOld, apOld[i], sizeof(MemPage));
- pOld->aData = (void*)&pOld[1];
- memcpy(pOld->aData, apOld[i]->aData, pBt->pageSize);
+ MemPage *pOld = apOld[i];
limit = pOld->nCell+pOld->nOverflow;
if( pOld->nOverflow>0 ){
@@ -58671,6 +59840,7 @@ static int balance_nonroot(
nCell++;
}
}
+ cntOld[i] = nCell;
if( i<nOld-1 && !leafData){
u16 sz = (u16)szNew[i];
u8 *pTemp;
@@ -58693,7 +59863,11 @@ static int balance_nonroot(
}else{
assert( leafCorrection==4 );
if( szCell[nCell]<4 ){
- /* Do not allow any cells smaller than 4 bytes. */
+ /* Do not allow any cells smaller than 4 bytes. If a smaller cell
+ ** does exist, pad it with 0x00 bytes. */
+ assert( szCell[nCell]==3 );
+ assert( apCell[nCell]==&aSpace1[iSpace1-3] );
+ aSpace1[iSpace1++] = 0x00;
szCell[nCell] = 4;
}
}
@@ -58722,7 +59896,7 @@ static int balance_nonroot(
assert( i<nMaxCells );
subtotal += szCell[i] + 2;
if( subtotal > usableSpace ){
- szNew[k] = subtotal - szCell[i];
+ szNew[k] = subtotal - szCell[i] - 2;
cntNew[k] = i;
if( leafData ){ i--; }
subtotal = 0;
@@ -58736,9 +59910,10 @@ static int balance_nonroot(
/*
** The packing computed by the previous block is biased toward the siblings
- ** on the left side. The left siblings are always nearly full, while the
- ** right-most sibling might be nearly empty. This block of code attempts
- ** to adjust the packing of siblings to get a better balance.
+ ** on the left side (siblings with smaller keys). The left siblings are
+ ** always nearly full, while the right-most sibling might be nearly empty.
+ ** The next block of code attempts to adjust the packing of siblings to
+ ** get a better balance.
**
** This adjustment is more than an optimization. The packing above might
** be so out of balance as to be illegal. For example, the right-most
@@ -58767,22 +59942,18 @@ static int balance_nonroot(
szNew[i-1] = szLeft;
}
- /* Either we found one or more cells (cntnew[0])>0) or pPage is
- ** a virtual root page. A virtual root page is when the real root
- ** page is page 1 and we are the only child of that page.
- **
- ** UPDATE: The assert() below is not necessarily true if the database
- ** file is corrupt. The corruption will be detected and reported later
- ** in this procedure so there is no need to act upon it now.
+ /* Sanity check: For a non-corrupt database file one of the follwing
+ ** must be true:
+ ** (1) We found one or more cells (cntNew[0])>0), or
+ ** (2) pPage is a virtual root page. A virtual root page is when
+ ** the real root page is page 1 and we are the only child of
+ ** that page.
*/
-#if 0
- assert( cntNew[0]>0 || (pParent->pgno==1 && pParent->nCell==0) );
-#endif
-
- TRACE(("BALANCE: old: %d %d %d ",
- apOld[0]->pgno,
- nOld>=2 ? apOld[1]->pgno : 0,
- nOld>=3 ? apOld[2]->pgno : 0
+ assert( cntNew[0]>0 || (pParent->pgno==1 && pParent->nCell==0) || CORRUPT_DB);
+ TRACE(("BALANCE: old: %d(nc=%d) %d(nc=%d) %d(nc=%d)\n",
+ apOld[0]->pgno, apOld[0]->nCell,
+ nOld>=2 ? apOld[1]->pgno : 0, nOld>=2 ? apOld[1]->nCell : 0,
+ nOld>=3 ? apOld[2]->pgno : 0, nOld>=3 ? apOld[2]->nCell : 0
));
/*
@@ -58805,8 +59976,10 @@ static int balance_nonroot(
assert( i>0 );
rc = allocateBtreePage(pBt, &pNew, &pgno, (bBulk ? 1 : pgno), 0);
if( rc ) goto balance_cleanup;
+ zeroPage(pNew, pageFlags);
apNew[i] = pNew;
nNew++;
+ cntOld[i] = nCell;
/* Set the pointer-map entry for the new sibling page. */
if( ISAUTOVACUUM ){
@@ -58818,135 +59991,247 @@ static int balance_nonroot(
}
}
- /* Free any old pages that were not reused as new pages.
- */
- while( i<nOld ){
- freePage(apOld[i], &rc);
- if( rc ) goto balance_cleanup;
- releasePage(apOld[i]);
- apOld[i] = 0;
- i++;
- }
-
/*
- ** Put the new pages in ascending order. This helps to
- ** keep entries in the disk file in order so that a scan
- ** of the table is a linear scan through the file. That
- ** in turn helps the operating system to deliver pages
- ** from the disk more rapidly.
+ ** Reassign page numbers so that the new pages are in ascending order.
+ ** This helps to keep entries in the disk file in order so that a scan
+ ** of the table is closer to a linear scan through the file. That in turn
+ ** helps the operating system to deliver pages from the disk more rapidly.
**
- ** An O(n^2) insertion sort algorithm is used, but since
- ** n is never more than NB (a small constant), that should
- ** not be a problem.
+ ** An O(n^2) insertion sort algorithm is used, but since n is never more
+ ** than (NB+2) (a small constant), that should not be a problem.
**
- ** When NB==3, this one optimization makes the database
- ** about 25% faster for large insertions and deletions.
+ ** When NB==3, this one optimization makes the database about 25% faster
+ ** for large insertions and deletions.
*/
- for(i=0; i<k-1; i++){
- int minV = apNew[i]->pgno;
- int minI = i;
- for(j=i+1; j<k; j++){
- if( apNew[j]->pgno<(unsigned)minV ){
- minI = j;
- minV = apNew[j]->pgno;
+ for(i=0; i<nNew; i++){
+ aPgOrder[i] = aPgno[i] = apNew[i]->pgno;
+ aPgFlags[i] = apNew[i]->pDbPage->flags;
+ for(j=0; j<i; j++){
+ if( aPgno[j]==aPgno[i] ){
+ /* This branch is taken if the set of sibling pages somehow contains
+ ** duplicate entries. This can happen if the database is corrupt.
+ ** It would be simpler to detect this as part of the loop below, but
+ ** we do the detection here in order to avoid populating the pager
+ ** cache with two separate objects associated with the same
+ ** page number. */
+ assert( CORRUPT_DB );
+ rc = SQLITE_CORRUPT_BKPT;
+ goto balance_cleanup;
}
}
- if( minI>i ){
- MemPage *pT;
- pT = apNew[i];
- apNew[i] = apNew[minI];
- apNew[minI] = pT;
+ }
+ for(i=0; i<nNew; i++){
+ int iBest = 0; /* aPgno[] index of page number to use */
+ for(j=1; j<nNew; j++){
+ if( aPgOrder[j]<aPgOrder[iBest] ) iBest = j;
+ }
+ pgno = aPgOrder[iBest];
+ aPgOrder[iBest] = 0xffffffff;
+ if( iBest!=i ){
+ if( iBest>i ){
+ sqlite3PagerRekey(apNew[iBest]->pDbPage, pBt->nPage+iBest+1, 0);
+ }
+ sqlite3PagerRekey(apNew[i]->pDbPage, pgno, aPgFlags[iBest]);
+ apNew[i]->pgno = pgno;
}
}
- TRACE(("new: %d(%d) %d(%d) %d(%d) %d(%d) %d(%d)\n",
- apNew[0]->pgno, szNew[0],
+
+ TRACE(("BALANCE: new: %d(%d nc=%d) %d(%d nc=%d) %d(%d nc=%d) "
+ "%d(%d nc=%d) %d(%d nc=%d)\n",
+ apNew[0]->pgno, szNew[0], cntNew[0],
nNew>=2 ? apNew[1]->pgno : 0, nNew>=2 ? szNew[1] : 0,
+ nNew>=2 ? cntNew[1] - cntNew[0] - !leafData : 0,
nNew>=3 ? apNew[2]->pgno : 0, nNew>=3 ? szNew[2] : 0,
+ nNew>=3 ? cntNew[2] - cntNew[1] - !leafData : 0,
nNew>=4 ? apNew[3]->pgno : 0, nNew>=4 ? szNew[3] : 0,
- nNew>=5 ? apNew[4]->pgno : 0, nNew>=5 ? szNew[4] : 0));
+ nNew>=4 ? cntNew[3] - cntNew[2] - !leafData : 0,
+ nNew>=5 ? apNew[4]->pgno : 0, nNew>=5 ? szNew[4] : 0,
+ nNew>=5 ? cntNew[4] - cntNew[3] - !leafData : 0
+ ));
assert( sqlite3PagerIswriteable(pParent->pDbPage) );
put4byte(pRight, apNew[nNew-1]->pgno);
- /*
- ** Evenly distribute the data in apCell[] across the new pages.
- ** Insert divider cells into pParent as necessary.
+ /* If the sibling pages are not leaves, ensure that the right-child pointer
+ ** of the right-most new sibling page is set to the value that was
+ ** originally in the same field of the right-most old sibling page. */
+ if( (pageFlags & PTF_LEAF)==0 && nOld!=nNew ){
+ MemPage *pOld = (nNew>nOld ? apNew : apOld)[nOld-1];
+ memcpy(&apNew[nNew-1]->aData[8], &pOld->aData[8], 4);
+ }
+
+ /* Make any required updates to pointer map entries associated with
+ ** cells stored on sibling pages following the balance operation. Pointer
+ ** map entries associated with divider cells are set by the insertCell()
+ ** routine. The associated pointer map entries are:
+ **
+ ** a) if the cell contains a reference to an overflow chain, the
+ ** entry associated with the first page in the overflow chain, and
+ **
+ ** b) if the sibling pages are not leaves, the child page associated
+ ** with the cell.
+ **
+ ** If the sibling pages are not leaves, then the pointer map entry
+ ** associated with the right-child of each sibling may also need to be
+ ** updated. This happens below, after the sibling pages have been
+ ** populated, not here.
*/
- j = 0;
- for(i=0; i<nNew; i++){
- /* Assemble the new sibling page. */
+ if( ISAUTOVACUUM ){
+ MemPage *pNew = apNew[0];
+ u8 *aOld = pNew->aData;
+ int cntOldNext = pNew->nCell + pNew->nOverflow;
+ int usableSize = pBt->usableSize;
+ int iNew = 0;
+ int iOld = 0;
+
+ for(i=0; i<nCell; i++){
+ u8 *pCell = apCell[i];
+ if( i==cntOldNext ){
+ MemPage *pOld = (++iOld)<nNew ? apNew[iOld] : apOld[iOld];
+ cntOldNext += pOld->nCell + pOld->nOverflow + !leafData;
+ aOld = pOld->aData;
+ }
+ if( i==cntNew[iNew] ){
+ pNew = apNew[++iNew];
+ if( !leafData ) continue;
+ }
+
+ /* Cell pCell is destined for new sibling page pNew. Originally, it
+ ** was either part of sibling page iOld (possibly an overflow cell),
+ ** or else the divider cell to the left of sibling page iOld. So,
+ ** if sibling page iOld had the same page number as pNew, and if
+ ** pCell really was a part of sibling page iOld (not a divider or
+ ** overflow cell), we can skip updating the pointer map entries. */
+ if( iOld>=nNew
+ || pNew->pgno!=aPgno[iOld]
+ || pCell<aOld
+ || pCell>=&aOld[usableSize]
+ ){
+ if( !leafCorrection ){
+ ptrmapPut(pBt, get4byte(pCell), PTRMAP_BTREE, pNew->pgno, &rc);
+ }
+ if( szCell[i]>pNew->minLocal ){
+ ptrmapPutOvflPtr(pNew, pCell, &rc);
+ }
+ }
+ }
+ }
+
+ /* Insert new divider cells into pParent. */
+ for(i=0; i<nNew-1; i++){
+ u8 *pCell;
+ u8 *pTemp;
+ int sz;
MemPage *pNew = apNew[i];
+ j = cntNew[i];
+
assert( j<nMaxCells );
- zeroPage(pNew, pageFlags);
- assemblePage(pNew, cntNew[i]-j, &apCell[j], &szCell[j]);
- assert( pNew->nCell>0 || (nNew==1 && cntNew[0]==0) );
- assert( pNew->nOverflow==0 );
+ pCell = apCell[j];
+ sz = szCell[j] + leafCorrection;
+ pTemp = &aOvflSpace[iOvflSpace];
+ if( !pNew->leaf ){
+ memcpy(&pNew->aData[8], pCell, 4);
+ }else if( leafData ){
+ /* If the tree is a leaf-data tree, and the siblings are leaves,
+ ** then there is no divider cell in apCell[]. Instead, the divider
+ ** cell consists of the integer key for the right-most cell of
+ ** the sibling-page assembled above only.
+ */
+ CellInfo info;
+ j--;
+ btreeParseCellPtr(pNew, apCell[j], &info);
+ pCell = pTemp;
+ sz = 4 + putVarint(&pCell[4], info.nKey);
+ pTemp = 0;
+ }else{
+ pCell -= 4;
+ /* Obscure case for non-leaf-data trees: If the cell at pCell was
+ ** previously stored on a leaf node, and its reported size was 4
+ ** bytes, then it may actually be smaller than this
+ ** (see btreeParseCellPtr(), 4 bytes is the minimum size of
+ ** any cell). But it is important to pass the correct size to
+ ** insertCell(), so reparse the cell now.
+ **
+ ** Note that this can never happen in an SQLite data file, as all
+ ** cells are at least 4 bytes. It only happens in b-trees used
+ ** to evaluate "IN (SELECT ...)" and similar clauses.
+ */
+ if( szCell[j]==4 ){
+ assert(leafCorrection==4);
+ sz = cellSizePtr(pParent, pCell);
+ }
+ }
+ iOvflSpace += sz;
+ assert( sz<=pBt->maxLocal+23 );
+ assert( iOvflSpace <= (int)pBt->pageSize );
+ insertCell(pParent, nxDiv+i, pCell, sz, pTemp, pNew->pgno, &rc);
+ if( rc!=SQLITE_OK ) goto balance_cleanup;
+ assert( sqlite3PagerIswriteable(pParent->pDbPage) );
+ }
- j = cntNew[i];
+ /* Now update the actual sibling pages. The order in which they are updated
+ ** is important, as this code needs to avoid disrupting any page from which
+ ** cells may still to be read. In practice, this means:
+ **
+ ** (1) If cells are moving left (from apNew[iPg] to apNew[iPg-1])
+ ** then it is not safe to update page apNew[iPg] until after
+ ** the left-hand sibling apNew[iPg-1] has been updated.
+ **
+ ** (2) If cells are moving right (from apNew[iPg] to apNew[iPg+1])
+ ** then it is not safe to update page apNew[iPg] until after
+ ** the right-hand sibling apNew[iPg+1] has been updated.
+ **
+ ** If neither of the above apply, the page is safe to update.
+ **
+ ** The iPg value in the following loop starts at nNew-1 goes down
+ ** to 0, then back up to nNew-1 again, thus making two passes over
+ ** the pages. On the initial downward pass, only condition (1) above
+ ** needs to be tested because (2) will always be true from the previous
+ ** step. On the upward pass, both conditions are always true, so the
+ ** upwards pass simply processes pages that were missed on the downward
+ ** pass.
+ */
+ for(i=1-nNew; i<nNew; i++){
+ int iPg = i<0 ? -i : i;
+ assert( iPg>=0 && iPg<nNew );
+ if( abDone[iPg] ) continue; /* Skip pages already processed */
+ if( i>=0 /* On the upwards pass, or... */
+ || cntOld[iPg-1]>=cntNew[iPg-1] /* Condition (1) is true */
+ ){
+ int iNew;
+ int iOld;
+ int nNewCell;
- /* If the sibling page assembled above was not the right-most sibling,
- ** insert a divider cell into the parent page.
- */
- assert( i<nNew-1 || j==nCell );
- if( j<nCell ){
- u8 *pCell;
- u8 *pTemp;
- int sz;
+ /* Verify condition (1): If cells are moving left, update iPg
+ ** only after iPg-1 has already been updated. */
+ assert( iPg==0 || cntOld[iPg-1]>=cntNew[iPg-1] || abDone[iPg-1] );
- assert( j<nMaxCells );
- pCell = apCell[j];
- sz = szCell[j] + leafCorrection;
- pTemp = &aOvflSpace[iOvflSpace];
- if( !pNew->leaf ){
- memcpy(&pNew->aData[8], pCell, 4);
- }else if( leafData ){
- /* If the tree is a leaf-data tree, and the siblings are leaves,
- ** then there is no divider cell in apCell[]. Instead, the divider
- ** cell consists of the integer key for the right-most cell of
- ** the sibling-page assembled above only.
- */
- CellInfo info;
- j--;
- btreeParseCellPtr(pNew, apCell[j], &info);
- pCell = pTemp;
- sz = 4 + putVarint(&pCell[4], info.nKey);
- pTemp = 0;
+ /* Verify condition (2): If cells are moving right, update iPg
+ ** only after iPg+1 has already been updated. */
+ assert( cntNew[iPg]>=cntOld[iPg] || abDone[iPg+1] );
+
+ if( iPg==0 ){
+ iNew = iOld = 0;
+ nNewCell = cntNew[0];
}else{
- pCell -= 4;
- /* Obscure case for non-leaf-data trees: If the cell at pCell was
- ** previously stored on a leaf node, and its reported size was 4
- ** bytes, then it may actually be smaller than this
- ** (see btreeParseCellPtr(), 4 bytes is the minimum size of
- ** any cell). But it is important to pass the correct size to
- ** insertCell(), so reparse the cell now.
- **
- ** Note that this can never happen in an SQLite data file, as all
- ** cells are at least 4 bytes. It only happens in b-trees used
- ** to evaluate "IN (SELECT ...)" and similar clauses.
- */
- if( szCell[j]==4 ){
- assert(leafCorrection==4);
- sz = cellSizePtr(pParent, pCell);
- }
+ iOld = iPg<nOld ? (cntOld[iPg-1] + !leafData) : nCell;
+ iNew = cntNew[iPg-1] + !leafData;
+ nNewCell = cntNew[iPg] - iNew;
}
- iOvflSpace += sz;
- assert( sz<=pBt->maxLocal+23 );
- assert( iOvflSpace <= (int)pBt->pageSize );
- insertCell(pParent, nxDiv, pCell, sz, pTemp, pNew->pgno, &rc);
- if( rc!=SQLITE_OK ) goto balance_cleanup;
- assert( sqlite3PagerIswriteable(pParent->pDbPage) );
- j++;
- nxDiv++;
+ editPage(apNew[iPg], iOld, iNew, nNewCell, apCell, szCell);
+ abDone[iPg]++;
+ apNew[iPg]->nFree = usableSpace-szNew[iPg];
+ assert( apNew[iPg]->nOverflow==0 );
+ assert( apNew[iPg]->nCell==nNewCell );
}
}
- assert( j==nCell );
+
+ /* All pages have been processed exactly once */
+ assert( memcmp(abDone, "\01\01\01\01\01", nNew)==0 );
+
assert( nOld>0 );
assert( nNew>0 );
- if( (pageFlags & PTF_LEAF)==0 ){
- u8 *zChild = &apCopy[nOld-1]->aData[8];
- memcpy(&apNew[nNew-1]->aData[8], zChild, 4);
- }
if( isRoot && pParent->nCell==0 && pParent->hdrOffset<=apNew[0]->nFree ){
/* The root page of the b-tree now contains no cells. The only sibling
@@ -58959,126 +60244,50 @@ static int balance_nonroot(
** sets all pointer-map entries corresponding to database image pages
** for which the pointer is stored within the content being copied.
**
- ** The second assert below verifies that the child page is defragmented
- ** (it must be, as it was just reconstructed using assemblePage()). This
- ** is important if the parent page happens to be page 1 of the database
- ** image. */
+ ** It is critical that the child page be defragmented before being
+ ** copied into the parent, because if the parent is page 1 then it will
+ ** by smaller than the child due to the database header, and so all the
+ ** free space needs to be up front.
+ */
assert( nNew==1 );
+ rc = defragmentPage(apNew[0]);
+ testcase( rc!=SQLITE_OK );
assert( apNew[0]->nFree ==
- (get2byte(&apNew[0]->aData[5])-apNew[0]->cellOffset-apNew[0]->nCell*2)
+ (get2byte(&apNew[0]->aData[5])-apNew[0]->cellOffset-apNew[0]->nCell*2)
+ || rc!=SQLITE_OK
);
copyNodeContent(apNew[0], pParent, &rc);
freePage(apNew[0], &rc);
- }else if( ISAUTOVACUUM ){
- /* Fix the pointer-map entries for all the cells that were shifted around.
- ** There are several different types of pointer-map entries that need to
- ** be dealt with by this routine. Some of these have been set already, but
- ** many have not. The following is a summary:
- **
- ** 1) The entries associated with new sibling pages that were not
- ** siblings when this function was called. These have already
- ** been set. We don't need to worry about old siblings that were
- ** moved to the free-list - the freePage() code has taken care
- ** of those.
- **
- ** 2) The pointer-map entries associated with the first overflow
- ** page in any overflow chains used by new divider cells. These
- ** have also already been taken care of by the insertCell() code.
- **
- ** 3) If the sibling pages are not leaves, then the child pages of
- ** cells stored on the sibling pages may need to be updated.
- **
- ** 4) If the sibling pages are not internal intkey nodes, then any
- ** overflow pages used by these cells may need to be updated
- ** (internal intkey nodes never contain pointers to overflow pages).
- **
- ** 5) If the sibling pages are not leaves, then the pointer-map
- ** entries for the right-child pages of each sibling may need
- ** to be updated.
- **
- ** Cases 1 and 2 are dealt with above by other code. The next
- ** block deals with cases 3 and 4 and the one after that, case 5. Since
- ** setting a pointer map entry is a relatively expensive operation, this
- ** code only sets pointer map entries for child or overflow pages that have
- ** actually moved between pages. */
- MemPage *pNew = apNew[0];
- MemPage *pOld = apCopy[0];
- int nOverflow = pOld->nOverflow;
- int iNextOld = pOld->nCell + nOverflow;
- int iOverflow = (nOverflow ? pOld->aiOvfl[0] : -1);
- j = 0; /* Current 'old' sibling page */
- k = 0; /* Current 'new' sibling page */
- for(i=0; i<nCell; i++){
- int isDivider = 0;
- while( i==iNextOld ){
- /* Cell i is the cell immediately following the last cell on old
- ** sibling page j. If the siblings are not leaf pages of an
- ** intkey b-tree, then cell i was a divider cell. */
- assert( j+1 < ArraySize(apCopy) );
- assert( j+1 < nOld );
- pOld = apCopy[++j];
- iNextOld = i + !leafData + pOld->nCell + pOld->nOverflow;
- if( pOld->nOverflow ){
- nOverflow = pOld->nOverflow;
- iOverflow = i + !leafData + pOld->aiOvfl[0];
- }
- isDivider = !leafData;
- }
-
- assert(nOverflow>0 || iOverflow<i );
- assert(nOverflow<2 || pOld->aiOvfl[0]==pOld->aiOvfl[1]-1);
- assert(nOverflow<3 || pOld->aiOvfl[1]==pOld->aiOvfl[2]-1);
- if( i==iOverflow ){
- isDivider = 1;
- if( (--nOverflow)>0 ){
- iOverflow++;
- }
- }
-
- if( i==cntNew[k] ){
- /* Cell i is the cell immediately following the last cell on new
- ** sibling page k. If the siblings are not leaf pages of an
- ** intkey b-tree, then cell i is a divider cell. */
- pNew = apNew[++k];
- if( !leafData ) continue;
- }
- assert( j<nOld );
- assert( k<nNew );
-
- /* If the cell was originally divider cell (and is not now) or
- ** an overflow cell, or if the cell was located on a different sibling
- ** page before the balancing, then the pointer map entries associated
- ** with any child or overflow pages need to be updated. */
- if( isDivider || pOld->pgno!=pNew->pgno ){
- if( !leafCorrection ){
- ptrmapPut(pBt, get4byte(apCell[i]), PTRMAP_BTREE, pNew->pgno, &rc);
- }
- if( szCell[i]>pNew->minLocal ){
- ptrmapPutOvflPtr(pNew, apCell[i], &rc);
- }
- }
+ }else if( ISAUTOVACUUM && !leafCorrection ){
+ /* Fix the pointer map entries associated with the right-child of each
+ ** sibling page. All other pointer map entries have already been taken
+ ** care of. */
+ for(i=0; i<nNew; i++){
+ u32 key = get4byte(&apNew[i]->aData[8]);
+ ptrmapPut(pBt, key, PTRMAP_BTREE, apNew[i]->pgno, &rc);
}
+ }
- if( !leafCorrection ){
- for(i=0; i<nNew; i++){
- u32 key = get4byte(&apNew[i]->aData[8]);
- ptrmapPut(pBt, key, PTRMAP_BTREE, apNew[i]->pgno, &rc);
- }
- }
+ assert( pParent->isInit );
+ TRACE(("BALANCE: finished: old=%d new=%d cells=%d\n",
+ nOld, nNew, nCell));
+
+ /* Free any old pages that were not reused as new pages.
+ */
+ for(i=nNew; i<nOld; i++){
+ freePage(apOld[i], &rc);
+ }
#if 0
+ if( ISAUTOVACUUM && rc==SQLITE_OK && apNew[0]->isInit ){
/* The ptrmapCheckPages() contains assert() statements that verify that
** all pointer map pages are set correctly. This is helpful while
** debugging. This is usually disabled because a corrupt database may
** cause an assert() statement to fail. */
ptrmapCheckPages(apNew, nNew);
ptrmapCheckPages(&pParent, 1);
-#endif
}
-
- assert( pParent->isInit );
- TRACE(("BALANCE: finished: old=%d new=%d cells=%d\n",
- nOld, nNew, nCell));
+#endif
/*
** Cleanup before returning.
@@ -59257,7 +60466,8 @@ static int balance(BtCursor *pCur){
** pSpace buffer passed to the latter call to balance_nonroot().
*/
u8 *pSpace = sqlite3PageMalloc(pCur->pBt->pageSize);
- rc = balance_nonroot(pParent, iIdx, pSpace, iPage==1, pCur->hints);
+ rc = balance_nonroot(pParent, iIdx, pSpace, iPage==1,
+ pCur->hints&BTREE_BULKLOAD);
if( pFree ){
/* If pFree is not NULL, it points to the pSpace buffer used
** by a previous call to balance_nonroot(). Its contents are
@@ -59278,6 +60488,7 @@ static int balance(BtCursor *pCur){
/* The next iteration of the do-loop balances the parent page. */
releasePage(pPage);
pCur->iPage--;
+ assert( pCur->iPage>=0 );
}
}while( rc==SQLITE_OK );
@@ -59754,9 +60965,13 @@ static int clearDatabasePage(
if( pgno>btreePagecount(pBt) ){
return SQLITE_CORRUPT_BKPT;
}
-
rc = getAndInitPage(pBt, pgno, &pPage, 0);
if( rc ) return rc;
+ if( pPage->bBusy ){
+ rc = SQLITE_CORRUPT_BKPT;
+ goto cleardatabasepage_out;
+ }
+ pPage->bBusy = 1;
hdr = pPage->hdrOffset;
for(i=0; i<pPage->nCell; i++){
pCell = findCell(pPage, i);
@@ -59781,6 +60996,7 @@ static int clearDatabasePage(
}
cleardatabasepage_out:
+ pPage->bBusy = 0;
releasePage(pPage);
return rc;
}
@@ -59970,6 +61186,13 @@ SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree *p, int iTable, int *piMoved){
** The schema layer numbers meta values differently. At the schema
** layer (and the SetCookie and ReadCookie opcodes) the number of
** free pages is not visible. So Cookie[0] is the same as Meta[1].
+**
+** This routine treats Meta[BTREE_DATA_VERSION] as a special case. Instead
+** of reading the value out of the header, it instead loads the "DataVersion"
+** from the pager. The BTREE_DATA_VERSION value is not actually stored in the
+** database file. It is a number computed by the pager. But its access
+** pattern is the same as header meta values, and so it is convenient to
+** read it from this routine.
*/
SQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *p, int idx, u32 *pMeta){
BtShared *pBt = p->pBt;
@@ -59980,7 +61203,11 @@ SQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *p, int idx, u32 *pMeta){
assert( pBt->pPage1 );
assert( idx>=0 && idx<=15 );
- *pMeta = get4byte(&pBt->pPage1->aData[36 + idx*4]);
+ if( idx==BTREE_DATA_VERSION ){
+ *pMeta = sqlite3PagerDataVersion(pBt->pPager) + p->iDataVersion;
+ }else{
+ *pMeta = get4byte(&pBt->pPage1->aData[36 + idx*4]);
+ }
/* If auto-vacuum is disabled in this build and this is an auto-vacuum
** database, mark the database as read-only. */
@@ -60071,7 +61298,7 @@ SQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *pCur, i64 *pnEntry){
if( pCur->iPage==0 ){
/* All pages of the b-tree have been visited. Return successfully. */
*pnEntry = nEntry;
- return SQLITE_OK;
+ return moveToRoot(pCur);
}
moveToParent(pCur);
}while ( pCur->aiIdx[pCur->iPage]>=pCur->apPage[pCur->iPage]->nCell );
@@ -60463,8 +61690,14 @@ static int checkTreePage(
assert( contentOffset<=usableSize ); /* Enforced by btreeInitPage() */
memset(hit+contentOffset, 0, usableSize-contentOffset);
memset(hit, 1, contentOffset);
+ /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
+ ** number of cells on the page. */
nCell = get2byte(&data[hdr+3]);
+ /* EVIDENCE-OF: R-23882-45353 The cell pointer array of a b-tree page
+ ** immediately follows the b-tree page header. */
cellStart = hdr + 12 - 4*pPage->leaf;
+ /* EVIDENCE-OF: R-02776-14802 The cell pointer array consists of K 2-byte
+ ** integer offsets to the cell contents. */
for(i=0; i<nCell; i++){
int pc = get2byte(&data[cellStart+i*2]);
u32 size = 65536;
@@ -60480,6 +61713,9 @@ static int checkTreePage(
for(j=pc+size-1; j>=pc; j--) hit[j]++;
}
}
+ /* EVIDENCE-OF: R-20690-50594 The second field of the b-tree page header
+ ** is the offset of the first freeblock, or zero if there are no
+ ** freeblocks on the page. */
i = get2byte(&data[hdr+1]);
while( i>0 ){
int size, j;
@@ -60487,7 +61723,13 @@ static int checkTreePage(
size = get2byte(&data[i+2]);
assert( i+size<=usableSize ); /* Enforced by btreeInitPage() */
for(j=i+size-1; j>=i; j--) hit[j]++;
+ /* EVIDENCE-OF: R-58208-19414 The first 2 bytes of a freeblock are a
+ ** big-endian integer which is the offset in the b-tree page of the next
+ ** freeblock in the chain, or zero if the freeblock is the last on the
+ ** chain. */
j = get2byte(&data[i]);
+ /* EVIDENCE-OF: R-06866-39125 Freeblocks are always connected in order of
+ ** increasing offset. */
assert( j==0 || j>i+size ); /* Enforced by btreeInitPage() */
assert( j<=usableSize-4 ); /* Enforced by btreeInitPage() */
i = j;
@@ -60501,6 +61743,11 @@ static int checkTreePage(
break;
}
}
+ /* EVIDENCE-OF: R-43263-13491 The total number of bytes in all fragments
+ ** is stored in the fifth field of the b-tree page header.
+ ** EVIDENCE-OF: R-07161-27322 The one-byte integer at offset 7 gives the
+ ** number of fragmented free bytes within the cell content area.
+ */
if( cnt!=data[hdr+7] ){
checkAppendMsg(pCheck,
"Fragmentation of %d bytes reported as %d on page %d",
@@ -60889,14 +62136,23 @@ SQLITE_PRIVATE int sqlite3BtreeSetVersion(Btree *pBtree, int iVersion){
}
/*
-** set the mask of hint flags for cursor pCsr. Currently the only valid
-** values are 0 and BTREE_BULKLOAD.
+** set the mask of hint flags for cursor pCsr.
*/
SQLITE_PRIVATE void sqlite3BtreeCursorHints(BtCursor *pCsr, unsigned int mask){
- assert( mask==BTREE_BULKLOAD || mask==0 );
+ assert( mask==BTREE_BULKLOAD || mask==BTREE_SEEK_EQ || mask==0 );
pCsr->hints = mask;
}
+#ifdef SQLITE_DEBUG
+/*
+** Return true if the cursor has a hint specified. This routine is
+** only used from within assert() statements
+*/
+SQLITE_PRIVATE int sqlite3BtreeCursorHasHint(BtCursor *pCsr, unsigned int mask){
+ return (pCsr->hints & mask)!=0;
+}
+#endif
+
/*
** Return true if the given Btree is read-only.
*/
@@ -60904,6 +62160,11 @@ SQLITE_PRIVATE int sqlite3BtreeIsReadonly(Btree *p){
return (p->pBt->btsFlags & BTS_READ_ONLY)!=0;
}
+/*
+** Return the size of the header added to each page by this module.
+*/
+SQLITE_PRIVATE int sqlite3HeaderSizeBtree(void){ return ROUND8(sizeof(MemPage)); }
+
/************** End of btree.c ***********************************************/
/************** Begin file backup.c ******************************************/
/*
@@ -61029,6 +62290,20 @@ static int setDestPgsz(sqlite3_backup *p){
}
/*
+** Check that there is no open read-transaction on the b-tree passed as the
+** second argument. If there is not, return SQLITE_OK. Otherwise, if there
+** is an open read-transaction, return SQLITE_ERROR and leave an error
+** message in database handle db.
+*/
+static int checkReadTransaction(sqlite3 *db, Btree *p){
+ if( sqlite3BtreeIsInReadTrans(p) ){
+ sqlite3ErrorWithMsg(db, SQLITE_ERROR, "destination database is in use");
+ return SQLITE_ERROR;
+ }
+ return SQLITE_OK;
+}
+
+/*
** Create an sqlite3_backup process to copy the contents of zSrcDb from
** connection handle pSrcDb to zDestDb in pDestDb. If successful, return
** a pointer to the new sqlite3_backup object.
@@ -61036,7 +62311,7 @@ static int setDestPgsz(sqlite3_backup *p){
** If an error occurs, NULL is returned and an error code and error message
** stored in database handle pDestDb.
*/
-SQLITE_API sqlite3_backup *sqlite3_backup_init(
+SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
sqlite3* pDestDb, /* Database to write to */
const char *zDestDb, /* Name of database within pDestDb */
sqlite3* pSrcDb, /* Database connection to read from */
@@ -61044,6 +62319,13 @@ SQLITE_API sqlite3_backup *sqlite3_backup_init(
){
sqlite3_backup *p; /* Value to return */
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(pSrcDb)||!sqlite3SafetyCheckOk(pDestDb) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
+
/* Lock the source database handle. The destination database
** handle is not locked in this routine, but it is locked in
** sqlite3_backup_step(). The user is required to ensure that no
@@ -61080,12 +62362,15 @@ SQLITE_API sqlite3_backup *sqlite3_backup_init(
p->iNext = 1;
p->isAttached = 0;
- if( 0==p->pSrc || 0==p->pDest || setDestPgsz(p)==SQLITE_NOMEM ){
+ if( 0==p->pSrc || 0==p->pDest
+ || setDestPgsz(p)==SQLITE_NOMEM
+ || checkReadTransaction(pDestDb, p->pDest)!=SQLITE_OK
+ ){
/* One (or both) of the named databases did not exist or an OOM
- ** error was hit. The error has already been written into the
- ** pDestDb handle. All that is left to do here is free the
- ** sqlite3_backup structure.
- */
+ ** error was hit. Or there is a transaction open on the destination
+ ** database. The error has already been written into the pDestDb
+ ** handle. All that is left to do here is free the sqlite3_backup
+ ** structure. */
sqlite3_free(p);
p = 0;
}
@@ -61129,7 +62414,7 @@ static int backupOnePage(
** guaranteed that the shared-mutex is held by this thread, handle
** p->pSrc may not actually be the owner. */
int nSrcReserve = sqlite3BtreeGetReserveNoMutex(p->pSrc);
- int nDestReserve = sqlite3BtreeGetReserve(p->pDest);
+ int nDestReserve = sqlite3BtreeGetOptimalReserve(p->pDest);
#endif
int rc = SQLITE_OK;
i64 iOff;
@@ -61234,12 +62519,15 @@ static void attachBackupObject(sqlite3_backup *p){
/*
** Copy nPage pages from the source b-tree to the destination.
*/
-SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage){
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage){
int rc;
int destMode; /* Destination journal mode */
int pgszSrc = 0; /* Source page size */
int pgszDest = 0; /* Destination page size */
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( p==0 ) return SQLITE_MISUSE_BKPT;
+#endif
sqlite3_mutex_enter(p->pSrcDb->mutex);
sqlite3BtreeEnter(p->pSrc);
if( p->pDestDb ){
@@ -61476,7 +62764,7 @@ SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage){
/*
** Release all resources associated with an sqlite3_backup* handle.
*/
-SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p){
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p){
sqlite3_backup **pp; /* Ptr to head of pagers backup list */
sqlite3 *pSrcDb; /* Source database connection */
int rc; /* Value to return */
@@ -61528,7 +62816,13 @@ SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p){
** Return the number of pages still to be backed up as of the most recent
** call to sqlite3_backup_step().
*/
-SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p){
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p){
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( p==0 ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
return p->nRemaining;
}
@@ -61536,7 +62830,13 @@ SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p){
** Return the total number of pages in the source database as of the most
** recent call to sqlite3_backup_step().
*/
-SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p){
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p){
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( p==0 ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
return p->nPagecount;
}
@@ -62745,7 +64045,7 @@ struct ValueNewStat4Ctx {
** Otherwise, if the second argument is non-zero, then this function is
** being called indirectly by sqlite3Stat4ProbeSetValue(). If it has not
** already been allocated, allocate the UnpackedRecord structure that
-** that function will return to its caller here. Then return a pointer
+** that function will return to its caller here. Then return a pointer to
** an sqlite3_value within the UnpackedRecord.a[] array.
*/
static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){
@@ -62790,6 +64090,113 @@ static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){
}
/*
+** The expression object indicated by the second argument is guaranteed
+** to be a scalar SQL function. If
+**
+** * all function arguments are SQL literals,
+** * the SQLITE_FUNC_CONSTANT function flag is set, and
+** * the SQLITE_FUNC_NEEDCOLL function flag is not set,
+**
+** then this routine attempts to invoke the SQL function. Assuming no
+** error occurs, output parameter (*ppVal) is set to point to a value
+** object containing the result before returning SQLITE_OK.
+**
+** Affinity aff is applied to the result of the function before returning.
+** If the result is a text value, the sqlite3_value object uses encoding
+** enc.
+**
+** If the conditions above are not met, this function returns SQLITE_OK
+** and sets (*ppVal) to NULL. Or, if an error occurs, (*ppVal) is set to
+** NULL and an SQLite error code returned.
+*/
+#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
+static int valueFromFunction(
+ sqlite3 *db, /* The database connection */
+ Expr *p, /* The expression to evaluate */
+ u8 enc, /* Encoding to use */
+ u8 aff, /* Affinity to use */
+ sqlite3_value **ppVal, /* Write the new value here */
+ struct ValueNewStat4Ctx *pCtx /* Second argument for valueNew() */
+){
+ sqlite3_context ctx; /* Context object for function invocation */
+ sqlite3_value **apVal = 0; /* Function arguments */
+ int nVal = 0; /* Size of apVal[] array */
+ FuncDef *pFunc = 0; /* Function definition */
+ sqlite3_value *pVal = 0; /* New value */
+ int rc = SQLITE_OK; /* Return code */
+ int nName; /* Size of function name in bytes */
+ ExprList *pList = 0; /* Function arguments */
+ int i; /* Iterator variable */
+
+ assert( pCtx!=0 );
+ assert( (p->flags & EP_TokenOnly)==0 );
+ pList = p->x.pList;
+ if( pList ) nVal = pList->nExpr;
+ nName = sqlite3Strlen30(p->u.zToken);
+ pFunc = sqlite3FindFunction(db, p->u.zToken, nName, nVal, enc, 0);
+ assert( pFunc );
+ if( (pFunc->funcFlags & SQLITE_FUNC_CONSTANT)==0
+ || (pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL)
+ ){
+ return SQLITE_OK;
+ }
+
+ if( pList ){
+ apVal = (sqlite3_value**)sqlite3DbMallocZero(db, sizeof(apVal[0]) * nVal);
+ if( apVal==0 ){
+ rc = SQLITE_NOMEM;
+ goto value_from_function_out;
+ }
+ for(i=0; i<nVal; i++){
+ rc = sqlite3ValueFromExpr(db, pList->a[i].pExpr, enc, aff, &apVal[i]);
+ if( apVal[i]==0 || rc!=SQLITE_OK ) goto value_from_function_out;
+ }
+ }
+
+ pVal = valueNew(db, pCtx);
+ if( pVal==0 ){
+ rc = SQLITE_NOMEM;
+ goto value_from_function_out;
+ }
+
+ assert( pCtx->pParse->rc==SQLITE_OK );
+ memset(&ctx, 0, sizeof(ctx));
+ ctx.pOut = pVal;
+ ctx.pFunc = pFunc;
+ pFunc->xFunc(&ctx, nVal, apVal);
+ if( ctx.isError ){
+ rc = ctx.isError;
+ sqlite3ErrorMsg(pCtx->pParse, "%s", sqlite3_value_text(pVal));
+ }else{
+ sqlite3ValueApplyAffinity(pVal, aff, SQLITE_UTF8);
+ assert( rc==SQLITE_OK );
+ rc = sqlite3VdbeChangeEncoding(pVal, enc);
+ if( rc==SQLITE_OK && sqlite3VdbeMemTooBig(pVal) ){
+ rc = SQLITE_TOOBIG;
+ pCtx->pParse->nErr++;
+ }
+ }
+ pCtx->pParse->rc = rc;
+
+ value_from_function_out:
+ if( rc!=SQLITE_OK ){
+ pVal = 0;
+ }
+ if( apVal ){
+ for(i=0; i<nVal; i++){
+ sqlite3ValueFree(apVal[i]);
+ }
+ sqlite3DbFree(db, apVal);
+ }
+
+ *ppVal = pVal;
+ return rc;
+}
+#else
+# define valueFromFunction(a,b,c,d,e,f) SQLITE_OK
+#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */
+
+/*
** Extract a value from the supplied expression in the manner described
** above sqlite3ValueFromExpr(). Allocate the sqlite3_value object
** using valueNew().
@@ -62821,6 +64228,12 @@ static int valueFromExpr(
while( (op = pExpr->op)==TK_UPLUS ) pExpr = pExpr->pLeft;
if( NEVER(op==TK_REGISTER) ) op = pExpr->op2;
+ /* Compressed expressions only appear when parsing the DEFAULT clause
+ ** on a table column definition, and hence only when pCtx==0. This
+ ** check ensures that an EP_TokenOnly expression is never passed down
+ ** into valueFromFunction(). */
+ assert( (pExpr->flags & EP_TokenOnly)==0 || pCtx==0 );
+
if( op==TK_CAST ){
u8 aff = sqlite3AffinityType(pExpr->u.zToken,0);
rc = valueFromExpr(db, pExpr->pLeft, enc, aff, ppVal, pCtx);
@@ -62897,6 +64310,12 @@ static int valueFromExpr(
}
#endif
+#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
+ else if( op==TK_FUNCTION && pCtx!=0 ){
+ rc = valueFromFunction(db, pExpr, enc, affinity, &pVal, pCtx);
+ }
+#endif
+
*ppVal = pVal;
return rc;
@@ -63286,7 +64705,7 @@ SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe *p, const char *z, int n, int isPrepa
/*
** Return the SQL associated with a prepared statement
*/
-SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt){
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt){
Vdbe *p = (Vdbe *)pStmt;
return (p && p->isPrepareV2) ? p->zSql : 0;
}
@@ -63627,6 +65046,7 @@ static Op *opIterNext(VdbeOpIter *p){
*/
SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){
int hasAbort = 0;
+ int hasFkCounter = 0;
Op *pOp;
VdbeOpIter sIter;
memset(&sIter, 0, sizeof(sIter));
@@ -63635,15 +65055,17 @@ SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){
while( (pOp = opIterNext(&sIter))!=0 ){
int opcode = pOp->opcode;
if( opcode==OP_Destroy || opcode==OP_VUpdate || opcode==OP_VRename
-#ifndef SQLITE_OMIT_FOREIGN_KEY
- || (opcode==OP_FkCounter && pOp->p1==0 && pOp->p2==1)
-#endif
|| ((opcode==OP_Halt || opcode==OP_HaltIfNull)
&& ((pOp->p1&0xff)==SQLITE_CONSTRAINT && pOp->p2==OE_Abort))
){
hasAbort = 1;
break;
}
+#ifndef SQLITE_OMIT_FOREIGN_KEY
+ if( opcode==OP_FkCounter && pOp->p1==0 && pOp->p2==1 ){
+ hasFkCounter = 1;
+ }
+#endif
}
sqlite3DbFree(v->db, sIter.apSub);
@@ -63652,7 +65074,7 @@ SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *v, int mayAbort){
** through all opcodes and hasAbort may be set incorrectly. Return
** true for this case to prevent the assert() in the callers frame
** from failing. */
- return ( v->db->mallocFailed || hasAbort==mayAbort );
+ return ( v->db->mallocFailed || hasAbort==mayAbort || hasFkCounter );
}
#endif /* SQLITE_DEBUG - the sqlite3AssertMayAbort() function */
@@ -63828,6 +65250,34 @@ SQLITE_PRIVATE int sqlite3VdbeAddOpList(Vdbe *p, int nOp, VdbeOpList const *aOp,
return addr;
}
+#if defined(SQLITE_ENABLE_STMT_SCANSTATUS)
+/*
+** Add an entry to the array of counters managed by sqlite3_stmt_scanstatus().
+*/
+SQLITE_PRIVATE void sqlite3VdbeScanStatus(
+ Vdbe *p, /* VM to add scanstatus() to */
+ int addrExplain, /* Address of OP_Explain (or 0) */
+ int addrLoop, /* Address of loop counter */
+ int addrVisit, /* Address of rows visited counter */
+ LogEst nEst, /* Estimated number of output rows */
+ const char *zName /* Name of table or index being scanned */
+){
+ int nByte = (p->nScan+1) * sizeof(ScanStatus);
+ ScanStatus *aNew;
+ aNew = (ScanStatus*)sqlite3DbRealloc(p->db, p->aScan, nByte);
+ if( aNew ){
+ ScanStatus *pNew = &aNew[p->nScan++];
+ pNew->addrExplain = addrExplain;
+ pNew->addrLoop = addrLoop;
+ pNew->addrVisit = addrVisit;
+ pNew->nEst = nEst;
+ pNew->zName = sqlite3DbStrDup(p->db, zName);
+ p->aScan = aNew;
+ }
+}
+#endif
+
+
/*
** Change the value of the P1 operand for a specific instruction.
** This routine is useful when a large program is loaded from a
@@ -64318,7 +65768,7 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){
#ifndef SQLITE_OMIT_VIRTUALTABLE
case P4_VTAB: {
sqlite3_vtab *pVtab = pOp->p4.pVtab->pVtab;
- sqlite3_snprintf(nTemp, zTemp, "vtab:%p:%p", pVtab, pVtab->pModule);
+ sqlite3_snprintf(nTemp, zTemp, "vtab:%p", pVtab);
break;
}
#endif
@@ -64926,6 +66376,9 @@ SQLITE_PRIVATE void sqlite3VdbeMakeReady(
p->apCsr = allocSpace(p->apCsr, nCursor*sizeof(VdbeCursor*),
&zCsr, zEnd, &nByte);
p->aOnceFlag = allocSpace(p->aOnceFlag, nOnce, &zCsr, zEnd, &nByte);
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
+ p->anExec = allocSpace(p->anExec, p->nOp*sizeof(i64), &zCsr, zEnd, &nByte);
+#endif
if( nByte ){
p->pFree = sqlite3DbMallocZero(db, nByte);
}
@@ -64942,7 +66395,7 @@ SQLITE_PRIVATE void sqlite3VdbeMakeReady(
p->aVar[n].db = db;
}
}
- if( p->azVar ){
+ if( p->azVar && pParse->nzVar>0 ){
p->nzVar = pParse->nzVar;
memcpy(p->azVar, pParse->azVar, p->nzVar*sizeof(p->azVar[0]));
memset(pParse->azVar, 0, pParse->nzVar*sizeof(pParse->azVar[0]));
@@ -64979,9 +66432,9 @@ SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){
else if( pCx->pVtabCursor ){
sqlite3_vtab_cursor *pVtabCursor = pCx->pVtabCursor;
const sqlite3_module *pModule = pVtabCursor->pVtab->pModule;
- p->inVtabMethod = 1;
+ assert( pVtabCursor->pVtab->nRef>0 );
+ pVtabCursor->pVtab->nRef--;
pModule->xClose(pVtabCursor);
- p->inVtabMethod = 0;
}
#endif
}
@@ -64993,6 +66446,9 @@ SQLITE_PRIVATE void sqlite3VdbeFreeCursor(Vdbe *p, VdbeCursor *pCx){
*/
SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *pFrame){
Vdbe *v = pFrame->v;
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
+ v->anExec = pFrame->anExec;
+#endif
v->aOnceFlag = pFrame->aOnceFlag;
v->nOnceFlag = pFrame->nOnceFlag;
v->aOp = pFrame->aOp;
@@ -65003,6 +66459,7 @@ SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *pFrame){
v->nCursor = pFrame->nCursor;
v->db->lastRowid = pFrame->lastRowid;
v->nChange = pFrame->nChange;
+ v->db->nChange = pFrame->nDbChange;
return pFrame->pc;
}
@@ -65336,7 +66793,7 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){
** doing this the directory is synced again before any individual
** transaction files are deleted.
*/
- rc = sqlite3OsDelete(pVfs, zMaster, 1);
+ rc = sqlite3OsDelete(pVfs, zMaster, needSync);
sqlite3DbFree(db, zMaster);
zMaster = 0;
if( rc ){
@@ -65570,6 +67027,7 @@ SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){
sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);
sqlite3CloseSavepoints(db);
db->autoCommit = 1;
+ p->nChange = 0;
}
}
}
@@ -65610,6 +67068,7 @@ SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){
}else if( rc!=SQLITE_OK ){
p->rc = rc;
sqlite3RollbackAll(db, SQLITE_OK);
+ p->nChange = 0;
}else{
db->nDeferredCons = 0;
db->nDeferredImmCons = 0;
@@ -65618,6 +67077,7 @@ SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){
}
}else{
sqlite3RollbackAll(db, SQLITE_OK);
+ p->nChange = 0;
}
db->nStatement = 0;
}else if( eStatementOp==0 ){
@@ -65629,6 +67089,7 @@ SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){
sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);
sqlite3CloseSavepoints(db);
db->autoCommit = 1;
+ p->nChange = 0;
}
}
@@ -65649,6 +67110,7 @@ SQLITE_PRIVATE int sqlite3VdbeHalt(Vdbe *p){
sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);
sqlite3CloseSavepoints(db);
db->autoCommit = 1;
+ p->nChange = 0;
}
}
@@ -65910,6 +67372,12 @@ SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){
sqlite3DbFree(db, p->aColName);
sqlite3DbFree(db, p->zSql);
sqlite3DbFree(db, p->pFree);
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
+ for(i=0; i<p->nScan; i++){
+ sqlite3DbFree(db, p->aScan[i].zName);
+ }
+ sqlite3DbFree(db, p->aScan);
+#endif
}
/*
@@ -66068,9 +67536,7 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialType(Mem *pMem, int file_format){
i64 i = pMem->u.i;
u64 u;
if( i<0 ){
- if( i<(-MAX_6BYTE) ) return 6;
- /* Previous test prevents: u = -(-9223372036854775808) */
- u = -i;
+ u = ~i;
}else{
u = i;
}
@@ -66236,10 +67702,14 @@ static u32 SQLITE_NOINLINE serialGet(
u32 y = FOUR_BYTE_UINT(buf+4);
x = (x<<32) + y;
if( serial_type==6 ){
+ /* EVIDENCE-OF: R-29851-52272 Value is a big-endian 64-bit
+ ** twos-complement integer. */
pMem->u.i = *(i64*)&x;
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
}else{
+ /* EVIDENCE-OF: R-57343-49114 Value is a big-endian IEEE 754-2008 64-bit
+ ** floating point number. */
#if !defined(NDEBUG) && !defined(SQLITE_OMIT_FLOATING_POINT)
/* Verify that integers and floating point values use the same
** byte order. Or, that if SQLITE_MIXED_ENDIAN_64BIT_FLOAT is
@@ -66267,35 +67737,46 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
switch( serial_type ){
case 10: /* Reserved for future use */
case 11: /* Reserved for future use */
- case 0: { /* NULL */
+ case 0: { /* Null */
+ /* EVIDENCE-OF: R-24078-09375 Value is a NULL. */
pMem->flags = MEM_Null;
break;
}
- case 1: { /* 1-byte signed integer */
+ case 1: {
+ /* EVIDENCE-OF: R-44885-25196 Value is an 8-bit twos-complement
+ ** integer. */
pMem->u.i = ONE_BYTE_INT(buf);
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
return 1;
}
case 2: { /* 2-byte signed integer */
+ /* EVIDENCE-OF: R-49794-35026 Value is a big-endian 16-bit
+ ** twos-complement integer. */
pMem->u.i = TWO_BYTE_INT(buf);
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
return 2;
}
case 3: { /* 3-byte signed integer */
+ /* EVIDENCE-OF: R-37839-54301 Value is a big-endian 24-bit
+ ** twos-complement integer. */
pMem->u.i = THREE_BYTE_INT(buf);
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
return 3;
}
case 4: { /* 4-byte signed integer */
+ /* EVIDENCE-OF: R-01849-26079 Value is a big-endian 32-bit
+ ** twos-complement integer. */
pMem->u.i = FOUR_BYTE_INT(buf);
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
return 4;
}
case 5: { /* 6-byte signed integer */
+ /* EVIDENCE-OF: R-50385-09674 Value is a big-endian 48-bit
+ ** twos-complement integer. */
pMem->u.i = FOUR_BYTE_UINT(buf+2) + (((i64)1)<<32)*TWO_BYTE_INT(buf);
pMem->flags = MEM_Int;
testcase( pMem->u.i<0 );
@@ -66309,11 +67790,17 @@ SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
}
case 8: /* Integer 0 */
case 9: { /* Integer 1 */
+ /* EVIDENCE-OF: R-12976-22893 Value is the integer 0. */
+ /* EVIDENCE-OF: R-18143-12121 Value is the integer 1. */
pMem->u.i = serial_type-8;
pMem->flags = MEM_Int;
return 0;
}
default: {
+ /* EVIDENCE-OF: R-14606-31564 Value is a BLOB that is (N-12)/2 bytes in
+ ** length.
+ ** EVIDENCE-OF: R-28401-00140 Value is a string in the text encoding and
+ ** (N-13)/2 bytes in length. */
static const u16 aFlag[] = { MEM_Blob|MEM_Ephem, MEM_Str|MEM_Ephem };
pMem->z = (char *)buf;
pMem->n = (serial_type-12)/2;
@@ -66512,6 +67999,42 @@ debugCompareEnd:
}
#endif
+#if SQLITE_DEBUG
+/*
+** Count the number of fields (a.k.a. columns) in the record given by
+** pKey,nKey. The verify that this count is less than or equal to the
+** limit given by pKeyInfo->nField + pKeyInfo->nXField.
+**
+** If this constraint is not satisfied, it means that the high-speed
+** vdbeRecordCompareInt() and vdbeRecordCompareString() routines will
+** not work correctly. If this assert() ever fires, it probably means
+** that the KeyInfo.nField or KeyInfo.nXField values were computed
+** incorrectly.
+*/
+static void vdbeAssertFieldCountWithinLimits(
+ int nKey, const void *pKey, /* The record to verify */
+ const KeyInfo *pKeyInfo /* Compare size with this KeyInfo */
+){
+ int nField = 0;
+ u32 szHdr;
+ u32 idx;
+ u32 notUsed;
+ const unsigned char *aKey = (const unsigned char*)pKey;
+
+ if( CORRUPT_DB ) return;
+ idx = getVarint32(aKey, szHdr);
+ assert( nKey>=0 );
+ assert( szHdr<=(u32)nKey );
+ while( idx<szHdr ){
+ idx += getVarint32(aKey+idx, notUsed);
+ nField++;
+ }
+ assert( nField <= pKeyInfo->nField+pKeyInfo->nXField );
+}
+#else
+# define vdbeAssertFieldCountWithinLimits(A,B,C)
+#endif
+
/*
** Both *pMem1 and *pMem2 contain string values. Compare the two values
** using the collation sequence pColl. As usual, return a negative , zero
@@ -66923,6 +68446,7 @@ static int vdbeRecordCompareInt(
i64 v = pPKey2->aMem[0].u.i;
i64 lhs;
+ vdbeAssertFieldCountWithinLimits(nKey1, pKey1, pPKey2->pKeyInfo);
assert( (*(u8*)pKey1)<=0x3F || CORRUPT_DB );
switch( serial_type ){
case 1: { /* 1-byte signed integer */
@@ -67010,6 +68534,7 @@ static int vdbeRecordCompareString(
int serial_type;
int res;
+ vdbeAssertFieldCountWithinLimits(nKey1, pKey1, pPKey2->pKeyInfo);
getVarint32(&aKey1[1], serial_type);
if( serial_type<12 ){
res = pPKey2->r1; /* (pKey1/nKey1) is a number or a null */
@@ -67336,7 +68861,7 @@ SQLITE_PRIVATE void sqlite3VtabImportErrmsg(Vdbe *p, sqlite3_vtab *pVtab){
** collating sequences are registered or if an authorizer function is
** added or changed.
*/
-SQLITE_API int sqlite3_expired(sqlite3_stmt *pStmt){
+SQLITE_API int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt *pStmt){
Vdbe *p = (Vdbe*)pStmt;
return p==0 || p->expired;
}
@@ -67373,7 +68898,7 @@ static int vdbeSafetyNotNull(Vdbe *p){
** This routine sets the error code and string returned by
** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
*/
-SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt){
+SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt){
int rc;
if( pStmt==0 ){
/* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL
@@ -67399,7 +68924,7 @@ SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt){
** This routine sets the error code and string returned by
** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
*/
-SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt){
+SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt){
int rc;
if( pStmt==0 ){
rc = SQLITE_OK;
@@ -67418,7 +68943,7 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt){
/*
** Set all the parameters in the compiled SQL statement to NULL.
*/
-SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt *pStmt){
+SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt *pStmt){
int i;
int rc = SQLITE_OK;
Vdbe *p = (Vdbe*)pStmt;
@@ -67442,7 +68967,7 @@ SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt *pStmt){
** The following routines extract information from a Mem or sqlite3_value
** structure.
*/
-SQLITE_API const void *sqlite3_value_blob(sqlite3_value *pVal){
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value *pVal){
Mem *p = (Mem*)pVal;
if( p->flags & (MEM_Blob|MEM_Str) ){
sqlite3VdbeMemExpandBlob(p);
@@ -67452,36 +68977,40 @@ SQLITE_API const void *sqlite3_value_blob(sqlite3_value *pVal){
return sqlite3_value_text(pVal);
}
}
-SQLITE_API int sqlite3_value_bytes(sqlite3_value *pVal){
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value *pVal){
return sqlite3ValueBytes(pVal, SQLITE_UTF8);
}
-SQLITE_API int sqlite3_value_bytes16(sqlite3_value *pVal){
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value *pVal){
return sqlite3ValueBytes(pVal, SQLITE_UTF16NATIVE);
}
-SQLITE_API double sqlite3_value_double(sqlite3_value *pVal){
+SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value *pVal){
return sqlite3VdbeRealValue((Mem*)pVal);
}
-SQLITE_API int sqlite3_value_int(sqlite3_value *pVal){
+SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value *pVal){
return (int)sqlite3VdbeIntValue((Mem*)pVal);
}
-SQLITE_API sqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){
+SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value *pVal){
return sqlite3VdbeIntValue((Mem*)pVal);
}
-SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value *pVal){
return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
}
#ifndef SQLITE_OMIT_UTF16
-SQLITE_API const void *sqlite3_value_text16(sqlite3_value* pVal){
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value* pVal){
return sqlite3ValueText(pVal, SQLITE_UTF16NATIVE);
}
-SQLITE_API const void *sqlite3_value_text16be(sqlite3_value *pVal){
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value *pVal){
return sqlite3ValueText(pVal, SQLITE_UTF16BE);
}
-SQLITE_API const void *sqlite3_value_text16le(sqlite3_value *pVal){
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value *pVal){
return sqlite3ValueText(pVal, SQLITE_UTF16LE);
}
#endif /* SQLITE_OMIT_UTF16 */
-SQLITE_API int sqlite3_value_type(sqlite3_value* pVal){
+/* EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five
+** fundamental datatypes: 64-bit signed integer 64-bit IEEE floating
+** point number string BLOB NULL
+*/
+SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value* pVal){
static const u8 aType[] = {
SQLITE_BLOB, /* 0x00 */
SQLITE_NULL, /* 0x01 */
@@ -67557,7 +69086,7 @@ static int invokeValueDestructor(
if( pCtx ) sqlite3_result_error_toobig(pCtx);
return SQLITE_TOOBIG;
}
-SQLITE_API void sqlite3_result_blob(
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(
sqlite3_context *pCtx,
const void *z,
int n,
@@ -67567,7 +69096,7 @@ SQLITE_API void sqlite3_result_blob(
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
setResultStrOrError(pCtx, z, n, 0, xDel);
}
-SQLITE_API void sqlite3_result_blob64(
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(
sqlite3_context *pCtx,
const void *z,
sqlite3_uint64 n,
@@ -67581,37 +69110,37 @@ SQLITE_API void sqlite3_result_blob64(
setResultStrOrError(pCtx, z, (int)n, 0, xDel);
}
}
-SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){
+SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context *pCtx, double rVal){
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
sqlite3VdbeMemSetDouble(pCtx->pOut, rVal);
}
-SQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
pCtx->isError = SQLITE_ERROR;
pCtx->fErrorOrAux = 1;
sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);
}
#ifndef SQLITE_OMIT_UTF16
-SQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
pCtx->isError = SQLITE_ERROR;
pCtx->fErrorOrAux = 1;
sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);
}
#endif
-SQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context *pCtx, int iVal){
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal);
}
-SQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);
}
-SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){
+SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context *pCtx){
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
sqlite3VdbeMemSetNull(pCtx->pOut);
}
-SQLITE_API void sqlite3_result_text(
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text(
sqlite3_context *pCtx,
const char *z,
int n,
@@ -67620,7 +69149,7 @@ SQLITE_API void sqlite3_result_text(
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel);
}
-SQLITE_API void sqlite3_result_text64(
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(
sqlite3_context *pCtx,
const char *z,
sqlite3_uint64 n,
@@ -67637,7 +69166,7 @@ SQLITE_API void sqlite3_result_text64(
}
}
#ifndef SQLITE_OMIT_UTF16
-SQLITE_API void sqlite3_result_text16(
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(
sqlite3_context *pCtx,
const void *z,
int n,
@@ -67646,7 +69175,7 @@ SQLITE_API void sqlite3_result_text16(
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
setResultStrOrError(pCtx, z, n, SQLITE_UTF16NATIVE, xDel);
}
-SQLITE_API void sqlite3_result_text16be(
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(
sqlite3_context *pCtx,
const void *z,
int n,
@@ -67655,7 +69184,7 @@ SQLITE_API void sqlite3_result_text16be(
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
setResultStrOrError(pCtx, z, n, SQLITE_UTF16BE, xDel);
}
-SQLITE_API void sqlite3_result_text16le(
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(
sqlite3_context *pCtx,
const void *z,
int n,
@@ -67665,17 +69194,20 @@ SQLITE_API void sqlite3_result_text16le(
setResultStrOrError(pCtx, z, n, SQLITE_UTF16LE, xDel);
}
#endif /* SQLITE_OMIT_UTF16 */
-SQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){
+SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
sqlite3VdbeMemCopy(pCtx->pOut, pValue);
}
-SQLITE_API void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){
+SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
sqlite3VdbeMemSetZeroBlob(pCtx->pOut, n);
}
-SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
pCtx->isError = errCode;
pCtx->fErrorOrAux = 1;
+#ifdef SQLITE_DEBUG
+ if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode;
+#endif
if( pCtx->pOut->flags & MEM_Null ){
sqlite3VdbeMemSetStr(pCtx->pOut, sqlite3ErrStr(errCode), -1,
SQLITE_UTF8, SQLITE_STATIC);
@@ -67683,7 +69215,7 @@ SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
}
/* Force an SQLITE_TOOBIG error. */
-SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context *pCtx){
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
pCtx->isError = SQLITE_TOOBIG;
pCtx->fErrorOrAux = 1;
@@ -67692,7 +69224,7 @@ SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){
}
/* An SQLITE_NOMEM error. */
-SQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context *pCtx){
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
sqlite3VdbeMemSetNull(pCtx->pOut);
pCtx->isError = SQLITE_NOMEM;
@@ -67711,7 +69243,10 @@ static int doWalCallbacks(sqlite3 *db){
for(i=0; i<db->nDb; i++){
Btree *pBt = db->aDb[i].pBt;
if( pBt ){
- int nEntry = sqlite3PagerWalCallback(sqlite3BtreePager(pBt));
+ int nEntry;
+ sqlite3BtreeEnter(pBt);
+ nEntry = sqlite3PagerWalCallback(sqlite3BtreePager(pBt));
+ sqlite3BtreeLeave(pBt);
if( db->xWalCallback && nEntry>0 && rc==SQLITE_OK ){
rc = db->xWalCallback(db->pWalArg, db, db->aDb[i].zName, nEntry);
}
@@ -67753,7 +69288,7 @@ static int sqlite3Step(Vdbe *p){
** or SQLITE_BUSY error.
*/
#ifdef SQLITE_OMIT_AUTORESET
- if( p->rc==SQLITE_BUSY || p->rc==SQLITE_LOCKED ){
+ if( (rc = p->rc&0xff)==SQLITE_BUSY || rc==SQLITE_LOCKED ){
sqlite3_reset((sqlite3_stmt*)p);
}else{
return SQLITE_MISUSE_BKPT;
@@ -67799,6 +69334,9 @@ static int sqlite3Step(Vdbe *p){
if( p->bIsReader ) db->nVdbeRead++;
p->pc = 0;
}
+#ifdef SQLITE_DEBUG
+ p->rcApp = SQLITE_OK;
+#endif
#ifndef SQLITE_OMIT_EXPLAIN
if( p->explain ){
rc = sqlite3VdbeList(p);
@@ -67843,7 +69381,7 @@ end_of_step:
assert( rc==SQLITE_ROW || rc==SQLITE_DONE || rc==SQLITE_ERROR
|| rc==SQLITE_BUSY || rc==SQLITE_MISUSE
);
- assert( p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE );
+ assert( (p->rc!=SQLITE_ROW && p->rc!=SQLITE_DONE) || p->rc==p->rcApp );
if( p->isPrepareV2 && rc!=SQLITE_ROW && rc!=SQLITE_DONE ){
/* If this statement was prepared using sqlite3_prepare_v2(), and an
** error has occurred, then return the error code in p->rc to the
@@ -67859,7 +69397,7 @@ end_of_step:
** sqlite3Step() to do most of the work. If a schema error occurs,
** call sqlite3Reprepare() and try again.
*/
-SQLITE_API int sqlite3_step(sqlite3_stmt *pStmt){
+SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt *pStmt){
int rc = SQLITE_OK; /* Result from sqlite3Step() */
int rc2 = SQLITE_OK; /* Result from sqlite3Reprepare() */
Vdbe *v = (Vdbe*)pStmt; /* the prepared statement */
@@ -67891,7 +69429,6 @@ SQLITE_API int sqlite3_step(sqlite3_stmt *pStmt){
** sqlite3_errmsg() and sqlite3_errcode().
*/
const char *zErr = (const char *)sqlite3_value_text(db->pErr);
- assert( zErr!=0 || db->mallocFailed );
sqlite3DbFree(db, v->zErrMsg);
if( !db->mallocFailed ){
v->zErrMsg = sqlite3DbStrDup(db, zErr);
@@ -67911,7 +69448,7 @@ SQLITE_API int sqlite3_step(sqlite3_stmt *pStmt){
** Extract the user data from a sqlite3_context structure and return a
** pointer to it.
*/
-SQLITE_API void *sqlite3_user_data(sqlite3_context *p){
+SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context *p){
assert( p && p->pFunc );
return p->pFunc->pUserData;
}
@@ -67926,22 +69463,32 @@ SQLITE_API void *sqlite3_user_data(sqlite3_context *p){
** sqlite3_create_function16() routines that originally registered the
** application defined function.
*/
-SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context *p){
assert( p && p->pFunc );
return p->pOut->db;
}
/*
-** Return the current time for a statement
+** Return the current time for a statement. If the current time
+** is requested more than once within the same run of a single prepared
+** statement, the exact same time is returned for each invocation regardless
+** of the amount of time that elapses between invocations. In other words,
+** the time returned is always the time of the first call.
*/
SQLITE_PRIVATE sqlite3_int64 sqlite3StmtCurrentTime(sqlite3_context *p){
- Vdbe *v = p->pVdbe;
int rc;
- if( v->iCurrentTime==0 ){
- rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, &v->iCurrentTime);
- if( rc ) v->iCurrentTime = 0;
+#ifndef SQLITE_ENABLE_STAT3_OR_STAT4
+ sqlite3_int64 *piTime = &p->pVdbe->iCurrentTime;
+ assert( p->pVdbe!=0 );
+#else
+ sqlite3_int64 iTime = 0;
+ sqlite3_int64 *piTime = p->pVdbe!=0 ? &p->pVdbe->iCurrentTime : &iTime;
+#endif
+ if( *piTime==0 ){
+ rc = sqlite3OsCurrentTimeInt64(p->pOut->db->pVfs, piTime);
+ if( rc ) *piTime = 0;
}
- return v->iCurrentTime;
+ return *piTime;
}
/*
@@ -67992,7 +69539,7 @@ static SQLITE_NOINLINE void *createAggContext(sqlite3_context *p, int nByte){
** context is allocated on the first call. Subsequent calls return the
** same context that was returned on prior calls.
*/
-SQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){
+SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context *p, int nByte){
assert( p && p->pFunc && p->pFunc->xStep );
assert( sqlite3_mutex_held(p->pOut->db->mutex) );
testcase( nByte<0 );
@@ -68007,10 +69554,15 @@ SQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){
** Return the auxiliary data pointer, if any, for the iArg'th argument to
** the user-function defined by pCtx.
*/
-SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
+SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
AuxData *pAuxData;
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
+#if SQLITE_ENABLE_STAT3_OR_STAT4
+ if( pCtx->pVdbe==0 ) return 0;
+#else
+ assert( pCtx->pVdbe!=0 );
+#endif
for(pAuxData=pCtx->pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
}
@@ -68023,7 +69575,7 @@ SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
** argument to the user-function defined by pCtx. Any previous value is
** deleted by calling the delete function specified when it was set.
*/
-SQLITE_API void sqlite3_set_auxdata(
+SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(
sqlite3_context *pCtx,
int iArg,
void *pAux,
@@ -68034,6 +69586,11 @@ SQLITE_API void sqlite3_set_auxdata(
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
if( iArg<0 ) goto failed;
+#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
+ if( pVdbe==0 ) goto failed;
+#else
+ assert( pVdbe!=0 );
+#endif
for(pAuxData=pVdbe->pAuxData; pAuxData; pAuxData=pAuxData->pNext){
if( pAuxData->iOp==pCtx->iOp && pAuxData->iArg==iArg ) break;
@@ -68073,7 +69630,7 @@ failed:
** implementations should keep their own counts within their aggregate
** context.
*/
-SQLITE_API int sqlite3_aggregate_count(sqlite3_context *p){
+SQLITE_API int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context *p){
assert( p && p->pMem && p->pFunc && p->pFunc->xStep );
return p->pMem->n;
}
@@ -68082,7 +69639,7 @@ SQLITE_API int sqlite3_aggregate_count(sqlite3_context *p){
/*
** Return the number of columns in the result set for the statement pStmt.
*/
-SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt){
+SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt){
Vdbe *pVm = (Vdbe *)pStmt;
return pVm ? pVm->nResColumn : 0;
}
@@ -68091,7 +69648,7 @@ SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt){
** Return the number of values available from the current row of the
** currently executing statement pStmt.
*/
-SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt){
+SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt){
Vdbe *pVm = (Vdbe *)pStmt;
if( pVm==0 || pVm->pResultSet==0 ) return 0;
return pVm->nResColumn;
@@ -68193,7 +69750,7 @@ static void columnMallocFailure(sqlite3_stmt *pStmt)
** The following routines are used to access elements of the current row
** in the result set.
*/
-SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt *pStmt, int i){
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt *pStmt, int i){
const void *val;
val = sqlite3_value_blob( columnMem(pStmt,i) );
/* Even though there is no encoding conversion, value_blob() might
@@ -68203,37 +69760,37 @@ SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt *pStmt, int i){
columnMallocFailure(pStmt);
return val;
}
-SQLITE_API int sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){
int val = sqlite3_value_bytes( columnMem(pStmt,i) );
columnMallocFailure(pStmt);
return val;
}
-SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){
int val = sqlite3_value_bytes16( columnMem(pStmt,i) );
columnMallocFailure(pStmt);
return val;
}
-SQLITE_API double sqlite3_column_double(sqlite3_stmt *pStmt, int i){
+SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt *pStmt, int i){
double val = sqlite3_value_double( columnMem(pStmt,i) );
columnMallocFailure(pStmt);
return val;
}
-SQLITE_API int sqlite3_column_int(sqlite3_stmt *pStmt, int i){
+SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt *pStmt, int i){
int val = sqlite3_value_int( columnMem(pStmt,i) );
columnMallocFailure(pStmt);
return val;
}
-SQLITE_API sqlite_int64 sqlite3_column_int64(sqlite3_stmt *pStmt, int i){
+SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt *pStmt, int i){
sqlite_int64 val = sqlite3_value_int64( columnMem(pStmt,i) );
columnMallocFailure(pStmt);
return val;
}
-SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt *pStmt, int i){
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt *pStmt, int i){
const unsigned char *val = sqlite3_value_text( columnMem(pStmt,i) );
columnMallocFailure(pStmt);
return val;
}
-SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt *pStmt, int i){
+SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt *pStmt, int i){
Mem *pOut = columnMem(pStmt, i);
if( pOut->flags&MEM_Static ){
pOut->flags &= ~MEM_Static;
@@ -68243,13 +69800,13 @@ SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt *pStmt, int i){
return (sqlite3_value *)pOut;
}
#ifndef SQLITE_OMIT_UTF16
-SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt *pStmt, int i){
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt *pStmt, int i){
const void *val = sqlite3_value_text16( columnMem(pStmt,i) );
columnMallocFailure(pStmt);
return val;
}
#endif /* SQLITE_OMIT_UTF16 */
-SQLITE_API int sqlite3_column_type(sqlite3_stmt *pStmt, int i){
+SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt *pStmt, int i){
int iType = sqlite3_value_type( columnMem(pStmt,i) );
columnMallocFailure(pStmt);
return iType;
@@ -68277,11 +69834,19 @@ static const void *columnName(
const void *(*xFunc)(Mem*),
int useType
){
- const void *ret = 0;
- Vdbe *p = (Vdbe *)pStmt;
+ const void *ret;
+ Vdbe *p;
int n;
- sqlite3 *db = p->db;
-
+ sqlite3 *db;
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( pStmt==0 ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
+ ret = 0;
+ p = (Vdbe *)pStmt;
+ db = p->db;
assert( db!=0 );
n = sqlite3_column_count(pStmt);
if( N<n && N>=0 ){
@@ -68305,12 +69870,12 @@ static const void *columnName(
** Return the name of the Nth column of the result set returned by SQL
** statement pStmt.
*/
-SQLITE_API const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt *pStmt, int N){
return columnName(
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_NAME);
}
#ifndef SQLITE_OMIT_UTF16
-SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt *pStmt, int N){
return columnName(
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_NAME);
}
@@ -68330,12 +69895,12 @@ SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){
** Return the column declaration type (if applicable) of the 'i'th column
** of the result set of SQL statement pStmt.
*/
-SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){
return columnName(
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DECLTYPE);
}
#ifndef SQLITE_OMIT_UTF16
-SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){
return columnName(
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DECLTYPE);
}
@@ -68348,12 +69913,12 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){
** NULL is returned if the result column is an expression or constant or
** anything else which is not an unambiguous reference to a database column.
*/
-SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){
return columnName(
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DATABASE);
}
#ifndef SQLITE_OMIT_UTF16
-SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){
return columnName(
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DATABASE);
}
@@ -68364,12 +69929,12 @@ SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N
** NULL is returned if the result column is an expression or constant or
** anything else which is not an unambiguous reference to a database column.
*/
-SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){
return columnName(
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_TABLE);
}
#ifndef SQLITE_OMIT_UTF16
-SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){
return columnName(
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_TABLE);
}
@@ -68380,12 +69945,12 @@ SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){
** NULL is returned if the result column is an expression or constant or
** anything else which is not an unambiguous reference to a database column.
*/
-SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){
return columnName(
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_COLUMN);
}
#ifndef SQLITE_OMIT_UTF16
-SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){
return columnName(
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_COLUMN);
}
@@ -68486,7 +70051,7 @@ static int bindText(
/*
** Bind a blob value to an SQL statement variable.
*/
-SQLITE_API int sqlite3_bind_blob(
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(
sqlite3_stmt *pStmt,
int i,
const void *zData,
@@ -68495,7 +70060,7 @@ SQLITE_API int sqlite3_bind_blob(
){
return bindText(pStmt, i, zData, nData, xDel, 0);
}
-SQLITE_API int sqlite3_bind_blob64(
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(
sqlite3_stmt *pStmt,
int i,
const void *zData,
@@ -68509,7 +70074,7 @@ SQLITE_API int sqlite3_bind_blob64(
return bindText(pStmt, i, zData, (int)nData, xDel, 0);
}
}
-SQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
int rc;
Vdbe *p = (Vdbe *)pStmt;
rc = vdbeUnbind(p, i);
@@ -68519,10 +70084,10 @@ SQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
}
return rc;
}
-SQLITE_API int sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){
return sqlite3_bind_int64(p, i, (i64)iValue);
}
-SQLITE_API int sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){
int rc;
Vdbe *p = (Vdbe *)pStmt;
rc = vdbeUnbind(p, i);
@@ -68532,7 +70097,7 @@ SQLITE_API int sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValu
}
return rc;
}
-SQLITE_API int sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
int rc;
Vdbe *p = (Vdbe*)pStmt;
rc = vdbeUnbind(p, i);
@@ -68541,7 +70106,7 @@ SQLITE_API int sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
}
return rc;
}
-SQLITE_API int sqlite3_bind_text(
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(
sqlite3_stmt *pStmt,
int i,
const char *zData,
@@ -68550,7 +70115,7 @@ SQLITE_API int sqlite3_bind_text(
){
return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8);
}
-SQLITE_API int sqlite3_bind_text64(
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(
sqlite3_stmt *pStmt,
int i,
const char *zData,
@@ -68567,7 +70132,7 @@ SQLITE_API int sqlite3_bind_text64(
}
}
#ifndef SQLITE_OMIT_UTF16
-SQLITE_API int sqlite3_bind_text16(
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(
sqlite3_stmt *pStmt,
int i,
const void *zData,
@@ -68577,7 +70142,7 @@ SQLITE_API int sqlite3_bind_text16(
return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE);
}
#endif /* SQLITE_OMIT_UTF16 */
-SQLITE_API int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){
int rc;
switch( sqlite3_value_type((sqlite3_value*)pValue) ){
case SQLITE_INTEGER: {
@@ -68608,7 +70173,7 @@ SQLITE_API int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_valu
}
return rc;
}
-SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
int rc;
Vdbe *p = (Vdbe *)pStmt;
rc = vdbeUnbind(p, i);
@@ -68623,7 +70188,7 @@ SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
** Return the number of wildcards that can be potentially bound to.
** This routine is added to support DBD::SQLite.
*/
-SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){
Vdbe *p = (Vdbe*)pStmt;
return p ? p->nVar : 0;
}
@@ -68634,7 +70199,7 @@ SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){
**
** The result is always UTF-8.
*/
-SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){
+SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){
Vdbe *p = (Vdbe*)pStmt;
if( p==0 || i<1 || i>p->nzVar ){
return 0;
@@ -68662,7 +70227,7 @@ SQLITE_PRIVATE int sqlite3VdbeParameterIndex(Vdbe *p, const char *zName, int nNa
}
return 0;
}
-SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){
return sqlite3VdbeParameterIndex((Vdbe*)pStmt, zName, sqlite3Strlen30(zName));
}
@@ -68696,7 +70261,7 @@ SQLITE_PRIVATE int sqlite3TransferBindings(sqlite3_stmt *pFromStmt, sqlite3_stmt
** an SQLITE_ERROR is returned. Nothing else can go wrong, so otherwise
** SQLITE_OK is returned.
*/
-SQLITE_API int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
+SQLITE_API int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
Vdbe *pFrom = (Vdbe*)pFromStmt;
Vdbe *pTo = (Vdbe*)pToStmt;
if( pFrom->nVar!=pTo->nVar ){
@@ -68718,7 +70283,7 @@ SQLITE_API int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *
** the first argument to the sqlite3_prepare() that was used to create
** the statement in the first place.
*/
-SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt *pStmt){
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt *pStmt){
return pStmt ? ((Vdbe*)pStmt)->db : 0;
}
@@ -68726,14 +70291,14 @@ SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt *pStmt){
** Return true if the prepared statement is guaranteed to not modify the
** database.
*/
-SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt){
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt){
return pStmt ? ((Vdbe*)pStmt)->readOnly : 1;
}
/*
** Return true if the prepared statement is in need of being reset.
*/
-SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt *pStmt){
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt *pStmt){
Vdbe *v = (Vdbe*)pStmt;
return v!=0 && v->pc>=0 && v->magic==VDBE_MAGIC_RUN;
}
@@ -68744,8 +70309,14 @@ SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt *pStmt){
** prepared statement for the database connection. Return NULL if there
** are no more.
*/
-SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){
+SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){
sqlite3_stmt *pNext;
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(pDb) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
sqlite3_mutex_enter(pDb->mutex);
if( pStmt==0 ){
pNext = (sqlite3_stmt*)pDb->pVdbe;
@@ -68759,13 +70330,89 @@ SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){
/*
** Return the value of a status counter for a prepared statement
*/
-SQLITE_API int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
Vdbe *pVdbe = (Vdbe*)pStmt;
- u32 v = pVdbe->aCounter[op];
+ u32 v;
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !pStmt ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
+ v = pVdbe->aCounter[op];
if( resetFlag ) pVdbe->aCounter[op] = 0;
return (int)v;
}
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
+/*
+** Return status data for a single loop within query pStmt.
+*/
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_scanstatus(
+ sqlite3_stmt *pStmt, /* Prepared statement being queried */
+ int idx, /* Index of loop to report on */
+ int iScanStatusOp, /* Which metric to return */
+ void *pOut /* OUT: Write the answer here */
+){
+ Vdbe *p = (Vdbe*)pStmt;
+ ScanStatus *pScan;
+ if( idx<0 || idx>=p->nScan ) return 1;
+ pScan = &p->aScan[idx];
+ switch( iScanStatusOp ){
+ case SQLITE_SCANSTAT_NLOOP: {
+ *(sqlite3_int64*)pOut = p->anExec[pScan->addrLoop];
+ break;
+ }
+ case SQLITE_SCANSTAT_NVISIT: {
+ *(sqlite3_int64*)pOut = p->anExec[pScan->addrVisit];
+ break;
+ }
+ case SQLITE_SCANSTAT_EST: {
+ double r = 1.0;
+ LogEst x = pScan->nEst;
+ while( x<100 ){
+ x += 10;
+ r *= 0.5;
+ }
+ *(double*)pOut = r*sqlite3LogEstToInt(x);
+ break;
+ }
+ case SQLITE_SCANSTAT_NAME: {
+ *(const char**)pOut = pScan->zName;
+ break;
+ }
+ case SQLITE_SCANSTAT_EXPLAIN: {
+ if( pScan->addrExplain ){
+ *(const char**)pOut = p->aOp[ pScan->addrExplain ].p4.z;
+ }else{
+ *(const char**)pOut = 0;
+ }
+ break;
+ }
+ case SQLITE_SCANSTAT_SELECTID: {
+ if( pScan->addrExplain ){
+ *(int*)pOut = p->aOp[ pScan->addrExplain ].p1;
+ }else{
+ *(int*)pOut = -1;
+ }
+ break;
+ }
+ default: {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+/*
+** Zero all counters associated with the sqlite3_stmt_scanstatus() data.
+*/
+SQLITE_API void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){
+ Vdbe *p = (Vdbe*)pStmt;
+ memset(p->anExec, 0, p->nOp * sizeof(i64));
+}
+#endif /* SQLITE_ENABLE_STMT_SCANSTATUS */
+
/************** End of vdbeapi.c *********************************************/
/************** Begin file vdbetrace.c ***************************************/
/*
@@ -69259,7 +70906,7 @@ static void applyAffinity(
** is appropriate. But only do the conversion if it is possible without
** loss of information and return the revised type of the argument.
*/
-SQLITE_API int sqlite3_value_numeric_type(sqlite3_value *pVal){
+SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value *pVal){
int eType = sqlite3_value_type(pVal);
if( eType==SQLITE_TEXT ){
Mem *pMem = (Mem*)pVal;
@@ -69651,6 +71298,9 @@ SQLITE_PRIVATE int sqlite3VdbeExec(
#endif
nVmStep++;
pOp = &aOp[pc];
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
+ if( p->anExec ) p->anExec[pc]++;
+#endif
/* Only allow tracing if SQLITE_DEBUG is defined.
*/
@@ -70055,7 +71705,7 @@ case OP_Real: { /* same as TK_FLOAT, out2-prerelease */
** Synopsis: r[P2]='P4'
**
** P4 points to a nul terminated UTF-8 string. This opcode is transformed
-** into a String before it is executed for the first time. During
+** into a String opcode before it is executed for the first time. During
** this transformation, the length of string P4 is computed and stored
** as the P1 parameter.
*/
@@ -70087,10 +71737,15 @@ case OP_String8: { /* same as TK_STRING, out2-prerelease */
/* Fall through to the next case, OP_String */
}
-/* Opcode: String P1 P2 * P4 *
+/* Opcode: String P1 P2 P3 P4 P5
** Synopsis: r[P2]='P4' (len=P1)
**
** The string value P4 of length P1 (bytes) is stored in register P2.
+**
+** If P5!=0 and the content of register P3 is greater than zero, then
+** the datatype of the register P2 is converted to BLOB. The content is
+** the same sequence of bytes, it is merely interpreted as a BLOB instead
+** of a string, as if it had been CAST.
*/
case OP_String: { /* out2-prerelease */
assert( pOp->p4.z!=0 );
@@ -70099,6 +71754,13 @@ case OP_String: { /* out2-prerelease */
pOut->n = pOp->p1;
pOut->enc = encoding;
UPDATE_MAX_BLOBSIZE(pOut);
+ if( pOp->p5 ){
+ assert( pOp->p3>0 );
+ assert( pOp->p3<=(p->nMem-p->nCursor) );
+ pIn3 = &aMem[pOp->p3];
+ assert( pIn3->flags & MEM_Int );
+ if( pIn3->u.i ) pOut->flags = MEM_Blob|MEM_Static|MEM_Term;
+ }
break;
}
@@ -70545,7 +72207,7 @@ arithmetic_result_is_null:
**
** The interface used by the implementation of the aforementioned functions
** to retrieve the collation sequence set by this opcode is not available
-** publicly, only to user functions defined in func.c.
+** publicly. Only built-in functions have access to this feature.
*/
case OP_CollSeq: {
assert( pOp->p4type==P4_COLLSEQ );
@@ -70948,11 +72610,15 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
testcase( pIn1->flags & MEM_Int );
testcase( pIn1->flags & MEM_Real );
sqlite3VdbeMemStringify(pIn1, encoding, 1);
+ testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
+ flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
}
if( (pIn3->flags & MEM_Str)==0 && (pIn3->flags & (MEM_Int|MEM_Real))!=0 ){
testcase( pIn3->flags & MEM_Int );
testcase( pIn3->flags & MEM_Real );
sqlite3VdbeMemStringify(pIn3, encoding, 1);
+ testcase( (flags3&MEM_Dyn) != (pIn3->flags&MEM_Dyn) );
+ flags3 = (pIn3->flags & ~MEM_TypeMask) | (flags3 & MEM_TypeMask);
}
}
assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
@@ -70989,7 +72655,9 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */
}
}
/* Undo any changes made by applyAffinity() to the input registers. */
+ assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) );
pIn1->flags = flags1;
+ assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) );
pIn3->flags = flags3;
break;
}
@@ -71676,7 +73344,10 @@ case OP_MakeRecord: {
nHdr += serial_type<=127 ? 1 : sqlite3VarintLen(serial_type);
}while( (--pRec)>=pData0 );
- /* Add the initial header varint and total the size */
+ /* EVIDENCE-OF: R-22564-11647 The header begins with a single varint
+ ** which determines the total number of bytes in the header. The varint
+ ** value is the size of the header in bytes including the size varint
+ ** itself. */
testcase( nHdr==126 );
testcase( nHdr==127 );
if( nHdr<=126 ){
@@ -71710,7 +73381,11 @@ case OP_MakeRecord: {
pRec = pData0;
do{
serial_type = pRec->uTemp;
+ /* EVIDENCE-OF: R-06529-47362 Following the size varint are one or more
+ ** additional varints, one per column. */
i += putVarint32(&zNewRecord[i], serial_type); /* serial type */
+ /* EVIDENCE-OF: R-64536-51728 The values for each column in the record
+ ** immediately follow the header. */
j += sqlite3VdbeSerialPut(&zNewRecord[j], pRec, serial_type); /* content */
}while( (++pRec)<=pLast );
assert( i==nHdr );
@@ -72083,7 +73758,12 @@ case OP_Transaction: {
p->nStmtDefImmCons = db->nDeferredImmCons;
}
- /* Gather the schema version number for checking */
+ /* Gather the schema version number for checking:
+ ** IMPLEMENTATION-OF: R-32195-19465 The schema version is used by SQLite
+ ** each time a query is executed to ensure that the internal cache of the
+ ** schema used when compiling the SQL query matches the schema of the
+ ** database against which the compiled query is actually executed.
+ */
sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&iMeta);
iGen = db->aDb[pOp->p1].pSchema->iGeneration;
}else{
@@ -72251,31 +73931,29 @@ case OP_SetCookie: { /* in3 */
** See also OpenRead.
*/
case OP_ReopenIdx: {
+ int nField;
+ KeyInfo *pKeyInfo;
+ int p2;
+ int iDb;
+ int wrFlag;
+ Btree *pX;
VdbeCursor *pCur;
+ Db *pDb;
- assert( pOp->p5==0 );
+ assert( pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );
assert( pOp->p4type==P4_KEYINFO );
pCur = p->apCsr[pOp->p1];
if( pCur && pCur->pgnoRoot==(u32)pOp->p2 ){
assert( pCur->iDb==pOp->p3 ); /* Guaranteed by the code generator */
- break;
+ goto open_cursor_set_hints;
}
/* If the cursor is not currently open or is open on a different
** index, then fall through into OP_OpenRead to force a reopen */
-}
case OP_OpenRead:
-case OP_OpenWrite: {
- int nField;
- KeyInfo *pKeyInfo;
- int p2;
- int iDb;
- int wrFlag;
- Btree *pX;
- VdbeCursor *pCur;
- Db *pDb;
+case OP_OpenWrite:
- assert( (pOp->p5&(OPFLAG_P2ISREG|OPFLAG_BULKCSR))==pOp->p5 );
- assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 );
+ assert( (pOp->p5&(OPFLAG_P2ISREG|OPFLAG_BULKCSR|OPFLAG_SEEKEQ))==pOp->p5 );
+ assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );
assert( p->bIsReader );
assert( pOp->opcode==OP_OpenRead || pOp->opcode==OP_ReopenIdx
|| p->readOnly==0 );
@@ -72338,14 +74016,17 @@ case OP_OpenWrite: {
pCur->pgnoRoot = p2;
rc = sqlite3BtreeCursor(pX, p2, wrFlag, pKeyInfo, pCur->pCursor);
pCur->pKeyInfo = pKeyInfo;
- assert( OPFLAG_BULKCSR==BTREE_BULKLOAD );
- sqlite3BtreeCursorHints(pCur->pCursor, (pOp->p5 & OPFLAG_BULKCSR));
-
/* Set the VdbeCursor.isTable variable. Previous versions of
** SQLite used to check if the root-page flags were sane at this point
** and report database corruption if they were not, but this check has
** since moved into the btree layer. */
pCur->isTable = pOp->p4type!=P4_KEYINFO;
+
+open_cursor_set_hints:
+ assert( OPFLAG_BULKCSR==BTREE_BULKLOAD );
+ assert( OPFLAG_SEEKEQ==BTREE_SEEK_EQ );
+ sqlite3BtreeCursorHints(pCur->pCursor,
+ (pOp->p5 & (OPFLAG_BULKCSR|OPFLAG_SEEKEQ)));
break;
}
@@ -72606,6 +74287,22 @@ case OP_SeekGT: { /* jump, in3 */
#ifdef SQLITE_DEBUG
pC->seekOp = pOp->opcode;
#endif
+
+ /* For a cursor with the BTREE_SEEK_EQ hint, only the OP_SeekGE and
+ ** OP_SeekLE opcodes are allowed, and these must be immediately followed
+ ** by an OP_IdxGT or OP_IdxLT opcode, respectively, with the same key.
+ */
+#ifdef SQLITE_DEBUG
+ if( sqlite3BtreeCursorHasHint(pC->pCursor, BTREE_SEEK_EQ) ){
+ assert( pOp->opcode==OP_SeekGE || pOp->opcode==OP_SeekLE );
+ assert( pOp[1].opcode==OP_IdxLT || pOp[1].opcode==OP_IdxGT );
+ assert( pOp[1].p1==pOp[0].p1 );
+ assert( pOp[1].p2==pOp[0].p2 );
+ assert( pOp[1].p3==pOp[0].p3 );
+ assert( pOp[1].p4.i==pOp[0].p4.i );
+ }
+#endif
+
if( pC->isTable ){
/* The input value in P3 might be of any type: integer, real, string,
** blob, or NULL. But it needs to be an integer before we can do
@@ -72845,10 +74542,10 @@ case OP_Found: { /* jump, in3 */
}else{
pIdxKey = sqlite3VdbeAllocUnpackedRecord(
pC->pKeyInfo, aTempRec, sizeof(aTempRec), &pFree
- );
+ );
if( pIdxKey==0 ) goto no_mem;
assert( pIn3->flags & MEM_Blob );
- assert( (pIn3->flags & MEM_Zero)==0 ); /* zeroblobs already expanded */
+ ExpandBlob(pIn3);
sqlite3VdbeRecordUnpack(pC->pKeyInfo, pIn3->n, pIn3->z, pIdxKey);
}
pIdxKey->default_rc = 0;
@@ -72856,8 +74553,8 @@ case OP_Found: { /* jump, in3 */
/* For the OP_NoConflict opcode, take the jump if any of the
** input fields are NULL, since any key with a NULL will not
** conflict */
- for(ii=0; ii<r.nField; ii++){
- if( r.aMem[ii].flags & MEM_Null ){
+ for(ii=0; ii<pIdxKey->nField; ii++){
+ if( pIdxKey->aMem[ii].flags & MEM_Null ){
pc = pOp->p2 - 1; VdbeBranchTaken(1,2);
break;
}
@@ -73542,9 +75239,9 @@ case OP_Sort: { /* jump */
**
** The next use of the Rowid or Column or Next instruction for P1
** will refer to the first entry in the database table or index.
-** If the table or index is empty and P2>0, then jump immediately to P2.
-** If P2 is 0 or if the table or index is not empty, fall through
-** to the following instruction.
+** If the table or index is empty, jump immediately to P2.
+** If the table or index is not empty, fall through to the following
+** instruction.
**
** This opcode leaves the cursor configured to move in forward order,
** from the beginning toward the end. In other words, the cursor is
@@ -73945,30 +75642,15 @@ case OP_IdxGE: { /* jump */
*/
case OP_Destroy: { /* out2-prerelease */
int iMoved;
- int iCnt;
- Vdbe *pVdbe;
int iDb;
assert( p->readOnly==0 );
-#ifndef SQLITE_OMIT_VIRTUALTABLE
- iCnt = 0;
- for(pVdbe=db->pVdbe; pVdbe; pVdbe = pVdbe->pNext){
- if( pVdbe->magic==VDBE_MAGIC_RUN && pVdbe->bIsReader
- && pVdbe->inVtabMethod<2 && pVdbe->pc>=0
- ){
- iCnt++;
- }
- }
-#else
- iCnt = db->nVdbeRead;
-#endif
pOut->flags = MEM_Null;
- if( iCnt>1 ){
+ if( db->nVdbeRead > db->nVDestroy+1 ){
rc = SQLITE_LOCKED;
p->errorAction = OE_Abort;
}else{
iDb = pOp->p3;
- assert( iCnt==1 );
assert( DbMaskTest(p->btreeMask, iDb) );
iMoved = 0; /* Not needed. Only to silence a warning. */
rc = sqlite3BtreeDropTable(db->aDb[iDb].pBt, pOp->p1, &iMoved);
@@ -74460,6 +76142,9 @@ case OP_Program: { /* jump */
pFrame->token = pProgram->token;
pFrame->aOnceFlag = p->aOnceFlag;
pFrame->nOnceFlag = p->nOnceFlag;
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
+ pFrame->anExec = p->anExec;
+#endif
pEnd = &VdbeFrameMem(pFrame)[pFrame->nChildMem];
for(pMem=VdbeFrameMem(pFrame); pMem!=pEnd; pMem++){
@@ -74477,6 +76162,7 @@ case OP_Program: { /* jump */
pFrame->pParent = p->pFrame;
pFrame->lastRowid = lastRowid;
pFrame->nChange = p->nChange;
+ pFrame->nDbChange = p->db->nChange;
p->nChange = 0;
p->pFrame = pFrame;
p->aMem = aMem = &VdbeFrameMem(pFrame)[-1];
@@ -74487,6 +76173,9 @@ case OP_Program: { /* jump */
p->nOp = pProgram->nOp;
p->aOnceFlag = (u8 *)&p->apCsr[p->nCursor];
p->nOnceFlag = pProgram->nOnce;
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
+ p->anExec = 0;
+#endif
pc = -1;
memset(p->aOnceFlag, 0, p->nOnceFlag);
@@ -74594,10 +76283,12 @@ case OP_MemMax: { /* in2 */
/* Opcode: IfPos P1 P2 * * *
** Synopsis: if r[P1]>0 goto P2
**
-** If the value of register P1 is 1 or greater, jump to P2.
+** Register P1 must contain an integer.
+** If the value of register P1 is 1 or greater, jump to P2 and
+** add the literal value P3 to register P1.
**
-** It is illegal to use this instruction on a register that does
-** not contain an integer. An assertion fault will result if you try.
+** If the initial value of register P1 is less than 1, then the
+** value is unchanged and control passes through to the next instruction.
*/
case OP_IfPos: { /* jump, in1 */
pIn1 = &aMem[pOp->p1];
@@ -74626,16 +76317,34 @@ case OP_IfNeg: { /* jump, in1 */
break;
}
-/* Opcode: IfZero P1 P2 P3 * *
-** Synopsis: r[P1]+=P3, if r[P1]==0 goto P2
+/* Opcode: IfNotZero P1 P2 P3 * *
+** Synopsis: if r[P1]!=0 then r[P1]+=P3, goto P2
**
-** The register P1 must contain an integer. Add literal P3 to the
-** value in register P1. If the result is exactly 0, jump to P2.
+** Register P1 must contain an integer. If the content of register P1 is
+** initially nonzero, then add P3 to P1 and jump to P2. If register P1 is
+** initially zero, leave it unchanged and fall through.
*/
-case OP_IfZero: { /* jump, in1 */
+case OP_IfNotZero: { /* jump, in1 */
pIn1 = &aMem[pOp->p1];
assert( pIn1->flags&MEM_Int );
- pIn1->u.i += pOp->p3;
+ VdbeBranchTaken(pIn1->u.i<0, 2);
+ if( pIn1->u.i ){
+ pIn1->u.i += pOp->p3;
+ pc = pOp->p2 - 1;
+ }
+ break;
+}
+
+/* Opcode: DecrJumpZero P1 P2 * * *
+** Synopsis: if (--r[P1])==0 goto P2
+**
+** Register P1 must hold an integer. Decrement the value in register P1
+** then jump to P2 if the new value is exactly zero.
+*/
+case OP_DecrJumpZero: { /* jump, in1 */
+ pIn1 = &aMem[pOp->p1];
+ assert( pIn1->flags&MEM_Int );
+ pIn1->u.i--;
VdbeBranchTaken(pIn1->u.i==0, 2);
if( pIn1->u.i==0 ){
pc = pOp->p2 - 1;
@@ -74643,6 +76352,24 @@ case OP_IfZero: { /* jump, in1 */
break;
}
+
+/* Opcode: JumpZeroIncr P1 P2 * * *
+** Synopsis: if (r[P1]++)==0 ) goto P2
+**
+** The register P1 must contain an integer. If register P1 is initially
+** zero, then jump to P2. Increment register P1 regardless of whether or
+** not the jump is taken.
+*/
+case OP_JumpZeroIncr: { /* jump, in1 */
+ pIn1 = &aMem[pOp->p1];
+ assert( pIn1->flags&MEM_Int );
+ VdbeBranchTaken(pIn1->u.i==0, 2);
+ if( (pIn1->u.i++)==0 ){
+ pc = pOp->p2 - 1;
+ }
+ break;
+}
+
/* Opcode: AggStep * P2 P3 P4 P5
** Synopsis: accum=r[P3] step(r[P2@P5])
**
@@ -74731,8 +76458,8 @@ case OP_AggFinal: {
/* Opcode: Checkpoint P1 P2 P3 * *
**
** Checkpoint database P1. This is a no-op if P1 is not currently in
-** WAL mode. Parameter P2 is one of SQLITE_CHECKPOINT_PASSIVE, FULL
-** or RESTART. Write 1 or 0 into mem[P3] if the checkpoint returns
+** WAL mode. Parameter P2 is one of SQLITE_CHECKPOINT_PASSIVE, FULL,
+** RESTART, or TRUNCATE. Write 1 or 0 into mem[P3] if the checkpoint returns
** SQLITE_BUSY or not, respectively. Write the number of pages in the
** WAL after the checkpoint into mem[P3+1] and the number of pages
** in the WAL that have been checkpointed after the checkpoint
@@ -74750,6 +76477,7 @@ case OP_Checkpoint: {
assert( pOp->p2==SQLITE_CHECKPOINT_PASSIVE
|| pOp->p2==SQLITE_CHECKPOINT_FULL
|| pOp->p2==SQLITE_CHECKPOINT_RESTART
+ || pOp->p2==SQLITE_CHECKPOINT_TRUNCATE
);
rc = sqlite3Checkpoint(db, pOp->p1, pOp->p2, &aRes[1], &aRes[2]);
if( rc==SQLITE_BUSY ){
@@ -74979,13 +76707,29 @@ case OP_VBegin: {
#endif /* SQLITE_OMIT_VIRTUALTABLE */
#ifndef SQLITE_OMIT_VIRTUALTABLE
-/* Opcode: VCreate P1 * * P4 *
+/* Opcode: VCreate P1 P2 * * *
**
-** P4 is the name of a virtual table in database P1. Call the xCreate method
-** for that table.
+** P2 is a register that holds the name of a virtual table in database
+** P1. Call the xCreate method for that table.
*/
case OP_VCreate: {
- rc = sqlite3VtabCallCreate(db, pOp->p1, pOp->p4.z, &p->zErrMsg);
+ Mem sMem; /* For storing the record being decoded */
+ const char *zTab; /* Name of the virtual table */
+
+ memset(&sMem, 0, sizeof(sMem));
+ sMem.db = db;
+ /* Because P2 is always a static string, it is impossible for the
+ ** sqlite3VdbeMemCopy() to fail */
+ assert( (aMem[pOp->p2].flags & MEM_Str)!=0 );
+ assert( (aMem[pOp->p2].flags & MEM_Static)!=0 );
+ rc = sqlite3VdbeMemCopy(&sMem, &aMem[pOp->p2]);
+ assert( rc==SQLITE_OK );
+ zTab = (const char*)sqlite3_value_text(&sMem);
+ assert( zTab || db->mallocFailed );
+ if( zTab ){
+ rc = sqlite3VtabCallCreate(db, pOp->p1, zTab, &p->zErrMsg);
+ }
+ sqlite3VdbeMemRelease(&sMem);
break;
}
#endif /* SQLITE_OMIT_VIRTUALTABLE */
@@ -74997,9 +76741,9 @@ case OP_VCreate: {
** of that table.
*/
case OP_VDestroy: {
- p->inVtabMethod = 2;
+ db->nVDestroy++;
rc = sqlite3VtabCallDestroy(db, pOp->p1, pOp->p4.z);
- p->inVtabMethod = 0;
+ db->nVDestroy--;
break;
}
#endif /* SQLITE_OMIT_VIRTUALTABLE */
@@ -75015,14 +76759,17 @@ case OP_VOpen: {
VdbeCursor *pCur;
sqlite3_vtab_cursor *pVtabCursor;
sqlite3_vtab *pVtab;
- sqlite3_module *pModule;
+ const sqlite3_module *pModule;
assert( p->bIsReader );
pCur = 0;
pVtabCursor = 0;
pVtab = pOp->p4.pVtab->pVtab;
- pModule = (sqlite3_module *)pVtab->pModule;
- assert(pVtab && pModule);
+ if( pVtab==0 || NEVER(pVtab->pModule==0) ){
+ rc = SQLITE_LOCKED;
+ break;
+ }
+ pModule = pVtab->pModule;
rc = pModule->xOpen(pVtab, &pVtabCursor);
sqlite3VtabImportErrmsg(p, pVtab);
if( SQLITE_OK==rc ){
@@ -75033,6 +76780,7 @@ case OP_VOpen: {
pCur = allocateCursor(p, pOp->p1, 0, -1, 0);
if( pCur ){
pCur->pVtabCursor = pVtabCursor;
+ pVtab->nRef++;
}else{
db->mallocFailed = 1;
pModule->xClose(pVtabCursor);
@@ -75098,9 +76846,7 @@ case OP_VFilter: { /* jump */
apArg[i] = &pArgc[i+1];
}
- p->inVtabMethod = 1;
rc = pModule->xFilter(pVtabCursor, iQuery, pOp->p4.z, nArg, apArg);
- p->inVtabMethod = 0;
sqlite3VtabImportErrmsg(p, pVtab);
if( rc==SQLITE_OK ){
res = pModule->xEof(pVtabCursor);
@@ -75190,9 +76936,7 @@ case OP_VNext: { /* jump */
** data is available) and the error code returned when xColumn or
** some other method is next invoked on the save virtual table cursor.
*/
- p->inVtabMethod = 1;
rc = pModule->xNext(pCur->pVtabCursor);
- p->inVtabMethod = 0;
sqlite3VtabImportErrmsg(p, pVtab);
if( rc==SQLITE_OK ){
res = pModule->xEof(pCur->pVtabCursor);
@@ -75267,7 +77011,7 @@ case OP_VRename: {
*/
case OP_VUpdate: {
sqlite3_vtab *pVtab;
- sqlite3_module *pModule;
+ const sqlite3_module *pModule;
int nArg;
int i;
sqlite_int64 rowid;
@@ -75279,7 +77023,11 @@ case OP_VUpdate: {
);
assert( p->readOnly==0 );
pVtab = pOp->p4.pVtab->pVtab;
- pModule = (sqlite3_module *)pVtab->pModule;
+ if( pVtab==0 || NEVER(pVtab->pModule==0) ){
+ rc = SQLITE_LOCKED;
+ break;
+ }
+ pModule = pVtab->pModule;
nArg = pOp->p2;
assert( pOp->p4type==P4_VTAB );
if( ALWAYS(pModule->xUpdate) ){
@@ -75626,7 +77374,7 @@ static int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){
/*
** Open a blob handle.
*/
-SQLITE_API int sqlite3_blob_open(
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
sqlite3* db, /* The database connection */
const char *zDb, /* The attached database containing the blob */
const char *zTable, /* The table containing the blob */
@@ -75675,8 +77423,18 @@ SQLITE_API int sqlite3_blob_open(
Parse *pParse = 0;
Incrblob *pBlob = 0;
- flags = !!flags; /* flags = (flags ? 1 : 0); */
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( ppBlob==0 ){
+ return SQLITE_MISUSE_BKPT;
+ }
+#endif
*ppBlob = 0;
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) || zTable==0 ){
+ return SQLITE_MISUSE_BKPT;
+ }
+#endif
+ flags = !!flags; /* flags = (flags ? 1 : 0); */
sqlite3_mutex_enter(db->mutex);
@@ -75853,7 +77611,7 @@ blob_open_out:
** Close a blob handle that was previously created using
** sqlite3_blob_open().
*/
-SQLITE_API int sqlite3_blob_close(sqlite3_blob *pBlob){
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *pBlob){
Incrblob *p = (Incrblob *)pBlob;
int rc;
sqlite3 *db;
@@ -75890,10 +77648,9 @@ static int blobReadWrite(
sqlite3_mutex_enter(db->mutex);
v = (Vdbe*)p->pStmt;
- if( n<0 || iOffset<0 || (iOffset+n)>p->nByte ){
+ if( n<0 || iOffset<0 || ((sqlite3_int64)iOffset+n)>p->nByte ){
/* Request is out of range. Return a transient error. */
rc = SQLITE_ERROR;
- sqlite3Error(db, SQLITE_ERROR);
}else if( v==0 ){
/* If there is no statement handle, then the blob-handle has
** already been invalidated. Return SQLITE_ABORT in this case.
@@ -75911,10 +77668,10 @@ static int blobReadWrite(
sqlite3VdbeFinalize(v);
p->pStmt = 0;
}else{
- db->errCode = rc;
v->rc = rc;
}
}
+ sqlite3Error(db, rc);
rc = sqlite3ApiExit(db, rc);
sqlite3_mutex_leave(db->mutex);
return rc;
@@ -75923,14 +77680,14 @@ static int blobReadWrite(
/*
** Read data from a blob handle.
*/
-SQLITE_API int sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){
return blobReadWrite(pBlob, z, n, iOffset, sqlite3BtreeData);
}
/*
** Write data to a blob handle.
*/
-SQLITE_API int sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int iOffset){
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int iOffset){
return blobReadWrite(pBlob, (void *)z, n, iOffset, sqlite3BtreePutData);
}
@@ -75940,7 +77697,7 @@ SQLITE_API int sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int
** The Incrblob.nByte field is fixed for the lifetime of the Incrblob
** so no mutex is required for access.
*/
-SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *pBlob){
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *pBlob){
Incrblob *p = (Incrblob *)pBlob;
return (p && p->pStmt) ? p->nByte : 0;
}
@@ -75955,7 +77712,7 @@ SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *pBlob){
** subsequent calls to sqlite3_blob_xxx() functions (except blob_close())
** immediately return SQLITE_ABORT.
*/
-SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){
int rc;
Incrblob *p = (Incrblob *)pBlob;
sqlite3 *db;
@@ -76091,7 +77848,7 @@ SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){
** The sorter is running in multi-threaded mode if (a) the library was built
** with pre-processor symbol SQLITE_MAX_WORKER_THREADS set to a value greater
** than zero, and (b) worker threads have been enabled at runtime by calling
-** sqlite3_config(SQLITE_CONFIG_WORKER_THREADS, ...).
+** "PRAGMA threads=N" with some value of N greater than 0.
**
** When Rewind() is called, any data remaining in memory is flushed to a
** final PMA. So at this point the data is stored in some number of sorted
@@ -76137,6 +77894,13 @@ SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){
#endif
/*
+** Hard-coded maximum amount of data to accumulate in memory before flushing
+** to a level 0 PMA. The purpose of this limit is to prevent various integer
+** overflows. 512MiB.
+*/
+#define SQLITE_MAX_PMASZ (1<<29)
+
+/*
** Private objects used by the sorter
*/
typedef struct MergeEngine MergeEngine; /* Merge PMAs together */
@@ -76430,9 +78194,6 @@ struct SorterRecord {
*/
#define SRVAL(p) ((void*)((SorterRecord*)(p) + 1))
-/* The minimum PMA size is set to this value multiplied by the database
-** page size in bytes. */
-#define SORTER_MIN_WORKING 10
/* Maximum number of PMAs that a single MergeEngine can merge */
#define SORTER_MAX_MERGE_COUNT 16
@@ -76831,16 +78592,15 @@ SQLITE_PRIVATE int sqlite3VdbeSorterInit(
}
if( !sqlite3TempInMemory(db) ){
- pSorter->mnPmaSize = SORTER_MIN_WORKING * pgsz;
+ u32 szPma = sqlite3GlobalConfig.szPma;
+ pSorter->mnPmaSize = szPma * pgsz;
mxCache = db->aDb[0].pSchema->cache_size;
- if( mxCache<SORTER_MIN_WORKING ) mxCache = SORTER_MIN_WORKING;
- pSorter->mxPmaSize = mxCache * pgsz;
-
- /* If the application has not configure scratch memory using
- ** SQLITE_CONFIG_SCRATCH then we assume it is OK to do large memory
- ** allocations. If scratch memory has been configured, then assume
- ** large memory allocations should be avoided to prevent heap
- ** fragmentation.
+ if( mxCache<(int)szPma ) mxCache = (int)szPma;
+ pSorter->mxPmaSize = MIN((i64)mxCache*pgsz, SQLITE_MAX_PMASZ);
+
+ /* EVIDENCE-OF: R-26747-61719 When the application provides any amount of
+ ** scratch memory using SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary
+ ** large heap allocations.
*/
if( sqlite3GlobalConfig.pScratch==0 ){
assert( pSorter->iMemory==0 );
@@ -77114,12 +78874,12 @@ SQLITE_PRIVATE void sqlite3VdbeSorterClose(sqlite3 *db, VdbeCursor *pCsr){
*/
static void vdbeSorterExtendFile(sqlite3 *db, sqlite3_file *pFd, i64 nByte){
if( nByte<=(i64)(db->nMaxSorterMmap) && pFd->pMethods->iVersion>=3 ){
- int rc = sqlite3OsTruncate(pFd, nByte);
- if( rc==SQLITE_OK ){
- void *p = 0;
- sqlite3OsFetch(pFd, 0, (int)nByte, &p);
- sqlite3OsUnfetch(pFd, 0, p);
- }
+ void *p = 0;
+ int chunksize = 4*1024;
+ sqlite3OsFileControlHint(pFd, SQLITE_FCNTL_CHUNK_SIZE, &chunksize);
+ sqlite3OsFileControlHint(pFd, SQLITE_FCNTL_SIZE_HINT, &nByte);
+ sqlite3OsFetch(pFd, 0, (int)nByte, &p);
+ sqlite3OsUnfetch(pFd, 0, p);
}
}
#else
@@ -77137,6 +78897,7 @@ static int vdbeSorterOpenTempFile(
sqlite3_file **ppFd
){
int rc;
+ if( sqlite3FaultSim(202) ) return SQLITE_IOERR_ACCESS;
rc = sqlite3OsOpenMalloc(db->pVfs, 0, ppFd,
SQLITE_OPEN_TEMP_JOURNAL |
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE |
@@ -78400,6 +80161,7 @@ SQLITE_PRIVATE int sqlite3VdbeSorterNext(sqlite3 *db, const VdbeCursor *pCsr, in
}else
#endif
/*if( !pSorter->bUseThreads )*/ {
+ assert( pSorter->pMerger!=0 );
assert( pSorter->pMerger->pTask==(&pSorter->aTask[0]) );
rc = vdbeMergeEngineStep(pSorter->pMerger, pbEof);
}
@@ -79212,7 +80974,7 @@ SQLITE_PRIVATE int sqlite3WalkSelect(Walker *pWalker, Select *p){
** is a helper function - a callback for the tree walker.
*/
static int incrAggDepth(Walker *pWalker, Expr *pExpr){
- if( pExpr->op==TK_AGG_FUNCTION ) pExpr->op2 += pWalker->u.i;
+ if( pExpr->op==TK_AGG_FUNCTION ) pExpr->op2 += pWalker->u.n;
return WRC_Continue;
}
static void incrAggFunctionDepth(Expr *pExpr, int N){
@@ -79220,7 +80982,7 @@ static void incrAggFunctionDepth(Expr *pExpr, int N){
Walker w;
memset(&w, 0, sizeof(w));
w.xExprCallback = incrAggDepth;
- w.u.i = N;
+ w.u.n = N;
sqlite3WalkExpr(&w, pExpr);
}
}
@@ -79431,9 +81193,10 @@ static int lookupName(
testcase( pNC->ncFlags & NC_PartIdx );
testcase( pNC->ncFlags & NC_IsCheck );
if( (pNC->ncFlags & (NC_PartIdx|NC_IsCheck))!=0 ){
- /* Silently ignore database qualifiers inside CHECK constraints and partial
- ** indices. Do not raise errors because that might break legacy and
- ** because it does not hurt anything to just ignore the database name. */
+ /* Silently ignore database qualifiers inside CHECK constraints and
+ ** partial indices. Do not raise errors because that might break
+ ** legacy and because it does not hurt anything to just ignore the
+ ** database name. */
zDb = 0;
}else{
for(i=0; i<db->nDb; i++){
@@ -79504,6 +81267,11 @@ static int lookupName(
if( pMatch ){
pExpr->iTable = pMatch->iCursor;
pExpr->pTab = pMatch->pTab;
+ /* RIGHT JOIN not (yet) supported */
+ assert( (pMatch->jointype & JT_RIGHT)==0 );
+ if( (pMatch->jointype & JT_LEFT)!=0 ){
+ ExprSetProperty(pExpr, EP_CanBeNull);
+ }
pSchema = pExpr->pTab->pSchema;
}
} /* if( pSrcList ) */
@@ -79768,7 +81536,7 @@ static int exprProbability(Expr *p){
sqlite3AtoF(p->u.zToken, &r, sqlite3Strlen30(p->u.zToken), SQLITE_UTF8);
assert( r>=0.0 );
if( r>1.0 ) return -1;
- return (int)(r*1000.0);
+ return (int)(r*134217728.0);
}
/*
@@ -79821,7 +81589,8 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
pExpr->affinity = SQLITE_AFF_INTEGER;
break;
}
-#endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT) && !defined(SQLITE_OMIT_SUBQUERY) */
+#endif /* defined(SQLITE_ENABLE_UPDATE_DELETE_LIMIT)
+ && !defined(SQLITE_OMIT_SUBQUERY) */
/* A lone identifier is the name of a column.
*/
@@ -79886,21 +81655,22 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
if( n==2 ){
pExpr->iTable = exprProbability(pList->a[1].pExpr);
if( pExpr->iTable<0 ){
- sqlite3ErrorMsg(pParse, "second argument to likelihood() must be a "
- "constant between 0.0 and 1.0");
+ sqlite3ErrorMsg(pParse,
+ "second argument to likelihood() must be a "
+ "constant between 0.0 and 1.0");
pNC->nErr++;
}
}else{
- /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is equivalent to
- ** likelihood(X, 0.0625).
- ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is short-hand for
- ** likelihood(X,0.0625).
- ** EVIDENCE-OF: R-36850-34127 The likely(X) function is short-hand for
- ** likelihood(X,0.9375).
- ** EVIDENCE-OF: R-53436-40973 The likely(X) function is equivalent to
- ** likelihood(X,0.9375). */
+ /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is
+ ** equivalent to likelihood(X, 0.0625).
+ ** EVIDENCE-OF: R-01283-11636 The unlikely(X) function is
+ ** short-hand for likelihood(X,0.0625).
+ ** EVIDENCE-OF: R-36850-34127 The likely(X) function is short-hand
+ ** for likelihood(X,0.9375).
+ ** EVIDENCE-OF: R-53436-40973 The likely(X) function is equivalent
+ ** to likelihood(X,0.9375). */
/* TUNING: unlikely() probability is 0.0625. likely() is 0.9375 */
- pExpr->iTable = pDef->zName[0]=='u' ? 62 : 938;
+ pExpr->iTable = pDef->zName[0]=='u' ? 8388608 : 125829120;
}
}
#ifndef SQLITE_OMIT_AUTHORIZATION
@@ -79915,7 +81685,9 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
return WRC_Prune;
}
#endif
- if( pDef->funcFlags & SQLITE_FUNC_CONSTANT ) ExprSetProperty(pExpr,EP_Constant);
+ if( pDef->funcFlags & SQLITE_FUNC_CONSTANT ){
+ ExprSetProperty(pExpr,EP_ConstFunc);
+ }
}
if( is_agg && (pNC->ncFlags & NC_AllowAgg)==0 ){
sqlite3ErrorMsg(pParse, "misuse of aggregate function %.*s()", nId,zId);
@@ -80226,7 +81998,8 @@ SQLITE_PRIVATE int sqlite3ResolveOrderGroupBy(
resolveOutOfRangeError(pParse, zType, i+1, pEList->nExpr);
return 1;
}
- resolveAlias(pParse, pEList, pItem->u.x.iOrderByCol-1, pItem->pExpr, zType,0);
+ resolveAlias(pParse, pEList, pItem->u.x.iOrderByCol-1, pItem->pExpr,
+ zType,0);
}
}
return 0;
@@ -80359,6 +82132,20 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
sqlite3ResolveExprNames(&sNC, p->pOffset) ){
return WRC_Abort;
}
+
+ /* If the SF_Converted flags is set, then this Select object was
+ ** was created by the convertCompoundSelectToSubquery() function.
+ ** In this case the ORDER BY clause (p->pOrderBy) should be resolved
+ ** as if it were part of the sub-query, not the parent. This block
+ ** moves the pOrderBy down to the sub-query. It will be moved back
+ ** after the names have been resolved. */
+ if( p->selFlags & SF_Converted ){
+ Select *pSub = p->pSrc->a[0].pSelect;
+ assert( p->pSrc->nSrc==1 && isCompound==0 && p->pOrderBy );
+ assert( pSub->pPrior && pSub->pOrderBy==0 );
+ pSub->pOrderBy = p->pOrderBy;
+ p->pOrderBy = 0;
+ }
/* Recursively resolve names in all subqueries
*/
@@ -80441,6 +82228,17 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
sNC.pNext = 0;
sNC.ncFlags |= NC_AllowAgg;
+ /* If this is a converted compound query, move the ORDER BY clause from
+ ** the sub-query back to the parent query. At this point each term
+ ** within the ORDER BY clause has been transformed to an integer value.
+ ** These integers will be replaced by copies of the corresponding result
+ ** set expressions by the call to resolveOrderGroupBy() below. */
+ if( p->selFlags & SF_Converted ){
+ Select *pSub = p->pSrc->a[0].pSelect;
+ p->pOrderBy = pSub->pOrderBy;
+ pSub->pOrderBy = 0;
+ }
+
/* Process the ORDER BY clause for singleton SELECT statements.
** The ORDER BY clause for compounds SELECT statements is handled
** below, after all of the result-sets for all of the elements of
@@ -80716,10 +82514,11 @@ SQLITE_PRIVATE char sqlite3ExprAffinity(Expr *pExpr){
SQLITE_PRIVATE Expr *sqlite3ExprAddCollateToken(
Parse *pParse, /* Parsing context */
Expr *pExpr, /* Add the "COLLATE" clause to this expression */
- const Token *pCollName /* Name of collating sequence */
+ const Token *pCollName, /* Name of collating sequence */
+ int dequote /* True to dequote pCollName */
){
if( pCollName->n>0 ){
- Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, 1);
+ Expr *pNew = sqlite3ExprAlloc(pParse->db, TK_COLLATE, pCollName, dequote);
if( pNew ){
pNew->pLeft = pExpr;
pNew->flags |= EP_Collate|EP_Skip;
@@ -80733,7 +82532,7 @@ SQLITE_PRIVATE Expr *sqlite3ExprAddCollateString(Parse *pParse, Expr *pExpr, con
assert( zC!=0 );
s.z = zC;
s.n = sqlite3Strlen30(s.z);
- return sqlite3ExprAddCollateToken(pParse, pExpr, &s);
+ return sqlite3ExprAddCollateToken(pParse, pExpr, &s, 0);
}
/*
@@ -80779,9 +82578,9 @@ SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){
pColl = sqlite3GetCollSeq(pParse, ENC(db), 0, p->u.zToken);
break;
}
- if( p->pTab!=0
- && (op==TK_AGG_COLUMN || op==TK_COLUMN
+ if( (op==TK_AGG_COLUMN || op==TK_COLUMN
|| op==TK_REGISTER || op==TK_TRIGGER)
+ && p->pTab!=0
){
/* op==TK_REGISTER && p->pTab!=0 happens when pExpr was originally
** a TK_COLUMN but was previously evaluated and cached in a register */
@@ -80793,10 +82592,25 @@ SQLITE_PRIVATE CollSeq *sqlite3ExprCollSeq(Parse *pParse, Expr *pExpr){
break;
}
if( p->flags & EP_Collate ){
- if( ALWAYS(p->pLeft) && (p->pLeft->flags & EP_Collate)!=0 ){
+ if( p->pLeft && (p->pLeft->flags & EP_Collate)!=0 ){
p = p->pLeft;
}else{
- p = p->pRight;
+ Expr *pNext = p->pRight;
+ /* The Expr.x union is never used at the same time as Expr.pRight */
+ assert( p->x.pList==0 || p->pRight==0 );
+ /* p->flags holds EP_Collate and p->pLeft->flags does not. And
+ ** p->x.pSelect cannot. So if p->x.pLeft exists, it must hold at
+ ** least one EP_Collate. Thus the following two ALWAYS. */
+ if( p->x.pList!=0 && ALWAYS(!ExprHasProperty(p, EP_xIsSelect)) ){
+ int i;
+ for(i=0; ALWAYS(i<p->x.pList->nExpr); i++){
+ if( ExprHasProperty(p->x.pList->a[i].pExpr, EP_Collate) ){
+ pNext = p->x.pList->a[i].pExpr;
+ break;
+ }
+ }
+ }
+ p = pNext;
}
}else{
break;
@@ -81002,6 +82816,9 @@ static void heightOfSelect(Select *p, int *pnHeight){
** Expr.pSelect member has a height of 1. Any other expression
** has a height equal to the maximum height of any other
** referenced Expr plus one.
+**
+** Also propagate EP_Propagate flags up from Expr.x.pList to Expr.flags,
+** if appropriate.
*/
static void exprSetHeight(Expr *p){
int nHeight = 0;
@@ -81009,8 +82826,9 @@ static void exprSetHeight(Expr *p){
heightOfExpr(p->pRight, &nHeight);
if( ExprHasProperty(p, EP_xIsSelect) ){
heightOfSelect(p->x.pSelect, &nHeight);
- }else{
+ }else if( p->x.pList ){
heightOfExprList(p->x.pList, &nHeight);
+ p->flags |= EP_Propagate & sqlite3ExprListFlags(p->x.pList);
}
p->nHeight = nHeight + 1;
}
@@ -81019,8 +82837,12 @@ static void exprSetHeight(Expr *p){
** Set the Expr.nHeight variable using the exprSetHeight() function. If
** the height is greater than the maximum allowed expression depth,
** leave an error in pParse.
+**
+** Also propagate all EP_Propagate flags from the Expr.x.pList into
+** Expr.flags.
*/
-SQLITE_PRIVATE void sqlite3ExprSetHeight(Parse *pParse, Expr *p){
+SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){
+ if( pParse->nErr ) return;
exprSetHeight(p);
sqlite3ExprCheckHeight(pParse, p->nHeight);
}
@@ -81034,8 +82856,17 @@ SQLITE_PRIVATE int sqlite3SelectExprHeight(Select *p){
heightOfSelect(p, &nHeight);
return nHeight;
}
-#else
- #define exprSetHeight(y)
+#else /* ABOVE: Height enforcement enabled. BELOW: Height enforcement off */
+/*
+** Propagate all EP_Propagate flags from the Expr.x.pList into
+** Expr.flags.
+*/
+SQLITE_PRIVATE void sqlite3ExprSetHeightAndFlags(Parse *pParse, Expr *p){
+ if( p && p->x.pList && !ExprHasProperty(p, EP_xIsSelect) ){
+ p->flags |= EP_Propagate & sqlite3ExprListFlags(p->x.pList);
+ }
+}
+#define exprSetHeight(y)
#endif /* SQLITE_MAX_EXPR_DEPTH>0 */
/*
@@ -81137,11 +82968,11 @@ SQLITE_PRIVATE void sqlite3ExprAttachSubtrees(
}else{
if( pRight ){
pRoot->pRight = pRight;
- pRoot->flags |= EP_Collate & pRight->flags;
+ pRoot->flags |= EP_Propagate & pRight->flags;
}
if( pLeft ){
pRoot->pLeft = pLeft;
- pRoot->flags |= EP_Collate & pLeft->flags;
+ pRoot->flags |= EP_Propagate & pLeft->flags;
}
exprSetHeight(pRoot);
}
@@ -81162,7 +82993,7 @@ SQLITE_PRIVATE Expr *sqlite3PExpr(
const Token *pToken /* Argument token */
){
Expr *p;
- if( op==TK_AND && pLeft && pRight ){
+ if( op==TK_AND && pLeft && pRight && pParse->nErr==0 ){
/* Take advantage of short-circuit false optimization for AND */
p = sqlite3ExprAnd(pParse->db, pLeft, pRight);
}else{
@@ -81241,7 +83072,7 @@ SQLITE_PRIVATE Expr *sqlite3ExprFunction(Parse *pParse, ExprList *pList, Token *
}
pNew->x.pList = pList;
assert( !ExprHasProperty(pNew, EP_xIsSelect) );
- sqlite3ExprSetHeight(pParse, pNew);
+ sqlite3ExprSetHeightAndFlags(pParse, pNew);
return pNew;
}
@@ -81857,20 +83688,39 @@ SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3 *db, ExprList *pList){
}
/*
-** These routines are Walker callbacks. Walker.u.pi is a pointer
-** to an integer. These routines are checking an expression to see
-** if it is a constant. Set *Walker.u.i to 0 if the expression is
-** not constant.
+** Return the bitwise-OR of all Expr.flags fields in the given
+** ExprList.
+*/
+SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList *pList){
+ int i;
+ u32 m = 0;
+ if( pList ){
+ for(i=0; i<pList->nExpr; i++){
+ m |= pList->a[i].pExpr->flags;
+ }
+ }
+ return m;
+}
+
+/*
+** These routines are Walker callbacks used to check expressions to
+** see if they are "constant" for some definition of constant. The
+** Walker.eCode value determines the type of "constant" we are looking
+** for.
**
** These callback routines are used to implement the following:
**
-** sqlite3ExprIsConstant() pWalker->u.i==1
-** sqlite3ExprIsConstantNotJoin() pWalker->u.i==2
-** sqlite3ExprIsConstantOrFunction() pWalker->u.i==3 or 4
+** sqlite3ExprIsConstant() pWalker->eCode==1
+** sqlite3ExprIsConstantNotJoin() pWalker->eCode==2
+** sqlite3ExprRefOneTableOnly() pWalker->eCode==3
+** sqlite3ExprIsConstantOrFunction() pWalker->eCode==4 or 5
+**
+** In all cases, the callbacks set Walker.eCode=0 and abort if the expression
+** is found to not be a constant.
**
** The sqlite3ExprIsConstantOrFunction() is used for evaluating expressions
-** in a CREATE TABLE statement. The Walker.u.i value is 4 when parsing
-** an existing schema and 3 when processing a new statement. A bound
+** in a CREATE TABLE statement. The Walker.eCode value is 5 when parsing
+** an existing schema and 4 when processing a new statement. A bound
** parameter raises an error for new statements, but is silently converted
** to NULL for existing schemas. This allows sqlite_master tables that
** contain a bound parameter because they were generated by older versions
@@ -81879,23 +83729,25 @@ SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3 *db, ExprList *pList){
*/
static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
- /* If pWalker->u.i is 2 then any term of the expression that comes from
- ** the ON or USING clauses of a join disqualifies the expression
+ /* If pWalker->eCode is 2 then any term of the expression that comes from
+ ** the ON or USING clauses of a left join disqualifies the expression
** from being considered constant. */
- if( pWalker->u.i==2 && ExprHasProperty(pExpr, EP_FromJoin) ){
- pWalker->u.i = 0;
+ if( pWalker->eCode==2 && ExprHasProperty(pExpr, EP_FromJoin) ){
+ pWalker->eCode = 0;
return WRC_Abort;
}
switch( pExpr->op ){
/* Consider functions to be constant if all their arguments are constant
- ** and either pWalker->u.i==3 or 4 or the function as the SQLITE_FUNC_CONST
- ** flag. */
+ ** and either pWalker->eCode==4 or 5 or the function has the
+ ** SQLITE_FUNC_CONST flag. */
case TK_FUNCTION:
- if( pWalker->u.i>=3 || ExprHasProperty(pExpr,EP_Constant) ){
+ if( pWalker->eCode>=4 || ExprHasProperty(pExpr,EP_ConstFunc) ){
return WRC_Continue;
+ }else{
+ pWalker->eCode = 0;
+ return WRC_Abort;
}
- /* Fall through */
case TK_ID:
case TK_COLUMN:
case TK_AGG_FUNCTION:
@@ -81904,18 +83756,22 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
testcase( pExpr->op==TK_COLUMN );
testcase( pExpr->op==TK_AGG_FUNCTION );
testcase( pExpr->op==TK_AGG_COLUMN );
- pWalker->u.i = 0;
- return WRC_Abort;
+ if( pWalker->eCode==3 && pExpr->iTable==pWalker->u.iCur ){
+ return WRC_Continue;
+ }else{
+ pWalker->eCode = 0;
+ return WRC_Abort;
+ }
case TK_VARIABLE:
- if( pWalker->u.i==4 ){
+ if( pWalker->eCode==5 ){
/* Silently convert bound parameters that appear inside of CREATE
** statements into a NULL when parsing the CREATE statement text out
** of the sqlite_master table */
pExpr->op = TK_NULL;
- }else if( pWalker->u.i==3 ){
+ }else if( pWalker->eCode==4 ){
/* A bound parameter in a CREATE statement that originates from
** sqlite3_prepare() causes an error */
- pWalker->u.i = 0;
+ pWalker->eCode = 0;
return WRC_Abort;
}
/* Fall through */
@@ -81927,21 +83783,22 @@ static int exprNodeIsConstant(Walker *pWalker, Expr *pExpr){
}
static int selectNodeIsConstant(Walker *pWalker, Select *NotUsed){
UNUSED_PARAMETER(NotUsed);
- pWalker->u.i = 0;
+ pWalker->eCode = 0;
return WRC_Abort;
}
-static int exprIsConst(Expr *p, int initFlag){
+static int exprIsConst(Expr *p, int initFlag, int iCur){
Walker w;
memset(&w, 0, sizeof(w));
- w.u.i = initFlag;
+ w.eCode = initFlag;
w.xExprCallback = exprNodeIsConstant;
w.xSelectCallback = selectNodeIsConstant;
+ w.u.iCur = iCur;
sqlite3WalkExpr(&w, p);
- return w.u.i;
+ return w.eCode;
}
/*
-** Walk an expression tree. Return 1 if the expression is constant
+** Walk an expression tree. Return non-zero if the expression is constant
** and 0 if it involves variables or function calls.
**
** For the purposes of this function, a double-quoted string (ex: "abc")
@@ -81949,21 +83806,31 @@ static int exprIsConst(Expr *p, int initFlag){
** a constant.
*/
SQLITE_PRIVATE int sqlite3ExprIsConstant(Expr *p){
- return exprIsConst(p, 1);
+ return exprIsConst(p, 1, 0);
}
/*
-** Walk an expression tree. Return 1 if the expression is constant
+** Walk an expression tree. Return non-zero if the expression is constant
** that does no originate from the ON or USING clauses of a join.
** Return 0 if it involves variables or function calls or terms from
** an ON or USING clause.
*/
SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr *p){
- return exprIsConst(p, 2);
+ return exprIsConst(p, 2, 0);
+}
+
+/*
+** Walk an expression tree. Return non-zero if the expression constant
+** for any single row of the table with cursor iCur. In other words, the
+** expression must not refer to any non-deterministic function nor any
+** table other than iCur.
+*/
+SQLITE_PRIVATE int sqlite3ExprIsTableConstant(Expr *p, int iCur){
+ return exprIsConst(p, 3, iCur);
}
/*
-** Walk an expression tree. Return 1 if the expression is constant
+** Walk an expression tree. Return non-zero if the expression is constant
** or a function call with constant arguments. Return and 0 if there
** are any variables.
**
@@ -81973,7 +83840,7 @@ SQLITE_PRIVATE int sqlite3ExprIsConstantNotJoin(Expr *p){
*/
SQLITE_PRIVATE int sqlite3ExprIsConstantOrFunction(Expr *p, u8 isInit){
assert( isInit==0 || isInit==1 );
- return exprIsConst(p, 3+isInit);
+ return exprIsConst(p, 4+isInit, 0);
}
/*
@@ -82040,7 +83907,8 @@ SQLITE_PRIVATE int sqlite3ExprCanBeNull(const Expr *p){
return 0;
case TK_COLUMN:
assert( p->pTab!=0 );
- return p->iColumn>=0 && p->pTab->aCol[p->iColumn].notNull==0;
+ return ExprHasProperty(p, EP_CanBeNull) ||
+ (p->iColumn>=0 && p->pTab->aCol[p->iColumn].notNull==0);
default:
return 1;
}
@@ -82881,7 +84749,8 @@ SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse *pParse, int iTab, int iCol, int
int idxLru;
struct yColCache *p;
- assert( iReg>0 ); /* Register numbers are always positive */
+ /* Unless an error has occurred, register numbers are always positive. */
+ assert( iReg>0 || pParse->nErr || pParse->db->mallocFailed );
assert( iCol>=-1 && iCol<32768 ); /* Finite column numbers */
/* The SQLITE_ColumnCache flag disables the column cache. This is used
@@ -83629,7 +85498,10 @@ SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target)
#ifndef SQLITE_OMIT_FLOATING_POINT
/* If the column has REAL affinity, it may currently be stored as an
- ** integer. Use OP_RealAffinity to make sure it is really real. */
+ ** integer. Use OP_RealAffinity to make sure it is really real.
+ **
+ ** EVIDENCE-OF: R-60985-57662 SQLite will convert the value back to
+ ** floating point when extracting it from the record. */
if( pExpr->iColumn>=0
&& pTab->aCol[pExpr->iColumn].affinity==SQLITE_AFF_REAL
){
@@ -84691,10 +86563,11 @@ static int exprSrcCount(Walker *pWalker, Expr *pExpr){
int i;
struct SrcCount *p = pWalker->u.pSrcCount;
SrcList *pSrc = p->pSrc;
- for(i=0; i<pSrc->nSrc; i++){
+ int nSrc = pSrc ? pSrc->nSrc : 0;
+ for(i=0; i<nSrc; i++){
if( pExpr->iTable==pSrc->a[i].iCursor ) break;
}
- if( i<pSrc->nSrc ){
+ if( i<nSrc ){
p->nThis++;
}else{
p->nOther++;
@@ -85684,7 +87557,10 @@ SQLITE_PRIVATE void sqlite3AlterFinishAddColumn(Parse *pParse, Token *pColDef){
*/
if( pDflt ){
sqlite3_value *pVal = 0;
- if( sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, &pVal) ){
+ int rc;
+ rc = sqlite3ValueFromExpr(db, pDflt, SQLITE_UTF8, SQLITE_AFF_NONE, &pVal);
+ assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
+ if( rc!=SQLITE_OK ){
db->mallocFailed = 1;
return;
}
@@ -86272,7 +88148,7 @@ static void statInit(
p->mxSample = mxSample;
p->nPSample = (tRowcnt)(sqlite3_value_int64(argv[2])/(mxSample/3+1) + 1);
p->current.anLt = &p->current.anEq[nColUp];
- p->iPrn = nCol*0x689e962d ^ sqlite3_value_int(argv[2])*0xd0944565;
+ p->iPrn = 0x689e962d*(u32)nCol ^ 0xd0944565*(u32)sqlite3_value_int(argv[2]);
/* Set up the Stat4Accum.a[] and aBest[] arrays */
p->a = (struct Stat4Sample*)&p->current.anLt[nColUp];
@@ -87281,23 +89157,28 @@ static void decodeIntArray(
if( *z==' ' ) z++;
}
#ifndef SQLITE_ENABLE_STAT3_OR_STAT4
- assert( pIndex!=0 );
+ assert( pIndex!=0 ); {
#else
- if( pIndex )
+ if( pIndex ){
#endif
- while( z[0] ){
- if( sqlite3_strglob("unordered*", z)==0 ){
- pIndex->bUnordered = 1;
- }else if( sqlite3_strglob("sz=[0-9]*", z)==0 ){
- pIndex->szIdxRow = sqlite3LogEst(sqlite3Atoi(z+3));
- }
+ pIndex->bUnordered = 0;
+ pIndex->noSkipScan = 0;
+ while( z[0] ){
+ if( sqlite3_strglob("unordered*", z)==0 ){
+ pIndex->bUnordered = 1;
+ }else if( sqlite3_strglob("sz=[0-9]*", z)==0 ){
+ pIndex->szIdxRow = sqlite3LogEst(sqlite3Atoi(z+3));
+ }else if( sqlite3_strglob("noskipscan*", z)==0 ){
+ pIndex->noSkipScan = 1;
+ }
#ifdef SQLITE_ENABLE_COSTMULT
- else if( sqlite3_strglob("costmult=[0-9]*",z)==0 ){
- pIndex->pTable->costMult = sqlite3LogEst(sqlite3Atoi(z+9));
- }
+ else if( sqlite3_strglob("costmult=[0-9]*",z)==0 ){
+ pIndex->pTable->costMult = sqlite3LogEst(sqlite3Atoi(z+9));
+ }
#endif
- while( z[0]!=0 && z[0]!=' ' ) z++;
- while( z[0]==' ' ) z++;
+ while( z[0]!=0 && z[0]!=' ' ) z++;
+ while( z[0]==' ' ) z++;
+ }
}
}
@@ -87415,7 +89296,7 @@ static void initAvgEq(Index *pIdx){
i64 nSum100 = 0; /* Number of terms contributing to sumEq */
i64 nDist100; /* Number of distinct values in index */
- if( pIdx->aiRowEst==0 || pIdx->aiRowEst[iCol+1]==0 ){
+ if( !pIdx->aiRowEst || iCol>=pIdx->nKeyCol || pIdx->aiRowEst[iCol+1]==0 ){
nRow = pFinal->anLt[iCol];
nDist100 = (i64)100 * pFinal->anDLt[iCol];
nSample--;
@@ -87423,6 +89304,7 @@ static void initAvgEq(Index *pIdx){
nRow = pIdx->aiRowEst[0];
nDist100 = ((i64)100 * pIdx->aiRowEst[0]) / pIdx->aiRowEst[iCol+1];
}
+ pIdx->nRowEst0 = nRow;
/* Set nSum to the number of distinct (iCol+1) field prefixes that
** occur in the stat4 table for this index. Set sumEq to the sum of
@@ -87684,7 +89566,7 @@ SQLITE_PRIVATE int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
/* Load the statistics from the sqlite_stat4 table. */
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
- if( rc==SQLITE_OK ){
+ if( rc==SQLITE_OK && OptimizationEnabled(db, SQLITE_Stat34) ){
int lookasideEnabled = db->lookaside.bEnabled;
db->lookaside.bEnabled = 0;
rc = loadStat4(db, sInfo.zDatabase);
@@ -87859,6 +89741,7 @@ static void attachFunc(
"attached databases must use the same text encoding as main database");
rc = SQLITE_ERROR;
}
+ sqlite3BtreeEnter(aNew->pBt);
pPager = sqlite3BtreePager(aNew->pBt);
sqlite3PagerLockingMode(pPager, db->dfltLockMode);
sqlite3BtreeSecureDelete(aNew->pBt,
@@ -87866,6 +89749,7 @@ static void attachFunc(
#ifndef SQLITE_OMIT_PAGER_PRAGMAS
sqlite3BtreeSetPagerFlags(aNew->pBt, 3 | (db->flags & PAGER_FLAGS_MASK));
#endif
+ sqlite3BtreeLeave(aNew->pBt);
}
aNew->safety_level = 3;
aNew->zName = sqlite3DbStrDup(db, zName);
@@ -87898,7 +89782,7 @@ static void attachFunc(
case SQLITE_NULL:
/* No key specified. Use the key from the main database */
sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
- if( nKey>0 || sqlite3BtreeGetReserve(db->aDb[0].pBt)>0 ){
+ if( nKey>0 || sqlite3BtreeGetOptimalReserve(db->aDb[0].pBt)>0 ){
rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
}
break;
@@ -88361,11 +90245,14 @@ SQLITE_PRIVATE int sqlite3FixTriggerStep(
** Setting the auth function to NULL disables this hook. The default
** setting of the auth function is NULL.
*/
-SQLITE_API int sqlite3_set_authorizer(
+SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
sqlite3 *db,
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
void *pArg
){
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
+#endif
sqlite3_mutex_enter(db->mutex);
db->xAuth = (sqlite3_xauth)xAuth;
db->pAuthArg = pArg;
@@ -88860,7 +90747,7 @@ SQLITE_PRIVATE int sqlite3UserAuthTable(const char *zTable){
SQLITE_PRIVATE Table *sqlite3FindTable(sqlite3 *db, const char *zName, const char *zDatabase){
Table *p = 0;
int i;
- assert( zName!=0 );
+
/* All mutexes are required for schema access. Make sure we hold them. */
assert( zDatabase!=0 || sqlite3BtreeHoldsAllMutexes(db) );
#if SQLITE_USER_AUTHENTICATION
@@ -88984,7 +90871,6 @@ static void freeIndex(sqlite3 *db, Index *p){
#ifndef SQLITE_OMIT_ANALYZE
sqlite3DeleteIndexSamples(db, p);
#endif
- if( db==0 || db->pnBytesFreed==0 ) sqlite3KeyInfoUnref(p->pKeyInfo);
sqlite3ExprDelete(db, p->pPartIdxWhere);
sqlite3DbFree(db, p->zColAff);
if( p->isResized ) sqlite3DbFree(db, p->azColl);
@@ -90263,16 +92149,32 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
pTab->iPKey = -1;
}else{
pPk = sqlite3PrimaryKeyIndex(pTab);
+ /*
+ ** Remove all redundant columns from the PRIMARY KEY. For example, change
+ ** "PRIMARY KEY(a,b,a,b,c,b,c,d)" into just "PRIMARY KEY(a,b,c,d)". Later
+ ** code assumes the PRIMARY KEY contains no repeated columns.
+ */
+ for(i=j=1; i<pPk->nKeyCol; i++){
+ if( hasColumn(pPk->aiColumn, j, pPk->aiColumn[i]) ){
+ pPk->nColumn--;
+ }else{
+ pPk->aiColumn[j++] = pPk->aiColumn[i];
+ }
+ }
+ pPk->nKeyCol = j;
}
pPk->isCovering = 1;
assert( pPk!=0 );
nPk = pPk->nKeyCol;
- /* Make sure every column of the PRIMARY KEY is NOT NULL */
- for(i=0; i<nPk; i++){
- pTab->aCol[pPk->aiColumn[i]].notNull = 1;
+ /* Make sure every column of the PRIMARY KEY is NOT NULL. (Except,
+ ** do not enforce this for imposter tables.) */
+ if( !db->init.imposterTable ){
+ for(i=0; i<nPk; i++){
+ pTab->aCol[pPk->aiColumn[i]].notNull = 1;
+ }
+ pPk->uniqNotNull = 1;
}
- pPk->uniqNotNull = 1;
/* The root page of the PRIMARY KEY is the table root page */
pPk->tnum = pTab->tnum;
@@ -91721,6 +93623,7 @@ SQLITE_PRIVATE Index *sqlite3CreateIndex(
pIdx->onError = pIndex->onError;
}
}
+ pRet = pIdx;
goto exit_create_index;
}
}
@@ -92739,40 +94642,31 @@ SQLITE_PRIVATE void sqlite3Reindex(Parse *pParse, Token *pName1, Token *pName2){
** when it has finished using it.
*/
SQLITE_PRIVATE KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){
+ int i;
+ int nCol = pIdx->nColumn;
+ int nKey = pIdx->nKeyCol;
+ KeyInfo *pKey;
if( pParse->nErr ) return 0;
-#ifndef SQLITE_OMIT_SHARED_CACHE
- if( pIdx->pKeyInfo && pIdx->pKeyInfo->db!=pParse->db ){
- sqlite3KeyInfoUnref(pIdx->pKeyInfo);
- pIdx->pKeyInfo = 0;
+ if( pIdx->uniqNotNull ){
+ pKey = sqlite3KeyInfoAlloc(pParse->db, nKey, nCol-nKey);
+ }else{
+ pKey = sqlite3KeyInfoAlloc(pParse->db, nCol, 0);
}
-#endif
- if( pIdx->pKeyInfo==0 ){
- int i;
- int nCol = pIdx->nColumn;
- int nKey = pIdx->nKeyCol;
- KeyInfo *pKey;
- if( pIdx->uniqNotNull ){
- pKey = sqlite3KeyInfoAlloc(pParse->db, nKey, nCol-nKey);
- }else{
- pKey = sqlite3KeyInfoAlloc(pParse->db, nCol, 0);
+ if( pKey ){
+ assert( sqlite3KeyInfoIsWriteable(pKey) );
+ for(i=0; i<nCol; i++){
+ char *zColl = pIdx->azColl[i];
+ assert( zColl!=0 );
+ pKey->aColl[i] = strcmp(zColl,"BINARY")==0 ? 0 :
+ sqlite3LocateCollSeq(pParse, zColl);
+ pKey->aSortOrder[i] = pIdx->aSortOrder[i];
}
- if( pKey ){
- assert( sqlite3KeyInfoIsWriteable(pKey) );
- for(i=0; i<nCol; i++){
- char *zColl = pIdx->azColl[i];
- assert( zColl!=0 );
- pKey->aColl[i] = strcmp(zColl,"BINARY")==0 ? 0 :
- sqlite3LocateCollSeq(pParse, zColl);
- pKey->aSortOrder[i] = pIdx->aSortOrder[i];
- }
- if( pParse->nErr ){
- sqlite3KeyInfoUnref(pKey);
- }else{
- pIdx->pKeyInfo = pKey;
- }
+ if( pParse->nErr ){
+ sqlite3KeyInfoUnref(pKey);
+ pKey = 0;
}
}
- return sqlite3KeyInfoRef(pIdx->pKeyInfo);
+ return pKey;
}
#ifndef SQLITE_OMIT_CTE
@@ -93516,7 +95410,7 @@ SQLITE_PRIVATE Expr *sqlite3LimitWhere(
pInClause->x.pSelect = pSelect;
pInClause->flags |= EP_xIsSelect;
- sqlite3ExprSetHeight(pParse, pInClause);
+ sqlite3ExprSetHeightAndFlags(pParse, pInClause);
return pInClause;
/* something went wrong. clean up anything allocated. */
@@ -93553,8 +95447,8 @@ SQLITE_PRIVATE void sqlite3DeleteFrom(
WhereInfo *pWInfo; /* Information about the WHERE clause */
Index *pIdx; /* For looping over indices of the table */
int iTabCur; /* Cursor number for the table */
- int iDataCur; /* VDBE cursor for the canonical data source */
- int iIdxCur; /* Cursor number of the first index */
+ int iDataCur = 0; /* VDBE cursor for the canonical data source */
+ int iIdxCur = 0; /* Cursor number of the first index */
int nIdx; /* Number of indices */
sqlite3 *db; /* Main database structure */
AuthContext sContext; /* Authorization context */
@@ -94189,7 +96083,9 @@ SQLITE_PRIVATE void sqlite3ResolvePartIdxLabel(Parse *pParse, int iLabel){
** Return the collating function associated with a function.
*/
static CollSeq *sqlite3GetFuncCollSeq(sqlite3_context *context){
- VdbeOp *pOp = &context->pVdbe->aOp[context->iOp-1];
+ VdbeOp *pOp;
+ assert( context->pVdbe!=0 );
+ pOp = &context->pVdbe->aOp[context->iOp-1];
assert( pOp->opcode==OP_CollSeq );
assert( pOp->p4type==P4_COLLSEQ );
return pOp->p4.pColl;
@@ -94324,8 +96220,8 @@ static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
default: {
/* Because sqlite3_value_double() returns 0.0 if the argument is not
** something that can be converted into a number, we have:
- ** IMP: R-57326-31541 Abs(X) return 0.0 if X is a string or blob that
- ** cannot be converted to a numeric value.
+ ** IMP: R-01992-00519 Abs(X) returns 0.0 if X is a string or blob
+ ** that cannot be converted to a numeric value.
*/
double rVal = sqlite3_value_double(argv[0]);
if( rVal<0 ) rVal = -rVal;
@@ -94458,6 +96354,14 @@ static void substrFunc(
}
}
}
+#ifdef SQLITE_SUBSTR_COMPATIBILITY
+ /* If SUBSTR_COMPATIBILITY is defined then substr(X,0,N) work the same as
+ ** as substr(X,1,N) - it returns the first N characters of X. This
+ ** is essentially a back-out of the bug-fix in check-in [5fc125d362df4b8]
+ ** from 2009-02-02 for compatibility of applications that exploited the
+ ** old buggy behavior. */
+ if( p1==0 ) p1 = 1; /* <rdar://problem/6778339> */
+#endif
if( argc==3 ){
p2 = sqlite3_value_int(argv[2]);
if( p2<0 ){
@@ -94919,7 +96823,7 @@ static int patternCompare(
/*
** The sqlite3_strglob() interface.
*/
-SQLITE_API int sqlite3_strglob(const char *zGlobPattern, const char *zString){
+SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlobPattern, const char *zString){
return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, 0)==0;
}
@@ -95809,6 +97713,11 @@ SQLITE_PRIVATE void sqlite3RegisterLikeFunctions(sqlite3 *db, int caseSensitive)
** then set aWc[0] through aWc[2] to the wildcard characters and
** return TRUE. If the function is not a LIKE-style function then
** return FALSE.
+**
+** *pIsNocase is set to true if uppercase and lowercase are equivalent for
+** the function (default for LIKE). If the function makes the distinction
+** between uppercase and lowercase (as does GLOB) then *pIsNocase is set to
+** false.
*/
SQLITE_PRIVATE int sqlite3IsLikeFunction(sqlite3 *db, Expr *pExpr, int *pIsNocase, char *aWc){
FuncDef *pDef;
@@ -96393,7 +98302,7 @@ static void fkLookupParent(
OE_Abort, 0, P4_STATIC, P5_ConstraintFK);
}else{
if( nIncr>0 && pFKey->isDeferred==0 ){
- sqlite3ParseToplevel(pParse)->mayAbort = 1;
+ sqlite3MayAbort(pParse);
}
sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);
}
@@ -96465,6 +98374,10 @@ static Expr *exprTableColumn(
** code for an SQL UPDATE operation, this function may be called twice -
** once to "delete" the old row and once to "insert" the new row.
**
+** Parameter nIncr is passed -1 when inserting a row (as this may decrease
+** the number of FK violations in the db) or +1 when deleting one (as this
+** may increase the number of FK constraint problems).
+**
** The code generated by this function scans through the rows in the child
** table that correspond to the parent table row being deleted or inserted.
** For each child row found, one of the following actions is taken:
@@ -96581,13 +98494,9 @@ static void fkScanChildren(
sqlite3ResolveExprNames(&sNameContext, pWhere);
/* Create VDBE to loop through the entries in pSrc that match the WHERE
- ** clause. If the constraint is not deferred, throw an exception for
- ** each row found. Otherwise, for deferred constraints, increment the
- ** deferred constraint counter by nIncr for each row selected. */
+ ** clause. For each row found, increment either the deferred or immediate
+ ** foreign key constraint counter. */
pWInfo = sqlite3WhereBegin(pParse, pSrc, pWhere, 0, 0, 0, 0);
- if( nIncr>0 && pFKey->isDeferred==0 ){
- sqlite3ParseToplevel(pParse)->mayAbort = 1;
- }
sqlite3VdbeAddOp2(v, OP_FkCounter, pFKey->isDeferred, nIncr);
if( pWInfo ){
sqlite3WhereEnd(pWInfo);
@@ -96767,6 +98676,24 @@ static int fkParentIsModified(
}
/*
+** Return true if the parser passed as the first argument is being
+** used to code a trigger that is really a "SET NULL" action belonging
+** to trigger pFKey.
+*/
+static int isSetNullAction(Parse *pParse, FKey *pFKey){
+ Parse *pTop = sqlite3ParseToplevel(pParse);
+ if( pTop->pTriggerPrg ){
+ Trigger *p = pTop->pTriggerPrg->pTrigger;
+ if( (p==pFKey->apTrigger[0] && pFKey->aAction[0]==OE_SetNull)
+ || (p==pFKey->apTrigger[1] && pFKey->aAction[1]==OE_SetNull)
+ ){
+ return 1;
+ }
+ }
+ return 0;
+}
+
+/*
** This function is called when inserting, deleting or updating a row of
** table pTab to generate VDBE code to perform foreign key constraint
** processing for the operation.
@@ -96818,7 +98745,7 @@ SQLITE_PRIVATE void sqlite3FkCheck(
int *aiCol;
int iCol;
int i;
- int isIgnore = 0;
+ int bIgnore = 0;
if( aChange
&& sqlite3_stricmp(pTab->zName, pFKey->zTo)!=0
@@ -96877,7 +98804,7 @@ SQLITE_PRIVATE void sqlite3FkCheck(
int rcauth;
char *zCol = pTo->aCol[pIdx ? pIdx->aiColumn[i] : pTo->iPKey].zName;
rcauth = sqlite3AuthReadCol(pParse, pTo->zName, zCol, iDb);
- isIgnore = (rcauth==SQLITE_IGNORE);
+ bIgnore = (rcauth==SQLITE_IGNORE);
}
#endif
}
@@ -96892,12 +98819,18 @@ SQLITE_PRIVATE void sqlite3FkCheck(
/* A row is being removed from the child table. Search for the parent.
** If the parent does not exist, removing the child row resolves an
** outstanding foreign key constraint violation. */
- fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regOld, -1,isIgnore);
+ fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regOld, -1, bIgnore);
}
- if( regNew!=0 ){
+ if( regNew!=0 && !isSetNullAction(pParse, pFKey) ){
/* A row is being added to the child table. If a parent row cannot
- ** be found, adding the child row has violated the FK constraint. */
- fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regNew, +1,isIgnore);
+ ** be found, adding the child row has violated the FK constraint.
+ **
+ ** If this operation is being performed as part of a trigger program
+ ** that is actually a "SET NULL" action belonging to this very
+ ** foreign key, then omit this scan altogether. As all child key
+ ** values are guaranteed to be NULL, it is not possible for adding
+ ** this row to cause an FK violation. */
+ fkLookupParent(pParse, iDb, pTo, pIdx, pFKey, aiCol, regNew, +1, bIgnore);
}
sqlite3DbFree(db, aiFree);
@@ -96918,8 +98851,8 @@ SQLITE_PRIVATE void sqlite3FkCheck(
&& !pParse->pToplevel && !pParse->isMultiWrite
){
assert( regOld==0 && regNew!=0 );
- /* Inserting a single row into a parent table cannot cause an immediate
- ** foreign key violation. So do nothing in this case. */
+ /* Inserting a single row into a parent table cannot cause (or fix)
+ ** an immediate foreign key violation. So do nothing in this case. */
continue;
}
@@ -96943,13 +98876,28 @@ SQLITE_PRIVATE void sqlite3FkCheck(
fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regNew, -1);
}
if( regOld!=0 ){
- /* If there is a RESTRICT action configured for the current operation
- ** on the parent table of this FK, then throw an exception
- ** immediately if the FK constraint is violated, even if this is a
- ** deferred trigger. That's what RESTRICT means. To defer checking
- ** the constraint, the FK should specify NO ACTION (represented
- ** using OE_None). NO ACTION is the default. */
+ int eAction = pFKey->aAction[aChange!=0];
fkScanChildren(pParse, pSrc, pTab, pIdx, pFKey, aiCol, regOld, 1);
+ /* If this is a deferred FK constraint, or a CASCADE or SET NULL
+ ** action applies, then any foreign key violations caused by
+ ** removing the parent key will be rectified by the action trigger.
+ ** So do not set the "may-abort" flag in this case.
+ **
+ ** Note 1: If the FK is declared "ON UPDATE CASCADE", then the
+ ** may-abort flag will eventually be set on this statement anyway
+ ** (when this function is called as part of processing the UPDATE
+ ** within the action trigger).
+ **
+ ** Note 2: At first glance it may seem like SQLite could simply omit
+ ** all OP_FkCounter related scans when either CASCADE or SET NULL
+ ** applies. The trouble starts if the CASCADE or SET NULL action
+ ** trigger causes other triggers or action rules attached to the
+ ** child table to fire. In these cases the fk constraint counters
+ ** might be set incorrectly if any OP_FkCounter related scans are
+ ** omitted. */
+ if( !pFKey->isDeferred && eAction!=OE_Cascade && eAction!=OE_SetNull ){
+ sqlite3MayAbort(pParse);
+ }
}
pItem->zName = 0;
sqlite3SrcListDelete(db, pSrc);
@@ -99370,7 +101318,7 @@ static int xferOptimization(
** argument to xCallback(). If xCallback=NULL then no callback
** is invoked, even for queries.
*/
-SQLITE_API int sqlite3_exec(
+SQLITE_API int SQLITE_STDCALL sqlite3_exec(
sqlite3 *db, /* The database on which the SQL executes */
const char *zSql, /* The SQL to be executed */
sqlite3_callback xCallback, /* Invoke this callback routine */
@@ -100043,7 +101991,6 @@ struct sqlite3_api_routines {
# define sqlite3_column_table_name16 0
# define sqlite3_column_origin_name 0
# define sqlite3_column_origin_name16 0
-# define sqlite3_table_column_metadata 0
#endif
#ifdef SQLITE_OMIT_AUTHORIZATION
@@ -100566,7 +102513,7 @@ static int sqlite3LoadExtension(
db->aExtension[db->nExtension++] = handle;
return SQLITE_OK;
}
-SQLITE_API int sqlite3_load_extension(
+SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
sqlite3 *db, /* Load the extension into this database connection */
const char *zFile, /* Name of the shared library containing extension */
const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */
@@ -100597,7 +102544,7 @@ SQLITE_PRIVATE void sqlite3CloseExtensions(sqlite3 *db){
** Enable or disable extension loading. Extension loading is disabled by
** default so as not to open security holes in older applications.
*/
-SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff){
sqlite3_mutex_enter(db->mutex);
if( onoff ){
db->flags |= SQLITE_LoadExtension;
@@ -100654,7 +102601,7 @@ static SQLITE_WSD struct sqlite3AutoExtList {
** Register a statically linked extension that is automatically
** loaded by every new database connection.
*/
-SQLITE_API int sqlite3_auto_extension(void (*xInit)(void)){
+SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xInit)(void)){
int rc = SQLITE_OK;
#ifndef SQLITE_OMIT_AUTOINIT
rc = sqlite3_initialize();
@@ -100699,7 +102646,7 @@ SQLITE_API int sqlite3_auto_extension(void (*xInit)(void)){
** Return 1 if xInit was found on the list and removed. Return 0 if xInit
** was not on the list.
*/
-SQLITE_API int sqlite3_cancel_auto_extension(void (*xInit)(void)){
+SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xInit)(void)){
#if SQLITE_THREADSAFE
sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
@@ -100722,7 +102669,7 @@ SQLITE_API int sqlite3_cancel_auto_extension(void (*xInit)(void)){
/*
** Reset the automatic extension loading mechanism.
*/
-SQLITE_API void sqlite3_reset_auto_extension(void){
+SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void){
#ifndef SQLITE_OMIT_AUTOINIT
if( sqlite3_initialize()==SQLITE_OK )
#endif
@@ -100804,11 +102751,18 @@ SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){
#endif
/***************************************************************************
-** The next block of code, including the PragTyp_XXXX macro definitions and
-** the aPragmaName[] object is composed of generated code. DO NOT EDIT.
-**
-** To add new pragmas, edit the code in ../tool/mkpragmatab.tcl and rerun
-** that script. Then copy/paste the output in place of the following:
+** The "pragma.h" include file is an automatically generated file that
+** that includes the PragType_XXXX macro definitions and the aPragmaName[]
+** object. This ensures that the aPragmaName[] table is arranged in
+** lexicographical order to facility a binary search of the pragma name.
+** Do not edit pragma.h directly. Edit and rerun the script in at
+** ../tool/mkpragmatab.tcl. */
+/************** Include pragma.h in the middle of pragma.c *******************/
+/************** Begin file pragma.h ******************************************/
+/* DO NOT EDIT!
+** This file is automatically generated by the script at
+** ../tool/mkpragmatab.tcl. To update the set of pragmas, edit
+** that script and rerun it.
*/
#define PragTyp_HEADER_VALUE 0
#define PragTyp_AUTO_VACUUM 1
@@ -100853,6 +102807,7 @@ SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){
#define PragTyp_LOCK_STATUS 40
#define PragTyp_PARSER_TRACE 41
#define PragFlag_NeedSchema 0x01
+#define PragFlag_ReadOnly 0x02
static const struct sPragmaNames {
const char *const zName; /* Name of pragma */
u8 ePragTyp; /* PragTyp_XXX value */
@@ -100869,7 +102824,7 @@ static const struct sPragmaNames {
{ /* zName: */ "application_id",
/* ePragTyp: */ PragTyp_HEADER_VALUE,
/* ePragFlag: */ 0,
- /* iArg: */ 0 },
+ /* iArg: */ BTREE_APPLICATION_ID },
#endif
#if !defined(SQLITE_OMIT_AUTOVACUUM)
{ /* zName: */ "auto_vacuum",
@@ -100935,6 +102890,12 @@ static const struct sPragmaNames {
/* ePragFlag: */ 0,
/* iArg: */ 0 },
#endif
+#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
+ { /* zName: */ "data_version",
+ /* ePragTyp: */ PragTyp_HEADER_VALUE,
+ /* ePragFlag: */ PragFlag_ReadOnly,
+ /* iArg: */ BTREE_DATA_VERSION },
+#endif
#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)
{ /* zName: */ "database_list",
/* ePragTyp: */ PragTyp_DATABASE_LIST,
@@ -100990,8 +102951,8 @@ static const struct sPragmaNames {
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
{ /* zName: */ "freelist_count",
/* ePragTyp: */ PragTyp_HEADER_VALUE,
- /* ePragFlag: */ 0,
- /* iArg: */ 0 },
+ /* ePragFlag: */ PragFlag_ReadOnly,
+ /* iArg: */ BTREE_FREE_PAGE_COUNT },
#endif
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
{ /* zName: */ "full_column_names",
@@ -101036,6 +102997,10 @@ static const struct sPragmaNames {
/* ePragTyp: */ PragTyp_INDEX_LIST,
/* ePragFlag: */ PragFlag_NeedSchema,
/* iArg: */ 0 },
+ { /* zName: */ "index_xinfo",
+ /* ePragTyp: */ PragTyp_INDEX_INFO,
+ /* ePragFlag: */ PragFlag_NeedSchema,
+ /* iArg: */ 1 },
#endif
#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
{ /* zName: */ "integrity_check",
@@ -101143,7 +103108,7 @@ static const struct sPragmaNames {
{ /* zName: */ "schema_version",
/* ePragTyp: */ PragTyp_HEADER_VALUE,
/* ePragFlag: */ 0,
- /* iArg: */ 0 },
+ /* iArg: */ BTREE_SCHEMA_VERSION },
#endif
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
{ /* zName: */ "secure_delete",
@@ -101209,7 +103174,7 @@ static const struct sPragmaNames {
{ /* zName: */ "user_version",
/* ePragTyp: */ PragTyp_HEADER_VALUE,
/* ePragFlag: */ 0,
- /* iArg: */ 0 },
+ /* iArg: */ BTREE_USER_VERSION },
#endif
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
#if defined(SQLITE_DEBUG)
@@ -101252,9 +103217,10 @@ static const struct sPragmaNames {
/* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode },
#endif
};
-/* Number of pragmas: 57 on by default, 70 total. */
-/* End of the automatically generated pragma table.
-***************************************************************************/
+/* Number of pragmas: 59 on by default, 72 total. */
+
+/************** End of pragma.h **********************************************/
+/************** Continuing where we left off in pragma.c *********************/
/*
** Interpret the given string as a safety level. Return 0 for OFF,
@@ -101502,11 +103468,12 @@ SQLITE_PRIVATE void sqlite3Pragma(
Token *pId; /* Pointer to <id> token */
char *aFcntl[4]; /* Argument to SQLITE_FCNTL_PRAGMA */
int iDb; /* Database index for <database> */
- int lwr, upr, mid; /* Binary search bounds */
+ int lwr, upr, mid = 0; /* Binary search bounds */
int rc; /* return value form SQLITE_FCNTL_PRAGMA */
sqlite3 *db = pParse->db; /* The database connection */
Db *pDb; /* The specific database being pragmaed */
Vdbe *v = sqlite3GetVdbe(pParse); /* Prepared statement */
+ const struct sPragmaNames *pPragma;
if( v==0 ) return;
sqlite3VdbeRunOnlyOnce(v);
@@ -101542,6 +103509,17 @@ SQLITE_PRIVATE void sqlite3Pragma(
/* Send an SQLITE_FCNTL_PRAGMA file-control to the underlying VFS
** connection. If it returns SQLITE_OK, then assume that the VFS
** handled the pragma and generate a no-op prepared statement.
+ **
+ ** IMPLEMENTATION-OF: R-12238-55120 Whenever a PRAGMA statement is parsed,
+ ** an SQLITE_FCNTL_PRAGMA file control is sent to the open sqlite3_file
+ ** object corresponding to the database file to which the pragma
+ ** statement refers.
+ **
+ ** IMPLEMENTATION-OF: R-29875-31678 The argument to the SQLITE_FCNTL_PRAGMA
+ ** file control is an array of pointers to strings (char**) in which the
+ ** second element of the array is the name of the pragma and the third
+ ** element is the argument to the pragma or NULL if the pragma has no
+ ** argument.
*/
aFcntl[0] = 0;
aFcntl[1] = zLeft;
@@ -101584,14 +103562,15 @@ SQLITE_PRIVATE void sqlite3Pragma(
}
}
if( lwr>upr ) goto pragma_out;
+ pPragma = &aPragmaNames[mid];
/* Make sure the database schema is loaded if the pragma requires that */
- if( (aPragmaNames[mid].mPragFlag & PragFlag_NeedSchema)!=0 ){
+ if( (pPragma->mPragFlag & PragFlag_NeedSchema)!=0 ){
if( sqlite3ReadSchema(pParse) ) goto pragma_out;
}
/* Jump to the appropriate pragma handler */
- switch( aPragmaNames[mid].ePragTyp ){
+ switch( pPragma->ePragTyp ){
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
/*
@@ -102170,10 +104149,9 @@ SQLITE_PRIVATE void sqlite3Pragma(
#ifndef SQLITE_OMIT_FLAG_PRAGMAS
case PragTyp_FLAG: {
if( zRight==0 ){
- returnSingleInt(pParse, aPragmaNames[mid].zName,
- (db->flags & aPragmaNames[mid].iArg)!=0 );
+ returnSingleInt(pParse, pPragma->zName, (db->flags & pPragma->iArg)!=0 );
}else{
- int mask = aPragmaNames[mid].iArg; /* Mask of bits to set or clear. */
+ int mask = pPragma->iArg; /* Mask of bits to set or clear. */
if( db->autoCommit==0 ){
/* Foreign key support may not be enabled or disabled while not
** in auto-commit mode. */
@@ -102302,20 +104280,42 @@ SQLITE_PRIVATE void sqlite3Pragma(
pIdx = sqlite3FindIndex(db, zRight, zDb);
if( pIdx ){
int i;
+ int mx;
+ if( pPragma->iArg ){
+ /* PRAGMA index_xinfo (newer version with more rows and columns) */
+ mx = pIdx->nColumn;
+ pParse->nMem = 6;
+ }else{
+ /* PRAGMA index_info (legacy version) */
+ mx = pIdx->nKeyCol;
+ pParse->nMem = 3;
+ }
pTab = pIdx->pTable;
- sqlite3VdbeSetNumCols(v, 3);
- pParse->nMem = 3;
+ sqlite3VdbeSetNumCols(v, pParse->nMem);
sqlite3CodeVerifySchema(pParse, iDb);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seqno", SQLITE_STATIC);
sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "cid", SQLITE_STATIC);
sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "name", SQLITE_STATIC);
- for(i=0; i<pIdx->nKeyCol; i++){
+ if( pPragma->iArg ){
+ sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "desc", SQLITE_STATIC);
+ sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "coll", SQLITE_STATIC);
+ sqlite3VdbeSetColName(v, 5, COLNAME_NAME, "key", SQLITE_STATIC);
+ }
+ for(i=0; i<mx; i++){
i16 cnum = pIdx->aiColumn[i];
sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
sqlite3VdbeAddOp2(v, OP_Integer, cnum, 2);
- assert( pTab->nCol>cnum );
- sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pTab->aCol[cnum].zName, 0);
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
+ if( cnum<0 ){
+ sqlite3VdbeAddOp2(v, OP_Null, 0, 3);
+ }else{
+ sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, pTab->aCol[cnum].zName, 0);
+ }
+ if( pPragma->iArg ){
+ sqlite3VdbeAddOp2(v, OP_Integer, pIdx->aSortOrder[i], 4);
+ sqlite3VdbeAddOp4(v, OP_String8, 0, 5, 0, pIdx->azColl[i], 0);
+ sqlite3VdbeAddOp2(v, OP_Integer, i<pIdx->nKeyCol, 6);
+ }
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 1, pParse->nMem);
}
}
}
@@ -102328,17 +104328,22 @@ SQLITE_PRIVATE void sqlite3Pragma(
pTab = sqlite3FindTable(db, zRight, zDb);
if( pTab ){
v = sqlite3GetVdbe(pParse);
- sqlite3VdbeSetNumCols(v, 3);
- pParse->nMem = 3;
+ sqlite3VdbeSetNumCols(v, 5);
+ pParse->nMem = 5;
sqlite3CodeVerifySchema(pParse, iDb);
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC);
sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC);
sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "unique", SQLITE_STATIC);
+ sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "origin", SQLITE_STATIC);
+ sqlite3VdbeSetColName(v, 4, COLNAME_NAME, "partial", SQLITE_STATIC);
for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){
+ const char *azOrigin[] = { "c", "u", "pk" };
sqlite3VdbeAddOp2(v, OP_Integer, i, 1);
sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0);
sqlite3VdbeAddOp2(v, OP_Integer, IsUniqueIndex(pIdx), 3);
- sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3);
+ sqlite3VdbeAddOp4(v, OP_String8, 0, 4, 0, azOrigin[pIdx->idxType], 0);
+ sqlite3VdbeAddOp2(v, OP_Integer, pIdx->pPartIdxWhere!=0, 5);
+ sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 5);
}
}
}
@@ -102862,7 +104867,8 @@ SQLITE_PRIVATE void sqlite3Pragma(
){
for(pEnc=&encnames[0]; pEnc->zName; pEnc++){
if( 0==sqlite3StrICmp(zRight, pEnc->zName) ){
- ENC(pParse->db) = pEnc->enc ? pEnc->enc : SQLITE_UTF16NATIVE;
+ SCHEMA_ENC(db) = ENC(db) =
+ pEnc->enc ? pEnc->enc : SQLITE_UTF16NATIVE;
break;
}
}
@@ -102907,24 +104913,9 @@ SQLITE_PRIVATE void sqlite3Pragma(
** applications for any purpose.
*/
case PragTyp_HEADER_VALUE: {
- int iCookie; /* Cookie index. 1 for schema-cookie, 6 for user-cookie. */
+ int iCookie = pPragma->iArg; /* Which cookie to read or write */
sqlite3VdbeUsesBtree(v, iDb);
- switch( zLeft[0] ){
- case 'a': case 'A':
- iCookie = BTREE_APPLICATION_ID;
- break;
- case 'f': case 'F':
- iCookie = BTREE_FREE_PAGE_COUNT;
- break;
- case 's': case 'S':
- iCookie = BTREE_SCHEMA_VERSION;
- break;
- default:
- iCookie = BTREE_USER_VERSION;
- break;
- }
-
- if( zRight && iCookie!=BTREE_FREE_PAGE_COUNT ){
+ if( zRight && (pPragma->mPragFlag & PragFlag_ReadOnly)==0 ){
/* Write the specified cookie value */
static const VdbeOpList setCookie[] = {
{ OP_Transaction, 0, 1, 0}, /* 0 */
@@ -102977,7 +104968,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
#ifndef SQLITE_OMIT_WAL
/*
- ** PRAGMA [database.]wal_checkpoint = passive|full|restart
+ ** PRAGMA [database.]wal_checkpoint = passive|full|restart|truncate
**
** Checkpoint the database.
*/
@@ -102989,6 +104980,8 @@ SQLITE_PRIVATE void sqlite3Pragma(
eMode = SQLITE_CHECKPOINT_FULL;
}else if( sqlite3StrICmp(zRight, "restart")==0 ){
eMode = SQLITE_CHECKPOINT_RESTART;
+ }else if( sqlite3StrICmp(zRight, "truncate")==0 ){
+ eMode = SQLITE_CHECKPOINT_TRUNCATE;
}
}
sqlite3VdbeSetNumCols(v, 3);
@@ -103024,8 +105017,9 @@ SQLITE_PRIVATE void sqlite3Pragma(
/*
** PRAGMA shrink_memory
**
- ** This pragma attempts to free as much memory as possible from the
- ** current database connection.
+ ** IMPLEMENTATION-OF: R-23445-46109 This pragma causes the database
+ ** connection on which it is invoked to free up as much memory as it
+ ** can, by calling sqlite3_db_release_memory().
*/
case PragTyp_SHRINK_MEMORY: {
sqlite3_db_release_memory(db);
@@ -103042,7 +105036,7 @@ SQLITE_PRIVATE void sqlite3Pragma(
** disables the timeout.
*/
/*case PragTyp_BUSY_TIMEOUT*/ default: {
- assert( aPragmaNames[mid].ePragTyp==PragTyp_BUSY_TIMEOUT );
+ assert( pPragma->ePragTyp==PragTyp_BUSY_TIMEOUT );
if( zRight ){
sqlite3_busy_timeout(db, sqlite3Atoi(zRight));
}
@@ -103054,8 +105048,12 @@ SQLITE_PRIVATE void sqlite3Pragma(
** PRAGMA soft_heap_limit
** PRAGMA soft_heap_limit = N
**
- ** Call sqlite3_soft_heap_limit64(N). Return the result. If N is omitted,
- ** use -1.
+ ** IMPLEMENTATION-OF: R-26343-45930 This pragma invokes the
+ ** sqlite3_soft_heap_limit64() interface with the argument N, if N is
+ ** specified and is a non-negative integer.
+ ** IMPLEMENTATION-OF: R-64451-07163 The soft_heap_limit pragma always
+ ** returns the same integer that would be returned by the
+ ** sqlite3_soft_heap_limit64(-1) C-language function.
*/
case PragTyp_SOFT_HEAP_LIMIT: {
sqlite3_int64 N;
@@ -103568,9 +105566,11 @@ SQLITE_PRIVATE int sqlite3Init(sqlite3 *db, char **pzErrMsg){
int commit_internal = !(db->flags&SQLITE_InternChanges);
assert( sqlite3_mutex_held(db->mutex) );
+ assert( sqlite3BtreeHoldsMutex(db->aDb[0].pBt) );
assert( db->init.busy==0 );
rc = SQLITE_OK;
db->init.busy = 1;
+ ENC(db) = SCHEMA_ENC(db);
for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
if( DbHasProperty(db, i, DB_SchemaLoaded) || i==1 ) continue;
rc = sqlite3InitOne(db, i, pzErrMsg);
@@ -103883,9 +105883,12 @@ static int sqlite3LockAndPrepare(
const char **pzTail /* OUT: End of parsed string */
){
int rc;
- assert( ppStmt!=0 );
+
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( ppStmt==0 ) return SQLITE_MISUSE_BKPT;
+#endif
*ppStmt = 0;
- if( !sqlite3SafetyCheckOk(db) ){
+ if( !sqlite3SafetyCheckOk(db)||zSql==0 ){
return SQLITE_MISUSE_BKPT;
}
sqlite3_mutex_enter(db->mutex);
@@ -103946,7 +105949,7 @@ SQLITE_PRIVATE int sqlite3Reprepare(Vdbe *p){
** and the statement is automatically recompiled if an schema change
** occurs.
*/
-SQLITE_API int sqlite3_prepare(
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
sqlite3 *db, /* Database handle. */
const char *zSql, /* UTF-8 encoded SQL statement. */
int nBytes, /* Length of zSql in bytes. */
@@ -103958,7 +105961,7 @@ SQLITE_API int sqlite3_prepare(
assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
return rc;
}
-SQLITE_API int sqlite3_prepare_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
sqlite3 *db, /* Database handle. */
const char *zSql, /* UTF-8 encoded SQL statement. */
int nBytes, /* Length of zSql in bytes. */
@@ -103992,9 +105995,11 @@ static int sqlite3Prepare16(
const char *zTail8 = 0;
int rc = SQLITE_OK;
- assert( ppStmt );
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( ppStmt==0 ) return SQLITE_MISUSE_BKPT;
+#endif
*ppStmt = 0;
- if( !sqlite3SafetyCheckOk(db) ){
+ if( !sqlite3SafetyCheckOk(db)||zSql==0 ){
return SQLITE_MISUSE_BKPT;
}
if( nBytes>=0 ){
@@ -104032,7 +106037,7 @@ static int sqlite3Prepare16(
** and the statement is automatically recompiled if an schema change
** occurs.
*/
-SQLITE_API int sqlite3_prepare16(
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
sqlite3 *db, /* Database handle. */
const void *zSql, /* UTF-16 encoded SQL statement. */
int nBytes, /* Length of zSql in bytes. */
@@ -104044,7 +106049,7 @@ SQLITE_API int sqlite3_prepare16(
assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
return rc;
}
-SQLITE_API int sqlite3_prepare16_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
sqlite3 *db, /* Database handle. */
const void *zSql, /* UTF-16 encoded SQL statement. */
int nBytes, /* Length of zSql in bytes. */
@@ -104120,20 +106125,25 @@ struct SortCtx {
#define SORTFLAG_UseSorter 0x01 /* Use SorterOpen instead of OpenEphemeral */
/*
-** Delete all the content of a Select structure but do not deallocate
-** the select structure itself.
+** Delete all the content of a Select structure. Deallocate the structure
+** itself only if bFree is true.
*/
-static void clearSelect(sqlite3 *db, Select *p){
- sqlite3ExprListDelete(db, p->pEList);
- sqlite3SrcListDelete(db, p->pSrc);
- sqlite3ExprDelete(db, p->pWhere);
- sqlite3ExprListDelete(db, p->pGroupBy);
- sqlite3ExprDelete(db, p->pHaving);
- sqlite3ExprListDelete(db, p->pOrderBy);
- sqlite3SelectDelete(db, p->pPrior);
- sqlite3ExprDelete(db, p->pLimit);
- sqlite3ExprDelete(db, p->pOffset);
- sqlite3WithDelete(db, p->pWith);
+static void clearSelect(sqlite3 *db, Select *p, int bFree){
+ while( p ){
+ Select *pPrior = p->pPrior;
+ sqlite3ExprListDelete(db, p->pEList);
+ sqlite3SrcListDelete(db, p->pSrc);
+ sqlite3ExprDelete(db, p->pWhere);
+ sqlite3ExprListDelete(db, p->pGroupBy);
+ sqlite3ExprDelete(db, p->pHaving);
+ sqlite3ExprListDelete(db, p->pOrderBy);
+ sqlite3ExprDelete(db, p->pLimit);
+ sqlite3ExprDelete(db, p->pOffset);
+ sqlite3WithDelete(db, p->pWith);
+ if( bFree ) sqlite3DbFree(db, p);
+ p = pPrior;
+ bFree = 1;
+ }
}
/*
@@ -104192,8 +106202,7 @@ SQLITE_PRIVATE Select *sqlite3SelectNew(
pNew->addrOpenEphm[0] = -1;
pNew->addrOpenEphm[1] = -1;
if( db->mallocFailed ) {
- clearSelect(db, pNew);
- if( pNew!=&standin ) sqlite3DbFree(db, pNew);
+ clearSelect(db, pNew, pNew!=&standin);
pNew = 0;
}else{
assert( pNew->pSrc!=0 || pParse->nErr>0 );
@@ -104218,10 +106227,7 @@ SQLITE_PRIVATE void sqlite3SelectSetName(Select *p, const char *zName){
** Delete the given Select structure and all of its substructures.
*/
SQLITE_PRIVATE void sqlite3SelectDelete(sqlite3 *db, Select *p){
- if( p ){
- clearSelect(db, p);
- sqlite3DbFree(db, p);
- }
+ clearSelect(db, p, 1);
}
/*
@@ -104604,7 +106610,9 @@ static void pushOntoSorter(
pKI = pOp->p4.pKeyInfo;
memset(pKI->aSortOrder, 0, pKI->nField); /* Makes OP_Jump below testable */
sqlite3VdbeChangeP4(v, -1, (char*)pKI, P4_KEYINFO);
- pOp->p4.pKeyInfo = keyInfoFromExprList(pParse, pSort->pOrderBy, nOBSat, 1);
+ testcase( pKI->nXField>2 );
+ pOp->p4.pKeyInfo = keyInfoFromExprList(pParse, pSort->pOrderBy, nOBSat,
+ pKI->nXField-1);
addrJmp = sqlite3VdbeCurrentAddr(v);
sqlite3VdbeAddOp3(v, OP_Jump, addrJmp+1, 0, addrJmp+1); VdbeCoverage(v);
pSort->labelBkOut = sqlite3VdbeMakeLabel(v);
@@ -104622,20 +106630,17 @@ static void pushOntoSorter(
}
sqlite3VdbeAddOp2(v, op, pSort->iECursor, regRecord);
if( pSelect->iLimit ){
- int addr1, addr2;
+ int addr;
int iLimit;
if( pSelect->iOffset ){
iLimit = pSelect->iOffset+1;
}else{
iLimit = pSelect->iLimit;
}
- addr1 = sqlite3VdbeAddOp1(v, OP_IfZero, iLimit); VdbeCoverage(v);
- sqlite3VdbeAddOp2(v, OP_AddImm, iLimit, -1);
- addr2 = sqlite3VdbeAddOp0(v, OP_Goto);
- sqlite3VdbeJumpHere(v, addr1);
+ addr = sqlite3VdbeAddOp3(v, OP_IfNotZero, iLimit, 0, -1); VdbeCoverage(v);
sqlite3VdbeAddOp1(v, OP_Last, pSort->iECursor);
sqlite3VdbeAddOp1(v, OP_Delete, pSort->iECursor);
- sqlite3VdbeJumpHere(v, addr2);
+ sqlite3VdbeJumpHere(v, addr);
}
}
@@ -105032,7 +107037,7 @@ static void selectInnerLoop(
** the output for us.
*/
if( pSort==0 && p->iLimit ){
- sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1); VdbeCoverage(v);
+ sqlite3VdbeAddOp2(v, OP_DecrJumpZero, p->iLimit, iBreak); VdbeCoverage(v);
}
}
@@ -105115,7 +107120,7 @@ static KeyInfo *keyInfoFromExprList(
int i;
nExpr = pList->nExpr;
- pInfo = sqlite3KeyInfoAlloc(db, nExpr+nExtra-iStart, 1);
+ pInfo = sqlite3KeyInfoAlloc(db, nExpr-iStart, nExtra+1);
if( pInfo ){
assert( sqlite3KeyInfoIsWriteable(pInfo) );
for(i=iStart, pItem=pList->a+iStart; i<nExpr; i++, pItem++){
@@ -105885,7 +107890,7 @@ static void computeLimitRegisters(Parse *pParse, Select *p, int iBreak){
sqlite3ExprCode(pParse, p->pLimit, iLimit);
sqlite3VdbeAddOp1(v, OP_MustBeInt, iLimit); VdbeCoverage(v);
VdbeComment((v, "LIMIT counter"));
- sqlite3VdbeAddOp2(v, OP_IfZero, iLimit, iBreak); VdbeCoverage(v);
+ sqlite3VdbeAddOp2(v, OP_IfNot, iLimit, iBreak); VdbeCoverage(v);
}
if( p->pOffset ){
p->iOffset = iOffset = ++pParse->nMem;
@@ -106104,7 +108109,7 @@ static void generateWithRecursiveQuery(
selectInnerLoop(pParse, p, p->pEList, iCurrent,
0, 0, pDest, addrCont, addrBreak);
if( regLimit ){
- sqlite3VdbeAddOp3(v, OP_IfZero, regLimit, addrBreak, -1);
+ sqlite3VdbeAddOp2(v, OP_DecrJumpZero, regLimit, addrBreak);
VdbeCoverage(v);
}
sqlite3VdbeResolveLabel(v, addrCont);
@@ -106137,6 +108142,66 @@ static int multiSelectOrderBy(
SelectDest *pDest /* What to do with query results */
);
+/*
+** Error message for when two or more terms of a compound select have different
+** size result sets.
+*/
+static void selectWrongNumTermsError(Parse *pParse, Select *p){
+ if( p->selFlags & SF_Values ){
+ sqlite3ErrorMsg(pParse, "all VALUES must have the same number of terms");
+ }else{
+ sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s"
+ " do not have the same number of result columns", selectOpName(p->op));
+ }
+}
+
+/*
+** Handle the special case of a compound-select that originates from a
+** VALUES clause. By handling this as a special case, we avoid deep
+** recursion, and thus do not need to enforce the SQLITE_LIMIT_COMPOUND_SELECT
+** on a VALUES clause.
+**
+** Because the Select object originates from a VALUES clause:
+** (1) It has no LIMIT or OFFSET
+** (2) All terms are UNION ALL
+** (3) There is no ORDER BY clause
+*/
+static int multiSelectValues(
+ Parse *pParse, /* Parsing context */
+ Select *p, /* The right-most of SELECTs to be coded */
+ SelectDest *pDest /* What to do with query results */
+){
+ Select *pPrior;
+ int nExpr = p->pEList->nExpr;
+ int nRow = 1;
+ int rc = 0;
+ assert( p->pNext==0 );
+ assert( p->selFlags & SF_AllValues );
+ do{
+ assert( p->selFlags & SF_Values );
+ assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) );
+ assert( p->pLimit==0 );
+ assert( p->pOffset==0 );
+ if( p->pEList->nExpr!=nExpr ){
+ selectWrongNumTermsError(pParse, p);
+ return 1;
+ }
+ if( p->pPrior==0 ) break;
+ assert( p->pPrior->pNext==p );
+ p = p->pPrior;
+ nRow++;
+ }while(1);
+ while( p ){
+ pPrior = p->pPrior;
+ p->pPrior = 0;
+ rc = sqlite3Select(pParse, p, pDest);
+ p->pPrior = pPrior;
+ if( rc ) break;
+ p->nSelectRow = nRow;
+ p = p->pNext;
+ }
+ return rc;
+}
/*
** This routine is called to process a compound query form from
@@ -106218,17 +108283,19 @@ static int multiSelect(
dest.eDest = SRT_Table;
}
+ /* Special handling for a compound-select that originates as a VALUES clause.
+ */
+ if( p->selFlags & SF_AllValues ){
+ rc = multiSelectValues(pParse, p, &dest);
+ goto multi_select_end;
+ }
+
/* Make sure all SELECTs in the statement have the same number of elements
** in their result sets.
*/
assert( p->pEList && pPrior->pEList );
if( p->pEList->nExpr!=pPrior->pEList->nExpr ){
- if( p->selFlags & SF_Values ){
- sqlite3ErrorMsg(pParse, "all VALUES must have the same number of terms");
- }else{
- sqlite3ErrorMsg(pParse, "SELECTs to the left and right of %s"
- " do not have the same number of result columns", selectOpName(p->op));
- }
+ selectWrongNumTermsError(pParse, p);
rc = 1;
goto multi_select_end;
}
@@ -106267,7 +108334,7 @@ static int multiSelect(
p->iLimit = pPrior->iLimit;
p->iOffset = pPrior->iOffset;
if( p->iLimit ){
- addr = sqlite3VdbeAddOp1(v, OP_IfZero, p->iLimit); VdbeCoverage(v);
+ addr = sqlite3VdbeAddOp1(v, OP_IfNot, p->iLimit); VdbeCoverage(v);
VdbeComment((v, "Jump ahead if LIMIT reached"));
}
explainSetInteger(iSub2, pParse->iNextSelectId);
@@ -106668,7 +108735,7 @@ static int generateOutputSubroutine(
/* Jump to the end of the loop if the LIMIT is reached.
*/
if( p->iLimit ){
- sqlite3VdbeAddOp3(v, OP_IfZero, p->iLimit, iBreak, -1); VdbeCoverage(v);
+ sqlite3VdbeAddOp2(v, OP_DecrJumpZero, p->iLimit, iBreak); VdbeCoverage(v);
}
/* Generate the subroutine return
@@ -107191,7 +109258,10 @@ static void substSelect(
**
** (1) The subquery and the outer query do not both use aggregates.
**
-** (2) The subquery is not an aggregate or the outer query is not a join.
+** (2) The subquery is not an aggregate or (2a) the outer query is not a join
+** and (2b) the outer query does not use subqueries other than the one
+** FROM-clause subquery that is a candidate for flattening. (2b is
+** due to ticket [2f7170d73bf9abf80] from 2015-02-09.)
**
** (3) The subquery is not the right operand of a left outer join
** (Originally ticket #306. Strengthened by ticket #3300)
@@ -107328,8 +109398,17 @@ static int flattenSubquery(
iParent = pSubitem->iCursor;
pSub = pSubitem->pSelect;
assert( pSub!=0 );
- if( isAgg && subqueryIsAgg ) return 0; /* Restriction (1) */
- if( subqueryIsAgg && pSrc->nSrc>1 ) return 0; /* Restriction (2) */
+ if( subqueryIsAgg ){
+ if( isAgg ) return 0; /* Restriction (1) */
+ if( pSrc->nSrc>1 ) return 0; /* Restriction (2a) */
+ if( (p->pWhere && ExprHasProperty(p->pWhere,EP_Subquery))
+ || (sqlite3ExprListFlags(p->pEList) & EP_Subquery)!=0
+ || (sqlite3ExprListFlags(p->pOrderBy) & EP_Subquery)!=0
+ ){
+ return 0; /* Restriction (2b) */
+ }
+ }
+
pSubSrc = pSub->pSrc;
assert( pSubSrc );
/* Prior to version 3.1.2, when LIMIT and OFFSET had to be simple constants,
@@ -107872,6 +109951,8 @@ static int convertCompoundSelectToSubquery(Walker *pWalker, Select *p){
p->pPrior = 0;
p->pNext = 0;
p->selFlags &= ~SF_Compound;
+ assert( (p->selFlags & SF_Converted)==0 );
+ p->selFlags |= SF_Converted;
assert( pNew->pPrior!=0 );
pNew->pPrior->pNext = pNew;
pNew->pLimit = 0;
@@ -108023,7 +110104,7 @@ static int withExpand(
for(pLeft=pSel; pLeft->pPrior; pLeft=pLeft->pPrior);
pEList = pLeft->pEList;
if( pCte->pCols ){
- if( pEList->nExpr!=pCte->pCols->nExpr ){
+ if( pEList && pEList->nExpr!=pCte->pCols->nExpr ){
sqlite3ErrorMsg(pParse, "table %s has %d values for %d columns",
pCte->zName, pEList->nExpr, pCte->pCols->nExpr
);
@@ -108114,7 +110195,9 @@ static int selectExpander(Walker *pWalker, Select *p){
}
pTabList = p->pSrc;
pEList = p->pEList;
- sqlite3WithPush(pParse, findRightmost(p)->pWith, 0);
+ if( pWalker->xSelectCallback2==selectPopWith ){
+ sqlite3WithPush(pParse, findRightmost(p)->pWith, 0);
+ }
/* Make sure cursor numbers have been assigned to all entries in
** the FROM clause of the SELECT statement.
@@ -108148,7 +110231,7 @@ static int selectExpander(Walker *pWalker, Select *p){
/* A sub-query in the FROM clause of a SELECT */
assert( pSel!=0 );
assert( pFrom->pTab==0 );
- sqlite3WalkSelect(pWalker, pSel);
+ if( sqlite3WalkSelect(pWalker, pSel) ) return WRC_Abort;
pFrom->pTab = pTab = sqlite3DbMallocZero(db, sizeof(Table));
if( pTab==0 ) return WRC_Abort;
pTab->nRef = 1;
@@ -108405,7 +110488,9 @@ static void sqlite3SelectExpand(Parse *pParse, Select *pSelect){
sqlite3WalkSelect(&w, pSelect);
}
w.xSelectCallback = selectExpander;
- w.xSelectCallback2 = selectPopWith;
+ if( (pSelect->selFlags & SF_AllValues)==0 ){
+ w.xSelectCallback2 = selectPopWith;
+ }
sqlite3WalkSelect(&w, pSelect);
}
@@ -108745,6 +110830,13 @@ SQLITE_PRIVATE int sqlite3Select(
}
isAgg = (p->selFlags & SF_Aggregate)!=0;
assert( pEList!=0 );
+#if SELECTTRACE_ENABLED
+ if( sqlite3SelectTrace & 0x100 ){
+ SELECTTRACE(0x100,pParse,p, ("after name resolution:\n"));
+ sqlite3TreeViewSelect(0, p, 0);
+ }
+#endif
+
/* Begin generating code.
*/
@@ -108891,7 +110983,7 @@ SQLITE_PRIVATE int sqlite3Select(
**
** is transformed to:
**
- ** SELECT xyz FROM ... GROUP BY xyz
+ ** SELECT xyz FROM ... GROUP BY xyz ORDER BY xyz
**
** The second form is preferred as a single index (or temp-table) may be
** used for both the ORDER BY and DISTINCT processing. As originally
@@ -108904,7 +110996,6 @@ SQLITE_PRIVATE int sqlite3Select(
p->selFlags &= ~SF_Distinct;
p->pGroupBy = sqlite3ExprListDup(db, p->pEList, 0);
pGroupBy = p->pGroupBy;
- sSort.pOrderBy = 0;
/* Notice that even thought SF_Distinct has been cleared from p->selFlags,
** the sDistinct.isTnct is still set. Hence, isTnct represents the
** original setting of the SF_Distinct flag, not the current setting */
@@ -108920,7 +111011,7 @@ SQLITE_PRIVATE int sqlite3Select(
*/
if( sSort.pOrderBy ){
KeyInfo *pKeyInfo;
- pKeyInfo = keyInfoFromExprList(pParse, sSort.pOrderBy, 0, 0);
+ pKeyInfo = keyInfoFromExprList(pParse, sSort.pOrderBy, 0, pEList->nExpr);
sSort.iECursor = pParse->nTab++;
sSort.addrSortIndex =
sqlite3VdbeAddOp4(v, OP_OpenEphemeral,
@@ -109094,7 +111185,7 @@ SQLITE_PRIVATE int sqlite3Select(
** will be converted into a Noop.
*/
sAggInfo.sortingIdx = pParse->nTab++;
- pKeyInfo = keyInfoFromExprList(pParse, pGroupBy, 0, 0);
+ pKeyInfo = keyInfoFromExprList(pParse, pGroupBy, 0, sAggInfo.nColumn);
addrSortingIdx = sqlite3VdbeAddOp4(v, OP_SorterOpen,
sAggInfo.sortingIdx, sAggInfo.nSortingColumn,
0, (char*)pKeyInfo, P4_KEYINFO);
@@ -109491,9 +111582,9 @@ select_end:
SQLITE_PRIVATE void sqlite3TreeViewSelect(TreeView *pView, const Select *p, u8 moreToFollow){
int n = 0;
pView = sqlite3TreeViewPush(pView, moreToFollow);
- sqlite3TreeViewLine(pView, "SELECT%s%s",
+ sqlite3TreeViewLine(pView, "SELECT%s%s (0x%p)",
((p->selFlags & SF_Distinct) ? " DISTINCT" : ""),
- ((p->selFlags & SF_Aggregate) ? " agg_flag" : "")
+ ((p->selFlags & SF_Aggregate) ? " agg_flag" : ""), p
);
if( p->pSrc && p->pSrc->nSrc ) n++;
if( p->pWhere ) n++;
@@ -109696,7 +111787,7 @@ malloc_failed:
** Instead, the entire table should be passed to sqlite3_free_table() when
** the calling procedure is finished using it.
*/
-SQLITE_API int sqlite3_get_table(
+SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
sqlite3 *db, /* The database on which the SQL executes */
const char *zSql, /* The SQL to be executed */
char ***pazResult, /* Write the result table here */
@@ -109707,6 +111798,9 @@ SQLITE_API int sqlite3_get_table(
int rc;
TabResult res;
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) || pazResult==0 ) return SQLITE_MISUSE_BKPT;
+#endif
*pazResult = 0;
if( pnColumn ) *pnColumn = 0;
if( pnRow ) *pnRow = 0;
@@ -109762,7 +111856,7 @@ SQLITE_API int sqlite3_get_table(
/*
** This routine frees the space the sqlite3_get_table() malloced.
*/
-SQLITE_API void sqlite3_free_table(
+SQLITE_API void SQLITE_STDCALL sqlite3_free_table(
char **azResult /* Result returned from sqlite3_get_table() */
){
if( azResult ){
@@ -111770,7 +113864,7 @@ static int execExecSql(sqlite3 *db, char **pzErrMsg, const char *zSql){
** overwriting the database with the vacuumed content.
**
** Only 1x temporary space and only 1x writes would be required if
-** the copy of step (3) were replace by deleting the original database
+** the copy of step (3) were replaced by deleting the original database
** and renaming the transient database as the original. But that will
** not work if other processes are attached to the original database.
** And a power loss in between deleting the original and renaming the
@@ -111860,7 +113954,7 @@ SQLITE_PRIVATE int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
** cause problems for the call to BtreeSetPageSize() below. */
sqlite3BtreeCommit(pTemp);
- nRes = sqlite3BtreeGetReserve(pMain);
+ nRes = sqlite3BtreeGetOptimalReserve(pMain);
/* A VACUUM cannot change the pagesize of an encrypted database. */
#ifdef SQLITE_HAS_CODEC
@@ -112122,25 +114216,31 @@ static int createModule(
/*
** External API function used to create a new virtual-table module.
*/
-SQLITE_API int sqlite3_create_module(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
sqlite3 *db, /* Database in which module is registered */
const char *zName, /* Name assigned to this module */
const sqlite3_module *pModule, /* The definition of the module */
void *pAux /* Context pointer for xCreate/xConnect */
){
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;
+#endif
return createModule(db, zName, pModule, pAux, 0);
}
/*
** External API function used to create a new virtual-table module.
*/
-SQLITE_API int sqlite3_create_module_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
sqlite3 *db, /* Database in which module is registered */
const char *zName, /* Name assigned to this module */
const sqlite3_module *pModule, /* The definition of the module */
void *pAux, /* Context pointer for xCreate/xConnect */
void (*xDestroy)(void *) /* Module destructor function */
){
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;
+#endif
return createModule(db, zName, pModule, pAux, xDestroy);
}
@@ -112373,7 +114473,12 @@ SQLITE_PRIVATE void sqlite3VtabBeginParse(
addModuleArgument(db, pTable, sqlite3NameFromToken(db, pModuleName));
addModuleArgument(db, pTable, 0);
addModuleArgument(db, pTable, sqlite3DbStrDup(db, pTable->zName));
- pParse->sNameToken.n = (int)(&pModuleName->z[pModuleName->n] - pName1->z);
+ assert( (pParse->sNameToken.z==pName2->z && pName2->z!=0)
+ || (pParse->sNameToken.z==pName1->z && pName2->z==0)
+ );
+ pParse->sNameToken.n = (int)(
+ &pModuleName->z[pModuleName->n] - pParse->sNameToken.z
+ );
#ifndef SQLITE_OMIT_AUTHORIZATION
/* Creating a virtual table invokes the authorization callback twice.
@@ -112425,6 +114530,7 @@ SQLITE_PRIVATE void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
char *zStmt;
char *zWhere;
int iDb;
+ int iReg;
Vdbe *v;
/* Compute the complete text of the CREATE VIRTUAL TABLE statement */
@@ -112459,8 +114565,10 @@ SQLITE_PRIVATE void sqlite3VtabFinishParse(Parse *pParse, Token *pEnd){
sqlite3VdbeAddOp2(v, OP_Expire, 0, 0);
zWhere = sqlite3MPrintf(db, "name='%q' AND type='table'", pTab->zName);
sqlite3VdbeAddParseSchemaOp(v, iDb, zWhere);
- sqlite3VdbeAddOp4(v, OP_VCreate, iDb, 0, 0,
- pTab->zName, sqlite3Strlen30(pTab->zName) + 1);
+
+ iReg = ++pParse->nMem;
+ sqlite3VdbeAddOp4(v, OP_String8, 0, iReg, 0, pTab->zName, 0);
+ sqlite3VdbeAddOp2(v, OP_VCreate, iDb, iReg);
}
/* If we are rereading the sqlite_master table create the in-memory
@@ -112738,13 +114846,18 @@ SQLITE_PRIVATE int sqlite3VtabCallCreate(sqlite3 *db, int iDb, const char *zTab,
** valid to call this function from within the xCreate() or xConnect() of a
** virtual table module.
*/
-SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
+SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
Parse *pParse;
int rc = SQLITE_OK;
Table *pTab;
char *zErr = 0;
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) || zCreateTable==0 ){
+ return SQLITE_MISUSE_BKPT;
+ }
+#endif
sqlite3_mutex_enter(db->mutex);
if( !db->pVtabCtx || !(pTab = db->pVtabCtx->pTab) ){
sqlite3Error(db, SQLITE_MISUSE);
@@ -112808,11 +114921,15 @@ SQLITE_PRIVATE int sqlite3VtabCallDestroy(sqlite3 *db, int iDb, const char *zTab
pTab = sqlite3FindTable(db, zTab, db->aDb[iDb].zName);
if( ALWAYS(pTab!=0 && pTab->pVTable!=0) ){
- VTable *p = vtabDisconnectAll(db, pTab);
-
- assert( rc==SQLITE_OK );
+ VTable *p;
+ for(p=pTab->pVTable; p; p=p->pNext){
+ assert( p->pVtab );
+ if( p->pVtab->nRef>0 ){
+ return SQLITE_LOCKED;
+ }
+ }
+ p = vtabDisconnectAll(db, pTab);
rc = p->pMod->pModule->xDestroy(p->pVtab);
-
/* Remove the sqlite3_vtab* from the aVTrans[] array, if applicable */
if( rc==SQLITE_OK ){
assert( pTab->pVTable==p && p->pNext==0 );
@@ -113097,10 +115214,13 @@ SQLITE_PRIVATE void sqlite3VtabMakeWritable(Parse *pParse, Table *pTab){
** The results of this routine are undefined unless it is called from
** within an xUpdate method.
*/
-SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *db){
+SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *db){
static const unsigned char aMap[] = {
SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE
};
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
+#endif
assert( OE_Rollback==1 && OE_Abort==2 && OE_Fail==3 );
assert( OE_Ignore==4 && OE_Replace==5 );
assert( db->vtabOnConflict>=1 && db->vtabOnConflict<=5 );
@@ -113112,12 +115232,14 @@ SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *db){
** the SQLite core with additional information about the behavior
** of the virtual table being implemented.
*/
-SQLITE_API int sqlite3_vtab_config(sqlite3 *db, int op, ...){
+SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3 *db, int op, ...){
va_list ap;
int rc = SQLITE_OK;
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
+#endif
sqlite3_mutex_enter(db->mutex);
-
va_start(ap, op);
switch( op ){
case SQLITE_VTAB_CONSTRAINT_SUPPORT: {
@@ -113236,6 +115358,8 @@ struct WhereLevel {
int addrCont; /* Jump here to continue with the next loop cycle */
int addrFirst; /* First instruction of interior of the loop */
int addrBody; /* Beginning of the body of this loop */
+ int iLikeRepCntr; /* LIKE range processing counter register */
+ int addrLikeRep; /* LIKE range processing address */
u8 iFrom; /* Which entry in the FROM clause */
u8 op, p3, p5; /* Opcode, P3 & P5 of the opcode that ends the loop */
int p1, p2; /* Operands of the opcode used to ends the loop */
@@ -113252,6 +115376,9 @@ struct WhereLevel {
} u;
struct WhereLoop *pWLoop; /* The selected WhereLoop object */
Bitmask notReady; /* FROM entries not usable at this level */
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
+ int addrVisit; /* Address at which row is visited */
+#endif
};
/*
@@ -113282,7 +115409,6 @@ struct WhereLoop {
union {
struct { /* Information for internal btree tables */
u16 nEq; /* Number of equality constraints */
- u16 nSkip; /* Number of initial index columns to skip */
Index *pIndex; /* Index used, or NULL */
} btree;
struct { /* Information for virtual tables */
@@ -113295,12 +115421,13 @@ struct WhereLoop {
} u;
u32 wsFlags; /* WHERE_* flags describing the plan */
u16 nLTerm; /* Number of entries in aLTerm[] */
+ u16 nSkip; /* Number of NULL aLTerm[] entries */
/**** whereLoopXfer() copies fields above ***********************/
# define WHERE_LOOP_XFER_SZ offsetof(WhereLoop,nLSlot)
u16 nLSlot; /* Number of slots allocated for aLTerm[] */
WhereTerm **aLTerm; /* WhereTerms used */
WhereLoop *pNextLoop; /* Next WhereLoop object in the WhereClause */
- WhereTerm *aLTermSpace[4]; /* Initial aLTerm[] space */
+ WhereTerm *aLTermSpace[3]; /* Initial aLTerm[] space */
};
/* This object holds the prerequisites and the cost of running a
@@ -113417,7 +115544,7 @@ struct WhereTerm {
} u;
LogEst truthProb; /* Probability of truth for this expression */
u16 eOperator; /* A WO_xx value describing <op> */
- u8 wtFlags; /* TERM_xxx bit flags. See below */
+ u16 wtFlags; /* TERM_xxx bit flags. See below */
u8 nChild; /* Number of children that must disable us */
WhereClause *pWC; /* The clause this term is part of */
Bitmask prereqRight; /* Bitmask of tables used by pExpr->pRight */
@@ -113439,6 +115566,9 @@ struct WhereTerm {
#else
# define TERM_VNULL 0x00 /* Disabled if not using stat3 */
#endif
+#define TERM_LIKEOPT 0x100 /* Virtual terms from the LIKE optimization */
+#define TERM_LIKECOND 0x200 /* Conditionally this LIKE operator term */
+#define TERM_LIKE 0x400 /* The original LIKE operator */
/*
** An instance of the WhereScan object is used as an iterator for locating
@@ -113626,6 +115756,7 @@ struct WhereInfo {
#define WHERE_AUTO_INDEX 0x00004000 /* Uses an ephemeral index */
#define WHERE_SKIPSCAN 0x00008000 /* Uses the skip-scan algorithm */
#define WHERE_UNQ_WANTED 0x00010000 /* WHERE_ONEROW would have been helpful*/
+#define WHERE_PARTIALIDX 0x00020000 /* The automatic index is partial */
/************** End of whereInt.h ********************************************/
/************** Continuing where we left off in where.c **********************/
@@ -113813,7 +115944,7 @@ static void whereClauseClear(WhereClause *pWC){
** calling this routine. Such pointers may be reinitialized by referencing
** the pWC->a[] array.
*/
-static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){
+static int whereClauseInsert(WhereClause *pWC, Expr *p, u16 wtFlags){
WhereTerm *pTerm;
int idx;
testcase( wtFlags & TERM_VIRTUAL );
@@ -113833,10 +115964,11 @@ static int whereClauseInsert(WhereClause *pWC, Expr *p, u8 wtFlags){
sqlite3DbFree(db, pOld);
}
pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]);
+ memset(&pWC->a[pWC->nTerm], 0, sizeof(pWC->a[0])*(pWC->nSlot-pWC->nTerm));
}
pTerm = &pWC->a[idx = pWC->nTerm++];
if( p && ExprHasProperty(p, EP_Unlikely) ){
- pTerm->truthProb = sqlite3LogEst(p->iTable) - 99;
+ pTerm->truthProb = sqlite3LogEst(p->iTable) - 270;
}else{
pTerm->truthProb = 1;
}
@@ -114237,7 +116369,11 @@ static void exprAnalyzeAll(
** so and false if not.
**
** In order for the operator to be optimizible, the RHS must be a string
-** literal that does not begin with a wildcard.
+** literal that does not begin with a wildcard. The LHS must be a column
+** that may only be NULL, a string, or a BLOB, never a number. (This means
+** that virtual tables cannot participate in the LIKE optimization.) If the
+** collating sequence for the column on the LHS must be appropriate for
+** the operator.
*/
static int isLikeOrGlob(
Parse *pParse, /* Parsing and code generating context */
@@ -114266,7 +116402,7 @@ static int isLikeOrGlob(
pLeft = pList->a[1].pExpr;
if( pLeft->op!=TK_COLUMN
|| sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
- || IsVirtual(pLeft->pTab)
+ || IsVirtual(pLeft->pTab) /* Value might be numeric */
){
/* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must
** be the name of an indexed column with TEXT affinity. */
@@ -114367,6 +116503,88 @@ static void transferJoinMarkings(Expr *pDerived, Expr *pBase){
}
}
+/*
+** Mark term iChild as being a child of term iParent
+*/
+static void markTermAsChild(WhereClause *pWC, int iChild, int iParent){
+ pWC->a[iChild].iParent = iParent;
+ pWC->a[iChild].truthProb = pWC->a[iParent].truthProb;
+ pWC->a[iParent].nChild++;
+}
+
+/*
+** Return the N-th AND-connected subterm of pTerm. Or if pTerm is not
+** a conjunction, then return just pTerm when N==0. If N is exceeds
+** the number of available subterms, return NULL.
+*/
+static WhereTerm *whereNthSubterm(WhereTerm *pTerm, int N){
+ if( pTerm->eOperator!=WO_AND ){
+ return N==0 ? pTerm : 0;
+ }
+ if( N<pTerm->u.pAndInfo->wc.nTerm ){
+ return &pTerm->u.pAndInfo->wc.a[N];
+ }
+ return 0;
+}
+
+/*
+** Subterms pOne and pTwo are contained within WHERE clause pWC. The
+** two subterms are in disjunction - they are OR-ed together.
+**
+** If these two terms are both of the form: "A op B" with the same
+** A and B values but different operators and if the operators are
+** compatible (if one is = and the other is <, for example) then
+** add a new virtual AND term to pWC that is the combination of the
+** two.
+**
+** Some examples:
+**
+** x<y OR x=y --> x<=y
+** x=y OR x=y --> x=y
+** x<=y OR x<y --> x<=y
+**
+** The following is NOT generated:
+**
+** x<y OR x>y --> x!=y
+*/
+static void whereCombineDisjuncts(
+ SrcList *pSrc, /* the FROM clause */
+ WhereClause *pWC, /* The complete WHERE clause */
+ WhereTerm *pOne, /* First disjunct */
+ WhereTerm *pTwo /* Second disjunct */
+){
+ u16 eOp = pOne->eOperator | pTwo->eOperator;
+ sqlite3 *db; /* Database connection (for malloc) */
+ Expr *pNew; /* New virtual expression */
+ int op; /* Operator for the combined expression */
+ int idxNew; /* Index in pWC of the next virtual term */
+
+ if( (pOne->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
+ if( (pTwo->eOperator & (WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE))==0 ) return;
+ if( (eOp & (WO_EQ|WO_LT|WO_LE))!=eOp
+ && (eOp & (WO_EQ|WO_GT|WO_GE))!=eOp ) return;
+ assert( pOne->pExpr->pLeft!=0 && pOne->pExpr->pRight!=0 );
+ assert( pTwo->pExpr->pLeft!=0 && pTwo->pExpr->pRight!=0 );
+ if( sqlite3ExprCompare(pOne->pExpr->pLeft, pTwo->pExpr->pLeft, -1) ) return;
+ if( sqlite3ExprCompare(pOne->pExpr->pRight, pTwo->pExpr->pRight, -1) )return;
+ /* If we reach this point, it means the two subterms can be combined */
+ if( (eOp & (eOp-1))!=0 ){
+ if( eOp & (WO_LT|WO_LE) ){
+ eOp = WO_LE;
+ }else{
+ assert( eOp & (WO_GT|WO_GE) );
+ eOp = WO_GE;
+ }
+ }
+ db = pWC->pWInfo->pParse->db;
+ pNew = sqlite3ExprDup(db, pOne->pExpr, 0);
+ if( pNew==0 ) return;
+ for(op=TK_EQ; eOp!=(WO_EQ<<(op-TK_EQ)); op++){ assert( op<TK_GE ); }
+ pNew->op = op;
+ idxNew = whereClauseInsert(pWC, pNew, TERM_VIRTUAL|TERM_DYNAMIC);
+ exprAnalyze(pSrc, pWC, idxNew);
+}
+
#if !defined(SQLITE_OMIT_OR_OPTIMIZATION) && !defined(SQLITE_OMIT_SUBQUERY)
/*
** Analyze a term that consists of two or more OR-connected
@@ -114391,6 +116609,7 @@ static void transferJoinMarkings(Expr *pDerived, Expr *pBase){
** (C) t1.x=t2.y OR (t1.x=t2.z AND t1.y=15)
** (D) x=expr1 OR (y>11 AND y<22 AND z LIKE '*hello*')
** (E) (p.a=1 AND q.b=2 AND r.c=3) OR (p.x=4 AND q.y=5 AND r.z=6)
+** (F) x>A OR (x=A AND y>=B)
**
** CASE 1:
**
@@ -114407,6 +116626,16 @@ static void transferJoinMarkings(Expr *pDerived, Expr *pBase){
**
** CASE 2:
**
+** If there are exactly two disjuncts one side has x>A and the other side
+** has x=A (for the same x and A) then add a new virtual conjunct term to the
+** WHERE clause of the form "x>=A". Example:
+**
+** x>A OR (x=A AND y>B) adds: x>=A
+**
+** The added conjunct can sometimes be helpful in query planning.
+**
+** CASE 3:
+**
** If all subterms are indexable by a single table T, then set
**
** WhereTerm.eOperator = WO_OR
@@ -114533,12 +116762,26 @@ static void exprAnalyzeOrTerm(
}
/*
- ** Record the set of tables that satisfy case 2. The set might be
+ ** Record the set of tables that satisfy case 3. The set might be
** empty.
*/
pOrInfo->indexable = indexable;
pTerm->eOperator = indexable==0 ? 0 : WO_OR;
+ /* For a two-way OR, attempt to implementation case 2.
+ */
+ if( indexable && pOrWc->nTerm==2 ){
+ int iOne = 0;
+ WhereTerm *pOne;
+ while( (pOne = whereNthSubterm(&pOrWc->a[0],iOne++))!=0 ){
+ int iTwo = 0;
+ WhereTerm *pTwo;
+ while( (pTwo = whereNthSubterm(&pOrWc->a[1],iTwo++))!=0 ){
+ whereCombineDisjuncts(pSrc, pWC, pOne, pTwo);
+ }
+ }
+ }
+
/*
** chngToIN holds a set of tables that *might* satisfy case 1. But
** we have to do some additional checking to see if case 1 really
@@ -114664,12 +116907,11 @@ static void exprAnalyzeOrTerm(
testcase( idxNew==0 );
exprAnalyze(pSrc, pWC, idxNew);
pTerm = &pWC->a[idxTerm];
- pWC->a[idxNew].iParent = idxTerm;
- pTerm->nChild = 1;
+ markTermAsChild(pWC, idxNew, idxTerm);
}else{
sqlite3ExprListDelete(db, pList);
}
- pTerm->eOperator = WO_NOOP; /* case 1 trumps case 2 */
+ pTerm->eOperator = WO_NOOP; /* case 1 trumps case 3 */
}
}
}
@@ -114707,7 +116949,7 @@ static void exprAnalyze(
Bitmask extraRight = 0; /* Extra dependencies on LEFT JOIN */
Expr *pStr1 = 0; /* RHS of LIKE/GLOB operator */
int isComplete = 0; /* RHS of LIKE/GLOB ends with wildcard */
- int noCase = 0; /* LIKE/GLOB distinguishes case */
+ int noCase = 0; /* uppercase equivalent to lowercase */
int op; /* Top-level operator. pExpr->op */
Parse *pParse = pWInfo->pParse; /* Parsing context */
sqlite3 *db = pParse->db; /* Database connection */
@@ -114767,9 +117009,8 @@ static void exprAnalyze(
idxNew = whereClauseInsert(pWC, pDup, TERM_VIRTUAL|TERM_DYNAMIC);
if( idxNew==0 ) return;
pNew = &pWC->a[idxNew];
- pNew->iParent = idxTerm;
+ markTermAsChild(pWC, idxNew, idxTerm);
pTerm = &pWC->a[idxTerm];
- pTerm->nChild = 1;
pTerm->wtFlags |= TERM_COPIED;
if( pExpr->op==TK_EQ
&& !ExprHasProperty(pExpr, EP_FromJoin)
@@ -114826,9 +117067,8 @@ static void exprAnalyze(
testcase( idxNew==0 );
exprAnalyze(pSrc, pWC, idxNew);
pTerm = &pWC->a[idxTerm];
- pWC->a[idxNew].iParent = idxTerm;
+ markTermAsChild(pWC, idxNew, idxTerm);
}
- pTerm->nChild = 2;
}
#endif /* SQLITE_OMIT_BETWEEN_OPTIMIZATION */
@@ -114847,12 +117087,15 @@ static void exprAnalyze(
/* Add constraints to reduce the search space on a LIKE or GLOB
** operator.
**
- ** A like pattern of the form "x LIKE 'abc%'" is changed into constraints
+ ** A like pattern of the form "x LIKE 'aBc%'" is changed into constraints
**
- ** x>='abc' AND x<'abd' AND x LIKE 'abc%'
+ ** x>='ABC' AND x<'abd' AND x LIKE 'aBc%'
**
** The last character of the prefix "abc" is incremented to form the
- ** termination condition "abd".
+ ** termination condition "abd". If case is not significant (the default
+ ** for LIKE) then the lower-bound is made all uppercase and the upper-
+ ** bound is made all lowercase so that the bounds also work when comparing
+ ** BLOBs.
*/
if( pWC->op==TK_AND
&& isLikeOrGlob(pParse, pExpr, &pStr1, &isComplete, &noCase)
@@ -114863,10 +117106,26 @@ static void exprAnalyze(
Expr *pNewExpr2;
int idxNew1;
int idxNew2;
- Token sCollSeqName; /* Name of collating sequence */
+ const char *zCollSeqName; /* Name of collating sequence */
+ const u16 wtFlags = TERM_LIKEOPT | TERM_VIRTUAL | TERM_DYNAMIC;
pLeft = pExpr->x.pList->a[1].pExpr;
pStr2 = sqlite3ExprDup(db, pStr1, 0);
+
+ /* Convert the lower bound to upper-case and the upper bound to
+ ** lower-case (upper-case is less than lower-case in ASCII) so that
+ ** the range constraints also work for BLOBs
+ */
+ if( noCase && !pParse->db->mallocFailed ){
+ int i;
+ char c;
+ pTerm->wtFlags |= TERM_LIKE;
+ for(i=0; (c = pStr1->u.zToken[i])!=0; i++){
+ pStr1->u.zToken[i] = sqlite3Toupper(c);
+ pStr2->u.zToken[i] = sqlite3Tolower(c);
+ }
+ }
+
if( !db->mallocFailed ){
u8 c, *pC; /* Last character before the first wildcard */
pC = (u8*)&pStr2->u.zToken[sqlite3Strlen30(pStr2->u.zToken)-1];
@@ -114883,29 +117142,27 @@ static void exprAnalyze(
}
*pC = c + 1;
}
- sCollSeqName.z = noCase ? "NOCASE" : "BINARY";
- sCollSeqName.n = 6;
+ zCollSeqName = noCase ? "NOCASE" : "BINARY";
pNewExpr1 = sqlite3ExprDup(db, pLeft, 0);
- pNewExpr1 = sqlite3PExpr(pParse, TK_GE,
- sqlite3ExprAddCollateToken(pParse,pNewExpr1,&sCollSeqName),
+ pNewExpr1 = sqlite3PExpr(pParse, TK_GE,
+ sqlite3ExprAddCollateString(pParse,pNewExpr1,zCollSeqName),
pStr1, 0);
transferJoinMarkings(pNewExpr1, pExpr);
- idxNew1 = whereClauseInsert(pWC, pNewExpr1, TERM_VIRTUAL|TERM_DYNAMIC);
+ idxNew1 = whereClauseInsert(pWC, pNewExpr1, wtFlags);
testcase( idxNew1==0 );
exprAnalyze(pSrc, pWC, idxNew1);
pNewExpr2 = sqlite3ExprDup(db, pLeft, 0);
pNewExpr2 = sqlite3PExpr(pParse, TK_LT,
- sqlite3ExprAddCollateToken(pParse,pNewExpr2,&sCollSeqName),
+ sqlite3ExprAddCollateString(pParse,pNewExpr2,zCollSeqName),
pStr2, 0);
transferJoinMarkings(pNewExpr2, pExpr);
- idxNew2 = whereClauseInsert(pWC, pNewExpr2, TERM_VIRTUAL|TERM_DYNAMIC);
+ idxNew2 = whereClauseInsert(pWC, pNewExpr2, wtFlags);
testcase( idxNew2==0 );
exprAnalyze(pSrc, pWC, idxNew2);
pTerm = &pWC->a[idxTerm];
if( isComplete ){
- pWC->a[idxNew1].iParent = idxTerm;
- pWC->a[idxNew2].iParent = idxTerm;
- pTerm->nChild = 2;
+ markTermAsChild(pWC, idxNew1, idxTerm);
+ markTermAsChild(pWC, idxNew2, idxTerm);
}
}
#endif /* SQLITE_OMIT_LIKE_OPTIMIZATION */
@@ -114938,9 +117195,8 @@ static void exprAnalyze(
pNewTerm->leftCursor = pLeft->iTable;
pNewTerm->u.leftColumn = pLeft->iColumn;
pNewTerm->eOperator = WO_MATCH;
- pNewTerm->iParent = idxTerm;
+ markTermAsChild(pWC, idxNew, idxTerm);
pTerm = &pWC->a[idxTerm];
- pTerm->nChild = 1;
pTerm->wtFlags |= TERM_COPIED;
pNewTerm->prereqAll = pTerm->prereqAll;
}
@@ -114961,7 +117217,7 @@ static void exprAnalyze(
if( pExpr->op==TK_NOTNULL
&& pExpr->pLeft->op==TK_COLUMN
&& pExpr->pLeft->iColumn>=0
- && OptimizationEnabled(db, SQLITE_Stat3)
+ && OptimizationEnabled(db, SQLITE_Stat34)
){
Expr *pNewExpr;
Expr *pLeft = pExpr->pLeft;
@@ -114980,9 +117236,8 @@ static void exprAnalyze(
pNewTerm->leftCursor = pLeft->iTable;
pNewTerm->u.leftColumn = pLeft->iColumn;
pNewTerm->eOperator = WO_GT;
- pNewTerm->iParent = idxTerm;
+ markTermAsChild(pWC, idxNew, idxTerm);
pTerm = &pWC->a[idxTerm];
- pTerm->nChild = 1;
pTerm->wtFlags |= TERM_COPIED;
pNewTerm->prereqAll = pTerm->prereqAll;
}
@@ -115202,6 +117457,8 @@ static void constructAutomaticIndex(
Bitmask idxCols; /* Bitmap of columns used for indexing */
Bitmask extraCols; /* Bitmap of additional columns */
u8 sentWarning = 0; /* True if a warnning has been issued */
+ Expr *pPartial = 0; /* Partial Index Expression */
+ int iContinue = 0; /* Jump here to skip excluded rows */
/* Generate code to skip over the creation and initialization of the
** transient index on 2nd and subsequent iterations of the loop. */
@@ -115217,6 +117474,17 @@ static void constructAutomaticIndex(
pLoop = pLevel->pWLoop;
idxCols = 0;
for(pTerm=pWC->a; pTerm<pWCEnd; pTerm++){
+ Expr *pExpr = pTerm->pExpr;
+ assert( !ExprHasProperty(pExpr, EP_FromJoin) /* prereq always non-zero */
+ || pExpr->iRightJoinTable!=pSrc->iCursor /* for the right-hand */
+ || pLoop->prereq!=0 ); /* table of a LEFT JOIN */
+ if( pLoop->prereq==0
+ && (pTerm->wtFlags & TERM_VIRTUAL)==0
+ && !ExprHasProperty(pExpr, EP_FromJoin)
+ && sqlite3ExprIsTableConstant(pExpr, pSrc->iCursor) ){
+ pPartial = sqlite3ExprAnd(pParse->db, pPartial,
+ sqlite3ExprDup(pParse->db, pExpr, 0));
+ }
if( termCanDriveIndex(pTerm, pSrc, notReady) ){
int iCol = pTerm->u.leftColumn;
Bitmask cMask = iCol>=BMS ? MASKBIT(BMS-1) : MASKBIT(iCol);
@@ -115229,7 +117497,9 @@ static void constructAutomaticIndex(
sentWarning = 1;
}
if( (idxCols & cMask)==0 ){
- if( whereLoopResize(pParse->db, pLoop, nKeyCol+1) ) return;
+ if( whereLoopResize(pParse->db, pLoop, nKeyCol+1) ){
+ goto end_auto_index_create;
+ }
pLoop->aLTerm[nKeyCol++] = pTerm;
idxCols |= cMask;
}
@@ -115249,7 +117519,7 @@ static void constructAutomaticIndex(
** if they go out of sync.
*/
extraCols = pSrc->colUsed & (~idxCols | MASKBIT(BMS-1));
- mxBitCol = (pTable->nCol >= BMS-1) ? BMS-1 : pTable->nCol;
+ mxBitCol = MIN(BMS-1,pTable->nCol);
testcase( pTable->nCol==BMS-1 );
testcase( pTable->nCol==BMS-2 );
for(i=0; i<mxBitCol; i++){
@@ -115258,11 +117528,10 @@ static void constructAutomaticIndex(
if( pSrc->colUsed & MASKBIT(BMS-1) ){
nKeyCol += pTable->nCol - BMS + 1;
}
- pLoop->wsFlags |= WHERE_COLUMN_EQ | WHERE_IDX_ONLY;
/* Construct the Index object to describe this index */
pIdx = sqlite3AllocateIndexObject(pParse->db, nKeyCol+1, 0, &zNotUsed);
- if( pIdx==0 ) return;
+ if( pIdx==0 ) goto end_auto_index_create;
pLoop->u.btree.pIndex = pIdx;
pIdx->zName = "auto-index";
pIdx->pTable = pTable;
@@ -115314,18 +117583,29 @@ static void constructAutomaticIndex(
VdbeComment((v, "for %s", pTable->zName));
/* Fill the automatic index with content */
+ sqlite3ExprCachePush(pParse);
addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, pLevel->iTabCur); VdbeCoverage(v);
+ if( pPartial ){
+ iContinue = sqlite3VdbeMakeLabel(v);
+ sqlite3ExprIfFalse(pParse, pPartial, iContinue, SQLITE_JUMPIFNULL);
+ pLoop->wsFlags |= WHERE_PARTIALIDX;
+ }
regRecord = sqlite3GetTempReg(pParse);
sqlite3GenerateIndexKey(pParse, pIdx, pLevel->iTabCur, regRecord, 0, 0, 0, 0);
sqlite3VdbeAddOp2(v, OP_IdxInsert, pLevel->iIdxCur, regRecord);
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
+ if( pPartial ) sqlite3VdbeResolveLabel(v, iContinue);
sqlite3VdbeAddOp2(v, OP_Next, pLevel->iTabCur, addrTop+1); VdbeCoverage(v);
sqlite3VdbeChangeP5(v, SQLITE_STMTSTATUS_AUTOINDEX);
sqlite3VdbeJumpHere(v, addrTop);
sqlite3ReleaseTempReg(pParse, regRecord);
+ sqlite3ExprCachePop(pParse);
/* Jump here when skipping the initialization */
sqlite3VdbeJumpHere(v, addrInit);
+
+end_auto_index_create:
+ sqlite3ExprDelete(pParse->db, pPartial);
}
#endif /* SQLITE_OMIT_AUTOMATIC_INDEX */
@@ -115485,18 +117765,21 @@ static int vtabBestIndex(Parse *pParse, Table *pTab, sqlite3_index_info *p){
}
#endif /* !defined(SQLITE_OMIT_VIRTUALTABLE) */
-
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
/*
** Estimate the location of a particular key among all keys in an
** index. Store the results in aStat as follows:
**
-** aStat[0] Est. number of rows less than pVal
-** aStat[1] Est. number of rows equal to pVal
+** aStat[0] Est. number of rows less than pRec
+** aStat[1] Est. number of rows equal to pRec
**
-** Return SQLITE_OK on success.
+** Return the index of the sample that is the smallest sample that
+** is greater than or equal to pRec. Note that this index is not an index
+** into the aSample[] array - it is an index into a virtual set of samples
+** based on the contents of aSample[] and the number of fields in record
+** pRec.
*/
-static void whereKeyStats(
+static int whereKeyStats(
Parse *pParse, /* Database connection */
Index *pIdx, /* Index to consider domain of */
UnpackedRecord *pRec, /* Vector of values to consider */
@@ -115505,67 +117788,158 @@ static void whereKeyStats(
){
IndexSample *aSample = pIdx->aSample;
int iCol; /* Index of required stats in anEq[] etc. */
+ int i; /* Index of first sample >= pRec */
+ int iSample; /* Smallest sample larger than or equal to pRec */
int iMin = 0; /* Smallest sample not yet tested */
- int i = pIdx->nSample; /* Smallest sample larger than or equal to pRec */
int iTest; /* Next sample to test */
int res; /* Result of comparison operation */
+ int nField; /* Number of fields in pRec */
+ tRowcnt iLower = 0; /* anLt[] + anEq[] of largest sample pRec is > */
#ifndef SQLITE_DEBUG
UNUSED_PARAMETER( pParse );
#endif
assert( pRec!=0 );
- iCol = pRec->nField - 1;
assert( pIdx->nSample>0 );
- assert( pRec->nField>0 && iCol<pIdx->nSampleCol );
+ assert( pRec->nField>0 && pRec->nField<=pIdx->nSampleCol );
+
+ /* Do a binary search to find the first sample greater than or equal
+ ** to pRec. If pRec contains a single field, the set of samples to search
+ ** is simply the aSample[] array. If the samples in aSample[] contain more
+ ** than one fields, all fields following the first are ignored.
+ **
+ ** If pRec contains N fields, where N is more than one, then as well as the
+ ** samples in aSample[] (truncated to N fields), the search also has to
+ ** consider prefixes of those samples. For example, if the set of samples
+ ** in aSample is:
+ **
+ ** aSample[0] = (a, 5)
+ ** aSample[1] = (a, 10)
+ ** aSample[2] = (b, 5)
+ ** aSample[3] = (c, 100)
+ ** aSample[4] = (c, 105)
+ **
+ ** Then the search space should ideally be the samples above and the
+ ** unique prefixes [a], [b] and [c]. But since that is hard to organize,
+ ** the code actually searches this set:
+ **
+ ** 0: (a)
+ ** 1: (a, 5)
+ ** 2: (a, 10)
+ ** 3: (a, 10)
+ ** 4: (b)
+ ** 5: (b, 5)
+ ** 6: (c)
+ ** 7: (c, 100)
+ ** 8: (c, 105)
+ ** 9: (c, 105)
+ **
+ ** For each sample in the aSample[] array, N samples are present in the
+ ** effective sample array. In the above, samples 0 and 1 are based on
+ ** sample aSample[0]. Samples 2 and 3 on aSample[1] etc.
+ **
+ ** Often, sample i of each block of N effective samples has (i+1) fields.
+ ** Except, each sample may be extended to ensure that it is greater than or
+ ** equal to the previous sample in the array. For example, in the above,
+ ** sample 2 is the first sample of a block of N samples, so at first it
+ ** appears that it should be 1 field in size. However, that would make it
+ ** smaller than sample 1, so the binary search would not work. As a result,
+ ** it is extended to two fields. The duplicates that this creates do not
+ ** cause any problems.
+ */
+ nField = pRec->nField;
+ iCol = 0;
+ iSample = pIdx->nSample * nField;
do{
- iTest = (iMin+i)/2;
- res = sqlite3VdbeRecordCompare(aSample[iTest].n, aSample[iTest].p, pRec);
+ int iSamp; /* Index in aSample[] of test sample */
+ int n; /* Number of fields in test sample */
+
+ iTest = (iMin+iSample)/2;
+ iSamp = iTest / nField;
+ if( iSamp>0 ){
+ /* The proposed effective sample is a prefix of sample aSample[iSamp].
+ ** Specifically, the shortest prefix of at least (1 + iTest%nField)
+ ** fields that is greater than the previous effective sample. */
+ for(n=(iTest % nField) + 1; n<nField; n++){
+ if( aSample[iSamp-1].anLt[n-1]!=aSample[iSamp].anLt[n-1] ) break;
+ }
+ }else{
+ n = iTest + 1;
+ }
+
+ pRec->nField = n;
+ res = sqlite3VdbeRecordCompare(aSample[iSamp].n, aSample[iSamp].p, pRec);
if( res<0 ){
+ iLower = aSample[iSamp].anLt[n-1] + aSample[iSamp].anEq[n-1];
+ iMin = iTest+1;
+ }else if( res==0 && n<nField ){
+ iLower = aSample[iSamp].anLt[n-1];
iMin = iTest+1;
+ res = -1;
}else{
- i = iTest;
+ iSample = iTest;
+ iCol = n-1;
}
- }while( res && iMin<i );
+ }while( res && iMin<iSample );
+ i = iSample / nField;
#ifdef SQLITE_DEBUG
/* The following assert statements check that the binary search code
** above found the right answer. This block serves no purpose other
** than to invoke the asserts. */
- if( res==0 ){
- /* If (res==0) is true, then sample $i must be equal to pRec */
- assert( i<pIdx->nSample );
- assert( 0==sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)
- || pParse->db->mallocFailed );
- }else{
- /* Otherwise, pRec must be smaller than sample $i and larger than
- ** sample ($i-1). */
- assert( i==pIdx->nSample
- || sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)>0
- || pParse->db->mallocFailed );
- assert( i==0
- || sqlite3VdbeRecordCompare(aSample[i-1].n, aSample[i-1].p, pRec)<0
- || pParse->db->mallocFailed );
+ if( pParse->db->mallocFailed==0 ){
+ if( res==0 ){
+ /* If (res==0) is true, then pRec must be equal to sample i. */
+ assert( i<pIdx->nSample );
+ assert( iCol==nField-1 );
+ pRec->nField = nField;
+ assert( 0==sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)
+ || pParse->db->mallocFailed
+ );
+ }else{
+ /* Unless i==pIdx->nSample, indicating that pRec is larger than
+ ** all samples in the aSample[] array, pRec must be smaller than the
+ ** (iCol+1) field prefix of sample i. */
+ assert( i<=pIdx->nSample && i>=0 );
+ pRec->nField = iCol+1;
+ assert( i==pIdx->nSample
+ || sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)>0
+ || pParse->db->mallocFailed );
+
+ /* if i==0 and iCol==0, then record pRec is smaller than all samples
+ ** in the aSample[] array. Otherwise, if (iCol>0) then pRec must
+ ** be greater than or equal to the (iCol) field prefix of sample i.
+ ** If (i>0), then pRec must also be greater than sample (i-1). */
+ if( iCol>0 ){
+ pRec->nField = iCol;
+ assert( sqlite3VdbeRecordCompare(aSample[i].n, aSample[i].p, pRec)<=0
+ || pParse->db->mallocFailed );
+ }
+ if( i>0 ){
+ pRec->nField = nField;
+ assert( sqlite3VdbeRecordCompare(aSample[i-1].n, aSample[i-1].p, pRec)<0
+ || pParse->db->mallocFailed );
+ }
+ }
}
#endif /* ifdef SQLITE_DEBUG */
- /* At this point, aSample[i] is the first sample that is greater than
- ** or equal to pVal. Or if i==pIdx->nSample, then all samples are less
- ** than pVal. If aSample[i]==pVal, then res==0.
- */
if( res==0 ){
+ /* Record pRec is equal to sample i */
+ assert( iCol==nField-1 );
aStat[0] = aSample[i].anLt[iCol];
aStat[1] = aSample[i].anEq[iCol];
}else{
- tRowcnt iLower, iUpper, iGap;
- if( i==0 ){
- iLower = 0;
- iUpper = aSample[0].anLt[iCol];
+ /* At this point, the (iCol+1) field prefix of aSample[i] is the first
+ ** sample that is greater than pRec. Or, if i==pIdx->nSample then pRec
+ ** is larger than all samples in the array. */
+ tRowcnt iUpper, iGap;
+ if( i>=pIdx->nSample ){
+ iUpper = sqlite3LogEstToInt(pIdx->aiRowLogEst[0]);
}else{
- i64 nRow0 = sqlite3LogEstToInt(pIdx->aiRowLogEst[0]);
- iUpper = i>=pIdx->nSample ? nRow0 : aSample[i].anLt[iCol];
- iLower = aSample[i-1].anEq[iCol] + aSample[i-1].anLt[iCol];
+ iUpper = aSample[i].anLt[iCol];
}
- aStat[1] = pIdx->aAvgEq[iCol];
+
if( iLower>=iUpper ){
iGap = 0;
}else{
@@ -115577,7 +117951,12 @@ static void whereKeyStats(
iGap = iGap/3;
}
aStat[0] = iLower + iGap;
+ aStat[1] = pIdx->aAvgEq[iCol];
}
+
+ /* Restore the pRec->nField value before returning. */
+ pRec->nField = nField;
+ return i;
}
#endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */
@@ -115728,7 +118107,7 @@ static int whereRangeSkipScanEst(
** If either of the upper or lower bound is not present, then NULL is passed in
** place of the corresponding WhereTerm.
**
-** The value in (pBuilder->pNew->u.btree.nEq) is the index of the index
+** The value in (pBuilder->pNew->u.btree.nEq) is the number of the index
** column subject to the range constraint. Or, equivalently, the number of
** equality constraints optimized by the proposed index scan. For example,
** assuming index p is on t1(a, b), and the SQL query is:
@@ -115744,7 +118123,7 @@ static int whereRangeSkipScanEst(
**
** When this function is called, *pnOut is set to the sqlite3LogEst() of the
** number of rows that the index scan is expected to visit without
-** considering the range constraints. If nEq is 0, this is the number of
+** considering the range constraints. If nEq is 0, then *pnOut is the number of
** rows in the index. Assuming no error occurs, *pnOut is adjusted (reduced)
** to account for the range constraints pLower and pUpper.
**
@@ -115768,10 +118147,7 @@ static int whereRangeScanEst(
Index *p = pLoop->u.btree.pIndex;
int nEq = pLoop->u.btree.nEq;
- if( p->nSample>0
- && nEq<p->nSampleCol
- && OptimizationEnabled(pParse->db, SQLITE_Stat3)
- ){
+ if( p->nSample>0 && nEq<p->nSampleCol ){
if( nEq==pBuilder->nRecValid ){
UnpackedRecord *pRec = pBuilder->pRec;
tRowcnt a[2];
@@ -115787,15 +118163,19 @@ static int whereRangeScanEst(
** is not a simple variable or literal value), the lower bound of the
** range is $P. Due to a quirk in the way whereKeyStats() works, even
** if $L is available, whereKeyStats() is called for both ($P) and
- ** ($P:$L) and the larger of the two returned values used.
+ ** ($P:$L) and the larger of the two returned values is used.
**
** Similarly, iUpper is to be set to the estimate of the number of rows
** less than the upper bound of the range query. Where the upper bound
** is either ($P) or ($P:$U). Again, even if $U is available, both values
** of iUpper are requested of whereKeyStats() and the smaller used.
+ **
+ ** The number of rows between the two bounds is then just iUpper-iLower.
*/
- tRowcnt iLower;
- tRowcnt iUpper;
+ tRowcnt iLower; /* Rows less than the lower bound */
+ tRowcnt iUpper; /* Rows less than the upper bound */
+ int iLwrIdx = -2; /* aSample[] for the lower bound */
+ int iUprIdx = -1; /* aSample[] for the upper bound */
if( pRec ){
testcase( pRec->nField!=pBuilder->nRecValid );
@@ -115809,7 +118189,7 @@ static int whereRangeScanEst(
/* Determine iLower and iUpper using ($P) only. */
if( nEq==0 ){
iLower = 0;
- iUpper = sqlite3LogEstToInt(p->aiRowLogEst[0]);
+ iUpper = p->nRowEst0;
}else{
/* Note: this call could be optimized away - since the same values must
** have been requested when testing key $P in whereEqualScanEst(). */
@@ -115833,7 +118213,7 @@ static int whereRangeScanEst(
rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq, &bOk);
if( rc==SQLITE_OK && bOk ){
tRowcnt iNew;
- whereKeyStats(pParse, p, pRec, 0, a);
+ iLwrIdx = whereKeyStats(pParse, p, pRec, 0, a);
iNew = a[0] + ((pLower->eOperator & (WO_GT|WO_LE)) ? a[1] : 0);
if( iNew>iLower ) iLower = iNew;
nOut--;
@@ -115848,7 +118228,7 @@ static int whereRangeScanEst(
rc = sqlite3Stat4ProbeSetValue(pParse, p, &pRec, pExpr, aff, nEq, &bOk);
if( rc==SQLITE_OK && bOk ){
tRowcnt iNew;
- whereKeyStats(pParse, p, pRec, 1, a);
+ iUprIdx = whereKeyStats(pParse, p, pRec, 1, a);
iNew = a[0] + ((pUpper->eOperator & (WO_GT|WO_LE)) ? a[1] : 0);
if( iNew<iUpper ) iUpper = iNew;
nOut--;
@@ -115860,6 +118240,11 @@ static int whereRangeScanEst(
if( rc==SQLITE_OK ){
if( iUpper>iLower ){
nNew = sqlite3LogEst(iUpper - iLower);
+ /* TUNING: If both iUpper and iLower are derived from the same
+ ** sample, then assume they are 4x more selective. This brings
+ ** the estimated selectivity more in line with what it would be
+ ** if estimated without the use of STAT3/4 tables. */
+ if( iLwrIdx==iUprIdx ) nNew -= 20; assert( 20==sqlite3LogEst(4) );
}else{
nNew = 10; assert( 10==sqlite3LogEst(2) );
}
@@ -115884,12 +118269,15 @@ static int whereRangeScanEst(
nNew = whereRangeAdjust(pLower, nOut);
nNew = whereRangeAdjust(pUpper, nNew);
- /* TUNING: If there is both an upper and lower limit, assume the range is
+ /* TUNING: If there is both an upper and lower limit and neither limit
+ ** has an application-defined likelihood(), assume the range is
** reduced by an additional 75%. This means that, by default, an open-ended
** range query (e.g. col > ?) is assumed to match 1/4 of the rows in the
** index. While a closed range (e.g. col BETWEEN ? AND ?) is estimated to
** match 1/64 of the index. */
- if( pLower && pUpper ) nNew -= 20;
+ if( pLower && pLower->truthProb>0 && pUpper && pUpper->truthProb>0 ){
+ nNew -= 20;
+ }
nOut -= (pLower!=0) + (pUpper!=0);
if( nNew<10 ) nNew = 10;
@@ -116041,20 +118429,43 @@ static int whereInScanEst(
** but joins might run a little slower. The trick is to disable as much
** as we can without disabling too much. If we disabled in (1), we'd get
** the wrong answer. See ticket #813.
+**
+** If all the children of a term are disabled, then that term is also
+** automatically disabled. In this way, terms get disabled if derived
+** virtual terms are tested first. For example:
+**
+** x GLOB 'abc*' AND x>='abc' AND x<'acd'
+** \___________/ \______/ \_____/
+** parent child1 child2
+**
+** Only the parent term was in the original WHERE clause. The child1
+** and child2 terms were added by the LIKE optimization. If both of
+** the virtual child terms are valid, then testing of the parent can be
+** skipped.
+**
+** Usually the parent term is marked as TERM_CODED. But if the parent
+** term was originally TERM_LIKE, then the parent gets TERM_LIKECOND instead.
+** The TERM_LIKECOND marking indicates that the term should be coded inside
+** a conditional such that is only evaluated on the second pass of a
+** LIKE-optimization loop, when scanning BLOBs instead of strings.
*/
static void disableTerm(WhereLevel *pLevel, WhereTerm *pTerm){
- if( pTerm
+ int nLoop = 0;
+ while( pTerm
&& (pTerm->wtFlags & TERM_CODED)==0
&& (pLevel->iLeftJoin==0 || ExprHasProperty(pTerm->pExpr, EP_FromJoin))
&& (pLevel->notReady & pTerm->prereqAll)==0
){
- pTerm->wtFlags |= TERM_CODED;
- if( pTerm->iParent>=0 ){
- WhereTerm *pOther = &pTerm->pWC->a[pTerm->iParent];
- if( (--pOther->nChild)==0 ){
- disableTerm(pLevel, pOther);
- }
+ if( nLoop && (pTerm->wtFlags & TERM_LIKE)!=0 ){
+ pTerm->wtFlags |= TERM_LIKECOND;
+ }else{
+ pTerm->wtFlags |= TERM_CODED;
}
+ if( pTerm->iParent<0 ) break;
+ pTerm = &pTerm->pWC->a[pTerm->iParent];
+ pTerm->nChild--;
+ if( pTerm->nChild!=0 ) break;
+ nLoop++;
}
}
@@ -116249,7 +118660,7 @@ static int codeAllEqualityTerms(
pLoop = pLevel->pWLoop;
assert( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 );
nEq = pLoop->u.btree.nEq;
- nSkip = pLoop->u.btree.nSkip;
+ nSkip = pLoop->nSkip;
pIdx = pLoop->u.btree.pIndex;
assert( pIdx!=0 );
@@ -116363,7 +118774,7 @@ static void explainAppendTerm(
static void explainIndexRange(StrAccum *pStr, WhereLoop *pLoop, Table *pTab){
Index *pIndex = pLoop->u.btree.pIndex;
u16 nEq = pLoop->u.btree.nEq;
- u16 nSkip = pLoop->u.btree.nSkip;
+ u16 nSkip = pLoop->nSkip;
int i, j;
Column *aCol = pTab->aCol;
i16 *aiColumn = pIndex->aiColumn;
@@ -116394,11 +118805,14 @@ static void explainIndexRange(StrAccum *pStr, WhereLoop *pLoop, Table *pTab){
/*
** This function is a no-op unless currently processing an EXPLAIN QUERY PLAN
-** command. If the query being compiled is an EXPLAIN QUERY PLAN, a single
-** record is added to the output to describe the table scan strategy in
-** pLevel.
+** command, or if either SQLITE_DEBUG or SQLITE_ENABLE_STMT_SCANSTATUS was
+** defined at compile-time. If it is not a no-op, a single OP_Explain opcode
+** is added to the output to describe the table scan strategy in pLevel.
+**
+** If an OP_Explain opcode is added to the VM, its address is returned.
+** Otherwise, if no OP_Explain is coded, zero is returned.
*/
-static void explainOneScan(
+static int explainOneScan(
Parse *pParse, /* Parse context */
SrcList *pTabList, /* Table list this loop refers to */
WhereLevel *pLevel, /* Scan to write OP_Explain opcode for */
@@ -116406,7 +118820,8 @@ static void explainOneScan(
int iFrom, /* Value for "from" column of output */
u16 wctrlFlags /* Flags passed to sqlite3WhereBegin() */
){
-#ifndef SQLITE_DEBUG
+ int ret = 0;
+#if !defined(SQLITE_DEBUG) && !defined(SQLITE_ENABLE_STMT_SCANSTATUS)
if( pParse->explain==2 )
#endif
{
@@ -116423,7 +118838,7 @@ static void explainOneScan(
pLoop = pLevel->pWLoop;
flags = pLoop->wsFlags;
- if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_ONETABLE_ONLY) ) return;
+ if( (flags&WHERE_MULTI_OR) || (wctrlFlags&WHERE_ONETABLE_ONLY) ) return 0;
isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0
|| ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
@@ -116452,6 +118867,8 @@ static void explainOneScan(
if( isSearch ){
zFmt = "PRIMARY KEY";
}
+ }else if( flags & WHERE_PARTIALIDX ){
+ zFmt = "AUTOMATIC PARTIAL COVERING INDEX";
}else if( flags & WHERE_AUTO_INDEX ){
zFmt = "AUTOMATIC COVERING INDEX";
}else if( flags & WHERE_IDX_ONLY ){
@@ -116493,13 +118910,73 @@ static void explainOneScan(
}
#endif
zMsg = sqlite3StrAccumFinish(&str);
- sqlite3VdbeAddOp4(v, OP_Explain, iId, iLevel, iFrom, zMsg, P4_DYNAMIC);
+ ret = sqlite3VdbeAddOp4(v, OP_Explain, iId, iLevel, iFrom, zMsg,P4_DYNAMIC);
}
+ return ret;
}
#else
-# define explainOneScan(u,v,w,x,y,z)
+# define explainOneScan(u,v,w,x,y,z) 0
#endif /* SQLITE_OMIT_EXPLAIN */
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
+/*
+** Configure the VM passed as the first argument with an
+** sqlite3_stmt_scanstatus() entry corresponding to the scan used to
+** implement level pLvl. Argument pSrclist is a pointer to the FROM
+** clause that the scan reads data from.
+**
+** If argument addrExplain is not 0, it must be the address of an
+** OP_Explain instruction that describes the same loop.
+*/
+static void addScanStatus(
+ Vdbe *v, /* Vdbe to add scanstatus entry to */
+ SrcList *pSrclist, /* FROM clause pLvl reads data from */
+ WhereLevel *pLvl, /* Level to add scanstatus() entry for */
+ int addrExplain /* Address of OP_Explain (or 0) */
+){
+ const char *zObj = 0;
+ WhereLoop *pLoop = pLvl->pWLoop;
+ if( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 && pLoop->u.btree.pIndex!=0 ){
+ zObj = pLoop->u.btree.pIndex->zName;
+ }else{
+ zObj = pSrclist->a[pLvl->iFrom].zName;
+ }
+ sqlite3VdbeScanStatus(
+ v, addrExplain, pLvl->addrBody, pLvl->addrVisit, pLoop->nOut, zObj
+ );
+}
+#else
+# define addScanStatus(a, b, c, d) ((void)d)
+#endif
+
+/*
+** If the most recently coded instruction is a constant range contraint
+** that originated from the LIKE optimization, then change the P3 to be
+** pLoop->iLikeRepCntr and set P5.
+**
+** The LIKE optimization trys to evaluate "x LIKE 'abc%'" as a range
+** expression: "x>='ABC' AND x<'abd'". But this requires that the range
+** scan loop run twice, once for strings and a second time for BLOBs.
+** The OP_String opcodes on the second pass convert the upper and lower
+** bound string contants to blobs. This routine makes the necessary changes
+** to the OP_String opcodes for that to happen.
+*/
+static void whereLikeOptimizationStringFixup(
+ Vdbe *v, /* prepared statement under construction */
+ WhereLevel *pLevel, /* The loop that contains the LIKE operator */
+ WhereTerm *pTerm /* The upper or lower bound just coded */
+){
+ if( pTerm->wtFlags & TERM_LIKEOPT ){
+ VdbeOp *pOp;
+ assert( pLevel->iLikeRepCntr>0 );
+ pOp = sqlite3VdbeGetOp(v, -1);
+ assert( pOp!=0 );
+ assert( pOp->opcode==OP_String8
+ || pTerm->pWC->pWInfo->pParse->db->mallocFailed );
+ pOp->p3 = pLevel->iLikeRepCntr;
+ pOp->p5 = 1;
+ }
+}
/*
** Generate code for the start of the iLevel-th loop in the WHERE clause
@@ -116800,7 +119277,7 @@ static Bitmask codeOneLoopStart(
pIdx = pLoop->u.btree.pIndex;
iIdxCur = pLevel->iIdxCur;
- assert( nEq>=pLoop->u.btree.nSkip );
+ assert( nEq>=pLoop->nSkip );
/* If this loop satisfies a sort order (pOrderBy) request that
** was passed to this function to implement a "SELECT min(x) ..."
@@ -116817,7 +119294,7 @@ static Bitmask codeOneLoopStart(
&& pWInfo->nOBSat>0
&& (pIdx->nKeyCol>nEq)
){
- assert( pLoop->u.btree.nSkip==0 );
+ assert( pLoop->nSkip==0 );
bSeekPastNull = 1;
nExtraReg = 1;
}
@@ -116829,10 +119306,25 @@ static Bitmask codeOneLoopStart(
if( pLoop->wsFlags & WHERE_BTM_LIMIT ){
pRangeStart = pLoop->aLTerm[j++];
nExtraReg = 1;
+ /* Like optimization range constraints always occur in pairs */
+ assert( (pRangeStart->wtFlags & TERM_LIKEOPT)==0 ||
+ (pLoop->wsFlags & WHERE_TOP_LIMIT)!=0 );
}
if( pLoop->wsFlags & WHERE_TOP_LIMIT ){
pRangeEnd = pLoop->aLTerm[j++];
nExtraReg = 1;
+ if( (pRangeEnd->wtFlags & TERM_LIKEOPT)!=0 ){
+ assert( pRangeStart!=0 ); /* LIKE opt constraints */
+ assert( pRangeStart->wtFlags & TERM_LIKEOPT ); /* occur in pairs */
+ pLevel->iLikeRepCntr = ++pParse->nMem;
+ testcase( bRev );
+ testcase( pIdx->aSortOrder[nEq]==SQLITE_SO_DESC );
+ sqlite3VdbeAddOp2(v, OP_Integer,
+ bRev ^ (pIdx->aSortOrder[nEq]==SQLITE_SO_DESC),
+ pLevel->iLikeRepCntr);
+ VdbeComment((v, "LIKE loop counter"));
+ pLevel->addrLikeRep = sqlite3VdbeCurrentAddr(v);
+ }
if( pRangeStart==0
&& (j = pIdx->aiColumn[nEq])>=0
&& pIdx->pTable->aCol[j].notNull==0
@@ -116875,6 +119367,7 @@ static Bitmask codeOneLoopStart(
if( pRangeStart ){
Expr *pRight = pRangeStart->pExpr->pRight;
sqlite3ExprCode(pParse, pRight, regBase+nEq);
+ whereLikeOptimizationStringFixup(v, pLevel, pRangeStart);
if( (pRangeStart->wtFlags & TERM_VNULL)==0
&& sqlite3ExprCanBeNull(pRight)
){
@@ -116920,6 +119413,7 @@ static Bitmask codeOneLoopStart(
Expr *pRight = pRangeEnd->pExpr->pRight;
sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
sqlite3ExprCode(pParse, pRight, regBase+nEq);
+ whereLikeOptimizationStringFixup(v, pLevel, pRangeEnd);
if( (pRangeEnd->wtFlags & TERM_VNULL)==0
&& sqlite3ExprCanBeNull(pRight)
){
@@ -117130,10 +119624,9 @@ static Bitmask codeOneLoopStart(
Expr *pExpr = pWC->a[iTerm].pExpr;
if( &pWC->a[iTerm] == pTerm ) continue;
if( ExprHasProperty(pExpr, EP_FromJoin) ) continue;
- testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO );
- testcase( pWC->a[iTerm].wtFlags & TERM_VIRTUAL );
- if( pWC->a[iTerm].wtFlags & (TERM_ORINFO|TERM_VIRTUAL) ) continue;
+ if( (pWC->a[iTerm].wtFlags & TERM_VIRTUAL)!=0 ) continue;
if( (pWC->a[iTerm].eOperator & WO_ALL)==0 ) continue;
+ testcase( pWC->a[iTerm].wtFlags & TERM_ORINFO );
pExpr = sqlite3ExprDup(db, pExpr, 0);
pAndExpr = sqlite3ExprAnd(db, pAndExpr, pExpr);
}
@@ -117148,7 +119641,8 @@ static Bitmask codeOneLoopStart(
*/
wctrlFlags = WHERE_OMIT_OPEN_CLOSE
| WHERE_FORCE_TABLE
- | WHERE_ONETABLE_ONLY;
+ | WHERE_ONETABLE_ONLY
+ | WHERE_NO_AUTOINDEX;
for(ii=0; ii<pOrWc->nTerm; ii++){
WhereTerm *pOrTerm = &pOrWc->a[ii];
if( pOrTerm->leftCursor==iCur || (pOrTerm->eOperator & WO_AND)!=0 ){
@@ -117166,9 +119660,11 @@ static Bitmask codeOneLoopStart(
assert( pSubWInfo || pParse->nErr || db->mallocFailed );
if( pSubWInfo ){
WhereLoop *pSubLoop;
- explainOneScan(
+ int addrExplain = explainOneScan(
pParse, pOrTab, &pSubWInfo->a[0], iLevel, pLevel->iFrom, 0
);
+ addScanStatus(v, pOrTab, &pSubWInfo->a[0], addrExplain);
+
/* This is the sub-WHERE clause body. First skip over
** duplicate rows from prior sub-WHERE clauses, and record the
** rowid (or PRIMARY KEY) for the current row so that the same
@@ -117299,11 +119795,16 @@ static Bitmask codeOneLoopStart(
}
}
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
+ pLevel->addrVisit = sqlite3VdbeCurrentAddr(v);
+#endif
+
/* Insert code to test every subexpression that can be completely
** computed using the current set of tables.
*/
for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
Expr *pE;
+ int skipLikeAddr = 0;
testcase( pTerm->wtFlags & TERM_VIRTUAL );
testcase( pTerm->wtFlags & TERM_CODED );
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
@@ -117318,7 +119819,13 @@ static Bitmask codeOneLoopStart(
if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){
continue;
}
+ if( pTerm->wtFlags & TERM_LIKECOND ){
+ assert( pLevel->iLikeRepCntr>0 );
+ skipLikeAddr = sqlite3VdbeAddOp1(v, OP_IfNot, pLevel->iLikeRepCntr);
+ VdbeCoverage(v);
+ }
sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL);
+ if( skipLikeAddr ) sqlite3VdbeJumpHere(v, skipLikeAddr);
pTerm->wtFlags |= TERM_CODED;
}
@@ -117438,7 +119945,7 @@ static void whereLoopPrint(WhereLoop *p, WhereClause *pWC){
sqlite3_free(z);
}
if( p->wsFlags & WHERE_SKIPSCAN ){
- sqlite3DebugPrintf(" f %05x %d-%d", p->wsFlags, p->nLTerm,p->u.btree.nSkip);
+ sqlite3DebugPrintf(" f %05x %d-%d", p->wsFlags, p->nLTerm,p->nSkip);
}else{
sqlite3DebugPrintf(" f %05x N %d", p->wsFlags, p->nLTerm);
}
@@ -117474,7 +119981,6 @@ static void whereLoopClearUnion(sqlite3 *db, WhereLoop *p){
p->u.vtab.idxStr = 0;
}else if( (p->wsFlags & WHERE_AUTO_INDEX)!=0 && p->u.btree.pIndex!=0 ){
sqlite3DbFree(db, p->u.btree.pIndex->zColAff);
- sqlite3KeyInfoUnref(p->u.btree.pIndex->pKeyInfo);
sqlite3DbFree(db, p->u.btree.pIndex);
p->u.btree.pIndex = 0;
}
@@ -117549,10 +120055,11 @@ static void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){
}
/*
-** Return TRUE if both of the following are true:
+** Return TRUE if all of the following are true:
**
** (1) X has the same or lower cost that Y
** (2) X is a proper subset of Y
+** (3) X skips at least as many columns as Y
**
** By "proper subset" we mean that X uses fewer WHERE clause terms
** than Y and that every WHERE clause term used by X is also used
@@ -117560,19 +120067,25 @@ static void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){
**
** If X is a proper subset of Y then Y is a better choice and ought
** to have a lower cost. This routine returns TRUE when that cost
-** relationship is inverted and needs to be adjusted.
+** relationship is inverted and needs to be adjusted. The third rule
+** was added because if X uses skip-scan less than Y it still might
+** deserve a lower cost even if it is a proper subset of Y.
*/
static int whereLoopCheaperProperSubset(
const WhereLoop *pX, /* First WhereLoop to compare */
const WhereLoop *pY /* Compare against this WhereLoop */
){
int i, j;
- if( pX->nLTerm >= pY->nLTerm ) return 0; /* X is not a subset of Y */
+ if( pX->nLTerm-pX->nSkip >= pY->nLTerm-pY->nSkip ){
+ return 0; /* X is not a subset of Y */
+ }
+ if( pY->nSkip > pX->nSkip ) return 0;
if( pX->rRun >= pY->rRun ){
if( pX->rRun > pY->rRun ) return 0; /* X costs more than Y */
if( pX->nOut > pY->nOut ) return 0; /* X costs more than Y */
}
for(i=pX->nLTerm-1; i>=0; i--){
+ if( pX->aLTerm[i]==0 ) continue;
for(j=pY->nLTerm-1; j>=0; j--){
if( pY->aLTerm[j]==pX->aLTerm[i] ) break;
}
@@ -117594,33 +120107,24 @@ static int whereLoopCheaperProperSubset(
** To say "WhereLoop X is a proper subset of Y" means that X uses fewer
** WHERE clause terms than Y and that every WHERE clause term used by X is
** also used by Y.
-**
-** This adjustment is omitted for SKIPSCAN loops. In a SKIPSCAN loop, the
-** WhereLoop.nLTerm field is not an accurate measure of the number of WHERE
-** clause terms covered, since some of the first nLTerm entries in aLTerm[]
-** will be NULL (because they are skipped). That makes it more difficult
-** to compare the loops. We could add extra code to do the comparison, and
-** perhaps we will someday. But SKIPSCAN is sufficiently uncommon, and this
-** adjustment is sufficient minor, that it is very difficult to construct
-** a test case where the extra code would improve the query plan. Better
-** to avoid the added complexity and just omit cost adjustments to SKIPSCAN
-** loops.
*/
static void whereLoopAdjustCost(const WhereLoop *p, WhereLoop *pTemplate){
if( (pTemplate->wsFlags & WHERE_INDEXED)==0 ) return;
- if( (pTemplate->wsFlags & WHERE_SKIPSCAN)!=0 ) return;
for(; p; p=p->pNextLoop){
if( p->iTab!=pTemplate->iTab ) continue;
if( (p->wsFlags & WHERE_INDEXED)==0 ) continue;
- if( (p->wsFlags & WHERE_SKIPSCAN)!=0 ) continue;
if( whereLoopCheaperProperSubset(p, pTemplate) ){
/* Adjust pTemplate cost downward so that it is cheaper than its
- ** subset p */
+ ** subset p. */
+ WHERETRACE(0x80,("subset cost adjustment %d,%d to %d,%d\n",
+ pTemplate->rRun, pTemplate->nOut, p->rRun, p->nOut-1));
pTemplate->rRun = p->rRun;
pTemplate->nOut = p->nOut - 1;
}else if( whereLoopCheaperProperSubset(pTemplate, p) ){
/* Adjust pTemplate cost upward so that it is costlier than p since
** pTemplate is a proper subset of p */
+ WHERETRACE(0x80,("subset cost adjustment %d,%d to %d,%d\n",
+ pTemplate->rRun, pTemplate->nOut, p->rRun, p->nOut+1));
pTemplate->rRun = p->rRun;
pTemplate->nOut = p->nOut + 1;
}
@@ -117665,8 +120169,9 @@ static WhereLoop **whereLoopFindLesser(
/* Any loop using an appliation-defined index (or PRIMARY KEY or
** UNIQUE constraint) with one or more == constraints is better
- ** than an automatic index. */
+ ** than an automatic index. Unless it is a skip-scan. */
if( (p->wsFlags & WHERE_AUTO_INDEX)!=0
+ && (pTemplate->nSkip)==0
&& (pTemplate->wsFlags & WHERE_INDEXED)!=0
&& (pTemplate->wsFlags & WHERE_COLUMN_EQ)!=0
&& (p->prereq & pTemplate->prereq)==pTemplate->prereq
@@ -117825,10 +120330,30 @@ static int whereLoopInsert(WhereLoopBuilder *pBuilder, WhereLoop *pTemplate){
** Adjust the WhereLoop.nOut value downward to account for terms of the
** WHERE clause that reference the loop but which are not used by an
** index.
-**
-** In the current implementation, the first extra WHERE clause term reduces
-** the number of output rows by a factor of 10 and each additional term
-** reduces the number of output rows by sqrt(2).
+*
+** For every WHERE clause term that is not used by the index
+** and which has a truth probability assigned by one of the likelihood(),
+** likely(), or unlikely() SQL functions, reduce the estimated number
+** of output rows by the probability specified.
+**
+** TUNING: For every WHERE clause term that is not used by the index
+** and which does not have an assigned truth probability, heuristics
+** described below are used to try to estimate the truth probability.
+** TODO --> Perhaps this is something that could be improved by better
+** table statistics.
+**
+** Heuristic 1: Estimate the truth probability as 93.75%. The 93.75%
+** value corresponds to -1 in LogEst notation, so this means decrement
+** the WhereLoop.nOut field for every such WHERE clause term.
+**
+** Heuristic 2: If there exists one or more WHERE clause terms of the
+** form "x==EXPR" and EXPR is not a constant 0 or 1, then make sure the
+** final output row estimate is no greater than 1/4 of the total number
+** of rows in the table. In other words, assume that x==EXPR will filter
+** out at least 3 out of 4 rows. If EXPR is -1 or 0 or 1, then maybe the
+** "x" column is boolean or else -1 or 0 or 1 is a common default value
+** on the "x" column and so in that case only cap the output row estimate
+** at 1/2 instead of 1/4.
*/
static void whereLoopOutputAdjust(
WhereClause *pWC, /* The WHERE clause */
@@ -117837,9 +120362,10 @@ static void whereLoopOutputAdjust(
){
WhereTerm *pTerm, *pX;
Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf);
- int i, j;
- int nEq = 0; /* Number of = constraints not within likely()/unlikely() */
+ int i, j, k;
+ LogEst iReduce = 0; /* pLoop->nOut should not exceed nRow-iReduce */
+ assert( (pLoop->wsFlags & WHERE_AUTO_INDEX)==0 );
for(i=pWC->nTerm, pTerm=pWC->a; i>0; i--, pTerm++){
if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) break;
if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;
@@ -117852,20 +120378,26 @@ static void whereLoopOutputAdjust(
}
if( j<0 ){
if( pTerm->truthProb<=0 ){
+ /* If a truth probability is specified using the likelihood() hints,
+ ** then use the probability provided by the application. */
pLoop->nOut += pTerm->truthProb;
}else{
+ /* In the absence of explicit truth probabilities, use heuristics to
+ ** guess a reasonable truth probability. */
pLoop->nOut--;
- if( pTerm->eOperator&WO_EQ ) nEq++;
+ if( pTerm->eOperator&WO_EQ ){
+ Expr *pRight = pTerm->pExpr->pRight;
+ if( sqlite3ExprIsInteger(pRight, &k) && k>=(-1) && k<=1 ){
+ k = 10;
+ }else{
+ k = 20;
+ }
+ if( iReduce<k ) iReduce = k;
+ }
}
}
}
- /* TUNING: If there is at least one equality constraint in the WHERE
- ** clause that does not have a likelihood() explicitly assigned to it
- ** then do not let the estimated number of output rows exceed half
- ** the number of rows in the table. */
- if( nEq && pLoop->nOut>nRow-10 ){
- pLoop->nOut = nRow - 10;
- }
+ if( pLoop->nOut > nRow-iReduce ) pLoop->nOut = nRow - iReduce;
}
/*
@@ -117906,7 +120438,7 @@ static int whereLoopAddBtreeIndex(
Bitmask saved_prereq; /* Original value of pNew->prereq */
u16 saved_nLTerm; /* Original value of pNew->nLTerm */
u16 saved_nEq; /* Original value of pNew->u.btree.nEq */
- u16 saved_nSkip; /* Original value of pNew->u.btree.nSkip */
+ u16 saved_nSkip; /* Original value of pNew->nSkip */
u32 saved_wsFlags; /* Original value of pNew->wsFlags */
LogEst saved_nOut; /* Original value of pNew->nOut */
int iCol; /* Index of the column in the table */
@@ -117935,7 +120467,7 @@ static int whereLoopAddBtreeIndex(
pTerm = whereScanInit(&scan, pBuilder->pWC, pSrc->iCursor, iCol,
opMask, pProbe);
saved_nEq = pNew->u.btree.nEq;
- saved_nSkip = pNew->u.btree.nSkip;
+ saved_nSkip = pNew->nSkip;
saved_nLTerm = pNew->nLTerm;
saved_wsFlags = pNew->wsFlags;
saved_prereq = pNew->prereq;
@@ -117943,44 +120475,6 @@ static int whereLoopAddBtreeIndex(
pNew->rSetup = 0;
rSize = pProbe->aiRowLogEst[0];
rLogSize = estLog(rSize);
-
- /* Consider using a skip-scan if there are no WHERE clause constraints
- ** available for the left-most terms of the index, and if the average
- ** number of repeats in the left-most terms is at least 18.
- **
- ** The magic number 18 is selected on the basis that scanning 17 rows
- ** is almost always quicker than an index seek (even though if the index
- ** contains fewer than 2^17 rows we assume otherwise in other parts of
- ** the code). And, even if it is not, it should not be too much slower.
- ** On the other hand, the extra seeks could end up being significantly
- ** more expensive. */
- assert( 42==sqlite3LogEst(18) );
- if( saved_nEq==saved_nSkip
- && saved_nEq+1<pProbe->nKeyCol
- && pProbe->aiRowLogEst[saved_nEq+1]>=42 /* TUNING: Minimum for skip-scan */
- && (rc = whereLoopResize(db, pNew, pNew->nLTerm+1))==SQLITE_OK
- ){
- LogEst nIter;
- pNew->u.btree.nEq++;
- pNew->u.btree.nSkip++;
- pNew->aLTerm[pNew->nLTerm++] = 0;
- pNew->wsFlags |= WHERE_SKIPSCAN;
- nIter = pProbe->aiRowLogEst[saved_nEq] - pProbe->aiRowLogEst[saved_nEq+1];
- if( pTerm ){
- /* TUNING: When estimating skip-scan for a term that is also indexable,
- ** multiply the cost of the skip-scan by 2.0, to make it a little less
- ** desirable than the regular index lookup. */
- nIter += 10; assert( 10==sqlite3LogEst(2) );
- }
- pNew->nOut -= nIter;
- /* TUNING: Because uncertainties in the estimates for skip-scan queries,
- ** add a 1.375 fudge factor to make skip-scan slightly less likely. */
- nIter += 5;
- whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nIter + nInMul);
- pNew->nOut = saved_nOut;
- pNew->u.btree.nEq = saved_nEq;
- pNew->u.btree.nSkip = saved_nSkip;
- }
for(; rc==SQLITE_OK && pTerm!=0; pTerm = whereScanNext(&scan)){
u16 eOp = pTerm->eOperator; /* Shorthand for pTerm->eOperator */
LogEst rCostIdx;
@@ -117996,6 +120490,10 @@ static int whereLoopAddBtreeIndex(
}
if( pTerm->prereqRight & pNew->maskSelf ) continue;
+ /* Do not allow the upper bound of a LIKE optimization range constraint
+ ** to mix with a lower range bound from some other source */
+ if( pTerm->wtFlags & TERM_LIKEOPT && pTerm->eOperator==WO_LT ) continue;
+
pNew->wsFlags = saved_wsFlags;
pNew->u.btree.nEq = saved_nEq;
pNew->nLTerm = saved_nLTerm;
@@ -118039,6 +120537,17 @@ static int whereLoopAddBtreeIndex(
pNew->wsFlags |= WHERE_COLUMN_RANGE|WHERE_BTM_LIMIT;
pBtm = pTerm;
pTop = 0;
+ if( pTerm->wtFlags & TERM_LIKEOPT ){
+ /* Range contraints that come from the LIKE optimization are
+ ** always used in pairs. */
+ pTop = &pTerm[1];
+ assert( (pTop-(pTerm->pWC->a))<pTerm->pWC->nTerm );
+ assert( pTop->wtFlags & TERM_LIKEOPT );
+ assert( pTop->eOperator==WO_LT );
+ if( whereLoopResize(db, pNew, pNew->nLTerm+1) ) break; /* OOM */
+ pNew->aLTerm[pNew->nLTerm++] = pTop;
+ pNew->wsFlags |= WHERE_TOP_LIMIT;
+ }
}else{
assert( eOp & (WO_LT|WO_LE) );
testcase( eOp & WO_LT );
@@ -118075,7 +120584,6 @@ static int whereLoopAddBtreeIndex(
if( nInMul==0
&& pProbe->nSample
&& pNew->u.btree.nEq<=pProbe->nSampleCol
- && OptimizationEnabled(db, SQLITE_Stat3)
&& ((eOp & WO_IN)==0 || !ExprHasProperty(pTerm->pExpr, EP_xIsSelect))
){
Expr *pExpr = pTerm->pExpr;
@@ -118143,10 +120651,45 @@ static int whereLoopAddBtreeIndex(
}
pNew->prereq = saved_prereq;
pNew->u.btree.nEq = saved_nEq;
- pNew->u.btree.nSkip = saved_nSkip;
+ pNew->nSkip = saved_nSkip;
pNew->wsFlags = saved_wsFlags;
pNew->nOut = saved_nOut;
pNew->nLTerm = saved_nLTerm;
+
+ /* Consider using a skip-scan if there are no WHERE clause constraints
+ ** available for the left-most terms of the index, and if the average
+ ** number of repeats in the left-most terms is at least 18.
+ **
+ ** The magic number 18 is selected on the basis that scanning 17 rows
+ ** is almost always quicker than an index seek (even though if the index
+ ** contains fewer than 2^17 rows we assume otherwise in other parts of
+ ** the code). And, even if it is not, it should not be too much slower.
+ ** On the other hand, the extra seeks could end up being significantly
+ ** more expensive. */
+ assert( 42==sqlite3LogEst(18) );
+ if( saved_nEq==saved_nSkip
+ && saved_nEq+1<pProbe->nKeyCol
+ && pProbe->noSkipScan==0
+ && pProbe->aiRowLogEst[saved_nEq+1]>=42 /* TUNING: Minimum for skip-scan */
+ && (rc = whereLoopResize(db, pNew, pNew->nLTerm+1))==SQLITE_OK
+ ){
+ LogEst nIter;
+ pNew->u.btree.nEq++;
+ pNew->nSkip++;
+ pNew->aLTerm[pNew->nLTerm++] = 0;
+ pNew->wsFlags |= WHERE_SKIPSCAN;
+ nIter = pProbe->aiRowLogEst[saved_nEq] - pProbe->aiRowLogEst[saved_nEq+1];
+ pNew->nOut -= nIter;
+ /* TUNING: Because uncertainties in the estimates for skip-scan queries,
+ ** add a 1.375 fudge factor to make skip-scan slightly less likely. */
+ nIter += 5;
+ whereLoopAddBtreeIndex(pBuilder, pSrc, pProbe, nIter + nInMul);
+ pNew->nOut = saved_nOut;
+ pNew->u.btree.nEq = saved_nEq;
+ pNew->nSkip = saved_nSkip;
+ pNew->wsFlags = saved_wsFlags;
+ }
+
return rc;
}
@@ -118206,7 +120749,12 @@ static int whereUsablePartialIndex(int iTab, WhereClause *pWC, Expr *pWhere){
int i;
WhereTerm *pTerm;
for(i=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
- if( sqlite3ExprImpliesExpr(pTerm->pExpr, pWhere, iTab) ) return 1;
+ Expr *pExpr = pTerm->pExpr;
+ if( sqlite3ExprImpliesExpr(pExpr, pWhere, iTab)
+ && (!ExprHasProperty(pExpr, EP_FromJoin) || pExpr->iRightJoinTable==iTab)
+ ){
+ return 1;
+ }
}
return 0;
}
@@ -118310,6 +120858,7 @@ static int whereLoopAddBtree(
#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
/* Automatic indexes */
if( !pBuilder->pOrSet
+ && (pWInfo->wctrlFlags & WHERE_NO_AUTOINDEX)==0
&& (pWInfo->pParse->db->flags & SQLITE_AutoIndex)!=0
&& pSrc->pIndex==0
&& !pSrc->viaCoroutine
@@ -118325,7 +120874,7 @@ static int whereLoopAddBtree(
if( pTerm->prereqRight & pNew->maskSelf ) continue;
if( termCanDriveIndex(pTerm, pSrc, 0) ){
pNew->u.btree.nEq = 1;
- pNew->u.btree.nSkip = 0;
+ pNew->nSkip = 0;
pNew->u.btree.pIndex = 0;
pNew->nLTerm = 1;
pNew->aLTerm[0] = pTerm;
@@ -118366,7 +120915,7 @@ static int whereLoopAddBtree(
}
rSize = pProbe->aiRowLogEst[0];
pNew->u.btree.nEq = 0;
- pNew->u.btree.nSkip = 0;
+ pNew->nSkip = 0;
pNew->nLTerm = 0;
pNew->iSortIdx = 0;
pNew->rSetup = 0;
@@ -118916,7 +121465,7 @@ static i8 wherePathSatisfiesOrderBy(
/* Skip over == and IS NULL terms */
if( j<pLoop->u.btree.nEq
- && pLoop->u.btree.nSkip==0
+ && pLoop->nSkip==0
&& ((i = pLoop->aLTerm[j]->eOperator) & (WO_EQ|WO_ISNULL))!=0
){
if( i & WO_ISNULL ){
@@ -119193,10 +121742,10 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
/* Seed the search with a single WherePath containing zero WhereLoops.
**
- ** TUNING: Do not let the number of iterations go above 25. If the cost
- ** of computing an automatic index is not paid back within the first 25
+ ** TUNING: Do not let the number of iterations go above 28. If the cost
+ ** of computing an automatic index is not paid back within the first 28
** rows, then do not use the automatic index. */
- aFrom[0].nRow = MIN(pParse->nQueryLoop, 46); assert( 46==sqlite3LogEst(25) );
+ aFrom[0].nRow = MIN(pParse->nQueryLoop, 48); assert( 48==sqlite3LogEst(28) );
nFrom = 1;
assert( aFrom[0].isOrdered==0 );
if( nOrderBy ){
@@ -119370,7 +121919,7 @@ static int wherePathSolver(WhereInfo *pWInfo, LogEst nRowEst){
}
#ifdef WHERETRACE_ENABLED /* >=2 */
- if( sqlite3WhereTrace>=2 ){
+ if( sqlite3WhereTrace & 0x02 ){
sqlite3DebugPrintf("---- after round %d ----\n", iLoop);
for(ii=0, pTo=aTo; ii<nTo; ii++, pTo++){
sqlite3DebugPrintf(" %s cost=%-3d nrow=%-3d order=%c",
@@ -119489,7 +122038,7 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){
pWC = &pWInfo->sWC;
pLoop = pBuilder->pNew;
pLoop->wsFlags = 0;
- pLoop->u.btree.nSkip = 0;
+ pLoop->nSkip = 0;
pTerm = findTerm(pWC, iCur, -1, 0, WO_EQ, 0);
if( pTerm ){
pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_IPK|WHERE_ONEROW;
@@ -119501,7 +122050,6 @@ static int whereShortCut(WhereLoopBuilder *pBuilder){
}else{
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
assert( pLoop->aLTermSpace==pLoop->aLTerm );
- assert( ArraySize(pLoop->aLTermSpace)==4 );
if( !IsUniqueIndex(pIdx)
|| pIdx->pPartIdxWhere!=0
|| pIdx->nKeyCol>ArraySize(pLoop->aLTermSpace)
@@ -119995,6 +122543,12 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
if( op ){
sqlite3VdbeAddOp3(v, op, iIndexCur, pIx->tnum, iDb);
sqlite3VdbeSetP4KeyInfo(pParse, pIx);
+ if( (pLoop->wsFlags & WHERE_CONSTRAINT)!=0
+ && (pLoop->wsFlags & (WHERE_COLUMN_RANGE|WHERE_SKIPSCAN))==0
+ && (pWInfo->wctrlFlags&WHERE_ORDERBY_MIN)==0
+ ){
+ sqlite3VdbeChangeP5(v, OPFLAG_SEEKEQ); /* Hint to COMDB2 */
+ }
VdbeComment((v, "%s", pIx->zName));
}
}
@@ -120010,7 +122564,10 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
*/
notReady = ~(Bitmask)0;
for(ii=0; ii<nTabList; ii++){
+ int addrExplain;
+ int wsFlags;
pLevel = &pWInfo->a[ii];
+ wsFlags = pLevel->pWLoop->wsFlags;
#ifndef SQLITE_OMIT_AUTOMATIC_INDEX
if( (pLevel->pWLoop->wsFlags & WHERE_AUTO_INDEX)!=0 ){
constructAutomaticIndex(pParse, &pWInfo->sWC,
@@ -120018,10 +122575,15 @@ SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(
if( db->mallocFailed ) goto whereBeginError;
}
#endif
- explainOneScan(pParse, pTabList, pLevel, ii, pLevel->iFrom, wctrlFlags);
+ addrExplain = explainOneScan(
+ pParse, pTabList, pLevel, ii, pLevel->iFrom, wctrlFlags
+ );
pLevel->addrBody = sqlite3VdbeCurrentAddr(v);
notReady = codeOneLoopStart(pWInfo, ii, notReady);
pWInfo->iContinue = pLevel->addrCont;
+ if( (wsFlags&WHERE_MULTI_OR)==0 && (wctrlFlags&WHERE_ONETABLE_ONLY)==0 ){
+ addScanStatus(v, pTabList, pLevel, addrExplain);
+ }
}
/* Done. */
@@ -120088,6 +122650,16 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
sqlite3VdbeJumpHere(v, pLevel->addrSkip);
sqlite3VdbeJumpHere(v, pLevel->addrSkip-2);
}
+ if( pLevel->addrLikeRep ){
+ int op;
+ if( sqlite3VdbeGetOp(v, pLevel->addrLikeRep-1)->p1 ){
+ op = OP_DecrJumpZero;
+ }else{
+ op = OP_JumpZeroIncr;
+ }
+ sqlite3VdbeAddOp2(v, op, pLevel->iLikeRepCntr, pLevel->addrLikeRep);
+ VdbeCoverage(v);
+ }
if( pLevel->iLeftJoin ){
addr = sqlite3VdbeAddOp1(v, OP_IfPos, pLevel->iLeftJoin); VdbeCoverage(v);
assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
@@ -122602,13 +125174,19 @@ static void yy_reduce(
int cnt = 0, mxSelect;
p->pWith = yymsp[-1].minor.yy59;
if( p->pPrior ){
+ u16 allValues = SF_Values;
pNext = 0;
for(pLoop=p; pLoop; pNext=pLoop, pLoop=pLoop->pPrior, cnt++){
pLoop->pNext = pNext;
pLoop->selFlags |= SF_Compound;
+ allValues &= pLoop->selFlags;
}
- mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT];
- if( mxSelect && cnt>mxSelect ){
+ if( allValues ){
+ p->selFlags |= SF_AllValues;
+ }else if(
+ (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0
+ && cnt>mxSelect
+ ){
sqlite3ErrorMsg(pParse, "too many terms in compound SELECT");
}
}
@@ -122972,7 +125550,7 @@ static void yy_reduce(
break;
case 193: /* expr ::= expr COLLATE ID|STRING */
{
- yygotominor.yy346.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy346.pExpr, &yymsp[0].minor.yy0);
+ yygotominor.yy346.pExpr = sqlite3ExprAddCollateToken(pParse, yymsp[-2].minor.yy346.pExpr, &yymsp[0].minor.yy0, 1);
yygotominor.yy346.zStart = yymsp[-2].minor.yy346.zStart;
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
}
@@ -123135,7 +125713,7 @@ static void yy_reduce(
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy346.pExpr, 0, 0);
if( yygotominor.yy346.pExpr ){
yygotominor.yy346.pExpr->x.pList = yymsp[-1].minor.yy14;
- sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
+ sqlite3ExprSetHeightAndFlags(pParse, yygotominor.yy346.pExpr);
}else{
sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy14);
}
@@ -123150,8 +125728,8 @@ static void yy_reduce(
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
if( yygotominor.yy346.pExpr ){
yygotominor.yy346.pExpr->x.pSelect = yymsp[-1].minor.yy3;
- ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect);
- sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
+ ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect|EP_Subquery);
+ sqlite3ExprSetHeightAndFlags(pParse, yygotominor.yy346.pExpr);
}else{
sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy3);
}
@@ -123164,8 +125742,8 @@ static void yy_reduce(
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy346.pExpr, 0, 0);
if( yygotominor.yy346.pExpr ){
yygotominor.yy346.pExpr->x.pSelect = yymsp[-1].minor.yy3;
- ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect);
- sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
+ ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect|EP_Subquery);
+ sqlite3ExprSetHeightAndFlags(pParse, yygotominor.yy346.pExpr);
}else{
sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy3);
}
@@ -123180,8 +125758,8 @@ static void yy_reduce(
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy346.pExpr, 0, 0);
if( yygotominor.yy346.pExpr ){
yygotominor.yy346.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
- ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect);
- sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
+ ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect|EP_Subquery);
+ sqlite3ExprSetHeightAndFlags(pParse, yygotominor.yy346.pExpr);
}else{
sqlite3SrcListDelete(pParse->db, pSrc);
}
@@ -123195,8 +125773,8 @@ static void yy_reduce(
Expr *p = yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
if( p ){
p->x.pSelect = yymsp[-1].minor.yy3;
- ExprSetProperty(p, EP_xIsSelect);
- sqlite3ExprSetHeight(pParse, p);
+ ExprSetProperty(p, EP_xIsSelect|EP_Subquery);
+ sqlite3ExprSetHeightAndFlags(pParse, p);
}else{
sqlite3SelectDelete(pParse->db, yymsp[-1].minor.yy3);
}
@@ -123209,7 +125787,7 @@ static void yy_reduce(
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy132, 0, 0);
if( yygotominor.yy346.pExpr ){
yygotominor.yy346.pExpr->x.pList = yymsp[-1].minor.yy132 ? sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[-1].minor.yy132) : yymsp[-2].minor.yy14;
- sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
+ sqlite3ExprSetHeightAndFlags(pParse, yygotominor.yy346.pExpr);
}else{
sqlite3ExprListDelete(pParse->db, yymsp[-2].minor.yy14);
sqlite3ExprDelete(pParse->db, yymsp[-1].minor.yy132);
@@ -123252,7 +125830,7 @@ static void yy_reduce(
break;
case 244: /* idxlist ::= idxlist COMMA nm collate sortorder */
{
- Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0);
+ Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0, 1);
yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, p);
sqlite3ExprListSetName(pParse,yygotominor.yy14,&yymsp[-2].minor.yy0,1);
sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
@@ -123261,7 +125839,7 @@ static void yy_reduce(
break;
case 245: /* idxlist ::= nm collate sortorder */
{
- Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0);
+ Expr *p = sqlite3ExprAddCollateToken(pParse, 0, &yymsp[-1].minor.yy0, 1);
yygotominor.yy14 = sqlite3ExprListAppend(pParse,0, p);
sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
@@ -124451,7 +127029,7 @@ SQLITE_PRIVATE int sqlite3RunParser(Parse *pParse, const char *zSql, char **pzEr
sqlite3 *db = pParse->db; /* The database connection */
int mxSqlLen; /* Max length of an SQL string */
-
+ assert( zSql!=0 );
mxSqlLen = db->aLimit[SQLITE_LIMIT_SQL_LENGTH];
if( db->nVdbeActive==0 ){
db->u1.isInterrupted = 0;
@@ -124520,9 +127098,11 @@ abort_parse:
sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse);
}
#ifdef YYTRACKMAXSTACKDEPTH
+ sqlite3_mutex_enter(sqlite3MallocMutex());
sqlite3StatusSet(SQLITE_STATUS_PARSER_STACK,
sqlite3ParserStackPeak(pEngine)
);
+ sqlite3_mutex_leave(sqlite3MallocMutex());
#endif /* YYDEBUG */
sqlite3ParserFree(pEngine, sqlite3_free);
db->lookaside.bEnabled = enableLookaside;
@@ -124686,7 +127266,7 @@ SQLITE_PRIVATE const char sqlite3IsEbcdicIdChar[];
** to recognize the end of a trigger can be omitted. All we have to do
** is look for a semicolon that is not part of an string or comment.
*/
-SQLITE_API int sqlite3_complete(const char *zSql){
+SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *zSql){
u8 state = 0; /* Current state, using numbers defined in header comment */
u8 token; /* Value of the next token */
@@ -124719,6 +127299,13 @@ SQLITE_API int sqlite3_complete(const char *zSql){
};
#endif /* SQLITE_OMIT_TRIGGER */
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( zSql==0 ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
+
while( *zSql ){
switch( *zSql ){
case ';': { /* A semicolon */
@@ -124844,7 +127431,7 @@ SQLITE_API int sqlite3_complete(const char *zSql){
** above, except that the parameter is required to be UTF-16 encoded, not
** UTF-8.
*/
-SQLITE_API int sqlite3_complete16(const void *zSql){
+SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *zSql){
sqlite3_value *pVal;
char const *zSql8;
int rc = SQLITE_NOMEM;
@@ -124994,24 +127581,24 @@ SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
/* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns
** a pointer to the to the sqlite3_version[] string constant.
*/
-SQLITE_API const char *sqlite3_libversion(void){ return sqlite3_version; }
+SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void){ return sqlite3_version; }
/* IMPLEMENTATION-OF: R-63124-39300 The sqlite3_sourceid() function returns a
** pointer to a string constant whose value is the same as the
** SQLITE_SOURCE_ID C preprocessor macro.
*/
-SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
/* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function
** returns an integer equal to SQLITE_VERSION_NUMBER.
*/
-SQLITE_API int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }
+SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }
/* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns
** zero if and only if SQLite was compiled with mutexing code omitted due to
** the SQLITE_THREADSAFE compile-time option being set to 0.
*/
-SQLITE_API int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
+SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
#if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
/*
@@ -125020,7 +127607,7 @@ SQLITE_API int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
** I/O active are written using this function. These messages
** are intended for debugging activity only.
*/
-SQLITE_PRIVATE void (*sqlite3IoTrace)(const char*, ...) = 0;
+SQLITE_API void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...) = 0;
#endif
/*
@@ -125072,7 +127659,7 @@ SQLITE_API char *sqlite3_data_directory = 0;
** * Recursive calls to this routine from thread X return immediately
** without blocking.
*/
-SQLITE_API int sqlite3_initialize(void){
+SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void){
MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */
int rc; /* Result code */
#ifdef SQLITE_EXTRA_INIT
@@ -125086,6 +127673,11 @@ SQLITE_API int sqlite3_initialize(void){
}
#endif
+ /* If the following assert() fails on some obscure processor/compiler
+ ** combination, the work-around is to set the correct pointer
+ ** size at compile-time using -DSQLITE_PTRSIZE=n compile-time option */
+ assert( SQLITE_PTRSIZE==sizeof(char*) );
+
/* If SQLite is already completely initialized, then this call
** to sqlite3_initialize() should be a no-op. But the initialization
** must be complete. So isInit must not be set until the very end
@@ -125228,7 +127820,14 @@ SQLITE_API int sqlite3_initialize(void){
** on when SQLite is already shut down. If SQLite is already shut down
** when this routine is invoked, then this routine is a harmless no-op.
*/
-SQLITE_API int sqlite3_shutdown(void){
+SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void){
+#ifdef SQLITE_OMIT_WSD
+ int rc = sqlite3_wsd_init(4096, 24);
+ if( rc!=SQLITE_OK ){
+ return rc;
+ }
+#endif
+
if( sqlite3GlobalConfig.isInit ){
#ifdef SQLITE_EXTRA_SHUTDOWN
void SQLITE_EXTRA_SHUTDOWN(void);
@@ -125275,7 +127874,7 @@ SQLITE_API int sqlite3_shutdown(void){
** threadsafe. Failure to heed these warnings can lead to unpredictable
** behavior.
*/
-SQLITE_API int sqlite3_config(int op, ...){
+SQLITE_API int SQLITE_CDECL sqlite3_config(int op, ...){
va_list ap;
int rc = SQLITE_OK;
@@ -125287,33 +127886,43 @@ SQLITE_API int sqlite3_config(int op, ...){
switch( op ){
/* Mutex configuration options are only available in a threadsafe
- ** compile.
+ ** compile.
*/
-#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0
+#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-54466-46756 */
case SQLITE_CONFIG_SINGLETHREAD: {
- /* Disable all mutexing */
- sqlite3GlobalConfig.bCoreMutex = 0;
- sqlite3GlobalConfig.bFullMutex = 0;
+ /* EVIDENCE-OF: R-02748-19096 This option sets the threading mode to
+ ** Single-thread. */
+ sqlite3GlobalConfig.bCoreMutex = 0; /* Disable mutex on core */
+ sqlite3GlobalConfig.bFullMutex = 0; /* Disable mutex on connections */
break;
}
+#endif
+#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-20520-54086 */
case SQLITE_CONFIG_MULTITHREAD: {
- /* Disable mutexing of database connections */
- /* Enable mutexing of core data structures */
- sqlite3GlobalConfig.bCoreMutex = 1;
- sqlite3GlobalConfig.bFullMutex = 0;
+ /* EVIDENCE-OF: R-14374-42468 This option sets the threading mode to
+ ** Multi-thread. */
+ sqlite3GlobalConfig.bCoreMutex = 1; /* Enable mutex on core */
+ sqlite3GlobalConfig.bFullMutex = 0; /* Disable mutex on connections */
break;
}
+#endif
+#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-59593-21810 */
case SQLITE_CONFIG_SERIALIZED: {
- /* Enable all mutexing */
- sqlite3GlobalConfig.bCoreMutex = 1;
- sqlite3GlobalConfig.bFullMutex = 1;
+ /* EVIDENCE-OF: R-41220-51800 This option sets the threading mode to
+ ** Serialized. */
+ sqlite3GlobalConfig.bCoreMutex = 1; /* Enable mutex on core */
+ sqlite3GlobalConfig.bFullMutex = 1; /* Enable mutex on connections */
break;
}
+#endif
+#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-63666-48755 */
case SQLITE_CONFIG_MUTEX: {
/* Specify an alternative mutex implementation */
sqlite3GlobalConfig.mutex = *va_arg(ap, sqlite3_mutex_methods*);
break;
}
+#endif
+#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 /* IMP: R-14450-37597 */
case SQLITE_CONFIG_GETMUTEX: {
/* Retrieve the current mutex implementation */
*va_arg(ap, sqlite3_mutex_methods*) = sqlite3GlobalConfig.mutex;
@@ -125321,37 +127930,61 @@ SQLITE_API int sqlite3_config(int op, ...){
}
#endif
-
case SQLITE_CONFIG_MALLOC: {
- /* Specify an alternative malloc implementation */
+ /* EVIDENCE-OF: R-55594-21030 The SQLITE_CONFIG_MALLOC option takes a
+ ** single argument which is a pointer to an instance of the
+ ** sqlite3_mem_methods structure. The argument specifies alternative
+ ** low-level memory allocation routines to be used in place of the memory
+ ** allocation routines built into SQLite. */
sqlite3GlobalConfig.m = *va_arg(ap, sqlite3_mem_methods*);
break;
}
case SQLITE_CONFIG_GETMALLOC: {
- /* Retrieve the current malloc() implementation */
+ /* EVIDENCE-OF: R-51213-46414 The SQLITE_CONFIG_GETMALLOC option takes a
+ ** single argument which is a pointer to an instance of the
+ ** sqlite3_mem_methods structure. The sqlite3_mem_methods structure is
+ ** filled with the currently defined memory allocation routines. */
if( sqlite3GlobalConfig.m.xMalloc==0 ) sqlite3MemSetDefault();
*va_arg(ap, sqlite3_mem_methods*) = sqlite3GlobalConfig.m;
break;
}
case SQLITE_CONFIG_MEMSTATUS: {
- /* Enable or disable the malloc status collection */
+ /* EVIDENCE-OF: R-61275-35157 The SQLITE_CONFIG_MEMSTATUS option takes
+ ** single argument of type int, interpreted as a boolean, which enables
+ ** or disables the collection of memory allocation statistics. */
sqlite3GlobalConfig.bMemstat = va_arg(ap, int);
break;
}
case SQLITE_CONFIG_SCRATCH: {
- /* Designate a buffer for scratch memory space */
+ /* EVIDENCE-OF: R-08404-60887 There are three arguments to
+ ** SQLITE_CONFIG_SCRATCH: A pointer an 8-byte aligned memory buffer from
+ ** which the scratch allocations will be drawn, the size of each scratch
+ ** allocation (sz), and the maximum number of scratch allocations (N). */
sqlite3GlobalConfig.pScratch = va_arg(ap, void*);
sqlite3GlobalConfig.szScratch = va_arg(ap, int);
sqlite3GlobalConfig.nScratch = va_arg(ap, int);
break;
}
case SQLITE_CONFIG_PAGECACHE: {
- /* Designate a buffer for page cache memory space */
+ /* EVIDENCE-OF: R-31408-40510 There are three arguments to
+ ** SQLITE_CONFIG_PAGECACHE: A pointer to 8-byte aligned memory, the size
+ ** of each page buffer (sz), and the number of pages (N). */
sqlite3GlobalConfig.pPage = va_arg(ap, void*);
sqlite3GlobalConfig.szPage = va_arg(ap, int);
sqlite3GlobalConfig.nPage = va_arg(ap, int);
break;
}
+ case SQLITE_CONFIG_PCACHE_HDRSZ: {
+ /* EVIDENCE-OF: R-39100-27317 The SQLITE_CONFIG_PCACHE_HDRSZ option takes
+ ** a single parameter which is a pointer to an integer and writes into
+ ** that integer the number of extra bytes per page required for each page
+ ** in SQLITE_CONFIG_PAGECACHE. */
+ *va_arg(ap, int*) =
+ sqlite3HeaderSizeBtree() +
+ sqlite3HeaderSizePcache() +
+ sqlite3HeaderSizePcache1();
+ break;
+ }
case SQLITE_CONFIG_PCACHE: {
/* no-op */
@@ -125364,11 +127997,18 @@ SQLITE_API int sqlite3_config(int op, ...){
}
case SQLITE_CONFIG_PCACHE2: {
- /* Specify an alternative page cache implementation */
+ /* EVIDENCE-OF: R-63325-48378 The SQLITE_CONFIG_PCACHE2 option takes a
+ ** single argument which is a pointer to an sqlite3_pcache_methods2
+ ** object. This object specifies the interface to a custom page cache
+ ** implementation. */
sqlite3GlobalConfig.pcache2 = *va_arg(ap, sqlite3_pcache_methods2*);
break;
}
case SQLITE_CONFIG_GETPCACHE2: {
+ /* EVIDENCE-OF: R-22035-46182 The SQLITE_CONFIG_GETPCACHE2 option takes a
+ ** single argument which is a pointer to an sqlite3_pcache_methods2
+ ** object. SQLite copies of the current page cache implementation into
+ ** that object. */
if( sqlite3GlobalConfig.pcache2.xInit==0 ){
sqlite3PCacheSetDefault();
}
@@ -125376,9 +128016,15 @@ SQLITE_API int sqlite3_config(int op, ...){
break;
}
+/* EVIDENCE-OF: R-06626-12911 The SQLITE_CONFIG_HEAP option is only
+** available if SQLite is compiled with either SQLITE_ENABLE_MEMSYS3 or
+** SQLITE_ENABLE_MEMSYS5 and returns SQLITE_ERROR if invoked otherwise. */
#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)
case SQLITE_CONFIG_HEAP: {
- /* Designate a buffer for heap memory space */
+ /* EVIDENCE-OF: R-19854-42126 There are three arguments to
+ ** SQLITE_CONFIG_HEAP: An 8-byte aligned pointer to the memory, the
+ ** number of bytes in the memory buffer, and the minimum allocation size.
+ */
sqlite3GlobalConfig.pHeap = va_arg(ap, void*);
sqlite3GlobalConfig.nHeap = va_arg(ap, int);
sqlite3GlobalConfig.mnReq = va_arg(ap, int);
@@ -125391,17 +128037,19 @@ SQLITE_API int sqlite3_config(int op, ...){
}
if( sqlite3GlobalConfig.pHeap==0 ){
- /* If the heap pointer is NULL, then restore the malloc implementation
- ** back to NULL pointers too. This will cause the malloc to go
- ** back to its default implementation when sqlite3_initialize() is
- ** run.
+ /* EVIDENCE-OF: R-49920-60189 If the first pointer (the memory pointer)
+ ** is NULL, then SQLite reverts to using its default memory allocator
+ ** (the system malloc() implementation), undoing any prior invocation of
+ ** SQLITE_CONFIG_MALLOC.
+ **
+ ** Setting sqlite3GlobalConfig.m to all zeros will cause malloc to
+ ** revert to its default implementation when sqlite3_initialize() is run
*/
memset(&sqlite3GlobalConfig.m, 0, sizeof(sqlite3GlobalConfig.m));
}else{
- /* The heap pointer is not NULL, then install one of the
- ** mem5.c/mem3.c methods. The enclosing #if guarantees at
- ** least one of these methods is currently enabled.
- */
+ /* EVIDENCE-OF: R-61006-08918 If the memory pointer is not NULL then the
+ ** alternative memory allocator is engaged to handle all of SQLites
+ ** memory allocation needs. */
#ifdef SQLITE_ENABLE_MEMSYS3
sqlite3GlobalConfig.m = *sqlite3MemGetMemsys3();
#endif
@@ -125440,11 +128088,19 @@ SQLITE_API int sqlite3_config(int op, ...){
** sqlite3_config(SQLITE_CONFIG_URI,0) configuration calls.
*/
case SQLITE_CONFIG_URI: {
+ /* EVIDENCE-OF: R-25451-61125 The SQLITE_CONFIG_URI option takes a single
+ ** argument of type int. If non-zero, then URI handling is globally
+ ** enabled. If the parameter is zero, then URI handling is globally
+ ** disabled. */
sqlite3GlobalConfig.bOpenUri = va_arg(ap, int);
break;
}
case SQLITE_CONFIG_COVERING_INDEX_SCAN: {
+ /* EVIDENCE-OF: R-36592-02772 The SQLITE_CONFIG_COVERING_INDEX_SCAN
+ ** option takes a single integer argument which is interpreted as a
+ ** boolean in order to enable or disable the use of covering indices for
+ ** full table scans in the query optimizer. */
sqlite3GlobalConfig.bUseCis = va_arg(ap, int);
break;
}
@@ -125459,25 +128115,45 @@ SQLITE_API int sqlite3_config(int op, ...){
#endif
case SQLITE_CONFIG_MMAP_SIZE: {
+ /* EVIDENCE-OF: R-58063-38258 SQLITE_CONFIG_MMAP_SIZE takes two 64-bit
+ ** integer (sqlite3_int64) values that are the default mmap size limit
+ ** (the default setting for PRAGMA mmap_size) and the maximum allowed
+ ** mmap size limit. */
sqlite3_int64 szMmap = va_arg(ap, sqlite3_int64);
sqlite3_int64 mxMmap = va_arg(ap, sqlite3_int64);
+ /* EVIDENCE-OF: R-53367-43190 If either argument to this option is
+ ** negative, then that argument is changed to its compile-time default.
+ **
+ ** EVIDENCE-OF: R-34993-45031 The maximum allowed mmap size will be
+ ** silently truncated if necessary so that it does not exceed the
+ ** compile-time maximum mmap size set by the SQLITE_MAX_MMAP_SIZE
+ ** compile-time option.
+ */
if( mxMmap<0 || mxMmap>SQLITE_MAX_MMAP_SIZE ){
mxMmap = SQLITE_MAX_MMAP_SIZE;
}
- sqlite3GlobalConfig.mxMmap = mxMmap;
if( szMmap<0 ) szMmap = SQLITE_DEFAULT_MMAP_SIZE;
if( szMmap>mxMmap) szMmap = mxMmap;
+ sqlite3GlobalConfig.mxMmap = mxMmap;
sqlite3GlobalConfig.szMmap = szMmap;
break;
}
-#if SQLITE_OS_WIN && defined(SQLITE_WIN32_MALLOC)
+#if SQLITE_OS_WIN && defined(SQLITE_WIN32_MALLOC) /* IMP: R-04780-55815 */
case SQLITE_CONFIG_WIN32_HEAPSIZE: {
+ /* EVIDENCE-OF: R-34926-03360 SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit
+ ** unsigned integer value that specifies the maximum size of the created
+ ** heap. */
sqlite3GlobalConfig.nHeap = va_arg(ap, int);
break;
}
#endif
+ case SQLITE_CONFIG_PMASZ: {
+ sqlite3GlobalConfig.szPma = va_arg(ap, unsigned int);
+ break;
+ }
+
default: {
rc = SQLITE_ERROR;
break;
@@ -125555,7 +128231,13 @@ static int setupLookaside(sqlite3 *db, void *pBuf, int sz, int cnt){
/*
** Return the mutex associated with a database connection.
*/
-SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3 *db){
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3 *db){
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
return db->mutex;
}
@@ -125563,8 +128245,12 @@ SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3 *db){
** Free up as much memory as we can from the given database
** connection.
*/
-SQLITE_API int sqlite3_db_release_memory(sqlite3 *db){
+SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3 *db){
int i;
+
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
+#endif
sqlite3_mutex_enter(db->mutex);
sqlite3BtreeEnterAll(db);
for(i=0; i<db->nDb; i++){
@@ -125582,7 +128268,7 @@ SQLITE_API int sqlite3_db_release_memory(sqlite3 *db){
/*
** Configuration settings for an individual database connection
*/
-SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){
+SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3 *db, int op, ...){
va_list ap;
int rc;
va_start(ap, op);
@@ -125654,13 +128340,20 @@ static int binCollFunc(
){
int rc, n;
n = nKey1<nKey2 ? nKey1 : nKey2;
+ /* EVIDENCE-OF: R-65033-28449 The built-in BINARY collation compares
+ ** strings byte by byte using the memcmp() function from the standard C
+ ** library. */
rc = memcmp(pKey1, pKey2, n);
if( rc==0 ){
if( padFlag
&& allSpaces(((char*)pKey1)+n, nKey1-n)
&& allSpaces(((char*)pKey2)+n, nKey2-n)
){
- /* Leave rc unchanged at 0 */
+ /* EVIDENCE-OF: R-31624-24737 RTRIM is like BINARY except that extra
+ ** spaces at the end of either string do not change the result. In other
+ ** words, strings will compare equal to one another as long as they
+ ** differ only in the number of spaces at the end.
+ */
}else{
rc = nKey1 - nKey2;
}
@@ -125694,21 +128387,39 @@ static int nocaseCollatingFunc(
/*
** Return the ROWID of the most recent insert
*/
-SQLITE_API sqlite_int64 sqlite3_last_insert_rowid(sqlite3 *db){
+SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3 *db){
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
return db->lastRowid;
}
/*
** Return the number of changes in the most recent call to sqlite3_exec().
*/
-SQLITE_API int sqlite3_changes(sqlite3 *db){
+SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3 *db){
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
return db->nChange;
}
/*
** Return the number of changes since the database handle was opened.
*/
-SQLITE_API int sqlite3_total_changes(sqlite3 *db){
+SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3 *db){
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
return db->nTotalChange;
}
@@ -125844,8 +128555,8 @@ static int sqlite3Close(sqlite3 *db, int forceZombie){
** unclosed resources, and arranges for deallocation when the last
** prepare statement or sqlite3_backup closes.
*/
-SQLITE_API int sqlite3_close(sqlite3 *db){ return sqlite3Close(db,0); }
-SQLITE_API int sqlite3_close_v2(sqlite3 *db){ return sqlite3Close(db,1); }
+SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3 *db){ return sqlite3Close(db,0); }
+SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3 *db){ return sqlite3Close(db,1); }
/*
@@ -126194,7 +128905,7 @@ static int sqliteDefaultBusyCallback(
void *ptr, /* Database connection */
int count /* Number of times table has been busy */
){
-#if SQLITE_OS_WIN || (defined(HAVE_USLEEP) && HAVE_USLEEP)
+#if SQLITE_OS_WIN || HAVE_USLEEP
static const u8 delays[] =
{ 1, 2, 5, 10, 15, 20, 25, 25, 25, 50, 50, 100 };
static const u8 totals[] =
@@ -126252,11 +128963,14 @@ SQLITE_PRIVATE int sqlite3InvokeBusyHandler(BusyHandler *p){
** This routine sets the busy callback for an Sqlite database to the
** given callback function with the given argument.
*/
-SQLITE_API int sqlite3_busy_handler(
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(
sqlite3 *db,
int (*xBusy)(void*,int),
void *pArg
){
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
+#endif
sqlite3_mutex_enter(db->mutex);
db->busyHandler.xFunc = xBusy;
db->busyHandler.pArg = pArg;
@@ -126272,12 +128986,18 @@ SQLITE_API int sqlite3_busy_handler(
** given callback function with the given argument. The progress callback will
** be invoked every nOps opcodes.
*/
-SQLITE_API void sqlite3_progress_handler(
+SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(
sqlite3 *db,
int nOps,
int (*xProgress)(void*),
void *pArg
){
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return;
+ }
+#endif
sqlite3_mutex_enter(db->mutex);
if( nOps>0 ){
db->xProgress = xProgress;
@@ -126297,7 +129017,10 @@ SQLITE_API void sqlite3_progress_handler(
** This routine installs a default busy handler that waits for the
** specified number of milliseconds before returning 0.
*/
-SQLITE_API int sqlite3_busy_timeout(sqlite3 *db, int ms){
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3 *db, int ms){
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
+#endif
if( ms>0 ){
sqlite3_busy_handler(db, sqliteDefaultBusyCallback, (void*)db);
db->busyTimeout = ms;
@@ -126310,7 +129033,13 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3 *db, int ms){
/*
** Cause any pending operation to stop at its earliest opportunity.
*/
-SQLITE_API void sqlite3_interrupt(sqlite3 *db){
+SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3 *db){
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return;
+ }
+#endif
db->u1.isInterrupted = 1;
}
@@ -126421,7 +129150,7 @@ SQLITE_PRIVATE int sqlite3CreateFunc(
/*
** Create new user functions.
*/
-SQLITE_API int sqlite3_create_function(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
sqlite3 *db,
const char *zFunc,
int nArg,
@@ -126435,7 +129164,7 @@ SQLITE_API int sqlite3_create_function(
xFinal, 0);
}
-SQLITE_API int sqlite3_create_function_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
sqlite3 *db,
const char *zFunc,
int nArg,
@@ -126448,6 +129177,12 @@ SQLITE_API int sqlite3_create_function_v2(
){
int rc = SQLITE_ERROR;
FuncDestructor *pArg = 0;
+
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ){
+ return SQLITE_MISUSE_BKPT;
+ }
+#endif
sqlite3_mutex_enter(db->mutex);
if( xDestroy ){
pArg = (FuncDestructor *)sqlite3DbMallocZero(db, sizeof(FuncDestructor));
@@ -126472,7 +129207,7 @@ SQLITE_API int sqlite3_create_function_v2(
}
#ifndef SQLITE_OMIT_UTF16
-SQLITE_API int sqlite3_create_function16(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
sqlite3 *db,
const void *zFunctionName,
int nArg,
@@ -126484,6 +129219,10 @@ SQLITE_API int sqlite3_create_function16(
){
int rc;
char *zFunc8;
+
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) || zFunctionName==0 ) return SQLITE_MISUSE_BKPT;
+#endif
sqlite3_mutex_enter(db->mutex);
assert( !db->mallocFailed );
zFunc8 = sqlite3Utf16to8(db, zFunctionName, -1, SQLITE_UTF16NATIVE);
@@ -126508,13 +129247,19 @@ SQLITE_API int sqlite3_create_function16(
** A global function must exist in order for name resolution to work
** properly.
*/
-SQLITE_API int sqlite3_overload_function(
+SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(
sqlite3 *db,
const char *zName,
int nArg
){
int nName = sqlite3Strlen30(zName);
int rc = SQLITE_OK;
+
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) || zName==0 || nArg<-2 ){
+ return SQLITE_MISUSE_BKPT;
+ }
+#endif
sqlite3_mutex_enter(db->mutex);
if( sqlite3FindFunction(db, zName, nName, nArg, SQLITE_UTF8, 0)==0 ){
rc = sqlite3CreateFunc(db, zName, nArg, SQLITE_UTF8,
@@ -126534,8 +129279,15 @@ SQLITE_API int sqlite3_overload_function(
** trace is a pointer to a function that is invoked at the start of each
** SQL statement.
*/
-SQLITE_API void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){
+SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){
void *pOld;
+
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
sqlite3_mutex_enter(db->mutex);
pOld = db->pTraceArg;
db->xTrace = xTrace;
@@ -126551,12 +129303,19 @@ SQLITE_API void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), v
** profile is a pointer to a function that is invoked at the conclusion of
** each SQL statement that is run.
*/
-SQLITE_API void *sqlite3_profile(
+SQLITE_API void *SQLITE_STDCALL sqlite3_profile(
sqlite3 *db,
void (*xProfile)(void*,const char*,sqlite_uint64),
void *pArg
){
void *pOld;
+
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
sqlite3_mutex_enter(db->mutex);
pOld = db->pProfileArg;
db->xProfile = xProfile;
@@ -126571,12 +129330,19 @@ SQLITE_API void *sqlite3_profile(
** If the invoked function returns non-zero, then the commit becomes a
** rollback.
*/
-SQLITE_API void *sqlite3_commit_hook(
+SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(
sqlite3 *db, /* Attach the hook to this database */
int (*xCallback)(void*), /* Function to invoke on each commit */
void *pArg /* Argument to the function */
){
void *pOld;
+
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
sqlite3_mutex_enter(db->mutex);
pOld = db->pCommitArg;
db->xCommitCallback = xCallback;
@@ -126589,12 +129355,19 @@ SQLITE_API void *sqlite3_commit_hook(
** Register a callback to be invoked each time a row is updated,
** inserted or deleted using this database connection.
*/
-SQLITE_API void *sqlite3_update_hook(
+SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
sqlite3 *db, /* Attach the hook to this database */
void (*xCallback)(void*,int,char const *,char const *,sqlite_int64),
void *pArg /* Argument to the function */
){
void *pRet;
+
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
sqlite3_mutex_enter(db->mutex);
pRet = db->pUpdateArg;
db->xUpdateCallback = xCallback;
@@ -126607,12 +129380,19 @@ SQLITE_API void *sqlite3_update_hook(
** Register a callback to be invoked each time a transaction is rolled
** back by this database connection.
*/
-SQLITE_API void *sqlite3_rollback_hook(
+SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(
sqlite3 *db, /* Attach the hook to this database */
void (*xCallback)(void*), /* Callback function */
void *pArg /* Argument to the function */
){
void *pRet;
+
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
sqlite3_mutex_enter(db->mutex);
pRet = db->pRollbackArg;
db->xRollbackCallback = xCallback;
@@ -126654,11 +129434,14 @@ SQLITE_PRIVATE int sqlite3WalDefaultHook(
** using sqlite3_wal_hook() disables the automatic checkpoint mechanism
** configured by this function.
*/
-SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){
#ifdef SQLITE_OMIT_WAL
UNUSED_PARAMETER(db);
UNUSED_PARAMETER(nFrame);
#else
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
+#endif
if( nFrame>0 ){
sqlite3_wal_hook(db, sqlite3WalDefaultHook, SQLITE_INT_TO_PTR(nFrame));
}else{
@@ -126672,13 +129455,19 @@ SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){
** Register a callback to be invoked each time a transaction is written
** into the write-ahead-log by this database connection.
*/
-SQLITE_API void *sqlite3_wal_hook(
+SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
sqlite3 *db, /* Attach the hook to this db handle */
int(*xCallback)(void *, sqlite3*, const char*, int),
void *pArg /* First argument passed to xCallback() */
){
#ifndef SQLITE_OMIT_WAL
void *pRet;
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
sqlite3_mutex_enter(db->mutex);
pRet = db->pWalArg;
db->xWalCallback = xCallback;
@@ -126693,7 +129482,7 @@ SQLITE_API void *sqlite3_wal_hook(
/*
** Checkpoint database zDb.
*/
-SQLITE_API int sqlite3_wal_checkpoint_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
sqlite3 *db, /* Database handle */
const char *zDb, /* Name of attached database (or NULL) */
int eMode, /* SQLITE_CHECKPOINT_* value */
@@ -126706,14 +129495,21 @@ SQLITE_API int sqlite3_wal_checkpoint_v2(
int rc; /* Return code */
int iDb = SQLITE_MAX_ATTACHED; /* sqlite3.aDb[] index of db to checkpoint */
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
+#endif
+
/* Initialize the output variables to -1 in case an error occurs. */
if( pnLog ) *pnLog = -1;
if( pnCkpt ) *pnCkpt = -1;
- assert( SQLITE_CHECKPOINT_FULL>SQLITE_CHECKPOINT_PASSIVE );
- assert( SQLITE_CHECKPOINT_FULL<SQLITE_CHECKPOINT_RESTART );
- assert( SQLITE_CHECKPOINT_PASSIVE+2==SQLITE_CHECKPOINT_RESTART );
- if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_RESTART ){
+ assert( SQLITE_CHECKPOINT_PASSIVE==0 );
+ assert( SQLITE_CHECKPOINT_FULL==1 );
+ assert( SQLITE_CHECKPOINT_RESTART==2 );
+ assert( SQLITE_CHECKPOINT_TRUNCATE==3 );
+ if( eMode<SQLITE_CHECKPOINT_PASSIVE || eMode>SQLITE_CHECKPOINT_TRUNCATE ){
+ /* EVIDENCE-OF: R-03996-12088 The M parameter must be a valid checkpoint
+ ** mode: */
return SQLITE_MISUSE;
}
@@ -126725,6 +129521,7 @@ SQLITE_API int sqlite3_wal_checkpoint_v2(
rc = SQLITE_ERROR;
sqlite3ErrorWithMsg(db, SQLITE_ERROR, "unknown database: %s", zDb);
}else{
+ db->busyHandler.nBusy = 0;
rc = sqlite3Checkpoint(db, iDb, eMode, pnLog, pnCkpt);
sqlite3Error(db, rc);
}
@@ -126740,8 +129537,10 @@ SQLITE_API int sqlite3_wal_checkpoint_v2(
** to contains a zero-length string, all attached databases are
** checkpointed.
*/
-SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){
- return sqlite3_wal_checkpoint_v2(db, zDb, SQLITE_CHECKPOINT_PASSIVE, 0, 0);
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){
+ /* EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is equivalent to
+ ** sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0). */
+ return sqlite3_wal_checkpoint_v2(db,zDb,SQLITE_CHECKPOINT_PASSIVE,0,0);
}
#ifndef SQLITE_OMIT_WAL
@@ -126827,7 +129626,7 @@ SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3 *db){
** Return UTF-8 encoded English language explanation of the most recent
** error.
*/
-SQLITE_API const char *sqlite3_errmsg(sqlite3 *db){
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3 *db){
const char *z;
if( !db ){
return sqlite3ErrStr(SQLITE_NOMEM);
@@ -126855,7 +129654,7 @@ SQLITE_API const char *sqlite3_errmsg(sqlite3 *db){
** Return UTF-16 encoded English language explanation of the most recent
** error.
*/
-SQLITE_API const void *sqlite3_errmsg16(sqlite3 *db){
+SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3 *db){
static const u16 outOfMem[] = {
'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0
};
@@ -126900,7 +129699,7 @@ SQLITE_API const void *sqlite3_errmsg16(sqlite3 *db){
** Return the most recent error code generated by an SQLite routine. If NULL is
** passed to this function, we assume a malloc() failed during sqlite3_open().
*/
-SQLITE_API int sqlite3_errcode(sqlite3 *db){
+SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db){
if( db && !sqlite3SafetyCheckSickOrOk(db) ){
return SQLITE_MISUSE_BKPT;
}
@@ -126909,7 +129708,7 @@ SQLITE_API int sqlite3_errcode(sqlite3 *db){
}
return db->errCode & db->errMask;
}
-SQLITE_API int sqlite3_extended_errcode(sqlite3 *db){
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db){
if( db && !sqlite3SafetyCheckSickOrOk(db) ){
return SQLITE_MISUSE_BKPT;
}
@@ -126924,37 +129723,11 @@ SQLITE_API int sqlite3_extended_errcode(sqlite3 *db){
** argument. For now, this simply calls the internal sqlite3ErrStr()
** function.
*/
-SQLITE_API const char *sqlite3_errstr(int rc){
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int rc){
return sqlite3ErrStr(rc);
}
/*
-** Invalidate all cached KeyInfo objects for database connection "db"
-*/
-static void invalidateCachedKeyInfo(sqlite3 *db){
- Db *pDb; /* A single database */
- int iDb; /* The database index number */
- HashElem *k; /* For looping over tables in pDb */
- Table *pTab; /* A table in the database */
- Index *pIdx; /* Each index */
-
- for(iDb=0, pDb=db->aDb; iDb<db->nDb; iDb++, pDb++){
- if( pDb->pBt==0 ) continue;
- sqlite3BtreeEnter(pDb->pBt);
- for(k=sqliteHashFirst(&pDb->pSchema->tblHash); k; k=sqliteHashNext(k)){
- pTab = (Table*)sqliteHashData(k);
- for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
- if( pIdx->pKeyInfo && pIdx->pKeyInfo->db==db ){
- sqlite3KeyInfoUnref(pIdx->pKeyInfo);
- pIdx->pKeyInfo = 0;
- }
- }
- }
- sqlite3BtreeLeave(pDb->pBt);
- }
-}
-
-/*
** Create a new collating function for database "db". The name is zName
** and the encoding is enc.
*/
@@ -126997,7 +129770,6 @@ static int createCollation(
return SQLITE_BUSY;
}
sqlite3ExpirePreparedStatements(db);
- invalidateCachedKeyInfo(db);
/* If collation sequence pColl was created directly by a call to
** sqlite3_create_collation, and not generated by synthCollSeq(),
@@ -127099,9 +129871,15 @@ static const int aHardLimit[] = {
** It merely prevents new constructs that exceed the limit
** from forming.
*/
-SQLITE_API int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
+SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
int oldLimit;
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return -1;
+ }
+#endif
/* EVIDENCE-OF: R-30189-54097 For each limit category SQLITE_LIMIT_NAME
** there is a hard upper bound set at compile-time by a C preprocessor
@@ -127178,7 +129956,8 @@ SQLITE_PRIVATE int sqlite3ParseUri(
assert( *pzErrMsg==0 );
- if( ((flags & SQLITE_OPEN_URI) || sqlite3GlobalConfig.bOpenUri)
+ if( ((flags & SQLITE_OPEN_URI) /* IMP: R-48725-32206 */
+ || sqlite3GlobalConfig.bOpenUri) /* IMP: R-51689-46548 */
&& nUri>=5 && memcmp(zUri, "file:", 5)==0 /* IMP: R-57884-37496 */
){
char *zOpt;
@@ -127196,7 +129975,19 @@ SQLITE_PRIVATE int sqlite3ParseUri(
if( !zFile ) return SQLITE_NOMEM;
iIn = 5;
-#ifndef SQLITE_ALLOW_URI_AUTHORITY
+#ifdef SQLITE_ALLOW_URI_AUTHORITY
+ if( strncmp(zUri+5, "///", 3)==0 ){
+ iIn = 7;
+ /* The following condition causes URIs with five leading / characters
+ ** like file://///host/path to be converted into UNCs like //host/path.
+ ** The correct URI for that UNC has only two or four leading / characters
+ ** file://host/path or file:////host/path. But 5 leading slashes is a
+ ** common error, we are told, so we handle it as a special case. */
+ if( strncmp(zUri+7, "///", 3)==0 ){ iIn++; }
+ }else if( strncmp(zUri+5, "//localhost/", 12)==0 ){
+ iIn = 16;
+ }
+#else
/* Discard the scheme and authority segments of the URI. */
if( zUri[5]=='/' && zUri[6]=='/' ){
iIn = 7;
@@ -127387,6 +130178,9 @@ static int openDatabase(
char *zOpen = 0; /* Filename argument to pass to BtreeOpen() */
char *zErrMsg = 0; /* Error message from sqlite3ParseUri() */
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( ppDb==0 ) return SQLITE_MISUSE_BKPT;
+#endif
*ppDb = 0;
#ifndef SQLITE_OMIT_AUTOINIT
rc = sqlite3_initialize();
@@ -127480,6 +130274,9 @@ static int openDatabase(
#if !defined(SQLITE_DEFAULT_AUTOMATIC_INDEX) || SQLITE_DEFAULT_AUTOMATIC_INDEX
| SQLITE_AutoIndex
#endif
+#if SQLITE_DEFAULT_CKPTFULLFSYNC
+ | SQLITE_CkptFullFSync
+#endif
#if SQLITE_DEFAULT_FILE_FORMAT<4
| SQLITE_LegacyFileFmt
#endif
@@ -127492,6 +130289,9 @@ static int openDatabase(
#if defined(SQLITE_DEFAULT_FOREIGN_KEYS) && SQLITE_DEFAULT_FOREIGN_KEYS
| SQLITE_ForeignKeys
#endif
+#if defined(SQLITE_REVERSE_UNORDERED_SELECTS)
+ | SQLITE_ReverseOrder
+#endif
;
sqlite3HashInit(&db->aCollSeq);
#ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -127501,20 +130301,24 @@ static int openDatabase(
/* Add the default collation sequence BINARY. BINARY works for both UTF-8
** and UTF-16, so add a version for each to avoid any unnecessary
** conversions. The only error that can occur here is a malloc() failure.
+ **
+ ** EVIDENCE-OF: R-52786-44878 SQLite defines three built-in collating
+ ** functions:
*/
createCollation(db, "BINARY", SQLITE_UTF8, 0, binCollFunc, 0);
createCollation(db, "BINARY", SQLITE_UTF16BE, 0, binCollFunc, 0);
createCollation(db, "BINARY", SQLITE_UTF16LE, 0, binCollFunc, 0);
+ createCollation(db, "NOCASE", SQLITE_UTF8, 0, nocaseCollatingFunc, 0);
createCollation(db, "RTRIM", SQLITE_UTF8, (void*)1, binCollFunc, 0);
if( db->mallocFailed ){
goto opendb_out;
}
+ /* EVIDENCE-OF: R-08308-17224 The default collating function for all
+ ** strings is BINARY.
+ */
db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 0);
assert( db->pDfltColl!=0 );
- /* Also add a UTF-8 case-insensitive collation sequence. */
- createCollation(db, "NOCASE", SQLITE_UTF8, 0, nocaseCollatingFunc, 0);
-
/* Parse the filename/URI argument. */
db->openFlags = flags;
rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);
@@ -127535,7 +130339,10 @@ static int openDatabase(
sqlite3Error(db, rc);
goto opendb_out;
}
+ sqlite3BtreeEnter(db->aDb[0].pBt);
db->aDb[0].pSchema = sqlite3SchemaGet(db, db->aDb[0].pBt);
+ if( !db->mallocFailed ) ENC(db) = SCHEMA_ENC(db);
+ sqlite3BtreeLeave(db->aDb[0].pBt);
db->aDb[1].pSchema = sqlite3SchemaGet(db, 0);
/* The default safety_level for the main database is 'full'; for the temp
@@ -127623,7 +130430,8 @@ static int openDatabase(
opendb_out:
sqlite3_free(zOpen);
if( db ){
- assert( db->mutex!=0 || isThreadsafe==0 || sqlite3GlobalConfig.bFullMutex==0 );
+ assert( db->mutex!=0 || isThreadsafe==0
+ || sqlite3GlobalConfig.bFullMutex==0 );
sqlite3_mutex_leave(db->mutex);
}
rc = sqlite3_errcode(db);
@@ -127648,14 +130456,14 @@ opendb_out:
/*
** Open a new database handle.
*/
-SQLITE_API int sqlite3_open(
+SQLITE_API int SQLITE_STDCALL sqlite3_open(
const char *zFilename,
sqlite3 **ppDb
){
return openDatabase(zFilename, ppDb,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
}
-SQLITE_API int sqlite3_open_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
const char *filename, /* Database filename (UTF-8) */
sqlite3 **ppDb, /* OUT: SQLite db handle */
int flags, /* Flags */
@@ -127668,7 +130476,7 @@ SQLITE_API int sqlite3_open_v2(
/*
** Open a new database handle.
*/
-SQLITE_API int sqlite3_open16(
+SQLITE_API int SQLITE_STDCALL sqlite3_open16(
const void *zFilename,
sqlite3 **ppDb
){
@@ -127676,13 +130484,15 @@ SQLITE_API int sqlite3_open16(
sqlite3_value *pVal;
int rc;
- assert( zFilename );
- assert( ppDb );
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( ppDb==0 ) return SQLITE_MISUSE_BKPT;
+#endif
*ppDb = 0;
#ifndef SQLITE_OMIT_AUTOINIT
rc = sqlite3_initialize();
if( rc ) return rc;
#endif
+ if( zFilename==0 ) zFilename = "\000\000";
pVal = sqlite3ValueNew(0);
sqlite3ValueSetStr(pVal, -1, zFilename, SQLITE_UTF16NATIVE, SQLITE_STATIC);
zFilename8 = sqlite3ValueText(pVal, SQLITE_UTF8);
@@ -127691,7 +130501,7 @@ SQLITE_API int sqlite3_open16(
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
assert( *ppDb || rc==SQLITE_NOMEM );
if( rc==SQLITE_OK && !DbHasProperty(*ppDb, 0, DB_SchemaLoaded) ){
- ENC(*ppDb) = SQLITE_UTF16NATIVE;
+ SCHEMA_ENC(*ppDb) = ENC(*ppDb) = SQLITE_UTF16NATIVE;
}
}else{
rc = SQLITE_NOMEM;
@@ -127705,26 +130515,20 @@ SQLITE_API int sqlite3_open16(
/*
** Register a new collation sequence with the database handle db.
*/
-SQLITE_API int sqlite3_create_collation(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
sqlite3* db,
const char *zName,
int enc,
void* pCtx,
int(*xCompare)(void*,int,const void*,int,const void*)
){
- int rc;
- sqlite3_mutex_enter(db->mutex);
- assert( !db->mallocFailed );
- rc = createCollation(db, zName, (u8)enc, pCtx, xCompare, 0);
- rc = sqlite3ApiExit(db, rc);
- sqlite3_mutex_leave(db->mutex);
- return rc;
+ return sqlite3_create_collation_v2(db, zName, enc, pCtx, xCompare, 0);
}
/*
** Register a new collation sequence with the database handle db.
*/
-SQLITE_API int sqlite3_create_collation_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
sqlite3* db,
const char *zName,
int enc,
@@ -127733,6 +130537,10 @@ SQLITE_API int sqlite3_create_collation_v2(
void(*xDel)(void*)
){
int rc;
+
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;
+#endif
sqlite3_mutex_enter(db->mutex);
assert( !db->mallocFailed );
rc = createCollation(db, zName, (u8)enc, pCtx, xCompare, xDel);
@@ -127745,7 +130553,7 @@ SQLITE_API int sqlite3_create_collation_v2(
/*
** Register a new collation sequence with the database handle db.
*/
-SQLITE_API int sqlite3_create_collation16(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
sqlite3* db,
const void *zName,
int enc,
@@ -127754,6 +130562,10 @@ SQLITE_API int sqlite3_create_collation16(
){
int rc = SQLITE_OK;
char *zName8;
+
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) || zName==0 ) return SQLITE_MISUSE_BKPT;
+#endif
sqlite3_mutex_enter(db->mutex);
assert( !db->mallocFailed );
zName8 = sqlite3Utf16to8(db, zName, -1, SQLITE_UTF16NATIVE);
@@ -127771,11 +130583,14 @@ SQLITE_API int sqlite3_create_collation16(
** Register a collation sequence factory callback with the database handle
** db. Replace any previously installed collation sequence factory.
*/
-SQLITE_API int sqlite3_collation_needed(
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
sqlite3 *db,
void *pCollNeededArg,
void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*)
){
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
+#endif
sqlite3_mutex_enter(db->mutex);
db->xCollNeeded = xCollNeeded;
db->xCollNeeded16 = 0;
@@ -127789,11 +130604,14 @@ SQLITE_API int sqlite3_collation_needed(
** Register a collation sequence factory callback with the database handle
** db. Replace any previously installed collation sequence factory.
*/
-SQLITE_API int sqlite3_collation_needed16(
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
sqlite3 *db,
void *pCollNeededArg,
void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*)
){
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
+#endif
sqlite3_mutex_enter(db->mutex);
db->xCollNeeded = 0;
db->xCollNeeded16 = xCollNeeded16;
@@ -127808,7 +130626,7 @@ SQLITE_API int sqlite3_collation_needed16(
** This function is now an anachronism. It used to be used to recover from a
** malloc() failure, but SQLite now does this automatically.
*/
-SQLITE_API int sqlite3_global_recover(void){
+SQLITE_API int SQLITE_STDCALL sqlite3_global_recover(void){
return SQLITE_OK;
}
#endif
@@ -127819,7 +130637,13 @@ SQLITE_API int sqlite3_global_recover(void){
** by default. Autocommit is disabled by a BEGIN statement and reenabled
** by the next COMMIT or ROLLBACK.
*/
-SQLITE_API int sqlite3_get_autocommit(sqlite3 *db){
+SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3 *db){
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
return db->autoCommit;
}
@@ -127865,7 +130689,7 @@ SQLITE_PRIVATE int sqlite3CantopenError(int lineno){
** SQLite no longer uses thread-specific data so this routine is now a
** no-op. It is retained for historical compatibility.
*/
-SQLITE_API void sqlite3_thread_cleanup(void){
+SQLITE_API void SQLITE_STDCALL sqlite3_thread_cleanup(void){
}
#endif
@@ -127873,8 +130697,7 @@ SQLITE_API void sqlite3_thread_cleanup(void){
** Return meta information about a specific column of a database table.
** See comment in sqlite3.h (sqlite.h.in) for details.
*/
-#ifdef SQLITE_ENABLE_COLUMN_METADATA
-SQLITE_API int sqlite3_table_column_metadata(
+SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
sqlite3 *db, /* Connection handle */
const char *zDbName, /* Database name or NULL */
const char *zTableName, /* Table name */
@@ -127889,14 +130712,20 @@ SQLITE_API int sqlite3_table_column_metadata(
char *zErrMsg = 0;
Table *pTab = 0;
Column *pCol = 0;
- int iCol;
-
+ int iCol = 0;
char const *zDataType = 0;
char const *zCollSeq = 0;
int notnull = 0;
int primarykey = 0;
int autoinc = 0;
+
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) || zTableName==0 ){
+ return SQLITE_MISUSE_BKPT;
+ }
+#endif
+
/* Ensure the database schema has been loaded */
sqlite3_mutex_enter(db->mutex);
sqlite3BtreeEnterAll(db);
@@ -127913,11 +130742,8 @@ SQLITE_API int sqlite3_table_column_metadata(
}
/* Find the column for which info is requested */
- if( sqlite3IsRowid(zColumnName) ){
- iCol = pTab->iPKey;
- if( iCol>=0 ){
- pCol = &pTab->aCol[iCol];
- }
+ if( zColumnName==0 ){
+ /* Query for existance of table only */
}else{
for(iCol=0; iCol<pTab->nCol; iCol++){
pCol = &pTab->aCol[iCol];
@@ -127926,8 +130752,13 @@ SQLITE_API int sqlite3_table_column_metadata(
}
}
if( iCol==pTab->nCol ){
- pTab = 0;
- goto error_out;
+ if( HasRowid(pTab) && sqlite3IsRowid(zColumnName) ){
+ iCol = pTab->iPKey;
+ pCol = iCol>=0 ? &pTab->aCol[iCol] : 0;
+ }else{
+ pTab = 0;
+ goto error_out;
+ }
}
}
@@ -127980,12 +130811,11 @@ error_out:
sqlite3_mutex_leave(db->mutex);
return rc;
}
-#endif
/*
** Sleep for a little while. Return the amount of time slept.
*/
-SQLITE_API int sqlite3_sleep(int ms){
+SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int ms){
sqlite3_vfs *pVfs;
int rc;
pVfs = sqlite3_vfs_find(0);
@@ -128001,7 +130831,10 @@ SQLITE_API int sqlite3_sleep(int ms){
/*
** Enable or disable the extended result codes.
*/
-SQLITE_API int sqlite3_extended_result_codes(sqlite3 *db, int onoff){
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3 *db, int onoff){
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
+#endif
sqlite3_mutex_enter(db->mutex);
db->errMask = onoff ? 0xffffffff : 0xff;
sqlite3_mutex_leave(db->mutex);
@@ -128011,10 +130844,13 @@ SQLITE_API int sqlite3_extended_result_codes(sqlite3 *db, int onoff){
/*
** Invoke the xFileControl method on a particular database.
*/
-SQLITE_API int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){
+SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){
int rc = SQLITE_ERROR;
Btree *pBtree;
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
+#endif
sqlite3_mutex_enter(db->mutex);
pBtree = sqlite3DbNameToBtree(db, zDbName);
if( pBtree ){
@@ -128036,13 +130872,13 @@ SQLITE_API int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, vo
sqlite3BtreeLeave(pBtree);
}
sqlite3_mutex_leave(db->mutex);
- return rc;
+ return rc;
}
/*
** Interface to the testing logic.
*/
-SQLITE_API int sqlite3_test_control(int op, ...){
+SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...){
int rc = 0;
#ifndef SQLITE_OMIT_BUILTIN_TEST
va_list ap;
@@ -128339,6 +131175,35 @@ SQLITE_API int sqlite3_test_control(int op, ...){
if( sqlite3GlobalConfig.isInit==0 ) rc = SQLITE_ERROR;
break;
}
+
+ /* sqlite3_test_control(SQLITE_TESTCTRL_IMPOSTER, db, dbName, onOff, tnum);
+ **
+ ** This test control is used to create imposter tables. "db" is a pointer
+ ** to the database connection. dbName is the database name (ex: "main" or
+ ** "temp") which will receive the imposter. "onOff" turns imposter mode on
+ ** or off. "tnum" is the root page of the b-tree to which the imposter
+ ** table should connect.
+ **
+ ** Enable imposter mode only when the schema has already been parsed. Then
+ ** run a single CREATE TABLE statement to construct the imposter table in
+ ** the parsed schema. Then turn imposter mode back off again.
+ **
+ ** If onOff==0 and tnum>0 then reset the schema for all databases, causing
+ ** the schema to be reparsed the next time it is needed. This has the
+ ** effect of erasing all imposter tables.
+ */
+ case SQLITE_TESTCTRL_IMPOSTER: {
+ sqlite3 *db = va_arg(ap, sqlite3*);
+ sqlite3_mutex_enter(db->mutex);
+ db->init.iDb = sqlite3FindDbName(db, va_arg(ap,const char*));
+ db->init.busy = db->init.imposterTable = va_arg(ap,int);
+ db->init.newTnum = va_arg(ap,int);
+ if( db->init.busy==0 && db->init.newTnum>0 ){
+ sqlite3ResetAllSchemasOfConnection(db);
+ }
+ sqlite3_mutex_leave(db->mutex);
+ break;
+ }
}
va_end(ap);
#endif /* SQLITE_OMIT_BUILTIN_TEST */
@@ -128356,8 +131221,8 @@ SQLITE_API int sqlite3_test_control(int op, ...){
** parameter if it exists. If the parameter does not exist, this routine
** returns a NULL pointer.
*/
-SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam){
- if( zFilename==0 ) return 0;
+SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam){
+ if( zFilename==0 || zParam==0 ) return 0;
zFilename += sqlite3Strlen30(zFilename) + 1;
while( zFilename[0] ){
int x = strcmp(zFilename, zParam);
@@ -128371,7 +131236,7 @@ SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *
/*
** Return a boolean value for a query parameter.
*/
-SQLITE_API int sqlite3_uri_boolean(const char *zFilename, const char *zParam, int bDflt){
+SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFilename, const char *zParam, int bDflt){
const char *z = sqlite3_uri_parameter(zFilename, zParam);
bDflt = bDflt!=0;
return z ? sqlite3GetBoolean(z, bDflt) : bDflt;
@@ -128380,7 +131245,7 @@ SQLITE_API int sqlite3_uri_boolean(const char *zFilename, const char *zParam, in
/*
** Return a 64-bit integer value for a query parameter.
*/
-SQLITE_API sqlite3_int64 sqlite3_uri_int64(
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(
const char *zFilename, /* Filename as passed to xOpen */
const char *zParam, /* URI parameter sought */
sqlite3_int64 bDflt /* return if parameter is missing */
@@ -128412,8 +131277,15 @@ SQLITE_PRIVATE Btree *sqlite3DbNameToBtree(sqlite3 *db, const char *zDbName){
** Return the filename of the database associated with a database
** connection.
*/
-SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){
- Btree *pBt = sqlite3DbNameToBtree(db, zDbName);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName){
+ Btree *pBt;
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return 0;
+ }
+#endif
+ pBt = sqlite3DbNameToBtree(db, zDbName);
return pBt ? sqlite3BtreeGetFilename(pBt) : 0;
}
@@ -128421,8 +131293,15 @@ SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){
** Return 1 if database is read-only or 0 if read/write. Return -1 if
** no such database exists.
*/
-SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName){
- Btree *pBt = sqlite3DbNameToBtree(db, zDbName);
+SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName){
+ Btree *pBt;
+#ifdef SQLITE_ENABLE_API_ARMOR
+ if( !sqlite3SafetyCheckOk(db) ){
+ (void)SQLITE_MISUSE_BKPT;
+ return -1;
+ }
+#endif
+ pBt = sqlite3DbNameToBtree(db, zDbName);
return pBt ? sqlite3BtreeIsReadonly(pBt) : -1;
}
@@ -128573,7 +131452,7 @@ static void leaveMutex(void){
** on the same "db". If xNotify==0 then any prior callbacks are immediately
** cancelled.
*/
-SQLITE_API int sqlite3_unlock_notify(
+SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
sqlite3 *db,
void (*xNotify)(void **, int),
void *pArg
@@ -129708,6 +132587,11 @@ struct Fts3Phrase {
int bIncr; /* True if doclist is loaded incrementally */
int iDoclistToken;
+ /* Used by sqlite3Fts3EvalPhrasePoslist() if this is a descendent of an
+ ** OR condition. */
+ char *pOrPoslist;
+ i64 iOrDocid;
+
/* Variables below this point are populated by fts3_expr.c when parsing
** a MATCH expression. Everything above is part of the evaluation phase.
*/
@@ -130548,11 +133432,16 @@ static char *fts3WriteExprList(Fts3Table *p, const char *zFunc, int *pRc){
** This function is used when parsing the "prefix=" FTS4 parameter.
*/
static int fts3GobbleInt(const char **pp, int *pnOut){
+ const int MAX_NPREFIX = 10000000;
const char *p; /* Iterator pointer */
int nInt = 0; /* Output value */
for(p=*pp; p[0]>='0' && p[0]<='9'; p++){
nInt = nInt * 10 + (p[0] - '0');
+ if( nInt>MAX_NPREFIX ){
+ nInt = 0;
+ break;
+ }
}
if( p==*pp ) return SQLITE_ERROR;
*pnOut = nInt;
@@ -130595,7 +133484,6 @@ static int fts3PrefixParameter(
aIndex = sqlite3_malloc(sizeof(struct Fts3Index) * nIndex);
*apIndex = aIndex;
- *pnIndex = nIndex;
if( !aIndex ){
return SQLITE_NOMEM;
}
@@ -130605,13 +133493,20 @@ static int fts3PrefixParameter(
const char *p = zParam;
int i;
for(i=1; i<nIndex; i++){
- int nPrefix;
+ int nPrefix = 0;
if( fts3GobbleInt(&p, &nPrefix) ) return SQLITE_ERROR;
- aIndex[i].nPrefix = nPrefix;
+ assert( nPrefix>=0 );
+ if( nPrefix==0 ){
+ nIndex--;
+ i--;
+ }else{
+ aIndex[i].nPrefix = nPrefix;
+ }
p++;
}
}
+ *pnIndex = nIndex;
return SQLITE_OK;
}
@@ -130735,7 +133630,7 @@ static int fts3InitVtab(
const char **aCol; /* Array of column names */
sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */
- int nIndex; /* Size of aIndex[] array */
+ int nIndex = 0; /* Size of aIndex[] array */
struct Fts3Index *aIndex = 0; /* Array of indexes for this table */
/* The results of parsing supported FTS4 key=value options: */
@@ -131491,7 +134386,7 @@ static int fts3SelectLeaf(
sqlite3_int64 *piLeaf, /* Selected leaf node */
sqlite3_int64 *piLeaf2 /* Selected leaf node */
){
- int rc; /* Return code */
+ int rc = SQLITE_OK; /* Return code */
int iHeight; /* Height of this node in tree */
assert( piLeaf || piLeaf2 );
@@ -131502,7 +134397,7 @@ static int fts3SelectLeaf(
if( rc==SQLITE_OK && iHeight>1 ){
char *zBlob = 0; /* Blob read from %_segments table */
- int nBlob; /* Size of zBlob in bytes */
+ int nBlob = 0; /* Size of zBlob in bytes */
if( piLeaf && piLeaf2 && (*piLeaf!=*piLeaf2) ){
rc = sqlite3Fts3ReadBlock(p, *piLeaf, &zBlob, &nBlob, 0);
@@ -132129,26 +135024,33 @@ static int fts3DoclistOrMerge(
**
** The right-hand input doclist is overwritten by this function.
*/
-static void fts3DoclistPhraseMerge(
+static int fts3DoclistPhraseMerge(
int bDescDoclist, /* True if arguments are desc */
int nDist, /* Distance from left to right (1=adjacent) */
char *aLeft, int nLeft, /* Left doclist */
- char *aRight, int *pnRight /* IN/OUT: Right/output doclist */
+ char **paRight, int *pnRight /* IN/OUT: Right/output doclist */
){
sqlite3_int64 i1 = 0;
sqlite3_int64 i2 = 0;
sqlite3_int64 iPrev = 0;
+ char *aRight = *paRight;
char *pEnd1 = &aLeft[nLeft];
char *pEnd2 = &aRight[*pnRight];
char *p1 = aLeft;
char *p2 = aRight;
char *p;
int bFirstOut = 0;
- char *aOut = aRight;
+ char *aOut;
assert( nDist>0 );
-
+ if( bDescDoclist ){
+ aOut = sqlite3_malloc(*pnRight + FTS3_VARINT_MAX);
+ if( aOut==0 ) return SQLITE_NOMEM;
+ }else{
+ aOut = aRight;
+ }
p = aOut;
+
fts3GetDeltaVarint3(&p1, pEnd1, 0, &i1);
fts3GetDeltaVarint3(&p2, pEnd2, 0, &i2);
@@ -132177,6 +135079,12 @@ static void fts3DoclistPhraseMerge(
}
*pnRight = (int)(p - aOut);
+ if( bDescDoclist ){
+ sqlite3_free(aRight);
+ *paRight = aOut;
+ }
+
+ return SQLITE_OK;
}
/*
@@ -132301,8 +135209,22 @@ static int fts3TermSelectMerge(
){
if( pTS->aaOutput[0]==0 ){
/* If this is the first term selected, copy the doclist to the output
- ** buffer using memcpy(). */
- pTS->aaOutput[0] = sqlite3_malloc(nDoclist);
+ ** buffer using memcpy().
+ **
+ ** Add FTS3_VARINT_MAX bytes of unused space to the end of the
+ ** allocation. This is so as to ensure that the buffer is big enough
+ ** to hold the current doclist AND'd with any other doclist. If the
+ ** doclists are stored in order=ASC order, this padding would not be
+ ** required (since the size of [doclistA AND doclistB] is always less
+ ** than or equal to the size of [doclistA] in that case). But this is
+ ** not true for order=DESC. For example, a doclist containing (1, -1)
+ ** may be smaller than (-1), as in the first example the -1 may be stored
+ ** as a single-byte delta, whereas in the second it must be stored as a
+ ** FTS3_VARINT_MAX byte varint.
+ **
+ ** Similar padding is added in the fts3DoclistOrMerge() function.
+ */
+ pTS->aaOutput[0] = sqlite3_malloc(nDoclist + FTS3_VARINT_MAX + 1);
pTS->anOutput[0] = nDoclist;
if( pTS->aaOutput[0] ){
memcpy(pTS->aaOutput[0], aDoclist, nDoclist);
@@ -132724,7 +135646,7 @@ static int fts3FilterMethod(
int nVal, /* Number of elements in apVal */
sqlite3_value **apVal /* Arguments for the indexing scheme */
){
- int rc;
+ int rc = SQLITE_OK;
char *zSql; /* SQL statement used to access %_content */
int eSearch;
Fts3Table *p = (Fts3Table *)pCursor->pVtab;
@@ -132802,10 +135724,17 @@ static int fts3FilterMethod(
** row by docid.
*/
if( eSearch==FTS3_FULLSCAN_SEARCH ){
- zSql = sqlite3_mprintf(
- "SELECT %s ORDER BY rowid %s",
- p->zReadExprlist, (pCsr->bDesc ? "DESC" : "ASC")
- );
+ if( pDocidGe || pDocidLe ){
+ zSql = sqlite3_mprintf(
+ "SELECT %s WHERE rowid BETWEEN %lld AND %lld ORDER BY rowid %s",
+ p->zReadExprlist, pCsr->iMinDocid, pCsr->iMaxDocid,
+ (pCsr->bDesc ? "DESC" : "ASC")
+ );
+ }else{
+ zSql = sqlite3_mprintf("SELECT %s ORDER BY rowid %s",
+ p->zReadExprlist, (pCsr->bDesc ? "DESC" : "ASC")
+ );
+ }
if( zSql ){
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pCsr->pStmt, 0);
sqlite3_free(zSql);
@@ -133551,14 +136480,17 @@ static void fts3EvalAllocateReaders(
** This function assumes that pList points to a buffer allocated using
** sqlite3_malloc(). This function takes responsibility for eventually
** freeing the buffer.
+**
+** SQLITE_OK is returned if successful, or SQLITE_NOMEM if an error occurs.
*/
-static void fts3EvalPhraseMergeToken(
+static int fts3EvalPhraseMergeToken(
Fts3Table *pTab, /* FTS Table pointer */
Fts3Phrase *p, /* Phrase to merge pList/nList into */
int iToken, /* Token pList/nList corresponds to */
char *pList, /* Pointer to doclist */
int nList /* Number of bytes in pList */
){
+ int rc = SQLITE_OK;
assert( iToken!=p->iDoclistToken );
if( pList==0 ){
@@ -133597,13 +136529,16 @@ static void fts3EvalPhraseMergeToken(
nDiff = p->iDoclistToken - iToken;
}
- fts3DoclistPhraseMerge(pTab->bDescIdx, nDiff, pLeft, nLeft, pRight,&nRight);
+ rc = fts3DoclistPhraseMerge(
+ pTab->bDescIdx, nDiff, pLeft, nLeft, &pRight, &nRight
+ );
sqlite3_free(pLeft);
p->doclist.aAll = pRight;
p->doclist.nAll = nRight;
}
if( iToken>p->iDoclistToken ) p->iDoclistToken = iToken;
+ return rc;
}
/*
@@ -133629,7 +136564,7 @@ static int fts3EvalPhraseLoad(
char *pThis = 0;
rc = fts3TermSelect(pTab, pToken, p->iColumn, &nThis, &pThis);
if( rc==SQLITE_OK ){
- fts3EvalPhraseMergeToken(pTab, p, iToken, pThis, nThis);
+ rc = fts3EvalPhraseMergeToken(pTab, p, iToken, pThis, nThis);
}
}
assert( pToken->pSegcsr==0 );
@@ -134432,8 +137367,12 @@ static int fts3EvalSelectDeferred(
rc = fts3TermSelect(pTab, pToken, pTC->iCol, &nList, &pList);
assert( rc==SQLITE_OK || pList==0 );
if( rc==SQLITE_OK ){
+ rc = fts3EvalPhraseMergeToken(
+ pTab, pTC->pPhrase, pTC->iToken,pList,nList
+ );
+ }
+ if( rc==SQLITE_OK ){
int nCount;
- fts3EvalPhraseMergeToken(pTab, pTC->pPhrase, pTC->iToken,pList,nList);
nCount = fts3DoclistCountDocids(
pTC->pPhrase->doclist.aAll, pTC->pPhrase->doclist.nAll
);
@@ -134658,6 +137597,22 @@ static void fts3EvalNextRow(
}
pExpr->iDocid = pLeft->iDocid;
pExpr->bEof = (pLeft->bEof || pRight->bEof);
+ if( pExpr->eType==FTSQUERY_NEAR && pExpr->bEof ){
+ if( pRight->pPhrase && pRight->pPhrase->doclist.aAll ){
+ Fts3Doclist *pDl = &pRight->pPhrase->doclist;
+ while( *pRc==SQLITE_OK && pRight->bEof==0 ){
+ memset(pDl->pList, 0, pDl->nList);
+ fts3EvalNextRow(pCsr, pRight, pRc);
+ }
+ }
+ if( pLeft->pPhrase && pLeft->pPhrase->doclist.aAll ){
+ Fts3Doclist *pDl = &pLeft->pPhrase->doclist;
+ while( *pRc==SQLITE_OK && pLeft->bEof==0 ){
+ memset(pDl->pList, 0, pDl->nList);
+ fts3EvalNextRow(pCsr, pLeft, pRc);
+ }
+ }
+ }
}
break;
}
@@ -135030,6 +137985,7 @@ static void fts3EvalRestart(
}
pPhrase->doclist.pNextDocid = 0;
pPhrase->doclist.iDocid = 0;
+ pPhrase->pOrPoslist = 0;
}
pExpr->iDocid = 0;
@@ -135275,8 +138231,8 @@ SQLITE_PRIVATE int sqlite3Fts3EvalPhrasePoslist(
iDocid = pExpr->iDocid;
pIter = pPhrase->doclist.pList;
if( iDocid!=pCsr->iPrevId || pExpr->bEof ){
+ int rc = SQLITE_OK;
int bDescDoclist = pTab->bDescIdx; /* For DOCID_CMP macro */
- int iMul; /* +1 if csr dir matches index dir, else -1 */
int bOr = 0;
u8 bEof = 0;
u8 bTreeEof = 0;
@@ -135300,72 +138256,43 @@ SQLITE_PRIVATE int sqlite3Fts3EvalPhrasePoslist(
** an incremental phrase. Load the entire doclist for the phrase
** into memory in this case. */
if( pPhrase->bIncr ){
- int rc = SQLITE_OK;
- int bEofSave = pExpr->bEof;
- fts3EvalRestart(pCsr, pExpr, &rc);
- while( rc==SQLITE_OK && !pExpr->bEof ){
- fts3EvalNextRow(pCsr, pExpr, &rc);
- if( bEofSave==0 && pExpr->iDocid==iDocid ) break;
+ int bEofSave = pNear->bEof;
+ fts3EvalRestart(pCsr, pNear, &rc);
+ while( rc==SQLITE_OK && !pNear->bEof ){
+ fts3EvalNextRow(pCsr, pNear, &rc);
+ if( bEofSave==0 && pNear->iDocid==iDocid ) break;
}
- pIter = pPhrase->doclist.pList;
assert( rc!=SQLITE_OK || pPhrase->bIncr==0 );
- if( rc!=SQLITE_OK ) return rc;
}
-
- iMul = ((pCsr->bDesc==bDescDoclist) ? 1 : -1);
- while( bTreeEof==1
- && pNear->bEof==0
- && (DOCID_CMP(pNear->iDocid, pCsr->iPrevId) * iMul)<0
- ){
- int rc = SQLITE_OK;
- fts3EvalNextRow(pCsr, pExpr, &rc);
- if( rc!=SQLITE_OK ) return rc;
- iDocid = pExpr->iDocid;
- pIter = pPhrase->doclist.pList;
+ if( bTreeEof ){
+ while( rc==SQLITE_OK && !pNear->bEof ){
+ fts3EvalNextRow(pCsr, pNear, &rc);
+ }
}
+ if( rc!=SQLITE_OK ) return rc;
- bEof = (pPhrase->doclist.nAll==0);
- assert( bDescDoclist==0 || bDescDoclist==1 );
- assert( pCsr->bDesc==0 || pCsr->bDesc==1 );
-
- if( bEof==0 ){
- if( pCsr->bDesc==bDescDoclist ){
+ pIter = pPhrase->pOrPoslist;
+ iDocid = pPhrase->iOrDocid;
+ if( pCsr->bDesc==bDescDoclist ){
+ bEof = (pIter >= (pPhrase->doclist.aAll + pPhrase->doclist.nAll));
+ while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){
+ sqlite3Fts3DoclistNext(
+ bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll,
+ &pIter, &iDocid, &bEof
+ );
+ }
+ }else{
+ bEof = !pPhrase->doclist.nAll || (pIter && pIter<=pPhrase->doclist.aAll);
+ while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){
int dummy;
- if( pNear->bEof ){
- /* This expression is already at EOF. So position it to point to the
- ** last entry in the doclist at pPhrase->doclist.aAll[]. Variable
- ** iDocid is already set for this entry, so all that is required is
- ** to set pIter to point to the first byte of the last position-list
- ** in the doclist.
- **
- ** It would also be correct to set pIter and iDocid to zero. In
- ** this case, the first call to sqltie3Fts4DoclistPrev() below
- ** would also move the iterator to point to the last entry in the
- ** doclist. However, this is expensive, as to do so it has to
- ** iterate through the entire doclist from start to finish (since
- ** it does not know the docid for the last entry). */
- pIter = &pPhrase->doclist.aAll[pPhrase->doclist.nAll-1];
- fts3ReversePoslist(pPhrase->doclist.aAll, &pIter);
- }
- while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)>0 ) && bEof==0 ){
- sqlite3Fts3DoclistPrev(
- bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll,
- &pIter, &iDocid, &dummy, &bEof
- );
- }
- }else{
- if( pNear->bEof ){
- pIter = 0;
- iDocid = 0;
- }
- while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){
- sqlite3Fts3DoclistNext(
- bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll,
- &pIter, &iDocid, &bEof
- );
- }
+ sqlite3Fts3DoclistPrev(
+ bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll,
+ &pIter, &iDocid, &dummy, &bEof
+ );
}
}
+ pPhrase->pOrPoslist = pIter;
+ pPhrase->iOrDocid = iDocid;
if( bEof || iDocid!=pCsr->iPrevId ) pIter = 0;
}
@@ -135379,10 +138306,13 @@ SQLITE_PRIVATE int sqlite3Fts3EvalPhrasePoslist(
}
while( iThis<iCol ){
fts3ColumnlistCopy(0, &pIter);
- if( *pIter==0x00 ) return 0;
+ if( *pIter==0x00 ) return SQLITE_OK;
pIter++;
pIter += fts3GetVarint32(pIter, &iThis);
}
+ if( *pIter==0x00 ){
+ pIter = 0;
+ }
*ppOut = ((iCol==iThis)?pIter:0);
return SQLITE_OK;
@@ -135425,7 +138355,7 @@ SQLITE_PRIVATE int sqlite3Fts3Corrupt(){
#ifdef _WIN32
__declspec(dllexport)
#endif
-SQLITE_API int sqlite3_fts3_init(
+SQLITE_API int SQLITE_STDCALL sqlite3_fts3_init(
sqlite3 *db,
char **pzErrMsg,
const sqlite3_api_routines *pApi
@@ -137843,7 +140773,7 @@ static int isVowel(const char *z){
** by a consonant.
**
** In this routine z[] is in reverse order. So we are really looking
-** for an instance of of a consonant followed by a vowel.
+** for an instance of a consonant followed by a vowel.
*/
static int m_gt_0(const char *z){
while( isVowel(z) ){ z++; }
@@ -138393,7 +141323,7 @@ static void scalarFunc(
if( argc==2 ){
void *pOld;
int n = sqlite3_value_bytes(argv[1]);
- if( n!=sizeof(pPtr) ){
+ if( zName==0 || n!=sizeof(pPtr) ){
sqlite3_result_error(context, "argument type mismatch", -1);
return;
}
@@ -138404,7 +141334,9 @@ static void scalarFunc(
return;
}
}else{
- pPtr = sqlite3Fts3HashFind(pHash, zName, nName);
+ if( zName ){
+ pPtr = sqlite3Fts3HashFind(pHash, zName, nName);
+ }
if( !pPtr ){
char *zErr = sqlite3_mprintf("unknown tokenizer: %s", zName);
sqlite3_result_error(context, zErr, -1);
@@ -138485,6 +141417,10 @@ SQLITE_PRIVATE int sqlite3Fts3InitTokenizer(
zEnd = &zCopy[strlen(zCopy)];
z = (char *)sqlite3Fts3NextToken(zCopy, &n);
+ if( z==0 ){
+ assert( n==0 );
+ z = zCopy;
+ }
z[n] = '\0';
sqlite3Fts3Dequote(z);
@@ -139212,7 +142148,7 @@ static int fts3tokConnectMethod(
sqlite3_vtab **ppVtab, /* OUT: New sqlite3_vtab object */
char **pzErr /* OUT: sqlite3_malloc'd error message */
){
- Fts3tokTable *pTab;
+ Fts3tokTable *pTab = 0;
const sqlite3_tokenizer_module *pMod = 0;
sqlite3_tokenizer *pTok = 0;
int rc;
@@ -141130,7 +144066,10 @@ SQLITE_PRIVATE int sqlite3Fts3SegReaderNew(
** an array of pending terms by term. This occurs as part of flushing
** the contents of the pending-terms hash table to the database.
*/
-static int fts3CompareElemByTerm(const void *lhs, const void *rhs){
+static int SQLITE_CDECL fts3CompareElemByTerm(
+ const void *lhs,
+ const void *rhs
+){
char *z1 = fts3HashKey(*(Fts3HashElem **)lhs);
char *z2 = fts3HashKey(*(Fts3HashElem **)rhs);
int n1 = fts3HashKeysize(*(Fts3HashElem **)lhs);
@@ -142587,8 +145526,8 @@ static int fts3PromoteSegments(
if( bOk ){
int iIdx = 0;
- sqlite3_stmt *pUpdate1;
- sqlite3_stmt *pUpdate2;
+ sqlite3_stmt *pUpdate1 = 0;
+ sqlite3_stmt *pUpdate2 = 0;
if( rc==SQLITE_OK ){
rc = fts3SqlStmt(p, SQL_UPDATE_LEVEL_IDX, &pUpdate1, 0);
@@ -145609,37 +148548,39 @@ static int fts3BestSnippet(
sIter.nSnippet = nSnippet;
sIter.nPhrase = nList;
sIter.iCurrent = -1;
- (void)fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void *)&sIter);
+ rc = fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void *)&sIter);
+ if( rc==SQLITE_OK ){
- /* Set the *pmSeen output variable. */
- for(i=0; i<nList; i++){
- if( sIter.aPhrase[i].pHead ){
- *pmSeen |= (u64)1 << i;
+ /* Set the *pmSeen output variable. */
+ for(i=0; i<nList; i++){
+ if( sIter.aPhrase[i].pHead ){
+ *pmSeen |= (u64)1 << i;
+ }
}
- }
- /* Loop through all candidate snippets. Store the best snippet in
- ** *pFragment. Store its associated 'score' in iBestScore.
- */
- pFragment->iCol = iCol;
- while( !fts3SnippetNextCandidate(&sIter) ){
- int iPos;
- int iScore;
- u64 mCover;
- u64 mHighlight;
- fts3SnippetDetails(&sIter, mCovered, &iPos, &iScore, &mCover, &mHighlight);
- assert( iScore>=0 );
- if( iScore>iBestScore ){
- pFragment->iPos = iPos;
- pFragment->hlmask = mHighlight;
- pFragment->covered = mCover;
- iBestScore = iScore;
+ /* Loop through all candidate snippets. Store the best snippet in
+ ** *pFragment. Store its associated 'score' in iBestScore.
+ */
+ pFragment->iCol = iCol;
+ while( !fts3SnippetNextCandidate(&sIter) ){
+ int iPos;
+ int iScore;
+ u64 mCover;
+ u64 mHighlite;
+ fts3SnippetDetails(&sIter, mCovered, &iPos, &iScore, &mCover,&mHighlite);
+ assert( iScore>=0 );
+ if( iScore>iBestScore ){
+ pFragment->iPos = iPos;
+ pFragment->hlmask = mHighlite;
+ pFragment->covered = mCover;
+ iBestScore = iScore;
+ }
}
- }
+ *piScore = iBestScore;
+ }
sqlite3_free(sIter.aPhrase);
- *piScore = iBestScore;
- return SQLITE_OK;
+ return rc;
}
@@ -145847,8 +148788,12 @@ static int fts3SnippetText(
** required. They are required if (a) this is not the first fragment,
** or (b) this fragment does not begin at position 0 of its column.
*/
- if( rc==SQLITE_OK && (iPos>0 || iFragment>0) ){
- rc = fts3StringAppend(pOut, zEllipsis, -1);
+ if( rc==SQLITE_OK ){
+ if( iPos>0 || iFragment>0 ){
+ rc = fts3StringAppend(pOut, zEllipsis, -1);
+ }else if( iBegin ){
+ rc = fts3StringAppend(pOut, zDoc, iBegin);
+ }
}
if( rc!=SQLITE_OK || iCurrent<iPos ) continue;
}
@@ -146414,7 +149359,7 @@ SQLITE_PRIVATE void sqlite3Fts3Snippet(
*/
for(iRead=0; iRead<pTab->nColumn; iRead++){
SnippetFragment sF = {0, 0, 0, 0};
- int iS;
+ int iS = 0;
if( iCol>=0 && iRead!=iCol ) continue;
/* Find the best snippet of nFToken tokens in column iRead. */
@@ -147820,13 +150765,12 @@ static int readInt16(u8 *p){
return (p[0]<<8) + p[1];
}
static void readCoord(u8 *p, RtreeCoord *pCoord){
- u32 i = (
+ pCoord->u = (
(((u32)p[0]) << 24) +
(((u32)p[1]) << 16) +
(((u32)p[2]) << 8) +
(((u32)p[3]) << 0)
);
- *(u32 *)pCoord = i;
}
static i64 readInt64(u8 *p){
return (
@@ -147855,7 +150799,7 @@ static int writeCoord(u8 *p, RtreeCoord *pCoord){
u32 i;
assert( sizeof(RtreeCoord)==4 );
assert( sizeof(u32)==4 );
- i = *(u32 *)pCoord;
+ i = pCoord->u;
p[0] = (i>>24)&0xFF;
p[1] = (i>>16)&0xFF;
p[2] = (i>> 8)&0xFF;
@@ -148186,14 +151130,13 @@ static void nodeGetCell(
RtreeCell *pCell /* OUT: Write the cell contents here */
){
u8 *pData;
- u8 *pEnd;
RtreeCoord *pCoord;
+ int ii;
pCell->iRowid = nodeGetRowid(pRtree, pNode, iCell);
pData = pNode->zData + (12 + pRtree->nBytesPerCell*iCell);
- pEnd = pData + pRtree->nDim*8;
pCoord = pCell->aCoord;
- for(; pData<pEnd; pData+=4, pCoord++){
- readCoord(pData, pCoord);
+ for(ii=0; ii<pRtree->nDim*2; ii++){
+ readCoord(&pData[ii*4], &pCoord[ii]);
}
}
@@ -148633,7 +151576,7 @@ static RtreeSearchPoint *rtreeEnqueue(
pNew = pCur->aPoint + i;
pNew->rScore = rScore;
pNew->iLevel = iLevel;
- assert( iLevel>=0 && iLevel<=RTREE_MAX_DEPTH );
+ assert( iLevel<=RTREE_MAX_DEPTH );
while( i>0 ){
RtreeSearchPoint *pParent;
j = (i-1)/2;
@@ -150257,6 +153200,8 @@ static int rtreeUpdate(
rtreeReference(pRtree);
assert(nData>=1);
+ cell.iRowid = 0; /* Used only to suppress a compiler warning */
+
/* Constraint handling. A write operation on an r-tree table may return
** SQLITE_CONSTRAINT for two reasons:
**
@@ -150857,7 +153802,7 @@ static void geomCallback(sqlite3_context *ctx, int nArg, sqlite3_value **aArg){
/*
** Register a new geometry function for use with the r-tree MATCH operator.
*/
-SQLITE_API int sqlite3_rtree_geometry_callback(
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
sqlite3 *db, /* Register SQL function on this connection */
const char *zGeom, /* Name of the new SQL function */
int (*xGeom)(sqlite3_rtree_geometry*,int,RtreeDValue*,int*), /* Callback */
@@ -150881,7 +153826,7 @@ SQLITE_API int sqlite3_rtree_geometry_callback(
** Register a new 2nd-generation geometry function for use with the
** r-tree MATCH operator.
*/
-SQLITE_API int sqlite3_rtree_query_callback(
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
sqlite3 *db, /* Register SQL function on this connection */
const char *zQueryFunc, /* Name of new SQL function */
int (*xQueryFunc)(sqlite3_rtree_query_info*), /* Callback */
@@ -150906,7 +153851,7 @@ SQLITE_API int sqlite3_rtree_query_callback(
#ifdef _WIN32
__declspec(dllexport)
#endif
-SQLITE_API int sqlite3_rtree_init(
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_init(
sqlite3 *db,
char **pzErrMsg,
const sqlite3_api_routines *pApi
@@ -151411,7 +154356,7 @@ SQLITE_PRIVATE int sqlite3IcuInit(sqlite3 *db){
#ifdef _WIN32
__declspec(dllexport)
#endif
-SQLITE_API int sqlite3_icu_init(
+SQLITE_API int SQLITE_STDCALL sqlite3_icu_init(
sqlite3 *db,
char **pzErrMsg,
const sqlite3_api_routines *pApi
diff --git a/contrib/sqlite3/sqlite3.h b/contrib/sqlite3/sqlite3.h
index 023dad1..2c244ab 100644
--- a/contrib/sqlite3/sqlite3.h
+++ b/contrib/sqlite3/sqlite3.h
@@ -43,21 +43,25 @@ extern "C" {
/*
-** Add the ability to override 'extern'
+** Provide the ability to override linkage features of the interface.
*/
#ifndef SQLITE_EXTERN
# define SQLITE_EXTERN extern
#endif
-
#ifndef SQLITE_API
# define SQLITE_API
#endif
-
+#ifndef SQLITE_CDECL
+# define SQLITE_CDECL
+#endif
+#ifndef SQLITE_STDCALL
+# define SQLITE_STDCALL
+#endif
/*
** These no-op macros are used in front of interfaces to mark those
** interfaces as either deprecated or experimental. New applications
-** should not use deprecated interfaces - they are support for backwards
+** should not use deprecated interfaces - they are supported for backwards
** compatibility only. Application writers should be aware that
** experimental interfaces are subject to change in point releases.
**
@@ -107,9 +111,9 @@ extern "C" {
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
-#define SQLITE_VERSION "3.8.7.2"
-#define SQLITE_VERSION_NUMBER 3008007
-#define SQLITE_SOURCE_ID "2014-11-18 20:57:56 2ab564bf9655b7c7b97ab85cafc8a48329b27f93"
+#define SQLITE_VERSION "3.8.9"
+#define SQLITE_VERSION_NUMBER 3008009
+#define SQLITE_SOURCE_ID "2015-04-08 12:16:33 8a8ffc862e96f57aa698f93de10dee28e69f6e09"
/*
** CAPI3REF: Run-Time Library Version Numbers
@@ -142,9 +146,9 @@ extern "C" {
** See also: [sqlite_version()] and [sqlite_source_id()].
*/
SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
-SQLITE_API const char *sqlite3_libversion(void);
-SQLITE_API const char *sqlite3_sourceid(void);
-SQLITE_API int sqlite3_libversion_number(void);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void);
+SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void);
/*
** CAPI3REF: Run-Time Library Compilation Options Diagnostics
@@ -169,8 +173,8 @@ SQLITE_API int sqlite3_libversion_number(void);
** [sqlite_compileoption_get()] and the [compile_options pragma].
*/
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
-SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
-SQLITE_API const char *sqlite3_compileoption_get(int N);
+SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N);
#endif
/*
@@ -201,7 +205,7 @@ SQLITE_API const char *sqlite3_compileoption_get(int N);
** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
** can be fully or partially disabled using a call to [sqlite3_config()]
** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
-** or [SQLITE_CONFIG_MUTEX]. ^(The return value of the
+** or [SQLITE_CONFIG_SERIALIZED]. ^(The return value of the
** sqlite3_threadsafe() function shows only the compile-time setting of
** thread safety, not any run-time changes to that setting made by
** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
@@ -209,7 +213,7 @@ SQLITE_API const char *sqlite3_compileoption_get(int N);
**
** See the [threading mode] documentation for additional information.
*/
-SQLITE_API int sqlite3_threadsafe(void);
+SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void);
/*
** CAPI3REF: Database Connection Handle
@@ -305,8 +309,8 @@ typedef sqlite_uint64 sqlite3_uint64;
** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
** argument is a harmless no-op.
*/
-SQLITE_API int sqlite3_close(sqlite3*);
-SQLITE_API int sqlite3_close_v2(sqlite3*);
+SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3*);
+SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3*);
/*
** The type for a callback function.
@@ -376,7 +380,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**);
** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
** </ul>
*/
-SQLITE_API int sqlite3_exec(
+SQLITE_API int SQLITE_STDCALL sqlite3_exec(
sqlite3*, /* An open database */
const char *sql, /* SQL to be evaluated */
int (*callback)(void*,int,char**,char**), /* Callback function */
@@ -756,14 +760,16 @@ struct sqlite3_io_methods {
** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
** interface.
**
+** <ul>
+** <li>[[SQLITE_FCNTL_LOCKSTATE]]
** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This
** opcode causes the xFileControl method to write the current state of
** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
** into an integer that the pArg argument points to. This capability
-** is used during testing and only needs to be supported when SQLITE_TEST
-** is defined.
-** <ul>
+** is used during testing and is only available when the SQLITE_TEST
+** compile-time option is used.
+**
** <li>[[SQLITE_FCNTL_SIZE_HINT]]
** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
** layer a hint of how large the database file will grow to be during the
@@ -888,7 +894,9 @@ struct sqlite3_io_methods {
** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA]
** file control returns [SQLITE_OK], then the parser assumes that the
** VFS has handled the PRAGMA itself and the parser generates a no-op
-** prepared statement. ^If the [SQLITE_FCNTL_PRAGMA] file control returns
+** prepared statement if result string is NULL, or that returns a copy
+** of the result string if the string is non-NULL.
+** ^If the [SQLITE_FCNTL_PRAGMA] file control returns
** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
** that the VFS encountered an error while handling the [PRAGMA] and the
** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA]
@@ -946,12 +954,19 @@ struct sqlite3_io_methods {
** pointed to by the pArg argument. This capability is used during testing
** and only needs to be supported when SQLITE_TEST is defined.
**
+** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
+** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
+** be advantageous to block on the next WAL lock if the lock is not immediately
+** available. The WAL subsystem issues this signal during rare
+** circumstances in order to fix a problem with priority inversion.
+** Applications should <em>not</em> use this file-control.
+**
** </ul>
*/
#define SQLITE_FCNTL_LOCKSTATE 1
-#define SQLITE_GET_LOCKPROXYFILE 2
-#define SQLITE_SET_LOCKPROXYFILE 3
-#define SQLITE_LAST_ERRNO 4
+#define SQLITE_FCNTL_GET_LOCKPROXYFILE 2
+#define SQLITE_FCNTL_SET_LOCKPROXYFILE 3
+#define SQLITE_FCNTL_LAST_ERRNO 4
#define SQLITE_FCNTL_SIZE_HINT 5
#define SQLITE_FCNTL_CHUNK_SIZE 6
#define SQLITE_FCNTL_FILE_POINTER 7
@@ -970,6 +985,13 @@ struct sqlite3_io_methods {
#define SQLITE_FCNTL_SYNC 21
#define SQLITE_FCNTL_COMMIT_PHASETWO 22
#define SQLITE_FCNTL_WIN32_SET_HANDLE 23
+#define SQLITE_FCNTL_WAL_BLOCK 24
+
+/* deprecated names */
+#define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE
+#define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE
+#define SQLITE_LAST_ERRNO SQLITE_FCNTL_LAST_ERRNO
+
/*
** CAPI3REF: Mutex Handle
@@ -1221,7 +1243,7 @@ struct sqlite3_vfs {
** </ul>
**
** When unlocking, the same SHARED or EXCLUSIVE flag must be supplied as
-** was given no the corresponding lock.
+** was given on the corresponding lock.
**
** The xShmLock method can transition between unlocked and SHARED or
** between unlocked and EXCLUSIVE. It cannot transition between SHARED
@@ -1318,10 +1340,10 @@ struct sqlite3_vfs {
** must return [SQLITE_OK] on success and some other [error code] upon
** failure.
*/
-SQLITE_API int sqlite3_initialize(void);
-SQLITE_API int sqlite3_shutdown(void);
-SQLITE_API int sqlite3_os_init(void);
-SQLITE_API int sqlite3_os_end(void);
+SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void);
+SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void);
+SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void);
+SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void);
/*
** CAPI3REF: Configuring The SQLite Library
@@ -1352,7 +1374,7 @@ SQLITE_API int sqlite3_os_end(void);
** ^If the option is unknown or SQLite is unable to set the option
** then this routine returns a non-zero [error code].
*/
-SQLITE_API int sqlite3_config(int, ...);
+SQLITE_API int SQLITE_CDECL sqlite3_config(int, ...);
/*
** CAPI3REF: Configure database connections
@@ -1370,7 +1392,7 @@ SQLITE_API int sqlite3_config(int, ...);
** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
** the call is considered successful.
*/
-SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
+SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3*, int op, ...);
/*
** CAPI3REF: Memory Allocation Routines
@@ -1504,31 +1526,33 @@ struct sqlite3_mem_methods {
** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
**
** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>
-** <dd> ^(This option takes a single argument which is a pointer to an
-** instance of the [sqlite3_mem_methods] structure. The argument specifies
+** <dd> ^(The SQLITE_CONFIG_MALLOC option takes a single argument which is
+** a pointer to an instance of the [sqlite3_mem_methods] structure.
+** The argument specifies
** alternative low-level memory allocation routines to be used in place of
** the memory allocation routines built into SQLite.)^ ^SQLite makes
** its own private copy of the content of the [sqlite3_mem_methods] structure
** before the [sqlite3_config()] call returns.</dd>
**
** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>
-** <dd> ^(This option takes a single argument which is a pointer to an
-** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods]
+** <dd> ^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which
+** is a pointer to an instance of the [sqlite3_mem_methods] structure.
+** The [sqlite3_mem_methods]
** structure is filled with the currently defined memory allocation routines.)^
** This option can be used to overload the default memory allocation
** routines with a wrapper that simulations memory allocation failure or
** tracks memory usage, for example. </dd>
**
** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>
-** <dd> ^This option takes single argument of type int, interpreted as a
-** boolean, which enables or disables the collection of memory allocation
-** statistics. ^(When memory allocation statistics are disabled, the
-** following SQLite interfaces become non-operational:
+** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int,
+** interpreted as a boolean, which enables or disables the collection of
+** memory allocation statistics. ^(When memory allocation statistics are
+** disabled, the following SQLite interfaces become non-operational:
** <ul>
** <li> [sqlite3_memory_used()]
** <li> [sqlite3_memory_highwater()]
** <li> [sqlite3_soft_heap_limit64()]
-** <li> [sqlite3_status()]
+** <li> [sqlite3_status64()]
** </ul>)^
** ^Memory allocation statistics are enabled by default unless SQLite is
** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
@@ -1536,53 +1560,67 @@ struct sqlite3_mem_methods {
** </dd>
**
** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>
-** <dd> ^This option specifies a static memory buffer that SQLite can use for
-** scratch memory. There are three arguments: A pointer an 8-byte
+** <dd> ^The SQLITE_CONFIG_SCRATCH option specifies a static memory buffer
+** that SQLite can use for scratch memory. ^(There are three arguments
+** to SQLITE_CONFIG_SCRATCH: A pointer an 8-byte
** aligned memory buffer from which the scratch allocations will be
** drawn, the size of each scratch allocation (sz),
-** and the maximum number of scratch allocations (N). The sz
-** argument must be a multiple of 16.
+** and the maximum number of scratch allocations (N).)^
** The first argument must be a pointer to an 8-byte aligned buffer
** of at least sz*N bytes of memory.
-** ^SQLite will use no more than two scratch buffers per thread. So
-** N should be set to twice the expected maximum number of threads.
-** ^SQLite will never require a scratch buffer that is more than 6
-** times the database page size. ^If SQLite needs needs additional
+** ^SQLite will not use more than one scratch buffers per thread.
+** ^SQLite will never request a scratch buffer that is more than 6
+** times the database page size.
+** ^If SQLite needs needs additional
** scratch memory beyond what is provided by this configuration option, then
-** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
+** [sqlite3_malloc()] will be used to obtain the memory needed.<p>
+** ^When the application provides any amount of scratch memory using
+** SQLITE_CONFIG_SCRATCH, SQLite avoids unnecessary large
+** [sqlite3_malloc|heap allocations].
+** This can help [Robson proof|prevent memory allocation failures] due to heap
+** fragmentation in low-memory embedded systems.
+** </dd>
**
** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
-** <dd> ^This option specifies a static memory buffer that SQLite can use for
-** the database page cache with the default page cache implementation.
+** <dd> ^The SQLITE_CONFIG_PAGECACHE option specifies a static memory buffer
+** that SQLite can use for the database page cache with the default page
+** cache implementation.
** This configuration should not be used if an application-define page
-** cache implementation is loaded using the SQLITE_CONFIG_PCACHE2 option.
-** There are three arguments to this option: A pointer to 8-byte aligned
+** cache implementation is loaded using the [SQLITE_CONFIG_PCACHE2]
+** configuration option.
+** ^There are three arguments to SQLITE_CONFIG_PAGECACHE: A pointer to
+** 8-byte aligned
** memory, the size of each page buffer (sz), and the number of pages (N).
** The sz argument should be the size of the largest database page
-** (a power of two between 512 and 32768) plus a little extra for each
-** page header. ^The page header size is 20 to 40 bytes depending on
-** the host architecture. ^It is harmless, apart from the wasted memory,
-** to make sz a little too large. The first
-** argument should point to an allocation of at least sz*N bytes of memory.
+** (a power of two between 512 and 65536) plus some extra bytes for each
+** page header. ^The number of extra bytes needed by the page header
+** can be determined using the [SQLITE_CONFIG_PCACHE_HDRSZ] option
+** to [sqlite3_config()].
+** ^It is harmless, apart from the wasted memory,
+** for the sz parameter to be larger than necessary. The first
+** argument should pointer to an 8-byte aligned block of memory that
+** is at least sz*N bytes of memory, otherwise subsequent behavior is
+** undefined.
** ^SQLite will use the memory provided by the first argument to satisfy its
** memory needs for the first N pages that it adds to cache. ^If additional
** page cache memory is needed beyond what is provided by this option, then
-** SQLite goes to [sqlite3_malloc()] for the additional storage space.
-** The pointer in the first argument must
-** be aligned to an 8-byte boundary or subsequent behavior of SQLite
-** will be undefined.</dd>
+** SQLite goes to [sqlite3_malloc()] for the additional storage space.</dd>
**
** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>
-** <dd> ^This option specifies a static memory buffer that SQLite will use
-** for all of its dynamic memory allocation needs beyond those provided
-** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
-** There are three arguments: An 8-byte aligned pointer to the memory,
+** <dd> ^The SQLITE_CONFIG_HEAP option specifies a static memory buffer
+** that SQLite will use for all of its dynamic memory allocation needs
+** beyond those provided for by [SQLITE_CONFIG_SCRATCH] and
+** [SQLITE_CONFIG_PAGECACHE].
+** ^The SQLITE_CONFIG_HEAP option is only available if SQLite is compiled
+** with either [SQLITE_ENABLE_MEMSYS3] or [SQLITE_ENABLE_MEMSYS5] and returns
+** [SQLITE_ERROR] if invoked otherwise.
+** ^There are three arguments to SQLITE_CONFIG_HEAP:
+** An 8-byte aligned pointer to the memory,
** the number of bytes in the memory buffer, and the minimum allocation size.
** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
** to using its default memory allocator (the system malloc() implementation),
** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the
-** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
-** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
+** memory pointer is not NULL then the alternative memory
** allocator is engaged to handle all of SQLites memory allocation needs.
** The first pointer (the memory pointer) must be aligned to an 8-byte
** boundary or subsequent behavior of SQLite will be undefined.
@@ -1590,11 +1628,11 @@ struct sqlite3_mem_methods {
** for the minimum allocation size are 2**5 through 2**8.</dd>
**
** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>
-** <dd> ^(This option takes a single argument which is a pointer to an
-** instance of the [sqlite3_mutex_methods] structure. The argument specifies
-** alternative low-level mutex routines to be used in place
-** the mutex routines built into SQLite.)^ ^SQLite makes a copy of the
-** content of the [sqlite3_mutex_methods] structure before the call to
+** <dd> ^(The SQLITE_CONFIG_MUTEX option takes a single argument which is a
+** pointer to an instance of the [sqlite3_mutex_methods] structure.
+** The argument specifies alternative low-level mutex routines to be used
+** in place the mutex routines built into SQLite.)^ ^SQLite makes a copy of
+** the content of the [sqlite3_mutex_methods] structure before the call to
** [sqlite3_config()] returns. ^If SQLite is compiled with
** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
** the entire mutexing subsystem is omitted from the build and hence calls to
@@ -1602,8 +1640,8 @@ struct sqlite3_mem_methods {
** return [SQLITE_ERROR].</dd>
**
** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>
-** <dd> ^(This option takes a single argument which is a pointer to an
-** instance of the [sqlite3_mutex_methods] structure. The
+** <dd> ^(The SQLITE_CONFIG_GETMUTEX option takes a single argument which
+** is a pointer to an instance of the [sqlite3_mutex_methods] structure. The
** [sqlite3_mutex_methods]
** structure is filled with the currently defined mutex routines.)^
** This option can be used to overload the default mutex allocation
@@ -1615,25 +1653,25 @@ struct sqlite3_mem_methods {
** return [SQLITE_ERROR].</dd>
**
** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
-** <dd> ^(This option takes two arguments that determine the default
-** memory allocation for the lookaside memory allocator on each
-** [database connection]. The first argument is the
+** <dd> ^(The SQLITE_CONFIG_LOOKASIDE option takes two arguments that determine
+** the default size of lookaside memory on each [database connection].
+** The first argument is the
** size of each lookaside buffer slot and the second is the number of
-** slots allocated to each database connection.)^ ^(This option sets the
-** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
-** verb to [sqlite3_db_config()] can be used to change the lookaside
+** slots allocated to each database connection.)^ ^(SQLITE_CONFIG_LOOKASIDE
+** sets the <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
+** option to [sqlite3_db_config()] can be used to change the lookaside
** configuration on individual connections.)^ </dd>
**
** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
-** <dd> ^(This option takes a single argument which is a pointer to
-** an [sqlite3_pcache_methods2] object. This object specifies the interface
-** to a custom page cache implementation.)^ ^SQLite makes a copy of the
-** object and uses it for page cache memory allocations.</dd>
+** <dd> ^(The SQLITE_CONFIG_PCACHE2 option takes a single argument which is
+** a pointer to an [sqlite3_pcache_methods2] object. This object specifies
+** the interface to a custom page cache implementation.)^
+** ^SQLite makes a copy of the [sqlite3_pcache_methods2] object.</dd>
**
** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>
-** <dd> ^(This option takes a single argument which is a pointer to an
-** [sqlite3_pcache_methods2] object. SQLite copies of the current
-** page cache implementation into that object.)^ </dd>
+** <dd> ^(The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which
+** is a pointer to an [sqlite3_pcache_methods2] object. SQLite copies of
+** the current page cache implementation into that object.)^ </dd>
**
** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>
** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite
@@ -1656,10 +1694,11 @@ struct sqlite3_mem_methods {
** function must be threadsafe. </dd>
**
** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
-** <dd>^(This option takes a single argument of type int. If non-zero, then
-** URI handling is globally enabled. If the parameter is zero, then URI handling
-** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
-** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
+** <dd>^(The SQLITE_CONFIG_URI option takes a single argument of type int.
+** If non-zero, then URI handling is globally enabled. If the parameter is zero,
+** then URI handling is globally disabled.)^ ^If URI handling is globally
+** enabled, all filenames passed to [sqlite3_open()], [sqlite3_open_v2()],
+** [sqlite3_open16()] or
** specified as part of [ATTACH] commands are interpreted as URIs, regardless
** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
** connection is opened. ^If it is globally disabled, filenames are
@@ -1669,9 +1708,10 @@ struct sqlite3_mem_methods {
** [SQLITE_USE_URI] symbol defined.)^
**
** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
-** <dd>^This option takes a single integer argument which is interpreted as
-** a boolean in order to enable or disable the use of covering indices for
-** full table scans in the query optimizer. ^The default setting is determined
+** <dd>^The SQLITE_CONFIG_COVERING_INDEX_SCAN option takes a single integer
+** argument which is interpreted as a boolean in order to enable or disable
+** the use of covering indices for full table scans in the query optimizer.
+** ^The default setting is determined
** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
** if that compile-time option is omitted.
** The ability to disable the use of covering indices for full table scans
@@ -1711,18 +1751,37 @@ struct sqlite3_mem_methods {
** ^The default setting can be overridden by each database connection using
** either the [PRAGMA mmap_size] command, or by using the
** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size
-** cannot be changed at run-time. Nor may the maximum allowed mmap size
-** exceed the compile-time maximum mmap size set by the
+** will be silently truncated if necessary so that it does not exceed the
+** compile-time maximum mmap size set by the
** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
** ^If either argument to this option is negative, then that argument is
** changed to its compile-time default.
**
** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]
** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
-** <dd>^This option is only available if SQLite is compiled for Windows
-** with the [SQLITE_WIN32_MALLOC] pre-processor macro defined.
-** SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
+** <dd>^The SQLITE_CONFIG_WIN32_HEAPSIZE option is only available if SQLite is
+** compiled for Windows with the [SQLITE_WIN32_MALLOC] pre-processor macro
+** defined. ^SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
** that specifies the maximum size of the created heap.
+**
+** [[SQLITE_CONFIG_PCACHE_HDRSZ]]
+** <dt>SQLITE_CONFIG_PCACHE_HDRSZ
+** <dd>^The SQLITE_CONFIG_PCACHE_HDRSZ option takes a single parameter which
+** is a pointer to an integer and writes into that integer the number of extra
+** bytes per page required for each page in [SQLITE_CONFIG_PAGECACHE].
+** The amount of extra space required can change depending on the compiler,
+** target platform, and SQLite version.
+**
+** [[SQLITE_CONFIG_PMASZ]]
+** <dt>SQLITE_CONFIG_PMASZ
+** <dd>^The SQLITE_CONFIG_PMASZ option takes a single parameter which
+** is an unsigned integer and sets the "Minimum PMA Size" for the multithreaded
+** sorter to that integer. The default minimum PMA Size is set by the
+** [SQLITE_SORTER_PMASZ] compile-time option. New threads are launched
+** to help with sort operations when multithreaded sorting
+** is enabled (using the [PRAGMA threads] command) and the amount of content
+** to be sorted exceeds the page size times the minimum of the
+** [PRAGMA cache_size] setting and this value.
** </dl>
*/
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
@@ -1748,6 +1807,8 @@ struct sqlite3_mem_methods {
#define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
#define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */
#define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */
+#define SQLITE_CONFIG_PCACHE_HDRSZ 24 /* int *psz */
+#define SQLITE_CONFIG_PMASZ 25 /* unsigned int szPma */
/*
** CAPI3REF: Database Connection Configuration Options
@@ -1819,7 +1880,7 @@ struct sqlite3_mem_methods {
** [extended result codes] feature of SQLite. ^The extended result
** codes are disabled by default for historical compatibility.
*/
-SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3*, int onoff);
/*
** CAPI3REF: Last Insert Rowid
@@ -1870,52 +1931,50 @@ SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
** unpredictable and might not equal either the old or the new
** last insert [rowid].
*/
-SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3*);
/*
** CAPI3REF: Count The Number Of Rows Modified
**
-** ^This function returns the number of database rows that were changed
-** or inserted or deleted by the most recently completed SQL statement
-** on the [database connection] specified by the first parameter.
-** ^(Only changes that are directly specified by the [INSERT], [UPDATE],
-** or [DELETE] statement are counted. Auxiliary changes caused by
-** triggers or [foreign key actions] are not counted.)^ Use the
-** [sqlite3_total_changes()] function to find the total number of changes
-** including changes caused by triggers and foreign key actions.
-**
-** ^Changes to a view that are simulated by an [INSTEAD OF trigger]
-** are not counted. Only real table changes are counted.
-**
-** ^(A "row change" is a change to a single row of a single table
-** caused by an INSERT, DELETE, or UPDATE statement. Rows that
-** are changed as side effects of [REPLACE] constraint resolution,
-** rollback, ABORT processing, [DROP TABLE], or by any other
-** mechanisms do not count as direct row changes.)^
-**
-** A "trigger context" is a scope of execution that begins and
-** ends with the script of a [CREATE TRIGGER | trigger].
-** Most SQL statements are
-** evaluated outside of any trigger. This is the "top level"
-** trigger context. If a trigger fires from the top level, a
-** new trigger context is entered for the duration of that one
-** trigger. Subtriggers create subcontexts for their duration.
-**
-** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
-** not create a new trigger context.
-**
-** ^This function returns the number of direct row changes in the
-** most recent INSERT, UPDATE, or DELETE statement within the same
-** trigger context.
-**
-** ^Thus, when called from the top level, this function returns the
-** number of changes in the most recent INSERT, UPDATE, or DELETE
-** that also occurred at the top level. ^(Within the body of a trigger,
-** the sqlite3_changes() interface can be called to find the number of
-** changes in the most recently completed INSERT, UPDATE, or DELETE
-** statement within the body of the same trigger.
-** However, the number returned does not include changes
-** caused by subtriggers since those have their own context.)^
+** ^This function returns the number of rows modified, inserted or
+** deleted by the most recently completed INSERT, UPDATE or DELETE
+** statement on the database connection specified by the only parameter.
+** ^Executing any other type of SQL statement does not modify the value
+** returned by this function.
+**
+** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
+** considered - auxiliary changes caused by [CREATE TRIGGER | triggers],
+** [foreign key actions] or [REPLACE] constraint resolution are not counted.
+**
+** Changes to a view that are intercepted by
+** [INSTEAD OF trigger | INSTEAD OF triggers] are not counted. ^The value
+** returned by sqlite3_changes() immediately after an INSERT, UPDATE or
+** DELETE statement run on a view is always zero. Only changes made to real
+** tables are counted.
+**
+** Things are more complicated if the sqlite3_changes() function is
+** executed while a trigger program is running. This may happen if the
+** program uses the [changes() SQL function], or if some other callback
+** function invokes sqlite3_changes() directly. Essentially:
+**
+** <ul>
+** <li> ^(Before entering a trigger program the value returned by
+** sqlite3_changes() function is saved. After the trigger program
+** has finished, the original value is restored.)^
+**
+** <li> ^(Within a trigger program each INSERT, UPDATE and DELETE
+** statement sets the value returned by sqlite3_changes()
+** upon completion as normal. Of course, this value will not include
+** any changes performed by sub-triggers, as the sqlite3_changes()
+** value will be saved and restored after each sub-trigger has run.)^
+** </ul>
+**
+** ^This means that if the changes() SQL function (or similar) is used
+** by the first INSERT, UPDATE or DELETE statement within a trigger, it
+** returns the value as set when the calling statement began executing.
+** ^If it is used by the second or subsequent such statement within a trigger
+** program, the value returned reflects the number of rows modified by the
+** previous INSERT, UPDATE or DELETE statement within the same trigger.
**
** See also the [sqlite3_total_changes()] interface, the
** [count_changes pragma], and the [changes() SQL function].
@@ -1924,25 +1983,22 @@ SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
** while [sqlite3_changes()] is running then the value returned
** is unpredictable and not meaningful.
*/
-SQLITE_API int sqlite3_changes(sqlite3*);
+SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3*);
/*
** CAPI3REF: Total Number Of Rows Modified
**
-** ^This function returns the number of row changes caused by [INSERT],
-** [UPDATE] or [DELETE] statements since the [database connection] was opened.
-** ^(The count returned by sqlite3_total_changes() includes all changes
-** from all [CREATE TRIGGER | trigger] contexts and changes made by
-** [foreign key actions]. However,
-** the count does not include changes used to implement [REPLACE] constraints,
-** do rollbacks or ABORT processing, or [DROP TABLE] processing. The
-** count does not include rows of views that fire an [INSTEAD OF trigger],
-** though if the INSTEAD OF trigger makes changes of its own, those changes
-** are counted.)^
-** ^The sqlite3_total_changes() function counts the changes as soon as
-** the statement that makes them is completed (when the statement handle
-** is passed to [sqlite3_reset()] or [sqlite3_finalize()]).
-**
+** ^This function returns the total number of rows inserted, modified or
+** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
+** since the database connection was opened, including those executed as
+** part of trigger programs. ^Executing any other type of SQL statement
+** does not affect the value returned by sqlite3_total_changes().
+**
+** ^Changes made as part of [foreign key actions] are included in the
+** count, but those made as part of REPLACE constraint resolution are
+** not. ^Changes to a view that are intercepted by INSTEAD OF triggers
+** are not counted.
+**
** See also the [sqlite3_changes()] interface, the
** [count_changes pragma], and the [total_changes() SQL function].
**
@@ -1950,7 +2006,7 @@ SQLITE_API int sqlite3_changes(sqlite3*);
** while [sqlite3_total_changes()] is running then the value
** returned is unpredictable and not meaningful.
*/
-SQLITE_API int sqlite3_total_changes(sqlite3*);
+SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3*);
/*
** CAPI3REF: Interrupt A Long-Running Query
@@ -1989,7 +2045,7 @@ SQLITE_API int sqlite3_total_changes(sqlite3*);
** If the database connection closes while [sqlite3_interrupt()]
** is running then bad things will likely happen.
*/
-SQLITE_API void sqlite3_interrupt(sqlite3*);
+SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3*);
/*
** CAPI3REF: Determine If An SQL Statement Is Complete
@@ -2024,11 +2080,12 @@ SQLITE_API void sqlite3_interrupt(sqlite3*);
** The input to [sqlite3_complete16()] must be a zero-terminated
** UTF-16 string in native byte order.
*/
-SQLITE_API int sqlite3_complete(const char *sql);
-SQLITE_API int sqlite3_complete16(const void *sql);
+SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *sql);
+SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *sql);
/*
** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
+** KEYWORDS: {busy-handler callback} {busy handler}
**
** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X
** that might be invoked with argument P whenever
@@ -2045,7 +2102,7 @@ SQLITE_API int sqlite3_complete16(const void *sql);
** ^The first argument to the busy handler is a copy of the void* pointer which
** is the third argument to sqlite3_busy_handler(). ^The second argument to
** the busy handler callback is the number of times that the busy handler has
-** been invoked for the same locking event. ^If the
+** been invoked previously for the same locking event. ^If the
** busy callback returns 0, then no additional attempts are made to
** access the database and [SQLITE_BUSY] is returned
** to the application.
@@ -2084,7 +2141,7 @@ SQLITE_API int sqlite3_complete16(const void *sql);
** A busy handler must not close the database connection
** or [prepared statement] that invoked the busy handler.
*/
-SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
/*
** CAPI3REF: Set A Busy Timeout
@@ -2106,7 +2163,7 @@ SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
**
** See also: [PRAGMA busy_timeout]
*/
-SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3*, int ms);
/*
** CAPI3REF: Convenience Routines For Running Queries
@@ -2180,7 +2237,7 @@ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
** reflected in subsequent calls to [sqlite3_errcode()] or
** [sqlite3_errmsg()].
*/
-SQLITE_API int sqlite3_get_table(
+SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
sqlite3 *db, /* An open database */
const char *zSql, /* SQL to be evaluated */
char ***pazResult, /* Results of the query */
@@ -2188,13 +2245,17 @@ SQLITE_API int sqlite3_get_table(
int *pnColumn, /* Number of result columns written here */
char **pzErrmsg /* Error msg written here */
);
-SQLITE_API void sqlite3_free_table(char **result);
+SQLITE_API void SQLITE_STDCALL sqlite3_free_table(char **result);
/*
** CAPI3REF: Formatted String Printing Functions
**
** These routines are work-alikes of the "printf()" family of functions
** from the standard C library.
+** These routines understand most of the common K&R formatting options,
+** plus some additional non-standard formats, detailed below.
+** Note that some of the more obscure formatting options from recent
+** C-library standards are omitted from this implementation.
**
** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
** results into memory obtained from [sqlite3_malloc()].
@@ -2227,7 +2288,7 @@ SQLITE_API void sqlite3_free_table(char **result);
** These routines all implement some additional formatting
** options that are useful for constructing SQL statements.
** All of the usual printf() formatting options apply. In addition, there
-** is are "%q", "%Q", and "%z" options.
+** is are "%q", "%Q", "%w" and "%z" options.
**
** ^(The %q option works like %s in that it substitutes a nul-terminated
** string from the argument list. But %q also doubles every '\'' character.
@@ -2280,14 +2341,20 @@ SQLITE_API void sqlite3_free_table(char **result);
** The code above will render a correct SQL statement in the zSQL
** variable even if the zText variable is a NULL pointer.
**
+** ^(The "%w" formatting option is like "%q" except that it expects to
+** be contained within double-quotes instead of single quotes, and it
+** escapes the double-quote character instead of the single-quote
+** character.)^ The "%w" formatting option is intended for safely inserting
+** table and column names into a constructed SQL statement.
+**
** ^(The "%z" formatting option works like "%s" but with the
** addition that after the string has been read and copied into
** the result, [sqlite3_free()] is called on the input string.)^
*/
-SQLITE_API char *sqlite3_mprintf(const char*,...);
-SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
-SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
-SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
+SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char*,...);
+SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char*, va_list);
+SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int,char*,const char*, ...);
+SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int,char*,const char*, va_list);
/*
** CAPI3REF: Memory Allocation Subsystem
@@ -2377,12 +2444,12 @@ SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
** a block of memory after it has been released using
** [sqlite3_free()] or [sqlite3_realloc()].
*/
-SQLITE_API void *sqlite3_malloc(int);
-SQLITE_API void *sqlite3_malloc64(sqlite3_uint64);
-SQLITE_API void *sqlite3_realloc(void*, int);
-SQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64);
-SQLITE_API void sqlite3_free(void*);
-SQLITE_API sqlite3_uint64 sqlite3_msize(void*);
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int);
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64);
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void*, int);
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void*, sqlite3_uint64);
+SQLITE_API void SQLITE_STDCALL sqlite3_free(void*);
+SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void*);
/*
** CAPI3REF: Memory Allocator Statistics
@@ -2407,8 +2474,8 @@ SQLITE_API sqlite3_uint64 sqlite3_msize(void*);
** by [sqlite3_memory_highwater(1)] is the high-water mark
** prior to the reset.
*/
-SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
-SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void);
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag);
/*
** CAPI3REF: Pseudo-Random Number Generator
@@ -2420,17 +2487,18 @@ SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
** applications to access the same PRNG for other purposes.
**
** ^A call to this routine stores N bytes of randomness into buffer P.
-** ^If N is less than one, then P can be a NULL pointer.
+** ^The P parameter can be a NULL pointer.
**
** ^If this routine has not been previously called or if the previous
-** call had N less than one, then the PRNG is seeded using randomness
-** obtained from the xRandomness method of the default [sqlite3_vfs] object.
-** ^If the previous call to this routine had an N of 1 or more then
-** the pseudo-randomness is generated
+** call had N less than one or a NULL pointer for P, then the PRNG is
+** seeded using randomness obtained from the xRandomness method of
+** the default [sqlite3_vfs] object.
+** ^If the previous call to this routine had an N of 1 or more and a
+** non-NULL P then the pseudo-randomness is generated
** internally and without recourse to the [sqlite3_vfs] xRandomness
** method.
*/
-SQLITE_API void sqlite3_randomness(int N, void *P);
+SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *P);
/*
** CAPI3REF: Compile-Time Authorization Callbacks
@@ -2512,7 +2580,7 @@ SQLITE_API void sqlite3_randomness(int N, void *P);
** as stated in the previous paragraph, sqlite3_step() invokes
** sqlite3_prepare_v2() to reprepare a statement after a schema change.
*/
-SQLITE_API int sqlite3_set_authorizer(
+SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
sqlite3*,
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
void *pUserData
@@ -2616,8 +2684,8 @@ SQLITE_API int sqlite3_set_authorizer(
** sqlite3_profile() function is considered experimental and is
** subject to change in future versions of SQLite.
*/
-SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
-SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
+SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
+SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
/*
@@ -2651,7 +2719,7 @@ SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
** database connections for the meaning of "modify" in this paragraph.
**
*/
-SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
+SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
/*
** CAPI3REF: Opening A New Database Connection
@@ -2879,15 +2947,15 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
**
** See also: [sqlite3_temp_directory]
*/
-SQLITE_API int sqlite3_open(
+SQLITE_API int SQLITE_STDCALL sqlite3_open(
const char *filename, /* Database filename (UTF-8) */
sqlite3 **ppDb /* OUT: SQLite db handle */
);
-SQLITE_API int sqlite3_open16(
+SQLITE_API int SQLITE_STDCALL sqlite3_open16(
const void *filename, /* Database filename (UTF-16) */
sqlite3 **ppDb /* OUT: SQLite db handle */
);
-SQLITE_API int sqlite3_open_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
const char *filename, /* Database filename (UTF-8) */
sqlite3 **ppDb, /* OUT: SQLite db handle */
int flags, /* Flags */
@@ -2933,19 +3001,21 @@ SQLITE_API int sqlite3_open_v2(
** VFS method, then the behavior of this routine is undefined and probably
** undesirable.
*/
-SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
-SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
-SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam);
+SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
/*
** CAPI3REF: Error Codes And Messages
**
-** ^The sqlite3_errcode() interface returns the numeric [result code] or
-** [extended result code] for the most recent failed sqlite3_* API call
-** associated with a [database connection]. If a prior API call failed
-** but the most recent API call succeeded, the return value from
-** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode()
+** ^If the most recent sqlite3_* API call associated with
+** [database connection] D failed, then the sqlite3_errcode(D) interface
+** returns the numeric [result code] or [extended result code] for that
+** API call.
+** If the most recent API call was successful,
+** then the return value from sqlite3_errcode() is undefined.
+** ^The sqlite3_extended_errcode()
** interface is the same except that it always returns the
** [extended result code] even when extended result codes are
** disabled.
@@ -2976,11 +3046,11 @@ SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int
** was invoked incorrectly by the application. In that case, the
** error code and message may or may not be set.
*/
-SQLITE_API int sqlite3_errcode(sqlite3 *db);
-SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
-SQLITE_API const char *sqlite3_errmsg(sqlite3*);
-SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
-SQLITE_API const char *sqlite3_errstr(int);
+SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db);
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3*);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3*);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int);
/*
** CAPI3REF: SQL Statement Object
@@ -3047,7 +3117,7 @@ typedef struct sqlite3_stmt sqlite3_stmt;
**
** New run-time limit categories may be added in future releases.
*/
-SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
+SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3*, int id, int newVal);
/*
** CAPI3REF: Run-Time Limit Categories
@@ -3134,16 +3204,14 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
** use UTF-16.
**
-** ^If the nByte argument is less than zero, then zSql is read up to the
-** first zero terminator. ^If nByte is non-negative, then it is the maximum
-** number of bytes read from zSql. ^When nByte is non-negative, the
-** zSql string ends at either the first '\000' or '\u0000' character or
-** the nByte-th byte, whichever comes first. If the caller knows
-** that the supplied string is nul-terminated, then there is a small
-** performance advantage to be gained by passing an nByte parameter that
-** is equal to the number of bytes in the input string <i>including</i>
-** the nul-terminator bytes as this saves SQLite from having to
-** make a copy of the input string.
+** ^If the nByte argument is negative, then zSql is read up to the
+** first zero terminator. ^If nByte is positive, then it is the
+** number of bytes read from zSql. ^If nByte is zero, then no prepared
+** statement is generated.
+** If the caller knows that the supplied string is nul-terminated, then
+** there is a small performance advantage to passing an nByte parameter that
+** is the number of bytes in the input string <i>including</i>
+** the nul-terminator.
**
** ^If pzTail is not NULL then *pzTail is made to point to the first byte
** past the end of the first SQL statement in zSql. These routines only
@@ -3199,28 +3267,28 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
** </li>
** </ol>
*/
-SQLITE_API int sqlite3_prepare(
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
sqlite3 *db, /* Database handle */
const char *zSql, /* SQL statement, UTF-8 encoded */
int nByte, /* Maximum length of zSql in bytes. */
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
const char **pzTail /* OUT: Pointer to unused portion of zSql */
);
-SQLITE_API int sqlite3_prepare_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
sqlite3 *db, /* Database handle */
const char *zSql, /* SQL statement, UTF-8 encoded */
int nByte, /* Maximum length of zSql in bytes. */
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
const char **pzTail /* OUT: Pointer to unused portion of zSql */
);
-SQLITE_API int sqlite3_prepare16(
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
sqlite3 *db, /* Database handle */
const void *zSql, /* SQL statement, UTF-16 encoded */
int nByte, /* Maximum length of zSql in bytes. */
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
const void **pzTail /* OUT: Pointer to unused portion of zSql */
);
-SQLITE_API int sqlite3_prepare16_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
sqlite3 *db, /* Database handle */
const void *zSql, /* SQL statement, UTF-16 encoded */
int nByte, /* Maximum length of zSql in bytes. */
@@ -3235,7 +3303,7 @@ SQLITE_API int sqlite3_prepare16_v2(
** SQL text used to create a [prepared statement] if that statement was
** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
*/
-SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
/*
** CAPI3REF: Determine If An SQL Statement Writes The Database
@@ -3266,7 +3334,7 @@ SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
** change the configuration of a database connection, they do not make
** changes to the content of the database files on disk.
*/
-SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
/*
** CAPI3REF: Determine If A Prepared Statement Has Been Reset
@@ -3285,7 +3353,7 @@ SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
** for example, in diagnostic routines to search for prepared
** statements that are holding a transaction open.
*/
-SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt*);
/*
** CAPI3REF: Dynamically Typed Value Object
@@ -3446,19 +3514,19 @@ typedef struct sqlite3_context sqlite3_context;
** See also: [sqlite3_bind_parameter_count()],
** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
*/
-SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
-SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
void(*)(void*));
-SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
-SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
-SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
-SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
-SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
-SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
-SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt*, int, double);
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt*, int, int);
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt*, int);
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
void(*)(void*), unsigned char encoding);
-SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
-SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
/*
** CAPI3REF: Number Of SQL Parameters
@@ -3478,7 +3546,7 @@ SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
** [sqlite3_bind_parameter_name()], and
** [sqlite3_bind_parameter_index()].
*/
-SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt*);
/*
** CAPI3REF: Name Of A Host Parameter
@@ -3505,7 +3573,7 @@ SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
** [sqlite3_bind_parameter_count()], and
** [sqlite3_bind_parameter_index()].
*/
-SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt*, int);
/*
** CAPI3REF: Index Of A Parameter With A Given Name
@@ -3521,7 +3589,7 @@ SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
** [sqlite3_bind_parameter_count()], and
** [sqlite3_bind_parameter_index()].
*/
-SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
/*
** CAPI3REF: Reset All Bindings On A Prepared Statement
@@ -3530,7 +3598,7 @@ SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
** the [sqlite3_bind_blob | bindings] on a [prepared statement].
** ^Use this routine to reset all host parameters to NULL.
*/
-SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
+SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt*);
/*
** CAPI3REF: Number Of Columns In A Result Set
@@ -3541,7 +3609,7 @@ SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
**
** See also: [sqlite3_data_count()]
*/
-SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
+SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt);
/*
** CAPI3REF: Column Names In A Result Set
@@ -3569,8 +3637,8 @@ SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
** then the name of the column is unspecified and may change from
** one release of SQLite to the next.
*/
-SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
-SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt*, int N);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt*, int N);
/*
** CAPI3REF: Source Of Data In A Query Result
@@ -3617,12 +3685,12 @@ SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
** for the same [prepared statement] and result column
** at the same time then the results are undefined.
*/
-SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
-SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
-SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
-SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
-SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
-SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt*,int);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt*,int);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt*,int);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt*,int);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt*,int);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt*,int);
/*
** CAPI3REF: Declared Datatype Of A Query Result
@@ -3653,8 +3721,8 @@ SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
** is associated with individual values, not with the containers
** used to hold those values.
*/
-SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
-SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt*,int);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt*,int);
/*
** CAPI3REF: Evaluate An SQL Statement
@@ -3733,7 +3801,7 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
** then the more specific [error codes] are returned directly
** by sqlite3_step(). The use of the "v2" interface is recommended.
*/
-SQLITE_API int sqlite3_step(sqlite3_stmt*);
+SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt*);
/*
** CAPI3REF: Number of columns in a result set
@@ -3753,7 +3821,7 @@ SQLITE_API int sqlite3_step(sqlite3_stmt*);
**
** See also: [sqlite3_column_count()]
*/
-SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
+SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt);
/*
** CAPI3REF: Fundamental Datatypes
@@ -3949,16 +4017,16 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
** pointer. Subsequent calls to [sqlite3_errcode()] will return
** [SQLITE_NOMEM].)^
*/
-SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
-SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
-SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
-SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
-SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
-SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
-SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
-SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
-SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
-SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt*, int iCol);
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol);
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
+SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt*, int iCol);
+SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt*, int iCol);
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt*, int iCol);
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt*, int iCol);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt*, int iCol);
+SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt*, int iCol);
+SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt*, int iCol);
/*
** CAPI3REF: Destroy A Prepared Statement Object
@@ -3985,7 +4053,7 @@ SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
** statement after it has been finalized can result in undefined and
** undesirable behavior such as segfaults and heap corruption.
*/
-SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
+SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt);
/*
** CAPI3REF: Reset A Prepared Statement Object
@@ -4011,7 +4079,7 @@ SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
** ^The [sqlite3_reset(S)] interface does not change the values
** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
*/
-SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
+SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt);
/*
** CAPI3REF: Create Or Redefine SQL Functions
@@ -4110,7 +4178,7 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
** close the database connection nor finalize or reset the prepared
** statement in which the function is running.
*/
-SQLITE_API int sqlite3_create_function(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
sqlite3 *db,
const char *zFunctionName,
int nArg,
@@ -4120,7 +4188,7 @@ SQLITE_API int sqlite3_create_function(
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*)
);
-SQLITE_API int sqlite3_create_function16(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
sqlite3 *db,
const void *zFunctionName,
int nArg,
@@ -4130,7 +4198,7 @@ SQLITE_API int sqlite3_create_function16(
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
void (*xFinal)(sqlite3_context*)
);
-SQLITE_API int sqlite3_create_function_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
sqlite3 *db,
const char *zFunctionName,
int nArg,
@@ -4148,9 +4216,9 @@ SQLITE_API int sqlite3_create_function_v2(
** These constant define integer codes that represent the various
** text encodings supported by SQLite.
*/
-#define SQLITE_UTF8 1
-#define SQLITE_UTF16LE 2
-#define SQLITE_UTF16BE 3
+#define SQLITE_UTF8 1 /* IMP: R-37514-35566 */
+#define SQLITE_UTF16LE 2 /* IMP: R-03371-37637 */
+#define SQLITE_UTF16BE 3 /* IMP: R-51971-34154 */
#define SQLITE_UTF16 4 /* Use native byte order */
#define SQLITE_ANY 5 /* Deprecated */
#define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */
@@ -4172,16 +4240,16 @@ SQLITE_API int sqlite3_create_function_v2(
** These functions are [deprecated]. In order to maintain
** backwards compatibility with older code, these functions continue
** to be supported. However, new applications should avoid
-** the use of these functions. To help encourage people to avoid
-** using these functions, we are not going to tell you what they do.
+** the use of these functions. To encourage programmers to avoid
+** these functions, we will not explain what they do.
*/
#ifndef SQLITE_OMIT_DEPRECATED
-SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
-SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
-SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
-SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
-SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
-SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*);
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*);
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_global_recover(void);
+SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_thread_cleanup(void);
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
void*,sqlite3_int64);
#endif
@@ -4230,18 +4298,18 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
** These routines must be called from the same thread as
** the SQL function that supplied the [sqlite3_value*] parameters.
*/
-SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
-SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
-SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
-SQLITE_API double sqlite3_value_double(sqlite3_value*);
-SQLITE_API int sqlite3_value_int(sqlite3_value*);
-SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
-SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
-SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
-SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
-SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
-SQLITE_API int sqlite3_value_type(sqlite3_value*);
-SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value*);
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*);
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*);
+SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value*);
+SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value*);
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value*);
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value*);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value*);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value*);
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value*);
+SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value*);
+SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value*);
/*
** CAPI3REF: Obtain Aggregate Function Context
@@ -4285,7 +4353,7 @@ SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
** This routine must be called from the same thread in which
** the aggregate SQL function is running.
*/
-SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
+SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context*, int nBytes);
/*
** CAPI3REF: User Data For Functions
@@ -4299,7 +4367,7 @@ SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
** This routine must be called from the same thread in which
** the application-defined function is running.
*/
-SQLITE_API void *sqlite3_user_data(sqlite3_context*);
+SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context*);
/*
** CAPI3REF: Database Connection For Functions
@@ -4310,7 +4378,7 @@ SQLITE_API void *sqlite3_user_data(sqlite3_context*);
** and [sqlite3_create_function16()] routines that originally
** registered the application defined function.
*/
-SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context*);
/*
** CAPI3REF: Function Auxiliary Data
@@ -4362,8 +4430,8 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
** These routines must be called from the same thread in which
** the SQL function is running.
*/
-SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
-SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
+SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context*, int N);
+SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
/*
@@ -4498,25 +4566,26 @@ typedef void (*sqlite3_destructor_type)(void*);
** than the one containing the application-defined function that received
** the [sqlite3_context] pointer, the results are undefined.
*/
-SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
-SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,sqlite3_uint64,void(*)(void*));
-SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
-SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
-SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
-SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
-SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
-SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
-SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
-SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
-SQLITE_API void sqlite3_result_null(sqlite3_context*);
-SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
-SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(sqlite3_context*,const void*,
+ sqlite3_uint64,void(*)(void*));
+SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context*, double);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context*, const char*, int);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context*, const void*, int);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context*);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context*);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context*, int);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context*, int);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context*);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
void(*)(void*), unsigned char encoding);
-SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
-SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
-SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
-SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
-SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
+SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context*, sqlite3_value*);
+SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context*, int n);
/*
** CAPI3REF: Define New Collating Sequences
@@ -4597,14 +4666,14 @@ SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
**
** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
*/
-SQLITE_API int sqlite3_create_collation(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
sqlite3*,
const char *zName,
int eTextRep,
void *pArg,
int(*xCompare)(void*,int,const void*,int,const void*)
);
-SQLITE_API int sqlite3_create_collation_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
sqlite3*,
const char *zName,
int eTextRep,
@@ -4612,7 +4681,7 @@ SQLITE_API int sqlite3_create_collation_v2(
int(*xCompare)(void*,int,const void*,int,const void*),
void(*xDestroy)(void*)
);
-SQLITE_API int sqlite3_create_collation16(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
sqlite3*,
const void *zName,
int eTextRep,
@@ -4646,12 +4715,12 @@ SQLITE_API int sqlite3_create_collation16(
** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
** [sqlite3_create_collation_v2()].
*/
-SQLITE_API int sqlite3_collation_needed(
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
sqlite3*,
void*,
void(*)(void*,sqlite3*,int eTextRep,const char*)
);
-SQLITE_API int sqlite3_collation_needed16(
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
sqlite3*,
void*,
void(*)(void*,sqlite3*,int eTextRep,const void*)
@@ -4665,11 +4734,11 @@ SQLITE_API int sqlite3_collation_needed16(
** The code to implement this API is not available in the public release
** of SQLite.
*/
-SQLITE_API int sqlite3_key(
+SQLITE_API int SQLITE_STDCALL sqlite3_key(
sqlite3 *db, /* Database to be rekeyed */
const void *pKey, int nKey /* The key */
);
-SQLITE_API int sqlite3_key_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_key_v2(
sqlite3 *db, /* Database to be rekeyed */
const char *zDbName, /* Name of the database */
const void *pKey, int nKey /* The key */
@@ -4683,11 +4752,11 @@ SQLITE_API int sqlite3_key_v2(
** The code to implement this API is not available in the public release
** of SQLite.
*/
-SQLITE_API int sqlite3_rekey(
+SQLITE_API int SQLITE_STDCALL sqlite3_rekey(
sqlite3 *db, /* Database to be rekeyed */
const void *pKey, int nKey /* The new key */
);
-SQLITE_API int sqlite3_rekey_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_rekey_v2(
sqlite3 *db, /* Database to be rekeyed */
const char *zDbName, /* Name of the database */
const void *pKey, int nKey /* The new key */
@@ -4697,7 +4766,7 @@ SQLITE_API int sqlite3_rekey_v2(
** Specify the activation key for a SEE database. Unless
** activated, none of the SEE routines will work.
*/
-SQLITE_API void sqlite3_activate_see(
+SQLITE_API void SQLITE_STDCALL sqlite3_activate_see(
const char *zPassPhrase /* Activation phrase */
);
#endif
@@ -4707,7 +4776,7 @@ SQLITE_API void sqlite3_activate_see(
** Specify the activation key for a CEROD database. Unless
** activated, none of the CEROD routines will work.
*/
-SQLITE_API void sqlite3_activate_cerod(
+SQLITE_API void SQLITE_STDCALL sqlite3_activate_cerod(
const char *zPassPhrase /* Activation phrase */
);
#endif
@@ -4729,7 +4798,7 @@ SQLITE_API void sqlite3_activate_cerod(
** all, then the behavior of sqlite3_sleep() may deviate from the description
** in the previous paragraphs.
*/
-SQLITE_API int sqlite3_sleep(int);
+SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int);
/*
** CAPI3REF: Name Of The Folder Holding Temporary Files
@@ -4847,7 +4916,7 @@ SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;
** connection while this routine is running, then the return value
** is undefined.
*/
-SQLITE_API int sqlite3_get_autocommit(sqlite3*);
+SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3*);
/*
** CAPI3REF: Find The Database Handle Of A Prepared Statement
@@ -4859,7 +4928,7 @@ SQLITE_API int sqlite3_get_autocommit(sqlite3*);
** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
** create the statement in the first place.
*/
-SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt*);
/*
** CAPI3REF: Return The Filename For A Database Connection
@@ -4875,7 +4944,7 @@ SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
** will be an absolute pathname, even if the filename used
** to open the database originally was a URI or relative pathname.
*/
-SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
+SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName);
/*
** CAPI3REF: Determine if a database is read-only
@@ -4884,7 +4953,7 @@ SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
** of connection D is read-only, 0 if it is read/write, or -1 if N is not
** the name of a database on connection D.
*/
-SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
+SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
/*
** CAPI3REF: Find the next prepared statement
@@ -4899,7 +4968,7 @@ SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
** [sqlite3_next_stmt(D,S)] must refer to an open database
** connection and in particular must not be a NULL pointer.
*/
-SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
+SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
/*
** CAPI3REF: Commit And Rollback Notification Callbacks
@@ -4947,8 +5016,8 @@ SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
**
** See also the [sqlite3_update_hook()] interface.
*/
-SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
-SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
+SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
+SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
/*
** CAPI3REF: Data Change Notification Callbacks
@@ -4998,7 +5067,7 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
** interfaces.
*/
-SQLITE_API void *sqlite3_update_hook(
+SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
sqlite3*,
void(*)(void *,int ,char const *,char const *,sqlite3_int64),
void*
@@ -5028,12 +5097,17 @@ SQLITE_API void *sqlite3_update_hook(
** future releases of SQLite. Applications that care about shared
** cache setting should set it explicitly.
**
+** Note: This method is disabled on MacOS X 10.7 and iOS version 5.0
+** and will always return SQLITE_MISUSE. On those systems,
+** shared cache mode should be enabled per-database connection via
+** [sqlite3_open_v2()] with [SQLITE_OPEN_SHAREDCACHE].
+**
** This interface is threadsafe on processors where writing a
** 32-bit integer is atomic.
**
** See Also: [SQLite Shared-Cache Mode]
*/
-SQLITE_API int sqlite3_enable_shared_cache(int);
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int);
/*
** CAPI3REF: Attempt To Free Heap Memory
@@ -5049,7 +5123,7 @@ SQLITE_API int sqlite3_enable_shared_cache(int);
**
** See also: [sqlite3_db_release_memory()]
*/
-SQLITE_API int sqlite3_release_memory(int);
+SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int);
/*
** CAPI3REF: Free Memory Used By A Database Connection
@@ -5062,7 +5136,7 @@ SQLITE_API int sqlite3_release_memory(int);
**
** See also: [sqlite3_release_memory()]
*/
-SQLITE_API int sqlite3_db_release_memory(sqlite3*);
+SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3*);
/*
** CAPI3REF: Impose A Limit On Heap Size
@@ -5114,7 +5188,7 @@ SQLITE_API int sqlite3_db_release_memory(sqlite3*);
** The circumstances under which SQLite will enforce the soft heap limit may
** changes in future releases of SQLite.
*/
-SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 N);
/*
** CAPI3REF: Deprecated Soft Heap Limit Interface
@@ -5125,26 +5199,33 @@ SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
** only. All new applications should use the
** [sqlite3_soft_heap_limit64()] interface rather than this one.
*/
-SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
+SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N);
/*
** CAPI3REF: Extract Metadata About A Column Of A Table
**
-** ^This routine returns metadata about a specific column of a specific
-** database table accessible using the [database connection] handle
-** passed as the first function argument.
+** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
+** information about column C of table T in database D
+** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
+** interface returns SQLITE_OK and fills in the non-NULL pointers in
+** the final five arguments with appropriate values if the specified
+** column exists. ^The sqlite3_table_column_metadata() interface returns
+** SQLITE_ERROR and if the specified column does not exist.
+** ^If the column-name parameter to sqlite3_table_column_metadata() is a
+** NULL pointer, then this routine simply checks for the existance of the
+** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
+** does not.
**
** ^The column is identified by the second, third and fourth parameters to
-** this function. ^The second parameter is either the name of the database
+** this function. ^(The second parameter is either the name of the database
** (i.e. "main", "temp", or an attached database) containing the specified
-** table or NULL. ^If it is NULL, then all attached databases are searched
+** table or NULL.)^ ^If it is NULL, then all attached databases are searched
** for the table using the same algorithm used by the database engine to
** resolve unqualified table references.
**
** ^The third and fourth parameters to this function are the table and column
-** name of the desired column, respectively. Neither of these parameters
-** may be NULL.
+** name of the desired column, respectively.
**
** ^Metadata is returned by writing to the memory locations passed as the 5th
** and subsequent parameters to this function. ^Any of these arguments may be
@@ -5163,16 +5244,17 @@ SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
** </blockquote>)^
**
** ^The memory pointed to by the character pointers returned for the
-** declaration type and collation sequence is valid only until the next
+** declaration type and collation sequence is valid until the next
** call to any SQLite API function.
**
** ^If the specified table is actually a view, an [error code] is returned.
**
-** ^If the specified column is "rowid", "oid" or "_rowid_" and an
+** ^If the specified column is "rowid", "oid" or "_rowid_" and the table
+** is not a [WITHOUT ROWID] table and an
** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
** parameters are set for the explicitly declared column. ^(If there is no
-** explicitly declared [INTEGER PRIMARY KEY] column, then the output
-** parameters are set as follows:
+** [INTEGER PRIMARY KEY] column, then the outputs
+** for the [rowid] are set as follows:
**
** <pre>
** data type: "INTEGER"
@@ -5182,15 +5264,11 @@ SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
** auto increment: 0
** </pre>)^
**
-** ^(This function may load one or more schemas from database files. If an
-** error occurs during this process, or if the requested table or column
-** cannot be found, an [error code] is returned and an error message left
-** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
-**
-** ^This API is only available if the library was compiled with the
-** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
+** ^This function causes all database schemas to be read from disk and
+** parsed, if that has not already been done, and returns an error if
+** any errors are encountered while loading the schema.
*/
-SQLITE_API int sqlite3_table_column_metadata(
+SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
sqlite3 *db, /* Connection handle */
const char *zDbName, /* Database name or NULL */
const char *zTableName, /* Table name */
@@ -5236,7 +5314,7 @@ SQLITE_API int sqlite3_table_column_metadata(
**
** See also the [load_extension() SQL function].
*/
-SQLITE_API int sqlite3_load_extension(
+SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
sqlite3 *db, /* Load the extension into this database connection */
const char *zFile, /* Name of the shared library containing extension */
const char *zProc, /* Entry point. Derived from zFile if 0 */
@@ -5256,7 +5334,7 @@ SQLITE_API int sqlite3_load_extension(
** to turn extension loading on and call it with onoff==0 to turn
** it back off again.
*/
-SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff);
/*
** CAPI3REF: Automatically Load Statically Linked Extensions
@@ -5294,7 +5372,7 @@ SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
** See also: [sqlite3_reset_auto_extension()]
** and [sqlite3_cancel_auto_extension()]
*/
-SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
+SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
/*
** CAPI3REF: Cancel Automatic Extension Loading
@@ -5306,7 +5384,7 @@ SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
** unregistered and it returns 0 if X was not on the list of initialization
** routines.
*/
-SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
+SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
/*
** CAPI3REF: Reset Automatic Extension Loading
@@ -5314,7 +5392,7 @@ SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
** ^This interface disables all automatic extensions previously
** registered using [sqlite3_auto_extension()].
*/
-SQLITE_API void sqlite3_reset_auto_extension(void);
+SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void);
/*
** The interface to the virtual-table mechanism is currently considered
@@ -5517,13 +5595,13 @@ struct sqlite3_index_info {
** interface is equivalent to sqlite3_create_module_v2() with a NULL
** destructor.
*/
-SQLITE_API int sqlite3_create_module(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
sqlite3 *db, /* SQLite connection to register module with */
const char *zName, /* Name of the module */
const sqlite3_module *p, /* Methods for the module */
void *pClientData /* Client data for xCreate/xConnect */
);
-SQLITE_API int sqlite3_create_module_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
sqlite3 *db, /* SQLite connection to register module with */
const char *zName, /* Name of the module */
const sqlite3_module *p, /* Methods for the module */
@@ -5551,7 +5629,7 @@ SQLITE_API int sqlite3_create_module_v2(
*/
struct sqlite3_vtab {
const sqlite3_module *pModule; /* The module for this virtual table */
- int nRef; /* NO LONGER USED */
+ int nRef; /* Number of open cursors */
char *zErrMsg; /* Error message from sqlite3_mprintf() */
/* Virtual table implementations will typically add additional fields */
};
@@ -5586,7 +5664,7 @@ struct sqlite3_vtab_cursor {
** to declare the format (the names and datatypes of the columns) of
** the virtual tables they implement.
*/
-SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
+SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3*, const char *zSQL);
/*
** CAPI3REF: Overload A Function For A Virtual Table
@@ -5604,7 +5682,7 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
** purpose is to be a placeholder function that can be overloaded
** by a [virtual table].
*/
-SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
+SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
/*
** The interface to the virtual-table mechanism defined above (back up
@@ -5641,26 +5719,42 @@ typedef struct sqlite3_blob sqlite3_blob;
** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
** </pre>)^
**
+** ^(Parameter zDb is not the filename that contains the database, but
+** rather the symbolic name of the database. For attached databases, this is
+** the name that appears after the AS keyword in the [ATTACH] statement.
+** For the main database file, the database name is "main". For TEMP
+** tables, the database name is "temp".)^
+**
** ^If the flags parameter is non-zero, then the BLOB is opened for read
-** and write access. ^If it is zero, the BLOB is opened for read access.
-** ^It is not possible to open a column that is part of an index or primary
-** key for writing. ^If [foreign key constraints] are enabled, it is
-** not possible to open a column that is part of a [child key] for writing.
-**
-** ^Note that the database name is not the filename that contains
-** the database but rather the symbolic name of the database that
-** appears after the AS keyword when the database is connected using [ATTACH].
-** ^For the main database file, the database name is "main".
-** ^For TEMP tables, the database name is "temp".
-**
-** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
-** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set
-** to be a null pointer.)^
-** ^This function sets the [database connection] error code and message
-** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related
-** functions. ^Note that the *ppBlob variable is always initialized in a
-** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob
-** regardless of the success or failure of this routine.
+** and write access. ^If the flags parameter is zero, the BLOB is opened for
+** read-only access.
+**
+** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is stored
+** in *ppBlob. Otherwise an [error code] is returned and, unless the error
+** code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided
+** the API is not misused, it is always safe to call [sqlite3_blob_close()]
+** on *ppBlob after this function it returns.
+**
+** This function fails with SQLITE_ERROR if any of the following are true:
+** <ul>
+** <li> ^(Database zDb does not exist)^,
+** <li> ^(Table zTable does not exist within database zDb)^,
+** <li> ^(Table zTable is a WITHOUT ROWID table)^,
+** <li> ^(Column zColumn does not exist)^,
+** <li> ^(Row iRow is not present in the table)^,
+** <li> ^(The specified column of row iRow contains a value that is not
+** a TEXT or BLOB value)^,
+** <li> ^(Column zColumn is part of an index, PRIMARY KEY or UNIQUE
+** constraint and the blob is being opened for read/write access)^,
+** <li> ^([foreign key constraints | Foreign key constraints] are enabled,
+** column zColumn is part of a [child key] definition and the blob is
+** being opened for read/write access)^.
+** </ul>
+**
+** ^Unless it returns SQLITE_MISUSE, this function sets the
+** [database connection] error code and message accessible via
+** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions.
+**
**
** ^(If the row that a BLOB handle points to is modified by an
** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects
@@ -5678,18 +5772,14 @@ typedef struct sqlite3_blob sqlite3_blob;
** interface. Use the [UPDATE] SQL command to change the size of a
** blob.
**
-** ^The [sqlite3_blob_open()] interface will fail for a [WITHOUT ROWID]
-** table. Incremental BLOB I/O is not possible on [WITHOUT ROWID] tables.
-**
** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
-** and the built-in [zeroblob] SQL function can be used, if desired,
-** to create an empty, zero-filled blob in which to read or write using
-** this interface.
+** and the built-in [zeroblob] SQL function may be used to create a
+** zero-filled blob to read or write using the incremental-blob interface.
**
** To avoid a resource leak, every open [BLOB handle] should eventually
** be released by a call to [sqlite3_blob_close()].
*/
-SQLITE_API int sqlite3_blob_open(
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
sqlite3*,
const char *zDb,
const char *zTable,
@@ -5721,31 +5811,29 @@ SQLITE_API int sqlite3_blob_open(
**
** ^This function sets the database handle error code and message.
*/
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
+SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
/*
** CAPI3REF: Close A BLOB Handle
**
-** ^Closes an open [BLOB handle].
+** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
+** unconditionally. Even if this routine returns an error code, the
+** handle is still closed.)^
**
-** ^Closing a BLOB shall cause the current transaction to commit
-** if there are no other BLOBs, no pending prepared statements, and the
-** database connection is in [autocommit mode].
-** ^If any writes were made to the BLOB, they might be held in cache
-** until the close operation if they will fit.
+** ^If the blob handle being closed was opened for read-write access, and if
+** the database is in auto-commit mode and there are no other open read-write
+** blob handles or active write statements, the current transaction is
+** committed. ^If an error occurs while committing the transaction, an error
+** code is returned and the transaction rolled back.
**
-** ^(Closing the BLOB often forces the changes
-** out to disk and so if any I/O errors occur, they will likely occur
-** at the time when the BLOB is closed. Any errors that occur during
-** closing are reported as a non-zero return value.)^
-**
-** ^(The BLOB is closed unconditionally. Even if this routine returns
-** an error code, the BLOB is still closed.)^
-**
-** ^Calling this routine with a null pointer (such as would be returned
-** by a failed call to [sqlite3_blob_open()]) is a harmless no-op.
+** Calling this function with an argument that is not a NULL pointer or an
+** open blob handle results in undefined behaviour. ^Calling this routine
+** with a null pointer (such as would be returned by a failed call to
+** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
+** is passed a valid open blob handle, the values returned by the
+** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
*/
-SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *);
/*
** CAPI3REF: Return The Size Of An Open BLOB
@@ -5760,7 +5848,7 @@ SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
** to this routine results in undefined and probably undesirable behavior.
*/
-SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *);
/*
** CAPI3REF: Read Data From A BLOB Incrementally
@@ -5788,26 +5876,32 @@ SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
**
** See also: [sqlite3_blob_write()].
*/
-SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
/*
** CAPI3REF: Write Data Into A BLOB Incrementally
**
-** ^This function is used to write data into an open [BLOB handle] from a
-** caller-supplied buffer. ^N bytes of data are copied from the buffer Z
-** into the open BLOB, starting at offset iOffset.
+** ^(This function is used to write data into an open [BLOB handle] from a
+** caller-supplied buffer. N bytes of data are copied from the buffer Z
+** into the open BLOB, starting at offset iOffset.)^
+**
+** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
+** Otherwise, an [error code] or an [extended error code] is returned.)^
+** ^Unless SQLITE_MISUSE is returned, this function sets the
+** [database connection] error code and message accessible via
+** [sqlite3_errcode()] and [sqlite3_errmsg()] and related functions.
**
** ^If the [BLOB handle] passed as the first argument was not opened for
** writing (the flags parameter to [sqlite3_blob_open()] was zero),
** this function returns [SQLITE_READONLY].
**
-** ^This function may only modify the contents of the BLOB; it is
+** This function may only modify the contents of the BLOB; it is
** not possible to increase the size of a BLOB using this API.
** ^If offset iOffset is less than N bytes from the end of the BLOB,
-** [SQLITE_ERROR] is returned and no data is written. ^If N is
-** less than zero [SQLITE_ERROR] is returned and no data is written.
-** The size of the BLOB (and hence the maximum value of N+iOffset)
-** can be determined using the [sqlite3_blob_bytes()] interface.
+** [SQLITE_ERROR] is returned and no data is written. The size of the
+** BLOB (and hence the maximum value of N+iOffset) can be determined
+** using the [sqlite3_blob_bytes()] interface. ^If N or iOffset are less
+** than zero [SQLITE_ERROR] is returned and no data is written.
**
** ^An attempt to write to an expired [BLOB handle] fails with an
** error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred
@@ -5816,9 +5910,6 @@ SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
** have been overwritten by the statement that expired the BLOB handle
** or by other independent statements.
**
-** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
-** Otherwise, an [error code] or an [extended error code] is returned.)^
-**
** This routine only works on a [BLOB handle] which has been created
** by a prior successful call to [sqlite3_blob_open()] and which has not
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
@@ -5826,7 +5917,7 @@ SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
**
** See also: [sqlite3_blob_read()].
*/
-SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
/*
** CAPI3REF: Virtual File System Objects
@@ -5857,9 +5948,9 @@ SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOff
** ^(If the default VFS is unregistered, another VFS is chosen as
** the default. The choice for the new VFS is arbitrary.)^
*/
-SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
-SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
-SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
+SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfsName);
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs*);
/*
** CAPI3REF: Mutexes
@@ -5871,34 +5962,34 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
**
** The SQLite source code contains multiple implementations
** of these mutex routines. An appropriate implementation
-** is selected automatically at compile-time. ^(The following
+** is selected automatically at compile-time. The following
** implementations are available in the SQLite core:
**
** <ul>
** <li> SQLITE_MUTEX_PTHREADS
** <li> SQLITE_MUTEX_W32
** <li> SQLITE_MUTEX_NOOP
-** </ul>)^
+** </ul>
**
-** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
+** The SQLITE_MUTEX_NOOP implementation is a set of routines
** that does no real locking and is appropriate for use in
-** a single-threaded application. ^The SQLITE_MUTEX_PTHREADS and
+** a single-threaded application. The SQLITE_MUTEX_PTHREADS and
** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix
** and Windows.
**
-** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
+** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
** implementation is included with the library. In this case the
** application must supply a custom mutex implementation using the
** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
** before calling sqlite3_initialize() or any other public sqlite3_
-** function that calls sqlite3_initialize().)^
+** function that calls sqlite3_initialize().
**
** ^The sqlite3_mutex_alloc() routine allocates a new
-** mutex and returns a pointer to it. ^If it returns NULL
-** that means that a mutex could not be allocated. ^SQLite
-** will unwind its stack and return an error. ^(The argument
-** to sqlite3_mutex_alloc() is one of these integer constants:
+** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc()
+** routine returns NULL if it is unable to allocate the requested
+** mutex. The argument to sqlite3_mutex_alloc() must one of these
+** integer constants:
**
** <ul>
** <li> SQLITE_MUTEX_FAST
@@ -5911,7 +6002,8 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
** <li> SQLITE_MUTEX_STATIC_PMEM
** <li> SQLITE_MUTEX_STATIC_APP1
** <li> SQLITE_MUTEX_STATIC_APP2
-** </ul>)^
+** <li> SQLITE_MUTEX_STATIC_APP3
+** </ul>
**
** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)
** cause sqlite3_mutex_alloc() to create
@@ -5919,14 +6011,14 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
** The mutex implementation does not need to make a distinction
** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
-** not want to. ^SQLite will only request a recursive mutex in
-** cases where it really needs one. ^If a faster non-recursive mutex
+** not want to. SQLite will only request a recursive mutex in
+** cases where it really needs one. If a faster non-recursive mutex
** implementation is available on the host platform, the mutex subsystem
** might return such a mutex in response to SQLITE_MUTEX_FAST.
**
** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other
** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return
-** a pointer to a static preexisting mutex. ^Six static mutexes are
+** a pointer to a static preexisting mutex. ^Nine static mutexes are
** used by the current version of SQLite. Future versions of SQLite
** may add additional static mutexes. Static mutexes are for internal
** use by SQLite only. Applications that use SQLite mutexes should
@@ -5935,16 +6027,13 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
**
** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
-** returns a different mutex on every call. ^But for the static
+** returns a different mutex on every call. ^For the static
** mutex types, the same mutex is returned on every call that has
** the same type number.
**
** ^The sqlite3_mutex_free() routine deallocates a previously
-** allocated dynamic mutex. ^SQLite is careful to deallocate every
-** dynamic mutex that it allocates. The dynamic mutexes must not be in
-** use when they are deallocated. Attempting to deallocate a static
-** mutex results in undefined behavior. ^SQLite never deallocates
-** a static mutex.
+** allocated dynamic mutex. Attempting to deallocate a static
+** mutex results in undefined behavior.
**
** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
** to enter a mutex. ^If another thread is already within the mutex,
@@ -5952,23 +6041,21 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
** SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK]
** upon successful entry. ^(Mutexes created using
** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
-** In such cases the,
+** In such cases, the
** mutex must be exited an equal number of times before another thread
-** can enter.)^ ^(If the same thread tries to enter any other
-** kind of mutex more than once, the behavior is undefined.
-** SQLite will never exhibit
-** such behavior in its own use of mutexes.)^
+** can enter.)^ If the same thread tries to enter any mutex other
+** than an SQLITE_MUTEX_RECURSIVE more than once, the behavior is undefined.
**
** ^(Some systems (for example, Windows 95) do not support the operation
** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try()
-** will always return SQLITE_BUSY. The SQLite core only ever uses
-** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^
+** will always return SQLITE_BUSY. The SQLite core only ever uses
+** sqlite3_mutex_try() as an optimization so this is acceptable
+** behavior.)^
**
** ^The sqlite3_mutex_leave() routine exits a mutex that was
-** previously entered by the same thread. ^(The behavior
+** previously entered by the same thread. The behavior
** is undefined if the mutex is not currently entered by the
-** calling thread or is not currently allocated. SQLite will
-** never do either.)^
+** calling thread or is not currently allocated.
**
** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
** sqlite3_mutex_leave() is a NULL pointer, then all three routines
@@ -5976,11 +6063,11 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
**
** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
*/
-SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);
-SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);
-SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
-SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
-SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int);
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex*);
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex*);
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex*);
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex*);
/*
** CAPI3REF: Mutex Methods Object
@@ -5989,9 +6076,9 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
** used to allocate and use mutexes.
**
** Usually, the default mutex implementations provided by SQLite are
-** sufficient, however the user has the option of substituting a custom
+** sufficient, however the application has the option of substituting a custom
** implementation for specialized deployments or systems for which SQLite
-** does not provide a suitable implementation. In this case, the user
+** does not provide a suitable implementation. In this case, the application
** creates and populates an instance of this structure to pass
** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.
** Additionally, an instance of this structure can be used as an
@@ -6032,13 +6119,13 @@ SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
** (i.e. it is acceptable to provide an implementation that segfaults if
** it is passed a NULL pointer).
**
-** The xMutexInit() method must be threadsafe. ^It must be harmless to
+** The xMutexInit() method must be threadsafe. It must be harmless to
** invoke xMutexInit() multiple times within the same process and without
** intervening calls to xMutexEnd(). Second and subsequent calls to
** xMutexInit() must be no-ops.
**
-** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
-** and its associates). ^Similarly, xMutexAlloc() must not use SQLite memory
+** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
+** and its associates). Similarly, xMutexAlloc() must not use SQLite memory
** allocation for a static mutex. ^However xMutexAlloc() may use SQLite
** memory allocation for a fast or recursive mutex.
**
@@ -6064,34 +6151,34 @@ struct sqlite3_mutex_methods {
** CAPI3REF: Mutex Verification Routines
**
** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
-** are intended for use inside assert() statements. ^The SQLite core
+** are intended for use inside assert() statements. The SQLite core
** never uses these routines except inside an assert() and applications
-** are advised to follow the lead of the core. ^The SQLite core only
+** are advised to follow the lead of the core. The SQLite core only
** provides implementations for these routines when it is compiled
-** with the SQLITE_DEBUG flag. ^External mutex implementations
+** with the SQLITE_DEBUG flag. External mutex implementations
** are only required to provide these routines if SQLITE_DEBUG is
** defined and if NDEBUG is not defined.
**
-** ^These routines should return true if the mutex in their argument
+** These routines should return true if the mutex in their argument
** is held or not held, respectively, by the calling thread.
**
-** ^The implementation is not required to provide versions of these
+** The implementation is not required to provide versions of these
** routines that actually work. If the implementation does not provide working
** versions of these routines, it should at least provide stubs that always
** return true so that one does not get spurious assertion failures.
**
-** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
+** If the argument to sqlite3_mutex_held() is a NULL pointer then
** the routine should return 1. This seems counter-intuitive since
** clearly the mutex cannot be held if it does not exist. But
** the reason the mutex does not exist is because the build is not
** using mutexes. And we do not want the assert() containing the
** call to sqlite3_mutex_held() to fail, so a non-zero return is
-** the appropriate thing to do. ^The sqlite3_mutex_notheld()
+** the appropriate thing to do. The sqlite3_mutex_notheld()
** interface should also return 1 when given a NULL pointer.
*/
#ifndef NDEBUG
-SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
-SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex*);
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex*);
#endif
/*
@@ -6127,7 +6214,7 @@ SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
** ^If the [threading mode] is Single-thread or Multi-thread then this
** routine returns a NULL pointer.
*/
-SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3*);
/*
** CAPI3REF: Low-Level Control Of Database Files
@@ -6161,7 +6248,7 @@ SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
**
** See also: [SQLITE_FCNTL_LOCKSTATE]
*/
-SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
+SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
/*
** CAPI3REF: Testing Interface
@@ -6180,7 +6267,7 @@ SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*
** Unlike most of the SQLite API, this function is not guaranteed to
** operate consistently from one release to the next.
*/
-SQLITE_API int sqlite3_test_control(int op, ...);
+SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...);
/*
** CAPI3REF: Testing Interface Operation Codes
@@ -6214,12 +6301,13 @@ SQLITE_API int sqlite3_test_control(int op, ...);
#define SQLITE_TESTCTRL_BYTEORDER 22
#define SQLITE_TESTCTRL_ISINIT 23
#define SQLITE_TESTCTRL_SORTER_MMAP 24
-#define SQLITE_TESTCTRL_LAST 24
+#define SQLITE_TESTCTRL_IMPOSTER 25
+#define SQLITE_TESTCTRL_LAST 25
/*
** CAPI3REF: SQLite Runtime Status
**
-** ^This interface is used to retrieve runtime status information
+** ^These interfaces are used to retrieve runtime status information
** about the performance of SQLite, and optionally to reset various
** highwater marks. ^The first argument is an integer code for
** the specific parameter to measure. ^(Recognized integer codes
@@ -6233,19 +6321,22 @@ SQLITE_API int sqlite3_test_control(int op, ...);
** ^(Other parameters record only the highwater mark and not the current
** value. For these latter parameters nothing is written into *pCurrent.)^
**
-** ^The sqlite3_status() routine returns SQLITE_OK on success and a
-** non-zero [error code] on failure.
+** ^The sqlite3_status() and sqlite3_status64() routines return
+** SQLITE_OK on success and a non-zero [error code] on failure.
**
-** This routine is threadsafe but is not atomic. This routine can be
-** called while other threads are running the same or different SQLite
-** interfaces. However the values returned in *pCurrent and
-** *pHighwater reflect the status of SQLite at different points in time
-** and it is possible that another thread might change the parameter
-** in between the times when *pCurrent and *pHighwater are written.
+** If either the current value or the highwater mark is too large to
+** be represented by a 32-bit integer, then the values returned by
+** sqlite3_status() are undefined.
**
** See also: [sqlite3_db_status()]
*/
-SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
+SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
+SQLITE_API int SQLITE_STDCALL sqlite3_status64(
+ int op,
+ sqlite3_int64 *pCurrent,
+ sqlite3_int64 *pHighwater,
+ int resetFlag
+);
/*
@@ -6363,7 +6454,7 @@ SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetF
**
** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
*/
-SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
+SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
/*
** CAPI3REF: Status Parameters for database connections
@@ -6492,7 +6583,7 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r
**
** See also: [sqlite3_status()] and [sqlite3_db_status()].
*/
-SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
/*
** CAPI3REF: Status Parameters for prepared statements
@@ -6819,6 +6910,10 @@ typedef struct sqlite3_backup sqlite3_backup;
** must be different or else sqlite3_backup_init(D,N,S,M) will fail with
** an error.
**
+** ^A call to sqlite3_backup_init() will fail, returning SQLITE_ERROR, if
+** there is already a read or read-write transaction open on the
+** destination database.
+**
** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is
** returned and an error code and error message are stored in the
** destination [database connection] D.
@@ -6911,20 +7006,20 @@ typedef struct sqlite3_backup sqlite3_backup;
** is not a permanent error and does not affect the return value of
** sqlite3_backup_finish().
**
-** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]]
+** [[sqlite3_backup_remaining()]] [[sqlite3_backup_pagecount()]]
** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>
**
-** ^Each call to sqlite3_backup_step() sets two values inside
-** the [sqlite3_backup] object: the number of pages still to be backed
-** up and the total number of pages in the source database file.
-** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
-** retrieve these two values, respectively.
-**
-** ^The values returned by these functions are only updated by
-** sqlite3_backup_step(). ^If the source database is modified during a backup
-** operation, then the values are not updated to account for any extra
-** pages that need to be updated or the size of the source database file
-** changing.
+** ^The sqlite3_backup_remaining() routine returns the number of pages still
+** to be backed up at the conclusion of the most recent sqlite3_backup_step().
+** ^The sqlite3_backup_pagecount() routine returns the total number of pages
+** in the source database at the conclusion of the most recent
+** sqlite3_backup_step().
+** ^(The values returned by these functions are only updated by
+** sqlite3_backup_step(). If the source database is modified in a way that
+** changes the size of the source database or the number of pages remaining,
+** those changes are not reflected in the output of sqlite3_backup_pagecount()
+** and sqlite3_backup_remaining() until after the next
+** sqlite3_backup_step().)^
**
** <b>Concurrent Usage of Database Handles</b>
**
@@ -6957,16 +7052,16 @@ typedef struct sqlite3_backup sqlite3_backup;
** same time as another thread is invoking sqlite3_backup_step() it is
** possible that they return invalid values.
*/
-SQLITE_API sqlite3_backup *sqlite3_backup_init(
+SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
sqlite3 *pDest, /* Destination database handle */
const char *zDestName, /* Destination database name */
sqlite3 *pSource, /* Source database handle */
const char *zSourceName /* Source database name */
);
-SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);
-SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);
-SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);
-SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage);
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p);
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p);
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p);
/*
** CAPI3REF: Unlock Notification
@@ -7082,7 +7177,7 @@ SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
** the special "DROP TABLE/INDEX" case, the extended error code is just
** SQLITE_LOCKED.)^
*/
-SQLITE_API int sqlite3_unlock_notify(
+SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
sqlite3 *pBlocked, /* Waiting connection */
void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
void *pNotifyArg /* Argument to pass to xNotify */
@@ -7097,8 +7192,8 @@ SQLITE_API int sqlite3_unlock_notify(
** strings in a case-independent fashion, using the same definition of "case
** independence" that SQLite uses internally when comparing identifiers.
*/
-SQLITE_API int sqlite3_stricmp(const char *, const char *);
-SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
+SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *, const char *);
+SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *, const char *, int);
/*
** CAPI3REF: String Globbing
@@ -7113,7 +7208,7 @@ SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
** Note that this routine returns zero on a match and non-zero if the strings
** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
*/
-SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
+SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlob, const char *zStr);
/*
** CAPI3REF: Error Logging Interface
@@ -7136,18 +7231,16 @@ SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
** a few hundred characters, it will be truncated to the length of the
** buffer.
*/
-SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
+SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...);
/*
** CAPI3REF: Write-Ahead Log Commit Hook
**
** ^The [sqlite3_wal_hook()] function is used to register a callback that
-** will be invoked each time a database connection commits data to a
-** [write-ahead log] (i.e. whenever a transaction is committed in
-** [journal_mode | journal_mode=WAL mode]).
+** is invoked each time data is committed to a database in wal mode.
**
-** ^The callback is invoked by SQLite after the commit has taken place and
-** the associated write-lock on the database released, so the implementation
+** ^(The callback is invoked by SQLite after the commit has taken place and
+** the associated write-lock on the database released)^, so the implementation
** may read, write or [checkpoint] the database as required.
**
** ^The first parameter passed to the callback function when it is invoked
@@ -7173,7 +7266,7 @@ SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
** those overwrite any prior [sqlite3_wal_hook()] settings.
*/
-SQLITE_API void *sqlite3_wal_hook(
+SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
sqlite3*,
int(*)(void *,sqlite3*,const char*,int),
void*
@@ -7207,104 +7300,121 @@ SQLITE_API void *sqlite3_wal_hook(
** is only necessary if the default setting is found to be suboptimal
** for a particular application.
*/
-SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
/*
** CAPI3REF: Checkpoint a database
**
-** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X
-** on [database connection] D to be [checkpointed]. ^If X is NULL or an
-** empty string, then a checkpoint is run on all databases of
-** connection D. ^If the database connection D is not in
-** [WAL | write-ahead log mode] then this interface is a harmless no-op.
-** ^The [sqlite3_wal_checkpoint(D,X)] interface initiates a
-** [sqlite3_wal_checkpoint_v2|PASSIVE] checkpoint.
-** Use the [sqlite3_wal_checkpoint_v2()] interface to get a FULL
-** or RESET checkpoint.
+** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
+** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^
**
-** ^The [wal_checkpoint pragma] can be used to invoke this interface
-** from SQL. ^The [sqlite3_wal_autocheckpoint()] interface and the
-** [wal_autocheckpoint pragma] can be used to cause this interface to be
-** run whenever the WAL reaches a certain size threshold.
+** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the
+** [write-ahead log] for database X on [database connection] D to be
+** transferred into the database file and for the write-ahead log to
+** be reset. See the [checkpointing] documentation for addition
+** information.
**
-** See also: [sqlite3_wal_checkpoint_v2()]
+** This interface used to be the only way to cause a checkpoint to
+** occur. But then the newer and more powerful [sqlite3_wal_checkpoint_v2()]
+** interface was added. This interface is retained for backwards
+** compatibility and as a convenience for applications that need to manually
+** start a callback but which do not need the full power (and corresponding
+** complication) of [sqlite3_wal_checkpoint_v2()].
*/
-SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
/*
** CAPI3REF: Checkpoint a database
**
-** Run a checkpoint operation on WAL database zDb attached to database
-** handle db. The specific operation is determined by the value of the
-** eMode parameter:
+** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
+** operation on database X of [database connection] D in mode M. Status
+** information is written back into integers pointed to by L and C.)^
+** ^(The M parameter must be a valid [checkpoint mode]:)^
**
** <dl>
** <dt>SQLITE_CHECKPOINT_PASSIVE<dd>
-** Checkpoint as many frames as possible without waiting for any database
-** readers or writers to finish. Sync the db file if all frames in the log
-** are checkpointed. This mode is the same as calling
-** sqlite3_wal_checkpoint(). The [sqlite3_busy_handler|busy-handler callback]
-** is never invoked.
+** ^Checkpoint as many frames as possible without waiting for any database
+** readers or writers to finish, then sync the database file if all frames
+** in the log were checkpointed. ^The [busy-handler callback]
+** is never invoked in the SQLITE_CHECKPOINT_PASSIVE mode.
+** ^On the other hand, passive mode might leave the checkpoint unfinished
+** if there are concurrent readers or writers.
**
** <dt>SQLITE_CHECKPOINT_FULL<dd>
-** This mode blocks (it invokes the
+** ^This mode blocks (it invokes the
** [sqlite3_busy_handler|busy-handler callback]) until there is no
** database writer and all readers are reading from the most recent database
-** snapshot. It then checkpoints all frames in the log file and syncs the
-** database file. This call blocks database writers while it is running,
-** but not database readers.
+** snapshot. ^It then checkpoints all frames in the log file and syncs the
+** database file. ^This mode blocks new database writers while it is pending,
+** but new database readers are allowed to continue unimpeded.
**
** <dt>SQLITE_CHECKPOINT_RESTART<dd>
-** This mode works the same way as SQLITE_CHECKPOINT_FULL, except after
-** checkpointing the log file it blocks (calls the
-** [sqlite3_busy_handler|busy-handler callback])
-** until all readers are reading from the database file only. This ensures
-** that the next client to write to the database file restarts the log file
-** from the beginning. This call blocks database writers while it is running,
-** but not database readers.
+** ^This mode works the same way as SQLITE_CHECKPOINT_FULL with the addition
+** that after checkpointing the log file it blocks (calls the
+** [busy-handler callback])
+** until all readers are reading from the database file only. ^This ensures
+** that the next writer will restart the log file from the beginning.
+** ^Like SQLITE_CHECKPOINT_FULL, this mode blocks new
+** database writer attempts while it is pending, but does not impede readers.
+**
+** <dt>SQLITE_CHECKPOINT_TRUNCATE<dd>
+** ^This mode works the same way as SQLITE_CHECKPOINT_RESTART with the
+** addition that it also truncates the log file to zero bytes just prior
+** to a successful return.
** </dl>
**
-** If pnLog is not NULL, then *pnLog is set to the total number of frames in
-** the log file before returning. If pnCkpt is not NULL, then *pnCkpt is set to
-** the total number of checkpointed frames (including any that were already
-** checkpointed when this function is called). *pnLog and *pnCkpt may be
-** populated even if sqlite3_wal_checkpoint_v2() returns other than SQLITE_OK.
-** If no values are available because of an error, they are both set to -1
-** before returning to communicate this to the caller.
-**
-** All calls obtain an exclusive "checkpoint" lock on the database file. If
+** ^If pnLog is not NULL, then *pnLog is set to the total number of frames in
+** the log file or to -1 if the checkpoint could not run because
+** of an error or because the database is not in [WAL mode]. ^If pnCkpt is not
+** NULL,then *pnCkpt is set to the total number of checkpointed frames in the
+** log file (including any that were already checkpointed before the function
+** was called) or to -1 if the checkpoint could not run due to an error or
+** because the database is not in WAL mode. ^Note that upon successful
+** completion of an SQLITE_CHECKPOINT_TRUNCATE, the log file will have been
+** truncated to zero bytes and so both *pnLog and *pnCkpt will be set to zero.
+**
+** ^All calls obtain an exclusive "checkpoint" lock on the database file. ^If
** any other process is running a checkpoint operation at the same time, the
-** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a
+** lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a
** busy-handler configured, it will not be invoked in this case.
**
-** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive
-** "writer" lock on the database file. If the writer lock cannot be obtained
-** immediately, and a busy-handler is configured, it is invoked and the writer
-** lock retried until either the busy-handler returns 0 or the lock is
-** successfully obtained. The busy-handler is also invoked while waiting for
-** database readers as described above. If the busy-handler returns 0 before
+** ^The SQLITE_CHECKPOINT_FULL, RESTART and TRUNCATE modes also obtain the
+** exclusive "writer" lock on the database file. ^If the writer lock cannot be
+** obtained immediately, and a busy-handler is configured, it is invoked and
+** the writer lock retried until either the busy-handler returns 0 or the lock
+** is successfully obtained. ^The busy-handler is also invoked while waiting for
+** database readers as described above. ^If the busy-handler returns 0 before
** the writer lock is obtained or while waiting for database readers, the
** checkpoint operation proceeds from that point in the same way as
** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible
-** without blocking any further. SQLITE_BUSY is returned in this case.
+** without blocking any further. ^SQLITE_BUSY is returned in this case.
**
-** If parameter zDb is NULL or points to a zero length string, then the
-** specified operation is attempted on all WAL databases. In this case the
-** values written to output parameters *pnLog and *pnCkpt are undefined. If
+** ^If parameter zDb is NULL or points to a zero length string, then the
+** specified operation is attempted on all WAL databases [attached] to
+** [database connection] db. In this case the
+** values written to output parameters *pnLog and *pnCkpt are undefined. ^If
** an SQLITE_BUSY error is encountered when processing one or more of the
** attached WAL databases, the operation is still attempted on any remaining
-** attached databases and SQLITE_BUSY is returned to the caller. If any other
+** attached databases and SQLITE_BUSY is returned at the end. ^If any other
** error occurs while processing an attached database, processing is abandoned
-** and the error code returned to the caller immediately. If no error
+** and the error code is returned to the caller immediately. ^If no error
** (SQLITE_BUSY or otherwise) is encountered while processing the attached
** databases, SQLITE_OK is returned.
**
-** If database zDb is the name of an attached database that is not in WAL
-** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. If
+** ^If database zDb is the name of an attached database that is not in WAL
+** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. ^If
** zDb is not NULL (or a zero length string) and is not the name of any
** attached database, SQLITE_ERROR is returned to the caller.
+**
+** ^Unless it returns SQLITE_MISUSE,
+** the sqlite3_wal_checkpoint_v2() interface
+** sets the error information that is queried by
+** [sqlite3_errcode()] and [sqlite3_errmsg()].
+**
+** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
+** from SQL.
*/
-SQLITE_API int sqlite3_wal_checkpoint_v2(
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
sqlite3 *db, /* Database handle */
const char *zDb, /* Name of attached database (or NULL) */
int eMode, /* SQLITE_CHECKPOINT_* value */
@@ -7313,16 +7423,18 @@ SQLITE_API int sqlite3_wal_checkpoint_v2(
);
/*
-** CAPI3REF: Checkpoint operation parameters
+** CAPI3REF: Checkpoint Mode Values
+** KEYWORDS: {checkpoint mode}
**
-** These constants can be used as the 3rd parameter to
-** [sqlite3_wal_checkpoint_v2()]. See the [sqlite3_wal_checkpoint_v2()]
-** documentation for additional information about the meaning and use of
-** each of these values.
+** These constants define all valid values for the "checkpoint mode" passed
+** as the third parameter to the [sqlite3_wal_checkpoint_v2()] interface.
+** See the [sqlite3_wal_checkpoint_v2()] documentation for details on the
+** meaning of each of these checkpoint modes.
*/
-#define SQLITE_CHECKPOINT_PASSIVE 0
-#define SQLITE_CHECKPOINT_FULL 1
-#define SQLITE_CHECKPOINT_RESTART 2
+#define SQLITE_CHECKPOINT_PASSIVE 0 /* Do as much as possible w/o blocking */
+#define SQLITE_CHECKPOINT_FULL 1 /* Wait for writers, then checkpoint */
+#define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for for readers */
+#define SQLITE_CHECKPOINT_TRUNCATE 3 /* Like RESTART but also truncate WAL */
/*
** CAPI3REF: Virtual Table Interface Configuration
@@ -7338,7 +7450,7 @@ SQLITE_API int sqlite3_wal_checkpoint_v2(
** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options
** may be added in the future.
*/
-SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
+SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3*, int op, ...);
/*
** CAPI3REF: Virtual Table Configuration Options
@@ -7391,7 +7503,7 @@ SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
** of the SQL statement that triggered the call to the [xUpdate] method of the
** [virtual table].
*/
-SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
+SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *);
/*
** CAPI3REF: Conflict resolution modes
@@ -7411,6 +7523,106 @@ SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
/* #define SQLITE_ABORT 4 // Also an error code */
#define SQLITE_REPLACE 5
+/*
+** CAPI3REF: Prepared Statement Scan Status Opcodes
+** KEYWORDS: {scanstatus options}
+**
+** The following constants can be used for the T parameter to the
+** [sqlite3_stmt_scanstatus(S,X,T,V)] interface. Each constant designates a
+** different metric for sqlite3_stmt_scanstatus() to return.
+**
+** When the value returned to V is a string, space to hold that string is
+** managed by the prepared statement S and will be automatically freed when
+** S is finalized.
+**
+** <dl>
+** [[SQLITE_SCANSTAT_NLOOP]] <dt>SQLITE_SCANSTAT_NLOOP</dt>
+** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be
+** set to the total number of times that the X-th loop has run.</dd>
+**
+** [[SQLITE_SCANSTAT_NVISIT]] <dt>SQLITE_SCANSTAT_NVISIT</dt>
+** <dd>^The [sqlite3_int64] variable pointed to by the T parameter will be set
+** to the total number of rows examined by all iterations of the X-th loop.</dd>
+**
+** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt>
+** <dd>^The "double" variable pointed to by the T parameter will be set to the
+** query planner's estimate for the average number of rows output from each
+** iteration of the X-th loop. If the query planner's estimates was accurate,
+** then this value will approximate the quotient NVISIT/NLOOP and the
+** product of this value for all prior loops with the same SELECTID will
+** be the NLOOP value for the current loop.
+**
+** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt>
+** <dd>^The "const char *" variable pointed to by the T parameter will be set
+** to a zero-terminated UTF-8 string containing the name of the index or table
+** used for the X-th loop.
+**
+** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt>
+** <dd>^The "const char *" variable pointed to by the T parameter will be set
+** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN]
+** description for the X-th loop.
+**
+** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECT</dt>
+** <dd>^The "int" variable pointed to by the T parameter will be set to the
+** "select-id" for the X-th loop. The select-id identifies which query or
+** subquery the loop is part of. The main query has a select-id of zero.
+** The select-id is the same value as is output in the first column
+** of an [EXPLAIN QUERY PLAN] query.
+** </dl>
+*/
+#define SQLITE_SCANSTAT_NLOOP 0
+#define SQLITE_SCANSTAT_NVISIT 1
+#define SQLITE_SCANSTAT_EST 2
+#define SQLITE_SCANSTAT_NAME 3
+#define SQLITE_SCANSTAT_EXPLAIN 4
+#define SQLITE_SCANSTAT_SELECTID 5
+
+/*
+** CAPI3REF: Prepared Statement Scan Status
+**
+** This interface returns information about the predicted and measured
+** performance for pStmt. Advanced applications can use this
+** interface to compare the predicted and the measured performance and
+** issue warnings and/or rerun [ANALYZE] if discrepancies are found.
+**
+** Since this interface is expected to be rarely used, it is only
+** available if SQLite is compiled using the [SQLITE_ENABLE_STMT_SCANSTATUS]
+** compile-time option.
+**
+** The "iScanStatusOp" parameter determines which status information to return.
+** The "iScanStatusOp" must be one of the [scanstatus options] or the behavior
+** of this interface is undefined.
+** ^The requested measurement is written into a variable pointed to by
+** the "pOut" parameter.
+** Parameter "idx" identifies the specific loop to retrieve statistics for.
+** Loops are numbered starting from zero. ^If idx is out of range - less than
+** zero or greater than or equal to the total number of loops used to implement
+** the statement - a non-zero value is returned and the variable that pOut
+** points to is unchanged.
+**
+** ^Statistics might not be available for all loops in all statements. ^In cases
+** where there exist loops with no available statistics, this function behaves
+** as if the loop did not exist - it returns non-zero and leave the variable
+** that pOut points to unchanged.
+**
+** See also: [sqlite3_stmt_scanstatus_reset()]
+*/
+SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_stmt_scanstatus(
+ sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
+ int idx, /* Index of loop to report on */
+ int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
+ void *pOut /* Result written here */
+);
+
+/*
+** CAPI3REF: Zero Scan-Status Counters
+**
+** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
+**
+** This API is only available if the library is built with pre-processor
+** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
+*/
+SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
/*
@@ -7465,7 +7677,7 @@ typedef struct sqlite3_rtree_query_info sqlite3_rtree_query_info;
**
** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
*/
-SQLITE_API int sqlite3_rtree_geometry_callback(
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
sqlite3 *db,
const char *zGeom,
int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
@@ -7491,7 +7703,7 @@ struct sqlite3_rtree_geometry {
**
** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
*/
-SQLITE_API int sqlite3_rtree_query_callback(
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
sqlite3 *db,
const char *zQueryFunc,
int (*xQueryFunc)(sqlite3_rtree_query_info*),
diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c
index b163081..c8ca0bf 100644
--- a/contrib/tcpdump/tcpdump.c
+++ b/contrib/tcpdump/tcpdump.c
@@ -1921,8 +1921,6 @@ main(int argc, char **argv)
#endif
if (cansandbox && cap_enter() < 0 && errno != ENOSYS)
error("unable to enter the capability mode");
- if (cap_sandboxed())
- fprintf(stderr, "capability mode sandbox enabled\n");
#endif /* __FreeBSD__ */
do {
diff --git a/contrib/tzdata/africa b/contrib/tzdata/africa
index 1b9bf50..ea0171a 100644
--- a/contrib/tzdata/africa
+++ b/contrib/tzdata/africa
@@ -319,35 +319,29 @@ Rule Egypt 2007 only - Sep Thu>=1 24:00 0 -
# above) says DST had no affect on electricity consumption. There is
# no information about when DST will end this fall. See:
# http://abcnews.go.com/International/wireStory/el-sissi-pushes-egyptians-line-23614833
+
+# From Steffen Thorsen (2015-04-08):
+# Egypt will start DST on midnight after Thursday, April 30, 2015.
+# This is based on a law (no 35) from May 15, 2014 saying it starts the last
+# Thursday of April.... Clocks will still be turned back for Ramadan, but
+# dates not yet announced....
+# http://almogaz.com/news/weird-news/2015/04/05/1947105 ...
+# http://www.timeanddate.com/news/time/egypt-starts-dst-2015.html
+
+# From Ahmed Nazmy (2015-04-20):
+# Egypt's ministers cabinet just announced ... that it will cancel DST at
+# least for 2015.
#
-# For now, guess that later spring and fall transitions will use
-# 2010's rules, and guess that Egypt will switch to standard time at
-# 24:00 the last Thursday before Ramadan, and back to DST at 00:00 the
-# first Friday after Ramadan. To implement this,
-# transition dates for 2015 through 2037 were determined by running
-# the following program under GNU Emacs 24.3, with the results integrated
-# by hand into the table below. Ramadan again intrudes on the guessed
-# DST starting in 2038, but that's beyond our somewhat-arbitrary cutoff.
-# (let ((islamic-year 1436))
-# (while (< islamic-year 1460)
-# (let ((a (calendar-islamic-to-absolute (list 9 1 islamic-year)))
-# (b (calendar-islamic-to-absolute (list 10 1 islamic-year)))
-# (friday 5))
-# (while (/= friday (mod a 7))
-# (setq a (1- a)))
-# (while (/= friday (mod b 7))
-# (setq b (1+ b)))
-# (setq a (1- a))
-# (setq b (1- b))
-# (setq a (calendar-gregorian-from-absolute a))
-# (setq b (calendar-gregorian-from-absolute b))
-# (insert
-# (format
-# (concat "Rule\tEgypt\t%d\tonly\t-\t%s\t%2d\t24:00\t0\t-\n"
-# "Rule\tEgypt\t%d\tonly\t-\t%s\t%2d\t24:00\t1:00\tS\n")
-# (car (cdr (cdr a))) (calendar-month-name (car a) t) (car (cdr a))
-# (car (cdr (cdr b))) (calendar-month-name (car b) t) (car (cdr b)))))
-# (setq islamic-year (+ 1 islamic-year))))
+# From Tim Parenti (2015-04-20):
+# http://english.ahram.org.eg/WriterArticles/NewsContentP/1/128195/Egypt/No-daylight-saving-this-summer-Egypts-prime-minist.aspx
+# "Egypt's cabinet agreed on Monday not to switch clocks for daylight saving
+# time this summer, and carry out studies on the possibility of canceling the
+# practice altogether in future years."
+#
+# From Paul Eggert (2015-04-20):
+# For now, assume DST will be canceled. Any resumption would likely
+# use different rules anyway.
+
Rule Egypt 2008 only - Aug lastThu 24:00 0 -
Rule Egypt 2009 only - Aug 20 24:00 0 -
Rule Egypt 2010 only - Aug 10 24:00 0 -
@@ -356,22 +350,7 @@ Rule Egypt 2010 only - Sep lastThu 24:00 0 -
Rule Egypt 2014 only - May 15 24:00 1:00 S
Rule Egypt 2014 only - Jun 26 24:00 0 -
Rule Egypt 2014 only - Jul 31 24:00 1:00 S
-Rule Egypt 2014 max - Sep lastThu 24:00 0 -
-Rule Egypt 2015 2019 - Apr lastFri 0:00s 1:00 S
-Rule Egypt 2015 only - Jun 11 24:00 0 -
-Rule Egypt 2015 only - Jul 23 24:00 1:00 S
-Rule Egypt 2016 only - Jun 2 24:00 0 -
-Rule Egypt 2016 only - Jul 7 24:00 1:00 S
-Rule Egypt 2017 only - May 25 24:00 0 -
-Rule Egypt 2017 only - Jun 29 24:00 1:00 S
-Rule Egypt 2018 only - May 10 24:00 0 -
-Rule Egypt 2018 only - Jun 14 24:00 1:00 S
-Rule Egypt 2019 only - May 2 24:00 0 -
-Rule Egypt 2019 only - Jun 6 24:00 1:00 S
-Rule Egypt 2020 only - May 28 24:00 1:00 S
-Rule Egypt 2021 only - May 13 24:00 1:00 S
-Rule Egypt 2022 only - May 5 24:00 1:00 S
-Rule Egypt 2023 max - Apr lastFri 0:00s 1:00 S
+Rule Egypt 2014 only - Sep lastThu 24:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Africa/Cairo 2:05:09 - LMT 1900 Oct
diff --git a/contrib/tzdata/antarctica b/contrib/tzdata/antarctica
index ebae994..2af088f 100644
--- a/contrib/tzdata/antarctica
+++ b/contrib/tzdata/antarctica
@@ -15,41 +15,6 @@
# I made up all time zone abbreviations mentioned here; corrections welcome!
# FORMAT is 'zzz' and GMTOFF is 0 for locations while uninhabited.
-# These rules are stolen from the 'southamerica' file.
-# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
-Rule ArgAQ 1964 1966 - Mar 1 0:00 0 -
-Rule ArgAQ 1964 1966 - Oct 15 0:00 1:00 S
-Rule ArgAQ 1967 only - Apr 2 0:00 0 -
-Rule ArgAQ 1967 1968 - Oct Sun>=1 0:00 1:00 S
-Rule ArgAQ 1968 1969 - Apr Sun>=1 0:00 0 -
-Rule ArgAQ 1974 only - Jan 23 0:00 1:00 S
-Rule ArgAQ 1974 only - May 1 0:00 0 -
-Rule ChileAQ 1972 1986 - Mar Sun>=9 3:00u 0 -
-Rule ChileAQ 1974 1987 - Oct Sun>=9 4:00u 1:00 S
-Rule ChileAQ 1987 only - Apr 12 3:00u 0 -
-Rule ChileAQ 1988 1989 - Mar Sun>=9 3:00u 0 -
-Rule ChileAQ 1988 only - Oct Sun>=1 4:00u 1:00 S
-Rule ChileAQ 1989 only - Oct Sun>=9 4:00u 1:00 S
-Rule ChileAQ 1990 only - Mar 18 3:00u 0 -
-Rule ChileAQ 1990 only - Sep 16 4:00u 1:00 S
-Rule ChileAQ 1991 1996 - Mar Sun>=9 3:00u 0 -
-Rule ChileAQ 1991 1997 - Oct Sun>=9 4:00u 1:00 S
-Rule ChileAQ 1997 only - Mar 30 3:00u 0 -
-Rule ChileAQ 1998 only - Mar Sun>=9 3:00u 0 -
-Rule ChileAQ 1998 only - Sep 27 4:00u 1:00 S
-Rule ChileAQ 1999 only - Apr 4 3:00u 0 -
-Rule ChileAQ 1999 2010 - Oct Sun>=9 4:00u 1:00 S
-Rule ChileAQ 2000 2007 - Mar Sun>=9 3:00u 0 -
-# N.B.: the end of March 29 in Chile is March 30 in Universal time,
-# which is used below in specifying the transition.
-Rule ChileAQ 2008 only - Mar 30 3:00u 0 -
-Rule ChileAQ 2009 only - Mar Sun>=9 3:00u 0 -
-Rule ChileAQ 2010 only - Apr Sun>=1 3:00u 0 -
-Rule ChileAQ 2011 only - May Sun>=2 3:00u 0 -
-Rule ChileAQ 2011 only - Aug Sun>=16 4:00u 1:00 S
-Rule ChileAQ 2012 2015 - Apr Sun>=23 3:00u 0 -
-Rule ChileAQ 2012 2014 - Sep Sun>=2 4:00u 1:00 S
-
# Argentina - year-round bases
# Belgrano II, Confin Coast, -770227-0343737, since 1972-02-05
# Carlini, Potter Cove, King George Island, -6414-0602320, since 1982-01
@@ -344,21 +309,7 @@ Zone Antarctica/Rothera 0 - zzz 1976 Dec 1
# USA - year-round bases
#
# Palmer, Anvers Island, since 1965 (moved 2 miles in 1968)
-#
-# From Ethan Dicks (1996-10-06):
-# It keeps the same time as Punta Arenas, Chile, because, just like us
-# and the South Pole, that's the other end of their supply line....
-# I verified with someone who was there that since 1980,
-# Palmer has followed Chile. Prior to that, before the Falklands War,
-# Palmer used to be supplied from Argentina.
-#
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Antarctica/Palmer 0 - zzz 1965
- -4:00 ArgAQ AR%sT 1969 Oct 5
- -3:00 ArgAQ AR%sT 1982 May
- -4:00 ChileAQ CL%sT 2015 Apr 26 3:00u
- -3:00 - CLT
-#
+# See 'southamerica' for Antarctica/Palmer, since it uses South American DST.
#
# McMurdo Station, Ross Island, since 1955-12
# Amundsen-Scott South Pole Station, continuously occupied since 1956-11-20
diff --git a/contrib/tzdata/backward b/contrib/tzdata/backward
index 3ceda88..8b0fef5 100644
--- a/contrib/tzdata/backward
+++ b/contrib/tzdata/backward
@@ -20,6 +20,7 @@ Link America/Argentina/Jujuy America/Jujuy
Link America/Indiana/Knox America/Knox_IN
Link America/Kentucky/Louisville America/Louisville
Link America/Argentina/Mendoza America/Mendoza
+Link America/Toronto America/Montreal
Link America/Rio_Branco America/Porto_Acre
Link America/Argentina/Cordoba America/Rosario
Link America/Denver America/Shiprock
diff --git a/contrib/tzdata/europe b/contrib/tzdata/europe
index 4109723..c64c41b 100644
--- a/contrib/tzdata/europe
+++ b/contrib/tzdata/europe
@@ -76,7 +76,7 @@
# 1:00:14 SET Swedish (1879-1899)*
# 2:00 EET EEST Eastern Europe
# 3:00 FET Further-eastern Europe (2011-2014)*
-# 3:00 MSK MSD MSM* Moscow
+# 3:00 MSK MSD MSM* Minsk, Moscow
# From Peter Ilieve (1994-12-04),
# The original six [EU members]: Belgium, France, (West) Germany, Italy,
diff --git a/contrib/tzdata/northamerica b/contrib/tzdata/northamerica
index 77463da..c3af9eb 100644
--- a/contrib/tzdata/northamerica
+++ b/contrib/tzdata/northamerica
@@ -227,9 +227,14 @@ Zone PST8PDT -8:00 US P%sT
# The law doesn't give abbreviations.
#
# From Paul Eggert (2000-01-08), following a heads-up from Rives McDow:
-# Public law 106-564 (2000-12-23) introduced the abbreviation
-# "Chamorro Standard Time" for time in Guam and the Northern Marianas.
-# See the file "australasia".
+# Public law 106-564 (2000-12-23) introduced ... "Chamorro Standard Time"
+# for time in Guam and the Northern Marianas. See the file "australasia".
+#
+# From Paul Eggert (2015-04-17):
+# HST and HDT are standardized abbreviations for Hawaii-Aleutian
+# standard and daylight times. See section 9.47 (p 234) of the
+# U.S. Government Printing Office Style Manual (2008)
+# http://www.gpo.gov/fdsys/pkg/GPO-STYLEMANUAL-2008/pdf/GPO-STYLEMANUAL-2008.pdf
# From Arthur David Olson, 2005-08-09
# The following was signed into law on 2005-08-08.
@@ -536,7 +541,7 @@ Zone America/Adak 12:13:21 - LMT 1867 Oct 18
-11:00 - BST 1969
-11:00 US B%sT 1983 Oct 30 2:00
-10:00 US AH%sT 1983 Nov 30
- -10:00 US HA%sT
+ -10:00 US H%sT
# The following switches don't quite make our 1970 cutoff.
#
# Shanks writes that part of southwest Alaska (e.g. Aniak)
@@ -1331,14 +1336,9 @@ Zone America/Moncton -4:19:08 - LMT 1883 Dec 9
# Quebec
-# From Paul Eggert (2013-08-30):
-# Since 1970 most of Quebec has been like Toronto.
-# However, because earlier versions of the tz database mistakenly relied on data
-# from Shanks & Pottenger saying that Quebec differed from Ontario after 1970,
-# a separate entry was created for most of Quebec. We're loath to lose
-# its pre-1970 info, even though the tz database is normally limited to
-# zones that differ after 1970, so keep this otherwise out-of-scope entry.
-
+# From Paul Eggert (2015-03-24):
+# See America/Toronto for most of Quebec, including Montreal.
+#
# Matthews and Vincent (1998) also write that Quebec east of the -63
# meridian is supposed to observe AST, but residents as far east as
# Natashquan use EST/EDT, and residents east of Natashquan use AST.
@@ -1352,39 +1352,10 @@ Zone America/Moncton -4:19:08 - LMT 1883 Dec 9
# For lack of better info, guess this practice began around 1970, contra to
# Shanks & Pottenger who have this region observing AST/ADT.
-# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
-Rule Mont 1917 only - Mar 25 2:00 1:00 D
-Rule Mont 1917 only - Apr 24 0:00 0 S
-Rule Mont 1919 only - Mar 31 2:30 1:00 D
-Rule Mont 1919 only - Oct 25 2:30 0 S
-Rule Mont 1920 only - May 2 2:30 1:00 D
-Rule Mont 1920 1922 - Oct Sun>=1 2:30 0 S
-Rule Mont 1921 only - May 1 2:00 1:00 D
-Rule Mont 1922 only - Apr 30 2:00 1:00 D
-Rule Mont 1924 only - May 17 2:00 1:00 D
-Rule Mont 1924 1926 - Sep lastSun 2:30 0 S
-Rule Mont 1925 1926 - May Sun>=1 2:00 1:00 D
-Rule Mont 1927 1937 - Apr lastSat 24:00 1:00 D
-Rule Mont 1927 1937 - Sep lastSat 24:00 0 S
-Rule Mont 1938 1940 - Apr lastSun 0:00 1:00 D
-Rule Mont 1938 1939 - Sep lastSun 0:00 0 S
-Rule Mont 1946 1973 - Apr lastSun 2:00 1:00 D
-Rule Mont 1945 1948 - Sep lastSun 2:00 0 S
-Rule Mont 1949 1950 - Oct lastSun 2:00 0 S
-Rule Mont 1951 1956 - Sep lastSun 2:00 0 S
-Rule Mont 1957 1973 - Oct lastSun 2:00 0 S
-
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone America/Blanc-Sablon -3:48:28 - LMT 1884
-4:00 Canada A%sT 1970
-4:00 - AST
-Zone America/Montreal -4:54:16 - LMT 1884
- -5:00 Mont E%sT 1918
- -5:00 Canada E%sT 1919
- -5:00 Mont E%sT 1942 Feb 9 2:00s
- -5:00 Canada E%sT 1946
- -5:00 Mont E%sT 1974
- -5:00 Canada E%sT
# Ontario
@@ -1875,17 +1846,115 @@ Zone America/Creston -7:46:04 - LMT 1884
# Dawson switched to PST in 1973. Inuvik switched to MST in 1979.
# Mathew Englander (1996-10-07) gives the following refs:
# * 1967. Paragraph 28(34)(g) of the Interpretation Act, S.C. 1967-68,
-# c. 7 defines Yukon standard time as UTC-9. This is still valid;
+# c. 7 defines Yukon standard time as UTC-9....
# see Interpretation Act, R.S.C. 1985, c. I-21, s. 35(1).
+# [http://canlii.ca/t/7vhg]
# * C.O. 1973/214 switched Yukon to PST on 1973-10-28 00:00.
# * O.I.C. 1980/02 established DST.
# * O.I.C. 1987/056 changed DST to Apr firstSun 2:00 to Oct lastSun 2:00.
-# Shanks & Pottenger say Yukon's 1973-10-28 switch was at 2:00; go
-# with Englander.
-# From Chris Walton (2006-06-26):
-# Here is a link to the old daylight saving portion of the interpretation
-# act which was last updated in 1987:
-# http://www.gov.yk.ca/legislation/regs/oic1987_056.pdf
+
+# From Brian Inglis (2015-04-14):
+#
+# I tried to trace the history of Yukon time and found the following
+# regulations, giving the reference title and URL if found, regulation name,
+# and relevant quote if available. Each regulation specifically revokes its
+# predecessor. The final reference is to the current Interpretation Act
+# authorizing and resulting from these regulatory changes.
+#
+# Only recent regulations were retrievable via Yukon government site search or
+# index, and only some via Canadian legal sources. Other sources used include
+# articles titled "Standard Time and Time Zones in Canada" from JRASC via ADS
+# Abstracts, cited by ADO for 1932 ..., and updated versions from 1958 and
+# 1970 quoted below; each article includes current extracts from provincial
+# and territorial ST and DST regulations at the end, summaries and details of
+# standard times and daylight saving time at many locations across Canada,
+# with time zone maps, tables and calculations for Canadian Sunrise, Sunset,
+# and LMST; they also cover many countries and global locations, with a chart
+# and table showing current Universal Time offsets, and may be useful as
+# another source of information for 1970 and earlier.
+#
+# * Standard Time and Time Zones in Canada; Smith, C.C.; JRASC, Vol. 26,
+# pp.49-77; February 1932; SAO/NASA Astrophysics Data System (ADS)
+# http://adsabs.harvard.edu/abs/1932JRASC..26...49S from p.75:
+# Yukon Interpretation Ordinance
+# Yukon standard time is the local mean time at the one hundred and
+# thirty-fifth meridian.
+#
+# * Standard Time and Time Zones in Canada; Smith, C.C.; Thomson, Malcolm M.;
+# JRASC, Vol. 52, pp.193-223; October 1958; SAO/NASA Astrophysics Data System
+# (ADS) http://adsabs.harvard.edu/abs/1958JRASC..52..193S from pp.220-1:
+# Yukon Interpretation Ordinance, 1955, Chap. 16.
+#
+# (1) Subject to this section, standard time shall be reckoned as nine
+# hours behind Greenwich Time and called Yukon Standard Time.
+#
+# (2) Notwithstanding subsection (1), the Commissioner may make regulations
+# varying the manner of reckoning standard time.
+#
+# * Yukon Territory Commissioner's Order 1966-20 Interpretation Ordinance
+# http://? - no online source found
+#
+# * Standard Time and Time Zones in Canada; Thomson, Malcolm M.; JRASC,
+# Vol. 64, pp.129-162; June 1970; SAO/NASA Astrophysics Data System (ADS)
+# http://adsabs.harvard.edu/abs/1970JRASC..64..129T from p.156: Yukon
+# Territory Commissioner's Order 1967-59 Interpretation Ordinance ...
+#
+# 1. Commissioner's Order 1966-20 dated at Whitehorse in the Yukon
+# Territory on 27th January, 1966, is hereby revoked.
+#
+# 2. Yukon (East) Standard Time as defined by section 36 of the
+# Interpretation Ordinance from and after mid-night on the 28th day of May,
+# 1967 shall be reckoned in the same manner as Pacific Standard Time, that
+# is to say, eight hours behind Greenwich Time in the area of the Yukon
+# Territory lying east of the 138th degree longitude west.
+#
+# 3. In the remainder of the Territory, lying west of the 138th degree
+# longitude west, Yukon (West) Standard Time shall be reckoned as nine
+# hours behind Greenwich Time.
+#
+# * Yukon Standard Time defined as Pacific Standard Time, YCO 1973/214
+# http://www.canlii.org/en/yk/laws/regu/yco-1973-214/latest/yco-1973-214.html
+# C.O. 1973/214 INTERPRETATION ACT ...
+#
+# 1. Effective October 28, 1973 Commissioner's Order 1967/59 is hereby
+# revoked.
+#
+# 2. Yukon Standard Time as defined by section 36 of the Interpretation
+# Act from and after midnight on the twenty-eighth day of October, 1973
+# shall be reckoned in the same manner as Pacific Standard Time, that is
+# to say eight hours behind Greenwich Time.
+#
+# * O.I.C. 1980/02 INTERPRETATION ACT
+# http://? - no online source found
+#
+# * Yukon Daylight Saving Time, YOIC 1987/56
+# http://www.canlii.org/en/yk/laws/regu/yoic-1987-56/latest/yoic-1987-56.html
+# O.I.C. 1987/056 INTERPRETATION ACT ...
+#
+# In every year between
+# (a) two o'clock in the morning in the first Sunday in April, and
+# (b) two o'clock in the morning in the last Sunday in October,
+# Standard Time shall be reckoned as seven hours behind Greenwich Time and
+# called Yukon Daylight Saving Time.
+# ...
+# Dated ... 9th day of March, A.D., 1987.
+#
+# * Yukon Daylight Saving Time 2006, YOIC 2006/127
+# http://www.canlii.org/en/yk/laws/regu/yoic-2006-127/latest/yoic-2006-127.html
+# O.I.C. 2006/127 INTERPRETATION ACT ...
+#
+# 1. In Yukon each year the time for general purposes shall be 7 hours
+# behind Greenwich mean time during the period commencing at two o'clock
+# in the forenoon on the second Sunday of March and ending at two o'clock
+# in the forenoon on the first Sunday of November and shall be called
+# Yukon Daylight Saving Time.
+#
+# 2. Order-in-Council 1987/56 is revoked.
+#
+# 3. This order comes into force January 1, 2007.
+#
+# * Interpretation Act, RSY 2002, c 125
+# http://www.canlii.org/en/yk/laws/stat/rsy-2002-c-125/latest/rsy-2002-c-125.html
# From Rives McDow (1999-09-04):
# Nunavut ... moved ... to incorporate the whole territory into one time zone.
@@ -2111,7 +2180,7 @@ Zone America/Inuvik 0 - zzz 1953 # Inuvik founded
-7:00 NT_YK M%sT 1980
-7:00 Canada M%sT
Zone America/Whitehorse -9:00:12 - LMT 1900 Aug 20
- -9:00 NT_YK Y%sT 1966 Jul 1 2:00
+ -9:00 NT_YK Y%sT 1967 May 28 0:00
-8:00 NT_YK P%sT 1980
-8:00 Canada P%sT
Zone America/Dawson -9:17:40 - LMT 1900 Aug 20
diff --git a/contrib/tzdata/southamerica b/contrib/tzdata/southamerica
index 77e3584..be63a88 100644
--- a/contrib/tzdata/southamerica
+++ b/contrib/tzdata/southamerica
@@ -1098,6 +1098,60 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914
# Chile
+# From Paul Eggert (2015-04-03):
+# Shanks & Pottenger says America/Santiago introduced standard time in
+# 1890 and rounds its UTC offset to 70W40; guess that in practice this
+# was the same offset as in 1916-1919. It also says Pacific/Easter
+# standardized on 109W22 in 1890; assume this didn't change the clocks.
+#
+# Dates for America/Santiago from 1910 to 2004 are primarily from
+# the following source, cited by Oscar van Vlijmen (2006-10-08):
+# [1] Chile Law
+# http://www.webexhibits.org/daylightsaving/chile.html
+# This contains a copy of a this official table:
+# Cambios en la hora oficial de Chile desde 1900 (retrieved 2008-03-30)
+# http://web.archive.org/web/20080330200901/http://www.horaoficial.cl/cambio.htm
+# [1] needs several corrections, though.
+#
+# The first set of corrections is from:
+# [2] History of the Official Time of Chile
+# http://www.horaoficial.cl/ing/horaof_ing.html (retrieved 2012-03-06). See:
+# http://web.archive.org/web/20120306042032/http://www.horaoficial.cl/ing/horaof_ing.html
+# This is an English translation of:
+# Historia de la hora oficial de Chile (retrieved 2012-10-24). See:
+# http://web.archive.org/web/20121024234627/http://www.horaoficial.cl/horaof.htm
+# A fancier Spanish version (requiring mouse-clicking) is at:
+# http://www.horaoficial.cl/historia_hora.html
+# Conflicts between [1] and [2] were resolved as follows:
+#
+# - [1] says the 1910 transition was Jan 1, [2] says Jan 10 and cites
+# Boletín Nº 1, Aviso Nº 1 (1910). Go with [2].
+#
+# - [1] says SMT was -4:42:45, [2] says Chile's official time from
+# 1916 to 1919 was -4:42:46.3, the meridian of Chile's National
+# Astronomical Observatory (OAN), then located in what is now
+# Quinta Normal in Santiago. Go with [2], rounding it to -4:42:46.
+#
+# - [1] says the 1918 transition was Sep 1, [2] says Sep 10 and cites
+# Boletín Nº 22, Aviso Nº 129/1918 (1918-08-23). Go with [2].
+#
+# - [1] does not give times for transitions; assume they occur
+# at midnight mainland time, the current common practice. However,
+# go with [2]'s specification of 23:00 for the 1947-05-21 transition.
+#
+# Another correction to [1] is from Jesper Nørgaard Welen, who
+# wrote (2006-10-08), "I think that there are some obvious mistakes in
+# the suggested link from Oscar van Vlijmen,... for instance entry 66
+# says that GMT-4 ended 1990-09-12 while entry 67 only begins GMT-3 at
+# 1990-09-15 (they should have been 1990-09-15 and 1990-09-16
+# respectively), but anyhow it clears up some doubts too."
+#
+# Data for Pacific/Easter from 1910 through 1967 come from Shanks &
+# Pottenger. After that, for lack of better info assume
+# Pacific/Easter is always two hours behind America/Santiago;
+# this is known to work for DST transitions starting in 2008 and
+# may well be true for earlier transitions.
+
# From Eduardo Krell (1995-10-19):
# The law says to switch to DST at midnight [24:00] on the second SATURDAY
# of October.... The law is the same for March and October.
@@ -1110,78 +1164,35 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914
# Because of the same drought, the government decided to end DST later,
# on April 3, (one-time change).
-# From Oscar van Vlijmen (2006-10-08):
-# http://www.horaoficial.cl/cambio.htm
-
-# From Jesper Nørgaard Welen (2006-10-08):
-# I think that there are some obvious mistakes in the suggested link
-# from Oscar van Vlijmen,... for instance entry 66 says that GMT-4
-# ended 1990-09-12 while entry 67 only begins GMT-3 at 1990-09-15
-# (they should have been 1990-09-15 and 1990-09-16 respectively), but
-# anyhow it clears up some doubts too.
-
-# From Paul Eggert (2014-08-12):
-# The following data entries for Chile and America/Santiago are from
-# <http://www.horaoficial.cl/horaof.htm> (2006-09-20), transcribed by
-# Jesper Nørgaard Welen. The data entries for Pacific/Easter are from Shanks
-# & Pottenger, except with DST transitions after 1932 cloned from
-# America/Santiago. The pre-1980 Pacific/Easter data entries are dubious,
-# but we have no other source.
-
# From Germán Poo-Caamaño (2008-03-03):
# Due to drought, Chile extends Daylight Time in three weeks. This
# is one-time change (Saturday 3/29 at 24:00 for America/Santiago
# and Saturday 3/29 at 22:00 for Pacific/Easter)
# The Supreme Decree is located at
# http://www.shoa.cl/servicios/supremo316.pdf
-# and the instructions for 2008 are located in:
-# http://www.horaoficial.cl/cambio.htm
-
+#
# From José Miguel Garrido (2008-03-05):
-# ...
-# You could see the announces of the change on
# http://www.shoa.cl/noticias/2008/04hora/hora.htm
# From Angel Chiang (2010-03-04):
# Subject: DST in Chile exceptionally extended to 3 April due to earthquake
# http://www.gobiernodechile.cl/viewNoticia.aspx?idArticulo=30098
-# (in Spanish, last paragraph).
#
-# This is breaking news. There should be more information available later.
-
# From Arthur David Olson (2010-03-06):
# Angel Chiang's message confirmed by Julio Pacheco; Julio provided a patch.
-# From Glenn Eychaner (2011-03-02):
-# It appears that the Chilean government has decided to postpone the
-# change from summer time to winter time again, by three weeks to April
-# 2nd:
-# http://www.emol.com/noticias/nacional/detalle/detallenoticias.asp?idnoticia=467651
-#
-# This is not yet reflected in the official "cambio de hora" site, but
-# probably will be soon:
-# http://www.horaoficial.cl/cambio.htm
-
-# From Arthur David Olson (2011-03-02):
-# The emol.com article mentions a water shortage as the cause of the
-# postponement, which may mean that it's not a permanent change.
-
# From Glenn Eychaner (2011-03-28):
-# The article:
# http://diario.elmercurio.com/2011/03/28/_portada/_portada/noticias/7565897A-CA86-49E6-9E03-660B21A4883E.htm?id=3D{7565897A-CA86-49E6-9E03-660B21A4883E}
-#
# In English:
# Chile's clocks will go back an hour this year on the 7th of May instead
# of this Saturday. They will go forward again the 3rd Saturday in
-# August, not in October as they have since 1968. This is a pilot plan
-# which will be reevaluated in 2012.
+# August, not in October as they have since 1968.
# From Mauricio Parada (2012-02-22), translated by Glenn Eychaner (2012-02-23):
# As stated in the website of the Chilean Energy Ministry
# http://www.minenergia.cl/ministerio/noticias/generales/gobierno-anuncia-fechas-de-cambio-de.html
# The Chilean Government has decided to postpone the entrance into winter time
-# (to leave DST) from March 11 2012 to April 28th 2012. The decision has not
-# been yet formalized but it will within the next days.
+# (to leave DST) from March 11 2012 to April 28th 2012....
# Quote from the website communication:
#
# 6. For the year 2012, the dates of entry into winter time will be as follows:
@@ -1214,17 +1225,9 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914
# From Paul Eggert (2015-03-03):
# For now, assume that the extension will persist indefinitely.
-# NOTE: ChileAQ rules for Antarctic bases are stored separately in the
-# 'antarctica' file.
-
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
-Rule Chile 1927 1932 - Sep 1 0:00 1:00 S
+Rule Chile 1927 1931 - Sep 1 0:00 1:00 S
Rule Chile 1928 1932 - Apr 1 0:00 0 -
-Rule Chile 1942 only - Jun 1 4:00u 0 -
-Rule Chile 1942 only - Aug 1 5:00u 1:00 S
-Rule Chile 1946 only - Jul 15 4:00u 1:00 S
-Rule Chile 1946 only - Sep 1 3:00u 0:00 -
-Rule Chile 1947 only - Apr 1 4:00u 0 -
Rule Chile 1968 only - Nov 3 4:00u 1:00 S
Rule Chile 1969 only - Mar 30 3:00u 0 -
Rule Chile 1969 only - Nov 23 4:00u 1:00 S
@@ -1235,10 +1238,8 @@ Rule Chile 1972 1986 - Mar Sun>=9 3:00u 0 -
Rule Chile 1973 only - Sep 30 4:00u 1:00 S
Rule Chile 1974 1987 - Oct Sun>=9 4:00u 1:00 S
Rule Chile 1987 only - Apr 12 3:00u 0 -
-Rule Chile 1988 1989 - Mar Sun>=9 3:00u 0 -
-Rule Chile 1988 only - Oct Sun>=1 4:00u 1:00 S
-Rule Chile 1989 only - Oct Sun>=9 4:00u 1:00 S
-Rule Chile 1990 only - Mar 18 3:00u 0 -
+Rule Chile 1988 1990 - Mar Sun>=9 3:00u 0 -
+Rule Chile 1988 1989 - Oct Sun>=9 4:00u 1:00 S
Rule Chile 1990 only - Sep 16 4:00u 1:00 S
Rule Chile 1991 1996 - Mar Sun>=9 3:00u 0 -
Rule Chile 1991 1997 - Oct Sun>=9 4:00u 1:00 S
@@ -1261,15 +1262,21 @@ Rule Chile 2012 2014 - Sep Sun>=2 4:00u 1:00 S
# (1996-09) says 1998-03-08. Ignore these.
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone America/Santiago -4:42:46 - LMT 1890
- -4:42:46 - SMT 1910 # Santiago Mean Time
+ -4:42:46 - SMT 1910 Jan 10 # Santiago Mean Time
-5:00 - CLT 1916 Jul 1 # Chile Time
- -4:42:46 - SMT 1918 Sep 1 # Santiago Mean Time
- -4:00 - CLT 1919 Jul 1 # Chile Time
- -4:42:46 - SMT 1927 Sep 1 # Santiago Mean Time
- -5:00 Chile CL%sT 1947 May 22 # Chile Time
+ -4:42:46 - SMT 1918 Sep 10
+ -4:00 - CLT 1919 Jul 1
+ -4:42:46 - SMT 1927 Sep 1
+ -5:00 Chile CL%sT 1932 Sep 1
+ -4:00 - CLT 1942 Jun 1
+ -5:00 - CLT 1942 Aug 1
+ -4:00 - CLT 1946 Jul 15
+ -4:00 1:00 CLST 1946 Sep 1 # central Chile
+ -4:00 - CLT 1947 Apr 1
+ -5:00 - CLT 1947 May 21 23:00
-4:00 Chile CL%sT 2015 Apr 26 3:00u
-3:00 - CLT
-Zone Pacific/Easter -7:17:44 - LMT 1890
+Zone Pacific/Easter -7:17:28 - LMT 1890
-7:17:28 - EMT 1932 Sep # Easter Mean Time
-7:00 Chile EAS%sT 1982 Mar 14 3:00u # Easter Time
-6:00 Chile EAS%sT 2015 Apr 26 3:00u
@@ -1279,6 +1286,25 @@ Zone Pacific/Easter -7:17:44 - LMT 1890
# Other Chilean locations, including Juan Fernández Is, Desventuradas Is,
# and Antarctic bases, are like America/Santiago.
+# Antarctic base using South American rules
+# (See the file 'antarctica' for more.)
+#
+# Palmer, Anvers Island, since 1965 (moved 2 miles in 1968)
+#
+# From Ethan Dicks (1996-10-06):
+# It keeps the same time as Punta Arenas, Chile, because, just like us
+# and the South Pole, that's the other end of their supply line....
+# I verified with someone who was there that since 1980,
+# Palmer has followed Chile. Prior to that, before the Falklands War,
+# Palmer used to be supplied from Argentina.
+#
+# Zone NAME GMTOFF RULES FORMAT [UNTIL]
+Zone Antarctica/Palmer 0 - zzz 1965
+ -4:00 Arg AR%sT 1969 Oct 5
+ -3:00 Arg AR%sT 1982 May
+ -4:00 Chile CL%sT 2015 Apr 26 3:00u
+ -3:00 - CLT
+
# Colombia
# Milne gives 4:56:16.4 for Bogotá time in 1899; round to nearest. He writes,
diff --git a/contrib/unbound/Makefile.in b/contrib/unbound/Makefile.in
index 02532a9..0c7e0c6 100644
--- a/contrib/unbound/Makefile.in
+++ b/contrib/unbound/Makefile.in
@@ -459,8 +459,8 @@ strip:
$(STRIP) unbound$(EXEEXT)
$(STRIP) unbound-checkconf$(EXEEXT)
$(STRIP) unbound-control$(EXEEXT)
- $(STRIP) unbound-host$(EXEEXT)
- $(STRIP) unbound-anchor$(EXEEXT)
+ $(STRIP) unbound-host$(EXEEXT) || $(STRIP) .libs/unbound-host$(EXEEXT)
+ $(STRIP) unbound-anchor$(EXEEXT) || $(STRIP) .libs/unbound-anchor$(EXEEXT)
pythonmod-install:
$(INSTALL) -m 755 -d $(DESTDIR)$(PYTHON_SITE_PKG)
@@ -576,6 +576,7 @@ depend:
-e 's?$$(srcdir)/util/configlexer.c?util/configlexer.c?g' \
-e 's?$$(srcdir)/util/configparser.c?util/configparser.c?g' \
-e 's?$$(srcdir)/util/configparser.h?util/configparser.h?g' \
+ -e 's?$$(srcdir)/dnstap/dnstap_config.h??g' \
-e 's?$$(srcdir)/pythonmod/pythonmod.h?$$(PYTHONMOD_HEADER)?g' \
-e 's!\(.*\)\.o[ :]*!\1.lo \1.o: !g' \
> $(DEPEND_TMP)
@@ -689,13 +690,14 @@ iter_utils.lo iter_utils.o: $(srcdir)/iterator/iter_utils.c config.h $(srcdir)/i
$(srcdir)/validator/val_utils.h $(srcdir)/validator/val_sigcrypt.h $(srcdir)/ldns/sbuffer.h
listen_dnsport.lo listen_dnsport.o: $(srcdir)/services/listen_dnsport.c config.h \
$(srcdir)/services/listen_dnsport.h $(srcdir)/util/netevent.h $(srcdir)/services/outside_network.h \
- $(srcdir)/util/rbtree.h $(srcdir)/util/log.h $(srcdir)/util/config_file.h $(srcdir)/util/net_help.h \
- $(srcdir)/ldns/sbuffer.h
+ $(srcdir)/util/rbtree.h $(srcdir)/util/log.h $(srcdir)/util/config_file.h \
+ $(srcdir)/util/net_help.h $(srcdir)/ldns/sbuffer.h
localzone.lo localzone.o: $(srcdir)/services/localzone.c config.h $(srcdir)/services/localzone.h \
$(srcdir)/util/rbtree.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/ldns/str2wire.h $(srcdir)/ldns/rrdef.h \
$(srcdir)/ldns/sbuffer.h $(srcdir)/util/regional.h $(srcdir)/util/config_file.h $(srcdir)/util/data/dname.h \
$(srcdir)/util/storage/lruhash.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgencode.h \
- $(srcdir)/util/net_help.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h
+ $(srcdir)/util/net_help.h $(srcdir)/util/netevent.h $(srcdir)/util/data/msgreply.h \
+ $(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h
mesh.lo mesh.o: $(srcdir)/services/mesh.c config.h $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h \
$(srcdir)/util/netevent.h $(srcdir)/util/data/msgparse.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \
$(srcdir)/util/log.h $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h \
@@ -711,15 +713,16 @@ modstack.lo modstack.o: $(srcdir)/services/modstack.c config.h $(srcdir)/service
$(srcdir)/services/outbound_list.h $(srcdir)/validator/validator.h $(srcdir)/validator/val_utils.h
outbound_list.lo outbound_list.o: $(srcdir)/services/outbound_list.c config.h \
$(srcdir)/services/outbound_list.h $(srcdir)/services/outside_network.h $(srcdir)/util/rbtree.h \
- $(srcdir)/util/netevent.h
+ $(srcdir)/util/netevent.h
outside_network.lo outside_network.o: $(srcdir)/services/outside_network.c config.h \
$(srcdir)/services/outside_network.h $(srcdir)/util/rbtree.h $(srcdir)/util/netevent.h \
- $(srcdir)/services/listen_dnsport.h $(srcdir)/services/cache/infra.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/rtt.h $(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h \
- $(srcdir)/ldns/rrdef.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgencode.h $(srcdir)/util/data/dname.h $(srcdir)/util/net_help.h $(srcdir)/util/random.h \
- $(srcdir)/util/fptr_wlist.h $(srcdir)/util/module.h $(srcdir)/util/tube.h $(srcdir)/services/mesh.h \
- $(srcdir)/services/modstack.h $(srcdir)/ldns/sbuffer.h \
+ $(srcdir)/services/listen_dnsport.h $(srcdir)/services/cache/infra.h \
+ $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/rtt.h \
+ $(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h $(srcdir)/util/data/msgreply.h \
+ $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgencode.h $(srcdir)/util/data/dname.h \
+ $(srcdir)/util/net_help.h $(srcdir)/util/random.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/module.h \
+ $(srcdir)/util/tube.h $(srcdir)/services/mesh.h $(srcdir)/services/modstack.h $(srcdir)/ldns/sbuffer.h \
+ $(srcdir)/dnstap/dnstap.h \
alloc.lo alloc.o: $(srcdir)/util/alloc.c config.h $(srcdir)/util/alloc.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
$(srcdir)/util/regional.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h \
@@ -732,8 +735,8 @@ config_file.lo config_file.o: $(srcdir)/util/config_file.c config.h $(srcdir)/ut
$(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h \
$(srcdir)/util/data/packed_rrset.h $(srcdir)/util/regional.h $(srcdir)/util/fptr_wlist.h \
$(srcdir)/util/netevent.h $(srcdir)/util/tube.h $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h \
- $(srcdir)/services/modstack.h $(srcdir)/util/data/dname.h $(srcdir)/ldns/wire2str.h $(srcdir)/ldns/parseutil.h \
- $(srcdir)/util/iana_ports.inc
+ $(srcdir)/services/modstack.h $(srcdir)/util/data/dname.h $(srcdir)/util/rtt.h $(srcdir)/ldns/wire2str.h \
+ $(srcdir)/ldns/parseutil.h $(srcdir)/util/iana_ports.inc
configlexer.lo configlexer.o: util/configlexer.c config.h $(srcdir)/util/configyyrename.h \
$(srcdir)/util/config_file.h util/configparser.h
configparser.lo configparser.o: util/configparser.c config.h $(srcdir)/util/configyyrename.h \
@@ -743,15 +746,16 @@ fptr_wlist.lo fptr_wlist.o: $(srcdir)/util/fptr_wlist.c config.h $(srcdir)/util/
$(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \
$(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h $(srcdir)/util/tube.h \
$(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h $(srcdir)/util/mini_event.h \
- $(srcdir)/util/rbtree.h $(srcdir)/services/outside_network.h $(srcdir)/services/localzone.h \
- $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h $(srcdir)/services/cache/rrset.h \
- $(srcdir)/util/storage/slabhash.h $(srcdir)/dns64/dns64.h $(srcdir)/iterator/iterator.h \
- $(srcdir)/services/outbound_list.h $(srcdir)/iterator/iter_fwd.h $(srcdir)/validator/validator.h \
- $(srcdir)/validator/val_utils.h $(srcdir)/validator/val_anchor.h $(srcdir)/validator/val_nsec3.h \
- $(srcdir)/validator/val_sigcrypt.h $(srcdir)/validator/val_kentry.h $(srcdir)/validator/val_neg.h \
- $(srcdir)/validator/autotrust.h $(srcdir)/util/storage/dnstree.h $(srcdir)/libunbound/libworker.h \
- $(srcdir)/libunbound/context.h $(srcdir)/util/alloc.h $(srcdir)/libunbound/unbound.h \
- $(srcdir)/libunbound/worker.h $(srcdir)/ldns/sbuffer.h $(srcdir)/util/config_file.h
+ $(srcdir)/util/rbtree.h $(srcdir)/services/outside_network.h \
+ $(srcdir)/services/localzone.h $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h \
+ $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h $(srcdir)/dns64/dns64.h \
+ $(srcdir)/iterator/iterator.h $(srcdir)/services/outbound_list.h $(srcdir)/iterator/iter_fwd.h \
+ $(srcdir)/validator/validator.h $(srcdir)/validator/val_utils.h $(srcdir)/validator/val_anchor.h \
+ $(srcdir)/validator/val_nsec3.h $(srcdir)/validator/val_sigcrypt.h $(srcdir)/validator/val_kentry.h \
+ $(srcdir)/validator/val_neg.h $(srcdir)/validator/autotrust.h $(srcdir)/util/storage/dnstree.h \
+ $(srcdir)/libunbound/libworker.h $(srcdir)/libunbound/context.h $(srcdir)/util/alloc.h \
+ $(srcdir)/libunbound/unbound.h $(srcdir)/libunbound/worker.h $(srcdir)/ldns/sbuffer.h \
+ $(srcdir)/util/config_file.h
locks.lo locks.o: $(srcdir)/util/locks.c config.h $(srcdir)/util/locks.h $(srcdir)/util/log.h
log.lo log.o: $(srcdir)/util/log.c config.h $(srcdir)/util/log.h $(srcdir)/util/locks.h $(srcdir)/ldns/sbuffer.h
mini_event.lo mini_event.o: $(srcdir)/util/mini_event.c config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h \
@@ -767,6 +771,7 @@ netevent.lo netevent.o: $(srcdir)/util/netevent.c config.h $(srcdir)/util/neteve
$(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \
$(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h $(srcdir)/util/tube.h \
$(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h $(srcdir)/ldns/sbuffer.h \
+ $(srcdir)/dnstap/dnstap.h \
$(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h
net_help.lo net_help.o: $(srcdir)/util/net_help.c config.h $(srcdir)/util/net_help.h $(srcdir)/util/log.h \
$(srcdir)/util/data/dname.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/module.h \
@@ -854,8 +859,8 @@ val_nsec.lo val_nsec.o: $(srcdir)/validator/val_nsec.c config.h $(srcdir)/valida
$(srcdir)/validator/val_utils.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/dname.h \
$(srcdir)/util/net_help.h $(srcdir)/util/module.h $(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h \
$(srcdir)/ldns/rrdef.h $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h
-val_secalgo.lo val_secalgo.o: $(srcdir)/validator/val_secalgo.c config.h $(srcdir)/validator/val_secalgo.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
+val_secalgo.lo val_secalgo.o: $(srcdir)/validator/val_secalgo.c config.h $(srcdir)/util/data/packed_rrset.h \
+ $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/validator/val_secalgo.h \
$(srcdir)/ldns/rrdef.h $(srcdir)/ldns/keyraw.h \
$(srcdir)/ldns/sbuffer.h \
@@ -884,6 +889,11 @@ dns64.lo dns64.o: $(srcdir)/dns64/dns64.c config.h $(srcdir)/dns64/dns64.h $(src
$(srcdir)/util/regional.h
checklocks.lo checklocks.o: $(srcdir)/testcode/checklocks.c config.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
$(srcdir)/testcode/checklocks.h
+dnstap.lo dnstap.o: $(srcdir)/dnstap/dnstap.c config.h $(srcdir)/ldns/sbuffer.h \
+ $(srcdir)/util/config_file.h $(srcdir)/util/net_help.h $(srcdir)/util/log.h $(srcdir)/util/netevent.h \
+ $(srcdir)/dnstap/dnstap.h \
+ $(srcdir)/dnstap/dnstap.pb-c.h
+dnstap.pb-c.lo dnstap.pb-c.o: $(srcdir)/dnstap/dnstap.pb-c.c $(srcdir)/dnstap/dnstap.pb-c.h
unitanchor.lo unitanchor.o: $(srcdir)/testcode/unitanchor.c config.h $(srcdir)/util/log.h $(srcdir)/util/data/dname.h \
$(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/testcode/unitmain.h \
$(srcdir)/validator/val_anchor.h $(srcdir)/util/rbtree.h $(srcdir)/ldns/sbuffer.h $(srcdir)/ldns/rrdef.h
@@ -894,7 +904,8 @@ unitlruhash.lo unitlruhash.o: $(srcdir)/testcode/unitlruhash.c config.h $(srcdir
$(srcdir)/util/log.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/storage/slabhash.h
unitmain.lo unitmain.o: $(srcdir)/testcode/unitmain.c config.h \
$(srcdir)/ldns/rrdef.h $(srcdir)/ldns/keyraw.h \
- $(srcdir)/util/log.h $(srcdir)/testcode/unitmain.h $(srcdir)/util/alloc.h $(srcdir)/util/locks.h $(srcdir)/util/net_help.h \
+ $(srcdir)/util/log.h \
+ $(srcdir)/testcode/unitmain.h $(srcdir)/util/alloc.h $(srcdir)/util/locks.h $(srcdir)/util/net_help.h \
$(srcdir)/util/config_file.h $(srcdir)/util/rtt.h $(srcdir)/services/cache/infra.h \
$(srcdir)/util/storage/lruhash.h $(srcdir)/util/random.h
unitmsgparse.lo unitmsgparse.o: $(srcdir)/testcode/unitmsgparse.c config.h $(srcdir)/util/log.h \
@@ -935,19 +946,21 @@ cachedump.lo cachedump.o: $(srcdir)/daemon/cachedump.c config.h \
$(srcdir)/ldns/sbuffer.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h \
$(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/netevent.h $(srcdir)/util/alloc.h \
$(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h \
- $(srcdir)/daemon/stats.h $(srcdir)/util/timehist.h $(srcdir)/util/module.h $(srcdir)/services/cache/rrset.h \
- $(srcdir)/util/storage/slabhash.h $(srcdir)/services/cache/dns.h $(srcdir)/services/cache/infra.h \
- $(srcdir)/util/rtt.h $(srcdir)/util/regional.h $(srcdir)/util/net_help.h $(srcdir)/util/data/dname.h \
- $(srcdir)/iterator/iterator.h $(srcdir)/services/outbound_list.h $(srcdir)/iterator/iter_delegpt.h \
- $(srcdir)/iterator/iter_utils.h $(srcdir)/iterator/iter_resptype.h $(srcdir)/iterator/iter_fwd.h \
- $(srcdir)/util/rbtree.h $(srcdir)/iterator/iter_hints.h $(srcdir)/util/storage/dnstree.h \
- $(srcdir)/ldns/wire2str.h $(srcdir)/ldns/str2wire.h
+ $(srcdir)/daemon/stats.h $(srcdir)/util/timehist.h $(srcdir)/util/module.h $(srcdir)/dnstap/dnstap.h \
+ $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h \
+ $(srcdir)/services/cache/dns.h $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h $(srcdir)/util/regional.h \
+ $(srcdir)/util/net_help.h $(srcdir)/util/data/dname.h $(srcdir)/iterator/iterator.h \
+ $(srcdir)/services/outbound_list.h $(srcdir)/iterator/iter_delegpt.h $(srcdir)/iterator/iter_utils.h \
+ $(srcdir)/iterator/iter_resptype.h $(srcdir)/iterator/iter_fwd.h $(srcdir)/util/rbtree.h \
+ $(srcdir)/iterator/iter_hints.h $(srcdir)/util/storage/dnstree.h $(srcdir)/ldns/wire2str.h \
+ $(srcdir)/ldns/str2wire.h
daemon.lo daemon.o: $(srcdir)/daemon/daemon.c config.h \
$(srcdir)/daemon/daemon.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/alloc.h $(srcdir)/services/modstack.h \
- $(srcdir)/daemon/worker.h $(srcdir)/libunbound/worker.h $(srcdir)/ldns/sbuffer.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/netevent.h \
- $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h \
- $(srcdir)/daemon/stats.h $(srcdir)/util/timehist.h $(srcdir)/util/module.h $(srcdir)/daemon/remote.h \
+ $(srcdir)/daemon/worker.h $(srcdir)/libunbound/worker.h \
+ $(srcdir)/ldns/sbuffer.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h \
+ $(srcdir)/util/netevent.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h \
+ $(srcdir)/ldns/rrdef.h $(srcdir)/daemon/stats.h $(srcdir)/util/timehist.h $(srcdir)/util/module.h \
+ $(srcdir)/dnstap/dnstap.h $(srcdir)/daemon/remote.h \
$(srcdir)/daemon/acl_list.h $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rbtree.h \
$(srcdir)/util/config_file.h $(srcdir)/util/storage/lookup3.h $(srcdir)/util/storage/slabhash.h \
$(srcdir)/services/listen_dnsport.h $(srcdir)/services/cache/rrset.h $(srcdir)/services/cache/infra.h \
@@ -959,11 +972,12 @@ remote.lo remote.o: $(srcdir)/daemon/remote.c config.h \
$(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
$(srcdir)/util/netevent.h $(srcdir)/util/alloc.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h \
$(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h $(srcdir)/daemon/stats.h $(srcdir)/util/timehist.h $(srcdir)/util/module.h \
- $(srcdir)/daemon/daemon.h $(srcdir)/services/modstack.h $(srcdir)/daemon/cachedump.h \
- $(srcdir)/util/config_file.h $(srcdir)/util/net_help.h $(srcdir)/services/listen_dnsport.h \
- $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h $(srcdir)/services/cache/infra.h \
- $(srcdir)/util/rtt.h $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h $(srcdir)/services/localzone.h \
- $(srcdir)/util/fptr_wlist.h $(srcdir)/util/tube.h $(srcdir)/util/data/dname.h $(srcdir)/validator/validator.h \
+ $(srcdir)/dnstap/dnstap.h $(srcdir)/daemon/daemon.h \
+ $(srcdir)/services/modstack.h $(srcdir)/daemon/cachedump.h $(srcdir)/util/config_file.h \
+ $(srcdir)/util/net_help.h $(srcdir)/services/listen_dnsport.h $(srcdir)/services/cache/rrset.h \
+ $(srcdir)/util/storage/slabhash.h $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h \
+ $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h $(srcdir)/services/localzone.h $(srcdir)/util/fptr_wlist.h \
+ $(srcdir)/util/tube.h $(srcdir)/util/data/dname.h $(srcdir)/validator/validator.h \
$(srcdir)/validator/val_utils.h $(srcdir)/validator/val_kcache.h $(srcdir)/validator/val_kentry.h \
$(srcdir)/validator/val_anchor.h $(srcdir)/iterator/iterator.h $(srcdir)/services/outbound_list.h \
$(srcdir)/iterator/iter_fwd.h $(srcdir)/iterator/iter_hints.h $(srcdir)/util/storage/dnstree.h \
@@ -973,14 +987,15 @@ stats.lo stats.o: $(srcdir)/daemon/stats.c config.h $(srcdir)/daemon/stats.h $(s
$(srcdir)/daemon/worker.h $(srcdir)/libunbound/worker.h $(srcdir)/ldns/sbuffer.h \
$(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
$(srcdir)/util/netevent.h $(srcdir)/util/alloc.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h \
- $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h $(srcdir)/util/module.h $(srcdir)/daemon/daemon.h \
- $(srcdir)/services/modstack.h $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h \
- $(srcdir)/services/outside_network.h $(srcdir)/util/config_file.h $(srcdir)/util/tube.h \
- $(srcdir)/util/net_help.h $(srcdir)/validator/validator.h $(srcdir)/validator/val_utils.h \
- $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h $(srcdir)/services/cache/infra.h \
- $(srcdir)/util/rtt.h $(srcdir)/validator/val_kcache.h
+ $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h $(srcdir)/util/module.h $(srcdir)/dnstap/dnstap.h \
+ $(srcdir)/daemon/daemon.h $(srcdir)/services/modstack.h \
+ $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h $(srcdir)/services/outside_network.h \
+ $(srcdir)/util/config_file.h $(srcdir)/util/tube.h $(srcdir)/util/net_help.h $(srcdir)/validator/validator.h \
+ $(srcdir)/validator/val_utils.h $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h \
+ $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h $(srcdir)/validator/val_kcache.h
unbound.lo unbound.o: $(srcdir)/daemon/unbound.c config.h $(srcdir)/util/log.h $(srcdir)/daemon/daemon.h \
- $(srcdir)/util/locks.h $(srcdir)/util/alloc.h $(srcdir)/services/modstack.h $(srcdir)/daemon/remote.h \
+ $(srcdir)/util/locks.h $(srcdir)/util/alloc.h $(srcdir)/services/modstack.h \
+ $(srcdir)/daemon/remote.h \
$(srcdir)/util/config_file.h $(srcdir)/util/storage/slabhash.h $(srcdir)/util/storage/lruhash.h \
$(srcdir)/services/listen_dnsport.h $(srcdir)/util/netevent.h $(srcdir)/services/cache/rrset.h \
$(srcdir)/util/data/packed_rrset.h $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h \
@@ -993,7 +1008,8 @@ worker.lo worker.o: $(srcdir)/daemon/worker.c config.h $(srcdir)/util/log.h $(sr
$(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \
$(srcdir)/util/netevent.h $(srcdir)/util/alloc.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h \
$(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h $(srcdir)/daemon/stats.h $(srcdir)/util/timehist.h $(srcdir)/util/module.h \
- $(srcdir)/daemon/daemon.h $(srcdir)/services/modstack.h $(srcdir)/daemon/remote.h \
+ $(srcdir)/dnstap/dnstap.h $(srcdir)/daemon/daemon.h \
+ $(srcdir)/services/modstack.h $(srcdir)/daemon/remote.h \
$(srcdir)/daemon/acl_list.h $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rbtree.h \
$(srcdir)/util/config_file.h $(srcdir)/util/regional.h $(srcdir)/util/storage/slabhash.h \
$(srcdir)/services/listen_dnsport.h $(srcdir)/services/outside_network.h \
@@ -1008,9 +1024,10 @@ testbound.lo testbound.o: $(srcdir)/testcode/testbound.c config.h $(srcdir)/test
$(srcdir)/daemon/remote.h \
$(srcdir)/util/config_file.h $(srcdir)/ldns/keyraw.h $(srcdir)/daemon/unbound.c $(srcdir)/util/log.h \
$(srcdir)/daemon/daemon.h $(srcdir)/util/locks.h $(srcdir)/util/alloc.h $(srcdir)/services/modstack.h \
- $(srcdir)/util/storage/slabhash.h $(srcdir)/util/storage/lruhash.h $(srcdir)/services/listen_dnsport.h \
- $(srcdir)/services/cache/rrset.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/services/cache/infra.h \
- $(srcdir)/util/rtt.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h \
+ $(srcdir)/util/storage/slabhash.h $(srcdir)/util/storage/lruhash.h \
+ $(srcdir)/services/listen_dnsport.h $(srcdir)/services/cache/rrset.h \
+ $(srcdir)/util/data/packed_rrset.h $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h \
+ $(srcdir)/util/fptr_wlist.h $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h \
$(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h $(srcdir)/util/tube.h \
$(srcdir)/services/mesh.h $(srcdir)/util/net_help.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h
testpkts.lo testpkts.o: $(srcdir)/testcode/testpkts.c config.h $(srcdir)/testcode/testpkts.h \
@@ -1021,7 +1038,8 @@ worker.lo worker.o: $(srcdir)/daemon/worker.c config.h $(srcdir)/util/log.h $(sr
$(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \
$(srcdir)/util/netevent.h $(srcdir)/util/alloc.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h \
$(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h $(srcdir)/daemon/stats.h $(srcdir)/util/timehist.h $(srcdir)/util/module.h \
- $(srcdir)/daemon/daemon.h $(srcdir)/services/modstack.h $(srcdir)/daemon/remote.h \
+ $(srcdir)/dnstap/dnstap.h $(srcdir)/daemon/daemon.h \
+ $(srcdir)/services/modstack.h $(srcdir)/daemon/remote.h \
$(srcdir)/daemon/acl_list.h $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rbtree.h \
$(srcdir)/util/config_file.h $(srcdir)/util/regional.h $(srcdir)/util/storage/slabhash.h \
$(srcdir)/services/listen_dnsport.h $(srcdir)/services/outside_network.h \
@@ -1036,10 +1054,11 @@ acl_list.lo acl_list.o: $(srcdir)/daemon/acl_list.c config.h $(srcdir)/daemon/ac
$(srcdir)/util/config_file.h $(srcdir)/util/net_help.h
daemon.lo daemon.o: $(srcdir)/daemon/daemon.c config.h \
$(srcdir)/daemon/daemon.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/alloc.h $(srcdir)/services/modstack.h \
- $(srcdir)/daemon/worker.h $(srcdir)/libunbound/worker.h $(srcdir)/ldns/sbuffer.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/netevent.h \
- $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h \
- $(srcdir)/daemon/stats.h $(srcdir)/util/timehist.h $(srcdir)/util/module.h $(srcdir)/daemon/remote.h \
+ $(srcdir)/daemon/worker.h $(srcdir)/libunbound/worker.h \
+ $(srcdir)/ldns/sbuffer.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h \
+ $(srcdir)/util/netevent.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h \
+ $(srcdir)/ldns/rrdef.h $(srcdir)/daemon/stats.h $(srcdir)/util/timehist.h $(srcdir)/util/module.h \
+ $(srcdir)/dnstap/dnstap.h $(srcdir)/daemon/remote.h \
$(srcdir)/daemon/acl_list.h $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rbtree.h \
$(srcdir)/util/config_file.h $(srcdir)/util/storage/lookup3.h $(srcdir)/util/storage/slabhash.h \
$(srcdir)/services/listen_dnsport.h $(srcdir)/services/cache/rrset.h $(srcdir)/services/cache/infra.h \
@@ -1049,12 +1068,12 @@ stats.lo stats.o: $(srcdir)/daemon/stats.c config.h $(srcdir)/daemon/stats.h $(s
$(srcdir)/daemon/worker.h $(srcdir)/libunbound/worker.h $(srcdir)/ldns/sbuffer.h \
$(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
$(srcdir)/util/netevent.h $(srcdir)/util/alloc.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h \
- $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h $(srcdir)/util/module.h $(srcdir)/daemon/daemon.h \
- $(srcdir)/services/modstack.h $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h \
- $(srcdir)/services/outside_network.h $(srcdir)/util/config_file.h $(srcdir)/util/tube.h \
- $(srcdir)/util/net_help.h $(srcdir)/validator/validator.h $(srcdir)/validator/val_utils.h \
- $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h $(srcdir)/services/cache/infra.h \
- $(srcdir)/util/rtt.h $(srcdir)/validator/val_kcache.h
+ $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h $(srcdir)/util/module.h $(srcdir)/dnstap/dnstap.h \
+ $(srcdir)/daemon/daemon.h $(srcdir)/services/modstack.h \
+ $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h $(srcdir)/services/outside_network.h \
+ $(srcdir)/util/config_file.h $(srcdir)/util/tube.h $(srcdir)/util/net_help.h $(srcdir)/validator/validator.h \
+ $(srcdir)/validator/val_utils.h $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h \
+ $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h $(srcdir)/validator/val_kcache.h
replay.lo replay.o: $(srcdir)/testcode/replay.c config.h $(srcdir)/util/log.h $(srcdir)/util/net_help.h \
$(srcdir)/util/config_file.h $(srcdir)/testcode/replay.h $(srcdir)/util/netevent.h $(srcdir)/testcode/testpkts.h \
$(srcdir)/util/rbtree.h $(srcdir)/testcode/fake_event.h $(srcdir)/ldns/str2wire.h $(srcdir)/ldns/rrdef.h
@@ -1063,10 +1082,10 @@ fake_event.lo fake_event.o: $(srcdir)/testcode/fake_event.c config.h $(srcdir)/t
$(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h \
$(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgencode.h \
$(srcdir)/util/data/dname.h $(srcdir)/util/config_file.h $(srcdir)/services/listen_dnsport.h \
- $(srcdir)/services/outside_network.h $(srcdir)/util/rbtree.h $(srcdir)/services/cache/infra.h \
- $(srcdir)/util/rtt.h $(srcdir)/testcode/replay.h $(srcdir)/testcode/testpkts.h $(srcdir)/util/fptr_wlist.h \
- $(srcdir)/util/module.h $(srcdir)/util/tube.h $(srcdir)/services/mesh.h $(srcdir)/services/modstack.h \
- $(srcdir)/ldns/sbuffer.h $(srcdir)/ldns/wire2str.h $(srcdir)/ldns/str2wire.h
+ $(srcdir)/services/outside_network.h $(srcdir)/util/rbtree.h \
+ $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h $(srcdir)/testcode/replay.h $(srcdir)/testcode/testpkts.h \
+ $(srcdir)/util/fptr_wlist.h $(srcdir)/util/module.h $(srcdir)/util/tube.h $(srcdir)/services/mesh.h \
+ $(srcdir)/services/modstack.h $(srcdir)/ldns/sbuffer.h $(srcdir)/ldns/wire2str.h $(srcdir)/ldns/str2wire.h
lock_verify.lo lock_verify.o: $(srcdir)/testcode/lock_verify.c config.h $(srcdir)/util/log.h $(srcdir)/util/rbtree.h \
$(srcdir)/util/locks.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/netevent.h $(srcdir)/util/storage/lruhash.h \
$(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \
@@ -1118,13 +1137,14 @@ libworker.lo libworker.o: $(srcdir)/libunbound/libworker.c config.h \
$(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/libunbound/context.h $(srcdir)/util/alloc.h $(srcdir)/util/rbtree.h \
$(srcdir)/services/modstack.h $(srcdir)/libunbound/unbound.h $(srcdir)/libunbound/worker.h \
$(srcdir)/ldns/sbuffer.h $(srcdir)/libunbound/unbound-event.h $(srcdir)/services/outside_network.h \
- $(srcdir)/util/netevent.h $(srcdir)/services/mesh.h $(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h \
- $(srcdir)/ldns/rrdef.h $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/services/localzone.h \
- $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h $(srcdir)/services/outbound_list.h \
- $(srcdir)/util/fptr_wlist.h $(srcdir)/util/tube.h $(srcdir)/util/regional.h $(srcdir)/util/random.h \
- $(srcdir)/util/config_file.h $(srcdir)/util/storage/lookup3.h $(srcdir)/util/net_help.h \
- $(srcdir)/util/data/dname.h $(srcdir)/util/data/msgencode.h $(srcdir)/iterator/iter_fwd.h \
- $(srcdir)/iterator/iter_hints.h $(srcdir)/util/storage/dnstree.h $(srcdir)/ldns/str2wire.h
+ $(srcdir)/util/netevent.h $(srcdir)/services/mesh.h \
+ $(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h $(srcdir)/util/module.h \
+ $(srcdir)/util/data/msgreply.h $(srcdir)/services/localzone.h $(srcdir)/services/cache/rrset.h \
+ $(srcdir)/util/storage/slabhash.h $(srcdir)/services/outbound_list.h $(srcdir)/util/fptr_wlist.h \
+ $(srcdir)/util/tube.h $(srcdir)/util/regional.h $(srcdir)/util/random.h $(srcdir)/util/config_file.h \
+ $(srcdir)/util/storage/lookup3.h $(srcdir)/util/net_help.h $(srcdir)/util/data/dname.h \
+ $(srcdir)/util/data/msgencode.h $(srcdir)/iterator/iter_fwd.h $(srcdir)/iterator/iter_hints.h \
+ $(srcdir)/util/storage/dnstree.h $(srcdir)/ldns/str2wire.h
unbound-host.lo unbound-host.o: $(srcdir)/smallapp/unbound-host.c config.h $(srcdir)/libunbound/unbound.h \
$(srcdir)/ldns/rrdef.h $(srcdir)/ldns/wire2str.h
asynclook.lo asynclook.o: $(srcdir)/testcode/asynclook.c config.h $(srcdir)/libunbound/unbound.h \
@@ -1144,7 +1164,8 @@ perf.lo perf.o: $(srcdir)/testcode/perf.c config.h $(srcdir)/util/log.h $(srcdir
delayer.lo delayer.o: $(srcdir)/testcode/delayer.c config.h $(srcdir)/util/net_help.h $(srcdir)/util/log.h \
$(srcdir)/util/config_file.h $(srcdir)/ldns/sbuffer.h
unbound-control.lo unbound-control.o: $(srcdir)/smallapp/unbound-control.c config.h \
- $(srcdir)/util/log.h $(srcdir)/util/config_file.h $(srcdir)/util/locks.h $(srcdir)/util/net_help.h
+ $(srcdir)/util/log.h \
+ $(srcdir)/util/config_file.h $(srcdir)/util/locks.h $(srcdir)/util/net_help.h
unbound-anchor.lo unbound-anchor.o: $(srcdir)/smallapp/unbound-anchor.c config.h $(srcdir)/libunbound/unbound.h \
$(srcdir)/ldns/rrdef.h \
@@ -1155,13 +1176,14 @@ pythonmod_utils.lo pythonmod_utils.o: $(srcdir)/pythonmod/pythonmod_utils.c conf
$(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h \
$(srcdir)/util/netevent.h $(srcdir)/util/net_help.h $(srcdir)/services/cache/dns.h \
$(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h $(srcdir)/util/regional.h \
- $(srcdir)/ldns/sbuffer.h
+ $(srcdir)/iterator/iter_delegpt.h $(srcdir)/ldns/sbuffer.h
win_svc.lo win_svc.o: $(srcdir)/winrc/win_svc.c config.h $(srcdir)/winrc/win_svc.h $(srcdir)/winrc/w_inst.h \
$(srcdir)/daemon/daemon.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/alloc.h $(srcdir)/services/modstack.h \
- $(srcdir)/daemon/worker.h $(srcdir)/libunbound/worker.h $(srcdir)/ldns/sbuffer.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/netevent.h \
- $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h $(srcdir)/ldns/rrdef.h \
- $(srcdir)/daemon/stats.h $(srcdir)/util/timehist.h $(srcdir)/util/module.h $(srcdir)/daemon/remote.h \
+ $(srcdir)/daemon/worker.h $(srcdir)/libunbound/worker.h \
+ $(srcdir)/ldns/sbuffer.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h \
+ $(srcdir)/util/netevent.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h $(srcdir)/ldns/pkthdr.h \
+ $(srcdir)/ldns/rrdef.h $(srcdir)/daemon/stats.h $(srcdir)/util/timehist.h $(srcdir)/util/module.h \
+ $(srcdir)/dnstap/dnstap.h $(srcdir)/daemon/remote.h \
$(srcdir)/util/config_file.h $(srcdir)/util/winsock_event.h
w_inst.lo w_inst.o: $(srcdir)/winrc/w_inst.c config.h $(srcdir)/winrc/w_inst.h $(srcdir)/winrc/win_svc.h
unbound-service-install.lo unbound-service-install.o: $(srcdir)/winrc/unbound-service-install.c config.h \
diff --git a/contrib/unbound/compat/getentropy_linux.c b/contrib/unbound/compat/getentropy_linux.c
index 32d58a7..d4adab2 100644
--- a/contrib/unbound/compat/getentropy_linux.c
+++ b/contrib/unbound/compat/getentropy_linux.c
@@ -93,6 +93,13 @@ getentropy(void *buf, size_t len)
return -1;
}
+#ifdef SYS_getrandom
+ /* try to use getrandom syscall introduced with kernel 3.17 */
+ ret = syscall(SYS_getrandom, buf, len, 0);
+ if (ret != -1)
+ return (ret);
+#endif /* SYS_getrandom */
+
/*
* Try to get entropy with /dev/urandom
*
@@ -474,22 +481,24 @@ getentropy_fallback(void *buf, size_t len)
HD(cnt);
}
-#ifdef AT_RANDOM
+#ifdef HAVE_GETAUXVAL
+# ifdef AT_RANDOM
/* Not as random as you think but we take what we are given */
p = (char *) getauxval(AT_RANDOM);
if (p)
HR(p, 16);
-#endif
-#ifdef AT_SYSINFO_EHDR
+# endif
+# ifdef AT_SYSINFO_EHDR
p = (char *) getauxval(AT_SYSINFO_EHDR);
if (p)
HR(p, pgs);
-#endif
-#ifdef AT_BASE
+# endif
+# ifdef AT_BASE
p = (char *) getauxval(AT_BASE);
if (p)
HD(p);
-#endif
+# endif
+#endif /* HAVE_GETAUXVAL */
SHA512_Final(results, &ctx);
memcpy((char*)buf + i, results, min(sizeof(results), len - i));
diff --git a/contrib/unbound/config.h b/contrib/unbound/config.h
index 8c93eb4..641ddd3 100644
--- a/contrib/unbound/config.h
+++ b/contrib/unbound/config.h
@@ -43,7 +43,7 @@
/* Whether the C compiler accepts the "unused" attribute */
#define HAVE_ATTR_UNUSED 1
-/* Define to 1 if your system has a working `chown' function. */
+/* Define to 1 if you have the `chown' function. */
#define HAVE_CHOWN 1
/* Define to 1 if you have the `chroot' function. */
@@ -147,6 +147,9 @@
/* Whether getaddrinfo is available */
#define HAVE_GETADDRINFO 1
+/* Define to 1 if you have the `getauxval' function. */
+/* #undef HAVE_GETAUXVAL */
+
/* Define to 1 if you have the `getentropy' function. */
/* #undef HAVE_GETENTROPY */
@@ -483,7 +486,7 @@
#define PACKAGE_NAME "unbound"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "unbound 1.5.1"
+#define PACKAGE_STRING "unbound 1.5.3"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "unbound"
@@ -492,7 +495,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.5.1"
+#define PACKAGE_VERSION "1.5.3"
/* default pidfile location */
#define PIDFILE "/var/unbound/unbound.pid"
@@ -511,7 +514,7 @@
#define ROOT_CERT_FILE "/var/unbound/icannbundle.pem"
/* version number for resource files */
-#define RSRC_PACKAGE_VERSION 1,5,1,0
+#define RSRC_PACKAGE_VERSION 1,5,3,0
/* Directory to chdir to */
#define RUN_DIR "/var/unbound"
@@ -800,6 +803,10 @@
#define ARG_LL "%I64"
#endif
+#ifndef AF_LOCAL
+#define AF_LOCAL AF_UNIX
+#endif
+
#ifdef HAVE_ATTR_FORMAT
diff --git a/contrib/unbound/config.h.in b/contrib/unbound/config.h.in
index a8fd05c..c36d4b9 100644
--- a/contrib/unbound/config.h.in
+++ b/contrib/unbound/config.h.in
@@ -42,7 +42,7 @@
/* Whether the C compiler accepts the "unused" attribute */
#undef HAVE_ATTR_UNUSED
-/* Define to 1 if your system has a working `chown' function. */
+/* Define to 1 if you have the `chown' function. */
#undef HAVE_CHOWN
/* Define to 1 if you have the `chroot' function. */
@@ -146,6 +146,9 @@
/* Whether getaddrinfo is available */
#undef HAVE_GETADDRINFO
+/* Define to 1 if you have the `getauxval' function. */
+#undef HAVE_GETAUXVAL
+
/* Define to 1 if you have the `getentropy' function. */
#undef HAVE_GETENTROPY
@@ -799,6 +802,10 @@
#define ARG_LL "%I64"
#endif
+#ifndef AF_LOCAL
+#define AF_LOCAL AF_UNIX
+#endif
+
#ifdef HAVE_ATTR_FORMAT
diff --git a/contrib/unbound/configure b/contrib/unbound/configure
index 8c6c078..20ff33d 100755
--- a/contrib/unbound/configure
+++ b/contrib/unbound/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for unbound 1.5.1.
+# Generated by GNU Autoconf 2.69 for unbound 1.5.3.
#
# Report bugs to <unbound-bugs@nlnetlabs.nl>.
#
@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='unbound'
PACKAGE_TARNAME='unbound'
-PACKAGE_VERSION='1.5.1'
-PACKAGE_STRING='unbound 1.5.1'
+PACKAGE_VERSION='1.5.3'
+PACKAGE_STRING='unbound 1.5.3'
PACKAGE_BUGREPORT='unbound-bugs@nlnetlabs.nl'
PACKAGE_URL=''
@@ -733,6 +733,7 @@ UNBOUND_PIDFILE
UNBOUND_SHARE_DIR
UNBOUND_CHROOT_DIR
UNBOUND_RUN_DIR
+ub_conf_dir
ub_conf_file
EGREP
GREP
@@ -1387,7 +1388,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures unbound 1.5.1 to adapt to many kinds of systems.
+\`configure' configures unbound 1.5.3 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1452,7 +1453,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of unbound 1.5.1:";;
+ short | recursive ) echo "Configuration of unbound 1.5.3:";;
esac
cat <<\_ACEOF
@@ -1627,7 +1628,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-unbound configure 1.5.1
+unbound configure 1.5.3
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2336,7 +2337,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by unbound $as_me 1.5.1, which was
+It was created by unbound $as_me 1.5.3, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2688,11 +2689,11 @@ UNBOUND_VERSION_MAJOR=1
UNBOUND_VERSION_MINOR=5
-UNBOUND_VERSION_MICRO=1
+UNBOUND_VERSION_MICRO=3
LIBUNBOUND_CURRENT=5
-LIBUNBOUND_REVISION=3
+LIBUNBOUND_REVISION=6
LIBUNBOUND_AGE=3
# 1.0.0 had 0:12:0
# 1.0.1 had 0:13:0
@@ -2732,7 +2733,9 @@ LIBUNBOUND_AGE=3
# 1.4.21 had 4:1:2
# 1.4.22 had 4:1:2
# 1.5.0 had 5:3:3 # adds ub_ctx_add_ta_autr
-# 1.5.1 had 5:4:3
+# 1.5.1 had 5:3:3
+# 1.5.2 had 5:5:3
+# 1.5.3 had 5:6:3
# Current -- the number of the binary API that we're implementing
# Revision -- which iteration of the implementation of the binary
@@ -4047,6 +4050,30 @@ cat >>confdefs.h <<_ACEOF
#define CONFIGFILE "$hdr_config"
_ACEOF
+ub_conf_dir=`$as_dirname -- "$ub_conf_file" ||
+$as_expr X"$ub_conf_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ub_conf_file" : 'X\(//\)[^/]' \| \
+ X"$ub_conf_file" : 'X\(//\)$' \| \
+ X"$ub_conf_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ub_conf_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
# Determine run, chroot directory and pidfile locations
@@ -17932,7 +17959,7 @@ if test "$ac_res" != no; then :
fi
-for ac_func in tzset sigprocmask fcntl getpwnam getrlimit setrlimit setsid sbrk chroot kill sleep usleep random srandom recvmsg sendmsg writev socketpair glob initgroups strftime localtime_r setusercontext _beginthreadex endservent endprotoent
+for ac_func in tzset sigprocmask fcntl getpwnam getrlimit setrlimit setsid sbrk chroot kill chown sleep usleep random srandom recvmsg sendmsg writev socketpair glob initgroups strftime localtime_r setusercontext _beginthreadex endservent endprotoent
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -18227,6 +18254,62 @@ done
# this lib needed for sha2 on solaris
LIBS="$LIBS -lmd"
fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5
+$as_echo_n "checking for library containing clock_gettime... " >&6; }
+if ${ac_cv_search_clock_gettime+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char clock_gettime ();
+int
+main ()
+{
+return clock_gettime ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' rt; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_clock_gettime=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_clock_gettime+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_clock_gettime+:} false; then :
+
+else
+ ac_cv_search_clock_gettime=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5
+$as_echo "$ac_cv_search_clock_gettime" >&6; }
+ac_res=$ac_cv_search_clock_gettime
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
;;
Linux|*)
case " $LIBOBJS " in
@@ -18271,6 +18354,17 @@ fi
done
+ for ac_func in getauxval
+do :
+ ac_fn_c_check_func "$LINENO" "getauxval" "ac_cv_func_getauxval"
+if test "x$ac_cv_func_getauxval" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_GETAUXVAL 1
+_ACEOF
+
+fi
+done
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5
$as_echo_n "checking for library containing clock_gettime... " >&6; }
if ${ac_cv_search_clock_gettime+:} false; then :
@@ -18768,7 +18862,7 @@ _ACEOF
-version=1.5.1
+version=1.5.3
date=`date +'%b %e, %Y'`
@@ -19283,7 +19377,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by unbound $as_me 1.5.1, which was
+This file was extended by unbound $as_me 1.5.3, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -19349,7 +19443,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-unbound config.status 1.5.1
+unbound config.status 1.5.3
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/contrib/unbound/configure.ac b/contrib/unbound/configure.ac
index e06c1d6..ae0525b 100644
--- a/contrib/unbound/configure.ac
+++ b/contrib/unbound/configure.ac
@@ -10,14 +10,14 @@ sinclude(dnstap/dnstap.m4)
# must be numbers. ac_defun because of later processing
m4_define([VERSION_MAJOR],[1])
m4_define([VERSION_MINOR],[5])
-m4_define([VERSION_MICRO],[1])
+m4_define([VERSION_MICRO],[3])
AC_INIT(unbound, m4_defn([VERSION_MAJOR]).m4_defn([VERSION_MINOR]).m4_defn([VERSION_MICRO]), unbound-bugs@nlnetlabs.nl, unbound)
AC_SUBST(UNBOUND_VERSION_MAJOR, [VERSION_MAJOR])
AC_SUBST(UNBOUND_VERSION_MINOR, [VERSION_MINOR])
AC_SUBST(UNBOUND_VERSION_MICRO, [VERSION_MICRO])
LIBUNBOUND_CURRENT=5
-LIBUNBOUND_REVISION=3
+LIBUNBOUND_REVISION=6
LIBUNBOUND_AGE=3
# 1.0.0 had 0:12:0
# 1.0.1 had 0:13:0
@@ -57,7 +57,9 @@ LIBUNBOUND_AGE=3
# 1.4.21 had 4:1:2
# 1.4.22 had 4:1:2
# 1.5.0 had 5:3:3 # adds ub_ctx_add_ta_autr
-# 1.5.1 had 5:4:3
+# 1.5.1 had 5:3:3
+# 1.5.2 had 5:5:3
+# 1.5.3 had 5:6:3
# Current -- the number of the binary API that we're implementing
# Revision -- which iteration of the implementation of the binary
@@ -118,6 +120,8 @@ AC_ARG_WITH([conf_file],
AC_SUBST(ub_conf_file)
ACX_ESCAPE_BACKSLASH($ub_conf_file, hdr_config)
AC_DEFINE_UNQUOTED(CONFIGFILE, ["$hdr_config"], [Pathname to the Unbound configuration file])
+ub_conf_dir=`AS_DIRNAME(["$ub_conf_file"])`
+AC_SUBST(ub_conf_dir)
# Determine run, chroot directory and pidfile locations
AC_ARG_WITH(run-dir,
@@ -975,7 +979,7 @@ AC_INCLUDES_DEFAULT
#endif
])
AC_SEARCH_LIBS([setusercontext], [util])
-AC_CHECK_FUNCS([tzset sigprocmask fcntl getpwnam getrlimit setrlimit setsid sbrk chroot kill sleep usleep random srandom recvmsg sendmsg writev socketpair glob initgroups strftime localtime_r setusercontext _beginthreadex endservent endprotoent])
+AC_CHECK_FUNCS([tzset sigprocmask fcntl getpwnam getrlimit setrlimit setsid sbrk chroot kill chown sleep usleep random srandom recvmsg sendmsg writev socketpair glob initgroups strftime localtime_r setusercontext _beginthreadex endservent endprotoent])
AC_CHECK_FUNCS([setresuid],,[AC_CHECK_FUNCS([setreuid])])
AC_CHECK_FUNCS([setresgid],,[AC_CHECK_FUNCS([setregid])])
@@ -1018,6 +1022,7 @@ if test "$USE_NSS" = "no"; then
# this lib needed for sha2 on solaris
LIBS="$LIBS -lmd"
fi
+ AC_SEARCH_LIBS([clock_gettime], [rt])
;;
Linux|*)
AC_LIBOBJ(getentropy_linux)
@@ -1026,6 +1031,7 @@ if test "$USE_NSS" = "no"; then
AC_LIBOBJ(sha512)
])
AC_CHECK_HEADERS([sys/sysctl.h],,, [AC_INCLUDES_DEFAULT])
+ AC_CHECK_FUNCS([getauxval])
AC_SEARCH_LIBS([clock_gettime], [rt])
;;
esac
@@ -1211,6 +1217,10 @@ dnl includes
#else
#define ARG_LL "%I64"
#endif
+
+#ifndef AF_LOCAL
+#define AF_LOCAL AF_UNIX
+#endif
]
AHX_CONFIG_FORMAT_ATTRIBUTE
diff --git a/contrib/unbound/daemon/remote.c b/contrib/unbound/daemon/remote.c
index a5be6d6..3ce55ee 100644
--- a/contrib/unbound/daemon/remote.c
+++ b/contrib/unbound/daemon/remote.c
@@ -327,9 +327,14 @@ add_open(const char* ip, int nr, struct listen_port** list, int noproto_is_err,
* group as the user we run as.
*/
if(fd != -1) {
- if (cfg->username && cfg->username[0])
- chown(ip, cfg->uid, cfg->gid);
+#ifdef HAVE_CHOWN
+ if (cfg->username && cfg->username[0] &&
+ cfg_uid != (uid_t)-1)
+ chown(ip, cfg_uid, cfg_gid);
chmod(ip, (mode_t)(S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP));
+#else
+ (void)cfg;
+#endif
}
} else {
hints.ai_socktype = SOCK_STREAM;
diff --git a/contrib/unbound/daemon/unbound.c b/contrib/unbound/daemon/unbound.c
index a31b039..8e07c38 100644
--- a/contrib/unbound/daemon/unbound.c
+++ b/contrib/unbound/daemon/unbound.c
@@ -503,26 +503,28 @@ perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode,
#ifdef HAVE_KILL
if(cfg->pidfile && cfg->pidfile[0]) {
writepid(daemon->pidfile, getpid());
- if(cfg->username && cfg->username[0]) {
- if(chown(daemon->pidfile, cfg->uid, cfg->gid) == -1) {
+ if(cfg->username && cfg->username[0] && cfg_uid != (uid_t)-1) {
+# ifdef HAVE_CHOWN
+ if(chown(daemon->pidfile, cfg_uid, cfg_gid) == -1) {
log_err("cannot chown %u.%u %s: %s",
- (unsigned)cfg->uid, (unsigned)cfg->gid,
+ (unsigned)cfg_uid, (unsigned)cfg_gid,
daemon->pidfile, strerror(errno));
}
+# endif /* HAVE_CHOWN */
}
}
#else
(void)daemon;
-#endif
+#endif /* HAVE_KILL */
/* Set user context */
#ifdef HAVE_GETPWNAM
- if(cfg->username && cfg->username[0]) {
+ if(cfg->username && cfg->username[0] && cfg_uid != (uid_t)-1) {
#ifdef HAVE_SETUSERCONTEXT
/* setusercontext does initgroups, setuid, setgid, and
* also resource limits from login config, but we
* still call setresuid, setresgid to be sure to set all uid*/
- if(setusercontext(NULL, pwd, cfg->uid, (unsigned)
+ if(setusercontext(NULL, pwd, cfg_uid, (unsigned)
LOGIN_SETALL & ~LOGIN_SETUSER & ~LOGIN_SETGROUP) != 0)
log_warn("unable to setusercontext %s: %s",
cfg->username, strerror(errno));
@@ -584,29 +586,29 @@ perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode,
/* drop permissions after chroot, getpwnam, pidfile, syslog done*/
#ifdef HAVE_GETPWNAM
- if(cfg->username && cfg->username[0]) {
+ if(cfg->username && cfg->username[0] && cfg_uid != (uid_t)-1) {
# ifdef HAVE_INITGROUPS
- if(initgroups(cfg->username, cfg->gid) != 0)
+ if(initgroups(cfg->username, cfg_gid) != 0)
log_warn("unable to initgroups %s: %s",
cfg->username, strerror(errno));
# endif /* HAVE_INITGROUPS */
endpwent();
#ifdef HAVE_SETRESGID
- if(setresgid(cfg->gid,cfg->gid,cfg->gid) != 0)
+ if(setresgid(cfg_gid,cfg_gid,cfg_gid) != 0)
#elif defined(HAVE_SETREGID) && !defined(DARWIN_BROKEN_SETREUID)
- if(setregid(cfg->gid,cfg->gid) != 0)
+ if(setregid(cfg_gid,cfg_gid) != 0)
#else /* use setgid */
- if(setgid(cfg->gid) != 0)
+ if(setgid(cfg_gid) != 0)
#endif /* HAVE_SETRESGID */
fatal_exit("unable to set group id of %s: %s",
cfg->username, strerror(errno));
#ifdef HAVE_SETRESUID
- if(setresuid(cfg->uid,cfg->uid,cfg->uid) != 0)
+ if(setresuid(cfg_uid,cfg_uid,cfg_uid) != 0)
#elif defined(HAVE_SETREUID) && !defined(DARWIN_BROKEN_SETREUID)
- if(setreuid(cfg->uid,cfg->uid) != 0)
+ if(setreuid(cfg_uid,cfg_uid) != 0)
#else /* use setuid */
- if(setuid(cfg->uid) != 0)
+ if(setuid(cfg_uid) != 0)
#endif /* HAVE_SETRESUID */
fatal_exit("unable to set user id of %s: %s",
cfg->username, strerror(errno));
@@ -651,7 +653,8 @@ run_daemon(const char* cfgfile, int cmdline_verbose, int debug_mode)
log_warn("Continuing with default config settings");
}
apply_settings(daemon, cfg, cmdline_verbose, debug_mode);
- config_lookup_uid(cfg);
+ if(!done_setup)
+ config_lookup_uid(cfg);
/* prepare */
if(!daemon_open_shared_ports(daemon))
diff --git a/contrib/unbound/daemon/worker.c b/contrib/unbound/daemon/worker.c
index 59ae9df..5edc21d 100644
--- a/contrib/unbound/daemon/worker.c
+++ b/contrib/unbound/daemon/worker.c
@@ -900,7 +900,7 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
goto send_reply;
}
if(local_zones_answer(worker->daemon->local_zones, &qinfo, &edns,
- c->buffer, worker->scratchpad)) {
+ c->buffer, worker->scratchpad, repinfo)) {
regional_free_all(worker->scratchpad);
if(sldns_buffer_limit(c->buffer) == 0) {
comm_point_drop_reply(repinfo);
diff --git a/contrib/unbound/doc/Changelog b/contrib/unbound/doc/Changelog
index 1bd19f1..a1c2f76 100644
--- a/contrib/unbound/doc/Changelog
+++ b/contrib/unbound/doc/Changelog
@@ -1,12 +1,112 @@
-8 December 2014: Wouter
- - Fix CVE-2014-8602: denial of service by making resolver chase
- endless series of delegations.
+23 March 2015: Wouter
+ - Fix segfault on user not found at startup (from Maciej Soltysiak).
+
+2 March 2015: Wouter
+ - iana portlist update.
+
+20 February 2015: Wouter
+ - Use the getrandom syscall introduced in Linux 3.17 (from Heiner
+ Kallweit).
+ - Fix #645 Portability to Solaris 10, use AF_LOCAL.
+ - Fix #646 Portability to Solaris, -lrt for getentropy_solaris.
+ - Fix #647 crash in 1.5.2 because pwd.db no longer accessible after
+ reload.
+
+19 February 2015: Wouter
+ - 1.5.2 release tag.
+ - svn trunk contains 1.5.3 under development.
+
+13 February 2015: Wouter
+ - Fix #643: doc/example.conf.in: unnecessary whitespace.
+
+12 February 2015: Wouter
+ - tag 1.5.2rc1
+
+11 February 2015: Wouter
+ - iana portlist update.
+
+10 February 2015: Wouter
+ - Fix scrubber with harden-glue turned off to reject NS (and other
+ not-address) records.
+
+9 February 2015: Wouter
+ - Fix validation failure in case upstream forwarder (ISC BIND) does
+ not have the same trust anchors and decides to insert unsigned NS
+ record in authority section.
+
+2 February 2015: Wouter
+ - infra-cache-min-rtt patch from Florian Riehm, for expected long
+ uplink roundtrip times.
+
+30 January 2015: Wouter
+ - Fix 0x20 capsforid fallback to omit gratuitous NS and additional
+ section changes.
+ - Portability fix for Solaris ('sun' is not usable for a variable).
+
+29 January 2015: Wouter
+ - Fix pyunbound byte string representation for python3.
+
+26 January 2015: Wouter
+ - Fix unintended use of gcc extension for incomplete enum types,
+ compile with pedantic c99 compliance (from Daniel Dickman).
+
+23 January 2015: Wouter
+ - windows port fixes, no AF_LOCAL, no chown, no chmod(grp).
+
+16 January 2015: Wouter
+ - unit test for local unix connection. Documentation and log_addr
+ does not inspect port for AF_LOCAL.
+ - unbound-checkconf -f prints chroot with pidfile path.
+
+13 January 2015: Wouter
+ - iana portlist update.
+
+12 January 2015: Wouter
+ - Cast sun_len sizeof to socklen_t.
+ - Fix pyunbound ord call, portable for python 2 and 3.
+
+7 January 2015: Wouter
+ - Fix warnings in pythonmod changes.
+
+6 January 2015: Wouter
+ - iana portlist update.
- patch for remote control over local sockets, from Dag-Erling
Smorgrav, Ilya Bakulin. Use control-interface: /path/sock and
control-use-cert: no.
- Fixup that patch and uid lookup (only for daemon).
- coded the default of control-use-cert, to yes.
+5 January 2015: Wouter
+ - getauxval test for ppc64 linux compatibility.
+ - make strip works for unbound-host and unbound-anchor.
+ - patch from Stephane Lapie that adds to the python API, that
+ exposes struct delegpt, and adds the find_delegation function.
+ - print query name when max target count is exceeded.
+ - patch from Stuart Henderson that fixes DESTDIR in
+ unbound-control-setup for installs where config is not in
+ the prefix location.
+ - Fix #634: fix fail to start on Linux LTS 3.14.X, ignores missing
+ IP_MTU_DISCOVER OMIT option (fix from Remi Gacogne).
+ - Updated contrib warmup.cmd/sh to support two modes - load
+ from pre-defined list of domains or (with filename as argument)
+ load from user-specified list of domains, and updated contrib
+ unbound_cache.sh/cmd to support loading/save/reload cache to/from
+ default path or (with secondary argument) arbitrary path/filename,
+ from Yuri Voinov.
+ - Patch from Philip Paeps to contrib/unbound_munin_ that uses
+ type ABSOLUTE. Allows munin.conf: [idleserver.example.net]
+ unbound_munin_hits.graph_period minute
+
+9 December 2014: Wouter
+ - svn trunk has 1.5.2 in development.
+ - config.guess and config.sub update from libtoolize.
+ - local-zone: example.com inform makes unbound log a message with
+ client IP for queries in that zone. Eg. for finding infected hosts.
+
+8 December 2014: Wouter
+ - Fix CVE-2014-8602: denial of service by making resolver chase
+ endless series of delegations.
+
1 December 2014: Wouter
- Fix bug#632: unbound fails to build on AArch64, protects
getentropy compat code from calling sysctl if it is has been removed.
diff --git a/contrib/unbound/doc/README b/contrib/unbound/doc/README
index df92fcc..f3530d6 100644
--- a/contrib/unbound/doc/README
+++ b/contrib/unbound/doc/README
@@ -1,4 +1,4 @@
-README for Unbound 1.5.1
+README for Unbound 1.5.3
Copyright 2007 NLnet Labs
http://unbound.net
diff --git a/contrib/unbound/doc/example.conf b/contrib/unbound/doc/example.conf
index 945e9e3..acb553b 100644
--- a/contrib/unbound/doc/example.conf
+++ b/contrib/unbound/doc/example.conf
@@ -1,7 +1,7 @@
#
# Example configuration file.
#
-# See unbound.conf(5) man page, version 1.5.1.
+# See unbound.conf(5) man page, version 1.5.3.
#
# this is a comment.
@@ -138,6 +138,9 @@ server:
# the time to live (TTL) value for cached roundtrip times, lameness and
# EDNS version information for hosts. In seconds.
# infra-host-ttl: 900
+
+ # minimum wait time for responses, increase if uplink is long. In msec.
+ # infra-cache-min-rtt: 50
# the number of slabs to use for the Infrastructure cache.
# the number of slabs must be a power of 2.
@@ -437,7 +440,7 @@ server:
# the amount of memory to use for the negative cache (used for DLV).
# plain value in bytes or you can append k, m or G. default is "1Mb".
# neg-cache-size: 1m
-
+
# By default, for a number of zones a small default 'nothing here'
# reply is built-in. Query traffic is thus blocked. If you
# wish to serve such zone you can unblock them by uncommenting one
@@ -497,6 +500,7 @@ server:
# o redirect serves the zone data for any subdomain in the zone.
# o nodefault can be used to normally resolve AS112 zones.
# o typetransparent resolves normally for other types and other names
+ # o inform resolves normally, but logs client IP address
#
# defaults are localhost address, reverse for 127.0.0.1 and ::1
# and nxdomain for AS112 zones. If you configure one of these zones
@@ -552,6 +556,10 @@ remote-control:
# set up the keys and certificates with unbound-control-setup.
# control-enable: no
+ # Set to no and use an absolute path as control-interface to use
+ # a unix local named pipe for unbound-control.
+ # control-use-cert: yes
+
# what interfaces are listened to for remote control.
# give 0.0.0.0 and ::0 to listen to all interfaces.
# control-interface: 127.0.0.1
diff --git a/contrib/unbound/doc/example.conf.in b/contrib/unbound/doc/example.conf.in
index b95b3a6..60ed5c8 100644
--- a/contrib/unbound/doc/example.conf.in
+++ b/contrib/unbound/doc/example.conf.in
@@ -1,7 +1,7 @@
#
# Example configuration file.
#
-# See unbound.conf(5) man page, version 1.5.1.
+# See unbound.conf(5) man page, version 1.5.3.
#
# this is a comment.
@@ -138,6 +138,9 @@ server:
# the time to live (TTL) value for cached roundtrip times, lameness and
# EDNS version information for hosts. In seconds.
# infra-host-ttl: 900
+
+ # minimum wait time for responses, increase if uplink is long. In msec.
+ # infra-cache-min-rtt: 50
# the number of slabs to use for the Infrastructure cache.
# the number of slabs must be a power of 2.
@@ -437,7 +440,7 @@ server:
# the amount of memory to use for the negative cache (used for DLV).
# plain value in bytes or you can append k, m or G. default is "1Mb".
# neg-cache-size: 1m
-
+
# By default, for a number of zones a small default 'nothing here'
# reply is built-in. Query traffic is thus blocked. If you
# wish to serve such zone you can unblock them by uncommenting one
@@ -497,6 +500,7 @@ server:
# o redirect serves the zone data for any subdomain in the zone.
# o nodefault can be used to normally resolve AS112 zones.
# o typetransparent resolves normally for other types and other names
+ # o inform resolves normally, but logs client IP address
#
# defaults are localhost address, reverse for 127.0.0.1 and ::1
# and nxdomain for AS112 zones. If you configure one of these zones
@@ -552,6 +556,10 @@ remote-control:
# set up the keys and certificates with unbound-control-setup.
# control-enable: no
+ # Set to no and use an absolute path as control-interface to use
+ # a unix local named pipe for unbound-control.
+ # control-use-cert: yes
+
# what interfaces are listened to for remote control.
# give 0.0.0.0 and ::0 to listen to all interfaces.
# control-interface: 127.0.0.1
diff --git a/contrib/unbound/doc/libunbound.3 b/contrib/unbound/doc/libunbound.3
index 55a9cb2..a4c7945 100644
--- a/contrib/unbound/doc/libunbound.3
+++ b/contrib/unbound/doc/libunbound.3
@@ -1,4 +1,4 @@
-.TH "libunbound" "3" "Dec 8, 2014" "NLnet Labs" "unbound 1.5.1"
+.TH "libunbound" "3" "Mar 10, 2015" "NLnet Labs" "unbound 1.5.3"
.\"
.\" libunbound.3 -- unbound library functions manual
.\"
@@ -42,7 +42,7 @@
.B ub_ctx_zone_remove,
.B ub_ctx_data_add,
.B ub_ctx_data_remove
-\- Unbound DNS validating resolver 1.5.1 functions.
+\- Unbound DNS validating resolver 1.5.3 functions.
.SH "SYNOPSIS"
.B #include <unbound.h>
.LP
diff --git a/contrib/unbound/doc/libunbound.3.in b/contrib/unbound/doc/libunbound.3.in
index 55a9cb2..a4c7945 100644
--- a/contrib/unbound/doc/libunbound.3.in
+++ b/contrib/unbound/doc/libunbound.3.in
@@ -1,4 +1,4 @@
-.TH "libunbound" "3" "Dec 8, 2014" "NLnet Labs" "unbound 1.5.1"
+.TH "libunbound" "3" "Mar 10, 2015" "NLnet Labs" "unbound 1.5.3"
.\"
.\" libunbound.3 -- unbound library functions manual
.\"
@@ -42,7 +42,7 @@
.B ub_ctx_zone_remove,
.B ub_ctx_data_add,
.B ub_ctx_data_remove
-\- Unbound DNS validating resolver 1.5.1 functions.
+\- Unbound DNS validating resolver 1.5.3 functions.
.SH "SYNOPSIS"
.B #include <unbound.h>
.LP
diff --git a/contrib/unbound/doc/unbound-anchor.8 b/contrib/unbound/doc/unbound-anchor.8
index a001620..3682d8f 100644
--- a/contrib/unbound/doc/unbound-anchor.8
+++ b/contrib/unbound/doc/unbound-anchor.8
@@ -1,4 +1,4 @@
-.TH "unbound-anchor" "8" "Dec 8, 2014" "NLnet Labs" "unbound 1.5.1"
+.TH "unbound-anchor" "8" "Mar 10, 2015" "NLnet Labs" "unbound 1.5.3"
.\"
.\" unbound-anchor.8 -- unbound anchor maintenance utility manual
.\"
diff --git a/contrib/unbound/doc/unbound-anchor.8.in b/contrib/unbound/doc/unbound-anchor.8.in
index 80a3438d..fb2136f 100644
--- a/contrib/unbound/doc/unbound-anchor.8.in
+++ b/contrib/unbound/doc/unbound-anchor.8.in
@@ -1,4 +1,4 @@
-.TH "unbound-anchor" "8" "Dec 8, 2014" "NLnet Labs" "unbound 1.5.1"
+.TH "unbound-anchor" "8" "Mar 10, 2015" "NLnet Labs" "unbound 1.5.3"
.\"
.\" unbound-anchor.8 -- unbound anchor maintenance utility manual
.\"
diff --git a/contrib/unbound/doc/unbound-checkconf.8 b/contrib/unbound/doc/unbound-checkconf.8
index 3da7ec0..d2b659e 100644
--- a/contrib/unbound/doc/unbound-checkconf.8
+++ b/contrib/unbound/doc/unbound-checkconf.8
@@ -1,4 +1,4 @@
-.TH "unbound-checkconf" "8" "Dec 8, 2014" "NLnet Labs" "unbound 1.5.1"
+.TH "unbound-checkconf" "8" "Mar 10, 2015" "NLnet Labs" "unbound 1.5.3"
.\"
.\" unbound-checkconf.8 -- unbound configuration checker manual
.\"
@@ -13,6 +13,7 @@ unbound\-checkconf
.SH "SYNOPSIS"
.B unbound\-checkconf
.RB [ \-h ]
+.RB [ \-f ]
.RB [ \-o
.IR option ]
.RI [ cfgfile ]
@@ -29,6 +30,9 @@ The available options are:
.B \-h
Show the version and commandline option help.
.TP
+.B \-f
+Print full pathname, with chroot applied to it. Use with the -o option.
+.TP
.B \-o\fI option
If given, after checking the config file the value of this option is
printed to stdout. For "" (disabled) options an empty line is printed.
diff --git a/contrib/unbound/doc/unbound-checkconf.8.in b/contrib/unbound/doc/unbound-checkconf.8.in
index 5ab5348..e7db810 100644
--- a/contrib/unbound/doc/unbound-checkconf.8.in
+++ b/contrib/unbound/doc/unbound-checkconf.8.in
@@ -1,4 +1,4 @@
-.TH "unbound-checkconf" "8" "Dec 8, 2014" "NLnet Labs" "unbound 1.5.1"
+.TH "unbound-checkconf" "8" "Mar 10, 2015" "NLnet Labs" "unbound 1.5.3"
.\"
.\" unbound-checkconf.8 -- unbound configuration checker manual
.\"
@@ -13,6 +13,7 @@ unbound\-checkconf
.SH "SYNOPSIS"
.B unbound\-checkconf
.RB [ \-h ]
+.RB [ \-f ]
.RB [ \-o
.IR option ]
.RI [ cfgfile ]
@@ -29,6 +30,9 @@ The available options are:
.B \-h
Show the version and commandline option help.
.TP
+.B \-f
+Print full pathname, with chroot applied to it. Use with the -o option.
+.TP
.B \-o\fI option
If given, after checking the config file the value of this option is
printed to stdout. For "" (disabled) options an empty line is printed.
diff --git a/contrib/unbound/doc/unbound-control.8 b/contrib/unbound/doc/unbound-control.8
index e768fa9..e6228b7 100644
--- a/contrib/unbound/doc/unbound-control.8
+++ b/contrib/unbound/doc/unbound-control.8
@@ -1,4 +1,4 @@
-.TH "unbound-control" "8" "Dec 8, 2014" "NLnet Labs" "unbound 1.5.1"
+.TH "unbound-control" "8" "Mar 10, 2015" "NLnet Labs" "unbound 1.5.3"
.\"
.\" unbound-control.8 -- unbound remote control manual
.\"
diff --git a/contrib/unbound/doc/unbound-control.8.in b/contrib/unbound/doc/unbound-control.8.in
index 92d2d1a..f6eae24 100644
--- a/contrib/unbound/doc/unbound-control.8.in
+++ b/contrib/unbound/doc/unbound-control.8.in
@@ -1,4 +1,4 @@
-.TH "unbound-control" "8" "Dec 8, 2014" "NLnet Labs" "unbound 1.5.1"
+.TH "unbound-control" "8" "Mar 10, 2015" "NLnet Labs" "unbound 1.5.3"
.\"
.\" unbound-control.8 -- unbound remote control manual
.\"
diff --git a/contrib/unbound/doc/unbound-host.1 b/contrib/unbound/doc/unbound-host.1
index 0bd194e..bda99ce 100644
--- a/contrib/unbound/doc/unbound-host.1
+++ b/contrib/unbound/doc/unbound-host.1
@@ -1,4 +1,4 @@
-.TH "unbound\-host" "1" "Dec 8, 2014" "NLnet Labs" "unbound 1.5.1"
+.TH "unbound\-host" "1" "Mar 10, 2015" "NLnet Labs" "unbound 1.5.3"
.\"
.\" unbound-host.1 -- unbound DNS lookup utility
.\"
diff --git a/contrib/unbound/doc/unbound-host.1.in b/contrib/unbound/doc/unbound-host.1.in
index d9e92bb..9129bea 100644
--- a/contrib/unbound/doc/unbound-host.1.in
+++ b/contrib/unbound/doc/unbound-host.1.in
@@ -1,4 +1,4 @@
-.TH "unbound\-host" "1" "Dec 8, 2014" "NLnet Labs" "unbound 1.5.1"
+.TH "unbound\-host" "1" "Mar 10, 2015" "NLnet Labs" "unbound 1.5.3"
.\"
.\" unbound-host.1 -- unbound DNS lookup utility
.\"
diff --git a/contrib/unbound/doc/unbound.8 b/contrib/unbound/doc/unbound.8
index f9c5b6a..8609a0a 100644
--- a/contrib/unbound/doc/unbound.8
+++ b/contrib/unbound/doc/unbound.8
@@ -1,4 +1,4 @@
-.TH "unbound" "8" "Dec 8, 2014" "NLnet Labs" "unbound 1.5.1"
+.TH "unbound" "8" "Mar 10, 2015" "NLnet Labs" "unbound 1.5.3"
.\"
.\" unbound.8 -- unbound manual
.\"
@@ -9,7 +9,7 @@
.\"
.SH "NAME"
.B unbound
-\- Unbound DNS validating resolver 1.5.1.
+\- Unbound DNS validating resolver 1.5.3.
.SH "SYNOPSIS"
.B unbound
.RB [ \-h ]
diff --git a/contrib/unbound/doc/unbound.8.in b/contrib/unbound/doc/unbound.8.in
index 3b74a32..7242469 100644
--- a/contrib/unbound/doc/unbound.8.in
+++ b/contrib/unbound/doc/unbound.8.in
@@ -1,4 +1,4 @@
-.TH "unbound" "8" "Dec 8, 2014" "NLnet Labs" "unbound 1.5.1"
+.TH "unbound" "8" "Mar 10, 2015" "NLnet Labs" "unbound 1.5.3"
.\"
.\" unbound.8 -- unbound manual
.\"
@@ -9,7 +9,7 @@
.\"
.SH "NAME"
.B unbound
-\- Unbound DNS validating resolver 1.5.1.
+\- Unbound DNS validating resolver 1.5.3.
.SH "SYNOPSIS"
.B unbound
.RB [ \-h ]
diff --git a/contrib/unbound/doc/unbound.conf.5 b/contrib/unbound/doc/unbound.conf.5
index f5a4471..c2637aa 100644
--- a/contrib/unbound/doc/unbound.conf.5
+++ b/contrib/unbound/doc/unbound.conf.5
@@ -1,4 +1,4 @@
-.TH "unbound.conf" "5" "Dec 8, 2014" "NLnet Labs" "unbound 1.5.1"
+.TH "unbound.conf" "5" "Mar 10, 2015" "NLnet Labs" "unbound 1.5.3"
.\"
.\" unbound.conf.5 -- unbound.conf manual
.\"
@@ -301,6 +301,11 @@ by threads. Must be set to a power of 2.
.B infra\-cache\-numhosts: \fI<number>
Number of hosts for which information is cached. Default is 10000.
.TP
+.B infra\-cache\-min\-rtt: \fI<msec>
+Lower limit for dynamic retransmit timeout calculation in infrastructure
+cache. Default is 50 milliseconds. Increase this value if using forwarders
+needing more time to do recursive name resolution.
+.TP
.B do\-ip4: \fI<yes or no>
Enable or disable whether ip4 queries are answered or issued. Default is yes.
.TP
@@ -791,7 +796,7 @@ data leakage about the local network to the upstream DNS servers.
.B local\-zone: \fI<zone> <type>
Configure a local zone. The type determines the answer to give if
there is no match from local\-data. The types are deny, refuse, static,
-transparent, redirect, nodefault, typetransparent, and are explained
+transparent, redirect, nodefault, typetransparent, inform, and are explained
below. After that the default settings are listed. Use local\-data: to
enter data into the local zone. Answers for local zones are authoritative
DNS answers. By default the zones are class IN.
@@ -841,6 +846,13 @@ local\-data: "example.com. A 127.0.0.1"
queries for www.example.com and www.foo.example.com are redirected, so
that users with web browsers cannot access sites with suffix example.com.
.TP 10
+\h'5'\fIinform\fR
+The query is answered normally. The client IP address (@portnumber)
+is printed to the logfile. The log message is: timestamp, unbound-pid,
+info: zonename inform IP@port queryname type class. This option can be
+used for normal resolution, but machines looking up infected names are
+logged, eg. to run antivirus on them.
+.TP 10
\h'5'\fInodefault\fR
Used to turn off default contents for AS112 zones. The other types
also turn off default contents for the zone. The 'nodefault' option
diff --git a/contrib/unbound/doc/unbound.conf.5.in b/contrib/unbound/doc/unbound.conf.5.in
index d4420e2..9b088f3 100644
--- a/contrib/unbound/doc/unbound.conf.5.in
+++ b/contrib/unbound/doc/unbound.conf.5.in
@@ -1,4 +1,4 @@
-.TH "unbound.conf" "5" "Dec 8, 2014" "NLnet Labs" "unbound 1.5.1"
+.TH "unbound.conf" "5" "Mar 10, 2015" "NLnet Labs" "unbound 1.5.3"
.\"
.\" unbound.conf.5 -- unbound.conf manual
.\"
@@ -301,6 +301,11 @@ by threads. Must be set to a power of 2.
.B infra\-cache\-numhosts: \fI<number>
Number of hosts for which information is cached. Default is 10000.
.TP
+.B infra\-cache\-min\-rtt: \fI<msec>
+Lower limit for dynamic retransmit timeout calculation in infrastructure
+cache. Default is 50 milliseconds. Increase this value if using forwarders
+needing more time to do recursive name resolution.
+.TP
.B do\-ip4: \fI<yes or no>
Enable or disable whether ip4 queries are answered or issued. Default is yes.
.TP
@@ -791,7 +796,7 @@ data leakage about the local network to the upstream DNS servers.
.B local\-zone: \fI<zone> <type>
Configure a local zone. The type determines the answer to give if
there is no match from local\-data. The types are deny, refuse, static,
-transparent, redirect, nodefault, typetransparent, and are explained
+transparent, redirect, nodefault, typetransparent, inform, and are explained
below. After that the default settings are listed. Use local\-data: to
enter data into the local zone. Answers for local zones are authoritative
DNS answers. By default the zones are class IN.
@@ -841,6 +846,13 @@ local\-data: "example.com. A 127.0.0.1"
queries for www.example.com and www.foo.example.com are redirected, so
that users with web browsers cannot access sites with suffix example.com.
.TP 10
+\h'5'\fIinform\fR
+The query is answered normally. The client IP address (@portnumber)
+is printed to the logfile. The log message is: timestamp, unbound-pid,
+info: zonename inform IP@port queryname type class. This option can be
+used for normal resolution, but machines looking up infected names are
+logged, eg. to run antivirus on them.
+.TP 10
\h'5'\fInodefault\fR
Used to turn off default contents for AS112 zones. The other types
also turn off default contents for the zone. The 'nodefault' option
diff --git a/contrib/unbound/iterator/iter_scrub.c b/contrib/unbound/iterator/iter_scrub.c
index b2248bc..1c81975 100644
--- a/contrib/unbound/iterator/iter_scrub.c
+++ b/contrib/unbound/iterator/iter_scrub.c
@@ -680,7 +680,9 @@ scrub_sanitize(sldns_buffer* pkt, struct msg_parse* msg,
* (we dont want its glue that was approved
* during the normalize action) */
del_addi = 1;
- } else if(!env->cfg->harden_glue) {
+ } else if(!env->cfg->harden_glue && (
+ rrset->type == LDNS_RR_TYPE_A ||
+ rrset->type == LDNS_RR_TYPE_AAAA)) {
/* store in cache! Since it is relevant
* (from normalize) it will be picked up
* from the cache to be used later */
diff --git a/contrib/unbound/iterator/iter_utils.c b/contrib/unbound/iterator/iter_utils.c
index 9d0aa69..10ae12f 100644
--- a/contrib/unbound/iterator/iter_utils.c
+++ b/contrib/unbound/iterator/iter_utils.c
@@ -715,6 +715,42 @@ reply_equal(struct reply_info* p, struct reply_info* q, struct regional* region)
}
void
+caps_strip_reply(struct reply_info* rep)
+{
+ size_t i;
+ if(!rep) return;
+ /* see if message is a referral, in which case the additional and
+ * NS record cannot be removed */
+ /* referrals have the AA flag unset (strict check, not elsewhere in
+ * unbound, but for 0x20 this is very convenient). */
+ if(!(rep->flags&BIT_AA))
+ return;
+ /* remove the additional section from the reply */
+ if(rep->ar_numrrsets != 0) {
+ verbose(VERB_ALGO, "caps fallback: removing additional section");
+ rep->rrset_count -= rep->ar_numrrsets;
+ rep->ar_numrrsets = 0;
+ }
+ /* is there an NS set in the authority section to remove? */
+ /* the failure case (Cisco firewalls) only has one rrset in authsec */
+ for(i=rep->an_numrrsets; i<rep->an_numrrsets+rep->ns_numrrsets; i++) {
+ struct ub_packed_rrset_key* s = rep->rrsets[i];
+ if(ntohs(s->rk.type) == LDNS_RR_TYPE_NS) {
+ /* remove NS rrset and break from loop (loop limits
+ * have changed) */
+ /* move last rrset into this position (there is no
+ * additional section any more) */
+ verbose(VERB_ALGO, "caps fallback: removing NS rrset");
+ if(i < rep->rrset_count-1)
+ rep->rrsets[i]=rep->rrsets[rep->rrset_count-1];
+ rep->rrset_count --;
+ rep->ns_numrrsets --;
+ break;
+ }
+ }
+}
+
+void
iter_store_parentside_rrset(struct module_env* env,
struct ub_packed_rrset_key* rrset)
{
diff --git a/contrib/unbound/iterator/iter_utils.h b/contrib/unbound/iterator/iter_utils.h
index d7c2b68..9373487 100644
--- a/contrib/unbound/iterator/iter_utils.h
+++ b/contrib/unbound/iterator/iter_utils.h
@@ -223,6 +223,15 @@ int iter_msg_from_zone(struct dns_msg* msg, struct delegpt* dp,
int reply_equal(struct reply_info* p, struct reply_info* q, struct regional* region);
/**
+ * Remove unused bits from the reply if possible.
+ * So that caps-for-id (0x20) fallback is more likely to be successful.
+ * This removes like, the additional section, and NS record in the authority
+ * section if those records are gratuitous (not for a referral).
+ * @param rep: the reply to strip stuff out of.
+ */
+void caps_strip_reply(struct reply_info* rep);
+
+/**
* Store parent-side rrset in seperate rrset cache entries for later
* last-resort * lookups in case the child-side versions of this information
* fails.
diff --git a/contrib/unbound/iterator/iterator.c b/contrib/unbound/iterator/iterator.c
index 6e05c99..2037cc8 100644
--- a/contrib/unbound/iterator/iterator.c
+++ b/contrib/unbound/iterator/iterator.c
@@ -1383,8 +1383,10 @@ query_for_targets(struct module_qstate* qstate, struct iter_qstate* iq,
return 0;
if(iq->depth > 0 && iq->target_count &&
iq->target_count[1] > MAX_TARGET_COUNT) {
- verbose(VERB_QUERY, "request has exceeded the maximum "
- "number of glue fetches %d", iq->target_count[1]);
+ char s[LDNS_MAX_DOMAINLEN+1];
+ dname_str(qstate->qinfo.qname, s);
+ verbose(VERB_QUERY, "request %s has exceeded the maximum "
+ "number of glue fetches %d", s, iq->target_count[1]);
return 0;
}
@@ -1581,8 +1583,10 @@ processLastResort(struct module_qstate* qstate, struct iter_qstate* iq,
}
if(iq->depth > 0 && iq->target_count &&
iq->target_count[1] > MAX_TARGET_COUNT) {
- verbose(VERB_QUERY, "request has exceeded the maximum "
- "number of glue fetches %d", iq->target_count[1]);
+ char s[LDNS_MAX_DOMAINLEN+1];
+ dname_str(qstate->qinfo.qname, s);
+ verbose(VERB_QUERY, "request %s has exceeded the maximum "
+ "number of glue fetches %d", s, iq->target_count[1]);
return error_response_cache(qstate, id, LDNS_RCODE_SERVFAIL);
}
/* mark cycle targets for parent-side lookups */
@@ -2878,6 +2882,9 @@ process_response(struct module_qstate* qstate, struct iter_qstate* iq,
iq->response->rep);
if(event == module_event_capsfail || iq->caps_fallback) {
+ /* for fallback we care about main answer, not additionals */
+ /* removing that makes comparison more likely to succeed */
+ caps_strip_reply(iq->response->rep);
if(!iq->caps_fallback) {
/* start fallback */
iq->caps_fallback = 1;
diff --git a/contrib/unbound/libunbound/libworker.c b/contrib/unbound/libunbound/libworker.c
index e388e79..c72b586 100644
--- a/contrib/unbound/libunbound/libworker.c
+++ b/contrib/unbound/libunbound/libworker.c
@@ -606,7 +606,7 @@ int libworker_fg(struct ub_ctx* ctx, struct ctx_query* q)
sldns_buffer_write_u16_at(w->back->udp_buff, 0, qid);
sldns_buffer_write_u16_at(w->back->udp_buff, 2, qflags);
if(local_zones_answer(ctx->local_zones, &qinfo, &edns,
- w->back->udp_buff, w->env->scratch)) {
+ w->back->udp_buff, w->env->scratch, NULL)) {
regional_free_all(w->env->scratch);
libworker_fillup_fg(q, LDNS_RCODE_NOERROR,
w->back->udp_buff, sec_status_insecure, NULL);
@@ -676,7 +676,7 @@ int libworker_attach_mesh(struct ub_ctx* ctx, struct ctx_query* q,
sldns_buffer_write_u16_at(w->back->udp_buff, 0, qid);
sldns_buffer_write_u16_at(w->back->udp_buff, 2, qflags);
if(local_zones_answer(ctx->local_zones, &qinfo, &edns,
- w->back->udp_buff, w->env->scratch)) {
+ w->back->udp_buff, w->env->scratch, NULL)) {
regional_free_all(w->env->scratch);
free(qinfo.qname);
libworker_event_done_cb(q, LDNS_RCODE_NOERROR,
@@ -796,7 +796,7 @@ handle_newq(struct libworker* w, uint8_t* buf, uint32_t len)
sldns_buffer_write_u16_at(w->back->udp_buff, 0, qid);
sldns_buffer_write_u16_at(w->back->udp_buff, 2, qflags);
if(local_zones_answer(w->ctx->local_zones, &qinfo, &edns,
- w->back->udp_buff, w->env->scratch)) {
+ w->back->udp_buff, w->env->scratch, NULL)) {
regional_free_all(w->env->scratch);
q->msg_security = sec_status_insecure;
add_bg_result(w, q, w->back->udp_buff, UB_NOERROR, NULL);
diff --git a/contrib/unbound/libunbound/python/libunbound.i b/contrib/unbound/libunbound/python/libunbound.i
index 313c748..1bef79f 100644
--- a/contrib/unbound/libunbound/python/libunbound.i
+++ b/contrib/unbound/libunbound/python/libunbound.i
@@ -44,6 +44,10 @@
%pythoncode %{
import encodings.idna
+ try:
+ import builtins
+ except ImportError:
+ import __builtin__ as builtins
# Ensure compatibility with older python versions
if 'bytes' not in vars():
@@ -52,7 +56,7 @@
def ord(s):
if isinstance(s, int):
return s
- return __builtins__.ord(s)
+ return builtins.ord(s)
%}
//%include "doc.i"
@@ -699,7 +703,7 @@ Result: ['74.125.43.147', '74.125.43.99', '74.125.43.103', '74.125.43.104']
while (idx < slen):
complen = ord(s[idx])
# In python 3.x `str()` converts the string to unicode which is the expected text string type
- res.append(str(s[idx+1:idx+1+complen]))
+ res.append(str(s[idx+1:idx+1+complen].decode()))
idx += complen + 1
return res
diff --git a/contrib/unbound/services/listen_dnsport.c b/contrib/unbound/services/listen_dnsport.c
index 0ce0a6b..3e5bf40 100644
--- a/contrib/unbound/services/listen_dnsport.c
+++ b/contrib/unbound/services/listen_dnsport.c
@@ -372,29 +372,47 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr,
* (and also uses the interface mtu to determine the size of the packets).
* So there won't be any EMSGSIZE error. Against DNS fragmentation attacks.
* FreeBSD already has same semantics without setting the option. */
-# if defined(IP_PMTUDISC_OMIT)
- int action = IP_PMTUDISC_OMIT;
-# else
- int action = IP_PMTUDISC_DONT;
-# endif
+ int omit_set = 0;
+ int action;
+# if defined(IP_PMTUDISC_OMIT)
+ action = IP_PMTUDISC_OMIT;
if (setsockopt(s, IPPROTO_IP, IP_MTU_DISCOVER,
&action, (socklen_t)sizeof(action)) < 0) {
- log_err("setsockopt(..., IP_MTU_DISCOVER, "
-# if defined(IP_PMTUDISC_OMIT)
- "IP_PMTUDISC_OMIT"
+
+ if (errno != EINVAL) {
+ log_err("setsockopt(..., IP_MTU_DISCOVER, IP_PMTUDISC_OMIT...) failed: %s",
+ strerror(errno));
+
+# ifndef USE_WINSOCK
+ close(s);
# else
- "IP_PMTUDISC_DONT"
+ closesocket(s);
# endif
- "...) failed: %s",
- strerror(errno));
+ *noproto = 0;
+ *inuse = 0;
+ return -1;
+ }
+ }
+ else
+ {
+ omit_set = 1;
+ }
+# endif
+ if (omit_set == 0) {
+ action = IP_PMTUDISC_DONT;
+ if (setsockopt(s, IPPROTO_IP, IP_MTU_DISCOVER,
+ &action, (socklen_t)sizeof(action)) < 0) {
+ log_err("setsockopt(..., IP_MTU_DISCOVER, IP_PMTUDISC_DONT...) failed: %s",
+ strerror(errno));
# ifndef USE_WINSOCK
- close(s);
+ close(s);
# else
- closesocket(s);
+ closesocket(s);
# endif
- *noproto = 0;
- *inuse = 0;
- return -1;
+ *noproto = 0;
+ *inuse = 0;
+ return -1;
+ }
}
# elif defined(IP_DONTFRAG)
int off = 0;
@@ -580,17 +598,18 @@ create_local_accept_sock(const char *path, int* noproto)
{
#ifdef HAVE_SYS_UN_H
int s;
- struct sockaddr_un sun;
+ struct sockaddr_un usock;
+ verbose(VERB_ALGO, "creating unix socket %s", path);
#ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
/* this member exists on BSDs, not Linux */
- sun.sun_len = (sa_family_t)sizeof(sun);
+ usock.sun_len = (socklen_t)sizeof(usock);
#endif
- sun.sun_family = AF_LOCAL;
+ usock.sun_family = AF_LOCAL;
/* length is 92-108, 104 on FreeBSD */
- (void)strlcpy(sun.sun_path, path, sizeof(sun.sun_path));
+ (void)strlcpy(usock.sun_path, path, sizeof(usock.sun_path));
- if ((s = socket(PF_LOCAL, SOCK_STREAM, 0)) == -1) {
+ if ((s = socket(AF_LOCAL, SOCK_STREAM, 0)) == -1) {
log_err("Cannot create local socket %s (%s)",
path, strerror(errno));
return -1;
@@ -603,7 +622,7 @@ create_local_accept_sock(const char *path, int* noproto)
return -1;
}
- if (bind(s, (struct sockaddr *)&sun,
+ if (bind(s, (struct sockaddr *)&usock,
(socklen_t)sizeof(struct sockaddr_un)) == -1) {
log_err("Cannot bind local socket %s (%s)",
path, strerror(errno));
@@ -623,6 +642,7 @@ create_local_accept_sock(const char *path, int* noproto)
(void)noproto; /*unused*/
return s;
#else
+ (void)path;
log_err("Local sockets are not supported");
*noproto = 1;
return -1;
diff --git a/contrib/unbound/services/localzone.c b/contrib/unbound/services/localzone.c
index d285a12..57510bd 100644
--- a/contrib/unbound/services/localzone.c
+++ b/contrib/unbound/services/localzone.c
@@ -48,6 +48,7 @@
#include "util/data/packed_rrset.h"
#include "util/data/msgencode.h"
#include "util/net_help.h"
+#include "util/netevent.h"
#include "util/data/msgreply.h"
#include "util/data/msgparse.h"
@@ -1022,6 +1023,10 @@ void local_zones_print(struct local_zones* zones)
log_nametypeclass(0, "static zone",
z->name, 0, z->dclass);
break;
+ case local_zone_inform:
+ log_nametypeclass(0, "inform zone",
+ z->name, 0, z->dclass);
+ break;
default:
log_nametypeclass(0, "badtyped zone",
z->name, 0, z->dclass);
@@ -1169,9 +1174,25 @@ lz_zone_answer(struct local_zone* z, struct query_info* qinfo,
return 0;
}
+/** print log information for an inform zone query */
+static void
+lz_inform_print(struct local_zone* z, struct query_info* qinfo,
+ struct comm_reply* repinfo)
+{
+ char ip[128], txt[512];
+ char zname[LDNS_MAX_DOMAINLEN+1];
+ uint16_t port = ntohs(((struct sockaddr_in*)&repinfo->addr)->sin_port);
+ dname_str(z->name, zname);
+ addr_to_str(&repinfo->addr, repinfo->addrlen, ip, sizeof(ip));
+ snprintf(txt, sizeof(txt), "%s inform %s@%u", zname, ip,
+ (unsigned)port);
+ log_nametypeclass(0, txt, qinfo->qname, qinfo->qtype, qinfo->qclass);
+}
+
int
local_zones_answer(struct local_zones* zones, struct query_info* qinfo,
- struct edns_data* edns, sldns_buffer* buf, struct regional* temp)
+ struct edns_data* edns, sldns_buffer* buf, struct regional* temp,
+ struct comm_reply* repinfo)
{
/* see if query is covered by a zone,
* if so: - try to match (exact) local data
@@ -1190,6 +1211,9 @@ local_zones_answer(struct local_zones* zones, struct query_info* qinfo,
lock_rw_rdlock(&z->lock);
lock_rw_unlock(&zones->lock);
+ if(z->type == local_zone_inform && repinfo)
+ lz_inform_print(z, qinfo, repinfo);
+
if(local_data_answer(z, qinfo, edns, buf, temp, labs, &ld)) {
lock_rw_unlock(&z->lock);
return 1;
@@ -1209,6 +1233,7 @@ const char* local_zone_type2str(enum localzone_type t)
case local_zone_typetransparent: return "typetransparent";
case local_zone_static: return "static";
case local_zone_nodefault: return "nodefault";
+ case local_zone_inform: return "inform";
}
return "badtyped";
}
@@ -1227,6 +1252,8 @@ int local_zone_str2type(const char* type, enum localzone_type* t)
*t = local_zone_typetransparent;
else if(strcmp(type, "redirect") == 0)
*t = local_zone_redirect;
+ else if(strcmp(type, "inform") == 0)
+ *t = local_zone_inform;
else return 0;
return 1;
}
diff --git a/contrib/unbound/services/localzone.h b/contrib/unbound/services/localzone.h
index 788fbfb..29ba866 100644
--- a/contrib/unbound/services/localzone.h
+++ b/contrib/unbound/services/localzone.h
@@ -49,6 +49,7 @@ struct config_file;
struct edns_data;
struct query_info;
struct sldns_buffer;
+struct comm_reply;
/**
* Local zone type
@@ -70,7 +71,9 @@ enum localzone_type {
local_zone_redirect,
/** remove default AS112 blocking contents for zone
* nodefault is used in config not during service. */
- local_zone_nodefault
+ local_zone_nodefault,
+ /** log client address, but no block (transparent) */
+ local_zone_inform
};
/**
@@ -220,12 +223,14 @@ void local_zones_print(struct local_zones* zones);
* @param edns: edns info (parsed).
* @param buf: buffer with query ID and flags, also for reply.
* @param temp: temporary storage region.
+ * @param repinfo: source address for checks. may be NULL.
* @return true if answer is in buffer. false if query is not answered
* by authority data. If the reply should be dropped altogether, the return
* value is true, but the buffer is cleared (empty).
*/
int local_zones_answer(struct local_zones* zones, struct query_info* qinfo,
- struct edns_data* edns, struct sldns_buffer* buf, struct regional* temp);
+ struct edns_data* edns, struct sldns_buffer* buf, struct regional* temp,
+ struct comm_reply* repinfo);
/**
* Parse the string into localzone type.
diff --git a/contrib/unbound/smallapp/unbound-checkconf.c b/contrib/unbound/smallapp/unbound-checkconf.c
index 7723c33..b5d7b9f 100644
--- a/contrib/unbound/smallapp/unbound-checkconf.c
+++ b/contrib/unbound/smallapp/unbound-checkconf.c
@@ -78,6 +78,7 @@ usage()
printf(" Checks unbound configuration file for errors.\n");
printf("file if omitted %s is used.\n", CONFIGFILE);
printf("-o option print value of option to stdout.\n");
+ printf("-f output full pathname with chroot applied, eg. with -o pidfile.\n");
printf("-h show this usage help.\n");
printf("Version %s\n", PACKAGE_VERSION);
printf("BSD licensed, see LICENSE in source package for details.\n");
@@ -90,10 +91,15 @@ usage()
* @param cfg: config
* @param opt: option name without trailing :.
* This is different from config_set_option.
+ * @param final: if final pathname with chroot applied has to be printed.
*/
static void
-print_option(struct config_file* cfg, const char* opt)
+print_option(struct config_file* cfg, const char* opt, int final)
{
+ if(strcmp(opt, "pidfile") == 0 && final) {
+ printf("%s\n", fname_after_chroot(cfg->pidfile, cfg, 1));
+ return;
+ }
if(!config_get_option(cfg, opt, config_print_func, stdout))
fatal_exit("cannot print option '%s'", opt);
}
@@ -456,7 +462,7 @@ check_hints(struct config_file* cfg)
/** check config file */
static void
-checkconf(const char* cfgfile, const char* opt)
+checkconf(const char* cfgfile, const char* opt, int final)
{
struct config_file* cfg = config_create();
if(!cfg)
@@ -467,7 +473,7 @@ checkconf(const char* cfgfile, const char* opt)
exit(1);
}
if(opt) {
- print_option(cfg, opt);
+ print_option(cfg, opt, final);
config_delete(cfg);
return;
}
@@ -493,6 +499,7 @@ extern char* optarg;
int main(int argc, char* argv[])
{
int c;
+ int final = 0;
const char* f;
const char* opt = NULL;
const char* cfgfile = CONFIGFILE;
@@ -505,8 +512,11 @@ int main(int argc, char* argv[])
cfgfile = CONFIGFILE;
#endif /* USE_WINSOCK */
/* parse the options */
- while( (c=getopt(argc, argv, "ho:")) != -1) {
+ while( (c=getopt(argc, argv, "fho:")) != -1) {
switch(c) {
+ case 'f':
+ final = 1;
+ break;
case 'o':
opt = optarg;
break;
@@ -523,7 +533,7 @@ int main(int argc, char* argv[])
if(argc == 1)
f = argv[0];
else f = cfgfile;
- checkconf(f, opt);
+ checkconf(f, opt, final);
checklock_stop();
return 0;
}
diff --git a/contrib/unbound/smallapp/unbound-control-setup.sh b/contrib/unbound/smallapp/unbound-control-setup.sh
index f22f4b8..010bfd4 100755
--- a/contrib/unbound/smallapp/unbound-control-setup.sh
+++ b/contrib/unbound/smallapp/unbound-control-setup.sh
@@ -36,8 +36,7 @@
# settings:
# directory for files
-prefix=
-DESTDIR=${prefix}/etc/unbound
+DESTDIR=/var/unbound
# issuer and subject name for certificates
SERVERNAME=unbound
diff --git a/contrib/unbound/smallapp/unbound-control-setup.sh.in b/contrib/unbound/smallapp/unbound-control-setup.sh.in
index 79605dc..75e76e2 100755
--- a/contrib/unbound/smallapp/unbound-control-setup.sh.in
+++ b/contrib/unbound/smallapp/unbound-control-setup.sh.in
@@ -36,8 +36,7 @@
# settings:
# directory for files
-prefix=@prefix@
-DESTDIR=@sysconfdir@/unbound
+DESTDIR=@ub_conf_dir@
# issuer and subject name for certificates
SERVERNAME=unbound
diff --git a/contrib/unbound/smallapp/unbound-control.c b/contrib/unbound/smallapp/unbound-control.c
index ac8d968..3b47d3b 100644
--- a/contrib/unbound/smallapp/unbound-control.c
+++ b/contrib/unbound/smallapp/unbound-control.c
@@ -204,12 +204,12 @@ contact_server(const char* svr, struct config_file* cfg, int statuscmd)
fatal_exit("could not parse IP@port: %s", svr);
#ifdef HAVE_SYS_UN_H
} else if(svr[0] == '/') {
- struct sockaddr_un* sun = (struct sockaddr_un *) &addr;
- sun->sun_family = AF_LOCAL;
+ struct sockaddr_un* usock = (struct sockaddr_un *) &addr;
+ usock->sun_family = AF_LOCAL;
#ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN
- sun->sun_len = (sa_family_t)sizeof(sun);
+ usock->sun_len = (socklen_t)sizeof(usock);
#endif
- (void)strlcpy(sun->sun_path, svr, sizeof(sun->sun_path));
+ (void)strlcpy(usock->sun_path, svr, sizeof(usock->sun_path));
addrlen = (socklen_t)sizeof(struct sockaddr_un);
addrfamily = AF_LOCAL;
#endif
diff --git a/contrib/unbound/util/config_file.c b/contrib/unbound/util/config_file.c
index a2352d5..cdb2b33 100644
--- a/contrib/unbound/util/config_file.c
+++ b/contrib/unbound/util/config_file.c
@@ -55,6 +55,7 @@
#include "util/regional.h"
#include "util/fptr_wlist.h"
#include "util/data/dname.h"
+#include "util/rtt.h"
#include "ldns/wire2str.h"
#include "ldns/parseutil.h"
#ifdef HAVE_GLOB_H
@@ -64,6 +65,11 @@
#include <pwd.h>
#endif
+/** from cfg username, after daemonise setup performed */
+uid_t cfg_uid = (uid_t)-1;
+/** from cfg username, after daemonise setup performed */
+gid_t cfg_gid = (gid_t)-1;
+
/** global config during parsing */
struct config_parser_state* cfg_parser = 0;
@@ -129,13 +135,12 @@ config_create(void)
cfg->prefetch_key = 0;
cfg->infra_cache_slabs = 4;
cfg->infra_cache_numhosts = 10000;
+ cfg->infra_cache_min_rtt = 50;
cfg->delay_close = 0;
if(!(cfg->outgoing_avail_ports = (int*)calloc(65536, sizeof(int))))
goto error_exit;
init_outgoing_availports(cfg->outgoing_avail_ports, 65536);
if(!(cfg->username = strdup(UB_USERNAME))) goto error_exit;
- cfg->uid = (uid_t)-1;
- cfg->gid = (gid_t)-1;
#ifdef HAVE_CHROOT
if(!(cfg->chrootdir = strdup(CHROOT_DIR))) goto error_exit;
#endif
@@ -375,6 +380,10 @@ int config_set_option(struct config_file* cfg, const char* opt,
{ IS_NUMBER_OR_ZERO; cfg->max_ttl = atoi(val); MAX_TTL=(time_t)cfg->max_ttl;}
else if(strcmp(opt, "cache-min-ttl:") == 0)
{ IS_NUMBER_OR_ZERO; cfg->min_ttl = atoi(val); MIN_TTL=(time_t)cfg->min_ttl;}
+ else if(strcmp(opt, "infra-cache-min-rtt:") == 0) {
+ IS_NUMBER_OR_ZERO; cfg->infra_cache_min_rtt = atoi(val);
+ RTT_MIN_TIMEOUT=cfg->infra_cache_min_rtt;
+ }
else S_NUMBER_OR_ZERO("infra-host-ttl:", host_ttl)
else S_POW2("infra-cache-slabs:", infra_cache_slabs)
else S_SIZET_NONZERO("infra-cache-numhosts:", infra_cache_numhosts)
@@ -623,6 +632,7 @@ config_get_option(struct config_file* cfg, const char* opt,
else O_DEC(opt, "cache-min-ttl", min_ttl)
else O_DEC(opt, "infra-host-ttl", host_ttl)
else O_DEC(opt, "infra-cache-slabs", infra_cache_slabs)
+ else O_DEC(opt, "infra-cache-min-rtt", infra_cache_min_rtt)
else O_MEM(opt, "infra-cache-numhosts", infra_cache_numhosts)
else O_UNS(opt, "delay-close", delay_close)
else O_YNO(opt, "do-ip4", do_ip4)
@@ -1188,6 +1198,7 @@ config_apply(struct config_file* config)
{
MAX_TTL = (time_t)config->max_ttl;
MIN_TTL = (time_t)config->min_ttl;
+ RTT_MIN_TIMEOUT = config->infra_cache_min_rtt;
EDNS_ADVERTISED_SIZE = (uint16_t)config->edns_buffer_size;
MINIMAL_RESPONSES = config->minimal_responses;
RRSET_ROUNDROBIN = config->rrset_roundrobin;
@@ -1200,11 +1211,13 @@ void config_lookup_uid(struct config_file* cfg)
/* translate username into uid and gid */
if(cfg->username && cfg->username[0]) {
struct passwd *pwd;
- if((pwd = getpwnam(cfg->username)) == NULL)
- log_err("user '%s' does not exist.", cfg->username);
- cfg->uid = pwd->pw_uid;
- cfg->gid = pwd->pw_gid;
+ if((pwd = getpwnam(cfg->username)) != NULL) {
+ cfg_uid = pwd->pw_uid;
+ cfg_gid = pwd->pw_gid;
+ }
}
+#else
+ (void)cfg;
#endif
}
diff --git a/contrib/unbound/util/config_file.h b/contrib/unbound/util/config_file.h
index 327eadc..ca512d7 100644
--- a/contrib/unbound/util/config_file.h
+++ b/contrib/unbound/util/config_file.h
@@ -119,6 +119,8 @@ struct config_file {
size_t infra_cache_slabs;
/** max number of hosts in the infra cache */
size_t infra_cache_numhosts;
+ /** min value for infra cache rtt */
+ int infra_cache_min_rtt;
/** delay close of udp-timeouted ports, if 0 no delayclose. in msec */
int delay_close;
@@ -192,8 +194,6 @@ struct config_file {
char* chrootdir;
/** username to change to, if not "". */
char* username;
- uid_t uid;
- gid_t gid;
/** working directory */
char* directory;
/** filename to log to. */
@@ -343,6 +343,11 @@ struct config_file {
int dnstap_log_forwarder_response_messages;
};
+/** from cfg username, after daemonise setup performed */
+extern uid_t cfg_uid;
+/** from cfg username, after daemonise setup performed */
+extern gid_t cfg_gid;
+
/**
* Stub config options
*/
@@ -427,7 +432,7 @@ void config_delete(struct config_file* config);
void config_apply(struct config_file* config);
/**
- * Find username, sets uid and gid.
+ * Find username, sets cfg_uid and cfg_gid.
* @param config: the config structure.
*/
void config_lookup_uid(struct config_file* config);
diff --git a/contrib/unbound/util/configlexer.lex b/contrib/unbound/util/configlexer.lex
index e13bad0..0e22946 100644
--- a/contrib/unbound/util/configlexer.lex
+++ b/contrib/unbound/util/configlexer.lex
@@ -247,6 +247,7 @@ infra-lame-ttl{COLON} { YDVAR(1, VAR_INFRA_LAME_TTL) }
infra-cache-slabs{COLON} { YDVAR(1, VAR_INFRA_CACHE_SLABS) }
infra-cache-numhosts{COLON} { YDVAR(1, VAR_INFRA_CACHE_NUMHOSTS) }
infra-cache-lame-size{COLON} { YDVAR(1, VAR_INFRA_CACHE_LAME_SIZE) }
+infra-cache-min-rtt{COLON} { YDVAR(1, VAR_INFRA_CACHE_MIN_RTT) }
num-queries-per-thread{COLON} { YDVAR(1, VAR_NUM_QUERIES_PER_THREAD) }
jostle-timeout{COLON} { YDVAR(1, VAR_JOSTLE_TIMEOUT) }
delay-close{COLON} { YDVAR(1, VAR_DELAY_CLOSE) }
diff --git a/contrib/unbound/util/configparser.y b/contrib/unbound/util/configparser.y
index cbb5e16..396ea3c 100644
--- a/contrib/unbound/util/configparser.y
+++ b/contrib/unbound/util/configparser.y
@@ -107,6 +107,7 @@ extern struct config_parser_state* cfg_parser;
%token VAR_SSL_SERVICE_KEY VAR_SSL_SERVICE_PEM VAR_SSL_PORT VAR_FORWARD_FIRST
%token VAR_STUB_FIRST VAR_MINIMAL_RESPONSES VAR_RRSET_ROUNDROBIN
%token VAR_MAX_UDP_SIZE VAR_DELAY_CLOSE VAR_UNBLOCK_LAN_ZONES
+%token VAR_INFRA_CACHE_MIN_RTT
%token VAR_DNS64_PREFIX VAR_DNS64_SYNTHALL
%token VAR_DNSTAP VAR_DNSTAP_ENABLE VAR_DNSTAP_SOCKET_PATH
%token VAR_DNSTAP_SEND_IDENTITY VAR_DNSTAP_SEND_VERSION
@@ -175,7 +176,8 @@ content_server: server_num_threads | server_verbosity | server_port |
server_ssl_service_key | server_ssl_service_pem | server_ssl_port |
server_minimal_responses | server_rrset_roundrobin | server_max_udp_size |
server_so_reuseport | server_delay_close | server_unblock_lan_zones |
- server_dns64_prefix | server_dns64_synthall
+ server_dns64_prefix | server_dns64_synthall |
+ server_infra_cache_min_rtt
;
stubstart: VAR_STUB_ZONE
{
@@ -768,6 +770,15 @@ server_infra_cache_slabs: VAR_INFRA_CACHE_SLABS STRING_ARG
free($2);
}
;
+server_infra_cache_min_rtt: VAR_INFRA_CACHE_MIN_RTT STRING_ARG
+ {
+ OUTYY(("P(server_infra_cache_min_rtt:%s)\n", $2));
+ if(atoi($2) == 0 && strcmp($2, "0") != 0)
+ yyerror("number expected");
+ else cfg_parser->cfg->infra_cache_min_rtt = atoi($2);
+ free($2);
+ }
+ ;
server_target_fetch_policy: VAR_TARGET_FETCH_POLICY STRING_ARG
{
OUTYY(("P(server_target_fetch_policy:%s)\n", $2));
@@ -1105,10 +1116,11 @@ server_local_zone: VAR_LOCAL_ZONE STRING_ARG STRING_ARG
if(strcmp($3, "static")!=0 && strcmp($3, "deny")!=0 &&
strcmp($3, "refuse")!=0 && strcmp($3, "redirect")!=0 &&
strcmp($3, "transparent")!=0 && strcmp($3, "nodefault")!=0
- && strcmp($3, "typetransparent")!=0)
+ && strcmp($3, "typetransparent")!=0 &&
+ strcmp($3, "inform")!=0)
yyerror("local-zone type: expected static, deny, "
"refuse, redirect, transparent, "
- "typetransparent or nodefault");
+ "typetransparent, inform or nodefault");
else if(strcmp($3, "nodefault")==0) {
if(!cfg_strlist_insert(&cfg_parser->cfg->
local_zones_nodefault, $2))
diff --git a/contrib/unbound/util/iana_ports.inc b/contrib/unbound/util/iana_ports.inc
index d318477..ce939d5 100644
--- a/contrib/unbound/util/iana_ports.inc
+++ b/contrib/unbound/util/iana_ports.inc
@@ -3819,6 +3819,7 @@
4359,
4361,
4362,
+4366,
4368,
4369,
4370,
@@ -4399,6 +4400,7 @@
6163,
6200,
6201,
+6209,
6222,
6241,
6242,
@@ -4488,6 +4490,8 @@
6628,
6633,
6634,
+6635,
+6636,
6653,
6657,
6670,
@@ -4671,6 +4675,7 @@
7778,
7779,
7781,
+7784,
7786,
7787,
7789,
@@ -4839,6 +4844,8 @@
8912,
8913,
8954,
+8980,
+8981,
8989,
8990,
8991,
diff --git a/contrib/unbound/util/net_help.c b/contrib/unbound/util/net_help.c
index 335ee74..e2b7c38 100644
--- a/contrib/unbound/util/net_help.c
+++ b/contrib/unbound/util/net_help.c
@@ -156,7 +156,12 @@ log_addr(enum verbosity_value v, const char* str,
case AF_INET6: family="ip6";
sinaddr = &((struct sockaddr_in6*)addr)->sin6_addr;
break;
- case AF_LOCAL: family="local"; break;
+ case AF_LOCAL:
+ dest[0]=0;
+ (void)inet_ntop(af, sinaddr, dest,
+ (socklen_t)sizeof(dest));
+ verbose(v, "%s local %s", str, dest);
+ return; /* do not continue and try to get port */
default: break;
}
if(inet_ntop(af, sinaddr, dest, (socklen_t)sizeof(dest)) == 0) {
diff --git a/contrib/unbound/util/rtt.c b/contrib/unbound/util/rtt.c
index 4b44fca..5d86f13 100644
--- a/contrib/unbound/util/rtt.c
+++ b/contrib/unbound/util/rtt.c
@@ -42,6 +42,8 @@
#include "config.h"
#include "util/rtt.h"
+/* overwritten by config: infra_cache_min_rtt: */
+int RTT_MIN_TIMEOUT = 50;
/** calculate RTO from rtt information */
static int
calc_rto(const struct rtt_info* rtt)
diff --git a/contrib/unbound/util/rtt.h b/contrib/unbound/util/rtt.h
index 57e904d..d6da986 100644
--- a/contrib/unbound/util/rtt.h
+++ b/contrib/unbound/util/rtt.h
@@ -56,7 +56,7 @@ struct rtt_info {
};
/** min retransmit timeout value, in milliseconds */
-#define RTT_MIN_TIMEOUT 50
+extern int RTT_MIN_TIMEOUT;
/** max retransmit timeout value, in milliseconds */
#define RTT_MAX_TIMEOUT 120000
diff --git a/contrib/unbound/validator/val_secalgo.c b/contrib/unbound/validator/val_secalgo.c
index d89675f..3437c8d 100644
--- a/contrib/unbound/validator/val_secalgo.c
+++ b/contrib/unbound/validator/val_secalgo.c
@@ -41,8 +41,9 @@
* and do the library calls (for the crypto library in use).
*/
#include "config.h"
-#include "validator/val_secalgo.h"
+/* packed_rrset on top to define enum types (forced by c99 standard) */
#include "util/data/packed_rrset.h"
+#include "validator/val_secalgo.h"
#include "util/log.h"
#include "ldns/rrdef.h"
#include "ldns/keyraw.h"
diff --git a/contrib/unbound/validator/val_utils.c b/contrib/unbound/validator/val_utils.c
index ecf2dfa..475b0c9 100644
--- a/contrib/unbound/validator/val_utils.c
+++ b/contrib/unbound/validator/val_utils.c
@@ -846,6 +846,18 @@ val_fill_reply(struct reply_info* chase, struct reply_info* orig,
chase->ar_numrrsets;
}
+void val_reply_remove_auth(struct reply_info* rep, size_t index)
+{
+ log_assert(index < rep->rrset_count);
+ log_assert(index >= rep->an_numrrsets);
+ log_assert(index < rep->an_numrrsets+rep->ns_numrrsets);
+ memmove(rep->rrsets+index, rep->rrsets+index+1,
+ sizeof(struct ub_packed_rrset_key*)*
+ (rep->rrset_count - index - 1));
+ rep->ns_numrrsets--;
+ rep->rrset_count--;
+}
+
void
val_check_nonsecure(struct val_env* ve, struct reply_info* rep)
{
diff --git a/contrib/unbound/validator/val_utils.h b/contrib/unbound/validator/val_utils.h
index b0344ef..cdb8769 100644
--- a/contrib/unbound/validator/val_utils.h
+++ b/contrib/unbound/validator/val_utils.h
@@ -295,6 +295,13 @@ void val_fill_reply(struct reply_info* chase, struct reply_info* orig,
size_t cname_skip, uint8_t* name, size_t len, uint8_t* signer);
/**
+ * Remove rrset with index from reply, from the authority section.
+ * @param rep: reply to remove it from.
+ * @param index: rrset to remove, must be in the authority section.
+ */
+void val_reply_remove_auth(struct reply_info* rep, size_t index);
+
+/**
* Remove all unsigned or non-secure status rrsets from NS and AR sections.
* So that unsigned data does not get let through to clients, when we have
* found the data to be secure.
diff --git a/contrib/unbound/validator/validator.c b/contrib/unbound/validator/validator.c
index 9d5d5c3..cc07cc2 100644
--- a/contrib/unbound/validator/validator.c
+++ b/contrib/unbound/validator/validator.c
@@ -574,6 +574,61 @@ detect_wrongly_truncated(struct reply_info* rep)
return 1;
}
+/**
+ * For messages that are not referrals, if the chase reply contains an
+ * unsigned NS record in the authority section it could have been
+ * inserted by a (BIND) forwarder that thinks the zone is insecure, and
+ * that has an NS record without signatures in cache. Remove the NS
+ * record since the reply does not hinge on that record (in the authority
+ * section), but do not remove it if it removes the last record from the
+ * answer+authority sections.
+ * @param chase_reply: the chased reply, we have a key for this contents,
+ * so we should have signatures for these rrsets and not having
+ * signatures means it will be bogus.
+ * @param orig_reply: original reply, remove NS from there as well because
+ * we cannot mark the NS record as DNSSEC valid because it is not
+ * validated by signatures.
+ */
+static void
+remove_spurious_authority(struct reply_info* chase_reply,
+ struct reply_info* orig_reply)
+{
+ size_t i, found = 0;
+ int remove = 0;
+ /* if no answer and only 1 auth RRset, do not remove that one */
+ if(chase_reply->an_numrrsets == 0 && chase_reply->ns_numrrsets == 1)
+ return;
+ /* search authority section for unsigned NS records */
+ for(i = chase_reply->an_numrrsets;
+ i < chase_reply->an_numrrsets+chase_reply->ns_numrrsets; i++) {
+ struct packed_rrset_data* d = (struct packed_rrset_data*)
+ chase_reply->rrsets[i]->entry.data;
+ if(ntohs(chase_reply->rrsets[i]->rk.type) == LDNS_RR_TYPE_NS
+ && d->rrsig_count == 0) {
+ found = i;
+ remove = 1;
+ break;
+ }
+ }
+ /* see if we found the entry */
+ if(!remove) return;
+ log_rrset_key(VERB_ALGO, "Removing spurious unsigned NS record "
+ "(likely inserted by forwarder)", chase_reply->rrsets[found]);
+
+ /* find rrset in orig_reply */
+ for(i = orig_reply->an_numrrsets;
+ i < orig_reply->an_numrrsets+orig_reply->ns_numrrsets; i++) {
+ if(ntohs(orig_reply->rrsets[i]->rk.type) == LDNS_RR_TYPE_NS
+ && query_dname_compare(orig_reply->rrsets[i]->rk.dname,
+ chase_reply->rrsets[found]->rk.dname) == 0) {
+ /* remove from orig_msg */
+ val_reply_remove_auth(orig_reply, i);
+ break;
+ }
+ }
+ /* remove rrset from chase_reply */
+ val_reply_remove_auth(chase_reply, found);
+}
/**
* Given a "positive" response -- a response that contains an answer to the
@@ -1642,6 +1697,8 @@ processValidate(struct module_qstate* qstate, struct val_qstate* vq,
}
subtype = val_classify_response(qstate->query_flags, &qstate->qinfo,
&vq->qchase, vq->orig_msg->rep, vq->rrset_skip);
+ if(subtype != VAL_CLASS_REFERRAL)
+ remove_spurious_authority(vq->chase_reply, vq->orig_msg->rep);
/* check signatures in the message;
* answer and authority must be valid, additional is only checked. */
diff --git a/etc/Makefile b/etc/Makefile
index e5ade7f..e5195f6 100644
--- a/etc/Makefile
+++ b/etc/Makefile
@@ -10,10 +10,6 @@ SUBDIR= \
SUBDIR+=sendmail
.endif
-.if ${MK_TESTS} != "no"
-SUBDIR+=tests
-.endif
-
BIN1= crontab \
devd.conf \
devfs.conf \
@@ -54,10 +50,6 @@ BIN1= crontab \
syslog.conf \
termcap.small
-.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "powerpc64"
-BIN1+= libmap32.conf
-.endif
-
.if exists(${.CURDIR}/etc.${MACHINE}/ttys)
BIN1+= etc.${MACHINE}/ttys
.elif exists(${.CURDIR}/etc.${MACHINE_ARCH}/ttys)
diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf
index 2f5cbca..ef3b861 100644
--- a/etc/defaults/rc.conf
+++ b/etc/defaults/rc.conf
@@ -648,7 +648,7 @@ devfs_system_ruleset="" # The name (NOT number) of a ruleset to apply to /dev
devfs_set_rulesets="" # A list of /mount/dev=ruleset_name settings to
# apply (must be mounted already, i.e. fstab(5))
devfs_load_rulesets="YES" # Enable to always load the default rulesets
-performance_cx_lowest="Cmax" # Online CPU idle state
+performance_cx_lowest="C2" # Online CPU idle state
performance_cpu_freq="NONE" # Online CPU frequency
economy_cx_lowest="Cmax" # Offline CPU idle state
economy_cpu_freq="NONE" # Offline CPU frequency
diff --git a/etc/etc.arm/ttys b/etc/etc.arm/ttys
index ba410b7..501bae6 100644
--- a/etc/etc.arm/ttys
+++ b/etc/etc.arm/ttys
@@ -29,7 +29,7 @@
# when going to single-user mode.
console none unknown off secure
#
-ttyv0 "/usr/libexec/getty Pc" xterm off secure
+ttyv0 "/usr/libexec/getty Pc" xterm onifconsole secure
# Virtual terminals
ttyv1 "/usr/libexec/getty Pc" xterm off secure
ttyv2 "/usr/libexec/getty Pc" xterm off secure
@@ -41,7 +41,7 @@ ttyv7 "/usr/libexec/getty Pc" xterm off secure
#ttyv8 "/usr/local/bin/xdm -nodaemon" xterm off secure
# Serial terminals
# The 'dialup' keyword identifies dialin lines to login, fingerd etc.
-ttyu0 "/usr/libexec/getty 3wire" vt100 on secure
+ttyu0 "/usr/libexec/getty 3wire" vt100 onifconsole secure
ttyu1 "/usr/libexec/getty std.9600" dialup off secure
ttyu2 "/usr/libexec/getty std.9600" dialup off secure
ttyu3 "/usr/libexec/getty std.9600" dialup off secure
diff --git a/etc/libmap32.conf b/etc/libmap32.conf
deleted file mode 100644
index 07fb138..0000000
--- a/etc/libmap32.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-# $FreeBSD$
-/usr/lib/private /usr/lib32/private
diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist
index 755b504..efa3837 100644
--- a/etc/mtree/BSD.tests.dist
+++ b/etc/mtree/BSD.tests.dist
@@ -410,6 +410,8 @@
..
vfs
..
+ vm
+ ..
..
usr.bin
apply
@@ -518,6 +520,8 @@
..
cmp
..
+ col
+ ..
comm
..
cut
@@ -550,6 +554,8 @@
regress.multitest.out
..
..
+ soelim
+ ..
timeout
..
tr
diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist
index b182894..f0d42a2 100644
--- a/etc/mtree/BSD.usr.dist
+++ b/etc/mtree/BSD.usr.dist
@@ -8,6 +8,12 @@
bin
..
include
+ private
+ bsdstat
+ ..
+ ucl
+ ..
+ ..
..
lib
aout
@@ -32,16 +38,12 @@
..
i18n
..
- private
- ..
..
lib32
dtrace
..
i18n
..
- private
- ..
..
libdata
gcc
diff --git a/etc/rc.d/Makefile b/etc/rc.d/Makefile
index f1f6afe..1e6e28f 100644
--- a/etc/rc.d/Makefile
+++ b/etc/rc.d/Makefile
@@ -263,10 +263,6 @@ FILES+= routed
FILES+= sendmail
.endif
-.if ${MK_TESTS} != "no"
-SUBDIR+= tests
-.endif
-
.if ${MK_TIMED} != "no"
FILES+= timed
.endif
diff --git a/etc/rc.d/devd b/etc/rc.d/devd
index c7288e4..53532cc 100755
--- a/etc/rc.d/devd
+++ b/etc/rc.d/devd
@@ -4,7 +4,7 @@
#
# PROVIDE: devd
-# REQUIRE: netif
+# REQUIRE: netif ldconfig
# BEFORE: NETWORKING mountcritremote
# KEYWORD: nojail shutdown
diff --git a/etc/rc.d/hostid b/etc/rc.d/hostid
index c4545bd..281b241 100755
--- a/etc/rc.d/hostid
+++ b/etc/rc.d/hostid
@@ -1,6 +1,7 @@
#!/bin/sh
#
# Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
+# Copyright (c) 2015 Xin LI <delphij@FreeBSD.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -55,23 +56,66 @@ hostid_set()
${SYSCTL} kern.hostid=${id} >/dev/null
}
-hostid_hardware()
+valid_hostid()
{
- uuid=`kenv -q smbios.system.uuid`
+ uuid=$1
+
x="[0-9a-f]"
y=$x$x$x$x
+
+ # Check against a blacklist before
+ # accepting the UUID.
case "${uuid}" in
+ 00000000-0000-0000-0000-000000000000)
+ ;;
+ 00020003-0004-0005-0006-000700080009)
+ ;;
+ 03000200-0400-0500-0006-000700080009)
+ ;;
+ 07090201-0103-0301-0807-060504030201)
+ ;;
+ 11111111-1111-1111-1111-111111111111)
+ ;;
+ 11111111-2222-3333-4444-555555555555)
+ ;;
+ 4c4c4544-0000-2010-8020-80c04f202020)
+ ;;
+ 58585858-5858-5858-5858-585858585858)
+ ;;
+ 890e2d14-cacd-45d1-ae66-bc80e8bfeb0f)
+ ;;
+ 8e275844-178f-44a8-aceb-a7d7e5178c63)
+ ;;
+ dc698397-fa54-4cf2-82c8-b1b5307a6a7f)
+ ;;
+ fefefefe-fefe-fefe-fefe-fefefefefefe)
+ ;;
+ *-ffff-ffff-ffff-ffffffffffff)
+ ;;
$y$y-$y-$y-$y-$y$y$y)
- echo "${uuid}"
+ return 0
;;
esac
+
+ return 1
+}
+
+hostid_hardware()
+{
+ uuid=`kenv -q smbios.system.uuid`
+
+ if valid_hostid $uuid; then
+ echo "${uuid}"
+ fi
}
hostid_generate()
{
# First look for UUID in hardware.
uuid=`hostid_hardware`
- if [ -z ${uuid} ]; then
+ if [ -z "${uuid}" ]; then
+ warn "hostid: unable to figure out a UUID from DMI data, generating a new one"
+ sleep 2
# If not found, fall back to software-generated UUID.
uuid=`uuidgen`
fi
@@ -92,11 +136,15 @@ hostid_start()
{
# If ${hostid_file} already exists, we take UUID from there.
if [ -r ${hostid_file} ]; then
- hostid_set `cat ${hostid_file}`
- else
- # No hostid file, generate UUID.
- hostid_generate
+ read saved_hostid < ${hostid_file}
+ if valid_hostid ${saved_hostid}; then
+ hostid_set `cat ${hostid_file}`
+ exit 0
+ fi
fi
+
+ # No hostid file, generate UUID.
+ hostid_generate
}
load_rc_config $name
diff --git a/etc/rc.d/local_unbound b/etc/rc.d/local_unbound
index 5f3d0cf..ce3256d 100755
--- a/etc/rc.d/local_unbound
+++ b/etc/rc.d/local_unbound
@@ -25,7 +25,7 @@ pidfile="/var/run/${name}.pid"
: ${local_unbound_workdir:=/var/unbound}
: ${local_unbound_config:=${local_unbound_workdir}/unbound.conf}
-: ${local_unbound_flags:=-c${local_unbound_config}}
+: ${local_unbound_flags:="-c ${local_unbound_config}"}
: ${local_unbound_forwardconf:=${local_unbound_workdir}/forward.conf}
: ${local_unbound_controlconf:=${local_unbound_workdir}/control.conf}
: ${local_unbound_anchor:=${local_unbound_workdir}/root.key}
diff --git a/gnu/lib/Makefile b/gnu/lib/Makefile
index 373c280..796cefc 100644
--- a/gnu/lib/Makefile
+++ b/gnu/lib/Makefile
@@ -2,7 +2,11 @@
.include <src.opts.mk>
-SUBDIR= csu libgcc libgcov libdialog libgomp libregex libreadline
+SUBDIR= csu libgcc libdialog libregex
+
+.if ${MK_GCC} != "no"
+SUBDIR+= libgcov libgomp
+.endif
.if ${MK_SSP} != "no"
SUBDIR+= libssp
@@ -12,6 +16,10 @@ SUBDIR+= libssp
SUBDIR+= tests
.endif
+.if ${MK_GDB} != "no"
+SUBDIR+= libreadline
+.endif
+
# libsupc++ uses libstdc++ headers, although 'make includes' should
# have taken care of that already.
.if ${MK_GNUCXX} != "no"
diff --git a/gnu/lib/libgomp/Makefile b/gnu/lib/libgomp/Makefile
index 237c14a..d428bd3 100644
--- a/gnu/lib/libgomp/Makefile
+++ b/gnu/lib/libgomp/Makefile
@@ -12,7 +12,7 @@ SHLIB_MAJOR= 1
SRCS= alloc.c barrier.c critical.c env.c \
error.c iter.c loop.c ordered.c parallel.c sections.c \
single.c team.c work.c lock.c mutex.c proc.c sem.c \
- bar.c time.c fortran.c
+ bar.c time.c fortran.c affinity.c
SRCS+= gstdint.h libgomp_f.h omp.h omp_lib.h
INCS+= omp.h
diff --git a/gnu/lib/libgomp/config.h b/gnu/lib/libgomp/config.h
index 6ef541b..547e692 100644
--- a/gnu/lib/libgomp/config.h
+++ b/gnu/lib/libgomp/config.h
@@ -26,6 +26,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
+/* Define if pthread_{,attr_}{g,s}etaffinity_np is supported. */
+#undef HAVE_PTHREAD_AFFINITY_NP
+
/* Define to 1 if you have the <semaphore.h> header file. */
#define HAVE_SEMAPHORE_H 1
@@ -52,6 +55,9 @@
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
+/* Define to 1 if you have the <sys/sysctl.h> header file. */
+#define HAVE_SYS_SYSCTL_H 1
+
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
diff --git a/gnu/usr.bin/cc/Makefile b/gnu/usr.bin/cc/Makefile
index abc9876..65dc087 100644
--- a/gnu/usr.bin/cc/Makefile
+++ b/gnu/usr.bin/cc/Makefile
@@ -12,7 +12,10 @@ SUBDIR+= cpp
.endif
.if ${MK_CXX} != "no"
-SUBDIR+= cc1plus c++ c++filt
+SUBDIR+= cc1plus c++
+.if ${MK_ELFTOOLCHAIN_TOOLS} == "no"
+SUBDIR+= c++filt
+.endif
.endif
.if ${MK_GCOV} != "no"
diff --git a/gnu/usr.bin/groff/src/preproc/Makefile b/gnu/usr.bin/groff/src/preproc/Makefile
index f208bf2..38942fb 100644
--- a/gnu/usr.bin/groff/src/preproc/Makefile
+++ b/gnu/usr.bin/groff/src/preproc/Makefile
@@ -1,6 +1,6 @@
# $FreeBSD$
-SUBDIR= eqn grn html pic refer soelim tbl
+SUBDIR= eqn grn html pic refer tbl
SUBDIR_PARALLEL=
diff --git a/gnu/usr.bin/groff/src/preproc/soelim/Makefile b/gnu/usr.bin/groff/src/preproc/soelim/Makefile
deleted file mode 100644
index 2c68b80..0000000
--- a/gnu/usr.bin/groff/src/preproc/soelim/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-# $FreeBSD$
-
-PROG_CXX= soelim
-SRCS= soelim.cpp
-DPADD= ${LIBGROFF}
-LDADD= ${LIBGROFF}
-CLEANFILES= ${MAN}
-
-.include <bsd.prog.mk>
diff --git a/include/stdlib.h b/include/stdlib.h
index 95db1b3..d5506ff 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -156,7 +156,8 @@ _Noreturn void _Exit(int);
* If we're in a mode greater than C99, expose C11 functions.
*/
#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
-void * aligned_alloc(size_t, size_t) __malloc_like __alloc_size(2);
+void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
+ __alloc_size(2);
int at_quick_exit(void (*)(void));
_Noreturn void
quick_exit(int);
@@ -171,7 +172,7 @@ char *realpath(const char * __restrict, char * __restrict);
int rand_r(unsigned *); /* (TSF) */
#endif
#if __POSIX_VISIBLE >= 200112
-int posix_memalign(void **, size_t, size_t) __nonnull(1)
+int posix_memalign(void **, size_t, size_t) __nonnull(1) __alloc_align(2)
__alloc_size(3); /* (ADV) */
int setenv(const char *, const char *, int);
int unsetenv(const char *);
@@ -303,7 +304,9 @@ void qsort_r(void *, size_t, size_t, void *,
int (*)(void *, const void *, const void *));
int radixsort(const unsigned char **, int, const unsigned char *,
unsigned);
-void *reallocf(void *, size_t) __result_use_check __alloc_size(2);
+void *reallocarray(void *, size_t, size_t) __result_use_check __alloc_size(2)
+ __alloc_size(3);
+void *reallocf(void *, size_t) __alloc_size(2);
int rpmatch(const char *);
void setprogname(const char *);
int sradixsort(const unsigned char **, int, const unsigned char *,
diff --git a/include/stringlist.h b/include/stringlist.h
index d3154b3..7222b31 100644
--- a/include/stringlist.h
+++ b/include/stringlist.h
@@ -12,11 +12,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with 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
diff --git a/kerberos5/lib/Makefile b/kerberos5/lib/Makefile
index d88bb5b..dddb4d2 100644
--- a/kerberos5/lib/Makefile
+++ b/kerberos5/lib/Makefile
@@ -3,7 +3,7 @@
SUBDIR= libasn1 libgssapi_krb5 libgssapi_ntlm libgssapi_spnego libhdb \
libheimntlm libhx509 libkadm5clnt libkadm5srv libkrb5 \
- libroken libsl libvers libkdc libwind libheimsqlite libheimbase libheimipcc libheimipcs
+ libroken libsl libvers libkdc libwind libheimbase libheimipcc libheimipcs
SUBDIR+= libkafs5 # requires krb_err.h from libkrb5
diff --git a/kerberos5/lib/libhdb/Makefile b/kerberos5/lib/libhdb/Makefile
index 2b178b2..7781e63 100644
--- a/kerberos5/lib/libhdb/Makefile
+++ b/kerberos5/lib/libhdb/Makefile
@@ -3,7 +3,7 @@
LIB= hdb
LDFLAGS= -Wl,--no-undefined
VERSION_MAP= ${KRB5DIR}/lib/hdb/version-script.map
-LIBADD= asn1 com_err krb5 roken heimsqlite
+LIBADD= asn1 com_err krb5 roken sqlite3
DPADD= ${LDAPDPADD}
MAN= HDB.3 hdb_entry_ex.3
@@ -56,7 +56,7 @@ SRCS= common.c \
${GEN:S/.x$/.c/:S/.hx$/.h/}
CFLAGS+=-I${KRB5DIR}/lib/hdb -I${KRB5DIR}/lib/asn1 \
- -I${KRB5DIR}/lib/roken -I${KRB5DIR}/lib/sqlite \
+ -I${KRB5DIR}/lib/roken -I${.CURDIR}/../../../contrib/sqlite3/ \
-I${KRB5DIR}/lib/krb5 \
-I. ${LDAPCFLAGS}
CFLAGS+=-DHDB_DB_DIR="\"/var/heimdal\""
diff --git a/kerberos5/lib/libheimsqlite/Makefile b/kerberos5/lib/libheimsqlite/Makefile
deleted file mode 100644
index 8cad7e7..0000000
--- a/kerberos5/lib/libheimsqlite/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-# $FreeBSD$
-
-LIB= heimsqlite
-SRCS= sqlite3.c
-LIBADD= pthread
-CFLAGS+=-I${KRB5DIR}/lib/sqlite
-
-.include <bsd.lib.mk>
-
-.PATH: ${KRB5DIR}/lib/sqlite
diff --git a/lib/Makefile b/lib/Makefile
index 349dfc2..bee05ab 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -8,7 +8,7 @@
# and the main list to avoid needing a SUBDIR_DEPEND line on every library
# naming just these few items.
-SUBDIR_ORDERED= ${_csu} \
+SUBDIR_ORDERED= csu \
.WAIT \
libc \
libc_nonshared \
@@ -65,7 +65,6 @@ SUBDIR= ${SUBDIR_ORDERED} \
${_libldns} \
liblzma \
${_libmagic} \
- libmandoc \
libmemstat \
libmd \
${_libmilter} \
@@ -156,16 +155,6 @@ SUBDIR_DEPEND_libulog= libmd
SUBDIR_DEPEND_libunbound= ${_libldns}
SUBDIR_DEPEND_liblzma= ${_libthr}
-.if exists(${.CURDIR}/csu/${MACHINE_ARCH}-elf)
-_csu=csu/${MACHINE_ARCH}-elf
-.elif exists(${.CURDIR}/csu/${MACHINE_ARCH})
-_csu=csu/${MACHINE_ARCH}
-.elif exists(${.CURDIR}/csu/${MACHINE_CPUARCH}/Makefile)
-_csu=csu/${MACHINE_CPUARCH}
-.else
-_csu=csu
-.endif
-
# NB: keep these sorted by MK_* knobs
.if ${MK_ATM} != "no"
diff --git a/lib/csu/Makefile b/lib/csu/Makefile
index 320a5a4..5f1cddc 100644
--- a/lib/csu/Makefile
+++ b/lib/csu/Makefile
@@ -1,8 +1,7 @@
# $FreeBSD$
-ARCH= ${MACHINE_ARCH:S/i386/i386-elf/}
-.if exists(${.CURDIR}/${ARCH})
-SUBDIR+= ${ARCH}
+.if exists(${.CURDIR}/${MACHINE_ARCH})
+SUBDIR+= ${MACHINE_ARCH}
.else
SUBDIR+= ${MACHINE_CPUARCH}
.endif
diff --git a/lib/csu/i386-elf/Makefile b/lib/csu/i386/Makefile
index d5ca479..d5ca479 100644
--- a/lib/csu/i386-elf/Makefile
+++ b/lib/csu/i386/Makefile
diff --git a/lib/csu/i386-elf/crt1_c.c b/lib/csu/i386/crt1_c.c
index 65de04c..65de04c 100644
--- a/lib/csu/i386-elf/crt1_c.c
+++ b/lib/csu/i386/crt1_c.c
diff --git a/lib/csu/i386-elf/crt1_s.S b/lib/csu/i386/crt1_s.S
index 17ac0e3..17ac0e3 100644
--- a/lib/csu/i386-elf/crt1_s.S
+++ b/lib/csu/i386/crt1_s.S
diff --git a/lib/csu/i386-elf/crti.S b/lib/csu/i386/crti.S
index 77e4e77..77e4e77 100644
--- a/lib/csu/i386-elf/crti.S
+++ b/lib/csu/i386/crti.S
diff --git a/lib/csu/i386-elf/crtn.S b/lib/csu/i386/crtn.S
index 0264e22..0264e22 100644
--- a/lib/csu/i386-elf/crtn.S
+++ b/lib/csu/i386/crtn.S
diff --git a/lib/libc/aarch64/Symbol.map b/lib/libc/aarch64/Symbol.map
index 5b21000..a0b33da 100644
--- a/lib/libc/aarch64/Symbol.map
+++ b/lib/libc/aarch64/Symbol.map
@@ -13,6 +13,7 @@ FBSD_1.0 {
_setjmp;
_longjmp;
+ fabs;
setjmp;
longjmp;
sigsetjmp;
diff --git a/lib/libc/aarch64/gen/Makefile.inc b/lib/libc/aarch64/gen/Makefile.inc
index 32dea00..c4f7c80 100644
--- a/lib/libc/aarch64/gen/Makefile.inc
+++ b/lib/libc/aarch64/gen/Makefile.inc
@@ -1,6 +1,7 @@
# $FreeBSD$
-SRCS+= flt_rounds.c \
+SRCS+= fabs.S \
+ flt_rounds.c \
ldexp.c \
_setjmp.S \
_set_tp.c \
diff --git a/lib/libc/aarch64/gen/fabs.S b/lib/libc/aarch64/gen/fabs.S
new file mode 100644
index 0000000..2f5fd06
--- /dev/null
+++ b/lib/libc/aarch64/gen/fabs.S
@@ -0,0 +1,33 @@
+/*-
+ * Copyright (c) 2015 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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.
+ */
+
+#include <machine/asm.h>
+__FBSDID("$FreeBSD$");
+
+ENTRY(fabs)
+ fabs d0, d0
+ ret
+END(fabs)
diff --git a/lib/libc/arm/SYS.h b/lib/libc/arm/SYS.h
index ed1a045..3254c45 100644
--- a/lib/libc/arm/SYS.h
+++ b/lib/libc/arm/SYS.h
@@ -62,6 +62,7 @@
#define _SYSCALL(x) \
_SYSCALL_NOERROR(x); \
+ it cs; \
bcs PIC_SYM(CERROR, PLT)
#define SYSCALL(x) \
@@ -72,6 +73,7 @@
.weak _C_LABEL(__CONCAT(_,x)); \
.set _C_LABEL(__CONCAT(_,x)),_C_LABEL(__CONCAT(__sys_,x)); \
SYSTRAP(x); \
+ it cs; \
bcs PIC_SYM(CERROR, PLT); \
RET
diff --git a/lib/libc/arm/aeabi/aeabi_vfp_double.S b/lib/libc/arm/aeabi/aeabi_vfp_double.S
index 62100d2..aae49f8 100644
--- a/lib/libc/arm/aeabi/aeabi_vfp_double.S
+++ b/lib/libc/arm/aeabi/aeabi_vfp_double.S
@@ -66,6 +66,7 @@ AEABI_ENTRY(dcmpeq)
LOAD_DREG(d1, r2, r3)
vcmp.f64 d0, d1
vmrs APSR_nzcv, fpscr
+ ite ne
movne r0, #0
moveq r0, #1
RET
@@ -77,8 +78,9 @@ AEABI_ENTRY(dcmplt)
LOAD_DREG(d1, r2, r3)
vcmp.f64 d0, d1
vmrs APSR_nzcv, fpscr
+ ite cs
movcs r0, #0
- movlt r0, #1
+ movcc r0, #1
RET
AEABI_END(dcmplt)
@@ -88,6 +90,7 @@ AEABI_ENTRY(dcmple)
LOAD_DREG(d1, r2, r3)
vcmp.f64 d0, d1
vmrs APSR_nzcv, fpscr
+ ite hi
movhi r0, #0
movls r0, #1
RET
@@ -99,6 +102,7 @@ AEABI_ENTRY(dcmpge)
LOAD_DREG(d1, r2, r3)
vcmp.f64 d0, d1
vmrs APSR_nzcv, fpscr
+ ite lt
movlt r0, #0
movge r0, #1
RET
@@ -110,6 +114,7 @@ AEABI_ENTRY(dcmpgt)
LOAD_DREG(d1, r2, r3)
vcmp.f64 d0, d1
vmrs APSR_nzcv, fpscr
+ ite le
movle r0, #0
movgt r0, #1
RET
@@ -121,6 +126,7 @@ AEABI_ENTRY(dcmpun)
LOAD_DREG(d1, r2, r3)
vcmp.f64 d0, d1
vmrs APSR_nzcv, fpscr
+ ite vc
movvc r0, #0
movvs r0, #1
RET
diff --git a/lib/libc/arm/aeabi/aeabi_vfp_float.S b/lib/libc/arm/aeabi/aeabi_vfp_float.S
index c9a9a7e..7de8daf 100644
--- a/lib/libc/arm/aeabi/aeabi_vfp_float.S
+++ b/lib/libc/arm/aeabi/aeabi_vfp_float.S
@@ -62,6 +62,7 @@ AEABI_ENTRY(fcmpeq)
LOAD_SREGS(s0, s1, r0, r1)
vcmp.f32 s0, s1
vmrs APSR_nzcv, fpscr
+ ite ne
movne r0, #0
moveq r0, #1
RET
@@ -72,8 +73,9 @@ AEABI_ENTRY(fcmplt)
LOAD_SREGS(s0, s1, r0, r1)
vcmp.f32 s0, s1
vmrs APSR_nzcv, fpscr
+ ite cs
movcs r0, #0
- movlt r0, #1
+ movcc r0, #1
RET
AEABI_END(fcmplt)
@@ -82,6 +84,7 @@ AEABI_ENTRY(fcmple)
LOAD_SREGS(s0, s1, r0, r1)
vcmp.f32 s0, s1
vmrs APSR_nzcv, fpscr
+ ite hi
movhi r0, #0
movls r0, #1
RET
@@ -92,6 +95,7 @@ AEABI_ENTRY(fcmpge)
LOAD_SREGS(s0, s1, r0, r1)
vcmp.f32 s0, s1
vmrs APSR_nzcv, fpscr
+ ite lt
movlt r0, #0
movge r0, #1
RET
@@ -102,6 +106,7 @@ AEABI_ENTRY(fcmpgt)
LOAD_SREGS(s0, s1, r0, r1)
vcmp.f32 s0, s1
vmrs APSR_nzcv, fpscr
+ ite le
movle r0, #0
movgt r0, #1
RET
@@ -112,6 +117,7 @@ AEABI_ENTRY(fcmpun)
LOAD_SREGS(s0, s1, r0, r1)
vcmp.f32 s0, s1
vmrs APSR_nzcv, fpscr
+ ite vc
movvc r0, #0
movvs r0, #1
RET
diff --git a/lib/libc/arm/gen/_setjmp.S b/lib/libc/arm/gen/_setjmp.S
index 387f8a9..3de9d99 100644
--- a/lib/libc/arm/gen/_setjmp.S
+++ b/lib/libc/arm/gen/_setjmp.S
@@ -85,7 +85,13 @@ ENTRY(_setjmp)
add r0, r0, #(_JB_REG_R4 * 4)
/* Store integer registers */
+#ifndef __thumb__
stmia r0, {r4-r14}
+#else
+ stmia r0, {r4-r12}
+ str r13, [r0, #((_JB_REG_R13 - _JB_REG_R4) * 4)]
+ str r14, [r0, #((_JB_REG_R14 - _JB_REG_R4) * 4)]
+#endif
mov r0, #0x00000000
RET
@@ -120,15 +126,24 @@ ENTRY(_longjmp)
add r0, r0, #(_JB_REG_R4 * 4)
/* Restore integer registers */
+#ifndef __thumb__
ldmia r0, {r4-r14}
+#else
+ ldmia r0, {r4-r12}
+ ldr r13, [r0, #((_JB_REG_R13 - _JB_REG_R4) * 4)]
+ ldr r14, [r0, #((_JB_REG_R14 - _JB_REG_R4) * 4)]
+#endif
/* Validate sp and r14 */
teq sp, #0
+ it ne
teqne r14, #0
+ it eq
beq botch
/* Set return value */
movs r0, r1
+ it eq
moveq r0, #0x00000001
RET
@@ -137,7 +152,7 @@ botch:
#if !defined(_STANDALONE)
bl PIC_SYM(_C_LABEL(longjmperror), PLT)
bl PIC_SYM(_C_LABEL(abort), PLT)
- b . - 8 /* Cannot get here */
+1: b 1b /* Cannot get here */
#else
b .
#endif
diff --git a/lib/libc/arm/gen/setjmp.S b/lib/libc/arm/gen/setjmp.S
index ad4ba38..6269563 100644
--- a/lib/libc/arm/gen/setjmp.S
+++ b/lib/libc/arm/gen/setjmp.S
@@ -90,7 +90,13 @@ ENTRY(setjmp)
/* Store integer registers */
add r0, r0, #(_JB_REG_R4 * 4)
+#ifndef __thumb__
stmia r0, {r4-r14}
+#else
+ stmia r0, {r4-r12}
+ str r13, [r0, #((_JB_REG_R13 - _JB_REG_R4) * 4)]
+ str r14, [r0, #((_JB_REG_R14 - _JB_REG_R4) * 4)]
+#endif
mov r0, #0x00000000
RET
@@ -133,15 +139,24 @@ ENTRY(__longjmp)
add r0, r0, #(_JB_REG_R4 * 4)
/* Restore integer registers */
+#ifndef __thumb__
ldmia r0, {r4-r14}
+#else
+ ldmia r0, {r4-r12}
+ ldr r13, [r0, #((_JB_REG_R13 - _JB_REG_R4) * 4)]
+ ldr r14, [r0, #((_JB_REG_R14 - _JB_REG_R4) * 4)]
+#endif
/* Validate sp and r14 */
teq sp, #0
+ it ne
teqne r14, #0
+ it eq
beq .Lbotch
/* Set return value */
movs r0, r1
+ it eq
moveq r0, #0x00000001
RET
@@ -149,5 +164,5 @@ ENTRY(__longjmp)
.Lbotch:
bl PIC_SYM(_C_LABEL(longjmperror), PLT)
bl PIC_SYM(_C_LABEL(abort), PLT)
- b . - 8 /* Cannot get here */
+1: b 1b /* Cannot get here */
END(__longjmp)
diff --git a/lib/libc/arm/sys/brk.S b/lib/libc/arm/sys/brk.S
index f3d8d87..e5f8336 100644
--- a/lib/libc/arm/sys/brk.S
+++ b/lib/libc/arm/sys/brk.S
@@ -53,16 +53,10 @@ _C_LABEL(minbrk):
* Change the data segment size
*/
ENTRY(_brk)
-#ifdef PIC
/* Setup the GOT */
- ldr r3, .Lgot
- add r3, pc, r3
-.L1:
- ldr r1, .Lminbrk
- ldr r1, [r3, r1]
-#else
- ldr r1, .Lminbrk
-#endif
+ GOT_INIT(r3, .Lgot, .L1)
+ GOT_GET(r1, r3, .Lminbrk)
+
/* Get the minimum allowable brk address */
ldr r1, [r1]
@@ -71,6 +65,7 @@ ENTRY(_brk)
* if the address is below minbrk.
*/
cmp r0, r1
+ it lt
movlt r0, r1
mov r2, r0
SYSTRAP(break)
@@ -90,10 +85,7 @@ ENTRY(_brk)
RET
.align 2
-#ifdef PIC
-.Lgot:
- .word _GLOBAL_OFFSET_TABLE_ - (.L1+4)
-#endif
+ GOT_INITSYM(.Lgot, .L1)
.Lminbrk:
.word PIC_SYM(_C_LABEL(minbrk), GOT)
.Lcurbrk:
diff --git a/lib/libc/arm/sys/sbrk.S b/lib/libc/arm/sys/sbrk.S
index 7d22aa7..5cd9a03 100644
--- a/lib/libc/arm/sys/sbrk.S
+++ b/lib/libc/arm/sys/sbrk.S
@@ -52,16 +52,10 @@ CURBRK:
* Change the data segment size
*/
ENTRY(_sbrk)
-#ifdef PIC
/* Setup the GOT */
- ldr r3, .Lgot
- add r3, pc, r3
-.L1:
- ldr r2, .Lcurbrk
- ldr r2, [r3, r2]
-#else
- ldr r2, .Lcurbrk
-#endif
+ GOT_INIT(r3, .Lgot, .L1)
+ GOT_GET(r2, r3, .Lcurbrk)
+
/* Get the current brk address */
ldr r1, [r2]
@@ -80,10 +74,7 @@ ENTRY(_sbrk)
RET
.align 0
-#ifdef PIC
-.Lgot:
- .word _GLOBAL_OFFSET_TABLE_ - (.L1+4)
-#endif
+ GOT_INITSYM(.Lgot, .L1)
.Lcurbrk:
.word PIC_SYM(CURBRK, GOT)
END(_sbrk)
diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c
index af80929..e6da5fe 100644
--- a/lib/libc/db/hash/hash.c
+++ b/lib/libc/db/hash/hash.c
@@ -808,7 +808,7 @@ __expand_table(HTAB *hashp)
hashp->DSIZE = dirsize << 1;
}
if ((hashp->dir[new_segnum] =
- (SEGMENT)calloc(hashp->SGSIZE, sizeof(SEGMENT))) == NULL)
+ calloc(hashp->SGSIZE, sizeof(SEGMENT))) == NULL)
return (-1);
hashp->exsegs++;
hashp->nsegs++;
@@ -877,7 +877,7 @@ alloc_segs(HTAB *hashp, int nsegs)
int save_errno;
if ((hashp->dir =
- (SEGMENT *)calloc(hashp->DSIZE, sizeof(SEGMENT *))) == NULL) {
+ calloc(hashp->DSIZE, sizeof(SEGMENT *))) == NULL) {
save_errno = errno;
(void)hdestroy(hashp);
errno = save_errno;
@@ -887,8 +887,7 @@ alloc_segs(HTAB *hashp, int nsegs)
if (nsegs == 0)
return (0);
/* Allocate segments */
- if ((store = (SEGMENT)calloc(nsegs << hashp->SSHIFT,
- sizeof(SEGMENT))) == NULL) {
+ if ((store = calloc(nsegs << hashp->SSHIFT, sizeof(SEGMENT))) == NULL) {
save_errno = errno;
(void)hdestroy(hashp);
errno = save_errno;
diff --git a/lib/libc/gen/directory.3 b/lib/libc/gen/directory.3
index 1e864f8..f0d0f4b 100644
--- a/lib/libc/gen/directory.3
+++ b/lib/libc/gen/directory.3
@@ -28,7 +28,7 @@
.\" @(#)directory.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd July 28, 2014
+.Dd May 6, 2015
.Dt DIRECTORY 3
.Os
.Sh NAME
@@ -263,8 +263,25 @@ function appeared in
function appeared in
.Fx 10.0 .
.Sh BUGS
-The invalidation of
+The behaviour of
.Fn telldir
-tokens when calling
+and
+.Fn seekdir
+is likely to be wrong if there are parallel unlinks happening
+and the directory is larger than one page.
+There is code to ensure that a
.Fn seekdir
-is non-standard.
+to the location given by a
+.Fn telldir
+immediately before the last
+.Fn readdir
+will always set the correct location to return the same value as that last
+.Fn readdir
+performed.
+This is enough for some applications which want to "push back the last entry read" E.g. Samba.
+Seeks back to any other location,
+other than the beginning of the directory,
+may result in unexpected behaviour if deletes are present.
+It is hoped that this situation will be resolved with changes to
+.Fn getdirentries
+and the VFS.
diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c
index 5bdf4ab..7d28797 100644
--- a/lib/libc/gen/dlfcn.c
+++ b/lib/libc/gen/dlfcn.c
@@ -149,10 +149,8 @@ static void
dl_init_phdr_info(void)
{
Elf_Auxinfo *auxp;
- size_t phent;
unsigned int i;
- phent = 0;
for (auxp = __elf_aux_vector; auxp->a_type != AT_NULL; auxp++) {
switch (auxp->a_type) {
case AT_BASE:
@@ -165,9 +163,6 @@ dl_init_phdr_info(void)
phdr_info.dlpi_phdr =
(const Elf_Phdr *)auxp->a_un.a_ptr;
break;
- case AT_PHENT:
- phent = auxp->a_un.a_val;
- break;
case AT_PHNUM:
phdr_info.dlpi_phnum = (Elf_Half)auxp->a_un.a_val;
break;
diff --git a/lib/libc/gen/readdir.c b/lib/libc/gen/readdir.c
index 69f59d1..c6f5d3f 100644
--- a/lib/libc/gen/readdir.c
+++ b/lib/libc/gen/readdir.c
@@ -54,19 +54,25 @@ _readdir_unlocked(dirp, skip)
int skip;
{
struct dirent *dp;
+ long initial_seek;
+ long initial_loc = 0;
for (;;) {
if (dirp->dd_loc >= dirp->dd_size) {
if (dirp->dd_flags & __DTF_READALL)
return (NULL);
+ initial_loc = dirp->dd_loc;
+ dirp->dd_flags &= ~__DTF_SKIPREAD;
dirp->dd_loc = 0;
}
if (dirp->dd_loc == 0 &&
!(dirp->dd_flags & (__DTF_READALL | __DTF_SKIPREAD))) {
+ initial_seek = dirp->dd_seek;
dirp->dd_size = _getdirentries(dirp->dd_fd,
dirp->dd_buf, dirp->dd_len, &dirp->dd_seek);
if (dirp->dd_size <= 0)
return (NULL);
+ _fixtelldir(dirp, initial_seek, initial_loc);
}
dirp->dd_flags &= ~__DTF_SKIPREAD;
dp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc);
diff --git a/lib/libc/gen/rewinddir.c b/lib/libc/gen/rewinddir.c
index 193f4b0..e157cd6 100644
--- a/lib/libc/gen/rewinddir.c
+++ b/lib/libc/gen/rewinddir.c
@@ -51,6 +51,7 @@ rewinddir(dirp)
if (__isthreaded)
_pthread_mutex_lock(&dirp->dd_lock);
+ dirp->dd_flags &= ~__DTF_SKIPREAD; /* current contents are invalid */
if (dirp->dd_flags & __DTF_READALL)
_filldir(dirp, false);
else {
diff --git a/lib/libc/gen/stringlist.c b/lib/libc/gen/stringlist.c
index a09a8e7..236af17 100644
--- a/lib/libc/gen/stringlist.c
+++ b/lib/libc/gen/stringlist.c
@@ -10,8 +10,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 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
diff --git a/lib/libc/gen/telldir.c b/lib/libc/gen/telldir.c
index d72b500..19cd6ee 100644
--- a/lib/libc/gen/telldir.c
+++ b/lib/libc/gen/telldir.c
@@ -101,9 +101,22 @@ _seekdir(dirp, loc)
return;
if (lp->loc_loc == dirp->dd_loc && lp->loc_seek == dirp->dd_seek)
return;
+
+ /* If it's within the same chunk of data, don't bother reloading. */
+ if (lp->loc_seek == dirp->dd_seek) {
+ /*
+ * If we go back to 0 don't make the next readdir
+ * trigger a call to getdirentries().
+ */
+ if (lp->loc_loc == 0)
+ dirp->dd_flags |= __DTF_SKIPREAD;
+ dirp->dd_loc = lp->loc_loc;
+ return;
+ }
(void) lseek(dirp->dd_fd, (off_t)lp->loc_seek, SEEK_SET);
dirp->dd_seek = lp->loc_seek;
dirp->dd_loc = 0;
+ dirp->dd_flags &= ~__DTF_SKIPREAD; /* current contents are invalid */
while (dirp->dd_loc < lp->loc_loc) {
dp = _readdir_unlocked(dirp, 0);
if (dp == NULL)
@@ -112,6 +125,30 @@ _seekdir(dirp, loc)
}
/*
+ * After readdir returns the last entry in a block, a call to telldir
+ * returns a location that is after the end of that last entry.
+ * However, that location doesn't refer to a valid directory entry.
+ * Ideally, the call to telldir would return a location that refers to
+ * the first entry in the next block. That location is not known
+ * until the next block is read, so readdir calls this function after
+ * fetching a new block to fix any such telldir locations.
+ */
+void
+_fixtelldir(DIR *dirp, long oldseek, long oldloc)
+{
+ struct ddloc *lp;
+
+ lp = LIST_FIRST(&dirp->dd_td->td_locq);
+ if (lp != NULL) {
+ if (lp->loc_loc == oldloc &&
+ lp->loc_seek == oldseek) {
+ lp->loc_seek = dirp->dd_seek;
+ lp->loc_loc = dirp->dd_loc;
+ }
+ }
+}
+
+/*
* Reclaim memory for telldir cookies which weren't used.
*/
void
diff --git a/lib/libc/gen/telldir.h b/lib/libc/gen/telldir.h
index 04989bb..bccabb1 100644
--- a/lib/libc/gen/telldir.h
+++ b/lib/libc/gen/telldir.h
@@ -64,5 +64,6 @@ bool _filldir(DIR *, bool);
struct dirent *_readdir_unlocked(DIR *, int);
void _reclaim_telldir(DIR *);
void _seekdir(DIR *, long);
+void _fixtelldir(DIR *dirp, long oldseek, long oldloc);
#endif
diff --git a/lib/libc/net/recv.c b/lib/libc/net/recv.c
index f71d478..6a584ca 100644
--- a/lib/libc/net/recv.c
+++ b/lib/libc/net/recv.c
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/socket.h>
+#include "libc_private.h"
#include <stddef.h>
@@ -48,5 +49,8 @@ recv(s, buf, len, flags)
* POSIX says recv() shall be a cancellation point, so call the
* cancellation-enabled recvfrom() and not _recvfrom().
*/
- return (recvfrom(s, buf, len, flags, NULL, 0));
+ return (((ssize_t (*)(int, void *, size_t, int,
+ struct sockaddr *, socklen_t *))
+ __libc_interposing[INTERPOS_recvfrom])(s, buf, len, flags,
+ NULL, NULL));
}
diff --git a/lib/libc/net/send.c b/lib/libc/net/send.c
index 93cdfda..c44f4b9 100644
--- a/lib/libc/net/send.c
+++ b/lib/libc/net/send.c
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/socket.h>
+#include "libc_private.h"
#include <stddef.h>
@@ -48,5 +49,8 @@ send(s, msg, len, flags)
* POSIX says send() shall be a cancellation point, so call the
* cancellation-enabled sendto() and not _sendto().
*/
- return (sendto(s, msg, len, flags, NULL, 0));
+ return (((ssize_t (*)(int, const void *, size_t, int,
+ const struct sockaddr *, socklen_t))
+ __libc_interposing[INTERPOS_sendto])(s, msg, len, flags,
+ NULL, 0));
}
diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc
index 57205a7..7cee03a 100644
--- a/lib/libc/stdlib/Makefile.inc
+++ b/lib/libc/stdlib/Makefile.inc
@@ -10,7 +10,8 @@ MISRCS+=_Exit.c a64l.c abort.c abs.c atexit.c atof.c atoi.c atol.c atoll.c \
insque.c l64a.c labs.c ldiv.c llabs.c lldiv.c lsearch.c \
merge.c mergesort_b.c ptsname.c qsort.c qsort_r.c quick_exit.c \
radixsort.c rand.c \
- random.c reallocf.c realpath.c remque.c strfmon.c strtoimax.c \
+ random.c reallocarray.c reallocf.c realpath.c remque.c strfmon.c \
+ strtoimax.c \
strtol.c strtoll.c strtoq.c strtoul.c strtonum.c strtoull.c \
strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c
@@ -25,7 +26,7 @@ MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 \
hcreate.3 imaxabs.3 imaxdiv.3 insque.3 labs.3 ldiv.3 llabs.3 lldiv.3 \
lsearch.3 memory.3 ptsname.3 qsort.3 \
quick_exit.3 \
- radixsort.3 rand.3 random.3 reallocf.3 \
+ radixsort.3 rand.3 random.3 reallocarray.3 reallocf.3 \
realpath.3 strfmon.3 strtod.3 strtol.3 strtonum.3 strtoul.3 system.3 \
tsearch.3
diff --git a/lib/libc/stdlib/Symbol.map b/lib/libc/stdlib/Symbol.map
index 39eab7d..782023e 100644
--- a/lib/libc/stdlib/Symbol.map
+++ b/lib/libc/stdlib/Symbol.map
@@ -113,6 +113,7 @@ FBSD_1.4 {
hcreate_r;
hdestroy_r;
hsearch_r;
+ reallocarray;
};
FBSDprivate_1.0 {
diff --git a/lib/libc/stdlib/reallocarray.3 b/lib/libc/stdlib/reallocarray.3
new file mode 100644
index 0000000..8e714f4
--- /dev/null
+++ b/lib/libc/stdlib/reallocarray.3
@@ -0,0 +1,142 @@
+.\" Copyright (c) 1980, 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" This code is derived from software contributed to Berkeley by
+.\" the American National Standards Committee X3, on Information
+.\" Processing 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.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING 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 May 1, 2015
+.Dt REALLOCARRAY 3
+.Os
+.Sh NAME
+.Nm reallocarray
+.Nd memory reallocation function
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In stdlib.h
+.Ft void *
+.Fn reallocarray "void *ptr" "size_t nmemb" "size_t size"
+.Sh DESCRIPTION
+The
+.Fn reallocarray
+function is similar to the
+.Fn realloc
+function
+except it operates on
+.Fa nmemb
+members of size
+.Fa size
+and checks for integer overflow in the calculation
+.Fa nmemb
+*
+.Fa size .
+.Sh RETURN VALUES
+The
+.Fn reallocarray
+function returns a pointer to the allocated space; otherwise, a
+.Dv NULL
+pointer is returned and
+.Va errno
+is set to
+.Er ENOMEM .
+.Sh EXAMPLES
+Consider
+.Fn reallocarray
+when there is multiplication in the
+.Fa size
+argument of
+.Fn malloc
+or
+.Fn realloc .
+For example, avoid this common idiom as it may lead to integer overflow:
+.Bd -literal -offset indent
+if ((p = malloc(num * size)) == NULL)
+ err(1, "malloc");
+.Ed
+.Pp
+A drop-in replacement is the
+.Ox
+extension
+.Fn reallocarray :
+.Bd -literal -offset indent
+if ((p = reallocarray(NULL, num, size)) == NULL)
+ err(1, "reallocarray");
+.Ed
+.Pp
+When using
+.Fn realloc ,
+be careful to avoid the following idiom:
+.Bd -literal -offset indent
+size += 50;
+if ((p = realloc(p, size)) == NULL)
+ return (NULL);
+.Ed
+.Pp
+Do not adjust the variable describing how much memory has been allocated
+until the allocation has been successful.
+This can cause aberrant program behavior if the incorrect size value is used.
+In most cases, the above sample will also result in a leak of memory.
+As stated earlier, a return value of
+.Dv NULL
+indicates that the old object still remains allocated.
+Better code looks like this:
+.Bd -literal -offset indent
+newsize = size + 50;
+if ((newp = realloc(p, newsize)) == NULL) {
+ free(p);
+ p = NULL;
+ size = 0;
+ return (NULL);
+}
+p = newp;
+size = newsize;
+.Ed
+.Pp
+As with
+.Fn malloc ,
+it is important to ensure the new size value will not overflow;
+i.e. avoid allocations like the following:
+.Bd -literal -offset indent
+if ((newp = realloc(p, num * size)) == NULL) {
+ ...
+.Ed
+.Pp
+Instead, use
+.Fn reallocarray :
+.Bd -literal -offset indent
+if ((newp = reallocarray(p, num, size)) == NULL) {
+ ...
+.Ed
+.Sh SEE ALSO
+.Xr realloc 3
+.Sh HISTORY
+The
+.Fn reallocarray
+function first appeared in
+.Ox 5.6
+and
+.Fx 11.0 .
diff --git a/lib/libc/stdlib/reallocarray.c b/lib/libc/stdlib/reallocarray.c
new file mode 100644
index 0000000..e1e9b7c
--- /dev/null
+++ b/lib/libc/stdlib/reallocarray.c
@@ -0,0 +1,42 @@
+/* $OpenBSD: reallocarray.c,v 1.2 2014/12/08 03:45:00 bcook Exp $ */
+/*
+ * Copyright (c) 2008 Otto Moerbeek <otto@drijf.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+/*
+ * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX
+ * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW
+ */
+#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
+
+void *
+reallocarray(void *optr, size_t nmemb, size_t size)
+{
+
+ if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
+ nmemb > 0 && SIZE_MAX / nmemb < size) {
+ errno = ENOMEM;
+ return (NULL);
+ }
+ return (realloc(optr, size * nmemb));
+}
diff --git a/lib/libc/sys/fork.2 b/lib/libc/sys/fork.2
index 1ad2052f..4fda74d 100644
--- a/lib/libc/sys/fork.2
+++ b/lib/libc/sys/fork.2
@@ -28,7 +28,7 @@
.\" @(#)fork.2 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd May 31, 2013
+.Dd May 1, 2015
.Dt FORK 2
.Os
.Sh NAME
@@ -53,7 +53,10 @@ The child process has a unique process ID.
The child process has a different parent
process ID (i.e., the process ID of the parent process).
.It
-The child process has its own copy of the parent's descriptors.
+The child process has its own copy of the parent's descriptors,
+except for descriptors returned by
+.Xr kqueue 2 ,
+which are not inherited from the parent process.
These descriptors reference the same underlying objects, so that,
for instance, file pointers in file objects are shared between
the child and the parent, so that an
diff --git a/lib/libc/sys/socketpair.2 b/lib/libc/sys/socketpair.2
index d3a47eb..b15553a 100644
--- a/lib/libc/sys/socketpair.2
+++ b/lib/libc/sys/socketpair.2
@@ -28,7 +28,7 @@
.\" @(#)socketpair.2 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd September 11, 2013
+.Dd May 4, 2015
.Dt SOCKETPAIR 2
.Os
.Sh NAME
@@ -40,13 +40,13 @@
.In sys/types.h
.In sys/socket.h
.Ft int
-.Fn socketpair "int fd" "int type" "int protocol" "int *sv"
+.Fn socketpair "int domain" "int type" "int protocol" "int *sv"
.Sh DESCRIPTION
The
.Fn socketpair
system call creates an unnamed pair of connected sockets in
-the specified domain
-.Fa fd ,
+the specified communications
+.Fa domain ,
of the specified
.Fa type ,
and using the optionally specified
diff --git a/lib/libc/sys/truncate.2 b/lib/libc/sys/truncate.2
index f06c1eb..0734464 100644
--- a/lib/libc/sys/truncate.2
+++ b/lib/libc/sys/truncate.2
@@ -28,7 +28,7 @@
.\" @(#)truncate.2 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd December 13, 2006
+.Dd May 4, 2015
.Dt TRUNCATE 2
.Os
.Sh NAME
@@ -60,9 +60,18 @@ is lost.
If the file was smaller than this size,
it will be extended as if by writing bytes
with the value zero.
-With
-.Fn ftruncate ,
-the file must be open for writing.
+.Pp
+The
+.Fn ftruncate
+system call causes the file or shared memory object backing the file descriptor
+.Fa fd
+to be truncated or extended to
+.Fa length
+bytes in size.
+The file descriptor must be a valid file descriptor open for writing.
+The file position pointer associated with the file descriptor
+.Fa fd
+will not be modified.
.Sh RETURN VALUES
.Rv -std
If the file to be modified is not a directory or
@@ -129,7 +138,7 @@ is not a valid descriptor.
The
.Fa fd
argument
-references a socket, not a file.
+references a file descriptor that is not a regular file or shared memory object.
.It Bq Er EINVAL
The
.Fa fd
@@ -138,11 +147,14 @@ is not open for writing.
.El
.Sh SEE ALSO
.Xr chflags 2 ,
-.Xr open 2
+.Xr open 2 ,
+.Xr shm_open 2
.Sh HISTORY
The
.Fn truncate
-system call appeared in
+and
+.Fn ftruncate
+system calls appeared in
.Bx 4.2 .
.Sh BUGS
These calls should be generalized to allow ranges
diff --git a/lib/libc/tests/sys/Makefile b/lib/libc/tests/sys/Makefile
index 89431bc..5e457fd 100644
--- a/lib/libc/tests/sys/Makefile
+++ b/lib/libc/tests/sys/Makefile
@@ -12,7 +12,9 @@ NETBSD_ATF_TESTS_C+= clock_gettime_test
NETBSD_ATF_TESTS_C+= connect_test
NETBSD_ATF_TESTS_C+= dup_test
NETBSD_ATF_TESTS_C+= fsync_test
+.if ${MACHINE} != "arm64" # ARM64TODO: Missing makecontext
NETBSD_ATF_TESTS_C+= getcontext_test
+.endif
NETBSD_ATF_TESTS_C+= getgroups_test
NETBSD_ATF_TESTS_C+= getitimer_test
NETBSD_ATF_TESTS_C+= getlogin_test
diff --git a/lib/libcapsicum/libcapsicum.3 b/lib/libcapsicum/libcapsicum.3
index 9df565a..cbfd214 100644
--- a/lib/libcapsicum/libcapsicum.3
+++ b/lib/libcapsicum/libcapsicum.3
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 14, 2014
+.Dd May 2, 2015
.Dt LIBCAPSICUM 3
.Os
.Sh NAME
@@ -68,9 +68,9 @@
.Ft "int"
.Fn cap_send_nvlist "const cap_channel_t *chan" "const nvlist_t *nvl"
.Ft "nvlist_t *"
-.Fn cap_recv_nvlist "const cap_channel_t *chan"
+.Fn cap_recv_nvlist "const cap_channel_t *chan" "int flags"
.Ft "nvlist_t *"
-.Fn cap_xfer_nvlist "const cap_channel_t *chan" "nvlist_t *nvl"
+.Fn cap_xfer_nvlist "const cap_channel_t *chan" "nvlist_t *nvl" "int flags"
.In libcapsicum_service.h
.Ft "cap_channel_t *"
.Fn cap_service_open "const cap_channel_t *chan" "const char *name"
@@ -171,11 +171,23 @@ Most services should provide higher level API.
The
.Fn cap_recv_nvlist
function receives the given nvlist over the given capability.
+The
+.Fa flags
+argument defines what type the top nvlist is expected to be.
+If the nvlist flags do not match the flags passed to
+.Fn cap_recv_nvlist ,
+the nvlist will not be returned.
.Pp
The
.Fn cap_xfer_nvlist
function sends the given nvlist, destroys it and receives new nvlist in
response over the given capability.
+The
+.Fa flags
+argument defines what type the top nvlist is expected to be.
+If the nvlist flags do not match the flags passed to
+.Fn cap_xfer_nvlist ,
+the nvlist will not be returned.
It does not matter if the function succeeds or fails, the nvlist given
for sending will always be destroyed once the function returns.
.Pp
diff --git a/lib/libcapsicum/libcapsicum.c b/lib/libcapsicum/libcapsicum.c
index 79ca871..79c570f 100644
--- a/lib/libcapsicum/libcapsicum.c
+++ b/lib/libcapsicum/libcapsicum.c
@@ -142,7 +142,7 @@ cap_clone(const cap_channel_t *chan)
nvl = nvlist_create(0);
nvlist_add_string(nvl, "cmd", "clone");
- nvl = cap_xfer_nvlist(chan, nvl);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
if (nvl == NULL)
return (NULL);
if (nvlist_get_number(nvl, "error") != 0) {
@@ -195,7 +195,7 @@ cap_limit_set(const cap_channel_t *chan, nvlist_t *limits)
nvlmsg = nvlist_create(0);
nvlist_add_string(nvlmsg, "cmd", "limit_set");
nvlist_add_nvlist(nvlmsg, "limits", limits);
- nvlmsg = cap_xfer_nvlist(chan, nvlmsg);
+ nvlmsg = cap_xfer_nvlist(chan, nvlmsg, 0);
if (nvlmsg == NULL) {
nvlist_destroy(limits);
return (-1);
@@ -218,7 +218,7 @@ cap_limit_get(const cap_channel_t *chan, nvlist_t **limitsp)
nvlmsg = nvlist_create(0);
nvlist_add_string(nvlmsg, "cmd", "limit_get");
- nvlmsg = cap_xfer_nvlist(chan, nvlmsg);
+ nvlmsg = cap_xfer_nvlist(chan, nvlmsg, 0);
if (nvlmsg == NULL)
return (-1);
error = (int)nvlist_get_number(nvlmsg, "error");
@@ -246,21 +246,21 @@ cap_send_nvlist(const cap_channel_t *chan, const nvlist_t *nvl)
}
nvlist_t *
-cap_recv_nvlist(const cap_channel_t *chan)
+cap_recv_nvlist(const cap_channel_t *chan, int flags)
{
assert(chan != NULL);
assert(chan->cch_magic == CAP_CHANNEL_MAGIC);
- return (nvlist_recv(chan->cch_sock));
+ return (nvlist_recv(chan->cch_sock, flags));
}
nvlist_t *
-cap_xfer_nvlist(const cap_channel_t *chan, nvlist_t *nvl)
+cap_xfer_nvlist(const cap_channel_t *chan, nvlist_t *nvl, int flags)
{
assert(chan != NULL);
assert(chan->cch_magic == CAP_CHANNEL_MAGIC);
- return (nvlist_xfer(chan->cch_sock, nvl));
+ return (nvlist_xfer(chan->cch_sock, nvl, flags));
}
diff --git a/lib/libcapsicum/libcapsicum.h b/lib/libcapsicum/libcapsicum.h
index 4f8c597..c7110d8 100644
--- a/lib/libcapsicum/libcapsicum.h
+++ b/lib/libcapsicum/libcapsicum.h
@@ -105,11 +105,11 @@ int cap_send_nvlist(const cap_channel_t *chan, const nvlist_t *nvl);
/*
* Function receives nvlist over the given capability.
*/
-nvlist_t *cap_recv_nvlist(const cap_channel_t *chan);
+nvlist_t *cap_recv_nvlist(const cap_channel_t *chan, int flags);
/*
* Function sends the given nvlist, destroys it and receives new nvlist in
* response over the given capability.
*/
-nvlist_t *cap_xfer_nvlist(const cap_channel_t *chan, nvlist_t *nvl);
+nvlist_t *cap_xfer_nvlist(const cap_channel_t *chan, nvlist_t *nvl, int flags);
#endif /* !_LIBCAPSICUM_H_ */
diff --git a/lib/libcapsicum/libcapsicum_dns.c b/lib/libcapsicum/libcapsicum_dns.c
index 113f8dc..a180b6b 100644
--- a/lib/libcapsicum/libcapsicum_dns.c
+++ b/lib/libcapsicum/libcapsicum_dns.c
@@ -30,6 +30,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <assert.h>
#include <netdb.h>
#include <stdlib.h>
#include <string.h>
@@ -67,6 +68,8 @@ static struct hostent *
hostent_unpack(const nvlist_t *nvl, struct hostent *hp)
{
unsigned int ii, nitems;
+ char nvlname[64];
+ int n;
hostent_free(hp);
@@ -81,8 +84,10 @@ hostent_unpack(const nvlist_t *nvl, struct hostent *hp)
if (hp->h_aliases == NULL)
goto fail;
for (ii = 0; ii < nitems; ii++) {
+ n = snprintf(nvlname, sizeof(nvlname), "alias%u", ii);
+ assert(n > 0 && n < (int)sizeof(nvlname));
hp->h_aliases[ii] =
- strdup(nvlist_getf_string(nvl, "alias%u", ii));
+ strdup(nvlist_get_string(nvl, nvlname));
if (hp->h_aliases[ii] == NULL)
goto fail;
}
@@ -96,7 +101,9 @@ hostent_unpack(const nvlist_t *nvl, struct hostent *hp)
hp->h_addr_list[ii] = malloc(hp->h_length);
if (hp->h_addr_list[ii] == NULL)
goto fail;
- bcopy(nvlist_getf_binary(nvl, NULL, "addr%u", ii),
+ n = snprintf(nvlname, sizeof(nvlname), "addr%u", ii);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ bcopy(nvlist_get_binary(nvl, nvlname, NULL),
hp->h_addr_list[ii], hp->h_length);
}
hp->h_addr_list[ii] = NULL;
@@ -125,7 +132,7 @@ cap_gethostbyname2(cap_channel_t *chan, const char *name, int type)
nvlist_add_string(nvl, "cmd", "gethostbyname");
nvlist_add_number(nvl, "family", (uint64_t)type);
nvlist_add_string(nvl, "name", name);
- nvl = cap_xfer_nvlist(chan, nvl);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
if (nvl == NULL) {
h_errno = NO_RECOVERY;
return (NULL);
@@ -152,7 +159,7 @@ cap_gethostbyaddr(cap_channel_t *chan, const void *addr, socklen_t len,
nvlist_add_string(nvl, "cmd", "gethostbyaddr");
nvlist_add_binary(nvl, "addr", addr, (size_t)len);
nvlist_add_number(nvl, "family", (uint64_t)type);
- nvl = cap_xfer_nvlist(chan, nvl);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
if (nvl == NULL) {
h_errno = NO_RECOVERY;
return (NULL);
@@ -208,8 +215,9 @@ cap_getaddrinfo(cap_channel_t *chan, const char *hostname, const char *servname,
struct addrinfo *firstai, *prevai, *curai;
unsigned int ii;
const nvlist_t *nvlai;
+ char nvlname[64];
nvlist_t *nvl;
- int error;
+ int error, n;
nvl = nvlist_create(0);
nvlist_add_string(nvl, "cmd", "getaddrinfo");
@@ -225,7 +233,7 @@ cap_getaddrinfo(cap_channel_t *chan, const char *hostname, const char *servname,
nvlist_add_number(nvl, "hints.ai_protocol",
(uint64_t)hints->ai_protocol);
}
- nvl = cap_xfer_nvlist(chan, nvl);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
if (nvl == NULL)
return (EAI_MEMORY);
if (nvlist_get_number(nvl, "error") != 0) {
@@ -237,9 +245,11 @@ cap_getaddrinfo(cap_channel_t *chan, const char *hostname, const char *servname,
nvlai = NULL;
firstai = prevai = curai = NULL;
for (ii = 0; ; ii++) {
- if (!nvlist_existsf_nvlist(nvl, "res%u", ii))
+ n = snprintf(nvlname, sizeof(nvlname), "res%u", ii);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ if (!nvlist_exists_nvlist(nvl, nvlname))
break;
- nvlai = nvlist_getf_nvlist(nvl, "res%u", ii);
+ nvlai = nvlist_get_nvlist(nvl, nvlname);
curai = addrinfo_unpack(nvlai);
if (curai == NULL)
break;
@@ -273,7 +283,7 @@ cap_getnameinfo(cap_channel_t *chan, const struct sockaddr *sa, socklen_t salen,
nvlist_add_number(nvl, "servlen", (uint64_t)servlen);
nvlist_add_binary(nvl, "sa", sa, (size_t)salen);
nvlist_add_number(nvl, "flags", (uint64_t)flags);
- nvl = cap_xfer_nvlist(chan, nvl);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
if (nvl == NULL)
return (EAI_MEMORY);
if (nvlist_get_number(nvl, "error") != 0) {
@@ -314,6 +324,8 @@ cap_dns_type_limit(cap_channel_t *chan, const char * const *types,
{
nvlist_t *limits;
unsigned int i;
+ char nvlname[64];
+ int n;
if (cap_limit_get(chan, &limits) < 0)
return (-1);
@@ -321,8 +333,11 @@ cap_dns_type_limit(cap_channel_t *chan, const char * const *types,
limits = nvlist_create(0);
else
limit_remove(limits, "type");
- for (i = 0; i < ntypes; i++)
- nvlist_addf_string(limits, types[i], "type%u", i);
+ for (i = 0; i < ntypes; i++) {
+ n = snprintf(nvlname, sizeof(nvlname), "type%u", i);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_add_string(limits, nvlname, types[i]);
+ }
return (cap_limit_set(chan, limits));
}
@@ -332,6 +347,8 @@ cap_dns_family_limit(cap_channel_t *chan, const int *families,
{
nvlist_t *limits;
unsigned int i;
+ char nvlname[64];
+ int n;
if (cap_limit_get(chan, &limits) < 0)
return (-1);
@@ -340,8 +357,9 @@ cap_dns_family_limit(cap_channel_t *chan, const int *families,
else
limit_remove(limits, "family");
for (i = 0; i < nfamilies; i++) {
- nvlist_addf_number(limits, (uint64_t)families[i],
- "family%u", i);
+ n = snprintf(nvlname, sizeof(nvlname), "family%u", i);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_add_number(limits, nvlname, (uint64_t)families[i]);
}
return (cap_limit_set(chan, limits));
}
diff --git a/lib/libcapsicum/libcapsicum_grp.c b/lib/libcapsicum/libcapsicum_grp.c
index c679ce9..267ac68 100644
--- a/lib/libcapsicum/libcapsicum_grp.c
+++ b/lib/libcapsicum/libcapsicum_grp.c
@@ -94,9 +94,10 @@ group_unpack_members(const nvlist_t *nvl, char ***fieldp, char **bufferp,
size_t *bufsizep)
{
const char *mem;
- char **outstrs, *str;
+ char **outstrs, *str, nvlname[64];
size_t nmem, datasize, strsize;
unsigned int ii;
+ int n;
if (!nvlist_exists_number(nvl, "gr_nmem")) {
datasize = _ALIGNBYTES + sizeof(char *);
@@ -113,7 +114,9 @@ group_unpack_members(const nvlist_t *nvl, char ***fieldp, char **bufferp,
nmem = (size_t)nvlist_get_number(nvl, "gr_nmem");
datasize = _ALIGNBYTES + sizeof(char *) * (nmem + 1);
for (ii = 0; ii < nmem; ii++) {
- mem = dnvlist_getf_string(nvl, NULL, "gr_mem[%u]", ii);
+ n = snprintf(nvlname, sizeof(nvlname), "gr_mem[%u]", ii);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ mem = dnvlist_get_string(nvl, nvlname, NULL);
if (mem == NULL)
return (EINVAL);
datasize += strlen(mem) + 1;
@@ -125,7 +128,9 @@ group_unpack_members(const nvlist_t *nvl, char ***fieldp, char **bufferp,
outstrs = (char **)_ALIGN(*bufferp);
str = (char *)outstrs + sizeof(char *) * (nmem + 1);
for (ii = 0; ii < nmem; ii++) {
- mem = nvlist_getf_string(nvl, "gr_mem[%u]", ii);
+ n = snprintf(nvlname, sizeof(nvlname), "gr_mem[%u]", ii);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ mem = nvlist_get_string(nvl, nvlname);
strsize = strlen(mem) + 1;
memcpy(str, mem, strsize);
outstrs[ii] = str;
@@ -190,7 +195,7 @@ cap_getgrcommon_r(cap_channel_t *chan, const char *cmd, const char *name,
} else {
abort();
}
- nvl = cap_xfer_nvlist(chan, nvl);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
if (nvl == NULL) {
assert(errno != 0);
*result = NULL;
@@ -314,7 +319,7 @@ cap_setgroupent(cap_channel_t *chan, int stayopen)
nvl = nvlist_create(0);
nvlist_add_string(nvl, "cmd", "setgroupent");
nvlist_add_bool(nvl, "stayopen", stayopen != 0);
- nvl = cap_xfer_nvlist(chan, nvl);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
if (nvl == NULL)
return (0);
if (nvlist_get_number(nvl, "error") != 0) {
@@ -334,7 +339,7 @@ cap_setgrent(cap_channel_t *chan)
nvl = nvlist_create(0);
nvlist_add_string(nvl, "cmd", "setgrent");
- nvl = cap_xfer_nvlist(chan, nvl);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
if (nvl == NULL)
return (0);
if (nvlist_get_number(nvl, "error") != 0) {
@@ -355,7 +360,7 @@ cap_endgrent(cap_channel_t *chan)
nvl = nvlist_create(0);
nvlist_add_string(nvl, "cmd", "endgrent");
/* Ignore any errors, we have no way to report them. */
- nvlist_destroy(cap_xfer_nvlist(chan, nvl));
+ nvlist_destroy(cap_xfer_nvlist(chan, nvl, 0));
}
int
@@ -407,6 +412,8 @@ cap_grp_limit_groups(cap_channel_t *chan, const char * const *names,
{
nvlist_t *limits, *groups;
unsigned int i;
+ char nvlname[64];
+ int n;
if (cap_limit_get(chan, &limits) < 0)
return (-1);
@@ -417,10 +424,16 @@ cap_grp_limit_groups(cap_channel_t *chan, const char * const *names,
nvlist_free_nvlist(limits, "groups");
}
groups = nvlist_create(0);
- for (i = 0; i < ngids; i++)
- nvlist_addf_number(groups, (uint64_t)gids[i], "gid%u", i);
- for (i = 0; i < nnames; i++)
- nvlist_addf_string(groups, names[i], "name%u", i);
+ for (i = 0; i < ngids; i++) {
+ n = snprintf(nvlname, sizeof(nvlname), "gid%u", i);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_add_number(groups, nvlname, (uint64_t)gids[i]);
+ }
+ for (i = 0; i < nnames; i++) {
+ n = snprintf(nvlname, sizeof(nvlname), "gid%u", i);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_add_string(groups, nvlname, names[i]);
+ }
nvlist_move_nvlist(limits, "groups", groups);
return (cap_limit_set(chan, limits));
}
diff --git a/lib/libcapsicum/libcapsicum_pwd.c b/lib/libcapsicum/libcapsicum_pwd.c
index 792fb66..32eeeb0 100644
--- a/lib/libcapsicum/libcapsicum_pwd.c
+++ b/lib/libcapsicum/libcapsicum_pwd.c
@@ -154,7 +154,7 @@ cap_getpwcommon_r(cap_channel_t *chan, const char *cmd, const char *login,
} else {
abort();
}
- nvl = cap_xfer_nvlist(chan, nvl);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
if (nvl == NULL) {
assert(errno != 0);
*result = NULL;
@@ -278,7 +278,7 @@ cap_setpassent(cap_channel_t *chan, int stayopen)
nvl = nvlist_create(0);
nvlist_add_string(nvl, "cmd", "setpassent");
nvlist_add_bool(nvl, "stayopen", stayopen != 0);
- nvl = cap_xfer_nvlist(chan, nvl);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
if (nvl == NULL)
return (0);
if (nvlist_get_number(nvl, "error") != 0) {
@@ -299,7 +299,7 @@ cap_set_end_pwent(cap_channel_t *chan, const char *cmd)
nvl = nvlist_create(0);
nvlist_add_string(nvl, "cmd", cmd);
/* Ignore any errors, we have no way to report them. */
- nvlist_destroy(cap_xfer_nvlist(chan, nvl));
+ nvlist_destroy(cap_xfer_nvlist(chan, nvl, 0));
}
void
@@ -364,7 +364,9 @@ cap_pwd_limit_users(cap_channel_t *chan, const char * const *names,
size_t nnames, uid_t *uids, size_t nuids)
{
nvlist_t *limits, *users;
+ char nvlname[64];
unsigned int i;
+ int n;
if (cap_limit_get(chan, &limits) < 0)
return (-1);
@@ -375,10 +377,16 @@ cap_pwd_limit_users(cap_channel_t *chan, const char * const *names,
nvlist_free_nvlist(limits, "users");
}
users = nvlist_create(0);
- for (i = 0; i < nuids; i++)
- nvlist_addf_number(users, (uint64_t)uids[i], "uid%u", i);
- for (i = 0; i < nnames; i++)
- nvlist_addf_string(users, names[i], "name%u", i);
+ for (i = 0; i < nuids; i++) {
+ n = snprintf(nvlname, sizeof(nvlname), "uid%u", i);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_add_number(users, nvlname, (uint64_t)uids[i]);
+ }
+ for (i = 0; i < nnames; i++) {
+ n = snprintf(nvlname, sizeof(nvlname), "name%u", i);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_add_string(users, nvlname, names[i]);
+ }
nvlist_move_nvlist(limits, "users", users);
return (cap_limit_set(chan, limits));
}
diff --git a/lib/libcapsicum/libcapsicum_random.c b/lib/libcapsicum/libcapsicum_random.c
index eed97e2..2c3eb36 100644
--- a/lib/libcapsicum/libcapsicum_random.c
+++ b/lib/libcapsicum/libcapsicum_random.c
@@ -57,7 +57,7 @@ cap_random_buf(cap_channel_t *chan, void *buf, size_t nbytes)
nvlist_add_string(nvl, "cmd", "generate");
nvlist_add_number(nvl, "size",
(uint64_t)(left > MAXSIZE ? MAXSIZE : left));
- nvl = cap_xfer_nvlist(chan, nvl);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
if (nvl == NULL)
return (-1);
if (nvlist_get_number(nvl, "error") != 0) {
diff --git a/lib/libcapsicum/libcapsicum_service.c b/lib/libcapsicum/libcapsicum_service.c
index 4127668..edfde8c 100644
--- a/lib/libcapsicum/libcapsicum_service.c
+++ b/lib/libcapsicum/libcapsicum_service.c
@@ -56,7 +56,7 @@ cap_service_open(const cap_channel_t *chan, const char *name)
nvlist_add_string(nvl, "service", name);
if (fd_is_valid(STDERR_FILENO))
nvlist_add_descriptor(nvl, "stderrfd", STDERR_FILENO);
- nvl = cap_xfer_nvlist(chan, nvl);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
if (nvl == NULL)
return (NULL);
error = (int)nvlist_get_number(nvl, "error");
diff --git a/lib/libcapsicum/libcapsicum_sysctl.c b/lib/libcapsicum/libcapsicum_sysctl.c
index 6ea951b..fc69113 100644
--- a/lib/libcapsicum/libcapsicum_sysctl.c
+++ b/lib/libcapsicum/libcapsicum_sysctl.c
@@ -63,7 +63,7 @@ cap_sysctlbyname(cap_channel_t *chan, const char *name, void *oldp,
nvlist_add_number(nvl, "oldlen", (uint64_t)*oldlenp);
if (newp != NULL)
nvlist_add_binary(nvl, "newp", newp, newlen);
- nvl = cap_xfer_nvlist(chan, nvl);
+ nvl = cap_xfer_nvlist(chan, nvl, 0);
if (nvl == NULL)
return (-1);
if (nvlist_get_number(nvl, "error") != 0) {
diff --git a/lib/libcasper/libcasper.c b/lib/libcasper/libcasper.c
index 7545baa..cb95346 100644
--- a/lib/libcasper/libcasper.c
+++ b/lib/libcasper/libcasper.c
@@ -279,7 +279,7 @@ casper_message(const cap_channel_t *capcas, struct service *service)
const char *cmd;
nvlist_t *nvl;
- nvl = cap_recv_nvlist(capcas);
+ nvl = cap_recv_nvlist(capcas, 0);
if (nvl == NULL)
pjdlog_exit(1, "Unable to receive message from Casper");
cmd = nvlist_get_string(nvl, "cmd");
@@ -297,7 +297,7 @@ service_message(struct service *service, struct service_connection *sconn)
const char *cmd;
int error;
- nvlin = cap_recv_nvlist(service_connection_get_chan(sconn));
+ nvlin = cap_recv_nvlist(service_connection_get_chan(sconn), 0);
if (nvlin == NULL) {
if (errno == ENOTCONN) {
pjdlog_debug(1, "Connection closed by the client.");
diff --git a/lib/libedit/chartype.c b/lib/libedit/chartype.c
index eed62ef..c240c8c 100644
--- a/lib/libedit/chartype.c
+++ b/lib/libedit/chartype.c
@@ -1,4 +1,4 @@
-/* $NetBSD: chartype.c,v 1.10 2011/08/16 16:25:15 christos Exp $ */
+/* $NetBSD: chartype.c,v 1.12 2015/02/22 02:16:19 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: chartype.c,v 1.10 2011/08/16 16:25:15 christos Exp $");
+__RCSID("$NetBSD: chartype.c,v 1.12 2015/02/22 02:16:19 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -42,31 +42,46 @@ __FBSDID("$FreeBSD$");
#define CT_BUFSIZ ((size_t)1024)
#ifdef WIDECHAR
-protected void
-ct_conv_buff_resize(ct_buffer_t *conv, size_t mincsize, size_t minwsize)
+protected int
+ct_conv_cbuff_resize(ct_buffer_t *conv, size_t csize)
{
void *p;
- if (mincsize > conv->csize) {
- conv->csize = mincsize;
- p = el_realloc(conv->cbuff, conv->csize * sizeof(*conv->cbuff));
- if (p == NULL) {
- conv->csize = 0;
- el_free(conv->cbuff);
- conv->cbuff = NULL;
- } else
- conv->cbuff = p;
+
+ if (csize <= conv->csize)
+ return 0;
+
+ conv->csize = csize;
+
+ p = el_realloc(conv->cbuff, conv->csize * sizeof(*conv->cbuff));
+ if (p == NULL) {
+ conv->csize = 0;
+ el_free(conv->cbuff);
+ conv->cbuff = NULL;
+ return -1;
}
+ conv->cbuff = p;
+ return 0;
+}
- if (minwsize > conv->wsize) {
- conv->wsize = minwsize;
- p = el_realloc(conv->wbuff, conv->wsize * sizeof(*conv->wbuff));
- if (p == NULL) {
- conv->wsize = 0;
- el_free(conv->wbuff);
- conv->wbuff = NULL;
- } else
- conv->wbuff = p;
+protected int
+ct_conv_wbuff_resize(ct_buffer_t *conv, size_t wsize)
+{
+ void *p;
+
+ if (wsize <= conv->wsize)
+ return 0;
+
+ conv->wsize = wsize;
+
+ p = el_realloc(conv->wbuff, conv->wsize * sizeof(*conv->wbuff));
+ if (p == NULL) {
+ conv->wsize = 0;
+ el_free(conv->wbuff);
+ conv->wbuff = NULL;
+ return -1;
}
+ conv->wbuff = p;
+ return 0;
}
@@ -74,26 +89,22 @@ public char *
ct_encode_string(const Char *s, ct_buffer_t *conv)
{
char *dst;
- ssize_t used = 0;
+ ssize_t used;
if (!s)
return NULL;
- if (!conv->cbuff)
- ct_conv_buff_resize(conv, CT_BUFSIZ, (size_t)0);
- if (!conv->cbuff)
- return NULL;
dst = conv->cbuff;
- while (*s) {
- used = (ssize_t)(conv->csize - (size_t)(dst - conv->cbuff));
- if (used < 5) {
- used = dst - conv->cbuff;
- ct_conv_buff_resize(conv, conv->csize + CT_BUFSIZ,
- (size_t)0);
- if (!conv->cbuff)
+ for (;;) {
+ used = (ssize_t)(dst - conv->cbuff);
+ if ((conv->csize - (size_t)used) < 5) {
+ if (ct_conv_cbuff_resize(conv,
+ conv->csize + CT_BUFSIZ) == -1)
return NULL;
dst = conv->cbuff + used;
}
+ if (!*s)
+ break;
used = ct_encode_char(dst, (size_t)5, *s);
if (used == -1) /* failed to encode, need more buffer space */
abort();
@@ -107,22 +118,19 @@ ct_encode_string(const Char *s, ct_buffer_t *conv)
public Char *
ct_decode_string(const char *s, ct_buffer_t *conv)
{
- size_t len = 0;
+ size_t len;
if (!s)
return NULL;
- if (!conv->wbuff)
- ct_conv_buff_resize(conv, (size_t)0, CT_BUFSIZ);
- if (!conv->wbuff)
- return NULL;
len = ct_mbstowcs(NULL, s, (size_t)0);
if (len == (size_t)-1)
return NULL;
- if (len > conv->wsize)
- ct_conv_buff_resize(conv, (size_t)0, len + 1);
- if (!conv->wbuff)
- return NULL;
+
+ if (conv->wsize < ++len)
+ if (ct_conv_wbuff_resize(conv, len + CT_BUFSIZ) == -1)
+ return NULL;
+
ct_mbstowcs(conv->wbuff, s, conv->wsize);
return conv->wbuff;
}
@@ -141,9 +149,9 @@ ct_decode_argv(int argc, const char *argv[], ct_buffer_t *conv)
* the argv strings. */
for (i = 0, bufspace = 0; i < argc; ++i)
bufspace += argv[i] ? strlen(argv[i]) + 1 : 0;
- ct_conv_buff_resize(conv, (size_t)0, bufspace);
- if (!conv->wsize)
- return NULL;
+ if (conv->wsize < ++bufspace)
+ if (ct_conv_wbuff_resize(conv, bufspace + CT_BUFSIZ) == -1)
+ return NULL;
wargv = el_malloc((size_t)argc * sizeof(*wargv));
diff --git a/lib/libedit/chartype.h b/lib/libedit/chartype.h
index c6aa8d5..17ca5f3 100644
--- a/lib/libedit/chartype.h
+++ b/lib/libedit/chartype.h
@@ -1,4 +1,4 @@
-/* $NetBSD: chartype.h,v 1.10 2011/11/16 01:45:10 christos Exp $ */
+/* $NetBSD: chartype.h,v 1.15 2015/05/17 13:14:41 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
* supports non-BMP code points without requiring UTF-16, but nothing
* seems to actually advertise this properly, despite Unicode 3.1 having
* been around since 2001... */
-#if !defined(__NetBSD__) && !defined(__sun) && !(defined(__APPLE__) && defined(__MACH__)) && !defined(__FreeBSD__)
+#if !defined(__NetBSD__) && !defined(__sun) && !(defined(__APPLE__) && defined(__MACH__)) && !defined(__OpenBSD__) && !defined(__FreeBSD__)
#ifndef __STDC_ISO_10646__
/* In many places it is assumed that the first 127 code points are ASCII
* compatible, so ensure wchar_t indeed does ISO 10646 and not some other
@@ -67,6 +67,7 @@
#define FUN(prefix,rest) prefix ## _w ## rest
#define FUNW(type) type ## _w
#define TYPE(type) type ## W
+#define FCHAR "%lc"
#define FSTR "%ls"
#define STR(x) L ## x
#define UC(c) c
@@ -121,6 +122,7 @@ Width(wchar_t c)
#define FUN(prefix,rest) prefix ## _ ## rest
#define FUNW(type) type
#define TYPE(type) type
+#define FCHAR "%c"
#define FSTR "%s"
#define STR(x) x
#define UC(c) (unsigned char)(c)
@@ -184,7 +186,8 @@ public Char *ct_decode_string(const char *, ct_buffer_t *);
protected Char **ct_decode_argv(int, const char *[], ct_buffer_t *);
/* Resizes the conversion buffer(s) if needed. */
-protected void ct_conv_buff_resize(ct_buffer_t *, size_t, size_t);
+protected int ct_conv_cbuff_resize(ct_buffer_t *, size_t);
+protected int ct_conv_wbuff_resize(ct_buffer_t *, size_t);
protected ssize_t ct_encode_char(char *, size_t, Char);
protected size_t ct_enc_width(Char);
@@ -194,7 +197,8 @@ protected size_t ct_enc_width(Char);
#define ct_encode_string(s, b) (s)
#define ct_decode_string(s, b) (s)
#define ct_decode_argv(l, s, b) (s)
-#define ct_conv_buff_resize(b, os, ns)
+#define ct_conv_cbuff_resize(b, s) ((s) == (0))
+#define ct_conv_wbuff_resize(b, s) ((s) == (0))
#define ct_encode_char(d, l, s) (*d = s, 1)
#define ct_free_argv(s)
#endif
diff --git a/lib/libedit/edit/readline/readline.h b/lib/libedit/edit/readline/readline.h
index 54e6f32..4371457 100644
--- a/lib/libedit/edit/readline/readline.h
+++ b/lib/libedit/edit/readline/readline.h
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.h,v 1.31 2010/08/04 20:29:18 christos Exp $ */
+/* $NetBSD: readline.h,v 1.34 2013/05/28 00:10:34 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
diff --git a/lib/libedit/el.c b/lib/libedit/el.c
index a0d7015..57ea6e5 100644
--- a/lib/libedit/el.c
+++ b/lib/libedit/el.c
@@ -96,7 +96,7 @@ el_init_fd(const char *prog, FILE *fin, FILE *fout, FILE *ferr,
*/
el->el_flags = 0;
#ifdef WIDECHAR
- if (setlocale(LC_CTYPE, NULL) != NULL) {
+ if (setlocale(LC_CTYPE, NULL) != NULL){
if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0)
el->el_flags |= CHARSET_IS_UTF8;
}
diff --git a/lib/libedit/eln.c b/lib/libedit/eln.c
index 41697f4..013aa3e 100644
--- a/lib/libedit/eln.c
+++ b/lib/libedit/eln.c
@@ -1,4 +1,4 @@
-/* $NetBSD: eln.c,v 1.17 2014/06/18 18:12:28 christos Exp $ */
+/* $NetBSD: eln.c,v 1.19 2015/05/18 15:07:04 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: eln.c,v 1.17 2014/06/18 18:12:28 christos Exp $");
+__RCSID("$NetBSD: eln.c,v 1.19 2015/05/18 15:07:04 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -77,18 +77,18 @@ public const char *
el_gets(EditLine *el, int *nread)
{
const wchar_t *tmp;
- int nwread;
-
- *nread = 0;
if (!(el->el_flags & CHARSET_IS_UTF8))
el->el_flags |= IGNORE_EXTCHARS;
- tmp = el_wgets(el, &nwread);
+ tmp = el_wgets(el, nread);
+ if (tmp != NULL) {
+ size_t nwread = 0;
+ for (int i = 0; i < *nread; i++)
+ nwread += ct_enc_width(tmp[i]);
+ *nread = (int)nwread;
+ }
if (!(el->el_flags & CHARSET_IS_UTF8))
el->el_flags &= ~IGNORE_EXTCHARS;
- for (int i = 0; i < nwread; i++)
- *nread += ct_enc_width(tmp[i]);
-
return ct_encode_string(tmp, &el->el_lgcyconv);
}
diff --git a/lib/libedit/map.c b/lib/libedit/map.c
index 44c8fbb..03bb3d8 100644
--- a/lib/libedit/map.c
+++ b/lib/libedit/map.c
@@ -1,4 +1,4 @@
-/* $NetBSD: map.c,v 1.34 2014/07/06 18:15:34 christos Exp $ */
+/* $NetBSD: map.c,v 1.35 2015/05/14 10:44:15 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: map.c,v 1.34 2014/07/06 18:15:34 christos Exp $");
+__RCSID("$NetBSD: map.c,v 1.35 2015/05/14 10:44:15 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -1302,8 +1302,8 @@ map_bind(EditLine *el, int argc, const Char **argv)
return 0;
default:
(void) fprintf(el->el_errfile,
- "" FSTR ": Invalid switch `%c'.\n",
- argv[0], p[1]);
+ "" FSTR ": Invalid switch `" FCHAR "'.\n",
+ argv[0], (Int)p[1]);
}
else
break;
diff --git a/lib/libedit/readline.c b/lib/libedit/readline.c
index a7d1350..2dd7f4f 100644
--- a/lib/libedit/readline.c
+++ b/lib/libedit/readline.c
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.c,v 1.113 2014/10/18 08:33:23 snj Exp $ */
+/* $NetBSD: readline.c,v 1.115 2015/04/01 15:23:15 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.113 2014/10/18 08:33:23 snj Exp $");
+__RCSID("$NetBSD: readline.c,v 1.115 2015/04/01 15:23:15 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
@@ -364,6 +364,37 @@ rl_initialize(void)
_el_rl_tstp);
el_set(e, EL_BIND, "^Z", "rl_tstp", NULL);
+ /*
+ * Set some readline compatible key-bindings.
+ */
+ el_set(e, EL_BIND, "^R", "em-inc-search-prev", NULL);
+
+ /*
+ * Allow the use of Home/End keys.
+ */
+ el_set(e, EL_BIND, "\\e[1~", "ed-move-to-beg", NULL);
+ el_set(e, EL_BIND, "\\e[4~", "ed-move-to-end", NULL);
+ el_set(e, EL_BIND, "\\e[7~", "ed-move-to-beg", NULL);
+ el_set(e, EL_BIND, "\\e[8~", "ed-move-to-end", NULL);
+ el_set(e, EL_BIND, "\\e[H", "ed-move-to-beg", NULL);
+ el_set(e, EL_BIND, "\\e[F", "ed-move-to-end", NULL);
+
+ /*
+ * Allow the use of the Delete/Insert keys.
+ */
+ el_set(e, EL_BIND, "\\e[3~", "ed-delete-next-char", NULL);
+ el_set(e, EL_BIND, "\\e[2~", "ed-quoted-insert", NULL);
+
+ /*
+ * Ctrl-left-arrow and Ctrl-right-arrow for word moving.
+ */
+ el_set(e, EL_BIND, "\\e[1;5C", "em-next-word", NULL);
+ el_set(e, EL_BIND, "\\e[1;5D", "ed-prev-word", NULL);
+ el_set(e, EL_BIND, "\\e[5C", "em-next-word", NULL);
+ el_set(e, EL_BIND, "\\e[5D", "ed-prev-word", NULL);
+ el_set(e, EL_BIND, "\\e\\e[C", "em-next-word", NULL);
+ el_set(e, EL_BIND, "\\e\\e[D", "ed-prev-word", NULL);
+
/* read settings from configuration file */
el_source(e, NULL);
@@ -950,7 +981,8 @@ loop:
for (; str[j]; j++) {
if (str[j] == '\\' &&
str[j + 1] == history_expansion_char) {
- (void)strcpy(&str[j], &str[j + 1]);
+ len = strlen(&str[j + 1]) + 1;
+ memmove(&str[j], &str[j + 1], len);
continue;
}
if (!loop_again) {
diff --git a/lib/libedit/tty.c b/lib/libedit/tty.c
index 562730e..ecf2e2a 100644
--- a/lib/libedit/tty.c
+++ b/lib/libedit/tty.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tty.c,v 1.46 2014/06/18 18:52:49 christos Exp $ */
+/* $NetBSD: tty.c,v 1.47 2015/05/14 10:44:15 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: tty.c,v 1.46 2014/06/18 18:52:49 christos Exp $");
+__RCSID("$NetBSD: tty.c,v 1.47 2015/05/14 10:44:15 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
#include <sys/cdefs.h>
@@ -1173,8 +1173,8 @@ tty_stty(EditLine *el, int argc __attribute__((__unused__)), const Char **argv)
break;
default:
(void) fprintf(el->el_errfile,
- "%s: Unknown switch `%c'.\n",
- name, argv[0][1]);
+ "%s: Unknown switch `" FCHAR "'.\n",
+ name, (Int)argv[0][1]);
return -1;
}
diff --git a/lib/libelftc/elftc_version.c b/lib/libelftc/elftc_version.c
index 7a8c96a..fb0a731 100644
--- a/lib/libelftc/elftc_version.c
+++ b/lib/libelftc/elftc_version.c
@@ -6,5 +6,5 @@
const char *
elftc_version(void)
{
- return "elftoolchain r3179M";
+ return "elftoolchain r3197M";
}
diff --git a/lib/libevent/Makefile b/lib/libevent/Makefile
index d8b1e20..1d20bcd 100644
--- a/lib/libevent/Makefile
+++ b/lib/libevent/Makefile
@@ -7,7 +7,6 @@
LIB= event
SHLIB_MAJOR= 1
PRIVATELIB=
-INTERNALLIB=
SRCS= buffer.c evbuffer.c event.c kqueue.c log.c poll.c select.c signal.c
HDRS= event.h
diff --git a/lib/libmandoc/Makefile b/lib/libmandoc/Makefile
deleted file mode 100644
index 276c463..0000000
--- a/lib/libmandoc/Makefile
+++ /dev/null
@@ -1,46 +0,0 @@
-# $FreeBSD$
-
-MDOCMLDIR= ${.CURDIR}/../../contrib/mdocml
-.PATH: ${MDOCMLDIR}
-
-LIB= mandoc
-#NO_PIC=
-INTERNALLIB=
-MAN= mandoc.3 mandoc_headers.3
-LIBMAN_SRCS= man.c \
- man_hash.c \
- man_macro.c \
- man_validate.c
-
-LIBMDOC_SRCS= att.c \
- lib.c \
- mdoc.c \
- mdoc_argv.c \
- mdoc_hash.c \
- mdoc_macro.c \
- mdoc_validate.c \
- st.c
-
-LIBROFF_SRCS= eqn.c \
- roff.c \
- tbl.c \
- tbl_data.c \
- tbl_layout.c \
- tbl_opts.c
-
-COMPAT_SRCS= compat_reallocarray.c
-SRCS= ${LIBMAN_SRCS} \
- ${LIBMDOC_SRCS} \
- ${LIBROFF_SRCS} \
- ${COMPAT_SRCS} \
- chars.c \
- mandoc.c \
- mandoc_aux.c \
- msec.c \
- preconv.c \
- read.c
-
-WARNS?= 3
-CFLAGS+= -DHAVE_CONFIG_H
-
-.include <bsd.lib.mk>
diff --git a/lib/libmd/Makefile b/lib/libmd/Makefile
index 727fd86..61bea29 100644
--- a/lib/libmd/Makefile
+++ b/lib/libmd/Makefile
@@ -42,7 +42,13 @@ CLEANFILES+= md[245]hl.c md[245].ref md[245].3 mddriver \
sha0.ref sha0hl.c sha1.ref sha1hl.c shadriver \
sha256.ref sha256hl.c sha512.ref sha512hl.c
-CFLAGS+= -I${.CURDIR}
+# Define WEAK_REFS to provide weak aliases for libmd symbols
+#
+# Note that the same sources are also used internally by libcrypt,
+# in which case:
+# * macros are used to rename symbols to libcrypt internal names
+# * no weak aliases are generated
+CFLAGS+= -I${.CURDIR} -DWEAK_REFS
.PATH: ${.CURDIR}/${MACHINE_ARCH} ${.CURDIR}/../../sys/crypto/sha2
.if exists(${MACHINE_ARCH}/sha.S)
diff --git a/lib/libmd/md4.h b/lib/libmd/md4.h
index 4773513..086a27b 100644
--- a/lib/libmd/md4.h
+++ b/lib/libmd/md4.h
@@ -35,6 +35,34 @@ typedef struct MD4Context {
#include <sys/cdefs.h>
__BEGIN_DECLS
+
+/* Ensure libmd symbols do not clash with libcrypto */
+
+#ifndef MD4Init
+#define MD4Init _libmd_MD4Init
+#endif
+#ifndef MD4Update
+#define MD4Update _libmd_MD4Update
+#endif
+#ifndef MD4Pad
+#define MD4Pad _libmd_MD4Pad
+#endif
+#ifndef MD4Final
+#define MD4Final _libmd_MD4Final
+#endif
+#ifndef MD4End
+#define MD4End _libmd_MD4End
+#endif
+#ifndef MD4File
+#define MD4File _libmd_MD4File
+#endif
+#ifndef MD4FileChunk
+#define MD4FileChunk _libmd_MD4FileChunk
+#endif
+#ifndef MD4Data
+#define MD4Data _libmd_MD4Data
+#endif
+
void MD4Init(MD4_CTX *);
void MD4Update(MD4_CTX *, const void *, unsigned int);
void MD4Pad(MD4_CTX *);
diff --git a/lib/libmd/md4c.c b/lib/libmd/md4c.c
index 1211a98..de1a7b4a 100644
--- a/lib/libmd/md4c.c
+++ b/lib/libmd/md4c.c
@@ -290,3 +290,18 @@ unsigned int len;
output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
(((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
}
+
+#ifdef WEAK_REFS
+/* When building libmd, provide weak references. Note: this is not
+ activated in the context of compiling these sources for internal
+ use in libcrypt.
+ */
+#undef MD4Init
+__weak_reference(_libmd_MD4Init, MD4Init);
+#undef MD4Update
+__weak_reference(_libmd_MD4Update, MD4Update);
+#undef MD4Pad
+__weak_reference(_libmd_MD4Pad, MD4Pad);
+#undef MD4Final
+__weak_reference(_libmd_MD4Final, MD4Final);
+#endif
diff --git a/lib/libmd/md5.h b/lib/libmd/md5.h
index 803a88f..5ab3b14 100644
--- a/lib/libmd/md5.h
+++ b/lib/libmd/md5.h
@@ -1,4 +1,41 @@
+/* $FreeBSD$ */
+
#ifndef _MD5_H_
#define _MD5_H_
+
+#ifndef _KERNEL
+
+/* Ensure libmd symbols do not clash with libcrypto */
+
+#ifndef MD5Init
+#define MD5Init _libmd_MD5Init
+#endif
+#ifndef MD5Update
+#define MD5Update _libmd_MD5Update
+#endif
+#ifndef MD5Pad
+#define MD5Pad _libmd_MD5Pad
+#endif
+#ifndef MD5Final
+#define MD5Final _libmd_MD5Final
+#endif
+#ifndef MD5Transform
+#define MD5Transform _libmd_MD5Transform
+#endif
+#ifndef MD5End
+#define MD5End _libmd_MD5End
+#endif
+#ifndef MD5File
+#define MD5File _libmd_MD5File
+#endif
+#ifndef MD5FileChunk
+#define MD5FileChunk _libmd_MD5FileChunk
+#endif
+#ifndef MD5Data
+#define MD5Data _libmd_MD5Data
+#endif
+
+#endif
+
#include <sys/md5.h>
#endif /* _MD5_H_ */
diff --git a/lib/libmd/md5c.c b/lib/libmd/md5c.c
index d097390..6b50464 100644
--- a/lib/libmd/md5c.c
+++ b/lib/libmd/md5c.c
@@ -39,7 +39,7 @@ __FBSDID("$FreeBSD$");
#include <machine/endian.h>
#include <sys/endian.h>
-#include <sys/md5.h>
+#include "md5.h"
static void MD5Transform(u_int32_t [4], const unsigned char [64]);
@@ -335,3 +335,20 @@ MD5Transform (state, block)
/* Zeroize sensitive information. */
memset ((void *)x, 0, sizeof (x));
}
+
+#ifdef WEAK_REFS
+/* When building libmd, provide weak references. Note: this is not
+ activated in the context of compiling these sources for internal
+ use in libcrypt.
+ */
+#undef MD5Init
+__weak_reference(_libmd_MD5Init, MD5Init);
+#undef MD5Update
+__weak_reference(_libmd_MD5Update, MD5Update);
+#undef MD5Pad
+__weak_reference(_libmd_MD5Pad, MD5Pad);
+#undef MD5Final
+__weak_reference(_libmd_MD5Final, MD5Final);
+#undef MD5Transform
+__weak_reference(_libmd_MD5Transform, MD5Transform);
+#endif
diff --git a/lib/libmd/mdXhl.c b/lib/libmd/mdXhl.c
index 2954548..62be235 100644
--- a/lib/libmd/mdXhl.c
+++ b/lib/libmd/mdXhl.c
@@ -96,3 +96,18 @@ MDXData (const void *data, unsigned int len, char *buf)
MDXUpdate(&ctx,data,len);
return (MDXEnd(&ctx, buf));
}
+
+#ifdef WEAK_REFS
+/* When building libmd, provide weak references. Note: this is not
+ activated in the context of compiling these sources for internal
+ use in libcrypt.
+ */
+#undef MDXEnd
+__weak_reference(_libmd_MDXEnd, MDXEnd);
+#undef MDXFile
+__weak_reference(_libmd_MDXFile, MDXFile);
+#undef MDXFileChunk
+__weak_reference(_libmd_MDXFileChunk, MDXFileChunk);
+#undef MDXData
+__weak_reference(_libmd_MDXData, MDXData);
+#endif
diff --git a/lib/libmd/ripemd.h b/lib/libmd/ripemd.h
index 2ff35cc..778808f 100644
--- a/lib/libmd/ripemd.h
+++ b/lib/libmd/ripemd.h
@@ -81,6 +81,41 @@ typedef struct RIPEMD160state_st {
} RIPEMD160_CTX;
__BEGIN_DECLS
+
+/* Ensure libmd symbols do not clash with libcrypto */
+
+#ifndef RIPEMD160_Init
+#define RIPEMD160_Init _libmd_RIPEMD160_Init
+#endif
+#ifndef RIPEMD160_Update
+#define RIPEMD160_Update _libmd_RIPEMD160_Update
+#endif
+#ifndef RIPEMD160_Final
+#define RIPEMD160_Final _libmd_RIPEMD160_Final
+#endif
+#ifndef RIPEMD160_End
+#define RIPEMD160_End _libmd_RIPEMD160_End
+#endif
+#ifndef RIPEMD160_File
+#define RIPEMD160_File _libmd_RIPEMD160_File
+#endif
+#ifndef RIPEMD160_FileChunk
+#define RIPEMD160_FileChunk _libmd_RIPEMD160_FileChunk
+#endif
+#ifndef RIPEMD160_Data
+#define RIPEMD160_Data _libmd_RIPEMD160_Data
+#endif
+
+#ifndef RIPEMD160_Transform
+#define RIPEMD160_Transform _libmd_RIPEMD160_Transform
+#endif
+#ifndef RMD160_version
+#define RMD160_version _libmd_RMD160_version
+#endif
+#ifndef ripemd160_block
+#define ripemd160_block _libmd_ripemd160_block
+#endif
+
void RIPEMD160_Init(RIPEMD160_CTX *c);
void RIPEMD160_Update(RIPEMD160_CTX *c, const void *data,
size_t len);
diff --git a/lib/libmd/rmd160c.c b/lib/libmd/rmd160c.c
index e01f1e0..5a3b783 100644
--- a/lib/libmd/rmd160c.c
+++ b/lib/libmd/rmd160c.c
@@ -545,3 +545,22 @@ unsigned long *l;
}
}
#endif
+
+#ifdef WEAK_REFS
+/* When building libmd, provide weak references. Note: this is not
+ activated in the context of compiling these sources for internal
+ use in libcrypt.
+ */
+#undef RIPEMD160_Init
+__weak_reference(_libmd_RIPEMD160_Init, RIPEMD160_Init);
+#undef RIPEMD160_Update
+__weak_reference(_libmd_RIPEMD160_Update, RIPEMD160_Update);
+#undef RIPEMD160_Final
+__weak_reference(_libmd_RIPEMD160_Final, RIPEMD160_Final);
+#undef RIPEMD160_Transform
+__weak_reference(_libmd_RIPEMD160_Transform, RIPEMD160_Transform);
+#undef RMD160_version
+__weak_reference(_libmd_RMD160_version, RMD160_version);
+#undef ripemd160_block
+__weak_reference(_libmd_ripemd160_block, ripemd160_block);
+#endif
diff --git a/lib/libmd/sha.h b/lib/libmd/sha.h
index 8a0b7c2..c608c5b 100644
--- a/lib/libmd/sha.h
+++ b/lib/libmd/sha.h
@@ -79,6 +79,73 @@ typedef struct SHAstate_st {
#define SHA1_CTX SHA_CTX
__BEGIN_DECLS
+
+/* Ensure libmd symbols do not clash with libcrypto */
+
+#ifndef SHA_Init
+#define SHA_Init _libmd_SHA_Init
+#endif
+#ifndef SHA_Update
+#define SHA_Update _libmd_SHA_Update
+#endif
+#ifndef SHA_Final
+#define SHA_Final _libmd_SHA_Final
+#endif
+#ifndef SHA_End
+#define SHA_End _libmd_SHA_End
+#endif
+#ifndef SHA_File
+#define SHA_File _libmd_SHA_File
+#endif
+#ifndef SHA_FileChunk
+#define SHA_FileChunk _libmd_SHA_FileChunk
+#endif
+#ifndef SHA_Data
+#define SHA_Data _libmd_SHA_Data
+#endif
+
+#ifndef SHA_Transform
+#define SHA_Transform _libmd_SHA_Transform
+#endif
+#ifndef SHA_version
+#define SHA_version _libmd_SHA_version
+#endif
+#ifndef sha_block
+#define sha_block _libmd_sha_block
+#endif
+
+#ifndef SHA1_Init
+#define SHA1_Init _libmd_SHA1_Init
+#endif
+#ifndef SHA1_Update
+#define SHA1_Update _libmd_SHA1_Update
+#endif
+#ifndef SHA1_Final
+#define SHA1_Final _libmd_SHA1_Final
+#endif
+#ifndef SHA1_End
+#define SHA1_End _libmd_SHA1_End
+#endif
+#ifndef SHA1_File
+#define SHA1_File _libmd_SHA1_File
+#endif
+#ifndef SHA1_FileChunk
+#define SHA1_FileChunk _libmd_SHA1_FileChunk
+#endif
+#ifndef SHA1_Data
+#define SHA1_Data _libmd_SHA1_Data
+#endif
+
+#ifndef SHA1_Transform
+#define SHA1_Transform _libmd_SHA1_Transform
+#endif
+#ifndef SHA1_version
+#define SHA1_version _libmd_SHA1_version
+#endif
+#ifndef sha1_block
+#define sha1_block _libmd_sha1_block
+#endif
+
void SHA_Init(SHA_CTX *c);
void SHA_Update(SHA_CTX *c, const void *data, size_t len);
void SHA_Final(unsigned char *md, SHA_CTX *c);
@@ -86,6 +153,7 @@ char *SHA_End(SHA_CTX *, char *);
char *SHA_File(const char *, char *);
char *SHA_FileChunk(const char *, char *, off_t, off_t);
char *SHA_Data(const void *, unsigned int, char *);
+
void SHA1_Init(SHA_CTX *c);
void SHA1_Update(SHA_CTX *c, const void *data, size_t len);
void SHA1_Final(unsigned char *md, SHA_CTX *c);
diff --git a/lib/libmd/sha1c.c b/lib/libmd/sha1c.c
index ba3278a..93a4ff3 100644
--- a/lib/libmd/sha1c.c
+++ b/lib/libmd/sha1c.c
@@ -488,3 +488,33 @@ SHA_CTX *c;
/* memset((char *)&c,0,sizeof(c));*/
}
+#ifdef WEAK_REFS
+/* When building libmd, provide weak references. Note: this is not
+ activated in the context of compiling these sources for internal
+ use in libcrypt.
+ */
+#undef SHA_Init
+__weak_reference(_libmd_SHA_Init, SHA_Init);
+#undef SHA_Update
+__weak_reference(_libmd_SHA_Update, SHA_Update);
+#undef SHA_Final
+__weak_reference(_libmd_SHA_Final, SHA_Final);
+#undef SHA_Transform
+__weak_reference(_libmd_SHA_Transform, SHA_Transform);
+#undef SHA_version
+__weak_reference(_libmd_SHA_version, SHA_version);
+#undef sha_block
+__weak_reference(_libmd_sha_block, sha_block);
+#undef SHA1_Init
+__weak_reference(_libmd_SHA1_Init, SHA1_Init);
+#undef SHA1_Update
+__weak_reference(_libmd_SHA1_Update, SHA1_Update);
+#undef SHA1_Final
+__weak_reference(_libmd_SHA1_Final, SHA1_Final);
+#undef SHA1_Transform
+__weak_reference(_libmd_SHA1_Transform, SHA1_Transform);
+#undef SHA1_version
+__weak_reference(_libmd_SHA1_version, SHA1_version);
+#undef sha1_block
+__weak_reference(_libmd_sha1_block, sha1_block);
+#endif
diff --git a/lib/libmd/sha256.h b/lib/libmd/sha256.h
index 1b6a4f4..f55d1d3 100644
--- a/lib/libmd/sha256.h
+++ b/lib/libmd/sha256.h
@@ -38,6 +38,38 @@ typedef struct SHA256Context {
} SHA256_CTX;
__BEGIN_DECLS
+
+/* Ensure libmd symbols do not clash with libcrypto */
+
+#ifndef SHA256_Init
+#define SHA256_Init _libmd_SHA256_Init
+#endif
+#ifndef SHA256_Update
+#define SHA256_Update _libmd_SHA256_Update
+#endif
+#ifndef SHA256_Final
+#define SHA256_Final _libmd_SHA256_Final
+#endif
+#ifndef SHA256_End
+#define SHA256_End _libmd_SHA256_End
+#endif
+#ifndef SHA256_File
+#define SHA256_File _libmd_SHA256_File
+#endif
+#ifndef SHA256_FileChunk
+#define SHA256_FileChunk _libmd_SHA256_FileChunk
+#endif
+#ifndef SHA256_Data
+#define SHA256_Data _libmd_SHA256_Data
+#endif
+
+#ifndef SHA256_Transform
+#define SHA256_Transform _libmd_SHA256_Transform
+#endif
+#ifndef SHA256_version
+#define SHA256_version _libmd_SHA256_version
+#endif
+
void SHA256_Init(SHA256_CTX *);
void SHA256_Update(SHA256_CTX *, const void *, size_t);
void SHA256_Final(unsigned char [32], SHA256_CTX *);
diff --git a/lib/libmd/sha256c.c b/lib/libmd/sha256c.c
index 76cec8e..4227b0c 100644
--- a/lib/libmd/sha256c.c
+++ b/lib/libmd/sha256c.c
@@ -295,3 +295,18 @@ SHA256_Final(unsigned char digest[32], SHA256_CTX * ctx)
/* Clear the context state */
memset((void *)ctx, 0, sizeof(*ctx));
}
+
+#ifdef WEAK_REFS
+/* When building libmd, provide weak references. Note: this is not
+ activated in the context of compiling these sources for internal
+ use in libcrypt.
+ */
+#undef SHA256_Init
+__weak_reference(_libmd_SHA256_Init, SHA256_Init);
+#undef SHA256_Update
+__weak_reference(_libmd_SHA256_Update, SHA256_Update);
+#undef SHA256_Final
+__weak_reference(_libmd_SHA256_Final, SHA256_Final);
+#undef SHA256_Transform
+__weak_reference(_libmd_SHA256_Transform, SHA256_Transform);
+#endif
diff --git a/lib/libmd/sha512.h b/lib/libmd/sha512.h
index 8998f4c..b034ca5 100644
--- a/lib/libmd/sha512.h
+++ b/lib/libmd/sha512.h
@@ -38,6 +38,38 @@ typedef struct SHA512Context {
} SHA512_CTX;
__BEGIN_DECLS
+
+/* Ensure libmd symbols do not clash with libcrypto */
+
+#ifndef SHA512_Init
+#define SHA512_Init _libmd_SHA512_Init
+#endif
+#ifndef SHA512_Update
+#define SHA512_Update _libmd_SHA512_Update
+#endif
+#ifndef SHA512_Final
+#define SHA512_Final _libmd_SHA512_Final
+#endif
+#ifndef SHA512_End
+#define SHA512_End _libmd_SHA512_End
+#endif
+#ifndef SHA512_File
+#define SHA512_File _libmd_SHA512_File
+#endif
+#ifndef SHA512_FileChunk
+#define SHA512_FileChunk _libmd_SHA512_FileChunk
+#endif
+#ifndef SHA512_Data
+#define SHA512_Data _libmd_SHA512_Data
+#endif
+
+#ifndef SHA512_Transform
+#define SHA512_Transform _libmd_SHA512_Transform
+#endif
+#ifndef SHA512_version
+#define SHA512_version _libmd_SHA512_version
+#endif
+
void SHA512_Init(SHA512_CTX *);
void SHA512_Update(SHA512_CTX *, const void *, size_t);
void SHA512_Final(unsigned char [64], SHA512_CTX *);
diff --git a/lib/libmd/sha512c.c b/lib/libmd/sha512c.c
index c2a93be..e5e52a8 100644
--- a/lib/libmd/sha512c.c
+++ b/lib/libmd/sha512c.c
@@ -318,3 +318,18 @@ SHA512_Final(unsigned char digest[64], SHA512_CTX * ctx)
/* Clear the context state */
memset((void *)ctx, 0, sizeof(*ctx));
}
+
+#ifdef WEAK_REFS
+/* When building libmd, provide weak references. Note: this is not
+ activated in the context of compiling these sources for internal
+ use in libcrypt.
+ */
+#undef SHA512_Init
+__weak_reference(_libmd_SHA512_Init, SHA512_Init);
+#undef SHA512_Update
+__weak_reference(_libmd_SHA512_Update, SHA512_Update);
+#undef SHA512_Final
+__weak_reference(_libmd_SHA512_Final, SHA512_Final);
+#undef SHA512_Transform
+__weak_reference(_libmd_SHA512_Transform, SHA512_Transform);
+#endif
diff --git a/lib/libmd/shadriver.c b/lib/libmd/shadriver.c
index adaf684..29a3cf0 100644
--- a/lib/libmd/shadriver.c
+++ b/lib/libmd/shadriver.c
@@ -31,10 +31,13 @@ __FBSDID("$FreeBSD$");
#endif
#if SHA == 1
+#undef SHA_Data
#define SHA_Data SHA1_Data
#elif SHA == 256
+#undef SHA_Data
#define SHA_Data SHA256_Data
#elif SHA == 512
+#undef SHA_Data
#define SHA_Data SHA512_Data
#endif
diff --git a/lib/libnv/Makefile b/lib/libnv/Makefile
index f7853b0..8b2fc78 100644
--- a/lib/libnv/Makefile
+++ b/lib/libnv/Makefile
@@ -22,147 +22,66 @@ MAN+= nv.3
MLINKS+=nv.3 libnv.3 \
nv.3 nvlist.3
-MLINKS+=nv.3 nvlist_create.3 \
- nv.3 nvlist_destroy.3 \
- nv.3 nvlist_error.3 \
- nv.3 nvlist_set_error.3 \
- nv.3 nvlist_empty.3 \
+MLINKS+=nv.3 nvlist_add_binary.3 \
+ nv.3 nvlist_add_bool.3 \
+ nv.3 nvlist_add_descriptor.3 \
+ nv.3 nvlist_add_null.3 \
+ nv.3 nvlist_add_number.3 \
+ nv.3 nvlist_add_nvlist.3 \
+ nv.3 nvlist_add_string.3 \
+ nv.3 nvlist_add_stringf.3 \
+ nv.3 nvlist_add_stringv.3 \
nv.3 nvlist_clone.3 \
+ nv.3 nvlist_create.3 \
+ nv.3 nvlist_destroy.3 \
nv.3 nvlist_dump.3 \
- nv.3 nvlist_fdump.3 \
- nv.3 nvlist_size.3 \
- nv.3 nvlist_pack.3 \
- nv.3 nvlist_unpack.3 \
- nv.3 nvlist_send.3 \
- nv.3 nvlist_recv.3 \
- nv.3 nvlist_xfer.3 \
- nv.3 nvlist_next.3 \
+ nv.3 nvlist_empty.3 \
+ nv.3 nvlist_error.3 \
nv.3 nvlist_exists.3 \
- nv.3 nvlist_exists_type.3 \
- nv.3 nvlist_exists_null.3 \
+ nv.3 nvlist_exists_binary.3 \
nv.3 nvlist_exists_bool.3 \
+ nv.3 nvlist_exists_descriptor.3 \
+ nv.3 nvlist_exists_null.3 \
nv.3 nvlist_exists_number.3 \
- nv.3 nvlist_exists_string.3 \
nv.3 nvlist_exists_nvlist.3 \
- nv.3 nvlist_exists_descriptor.3 \
- nv.3 nvlist_exists_binary.3 \
- nv.3 nvlist_add_null.3 \
- nv.3 nvlist_add_bool.3 \
- nv.3 nvlist_add_number.3 \
- nv.3 nvlist_add_string.3 \
- nv.3 nvlist_add_stringf.3 \
- nv.3 nvlist_add_stringv.3 \
- nv.3 nvlist_add_nvlist.3 \
- nv.3 nvlist_add_descriptor.3 \
- nv.3 nvlist_add_binary.3 \
- nv.3 nvlist_move_string.3 \
- nv.3 nvlist_move_nvlist.3 \
- nv.3 nvlist_move_descriptor.3 \
- nv.3 nvlist_move_binary.3 \
+ nv.3 nvlist_exists_string.3 \
+ nv.3 nvlist_exists_type.3 \
+ nv.3 nvlist_fdump.3 \
+ nv.3 nvlist_flags.3 \
+ nv.3 nvlist_free.3 \
+ nv.3 nvlist_free_binary.3 \
+ nv.3 nvlist_free_bool.3 \
+ nv.3 nvlist_free_descriptor.3 \
+ nv.3 nvlist_free_null.3 \
+ nv.3 nvlist_free_number.3 \
+ nv.3 nvlist_free_nvlist.3 \
+ nv.3 nvlist_free_string.3 \
+ nv.3 nvlist_free_type.3 \
+ nv.3 nvlist_get_binary.3 \
nv.3 nvlist_get_bool.3 \
+ nv.3 nvlist_get_descriptor.3 \
nv.3 nvlist_get_number.3 \
- nv.3 nvlist_get_string.3 \
nv.3 nvlist_get_nvlist.3 \
- nv.3 nvlist_get_descriptor.3 \
- nv.3 nvlist_get_binary.3 \
nv.3 nvlist_get_parent.3 \
+ nv.3 nvlist_get_string.3 \
+ nv.3 nvlist_move_binary.3 \
+ nv.3 nvlist_move_descriptor.3 \
+ nv.3 nvlist_move_nvlist.3 \
+ nv.3 nvlist_move_string.3 \
+ nv.3 nvlist_next.3 \
+ nv.3 nvlist_pack.3 \
+ nv.3 nvlist_recv.3 \
+ nv.3 nvlist_send.3 \
+ nv.3 nvlist_set_error.3 \
+ nv.3 nvlist_size.3 \
+ nv.3 nvlist_take_binary.3 \
nv.3 nvlist_take_bool.3 \
+ nv.3 nvlist_take_descriptor.3 \
nv.3 nvlist_take_number.3 \
- nv.3 nvlist_take_string.3 \
nv.3 nvlist_take_nvlist.3 \
- nv.3 nvlist_take_descriptor.3 \
- nv.3 nvlist_take_binary.3 \
- nv.3 nvlist_free.3 \
- nv.3 nvlist_free_type.3 \
- nv.3 nvlist_free_null.3 \
- nv.3 nvlist_free_bool.3 \
- nv.3 nvlist_free_number.3 \
- nv.3 nvlist_free_string.3 \
- nv.3 nvlist_free_nvlist.3 \
- nv.3 nvlist_free_descriptor.3 \
- nv.3 nvlist_free_binary.3
-MLINKS+=nv.3 nvlist_existsf.3 \
- nv.3 nvlist_existsf_type.3 \
- nv.3 nvlist_existsf_null.3 \
- nv.3 nvlist_existsf_bool.3 \
- nv.3 nvlist_existsf_number.3 \
- nv.3 nvlist_existsf_string.3 \
- nv.3 nvlist_existsf_nvlist.3 \
- nv.3 nvlist_existsf_descriptor.3 \
- nv.3 nvlist_existsf_binary.3 \
- nv.3 nvlist_addf_null.3 \
- nv.3 nvlist_addf_bool.3 \
- nv.3 nvlist_addf_number.3 \
- nv.3 nvlist_addf_string.3 \
- nv.3 nvlist_addf_nvlist.3 \
- nv.3 nvlist_addf_descriptor.3 \
- nv.3 nvlist_addf_binary.3 \
- nv.3 nvlist_movef_string.3 \
- nv.3 nvlist_movef_nvlist.3 \
- nv.3 nvlist_movef_descriptor.3 \
- nv.3 nvlist_movef_binary.3 \
- nv.3 nvlist_getf_bool.3 \
- nv.3 nvlist_getf_number.3 \
- nv.3 nvlist_getf_string.3 \
- nv.3 nvlist_getf_nvlist.3 \
- nv.3 nvlist_getf_descriptor.3 \
- nv.3 nvlist_getf_binary.3 \
- nv.3 nvlist_takef_bool.3 \
- nv.3 nvlist_takef_number.3 \
- nv.3 nvlist_takef_string.3 \
- nv.3 nvlist_takef_nvlist.3 \
- nv.3 nvlist_takef_descriptor.3 \
- nv.3 nvlist_takef_binary.3 \
- nv.3 nvlist_freef.3 \
- nv.3 nvlist_freef_type.3 \
- nv.3 nvlist_freef_null.3 \
- nv.3 nvlist_freef_bool.3 \
- nv.3 nvlist_freef_number.3 \
- nv.3 nvlist_freef_string.3 \
- nv.3 nvlist_freef_nvlist.3 \
- nv.3 nvlist_freef_descriptor.3 \
- nv.3 nvlist_freef_binary.3
-MLINKS+=nv.3 nvlist_existsv.3 \
- nv.3 nvlist_existsv_type.3 \
- nv.3 nvlist_existsv_null.3 \
- nv.3 nvlist_existsv_bool.3 \
- nv.3 nvlist_existsv_number.3 \
- nv.3 nvlist_existsv_string.3 \
- nv.3 nvlist_existsv_nvlist.3 \
- nv.3 nvlist_existsv_descriptor.3 \
- nv.3 nvlist_existsv_binary.3 \
- nv.3 nvlist_addv_null.3 \
- nv.3 nvlist_addv_bool.3 \
- nv.3 nvlist_addv_number.3 \
- nv.3 nvlist_addv_string.3 \
- nv.3 nvlist_addv_nvlist.3 \
- nv.3 nvlist_addv_descriptor.3 \
- nv.3 nvlist_addv_binary.3 \
- nv.3 nvlist_movev_string.3 \
- nv.3 nvlist_movev_nvlist.3 \
- nv.3 nvlist_movev_descriptor.3 \
- nv.3 nvlist_movev_binary.3 \
- nv.3 nvlist_getv_bool.3 \
- nv.3 nvlist_getv_number.3 \
- nv.3 nvlist_getv_string.3 \
- nv.3 nvlist_getv_nvlist.3 \
- nv.3 nvlist_getv_descriptor.3 \
- nv.3 nvlist_getv_binary.3 \
- nv.3 nvlist_takev_bool.3 \
- nv.3 nvlist_takev_number.3 \
- nv.3 nvlist_takev_string.3 \
- nv.3 nvlist_takev_nvlist.3 \
- nv.3 nvlist_takev_descriptor.3 \
- nv.3 nvlist_takev_binary.3 \
- nv.3 nvlist_freev.3 \
- nv.3 nvlist_freev_type.3 \
- nv.3 nvlist_freev_null.3 \
- nv.3 nvlist_freev_bool.3 \
- nv.3 nvlist_freev_number.3 \
- nv.3 nvlist_freev_string.3 \
- nv.3 nvlist_freev_nvlist.3 \
- nv.3 nvlist_freev_descriptor.3 \
- nv.3 nvlist_freev_binary.3
+ nv.3 nvlist_take_string.3 \
+ nv.3 nvlist_unpack.3 \
+ nv.3 nvlist_xfer.3
WARNS?= 6
diff --git a/lib/libnv/nv.3 b/lib/libnv/nv.3
index be6e0fe..58033be 100644
--- a/lib/libnv/nv.3
+++ b/lib/libnv/nv.3
@@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd January 30, 2015
+.Dd May 2, 2015
.Dt NV 3
.Os
.Sh NAME
@@ -37,6 +37,7 @@
.Nm nvlist_error ,
.Nm nvlist_set_error ,
.Nm nvlist_empty ,
+.Nm nvlist_flags ,
.Nm nvlist_exists ,
.Nm nvlist_free ,
.Nm nvlist_clone ,
@@ -68,6 +69,8 @@
.Fn nvlist_set_error "nvlist_t *nvl, int error"
.Ft bool
.Fn nvlist_empty "const nvlist_t *nvl"
+.Ft int
+.Fn nvlist_flags "const nvlist_t *nvl"
.\"
.Ft "nvlist_t *"
.Fn nvlist_clone "const nvlist_t *nvl"
@@ -82,14 +85,14 @@
.Ft "void *"
.Fn nvlist_pack "const nvlist_t *nvl" "size_t *sizep"
.Ft "nvlist_t *"
-.Fn nvlist_unpack "const void *buf" "size_t size"
+.Fn nvlist_unpack "const void *buf" "size_t size" "int flags"
.\"
.Ft int
.Fn nvlist_send "int sock" "const nvlist_t *nvl"
.Ft "nvlist_t *"
-.Fn nvlist_recv "int sock"
+.Fn nvlist_recv "int sock" "int flags"
.Ft "nvlist_t *"
-.Fn nvlist_xfer "int sock" "nvlist_t *nvl"
+.Fn nvlist_xfer "int sock" "nvlist_t *nvl" "int flags"
.\"
.Ft "const char *"
.Fn nvlist_next "const nvlist_t *nvl" "int *typep" "void **cookiep"
@@ -229,6 +232,8 @@ The following flag can be provided:
.Bl -tag -width "NV_FLAG_IGNORE_CASE" -compact -offset indent
.It Dv NV_FLAG_IGNORE_CASE
Perform case-insensitive lookups of provided names.
+.It Dv NV_FLAG_NO_UNIQUE
+Names in the nvlist do not have to be unique.
.El
.Pp
The
@@ -269,6 +274,12 @@ otherwise.
The nvlist must not be in error state.
.Pp
The
+.Fn nvlist_flags
+function returns flags used to create the nvlist with the
+.Fn nvlist_create
+function.
+.Pp
+The
.Fn nvlist_clone
functions clones the given nvlist.
The clone shares no resources with its origin.
@@ -316,6 +327,18 @@ The nvlist must not be in error state.
The
.Fn nvlist_unpack
function converts the given buffer to the nvlist.
+The
+.Fa flags
+argument defines what type of the top level nvlist is expected to be.
+Flags are set up using the
+.Fn nvlist_create
+function.
+If the nvlist flags do not match the flags passed to
+.Fn nvlist_unpack ,
+the nvlist will not be returned.
+Every nested nvlist list should be checked using
+.Fn nvlist_flags
+function.
The function returns
.Dv NULL
in case of an error.
@@ -334,12 +357,36 @@ The
function receives nvlist over the socket given by the
.Fa sock
argument.
+The
+.Fa flags
+argument defines what type of the top level nvlist is expected to be.
+Flags are set up using the
+.Fn nvlist_create
+function.
+If the nvlist flags do not match the flags passed to
+.Fn nvlist_recv ,
+the nvlist will not be returned.
+Every nested nvlist list should be checked using
+.Fn nvlist_flags
+function.
.Pp
The
.Fn nvlist_xfer
function sends the given nvlist over the socket given by the
.Fa sock
argument and receives nvlist over the same socket.
+The
+.Fa flags
+argument defines what type of the top level nvlist is expected to be.
+Flags are set up using the
+.Fn nvlist_create
+function.
+If the nvlist flags do not match the flags passed to
+.Fn nvlist_xfer ,
+the nvlist will not be returned.
+Every nested nvlist list should be checked using
+.Fn nvlist_flags
+function.
The given nvlist is always destroyed.
.Pp
The
@@ -550,7 +597,7 @@ const char *command;
char *filename;
int fd;
-nvl = nvlist_recv(sock);
+nvl = nvlist_recv(sock, 0);
if (nvl == NULL)
err(1, "nvlist_recv() failed");
@@ -579,7 +626,7 @@ const char *name;
void *cookie;
int type;
-nvl = nvlist_recv(sock);
+nvl = nvlist_recv(sock, 0);
if (nvl == NULL)
err(1, "nvlist_recv() failed");
@@ -608,7 +655,7 @@ const char *name;
void *cookie;
int type;
-nvl = nvlist_recv(sock);
+nvl = nvlist_recv(sock, 0);
if (nvl == NULL)
err(1, "nvlist_recv() failed");
diff --git a/lib/libnv/tests/dnv_tests.cc b/lib/libnv/tests/dnv_tests.cc
index ad26f38..2f92d9d 100644
--- a/lib/libnv/tests/dnv_tests.cc
+++ b/lib/libnv/tests/dnv_tests.cc
@@ -45,7 +45,7 @@ ATF_TEST_CASE_BODY(dnvlist_get_bool__present)
nvlist_add_bool(nvl, key, value);
ATF_REQUIRE_EQ(dnvlist_get_bool(nvl, key, false), value);
- ATF_REQUIRE_EQ(dnvlist_getf_bool(nvl, false, "%c%s", 'n', "ame"), value);
+ ATF_REQUIRE_EQ(dnvlist_get_bool(nvl, "name", false), value);
nvlist_destroy(nvl);
}
@@ -60,12 +60,12 @@ ATF_TEST_CASE_BODY(dnvlist_get_bool__default_value)
nvl = nvlist_create(0);
ATF_REQUIRE_EQ(dnvlist_get_bool(nvl, key, false), false);
- ATF_REQUIRE_EQ(dnvlist_getf_bool(nvl, true, "%d", 123), true);
+ ATF_REQUIRE_EQ(dnvlist_get_bool(nvl, "123", true), true);
nvlist_add_bool(nvl, key, true);
ATF_REQUIRE_EQ(dnvlist_get_bool(nvl, "otherkey", true), true);
- ATF_REQUIRE_EQ(dnvlist_getf_bool(nvl, false, "%d%c", 12, 'c'), false);
+ ATF_REQUIRE_EQ(dnvlist_get_bool(nvl, "12c", false), false);
nvlist_destroy(nvl);
}
@@ -84,7 +84,7 @@ ATF_TEST_CASE_BODY(dnvlist_get_number__present)
nvlist_add_number(nvl, key, value);
ATF_REQUIRE_EQ(dnvlist_get_number(nvl, key, 19), value);
- ATF_REQUIRE_EQ(dnvlist_getf_number(nvl, 65, "key"), value);
+ ATF_REQUIRE_EQ(dnvlist_get_number(nvl, "key", 65), value);
nvlist_destroy(nvl);
}
@@ -99,12 +99,11 @@ ATF_TEST_CASE_BODY(dnvlist_get_number__default_value)
nvl = nvlist_create(0);
ATF_REQUIRE_EQ(dnvlist_get_number(nvl, key, 5), 5);
- ATF_REQUIRE_EQ(dnvlist_getf_number(nvl, 12, "%s", key), 12);
+ ATF_REQUIRE_EQ(dnvlist_get_number(nvl, "1234", 5), 5);
nvlist_add_number(nvl, key, 24841);
- ATF_REQUIRE_EQ(dnvlist_get_number(nvl, "hthth", 184), 184);
- ATF_REQUIRE_EQ(dnvlist_getf_number(nvl, 5641, "%d", 1234), 5641);
+ ATF_REQUIRE_EQ(dnvlist_get_number(nvl, "1234", 5641), 5641);
nvlist_destroy(nvl);
}
@@ -124,7 +123,7 @@ ATF_TEST_CASE_BODY(dnvlist_get_string__present)
ATF_REQUIRE_EQ(strcmp(dnvlist_get_string(nvl, key, "g"), value), 0);
- actual_value = dnvlist_getf_string(nvl, "rs", "%s", key);
+ actual_value = dnvlist_get_string(nvl, key, "rs");
ATF_REQUIRE_EQ(strcmp(actual_value, value), 0);
nvlist_destroy(nvl);
@@ -142,13 +141,13 @@ ATF_TEST_CASE_BODY(dnvlist_get_string__default_value)
ATF_REQUIRE_EQ(strcmp(dnvlist_get_string(nvl, key, "bar"), "bar"), 0);
- actual_value = dnvlist_getf_string(nvl, "d", "%s", key);
+ actual_value = dnvlist_get_string(nvl, key, "d");
ATF_REQUIRE_EQ(strcmp(actual_value, "d"), 0);
nvlist_add_string(nvl, key, "cxhweh");
ATF_REQUIRE_EQ(strcmp(dnvlist_get_string(nvl, "hthth", "fd"), "fd"), 0);
- actual_value = dnvlist_getf_string(nvl, "5", "%s", "5");
+ actual_value = dnvlist_get_string(nvl, "5", "5");
ATF_REQUIRE_EQ(strcmp("5", "5"), 0);
nvlist_destroy(nvl);
@@ -172,10 +171,6 @@ ATF_TEST_CASE_BODY(dnvlist_get_nvlist__present)
ATF_REQUIRE(actual_value != NULL);
ATF_REQUIRE(nvlist_empty(actual_value));
- actual_value = dnvlist_getf_nvlist(nvl, NULL, "%s", key);
- ATF_REQUIRE(actual_value != NULL);
- ATF_REQUIRE(nvlist_empty(actual_value));
-
nvlist_destroy(nvl);
}
@@ -191,11 +186,10 @@ ATF_TEST_CASE_BODY(dnvlist_get_nvlist__default_value)
dummy = nvlist_create(0);
ATF_REQUIRE_EQ(dnvlist_get_nvlist(nvl, key, dummy), dummy);
- ATF_REQUIRE_EQ(dnvlist_getf_nvlist(nvl, dummy, "%s", key), dummy);
nvlist_move_nvlist(nvl, key, nvlist_create(0));
ATF_REQUIRE_EQ(dnvlist_get_nvlist(nvl, "456", dummy), dummy);
- ATF_REQUIRE_EQ(dnvlist_getf_nvlist(nvl, dummy, "%s", "gh"), dummy);
+ ATF_REQUIRE_EQ(dnvlist_get_nvlist(nvl, "gh", dummy), dummy);
nvlist_destroy(nvl);
}
@@ -226,10 +220,6 @@ ATF_TEST_CASE_BODY(dnvlist_get_binary__present)
ATF_REQUIRE_EQ(value_size, actual_size);
ATF_REQUIRE_EQ(memcmp(actual_value, value, actual_size), 0);
- actual_value = dnvlist_getf_binary(nvl, &actual_size, "g", 1, "%s", k);
- ATF_REQUIRE_EQ(value_size, actual_size);
- ATF_REQUIRE_EQ(memcmp(actual_value, value, actual_size), 0);
-
nvlist_destroy(nvl);
}
@@ -251,8 +241,8 @@ ATF_TEST_CASE_BODY(dnvlist_get_binary__default_value)
ATF_REQUIRE_EQ(memcmp(actual_value, default_value, actual_size), 0);
set_const_binary_value(default_value, default_size, "atf");
- actual_value = dnvlist_getf_binary(nvl, &actual_size, default_value,
- default_size, "%s", key);
+ actual_value = dnvlist_get_binary(nvl, key, &actual_size, default_value,
+ default_size);
ATF_REQUIRE_EQ(default_size, actual_size);
ATF_REQUIRE_EQ(memcmp(actual_value, default_value, actual_size), 0);
@@ -266,8 +256,8 @@ ATF_TEST_CASE_BODY(dnvlist_get_binary__default_value)
set_const_binary_value(default_value, default_size,
"rrhgrythtyrtgbrhgrtdsvdfbtjlkul");
- actual_value = dnvlist_getf_binary(nvl, &actual_size, default_value,
- default_size, "s");
+ actual_value = dnvlist_get_binary(nvl, "s", &actual_size, default_value,
+ default_size);
ATF_REQUIRE_EQ(default_size, actual_size);
ATF_REQUIRE_EQ(memcmp(actual_value, default_value, actual_size), 0);
diff --git a/lib/libnv/tests/nv_tests.cc b/lib/libnv/tests/nv_tests.cc
index bfdc972..d779190 100644
--- a/lib/libnv/tests/nv_tests.cc
+++ b/lib/libnv/tests/nv_tests.cc
@@ -77,9 +77,8 @@ ATF_TEST_CASE_BODY(nvlist_add_null__single_insert)
ATF_REQUIRE(!nvlist_empty(nvl));
ATF_REQUIRE(nvlist_exists(nvl, key));
- ATF_REQUIRE(nvlist_existsf(nvl, "%s", key));
ATF_REQUIRE(nvlist_exists_null(nvl, key));
- ATF_REQUIRE(nvlist_existsf_null(nvl, "key"));
+ ATF_REQUIRE(nvlist_exists_null(nvl, "key"));
/* Iterate over the nvlist; ensure that it has only our one key. */
it = NULL;
@@ -108,11 +107,10 @@ ATF_TEST_CASE_BODY(nvlist_add_bool__single_insert)
ATF_REQUIRE(!nvlist_empty(nvl));
ATF_REQUIRE(nvlist_exists(nvl, key));
- ATF_REQUIRE(nvlist_existsf(nvl, "%s%s", "na", "me"));
+ ATF_REQUIRE(nvlist_exists(nvl, "name"));
ATF_REQUIRE(nvlist_exists_bool(nvl, key));
- ATF_REQUIRE(nvlist_existsf_bool(nvl, "%s%c", "nam", 'e'));
+ ATF_REQUIRE(nvlist_exists_bool(nvl, "name"));
ATF_REQUIRE_EQ(nvlist_get_bool(nvl, key), true);
- ATF_REQUIRE_EQ(nvlist_getf_bool(nvl, "%c%s", 'n', "ame"), true);
/* Iterate over the nvlist; ensure that it has only our one key. */
it = NULL;
@@ -143,11 +141,9 @@ ATF_TEST_CASE_BODY(nvlist_add_number__single_insert)
ATF_REQUIRE(!nvlist_empty(nvl));
ATF_REQUIRE(nvlist_exists(nvl, key));
- ATF_REQUIRE(nvlist_existsf(nvl, "%s%d", "foo", 123));
+ ATF_REQUIRE(nvlist_exists(nvl, "foo123"));
ATF_REQUIRE(nvlist_exists_number(nvl, key));
- ATF_REQUIRE(nvlist_existsf_number(nvl, "%s", key));
ATF_REQUIRE_EQ(nvlist_get_number(nvl, key), value);
- ATF_REQUIRE_EQ(nvlist_getf_number(nvl, "%s", key), value);
/* Iterate over the nvlist; ensure that it has only our one key. */
it = NULL;
@@ -178,11 +174,10 @@ ATF_TEST_CASE_BODY(nvlist_add_string__single_insert)
ATF_REQUIRE(!nvlist_empty(nvl));
ATF_REQUIRE(nvlist_exists(nvl, key));
- ATF_REQUIRE(nvlist_existsf(nvl, "%s", key));
+ ATF_REQUIRE(nvlist_exists(nvl, "test"));
ATF_REQUIRE(nvlist_exists_string(nvl, key));
- ATF_REQUIRE(nvlist_existsf_string(nvl, "%s", key));
+ ATF_REQUIRE(nvlist_exists_string(nvl, "test"));
ATF_REQUIRE_EQ(strcmp(nvlist_get_string(nvl, key), value), 0);
- ATF_REQUIRE_EQ(strcmp(nvlist_getf_string(nvl, "%s", key), value), 0);
/* nvlist_add_* is required to clone the value, so check for that. */
ATF_REQUIRE(nvlist_get_string(nvl, key) != value);
@@ -219,9 +214,9 @@ ATF_TEST_CASE_BODY(nvlist_add_nvlist__single_insert)
ATF_REQUIRE(!nvlist_empty(nvl));
ATF_REQUIRE(nvlist_exists(nvl, key));
- ATF_REQUIRE(nvlist_existsf(nvl, "%s", key));
+ ATF_REQUIRE(nvlist_exists(nvl, "test"));
ATF_REQUIRE(nvlist_exists_nvlist(nvl, key));
- ATF_REQUIRE(nvlist_existsf_nvlist(nvl, "%s", key));
+ ATF_REQUIRE(nvlist_exists_nvlist(nvl, "test"));
value = nvlist_get_nvlist(nvl, key);
ATF_REQUIRE(nvlist_exists_null(value, subkey));
@@ -229,10 +224,6 @@ ATF_TEST_CASE_BODY(nvlist_add_nvlist__single_insert)
/* nvlist_add_* is required to clone the value, so check for that. */
ATF_REQUIRE(sublist != value);
- value = nvlist_getf_nvlist(nvl, "%s", key);
- ATF_REQUIRE(nvlist_exists_null(value, subkey));
- ATF_REQUIRE(sublist != value);
-
/* Iterate over the nvlist; ensure that it has only our one key. */
it = NULL;
ATF_REQUIRE_EQ(strcmp(nvlist_next(nvl, &type, &it), key), 0);
@@ -283,9 +274,9 @@ ATF_TEST_CASE_BODY(nvlist_add_binary__single_insert)
ATF_REQUIRE(!nvlist_empty(nvl));
ATF_REQUIRE(nvlist_exists(nvl, key));
- ATF_REQUIRE(nvlist_existsf(nvl, "%s", key));
+ ATF_REQUIRE(nvlist_exists(nvl, "binary"));
ATF_REQUIRE(nvlist_exists_binary(nvl, key));
- ATF_REQUIRE(nvlist_existsf_binary(nvl, "%s", key));
+ ATF_REQUIRE(nvlist_exists_binary(nvl, "binary"));
ret_value = nvlist_get_binary(nvl, key, &ret_size);
ATF_REQUIRE_EQ(value_size, ret_size);
@@ -294,11 +285,6 @@ ATF_TEST_CASE_BODY(nvlist_add_binary__single_insert)
/* nvlist_add_* is required to clone the value, so check for that. */
ATF_REQUIRE(value != ret_value);
- ret_value = nvlist_getf_binary(nvl, &ret_size, "%s", key);
- ATF_REQUIRE_EQ(value_size, ret_size);
- ATF_REQUIRE_EQ(memcmp(value, ret_value, ret_size), 0);
- ATF_REQUIRE(value != ret_value);
-
/* Iterate over the nvlist; ensure that it has only our one key. */
it = NULL;
ATF_REQUIRE_EQ(strcmp(nvlist_next(nvl, &type, &it), key), 0);
@@ -454,7 +440,7 @@ ATF_TEST_CASE_BODY(nvlist_pack__empty_nvlist)
packed = nvlist_pack(nvl, &packed_size);
ATF_REQUIRE(packed != NULL);
- unpacked = nvlist_unpack(packed, packed_size);
+ unpacked = nvlist_unpack(packed, packed_size, 0);
ATF_REQUIRE(unpacked != NULL);
ATF_REQUIRE(unpacked != nvl);
ATF_REQUIRE(nvlist_empty(unpacked));
@@ -464,6 +450,40 @@ ATF_TEST_CASE_BODY(nvlist_pack__empty_nvlist)
free(packed);
}
+ATF_TEST_CASE_WITHOUT_HEAD(nvlist_unpack__flags_nvlist);
+ATF_TEST_CASE_BODY(nvlist_unpack__flags_nvlist)
+{
+ nvlist_t *nvl, *unpacked;
+ void *packed;
+ size_t packed_size;
+
+ nvl = nvlist_create(NV_FLAG_NO_UNIQUE);
+ ATF_REQUIRE(nvl != NULL);
+
+ nvlist_add_bool(nvl, "name", true);
+ ATF_REQUIRE(!nvlist_empty(nvl));
+ ATF_REQUIRE(nvlist_exists_bool(nvl, "name"));
+
+ packed = nvlist_pack(nvl, &packed_size);
+ ATF_REQUIRE(packed != NULL);
+
+ unpacked = nvlist_unpack(packed, packed_size, 0);
+ ATF_REQUIRE(unpacked == NULL);
+
+ unpacked = nvlist_unpack(packed, packed_size, NV_FLAG_IGNORE_CASE);
+ ATF_REQUIRE(unpacked == NULL);
+
+ unpacked = nvlist_unpack(packed, packed_size, NV_FLAG_NO_UNIQUE);
+ ATF_REQUIRE(unpacked != NULL);
+ ATF_REQUIRE(unpacked != nvl);
+ ATF_REQUIRE(!nvlist_empty(unpacked));
+ ATF_REQUIRE(nvlist_exists_bool(unpacked, "name"));
+
+ nvlist_destroy(unpacked);
+ nvlist_destroy(nvl);
+ free(packed);
+}
+
static void
verify_null(const nvlist_t *nvl, int type)
{
@@ -548,7 +568,7 @@ ATF_TEST_CASE_BODY(nvlist_pack__multiple_values)
packed = nvlist_pack(nvl, &packed_size);
ATF_REQUIRE(packed != NULL);
- unpacked = nvlist_unpack(packed, packed_size);
+ unpacked = nvlist_unpack(packed, packed_size, 0);
ATF_REQUIRE(unpacked != 0);
it = NULL;
@@ -628,7 +648,7 @@ ATF_TEST_CASE_BODY(nvlist_unpack__duplicate_key)
ATF_REQUIRE(keypos != NULL);
memcpy(keypos, key2, keylen);
- unpacked = nvlist_unpack(packed, size);
+ unpacked = nvlist_unpack(packed, size, 0);
ATF_REQUIRE(nvlist_error(unpacked) != 0);
free(packed);
@@ -1220,6 +1240,7 @@ ATF_INIT_TEST_CASES(tp)
ATF_ADD_TEST_CASE(tp, nvlist_pack__multiple_values);
ATF_ADD_TEST_CASE(tp, nvlist_pack__error_nvlist);
ATF_ADD_TEST_CASE(tp, nvlist_unpack__duplicate_key);
+ ATF_ADD_TEST_CASE(tp, nvlist_unpack__flags_nvlist);
ATF_ADD_TEST_CASE(tp, nvlist_move_string__single_insert);
ATF_ADD_TEST_CASE(tp, nvlist_move_nvlist__single_insert);
diff --git a/lib/libnv/tests/nvlist_send_recv_test.c b/lib/libnv/tests/nvlist_send_recv_test.c
index 1b083c3..50222fb 100644
--- a/lib/libnv/tests/nvlist_send_recv_test.c
+++ b/lib/libnv/tests/nvlist_send_recv_test.c
@@ -95,7 +95,7 @@ parent(int sock)
int type, ctype;
size_t size;
- nvl = nvlist_recv(sock);
+ nvl = nvlist_recv(sock, 0);
CHECK(nvlist_error(nvl) == 0);
if (nvlist_error(nvl) != 0)
err(1, "nvlist_recv() failed");
diff --git a/lib/libpmc/libpmc.c b/lib/libpmc/libpmc.c
index 2ad2268..d9d7902 100644
--- a/lib/libpmc/libpmc.c
+++ b/lib/libpmc/libpmc.c
@@ -82,6 +82,10 @@ static int xscale_allocate_pmc(enum pmc_event _pe, char *_ctrspec,
static int armv7_allocate_pmc(enum pmc_event _pe, char *_ctrspec,
struct pmc_op_pmcallocate *_pmc_config);
#endif
+#if defined(__aarch64__)
+static int arm64_allocate_pmc(enum pmc_event _pe, char *_ctrspec,
+ struct pmc_op_pmcallocate *_pmc_config);
+#endif
#if defined(__mips__)
static int mips_allocate_pmc(enum pmc_event _pe, char* ctrspec,
struct pmc_op_pmcallocate *_pmc_config);
@@ -158,6 +162,7 @@ PMC_CLASSDEP_TABLE(p5, P5);
PMC_CLASSDEP_TABLE(p6, P6);
PMC_CLASSDEP_TABLE(xscale, XSCALE);
PMC_CLASSDEP_TABLE(armv7, ARMV7);
+PMC_CLASSDEP_TABLE(armv8, ARMV8);
PMC_CLASSDEP_TABLE(mips24k, MIPS24K);
PMC_CLASSDEP_TABLE(mips74k, MIPS74K);
PMC_CLASSDEP_TABLE(octeon, OCTEON);
@@ -263,6 +268,16 @@ static const struct pmc_event_descr westmereuc_event_table[] =
__PMC_EV_ALIAS_WESTMEREUC()
};
+static const struct pmc_event_descr cortex_a53_event_table[] =
+{
+ __PMC_EV_ALIAS_ARMV8_CORTEX_A53()
+};
+
+static const struct pmc_event_descr cortex_a57_event_table[] =
+{
+ __PMC_EV_ALIAS_ARMV8_CORTEX_A57()
+};
+
/*
* PMC_MDEP_TABLE(NAME, PRIMARYCLASS, ADDITIONAL_CLASSES...)
*
@@ -294,6 +309,8 @@ PMC_MDEP_TABLE(p5, P5, PMC_CLASS_SOFT, PMC_CLASS_TSC);
PMC_MDEP_TABLE(p6, P6, PMC_CLASS_SOFT, PMC_CLASS_TSC);
PMC_MDEP_TABLE(xscale, XSCALE, PMC_CLASS_SOFT, PMC_CLASS_XSCALE);
PMC_MDEP_TABLE(armv7, ARMV7, PMC_CLASS_SOFT, PMC_CLASS_ARMV7);
+PMC_MDEP_TABLE(cortex_a53, ARMV8, PMC_CLASS_SOFT, PMC_CLASS_ARMV8);
+PMC_MDEP_TABLE(cortex_a57, ARMV8, PMC_CLASS_SOFT, PMC_CLASS_ARMV8);
PMC_MDEP_TABLE(mips24k, MIPS24K, PMC_CLASS_SOFT, PMC_CLASS_MIPS24K);
PMC_MDEP_TABLE(mips74k, MIPS74K, PMC_CLASS_SOFT, PMC_CLASS_MIPS74K);
PMC_MDEP_TABLE(octeon, OCTEON, PMC_CLASS_SOFT, PMC_CLASS_OCTEON);
@@ -362,6 +379,10 @@ PMC_CLASS_TABLE_DESC(xscale, XSCALE, xscale, xscale);
#endif
PMC_CLASS_TABLE_DESC(armv7, ARMV7, armv7, armv7);
#endif
+#if defined(__aarch64__)
+PMC_CLASS_TABLE_DESC(cortex_a53, ARMV8, cortex_a53, arm64);
+PMC_CLASS_TABLE_DESC(cortex_a57, ARMV8, cortex_a57, arm64);
+#endif
#if defined(__mips__)
PMC_CLASS_TABLE_DESC(mips24k, MIPS24K, mips24k, mips);
PMC_CLASS_TABLE_DESC(mips74k, MIPS74K, mips74k, mips);
@@ -402,9 +423,14 @@ static const char * pmc_capability_names[] = {
__PMC_CAPS()
};
-static const char * pmc_class_names[] = {
+struct pmc_class_map {
+ enum pmc_class pm_class;
+ const char *pm_name;
+};
+
+static const struct pmc_class_map pmc_class_names[] = {
#undef __PMC_CLASS
-#define __PMC_CLASS(C) #C ,
+#define __PMC_CLASS(S,V,D) { .pm_class = PMC_CLASS_##S, .pm_name = #S } ,
__PMC_CLASSES()
};
@@ -2429,6 +2455,26 @@ armv7_allocate_pmc(enum pmc_event pe, char *ctrspec __unused,
}
#endif
+#if defined(__aarch64__)
+static struct pmc_event_alias cortex_a53_aliases[] = {
+ EV_ALIAS(NULL, NULL)
+};
+static struct pmc_event_alias cortex_a57_aliases[] = {
+ EV_ALIAS(NULL, NULL)
+};
+static int
+arm64_allocate_pmc(enum pmc_event pe, char *ctrspec __unused,
+ struct pmc_op_pmcallocate *pmc_config __unused)
+{
+ switch (pe) {
+ default:
+ break;
+ }
+
+ return (0);
+}
+#endif
+
#if defined(__mips__)
static struct pmc_event_alias mips24k_aliases[] = {
@@ -2938,6 +2984,19 @@ pmc_event_names_of_class(enum pmc_class cl, const char ***eventnames,
ev = armv7_event_table;
count = PMC_EVENT_TABLE_SIZE(armv7);
break;
+ case PMC_CLASS_ARMV8:
+ switch (cpu_info.pm_cputype) {
+ default:
+ case PMC_CPU_ARMV8_CORTEX_A53:
+ ev = cortex_a53_event_table;
+ count = PMC_EVENT_TABLE_SIZE(cortex_a53);
+ break;
+ case PMC_CPU_ARMV8_CORTEX_A57:
+ ev = cortex_a57_event_table;
+ count = PMC_EVENT_TABLE_SIZE(cortex_a57);
+ break;
+ }
+ break;
case PMC_CLASS_MIPS24K:
ev = mips24k_event_table;
count = PMC_EVENT_TABLE_SIZE(mips24k);
@@ -3235,6 +3294,16 @@ pmc_init(void)
pmc_class_table[n] = &armv7_class_table_descr;
break;
#endif
+#if defined(__aarch64__)
+ case PMC_CPU_ARMV8_CORTEX_A53:
+ PMC_MDEP_INIT(cortex_a53);
+ pmc_class_table[n] = &cortex_a53_class_table_descr;
+ break;
+ case PMC_CPU_ARMV8_CORTEX_A57:
+ PMC_MDEP_INIT(cortex_a57);
+ pmc_class_table[n] = &cortex_a57_class_table_descr;
+ break;
+#endif
#if defined(__mips__)
case PMC_CPU_MIPS_24K:
PMC_MDEP_INIT(mips24k);
@@ -3298,9 +3367,11 @@ pmc_name_of_capability(enum pmc_caps cap)
const char *
pmc_name_of_class(enum pmc_class pc)
{
- if ((int) pc >= PMC_CLASS_FIRST &&
- pc <= PMC_CLASS_LAST)
- return (pmc_class_names[pc]);
+ size_t n;
+
+ for (n = 0; n < PMC_TABLE_SIZE(pmc_class_names); n++)
+ if (pc == pmc_class_names[n].pm_class)
+ return (pmc_class_names[n].pm_name);
errno = EINVAL;
return (NULL);
@@ -3446,6 +3517,19 @@ _pmc_name_of_event(enum pmc_event pe, enum pmc_cputype cpu)
} else if (pe >= PMC_EV_ARMV7_FIRST && pe <= PMC_EV_ARMV7_LAST) {
ev = armv7_event_table;
evfence = armv7_event_table + PMC_EVENT_TABLE_SIZE(armv7);
+ } else if (pe >= PMC_EV_ARMV8_FIRST && pe <= PMC_EV_ARMV8_LAST) {
+ switch (cpu) {
+ case PMC_CPU_ARMV8_CORTEX_A53:
+ ev = cortex_a53_event_table;
+ evfence = cortex_a53_event_table + PMC_EVENT_TABLE_SIZE(cortex_a53);
+ break;
+ case PMC_CPU_ARMV8_CORTEX_A57:
+ ev = cortex_a57_event_table;
+ evfence = cortex_a57_event_table + PMC_EVENT_TABLE_SIZE(cortex_a57);
+ break;
+ default: /* Unknown CPU type. */
+ break;
+ }
} else if (pe >= PMC_EV_MIPS24K_FIRST && pe <= PMC_EV_MIPS24K_LAST) {
ev = mips24k_event_table;
evfence = mips24k_event_table + PMC_EVENT_TABLE_SIZE(mips24k);
diff --git a/lib/libproc/Makefile b/lib/libproc/Makefile
index 9646570..8c4f484 100644
--- a/lib/libproc/Makefile
+++ b/lib/libproc/Makefile
@@ -23,6 +23,8 @@ LIBADD+= cxxrt
LIBADD+= supcplusplus
.endif
+LIBADD+= elf rtld_db util
+
.if ${MK_CDDL} != "no"
LIBADD+= ctf
IGNORE_PRAGMA= YES
diff --git a/lib/libprocstat/Makefile b/lib/libprocstat/Makefile
index ff9146b..fc71dbc 100644
--- a/lib/libprocstat/Makefile
+++ b/lib/libprocstat/Makefile
@@ -22,6 +22,36 @@ SHLIB_MAJOR= 1
LIBADD= elf kvm util
MAN= libprocstat.3
+MLINKS+=libprocstat.3 procstat_close.3 \
+ libprocstat.3 procstat_freeargv.3 \
+ libprocstat.3 procstat_freeauxv.3 \
+ libprocstat.3 procstat_freeenvv.3 \
+ libprocstat.3 procstat_freefiles.3 \
+ libprocstat.3 procstat_freegroups.3 \
+ libprocstat.3 procstat_freekstack.3 \
+ libprocstat.3 procstat_freeprocs.3 \
+ libprocstat.3 procstat_freevmmap.3 \
+ libprocstat.3 procstat_get_pipe_info.3 \
+ libprocstat.3 procstat_get_pts_info.3 \
+ libprocstat.3 procstat_get_sem_info.3 \
+ libprocstat.3 procstat_get_shm_info.3 \
+ libprocstat.3 procstat_get_socket_info.3 \
+ libprocstat.3 procstat_get_vnode_info.3 \
+ libprocstat.3 procstat_getargv.3 \
+ libprocstat.3 procstat_getauxv.3 \
+ libprocstat.3 procstat_getenvv.3 \
+ libprocstat.3 procstat_getfiles.3 \
+ libprocstat.3 procstat_getgroups.3 \
+ libprocstat.3 procstat_getkstack.3 \
+ libprocstat.3 procstat_getosrel.3 \
+ libprocstat.3 procstat_getpathname.3 \
+ libprocstat.3 procstat_getprocs.3 \
+ libprocstat.3 procstat_getrlimit.3 \
+ libprocstat.3 procstat_getumask.3 \
+ libprocstat.3 procstat_getvmmap.3 \
+ libprocstat.3 procstat_open_core.3 \
+ libprocstat.3 procstat_open_kvm.3 \
+ libprocstat.3 procstat_open_sysctl.3
# XXX This is a hack.
.if ${MK_CDDL} != "no"
diff --git a/lib/libprocstat/libprocstat.3 b/lib/libprocstat/libprocstat.3
index 1c1f811..e8be41c 100644
--- a/lib/libprocstat/libprocstat.3
+++ b/lib/libprocstat/libprocstat.3
@@ -24,25 +24,11 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 3, 2013
+.Dd May 18, 2015
.Dt LIBPROCSTAT 3
.Os
.Sh NAME
-.Nm procstat_open_core ,
-.Nm procstat_open_kvm ,
-.Nm procstat_open_sysctl ,
.Nm procstat_close ,
-.Nm procstat_getargv ,
-.Nm procstat_getauxv ,
-.Nm procstat_getenvv ,
-.Nm procstat_getfiles ,
-.Nm procstat_getgroups ,
-.Nm procstat_getkstack ,
-.Nm procstat_getosrel ,
-.Nm procstat_getpathname ,
-.Nm procstat_getprocs ,
-.Nm procstat_getumask ,
-.Nm procstat_getvmmap ,
.Nm procstat_freeargv ,
.Nm procstat_freeauxv ,
.Nm procstat_freeenvv ,
@@ -56,7 +42,22 @@
.Nm procstat_get_sem_info ,
.Nm procstat_get_shm_info ,
.Nm procstat_get_socket_info ,
-.Nm procstat_get_vnode_info
+.Nm procstat_get_vnode_info ,
+.Nm procstat_getargv ,
+.Nm procstat_getauxv ,
+.Nm procstat_getenvv ,
+.Nm procstat_getfiles ,
+.Nm procstat_getgroups ,
+.Nm procstat_getkstack ,
+.Nm procstat_getosrel ,
+.Nm procstat_getpathname ,
+.Nm procstat_getprocs ,
+.Nm procstat_getrlimit ,
+.Nm procstat_getumask ,
+.Nm procstat_getvmmap ,
+.Nm procstat_open_core ,
+.Nm procstat_open_kvm ,
+.Nm procstat_open_sysctl
.Nd library interface for file and process information retrieval
.Sh LIBRARY
.Lb libprocstat
@@ -175,17 +176,24 @@
.Fa "struct kinfo_proc *kp"
.Fa "unsigned int *count"
.Fc
+.Ft "struct kinfo_kstack *"
+.Fo procstat_getkstack
+.Fa "struct procstat *procstat"
+.Fa "struct kinfo_proc *kp"
+.Fa "unsigned int *count"
+.Fc
.Ft int
.Fo procstat_getosrel
.Fa "struct procstat *procstat"
.Fa "struct kinfo_proc *kp"
.Fa "int *osrelp"
.Fc
-.Ft "struct kinfo_kstack *"
-.Fo procstat_getkstack
+.Ft "int"
+.Fo procstat_getpathname
.Fa "struct procstat *procstat"
.Fa "struct kinfo_proc *kp"
-.Fa "unsigned int *count"
+.Fa "char *pathname"
+.Fa "size_t maxlen"
.Fc
.Ft "struct kinfo_proc *"
.Fo procstat_getprocs
@@ -195,13 +203,6 @@
.Fa "unsigned int *count"
.Fc
.Ft "int"
-.Fo procstat_getpathname
-.Fa "struct procstat *procstat"
-.Fa "struct kinfo_proc *kp"
-.Fa "char *pathname"
-.Fa "size_t maxlen"
-.Fc
-.Ft "int"
.Fo procstat_getrlimit
.Fa "struct procstat *procstat"
.Fa "struct kinfo_proc *kp"
diff --git a/lib/libthr/tests/Makefile b/lib/libthr/tests/Makefile
index 50f07f0..11cf0e7 100644
--- a/lib/libthr/tests/Makefile
+++ b/lib/libthr/tests/Makefile
@@ -25,7 +25,9 @@ NETBSD_ATF_TESTS_C+= sigmask_test
NETBSD_ATF_TESTS_C+= sigsuspend_test
NETBSD_ATF_TESTS_C+= siglongjmp_test
NETBSD_ATF_TESTS_C+= sleep_test
+.if ${MACHINE} != "arm64" # ARM64TODO: Missing makecontext
NETBSD_ATF_TESTS_C+= swapcontext_test
+.endif
NETBSD_ATF_TESTS_SH= atexit_test
NETBSD_ATF_TESTS_SH+= cancel_test
diff --git a/lib/libthr/thread/thr_spec.c b/lib/libthr/thread/thr_spec.c
index 46a6105..b53c4b7 100644
--- a/lib/libthr/thread/thr_spec.c
+++ b/lib/libthr/thread/thr_spec.c
@@ -30,6 +30,7 @@
*/
#include "namespace.h"
+#include <sys/mman.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
@@ -40,7 +41,6 @@
#include "thr_private.h"
-/* Static variables: */
struct pthread_key _thread_keytable[PTHREAD_KEYS_MAX];
__weak_reference(_pthread_key_create, pthread_key_create);
@@ -50,7 +50,7 @@ __weak_reference(_pthread_setspecific, pthread_setspecific);
int
-_pthread_key_create(pthread_key_t *key, void (*destructor) (void *))
+_pthread_key_create(pthread_key_t *key, void (*destructor)(void *))
{
struct pthread *curthread;
int i;
@@ -59,7 +59,6 @@ _pthread_key_create(pthread_key_t *key, void (*destructor) (void *))
curthread = _get_curthread();
- /* Lock the key table: */
THR_LOCK_ACQUIRE(curthread, &_keytable_lock);
for (i = 0; i < PTHREAD_KEYS_MAX; i++) {
@@ -68,14 +67,12 @@ _pthread_key_create(pthread_key_t *key, void (*destructor) (void *))
_thread_keytable[i].destructor = destructor;
_thread_keytable[i].seqno++;
- /* Unlock the key table: */
THR_LOCK_RELEASE(curthread, &_keytable_lock);
*key = i + 1;
return (0);
}
}
- /* Unlock the key table: */
THR_LOCK_RELEASE(curthread, &_keytable_lock);
return (EAGAIN);
}
@@ -83,44 +80,40 @@ _pthread_key_create(pthread_key_t *key, void (*destructor) (void *))
int
_pthread_key_delete(pthread_key_t userkey)
{
- struct pthread *curthread = _get_curthread();
- int key = userkey - 1;
- int ret = 0;
-
- if ((unsigned int)key < PTHREAD_KEYS_MAX) {
- /* Lock the key table: */
- THR_LOCK_ACQUIRE(curthread, &_keytable_lock);
-
- if (_thread_keytable[key].allocated)
- _thread_keytable[key].allocated = 0;
- else
- ret = EINVAL;
+ struct pthread *curthread;
+ int key, ret;
- /* Unlock the key table: */
- THR_LOCK_RELEASE(curthread, &_keytable_lock);
- } else
+ key = userkey - 1;
+ if ((unsigned int)key >= PTHREAD_KEYS_MAX)
+ return (EINVAL);
+ curthread = _get_curthread();
+ THR_LOCK_ACQUIRE(curthread, &_keytable_lock);
+ if (_thread_keytable[key].allocated) {
+ _thread_keytable[key].allocated = 0;
+ ret = 0;
+ } else {
ret = EINVAL;
+ }
+ THR_LOCK_RELEASE(curthread, &_keytable_lock);
return (ret);
}
void
_thread_cleanupspecific(void)
{
- struct pthread *curthread = _get_curthread();
- void (*destructor)( void *);
- const void *data = NULL;
- int key;
- int i;
+ struct pthread *curthread;
+ void (*destructor)(void *);
+ const void *data;
+ int i, key;
+ curthread = _get_curthread();
if (curthread->specific == NULL)
return;
-
- /* Lock the key table: */
THR_LOCK_ACQUIRE(curthread, &_keytable_lock);
- for (i = 0; (i < PTHREAD_DESTRUCTOR_ITERATIONS) &&
- (curthread->specific_data_count > 0); i++) {
- for (key = 0; (key < PTHREAD_KEYS_MAX) &&
- (curthread->specific_data_count > 0); key++) {
+ for (i = 0; i < PTHREAD_DESTRUCTOR_ITERATIONS &&
+ curthread->specific_data_count > 0; i++) {
+ for (key = 0; key < PTHREAD_KEYS_MAX &&
+ curthread->specific_data_count > 0; key++) {
destructor = NULL;
if (_thread_keytable[key].allocated &&
@@ -128,31 +121,29 @@ _thread_cleanupspecific(void)
if (curthread->specific[key].seqno ==
_thread_keytable[key].seqno) {
data = curthread->specific[key].data;
- destructor = _thread_keytable[key].destructor;
+ destructor = _thread_keytable[key].
+ destructor;
}
curthread->specific[key].data = NULL;
curthread->specific_data_count--;
- }
- else if (curthread->specific[key].data != NULL) {
+ } else if (curthread->specific[key].data != NULL) {
/*
- * This can happen if the key is deleted via
- * pthread_key_delete without first setting the value
- * to NULL in all threads. POSIX says that the
- * destructor is not invoked in this case.
+ * This can happen if the key is
+ * deleted via pthread_key_delete
+ * without first setting the value to
+ * NULL in all threads. POSIX says
+ * that the destructor is not invoked
+ * in this case.
*/
curthread->specific[key].data = NULL;
curthread->specific_data_count--;
}
/*
- * If there is a destructor, call it
- * with the key table entry unlocked:
+ * If there is a destructor, call it with the
+ * key table entry unlocked.
*/
if (destructor != NULL) {
- /*
- * Don't hold the lock while calling the
- * destructor:
- */
THR_LOCK_RELEASE(curthread, &_keytable_lock);
destructor(__DECONST(void *, data));
THR_LOCK_ACQUIRE(curthread, &_keytable_lock);
@@ -160,102 +151,92 @@ _thread_cleanupspecific(void)
}
}
THR_LOCK_RELEASE(curthread, &_keytable_lock);
- free(curthread->specific);
+ munmap(curthread->specific, PTHREAD_KEYS_MAX * sizeof(struct
+ pthread_specific_elem));
curthread->specific = NULL;
- if (curthread->specific_data_count > 0)
+ if (curthread->specific_data_count > 0) {
stderr_debug("Thread %p has exited with leftover "
"thread-specific data after %d destructor iterations\n",
curthread, PTHREAD_DESTRUCTOR_ITERATIONS);
-}
-
-static inline struct pthread_specific_elem *
-pthread_key_allocate_data(void)
-{
- struct pthread_specific_elem *new_data;
-
- new_data = (struct pthread_specific_elem *)
- calloc(1, sizeof(struct pthread_specific_elem) * PTHREAD_KEYS_MAX);
- return (new_data);
+ }
}
int
_pthread_setspecific(pthread_key_t userkey, const void *value)
{
- struct pthread *pthread;
- pthread_key_t key = userkey - 1;
- int ret = 0;
+ struct pthread *pthread;
+ void *tmp;
+ pthread_key_t key;
- /* Point to the running thread: */
- pthread = _get_curthread();
+ key = userkey - 1;
+ if ((unsigned int)key >= PTHREAD_KEYS_MAX ||
+ !_thread_keytable[key].allocated)
+ return (EINVAL);
- if ((pthread->specific) ||
- (pthread->specific = pthread_key_allocate_data())) {
- if ((unsigned int)key < PTHREAD_KEYS_MAX) {
- if (_thread_keytable[key].allocated) {
- if (pthread->specific[key].data == NULL) {
- if (value != NULL)
- pthread->specific_data_count++;
- } else if (value == NULL)
- pthread->specific_data_count--;
- pthread->specific[key].data = value;
- pthread->specific[key].seqno =
- _thread_keytable[key].seqno;
- ret = 0;
- } else
- ret = EINVAL;
- } else
- ret = EINVAL;
- } else
- ret = ENOMEM;
- return (ret);
+ pthread = _get_curthread();
+ if (pthread->specific == NULL) {
+ tmp = mmap(NULL, PTHREAD_KEYS_MAX *
+ sizeof(struct pthread_specific_elem),
+ PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+ if (tmp == MAP_FAILED)
+ return (ENOMEM);
+ pthread->specific = tmp;
+ }
+ if (pthread->specific[key].data == NULL) {
+ if (value != NULL)
+ pthread->specific_data_count++;
+ } else if (value == NULL)
+ pthread->specific_data_count--;
+ pthread->specific[key].data = value;
+ pthread->specific[key].seqno = _thread_keytable[key].seqno;
+ return (0);
}
void *
_pthread_getspecific(pthread_key_t userkey)
{
- struct pthread *pthread;
- pthread_key_t key = userkey - 1;
- const void *data;
+ struct pthread *pthread;
+ const void *data;
+ pthread_key_t key;
- /* Point to the running thread: */
- pthread = _get_curthread();
+ /* Check if there is specific data. */
+ key = userkey - 1;
+ if ((unsigned int)key >= PTHREAD_KEYS_MAX)
+ return (NULL);
- /* Check if there is specific data: */
- if (pthread->specific != NULL && (unsigned int)key < PTHREAD_KEYS_MAX) {
- /* Check if this key has been used before: */
- if (_thread_keytable[key].allocated &&
- (pthread->specific[key].seqno == _thread_keytable[key].seqno)) {
- /* Return the value: */
- data = pthread->specific[key].data;
- } 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: */
+ pthread = _get_curthread();
+ /* Check if this key has been used before. */
+ if (_thread_keytable[key].allocated && pthread->specific != NULL &&
+ pthread->specific[key].seqno == _thread_keytable[key].seqno) {
+ /* Return the value: */
+ data = pthread->specific[key].data;
+ } else {
+ /*
+ * This key has not been used before, so return NULL
+ * instead.
+ */
data = NULL;
+ }
return (__DECONST(void *, data));
}
void
_thr_tsd_unload(struct dl_phdr_info *phdr_info)
{
- struct pthread *curthread = _get_curthread();
+ struct pthread *curthread;
void (*destructor)(void *);
int key;
+ curthread = _get_curthread();
THR_LOCK_ACQUIRE(curthread, &_keytable_lock);
for (key = 0; key < PTHREAD_KEYS_MAX; key++) {
- if (_thread_keytable[key].allocated) {
- destructor = _thread_keytable[key].destructor;
- if (destructor != NULL) {
- if (__elf_phdr_match_addr(phdr_info, destructor))
- _thread_keytable[key].destructor = NULL;
- }
- }
+ if (!_thread_keytable[key].allocated)
+ continue;
+ destructor = _thread_keytable[key].destructor;
+ if (destructor == NULL)
+ continue;
+ if (__elf_phdr_match_addr(phdr_info, destructor))
+ _thread_keytable[key].destructor = NULL;
}
THR_LOCK_RELEASE(curthread, &_keytable_lock);
}
diff --git a/lib/libucl/Makefile b/lib/libucl/Makefile
index b94f3da..310e8b7 100644
--- a/lib/libucl/Makefile
+++ b/lib/libucl/Makefile
@@ -14,8 +14,10 @@ SRCS= ucl_emitter_streamline.c \
ucl_util.c \
xxhash.c
-.PATH: ${LIBUCL}/src
+.PATH: ${LIBUCL}/src \
+ ${LIBUCL}/include
+INCS= ucl.h
LIBADD= m
WARNS= 1
diff --git a/lib/libufs/Makefile b/lib/libufs/Makefile
index 78832d8..24efd0c 100644
--- a/lib/libufs/Makefile
+++ b/lib/libufs/Makefile
@@ -21,7 +21,6 @@ MLINKS+= ufs_disk_close.3 ufs_disk_write.3
WARNS?= 2
-DEBUG_FLAGS = -g
CFLAGS+= -D_LIBUFS
.if defined(LIBUFS_DEBUG)
CFLAGS+= -D_LIBUFS_DEBUGGING
diff --git a/lib/libvmmapi/vmmapi.c b/lib/libvmmapi/vmmapi.c
index 0c15845..1e6e627 100644
--- a/lib/libvmmapi/vmmapi.c
+++ b/lib/libvmmapi/vmmapi.c
@@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$");
#include <machine/specialreg.h>
#include <machine/param.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
@@ -958,9 +959,9 @@ vm_get_hpet_capabilities(struct vmctx *ctx, uint32_t *capabilities)
return (error);
}
-static int
-gla2gpa(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
- uint64_t gla, int prot, int *fault, uint64_t *gpa)
+int
+vm_gla2gpa(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
+ uint64_t gla, int prot, uint64_t *gpa, int *fault)
{
struct vm_gla2gpa gg;
int error;
@@ -979,29 +980,18 @@ gla2gpa(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
return (error);
}
-int
-vm_gla2gpa(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
- uint64_t gla, int prot, uint64_t *gpa)
-{
- int error, fault;
-
- error = gla2gpa(ctx, vcpu, paging, gla, prot, &fault, gpa);
- if (fault)
- error = fault;
- return (error);
-}
-
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
int
vm_copy_setup(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
- uint64_t gla, size_t len, int prot, struct iovec *iov, int iovcnt)
+ uint64_t gla, size_t len, int prot, struct iovec *iov, int iovcnt,
+ int *fault)
{
void *va;
uint64_t gpa;
- int error, fault, i, n, off;
+ int error, i, n, off;
for (i = 0; i < iovcnt; i++) {
iov[i].iov_base = 0;
@@ -1010,18 +1000,16 @@ vm_copy_setup(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
while (len) {
assert(iovcnt > 0);
- error = gla2gpa(ctx, vcpu, paging, gla, prot, &fault, &gpa);
- if (error)
- return (-1);
- if (fault)
- return (1);
+ error = vm_gla2gpa(ctx, vcpu, paging, gla, prot, &gpa, fault);
+ if (error || *fault)
+ return (error);
off = gpa & PAGE_MASK;
n = min(len, PAGE_SIZE - off);
va = vm_map_gpa(ctx, gpa, n);
if (va == NULL)
- return (-1);
+ return (EFAULT);
iov->iov_base = va;
iov->iov_len = n;
diff --git a/lib/libvmmapi/vmmapi.h b/lib/libvmmapi/vmmapi.h
index d001cd8..d3ecdc4 100644
--- a/lib/libvmmapi/vmmapi.h
+++ b/lib/libvmmapi/vmmapi.h
@@ -64,7 +64,7 @@ int vm_setup_memory(struct vmctx *ctx, size_t len, enum vm_mmap_style s);
void *vm_map_gpa(struct vmctx *ctx, vm_paddr_t gaddr, size_t len);
int vm_get_gpa_pmap(struct vmctx *, uint64_t gpa, uint64_t *pte, int *num);
int vm_gla2gpa(struct vmctx *, int vcpuid, struct vm_guest_paging *paging,
- uint64_t gla, int prot, uint64_t *gpa);
+ uint64_t gla, int prot, uint64_t *gpa, int *fault);
uint32_t vm_get_lowmem_limit(struct vmctx *ctx);
void vm_set_lowmem_limit(struct vmctx *ctx, uint32_t limit);
void vm_set_memflags(struct vmctx *ctx, int flags);
@@ -131,10 +131,15 @@ int vm_get_hpet_capabilities(struct vmctx *ctx, uint32_t *capabilities);
/*
* Translate the GLA range [gla,gla+len) into GPA segments in 'iov'.
* The 'iovcnt' should be big enough to accomodate all GPA segments.
- * Returns 0 on success, 1 on a guest fault condition and -1 otherwise.
+ *
+ * retval fault Interpretation
+ * 0 0 Success
+ * 0 1 An exception was injected into the guest
+ * EFAULT N/A Error
*/
int vm_copy_setup(struct vmctx *ctx, int vcpu, struct vm_guest_paging *pg,
- uint64_t gla, size_t len, int prot, struct iovec *iov, int iovcnt);
+ uint64_t gla, size_t len, int prot, struct iovec *iov, int iovcnt,
+ int *fault);
void vm_copyin(struct vmctx *ctx, int vcpu, struct iovec *guest_iov,
void *host_dst, size_t len);
void vm_copyout(struct vmctx *ctx, int vcpu, const void *host_src,
diff --git a/lib/libxo/Makefile b/lib/libxo/Makefile
index cc0e72a..62fface 100644
--- a/lib/libxo/Makefile
+++ b/lib/libxo/Makefile
@@ -26,6 +26,7 @@ MAN+= xo_attr.3 \
xo_flush.3 \
xo_no_setlocale.3 \
xo_open_container.3 \
+ xo_open_marker.3 \
xo_open_list.3 \
xo_parse_args.3 \
xo_set_allocator.3 \
@@ -33,6 +34,7 @@ MAN+= xo_attr.3 \
xo_set_info.3 \
xo_set_options.3 \
xo_set_style.3 \
+ xo_set_version.3 \
xo_set_writer.3
MAN+= xo_format.5
diff --git a/lib/msun/src/e_j0.c b/lib/msun/src/e_j0.c
index 365ffe5..a253ed1 100644
--- a/lib/msun/src/e_j0.c
+++ b/lib/msun/src/e_j0.c
@@ -62,7 +62,7 @@ __FBSDID("$FreeBSD$");
#include "math.h"
#include "math_private.h"
-static double pzero(double), qzero(double);
+static __inline double pzero(double), qzero(double);
static const volatile double vone = 1, vzero = 0;
diff --git a/lib/msun/src/e_j0f.c b/lib/msun/src/e_j0f.c
index e86ed64..3e2f7e8 100644
--- a/lib/msun/src/e_j0f.c
+++ b/lib/msun/src/e_j0f.c
@@ -23,7 +23,7 @@ __FBSDID("$FreeBSD$");
#include "math.h"
#include "math_private.h"
-static float pzerof(float), qzerof(float);
+static __inline float pzerof(float), qzerof(float);
static const volatile float vone = 1, vzero = 0;
diff --git a/lib/msun/src/e_j1.c b/lib/msun/src/e_j1.c
index 4922058..74a7c69 100644
--- a/lib/msun/src/e_j1.c
+++ b/lib/msun/src/e_j1.c
@@ -62,7 +62,7 @@ __FBSDID("$FreeBSD$");
#include "math.h"
#include "math_private.h"
-static double pone(double), qone(double);
+static __inline double pone(double), qone(double);
static const volatile double vone = 1, vzero = 0;
diff --git a/lib/msun/src/e_j1f.c b/lib/msun/src/e_j1f.c
index c39c548..ec7f381 100644
--- a/lib/msun/src/e_j1f.c
+++ b/lib/msun/src/e_j1f.c
@@ -23,7 +23,7 @@ __FBSDID("$FreeBSD$");
#include "math.h"
#include "math_private.h"
-static float ponef(float), qonef(float);
+static __inline float ponef(float), qonef(float);
static const volatile float vone = 1, vzero = 0;
diff --git a/lib/msun/tests/Makefile b/lib/msun/tests/Makefile
index cb06868..0479cfb 100644
--- a/lib/msun/tests/Makefile
+++ b/lib/msun/tests/Makefile
@@ -6,13 +6,12 @@ TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libm
TESTSDIR= ${TESTSBASE}/lib/msun
-.if ${MACHINE} == "sparc" || ${MACHINE} == "i386" \
- || ${MACHINE} == "amd64" || ${MACHINE_CPU} == "arm" \
- || ${MACHINE} == "sparc64"
+# All architectures on FreeBSD have fenv.h
CFLAGS+= -DHAVE_FENV_H
-.endif
-.if ${MACHINE} == "amd64" || ${MACHINE} == "i386"
+# Not sure why this isn't defined for all architectures, since most
+# have long double.
+.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
CFLAGS+= -D__HAVE_LONG_DOUBLE
.endif
diff --git a/libexec/casper/dns/dns.c b/libexec/casper/dns/dns.c
index 6be022a..f82801e 100644
--- a/libexec/casper/dns/dns.c
+++ b/libexec/casper/dns/dns.c
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
#include <netinet/in.h>
+#include <assert.h>
#include <errno.h>
#include <netdb.h>
#include <stdlib.h>
@@ -103,6 +104,8 @@ static void
hostent_pack(const struct hostent *hp, nvlist_t *nvl)
{
unsigned int ii;
+ char nvlname[64];
+ int n;
nvlist_add_string(nvl, "name", hp->h_name);
nvlist_add_number(nvl, "addrtype", (uint64_t)hp->h_addrtype);
@@ -112,8 +115,9 @@ hostent_pack(const struct hostent *hp, nvlist_t *nvl)
nvlist_add_number(nvl, "naliases", 0);
} else {
for (ii = 0; hp->h_aliases[ii] != NULL; ii++) {
- nvlist_addf_string(nvl, hp->h_aliases[ii], "alias%u",
- ii);
+ n = snprintf(nvlname, sizeof(nvlname), "alias%u", ii);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_add_string(nvl, nvlname, hp->h_aliases[ii]);
}
nvlist_add_number(nvl, "naliases", (uint64_t)ii);
}
@@ -122,8 +126,10 @@ hostent_pack(const struct hostent *hp, nvlist_t *nvl)
nvlist_add_number(nvl, "naddrs", 0);
} else {
for (ii = 0; hp->h_addr_list[ii] != NULL; ii++) {
- nvlist_addf_binary(nvl, hp->h_addr_list[ii],
- (size_t)hp->h_length, "addr%u", ii);
+ n = snprintf(nvlname, sizeof(nvlname), "addr%u", ii);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_add_binary(nvl, nvlname, hp->h_addr_list[ii],
+ (size_t)hp->h_length);
}
nvlist_add_number(nvl, "naddrs", (uint64_t)ii);
}
@@ -228,8 +234,10 @@ dns_getnameinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
goto out;
}
- if (!dns_allowed_family(limits, (int)sast.ss_family))
- return (NO_RECOVERY);
+ if (!dns_allowed_family(limits, (int)sast.ss_family)) {
+ error = NO_RECOVERY;
+ goto out;
+ }
flags = (int)nvlist_get_number(nvlin, "flags");
@@ -269,9 +277,10 @@ dns_getaddrinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
{
struct addrinfo hints, *hintsp, *res, *cur;
const char *hostname, *servname;
+ char nvlname[64];
nvlist_t *elem;
unsigned int ii;
- int error, family;
+ int error, family, n;
if (!dns_allowed_type(limits, "ADDR"))
return (NO_RECOVERY);
@@ -308,7 +317,9 @@ dns_getaddrinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
for (cur = res, ii = 0; cur != NULL; cur = cur->ai_next, ii++) {
elem = addrinfo_pack(cur);
- nvlist_movef_nvlist(nvlout, elem, "res%u", ii);
+ n = snprintf(nvlname, sizeof(nvlname), "res%u", ii);
+ assert(n > 0 && n < (int)sizeof(nvlname));
+ nvlist_move_nvlist(nvlout, nvlname, elem);
}
freeaddrinfo(res);
diff --git a/libexec/casper/grp/grp.c b/libexec/casper/grp/grp.c
index ba22f62..ab28e1a 100644
--- a/libexec/casper/grp/grp.c
+++ b/libexec/casper/grp/grp.c
@@ -30,6 +30,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <assert.h>
#include <errno.h>
#include <grp.h>
#include <stdlib.h>
@@ -184,6 +185,8 @@ grp_allowed_fields(const nvlist_t *oldlimits, const nvlist_t *newlimits)
static bool
grp_pack(const nvlist_t *limits, const struct group *grp, nvlist_t *nvl)
{
+ char nvlname[64];
+ int n;
if (grp == NULL)
return (true);
@@ -210,8 +213,10 @@ grp_pack(const nvlist_t *limits, const struct group *grp, nvlist_t *nvl)
unsigned int ngroups;
for (ngroups = 0; grp->gr_mem[ngroups] != NULL; ngroups++) {
- nvlist_addf_string(nvl, grp->gr_mem[ngroups],
- "gr_mem[%u]", ngroups);
+ n = snprintf(nvlname, sizeof(nvlname), "gr_mem[%u]",
+ ngroups);
+ assert(n > 0 && n < sizeof(nvlname));
+ nvlist_add_string(nvl, nvlname, grp->gr_mem[ngroups]);
}
nvlist_add_number(nvl, "gr_nmem", (uint64_t)ngroups);
}
diff --git a/libexec/getty/subr.c b/libexec/getty/subr.c
index 26d2173..992280a 100644
--- a/libexec/getty/subr.c
+++ b/libexec/getty/subr.c
@@ -38,9 +38,6 @@ static const char rcsid[] =
/*
* Melbourne getty.
*/
-#ifdef DEBUG
-#include <stdio.h>
-#endif
#include <stdlib.h>
#include <string.h>
#include <termios.h>
@@ -160,17 +157,6 @@ gettable(const char *name, char *buf)
fp->value = 1 ^ fp->invrt;
}
}
-
-#ifdef DEBUG
- printf("name=\"%s\", buf=\"%s\"\r\n", name, buf);
- for (sp = gettystrs; sp->field; sp++)
- printf("cgetstr: %s=%s\r\n", sp->field, sp->value);
- for (np = gettynums; np->field; np++)
- printf("cgetnum: %s=%d\r\n", np->field, np->value);
- for (fp = gettyflags; fp->field; fp++)
- printf("cgetflags: %s='%c' set='%c'\r\n", fp->field,
- fp->value + '0', fp->set + '0');
-#endif /* DEBUG */
}
void
diff --git a/libexec/rtld-elf/debug.h b/libexec/rtld-elf/debug.h
index 98fdfb4..ed65227 100644
--- a/libexec/rtld-elf/debug.h
+++ b/libexec/rtld-elf/debug.h
@@ -32,10 +32,6 @@
#ifndef DEBUG_H
#define DEBUG_H 1
-#ifndef __GNUC__
-#error "This file must be compiled with GCC"
-#endif
-
#include <sys/cdefs.h>
#include <string.h>
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index b070474..1d91460 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -34,10 +34,6 @@
* John Polstra <jdp@polstra.com>.
*/
-#ifndef __GNUC__
-#error "GCC is needed to compile this file"
-#endif
-
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/mman.h>
@@ -148,8 +144,10 @@ static void unlink_object(Obj_Entry *);
static void unload_object(Obj_Entry *);
static void unref_dag(Obj_Entry *);
static void ref_dag(Obj_Entry *);
-static char *origin_subst_one(char *, const char *, const char *, bool);
-static char *origin_subst(char *, const char *);
+static char *origin_subst_one(Obj_Entry *, char *, const char *,
+ const char *, bool);
+static char *origin_subst(Obj_Entry *, char *);
+static bool obj_resolve_origin(Obj_Entry *obj);
static void preinit_main(void);
static int rtld_verify_versions(const Objlist *);
static int rtld_verify_object_versions(Obj_Entry *);
@@ -788,8 +786,8 @@ basename(const char *name)
static struct utsname uts;
static char *
-origin_subst_one(char *real, const char *kw, const char *subst,
- bool may_free)
+origin_subst_one(Obj_Entry *obj, char *real, const char *kw,
+ const char *subst, bool may_free)
{
char *p, *p1, *res, *resp;
int subst_len, kw_len, subst_count, old_len, new_len;
@@ -808,9 +806,15 @@ origin_subst_one(char *real, const char *kw, const char *subst,
/*
* If the keyword is not found, just return.
+ *
+ * Return non-substituted string if resolution failed. We
+ * cannot do anything more reasonable, the failure mode of the
+ * caller is unresolved library anyway.
*/
- if (subst_count == 0)
+ if (subst_count == 0 || (obj != NULL && !obj_resolve_origin(obj)))
return (may_free ? real : xstrdup(real));
+ if (obj != NULL)
+ subst = obj->origin_path;
/*
* There is indeed something to substitute. Calculate the
@@ -847,20 +851,22 @@ origin_subst_one(char *real, const char *kw, const char *subst,
}
static char *
-origin_subst(char *real, const char *origin_path)
+origin_subst(Obj_Entry *obj, char *real)
{
char *res1, *res2, *res3, *res4;
+ if (obj == NULL || !trust)
+ return (xstrdup(real));
if (uts.sysname[0] == '\0') {
if (uname(&uts) != 0) {
_rtld_error("utsname failed: %d", errno);
return (NULL);
}
}
- res1 = origin_subst_one(real, "$ORIGIN", origin_path, false);
- res2 = origin_subst_one(res1, "$OSNAME", uts.sysname, true);
- res3 = origin_subst_one(res2, "$OSREL", uts.release, true);
- res4 = origin_subst_one(res3, "$PLATFORM", uts.machine, true);
+ res1 = origin_subst_one(obj, real, "$ORIGIN", NULL, false);
+ res2 = origin_subst_one(NULL, res1, "$OSNAME", uts.sysname, true);
+ res3 = origin_subst_one(NULL, res2, "$OSREL", uts.release, true);
+ res4 = origin_subst_one(NULL, res3, "$PLATFORM", uts.machine, true);
return (res4);
}
@@ -1124,7 +1130,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
#endif
case DT_FLAGS:
- if ((dynp->d_un.d_val & DF_ORIGIN) && trust)
+ if (dynp->d_un.d_val & DF_ORIGIN)
obj->z_origin = true;
if (dynp->d_un.d_val & DF_SYMBOLIC)
obj->symbolic = true;
@@ -1156,7 +1162,7 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
case DT_FLAGS_1:
if (dynp->d_un.d_val & DF_1_NOOPEN)
obj->z_noopen = true;
- if ((dynp->d_un.d_val & DF_1_ORIGIN) && trust)
+ if (dynp->d_un.d_val & DF_1_ORIGIN)
obj->z_origin = true;
if (dynp->d_un.d_val & DF_1_GLOBAL)
obj->z_global = true;
@@ -1207,30 +1213,33 @@ digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath,
}
}
+static bool
+obj_resolve_origin(Obj_Entry *obj)
+{
+
+ if (obj->origin_path != NULL)
+ return (true);
+ obj->origin_path = xmalloc(PATH_MAX);
+ return (rtld_dirname_abs(obj->path, obj->origin_path) != -1);
+}
+
static void
digest_dynamic2(Obj_Entry *obj, const Elf_Dyn *dyn_rpath,
const Elf_Dyn *dyn_soname, const Elf_Dyn *dyn_runpath)
{
- if (obj->z_origin && obj->origin_path == NULL) {
- obj->origin_path = xmalloc(PATH_MAX);
- if (rtld_dirname_abs(obj->path, obj->origin_path) == -1)
- rtld_die();
- }
-
- if (dyn_runpath != NULL) {
- obj->runpath = (char *)obj->strtab + dyn_runpath->d_un.d_val;
- if (obj->z_origin)
- obj->runpath = origin_subst(obj->runpath, obj->origin_path);
- }
- else if (dyn_rpath != NULL) {
- obj->rpath = (char *)obj->strtab + dyn_rpath->d_un.d_val;
- if (obj->z_origin)
- obj->rpath = origin_subst(obj->rpath, obj->origin_path);
- }
+ if (obj->z_origin && !obj_resolve_origin(obj))
+ rtld_die();
- if (dyn_soname != NULL)
- object_add_name(obj, obj->strtab + dyn_soname->d_un.d_val);
+ if (dyn_runpath != NULL) {
+ obj->runpath = (char *)obj->strtab + dyn_runpath->d_un.d_val;
+ obj->runpath = origin_subst(obj, obj->runpath);
+ } else if (dyn_rpath != NULL) {
+ obj->rpath = (char *)obj->strtab + dyn_rpath->d_un.d_val;
+ obj->rpath = origin_subst(obj, obj->rpath);
+ }
+ if (dyn_soname != NULL)
+ object_add_name(obj, obj->strtab + dyn_soname->d_un.d_val);
}
static void
@@ -1480,12 +1489,8 @@ find_library(const char *xname, const Obj_Entry *refobj, int *fdp)
xname);
return NULL;
}
- if (objgiven && refobj->z_origin) {
- return (origin_subst(__DECONST(char *, xname),
- refobj->origin_path));
- } else {
- return (xstrdup(xname));
- }
+ return (origin_subst(__DECONST(Obj_Entry *, refobj),
+ __DECONST(char *, xname)));
}
if (libmap_disable || !objgiven ||
diff --git a/release/Makefile.ec2 b/release/Makefile.ec2
index 869ebc1..a781bc6 100644
--- a/release/Makefile.ec2
+++ b/release/Makefile.ec2
@@ -12,13 +12,27 @@ AMINAMESUFFIX!= date +-%Y-%m-%d
PUBLISH= --public
.endif
-ec2ami: cw-ec2
+CLEANFILES+= ec2ami
+
.if !exists(/usr/local/bin/bsdec2-image-upload)
- @echo "--------------------------------------------------------------"
- @echo ">>> Creating EC2 AMIs requires bsdec2-image-upload"
- @echo "--------------------------------------------------------------"
- @false
+CW_EC2_PORTINSTALL= cw-ec2-portinstall
+CLEANFILES+= ${CW_EC2_PORTINSTALL}
+.else
+CW_EC2_PORTINSTALL=
.endif
+
+cw-ec2-portinstall:
+.if exists(${PORTSDIR}/net/bsdec2-image-upload/Makefile)
+ make -C ${PORTSDIR}/net/bsdec2-image-upload BATCH=1 all install clean
+.else
+. if !exists(/usr/local/sbin/pkg-static)
+ env ASSUME_ALWAYS_YES=yes pkg bootstrap -y
+. endif
+ env ASSUME_ALWAYS_YES=yes pkg install -y net/bsdec2-image-upload
+.endif
+ @touch ${.TARGET}
+
+ec2ami: cw-ec2 ${CW_EC2_PORTINSTALL}
.if !defined(AWSKEYFILE) || !exists(${AWSKEYFILE})
@echo "--------------------------------------------------------------"
@echo ">>> AWSKEYFILE must point at AWS keys for EC2 AMI creation"
@@ -39,6 +53,7 @@ ec2ami: cw-ec2
.endif
/usr/local/bin/bsdec2-image-upload ${PUBLISH} \
${.OBJDIR}/ec2.raw \
- "${TYPE} ${REVISION}-${BRANCH}${AMINAMESUFFIX}" \
- "${TYPE} ${REVISION}-${BRANCH}" \
+ "${TYPE} ${REVISION}-${BRANCH}-${TARGET}${AMINAMESUFFIX}" \
+ "${TYPE} ${REVISION}-${BRANCH}-${TARGET}" \
${AWSREGION} ${AWSBUCKET} ${AWSKEYFILE}
+ @touch ${.TARGET}
diff --git a/release/Makefile.mirrors b/release/Makefile.mirrors
new file mode 100644
index 0000000..f534c19
--- /dev/null
+++ b/release/Makefile.mirrors
@@ -0,0 +1,253 @@
+#
+# This Makefile helps create the directory structure on ftp-master,
+# making staging builds a bit more sane.
+#
+# You probably do not want to use this. Really.
+# You have been warned.
+#
+# Seriously.
+#
+# Don't use this unless you know why you're using it.
+#
+# $FreeBSD$
+#
+
+.include "${.CURDIR}/Makefile"
+
+RELEASEDIR?= /R
+FTPDIR?= ${RELEASEDIR}/ftp-stage
+STAGE_TARGETS?= iso-images-stage
+
+.if (defined(EMBEDDED_TARGET) && !empty(EMBEDDED_TARGET)) || (defined(EMBEDDEDBUILD) && !empty(EMBEDDEDBUILD))
+. if ${TARGET} == "arm" || ${EMBEDDED_TARGET} == "arm"
+EMBEDDED= 1
+. endif
+.endif
+
+# snapshot
+.if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT"
+SNAPSHOT= 1
+TLD?= ${FTPDIR}/snapshots
+. for _D in /usr/bin /usr/local/bin
+. for _S in svnversion svnliteversion
+. if exists(${_D}/${_S})
+SVNVERSION?= ${_D}/${_S}
+. endif
+. endfor
+. endfor
+. if exists(${.CURDIR}/${.OBJDIR}/dist/base/bin/sh)
+BUILDDATE!= cd ${.CURDIR} && date -j -f '%s' $$(stat -f "%c" ${.OBJDIR}/dist/base/bin/sh) +%Y%m%d
+. else
+BUILDDATE!= date +%Y%m%d
+. endif
+. if exists(${SVNVERSION}) && !empty(SVNVERSION)
+SVNREVISION!= ${SVNVERSION} ${WORLDDIR}/Makefile
+_SNAP_SUFFIX:= -r${SVNREVISION}-${BUILDDATE}
+. else
+_SNAP_SUFFIX:= -${BUILDDATE}
+. endif
+.else
+# release
+SNAPSHOT=
+TLD?= ${FTPDIR}/releases
+.endif
+
+.if defined(EMBEDDED) && !empty(EMBEDDED)
+. if ${TARGET} == "arm" && ${TARGET_ARCH} == "armv6"
+. if !defined(BOARDNAME) && empty(BOARDNAME)
+BOARDNAME:= ${KERNCONF}
+. else
+OLDNAME:= ${KERNCONF}
+. endif
+. if ${BRANCH} == "STABLE" || ${BRANCH} == "CURRENT"
+SNAPSHOT= 1
+. endif
+IMAGES:= img
+. endif # arm/armv6
+.endif # embedded
+
+.if defined(WITH_VMIMAGES) && !empty(WITH_VMIMAGES)
+STAGE_TARGETS+= vm-images-stage
+VM_DIR= ${TLD}/VM-IMAGES/${REVISION}-${BRANCH}/${TARGET_ARCH}
+.endif
+
+CLEANFILES+= ${STAGE_TARGETS}
+CHECKSUM_FILES?= SHA256 MD5
+SNAP_SUFFIX!= echo ${_SNAP_SUFFIX:S,^-,,1} | tr -d ' '
+ISO_DIR= ${TLD}/${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}
+FTP_DIR= ${TLD}/${TARGET}/${TARGET_ARCH}/${REVISION}-${BRANCH}
+
+remove-old-bits:
+ rm -rf ${FTPDIR}
+
+iso-images-stage:
+ mkdir -p ${ISO_DIR}
+ mkdir -p ${TLD}/ISO-IMAGES/${REVISION}
+.if exists(${RELEASEDIR})
+ @# Assume we have images to copy.
+. if defined(SNAPSHOT) && !empty(SNAPSHOT)
+ cd ${RELEASEDIR} && rm -f CHECKSUM.*
+. for IMAGE in ${IMAGES}
+. if defined(EMBEDDED) && !empty(EMBEDDED)
+. if defined(OLDNAME) && !empty(OLDNAME)
+ @# arm/armv6 IMX6 -> WANDBOARD, for example.
+ cd ${RELEASEDIR} && \
+ mv ${OSRELEASE}-${OLDNAME}.${IMAGE}.xz \
+ ${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz
+. endif
+ cd ${RELEASEDIR} && \
+ mv ${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz \
+ ${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz
+ cp -p ${RELEASEDIR}/${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz \
+ ${ISO_DIR}/${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz
+ cd ${TLD}/ISO-IMAGES/${REVISION} && \
+ ln -s \
+ ../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}.${IMAGE}.xz
+. endif # not embedded
+. if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE})
+ cd ${RELEASEDIR} && \
+ mv ${OSRELEASE}-${IMAGE} \
+ ${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE} || true
+ cp -p ${RELEASEDIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE} \
+ ${ISO_DIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}
+ cd ${TLD}/ISO-IMAGES/${REVISION} && \
+ ln -s \
+ ../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}
+. endif
+. if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE}.xz)
+ cd ${RELEASEDIR} && \
+ mv ${OSRELEASE}-${IMAGE}.xz \
+ ${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz || true
+ cp -p ${RELEASEDIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz \
+ ${ISO_DIR}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz
+ cd ${TLD}/ISO-IMAGES/${REVISION} && \
+ ln -s \
+ ../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${SNAP_SUFFIX}-${IMAGE}.xz
+. endif
+. endfor # images loop
+ cd ${RELEASEDIR} && rm -f CHECKSUM.*
+. for CHECKSUM in ${CHECKSUM_FILES}
+. if defined(EMBEDDED) && !empty(EMBEDDED)
+ cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
+ CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}
+ cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX} \
+ ${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}
+ cd ${TLD}/ISO-IMAGES/${REVISION} && \
+ ln -s \
+ ../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}-${SNAP_SUFFIX}
+. else # not embedded
+ cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
+ CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX}
+ cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX} \
+ ${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX}
+ cd ${TLD}/ISO-IMAGES/${REVISION} && \
+ ln -s \
+ ../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${SNAP_SUFFIX}
+. endif #
+. endfor # checksum files
+. else # not snapshot
+. for IMAGE in ${IMAGES}
+. if defined(EMBEDDED) && !empty(EMBEDDED)
+. if defined(OLDNAME) && !empty(OLDNAME)
+ @# arm/armv6 IMX6 -> WANDBOARD, for example.
+ cd ${RELEASEDIR} && \
+ mv ${OSRELEASE}-${OLDNAME}.${IMAGE}.xz \
+ ${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz
+. endif
+ cp -p ${RELEASEDIR}/${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz \
+ ${ISO_DIR}/${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz
+ cd ${TLD}/ISO-IMAGES/${REVISION} && \
+ ln -s \
+ ../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${BOARDNAME}.${IMAGE}.xz
+. endif # not embedded
+. if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE})
+ cd ${RELEASEDIR} && \
+ cp -p ${RELEASEDIR}/${OSRELEASE}-${IMAGE} \
+ ${ISO_DIR}/${OSRELEASE}-${IMAGE}
+ cd ${TLD}/ISO-IMAGES/${REVISION} && \
+ ln -s \
+ ../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${IMAGE}
+. endif
+. if exists(${RELEASEDIR}/${OSRELEASE}-${IMAGE}.xz)
+ cp -p ${RELEASEDIR}/${OSRELEASE}-${IMAGE}.xz \
+ ${ISO_DIR}/${OSRELEASE}-${IMAGE}.xz
+ cd ${TLD}/ISO-IMAGES/${REVISION} && \
+ ln -s \
+ ../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/${OSRELEASE}-${IMAGE}.xz
+. endif
+. endfor # images loop
+ cd ${RELEASEDIR} && rm -f CHECKSUM.*
+. for CHECKSUM in ${CHECKSUM_FILES}
+. if defined(EMBEDDED) && !empty(EMBEDDED)
+ cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
+ CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}
+ cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME} \
+ ${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}
+ cd ${TLD}/ISO-IMAGES/${REVISION} && \
+ ln -s \
+ ../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}-${BOARDNAME}
+. else # not embedded
+ cd ${RELEASEDIR} && ${CHECKSUM:tl} ${OSRELEASE}* > \
+ CHECKSUM.${CHECKSUM}-${OSRELEASE}
+ cp -p ${RELEASEDIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE} \
+ ${ISO_DIR}/CHECKSUM.${CHECKSUM}-${OSRELEASE}
+ cd ${TLD}/ISO-IMAGES/${REVISION} && \
+ ln -s \
+ ../../${TARGET}/${TARGET_ARCH}/ISO-IMAGES/${REVISION}/CHECKSUM.${CHECKSUM}-${OSRELEASE}
+. endif
+. endfor # checksum files
+. endif # release
+. if exists(${RELEASEDIR}/ftp)
+ mkdir -p ${FTP_DIR}
+ cp -p ${RELEASEDIR}/ftp/*.txz ${RELEASEDIR}/ftp/MANIFEST ${FTP_DIR}
+ cd ${TLD}/${TARGET} && \
+ ln -s ${TARGET_ARCH}/${REVISION}-${BRANCH} \
+ ${REVISION}-${BRANCH}
+. endif
+.endif # no RELEASEDIR
+
+vm-images-stage:
+ mkdir -p ${VM_DIR}
+.if defined(SNAPSHOT) && !empty(SNAPSHOT)
+. if exists(${VM_DIR}/Latest)
+ rm -rf ${VM_DIR}/Latest
+. endif
+ mkdir -p ${VM_DIR}/Latest
+ mkdir -p ${VM_DIR}/${BUILDDATE}
+. for VMFORMAT in ${VMFORMATS}
+ cd ${RELEASEDIR}/vmimages && \
+ mv ${OSRELEASE}.${VMFORMAT}.xz \
+ ${OSRELEASE}-${SNAP_SUFFIX}.${VMFORMAT}.xz
+ cp -p ${RELEASEDIR}/vmimages/${OSRELEASE}-${SNAP_SUFFIX}.${VMFORMAT}.xz \
+ ${VM_DIR}/${BUILDDATE}/${OSRELEASE}-${SNAP_SUFFIX}.${VMFORMAT}.xz
+ cd ${VM_DIR}/Latest && \
+ ln -s ../${BUILDDATE}/${OSRELEASE}-${SNAP_SUFFIX}.${VMFORMAT}.xz \
+ ${OSRELEASE}.${VMFORMAT}.xz
+. endfor
+ cd ${RELEASEDIR}/vmimages && rm -f CHECKSUM.*
+. for CHECKSUM in ${CHECKSUM_FILES}
+ cd ${RELEASEDIR}/vmimages && \
+ ${CHECKSUM:tl} ${OSRELEASE}* > CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX}
+ cp -p ${RELEASEDIR}/vmimages/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX} \
+ ${VM_DIR}/${BUILDDATE}/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX}
+ cd ${VM_DIR}/Latest && \
+ ln -s ../${BUILDDATE}/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX} \
+ CHECKSUM.${CHECKSUM}
+. endfor
+.else # not snapshot
+. if exists(${VM_DIR}/Latest)
+ rm -rf ${VM_DIR}/Latest
+. endif
+ mkdir -p ${VM_DIR}/Latest
+. for VMFORMAT in ${VMFORMATS}
+ cp -p ${RELEASEDIR}/vmimages/${OSRELEASE}.${VMFORMAT}.xz \
+ ${VM_DIR}/Latest/${OSRELEASE}.${VMFORMAT}.xz
+. endfor
+. for CHECKSUM in ${CHECKSUM_FILES}
+ cp -p ${RELEASEDIR}/vmimages/CHECKSUM.${CHECKSUM} \
+ ${VM_DIR}/Latest/CHECKSUM.${CHECKSUM}
+. endfor
+.endif
+
+ftp-stage: remove-old-bits ${STAGE_TARGETS}
+
diff --git a/release/arm/BEAGLEBONE.conf b/release/arm/BEAGLEBONE.conf
index 546af5c..3ae4871 100644
--- a/release/arm/BEAGLEBONE.conf
+++ b/release/arm/BEAGLEBONE.conf
@@ -3,35 +3,35 @@
# $FreeBSD$
#
-# Global variables.
-export SVNROOT="svn://svn.FreeBSD.org/"
-export SRCBRANCH="base/head@rHEAD"
-export DOCBRANCH="doc/head@rHEAD"
-export PORTBRANCH="ports/head@rHEAD"
-export NODOC=yes
-export WORLD_FLAGS="-j $(sysctl -n hw.ncpu)"
-export KERNEL_FLAGS="-j $(( $(( $(sysctl -n hw.ncpu) + 1 )) / 2 ))"
-export CHROOTDIR="/scratch"
-export EMBEDDEDBUILD=1
+EMBEDDEDBUILD=1
+EMBEDDED_TARGET="arm"
+EMBEDDED_TARGET_ARCH="armv6"
+EMBEDDEDPORTS="sysutils/u-boot-beaglebone"
+KERNEL="BEAGLEBONE"
+WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x88000000"
+IMAGE_SIZE="1G"
+PART_SCHEME="MBR"
+FAT_SIZE="2m"
+FAT_TYPE="12"
+MD_ARGS="-x 63 -y 255"
+NODOC=1
-# Build chroot configuration
-load_chroot_env() {
- # Avoid collision with TARGET and XDEV.
- unset XDEV XDEV_ARCH KERNEL
- export TARGET="amd64"
- export TARGET_ARCH="amd64"
-}
-
-# Build target configuration
-load_target_env() {
- # Avoid collision with TARGET and XDEV.
- unset TARGET TARGET_ARCH
- export EMBEDDEDPORTS="lang/python textproc/gsed"
- export XDEV="arm"
- export XDEV_ARCH="armv6"
- export XDEV_FLAGS="WITH_GCC=1 WITH_GCC_BOOTSTRAP=1 WITHOUT_CLANG_IS_CC=1"
- export XDEV_FLAGS="${XDEV_FLAGS} MK_TESTS=no"
- export KERNEL="BEAGLEBONE"
- export CROCHETSRC="https://github.com/freebsd/crochet"
- export CROCHETBRANCH="trunk@r744"
+arm_install_uboot() {
+ UBOOT_DIR="/usr/local/share/u-boot/u-boot-beaglebone"
+ FATMOUNT="${DESTDIR%${KERNEL}}/fat"
+ UFSMOUNT="${DESTDIR%${KERNEL}}/ufs"
+ chroot ${CHROOTDIR} mkdir -p "${FATMOUNT}" "${UFSMOUNT}"
+ chroot ${CHROOTDIR} mount_msdosfs /dev/${mddev}s1 ${FATMOUNT}
+ chroot ${CHROOTDIR} mount /dev/${mddev}s2a ${UFSMOUNT}
+ chroot ${CHROOTDIR} cp -p ${UBOOT_DIR}/MLO ${FATMOUNT}/MLO
+ chroot ${CHROOTDIR} cp -p ${UBOOT_DIR}/u-boot.img ${FATMOUNT}/u-boot.img
+ chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/ubldr ${FATMOUNT}/ubldr
+ chroot ${CHROOTDIR} touch ${UFSMOUNT}/firstboot
+ sync
+ umount_loop ${CHROOTDIR}/${FATMOUNT}
+ umount_loop ${CHROOTDIR}/${UFSMOUNT}
+ chroot ${CHROOTDIR} rmdir ${FATMOUNT}
+ chroot ${CHROOTDIR} rmdir ${UFSMOUNT}
+
+ return 0
}
diff --git a/release/arm/PANDABOARD.conf b/release/arm/PANDABOARD.conf
index 9518914..b5a120e 100644
--- a/release/arm/PANDABOARD.conf
+++ b/release/arm/PANDABOARD.conf
@@ -3,35 +3,35 @@
# $FreeBSD$
#
-# Global variables.
-export SVNROOT="svn://svn.FreeBSD.org/"
-export SRCBRANCH="base/head@rHEAD"
-export DOCBRANCH="doc/head@rHEAD"
-export PORTBRANCH="ports/head@rHEAD"
-export NODOC=yes
-export WORLD_FLAGS="-j $(sysctl -n hw.ncpu)"
-export KERNEL_FLAGS="-j $(( $(( $(sysctl -n hw.ncpu) + 1 )) / 2 ))"
-export CHROOTDIR="/scratch"
-export EMBEDDEDBUILD=1
-export EMBEDDEDPORTS="lang/python textproc/gsed"
+EMBEDDEDBUILD=1
+EMBEDDED_TARGET="arm"
+EMBEDDED_TARGET_ARCH="armv6"
+EMBEDDEDPORTS="sysutils/u-boot-pandaboard"
+KERNEL="PANDABOARD"
+NODOC=1
+WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x88000000"
+IMAGE_SIZE="1G"
+PART_SCHEME="MBR"
+FAT_SIZE="2m"
+FAT_TYPE="12"
+MD_ARGS="-x 63 -y 255"
-# Build chroot configuration
-load_chroot_env() {
- # Avoid collision with TARGET and XDEV.
- unset XDEV XDEV_ARCH KERNEL
- export TARGET="amd64"
- export TARGET_ARCH="amd64"
-}
-
-# Build target configuration
-load_target_env() {
- # Avoid collision with TARGET and XDEV.
- unset TARGET TARGET_ARCH
- export XDEV="arm"
- export XDEV_ARCH="armv6"
- export XDEV_FLAGS="WITH_GCC=1 WITH_GCC_BOOTSTRAP=1 WITHOUT_CLANG_IS_CC=1"
- export XDEV_FLAGS="${XDEV_FLAGS} MK_TESTS=no"
- export KERNEL="PANDABOARD"
- export CROCHETSRC="https://github.com/freebsd/crochet"
- export CROCHETBRANCH="trunk@r744"
+arm_install_uboot() {
+ UBOOT_DIR="/usr/local/share/u-boot/u-boot-pandaboard"
+ FATMOUNT="${DESTDIR%${KERNEL}}/fat"
+ UFSMOUNT="${DESTDIR%${KERNEL}}/ufs"
+ chroot ${CHROOTDIR} mkdir -p "${FATMOUNT}" "${UFSMOUNT}"
+ chroot ${CHROOTDIR} mount_msdosfs /dev/${mddev}s1 ${FATMOUNT}
+ chroot ${CHROOTDIR} mount /dev/${mddev}s2a ${UFSMOUNT}
+ chroot ${CHROOTDIR} cp -p ${UBOOT_DIR}/MLO ${FATMOUNT}/MLO
+ chroot ${CHROOTDIR} cp -p ${UBOOT_DIR}/u-boot.img ${FATMOUNT}/u-boot.img
+ chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/ubldr ${FATMOUNT}/ubldr
+ chroot ${CHROOTDIR} touch ${UFSMOUNT}/firstboot
+ sync
+ umount_loop ${CHROOTDIR}/${FATMOUNT}
+ umount_loop ${CHROOTDIR}/${UFSMOUNT}
+ chroot ${CHROOTDIR} rmdir ${FATMOUNT}
+ chroot ${CHROOTDIR} rmdir ${UFSMOUNT}
+
+ return 0
}
diff --git a/release/arm/RPI-B.conf b/release/arm/RPI-B.conf
index 19778f8..e5abaab 100644
--- a/release/arm/RPI-B.conf
+++ b/release/arm/RPI-B.conf
@@ -3,38 +3,41 @@
# $FreeBSD$
#
-# Global variables.
-export SVNROOT="svn://svn.FreeBSD.org/"
-export SRCBRANCH="base/head@rHEAD"
-export DOCBRANCH="doc/head@rHEAD"
-export PORTBRANCH="ports/head@rHEAD"
-export NODOC=yes
-export WORLD_FLAGS="-j $(sysctl -n hw.ncpu)"
-export KERNEL_FLAGS="-j $(( $(( $(sysctl -n hw.ncpu) + 1 )) / 2 ))"
-export CHROOTDIR="/scratch"
-export EMBEDDEDBUILD=1
-export EMBEDDEDPORTS="lang/python textproc/gsed"
+EMBEDDEDBUILD=1
+EMBEDDED_TARGET="arm"
+EMBEDDED_TARGET_ARCH="armv6"
+EMBEDDEDPORTS="sysutils/u-boot-rpi"
+KERNEL="RPI-B"
+WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x2000000"
+IMAGE_SIZE="1G"
+PART_SCHEME="MBR"
+FAT_SIZE="17m"
+FAT_TYPE="16"
+MD_ARGS="-x 63 -y 255"
+NODOC=1
-# Build chroot configuration
-load_chroot_env() {
- # Avoid collision with TARGET and XDEV.
- unset XDEV XDEV_ARCH KERNEL
- export TARGET="amd64"
- export TARGET_ARCH="amd64"
-}
-
-# Build target configuration
-load_target_env() {
- # Avoid collision with TARGET and XDEV.
- unset TARGET TARGET_ARCH
- export XDEV="arm"
- export XDEV_ARCH="armv6"
- export XDEV_FLAGS="WITH_GCC=1 WITH_GCC_BOOTSTRAP=1 WITHOUT_CLANG_IS_CC=1"
- export XDEV_FLAGS="${XDEV_FLAGS} MK_TESTS=no"
- export KERNEL="RPI-B"
- export CROCHETSRC="https://github.com/freebsd/crochet"
- export CROCHETBRANCH="trunk@r744"
- export UBOOTSRC="https://github.com/gonzoua/u-boot-pi"
- export UBOOTBRANCH="trunk"
- export UBOOTDIR="/tmp/crochet/u-boot-rpi"
+arm_install_uboot() {
+ UBOOT_DIR="/usr/local/share/u-boot/u-boot-rpi"
+ UBOOT_FILES="bootcode.bin config.txt fixup.dat fixup_cd.dat \
+ start.elf start_cd.elf u-boot.img"
+ FATMOUNT="${DESTDIR%${KERNEL}}/fat"
+ UFSMOUNT="${DESTDIR%${KERNEL}}/ufs"
+ chroot ${CHROOTDIR} mkdir -p "${FATMOUNT}" "${UFSMOUNT}"
+ chroot ${CHROOTDIR} mount_msdosfs /dev/${mddev}s1 ${FATMOUNT}
+ chroot ${CHROOTDIR} mount /dev/${mddev}s2a ${UFSMOUNT}
+ for _UF in ${UBOOT_FILES}; do
+ chroot ${CHROOTDIR} cp -p ${UBOOT_DIR}/${_UF} \
+ ${FATMOUNT}/${_UF}
+ done
+ chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/ubldr ${FATMOUNT}/ubldr
+ chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/dtb/rpi.dtb \
+ ${FATMOUNT}/rpi.dtb
+ chroot ${CHROOTDIR} touch ${UFSMOUNT}/firstboot
+ sync
+ umount_loop ${CHROOTDIR}/${FATMOUNT}
+ umount_loop ${CHROOTDIR}/${UFSMOUNT}
+ chroot ${CHROOTDIR} rmdir ${FATMOUNT}
+ chroot ${CHROOTDIR} rmdir ${UFSMOUNT}
+
+ return 0
}
diff --git a/release/arm/RPI2.conf b/release/arm/RPI2.conf
new file mode 100644
index 0000000..e1d15d1
--- /dev/null
+++ b/release/arm/RPI2.conf
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+EMBEDDEDBUILD=1
+EMBEDDED_TARGET="arm"
+EMBEDDED_TARGET_ARCH="armv6"
+EMBEDDEDPORTS="sysutils/u-boot-rpi2"
+KERNEL="RPI2"
+NODOC=1
+WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x2000000"
+IMAGE_SIZE="1G"
+PART_SCHEME="MBR"
+FAT_SIZE="50m"
+FAT_TYPE="16"
+MD_ARGS="-x 63 -y 255"
+
+arm_install_uboot() {
+ UBOOT_DIR="/usr/local/share/u-boot/u-boot-rpi2"
+ UBOOT_FILES="bootcode.bin config.txt fixup.dat fixup_cd.dat \
+ fixup_x.dat start.elf start_cd.elf start_x.elf u-boot.bin"
+ FATMOUNT="${DESTDIR%${KERNEL}}/fat"
+ UFSMOUNT="${DESTDIR%${KERNEL}}/ufs"
+ chroot ${CHROOTDIR} mkdir -p "${FATMOUNT}" "${UFSMOUNT}"
+ chroot ${CHROOTDIR} mount_msdosfs /dev/${mddev}s1 ${FATMOUNT}
+ chroot ${CHROOTDIR} mount /dev/${mddev}s2a ${UFSMOUNT}
+ for _UF in ${UBOOT_FILES}; do
+ chroot ${CHROOTDIR} cp -p ${UBOOT_DIR}/${_UF} \
+ ${FATMOUNT}/${_UF}
+ done
+ chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/ubldr ${FATMOUNT}/ubldr
+ chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/dtb/rpi2.dtb \
+ ${FATMOUNT}/rpi2.dtb
+ chroot ${CHROOTDIR} touch ${UFSMOUNT}/firstboot
+ sync
+ umount_loop ${CHROOTDIR}/${FATMOUNT}
+ umount_loop ${CHROOTDIR}/${UFSMOUNT}
+ chroot ${CHROOTDIR} rmdir ${FATMOUNT}
+ chroot ${CHROOTDIR} rmdir ${UFSMOUNT}
+
+ return 0
+}
diff --git a/release/arm/WANDBOARD-QUAD.conf b/release/arm/WANDBOARD-QUAD.conf
deleted file mode 100644
index 48aa631..0000000
--- a/release/arm/WANDBOARD-QUAD.conf
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-# Global variables.
-export SVNROOT="svn://svn.FreeBSD.org/"
-export SRCBRANCH="base/head@rHEAD"
-export DOCBRANCH="doc/head@rHEAD"
-export PORTBRANCH="ports/head@rHEAD"
-export NODOC=yes
-export WORLD_FLAGS="-j $(sysctl -n hw.ncpu)"
-export KERNEL_FLAGS="-j $(( $(( $(sysctl -n hw.ncpu) + 1 )) / 2 ))"
-export CHROOTDIR="/scratch"
-export EMBEDDEDBUILD=1
-export EMBEDDEDPORTS="lang/python textproc/gsed"
-
-# Build chroot configuration
-load_chroot_env() {
- # Avoid collision with TARGET and XDEV.
- unset XDEV XDEV_ARCH KERNEL
- export TARGET="amd64"
- export TARGET_ARCH="amd64"
-}
-
-# Build target configuration
-load_target_env() {
- # Avoid collision with TARGET and XDEV.
- unset TARGET TARGET_ARCH
- export XDEV="arm"
- export XDEV_ARCH="armv6"
- export XDEV_FLAGS="WITH_GCC=1 WITH_GCC_BOOTSTRAP=1 WITHOUT_CLANG_IS_CC=1"
- export XDEV_FLAGS="${XDEV_FLAGS} MK_TESTS=no"
- export KERNEL="WANDBOARD-QUAD"
- export CROCHETSRC="https://github.com/freebsd/crochet"
- export CROCHETBRANCH="trunk@r744"
-}
diff --git a/release/arm/WANDBOARD.conf b/release/arm/WANDBOARD.conf
new file mode 100644
index 0000000..42b4523
--- /dev/null
+++ b/release/arm/WANDBOARD.conf
@@ -0,0 +1,41 @@
+#!/bin/sh
+#
+# $FreeBSD$
+#
+
+EMBEDDEDBUILD=1
+EMBEDDED_TARGET="arm"
+EMBEDDED_TARGET_ARCH="armv6"
+EMBEDDEDPORTS="sysutils/u-boot-wandboard"
+KERNEL="IMX6"
+WORLD_FLAGS="${WORLD_FLAGS} UBLDR_LOADADDR=0x11000000"
+IMAGE_SIZE="1G"
+PART_SCHEME="MBR"
+FAT_SIZE="50m -b 16384"
+FAT_TYPE="16"
+MD_ARGS="-x 63 -y 255"
+NODOC=1
+
+arm_install_uboot() {
+ UBOOT_DIR="/usr/local/share/u-boot/u-boot-wandboard"
+ UBOOT_FILES="u-boot.imx"
+ FATMOUNT="${DESTDIR%${KERNEL}}/fat"
+ UFSMOUNT="${DESTDIR%${KERNEL}}/ufs"
+ chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/${UBOOT_FILES} \
+ of=/dev/${mddev} bs=512 seek=2
+ chroot ${CHROOTDIR} mkdir -p "${FATMOUNT}" "${UFSMOUNT}"
+ chroot ${CHROOTDIR} mount_msdosfs /dev/${mddev}s1 ${FATMOUNT}
+ chroot ${CHROOTDIR} mount /dev/${mddev}s2a ${UFSMOUNT}
+ chroot ${CHROOTDIR} cp -p ${UFSMOUNT}/boot/ubldr ${FATMOUNT}/ubldr
+ chroot ${CHROOTDIR} /bin/sh -c 'echo \
+ setenv fdt_file wandboard-quad.dtb\; fatload mmc 0:1 11000000 ubldr\; bootelf 11000000\; \
+ > ${FATMOUNT}/boot.txt'
+ chroot ${CHROOTDIR} touch ${UFSMOUNT}/firstboot
+ sync
+ umount_loop ${CHROOTDIR}/${FATMOUNT}
+ umount_loop ${CHROOTDIR}/${UFSMOUNT}
+ chroot ${CHROOTDIR} rmdir ${FATMOUNT}
+ chroot ${CHROOTDIR} rmdir ${UFSMOUNT}
+
+ return 0
+}
diff --git a/release/arm/ZEDBOARD.conf b/release/arm/ZEDBOARD.conf
deleted file mode 100644
index 07c35ba..0000000
--- a/release/arm/ZEDBOARD.conf
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-#
-# $FreeBSD$
-#
-
-# Global variables.
-export SVNROOT="svn://svn.FreeBSD.org/"
-export SRCBRANCH="base/head@rHEAD"
-export DOCBRANCH="doc/head@rHEAD"
-export PORTBRANCH="ports/head@rHEAD"
-export NODOC=yes
-export WORLD_FLAGS="-j $(sysctl -n hw.ncpu)"
-export export KERNEL_FLAGS="-j $(( $(( $(sysctl -n hw.ncpu) + 1 )) / 2 ))"
-export CHROOTDIR="/scratch"
-export EMBEDDEDBUILD=1
-
-# Build chroot configuration
-load_chroot_env() {
- # Avoid collision with TARGET and XDEV.
- unset XDEV XDEV_ARCH KERNEL
- export TARGET="amd64"
- export TARGET_ARCH="amd64"
-}
-
-# Build target configuration
-load_target_env() {
- # Avoid collision with TARGET and XDEV.
- unset TARGET TARGET_ARCH
- export XDEV="arm"
- export XDEV_ARCH="armv6"
- export XDEV_FLAGS="WITH_GCC=1 WITH_GCC_BOOTSTRAP=1 WITHOUT_CLANG_IS_CC=1"
- export XDEV_FLAGS="${XDEV_FLAGS} MK_TESTS=no"
- export KERNEL="ZEDBOARD"
- export CROCHETSRC="https://github.com/freebsd/crochet"
- export CROCHETBRANCH="trunk@r744"
-}
diff --git a/release/arm/release.sh b/release/arm/release.sh
deleted file mode 100755
index 104edd8..0000000
--- a/release/arm/release.sh
+++ /dev/null
@@ -1,156 +0,0 @@
-#!/bin/sh
-#-
-# Copyright (c) 2013, 2014 The FreeBSD Foundation
-# All rights reserved.
-#
-# This software was developed by Glen Barber
-# under sponsorship from the FreeBSD Foundation.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this 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 script is intended to be called by release/release.sh to build ARM
-# images for release. It is not intended to be run directly. This sets up
-# the software needed within a build chroot, then runs crochet to provide
-# downloadable images for embedded devices.
-
-set -e
-
-before_build() {
- WANT_UBOOT=
- KNOWNHASH=
- UBOOT_VERSION=
- case ${KERNEL} in
- BEAGLEBONE)
- WANT_UBOOT=1
- KNOWNHASH="7b6444bd23eb61068c43bd1d44ec7e7bfdbce5cadeca20c833eee186b4d3fd31"
- UBOOT_VERSION="u-boot-2014.04"
- ;;
- PANDABOARD)
- WANT_UBOOT=1
- KNOWNHASH="e08e20a6979bfca6eebb9a2b0e42aa4416af3d796332fd63a3470495a089d496"
- UBOOT_VERSION="u-boot-2012.07"
- ;;
- WANDBOARD-QUAD)
- WANT_UBOOT=1
- KNOWNHASH="b4f83b8db325c21671a997198ec3a373e2e00dde2fcf17be9b9afd7cfd727f56"
- UBOOT_VERSION="u-boot-2014.07"
- ;;
- *)
- # Fallthrough.
- ;;
- esac
- if [ ! -z ${WANT_UBOOT} ]; then
- chroot ${CHROOTDIR} fetch -o /tmp/crochet/${UBOOT_VERSION}.tar.bz2 \
- http://people.freebsd.org/~gjb/${UBOOT_VERSION}.tar.bz2
- UBOOT_HASH="$(sha256 -q ${CHROOTDIR}/tmp/crochet/${UBOOT_VERSION}.tar.bz2)"
- if [ "${UBOOT_HASH}" != "${KNOWNHASH}" ]; then
- echo "Checksum mismatch! Exiting now."
- exit 1
- fi
- chroot ${CHROOTDIR} tar xf /tmp/crochet/${UBOOT_VERSION}.tar.bz2 \
- -C /tmp/crochet/
- fi
-}
-
-install_crochet() {
- chroot ${CHROOTDIR} svn co -q ${CROCHETSRC}/${CROCHETBRANCH} \
- /tmp/crochet
-}
-
-install_uboot() {
- # Only fetch u-boot sources if UBOOTSRC is set; otherwise it is
- # not needed.
- if [ -n "${UBOOTSRC}" ]; then
- continue
- else
- return 0
- fi
- chroot ${CHROOTDIR} svn co -q ${UBOOTSRC}/${UBOOTBRANCH} \
- /${UBOOTDIR}
-}
-
-main() {
- # Fix broken ports that use kern.osreldate.
- OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U)
- export OSVERSION
- REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release -V REVISION)
- BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release -V BRANCH)
- UNAME_r=${REVISION}-${BRANCH}
- export UNAME_r
- export XZ_CMD=$(chroot ${CHROOTDIR} make -C /usr/src/release -V XZ_CMD)
-
- # Build the 'xdev' target for crochet.
- eval chroot ${CHROOTDIR} make -C /usr/src \
- ${XDEV_FLAGS} XDEV=${XDEV} XDEV_ARCH=${XDEV_ARCH} \
- TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH} \
- ${WORLD_FLAGS} xdev
-
- # Install the cross-build symlinks to /usr/bin to make crochet
- # happy.
- eval chroot ${CHROOTDIR} make -C /usr/src \
- ${XDEV_FLAGS} XDEV=${XDEV} XDEV_ARCH=${XDEV_ARCH} \
- TARGET=${XDEV} TARGET_ARCH=${XDEV_ARCH} \
- ${WORLD_FLAGS} xdev-links || true
-
- # Run the ldconfig(8) startup script so /var/run/ld-elf*.so.hints
- # is created.
- eval chroot ${CHROOTDIR} /etc/rc.d/ldconfig forcerestart
- # Install security/ca_root_nss since we need to check the https
- # certificate of github.
- eval chroot ${CHROOTDIR} make -C /usr/ports/security/ca_root_nss \
- OPTIONS_SET="ETCSYMLINK" BATCH=1 FORCE_PKG_REGISTER=1 \
- install clean distclean
- EMBEDDEDPORTS="${EMBEDDEDPORTS} devel/subversion"
- for _PORT in ${EMBEDDEDPORTS}; do
- eval chroot ${CHROOTDIR} make -C /usr/ports/${_PORT} \
- BATCH=1 FORCE_PKG_REGISTER=1 install clean distclean
- done
-
- # Certain u-boot versions hardcode the use of a host gcc, and gcc's
- # build relies on having gperf installed.
- eval chroot ${CHROOTDIR} make -C /usr/src/gnu/usr.bin/gperf \
- WITH_GCC=1 ${WORLD_FLAGS} obj
- eval chroot ${CHROOTDIR} make -C /usr/src/gnu/usr.bin/gperf \
- WITH_GCC=1 ${WORLD_FLAGS} -j1 depend all
- eval chroot ${CHROOTDIR} make -C /usr/src/gnu/usr.bin/gperf \
- WITH_GCC=1 ${WORLD_FLAGS} -j1 install
- eval chroot ${CHROOTDIR} make -C /usr/src/gnu/usr.bin/cc \
- WITH_GCC=1 ${WORLD_FLAGS} -j1 obj depend all install
-
- mkdir -p ${CHROOTDIR}/tmp/crochet/work
- before_build
- install_crochet
- install_uboot
- eval chroot ${CHROOTDIR} /bin/sh /tmp/crochet/crochet.sh \
- -c /tmp/external/${XDEV}/crochet-${KERNEL}.conf
- mkdir -p ${CHROOTDIR}/R/
- cp -p ${CHROOTDIR}/usr/obj/*.img ${CHROOTDIR}/R/
- ${XZ_CMD} ${CHROOTDIR}/R/FreeBSD*.img
- cd ${CHROOTDIR}/R/ && sha256 FreeBSD*.img.xz > CHECKSUM.SHA256
- cd ${CHROOTDIR}/R/ && md5 FreeBSD*.img.xz > CHECKSUM.MD5
-}
-
-main "$@"
-exit 0
diff --git a/release/arm64/make-memstick.sh b/release/arm64/make-memstick.sh
index 943dfbe..27ebf27 100755
--- a/release/arm64/make-memstick.sh
+++ b/release/arm64/make-memstick.sh
@@ -36,6 +36,6 @@ if [ $? -ne 0 ]; then
fi
rm ${1}/etc/fstab
-mkimg -s gpt -p efi:=${1}/boot/boot1.efifat -p freebsd-ufs:=${2}.part -p freebsd-swap::1M -o ${2}
+mkimg -s mbr -p efi:=${1}/boot/boot1.efifat -p freebsd:=${2}.part -o ${2}
rm ${2}.part
diff --git a/release/doc/en_US.ISO8859-1/relnotes/article.xml b/release/doc/en_US.ISO8859-1/relnotes/article.xml
index d3f82d7..b6ea140 100644
--- a/release/doc/en_US.ISO8859-1/relnotes/article.xml
+++ b/release/doc/en_US.ISO8859-1/relnotes/article.xml
@@ -22,7 +22,7 @@
<pubdate>$FreeBSD$</pubdate>
- <!-- Last rev: 278934 -->
+ <!-- Last rev: 282482 -->
<copyright>
<year>2015</year>
@@ -316,7 +316,35 @@
<para revision="279571" contrib="sponsor"
sponsor="&scaleengine;">The &man.freebsd-update.8; utility has
been updated to prevent fetching updated binary patches when
- a previous upgrade has not been throughly completed.</para>
+ a previous upgrade has not been thoroughly completed.</para>
+
+ <para revision="279122" contrib="sponsor"
+ sponsor="&juniper;">The &man.netstat.1; utility has been
+ updated to link against the &man.libxo.3; shared
+ library.</para>
+
+ <para revision="280870">A regression in the &man.libarchive.3;
+ library that would prevent a directory from being included in
+ the archive when <literal>--one-file-system</literal> is used
+ has been fixed.</para>
+
+ <para revision="281311" contrib="sponsor" sponsor="&ff;">The
+ &man.ar.1; utility has been updated to set
+ <literal>ARCHIVE_EXTRACT_SECURE_SYMLINKS</literal> and
+ <literal>ARCHIVE_EXTRACT_SECURE_NODOTDOT</literal> to disallow
+ directory traversal when extracting an archive, similar to
+ &man.tar.1;.</para>
+
+ <para revision="282208" contrib="sponsor"
+ sponsor="&multiplay;">The &man.chflags.1;, &man.chgrp.1;,
+ &man.chmod.1;, and &man.chown.8; utilities now affect symbolic
+ links when the <literal>-R</literal> flag is specified, as
+ documented in &man.symlink.7;.</para>
+
+ <para revision="281617">A race condition in &man.wc.1; that
+ would cause final results to be sent to &man.stderr.4; when
+ receiving the <literal>SIGINFO</literal> signal has been
+ fixed.</para>
</sect2>
<sect2 xml:id="userland-contrib">
@@ -335,9 +363,6 @@
<para revision="261071">&man.jemalloc.3; has been updated to
version 3.5.0.</para>
- <para revision="261212"><application>bmake</application> has
- been updated to version 20140101.</para>
-
<para revision="261283"><application>libc++</application> has
been updated to version 3.4.</para>
@@ -379,6 +404,7 @@
<application>addr2line</application>,
<application>elfcopy (strip)</application>,
<application>nm</application>,
+ <application>readelf</application>,
<application>size</application>, and
<application>strings</application> were switched to the
versions from the ELF Tool Chain project.</para>
@@ -388,17 +414,38 @@
adding <acronym>UTF-8</acronym> support to the &man.sh.1;
shell.</para>
- <para revision="277270"><application>OpenSSL</application> has
- been updated to version 1.0.1l.</para>
-
- <para revision="278433">The &man.xz.1; utility has been udpated
- to version 5.2.0.</para>
-
<para revision="278433">The &man.xz.1; utility has been updated
to support multi-threaded compression.</para>
- <para revision="278970">The &man.acpi.4; subsystem has been
- updated to version 20150204.</para>
+ <para revision="280297"><application>OpenSSL</application> has
+ been updated to version 1.0.1m.</para>
+
+ <para revision="280932" contrib="sponsor" sponsor="&ff;">The
+ <application>elftoolchain</application> utilities have been
+ updated to version 3179.</para>
+
+ <para revision="281316">The &man.xz.1; utility has been updated
+ to version 5.2.1.</para>
+
+ <para revision="281373">The &man.nvi.1; utility has been updated
+ to version 2.1.3.</para>
+
+ <para revision="281396">The &man.acpi.4; subsystem has been
+ updated to version 20150410.</para>
+
+ <para revision="281806">The &man.wpa.supplicant.8; and
+ &man.hostapd.8; utilities have been updated to version
+ 2.4.</para>
+
+ <para revision="281812"><application>bmake</application> has
+ been updated to version 20150418.</para>
+
+ <para revision="282089">The &man.unbound.8; utility has been
+ updated to version 1.5.3.</para>
+
+ <para revision="282434" contrib="sponsor" sponsor="&ff;">The
+ &man.resolvconf.8; utility has been updated to version
+ 3.7.0.</para>
</sect2>
<sect2 xml:id="userland-installer">
@@ -481,6 +528,10 @@
<acronym>ELF</acronym> object in the
<literal>dlpi_name</literal> structure member.</para>
+ <para revision="273562" contrib="sponsor"
+ sponsor="&juniper;">The &man.libxo.3; library has been
+ imported to the base system.</para>
+
<para revision="273806" contrib="sponsor" sponsor="&chelsio;">A
userland library for Chelsio Terminator 5 based iWARP cards
has been added, allowing userland <acronym>RDMA</acronym>
@@ -509,6 +560,15 @@
updated to be able to handle 32-bit aligned data on 64-bit
platforms, also providing a significant improvement in 32-bit
workloads.</para>
+
+ <para revision="281130">Several standard include headers have
+ been updated to use of <application>gcc</application>
+ attributes, such as <literal>__result_use_check()</literal>,
+ <literal>__alloc_size()</literal>, and
+ <literal>__nonnull()</literal>.</para>
+
+ <para revision="281845">Support for file verification in
+ <acronym>MAC</acronym> has been added.</para>
</sect2>
<sect2 xml:id="userland-abi">
@@ -547,6 +607,30 @@
<para revision="272089">A bug in &man.ipfw.4; that could
potentially lead to a kernel panic when using &man.dummynet.4;
at layer 2 has been fixed.</para>
+
+ <para revision="280930" contrib="sponsor" sponsor="&mitail;">The
+ kernel <acronym>RPC</acronym> has been updated to include
+ several enhancements:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>The 45 MiB limit on requests queued for
+ &man.nfsd.8; threads has been removed.</para>
+ </listitem>
+
+ <listitem>
+ <para>Avoids unnecessary throttling by not deferring
+ accounting for completed requests.</para>
+ </listitem>
+
+ <listitem>
+ <para>Fixes an integer overflow and signedness bugs.</para>
+ </listitem>
+ </itemizedlist>
+
+ <para revision="281261" arch="powerpc">Support for
+ &man.dtrace.1; has been added for the
+ Book-E&nbsp;&trade;.</para>
</sect2>
<sect2 xml:id="kernel-config">
@@ -604,6 +688,21 @@
<para revision="279361">The <literal>kern.osrelease</literal>
and <literal>kern.osreldate</literal> are now configurable
&man.jail.8; parameters.</para>
+
+ <para revision="280308,280949" contrib="sponsor"
+ sponsor="&ix;, &ff;">The &man.devfs.5; device filesystem has
+ been changed to update timestamps for read/write operations
+ using seconds precision. A new &man.sysctl.8;,
+ <literal>vfs.devfs.dotimes</literal> has been added, which
+ when set to a non-zero value, enables default precision
+ timestamps for these operations.</para>
+
+ <para revision="282213" contrib="sponsor" sponsor="&ff;">A new
+ &man.sysctl.8;, <literal>kern.racct.enable</literal>, has been
+ added, which when set to a non-zero value allows using
+ &man.rctl.8; with the <literal>GENERIC</literal> kernel.
+ A new kernel configuration option,
+ <literal>RACCT_DISABLED</literal> has also been added.</para>
</sect2>
</sect1>
@@ -642,6 +741,9 @@
<filename>/dev/hpet<replaceable>N</replaceable></filename>
device, providing access to <acronym>HPET</acronym> from
userspace.</para>
+
+ <para revision="280183">The <literal>drm</literal> code has
+ been updated to match &linux; version 3.8.13.</para>
</sect2>
<sect2 xml:id="drivers-storage">
@@ -676,6 +778,9 @@
<para revision="276526">The <literal>asr(4)</literal> driver has
been removed, and is no longer supported.</para>
+
+ <para revision="281387">The &man.hptnr.4; driver has been
+ updated to version 1.1.1.</para>
</sect2>
<sect2 xml:id="drivers-network">
@@ -768,6 +873,10 @@
driver has been updated to correct performance counter
sampling on G4 (MPC74xxx) and G5 class processors.</para>
+ <para revision="281713" arch="powerpc">The &man.hwpmc.4;
+ driver has been updated to support the Freescale e500
+ core.</para>
+
<para revision="275732" contrib="sponsor"
sponsor="&ff;,&netgate;">The
<application>OpenCrypto</application> framework has been
@@ -819,6 +928,38 @@
<para revision="273515">The &man.virtio.console.4; driver has
been added, which provides an interface to VirtIO console
devices through a &man.tty.4; device.</para>
+
+ <para revision="279957">The &man.bhyve.8; hypervisor has been
+ updated to support <literal>DSM TRIM</literal> commands for
+ virtual <acronym>AHCI</acronym> disks.</para>
+
+ <para revision="281439" arch="arm">Support for the
+ <application>QEMU</application> <literal>virt</literal> system
+ has been added.</para>
+
+ <para revision="282212" contrib="sponsor" sponsor="&msostc;">The
+ HyperV&trade; drivers have been updated with several
+ enhancements:</para>
+
+ <itemizedlist>
+ <listitem>
+ <para>The &man.hv.vmbus.4; driver now has multi-channel
+ support.</para>
+ </listitem>
+
+ <listitem>
+ <para>The &man.hv.storvsc.4; driver now has scatter/gather
+ support, in addition to performance improvements.</para>
+ </listitem>
+
+ <listitem>
+ <para>The &man.hv.kvp.4; driver has received several bug
+ fixes.</para>
+ </listitem>
+ </itemizedlist>
+
+ <para revision="282274">Support for &man.xen.4; para-virtualized
+ <literal>domU</literal> kernels has been removed.</para>
</sect2>
<sect2 xml:id="hardware-arm">
@@ -835,6 +976,10 @@
driver has been added, which supports <acronym>CPU</acronym>
frequency and voltage control on the Raspberry Pi
<acronym>SOC</acronym>.</para>
+
+ <para revision="280259" contrib="sponsor" sponsor="&ff;">Initial
+ support for the ARM AArch64 architecture has been
+ added.</para>
</sect2>
</sect1>
@@ -846,6 +991,7 @@
<sect2 xml:id="storage-general">
<title>General Storage</title>
+
<para revision="278037" contrib="sponsor" sponsor="&ix;">The
&man.ctl.4; <acronym>LUN</acronym> mapping has been rewritten,
replacing <acronym>iSCSI</acronym>-specific mapping mechanisms
@@ -907,6 +1053,12 @@
Alternatively, &man.syscons.4; can be enabled at boot time by
entering <literal>set kern.vty=sc</literal> at the
&man.loader.8; prompt.</para>
+
+ <para revision="281616">The boot loader has been updated to
+ support entering the <acronym>GELI</acronym> passphrase before
+ loading the kernel. To enable this behavior, add
+ <literal>geom_eli_passphrase_prompt="YES"</literal> to
+ &man.loader.conf.5;.</para>
</sect2>
<sect2 xml:id="boot-menu">
@@ -1002,6 +1154,13 @@
</tbody>
</tgroup>
</informaltable>
+
+ <para revision="280971" contrib="sponsor"
+ sponsor="&netflix;, &nginx;">Support for <acronym>IP</acronym>
+ identification for atomic datagrams (<acronym>RFC</acronym>
+ 6864) has been added. Support for this feature can be toggled
+ with the <literal>net.inet.ip.rfc6864</literal>
+ &man.sysctl.8;, which is enabled by default.</para>
</sect2>
</sect1>
@@ -1062,6 +1221,11 @@
been updated to use multi-threaded &man.xz.1;. By default,
the number of &man.xz.1; threads is set to the number of cores
available.</para>
+
+ <para revision="281802" contrib="sponsor" sponsor="&ff;">The
+ Release Engineering build tools have been updated to include
+ support for building &os;/&arch.arm64; virtual machine and
+ memory stick installation images.</para>
</sect2>
</sect1>
</article>
diff --git a/release/doc/share/xml/release.ent b/release/doc/share/xml/release.ent
index e02a5f6..f72b4d0 100644
--- a/release/doc/share/xml/release.ent
+++ b/release/doc/share/xml/release.ent
@@ -70,6 +70,7 @@
<!-- Architecture names -->
<!ENTITY arch.amd64 "amd64">
<!ENTITY arch.arm "arm">
+<!ENTITY arch.arm64 "aarch64">
<!ENTITY arch.i386 "i386">
<!ENTITY arch.mips "mips">
<!ENTITY arch.pc98 "pc98">
diff --git a/release/doc/share/xml/sponsor.ent b/release/doc/share/xml/sponsor.ent
index 6e77d0d..19787a2 100644
--- a/release/doc/share/xml/sponsor.ent
+++ b/release/doc/share/xml/sponsor.ent
@@ -23,12 +23,20 @@
<!ENTITY google "Google">
+<!ENTITY juniper "Juniper Networks, Inc.">
+
<!ENTITY ix "iXsystems">
<!ENTITY limelight "Limelight Networks">
<!ENTITY lsi "LSI">
+<!ENTITY msostc "Microsoft Open Source Technology Center">
+<!ENTITY mitail "MIT Computer Science &amp; Artificial Intelligence Laboratory">
+<!ENTITY multiplay "Multiplay">
+
+<!ENTITY netflix "Netflix">
<!ENTITY netgate "Netgate">
+<!ENTITY nginx "Nginx, Inc.">
<!ENTITY sandvine "Sandvine, Inc.">
<!ENTITY scaleengine "ScaleEngine, Inc.">
diff --git a/release/i386/make-memstick.sh b/release/i386/make-memstick.sh
index e10b892..27979ae7 100755
--- a/release/i386/make-memstick.sh
+++ b/release/i386/make-memstick.sh
@@ -29,20 +29,13 @@ if [ -e ${2} ]; then
fi
echo '/dev/ufs/FreeBSD_Install / ufs ro,noatime 1 1' > ${1}/etc/fstab
-makefs -B little -o label=FreeBSD_Install ${2} ${1}
+makefs -B little -o label=FreeBSD_Install ${2}.part ${1}
if [ $? -ne 0 ]; then
echo "makefs failed"
exit 1
fi
rm ${1}/etc/fstab
-unit=$(mdconfig -a -t vnode -f ${2})
-if [ $? -ne 0 ]; then
- echo "mdconfig failed"
- exit 1
-fi
-gpart create -s BSD ${unit}
-gpart bootcode -b ${1}/boot/boot ${unit}
-gpart add -t freebsd-ufs ${unit}
-mdconfig -d -u ${unit}
+mkimg -s gpt -b ${1}/boot/pmbr -p freebsd-boot:=${1}/boot/gptboot -p freebsd-ufs:=${2}.part -p freebsd-swap::1M -o ${2}
+rm ${2}.part
diff --git a/release/release.sh b/release/release.sh
index 6b24b73..94a9bb6 100755
--- a/release/release.sh
+++ b/release/release.sh
@@ -36,256 +36,359 @@
# $FreeBSD$
#
-PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
-export PATH
+export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"
+
+VERSION=2
# Prototypes that can be redefined per-chroot or per-target.
load_chroot_env() { }
load_target_env() { }
buildenv_setup() { }
-# The directory within which the release will be built.
-CHROOTDIR="/scratch"
-RELENGDIR="$(realpath $(dirname $(basename ${0})))"
+usage() {
+ echo "Usage: $0 [-c release.conf]"
+ exit 1
+}
-# The default version control system command to obtain the sources.
-VCSCMD="svn checkout"
+# env_setup(): Set up the default build environment variables, such as the
+# CHROOTDIR, VCSCMD, SVNROOT, etc. This is called before the release.conf
+# file is sourced, if '-c <release.conf>' is specified.
+env_setup() {
+ # The directory within which the release will be built.
+ CHROOTDIR="/scratch"
+ RELENGDIR="$(dirname $(realpath ${0}))"
+
+ # The default version control system command to obtain the sources.
+ for _dir in /usr/bin /usr/local/bin; do
+ for _svn in svn svnlite; do
+ [ -x "${_dir}/${_svn}" ] && VCSCMD="${_dir}/${_svn}"
+ [ ! -z "${VCSCMD}" ] && break 2
+ done
+ done
+ VCSCMD="${VCSCMD} checkout"
+
+ # The default svn checkout server, and svn branches for src/, doc/,
+ # and ports/.
+ SVNROOT="svn://svn.FreeBSD.org/"
+ SRCBRANCH="base/head@rHEAD"
+ DOCBRANCH="doc/head@rHEAD"
+ PORTBRANCH="ports/head@rHEAD"
+
+ # Set for embedded device builds.
+ EMBEDDEDBUILD=
+
+ # Sometimes one needs to checkout src with --force svn option.
+ # If custom kernel configs copied to src tree before checkout, e.g.
+ SRC_FORCE_CHECKOUT=
+
+ # The default make.conf and src.conf to use. Set to /dev/null
+ # by default to avoid polluting the chroot(8) environment with
+ # non-default settings.
+ MAKE_CONF="/dev/null"
+ SRC_CONF="/dev/null"
+
+ # The number of make(1) jobs, defaults to the number of CPUs available
+ # for buildworld, and half of number of CPUs available for buildkernel.
+ WORLD_FLAGS="-j$(sysctl -n hw.ncpu)"
+ KERNEL_FLAGS="-j$(( $(( $(sysctl -n hw.ncpu) + 1 )) / 2))"
+
+ MAKE_FLAGS="-s"
+
+ # The name of the kernel to build, defaults to GENERIC.
+ KERNEL="GENERIC"
+
+ # Set to non-empty value to disable checkout of doc/ and/or ports/.
+ # Disabling ports/ checkout also forces NODOC to be set.
+ NODOC=
+ NOPORTS=
+
+ # Set to non-empty value to build dvd1.iso as part of the release.
+ WITH_DVD=
+ WITH_COMPRESSED_IMAGES=
-# The default svn checkout server, and svn branches for src/, doc/,
-# and ports/.
-SVNROOT="svn://svn.FreeBSD.org/"
-SRCBRANCH="base/head@rHEAD"
-DOCBRANCH="doc/head@rHEAD"
-PORTBRANCH="ports/head@rHEAD"
+ # Set to non-empty value to build virtual machine images as part of
+ # the release.
+ WITH_VMIMAGES=
+ WITH_COMPRESSED_VMIMAGES=
+ XZ_THREADS=0
+
+ # Set to non-empty value to build virtual machine images for various
+ # cloud providers as part of the release.
+ WITH_CLOUDWARE=
+
+ return 0
+} # env_setup()
+
+# env_check(): Perform sanity tests on the build environment, such as ensuring
+# files/directories exist, as well as adding backwards-compatibility hacks if
+# necessary. This is called unconditionally, and overrides the defaults set
+# in env_setup() if '-c <release.conf>' is specified.
+env_check() {
+ chroot_build_release_cmd="chroot_build_release"
+ # Fix for backwards-compatibility with release.conf that does not have
+ # the trailing '/'.
+ case ${SVNROOT} in
+ *svn*)
+ SVNROOT="${SVNROOT}/"
+ ;;
+ *)
+ ;;
+ esac
-# Set for embedded device builds.
-EMBEDDEDBUILD=
+ # Prefix the branches with the SVNROOT for the full checkout URL.
+ SRCBRANCH="${SVNROOT}${SRCBRANCH}"
+ DOCBRANCH="${SVNROOT}${DOCBRANCH}"
+ PORTBRANCH="${SVNROOT}${PORTBRANCH}"
+
+ if [ -n "${EMBEDDEDBUILD}" ]; then
+ WITH_DVD=
+ WITH_COMPRESSED_IMAGES=
+ NODOC=yes
+ case ${EMBEDDED_TARGET}:${EMBEDDED_TARGET_ARCH} in
+ arm:armv6)
+ chroot_build_release_cmd="chroot_arm_armv6_build_release"
+ ;;
+ *)
+ esac
+ fi
-# Sometimes one needs to checkout src with --force svn option.
-# If custom kernel configs copied to src tree before checkout, e.g.
-SRC_FORCE_CHECKOUT=
+ # If PORTS is set and NODOC is unset, force NODOC=yes because the ports
+ # tree is required to build the documentation set.
+ if [ -n "${NOPORTS}" ] && [ -z "${NODOC}" ]; then
+ echo "*** NOTICE: Setting NODOC=1 since ports tree is required"
+ echo " and NOPORTS is set."
+ NODOC=yes
+ fi
-# The default make.conf and src.conf to use. Set to /dev/null
-# by default to avoid polluting the chroot(8) environment with
-# non-default settings.
-MAKE_CONF="/dev/null"
-SRC_CONF="/dev/null"
+ # If NOPORTS and/or NODOC are unset, they must not pass to make as
+ # variables. The release makefile verifies definedness of the
+ # NOPORTS/NODOC variables instead of their values.
+ DOCPORTS=
+ if [ -n "${NOPORTS}" ]; then
+ DOCPORTS="NOPORTS=yes "
+ fi
+ if [ -n "${NODOC}" ]; then
+ DOCPORTS="${DOCPORTS}NODOC=yes"
+ fi
-# The number of make(1) jobs, defaults to the number of CPUs available for
-# buildworld, and half of number of CPUs available for buildkernel.
-WORLD_FLAGS="-j$(sysctl -n hw.ncpu)"
-KERNEL_FLAGS="-j$(( $(( $(sysctl -n hw.ncpu) + 1 )) / 2))"
+ # The aggregated build-time flags based upon variables defined within
+ # this file, unless overridden by release.conf. In most cases, these
+ # will not need to be changed.
+ CONF_FILES="__MAKE_CONF=${MAKE_CONF} SRCCONF=${SRC_CONF}"
+ if [ -n "${TARGET}" ] && [ -n "${TARGET_ARCH}" ]; then
+ ARCH_FLAGS="TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}"
+ else
+ ARCH_FLAGS=
+ fi
+ # Force src checkout if configured
+ FORCE_SRC_KEY=
+ if [ -n "${SRC_FORCE_CHECKOUT}" ]; then
+ FORCE_SRC_KEY="--force"
+ fi
-MAKE_FLAGS="-s"
+ if [ -z "${CHROOTDIR}" ]; then
+ echo "Please set CHROOTDIR."
+ exit 1
+ fi
-# The name of the kernel to build, defaults to GENERIC.
-KERNEL="GENERIC"
+ if [ $(id -u) -ne 0 ]; then
+ echo "Needs to be run as root."
+ exit 1
+ fi
-# Set to non-empty value to disable checkout of doc/ and/or ports/. Disabling
-# ports/ checkout also forces NODOC to be set.
-NODOC=
-NOPORTS=
+ CHROOT_MAKEENV="${CHROOT_MAKEENV} \
+ MAKEOBJDIRPREFIX=${CHROOTDIR}/tmp/obj"
+ CHROOT_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${CONF_FILES}"
+ CHROOT_IMAKEFLAGS="${CONF_FILES}"
+ CHROOT_DMAKEFLAGS="${CONF_FILES}"
+ RELEASE_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${ARCH_FLAGS} \
+ ${CONF_FILES}"
+ RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} \
+ KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}"
+ RELEASE_RMAKEFLAGS="${ARCH_FLAGS} \
+ KERNCONF=\"${KERNEL}\" ${CONF_FILES} ${DOCPORTS} \
+ WITH_DVD=${WITH_DVD} WITH_VMIMAGES=${WITH_VMIMAGES} \
+ WITH_CLOUDWARE=${WITH_CLOUDWARE} XZ_THREADS=${XZ_THREADS}"
+
+ return 0
+} # env_check()
+
+# chroot_setup(): Prepare the build chroot environment for the release build.
+chroot_setup() {
+ load_chroot_env
+ mkdir -p ${CHROOTDIR}/usr
+
+ if [ -z "${SRC_UPDATE_SKIP}" ]; then
+ ${VCSCMD} ${FORCE_SRC_KEY} ${SRCBRANCH} ${CHROOTDIR}/usr/src
+ fi
+ if [ -z "${NODOC}" ] && [ -z "${DOC_UPDATE_SKIP}" ]; then
+ ${VCSCMD} ${DOCBRANCH} ${CHROOTDIR}/usr/doc
+ fi
+ if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then
+ ${VCSCMD} ${PORTBRANCH} ${CHROOTDIR}/usr/ports
+ fi
-# Set to non-empty value to build dvd1.iso as part of the release.
-WITH_DVD=
-WITH_COMPRESSED_IMAGES=
+ if [ -z "${CHROOTBUILD_SKIP}" ]; then
+ cd ${CHROOTDIR}/usr/src
+ env ${CHROOT_MAKEENV} make ${CHROOT_WMAKEFLAGS} buildworld
+ env ${CHROOT_MAKEENV} make ${CHROOT_IMAKEFLAGS} installworld \
+ DESTDIR=${CHROOTDIR}
+ env ${CHROOT_MAKEENV} make ${CHROOT_DMAKEFLAGS} distribution \
+ DESTDIR=${CHROOTDIR}
+ fi
-# Set to non-empty value to build virtual machine images as part of
-# the release.
-WITH_VMIMAGES=
-WITH_COMPRESSED_VMIMAGES=
-XZ_THREADS=0
+ return 0
+} # chroot_setup()
-# Set to non-empty value to build virtual machine images for various
-# cloud providers as part of the release.
-WITH_CLOUDWARE=
+# extra_chroot_setup(): Prepare anything additional within the build
+# necessary for the release build.
+extra_chroot_setup() {
+ mkdir -p ${CHROOTDIR}/dev
+ mount -t devfs devfs ${CHROOTDIR}/dev
+ [ -e /etc/resolv.conf ] && cp /etc/resolv.conf \
+ ${CHROOTDIR}/etc/resolv.conf
+ # Run ldconfig(8) in the chroot directory so /var/run/ld-elf*.so.hints
+ # is created. This is needed by ports-mgmt/pkg.
+ eval chroot ${CHROOTDIR} /etc/rc.d/ldconfig forcerestart
-usage() {
- echo "Usage: $0 [-c release.conf]"
- exit 1
-}
+ # If MAKE_CONF and/or SRC_CONF are set and not character devices
+ # (/dev/null), copy them to the chroot.
+ if [ -e ${MAKE_CONF} ] && [ ! -c ${MAKE_CONF} ]; then
+ mkdir -p ${CHROOTDIR}/$(dirname ${MAKE_CONF})
+ cp ${MAKE_CONF} ${CHROOTDIR}/${MAKE_CONF}
+ fi
+ if [ -e ${SRC_CONF} ] && [ ! -c ${SRC_CONF} ]; then
+ mkdir -p ${CHROOTDIR}/$(dirname ${SRC_CONF})
+ cp ${SRC_CONF} ${CHROOTDIR}/${SRC_CONF}
+ fi
-while getopts c: opt; do
- case ${opt} in
- c)
- RELEASECONF="${OPTARG}"
- if [ ! -e "${RELEASECONF}" ]; then
- echo "ERROR: Configuration file ${RELEASECONF} does not exist."
- exit 1
+ if [ -d ${CHROOTDIR}/usr/ports ]; then
+ # Trick the ports 'run-autotools-fixup' target to do the right
+ # thing.
+ _OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U)
+ REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release -V REVISION)
+ BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release -V BRANCH)
+ UNAME_r=${REVISION}-${BRANCH}
+ if [ -d ${CHROOTDIR}/usr/doc ] && [ -z "${NODOC}" ]; then
+ PBUILD_FLAGS="OSVERSION=${_OSVERSION} BATCH=yes"
+ PBUILD_FLAGS="${PBUILD_FLAGS} UNAME_r=${UNAME_r}"
+ PBUILD_FLAGS="${PBUILD_FLAGS} OSREL=${REVISION}"
+ chroot ${CHROOTDIR} make -C /usr/ports/textproc/docproj \
+ ${PBUILD_FLAGS} OPTIONS_UNSET="FOP IGOR" \
+ install clean distclean
fi
- # Source the specified configuration file for overrides
- . ${RELEASECONF}
- ;;
- \?)
- usage
- ;;
- esac
-done
-shift $(($OPTIND - 1))
-
-# Fix for backwards-compatibility with release.conf that does not have the
-# trailing '/'.
-case ${SVNROOT} in
- *svn*)
- SVNROOT="${SVNROOT}/"
- ;;
- *)
- ;;
-esac
-
-# Prefix the branches with the SVNROOT for the full checkout URL.
-SRCBRANCH="${SVNROOT}${SRCBRANCH}"
-DOCBRANCH="${SVNROOT}${DOCBRANCH}"
-PORTBRANCH="${SVNROOT}${PORTBRANCH}"
-
-if [ -n "${EMBEDDEDBUILD}" ]; then
- WITH_DVD=
- WITH_COMPRESSED_IMAGES=
- NODOC=yes
-fi
-
-# If PORTS is set and NODOC is unset, force NODOC=yes because the ports tree
-# is required to build the documentation set.
-if [ -n "${NOPORTS}" ] && [ -z "${NODOC}" ]; then
- echo "*** NOTICE: Setting NODOC=1 since ports tree is required"
- echo " and NOPORTS is set."
- NODOC=yes
-fi
-
-# If NOPORTS and/or NODOC are unset, they must not pass to make as variables.
-# The release makefile verifies definedness of NOPORTS/NODOC variables
-# instead of their values.
-DOCPORTS=
-if [ -n "${NOPORTS}" ]; then
- DOCPORTS="NOPORTS=yes "
-fi
-if [ -n "${NODOC}" ]; then
- DOCPORTS="${DOCPORTS}NODOC=yes"
-fi
-
-# The aggregated build-time flags based upon variables defined within
-# this file, unless overridden by release.conf. In most cases, these
-# will not need to be changed.
-CONF_FILES="__MAKE_CONF=${MAKE_CONF} SRCCONF=${SRC_CONF}"
-if [ -n "${TARGET}" ] && [ -n "${TARGET_ARCH}" ]; then
- ARCH_FLAGS="TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH}"
-else
- ARCH_FLAGS=
-fi
-load_chroot_env
-CHROOT_MAKEENV="${CHROOT_MAKEENV} MAKEOBJDIRPREFIX=${CHROOTDIR}/tmp/obj"
-CHROOT_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${CONF_FILES}"
-CHROOT_IMAKEFLAGS="${CONF_FILES}"
-CHROOT_DMAKEFLAGS="${CONF_FILES}"
-RELEASE_WMAKEFLAGS="${MAKE_FLAGS} ${WORLD_FLAGS} ${ARCH_FLAGS} ${CONF_FILES}"
-RELEASE_KMAKEFLAGS="${MAKE_FLAGS} ${KERNEL_FLAGS} KERNCONF=\"${KERNEL}\" ${ARCH_FLAGS} ${CONF_FILES}"
-RELEASE_RMAKEFLAGS="${ARCH_FLAGS} KERNCONF=\"${KERNEL}\" ${CONF_FILES} \
- ${DOCPORTS} WITH_DVD=${WITH_DVD} WITH_VMIMAGES=${WITH_VMIMAGES} \
- WITH_CLOUDWARE=${WITH_CLOUDWARE} XZ_THREADS=${XZ_THREADS}"
-
-# Force src checkout if configured
-FORCE_SRC_KEY=
-if [ -n "${SRC_FORCE_CHECKOUT}" ]; then
- FORCE_SRC_KEY="--force"
-fi
-
-if [ -z "${CHROOTDIR}" ]; then
- echo "Please set CHROOTDIR."
- exit 1
-fi
+ fi
-if [ $(id -u) -ne 0 ]; then
- echo "Needs to be run as root."
- exit 1
-fi
-
-set -e # Everything must succeed
-
-mkdir -p ${CHROOTDIR}/usr
-
-if [ -z "${SRC_UPDATE_SKIP}" ]; then
- ${VCSCMD} ${FORCE_SRC_KEY} ${SRCBRANCH} ${CHROOTDIR}/usr/src
-fi
-if [ -z "${NODOC}" ] && [ -z "${DOC_UPDATE_SKIP}" ]; then
- ${VCSCMD} ${DOCBRANCH} ${CHROOTDIR}/usr/doc
-fi
-if [ -z "${NOPORTS}" ] && [ -z "${PORTS_UPDATE_SKIP}" ]; then
- ${VCSCMD} ${PORTBRANCH} ${CHROOTDIR}/usr/ports
-fi
-
-if [ -z "${CHROOTBUILD_SKIP}" ]; then
- cd ${CHROOTDIR}/usr/src
- env ${CHROOT_MAKEENV} make ${CHROOT_WMAKEFLAGS} buildworld
- env ${CHROOT_MAKEENV} make ${CHROOT_IMAKEFLAGS} installworld \
- DESTDIR=${CHROOTDIR}
- env ${CHROOT_MAKEENV} make ${CHROOT_DMAKEFLAGS} distribution \
- DESTDIR=${CHROOTDIR}
-fi
-mount -t devfs devfs ${CHROOTDIR}/dev
-cp /etc/resolv.conf ${CHROOTDIR}/etc/resolv.conf
-trap "umount ${CHROOTDIR}/dev" EXIT # Clean up devfs mount on exit
-
-# If MAKE_CONF and/or SRC_CONF are set and not character devices (/dev/null),
-# copy them to the chroot.
-if [ -e ${MAKE_CONF} ] && [ ! -c ${MAKE_CONF} ]; then
- mkdir -p ${CHROOTDIR}/$(dirname ${MAKE_CONF})
- cp ${MAKE_CONF} ${CHROOTDIR}/${MAKE_CONF}
-fi
-if [ -e ${SRC_CONF} ] && [ ! -c ${SRC_CONF} ]; then
- mkdir -p ${CHROOTDIR}/$(dirname ${SRC_CONF})
- cp ${SRC_CONF} ${CHROOTDIR}/${SRC_CONF}
-fi
-
-# Embedded builds do not use the 'make release' target.
-if [ -n "${EMBEDDEDBUILD}" ]; then
- # If a crochet configuration file exists in *this* checkout of
- # release/, copy it to the /tmp/external directory within the chroot.
- # This allows building embedded releases without relying on updated
- # scripts and/or configurations to exist in the branch being built.
+ if [ ! -z "${EMBEDDEDPORTS}" ]; then
+ for _PORT in ${EMBEDDEDPORTS}; do
+ eval chroot ${CHROOTDIR} make -C /usr/ports/${_PORT} \
+ BATCH=1 FORCE_PKG_REGISTER=1 install clean distclean
+ done
+ fi
+
+ buildenv_setup
+
+ return 0
+} # extra_chroot_setup()
+
+# chroot_build_target(): Build the userland and kernel for the build target.
+chroot_build_target() {
load_target_env
- if [ -e ${RELENGDIR}/tools/${XDEV}/crochet-${KERNEL}.conf ] && \
- [ -e ${RELENGDIR}/${XDEV}/release.sh ]; then
- mkdir -p ${CHROOTDIR}/tmp/external/${XDEV}/
- cp ${RELENGDIR}/tools/${XDEV}/crochet-${KERNEL}.conf \
- ${CHROOTDIR}/tmp/external/${XDEV}/crochet-${KERNEL}.conf
- /bin/sh ${RELENGDIR}/${XDEV}/release.sh
+ if [ ! -z "${EMBEDDEDBUILD}" ]; then
+ RELEASE_WMAKEFLAGS="${RELEASE_WMAKEFLAGS} \
+ TARGET=${EMBEDDED_TARGET} \
+ TARGET_ARCH=${EMBEDDED_TARGET_ARCH}"
+ RELEASE_KMAKEFLAGS="${RELEASE_KMAKEFLAGS} \
+ TARGET=${EMBEDDED_TARGET} \
+ TARGET_ARCH=${EMBEDDED_TARGET_ARCH}"
fi
- # If the script does not exist for this architecture, exit.
- # This probably should be checked earlier, but allowing the rest
- # of the build process to get this far will at least set up the
- # chroot environment for testing.
- exit 0
-else
- # Not embedded.
- continue
-fi
-
-if [ -d ${CHROOTDIR}/usr/ports ]; then
- # Run ldconfig(8) in the chroot directory so /var/run/ld-elf*.so.hints
- # is created. This is needed by ports-mgmt/pkg.
- chroot ${CHROOTDIR} /etc/rc.d/ldconfig forcerestart
-
- ## Trick the ports 'run-autotools-fixup' target to do the right thing.
- _OSVERSION=$(sysctl -n kern.osreldate)
- REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release -V REVISION)
- BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release -V BRANCH)
- UNAME_r=${REVISION}-${BRANCH}
- if [ -d ${CHROOTDIR}/usr/doc ] && [ -z "${NODOC}" ]; then
- PBUILD_FLAGS="OSVERSION=${_OSVERSION} BATCH=yes"
- PBUILD_FLAGS="${PBUILD_FLAGS} UNAME_r=${UNAME_r}"
- PBUILD_FLAGS="${PBUILD_FLAGS} OSREL=${REVISION}"
- chroot ${CHROOTDIR} make -C /usr/ports/textproc/docproj \
- ${PBUILD_FLAGS} OPTIONS_UNSET="FOP IGOR" \
- install clean distclean
+ eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_WMAKEFLAGS} buildworld
+ eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_KMAKEFLAGS} buildkernel
+
+ return 0
+} # chroot_build_target
+
+# chroot_build_release(): Invoke the 'make release' target.
+chroot_build_release() {
+ load_target_env
+ eval chroot ${CHROOTDIR} make -C /usr/src/release \
+ ${RELEASE_RMAKEFLAGS} release
+ eval chroot ${CHROOTDIR} make -C /usr/src/release \
+ ${RELEASE_RMAKEFLAGS} install DESTDIR=/R \
+ WITH_COMPRESSED_IMAGES=${WITH_COMPRESSED_IMAGES} \
+ WITH_COMPRESSED_VMIMAGES=${WITH_COMPRESSED_VMIMAGES}
+
+ return 0
+} # chroot_build_release()
+
+# chroot_arm_armv6_build_release(): Create arm/armv6 SD card image.
+chroot_arm_armv6_build_release() {
+ load_target_env
+ eval chroot ${CHROOTDIR} make -C /usr/src/release obj
+ if [ -e "${RELENGDIR}/tools/${EMBEDDED_TARGET}.subr" ]; then
+ . "${RELENGDIR}/tools/${EMBEDDED_TARGET}.subr"
+ fi
+ [ ! -z "${RELEASECONF}" ] && . "${RELEASECONF}"
+ WORLDDIR="$(eval chroot ${CHROOTDIR} make -C /usr/src/release -V WORLDDIR)"
+ OBJDIR="$(eval chroot ${CHROOTDIR} make -C /usr/src/release -V .OBJDIR)"
+ DESTDIR="${OBJDIR}/${KERNEL}"
+ IMGBASE="${CHROOTDIR}/${OBJDIR}/${KERNEL}.img"
+ OSRELEASE="$(eval chroot ${CHROOTDIR} make -C /usr/src/release \
+ TARGET=${EMBEDDED_TARGET} TARGET_ARCH=${EMBEDDED_TARGET_ARCH} \
+ -V OSRELEASE)"
+ chroot ${CHROOTDIR} mkdir -p ${DESTDIR}
+ chroot ${CHROOTDIR} truncate -s ${IMAGE_SIZE} ${IMGBASE##${CHROOTDIR}}
+ export mddev=$(chroot ${CHROOTDIR} \
+ mdconfig -f ${IMGBASE##${CHROOTDIR}} ${MD_ARGS})
+ arm_create_disk
+ arm_install_base
+ arm_install_uboot
+ mdconfig -d -u ${mddev}
+ chroot ${CHROOTDIR} rmdir ${DESTDIR}
+ mv ${IMGBASE} ${CHROOTDIR}/${OBJDIR}/${OSRELEASE}-${KERNEL}.img
+ chroot ${CHROOTDIR} mkdir -p /R
+ chroot ${CHROOTDIR} cp -p ${OBJDIR}/${OSRELEASE}-${KERNEL}.img \
+ /R/${OSRELEASE}-${KERNEL}.img
+ chroot ${CHROOTDIR} xz -T ${XZ_THREADS} /R/${OSRELEASE}-${KERNEL}.img
+ cd ${CHROOTDIR}/R && sha256 ${OSRELEASE}* \
+ > CHECKSUM.SHA256
+ cd ${CHROOTDIR}/R && md5 ${OSRELEASE}* \
+ > CHECKSUM.MD5
+
+ return 0
+} # chroot_arm_armv6_build_release()
+
+# main(): Start here.
+main() {
+ set -e # Everything must succeed
+ env_setup
+ while getopts c: opt; do
+ case ${opt} in
+ c)
+ RELEASECONF="${OPTARG}"
+ ;;
+ \?)
+ usage
+ ;;
+ esac
+ done
+ shift $(($OPTIND - 1))
+ if [ ! -z "${RELEASECONF}" ]; then
+ if [ -e "${RELEASECONF}" ]; then
+ . ${RELEASECONF}
+ else
+ echo "Nonexistent configuration file: ${RELEASECONF}"
+ echo "Using default build environment."
+ fi
fi
-fi
-
-buildenv_setup
-load_target_env
-eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_WMAKEFLAGS} buildworld
-eval chroot ${CHROOTDIR} make -C /usr/src ${RELEASE_KMAKEFLAGS} buildkernel
-eval chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \
- release
-eval chroot ${CHROOTDIR} make -C /usr/src/release ${RELEASE_RMAKEFLAGS} \
- install DESTDIR=/R WITH_COMPRESSED_IMAGES=${WITH_COMPRESSED_IMAGES} \
- WITH_COMPRESSED_VMIMAGES=${WITH_COMPRESSED_VMIMAGES}
+ env_check
+ trap "umount ${CHROOTDIR}/dev" EXIT # Clean up devfs mount on exit
+ chroot_setup
+ extra_chroot_setup
+ chroot_build_target
+ ${chroot_build_release_cmd}
+
+ return 0
+} # main()
+
+main "${@}"
diff --git a/release/tools/arm.subr b/release/tools/arm.subr
new file mode 100644
index 0000000..5cc61e3
--- /dev/null
+++ b/release/tools/arm.subr
@@ -0,0 +1,137 @@
+#!/bin/sh
+#-
+# Copyright (c) 2015 The FreeBSD Foundation
+# All rights reserved.
+#
+# Portions of this software were developed by Glen Barber
+# under sponsorship from the FreeBSD Foundation.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this 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.
+#
+# Common subroutines used to build arm/armv6 images.
+#
+# $FreeBSD$
+#
+
+cleanup() {
+ if [ -c "${DESTDIR}/dev/null" ]; then
+ umount_loop ${DESTDIR}/dev 2>/dev/null
+ fi
+ umount_loop ${DESTDIR}
+ if [ ! -z "${mddev}" ]; then
+ mdconfig -d -u ${mddev}
+ fi
+
+ return 0
+}
+
+umount_loop() {
+ DIR=$1
+ i=0
+ sync
+ while ! umount ${DIR}; do
+ i=$(( $i + 1 ))
+ if [ $i -ge 10 ]; then
+ # This should never happen. But, it has happened.
+ echo "Cannot umount(8) ${DIR}"
+ echo "Something has gone horribly wrong."
+ return 1
+ fi
+ sleep 1
+ done
+
+ return 0
+}
+
+arm_create_disk() {
+ # Create the target raw file and temporary work directory.
+ chroot ${CHROOTDIR} gpart create -s ${PART_SCHEME} ${mddev}
+ chroot ${CHROOTDIR} gpart add -t '!12' -a 63 -s ${FAT_SIZE} ${mddev}
+ chroot ${CHROOTDIR} gpart set -a active -i 1 ${mddev}
+ chroot ${CHROOTDIR} newfs_msdos -L msdosboot -F ${FAT_TYPE} /dev/${mddev}s1
+ chroot ${CHROOTDIR} gpart add -t freebsd ${mddev}
+ chroot ${CHROOTDIR} gpart create -s bsd ${mddev}s2
+ chroot ${CHROOTDIR} gpart add -t freebsd-ufs -a 64k /dev/${mddev}s2
+ chroot ${CHROOTDIR} newfs -U -L rootfs /dev/${mddev}s2a
+ chroot ${CHROOTDIR} tunefs -j enable -N enable /dev/${mddev}s2a
+
+ return 0
+}
+
+arm_create_user() {
+ # Create a default user account 'freebsd' with the password 'freebsd',
+ # and set the default password for the 'root' user to 'root'.
+ chroot ${CHROOTDIR} /usr/sbin/pw groupadd freebsd -g 1001
+ chroot ${CHROOTDIR} /usr/sbin/pw useradd freebsd \
+ -m -M 0755 -w yes -n freebsd -u 1001 -g 1001 -G 0 \
+ -c 'FreeBSD User' -d '/home/freebsd' -s '/bin/csh'
+ chroot ${CHROOTDIR} /usr/sbin/pw usermod root -w yes
+
+ return 0
+}
+
+arm_install_base() {
+ chroot ${CHROOTDIR} mount /dev/${mddev}s2a ${DESTDIR}
+ eval chroot ${CHROOTDIR} make -C ${WORLDDIR} \
+ TARGET=${EMBEDDED_TARGET} \
+ TARGET_ARCH=${EMBEDDED_TARGET_ARCH} \
+ DESTDIR=${DESTDIR} KERNCONF=${KERNEL} \
+ installworld installkernel distribution
+ chroot ${CHROOTDIR} mkdir -p ${DESTDIR}/boot/msdos
+
+ arm_create_user
+
+ echo '# Custom /etc/fstab for FreeBSD embedded images' \
+ > ${CHROOTDIR}/${DESTDIR}/etc/fstab
+ echo "/dev/ufs/rootfs / ufs rw 1 1" \
+ >> ${CHROOTDIR}/${DESTDIR}/etc/fstab
+ echo "/dev/msdosfs/MSDOSBOOT /boot/msdos msdosfs rw,noatime 0 0" \
+ >> ${CHROOTDIR}/${DESTDIR}/etc/fstab
+ echo "md /tmp mfs rw,noatime,-s30m 0 0" \
+ >> ${CHROOTDIR}/${DESTDIR}/etc/fstab
+ echo "md /var/log mfs rw,noatime,-s15m 0 0" \
+ >> ${CHROOTDIR}/${DESTDIR}/etc/fstab
+ echo "md /var/tmp mfs rw,noatime,-s12m 0 0" \
+ >> ${CHROOTDIR}/${DESTDIR}/etc/fstab
+
+ local hostname
+ hostname="$(echo ${KERNEL} | tr '[:upper:]' '[:lower:]')"
+ echo "hostname=\"${hostname}\"" > ${CHROOTDIR}/${DESTDIR}/etc/rc.conf
+ echo 'ifconfig_DEFAULT="DHCP"' >> ${CHROOTDIR}/${DESTDIR}/etc/rc.conf
+ echo 'sshd_enable="YES"' >> ${CHROOTDIR}/${DESTDIR}/etc/rc.conf
+ echo 'sendmail_enable="NONE"' >> ${CHROOTDIR}/${DESTDIR}/etc/rc.conf
+ echo 'sendmail_submit_enable="NO"' >> ${CHROOTDIR}/${DESTDIR}/etc/rc.conf
+ echo 'sendmail_outbound_enable="NO"' >> ${CHROOTDIR}/${DESTDIR}/etc/rc.conf
+ echo 'sendmail_msp_queue_enable="NO"' >> ${CHROOTDIR}/${DESTDIR}/etc/rc.conf
+ echo 'growfs_enable="YES"' >> ${CHROOTDIR}/${DESTDIR}/etc/rc.conf
+
+ sync
+ umount_loop ${CHROOTDIR}/${DESTDIR}
+
+ return 0
+}
+
+arm_install_uboot() {
+ # Override in the arm/KERNEL.conf file.
+
+ return 0
+}
diff --git a/release/tools/arm/crochet-BEAGLEBONE.conf b/release/tools/arm/crochet-BEAGLEBONE.conf
deleted file mode 100644
index e72814f..0000000
--- a/release/tools/arm/crochet-BEAGLEBONE.conf
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# $FreeBSD$
-#
-
-# This is the configuration file for use with crochet to produce
-# FreeBSD BeagleBone images.
-
-board_setup BeagleBone
-option ImageSize 1gb
-option Growfs
-
-export MAKEOBJDIRPREFIX=/usr/obj
-FREEBSD_SRC=/usr/src
-__MAKE_CONF=/dev/null
-SRCCONF=/dev/null
-WORKDIR=/usr/obj
-_BRANCH=$(make -C ${FREEBSD_SRC}/release -V BRANCH)
-_REVISION=$(make -C ${FREEBSD_SRC}/release -V REVISION)
-KERNCONF=BEAGLEBONE
-TARGET=arm
-TARGET_ARCH=armv6
-FREEBSD_BUILDWORLD_EXTRA_ARGS="${WORLD_FLAGS}"
-FREEBSD_BUILDKERNEL_EXTRA_ARGS="${KERNEL_FLAGS}"
-FREEBSD_INSTALLWORLD_EXTRA_ARGS=""
-FREEBSD_INSTALLKERNEL_EXTRA_ARGS=""
-FREEBSD_WORLD_EXTRA_ARGS=""
-FREEBSD_KERNEL_EXTRA_ARGS=""
-FREEBSD_EXTRA_ARGS=""
-IMG=${WORKDIR}/FreeBSD-${_REVISION}-${_BRANCH}-${TARGET}-${TARGET_ARCH}-${KERNCONF}.img
diff --git a/release/tools/arm/crochet-PANDABOARD.conf b/release/tools/arm/crochet-PANDABOARD.conf
deleted file mode 100644
index 366c4cc..0000000
--- a/release/tools/arm/crochet-PANDABOARD.conf
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# $FreeBSD$
-#
-
-# This is the configuration file for use with crochet to produce
-# FreeBSD PandaBoard images.
-
-board_setup PandaBoard
-option ImageSize 1gb
-option Growfs
-
-export MAKEOBJDIRPREFIX=/usr/obj
-FREEBSD_SRC=/usr/src
-__MAKE_CONF=/dev/null
-SRCCONF=/dev/null
-WORKDIR=/usr/obj
-_BRANCH=$(make -C ${FREEBSD_SRC}/release -V BRANCH)
-_REVISION=$(make -C ${FREEBSD_SRC}/release -V REVISION)
-KERNCONF=PANDABOARD
-TARGET=arm
-TARGET_ARCH=armv6
-FREEBSD_BUILDWORLD_EXTRA_ARGS="${WORLD_FLAGS}"
-FREEBSD_BUILDKERNEL_EXTRA_ARGS="${KERNEL_FLAGS}"
-FREEBSD_INSTALLWORLD_EXTRA_ARGS=""
-FREEBSD_INSTALLKERNEL_EXTRA_ARGS=""
-FREEBSD_WORLD_EXTRA_ARGS=""
-FREEBSD_KERNEL_EXTRA_ARGS=""
-FREEBSD_EXTRA_ARGS=""
-IMG=${WORKDIR}/FreeBSD-${_REVISION}-${_BRANCH}-${TARGET}-${TARGET_ARCH}-${KERNCONF}.img
diff --git a/release/tools/arm/crochet-RPI-B.conf b/release/tools/arm/crochet-RPI-B.conf
deleted file mode 100644
index 352048f..0000000
--- a/release/tools/arm/crochet-RPI-B.conf
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# $FreeBSD$
-#
-
-# This is the configuration file for use with crochet to produce
-# FreeBSD Raspberry Pi images.
-
-board_setup RaspberryPi
-option ImageSize 1gb
-option Growfs
-
-export MAKEOBJDIRPREFIX=/usr/obj
-FREEBSD_SRC=/usr/src
-__MAKE_CONF=/dev/null
-SRCCONF=/dev/null
-WORKDIR=/usr/obj
-_BRANCH=$(make -C ${FREEBSD_SRC}/release -V BRANCH)
-_REVISION=$(make -C ${FREEBSD_SRC}/release -V REVISION)
-KERNCONF=RPI-B
-TARGET=arm
-TARGET_ARCH=armv6
-FREEBSD_BUILDWORLD_EXTRA_ARGS="${WORLD_FLAGS}"
-FREEBSD_BUILDKERNEL_EXTRA_ARGS="${KERNEL_FLAGS}"
-FREEBSD_INSTALLWORLD_EXTRA_ARGS=""
-FREEBSD_INSTALLKERNEL_EXTRA_ARGS=""
-FREEBSD_WORLD_EXTRA_ARGS=""
-FREEBSD_KERNEL_EXTRA_ARGS=""
-FREEBSD_EXTRA_ARGS=""
-IMG=${WORKDIR}/FreeBSD-${_REVISION}-${_BRANCH}-${TARGET}-${TARGET_ARCH}-${KERNCONF}.img
diff --git a/release/tools/arm/crochet-WANDBOARD-QUAD.conf b/release/tools/arm/crochet-WANDBOARD-QUAD.conf
deleted file mode 100644
index d1e0062..0000000
--- a/release/tools/arm/crochet-WANDBOARD-QUAD.conf
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# $FreeBSD$
-#
-
-# This is the configuration file for use with crochet to produce
-# FreeBSD WandboardQuad images.
-
-board_setup Wandboard
-option ImageSize 1gb
-option Growfs
-
-export MAKEOBJDIRPREFIX=/usr/obj
-FREEBSD_SRC=/usr/src
-__MAKE_CONF=/dev/null
-SRCCONF=/dev/null
-WORKDIR=/usr/obj
-_BRANCH=$(make -C ${FREEBSD_SRC}/release -V BRANCH)
-_REVISION=$(make -C ${FREEBSD_SRC}/release -V REVISION)
-KERNCONF=WANDBOARD-QUAD
-TARGET=arm
-TARGET_ARCH=armv6
-FREEBSD_BUILDWORLD_EXTRA_ARGS="${WORLD_FLAGS}"
-FREEBSD_BUILDKERNEL_EXTRA_ARGS="${KERNEL_FLAGS}"
-FREEBSD_INSTALLWORLD_EXTRA_ARGS=""
-FREEBSD_INSTALLKERNEL_EXTRA_ARGS=""
-FREEBSD_WORLD_EXTRA_ARGS=""
-FREEBSD_KERNEL_EXTRA_ARGS=""
-FREEBSD_EXTRA_ARGS=""
-IMG=${WORKDIR}/FreeBSD-${_REVISION}-${_BRANCH}-${TARGET}-${TARGET_ARCH}-${KERNCONF}.img
diff --git a/release/tools/arm/crochet-ZEDBOARD.conf b/release/tools/arm/crochet-ZEDBOARD.conf
deleted file mode 100644
index 8353038..0000000
--- a/release/tools/arm/crochet-ZEDBOARD.conf
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# $FreeBSD$
-#
-
-# This is the configuration file for use with crochet to produce
-# FreeBSD ZedBoard images.
-
-board_setup ZedBoard
-option ImageSize 1gb
-option Growfs
-
-export MAKEOBJDIRPREFIX=/usr/obj
-FREEBSD_SRC=/usr/src
-__MAKE_CONF=/dev/null
-SRCCONF=/dev/null
-WORKDIR=/usr/obj
-_BRANCH=$(make -C ${FREEBSD_SRC}/release -V BRANCH)
-_REVISION=$(make -C ${FREEBSD_SRC}/release -V REVISION)
-KERNCONF=ZEDBOARD
-TARGET=arm
-TARGET_ARCH=armv6
-FREEBSD_BUILDWORLD_EXTRA_ARGS="${WORLD_FLAGS}"
-FREEBSD_BUILDKERNEL_EXTRA_ARGS="${KERNEL_FLAGS}"
-FREEBSD_INSTALLWORLD_EXTRA_ARGS=""
-FREEBSD_INSTALLKERNEL_EXTRA_ARGS=""
-FREEBSD_WORLD_EXTRA_ARGS=""
-FREEBSD_KERNEL_EXTRA_ARGS=""
-FREEBSD_EXTRA_ARGS=""
-IMG=${WORKDIR}/FreeBSD-${_REVISION}-${_BRANCH}-${TARGET}-${TARGET_ARCH}-${KERNCONF}.img
diff --git a/release/tools/vmimage.subr b/release/tools/vmimage.subr
index fa6db41..262e245b 100644
--- a/release/tools/vmimage.subr
+++ b/release/tools/vmimage.subr
@@ -23,20 +23,21 @@ write_partition_layout() {
case "${TARGET}:${TARGET_ARCH}" in
amd64:amd64 | i386:i386)
- mkimg -s gpt -b ${BOOTFILES}/i386/pmbr/pmbr \
+ mkimg -s gpt -f ${VMFORMAT} \
+ -b ${BOOTFILES}/i386/pmbr/pmbr \
-p freebsd-boot/bootfs:=${BOOTFILES}/i386/gptboot/gptboot \
${SWAPOPT} \
-p freebsd-ufs/rootfs:=${VMBASE} \
-o ${VMIMAGE}
;;
arm64:aarch64)
- mkimg -s mbr \
+ mkimg -s mbr -f ${VMFORMAT} \
-p efi:=${BOOTFILES}/efi/boot1/boot1.efifat \
-p freebsd:=${VMBASE} \
-o ${VMIMAGE}
;;
powerpc:powerpc*)
- mkimg -s apm \
+ mkimg -s apm -f ${VMFORMAT} \
-p apple-boot/bootfs:=${BOOTFILES}/powerpc/boot1.chrp/boot1.hfs \
${SWAPOPT} \
-p freebsd-ufs/rootfs:=${VMBASE} \
@@ -181,8 +182,10 @@ vm_extra_install_ports() {
}
vm_extra_pre_umount() {
- # Prototype. When overridden, installs additional ports within the
- # virtual machine environment.
+ # Prototype. When overridden, performs additional tasks within the
+ # virtual machine environment prior to unmounting the filesystem.
+ # Note: When overriding this function, removing resolv.conf in the
+ # disk image must be included.
rm -f ${DESTDIR}/etc/resolv.conf
return 0
diff --git a/sbin/casperd/casperd.c b/sbin/casperd/casperd.c
index 4b9037b..f838811 100644
--- a/sbin/casperd/casperd.c
+++ b/sbin/casperd/casperd.c
@@ -357,7 +357,7 @@ service_external_execute(int chanfd)
int stderrfd, execfd, procfd;
nvlist_t *nvl;
- nvl = nvlist_recv(chanfd);
+ nvl = nvlist_recv(chanfd, 0);
if (nvl == NULL)
pjdlog_exit(1, "Unable to receive nvlist");
service = nvlist_take_string(nvl, "service");
diff --git a/sbin/casperd/zygote.c b/sbin/casperd/zygote.c
index be3d9e5..c460bd3 100644
--- a/sbin/casperd/zygote.c
+++ b/sbin/casperd/zygote.c
@@ -91,7 +91,7 @@ zygote_clone(zygote_func_t *func, int flags, int *chanfdp, int *procfdp)
nvl = nvlist_create(0);
nvlist_add_number(nvl, "func", (uint64_t)(uintptr_t)func);
nvlist_add_number(nvl, "flags", (uint64_t)flags);
- nvl = nvlist_xfer(zygote_sock, nvl);
+ nvl = nvlist_xfer(zygote_sock, nvl, 0);
if (nvl == NULL)
return (-1);
if (nvlist_exists_number(nvl, "error")) {
@@ -134,7 +134,7 @@ zygote_main(int sock)
closefrom(sock + 1);
for (;;) {
- nvlin = nvlist_recv(sock);
+ nvlin = nvlist_recv(sock, 0);
if (nvlin == NULL) {
if (errno == ENOTCONN) {
/* Casperd exited. */
diff --git a/sbin/devd/devd.conf.5 b/sbin/devd/devd.conf.5
index 9749283..3956a73 100644
--- a/sbin/devd/devd.conf.5
+++ b/sbin/devd/devd.conf.5
@@ -41,7 +41,7 @@
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
.\" SOFTWARE.
.\"
-.Dd January 14, 2015
+.Dd May 13, 2015
.Dt DEVD.CONF 5
.Os
.Sh NAME
@@ -270,6 +270,8 @@ Interface Class (USB)
Interface Protocol (USB)
.It Li intsubclass
Interface Sub-class (USB)
+.It Li jail
+Jail name for the process triggering the rule (RCTL)
.It Li manufacturer
Manufacturer ID (pccard).
.It Li mode
@@ -280,12 +282,18 @@ Match the value of the
variable.
.It Li parent
Parent device
+.It Li pid
+PID of the process triggering the rule (RCTL)
.It Li port
Hub port number (USB)
.It Li product
Product ID (pccard/USB).
.It Li release
Hardware revision (USB)
+.It Li ruid
+Real UID of the process triggering the rule (RCTL)
+.It Li rule
+Rule (RCTL)
.It Li sernum
Serial Number (USB).
.It Li slot
@@ -397,6 +405,20 @@ Physical media has changed.
.El
.El
.Pp
+.It Li RCTL
+Events related to the
+.Xr rctl 8
+framework.
+.Bl -tag -width ".Sy Subsystem" -compact
+.It Sy Subsystem
+.It Li rule
+.Bl -tag -width ".Li matched" -compact
+.It Sy Type
+.It Li matched
+A rule with action specified as "devctl" was triggered.
+.El
+.El
+.Pp
.It Li USB
Events related to the USB subsystem.
.Bl -tag -width ".Sy Subsystem" -compact
diff --git a/sbin/geom/class/mountver/geom_mountver.c b/sbin/geom/class/mountver/geom_mountver.c
index a1ed95d..bff69c5 100644
--- a/sbin/geom/class/mountver/geom_mountver.c
+++ b/sbin/geom/class/mountver/geom_mountver.c
@@ -43,14 +43,14 @@ struct g_command class_commands[] = {
{
G_OPT_SENTINEL
},
- "[-v] dev ..."
+ "[-v] prov ..."
},
{ "destroy", G_FLAG_VERBOSE, NULL,
{
{ 'f', "force", NULL, G_TYPE_BOOL },
G_OPT_SENTINEL
},
- "[-fv] prov ..."
+ "[-fv] name"
},
G_CMD_SENTINEL
};
diff --git a/sbin/geom/class/mountver/gmountver.8 b/sbin/geom/class/mountver/gmountver.8
index 44736d5..4c27a65 100644
--- a/sbin/geom/class/mountver/gmountver.8
+++ b/sbin/geom/class/mountver/gmountver.8
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd January 27, 2015
+.Dd May 18, 2015
.Dt GMOUNTVER 8
.Os
.Sh NAME
@@ -35,11 +35,11 @@
.Nm
.Cm create
.Op Fl v
-.Ar dev ...
+.Ar prov ...
.Nm
.Cm destroy
.Op Fl fv
-.Ar prov ...
+.Ar name
.Nm
.Cm list
.Nm
@@ -66,8 +66,11 @@ The first argument to
indicates an action to be performed:
.Bl -tag -width ".Cm destroy"
.It Cm create
-Cache the given devices with specified
-.Ar name .
+Enable mount verification for the given provider.
+If the operation succeeds, a new GEOM provider will be created using the
+given provider's name with a
+.Ql .mountver
+suffix.
The kernel module
.Pa geom_mountver.ko
will be loaded if it is not loaded already.
diff --git a/sbin/geom/class/part/gpart.8 b/sbin/geom/class/part/gpart.8
index 520f049..8e8f858 100644
--- a/sbin/geom/class/part/gpart.8
+++ b/sbin/geom/class/part/gpart.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 12, 2015
+.Dd May 5, 2015
.Dt GPART 8
.Os
.Sh NAME
@@ -668,6 +668,8 @@ for GPT.
.It Cm apple-hfs
An Apple Mac OS X partition that contains a HFS or HFS+ filesystem.
The scheme-specific types are
+.Qq Li "!175"
+for MBR,
.Qq Li "!Apple_HFS"
for APM and
.Qq Li "!48465300-0000-11aa-aa11-00306543ecac"
@@ -696,6 +698,8 @@ for GPT.
.It Cm apple-ufs
An Apple Mac OS X partition that contains a UFS filesystem.
The scheme-specific types are
+.Qq Li "!168"
+for MBR,
.Qq Li "!Apple_UNIX_SVR2"
for APM and
.Qq Li "!55465300-0000-11aa-aa11-00306543ecac"
diff --git a/sbin/ifconfig/af_inet.c b/sbin/ifconfig/af_inet.c
index 3c3a757..eff1ce5 100644
--- a/sbin/ifconfig/af_inet.c
+++ b/sbin/ifconfig/af_inet.c
@@ -32,7 +32,7 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
-#include <sys/types.h>
+#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
@@ -100,7 +100,6 @@ static struct sockaddr_in *sintab[] = {
static void
in_getaddr(const char *s, int which)
{
-#define MIN(a,b) ((a)<(b)?(a):(b))
struct sockaddr_in *sin = sintab[which];
struct hostent *hp;
struct netent *np;
@@ -141,7 +140,6 @@ in_getaddr(const char *s, int which)
sin->sin_addr = inet_makeaddr(np->n_net, INADDR_ANY);
else
errx(1, "%s: bad value", s);
-#undef MIN
}
static void
diff --git a/sbin/ifconfig/af_inet6.c b/sbin/ifconfig/af_inet6.c
index 8a18401..6dd8622 100644
--- a/sbin/ifconfig/af_inet6.c
+++ b/sbin/ifconfig/af_inet6.c
@@ -486,8 +486,6 @@ static struct cmd inet6_cmds[] = {
DEF_CMD("-no_prefer_iface",-ND6_IFF_NO_PREFER_IFACE,setnd6flags),
DEF_CMD("no_dad", ND6_IFF_NO_DAD, setnd6flags),
DEF_CMD("-no_dad", -ND6_IFF_NO_DAD, setnd6flags),
- DEF_CMD("ignoreloop", ND6_IFF_IGNORELOOP, setnd6flags),
- DEF_CMD("-ignoreloop", -ND6_IFF_IGNORELOOP, setnd6flags),
DEF_CMD_ARG("pltime", setip6pltime),
DEF_CMD_ARG("vltime", setip6vltime),
DEF_CMD("eui64", 0, setip6eui64),
diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8
index 1e4870d..56b5c14 100644
--- a/sbin/ifconfig/ifconfig.8
+++ b/sbin/ifconfig/ifconfig.8
@@ -28,7 +28,7 @@
.\" From: @(#)ifconfig.8 8.3 (Berkeley) 1/5/94
.\" $FreeBSD$
.\"
-.Dd March 6, 2015
+.Dd May 15, 2015
.Dt IFCONFIG 8
.Os
.Sh NAME
@@ -316,6 +316,14 @@ using the
kernel configuration option, or the
.Va net.fibs
tunable.
+.It Cm tunnelfib Ar fib_number
+Specify tunnel FIB.
+A FIB
+.Ar fib_number
+is assigned to all packets encapsulated by tunnel interface, e.g.,
+.Xr gif 4
+and
+.Xr gre 4 .
.It Cm maclabel Ar label
If Mandatory Access Control support is enabled in the kernel,
set the MAC label to
@@ -692,15 +700,6 @@ Set a flag to disable Duplicate Address Detection.
.It Cm -no_dad
Clear a flag
.Cm no_dad .
-.It Cm ignoreloop
-Set a flag to disable loopback detection in Enhanced Duplicate Address
-Detection Algorithm.
-When this flag is set,
-Duplicate Address Detection will stop in a finite number of probings
-even if a loopback configuration is detected.
-.It Cm -ignoreloop
-Clear a flag
-.Cm ignoreloop .
.El
.Pp
The following parameters are specific for IPv6 addresses.
@@ -2429,6 +2428,14 @@ This is for backward compatibility with
.It Cm -accept_rev_ethip_ver
Clear a flag
.Cm accept_rev_ethip_ver .
+.It Cm ignore_source
+Set a flag to accept encapsulated packets destined to this host
+independently from source address.
+This may be useful for hosts, that receive encapsulated packets
+from the load balancers.
+.It Cm -ignore_source
+Clear a flag
+.Cm ignore_source .
.It Cm send_rev_ethip_ver
Set a flag to send EtherIP packets with reversed version
field intentionally.
diff --git a/sbin/ifconfig/iffib.c b/sbin/ifconfig/iffib.c
index f3498b4..07ded3c 100644
--- a/sbin/ifconfig/iffib.c
+++ b/sbin/ifconfig/iffib.c
@@ -50,15 +50,15 @@ fib_status(int s)
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+ if (ioctl(s, SIOCGIFFIB, (caddr_t)&ifr) == 0 &&
+ ifr.ifr_fib != RT_DEFAULT_FIB)
+ printf("\tfib: %u\n", ifr.ifr_fib);
- if (ioctl(s, SIOCGIFFIB, (caddr_t)&ifr) < 0)
- return;
-
- /* Ignore if it is the default. */
- if (ifr.ifr_fib == 0)
- return;
-
- printf("\tfib: %u\n", ifr.ifr_fib);
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+ if (ioctl(s, SIOCGTUNFIB, (caddr_t)&ifr) == 0 &&
+ ifr.ifr_fib != RT_DEFAULT_FIB)
+ printf("\ttunnelfib: %u\n", ifr.ifr_fib);
}
static void
@@ -80,8 +80,28 @@ setiffib(const char *val, int dummy __unused, int s,
warn("ioctl (SIOCSIFFIB)");
}
+static void
+settunfib(const char *val, int dummy __unused, int s,
+ const struct afswtch *afp)
+{
+ unsigned long fib;
+ char *ep;
+
+ fib = strtoul(val, &ep, 0);
+ if (*ep != '\0' || fib > UINT_MAX) {
+ warn("fib %s not valid", val);
+ return;
+ }
+
+ strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
+ ifr.ifr_fib = fib;
+ if (ioctl(s, SIOCSTUNFIB, (caddr_t)&ifr) < 0)
+ warn("ioctl (SIOCSTUNFIB)");
+}
+
static struct cmd fib_cmds[] = {
DEF_CMD_ARG("fib", setiffib),
+ DEF_CMD_ARG("tunnelfib", settunfib),
};
static struct afswtch af_fib = {
diff --git a/sbin/ifconfig/ifgif.c b/sbin/ifconfig/ifgif.c
index f91508b..91c433c 100644
--- a/sbin/ifconfig/ifgif.c
+++ b/sbin/ifconfig/ifgif.c
@@ -51,7 +51,7 @@ static const char rcsid[] =
#include "ifconfig.h"
-#define GIFBITS "\020\1ACCEPT_REV_ETHIP_VER\5SEND_REV_ETHIP_VER"
+#define GIFBITS "\020\1ACCEPT_REV_ETHIP_VER\2IGNORE_SOURCE\5SEND_REV_ETHIP_VER"
static void gif_status(int);
@@ -95,6 +95,8 @@ setgifopts(const char *val,
static struct cmd gif_cmds[] = {
DEF_CMD("accept_rev_ethip_ver", GIF_ACCEPT_REVETHIP, setgifopts),
DEF_CMD("-accept_rev_ethip_ver",-GIF_ACCEPT_REVETHIP, setgifopts),
+ DEF_CMD("ignore_source", GIF_IGNORE_SOURCE, setgifopts),
+ DEF_CMD("-ignore_source", -GIF_IGNORE_SOURCE, setgifopts),
DEF_CMD("send_rev_ethip_ver", GIF_SEND_REVETHIP, setgifopts),
DEF_CMD("-send_rev_ethip_ver", -GIF_SEND_REVETHIP, setgifopts),
};
diff --git a/sbin/ifconfig/sfp.c b/sbin/ifconfig/sfp.c
index d4da8c3..7c090e1 100644
--- a/sbin/ifconfig/sfp.c
+++ b/sbin/ifconfig/sfp.c
@@ -48,25 +48,16 @@ static const char rcsid[] =
#include "ifconfig.h"
-struct i2c_info;
-typedef int (read_i2c)(struct i2c_info *ii, uint8_t addr, uint8_t off,
- uint8_t len, caddr_t buf);
-
struct i2c_info {
- int s;
- int error;
- int bshift;
- int qsfp;
- int do_diag;
- struct ifreq *ifr;
- read_i2c *f;
- char *textbuf;
- size_t bufsize;
- int cfd;
- int port_id;
- int chip_id;
+ int fd; /* fd to issue SIOCGI2C */
+ int error; /* Store first error */
+ int qsfp; /* True if transceiver is QSFP */
+ int do_diag; /* True if we need to request DDM */
+ struct ifreq *ifr; /* Pointer to pre-filled ifreq */
};
+static int read_i2c(struct i2c_info *ii, uint8_t addr, uint8_t off,
+ uint8_t len, uint8_t *buf);
static void dump_i2c_data(struct i2c_info *ii, uint8_t addr, uint8_t off,
uint8_t len);
@@ -191,6 +182,18 @@ static struct _nv eth_1040g[] = {
{ 0, NULL }
};
+/* SFF-8636 Rev. 2.5 table 6.3: Revision compliance */
+static struct _nv rev_compl[] = {
+ { 0x1, "SFF-8436 rev <=4.8" },
+ { 0x2, "SFF-8436 rev <=4.8" },
+ { 0x3, "SFF-8636 rev <=1.3" },
+ { 0x4, "SFF-8636 rev <=1.4" },
+ { 0x5, "SFF-8636 rev <=1.5" },
+ { 0x6, "SFF-8636 rev <=2.0" },
+ { 0x7, "SFF-8636 rev <=2.5" },
+ { 0x0, "Unspecified" }
+};
+
const char *
find_value(struct _nv *x, int value)
{
@@ -255,11 +258,24 @@ convert_sff_connector(char *buf, size_t size, uint8_t value)
}
static void
+convert_sff_rev_compliance(char *buf, size_t size, uint8_t value)
+{
+ const char *x;
+
+ if (value > 0x07)
+ x = "Unallocated";
+ else
+ x = find_value(rev_compl, value);
+
+ snprintf(buf, size, "%s", x);
+}
+
+static void
get_sfp_identifier(struct i2c_info *ii, char *buf, size_t size)
{
uint8_t data;
- ii->f(ii, SFF_8472_BASE, SFF_8472_ID, 1, (caddr_t)&data);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_ID, 1, &data);
convert_sff_identifier(buf, size, data);
}
@@ -268,7 +284,7 @@ get_sfp_connector(struct i2c_info *ii, char *buf, size_t size)
{
uint8_t data;
- ii->f(ii, SFF_8472_BASE, SFF_8472_CONNECTOR, 1, (caddr_t)&data);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_CONNECTOR, 1, &data);
convert_sff_connector(buf, size, data);
}
@@ -277,7 +293,7 @@ get_qsfp_identifier(struct i2c_info *ii, char *buf, size_t size)
{
uint8_t data;
- ii->f(ii, SFF_8436_BASE, SFF_8436_ID, 1, (caddr_t)&data);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_ID, 1, &data);
convert_sff_identifier(buf, size, data);
}
@@ -286,7 +302,7 @@ get_qsfp_connector(struct i2c_info *ii, char *buf, size_t size)
{
uint8_t data;
- ii->f(ii, SFF_8436_BASE, SFF_8436_CONNECTOR, 1, (caddr_t)&data);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_CONNECTOR, 1, &data);
convert_sff_connector(buf, size, data);
}
@@ -303,7 +319,7 @@ printf_sfp_transceiver_descr(struct i2c_info *ii, char *buf, size_t size)
tech_speed = NULL;
/* Read bytes 3-10 at once */
- ii->f(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 8, &xbuf[3]);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 8, &xbuf[3]);
/* Check 10G ethernet first */
tech_class = find_zero_bit(eth_10g, xbuf[3], 1);
@@ -331,14 +347,14 @@ get_sfp_transceiver_class(struct i2c_info *ii, char *buf, size_t size)
uint8_t code;
unsigned char qbuf[8];
- ii->f(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 8, (caddr_t)qbuf);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 8, (uint8_t *)qbuf);
/* Check 10G Ethernet/IB first */
- ii->f(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 1, (caddr_t)&code);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_TRANS_START, 1, &code);
tech_class = find_zero_bit(eth_10g, code, 1);
if (tech_class == NULL) {
/* No match. Try Ethernet 1G */
- ii->f(ii, SFF_8472_BASE, SFF_8472_TRANS_START + 3,
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_TRANS_START + 3,
1, (caddr_t)&code);
tech_class = find_zero_bit(eth_compat, code, 1);
}
@@ -356,7 +372,7 @@ get_qsfp_transceiver_class(struct i2c_info *ii, char *buf, size_t size)
uint8_t code;
/* Check 10/40G Ethernet class only */
- ii->f(ii, SFF_8436_BASE, SFF_8436_CODE_E1040G, 1, (caddr_t)&code);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_CODE_E1040G, 1, &code);
tech_class = find_zero_bit(eth_1040g, code, 1);
if (tech_class == NULL)
tech_class = "Unknown";
@@ -393,7 +409,7 @@ get_sfp_vendor_name(struct i2c_info *ii, char *buf, size_t size)
char xbuf[17];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8472_BASE, SFF_8472_VENDOR_START, 16, xbuf);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_VENDOR_START, 16, (uint8_t *)xbuf);
convert_sff_name(buf, size, xbuf);
}
@@ -403,7 +419,7 @@ get_sfp_vendor_pn(struct i2c_info *ii, char *buf, size_t size)
char xbuf[17];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8472_BASE, SFF_8472_PN_START, 16, xbuf);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_PN_START, 16, (uint8_t *)xbuf);
convert_sff_name(buf, size, xbuf);
}
@@ -413,7 +429,7 @@ get_sfp_vendor_sn(struct i2c_info *ii, char *buf, size_t size)
char xbuf[17];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8472_BASE, SFF_8472_SN_START, 16, xbuf);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_SN_START, 16, (uint8_t *)xbuf);
convert_sff_name(buf, size, xbuf);
}
@@ -424,7 +440,7 @@ get_sfp_vendor_date(struct i2c_info *ii, char *buf, size_t size)
memset(xbuf, 0, sizeof(xbuf));
/* Date code, see Table 3.8 for description */
- ii->f(ii, SFF_8472_BASE, SFF_8472_DATE_START, 6, xbuf);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_DATE_START, 6, (uint8_t *)xbuf);
convert_sff_date(buf, size, xbuf);
}
@@ -434,7 +450,7 @@ get_qsfp_vendor_name(struct i2c_info *ii, char *buf, size_t size)
char xbuf[17];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8436_BASE, SFF_8436_VENDOR_START, 16, xbuf);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_VENDOR_START, 16, (uint8_t *)xbuf);
convert_sff_name(buf, size, xbuf);
}
@@ -444,7 +460,7 @@ get_qsfp_vendor_pn(struct i2c_info *ii, char *buf, size_t size)
char xbuf[17];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8436_BASE, SFF_8436_PN_START, 16, xbuf);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_PN_START, 16, (uint8_t *)xbuf);
convert_sff_name(buf, size, xbuf);
}
@@ -454,7 +470,7 @@ get_qsfp_vendor_sn(struct i2c_info *ii, char *buf, size_t size)
char xbuf[17];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8436_BASE, SFF_8436_SN_START, 16, xbuf);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_SN_START, 16, (uint8_t *)xbuf);
convert_sff_name(buf, size, xbuf);
}
@@ -464,7 +480,7 @@ get_qsfp_vendor_date(struct i2c_info *ii, char *buf, size_t size)
char xbuf[6];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8436_BASE, SFF_8436_DATE_START, 6, xbuf);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_DATE_START, 6, (uint8_t *)xbuf);
convert_sff_date(buf, size, xbuf);
}
@@ -501,12 +517,12 @@ print_sfp_vendor(struct i2c_info *ii, char *buf, size_t size)
*
*/
static void
-convert_sff_temp(char *buf, size_t size, char *xbuf)
+convert_sff_temp(char *buf, size_t size, uint8_t *xbuf)
{
double d;
- d = (double)(int8_t)xbuf[0];
- d += (double)(uint8_t)xbuf[1] / 256;
+ d = (double)xbuf[0];
+ d += (double)xbuf[1] / 256;
snprintf(buf, size, "%.2f C", d);
}
@@ -516,11 +532,11 @@ convert_sff_temp(char *buf, size_t size, char *xbuf)
* 16-bit usigned value, treated as range 0..+6.55 Volts
*/
static void
-convert_sff_voltage(char *buf, size_t size, char *xbuf)
+convert_sff_voltage(char *buf, size_t size, uint8_t *xbuf)
{
double d;
- d = (double)(((uint8_t)xbuf[0] << 8) | (uint8_t)xbuf[1]);
+ d = (double)((xbuf[0] << 8) | xbuf[1]);
snprintf(buf, size, "%.2f Volts", d / 10000);
}
@@ -529,12 +545,12 @@ convert_sff_voltage(char *buf, size_t size, char *xbuf)
* human representation.
*/
static void
-convert_sff_power(struct i2c_info *ii, char *buf, size_t size, char *xbuf)
+convert_sff_power(struct i2c_info *ii, char *buf, size_t size, uint8_t *xbuf)
{
uint16_t mW;
double dbm;
- mW = ((uint8_t)xbuf[0] << 8) + (uint8_t)xbuf[1];
+ mW = (xbuf[0] << 8) + xbuf[1];
/* Convert mw to dbm */
dbm = 10.0 * log10(1.0 * mW / 10000);
@@ -553,87 +569,116 @@ convert_sff_power(struct i2c_info *ii, char *buf, size_t size, char *xbuf)
static void
get_sfp_temp(struct i2c_info *ii, char *buf, size_t size)
{
- char xbuf[2];
+ uint8_t xbuf[2];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8472_DIAG, SFF_8472_TEMP, 2, xbuf);
+ read_i2c(ii, SFF_8472_DIAG, SFF_8472_TEMP, 2, xbuf);
convert_sff_temp(buf, size, xbuf);
}
static void
get_sfp_voltage(struct i2c_info *ii, char *buf, size_t size)
{
- char xbuf[2];
+ uint8_t xbuf[2];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8472_DIAG, SFF_8472_VCC, 2, xbuf);
+ read_i2c(ii, SFF_8472_DIAG, SFF_8472_VCC, 2, xbuf);
convert_sff_voltage(buf, size, xbuf);
}
static void
get_qsfp_temp(struct i2c_info *ii, char *buf, size_t size)
{
- char xbuf[2];
+ uint8_t xbuf[2];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8436_BASE, SFF_8436_TEMP, 2, xbuf);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_TEMP, 2, xbuf);
convert_sff_temp(buf, size, xbuf);
}
static void
get_qsfp_voltage(struct i2c_info *ii, char *buf, size_t size)
{
- char xbuf[2];
+ uint8_t xbuf[2];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8436_BASE, SFF_8436_VCC, 2, xbuf);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_VCC, 2, xbuf);
convert_sff_voltage(buf, size, xbuf);
}
static void
get_sfp_rx_power(struct i2c_info *ii, char *buf, size_t size)
{
- char xbuf[2];
+ uint8_t xbuf[2];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8472_DIAG, SFF_8472_RX_POWER, 2, xbuf);
+ read_i2c(ii, SFF_8472_DIAG, SFF_8472_RX_POWER, 2, xbuf);
convert_sff_power(ii, buf, size, xbuf);
}
static void
get_sfp_tx_power(struct i2c_info *ii, char *buf, size_t size)
{
- char xbuf[2];
+ uint8_t xbuf[2];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8472_DIAG, SFF_8472_TX_POWER, 2, xbuf);
+ read_i2c(ii, SFF_8472_DIAG, SFF_8472_TX_POWER, 2, xbuf);
convert_sff_power(ii, buf, size, xbuf);
}
static void
get_qsfp_rx_power(struct i2c_info *ii, char *buf, size_t size, int chan)
{
- char xbuf[2];
+ uint8_t xbuf[2];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8436_BASE, SFF_8436_RX_CH1_MSB + (chan - 1) * 2, 2, xbuf);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_RX_CH1_MSB + (chan-1)*2, 2, xbuf);
convert_sff_power(ii, buf, size, xbuf);
}
static void
get_qsfp_tx_power(struct i2c_info *ii, char *buf, size_t size, int chan)
{
- char xbuf[2];
+ uint8_t xbuf[2];
memset(xbuf, 0, sizeof(xbuf));
- ii->f(ii, SFF_8436_BASE, SFF_8436_TX_CH1_MSB + (chan -1) * 2, 2, xbuf);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_TX_CH1_MSB + (chan-1)*2, 2, xbuf);
convert_sff_power(ii, buf, size, xbuf);
}
-/* Generic handler */
+static void
+get_qsfp_rev_compliance(struct i2c_info *ii, char *buf, size_t size)
+{
+ uint8_t xbuf;
+
+ xbuf = 0;
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_STATUS, 1, &xbuf);
+ convert_sff_rev_compliance(buf, size, xbuf);
+}
+
+static uint32_t
+get_qsfp_br(struct i2c_info *ii)
+{
+ uint8_t xbuf;
+ uint32_t rate;
+
+ xbuf = 0;
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_BITRATE, 1, &xbuf);
+ rate = xbuf * 100;
+ if (xbuf == 0xFF) {
+ read_i2c(ii, SFF_8436_BASE, SFF_8636_BITRATE, 1, &xbuf);
+ rate = xbuf * 250;
+ }
+
+ return (rate);
+}
+
+/*
+ * Reads i2c data from opened kernel socket.
+ */
static int
-read_i2c_generic(struct i2c_info *ii, uint8_t addr, uint8_t off, uint8_t len,
- caddr_t buf)
+read_i2c(struct i2c_info *ii, uint8_t addr, uint8_t off, uint8_t len,
+ uint8_t *buf)
{
struct ifi2creq req;
int i, l;
@@ -653,7 +698,7 @@ read_i2c_generic(struct i2c_info *ii, uint8_t addr, uint8_t off, uint8_t len,
while (len > 0) {
l = (len > sizeof(req.data)) ? sizeof(req.data) : len;
req.len = l;
- if (ioctl(ii->s, SIOCGI2C, ii->ifr) != 0) {
+ if (ioctl(ii->fd, SIOCGI2C, ii->ifr) != 0) {
ii->error = errno;
return (errno);
}
@@ -676,7 +721,7 @@ dump_i2c_data(struct i2c_info *ii, uint8_t addr, uint8_t off, uint8_t len)
while (len > 0) {
memset(buf, 0, sizeof(buf));
read = (len > sizeof(buf)) ? sizeof(buf) : len;
- ii->f(ii, addr, off, read, buf);
+ read_i2c(ii, addr, off, read, buf);
if (ii->error != 0) {
fprintf(stderr, "Error reading i2c info\n");
return;
@@ -696,10 +741,11 @@ print_qsfp_status(struct i2c_info *ii, int verbose)
{
char buf[80], buf2[40], buf3[40];
uint8_t diag_type;
+ uint32_t bitrate;
int i;
/* Read diagnostic monitoring type */
- ii->f(ii, SFF_8436_BASE, SFF_8436_DIAG_TYPE, 1, (caddr_t)&diag_type);
+ read_i2c(ii, SFF_8436_BASE, SFF_8436_DIAG_TYPE, 1, (caddr_t)&diag_type);
if (ii->error != 0)
return;
@@ -722,6 +768,16 @@ print_qsfp_status(struct i2c_info *ii, int verbose)
if (ii->error == 0)
printf("\t%s\n", buf);
+ if (verbose > 1) {
+ get_qsfp_rev_compliance(ii, buf, sizeof(buf));
+ if (ii->error == 0)
+ printf("\tcompliance level: %s\n", buf);
+
+ bitrate = get_qsfp_br(ii);
+ if (ii->error == 0 && bitrate > 0)
+ printf("\tnominal bitrate: %u Mbps\n", bitrate);
+ }
+
/* Request current measurements if they are provided: */
if (ii->do_diag != 0) {
get_qsfp_temp(ii, buf, sizeof(buf));
@@ -749,7 +805,7 @@ print_sfp_status(struct i2c_info *ii, int verbose)
uint8_t diag_type, flags;
/* Read diagnostic monitoring type */
- ii->f(ii, SFF_8472_BASE, SFF_8472_DIAG_TYPE, 1, (caddr_t)&diag_type);
+ read_i2c(ii, SFF_8472_BASE, SFF_8472_DIAG_TYPE, 1, (caddr_t)&diag_type);
if (ii->error != 0)
return;
@@ -797,11 +853,10 @@ sfp_status(int s, struct ifreq *ifr, int verbose)
struct i2c_info ii;
uint8_t id_byte;
+ /* Prepare necessary into pass to i2c reader */
memset(&ii, 0, sizeof(ii));
- /* Prepare necessary into to pass to NIC handler */
- ii.s = s;
+ ii.fd = s;
ii.ifr = ifr;
- ii.f = read_i2c_generic;
/*
* Try to read byte 0 from i2c:
@@ -811,7 +866,7 @@ sfp_status(int s, struct ifreq *ifr, int verbose)
* this might happen in case of empty transceiver slot.
*/
id_byte = 0;
- ii.f(&ii, SFF_8472_BASE, SFF_8472_ID, 1, (caddr_t)&id_byte);
+ read_i2c(&ii, SFF_8472_BASE, SFF_8472_ID, 1, (caddr_t)&id_byte);
if (ii.error != 0 || id_byte == 0)
return;
diff --git a/sbin/ipfw/tables.c b/sbin/ipfw/tables.c
index 08f4731..b3473fc 100644
--- a/sbin/ipfw/tables.c
+++ b/sbin/ipfw/tables.c
@@ -715,6 +715,7 @@ table_print_valheader(char *buf, size_t bufsize, uint32_t vmask)
return;
}
+ memset(buf, 0, bufsize);
print_flags_buffer(buf, bufsize, tablevaltypes, vmask);
}
@@ -1309,6 +1310,63 @@ tentry_fill_key_type(char *arg, ipfw_obj_tentry *tentry, uint8_t type,
tentry->masklen = masklen;
}
+/*
+ * Tries to guess table key type.
+ * This procedure is used in legacy table auto-create
+ * code AND in `ipfw -n` ruleset checking.
+ *
+ * Imported from old table_fill_xentry() parse code.
+ */
+static int
+guess_key_type(char *key, uint8_t *ptype)
+{
+ char *p;
+ struct in6_addr addr;
+ uint32_t kv;
+
+ if (ishexnumber(*key) != 0 || *key == ':') {
+ /* Remove / if exists */
+ if ((p = strchr(key, '/')) != NULL)
+ *p = '\0';
+
+ if ((inet_pton(AF_INET, key, &addr) == 1) ||
+ (inet_pton(AF_INET6, key, &addr) == 1)) {
+ *ptype = IPFW_TABLE_CIDR;
+ if (p != NULL)
+ *p = '/';
+ return (0);
+ } else {
+ /* Port or any other key */
+ /* Skip non-base 10 entries like 'fa1' */
+ kv = strtol(key, &p, 10);
+ if (*p == '\0') {
+ *ptype = IPFW_TABLE_NUMBER;
+ return (0);
+ } else if ((p != key) && (*p == '.')) {
+ /*
+ * Warn on IPv4 address strings
+ * which are "valid" for inet_aton() but not
+ * in inet_pton().
+ *
+ * Typical examples: '10.5' or '10.0.0.05'
+ */
+ return (1);
+ }
+ }
+ }
+
+ if (strchr(key, '.') == NULL) {
+ *ptype = IPFW_TABLE_INTERFACE;
+ return (0);
+ }
+
+ if (lookup_host(key, (struct in_addr *)&addr) != 0)
+ return (1);
+
+ *ptype = IPFW_TABLE_CIDR;
+ return (0);
+}
+
static void
tentry_fill_key(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *key,
int add, uint8_t *ptype, uint32_t *pvmask, ipfw_xtable_info *xi)
@@ -1316,7 +1374,6 @@ tentry_fill_key(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *key,
uint8_t type, tflags;
uint32_t vmask;
int error;
- char *del;
type = 0;
tflags = 0;
@@ -1328,10 +1385,24 @@ tentry_fill_key(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *key,
error = 0;
if (error == 0) {
- /* Table found. */
- type = xi->type;
- tflags = xi->tflags;
- vmask = xi->vmask;
+ if (co.test_only == 0) {
+ /* Table found */
+ type = xi->type;
+ tflags = xi->tflags;
+ vmask = xi->vmask;
+ } else {
+ /*
+ * we're running `ipfw -n`
+ * Compability layer: try to guess key type
+ * before failing.
+ */
+ if (guess_key_type(key, &type) != 0) {
+ /* Inknown key */
+ errx(EX_USAGE, "Cannot guess "
+ "key '%s' type", key);
+ }
+ vmask = IPFW_VTYPE_LEGACY;
+ }
} else {
if (error != ESRCH)
errx(EX_OSERR, "Error requesting table %s info",
@@ -1340,24 +1411,16 @@ tentry_fill_key(ipfw_obj_header *oh, ipfw_obj_tentry *tent, char *key,
errx(EX_DATAERR, "Table %s does not exist",
oh->ntlv.name);
/*
- * Table does not exist.
- * Compability layer: try to interpret data as ADDR
- * before failing.
+ * Table does not exist
+ * Compability layer: try to guess key type before failing.
*/
- if ((del = strchr(key, '/')) != NULL)
- *del = '\0';
- if (inet_pton(AF_INET, key, &tent->k.addr6) == 1 ||
- inet_pton(AF_INET6, key, &tent->k.addr6) == 1) {
- /* OK Prepare and send */
- type = IPFW_TABLE_ADDR;
- vmask = IPFW_VTYPE_LEGACY;
- } else {
+ if (guess_key_type(key, &type) != 0) {
/* Inknown key */
errx(EX_USAGE, "Table %s does not exist, cannot guess "
"key '%s' type", oh->ntlv.name, key);
}
- if (del != NULL)
- *del = '/';
+
+ vmask = IPFW_VTYPE_LEGACY;
}
tentry_fill_key_type(key, tent, type, tflags);
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c
index f24ecde..23d5696 100644
--- a/sbin/ping/ping.c
+++ b/sbin/ping/ping.c
@@ -737,9 +737,6 @@ main(int argc, char *const *argv)
if (cansandbox && cap_enter() < 0 && errno != ENOSYS)
err(1, "cap_enter");
- if (cap_sandboxed())
- fprintf(stderr, "capability mode sandbox enabled\n");
-
cap_rights_init(&rights, CAP_RECV, CAP_EVENT, CAP_SETSOCKOPT);
if (cap_rights_limit(srecv, &rights) < 0 && errno != ENOSYS)
err(1, "cap_rights_limit srecv");
diff --git a/sbin/resolvconf/Makefile b/sbin/resolvconf/Makefile
index 18ef240..2d4701e 100644
--- a/sbin/resolvconf/Makefile
+++ b/sbin/resolvconf/Makefile
@@ -5,7 +5,7 @@ DIST= ${.CURDIR}/../../contrib/openresolv
SCRIPTS= resolvconf
-FILES= libc dnsmasq named pdnsd unbound
+FILES= libc dnsmasq named pdnsd pdns_recursor unbound
FILESDIR= /libexec/resolvconf
MAN= resolvconf.conf.5 resolvconf.8
diff --git a/share/doc/papers/Makefile b/share/doc/papers/Makefile
index 866fe20..eaf097f 100644
--- a/share/doc/papers/Makefile
+++ b/share/doc/papers/Makefile
@@ -6,7 +6,6 @@ SUBDIR= beyond4.3 \
devfs \
diskperf \
fsinterface \
- hwpmc \
jail \
kernmalloc \
kerntune \
diff --git a/share/doc/papers/bufbio/bio.ms b/share/doc/papers/bufbio/bio.ms
index 123f8e7..32e2917 100644
--- a/share/doc/papers/bufbio/bio.ms
+++ b/share/doc/papers/bufbio/bio.ms
@@ -40,7 +40,7 @@ This paper contains the road-map for a stackable "BIO" system in
FreeBSD, which will support these facilities.
.AE
.NH
-The miseducation of \fCstruct buf\fP.
+The miseducation of \f(CW.)struct buf\fP.
.PP
To fully appreciate the topic, I include a little historic overview
of struct buf, it is a most enlightening case of not exactly bit-rot
@@ -51,7 +51,7 @@ memory is was introduced into UNIX, all disk I/O were done from or
to a struct buf. In the 6th edition sources, as printed in Lions
Book, struct buf looks like this:
.DS
-.ft C
+.ft CW
.ps -1
struct buf
{
@@ -95,7 +95,7 @@ aspect and only a few fields relate exclusively to the cache aspect.
If we step forward to the BSD 4.4-Lite-2 release, struct buf has grown
a bit here or there:
.DS
-.ft C
+.ft CW
.ps -1
struct buf {
LIST_ENTRY(buf) b_hash; /* Hash chain. */
@@ -144,7 +144,7 @@ aspect, link buffers to the VM system, provide hacks for file-systems
.PP
By the time we get to FreeBSD 3.0 more stuff has grown on struct buf:
.DS
-.ft C
+.ft CW
.ps -1
struct buf {
LIST_ENTRY(buf) b_hash; /* Hash chain. */
@@ -215,7 +215,7 @@ and Vinum. They all basically do the same: they map I/O requests from
a logical space to a physical space, and the mappings they perform
can be 1:1 or 1:N. \**
.FS
-It is interesting to note that Lions in his comments to the \fCrkaddr\fP
+It is interesting to note that Lions in his comments to the \f(CW.)rkaddr\fP
routine (p. 16-2) writes \fIThe code in this procedure incorporates
a special feature for files which extend over more than one disk
drive. This feature is described in the UPM Section "RK(IV)". Its
@@ -258,7 +258,7 @@ limited extent diskslice/label, which
need only the I/O aspect, not the vnode, caching or VM linkage.
.IP
.I
-The I/O aspect of struct buf should be put in a separate \fCstruct bio\fP.
+The I/O aspect of struct buf should be put in a separate \f(CW.)struct bio\fP.
.R
.NH 1
Implications for future struct buf improvements
@@ -296,7 +296,7 @@ Anything that could be added to or done with
the I/O aspect of struct buf can also be added to or done
with the I/O aspect if it lives in a new "struct bio".
.NH 1
-Implementing a \fCstruct bio\fP
+Implementing a \f(CW.)struct bio\fP
.PP
The first decision to be made was who got to use the name "struct buf",
and considering the fact that it is the I/O aspect which gets separated
@@ -344,7 +344,7 @@ Definition of struct bio
.PP
With the cleanup of b_flags in place, the definition of struct bio looks like this:
.DS
-.ft C
+.ft CW
.ps -1
struct bio {
u_int bio_cmd; /* I/O operation. */
@@ -375,7 +375,7 @@ Definition of struct buf
After adding a struct bio to struct buf and the fields aliased into it
struct buf looks like this:
.DS
-.ft C
+.ft CW
.ps -1
struct buf {
/* XXX: b_io must be the first element of struct buf for now /phk */
@@ -424,7 +424,7 @@ And can be found at http://phk.freebsd.dk/misc
.FE
and consists mainly of systematic substitutions like these
.DS
-.ft C
+.ft CW
s/struct buf/struct bio/
s/b_flags/bio_flags/
s/b_bcount/bio_bcount/
diff --git a/share/doc/papers/hwpmc/Makefile b/share/doc/papers/hwpmc/Makefile
deleted file mode 100644
index d24fe06..0000000
--- a/share/doc/papers/hwpmc/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# $FreeBSD$
-
-VOLUME= papers
-DOC= hwpmc
-SRCS= hwpmc.ms
-MACROS= -ms
-
-.include <bsd.doc.mk>
diff --git a/share/doc/papers/hwpmc/hwpmc.ms b/share/doc/papers/hwpmc/hwpmc.ms
deleted file mode 100644
index 9061bb7..0000000
--- a/share/doc/papers/hwpmc/hwpmc.ms
+++ /dev/null
@@ -1,34 +0,0 @@
-.\" Copyright (c) 2004 Joseph Koshy.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY JOSEPH KOSHY AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL JOSEPH KOSHY OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD$
-.\"
-.OH '''Using Hardware Performance Monitoring Counters'
-.EH 'HWPMC'''
-.TL
-Using Hardware Performance Monitoring Counters in FreeBSD
-.sp
-\s-2FreeBSD 5.2.1\s+2
-.sp
-\fRJuly, 2004\fR
-.PP
diff --git a/share/doc/usd/06.bc/bc b/share/doc/usd/06.bc/bc
index c4e68c6..4d87f2c 100644
--- a/share/doc/usd/06.bc/bc
+++ b/share/doc/usd/06.bc/bc
@@ -36,12 +36,13 @@
.\" @(#)bc 6.2 (Berkeley) 4/17/91
.\"
.if n \{\
-.po 5n
-.ll 70n
+.nr PO 5n
+.nr LL 70n
.\}
.EH 'USD:6-%''BC \- An Arbitrary Precision Desk-Calculator Language'
.OH 'BC \- An Arbitrary Precision Desk-Calculator Language''USD:6-%'
.\".RP
+.ND
.TL
BC \- An Arbitrary Precision Desk-Calculator Language
.AU
diff --git a/share/doc/usd/10.exref/exref/ex.rm b/share/doc/usd/10.exref/exref/ex.rm
index 217bad4..9adde17 100644
--- a/share/doc/usd/10.exref/exref/ex.rm
+++ b/share/doc/usd/10.exref/exref/ex.rm
@@ -30,11 +30,13 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)ex.rm 8.5 (Berkeley) 8/18/96
+.\" $FreeBSD$
.\"
.nr LL 6.5i
.nr FL 6.5i
.EH 'USD:12-%''Ex Reference Manual'
.OH 'Ex Reference Manual''USD:12-%'
+.ND
.nr )P 0
.de ZP
.nr pd \\n()P
diff --git a/share/doc/usd/18.msdiffs/ms.diffs b/share/doc/usd/18.msdiffs/ms.diffs
index 3bd8de6..de937af 100644
--- a/share/doc/usd/18.msdiffs/ms.diffs
+++ b/share/doc/usd/18.msdiffs/ms.diffs
@@ -37,6 +37,7 @@
.AM
.OH 'A Revised Version of \*ms''USD:18-%'
.EH 'USD:18-%''A Revised Version of \*ms'
+.ND
.TL
A Revised Version of \*ms
.AU
diff --git a/share/doc/usd/22.trofftut/tt00 b/share/doc/usd/22.trofftut/tt00
index f8c5ea7..cb893ff 100644
--- a/share/doc/usd/22.trofftut/tt00
+++ b/share/doc/usd/22.trofftut/tt00
@@ -46,6 +46,7 @@
.OH 'A TROFF Tutorial''USD:22-%'
.\".RP
.\" .....TM 76-1273-7 39199 39199-11
+.ND
.TL
A TROFF Tutorial
.AU "MH 2C-518" 6021
diff --git a/share/doc/usd/contents/contents.ms b/share/doc/usd/contents/contents.ms
index f18d046..03fde20 100644
--- a/share/doc/usd/contents/contents.ms
+++ b/share/doc/usd/contents/contents.ms
@@ -35,6 +35,7 @@
..
.OH '''USD Contents'
.EH 'USD Contents'''
+.ND
.TL
UNIX User's Supplementary Documents (USD)
.if !r.U .nr .U 0
diff --git a/share/dtrace/siftr b/share/dtrace/siftr
new file mode 100755
index 0000000..d12d35f
--- /dev/null
+++ b/share/dtrace/siftr
@@ -0,0 +1,68 @@
+#!/usr/sbin/dtrace -s
+/*-
+ * Copyright (c) 2015 George V. Neville-Neil
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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$
+ *
+ * The siftr D script collects data from the SIFTR kernel module.
+ *
+ * Usage: siftr
+ */
+
+#pragma D option quiet
+tcp:kernel::siftr
+{
+ printf("direction %s state %s local %d remote %d\n",
+ siftr_dir_string[args[0]->direction],
+ tcp_state_string[args[0]->conn_state],
+ args[0]->tcp_localport,
+ args[0]->tcp_foreignport);
+ printf("snd_cwnd %d snd_wnd %d rcv_wnd %d snd_bwnd %d snd_ssthresh %d\n",
+ args[0]->snd_cwnd,
+ args[0]->snd_wnd,
+ args[0]->rcv_wnd,
+ args[0]->snd_bwnd,
+ args[0]->snd_ssthresh);
+ printf("\tmax_seg_size %u smoothed_rtt %d sack_enabled %d\n",
+ args[0]->max_seg_size,
+ args[0]->smoothed_rtt,
+ args[0]->sack_enabled);
+ printf("\tsnd_scale %d rcv_scale %d flags 0x%x rxt_length %d\n",
+ args[0]->snd_scale,
+ args[0]->rcv_scale,
+ args[0]->flags,
+ args[0]->rxt_length);
+ printf("\tsnd_buf_hiwater %u snd_buf_cc %u rcv_buf_hiwater %u\n",
+ args[0]->snd_buf_hiwater,
+ args[0]->snd_buf_cc,
+ args[0]->rcv_buf_hiwater);
+ printf("\trcv_buf_cc %u sent_inflight_bytes %u t_segqlen %d\n",
+ args[0]->rcv_buf_cc,
+ args[0]->sent_inflight_bytes,
+ args[0]->t_segqlen);
+ printf("\tflowid %u flowtype %u\n",
+ args[0]->flowid,
+ args[0]->flowtype);
+}
diff --git a/share/man/man3/pthread_getspecific.3 b/share/man/man3/pthread_getspecific.3
index d59003f..3657e13 100644
--- a/share/man/man3/pthread_getspecific.3
+++ b/share/man/man3/pthread_getspecific.3
@@ -64,6 +64,11 @@ is undefined.
The
.Fn pthread_getspecific
function may be called from a thread-specific data destructor function.
+A call to
+.Fn pthread_getspecific
+for the thread-specific data key being destroyed returns the value NULL,
+unless the value is changed (after the destructor starts) by a call to
+.Fn pthread_setspecific .
.Sh RETURN VALUES
The
.Fn pthread_getspecific
diff --git a/share/man/man4/acpi.4 b/share/man/man4/acpi.4
index 17cf1cb..8c221be 100644
--- a/share/man/man4/acpi.4
+++ b/share/man/man4/acpi.4
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 23, 2014
+.Dd May 9, 2015
.Dt ACPI 4
.Os
.Sh NAME
@@ -69,14 +69,12 @@ them (such as
Enable dumping Debug objects without
.Cd "options ACPI_DEBUG" .
Default is 0, ignore Debug objects.
-.It Va hw.acpi.acline
-AC line state (1 means online, 0 means on battery power).
-.It Va hw.acpi.cpu.cx_usage
+.It Va dev.cpu.N.cx_usage
Debugging information listing the percent of total usage for each sleep state.
The values are reset when
-.Va hw.acpi.cpu.cx_lowest
+.Va dev.cpu.N.cx_lowest
is modified.
-.It Va hw.acpi.cpu.cx_lowest
+.It Va dev.cpu.N.cx_lowest
Lowest Cx state to use for idling the CPU.
A scheduling algorithm will select states between
.Li C1
@@ -111,6 +109,11 @@ semantics as the
state.
Deeper sleeps provide more power savings but increased transition
latency when an interrupt occurs.
+.It Va dev.cpu.N.cx_method
+List of supported CPU idle states and their transition methods, as
+directed by the firmware.
+.It Va hw.acpi.acline
+AC line state (1 means online, 0 means on battery power).
.It Va hw.acpi.disable_on_reboot
Disable ACPI during the reboot process.
Most systems reboot fine with ACPI still enabled, but some require
@@ -374,6 +377,14 @@ typically as a child of a PCI bus.
.Pq Vt device
Supports an ACPI laptop lid switch, which typically puts a
system to sleep.
+.It Li mwait
+.Pq Vt feature
+Do not ask firmware for available x86-vendor specific methods to enter
+.Li Cx
+sleep states.
+Only query and use the generic I/O-based entrance method.
+The knob is provided to work around inconsistencies in the tables
+filled by firmware.
.It Li quirks
.Pq Vt feature
Do not honor quirks.
diff --git a/share/man/man4/ctl.4 b/share/man/man4/ctl.4
index a04f2fe..49d98a0 100644
--- a/share/man/man4/ctl.4
+++ b/share/man/man4/ctl.4
@@ -23,7 +23,7 @@
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD$
-.Dd April 8, 2015
+.Dd May 22, 2015
.Dt CTL 4
.Os
.Sh NAME
@@ -84,6 +84,22 @@ All I/O handled in-kernel, no userland context switch overhead
.El
.Pp
It also serves as a kernel component of the native iSCSI target.
+.Sh SYSCTL VARIABLES
+The following variables are available as both
+.Xr sysctl 8
+variables and
+.Xr loader 8
+tunables:
+.Bl -tag -width indent
+.It Va kern.cam.ctl.iscsi.maxcmdsn_delta
+The number of outstanding commands to advertise to the initiator.
+Technically, it's the difference between ExpCmdSN and MaxCmdSN fields
+in the iSCSI PDU.
+.It Va kern.cam.ctl.iscsi.ping_timeout
+The number of seconds to wait for the initiator to respond to a NOP-In
+PDU.
+In the event that there is no response within that time the session gets
+forcibly terminated.
.Sh SEE ALSO
.Xr ctladm 8 ,
.Xr ctld 8 ,
diff --git a/share/man/man4/iic.4 b/share/man/man4/iic.4
index d82f574..a650c8d 100644
--- a/share/man/man4/iic.4
+++ b/share/man/man4/iic.4
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 24, 2014
+.Dd May 15, 2015
.Dt IIC 4
.Os
.Sh NAME
@@ -54,10 +54,12 @@ element to the bus.
The
.Va slave
element consists of a 7-bit address and a read/write bit
-(i.e., 7-bit address << 1 | r/w).
-If the read/write bit is set a read operation is initiated, if the read/write
-bit is cleared a write operation is initiated.
+(that is, a 7-bit address << 1 | r/w).
+A read operation is initiated when the read/write bit is set, or a write
+operation when it is cleared.
All other elements are ignored.
+If successful, the file descriptor receives exclusive
+ownership of the underlying iicbus instance.
.It Dv I2CRPTSTART
.Pq Vt "struct iiccmd"
Sends the repeated start condition to the slave specified by the
@@ -66,19 +68,33 @@ element to the bus.
The slave address should be specified as in
.Dv I2CSTART .
All other elements are ignored.
+.Dv I2CSTART
+must have previously been issued on the same file descriptor.
.It Dv I2CSTOP
No argument is passed.
Sends the stop condition to the bus.
-This terminates the current transaction.
+If
+.Dv I2CSTART
+was previously issued on the file descriptor, the current transaction is
+terminated and exclusive ownership of the underlying iicbus instance is
+released.
+Otherwise, no action is performed.
.It Dv I2CRSTCARD
.Pq Vt "struct iiccmd"
Resets the bus.
The argument is completely ignored.
+This command does not require
+.Dv I2CSTART
+to have been previously issued on the file descriptor.
+If it was previously issued, exclusive ownership of the underlying iicbus
+instance is released.
.It Dv I2CWRITE
.Pq Vt "struct iiccmd"
Writes data to the
.Xr iicbus 4 .
-The bus should already be started.
+The bus must already be started by a previous
+.Dv I2CSTART
+on the file descriptor.
The
.Va slave
element is ignored.
@@ -96,7 +112,9 @@ element is a pointer to the data to write to the bus.
.Pq Vt "struct iiccmd"
Reads data from the
.Xr iicbus 4 .
-The bus should already be started.
+The bus must already be started by a previous
+.Dv I2CSTART
+on the file descriptor.
The
.Va slave
element is ignored.
@@ -116,6 +134,15 @@ Short reads on the bus produce undefined results.
Generic read/write interface.
Allows for an arbitrary number of commands to be sent to
an arbitrary number of devices on the bus.
+Any previous transaction started by
+.Dv I2CSTART
+must be terminated by
+.Dv I2CSTOP
+or
+.Dv I2CRSTCARD
+before
+.Dv I2CRDWR
+can be issued on the same file descriptor.
A read transfer is specified if
.Dv IIC_M_RD
is set in
@@ -138,6 +165,17 @@ element is a buffer for that data.
This ioctl is intended to be
.Tn Linux
compatible.
+.It Dv I2CSADDR
+.Pq Vt "uint8_t"
+Associate the specified address with the file descriptor for use by
+subsequent
+.Xr read 2
+or
+.Xr write 2
+calls.
+The argument is an 8-bit address (that is, a 7-bit address << 1).
+The read/write bit in the least-significant position is ignored.
+Any subsequent read or write operation will set or clear that bit as needed.
.El
.Pp
The following data structures are defined in
@@ -156,7 +194,10 @@ struct iic_msg
{
uint16_t slave;
uint16_t flags;
-#define IIC_M_RD 0x0001 /* read vs write */
+#define IIC_M_WR 0 /* Fake flag for write */
+#define IIC_M_RD 0x0001 /* read vs write */
+#define IIC_M_NOSTOP 0x0002 /* do not send a I2C stop after message */
+#define IIC_M_NOSTART 0x0004 /* do not send a I2C start before message */
uint16_t len; /* msg length */
uint8_t * buf;
};
@@ -167,15 +208,37 @@ struct iic_rdwr_data {
};
.Ed
.Pp
-It is also possible to use read/write routines, then I2C start/stop handshake is
-managed by the
-.Xr iicbus 4
-system.
-However, the address used for the read/write routines is the one
-passed to last
+It is also possible to use
+.Xr read 2
+or
+.Xr write 2 ,
+in which case the I2C start/stop handshake is managed by
+.Xr iicbus 4 .
+The address used for the read/write operation is the one passed to the most
+recent
.Dv I2CSTART
.Xr ioctl 2
-to this device.
+or
+.Dv I2CSADDR
+.Xr ioctl 2
+on the open
+.Pa /dev/iic?
+file descriptor.
+Closing the file descriptor clears any addressing state established by a
+previous
+.Dv I2CSTART
+or
+.Dv I2CSADDR ,
+stops any transaction established by a not-yet-terminated
+.Dv I2CSTART ,
+and releases iicbus ownership.
+Because addressing state is stored on a per-file-descriptor basis, it is
+permissible for multiple file descriptors to be simultaneously open on the
+same
+.Pa /dev/iic?
+device.
+Concurrent transactions on those descriptors are synchronized by the
+exclusive-ownership requests issued to the underlying iicbus instance.
.Sh SEE ALSO
.Xr ioctl 2 ,
.Xr read 2 ,
@@ -193,9 +256,3 @@ manual page was written by
.An Nicolas Souchu
and
.An M. Warner Losh .
-.Sh BUGS
-Only the
-.Dv I2CRDWR
-.Xr ioctl 2
-is thread safe.
-All other interfaces suffer from some kind of race.
diff --git a/share/man/man4/usb_quirk.4 b/share/man/man4/usb_quirk.4
index 9352e76..d7686fd 100644
--- a/share/man/man4/usb_quirk.4
+++ b/share/man/man4/usb_quirk.4
@@ -16,7 +16,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 21, 2013
+.Dd May 7, 2015
.Dt USB_QUIRK 4
.Os
.Sh NAME
@@ -170,6 +170,9 @@ ejects after Huawei SCSI command
.It UQ_MSC_EJECT_TCT
ejects after TCT SCSI command
.Dv 0x06f504025270
+.It UQ_MSC_DYMO_EJECT
+ejects after HID command
+.Dv 0x1b5a01
.El
.Pp
See
diff --git a/share/man/man4/xen.4 b/share/man/man4/xen.4
index 83b3d12..c2b1f5b 100644
--- a/share/man/man4/xen.4
+++ b/share/man/man4/xen.4
@@ -28,24 +28,16 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 17, 2010
+.Dd April 30, 2015
.Dt XEN 4
.Os
.Sh NAME
.Nm xen
.Nd Xen Hypervisor Guest (DomU) Support
.Sh SYNOPSIS
-To compile para-virtualized (PV) Xen guest support into an i386 kernel, place
-the following lines in your kernel configuration file:
-.Bd -ragged -offset indent
-.Cd "options PAE"
-.Cd "options XEN"
-.Cd "nooptions NATIVE"
-.Ed
-.Pp
To compile hardware-assisted virtualization (HVM) Xen guest support with
-para-virtualized drivers into an amd64 kernel, place the following lines in
-your kernel configuration file:
+para-virtualized drivers into an amd64 or i386 kernel,
+place the following lines in your kernel configuration file:
.Bd -ragged -offset indent
.Cd "options XENHVM"
.Cd "device xenpci"
@@ -69,34 +61,14 @@ and hence able to optimize certain behaviors to improve performance or
semantics.
.Pp
.Fx
-supports a fully para-virtualized (PV) kernel on the i386 architecture using
-.Cd "options XEN"
-and
-.Cd "nooptions NATIVE" ;
-currently, this requires use of a PAE kernel, enabled via
-.Cd "options PAE" .
-.Pp
-.Fx
-supports hardware-assisted virtualization (HVM) on both the i386 and amd64
-kernels; however, PV device drivers with an HVM kernel are only supported on
-the amd64 architecture, and require
-.Cd "options XENHVM"
-and
-.Cd "device xenpci" .
+supports hardware-assisted virtualization (HVM) on both i386 and amd64
+kernels.
.Pp
Para-virtualized device drivers are required in order to support certain
functionality, such as processing management requests, returning idle
physical memory pages to the hypervisor, etc.
.Ss Xen DomU device drivers
-Xen para-virtualized drivers are automatically added to the kernel if a PV
-kernel is compiled using
-.Cd "options XEN" ;
-for HVM environments,
-.Cd "options XENHVM"
-and
-.Cd "device xenpci"
-are required.
-The follow drivers are supported:
+These para-virtualized drivers are supported:
.Bl -hang -offset indent -width blkfront
.It Nm balloon
Allow physical memory pages to be returned to the hypervisor as a result of
@@ -148,8 +120,6 @@ It is recommended that adaptive locking be disabled when using Xen:
.Cd "options NO_ADAPTIVE_RWLOCKS"
.Cd "options NO_ADAPTIVE_SX"
.Ed
-.Sh SEE ALSO
-.Xr pae 4
.Sh HISTORY
Support for
.Nm
@@ -173,12 +143,6 @@ This manual page was written by
.Fx
is only able to run as a Xen guest (DomU) and not as a Xen host (Dom0).
.Pp
-A fully para-virtualized (PV) kernel is only supported on i386, and not
-amd64.
-.Pp
-Para-virtualized drivers under hardware-assisted virtualization (HVM) kernel
-are only supported on amd64, not i386.
-.Pp
As of this release, Xen PV DomU support is not heavily tested; instability
has been reported during VM migration of PV kernels.
.Pp
diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile
index 7f79156..11dcb01 100644
--- a/share/man/man9/Makefile
+++ b/share/man/man9/Makefile
@@ -1113,7 +1113,6 @@ MLINKS+=mutex.9 mtx_assert.9 \
mutex.9 mtx_unlock_spin.9 \
mutex.9 mtx_unlock_spin_flags.9
MLINKS+=namei.9 NDFREE.9 \
- namei.9 NDHASGIANT.9 \
namei.9 NDINIT.9
MLINKS+=netisr.9 netisr_clearqdrops.9 \
netisr.9 netisr_default_flow2cpu.9 \
diff --git a/share/man/man9/namei.9 b/share/man/man9/namei.9
index 0bd827f..305665a 100644
--- a/share/man/man9/namei.9
+++ b/share/man/man9/namei.9
@@ -33,14 +33,13 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 1, 2012
+.Dd May 6, 2015
.Dt NAMEI 9
.Os
.Sh NAME
.Nm namei ,
.Nm NDINIT ,
.Nm NDFREE ,
-.Nm NDHASGIANT
.Nd pathname translation and lookup operations
.Sh SYNOPSIS
.In sys/param.h
@@ -55,8 +54,6 @@
.Fc
.Ft void
.Fn NDFREE "struct nameidata *ndp" "const uint flags"
-.Ft int
-.Fn NDHASGIANT "struct nameidata *ndp"
.Sh DESCRIPTION
The
.Nm
@@ -73,16 +70,6 @@ or
depending on whether the
.Dv LOCKLEAF
flag was specified or not.
-If the
-.Va Giant
-lock is required,
-.Nm
-will acquire it if the caller indicates it is
-.Dv MPSAFE ,
-in which case the caller must later release
-.Va Giant
-based on the results of
-.Fn NDHASGIANT .
.Pp
The
.Fn NDINIT
@@ -362,6 +349,3 @@ In order to solve this for the cases where both
and
.Dv LOCKLEAF
are used, it is necessary to resort to recursive locking.
-.Pp
-Non-MPSAFE file systems exist, requiring callers to conditionally unlock
-.Va Giant .
diff --git a/share/man/man9/psignal.9 b/share/man/man9/psignal.9
index 4193bcb..aa17032 100644
--- a/share/man/man9/psignal.9
+++ b/share/man/man9/psignal.9
@@ -33,6 +33,7 @@
.Os
.Sh NAME
.Nm psignal ,
+.Nm kern_psignal ,
.Nm pgsignal ,
.Nm gsignal ,
.Nm tdsignal
@@ -41,7 +42,7 @@
.In sys/types.h
.In sys/signalvar.h
.Ft void
-.Fn psignal "struct proc *p" "int signum"
+.Fn kern_psignal "struct proc *p" "int signum"
.Ft void
.Fn pgsignal "struct pgrp *pgrp" "int signum" "int checkctty"
.Ft void
@@ -56,16 +57,22 @@ common to all three functions should be in the range
.Bq 1- Ns Dv NSIG .
.Pp
The
-.Fn psignal
+.Fn kern_psignal
function posts signal number
.Fa signum
to the process represented by the process structure
.Fa p .
+The
+.Fn kern_psignal
+function used to be called
+.Fn psignal
+but was renamed in order to eliminate a name collision with the libc
+function of that name and facilitate code reuse.
With a few exceptions noted below, the target process signal disposition is
updated and is marked as runnable, so further handling of the signal is done
in the context of the target process after a context switch.
Note that
-.Fn psignal
+.Fn kern_psignal
does not by itself cause a context switch to happen.
.Pp
The target process is not marked as runnable in the following cases:
@@ -91,7 +98,7 @@ regardless of the signal action
.El
.Pp
If the target process is being traced
-.Fn psignal
+.Fn kern_psignal
behaves as if the target process were taking the default action for
.Fa signum .
This allows the tracing process to be notified of the signal.
@@ -113,7 +120,7 @@ of the process group structure
pointed at by
.Fa pgrp
and calling
-.Fn psignal
+.Fn kern_psignal
as appropriate.
If
.Fa pgrp
@@ -149,3 +156,10 @@ to the thread represented by the thread structure
.Xr sigaction 2 ,
.Xr signal 9 ,
.Xr tsleep 9
+.Sh HISTORY
+The
+.Fn psignal
+function was renamed to
+.Fn kern_psignal
+in
+.Fx 9.0 .
diff --git a/share/misc/bsd-family-tree b/share/misc/bsd-family-tree
index 7df15cc..0bf1113 100644
--- a/share/misc/bsd-family-tree
+++ b/share/misc/bsd-family-tree
@@ -321,8 +321,15 @@ FreeBSD 5.2 | | | |
| FreeBSD | | | |
| 10.1 | | | DragonFly 4.0.1
| | | | |
+ | | | | DragonFly 4.0.2
| | | | |
+ | | | | DragonFly 4.0.3
| | | | |
+ | | | | DragonFly 4.0.4
+ | | | | |
+ | | | | DragonFly 4.0.5
+ | | | | |
+ | | | OpenBSD 5.7 |
| | | | |
| | | | |
FreeBSD 11 -current | NetBSD -current OpenBSD -current DragonFly -current
@@ -655,11 +662,16 @@ DragonFly 3.8.1 2014-06-16 [DFB]
DragonFly 3.6.3 2014-06-17 [DFB]
FreeBSD 9.3 2014-07-05 [FBD]
DragonFly 3.8.2 2014-08-08 [DFB]
-NetBSD 6.1.5 2014-09-22 [NDB]
+NetBSD 6.1.5 2014-09-22 [NBD]
Mac OS X 10.10 2014-10-16 [APL]
OpenBSD 5.6 2014-11-01 [OBD]
FreeBSD 10.1 2014-11-14 [FBD]
DragonFly 4.0.1 2014-11-25 [DFB]
+DragonFly 4.0.2 2015-01-07 [DFB]
+DragonFly 4.0.3 2015-01-21 [DFB]
+DragonFly 4.0.4 2015-03-09 [DFB]
+DragonFly 4.0.5 2015-03-23 [DFB]
+OpenBSD 5.7 2015-05-01 [OBD]
Bibliography
------------------------
@@ -679,6 +691,10 @@ McKusick, Marshall Kirk, George Neville-Neil. The Design and
Implementation of the FreeBSD Operating System.
Addison-Wesley Professional, Published: Aug 2, 2004. ISBN 0-201-70245-2
+McKusick, Marshall Kirk, George Neville-Neil, Robert Watson. The
+Design and Implementation of the FreeBSD Operating System, 2nd Edition.
+Pearson Education, Inc., 2014. ISBN 0-321-96897-2
+
Doug McIlroy. Research Unix Reader.
Michael G. Brown. The Role of BSD in the Development of Unix.
diff --git a/share/misc/committers-src.dot b/share/misc/committers-src.dot
index 98ea817..9af30b7 100644
--- a/share/misc/committers-src.dot
+++ b/share/misc/committers-src.dot
@@ -240,6 +240,7 @@ np [label="Navdeep Parhar\nnp@FreeBSD.org\n2009/06/05"]
nwhitehorn [label="Nathan Whitehorn\nnwhitehorn@FreeBSD.org\n2008/07/03"]
obrien [label="David E. O'Brien\nobrien@FreeBSD.org\n1996/10/29"]
olli [label="Oliver Fromme\nolli@FreeBSD.org\n2008/02/14"]
+oshogbo [label="Mariusz Zaborski\noshogbo@FreeBSD.org\n2015/04/15"]
peadar [label="Peter Edwards\npeadar@FreeBSD.org\n2004/03/08"]
peter [label="Peter Wemm\npeter@FreeBSD.org\n1995/07/04"]
peterj [label="Peter Jeremy\npeterj@FreeBSD.org\n2012/09/14"]
@@ -633,6 +634,7 @@ phk -> mux
pjd -> kib
pjd -> lulf
+pjd -> oshogbo
pjd -> smh
pjd -> trociny
diff --git a/share/mk/atf.test.mk b/share/mk/atf.test.mk
index 23ec836..bef87bd 100644
--- a/share/mk/atf.test.mk
+++ b/share/mk/atf.test.mk
@@ -72,11 +72,10 @@ MAN.${_T}?= # empty
SRCS.${_T}?= ${_T}.c
DPADD.${_T}+= ${LIBATF_C}
.if empty(LDFLAGS:M-static) && empty(LDFLAGS.${_T}:M-static)
-LDADD.${_T}+= ${LDATF_C}
+LDADD.${_T}+= ${LDADD_atf_c}
.else
LDADD.${_T}+= ${LIBATF_C}
.endif
-USEPRIVATELIB+= atf-c
TEST_INTERFACE.${_T}= atf
.endfor
.endif
@@ -90,11 +89,10 @@ MAN.${_T}?= # empty
SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc}
DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
.if empty(LDFLAGS:M-static) && empty(LDFLAGS.${_T}:M-static)
-LDADD.${_T}+= ${LDATF_CXX} ${LDATF_C}
+LDADD.${_T}+= ${LDADD_atf_cxx} ${LDADD_atf_c}
.else
LDADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
.endif
-USEPRIVATELIB+= atf-c++
TEST_INTERFACE.${_T}= atf
.endfor
.endif
diff --git a/share/mk/bsd.incs.mk b/share/mk/bsd.incs.mk
index a7e7683..cc65baf 100644
--- a/share/mk/bsd.incs.mk
+++ b/share/mk/bsd.incs.mk
@@ -23,7 +23,7 @@ all: buildincludes
${group}OWN?= ${BINOWN}
${group}GRP?= ${BINGRP}
${group}MODE?= ${NOBINMODE}
-${group}DIR?= ${INCLUDEDIR}
+${group}DIR?= ${INCLUDEDIR}${PRIVATELIB:D/private/${LIB}}
_${group}INCS=
.for header in ${${group}}
diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
index 2d0eb00..2c8ab36 100644
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -11,6 +11,7 @@ _LD= ${CXX}
_LD= ${CC}
.endif
+LIB_PRIVATE= ${PRIVATELIB:Dprivate}
# Set up the variables controlling shared libraries. After this section,
# SHLIB_NAME will be defined only if we are to create a shared library.
# SHLIB_LINK will be defined only if we are to create a link to it.
@@ -23,7 +24,7 @@ _LD= ${CC}
SHLIB= ${LIB}
.endif
.if !defined(SHLIB_NAME) && defined(SHLIB) && defined(SHLIB_MAJOR)
-SHLIB_NAME= lib${SHLIB}.so.${SHLIB_MAJOR}
+SHLIB_NAME= lib${LIB_PRIVATE}${SHLIB}.so.${SHLIB_MAJOR}
.endif
.if defined(SHLIB_NAME) && !empty(SHLIB_NAME:M*.so.*)
SHLIB_LINK?= ${SHLIB_NAME:R}
@@ -128,13 +129,8 @@ PO_FLAG=-pg
all: beforebuild .WAIT
beforebuild: objwarn
-.if defined(PRIVATELIB)
-_LIBDIR:=${LIBPRIVATEDIR}
-_SHLIBDIR:=${LIBPRIVATEDIR}
-.else
_LIBDIR:=${LIBDIR}
_SHLIBDIR:=${SHLIBDIR}
-.endif
.if defined(SHLIB_NAME)
.if ${MK_DEBUG_FILES} != "no"
@@ -162,19 +158,15 @@ ${SHLIB_NAME_FULL}: ${VERSION_MAP}
LDFLAGS+= -Wl,--version-script=${VERSION_MAP}
.endif
-.if defined(USEPRIVATELIB)
-LDFLAGS+= -rpath ${LIBPRIVATEDIR}
-.endif
-
.if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME)
OBJS+= ${SRCS:N*.h:R:S/$/.o/}
NOPATH_FILES+= ${OBJS}
.endif
.if defined(LIB) && !empty(LIB)
-_LIBS= lib${LIB}.a
+_LIBS= lib${LIB_PRIVATE}${LIB}.a
-lib${LIB}.a: ${OBJS} ${STATICOBJS}
+lib${LIB_PRIVATE}${LIB}.a: ${OBJS} ${STATICOBJS}
@${ECHO} building static ${LIB} library
@rm -f ${.TARGET}
@${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
@@ -184,11 +176,11 @@ lib${LIB}.a: ${OBJS} ${STATICOBJS}
.if !defined(INTERNALLIB)
.if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
-_LIBS+= lib${LIB}_p.a
+_LIBS+= lib${LIB_PRIVATE}${LIB}_p.a
POBJS+= ${OBJS:.o=.po} ${STATICOBJS:.o=.po}
NOPATH_FILES+= ${POBJS}
-lib${LIB}_p.a: ${POBJS}
+lib${LIB_PRIVATE}${LIB}_p.a: ${POBJS}
@${ECHO} building profiled ${LIB} library
@rm -f ${.TARGET}
@${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' lorder ${POBJS} | tsort -q` ${ARADD}
@@ -243,9 +235,9 @@ ${SHLIB_NAME}.debug: ${SHLIB_NAME_FULL}
.endif #defined(SHLIB_NAME)
.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
-_LIBS+= lib${LIB}_pic.a
+_LIBS+= lib${LIB_PRIVATE}${LIB}_pic.a
-lib${LIB}_pic.a: ${SOBJS}
+lib${LIB_PRIVATE}${LIB}_pic.a: ${SOBJS}
@${ECHO} building special pic ${LIB} library
@rm -f ${.TARGET}
@${AR} ${ARFLAGS} ${.TARGET} ${SOBJS} ${ARADD}
@@ -305,13 +297,13 @@ _SHLINSTALLFLAGS:= ${_SHLINSTALLFLAGS${ie}}
realinstall: _libinstall
.ORDER: beforeinstall _libinstall
_libinstall:
-.if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no" && !defined(PRIVATELIB)
+.if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
- ${_INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${_LIBDIR}
+ ${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}.a ${DESTDIR}${_LIBDIR}
.endif
-.if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB) && !defined(PRIVATELIB)
+.if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
- ${_INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${_LIBDIR}
+ ${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}_p.a ${DESTDIR}${_LIBDIR}
.endif
.if defined(SHLIB_NAME)
${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
@@ -325,7 +317,7 @@ _libinstall:
${_INSTALLFLAGS} \
${SHLIB_NAME}.debug ${DESTDIR}${DEBUGFILEDIR}
.endif
-.if defined(SHLIB_LINK) && !defined(PRIVATELIB)
+.if defined(SHLIB_LINK)
# ${_SHLIBDIRPREFIX} and ${_LDSCRIPTROOT} are both needed when cross-building
# and when building 32 bits library shims. ${_SHLIBDIRPREFIX} is the directory
# prefix where shared objects will be installed by the install target.
@@ -366,7 +358,7 @@ _libinstall:
.endif # SHLIB_LDSCRIPT
.endif # SHLIB_LINK
.endif # SHIB_NAME
-.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no" && !defined(PRIVATELIB)
+.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${_LIBDIR}
.endif
diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk
index 3fb70d1..8366ade 100644
--- a/share/mk/bsd.prog.mk
+++ b/share/mk/bsd.prog.mk
@@ -51,10 +51,6 @@ STRIP?= -s
LDFLAGS+= -static
.endif
-.if defined(USEPRIVATELIB)
-LDFLAGS+= -L${_SHLIBDIRPREFIX}${LIBPRIVATEDIR} -rpath ${LIBPRIVATEDIR}
-.endif
-
.if ${MK_DEBUG_FILES} != "no"
PROG_FULL=${PROG}.full
# Use ${DEBUGDIR} for base system debug files, else .debug subdirectory
diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk
index 512ad2f..181bbb4 100644
--- a/share/mk/src.libnames.mk
+++ b/share/mk/src.libnames.mk
@@ -15,6 +15,7 @@ _PRIVATELIBS= \
atf_c \
atf_cxx \
bsdstat \
+ event \
heimipcc \
heimipcs \
ldns \
@@ -23,16 +24,14 @@ _PRIVATELIBS= \
ucl \
unbound
-_INTERNALIBS= \
+_INTERNALLIBS= \
amu \
bsnmptools \
cron \
elftc \
- event \
fifolog \
ipf \
lpr \
- mandoc \
netbsd \
ntp \
ntpevent \
@@ -49,7 +48,7 @@ _INTERNALIBS= \
_LIBRARIES= \
${_PRIVATELIBS} \
- ${_INTERNALIBS} \
+ ${_INTERNALLIBS} \
alias \
archive \
asn1 \
@@ -78,6 +77,7 @@ _LIBRARIES= \
devstat \
dialog \
dpv \
+ dtrace \
dwarf \
edit \
elf \
@@ -107,7 +107,6 @@ _LIBRARIES= \
lzma \
m \
magic \
- mandoc \
md \
memstat \
mp \
@@ -133,6 +132,7 @@ _LIBRARIES= \
rpcsec_gss \
rpcsvc \
rt \
+ rtld_db \
sbuf \
sdp \
sm \
@@ -230,21 +230,31 @@ _DP_gssapi_krb5+= gssapi krb5 crypto roken asn1 com_err
_DP_lzma= pthread
_DP_ucl= m
_DP_vmmapi= util
+_DP_ctf= z
+_DP_proc= rtld_db util
+_DP_dtrace= rtld_db pthread
# Define spacial cases
LDADD_supcplusplus= -lsupc++
-LDADD_atf_c= -L${LIBATF_CDIR} -latf-c
-LDADD_atf_cxx= -L${LIBATF_CXXDIR} -latf-c++
+LIBATF_C= ${DESTDIR}${LIBDIR}/libprivateatf-c.a
+LIBATF_CXX= ${DESTDIR}${LIBDIR}/libprivateatf-c++.a
+LDADD_atf_c= -lprivateatf-c
+LDADD_atf_cxx= -lprivateatf-c++
+
+.for _l in ${_PRIVATELIBS}
+LIB${_l:tu}?= ${DESTDIR}${LIBDIR}/libprivate${_l}.a
+.endfor
.for _l in ${_LIBRARIES}
-.if ${_PRIVATELIBS:M${_l}}
-LDADD_${_l}_L+= -L${LIB${_l:tu}DIR}
-.endif
-.if ${_INTERNALIBS:M${_l}}
+.if ${_INTERNALLIBS:M${_l}}
LDADD_${_l}_L+= -L${LIB${_l:tu}DIR}
.endif
DPADD_${_l}?= ${LIB${_l:tu}}
+.if ${_PRIVATELIBS:M${_l}}
+LDADD_${_l}?= -lprivate${_l}
+.else
LDADD_${_l}?= ${LDADD_${_l}_L} -l${_l}
+.endif
.if defined(_DP_${_l}) && defined(NO_SHARED)
.for _d in ${_DP_${_l}}
DPADD_${_l}+= ${DPADD_${_d}}
@@ -253,12 +263,12 @@ LDADD_${_l}+= ${LDADD_${_d}}
.endif
.endfor
-DPADD_sqlite3+= ${DPADD_pthread}
-LDADD_sqlite3+= ${LDADD_pthread}
-
DPADD_atf_cxx+= ${DPADD_atf_c}
LDADD_atf_cxx+= ${LDADD_atf_c}
+DPADD_sqlite3+= ${DPADD_pthread}
+LDADD_sqlite3+= ${LDADD_pthread}
+
DPADD_fifolog+= ${DPADD_z}
LDADD_fifolog+= ${LDADD_z}
@@ -268,6 +278,9 @@ LDADD_ipf+= ${LDADD_kvm}
DPADD_mt+= ${DPADD_sbuf}
LDADD_mt+= ${LDADD_sbuf}
+DPADD_dtrace+= ${DPADD_ctf} ${DPADD_elf} ${DPADD_proc}
+LDADD_dtrace+= ${LDADD_ctf} ${LDADD_elf} ${LDADD_proc}
+
# The following depends on libraries which are using pthread
DPADD_hdb+= ${DPADD_pthread}
LDADD_hdb+= ${LDADD_pthread}
@@ -290,58 +303,15 @@ LDADD+= ${LDADD_${_l}}
.error Missing ${DPADD:Mmissing-dpadd_*:S/missing-dpadd_//:S/^/DPADD_/} variable add "${DPADD:Mmissing-dpadd_*:S/missing-dpadd_//}" to _LIBRARIES, _INTERNALLIBS, or _PRIVATELIBS and define "${DPADD:Mmissing-dpadd_*:S/missing-dpadd_//:S/^/LIB/:tu}".
.endif
-.if defined(USEPRIVATELIB)
-LDFLAGS+= -rpath ${LIBPRIVATEDIR}
-.endif
-
-LIBATF_CDIR= ${ROOTOBJDIR}/lib/atf/libatf-c
-LDATF_C?= ${LIBATF_CDIR}/libatf-c.so
-LIBATF_C?= ${LIBATF_CDIR}/libatf-c.a
-
-LIBATF_CXXDIR= ${ROOTOBJDIR}/lib/atf/libatf-c++
-LDATF_CXX?= ${LIBATF_CXXDIR}/libatf-c++.so
-LIBATF_CXX?= ${LIBATF_CXXDIR}/libatf-c++.a
-
-LIBBSDSTATDIR= ${ROOTOBJDIR}/lib/libbsdstat
-LIBBSDSTAT?= ${LIBBSDSTATDIR}/libbsdstat.a
-
LIBELFTCDIR= ${ROOTOBJDIR}/lib/libelftc
-LDELFTC?= ${LIBELFTCDIR}/libelftc.a
LIBELFTC?= ${LIBELFTCDIR}/libelftc.a
-LIBEVENTDIR= ${ROOTOBJDIR}/lib/libevent
-LIBEVENT?= ${LIBEVENTDIR}/libevent.a
-
-LIBHEIMIPCCDIR= ${ROOTOBJDIR}/kerberos5/lib/libheimipcc
-LIBHEIMIPCC?= ${LIBHEIMIPCCDIR}/libheimipcc.a
-
-LIBHEIMIPCSDIR= ${ROOTOBJDIR}/kerberos5/lib/libheimipcs
-LIBHEIMIPCS?= ${LIBHEIMIPCSDIR}/libheimipcs.a
-
-LIBLDNSDIR= ${ROOTOBJDIR}/lib/libldns
-LIBLDNS?= ${LIBLDNSDIR}/libldns.a
-
-LIBSSHDIR= ${ROOTOBJDIR}/secure/lib/libssh
-LIBSSH?= ${LIBSSHDIR}/libssh.a
-
-LIBUNBOUNDDIR= ${ROOTOBJDIR}/lib/libunbound
-LIBUNBOUND?= ${LIBUNBOUNDDIR}/libunbound.a
-
-LIBUCLDIR= ${ROOTOBJDIR}/lib/libucl
-LIBUCL?= ${LIBUCLDIR}/libucl.a
-
LIBREADLINEDIR= ${ROOTOBJDIR}/gnu/lib/libreadline/readline
LIBREADLINE?= ${LIBREADLINEDIR}/libreadline.a
LIBOHASHDIR= ${ROOTOBJDIR}/lib/libohash
LIBOHASH?= ${LIBOHASHDIR}/libohash.a
-LIBSQLITE3DIR= ${ROOTOBJDIR}/lib/libsqlite3
-LIBSQLITE3?= ${LIBSQLITE3DIR}/libsqlite3.a
-
-LIBMANDOCDIR= ${ROOTOBJDIR}/lib/libmandoc
-LIBMANDOC?= ${LIBMANDOCDIR}/libmandoc.a
-
LIBSMDIR= ${ROOTOBJDIR}/lib/libsm
LIBSM?= ${LIBSMDIR}/libsm.a
@@ -373,7 +343,7 @@ LIBNTPDIR= ${ROOTOBJDIR}/usr.sbin/ntp/libntp
LIBNTP?= ${LIBNTPDIR}/libntp.a
LIBNTPEVENTDIR= ${ROOTOBJDIR}/usr.sbin/ntp/libntpevent
-LIBNTPEVENT?= ${LIBNTPDIR}/libntpevent.a
+LIBNTPEVENT?= ${LIBNTPEVENTDIR}/libntpevent.a
LIBOPTSDIR= ${ROOTOBJDIR}/usr.sbin/ntp/libopts
LIBOTPS?= ${LIBOPTSDIR}/libopts.a
diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk
index 278f87a..6e18874 100644
--- a/share/mk/src.opts.mk
+++ b/share/mk/src.opts.mk
@@ -233,7 +233,7 @@ __DEFAULT_YES_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX
__DEFAULT_NO_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC
.endif
.if ${__T} == "aarch64"
-BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GDB
+BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GCC GCC_BOOTSTRAP GDB
.endif
# LLVM lacks support for FreeBSD 64-bit atomic operations for ARMv4/ARMv5
.if ${__T} == "arm" || ${__T} == "armeb"
diff --git a/share/syscons/keymaps/INDEX.keymaps b/share/syscons/keymaps/INDEX.keymaps
index 221bf5a..d8ca736 100644
--- a/share/syscons/keymaps/INDEX.keymaps
+++ b/share/syscons/keymaps/INDEX.keymaps
@@ -123,7 +123,7 @@ danish.cp865.kbd:fr:Danois Code page 865
danish.cp865.kbd:pt:Dinamarquês Codepage 865
danish.cp865.kbd:es:Danés Codepage 865
-danish.iso.macbook.kbd:da:Danish ISO-8859-1 (macbook)
+danish.iso.macbook.kbd:en:Danish ISO-8859-1 (macbook)
danish.iso.macbook.kbd:da:Dansk ISO-8859-1 (macbook)
danish.iso.macbook.kbd:de:Dänisch ISO-8859-1 (Macbook)
danish.iso.macbook.kbd:fr:Danois ISO-8859-1 (macbook)
diff --git a/share/vt/keymaps/INDEX.keymaps b/share/vt/keymaps/INDEX.keymaps
index 8a33bc8..3fac998 100644
--- a/share/vt/keymaps/INDEX.keymaps
+++ b/share/vt/keymaps/INDEX.keymaps
@@ -20,15 +20,15 @@
#
# Language support: MENU, FONT
#
-MENU:en:Choose your keyboard language
+MENU:en:Choose your keyboard layout
MENU:da,no,sv:Vælg dit keyboard layout
MENU:de:Wählen Sie Ihre Tastaturbelegung
-MENU:fr:Choisissez la nationalité de votre clavier
+MENU:fr:Choisissez la disposition de votre clavier
MENU:pl:Wybierz układ klawiatury
MENU:pt:Escolha o layout do teclado
-MENU:es:Seleccione el idioma de su teclado
-MENU::ךלש תדלקמה תפש ×ª× ×¨×—×‘
-MENU:uk:Bиберіть розкладку клавіатури
+MENU:es:Seleccione la disposición de su teclado
+MENU:he:ךלש תדלקמה תפש ×ª× ×¨×—×‘
+MENU:uk:Оберiть розкладку клавіатури
MENU:el:Επιλέξτε το πληκτÏολόγιο της κονσόλας
MENU:hy:Ô¸Õ¶Õ¿Ö€Õ¥Ö„ Õ½Õ¿Õ¥Õ²Õ¶Õ¡Õ·Õ¡Ö€Õ« Õ¤Õ¡Õ½Õ¡Õ¾Õ¸Ö€Õ¸Ö‚Õ©ÕµÕ¸Ö‚Õ¶Õ¨
@@ -121,7 +121,7 @@ dk.kbd.from-cp865:fr:Danois
dk.kbd.from-cp865:pt:Dinamarquês
dk.kbd.from-cp865:es:Danés
-dk.macbook.kbd:da:Danish (macbook)
+dk.macbook.kbd:en:Danish (macbook)
dk.macbook.kbd:da:Dansk (macbook)
dk.macbook.kbd:de:Dänisch (Macbook)
dk.macbook.kbd:fr:Danois (macbook)
@@ -517,7 +517,7 @@ uk.capsctrl.kbd:en:United Kingdom (Caps Lock acts as Left Ctrl)
uk.capsctrl.kbd:de:Vereinigtes Königreich (Caps Lock als linke Strg)
#uk.iso-ctrl.kbd:fr:Royaume Uni (caps lock acts as Left Ctrl)
#uk.iso-ctrl.kbd:pt:Reino Unido (caps lock acts as Left Ctrl)
-#uk.iso-ctrl.kbd:es:Británico (caps lock acts as Left Ctrl)
+#uk.iso-ctrl.kbd:es:Británico (caps lock acts as Left Ctrl)
uk.dvorak.kbd:en:United Kingdom Dvorak
uk.dvorak.kbd:de:Vereinigtes Königreich Dvorak
diff --git a/sys/amd64/acpica/acpi_machdep.c b/sys/amd64/acpica/acpi_machdep.c
index 049b51bb4e..8f88a00 100644
--- a/sys/amd64/acpica/acpi_machdep.c
+++ b/sys/amd64/acpica/acpi_machdep.c
@@ -87,13 +87,6 @@ acpi_machdep_quirks(int *quirks)
return (0);
}
-void
-acpi_cpu_c1()
-{
-
- __asm __volatile("sti; hlt");
-}
-
/*
* Support for mapping ACPI tables during early boot. Currently this
* uses the crashdump map to map each table. However, the crashdump
diff --git a/sys/amd64/amd64/apic_vector.S b/sys/amd64/amd64/apic_vector.S
index c3aac33..a1279e6 100644
--- a/sys/amd64/amd64/apic_vector.S
+++ b/sys/amd64/amd64/apic_vector.S
@@ -174,14 +174,28 @@ IDTVEC(xen_intr_upcall)
jmp doreti
#endif
+#ifdef HYPERV
+/*
+ * This is the Hyper-V vmbus channel direct callback interrupt.
+ * Only used when it is running on Hyper-V.
+ */
+ .text
+ SUPERALIGN_TEXT
+IDTVEC(hv_vmbus_callback)
+ PUSH_FRAME
+ FAKE_MCOUNT(TF_RIP(%rsp))
+ movq %rsp, %rdi
+ call hv_vector_handler
+ MEXITCOUNT
+ jmp doreti
+#endif
+
#ifdef SMP
/*
* Global address space TLB shootdown.
*/
.text
-#define NAKE_INTR_CS 24
-
SUPERALIGN_TEXT
invltlb_ret:
call as_lapic_eoi
@@ -189,30 +203,28 @@ invltlb_ret:
jmp doreti_iret
SUPERALIGN_TEXT
+IDTVEC(invltlb)
+ PUSH_FRAME
+
+ call invltlb_handler
+ jmp invltlb_ret
+
IDTVEC(invltlb_pcid)
PUSH_FRAME
call invltlb_pcid_handler
jmp invltlb_ret
-
- SUPERALIGN_TEXT
-IDTVEC(invltlb)
+IDTVEC(invltlb_invpcid)
PUSH_FRAME
- call invltlb_handler
+ call invltlb_invpcid_handler
jmp invltlb_ret
/*
* Single page TLB shootdown
*/
.text
- SUPERALIGN_TEXT
-IDTVEC(invlpg_pcid)
- PUSH_FRAME
-
- call invlpg_pcid_handler
- jmp invltlb_ret
SUPERALIGN_TEXT
IDTVEC(invlpg)
diff --git a/sys/amd64/amd64/cpu_switch.S b/sys/amd64/amd64/cpu_switch.S
index eb0ee8b..e292797 100644
--- a/sys/amd64/amd64/cpu_switch.S
+++ b/sys/amd64/amd64/cpu_switch.S
@@ -69,16 +69,10 @@
* %rsi = newtd
*/
ENTRY(cpu_throw)
- movl PCPU(CPUID),%eax
- testq %rdi,%rdi
- jz 1f
- /* release bit from old pm_active */
- movq PCPU(CURPMAP),%rdx
- LK btrl %eax,PM_ACTIVE(%rdx) /* clear old */
-1:
- movq TD_PCB(%rsi),%r8 /* newtd->td_pcb */
- movq PCB_CR3(%r8),%rcx /* new address space */
- jmp swact
+ movq %rsi,%r12
+ movq %rsi,%rdi
+ call pmap_activate_sw
+ jmp sw1
END(cpu_throw)
/*
@@ -132,59 +126,20 @@ ctx_switch_xsave:
xorl %eax,%eax
movq %rax,PCPU(FPCURTHREAD)
3:
-
/* Save is done. Now fire up new thread. Leave old vmspace. */
- movq TD_PCB(%rsi),%r8
-
- /* switch address space */
- movq PCB_CR3(%r8),%rcx
- movq %cr3,%rax
- cmpq %rcx,%rax /* Same address space? */
- jne swinact
- SETLK %rdx, TD_LOCK(%rdi) /* Release the old thread */
- jmp sw1
-swinact:
- movl PCPU(CPUID),%eax
- /* Release bit from old pmap->pm_active */
- movq PCPU(CURPMAP),%r12
- LK btrl %eax,PM_ACTIVE(%r12) /* clear old */
- SETLK %rdx,TD_LOCK(%rdi) /* Release the old thread */
-swact:
- /* Set bit in new pmap->pm_active */
- movq TD_PROC(%rsi),%rdx /* newproc */
- movq P_VMSPACE(%rdx), %rdx
- addq $VM_PMAP,%rdx
- cmpl $-1,PM_PCID(%rdx)
- je 1f
- LK btsl %eax,PM_SAVE(%rdx)
- jnc 1f
- btsq $63,%rcx /* CR3_PCID_SAVE */
- incq PCPU(PM_SAVE_CNT)
-1:
- movq %rcx,%cr3 /* new address space */
- LK btsl %eax,PM_ACTIVE(%rdx) /* set new */
- movq %rdx,PCPU(CURPMAP)
-
- /*
- * We might lose the race and other CPU might have changed
- * the pmap after we set our bit in pmap->pm_save. Recheck.
- * Reload %cr3 with CR3_PCID_SAVE bit cleared if pmap was
- * modified, causing TLB flush for this pcid.
- */
- btrq $63,%rcx
- jnc 1f
- LK btsl %eax,PM_SAVE(%rdx)
- jc 1f
- decq PCPU(PM_SAVE_CNT)
- movq %rcx,%cr3
-1:
-
+ movq %rsi,%r12
+ movq %rdi,%r13
+ movq %rdx,%r15
+ movq %rsi,%rdi
+ callq pmap_activate_sw
+ SETLK %r15,TD_LOCK(%r13) /* Release the old thread */
sw1:
+ movq TD_PCB(%r12),%r8
#if defined(SCHED_ULE) && defined(SMP)
/* Wait for the new thread to become unblocked */
movq $blocked_lock, %rdx
1:
- movq TD_LOCK(%rsi),%rcx
+ movq TD_LOCK(%r12),%rcx
cmpq %rcx, %rdx
pause
je 1b
@@ -195,13 +150,13 @@ sw1:
*/
/* Skip loading user fsbase/gsbase for kthreads */
- testl $TDP_KTHREAD,TD_PFLAGS(%rsi)
+ testl $TDP_KTHREAD,TD_PFLAGS(%r12)
jnz do_kthread
/*
* Load ldt register
*/
- movq TD_PROC(%rsi),%rcx
+ movq TD_PROC(%r12),%rcx
cmpq $0, P_MD+MD_LDT(%rcx)
jne do_ldt
xorl %eax,%eax
@@ -238,7 +193,7 @@ done_tss:
movq %r8,PCPU(CURPCB)
/* Update the TSS_RSP0 pointer for the next interrupt */
movq %r8,COMMON_TSS_RSP0(%rdx)
- movq %rsi,PCPU(CURTHREAD) /* into next thread */
+ movq %r12,PCPU(CURTHREAD) /* into next thread */
/* Test if debug registers should be restored. */
testl $PCB_DBREGS,PCB_FLAGS(%r8)
diff --git a/sys/amd64/amd64/db_disasm.c b/sys/amd64/amd64/db_disasm.c
index 50da76b..dd436d7 100644
--- a/sys/amd64/amd64/db_disasm.c
+++ b/sys/amd64/amd64/db_disasm.c
@@ -1223,9 +1223,7 @@ db_disasm_esc(loc, inst, rex, short_addr, size, seg)
* next instruction.
*/
db_addr_t
-db_disasm(loc, altfmt)
- db_addr_t loc;
- boolean_t altfmt;
+db_disasm(db_addr_t loc, bool altfmt)
{
int inst;
int size;
diff --git a/sys/amd64/amd64/genassym.c b/sys/amd64/amd64/genassym.c
index 3ffefc0..11012c4 100644
--- a/sys/amd64/amd64/genassym.c
+++ b/sys/amd64/amd64/genassym.c
@@ -71,8 +71,6 @@ __FBSDID("$FreeBSD$");
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(PM_SAVE, offsetof(struct pmap, pm_save));
-ASSYM(PM_PCID, offsetof(struct pmap, pm_pcid));
ASSYM(P_MD, offsetof(struct proc, p_md));
ASSYM(MD_LDT, offsetof(struct mdproc, md_ldt));
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index 3230937..7cd58b1 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -1718,7 +1718,6 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
/* setup proc 0's pcb */
thread0.td_pcb->pcb_flags = 0;
- thread0.td_pcb->pcb_cr3 = KPML4phys; /* PCID 0 is reserved for kernel */
thread0.td_frame = &proc0_tf;
env = kern_getenv("kernelname");
diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c
index 83ca548..e91e6d5 100644
--- a/sys/amd64/amd64/mp_machdep.c
+++ b/sys/amd64/amd64/mp_machdep.c
@@ -88,12 +88,9 @@ char *doublefault_stack;
char *nmi_stack;
/* Variables needed for SMP tlb shootdown. */
-vm_offset_t smp_tlb_addr2;
-struct invpcid_descr smp_tlb_invpcid;
+static vm_offset_t smp_tlb_addr1, smp_tlb_addr2;
+static pmap_t smp_tlb_pmap;
volatile int smp_tlb_wait;
-uint64_t pcid_cr3;
-pmap_t smp_tlb_pmap;
-extern int invpcid_works;
extern inthand_t IDTVEC(fast_syscall), IDTVEC(fast_syscall32);
@@ -139,14 +136,17 @@ cpu_mp_start(void)
/* Install an inter-CPU IPI for TLB invalidation */
if (pmap_pcid_enabled) {
- setidt(IPI_INVLTLB, IDTVEC(invltlb_pcid), SDT_SYSIGT,
- SEL_KPL, 0);
- setidt(IPI_INVLPG, IDTVEC(invlpg_pcid), SDT_SYSIGT,
- SEL_KPL, 0);
+ if (invpcid_works) {
+ setidt(IPI_INVLTLB, IDTVEC(invltlb_invpcid),
+ SDT_SYSIGT, SEL_KPL, 0);
+ } else {
+ setidt(IPI_INVLTLB, IDTVEC(invltlb_pcid), SDT_SYSIGT,
+ SEL_KPL, 0);
+ }
} else {
setidt(IPI_INVLTLB, IDTVEC(invltlb), SDT_SYSIGT, SEL_KPL, 0);
- setidt(IPI_INVLPG, IDTVEC(invlpg), SDT_SYSIGT, SEL_KPL, 0);
}
+ setidt(IPI_INVLPG, IDTVEC(invlpg), SDT_SYSIGT, SEL_KPL, 0);
setidt(IPI_INVLRNG, IDTVEC(invlrng), SDT_SYSIGT, SEL_KPL, 0);
/* Install an inter-CPU IPI for cache invalidation. */
@@ -242,6 +242,9 @@ init_secondary(void)
pc->pc_gs32p = &gdt[NGDT * cpu + GUGS32_SEL];
pc->pc_ldt = (struct system_segment_descriptor *)&gdt[NGDT * cpu +
GUSERLDT_SEL];
+ pc->pc_curpmap = kernel_pmap;
+ pc->pc_pcid_gen = 1;
+ pc->pc_pcid_next = PMAP_PCID_KERN + 1;
/* Save the per-cpu pointer for use by the NMI handler. */
np->np_pcpu = (register_t) pc;
@@ -407,35 +410,8 @@ start_ap(int apic_id)
}
/*
- * Flush the TLB on all other CPU's
+ * Flush the TLB on other CPU's
*/
-static void
-smp_tlb_shootdown(u_int vector, pmap_t pmap, vm_offset_t addr1,
- vm_offset_t addr2)
-{
- u_int ncpu;
-
- ncpu = mp_ncpus - 1; /* does not shootdown self */
- if (ncpu < 1)
- return; /* no other cpus */
- if (!(read_rflags() & PSL_I))
- panic("%s: interrupts disabled", __func__);
- mtx_lock_spin(&smp_ipi_mtx);
- smp_tlb_invpcid.addr = addr1;
- if (pmap == NULL) {
- smp_tlb_invpcid.pcid = 0;
- } else {
- smp_tlb_invpcid.pcid = pmap->pm_pcid;
- pcid_cr3 = pmap->pm_cr3;
- }
- smp_tlb_addr2 = addr2;
- smp_tlb_pmap = pmap;
- atomic_store_rel_int(&smp_tlb_wait, 0);
- ipi_all_but_self(vector);
- while (smp_tlb_wait < ncpu)
- ia32_pause();
- mtx_unlock_spin(&smp_ipi_mtx);
-}
static void
smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector, pmap_t pmap,
@@ -443,7 +419,11 @@ smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector, pmap_t pmap,
{
int cpu, ncpu, othercpus;
- othercpus = mp_ncpus - 1;
+ othercpus = mp_ncpus - 1; /* does not shootdown self */
+
+ /*
+ * Check for other cpus. Return if none.
+ */
if (CPU_ISFULLSET(&mask)) {
if (othercpus < 1)
return;
@@ -452,16 +432,11 @@ smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector, pmap_t pmap,
if (CPU_EMPTY(&mask))
return;
}
+
if (!(read_rflags() & PSL_I))
panic("%s: interrupts disabled", __func__);
mtx_lock_spin(&smp_ipi_mtx);
- smp_tlb_invpcid.addr = addr1;
- if (pmap == NULL) {
- smp_tlb_invpcid.pcid = 0;
- } else {
- smp_tlb_invpcid.pcid = pmap->pm_pcid;
- pcid_cr3 = pmap->pm_cr3;
- }
+ smp_tlb_addr1 = addr1;
smp_tlb_addr2 = addr2;
smp_tlb_pmap = pmap;
atomic_store_rel_int(&smp_tlb_wait, 0);
@@ -485,65 +460,39 @@ smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector, pmap_t pmap,
}
void
-smp_invlpg(pmap_t pmap, vm_offset_t addr)
-{
-
- if (smp_started) {
- smp_tlb_shootdown(IPI_INVLPG, pmap, addr, 0);
-#ifdef COUNT_XINVLTLB_HITS
- ipi_page++;
-#endif
- }
-}
-
-void
-smp_invlpg_range(pmap_t pmap, vm_offset_t addr1, vm_offset_t addr2)
-{
-
- if (smp_started) {
- smp_tlb_shootdown(IPI_INVLRNG, pmap, addr1, addr2);
-#ifdef COUNT_XINVLTLB_HITS
- ipi_range++;
- ipi_range_size += (addr2 - addr1) / PAGE_SIZE;
-#endif
- }
-}
-
-void
smp_masked_invltlb(cpuset_t mask, pmap_t pmap)
{
if (smp_started) {
smp_targeted_tlb_shootdown(mask, IPI_INVLTLB, pmap, 0, 0);
#ifdef COUNT_XINVLTLB_HITS
- ipi_masked_global++;
+ ipi_global++;
#endif
}
}
void
-smp_masked_invlpg(cpuset_t mask, pmap_t pmap, vm_offset_t addr)
+smp_masked_invlpg(cpuset_t mask, vm_offset_t addr)
{
if (smp_started) {
- smp_targeted_tlb_shootdown(mask, IPI_INVLPG, pmap, addr, 0);
+ smp_targeted_tlb_shootdown(mask, IPI_INVLPG, NULL, addr, 0);
#ifdef COUNT_XINVLTLB_HITS
- ipi_masked_page++;
+ ipi_page++;
#endif
}
}
void
-smp_masked_invlpg_range(cpuset_t mask, pmap_t pmap, vm_offset_t addr1,
- vm_offset_t addr2)
+smp_masked_invlpg_range(cpuset_t mask, vm_offset_t addr1, vm_offset_t addr2)
{
if (smp_started) {
- smp_targeted_tlb_shootdown(mask, IPI_INVLRNG, pmap, addr1,
- addr2);
+ smp_targeted_tlb_shootdown(mask, IPI_INVLRNG, NULL,
+ addr1, addr2);
#ifdef COUNT_XINVLTLB_HITS
- ipi_masked_range++;
- ipi_masked_range_size += (addr2 - addr1) / PAGE_SIZE;
+ ipi_range++;
+ ipi_range_size += (addr2 - addr1) / PAGE_SIZE;
#endif
}
}
@@ -552,19 +501,9 @@ void
smp_cache_flush(void)
{
- if (smp_started)
- smp_tlb_shootdown(IPI_INVLCACHE, NULL, 0, 0);
-}
-
-void
-smp_invltlb(pmap_t pmap)
-{
-
if (smp_started) {
- smp_tlb_shootdown(IPI_INVLTLB, pmap, 0, 0);
-#ifdef COUNT_XINVLTLB_HITS
- ipi_global++;
-#endif
+ smp_targeted_tlb_shootdown(all_cpus, IPI_INVLCACHE, NULL,
+ 0, 0);
}
}
@@ -586,10 +525,10 @@ invltlb_handler(void)
}
void
-invltlb_pcid_handler(void)
+invltlb_invpcid_handler(void)
{
- uint64_t cr3;
- u_int cpuid;
+ struct invpcid_descr d;
+
#ifdef COUNT_XINVLTLB_HITS
xhits_gbl[PCPU_GET(cpuid)]++;
#endif /* COUNT_XINVLTLB_HITS */
@@ -597,49 +536,45 @@ invltlb_pcid_handler(void)
(*ipi_invltlb_counts[PCPU_GET(cpuid)])++;
#endif /* COUNT_IPIS */
- if (smp_tlb_invpcid.pcid != (uint64_t)-1 &&
- smp_tlb_invpcid.pcid != 0) {
- if (invpcid_works) {
- invpcid(&smp_tlb_invpcid, INVPCID_CTX);
- } else {
- /* Otherwise reload %cr3 twice. */
- cr3 = rcr3();
- if (cr3 != pcid_cr3) {
- load_cr3(pcid_cr3);
- cr3 |= CR3_PCID_SAVE;
- }
- load_cr3(cr3);
- }
- } else {
- invltlb_globpcid();
- }
- if (smp_tlb_pmap != NULL) {
- cpuid = PCPU_GET(cpuid);
- if (!CPU_ISSET(cpuid, &smp_tlb_pmap->pm_active))
- CPU_CLR_ATOMIC(cpuid, &smp_tlb_pmap->pm_save);
- }
-
+ d.pcid = smp_tlb_pmap->pm_pcids[PCPU_GET(cpuid)].pm_pcid;
+ d.pad = 0;
+ d.addr = 0;
+ invpcid(&d, smp_tlb_pmap == kernel_pmap ? INVPCID_CTXGLOB :
+ INVPCID_CTX);
atomic_add_int(&smp_tlb_wait, 1);
}
void
-invlpg_handler(void)
+invltlb_pcid_handler(void)
{
#ifdef COUNT_XINVLTLB_HITS
- xhits_pg[PCPU_GET(cpuid)]++;
+ xhits_gbl[PCPU_GET(cpuid)]++;
#endif /* COUNT_XINVLTLB_HITS */
#ifdef COUNT_IPIS
- (*ipi_invlpg_counts[PCPU_GET(cpuid)])++;
+ (*ipi_invltlb_counts[PCPU_GET(cpuid)])++;
#endif /* COUNT_IPIS */
- invlpg(smp_tlb_invpcid.addr);
+ if (smp_tlb_pmap == kernel_pmap) {
+ invltlb_globpcid();
+ } else {
+ /*
+ * The current pmap might not be equal to
+ * smp_tlb_pmap. The clearing of the pm_gen in
+ * pmap_invalidate_all() takes care of TLB
+ * invalidation when switching to the pmap on this
+ * CPU.
+ */
+ if (PCPU_GET(curpmap) == smp_tlb_pmap) {
+ load_cr3(smp_tlb_pmap->pm_cr3 |
+ smp_tlb_pmap->pm_pcids[PCPU_GET(cpuid)].pm_pcid);
+ }
+ }
atomic_add_int(&smp_tlb_wait, 1);
}
void
-invlpg_pcid_handler(void)
+invlpg_handler(void)
{
- uint64_t cr3;
#ifdef COUNT_XINVLTLB_HITS
xhits_pg[PCPU_GET(cpuid)]++;
#endif /* COUNT_XINVLTLB_HITS */
@@ -647,45 +582,15 @@ invlpg_pcid_handler(void)
(*ipi_invlpg_counts[PCPU_GET(cpuid)])++;
#endif /* COUNT_IPIS */
- if (smp_tlb_invpcid.pcid == (uint64_t)-1) {
- invltlb_globpcid();
- } else if (smp_tlb_invpcid.pcid == 0) {
- invlpg(smp_tlb_invpcid.addr);
- } else if (invpcid_works) {
- invpcid(&smp_tlb_invpcid, INVPCID_ADDR);
- } else {
- /*
- * PCID supported, but INVPCID is not.
- * Temporarily switch to the target address
- * space and do INVLPG.
- */
- cr3 = rcr3();
- if (cr3 != pcid_cr3)
- load_cr3(pcid_cr3 | CR3_PCID_SAVE);
- invlpg(smp_tlb_invpcid.addr);
- load_cr3(cr3 | CR3_PCID_SAVE);
- }
-
+ invlpg(smp_tlb_addr1);
atomic_add_int(&smp_tlb_wait, 1);
}
-static inline void
-invlpg_range(vm_offset_t start, vm_offset_t end)
-{
-
- do {
- invlpg(start);
- start += PAGE_SIZE;
- } while (start < end);
-}
-
void
invlrng_handler(void)
{
- struct invpcid_descr d;
vm_offset_t addr;
- uint64_t cr3;
- u_int cpuid;
+
#ifdef COUNT_XINVLTLB_HITS
xhits_rng[PCPU_GET(cpuid)]++;
#endif /* COUNT_XINVLTLB_HITS */
@@ -693,38 +598,11 @@ invlrng_handler(void)
(*ipi_invlrng_counts[PCPU_GET(cpuid)])++;
#endif /* COUNT_IPIS */
- addr = smp_tlb_invpcid.addr;
- if (pmap_pcid_enabled) {
- if (smp_tlb_invpcid.pcid == 0) {
- /*
- * kernel pmap - use invlpg to invalidate
- * global mapping.
- */
- invlpg_range(addr, smp_tlb_addr2);
- } else if (smp_tlb_invpcid.pcid == (uint64_t)-1) {
- invltlb_globpcid();
- if (smp_tlb_pmap != NULL) {
- cpuid = PCPU_GET(cpuid);
- if (!CPU_ISSET(cpuid, &smp_tlb_pmap->pm_active))
- CPU_CLR_ATOMIC(cpuid,
- &smp_tlb_pmap->pm_save);
- }
- } else if (invpcid_works) {
- d = smp_tlb_invpcid;
- do {
- invpcid(&d, INVPCID_ADDR);
- d.addr += PAGE_SIZE;
- } while (d.addr <= smp_tlb_addr2);
- } else {
- cr3 = rcr3();
- if (cr3 != pcid_cr3)
- load_cr3(pcid_cr3 | CR3_PCID_SAVE);
- invlpg_range(addr, smp_tlb_addr2);
- load_cr3(cr3 | CR3_PCID_SAVE);
- }
- } else {
- invlpg_range(addr, smp_tlb_addr2);
- }
+ addr = smp_tlb_addr1;
+ do {
+ invlpg(addr);
+ addr += PAGE_SIZE;
+ } while (addr < smp_tlb_addr2);
atomic_add_int(&smp_tlb_wait, 1);
}
diff --git a/sys/amd64/amd64/mp_watchdog.c b/sys/amd64/amd64/mp_watchdog.c
index b03d261..f6b853a 100644
--- a/sys/amd64/amd64/mp_watchdog.c
+++ b/sys/amd64/amd64/mp_watchdog.c
@@ -85,7 +85,7 @@ static void
watchdog_init(void *arg)
{
- callout_init(&watchdog_callout, CALLOUT_MPSAFE);
+ callout_init(&watchdog_callout, 1);
if (watchdog_cpu != -1)
watchdog_change(watchdog_cpu);
}
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index dc823fa..118bb34 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -273,6 +273,8 @@ pmap_modified_bit(pmap_t pmap)
return (mask);
}
+extern struct pcpu __pcpu[];
+
#if !defined(DIAGNOSTIC)
#ifdef __GNUC_GNU_INLINE__
#define PMAP_INLINE __attribute__((__gnu_inline__)) inline
@@ -379,8 +381,6 @@ caddr_t CADDR1 = 0;
static int pmap_flags = PMAP_PDE_SUPERPAGE; /* flags for x86 pmaps */
-static struct unrhdr pcid_unr;
-static struct mtx pcid_mtx;
int pmap_pcid_enabled = 0;
SYSCTL_INT(_vm_pmap, OID_AUTO, pcid_enabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH,
&pmap_pcid_enabled, 0, "Is TLB Context ID enabled ?");
@@ -827,6 +827,7 @@ pmap_bootstrap(vm_paddr_t *firstaddr)
{
vm_offset_t va;
pt_entry_t *pte;
+ int i;
/*
* Create an initial set of page tables to run the kernel in.
@@ -861,7 +862,6 @@ pmap_bootstrap(vm_paddr_t *firstaddr)
kernel_pmap->pm_pml4 = (pdp_entry_t *)PHYS_TO_DMAP(KPML4phys);
kernel_pmap->pm_cr3 = KPML4phys;
CPU_FILL(&kernel_pmap->pm_active); /* don't allow deactivation */
- CPU_FILL(&kernel_pmap->pm_save); /* always superset of pm_active */
TAILQ_INIT(&kernel_pmap->pm_pvchunk);
kernel_pmap->pm_flags = pmap_flags;
@@ -895,18 +895,24 @@ pmap_bootstrap(vm_paddr_t *firstaddr)
/* Initialize TLB Context Id. */
TUNABLE_INT_FETCH("vm.pmap.pcid_enabled", &pmap_pcid_enabled);
if ((cpu_feature2 & CPUID2_PCID) != 0 && pmap_pcid_enabled) {
- load_cr4(rcr4() | CR4_PCIDE);
- mtx_init(&pcid_mtx, "pcid", NULL, MTX_DEF);
- init_unrhdr(&pcid_unr, 1, (1 << 12) - 1, &pcid_mtx);
/* Check for INVPCID support */
invpcid_works = (cpu_stdext_feature & CPUID_STDEXT_INVPCID)
!= 0;
- kernel_pmap->pm_pcid = 0;
-#ifndef SMP
- pmap_pcid_enabled = 0;
-#endif
- } else
+ for (i = 0; i < MAXCPU; i++) {
+ kernel_pmap->pm_pcids[i].pm_pcid = PMAP_PCID_KERN;
+ kernel_pmap->pm_pcids[i].pm_gen = 1;
+ }
+ __pcpu[0].pc_pcid_next = PMAP_PCID_KERN + 1;
+ __pcpu[0].pc_pcid_gen = 1;
+ /*
+ * pcpu area for APs is zeroed during AP startup.
+ * pc_pcid_next and pc_pcid_gen are initialized by AP
+ * during pcpu setup.
+ */
+ load_cr4(rcr4() | CR4_PCIDE);
+ } else {
pmap_pcid_enabled = 0;
+ }
}
/*
@@ -1277,28 +1283,6 @@ pmap_update_pde_invalidate(pmap_t pmap, vm_offset_t va, pd_entry_t newpde)
}
#ifdef SMP
-static void
-pmap_invalidate_page_pcid(pmap_t pmap, vm_offset_t va)
-{
- struct invpcid_descr d;
- uint64_t cr3;
-
- if (invpcid_works) {
- d.pcid = pmap->pm_pcid;
- d.pad = 0;
- d.addr = va;
- invpcid(&d, INVPCID_ADDR);
- return;
- }
-
- cr3 = rcr3();
- critical_enter();
- load_cr3(pmap->pm_cr3 | CR3_PCID_SAVE);
- invlpg(va);
- load_cr3(cr3 | CR3_PCID_SAVE);
- critical_exit();
-}
-
/*
* For SMP, these functions have to use the IPI mechanism for coherence.
*
@@ -1361,8 +1345,8 @@ pmap_invalidate_ept(pmap_t pmap)
void
pmap_invalidate_page(pmap_t pmap, vm_offset_t va)
{
- cpuset_t other_cpus;
- u_int cpuid;
+ cpuset_t *mask;
+ u_int cpuid, i;
if (pmap_type_guest(pmap)) {
pmap_invalidate_ept(pmap);
@@ -1373,74 +1357,33 @@ pmap_invalidate_page(pmap_t pmap, vm_offset_t va)
("pmap_invalidate_page: invalid type %d", pmap->pm_type));
sched_pin();
- if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) {
- if (!pmap_pcid_enabled) {
- invlpg(va);
- } else {
- if (pmap->pm_pcid != -1 && pmap->pm_pcid != 0) {
- if (pmap == PCPU_GET(curpmap))
- invlpg(va);
- else
- pmap_invalidate_page_pcid(pmap, va);
- } else {
- invltlb_globpcid();
- }
- }
- smp_invlpg(pmap, va);
+ if (pmap == kernel_pmap) {
+ invlpg(va);
+ mask = &all_cpus;
} else {
cpuid = PCPU_GET(cpuid);
- other_cpus = all_cpus;
- CPU_CLR(cpuid, &other_cpus);
- if (CPU_ISSET(cpuid, &pmap->pm_active))
+ if (pmap == PCPU_GET(curpmap))
invlpg(va);
- else if (pmap_pcid_enabled) {
- if (pmap->pm_pcid != -1 && pmap->pm_pcid != 0)
- pmap_invalidate_page_pcid(pmap, va);
- else
- invltlb_globpcid();
+ else if (pmap_pcid_enabled)
+ pmap->pm_pcids[cpuid].pm_gen = 0;
+ if (pmap_pcid_enabled) {
+ CPU_FOREACH(i) {
+ if (cpuid != i)
+ pmap->pm_pcids[i].pm_gen = 0;
+ }
}
- if (pmap_pcid_enabled)
- CPU_AND(&other_cpus, &pmap->pm_save);
- else
- CPU_AND(&other_cpus, &pmap->pm_active);
- if (!CPU_EMPTY(&other_cpus))
- smp_masked_invlpg(other_cpus, pmap, va);
+ mask = &pmap->pm_active;
}
+ smp_masked_invlpg(*mask, va);
sched_unpin();
}
-static void
-pmap_invalidate_range_pcid(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
-{
- struct invpcid_descr d;
- uint64_t cr3;
- vm_offset_t addr;
-
- if (invpcid_works) {
- d.pcid = pmap->pm_pcid;
- d.pad = 0;
- for (addr = sva; addr < eva; addr += PAGE_SIZE) {
- d.addr = addr;
- invpcid(&d, INVPCID_ADDR);
- }
- return;
- }
-
- cr3 = rcr3();
- critical_enter();
- load_cr3(pmap->pm_cr3 | CR3_PCID_SAVE);
- for (addr = sva; addr < eva; addr += PAGE_SIZE)
- invlpg(addr);
- load_cr3(cr3 | CR3_PCID_SAVE);
- critical_exit();
-}
-
void
pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
{
- cpuset_t other_cpus;
+ cpuset_t *mask;
vm_offset_t addr;
- u_int cpuid;
+ u_int cpuid, i;
if (pmap_type_guest(pmap)) {
pmap_invalidate_ept(pmap);
@@ -1451,55 +1394,36 @@ pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
("pmap_invalidate_range: invalid type %d", pmap->pm_type));
sched_pin();
- if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) {
- if (!pmap_pcid_enabled) {
- for (addr = sva; addr < eva; addr += PAGE_SIZE)
- invlpg(addr);
- } else {
- if (pmap->pm_pcid != -1 && pmap->pm_pcid != 0) {
- if (pmap == PCPU_GET(curpmap)) {
- for (addr = sva; addr < eva;
- addr += PAGE_SIZE)
- invlpg(addr);
- } else {
- pmap_invalidate_range_pcid(pmap,
- sva, eva);
- }
- } else {
- invltlb_globpcid();
- }
- }
- smp_invlpg_range(pmap, sva, eva);
+ cpuid = PCPU_GET(cpuid);
+ if (pmap == kernel_pmap) {
+ for (addr = sva; addr < eva; addr += PAGE_SIZE)
+ invlpg(addr);
+ mask = &all_cpus;
} else {
- cpuid = PCPU_GET(cpuid);
- other_cpus = all_cpus;
- CPU_CLR(cpuid, &other_cpus);
- if (CPU_ISSET(cpuid, &pmap->pm_active)) {
+ if (pmap == PCPU_GET(curpmap)) {
for (addr = sva; addr < eva; addr += PAGE_SIZE)
invlpg(addr);
} else if (pmap_pcid_enabled) {
- if (pmap->pm_pcid != -1 && pmap->pm_pcid != 0)
- pmap_invalidate_range_pcid(pmap, sva, eva);
- else
- invltlb_globpcid();
+ pmap->pm_pcids[cpuid].pm_gen = 0;
}
- if (pmap_pcid_enabled)
- CPU_AND(&other_cpus, &pmap->pm_save);
- else
- CPU_AND(&other_cpus, &pmap->pm_active);
- if (!CPU_EMPTY(&other_cpus))
- smp_masked_invlpg_range(other_cpus, pmap, sva, eva);
+ if (pmap_pcid_enabled) {
+ CPU_FOREACH(i) {
+ if (cpuid != i)
+ pmap->pm_pcids[i].pm_gen = 0;
+ }
+ }
+ mask = &pmap->pm_active;
}
+ smp_masked_invlpg_range(*mask, sva, eva);
sched_unpin();
}
void
pmap_invalidate_all(pmap_t pmap)
{
- cpuset_t other_cpus;
+ cpuset_t *mask;
struct invpcid_descr d;
- uint64_t cr3;
- u_int cpuid;
+ u_int cpuid, i;
if (pmap_type_guest(pmap)) {
pmap_invalidate_ept(pmap);
@@ -1510,60 +1434,42 @@ pmap_invalidate_all(pmap_t pmap)
("pmap_invalidate_all: invalid type %d", pmap->pm_type));
sched_pin();
- cpuid = PCPU_GET(cpuid);
- if (pmap == kernel_pmap ||
- (pmap_pcid_enabled && !CPU_CMP(&pmap->pm_save, &all_cpus)) ||
- !CPU_CMP(&pmap->pm_active, &all_cpus)) {
- if (invpcid_works) {
+ if (pmap == kernel_pmap) {
+ if (pmap_pcid_enabled && invpcid_works) {
bzero(&d, sizeof(d));
invpcid(&d, INVPCID_CTXGLOB);
} else {
invltlb_globpcid();
}
- if (!CPU_ISSET(cpuid, &pmap->pm_active))
- CPU_CLR_ATOMIC(cpuid, &pmap->pm_save);
- smp_invltlb(pmap);
+ mask = &all_cpus;
} else {
- other_cpus = all_cpus;
- CPU_CLR(cpuid, &other_cpus);
-
- /*
- * This logic is duplicated in the Xinvltlb shootdown
- * IPI handler.
- */
- if (pmap_pcid_enabled) {
- if (pmap->pm_pcid != -1 && pmap->pm_pcid != 0) {
+ cpuid = PCPU_GET(cpuid);
+ if (pmap == PCPU_GET(curpmap)) {
+ if (pmap_pcid_enabled) {
if (invpcid_works) {
- d.pcid = pmap->pm_pcid;
+ d.pcid = pmap->pm_pcids[cpuid].pm_pcid;
d.pad = 0;
d.addr = 0;
invpcid(&d, INVPCID_CTX);
} else {
- cr3 = rcr3();
- critical_enter();
-
- /*
- * Bit 63 is clear, pcid TLB
- * entries are invalidated.
- */
- load_cr3(pmap->pm_cr3);
- load_cr3(cr3 | CR3_PCID_SAVE);
- critical_exit();
+ load_cr3(pmap->pm_cr3 | pmap->pm_pcids
+ [PCPU_GET(cpuid)].pm_pcid);
}
} else {
- invltlb_globpcid();
+ invltlb();
}
- } else if (CPU_ISSET(cpuid, &pmap->pm_active))
- invltlb();
- if (!CPU_ISSET(cpuid, &pmap->pm_active))
- CPU_CLR_ATOMIC(cpuid, &pmap->pm_save);
- if (pmap_pcid_enabled)
- CPU_AND(&other_cpus, &pmap->pm_save);
- else
- CPU_AND(&other_cpus, &pmap->pm_active);
- if (!CPU_EMPTY(&other_cpus))
- smp_masked_invltlb(other_cpus, pmap);
+ } else if (pmap_pcid_enabled) {
+ pmap->pm_pcids[cpuid].pm_gen = 0;
+ }
+ if (pmap_pcid_enabled) {
+ CPU_FOREACH(i) {
+ if (cpuid != i)
+ pmap->pm_pcids[i].pm_gen = 0;
+ }
+ }
+ mask = &pmap->pm_active;
}
+ smp_masked_invltlb(*mask, pmap);
sched_unpin();
}
@@ -1627,7 +1533,6 @@ pmap_update_pde(pmap_t pmap, vm_offset_t va, pd_entry_t *pde, pd_entry_t newpde)
active = all_cpus;
else {
active = pmap->pm_active;
- CPU_AND_ATOMIC(&pmap->pm_save, &active);
}
if (CPU_OVERLAP(&active, &other_cpus)) {
act.store = cpuid;
@@ -1650,61 +1555,79 @@ pmap_update_pde(pmap_t pmap, vm_offset_t va, pd_entry_t *pde, pd_entry_t newpde)
#else /* !SMP */
/*
* Normal, non-SMP, invalidation functions.
- * We inline these within pmap.c for speed.
*/
-PMAP_INLINE void
+void
pmap_invalidate_page(pmap_t pmap, vm_offset_t va)
{
- switch (pmap->pm_type) {
- case PT_X86:
- if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active))
- invlpg(va);
- break;
- case PT_RVI:
- case PT_EPT:
+ if (pmap->pm_type == PT_RVI || pmap->pm_type == PT_EPT) {
pmap->pm_eptgen++;
- break;
- default:
- panic("pmap_invalidate_page: unknown type: %d", pmap->pm_type);
+ return;
}
+ KASSERT(pmap->pm_type == PT_X86,
+ ("pmap_invalidate_range: unknown type %d", pmap->pm_type));
+
+ if (pmap == kernel_pmap || pmap == PCPU_GET(curpmap))
+ invlpg(va);
+ else if (pmap_pcid_enabled)
+ pmap->pm_pcids[0].pm_gen = 0;
}
-PMAP_INLINE void
+void
pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
{
vm_offset_t addr;
- switch (pmap->pm_type) {
- case PT_X86:
- if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active))
- for (addr = sva; addr < eva; addr += PAGE_SIZE)
- invlpg(addr);
- break;
- case PT_RVI:
- case PT_EPT:
+ if (pmap->pm_type == PT_RVI || pmap->pm_type == PT_EPT) {
pmap->pm_eptgen++;
- break;
- default:
- panic("pmap_invalidate_range: unknown type: %d", pmap->pm_type);
+ return;
+ }
+ KASSERT(pmap->pm_type == PT_X86,
+ ("pmap_invalidate_range: unknown type %d", pmap->pm_type));
+
+ if (pmap == kernel_pmap || pmap == PCPU_GET(curpmap)) {
+ for (addr = sva; addr < eva; addr += PAGE_SIZE)
+ invlpg(addr);
+ } else if (pmap_pcid_enabled) {
+ pmap->pm_pcids[0].pm_gen = 0;
}
}
-PMAP_INLINE void
+void
pmap_invalidate_all(pmap_t pmap)
{
+ struct invpcid_descr d;
- switch (pmap->pm_type) {
- case PT_X86:
- if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active))
- invltlb();
- break;
- case PT_RVI:
- case PT_EPT:
+ if (pmap->pm_type == PT_RVI || pmap->pm_type == PT_EPT) {
pmap->pm_eptgen++;
- break;
- default:
- panic("pmap_invalidate_all: unknown type %d", pmap->pm_type);
+ return;
+ }
+ KASSERT(pmap->pm_type == PT_X86,
+ ("pmap_invalidate_all: unknown type %d", pmap->pm_type));
+
+ if (pmap == kernel_pmap) {
+ if (pmap_pcid_enabled && invpcid_works) {
+ bzero(&d, sizeof(d));
+ invpcid(&d, INVPCID_CTXGLOB);
+ } else {
+ invltlb_globpcid();
+ }
+ } else if (pmap == PCPU_GET(curpmap)) {
+ if (pmap_pcid_enabled) {
+ if (invpcid_works) {
+ d.pcid = pmap->pm_pcids[0].pm_pcid;
+ d.pad = 0;
+ d.addr = 0;
+ invpcid(&d, INVPCID_CTX);
+ } else {
+ load_cr3(pmap->pm_cr3 | pmap->pm_pcids[0].
+ pm_pcid);
+ }
+ } else {
+ invltlb();
+ }
+ } else if (pmap_pcid_enabled) {
+ pmap->pm_pcids[0].pm_gen = 0;
}
}
@@ -1720,10 +1643,10 @@ pmap_update_pde(pmap_t pmap, vm_offset_t va, pd_entry_t *pde, pd_entry_t newpde)
{
pmap_update_pde_store(pmap, pde, newpde);
- if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active))
+ if (pmap == kernel_pmap || pmap == PCPU_GET(curpmap))
pmap_update_pde_invalidate(pmap, va, newpde);
else
- CPU_ZERO(&pmap->pm_save);
+ pmap->pm_pcids[0].pm_gen = 0;
}
#endif /* !SMP */
@@ -2199,18 +2122,23 @@ pmap_unuse_pt(pmap_t pmap, vm_offset_t va, pd_entry_t ptepde,
void
pmap_pinit0(pmap_t pmap)
{
+ int i;
PMAP_LOCK_INIT(pmap);
pmap->pm_pml4 = (pml4_entry_t *)PHYS_TO_DMAP(KPML4phys);
pmap->pm_cr3 = KPML4phys;
pmap->pm_root.rt_root = 0;
CPU_ZERO(&pmap->pm_active);
- CPU_ZERO(&pmap->pm_save);
- PCPU_SET(curpmap, pmap);
TAILQ_INIT(&pmap->pm_pvchunk);
bzero(&pmap->pm_stats, sizeof pmap->pm_stats);
- pmap->pm_pcid = pmap_pcid_enabled ? 0 : -1;
pmap->pm_flags = pmap_flags;
+ CPU_FOREACH(i) {
+ pmap->pm_pcids[i].pm_pcid = PMAP_PCID_NONE;
+ pmap->pm_pcids[i].pm_gen = 0;
+ }
+ PCPU_SET(curpmap, kernel_pmap);
+ pmap_activate(curthread);
+ CPU_FILL(&kernel_pmap->pm_active);
}
/*
@@ -2233,7 +2161,10 @@ pmap_pinit_type(pmap_t pmap, enum pmap_type pm_type, int flags)
pml4phys = VM_PAGE_TO_PHYS(pml4pg);
pmap->pm_pml4 = (pml4_entry_t *)PHYS_TO_DMAP(pml4phys);
- pmap->pm_pcid = -1;
+ CPU_FOREACH(i) {
+ pmap->pm_pcids[i].pm_pcid = PMAP_PCID_NONE;
+ pmap->pm_pcids[i].pm_gen = 0;
+ }
pmap->pm_cr3 = ~0; /* initialize to an invalid value */
if ((pml4pg->flags & PG_ZERO) == 0)
@@ -2260,12 +2191,6 @@ pmap_pinit_type(pmap_t pmap, enum pmap_type pm_type, int flags)
/* install self-referential address mapping entry(s) */
pmap->pm_pml4[PML4PML4I] = VM_PAGE_TO_PHYS(pml4pg) |
X86_PG_V | X86_PG_RW | X86_PG_A | X86_PG_M;
-
- if (pmap_pcid_enabled) {
- pmap->pm_pcid = alloc_unr(&pcid_unr);
- if (pmap->pm_pcid != -1)
- pmap->pm_cr3 |= pmap->pm_pcid;
- }
}
pmap->pm_root.rt_root = 0;
@@ -2274,7 +2199,6 @@ pmap_pinit_type(pmap_t pmap, enum pmap_type pm_type, int flags)
bzero(&pmap->pm_stats, sizeof pmap->pm_stats);
pmap->pm_flags = flags;
pmap->pm_eptgen = 0;
- CPU_ZERO(&pmap->pm_save);
return (1);
}
@@ -2535,14 +2459,6 @@ pmap_release(pmap_t pmap)
KASSERT(CPU_EMPTY(&pmap->pm_active),
("releasing active pmap %p", pmap));
- if (pmap_pcid_enabled) {
- /*
- * Invalidate any left TLB entries, to allow the reuse
- * of the pcid.
- */
- pmap_invalidate_all(pmap);
- }
-
m = PHYS_TO_VM_PAGE(DMAP_TO_PHYS((vm_offset_t)pmap->pm_pml4));
for (i = 0; i < NKPML4E; i++) /* KVA */
@@ -2554,8 +2470,6 @@ pmap_release(pmap_t pmap)
m->wire_count--;
atomic_subtract_int(&vm_cnt.v_wire_count, 1);
vm_page_free_zero(m);
- if (pmap->pm_pcid != -1)
- free_unr(&pcid_unr, pmap->pm_pcid);
}
static int
@@ -6657,28 +6571,85 @@ retry:
return (val);
}
+static uint64_t
+pmap_pcid_alloc(pmap_t pmap, u_int cpuid)
+{
+ uint32_t gen, new_gen, pcid_next;
+
+ CRITICAL_ASSERT(curthread);
+ gen = PCPU_GET(pcid_gen);
+ if (pmap->pm_pcids[cpuid].pm_pcid == PMAP_PCID_KERN ||
+ pmap->pm_pcids[cpuid].pm_gen == gen)
+ return (CR3_PCID_SAVE);
+ pcid_next = PCPU_GET(pcid_next);
+ KASSERT(pcid_next <= PMAP_PCID_OVERMAX, ("cpu %d pcid_next %#x",
+ cpuid, pcid_next));
+ if (pcid_next == PMAP_PCID_OVERMAX) {
+ new_gen = gen + 1;
+ if (new_gen == 0)
+ new_gen = 1;
+ PCPU_SET(pcid_gen, new_gen);
+ pcid_next = PMAP_PCID_KERN + 1;
+ } else {
+ new_gen = gen;
+ }
+ pmap->pm_pcids[cpuid].pm_pcid = pcid_next;
+ pmap->pm_pcids[cpuid].pm_gen = new_gen;
+ PCPU_SET(pcid_next, pcid_next + 1);
+ return (0);
+}
+
void
-pmap_activate(struct thread *td)
+pmap_activate_sw(struct thread *td)
{
- pmap_t pmap, oldpmap;
- u_int cpuid;
+ pmap_t oldpmap, pmap;
+ uint64_t cached, cr3;
+ u_int cpuid;
- critical_enter();
- pmap = vmspace_pmap(td->td_proc->p_vmspace);
oldpmap = PCPU_GET(curpmap);
+ pmap = vmspace_pmap(td->td_proc->p_vmspace);
+ if (oldpmap == pmap)
+ return;
cpuid = PCPU_GET(cpuid);
#ifdef SMP
- CPU_CLR_ATOMIC(cpuid, &oldpmap->pm_active);
CPU_SET_ATOMIC(cpuid, &pmap->pm_active);
- CPU_SET_ATOMIC(cpuid, &pmap->pm_save);
#else
- CPU_CLR(cpuid, &oldpmap->pm_active);
CPU_SET(cpuid, &pmap->pm_active);
- CPU_SET(cpuid, &pmap->pm_save);
#endif
- td->td_pcb->pcb_cr3 = pmap->pm_cr3;
- load_cr3(pmap->pm_cr3);
+ cr3 = rcr3();
+ if (pmap_pcid_enabled) {
+ cached = pmap_pcid_alloc(pmap, cpuid);
+ KASSERT(pmap->pm_pcids[cpuid].pm_pcid >= 0 &&
+ pmap->pm_pcids[cpuid].pm_pcid < PMAP_PCID_OVERMAX,
+ ("pmap %p cpu %d pcid %#x", pmap, cpuid,
+ pmap->pm_pcids[cpuid].pm_pcid));
+ KASSERT(pmap->pm_pcids[cpuid].pm_pcid != PMAP_PCID_KERN ||
+ pmap == kernel_pmap,
+ ("non-kernel pmap thread %p pmap %p cpu %d pcid %#x",
+ td, pmap, cpuid, pmap->pm_pcids[cpuid].pm_pcid));
+ if (!cached || (cr3 & ~CR3_PCID_MASK) != pmap->pm_cr3) {
+ load_cr3(pmap->pm_cr3 | pmap->pm_pcids[cpuid].pm_pcid |
+ cached);
+ if (cached)
+ PCPU_INC(pm_save_cnt);
+ }
+ } else if (cr3 != pmap->pm_cr3) {
+ load_cr3(pmap->pm_cr3);
+ }
PCPU_SET(curpmap, pmap);
+#ifdef SMP
+ CPU_CLR_ATOMIC(cpuid, &oldpmap->pm_active);
+#else
+ CPU_CLR(cpuid, &oldpmap->pm_active);
+#endif
+}
+
+void
+pmap_activate(struct thread *td)
+{
+
+ critical_enter();
+ pmap_activate_sw(td);
critical_exit();
}
diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c
index 26ac7ab..0d03ed6 100644
--- a/sys/amd64/amd64/vm_machdep.c
+++ b/sys/amd64/amd64/vm_machdep.c
@@ -219,7 +219,6 @@ cpu_fork(td1, p2, td2, flags)
* return address on stack. These are the kernel mode register values.
*/
pmap2 = vmspace_pmap(p2->p_vmspace);
- pcb2->pcb_cr3 = pmap2->pm_cr3;
pcb2->pcb_r12 = (register_t)fork_return; /* fork_trampoline argument */
pcb2->pcb_rbp = 0;
pcb2->pcb_rsp = (register_t)td2->td_frame - sizeof(void *);
@@ -477,7 +476,6 @@ cpu_set_upcall(struct thread *td, struct thread *td0)
pcb2->pcb_rip = (register_t)fork_trampoline;
/*
* If we didn't copy the pcb, we'd need to do the following registers:
- * pcb2->pcb_cr3: cloned above.
* pcb2->pcb_dr*: cloned above.
* pcb2->pcb_savefpu: cloned above.
* pcb2->pcb_onfault: cloned above (always NULL here?).
diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC
index bdaca33..3d2cc39 100644
--- a/sys/amd64/conf/GENERIC
+++ b/sys/amd64/conf/GENERIC
@@ -73,6 +73,9 @@ options KDTRACE_FRAME # Ensure frames are compiled in
options KDTRACE_HOOKS # Kernel DTrace hooks
options DDB_CTF # Kernel ELF linker loads CTF data
options INCLUDE_CONFIG_FILE # Include this file in kernel
+options RACCT # Resource accounting framework
+options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default
+options RCTL # Resource limits
# Debugging support. Always need this:
options KDB # Enable kernel debugger support.
@@ -170,6 +173,10 @@ device mrsas # LSI/Avago MegaRAID SAS/SATA, 6Gb/s and 12Gb/s
#device pst # Promise Supertrak SX6000
device twe # 3ware ATA RAID
+# NVM Express (NVMe) support
+device nvme # base NVMe driver
+device nvd # expose NVMe namespaces as disks, depends on nvme
+
# atkbdc0 controls both the keyboard and the PS/2 mouse
device atkbdc # AT keyboard controller
device atkbd # AT keyboard
@@ -340,7 +347,9 @@ device virtio_blk # VirtIO Block device
device virtio_scsi # VirtIO SCSI device
device virtio_balloon # VirtIO Memory Balloon device
-# HyperV drivers
+# HyperV drivers and enchancement support
+# NOTE: HYPERV depends on hyperv. They must be added or removed together.
+options HYPERV # Hyper-V kernel infrastructure
device hyperv # HyperV drivers
# Xen HVM Guest Optimizations
diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES
index 9b697f0..e0fe465 100644
--- a/sys/amd64/conf/NOTES
+++ b/sys/amd64/conf/NOTES
@@ -494,6 +494,8 @@ device virtio_balloon # VirtIO Memory Balloon device
device virtio_random # VirtIO Entropy device
device virtio_console # VirtIO Console device
+# Microsoft Hyper-V enchancement support
+options HYPERV # Hyper-V kernel infrastructure
device hyperv # HyperV drivers
# Xen HVM Guest Optimizations
diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h
index 7ea4bcf..c0c5b0a 100644
--- a/sys/amd64/include/cpufunc.h
+++ b/sys/amd64/include/cpufunc.h
@@ -540,9 +540,8 @@ static __inline void
invpcid(struct invpcid_descr *d, int type)
{
- /* invpcid (%rdx),%rax */
- __asm __volatile(".byte 0x66,0x0f,0x38,0x82,0x02"
- : : "d" (d), "a" ((u_long)type) : "memory");
+ __asm __volatile("invpcid (%0),%1"
+ : : "r" (d), "r" ((u_long)type) : "memory");
}
static __inline u_short
diff --git a/sys/amd64/include/md_var.h b/sys/amd64/include/md_var.h
index 9083421..0813e5f 100644
--- a/sys/amd64/include/md_var.h
+++ b/sys/amd64/include/md_var.h
@@ -91,6 +91,7 @@ struct dumperinfo;
void *alloc_fpusave(int flags);
void amd64_syscall(struct thread *td, int traced);
void busdma_swi(void);
+bool cpu_mwait_usable(void);
void cpu_probe_amdc1e(void);
void cpu_setregs(void);
void doreti_iret(void) __asm(__STRING(doreti_iret));
diff --git a/sys/amd64/include/pcpu.h b/sys/amd64/include/pcpu.h
index fe898e9..91e8fb2 100644
--- a/sys/amd64/include/pcpu.h
+++ b/sys/amd64/include/pcpu.h
@@ -63,7 +63,9 @@
uint64_t pc_dbreg[16]; /* ddb debugging regs */ \
int pc_dbreg_cmd; /* ddb debugging reg cmd */ \
u_int pc_vcpu_id; /* Xen vCPU ID */ \
- char __pad[157] /* be divisor of PAGE_SIZE \
+ uint32_t pc_pcid_next; \
+ uint32_t pc_pcid_gen; \
+ char __pad[149] /* be divisor of PAGE_SIZE \
after cache alignment */
#define PC_DBREG_CMD_NONE 0
diff --git a/sys/amd64/include/pmap.h b/sys/amd64/include/pmap.h
index 868db7d..39df87a 100644
--- a/sys/amd64/include/pmap.h
+++ b/sys/amd64/include/pmap.h
@@ -219,6 +219,10 @@
#define ISA_HOLE_START 0xa0000
#define ISA_HOLE_LENGTH (0x100000-ISA_HOLE_START)
+#define PMAP_PCID_NONE 0xffffffff
+#define PMAP_PCID_KERN 0
+#define PMAP_PCID_OVERMAX 0x1000
+
#ifndef LOCORE
#include <sys/queue.h>
@@ -292,6 +296,11 @@ enum pmap_type {
PT_RVI, /* AMD's nested page tables */
};
+struct pmap_pcids {
+ uint32_t pm_pcid;
+ uint32_t pm_gen;
+};
+
/*
* The kernel virtual address (KVA) of the level 4 page table page is always
* within the direct map (DMAP) region.
@@ -302,13 +311,12 @@ struct pmap {
uint64_t pm_cr3;
TAILQ_HEAD(,pv_chunk) pm_pvchunk; /* list of mappings in pmap */
cpuset_t pm_active; /* active on cpus */
- cpuset_t pm_save; /* Context valid on cpus mask */
- int pm_pcid; /* context id */
enum pmap_type pm_type; /* regular or nested tables */
struct pmap_statistics pm_stats; /* pmap statistics */
struct vm_radix pm_root; /* spare page table pages */
long pm_eptgen; /* EPT pmap generation id */
int pm_flags;
+ struct pmap_pcids pm_pcids[MAXCPU];
};
/* flags */
@@ -375,6 +383,9 @@ extern vm_paddr_t dmaplimit;
#define pmap_page_is_write_mapped(m) (((m)->aflags & PGA_WRITEABLE) != 0)
#define pmap_unmapbios(va, sz) pmap_unmapdev((va), (sz))
+struct thread;
+
+void pmap_activate_sw(struct thread *);
void pmap_bootstrap(vm_paddr_t *);
int pmap_change_attr(vm_offset_t, vm_size_t, int);
void pmap_demote_DMAP(vm_paddr_t base, vm_size_t len, boolean_t invalidate);
diff --git a/sys/amd64/include/smp.h b/sys/amd64/include/smp.h
index 034a693..4fd6aac 100644
--- a/sys/amd64/include/smp.h
+++ b/sys/amd64/include/smp.h
@@ -46,6 +46,7 @@ extern struct mtx ap_boot_mtx;
extern int cpu_logical;
extern int cpu_cores;
extern int pmap_pcid_enabled;
+extern int invpcid_works;
extern u_int xhits_gbl[];
extern u_int xhits_pg[];
extern u_int xhits_rng[];
@@ -53,10 +54,6 @@ extern u_int ipi_global;
extern u_int ipi_page;
extern u_int ipi_range;
extern u_int ipi_range_size;
-extern u_int ipi_masked_global;
-extern u_int ipi_masked_page;
-extern u_int ipi_masked_range;
-extern u_int ipi_masked_range_size;
extern volatile int smp_tlb_wait;
@@ -78,9 +75,9 @@ extern u_long *ipi_rendezvous_counts[MAXCPU];
/* IPI handlers */
inthand_t
- IDTVEC(invltlb_pcid), /* TLB shootdowns - global, pcid enabled */
IDTVEC(invltlb), /* TLB shootdowns - global */
- IDTVEC(invlpg_pcid), /* TLB shootdowns - 1 page, pcid enabled */
+ IDTVEC(invltlb_pcid), /* TLB shootdowns - global, pcid */
+ IDTVEC(invltlb_invpcid),/* TLB shootdowns - global, invpcid */
IDTVEC(invlpg), /* TLB shootdowns - 1 page */
IDTVEC(invlrng), /* TLB shootdowns - page range */
IDTVEC(invlcache), /* Write back and invalidate cache */
@@ -100,8 +97,8 @@ void cpususpend_handler(void);
void init_secondary_tail(void);
void invltlb_handler(void);
void invltlb_pcid_handler(void);
+void invltlb_invpcid_handler(void);
void invlpg_handler(void);
-void invlpg_pcid_handler(void);
void invlrng_handler(void);
void invlcache_handler(void);
void init_secondary(void);
@@ -114,13 +111,9 @@ void ipi_selected(cpuset_t cpus, u_int ipi);
u_int mp_bootaddress(u_int);
void set_interrupt_apic_ids(void);
void smp_cache_flush(void);
-void smp_invlpg(struct pmap *pmap, vm_offset_t addr);
-void smp_masked_invlpg(cpuset_t mask, struct pmap *pmap, vm_offset_t addr);
-void smp_invlpg_range(struct pmap *pmap, vm_offset_t startva,
+void smp_masked_invlpg(cpuset_t mask, vm_offset_t addr);
+void smp_masked_invlpg_range(cpuset_t mask, vm_offset_t startva,
vm_offset_t endva);
-void smp_masked_invlpg_range(cpuset_t mask, struct pmap *pmap,
- vm_offset_t startva, vm_offset_t endva);
-void smp_invltlb(struct pmap *pmap);
void smp_masked_invltlb(cpuset_t mask, struct pmap *pmap);
int native_start_all_aps(void);
void mem_range_AP_init(void);
diff --git a/sys/amd64/include/vmm.h b/sys/amd64/include/vmm.h
index 52294bd..d3798bc 100644
--- a/sys/amd64/include/vmm.h
+++ b/sys/amd64/include/vmm.h
@@ -204,13 +204,12 @@ int vm_get_x2apic_state(struct vm *vm, int vcpu, enum x2apic_state *state);
int vm_set_x2apic_state(struct vm *vm, int vcpu, enum x2apic_state state);
int vm_apicid2vcpuid(struct vm *vm, int apicid);
int vm_activate_cpu(struct vm *vm, int vcpu);
-cpuset_t vm_active_cpus(struct vm *vm);
-cpuset_t vm_suspended_cpus(struct vm *vm);
struct vm_exit *vm_exitinfo(struct vm *vm, int vcpuid);
void vm_exit_suspended(struct vm *vm, int vcpuid, uint64_t rip);
void vm_exit_rendezvous(struct vm *vm, int vcpuid, uint64_t rip);
void vm_exit_astpending(struct vm *vm, int vcpuid, uint64_t rip);
+#ifdef _SYS__CPUSET_H_
/*
* Rendezvous all vcpus specified in 'dest' and execute 'func(arg)'.
* The rendezvous 'func(arg)' is not allowed to do anything that will
@@ -228,6 +227,9 @@ void vm_exit_astpending(struct vm *vm, int vcpuid, uint64_t rip);
typedef void (*vm_rendezvous_func_t)(struct vm *vm, int vcpuid, void *arg);
void vm_smp_rendezvous(struct vm *vm, int vcpuid, cpuset_t dest,
vm_rendezvous_func_t func, void *arg);
+cpuset_t vm_active_cpus(struct vm *vm);
+cpuset_t vm_suspended_cpus(struct vm *vm);
+#endif /* _SYS__CPUSET_H_ */
static __inline int
vcpu_rendezvous_pending(void *rendezvous_cookie)
@@ -274,7 +276,13 @@ vcpu_is_running(struct vm *vm, int vcpu, int *hostcpu)
static int __inline
vcpu_should_yield(struct vm *vm, int vcpu)
{
- return (curthread->td_flags & (TDF_ASTPENDING | TDF_NEEDRESCHED));
+
+ if (curthread->td_flags & (TDF_ASTPENDING | TDF_NEEDRESCHED))
+ return (1);
+ else if (curthread->td_owepreempt)
+ return (1);
+ else
+ return (0);
}
#endif
@@ -343,9 +351,10 @@ struct vm_copyinfo {
* at 'gla' and 'len' bytes long. The 'prot' should be set to PROT_READ for
* a copyin or PROT_WRITE for a copyout.
*
- * Returns 0 on success.
- * Returns 1 if an exception was injected into the guest.
- * Returns -1 otherwise.
+ * retval is_fault Intepretation
+ * 0 0 Success
+ * 0 1 An exception was injected into the guest
+ * EFAULT N/A Unrecoverable error
*
* The 'copyinfo[]' can be passed to 'vm_copyin()' or 'vm_copyout()' only if
* the return value is 0. The 'copyinfo[]' resources should be freed by calling
@@ -353,7 +362,7 @@ struct vm_copyinfo {
*/
int vm_copy_setup(struct vm *vm, int vcpuid, struct vm_guest_paging *paging,
uint64_t gla, size_t len, int prot, struct vm_copyinfo *copyinfo,
- int num_copyinfo);
+ int num_copyinfo, int *is_fault);
void vm_copy_teardown(struct vm *vm, int vcpuid, struct vm_copyinfo *copyinfo,
int num_copyinfo);
void vm_copyin(struct vm *vm, int vcpuid, struct vm_copyinfo *copyinfo,
diff --git a/sys/amd64/include/vmm_instruction_emul.h b/sys/amd64/include/vmm_instruction_emul.h
index 651b3b3..5e7127f 100644
--- a/sys/amd64/include/vmm_instruction_emul.h
+++ b/sys/amd64/include/vmm_instruction_emul.h
@@ -81,17 +81,19 @@ int vie_calculate_gla(enum vm_cpu_mode cpu_mode, enum vm_reg_name seg,
*/
int vmm_fetch_instruction(struct vm *vm, int cpuid,
struct vm_guest_paging *guest_paging,
- uint64_t rip, int inst_length, struct vie *vie);
+ uint64_t rip, int inst_length, struct vie *vie,
+ int *is_fault);
/*
* Translate the guest linear address 'gla' to a guest physical address.
*
- * Returns 0 on success and '*gpa' contains the result of the translation.
- * Returns 1 if an exception was injected into the guest.
- * Returns -1 otherwise.
+ * retval is_fault Interpretation
+ * 0 0 'gpa' contains result of the translation
+ * 0 1 An exception was injected into the guest
+ * EFAULT N/A An unrecoverable hypervisor error occurred
*/
int vm_gla2gpa(struct vm *vm, int vcpuid, struct vm_guest_paging *paging,
- uint64_t gla, int prot, uint64_t *gpa);
+ uint64_t gla, int prot, uint64_t *gpa, int *is_fault);
void vie_init(struct vie *vie, const char *inst_bytes, int inst_length);
diff --git a/sys/amd64/include/xen/xenfunc.h b/sys/amd64/include/xen/xenfunc.h
index d03d4f6..d8a6b5c 100644
--- a/sys/amd64/include/xen/xenfunc.h
+++ b/sys/amd64/include/xen/xenfunc.h
@@ -29,12 +29,7 @@
#ifndef _XEN_XENFUNC_H_
#define _XEN_XENFUNC_H_
-#ifdef XENHVM
#include <machine/xen/xenvar.h>
-#else
-#include <machine/xen/xenpmap.h>
-#include <machine/segments.h>
-#endif
#define BKPT __asm__("int3");
#define XPQ_CALL_DEPTH 5
@@ -64,10 +59,6 @@ void _xen_machphys_update(vm_paddr_t, vm_paddr_t, char *file, int line);
#define xen_machphys_update(a, b) _xen_machphys_update((a), (b), NULL, 0)
#endif
-#ifndef XENHVM
-void xen_update_descriptor(union descriptor *, union descriptor *);
-#endif
-
extern struct mtx balloon_lock;
#if 0
#define balloon_lock(__flags) mtx_lock_irqsave(&balloon_lock, __flags)
diff --git a/sys/amd64/include/xen/xenpmap.h b/sys/amd64/include/xen/xenpmap.h
deleted file mode 100644
index d768dad..0000000
--- a/sys/amd64/include/xen/xenpmap.h
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- *
- * Copyright (c) 2004 Christian Limpach.
- * Copyright (c) 2004,2005 Kip Macy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Christian Limpach.
- * 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 _XEN_XENPMAP_H_
-#define _XEN_XENPMAP_H_
-
-#include <machine/xen/features.h>
-
-void _xen_queue_pt_update(vm_paddr_t, vm_paddr_t, char *, int);
-void xen_pt_switch(vm_paddr_t);
-void xen_set_ldt(vm_paddr_t, unsigned long);
-void xen_pgdpt_pin(vm_paddr_t);
-void xen_pgd_pin(vm_paddr_t);
-void xen_pgd_unpin(vm_paddr_t);
-void xen_pt_pin(vm_paddr_t);
-void xen_pt_unpin(vm_paddr_t);
-void xen_flush_queue(void);
-void xen_check_queue(void);
-#if 0
-void pmap_ref(pt_entry_t *pte, vm_paddr_t ma);
-#endif
-
-#ifdef INVARIANTS
-#define xen_queue_pt_update(a, b) _xen_queue_pt_update((a), (b), __FILE__, __LINE__)
-#else
-#define xen_queue_pt_update(a, b) _xen_queue_pt_update((a), (b), NULL, 0)
-#endif
-
-#ifdef PMAP_DEBUG
-#define PMAP_REF pmap_ref
-#define PMAP_DEC_REF_PAGE pmap_dec_ref_page
-#define PMAP_MARK_PRIV pmap_mark_privileged
-#define PMAP_MARK_UNPRIV pmap_mark_unprivileged
-#else
-#define PMAP_MARK_PRIV(a)
-#define PMAP_MARK_UNPRIV(a)
-#define PMAP_REF(a, b)
-#define PMAP_DEC_REF_PAGE(a)
-#endif
-
-#define ALWAYS_SYNC 0
-
-#ifdef PT_DEBUG
-#define PT_LOG() printk("WP PT_SET %s:%d\n", __FILE__, __LINE__)
-#else
-#define PT_LOG()
-#endif
-
-#define INVALID_P2M_ENTRY (~0UL)
-
-#define pmap_valid_entry(E) ((E) & PG_V) /* is PDE or PTE valid? */
-
-#define SH_PD_SET_VA 1
-#define SH_PD_SET_VA_MA 2
-#define SH_PD_SET_VA_CLEAR 3
-
-struct pmap;
-void pd_set(struct pmap *pmap, int ptepindex, vm_paddr_t val, int type);
-#ifdef notyet
-static vm_paddr_t
-vptetomachpte(vm_paddr_t *pte)
-{
- vm_offset_t offset, ppte;
- vm_paddr_t pgoffset, retval, *pdir_shadow_ptr;
- int pgindex;
-
- ppte = (vm_offset_t)pte;
- pgoffset = (ppte & PAGE_MASK);
- offset = ppte - (vm_offset_t)PTmap;
- pgindex = ppte >> PDRSHIFT;
-
- pdir_shadow_ptr = (vm_paddr_t *)PCPU_GET(pdir_shadow);
- retval = (pdir_shadow_ptr[pgindex] & ~PAGE_MASK) + pgoffset;
- return (retval);
-}
-#endif
-#define PT_GET(_ptp) \
- (pmap_valid_entry(*(_ptp)) ? xpmap_mtop(*(_ptp)) : (0))
-
-#ifdef WRITABLE_PAGETABLES
-
-#define PT_SET_VA(_ptp,_npte,sync) do { \
- PMAP_REF((_ptp), xpmap_ptom(_npte)); \
- PT_LOG(); \
- *(_ptp) = xpmap_ptom((_npte)); \
-} while (/*CONSTCOND*/0)
-#define PT_SET_VA_MA(_ptp,_npte,sync) do { \
- PMAP_REF((_ptp), (_npte)); \
- PT_LOG(); \
- *(_ptp) = (_npte); \
-} while (/*CONSTCOND*/0)
-#define PT_CLEAR_VA(_ptp, sync) do { \
- PMAP_REF((pt_entry_t *)(_ptp), 0); \
- PT_LOG(); \
- *(_ptp) = 0; \
-} while (/*CONSTCOND*/0)
-
-#define PD_SET_VA(_pmap, _ptp, _npte, sync) do { \
- PMAP_REF((_ptp), xpmap_ptom(_npte)); \
- pd_set((_pmap),(_ptp),(_npte), SH_PD_SET_VA); \
- if (sync || ALWAYS_SYNC) xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-#define PD_SET_VA_MA(_pmap, _ptp, _npte, sync) do { \
- PMAP_REF((_ptp), (_npte)); \
- pd_set((_pmap),(_ptp),(_npte), SH_PD_SET_VA_MA); \
- if (sync || ALWAYS_SYNC) xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-#define PD_CLEAR_VA(_pmap, _ptp, sync) do { \
- PMAP_REF((pt_entry_t *)(_ptp), 0); \
- pd_set((_pmap),(_ptp), 0, SH_PD_SET_VA_CLEAR); \
- if (sync || ALWAYS_SYNC) xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-
-#else /* !WRITABLE_PAGETABLES */
-
-#define PT_SET_VA(_ptp,_npte,sync) do { \
- PMAP_REF((_ptp), xpmap_ptom(_npte)); \
- xen_queue_pt_update(vtomach(_ptp), \
- xpmap_ptom(_npte)); \
- if (sync || ALWAYS_SYNC) xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-#define PT_SET_VA_MA(_ptp,_npte,sync) do { \
- PMAP_REF((_ptp), (_npte)); \
- xen_queue_pt_update(vtomach(_ptp), _npte); \
- if (sync || ALWAYS_SYNC) xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-#define PT_CLEAR_VA(_ptp, sync) do { \
- PMAP_REF((pt_entry_t *)(_ptp), 0); \
- xen_queue_pt_update(vtomach(_ptp), 0); \
- if (sync || ALWAYS_SYNC) \
- xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-
-#define PD_SET_VA(_pmap, _ptepindex,_npte,sync) do { \
- PMAP_REF((_ptp), xpmap_ptom(_npte)); \
- pd_set((_pmap),(_ptepindex),(_npte), SH_PD_SET_VA); \
- if (sync || ALWAYS_SYNC) xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-#define PD_SET_VA_MA(_pmap, _ptepindex,_npte,sync) do { \
- PMAP_REF((_ptp), (_npte)); \
- pd_set((_pmap),(_ptepindex),(_npte), SH_PD_SET_VA_MA); \
- if (sync || ALWAYS_SYNC) xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-#define PD_CLEAR_VA(_pmap, _ptepindex, sync) do { \
- PMAP_REF((pt_entry_t *)(_ptp), 0); \
- pd_set((_pmap),(_ptepindex), 0, SH_PD_SET_VA_CLEAR); \
- if (sync || ALWAYS_SYNC) xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-
-#endif
-
-#define PT_SET_MA(_va, _ma) \
-do { \
- PANIC_IF(HYPERVISOR_update_va_mapping(((unsigned long)(_va)),\
- (_ma), \
- UVMF_INVLPG| UVMF_ALL) < 0); \
-} while (/*CONSTCOND*/0)
-
-#define PT_UPDATES_FLUSH() do { \
- xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-
-static __inline vm_paddr_t
-xpmap_mtop(vm_paddr_t mpa)
-{
- vm_paddr_t tmp = (mpa & PG_FRAME);
-
- return machtophys(tmp) | (mpa & ~PG_FRAME);
-}
-
-static __inline vm_paddr_t
-xpmap_ptom(vm_paddr_t ppa)
-{
- vm_paddr_t tmp = (ppa & PG_FRAME);
-
- return phystomach(tmp) | (ppa & ~PG_FRAME);
-}
-
-static __inline void
-set_phys_to_machine(unsigned long pfn, unsigned long mfn)
-{
-#ifdef notyet
- PANIC_IF(max_mapnr && pfn >= max_mapnr);
-#endif
- if (xen_feature(XENFEAT_auto_translated_physmap)) {
-#ifdef notyet
- PANIC_IF((pfn != mfn && mfn != INVALID_P2M_ENTRY));
-#endif
- return;
- }
- xen_phys_machine[pfn] = mfn;
-}
-
-
-
-
-#endif /* _XEN_XENPMAP_H_ */
diff --git a/sys/amd64/include/xen/xenvar.h b/sys/amd64/include/xen/xenvar.h
index d9dbc5d..110a351 100644
--- a/sys/amd64/include/xen/xenvar.h
+++ b/sys/amd64/include/xen/xenvar.h
@@ -48,68 +48,7 @@ if (xendebug_flags & argflags) XENPRINTF("(file=%s, line=%d) " _f "\n", __FILE__
#define TRACE_DEBUG(argflags, _f, _a...)
#endif
-#ifdef XENHVM
-
-static inline vm_paddr_t
-phystomach(vm_paddr_t pa)
-{
-
- return (pa);
-}
-
-static inline vm_paddr_t
-machtophys(vm_paddr_t ma)
-{
-
- return (ma);
-}
-
#define vtomach(va) pmap_kextract((vm_offset_t) (va))
-#define PFNTOMFN(pa) (pa)
-#define MFNTOPFN(ma) (ma)
-
-#define set_phys_to_machine(pfn, mfn) ((void)0)
-#define phys_to_machine_mapping_valid(pfn) (TRUE)
-#define PT_UPDATES_FLUSH() ((void)0)
-
-#else
-
-extern xen_pfn_t *xen_phys_machine;
-
-
-extern xen_pfn_t *xen_machine_phys;
-/* Xen starts physical pages after the 4MB ISA hole -
- * FreeBSD doesn't
- */
-
-
-#undef ADD_ISA_HOLE /* XXX */
-
-#ifdef ADD_ISA_HOLE
-#define ISA_INDEX_OFFSET 1024
-#define ISA_PDR_OFFSET 1
-#else
-#define ISA_INDEX_OFFSET 0
-#define ISA_PDR_OFFSET 0
-#endif
-
-
-#define PFNTOMFN(i) (xen_phys_machine[(i)])
-#define MFNTOPFN(i) ((vm_paddr_t)xen_machine_phys[(i)])
-
-#define VTOP(x) ((((uintptr_t)(x))) - KERNBASE)
-#define PTOV(x) (((uintptr_t)(x)) + KERNBASE)
-
-#define VTOPFN(x) (VTOP(x) >> PAGE_SHIFT)
-#define PFNTOV(x) PTOV((vm_paddr_t)(x) << PAGE_SHIFT)
-
-#define VTOMFN(va) (vtomach(va) >> PAGE_SHIFT)
-#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
-
-#define phystomach(pa) (((vm_paddr_t)(PFNTOMFN((pa) >> PAGE_SHIFT))) << PAGE_SHIFT)
-#define machtophys(ma) (((vm_paddr_t)(MFNTOPFN((ma) >> PAGE_SHIFT))) << PAGE_SHIFT)
-
-#endif
void xpq_init(void);
diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c
index 2b955d0..155e90b 100644
--- a/sys/amd64/linux32/linux32_machdep.c
+++ b/sys/amd64/linux32/linux32_machdep.c
@@ -137,6 +137,7 @@ int
linux_execve(struct thread *td, struct linux_execve_args *args)
{
struct image_args eargs;
+ struct vmspace *oldvmspace;
char *path;
int error;
@@ -147,12 +148,17 @@ linux_execve(struct thread *td, struct linux_execve_args *args)
printf(ARGS(execve, "%s"), path);
#endif
+ error = pre_execve(td, &oldvmspace);
+ if (error != 0) {
+ free(path, M_TEMP);
+ return (error);
+ }
error = freebsd32_exec_copyin_args(&eargs, path, UIO_SYSSPACE,
args->argp, args->envp);
free(path, M_TEMP);
if (error == 0)
error = kern_execve(td, &eargs, NULL);
- if (error == 0)
+ if (error == 0) {
/* Linux process can execute FreeBSD one, do not attempt
* to create emuldata for such process using
* linux_proc_init, this leads to a panic on KASSERT
@@ -160,6 +166,8 @@ linux_execve(struct thread *td, struct linux_execve_args *args)
*/
if (SV_PROC_ABI(td->td_proc) == SV_ABI_LINUX)
error = linux_proc_init(td, 0, 0);
+ }
+ post_execve(td, error, oldvmspace);
return (error);
}
diff --git a/sys/amd64/vmm/amd/amdv.c b/sys/amd64/vmm/amd/amdv.c
index acb3a3d..3157e21 100644
--- a/sys/amd64/vmm/amd/amdv.c
+++ b/sys/amd64/vmm/amd/amdv.c
@@ -32,7 +32,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
-#include <sys/smp.h>
#include <machine/vmm.h>
#include "io/iommu.h"
diff --git a/sys/amd64/vmm/amd/svm.c b/sys/amd64/vmm/amd/svm.c
index 7cc13ca..20e8f76 100644
--- a/sys/amd64/vmm/amd/svm.c
+++ b/sys/amd64/vmm/amd/svm.c
@@ -564,6 +564,19 @@ svm_vminit(struct vm *vm, pmap_t pmap)
return (svm_sc);
}
+/*
+ * Collateral for a generic SVM VM-exit.
+ */
+static void
+vm_exit_svm(struct vm_exit *vme, uint64_t code, uint64_t info1, uint64_t info2)
+{
+
+ vme->exitcode = VM_EXITCODE_SVM;
+ vme->u.svm.exitcode = code;
+ vme->u.svm.exitinfo1 = info1;
+ vme->u.svm.exitinfo2 = info2;
+}
+
static int
svm_cpl(struct vmcb_state *state)
{
@@ -1080,6 +1093,76 @@ clear_nmi_blocking(struct svm_softc *sc, int vcpu)
KASSERT(!error, ("%s: error %d setting intr_shadow", __func__, error));
}
+#define EFER_MBZ_BITS 0xFFFFFFFFFFFF0200UL
+
+static int
+svm_write_efer(struct svm_softc *sc, int vcpu, uint64_t newval, bool *retu)
+{
+ struct vm_exit *vme;
+ struct vmcb_state *state;
+ uint64_t changed, lma, oldval;
+ int error;
+
+ state = svm_get_vmcb_state(sc, vcpu);
+
+ oldval = state->efer;
+ VCPU_CTR2(sc->vm, vcpu, "wrmsr(efer) %#lx/%#lx", oldval, newval);
+
+ newval &= ~0xFE; /* clear the Read-As-Zero (RAZ) bits */
+ changed = oldval ^ newval;
+
+ if (newval & EFER_MBZ_BITS)
+ goto gpf;
+
+ /* APMv2 Table 14-5 "Long-Mode Consistency Checks" */
+ if (changed & EFER_LME) {
+ if (state->cr0 & CR0_PG)
+ goto gpf;
+ }
+
+ /* EFER.LMA = EFER.LME & CR0.PG */
+ if ((newval & EFER_LME) != 0 && (state->cr0 & CR0_PG) != 0)
+ lma = EFER_LMA;
+ else
+ lma = 0;
+
+ if ((newval & EFER_LMA) != lma)
+ goto gpf;
+
+ if (newval & EFER_NXE) {
+ if (!vm_cpuid_capability(sc->vm, vcpu, VCC_NO_EXECUTE))
+ goto gpf;
+ }
+
+ /*
+ * XXX bhyve does not enforce segment limits in 64-bit mode. Until
+ * this is fixed flag guest attempt to set EFER_LMSLE as an error.
+ */
+ if (newval & EFER_LMSLE) {
+ vme = vm_exitinfo(sc->vm, vcpu);
+ vm_exit_svm(vme, VMCB_EXIT_MSR, 1, 0);
+ *retu = true;
+ return (0);
+ }
+
+ if (newval & EFER_FFXSR) {
+ if (!vm_cpuid_capability(sc->vm, vcpu, VCC_FFXSR))
+ goto gpf;
+ }
+
+ if (newval & EFER_TCE) {
+ if (!vm_cpuid_capability(sc->vm, vcpu, VCC_TCE))
+ goto gpf;
+ }
+
+ error = svm_setreg(sc, vcpu, VM_REG_GUEST_EFER, newval);
+ KASSERT(error == 0, ("%s: error %d updating efer", __func__, error));
+ return (0);
+gpf:
+ vm_inject_gp(sc->vm, vcpu);
+ return (0);
+}
+
static int
emulate_wrmsr(struct svm_softc *sc, int vcpu, u_int num, uint64_t val,
bool *retu)
@@ -1089,7 +1172,7 @@ emulate_wrmsr(struct svm_softc *sc, int vcpu, u_int num, uint64_t val,
if (lapic_msr(num))
error = lapic_wrmsr(sc->vm, vcpu, num, val, retu);
else if (num == MSR_EFER)
- error = svm_setreg(sc, vcpu, VM_REG_GUEST_EFER, val);
+ error = svm_write_efer(sc, vcpu, val, retu);
else
error = svm_wrmsr(sc, vcpu, num, val, retu);
@@ -1189,19 +1272,6 @@ nrip_valid(uint64_t exitcode)
}
}
-/*
- * Collateral for a generic SVM VM-exit.
- */
-static void
-vm_exit_svm(struct vm_exit *vme, uint64_t code, uint64_t info1, uint64_t info2)
-{
-
- vme->exitcode = VM_EXITCODE_SVM;
- vme->u.svm.exitcode = code;
- vme->u.svm.exitinfo1 = info1;
- vme->u.svm.exitinfo2 = info2;
-}
-
static int
svm_vmexit(struct svm_softc *svm_sc, int vcpu, struct vm_exit *vmexit)
{
diff --git a/sys/amd64/vmm/amd/svm_msr.c b/sys/amd64/vmm/amd/svm_msr.c
index 100af4b..088751a 100644
--- a/sys/amd64/vmm/amd/svm_msr.c
+++ b/sys/amd64/vmm/amd/svm_msr.c
@@ -27,12 +27,17 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/types.h>
+#include <sys/param.h>
#include <sys/errno.h>
+#include <sys/systm.h>
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
+#include <machine/vmm.h>
+#include "svm.h"
+#include "vmcb.h"
+#include "svm_softc.h"
#include "svm_msr.h"
#ifndef MSR_AMDK8_IPM
@@ -105,6 +110,18 @@ svm_rdmsr(struct svm_softc *sc, int vcpu, u_int num, uint64_t *result,
int error = 0;
switch (num) {
+ case MSR_MCG_CAP:
+ case MSR_MCG_STATUS:
+ *result = 0;
+ break;
+ case MSR_MTRRcap:
+ case MSR_MTRRdefType:
+ case MSR_MTRR4kBase ... MSR_MTRR4kBase + 8:
+ case MSR_MTRR16kBase ... MSR_MTRR16kBase + 1:
+ case MSR_MTRR64kBase:
+ case MSR_SYSCFG:
+ *result = 0;
+ break;
case MSR_AMDK8_IPM:
*result = 0;
break;
@@ -122,6 +139,18 @@ svm_wrmsr(struct svm_softc *sc, int vcpu, u_int num, uint64_t val, bool *retu)
int error = 0;
switch (num) {
+ case MSR_MCG_CAP:
+ case MSR_MCG_STATUS:
+ break; /* ignore writes */
+ case MSR_MTRRcap:
+ vm_inject_gp(sc->vm, vcpu);
+ break;
+ case MSR_MTRRdefType:
+ case MSR_MTRR4kBase ... MSR_MTRR4kBase + 8:
+ case MSR_MTRR16kBase ... MSR_MTRR16kBase + 1:
+ case MSR_MTRR64kBase:
+ case MSR_SYSCFG:
+ break; /* Ignore writes */
case MSR_AMDK8_IPM:
/*
* Ignore writes to the "Interrupt Pending Message" MSR.
diff --git a/sys/amd64/vmm/amd/vmcb.c b/sys/amd64/vmm/amd/vmcb.c
index fb4b2c8..d860169 100644
--- a/sys/amd64/vmm/amd/vmcb.c
+++ b/sys/amd64/vmm/amd/vmcb.c
@@ -29,7 +29,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/cpuset.h>
#include <machine/segments.h>
#include <machine/specialreg.h>
diff --git a/sys/amd64/vmm/intel/vmx.c b/sys/amd64/vmm/intel/vmx.c
index 03d755c..4c3f20d 100644
--- a/sys/amd64/vmm/intel/vmx.c
+++ b/sys/amd64/vmm/intel/vmx.c
@@ -1780,6 +1780,7 @@ vmexit_inst_emul(struct vm_exit *vmexit, uint64_t gpa, uint64_t gla)
paging = &vmexit->u.inst_emul.paging;
vmexit->exitcode = VM_EXITCODE_INST_EMUL;
+ vmexit->inst_length = 0;
vmexit->u.inst_emul.gpa = gpa;
vmexit->u.inst_emul.gla = gla;
vmx_paging_info(paging);
diff --git a/sys/amd64/vmm/intel/vmx_msr.c b/sys/amd64/vmm/intel/vmx_msr.c
index e517778..3091f68 100644
--- a/sys/amd64/vmm/intel/vmx_msr.c
+++ b/sys/amd64/vmm/intel/vmx_msr.c
@@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/cpuset.h>
#include <machine/clock.h>
#include <machine/cpufunc.h>
@@ -396,6 +395,17 @@ vmx_rdmsr(struct vmx *vmx, int vcpuid, u_int num, uint64_t *val, bool *retu)
error = 0;
switch (num) {
+ case MSR_MCG_CAP:
+ case MSR_MCG_STATUS:
+ *val = 0;
+ break;
+ case MSR_MTRRcap:
+ case MSR_MTRRdefType:
+ case MSR_MTRR4kBase ... MSR_MTRR4kBase + 8:
+ case MSR_MTRR16kBase ... MSR_MTRR16kBase + 1:
+ case MSR_MTRR64kBase:
+ *val = 0;
+ break;
case MSR_IA32_MISC_ENABLE:
*val = misc_enable;
break;
@@ -427,6 +437,17 @@ vmx_wrmsr(struct vmx *vmx, int vcpuid, u_int num, uint64_t val, bool *retu)
error = 0;
switch (num) {
+ case MSR_MCG_CAP:
+ case MSR_MCG_STATUS:
+ break; /* ignore writes */
+ case MSR_MTRRcap:
+ vm_inject_gp(vmx->vm, vcpuid);
+ break;
+ case MSR_MTRRdefType:
+ case MSR_MTRR4kBase ... MSR_MTRR4kBase + 8:
+ case MSR_MTRR16kBase ... MSR_MTRR16kBase + 1:
+ case MSR_MTRR64kBase:
+ break; /* Ignore writes */
case MSR_IA32_MISC_ENABLE:
changed = val ^ misc_enable;
/*
diff --git a/sys/amd64/vmm/io/vatpic.c b/sys/amd64/vmm/io/vatpic.c
index 0df6e7c..6e94f5b 100644
--- a/sys/amd64/vmm/io/vatpic.c
+++ b/sys/amd64/vmm/io/vatpic.c
@@ -30,7 +30,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/types.h>
#include <sys/queue.h>
-#include <sys/cpuset.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
diff --git a/sys/amd64/vmm/io/vatpit.c b/sys/amd64/vmm/io/vatpit.c
index 842253d..d39c759 100644
--- a/sys/amd64/vmm/io/vatpit.c
+++ b/sys/amd64/vmm/io/vatpit.c
@@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/types.h>
#include <sys/queue.h>
-#include <sys/cpuset.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
@@ -437,7 +436,7 @@ vatpit_init(struct vm *vm)
vatpit->freq_sbt = bttosbt(bt);
for (i = 0; i < 3; i++) {
- callout_init(&vatpit->channel[i].callout, true);
+ callout_init(&vatpit->channel[i].callout, 1);
arg = &vatpit->channel[i].callout_arg;
arg->vatpit = vatpit;
arg->channel_num = i;
diff --git a/sys/amd64/vmm/io/vhpet.c b/sys/amd64/vmm/io/vhpet.c
index a4c96cd..1db1c51 100644
--- a/sys/amd64/vmm/io/vhpet.c
+++ b/sys/amd64/vmm/io/vhpet.c
@@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/systm.h>
-#include <sys/cpuset.h>
#include <dev/acpica/acpi_hpet.h>
diff --git a/sys/amd64/vmm/io/vioapic.c b/sys/amd64/vmm/io/vioapic.c
index 411887d..e6b8b5a 100644
--- a/sys/amd64/vmm/io/vioapic.c
+++ b/sys/amd64/vmm/io/vioapic.c
@@ -32,7 +32,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/queue.h>
-#include <sys/cpuset.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/systm.h>
diff --git a/sys/amd64/vmm/io/vlapic.c b/sys/amd64/vmm/io/vlapic.c
index 7097248..3451e1e 100644
--- a/sys/amd64/vmm/io/vlapic.c
+++ b/sys/amd64/vmm/io/vlapic.c
@@ -547,6 +547,8 @@ vlapic_update_ppr(struct vlapic *vlapic)
VLAPIC_CTR1(vlapic, "vlapic_update_ppr 0x%02x", ppr);
}
+static VMM_STAT(VLAPIC_GRATUITOUS_EOI, "EOI without any in-service interrupt");
+
static void
vlapic_process_eoi(struct vlapic *vlapic)
{
@@ -557,11 +559,7 @@ vlapic_process_eoi(struct vlapic *vlapic)
isrptr = &lapic->isr0;
tmrptr = &lapic->tmr0;
- /*
- * The x86 architecture reserves the the first 32 vectors for use
- * by the processor.
- */
- for (i = 7; i > 0; i--) {
+ for (i = 7; i >= 0; i--) {
idx = i * 4;
bitpos = fls(isrptr[idx]);
if (bitpos-- != 0) {
@@ -570,17 +568,21 @@ vlapic_process_eoi(struct vlapic *vlapic)
vlapic->isrvec_stk_top);
}
isrptr[idx] &= ~(1 << bitpos);
+ vector = i * 32 + bitpos;
+ VCPU_CTR1(vlapic->vm, vlapic->vcpuid, "EOI vector %d",
+ vector);
VLAPIC_CTR_ISR(vlapic, "vlapic_process_eoi");
vlapic->isrvec_stk_top--;
vlapic_update_ppr(vlapic);
if ((tmrptr[idx] & (1 << bitpos)) != 0) {
- vector = i * 32 + bitpos;
vioapic_process_eoi(vlapic->vm, vlapic->vcpuid,
vector);
}
return;
}
}
+ VCPU_CTR0(vlapic->vm, vlapic->vcpuid, "Gratuitous EOI");
+ vmm_stat_incr(vlapic->vm, vlapic->vcpuid, VLAPIC_GRATUITOUS_EOI, 1);
}
static __inline int
@@ -1092,11 +1094,7 @@ vlapic_pending_intr(struct vlapic *vlapic, int *vecptr)
irrptr = &lapic->irr0;
- /*
- * The x86 architecture reserves the the first 32 vectors for use
- * by the processor.
- */
- for (i = 7; i > 0; i--) {
+ for (i = 7; i >= 0; i--) {
idx = i * 4;
val = atomic_load_acq_int(&irrptr[idx]);
bitpos = fls(val);
diff --git a/sys/amd64/vmm/io/vpmtmr.c b/sys/amd64/vmm/io/vpmtmr.c
index 09f763f..1e7bb93 100644
--- a/sys/amd64/vmm/io/vpmtmr.c
+++ b/sys/amd64/vmm/io/vpmtmr.c
@@ -29,7 +29,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/queue.h>
-#include <sys/cpuset.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/systm.h>
diff --git a/sys/amd64/vmm/io/vrtc.c b/sys/amd64/vmm/io/vrtc.c
index ab9cabb..18ebc4b 100644
--- a/sys/amd64/vmm/io/vrtc.c
+++ b/sys/amd64/vmm/io/vrtc.c
@@ -30,7 +30,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/queue.h>
-#include <sys/cpuset.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/lock.h>
@@ -63,9 +62,12 @@ struct rtcdev {
uint8_t reg_b;
uint8_t reg_c;
uint8_t reg_d;
- uint8_t nvram[128 - 14];
+ uint8_t nvram[36];
+ uint8_t century;
+ uint8_t nvram2[128 - 51];
} __packed;
CTASSERT(sizeof(struct rtcdev) == 128);
+CTASSERT(offsetof(struct rtcdev, century) == RTC_CENTURY);
struct vrtc {
struct vm *vm;
@@ -139,20 +141,23 @@ update_enabled(struct vrtc *vrtc)
}
static time_t
-vrtc_curtime(struct vrtc *vrtc)
+vrtc_curtime(struct vrtc *vrtc, sbintime_t *basetime)
{
sbintime_t now, delta;
- time_t t;
+ time_t t, secs;
KASSERT(VRTC_LOCKED(vrtc), ("%s: vrtc not locked", __func__));
t = vrtc->base_rtctime;
+ *basetime = vrtc->base_uptime;
if (update_enabled(vrtc)) {
now = sbinuptime();
delta = now - vrtc->base_uptime;
KASSERT(delta >= 0, ("vrtc_curtime: uptime went backwards: "
"%#lx to %#lx", vrtc->base_uptime, now));
- t += delta / SBT_1S;
+ secs = delta / SBT_1S;
+ t += secs;
+ *basetime += secs * SBT_1S;
}
return (t);
}
@@ -245,6 +250,7 @@ secs_to_rtc(time_t rtctime, struct vrtc *vrtc, int force_update)
rtc->day_of_month = rtcset(rtc, ct.day);
rtc->month = rtcset(rtc, ct.mon);
rtc->year = rtcset(rtc, ct.year % 100);
+ rtc->century = rtcset(rtc, ct.year / 100);
}
static int
@@ -274,7 +280,7 @@ rtc_to_secs(struct vrtc *vrtc)
struct timespec ts;
struct rtcdev *rtc;
struct vm *vm;
- int error, hour, pm, year;
+ int century, error, hour, pm, year;
KASSERT(VRTC_LOCKED(vrtc), ("%s: vrtc not locked", __func__));
@@ -358,10 +364,14 @@ rtc_to_secs(struct vrtc *vrtc)
VM_CTR2(vm, "Invalid RTC year %#x/%d", rtc->year, year);
goto fail;
}
- if (year >= 70)
- ct.year = 1900 + year;
- else
- ct.year = 2000 + year;
+
+ error = rtcget(rtc, rtc->century, &century);
+ ct.year = century * 100 + year;
+ if (error || ct.year < POSIX_BASE_YEAR) {
+ VM_CTR2(vm, "Invalid RTC century %#x/%d", rtc->century,
+ ct.year);
+ goto fail;
+ }
error = clock_ct_to_ts(&ct, &ts);
if (error || ts.tv_sec < 0) {
@@ -373,13 +383,19 @@ rtc_to_secs(struct vrtc *vrtc)
}
return (ts.tv_sec); /* success */
fail:
- return (VRTC_BROKEN_TIME); /* failure */
+ /*
+ * Stop updating the RTC if the date/time fields programmed by
+ * the guest are invalid.
+ */
+ VM_CTR0(vrtc->vm, "Invalid RTC date/time programming detected");
+ return (VRTC_BROKEN_TIME);
}
static int
-vrtc_time_update(struct vrtc *vrtc, time_t newtime)
+vrtc_time_update(struct vrtc *vrtc, time_t newtime, sbintime_t newbase)
{
struct rtcdev *rtc;
+ sbintime_t oldbase;
time_t oldtime;
uint8_t alarm_sec, alarm_min, alarm_hour;
@@ -391,16 +407,21 @@ vrtc_time_update(struct vrtc *vrtc, time_t newtime)
alarm_hour = rtc->alarm_hour;
oldtime = vrtc->base_rtctime;
- VM_CTR2(vrtc->vm, "Updating RTC time from %#lx to %#lx",
+ VM_CTR2(vrtc->vm, "Updating RTC secs from %#lx to %#lx",
oldtime, newtime);
+ oldbase = vrtc->base_uptime;
+ VM_CTR2(vrtc->vm, "Updating RTC base uptime from %#lx to %#lx",
+ oldbase, newbase);
+ vrtc->base_uptime = newbase;
+
if (newtime == oldtime)
return (0);
/*
* If 'newtime' indicates that RTC updates are disabled then just
* record that and return. There is no need to do alarm interrupt
- * processing or update 'base_uptime' in this case.
+ * processing in this case.
*/
if (newtime == VRTC_BROKEN_TIME) {
vrtc->base_rtctime = VRTC_BROKEN_TIME;
@@ -446,8 +467,6 @@ vrtc_time_update(struct vrtc *vrtc, time_t newtime)
if (uintr_enabled(vrtc))
vrtc_set_reg_c(vrtc, rtc->reg_c | RTCIR_UPDATE);
- vrtc->base_uptime = sbinuptime();
-
return (0);
}
@@ -518,7 +537,7 @@ static void
vrtc_callout_handler(void *arg)
{
struct vrtc *vrtc = arg;
- sbintime_t freqsbt;
+ sbintime_t freqsbt, basetime;
time_t rtctime;
int error;
@@ -540,8 +559,8 @@ vrtc_callout_handler(void *arg)
vrtc_set_reg_c(vrtc, vrtc->rtcdev.reg_c | RTCIR_PERIOD);
if (aintr_enabled(vrtc) || uintr_enabled(vrtc)) {
- rtctime = vrtc_curtime(vrtc);
- error = vrtc_time_update(vrtc, rtctime);
+ rtctime = vrtc_curtime(vrtc, &basetime);
+ error = vrtc_time_update(vrtc, rtctime, basetime);
KASSERT(error == 0, ("%s: vrtc_time_update error %d",
__func__, error));
}
@@ -606,7 +625,7 @@ static int
vrtc_set_reg_b(struct vrtc *vrtc, uint8_t newval)
{
struct rtcdev *rtc;
- sbintime_t oldfreq, newfreq;
+ sbintime_t oldfreq, newfreq, basetime;
time_t curtime, rtctime;
int error;
uint8_t oldval, changed;
@@ -627,19 +646,13 @@ vrtc_set_reg_b(struct vrtc *vrtc, uint8_t newval)
if (changed & RTCSB_HALT) {
if ((newval & RTCSB_HALT) == 0) {
rtctime = rtc_to_secs(vrtc);
+ basetime = sbinuptime();
if (rtctime == VRTC_BROKEN_TIME) {
- /*
- * Stop updating the RTC if the date/time
- * programmed by the guest is not correct.
- */
- VM_CTR0(vrtc->vm, "Invalid RTC date/time "
- "programming detected");
-
if (rtc_flag_broken_time)
return (-1);
}
} else {
- curtime = vrtc_curtime(vrtc);
+ curtime = vrtc_curtime(vrtc, &basetime);
KASSERT(curtime == vrtc->base_rtctime, ("%s: mismatch "
"between vrtc basetime (%#lx) and curtime (%#lx)",
__func__, vrtc->base_rtctime, curtime));
@@ -658,7 +671,7 @@ vrtc_set_reg_b(struct vrtc *vrtc, uint8_t newval)
rtctime = VRTC_BROKEN_TIME;
rtc->reg_b &= ~RTCSB_UINTR;
}
- error = vrtc_time_update(vrtc, rtctime);
+ error = vrtc_time_update(vrtc, rtctime, basetime);
KASSERT(error == 0, ("vrtc_time_update error %d", error));
}
@@ -738,7 +751,7 @@ vrtc_set_time(struct vm *vm, time_t secs)
vrtc = vm_rtc(vm);
VRTC_LOCK(vrtc);
- error = vrtc_time_update(vrtc, secs);
+ error = vrtc_time_update(vrtc, secs, sbinuptime());
VRTC_UNLOCK(vrtc);
if (error) {
@@ -755,11 +768,12 @@ time_t
vrtc_get_time(struct vm *vm)
{
struct vrtc *vrtc;
+ sbintime_t basetime;
time_t t;
vrtc = vm_rtc(vm);
VRTC_LOCK(vrtc);
- t = vrtc_curtime(vrtc);
+ t = vrtc_curtime(vrtc, &basetime);
VRTC_UNLOCK(vrtc);
return (t);
@@ -777,7 +791,7 @@ vrtc_nvram_write(struct vm *vm, int offset, uint8_t value)
* Don't allow writes to RTC control registers or the date/time fields.
*/
if (offset < offsetof(struct rtcdev, nvram[0]) ||
- offset >= sizeof(struct rtcdev)) {
+ offset == RTC_CENTURY || offset >= sizeof(struct rtcdev)) {
VM_CTR1(vrtc->vm, "RTC nvram write to invalid offset %d",
offset);
return (EINVAL);
@@ -796,6 +810,7 @@ int
vrtc_nvram_read(struct vm *vm, int offset, uint8_t *retval)
{
struct vrtc *vrtc;
+ sbintime_t basetime;
time_t curtime;
uint8_t *ptr;
@@ -811,8 +826,8 @@ vrtc_nvram_read(struct vm *vm, int offset, uint8_t *retval)
/*
* Update RTC date/time fields if necessary.
*/
- if (offset < 10) {
- curtime = vrtc_curtime(vrtc);
+ if (offset < 10 || offset == RTC_CENTURY) {
+ curtime = vrtc_curtime(vrtc, &basetime);
secs_to_rtc(curtime, vrtc, 0);
}
@@ -852,6 +867,7 @@ vrtc_data_handler(struct vm *vm, int vcpuid, bool in, int port, int bytes,
{
struct vrtc *vrtc;
struct rtcdev *rtc;
+ sbintime_t basetime;
time_t curtime;
int error, offset;
@@ -869,16 +885,20 @@ vrtc_data_handler(struct vm *vm, int vcpuid, bool in, int port, int bytes,
}
error = 0;
- curtime = vrtc_curtime(vrtc);
- vrtc_time_update(vrtc, curtime);
+ curtime = vrtc_curtime(vrtc, &basetime);
+ vrtc_time_update(vrtc, curtime, basetime);
- if (in) {
- /*
- * Update RTC date/time fields if necessary.
- */
- if (offset < 10)
- secs_to_rtc(curtime, vrtc, 0);
+ /*
+ * Update RTC date/time fields if necessary.
+ *
+ * This is not just for reads of the RTC. The side-effect of writing
+ * the century byte requires other RTC date/time fields (e.g. sec)
+ * to be updated here.
+ */
+ if (offset < 10 || offset == RTC_CENTURY)
+ secs_to_rtc(curtime, vrtc, 0);
+ if (in) {
if (offset == 12) {
/*
* XXX
@@ -922,6 +942,18 @@ vrtc_data_handler(struct vm *vm, int vcpuid, bool in, int port, int bytes,
*((uint8_t *)rtc + offset) = *val;
break;
}
+
+ /*
+ * XXX some guests (e.g. OpenBSD) write the century byte
+ * outside of RTCSB_HALT so re-calculate the RTC date/time.
+ */
+ if (offset == RTC_CENTURY && !rtc_halted(vrtc)) {
+ curtime = rtc_to_secs(vrtc);
+ error = vrtc_time_update(vrtc, curtime, sbinuptime());
+ KASSERT(!error, ("vrtc_time_update error %d", error));
+ if (curtime == VRTC_BROKEN_TIME && rtc_flag_broken_time)
+ error = -1;
+ }
}
VRTC_UNLOCK(vrtc);
return (error);
@@ -971,7 +1003,7 @@ vrtc_init(struct vm *vm)
VRTC_LOCK(vrtc);
vrtc->base_rtctime = VRTC_BROKEN_TIME;
- vrtc_time_update(vrtc, curtime);
+ vrtc_time_update(vrtc, curtime, sbinuptime());
secs_to_rtc(curtime, vrtc, 0);
VRTC_UNLOCK(vrtc);
diff --git a/sys/amd64/vmm/vmm.c b/sys/amd64/vmm/vmm.c
index 6bd5bce..2671295 100644
--- a/sys/amd64/vmm/vmm.c
+++ b/sys/amd64/vmm/vmm.c
@@ -1256,11 +1256,14 @@ vm_handle_inst_emul(struct vm *vm, int vcpuid, bool *retu)
mem_region_read_t mread;
mem_region_write_t mwrite;
enum vm_cpu_mode cpu_mode;
- int cs_d, error, length;
+ int cs_d, error, fault;
vcpu = &vm->vcpu[vcpuid];
vme = &vcpu->exitinfo;
+ KASSERT(vme->inst_length == 0, ("%s: invalid inst_length %d",
+ __func__, vme->inst_length));
+
gla = vme->u.inst_emul.gla;
gpa = vme->u.inst_emul.gpa;
cs_base = vme->u.inst_emul.cs_base;
@@ -1273,37 +1276,31 @@ vm_handle_inst_emul(struct vm *vm, int vcpuid, bool *retu)
/* Fetch, decode and emulate the faulting instruction */
if (vie->num_valid == 0) {
- /*
- * If the instruction length is not known then assume a
- * maximum size instruction.
- */
- length = vme->inst_length ? vme->inst_length : VIE_INST_SIZE;
error = vmm_fetch_instruction(vm, vcpuid, paging, vme->rip +
- cs_base, length, vie);
+ cs_base, VIE_INST_SIZE, vie, &fault);
} else {
/*
* The instruction bytes have already been copied into 'vie'
*/
- error = 0;
+ error = fault = 0;
}
- if (error == 1)
- return (0); /* Resume guest to handle page fault */
- else if (error == -1)
- return (EFAULT);
- else if (error != 0)
- panic("%s: vmm_fetch_instruction error %d", __func__, error);
+ if (error || fault)
+ return (error);
- if (vmm_decode_instruction(vm, vcpuid, gla, cpu_mode, cs_d, vie) != 0)
- return (EFAULT);
+ if (vmm_decode_instruction(vm, vcpuid, gla, cpu_mode, cs_d, vie) != 0) {
+ VCPU_CTR1(vm, vcpuid, "Error decoding instruction at %#lx",
+ vme->rip + cs_base);
+ *retu = true; /* dump instruction bytes in userspace */
+ return (0);
+ }
/*
- * If the instruction length was not specified then update it now
- * along with 'nextrip'.
+ * Update 'nextrip' based on the length of the emulated instruction.
*/
- if (vme->inst_length == 0) {
- vme->inst_length = vie->num_processed;
- vcpu->nextrip += vie->num_processed;
- }
+ vme->inst_length = vie->num_processed;
+ vcpu->nextrip += vie->num_processed;
+ VCPU_CTR1(vm, vcpuid, "nextrip updated to %#lx after instruction "
+ "decoding", vcpu->nextrip);
/* return to userland unless this is an in-kernel emulated device */
if (gpa >= DEFAULT_APIC_BASE && gpa < DEFAULT_APIC_BASE + PAGE_SIZE) {
@@ -1788,6 +1785,7 @@ vm_inject_exception(struct vm *vm, int vcpuid, int vector, int errcode_valid,
uint32_t errcode, int restart_instruction)
{
struct vcpu *vcpu;
+ uint64_t regval;
int error;
if (vcpuid < 0 || vcpuid >= VM_MAXCPU)
@@ -1812,6 +1810,16 @@ vm_inject_exception(struct vm *vm, int vcpuid, int vector, int errcode_valid,
return (EBUSY);
}
+ if (errcode_valid) {
+ /*
+ * Exceptions don't deliver an error code in real mode.
+ */
+ error = vm_get_register(vm, vcpuid, VM_REG_GUEST_CR0, &regval);
+ KASSERT(!error, ("%s: error %d getting CR0", __func__, error));
+ if (!(regval & CR0_PE))
+ errcode_valid = 0;
+ }
+
/*
* From section 26.6.1 "Interruptibility State" in Intel SDM:
*
@@ -2319,7 +2327,7 @@ vm_copy_teardown(struct vm *vm, int vcpuid, struct vm_copyinfo *copyinfo,
int
vm_copy_setup(struct vm *vm, int vcpuid, struct vm_guest_paging *paging,
uint64_t gla, size_t len, int prot, struct vm_copyinfo *copyinfo,
- int num_copyinfo)
+ int num_copyinfo, int *fault)
{
int error, idx, nused;
size_t n, off, remaining;
@@ -2332,8 +2340,8 @@ vm_copy_setup(struct vm *vm, int vcpuid, struct vm_guest_paging *paging,
remaining = len;
while (remaining > 0) {
KASSERT(nused < num_copyinfo, ("insufficient vm_copyinfo"));
- error = vm_gla2gpa(vm, vcpuid, paging, gla, prot, &gpa);
- if (error)
+ error = vm_gla2gpa(vm, vcpuid, paging, gla, prot, &gpa, fault);
+ if (error || *fault)
return (error);
off = gpa & PAGE_MASK;
n = min(remaining, PAGE_SIZE - off);
@@ -2355,8 +2363,9 @@ vm_copy_setup(struct vm *vm, int vcpuid, struct vm_guest_paging *paging,
if (idx != nused) {
vm_copy_teardown(vm, vcpuid, copyinfo, num_copyinfo);
- return (-1);
+ return (EFAULT);
} else {
+ *fault = 0;
return (0);
}
}
diff --git a/sys/amd64/vmm/vmm_dev.c b/sys/amd64/vmm/vmm_dev.c
index 5be99cb..e3e140a 100644
--- a/sys/amd64/vmm/vmm_dev.c
+++ b/sys/amd64/vmm/vmm_dev.c
@@ -441,19 +441,9 @@ vmmdev_ioctl(struct cdev *cdev, u_long cmd, caddr_t data, int fflag,
CTASSERT(PROT_EXEC == VM_PROT_EXECUTE);
gg = (struct vm_gla2gpa *)data;
error = vm_gla2gpa(sc->vm, gg->vcpuid, &gg->paging, gg->gla,
- gg->prot, &gg->gpa);
- KASSERT(error == 0 || error == 1 || error == -1,
+ gg->prot, &gg->gpa, &gg->fault);
+ KASSERT(error == 0 || error == EFAULT,
("%s: vm_gla2gpa unknown error %d", __func__, error));
- if (error >= 0) {
- /*
- * error = 0: the translation was successful
- * error = 1: a fault was injected into the guest
- */
- gg->fault = error;
- error = 0;
- } else {
- error = EFAULT;
- }
break;
}
case VM_ACTIVATE_CPU:
diff --git a/sys/amd64/vmm/vmm_instruction_emul.c b/sys/amd64/vmm/vmm_instruction_emul.c
index 6f75515..9b5713d 100644
--- a/sys/amd64/vmm/vmm_instruction_emul.c
+++ b/sys/amd64/vmm/vmm_instruction_emul.c
@@ -73,6 +73,7 @@ enum {
VIE_OP_TYPE_MOVS,
VIE_OP_TYPE_GROUP1,
VIE_OP_TYPE_STOS,
+ VIE_OP_TYPE_BITTEST,
VIE_OP_TYPE_LAST
};
@@ -92,6 +93,11 @@ static const struct vie_op two_byte_opcodes[256] = {
.op_byte = 0xB7,
.op_type = VIE_OP_TYPE_MOVZX,
},
+ [0xBA] = {
+ .op_byte = 0xBA,
+ .op_type = VIE_OP_TYPE_BITTEST,
+ .op_flags = VIE_OP_F_IMM8,
+ },
[0xBE] = {
.op_byte = 0xBE,
.op_type = VIE_OP_TYPE_MOVSX,
@@ -107,6 +113,10 @@ static const struct vie_op one_byte_opcodes[256] = {
.op_byte = 0x2B,
.op_type = VIE_OP_TYPE_SUB,
},
+ [0x39] = {
+ .op_byte = 0x39,
+ .op_type = VIE_OP_TYPE_CMP,
+ },
[0x3B] = {
.op_byte = 0x3B,
.op_type = VIE_OP_TYPE_CMP,
@@ -172,14 +182,20 @@ static const struct vie_op one_byte_opcodes[256] = {
.op_byte = 0x23,
.op_type = VIE_OP_TYPE_AND,
},
+ [0x80] = {
+ /* Group 1 extended opcode */
+ .op_byte = 0x80,
+ .op_type = VIE_OP_TYPE_GROUP1,
+ .op_flags = VIE_OP_F_IMM8,
+ },
[0x81] = {
- /* XXX Group 1 extended opcode */
+ /* Group 1 extended opcode */
.op_byte = 0x81,
.op_type = VIE_OP_TYPE_GROUP1,
.op_flags = VIE_OP_F_IMM,
},
[0x83] = {
- /* XXX Group 1 extended opcode */
+ /* Group 1 extended opcode */
.op_byte = 0x83,
.op_type = VIE_OP_TYPE_GROUP1,
.op_flags = VIE_OP_F_IMM8,
@@ -585,13 +601,11 @@ emulate_movx(void *vm, int vcpuid, uint64_t gpa, struct vie *vie,
/*
* Helper function to calculate and validate a linear address.
- *
- * Returns 0 on success and 1 if an exception was injected into the guest.
*/
static int
get_gla(void *vm, int vcpuid, struct vie *vie, struct vm_guest_paging *paging,
int opsize, int addrsize, int prot, enum vm_reg_name seg,
- enum vm_reg_name gpr, uint64_t *gla)
+ enum vm_reg_name gpr, uint64_t *gla, int *fault)
{
struct seg_desc desc;
uint64_t cr0, val, rflags;
@@ -617,7 +631,7 @@ get_gla(void *vm, int vcpuid, struct vie *vie, struct vm_guest_paging *paging,
vm_inject_ss(vm, vcpuid, 0);
else
vm_inject_gp(vm, vcpuid);
- return (1);
+ goto guest_fault;
}
if (vie_canonical_check(paging->cpu_mode, *gla)) {
@@ -625,14 +639,19 @@ get_gla(void *vm, int vcpuid, struct vie *vie, struct vm_guest_paging *paging,
vm_inject_ss(vm, vcpuid, 0);
else
vm_inject_gp(vm, vcpuid);
- return (1);
+ goto guest_fault;
}
if (vie_alignment_check(paging->cpl, opsize, cr0, rflags, *gla)) {
vm_inject_ac(vm, vcpuid, 0);
- return (1);
+ goto guest_fault;
}
+ *fault = 0;
+ return (0);
+
+guest_fault:
+ *fault = 1;
return (0);
}
@@ -648,7 +667,7 @@ emulate_movs(void *vm, int vcpuid, uint64_t gpa, struct vie *vie,
#endif
uint64_t dstaddr, srcaddr, dstgpa, srcgpa, val;
uint64_t rcx, rdi, rsi, rflags;
- int error, opsize, seg, repeat;
+ int error, fault, opsize, seg, repeat;
opsize = (vie->op.op_byte == 0xA4) ? 1 : vie->opsize;
val = 0;
@@ -671,8 +690,10 @@ emulate_movs(void *vm, int vcpuid, uint64_t gpa, struct vie *vie,
* The count register is %rcx, %ecx or %cx depending on the
* address size of the instruction.
*/
- if ((rcx & vie_size2mask(vie->addrsize)) == 0)
- return (0);
+ if ((rcx & vie_size2mask(vie->addrsize)) == 0) {
+ error = 0;
+ goto done;
+ }
}
/*
@@ -693,13 +714,16 @@ emulate_movs(void *vm, int vcpuid, uint64_t gpa, struct vie *vie,
seg = vie->segment_override ? vie->segment_register : VM_REG_GUEST_DS;
error = get_gla(vm, vcpuid, vie, paging, opsize, vie->addrsize,
- PROT_READ, seg, VM_REG_GUEST_RSI, &srcaddr);
- if (error)
+ PROT_READ, seg, VM_REG_GUEST_RSI, &srcaddr, &fault);
+ if (error || fault)
goto done;
error = vm_copy_setup(vm, vcpuid, paging, srcaddr, opsize, PROT_READ,
- copyinfo, nitems(copyinfo));
+ copyinfo, nitems(copyinfo), &fault);
if (error == 0) {
+ if (fault)
+ goto done; /* Resume guest to handle fault */
+
/*
* case (2): read from system memory and write to mmio.
*/
@@ -708,11 +732,6 @@ emulate_movs(void *vm, int vcpuid, uint64_t gpa, struct vie *vie,
error = memwrite(vm, vcpuid, gpa, val, opsize, arg);
if (error)
goto done;
- } else if (error > 0) {
- /*
- * Resume guest execution to handle fault.
- */
- goto done;
} else {
/*
* 'vm_copy_setup()' is expected to fail for cases (3) and (4)
@@ -720,13 +739,17 @@ emulate_movs(void *vm, int vcpuid, uint64_t gpa, struct vie *vie,
*/
error = get_gla(vm, vcpuid, vie, paging, opsize, vie->addrsize,
- PROT_WRITE, VM_REG_GUEST_ES, VM_REG_GUEST_RDI, &dstaddr);
- if (error)
+ PROT_WRITE, VM_REG_GUEST_ES, VM_REG_GUEST_RDI, &dstaddr,
+ &fault);
+ if (error || fault)
goto done;
error = vm_copy_setup(vm, vcpuid, paging, dstaddr, opsize,
- PROT_WRITE, copyinfo, nitems(copyinfo));
+ PROT_WRITE, copyinfo, nitems(copyinfo), &fault);
if (error == 0) {
+ if (fault)
+ goto done; /* Resume guest to handle fault */
+
/*
* case (3): read from MMIO and write to system memory.
*
@@ -742,27 +765,29 @@ emulate_movs(void *vm, int vcpuid, uint64_t gpa, struct vie *vie,
vm_copyout(vm, vcpuid, &val, copyinfo, opsize);
vm_copy_teardown(vm, vcpuid, copyinfo, nitems(copyinfo));
- } else if (error > 0) {
- /*
- * Resume guest execution to handle fault.
- */
- goto done;
} else {
/*
* Case (4): read from and write to mmio.
+ *
+ * Commit to the MMIO read/write (with potential
+ * side-effects) only after we are sure that the
+ * instruction is not going to be restarted due
+ * to address translation faults.
*/
error = vm_gla2gpa(vm, vcpuid, paging, srcaddr,
- PROT_READ, &srcgpa);
- if (error)
- goto done;
- error = memread(vm, vcpuid, srcgpa, &val, opsize, arg);
- if (error)
+ PROT_READ, &srcgpa, &fault);
+ if (error || fault)
goto done;
error = vm_gla2gpa(vm, vcpuid, paging, dstaddr,
- PROT_WRITE, &dstgpa);
+ PROT_WRITE, &dstgpa, &fault);
+ if (error || fault)
+ goto done;
+
+ error = memread(vm, vcpuid, srcgpa, &val, opsize, arg);
if (error)
goto done;
+
error = memwrite(vm, vcpuid, dstgpa, val, opsize, arg);
if (error)
goto done;
@@ -807,10 +832,9 @@ emulate_movs(void *vm, int vcpuid, uint64_t gpa, struct vie *vie,
vm_restart_instruction(vm, vcpuid);
}
done:
- if (error < 0)
- return (EFAULT);
- else
- return (0);
+ KASSERT(error == 0 || error == EFAULT, ("%s: unexpected error %d",
+ __func__, error));
+ return (error);
}
static int
@@ -1030,39 +1054,55 @@ emulate_cmp(void *vm, int vcpuid, uint64_t gpa, struct vie *vie,
mem_region_read_t memread, mem_region_write_t memwrite, void *arg)
{
int error, size;
- uint64_t op1, op2, rflags, rflags2;
+ uint64_t regop, memop, op1, op2, rflags, rflags2;
enum vm_reg_name reg;
size = vie->opsize;
switch (vie->op.op_byte) {
+ case 0x39:
case 0x3B:
/*
+ * 39/r CMP r/m16, r16
+ * 39/r CMP r/m32, r32
+ * REX.W 39/r CMP r/m64, r64
+ *
* 3B/r CMP r16, r/m16
* 3B/r CMP r32, r/m32
* REX.W + 3B/r CMP r64, r/m64
*
- * Compare first operand (reg) with second operand (r/m) and
+ * Compare the first operand with the second operand and
* set status flags in EFLAGS register. The comparison is
* performed by subtracting the second operand from the first
* operand and then setting the status flags.
*/
- /* Get the first operand */
+ /* Get the register operand */
reg = gpr_map[vie->reg];
- error = vie_read_register(vm, vcpuid, reg, &op1);
+ error = vie_read_register(vm, vcpuid, reg, &regop);
if (error)
return (error);
- /* Get the second operand */
- error = memread(vm, vcpuid, gpa, &op2, size, arg);
+ /* Get the memory operand */
+ error = memread(vm, vcpuid, gpa, &memop, size, arg);
if (error)
return (error);
+ if (vie->op.op_byte == 0x3B) {
+ op1 = regop;
+ op2 = memop;
+ } else {
+ op1 = memop;
+ op2 = regop;
+ }
rflags2 = getcc(size, op1, op2);
break;
+ case 0x80:
case 0x81:
case 0x83:
/*
+ * 80 /7 cmp r/m8, imm8
+ * REX + 80 /7 cmp r/m8, imm8
+ *
* 81 /7 cmp r/m16, imm16
* 81 /7 cmp r/m32, imm32
* REX.W + 81 /7 cmp r/m64, imm32 sign-extended to 64
@@ -1078,6 +1118,8 @@ emulate_cmp(void *vm, int vcpuid, uint64_t gpa, struct vie *vie,
* the status flags.
*
*/
+ if (vie->op.op_byte == 0x80)
+ size = 1;
/* get the first operand */
error = memread(vm, vcpuid, gpa, &op1, size, arg);
@@ -1167,7 +1209,7 @@ emulate_stack_op(void *vm, int vcpuid, uint64_t mmio_gpa, struct vie *vie,
#endif
struct seg_desc ss_desc;
uint64_t cr0, rflags, rsp, stack_gla, val;
- int error, size, stackaddrsize, pushop;
+ int error, fault, size, stackaddrsize, pushop;
val = 0;
size = vie->opsize;
@@ -1233,18 +1275,10 @@ emulate_stack_op(void *vm, int vcpuid, uint64_t mmio_gpa, struct vie *vie,
}
error = vm_copy_setup(vm, vcpuid, paging, stack_gla, size,
- pushop ? PROT_WRITE : PROT_READ, copyinfo, nitems(copyinfo));
- if (error == -1) {
- /*
- * XXX cannot return a negative error value here because it
- * ends up being the return value of the VM_RUN() ioctl and
- * is interpreted as a pseudo-error (for e.g. ERESTART).
- */
- return (EFAULT);
- } else if (error == 1) {
- /* Resume guest execution to handle page fault */
- return (0);
- }
+ pushop ? PROT_WRITE : PROT_READ, copyinfo, nitems(copyinfo),
+ &fault);
+ if (error || fault)
+ return (error);
if (pushop) {
error = memread(vm, vcpuid, mmio_gpa, &val, size, arg);
@@ -1335,6 +1369,48 @@ emulate_group1(void *vm, int vcpuid, uint64_t gpa, struct vie *vie,
return (error);
}
+static int
+emulate_bittest(void *vm, int vcpuid, uint64_t gpa, struct vie *vie,
+ mem_region_read_t memread, mem_region_write_t memwrite, void *memarg)
+{
+ uint64_t val, rflags;
+ int error, bitmask, bitoff;
+
+ /*
+ * 0F BA is a Group 8 extended opcode.
+ *
+ * Currently we only emulate the 'Bit Test' instruction which is
+ * identified by a ModR/M:reg encoding of 100b.
+ */
+ if ((vie->reg & 7) != 4)
+ return (EINVAL);
+
+ error = vie_read_register(vm, vcpuid, VM_REG_GUEST_RFLAGS, &rflags);
+ KASSERT(error == 0, ("%s: error %d getting rflags", __func__, error));
+
+ error = memread(vm, vcpuid, gpa, &val, vie->opsize, memarg);
+ if (error)
+ return (error);
+
+ /*
+ * Intel SDM, Vol 2, Table 3-2:
+ * "Range of Bit Positions Specified by Bit Offset Operands"
+ */
+ bitmask = vie->opsize * 8 - 1;
+ bitoff = vie->immediate & bitmask;
+
+ /* Copy the bit into the Carry flag in %rflags */
+ if (val & (1UL << bitoff))
+ rflags |= PSL_C;
+ else
+ rflags &= ~PSL_C;
+
+ error = vie_update_register(vm, vcpuid, VM_REG_GUEST_RFLAGS, rflags, 8);
+ KASSERT(error == 0, ("%s: error %d updating rflags", __func__, error));
+
+ return (0);
+}
+
int
vmm_emulate_instruction(void *vm, int vcpuid, uint64_t gpa, struct vie *vie,
struct vm_guest_paging *paging, mem_region_read_t memread,
@@ -1391,6 +1467,10 @@ vmm_emulate_instruction(void *vm, int vcpuid, uint64_t gpa, struct vie *vie,
error = emulate_sub(vm, vcpuid, gpa, vie,
memread, memwrite, memarg);
break;
+ case VIE_OP_TYPE_BITTEST:
+ error = emulate_bittest(vm, vcpuid, gpa, vie,
+ memread, memwrite, memarg);
+ break;
default:
error = EINVAL;
break;
@@ -1608,7 +1688,7 @@ ptp_hold(struct vm *vm, vm_paddr_t ptpphys, size_t len, void **cookie)
int
vm_gla2gpa(struct vm *vm, int vcpuid, struct vm_guest_paging *paging,
- uint64_t gla, int prot, uint64_t *gpa)
+ uint64_t gla, int prot, uint64_t *gpa, int *guest_fault)
{
int nlevels, pfcode, ptpshift, ptpindex, retval, usermode, writable;
u_int retries;
@@ -1616,6 +1696,8 @@ vm_gla2gpa(struct vm *vm, int vcpuid, struct vm_guest_paging *paging,
uint32_t *ptpbase32, pte32;
void *cookie;
+ *guest_fault = 0;
+
usermode = (paging->cpl == 3 ? 1 : 0);
writable = prot & VM_PROT_WRITE;
cookie = NULL;
@@ -1778,18 +1860,20 @@ restart:
*gpa = pte | (gla & (pgsize - 1));
done:
ptp_release(&cookie);
+ KASSERT(retval == 0 || retval == EFAULT, ("%s: unexpected retval %d",
+ __func__, retval));
return (retval);
error:
- retval = -1;
+ retval = EFAULT;
goto done;
fault:
- retval = 1;
+ *guest_fault = 1;
goto done;
}
int
vmm_fetch_instruction(struct vm *vm, int vcpuid, struct vm_guest_paging *paging,
- uint64_t rip, int inst_length, struct vie *vie)
+ uint64_t rip, int inst_length, struct vie *vie, int *faultptr)
{
struct vm_copyinfo copyinfo[2];
int error, prot;
@@ -1799,13 +1883,14 @@ vmm_fetch_instruction(struct vm *vm, int vcpuid, struct vm_guest_paging *paging,
prot = PROT_READ | PROT_EXEC;
error = vm_copy_setup(vm, vcpuid, paging, rip, inst_length, prot,
- copyinfo, nitems(copyinfo));
- if (error == 0) {
- vm_copyin(vm, vcpuid, copyinfo, vie->inst, inst_length);
- vm_copy_teardown(vm, vcpuid, copyinfo, nitems(copyinfo));
- vie->num_valid = inst_length;
- }
- return (error);
+ copyinfo, nitems(copyinfo), faultptr);
+ if (error || *faultptr)
+ return (error);
+
+ vm_copyin(vm, vcpuid, copyinfo, vie->inst, inst_length);
+ vm_copy_teardown(vm, vcpuid, copyinfo, nitems(copyinfo));
+ vie->num_valid = inst_length;
+ return (0);
}
static int
@@ -2230,19 +2315,6 @@ decode_moffset(struct vie *vie)
}
/*
- * Verify that all the bytes in the instruction buffer were consumed.
- */
-static int
-verify_inst_length(struct vie *vie)
-{
-
- if (vie->num_processed)
- return (0);
- else
- return (-1);
-}
-
-/*
* Verify that the 'guest linear address' provided as collateral of the nested
* page table fault matches with our instruction decoding.
*/
@@ -2323,9 +2395,6 @@ vmm_decode_instruction(struct vm *vm, int cpuid, uint64_t gla,
if (decode_moffset(vie))
return (-1);
- if (verify_inst_length(vie))
- return (-1);
-
if ((vie->op.op_flags & VIE_OP_F_NO_GLA_VERIFICATION) == 0) {
if (verify_gla(vm, cpuid, gla, vie))
return (-1);
diff --git a/sys/amd64/vmm/vmm_ioport.c b/sys/amd64/vmm/vmm_ioport.c
index fc68a61..63044e8 100644
--- a/sys/amd64/vmm/vmm_ioport.c
+++ b/sys/amd64/vmm/vmm_ioport.c
@@ -28,16 +28,10 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/queue.h>
-#include <sys/cpuset.h>
#include <sys/systm.h>
-#include <vm/vm.h>
-
#include <machine/vmm.h>
#include <machine/vmm_instruction_emul.h>
-#include <x86/psl.h>
#include "vatpic.h"
#include "vatpit.h"
diff --git a/sys/amd64/vmm/vmm_stat.c b/sys/amd64/vmm/vmm_stat.c
index 9ecf9af..4ae5fb9 100644
--- a/sys/amd64/vmm/vmm_stat.c
+++ b/sys/amd64/vmm/vmm_stat.c
@@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/malloc.h>
-#include <sys/smp.h>
#include <machine/vmm.h>
#include "vmm_util.h"
diff --git a/sys/amd64/vmm/x86.c b/sys/amd64/vmm/x86.c
index c37d21c..525e1d9 100644
--- a/sys/amd64/vmm/x86.c
+++ b/sys/amd64/vmm/x86.c
@@ -32,7 +32,6 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/pcpu.h>
#include <sys/systm.h>
-#include <sys/cpuset.h>
#include <sys/sysctl.h>
#include <machine/clock.h>
@@ -231,10 +230,11 @@ x86_emulate_cpuid(struct vm *vm, int vcpu_id,
regs[1] |= (vcpu_id << CPUID_0000_0001_APICID_SHIFT);
/*
- * Don't expose VMX, SpeedStep or TME capability.
+ * Don't expose VMX, SpeedStep, TME or SMX capability.
* Advertise x2APIC capability and Hypervisor guest.
*/
regs[2] &= ~(CPUID2_VMX | CPUID2_EST | CPUID2_TM2);
+ regs[2] &= ~(CPUID2_SMX);
regs[2] |= CPUID2_HV;
@@ -286,18 +286,20 @@ x86_emulate_cpuid(struct vm *vm, int vcpu_id,
* Hide thermal monitoring
*/
regs[3] &= ~(CPUID_ACPI | CPUID_TM);
-
+
/*
- * Machine check handling is done in the host.
- * Hide MTRR capability.
+ * Hide the debug store capability.
*/
- regs[3] &= ~(CPUID_MCA | CPUID_MCE | CPUID_MTRR);
-
- /*
- * Hide the debug store capability.
- */
regs[3] &= ~CPUID_DS;
+ /*
+ * Advertise the Machine Check and MTRR capability.
+ *
+ * Some guest OSes (e.g. Windows) will not boot if
+ * these features are absent.
+ */
+ regs[3] |= (CPUID_MCA | CPUID_MCE | CPUID_MTRR);
+
logical_cpus = threads_per_core * cores_per_package;
regs[1] &= ~CPUID_HTT_CORES;
regs[1] |= (logical_cpus & 0xff) << 16;
@@ -486,3 +488,34 @@ x86_emulate_cpuid(struct vm *vm, int vcpu_id,
return (1);
}
+
+bool
+vm_cpuid_capability(struct vm *vm, int vcpuid, enum vm_cpuid_capability cap)
+{
+ bool rv;
+
+ KASSERT(cap > 0 && cap < VCC_LAST, ("%s: invalid vm_cpu_capability %d",
+ __func__, cap));
+
+ /*
+ * Simply passthrough the capabilities of the host cpu for now.
+ */
+ rv = false;
+ switch (cap) {
+ case VCC_NO_EXECUTE:
+ if (amd_feature & AMDID_NX)
+ rv = true;
+ break;
+ case VCC_FFXSR:
+ if (amd_feature & AMDID_FFXSR)
+ rv = true;
+ break;
+ case VCC_TCE:
+ if (amd_feature2 & AMDID2_TCE)
+ rv = true;
+ break;
+ default:
+ panic("%s: unknown vm_cpu_capability %d", __func__, cap);
+ }
+ return (rv);
+}
diff --git a/sys/amd64/vmm/x86.h b/sys/amd64/vmm/x86.h
index 8401c15..6f99d52 100644
--- a/sys/amd64/vmm/x86.h
+++ b/sys/amd64/vmm/x86.h
@@ -62,4 +62,17 @@
int x86_emulate_cpuid(struct vm *vm, int vcpu_id, uint32_t *eax, uint32_t *ebx,
uint32_t *ecx, uint32_t *edx);
+enum vm_cpuid_capability {
+ VCC_NONE,
+ VCC_NO_EXECUTE,
+ VCC_FFXSR,
+ VCC_TCE,
+ VCC_LAST
+};
+
+/*
+ * Return 'true' if the capability 'cap' is enabled in this virtual cpu
+ * and 'false' otherwise.
+ */
+bool vm_cpuid_capability(struct vm *vm, int vcpuid, enum vm_cpuid_capability);
#endif
diff --git a/sys/arm/allwinner/a10_clk.c b/sys/arm/allwinner/a10_clk.c
index ddec359..0c3634f 100644
--- a/sys/arm/allwinner/a10_clk.c
+++ b/sys/arm/allwinner/a10_clk.c
@@ -174,7 +174,8 @@ a10_clk_usb_deactivate(void)
}
int
-a10_clk_emac_activate(void) {
+a10_clk_emac_activate(void)
+{
struct a10_ccm_softc *sc = a10_ccm_sc;
uint32_t reg_value;
@@ -189,3 +190,110 @@ a10_clk_emac_activate(void) {
return (0);
}
+static void
+a10_clk_pll6_enable(void)
+{
+ struct a10_ccm_softc *sc;
+ uint32_t reg_value;
+
+ /*
+ * SATA needs PLL6 to be a 100MHz clock.
+ * The SATA output frequency is 24MHz * n * k / m / 6.
+ * To get to 100MHz, k & m must be equal and n must be 25.
+ * For other uses the output frequency is 24MHz * n * k / 2.
+ */
+ sc = a10_ccm_sc;
+ reg_value = ccm_read_4(sc, CCM_PLL6_CFG);
+ reg_value &= ~CCM_PLL_CFG_BYPASS;
+ reg_value &= ~(CCM_PLL_CFG_FACTOR_K | CCM_PLL_CFG_FACTOR_M |
+ CCM_PLL_CFG_FACTOR_N);
+ reg_value |= (25 << CCM_PLL_CFG_FACTOR_N_SHIFT);
+ reg_value |= CCM_PLL6_CFG_SATA_CLKEN;
+ reg_value |= CCM_PLL_CFG_ENABLE;
+ ccm_write_4(sc, CCM_PLL6_CFG, reg_value);
+}
+
+static unsigned int
+a10_clk_pll6_get_rate(void)
+{
+ struct a10_ccm_softc *sc;
+ uint32_t k, n, reg_value;
+
+ sc = a10_ccm_sc;
+ reg_value = ccm_read_4(sc, CCM_PLL6_CFG);
+ n = ((reg_value & CCM_PLL_CFG_FACTOR_N) >> CCM_PLL_CFG_FACTOR_N_SHIFT);
+ k = ((reg_value & CCM_PLL_CFG_FACTOR_K) >> CCM_PLL_CFG_FACTOR_K_SHIFT) +
+ 1;
+
+ return ((CCM_CLK_REF_FREQ * n * k) / 2);
+}
+
+int
+a10_clk_mmc_activate(int devid)
+{
+ struct a10_ccm_softc *sc;
+ uint32_t reg_value;
+
+ sc = a10_ccm_sc;
+ if (sc == NULL)
+ return (ENXIO);
+
+ a10_clk_pll6_enable();
+
+ /* Gating AHB clock for SD/MMC */
+ reg_value = ccm_read_4(sc, CCM_AHB_GATING0);
+ reg_value |= CCM_AHB_GATING_SDMMC0 << devid;
+ ccm_write_4(sc, CCM_AHB_GATING0, reg_value);
+
+ return (0);
+}
+
+int
+a10_clk_mmc_cfg(int devid, int freq)
+{
+ struct a10_ccm_softc *sc;
+ uint32_t clksrc, m, n, ophase, phase, reg_value;
+ unsigned int pll_freq;
+
+ sc = a10_ccm_sc;
+ if (sc == NULL)
+ return (ENXIO);
+
+ freq /= 1000;
+ if (freq <= 400) {
+ pll_freq = CCM_CLK_REF_FREQ / 1000;
+ clksrc = CCM_SD_CLK_SRC_SEL_OSC24M;
+ ophase = 0;
+ phase = 0;
+ n = 2;
+ } else if (freq <= 25000) {
+ pll_freq = a10_clk_pll6_get_rate() / 1000;
+ clksrc = CCM_SD_CLK_SRC_SEL_PLL6;
+ ophase = 0;
+ phase = 5;
+ n = 2;
+ } else if (freq <= 50000) {
+ pll_freq = a10_clk_pll6_get_rate() / 1000;
+ clksrc = CCM_SD_CLK_SRC_SEL_PLL6;
+ ophase = 3;
+ phase = 5;
+ n = 0;
+ } else
+ return (EINVAL);
+ m = ((pll_freq / (1 << n)) / (freq)) - 1;
+ reg_value = ccm_read_4(sc, CCM_MMC0_SCLK_CFG + (devid * 4));
+ reg_value &= ~CCM_SD_CLK_SRC_SEL;
+ reg_value |= (clksrc << CCM_SD_CLK_SRC_SEL_SHIFT);
+ reg_value &= ~CCM_SD_CLK_PHASE_CTR;
+ reg_value |= (phase << CCM_SD_CLK_PHASE_CTR_SHIFT);
+ reg_value &= ~CCM_SD_CLK_DIV_RATIO_N;
+ reg_value |= (n << CCM_SD_CLK_DIV_RATIO_N_SHIFT);
+ reg_value &= ~CCM_SD_CLK_OPHASE_CTR;
+ reg_value |= (ophase << CCM_SD_CLK_OPHASE_CTR_SHIFT);
+ reg_value &= ~CCM_SD_CLK_DIV_RATIO_M;
+ reg_value |= m;
+ reg_value |= CCM_PLL_CFG_ENABLE;
+ ccm_write_4(sc, CCM_MMC0_SCLK_CFG + (devid * 4), reg_value);
+
+ return (0);
+}
diff --git a/sys/arm/allwinner/a10_clk.h b/sys/arm/allwinner/a10_clk.h
index 2bba1a4..f9b88c1 100644
--- a/sys/arm/allwinner/a10_clk.h
+++ b/sys/arm/allwinner/a10_clk.h
@@ -103,6 +103,7 @@
#define CCM_AHB_GATING_USB0 (1 << 0)
#define CCM_AHB_GATING_EHCI0 (1 << 1)
#define CCM_AHB_GATING_EHCI1 (1 << 3)
+#define CCM_AHB_GATING_SDMMC0 (1 << 8)
#define CCM_AHB_GATING_EMAC (1 << 17)
#define CCM_USB_PHY (1 << 8)
@@ -110,8 +111,36 @@
#define CCM_USB1_RESET (1 << 1)
#define CCM_USB2_RESET (1 << 2)
+#define CCM_PLL_CFG_ENABLE (1U << 31)
+#define CCM_PLL_CFG_BYPASS (1U << 30)
+#define CCM_PLL_CFG_PLL5 (1U << 25)
+#define CCM_PLL_CFG_PLL6 (1U << 24)
+#define CCM_PLL_CFG_FACTOR_N 0x1f00
+#define CCM_PLL_CFG_FACTOR_N_SHIFT 8
+#define CCM_PLL_CFG_FACTOR_K 0x30
+#define CCM_PLL_CFG_FACTOR_K_SHIFT 4
+#define CCM_PLL_CFG_FACTOR_M 0x3
+
+#define CCM_PLL6_CFG_SATA_CLKEN (1U << 14)
+
+#define CCM_SD_CLK_SRC_SEL 0x3000000
+#define CCM_SD_CLK_SRC_SEL_SHIFT 24
+#define CCM_SD_CLK_SRC_SEL_OSC24M 0
+#define CCM_SD_CLK_SRC_SEL_PLL6 1
+#define CCM_SD_CLK_PHASE_CTR 0x700000
+#define CCM_SD_CLK_PHASE_CTR_SHIFT 20
+#define CCM_SD_CLK_DIV_RATIO_N 0x30000
+#define CCM_SD_CLK_DIV_RATIO_N_SHIFT 16
+#define CCM_SD_CLK_OPHASE_CTR 0x700
+#define CCM_SD_CLK_OPHASE_CTR_SHIFT 8
+#define CCM_SD_CLK_DIV_RATIO_M 0xf
+
+#define CCM_CLK_REF_FREQ 24000000U
+
int a10_clk_usb_activate(void);
int a10_clk_usb_deactivate(void);
int a10_clk_emac_activate(void);
+int a10_clk_mmc_activate(int);
+int a10_clk_mmc_cfg(int, int);
#endif /* _A10_CLK_H_ */
diff --git a/sys/arm/allwinner/a10_mmc.c b/sys/arm/allwinner/a10_mmc.c
new file mode 100644
index 0000000..85ce980
--- /dev/null
+++ b/sys/arm/allwinner/a10_mmc.c
@@ -0,0 +1,689 @@
+/*-
+ * Copyright (c) 2013 Alexander Fedorov
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/module.h>
+#include <sys/mutex.h>
+#include <sys/resource.h>
+#include <sys/rman.h>
+#include <sys/sysctl.h>
+
+#include <machine/bus.h>
+
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include <dev/mmc/bridge.h>
+#include <dev/mmc/mmcreg.h>
+#include <dev/mmc/mmcbrvar.h>
+
+#include <arm/allwinner/a10_clk.h>
+#include <arm/allwinner/a10_mmc.h>
+
+#define A10_MMC_MEMRES 0
+#define A10_MMC_IRQRES 1
+#define A10_MMC_RESSZ 2
+
+struct a10_mmc_softc {
+ bus_space_handle_t a10_bsh;
+ bus_space_tag_t a10_bst;
+ device_t a10_dev;
+ int a10_bus_busy;
+ int a10_id;
+ int a10_resid;
+ int a10_timeout;
+ struct callout a10_timeoutc;
+ struct mmc_host a10_host;
+ struct mmc_request * a10_req;
+ struct mtx a10_mtx;
+ struct resource * a10_res[A10_MMC_RESSZ];
+ uint32_t a10_intr;
+ uint32_t a10_intr_wait;
+ void * a10_intrhand;
+};
+
+static struct resource_spec a10_mmc_res_spec[] = {
+ { SYS_RES_MEMORY, 0, RF_ACTIVE },
+ { SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE },
+ { -1, 0, 0 }
+};
+
+static int a10_mmc_probe(device_t);
+static int a10_mmc_attach(device_t);
+static int a10_mmc_detach(device_t);
+static int a10_mmc_reset(struct a10_mmc_softc *);
+static void a10_mmc_intr(void *);
+static int a10_mmc_update_clock(struct a10_mmc_softc *);
+
+static int a10_mmc_update_ios(device_t, device_t);
+static int a10_mmc_request(device_t, device_t, struct mmc_request *);
+static int a10_mmc_get_ro(device_t, device_t);
+static int a10_mmc_acquire_host(device_t, device_t);
+static int a10_mmc_release_host(device_t, device_t);
+
+#define A10_MMC_LOCK(_sc) mtx_lock(&(_sc)->a10_mtx)
+#define A10_MMC_UNLOCK(_sc) mtx_unlock(&(_sc)->a10_mtx)
+#define A10_MMC_READ_4(_sc, _reg) \
+ bus_space_read_4((_sc)->a10_bst, (_sc)->a10_bsh, _reg)
+#define A10_MMC_WRITE_4(_sc, _reg, _value) \
+ bus_space_write_4((_sc)->a10_bst, (_sc)->a10_bsh, _reg, _value)
+
+static int
+a10_mmc_probe(device_t dev)
+{
+
+ if (!ofw_bus_status_okay(dev))
+ return (ENXIO);
+ if (!ofw_bus_is_compatible(dev, "allwinner,sun4i-a10-mmc"))
+ return (ENXIO);
+ device_set_desc(dev, "Allwinner Integrated MMC/SD controller");
+
+ return (BUS_PROBE_DEFAULT);
+}
+
+static int
+a10_mmc_attach(device_t dev)
+{
+ device_t child;
+ struct a10_mmc_softc *sc;
+ struct sysctl_ctx_list *ctx;
+ struct sysctl_oid_list *tree;
+
+ sc = device_get_softc(dev);
+ sc->a10_dev = dev;
+ sc->a10_req = NULL;
+ sc->a10_id = device_get_unit(dev);
+ if (sc->a10_id > 3) {
+ device_printf(dev, "only 4 hosts are supported (0-3)\n");
+ return (ENXIO);
+ }
+ if (bus_alloc_resources(dev, a10_mmc_res_spec, sc->a10_res) != 0) {
+ device_printf(dev, "cannot allocate device resources\n");
+ return (ENXIO);
+ }
+ sc->a10_bst = rman_get_bustag(sc->a10_res[A10_MMC_MEMRES]);
+ sc->a10_bsh = rman_get_bushandle(sc->a10_res[A10_MMC_MEMRES]);
+ if (bus_setup_intr(dev, sc->a10_res[A10_MMC_IRQRES],
+ INTR_TYPE_MISC | INTR_MPSAFE, NULL, a10_mmc_intr, sc,
+ &sc->a10_intrhand)) {
+ bus_release_resources(dev, a10_mmc_res_spec, sc->a10_res);
+ device_printf(dev, "cannot setup interrupt handler\n");
+ return (ENXIO);
+ }
+
+ /* Activate the module clock. */
+ if (a10_clk_mmc_activate(sc->a10_id) != 0) {
+ bus_teardown_intr(dev, sc->a10_res[A10_MMC_IRQRES],
+ sc->a10_intrhand);
+ bus_release_resources(dev, a10_mmc_res_spec, sc->a10_res);
+ device_printf(dev, "cannot activate mmc clock\n");
+ return (ENXIO);
+ }
+
+ sc->a10_timeout = 10;
+ ctx = device_get_sysctl_ctx(dev);
+ tree = SYSCTL_CHILDREN(device_get_sysctl_tree(dev));
+ SYSCTL_ADD_INT(ctx, tree, OID_AUTO, "req_timeout", CTLFLAG_RW,
+ &sc->a10_timeout, 0, "Request timeout in seconds");
+ mtx_init(&sc->a10_mtx, device_get_nameunit(sc->a10_dev), "a10_mmc",
+ MTX_DEF);
+ callout_init_mtx(&sc->a10_timeoutc, &sc->a10_mtx, 0);
+
+ /* Reset controller. */
+ if (a10_mmc_reset(sc) != 0) {
+ device_printf(dev, "cannot reset the controller\n");
+ goto fail;
+ }
+
+ sc->a10_host.f_min = 400000;
+ sc->a10_host.f_max = 52000000;
+ sc->a10_host.host_ocr = MMC_OCR_320_330 | MMC_OCR_330_340;
+ sc->a10_host.caps = MMC_CAP_4_BIT_DATA | MMC_CAP_HSPEED;
+ sc->a10_host.mode = mode_sd;
+
+ child = device_add_child(dev, "mmc", -1);
+ if (child == NULL) {
+ device_printf(dev, "attaching MMC bus failed!\n");
+ goto fail;
+ }
+ if (device_probe_and_attach(child) != 0) {
+ device_printf(dev, "attaching MMC child failed!\n");
+ device_delete_child(dev, child);
+ goto fail;
+ }
+
+ return (0);
+
+fail:
+ callout_drain(&sc->a10_timeoutc);
+ mtx_destroy(&sc->a10_mtx);
+ bus_teardown_intr(dev, sc->a10_res[A10_MMC_IRQRES], sc->a10_intrhand);
+ bus_release_resources(dev, a10_mmc_res_spec, sc->a10_res);
+
+ return (ENXIO);
+}
+
+static int
+a10_mmc_detach(device_t dev)
+{
+
+ return (EBUSY);
+}
+
+static int
+a10_mmc_reset(struct a10_mmc_softc *sc)
+{
+ int timeout;
+
+ A10_MMC_WRITE_4(sc, A10_MMC_GCTRL,
+ A10_MMC_READ_4(sc, A10_MMC_GCTRL) | A10_MMC_RESET);
+ timeout = 1000;
+ while (--timeout > 0) {
+ if ((A10_MMC_READ_4(sc, A10_MMC_GCTRL) & A10_MMC_RESET) == 0)
+ break;
+ DELAY(100);
+ }
+ if (timeout == 0)
+ return (ETIMEDOUT);
+
+ /* Set the timeout. */
+ A10_MMC_WRITE_4(sc, A10_MMC_TIMEOUT, 0xffffffff);
+
+ /* Clear pending interrupts. */
+ A10_MMC_WRITE_4(sc, A10_MMC_RINTR, 0xffffffff);
+ /* Unmask interrupts. */
+ A10_MMC_WRITE_4(sc, A10_MMC_IMASK,
+ A10_MMC_CMD_DONE | A10_MMC_INT_ERR_BIT |
+ A10_MMC_DATA_OVER | A10_MMC_AUTOCMD_DONE |
+ A10_MMC_RX_DATA_REQ | A10_MMC_TX_DATA_REQ);
+ /* Enable interrupts and AHB access. */
+ A10_MMC_WRITE_4(sc, A10_MMC_GCTRL,
+ A10_MMC_READ_4(sc, A10_MMC_GCTRL) |
+ A10_MMC_INT_ENABLE | A10_MMC_ACCESS_BY_AHB);
+
+ return (0);
+}
+
+static void
+a10_mmc_req_done(struct a10_mmc_softc *sc)
+{
+ struct mmc_command *cmd;
+ struct mmc_request *req;
+
+ cmd = sc->a10_req->cmd;
+ if (cmd->error != MMC_ERR_NONE) {
+ /* Reset the controller. */
+ a10_mmc_reset(sc);
+ a10_mmc_update_clock(sc);
+ }
+ /* Reset the FIFO. */
+ A10_MMC_WRITE_4(sc, A10_MMC_GCTRL,
+ A10_MMC_READ_4(sc, A10_MMC_GCTRL) | A10_MMC_FIFO_RESET);
+
+ req = sc->a10_req;
+ callout_stop(&sc->a10_timeoutc);
+ sc->a10_req = NULL;
+ sc->a10_intr = 0;
+ sc->a10_resid = 0;
+ sc->a10_intr_wait = 0;
+ req->done(req);
+}
+
+static void
+a10_mmc_req_ok(struct a10_mmc_softc *sc)
+{
+ int timeout;
+ struct mmc_command *cmd;
+ uint32_t status;
+
+ timeout = 1000;
+ while (--timeout > 0) {
+ status = A10_MMC_READ_4(sc, A10_MMC_STAS);
+ if ((status & A10_MMC_CARD_DATA_BUSY) == 0)
+ break;
+ DELAY(1000);
+ }
+ cmd = sc->a10_req->cmd;
+ if (timeout == 0) {
+ cmd->error = MMC_ERR_FAILED;
+ a10_mmc_req_done(sc);
+ return;
+ }
+ if (cmd->flags & MMC_RSP_PRESENT) {
+ if (cmd->flags & MMC_RSP_136) {
+ cmd->resp[0] = A10_MMC_READ_4(sc, A10_MMC_RESP3);
+ cmd->resp[1] = A10_MMC_READ_4(sc, A10_MMC_RESP2);
+ cmd->resp[2] = A10_MMC_READ_4(sc, A10_MMC_RESP1);
+ cmd->resp[3] = A10_MMC_READ_4(sc, A10_MMC_RESP0);
+ } else
+ cmd->resp[0] = A10_MMC_READ_4(sc, A10_MMC_RESP0);
+ }
+ /* All data has been transferred ? */
+ if (cmd->data != NULL && (sc->a10_resid << 2) < cmd->data->len)
+ cmd->error = MMC_ERR_FAILED;
+ a10_mmc_req_done(sc);
+}
+
+static void
+a10_mmc_timeout(void *arg)
+{
+ struct a10_mmc_softc *sc;
+
+ sc = (struct a10_mmc_softc *)arg;
+ if (sc->a10_req != NULL) {
+ device_printf(sc->a10_dev, "controller timeout\n");
+ sc->a10_req->cmd->error = MMC_ERR_TIMEOUT;
+ a10_mmc_req_done(sc);
+ } else
+ device_printf(sc->a10_dev,
+ "Spurious timeout - no active request\n");
+}
+
+static int
+a10_mmc_pio_transfer(struct a10_mmc_softc *sc, struct mmc_data *data)
+{
+ int i, write;
+ uint32_t bit, *buf;
+
+ buf = (uint32_t *)data->data;
+ write = (data->flags & MMC_DATA_WRITE) ? 1 : 0;
+ bit = write ? A10_MMC_FIFO_FULL : A10_MMC_FIFO_EMPTY;
+ for (i = sc->a10_resid; i < (data->len >> 2); i++) {
+ if ((A10_MMC_READ_4(sc, A10_MMC_STAS) & bit))
+ return (1);
+ if (write)
+ A10_MMC_WRITE_4(sc, A10_MMC_FIFO, buf[i]);
+ else
+ buf[i] = A10_MMC_READ_4(sc, A10_MMC_FIFO);
+ sc->a10_resid = i + 1;
+ }
+
+ return (0);
+}
+
+static void
+a10_mmc_intr(void *arg)
+{
+ struct a10_mmc_softc *sc;
+ struct mmc_data *data;
+ uint32_t imask, rint;
+
+ sc = (struct a10_mmc_softc *)arg;
+ A10_MMC_LOCK(sc);
+ rint = A10_MMC_READ_4(sc, A10_MMC_RINTR);
+ imask = A10_MMC_READ_4(sc, A10_MMC_IMASK);
+ if (imask == 0 && rint == 0) {
+ A10_MMC_UNLOCK(sc);
+ return;
+ }
+#ifdef DEBUG
+ device_printf(sc->a10_dev, "imask: %#x, rint: %#x\n", imask, rint);
+#endif
+ if (sc->a10_req == NULL) {
+ device_printf(sc->a10_dev,
+ "Spurious interrupt - no active request, rint: 0x%08X\n",
+ rint);
+ A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint);
+ A10_MMC_UNLOCK(sc);
+ return;
+ }
+ if (rint & A10_MMC_INT_ERR_BIT) {
+ device_printf(sc->a10_dev, "error rint: 0x%08X\n", rint);
+ if (rint & A10_MMC_RESP_TIMEOUT)
+ sc->a10_req->cmd->error = MMC_ERR_TIMEOUT;
+ else
+ sc->a10_req->cmd->error = MMC_ERR_FAILED;
+ A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint);
+ a10_mmc_req_done(sc);
+ A10_MMC_UNLOCK(sc);
+ return;
+ }
+
+ sc->a10_intr |= rint;
+ data = sc->a10_req->cmd->data;
+ if (data != NULL && (rint & (A10_MMC_DATA_OVER |
+ A10_MMC_RX_DATA_REQ | A10_MMC_TX_DATA_REQ)) != 0)
+ a10_mmc_pio_transfer(sc, data);
+ if ((sc->a10_intr & sc->a10_intr_wait) == sc->a10_intr_wait)
+ a10_mmc_req_ok(sc);
+
+ A10_MMC_WRITE_4(sc, A10_MMC_RINTR, rint);
+ A10_MMC_UNLOCK(sc);
+}
+
+static int
+a10_mmc_request(device_t bus, device_t child, struct mmc_request *req)
+{
+ int blksz;
+ struct a10_mmc_softc *sc;
+ struct mmc_command *cmd;
+ uint32_t cmdreg;
+
+ sc = device_get_softc(bus);
+ A10_MMC_LOCK(sc);
+ if (sc->a10_req) {
+ A10_MMC_UNLOCK(sc);
+ return (EBUSY);
+ }
+ sc->a10_req = req;
+ cmd = req->cmd;
+ cmdreg = A10_MMC_START;
+ if (cmd->opcode == MMC_GO_IDLE_STATE)
+ cmdreg |= A10_MMC_SEND_INIT_SEQ;
+ if (cmd->flags & MMC_RSP_PRESENT)
+ cmdreg |= A10_MMC_RESP_EXP;
+ if (cmd->flags & MMC_RSP_136)
+ cmdreg |= A10_MMC_LONG_RESP;
+ if (cmd->flags & MMC_RSP_CRC)
+ cmdreg |= A10_MMC_CHECK_RESP_CRC;
+
+ sc->a10_intr = 0;
+ sc->a10_resid = 0;
+ sc->a10_intr_wait = A10_MMC_CMD_DONE;
+ cmd->error = MMC_ERR_NONE;
+ if (cmd->data != NULL) {
+ sc->a10_intr_wait |= A10_MMC_DATA_OVER;
+ cmdreg |= A10_MMC_DATA_EXP | A10_MMC_WAIT_PREOVER;
+ if (cmd->data->flags & MMC_DATA_MULTI) {
+ cmdreg |= A10_MMC_SEND_AUTOSTOP;
+ sc->a10_intr_wait |= A10_MMC_AUTOCMD_DONE;
+ }
+ if (cmd->data->flags & MMC_DATA_WRITE)
+ cmdreg |= A10_MMC_WRITE;
+ blksz = min(cmd->data->len, MMC_SECTOR_SIZE);
+ A10_MMC_WRITE_4(sc, A10_MMC_BLKSZ, blksz);
+ A10_MMC_WRITE_4(sc, A10_MMC_BCNTR, cmd->data->len);
+ }
+
+ A10_MMC_WRITE_4(sc, A10_MMC_CARG, cmd->arg);
+ A10_MMC_WRITE_4(sc, A10_MMC_CMDR, cmdreg | cmd->opcode);
+ callout_reset(&sc->a10_timeoutc, sc->a10_timeout * hz,
+ a10_mmc_timeout, sc);
+ A10_MMC_UNLOCK(sc);
+
+ return (0);
+}
+
+static int
+a10_mmc_read_ivar(device_t bus, device_t child, int which,
+ uintptr_t *result)
+{
+ struct a10_mmc_softc *sc;
+
+ sc = device_get_softc(bus);
+ switch (which) {
+ default:
+ return (EINVAL);
+ case MMCBR_IVAR_BUS_MODE:
+ *(int *)result = sc->a10_host.ios.bus_mode;
+ break;
+ case MMCBR_IVAR_BUS_WIDTH:
+ *(int *)result = sc->a10_host.ios.bus_width;
+ break;
+ case MMCBR_IVAR_CHIP_SELECT:
+ *(int *)result = sc->a10_host.ios.chip_select;
+ break;
+ case MMCBR_IVAR_CLOCK:
+ *(int *)result = sc->a10_host.ios.clock;
+ break;
+ case MMCBR_IVAR_F_MIN:
+ *(int *)result = sc->a10_host.f_min;
+ break;
+ case MMCBR_IVAR_F_MAX:
+ *(int *)result = sc->a10_host.f_max;
+ break;
+ case MMCBR_IVAR_HOST_OCR:
+ *(int *)result = sc->a10_host.host_ocr;
+ break;
+ case MMCBR_IVAR_MODE:
+ *(int *)result = sc->a10_host.mode;
+ break;
+ case MMCBR_IVAR_OCR:
+ *(int *)result = sc->a10_host.ocr;
+ break;
+ case MMCBR_IVAR_POWER_MODE:
+ *(int *)result = sc->a10_host.ios.power_mode;
+ break;
+ case MMCBR_IVAR_VDD:
+ *(int *)result = sc->a10_host.ios.vdd;
+ break;
+ case MMCBR_IVAR_CAPS:
+ *(int *)result = sc->a10_host.caps;
+ break;
+ case MMCBR_IVAR_MAX_DATA:
+ *(int *)result = 65535;
+ break;
+ }
+
+ return (0);
+}
+
+static int
+a10_mmc_write_ivar(device_t bus, device_t child, int which,
+ uintptr_t value)
+{
+ struct a10_mmc_softc *sc;
+
+ sc = device_get_softc(bus);
+ switch (which) {
+ default:
+ return (EINVAL);
+ case MMCBR_IVAR_BUS_MODE:
+ sc->a10_host.ios.bus_mode = value;
+ break;
+ case MMCBR_IVAR_BUS_WIDTH:
+ sc->a10_host.ios.bus_width = value;
+ break;
+ case MMCBR_IVAR_CHIP_SELECT:
+ sc->a10_host.ios.chip_select = value;
+ break;
+ case MMCBR_IVAR_CLOCK:
+ sc->a10_host.ios.clock = value;
+ break;
+ case MMCBR_IVAR_MODE:
+ sc->a10_host.mode = value;
+ break;
+ case MMCBR_IVAR_OCR:
+ sc->a10_host.ocr = value;
+ break;
+ case MMCBR_IVAR_POWER_MODE:
+ sc->a10_host.ios.power_mode = value;
+ break;
+ case MMCBR_IVAR_VDD:
+ sc->a10_host.ios.vdd = value;
+ break;
+ /* These are read-only */
+ case MMCBR_IVAR_CAPS:
+ case MMCBR_IVAR_HOST_OCR:
+ case MMCBR_IVAR_F_MIN:
+ case MMCBR_IVAR_F_MAX:
+ case MMCBR_IVAR_MAX_DATA:
+ return (EINVAL);
+ }
+
+ return (0);
+}
+
+static int
+a10_mmc_update_clock(struct a10_mmc_softc *sc)
+{
+ uint32_t cmdreg;
+ int retry;
+
+ cmdreg = A10_MMC_START | A10_MMC_UPCLK_ONLY |
+ A10_MMC_WAIT_PREOVER;
+ A10_MMC_WRITE_4(sc, A10_MMC_CMDR, cmdreg);
+ retry = 0xfffff;
+ while (--retry > 0) {
+ if ((A10_MMC_READ_4(sc, A10_MMC_CMDR) & A10_MMC_START) == 0) {
+ A10_MMC_WRITE_4(sc, A10_MMC_RINTR, 0xffffffff);
+ return (0);
+ }
+ DELAY(10);
+ }
+ A10_MMC_WRITE_4(sc, A10_MMC_RINTR, 0xffffffff);
+ device_printf(sc->a10_dev, "timeout updating clock\n");
+
+ return (ETIMEDOUT);
+}
+
+static int
+a10_mmc_update_ios(device_t bus, device_t child)
+{
+ int error;
+ struct a10_mmc_softc *sc;
+ struct mmc_ios *ios;
+ uint32_t clkcr;
+
+ sc = device_get_softc(bus);
+ clkcr = A10_MMC_READ_4(sc, A10_MMC_CLKCR);
+ if (clkcr & A10_MMC_CARD_CLK_ON) {
+ /* Disable clock. */
+ clkcr &= ~A10_MMC_CARD_CLK_ON;
+ A10_MMC_WRITE_4(sc, A10_MMC_CLKCR, clkcr);
+ error = a10_mmc_update_clock(sc);
+ if (error != 0)
+ return (error);
+ }
+
+ ios = &sc->a10_host.ios;
+ if (ios->clock) {
+ /* Reset the divider. */
+ clkcr &= ~A10_MMC_CLKCR_DIV;
+ A10_MMC_WRITE_4(sc, A10_MMC_CLKCR, clkcr);
+ error = a10_mmc_update_clock(sc);
+ if (error != 0)
+ return (error);
+
+ /* Set the MMC clock. */
+ error = a10_clk_mmc_cfg(sc->a10_id, ios->clock);
+ if (error != 0)
+ return (error);
+
+ /* Enable clock. */
+ clkcr |= A10_MMC_CARD_CLK_ON;
+ A10_MMC_WRITE_4(sc, A10_MMC_CLKCR, clkcr);
+ error = a10_mmc_update_clock(sc);
+ if (error != 0)
+ return (error);
+ }
+
+ /* Set the bus width. */
+ switch (ios->bus_width) {
+ case bus_width_1:
+ A10_MMC_WRITE_4(sc, A10_MMC_WIDTH, A10_MMC_WIDTH1);
+ break;
+ case bus_width_4:
+ A10_MMC_WRITE_4(sc, A10_MMC_WIDTH, A10_MMC_WIDTH4);
+ break;
+ case bus_width_8:
+ A10_MMC_WRITE_4(sc, A10_MMC_WIDTH, A10_MMC_WIDTH8);
+ break;
+ }
+
+ return (0);
+}
+
+static int
+a10_mmc_get_ro(device_t bus, device_t child)
+{
+
+ return (0);
+}
+
+static int
+a10_mmc_acquire_host(device_t bus, device_t child)
+{
+ struct a10_mmc_softc *sc;
+ int error;
+
+ sc = device_get_softc(bus);
+ A10_MMC_LOCK(sc);
+ while (sc->a10_bus_busy) {
+ error = msleep(sc, &sc->a10_mtx, PCATCH, "mmchw", 0);
+ if (error != 0) {
+ A10_MMC_UNLOCK(sc);
+ return (error);
+ }
+ }
+ sc->a10_bus_busy++;
+ A10_MMC_UNLOCK(sc);
+
+ return (0);
+}
+
+static int
+a10_mmc_release_host(device_t bus, device_t child)
+{
+ struct a10_mmc_softc *sc;
+
+ sc = device_get_softc(bus);
+ A10_MMC_LOCK(sc);
+ sc->a10_bus_busy--;
+ wakeup(sc);
+ A10_MMC_UNLOCK(sc);
+
+ return (0);
+}
+
+static device_method_t a10_mmc_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, a10_mmc_probe),
+ DEVMETHOD(device_attach, a10_mmc_attach),
+ DEVMETHOD(device_detach, a10_mmc_detach),
+
+ /* Bus interface */
+ DEVMETHOD(bus_read_ivar, a10_mmc_read_ivar),
+ DEVMETHOD(bus_write_ivar, a10_mmc_write_ivar),
+ DEVMETHOD(bus_print_child, bus_generic_print_child),
+
+ /* MMC bridge interface */
+ DEVMETHOD(mmcbr_update_ios, a10_mmc_update_ios),
+ DEVMETHOD(mmcbr_request, a10_mmc_request),
+ DEVMETHOD(mmcbr_get_ro, a10_mmc_get_ro),
+ DEVMETHOD(mmcbr_acquire_host, a10_mmc_acquire_host),
+ DEVMETHOD(mmcbr_release_host, a10_mmc_release_host),
+
+ DEVMETHOD_END
+};
+
+static devclass_t a10_mmc_devclass;
+
+static driver_t a10_mmc_driver = {
+ "a10_mmc",
+ a10_mmc_methods,
+ sizeof(struct a10_mmc_softc),
+};
+
+DRIVER_MODULE(a10_mmc, simplebus, a10_mmc_driver, a10_mmc_devclass, 0, 0);
diff --git a/sys/arm/allwinner/a10_mmc.h b/sys/arm/allwinner/a10_mmc.h
new file mode 100644
index 0000000..84c13a5
--- /dev/null
+++ b/sys/arm/allwinner/a10_mmc.h
@@ -0,0 +1,179 @@
+/*-
+ * Copyright (c) 2013 Alexander Fedorov <alexander.fedorov@rtlservice.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.
+ *
+ * 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 _A10_MMC_H_
+#define _A10_MMC_H_
+
+#define A10_MMC_GCTRL 0x00 /* Global Control Register */
+#define A10_MMC_CLKCR 0x04 /* Clock Control Register */
+#define A10_MMC_TIMEOUT 0x08 /* Timeout Register */
+#define A10_MMC_WIDTH 0x0C /* Bus Width Register */
+#define A10_MMC_BLKSZ 0x10 /* Block Size Register */
+#define A10_MMC_BCNTR 0x14 /* Byte Count Register */
+#define A10_MMC_CMDR 0x18 /* Command Register */
+#define A10_MMC_CARG 0x1C /* Argument Register */
+#define A10_MMC_RESP0 0x20 /* Response Register 0 */
+#define A10_MMC_RESP1 0x24 /* Response Register 1 */
+#define A10_MMC_RESP2 0x28 /* Response Register 2 */
+#define A10_MMC_RESP3 0x2C /* Response Register 3 */
+#define A10_MMC_IMASK 0x30 /* Interrupt Mask Register */
+#define A10_MMC_MISTA 0x34 /* Masked Interrupt Status Register */
+#define A10_MMC_RINTR 0x38 /* Raw Interrupt Status Register */
+#define A10_MMC_STAS 0x3C /* Status Register */
+#define A10_MMC_FTRGL 0x40 /* FIFO Threshold Watermark Register */
+#define A10_MMC_FUNS 0x44 /* Function Select Register */
+#define A10_MMC_CBCR 0x48 /* CIU Byte Count Register */
+#define A10_MMC_BBCR 0x4C /* BIU Byte Count Register */
+#define A10_MMC_DBGC 0x50 /* Debug Enable Register */
+#define A10_MMC_DMAC 0x80 /* IDMAC Control Register */
+#define A10_MMC_DLBA 0x84 /* IDMAC Desc List Base Address Reg */
+#define A10_MMC_IDST 0x88 /* IDMAC Status Register */
+#define A10_MMC_IDIE 0x8C /* IDMAC Interrupt Enable Register */
+#define A10_MMC_CHDA 0x90
+#define A10_MMC_CBDA 0x94
+#define A10_MMC_FIFO 0x100 /* FIFO Access Address */
+
+/* A10_MMC_GCTRL */
+#define A10_MMC_SOFT_RESET (1U << 0)
+#define A10_MMC_FIFO_RESET (1U << 1)
+#define A10_MMC_DMA_RESET (1U << 2)
+#define A10_MMC_INT_ENABLE (1U << 4)
+#define A10_MMC_DMA_ENABLE (1U << 5)
+#define A10_MMC_DEBOUNCE_ENABLE (1U << 8)
+#define A10_MMC_DDR_MODE (1U << 10)
+#define A10_MMC_ACCESS_BY_DMA (1U << 30)
+#define A10_MMC_ACCESS_BY_AHB (1U << 31)
+#define A10_MMC_RESET \
+ (A10_MMC_SOFT_RESET | A10_MMC_FIFO_RESET | A10_MMC_DMA_RESET)
+
+/* A10_MMC_CLKCR */
+#define A10_MMC_CARD_CLK_ON (1U << 16)
+#define A10_MMC_LOW_POWER_ON (1U << 17)
+#define A10_MMC_CLKCR_DIV 0xff
+
+/* A10_MMC_WIDTH */
+#define A10_MMC_WIDTH1 0
+#define A10_MMC_WIDTH4 1
+#define A10_MMC_WIDTH8 2
+
+/* A10_MMC_CMDR */
+#define A10_MMC_RESP_EXP (1U << 6)
+#define A10_MMC_LONG_RESP (1U << 7)
+#define A10_MMC_CHECK_RESP_CRC (1U << 8)
+#define A10_MMC_DATA_EXP (1U << 9)
+#define A10_MMC_WRITE (1U << 10)
+#define A10_MMC_SEQ_MODE (1U << 11)
+#define A10_MMC_SEND_AUTOSTOP (1U << 12)
+#define A10_MMC_WAIT_PREOVER (1U << 13)
+#define A10_MMC_STOP_ABORT_CMD (1U << 14)
+#define A10_MMC_SEND_INIT_SEQ (1U << 15)
+#define A10_MMC_UPCLK_ONLY (1U << 21)
+#define A10_MMC_RDCEATADEV (1U << 22)
+#define A10_MMC_CCS_EXP (1U << 23)
+#define A10_MMC_ENB_BOOT (1U << 24)
+#define A10_MMC_ALT_BOOT_OPT (1U << 25)
+#define A10_MMC_BOOT_ACK_EXP (1U << 26)
+#define A10_MMC_DISABLE_BOOT (1U << 27)
+#define A10_MMC_VOL_SWITCH (1U << 28)
+#define A10_MMC_START (1U << 31)
+
+/* A10_MMC_IMASK and A10_MMC_RINTR */
+#define A10_MMC_RESP_ERR (1U << 1)
+#define A10_MMC_CMD_DONE (1U << 2)
+#define A10_MMC_DATA_OVER (1U << 3)
+#define A10_MMC_TX_DATA_REQ (1U << 4)
+#define A10_MMC_RX_DATA_REQ (1U << 5)
+#define A10_MMC_RESP_CRC_ERR (1U << 6)
+#define A10_MMC_DATA_CRC_ERR (1U << 7)
+#define A10_MMC_RESP_TIMEOUT (1U << 8)
+#define A10_MMC_ACK_RECV (1U << 8)
+#define A10_MMC_DATA_TIMEOUT (1U << 9)
+#define A10_MMC_BOOT_START (1U << 9)
+#define A10_MMC_DATA_STARVE (1U << 10)
+#define A10_MMC_VOL_CHG_DONE (1U << 10)
+#define A10_MMC_FIFO_RUN_ERR (1U << 11)
+#define A10_MMC_HARDW_LOCKED (1U << 12)
+#define A10_MMC_START_BIT_ERR (1U << 13)
+#define A10_MMC_AUTOCMD_DONE (1U << 14)
+#define A10_MMC_END_BIT_ERR (1U << 15)
+#define A10_MMC_SDIO_INT (1U << 16)
+#define A10_MMC_CARD_INSERT (1U << 30)
+#define A10_MMC_CARD_REMOVE (1U << 31)
+#define A10_MMC_INT_ERR_BIT \
+ (A10_MMC_RESP_ERR | A10_MMC_RESP_CRC_ERR | \
+ A10_MMC_DATA_CRC_ERR | A10_MMC_RESP_TIMEOUT | \
+ A10_MMC_FIFO_RUN_ERR | A10_MMC_HARDW_LOCKED | \
+ A10_MMC_START_BIT_ERR | A10_MMC_END_BIT_ERR)
+
+/* A10_MMC_STAS */
+#define A10_MMC_RX_WLFLAG (1U << 0)
+#define A10_MMC_TX_WLFLAG (1U << 1)
+#define A10_MMC_FIFO_EMPTY (1U << 2)
+#define A10_MMC_FIFO_FULL (1U << 3)
+#define A10_MMC_CARD_PRESENT (1U << 8)
+#define A10_MMC_CARD_DATA_BUSY (1U << 9)
+#define A10_MMC_DATA_FSM_BUSY (1U << 10)
+#define A10_MMC_DMA_REQ (1U << 31)
+#define A10_MMC_FIFO_SIZE 16
+
+/* A10_MMC_FUNS */
+#define A10_MMC_CE_ATA_ON (0xceaaU << 16)
+#define A10_MMC_SEND_IRQ_RESP (1U << 0)
+#define A10_MMC_SDIO_RD_WAIT (1U << 1)
+#define A10_MMC_ABT_RD_DATA (1U << 2)
+#define A10_MMC_SEND_CC_SD (1U << 8)
+#define A10_MMC_SEND_AUTOSTOP_CC_SD (1U << 9)
+#define A10_MMC_CE_ATA_DEV_INT_ENB (1U << 10)
+
+/* IDMA CONTROLLER BUS MOD BIT FIELD */
+#define A10_MMC_IDMAC_SOFT_RST (1U << 0)
+#define A10_MMC_IDMAC_FIX_BURST (1U << 1)
+#define A10_MMC_IDMAC_IDMA_ON (1U << 7)
+#define A10_MMC_IDMAC_REFETCH_DES (1U << 31)
+
+/* A10_MMC_IDST */
+#define A10_MMC_IDMAC_TRANSMIT_INT (1U << 0)
+#define A10_MMC_IDMAC_RECEIVE_INT (1U << 1)
+#define A10_MMC_IDMAC_FATAL_BUS_ERR (1U << 2)
+#define A10_MMC_IDMAC_DES_INVALID (1U << 4)
+#define A10_MMC_IDMAC_CARD_ERR_SUM (1U << 5)
+#define A10_MMC_IDMAC_NORMAL_INT_SUM (1U << 8)
+#define A10_MMC_IDMAC_ABNORMAL_INT_SUM (1U << 9)
+#define A10_MMC_IDMAC_HOST_ABT_INTX (1U << 10)
+#define A10_MMC_IDMAC_HOST_ABT_INRX (1U << 10)
+#define A10_MMC_IDMAC_IDLE (0U << 13)
+#define A10_MMC_IDMAC_SUSPEND (1U << 13)
+#define A10_MMC_IDMAC_DESC_RD (2U << 13)
+#define A10_MMC_IDMAC_DESC_CHECK (3U << 13)
+#define A10_MMC_IDMAC_RD_REQ_WAIT (4U << 13)
+#define A10_MMC_IDMAC_WR_REQ_WAIT (5U << 13)
+#define A10_MMC_IDMAC_RD (6U << 13)
+#define A10_MMC_IDMAC_WR (7U << 13)
+#define A10_MMC_IDMAC_DESC_CLOSE (8U << 13)
+
+#endif /* _A10_MMC_H_ */
diff --git a/sys/arm/allwinner/a20/files.a20 b/sys/arm/allwinner/a20/files.a20
index f8d8f6f..25fd880 100644
--- a/sys/arm/allwinner/a20/files.a20
+++ b/sys/arm/allwinner/a20/files.a20
@@ -1,5 +1,3 @@
# $FreeBSD$
-arm/arm/gic.c standard
-
arm/allwinner/a20/a20_mp.c optional smp
diff --git a/sys/arm/allwinner/files.allwinner b/sys/arm/allwinner/files.allwinner
index 9b65e7c..8447939 100644
--- a/sys/arm/allwinner/files.allwinner
+++ b/sys/arm/allwinner/files.allwinner
@@ -10,6 +10,7 @@ arm/allwinner/a10_common.c standard
arm/allwinner/a10_ehci.c optional ehci
arm/allwinner/a10_gpio.c optional gpio
arm/allwinner/a10_machdep.c standard
+arm/allwinner/a10_mmc.c optional mmc
arm/allwinner/a10_sramc.c standard
arm/allwinner/a10_wdog.c standard
arm/allwinner/a20/a20_cpu_cfg.c standard
diff --git a/sys/arm/allwinner/std.a10 b/sys/arm/allwinner/std.a10
index da5d895..8d99ab8 100644
--- a/sys/arm/allwinner/std.a10
+++ b/sys/arm/allwinner/std.a10
@@ -10,12 +10,12 @@ makeoption ARM_LITTLE_ENDIAN
# 0x40200000, e.g. from u-boot with 'fatload mmc 0 0x40200000 kernel'
#
#
-options PHYSADDR=0x40000000
+options PHYSADDR=0x40000000
makeoptions KERNPHYSADDR=0x40200000
-options KERNPHYSADDR=0x40200000
+options KERNPHYSADDR=0x40200000
makeoptions KERNVIRTADDR=0xc0200000
-options KERNVIRTADDR=0xc0200000
+options KERNVIRTADDR=0xc0200000
options ARM_L2_PIPT
diff --git a/sys/arm/altera/socfpga/files.socfpga b/sys/arm/altera/socfpga/files.socfpga
index 7f425ec..901069b 100644
--- a/sys/arm/altera/socfpga/files.socfpga
+++ b/sys/arm/altera/socfpga/files.socfpga
@@ -6,7 +6,6 @@ arm/arm/bus_space_generic.c standard
arm/arm/bus_space_asm_generic.S standard
arm/arm/bus_space_base.c standard
-arm/arm/gic.c standard
arm/arm/mpcore_timer.c standard
arm/altera/socfpga/socfpga_common.c standard
diff --git a/sys/arm/amlogic/aml8726/aml8726_ccm.c b/sys/arm/amlogic/aml8726/aml8726_ccm.c
index 77b1648..186a3ca 100644
--- a/sys/arm/amlogic/aml8726/aml8726_ccm.c
+++ b/sys/arm/amlogic/aml8726/aml8726_ccm.c
@@ -185,7 +185,6 @@ aml8726_ccm_attach(device_t dev)
device_printf(dev, "unsupported SoC\n");
return (ENXIO);
/* NOTREACHED */
- break;
}
if (bus_alloc_resources(dev, aml8726_ccm_spec, sc->res)) {
diff --git a/sys/arm/amlogic/aml8726/aml8726_machdep.c b/sys/arm/amlogic/aml8726/aml8726_machdep.c
index 4476c90..2f98235 100644
--- a/sys/arm/amlogic/aml8726/aml8726_machdep.c
+++ b/sys/arm/amlogic/aml8726/aml8726_machdep.c
@@ -38,7 +38,9 @@ __FBSDID("$FreeBSD$");
#include <vm/pmap.h>
#include <machine/bus.h>
+#include <machine/cpufunc.h>
#include <machine/devmap.h>
+#include <machine/intr.h>
#include <machine/machdep.h>
#include <machine/platform.h>
@@ -114,6 +116,19 @@ platform_gpio_init(void)
aml8726_identify_soc();
/*
+ * My aml8726-m3 development box which identifies the CPU as
+ * a Cortex A9-r2 rev 4 randomly locks up during boot when WFI
+ * is used.
+ */
+ switch (aml8726_soc_hw_rev) {
+ case AML_SOC_HW_REV_M3:
+ cpufuncs.cf_sleep = (void *)cpufunc_nullop;
+ break;
+ default:
+ break;
+ }
+
+ /*
* This FDT fixup should arguably be called through fdt_fixup_table,
* however currently there's no mechanism to specify a fixup which
* should always be invoked.
@@ -167,43 +182,31 @@ struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
};
+#ifndef DEV_GIC
static int
fdt_pic_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
int *pol)
{
/*
- * The single core chips have just an Amlogic PIC. However the
- * multi core chips also have a GIC.
+ * The single core chips have just an Amlogic PIC.
*/
-#ifdef SMP
- if (!fdt_is_compatible_strict(node, "arm,cortex-a9-gic"))
-#else
if (!fdt_is_compatible_strict(node, "amlogic,aml8726-pic"))
-#endif
return (ENXIO);
*interrupt = fdt32_to_cpu(intr[1]);
*trig = INTR_TRIGGER_EDGE;
*pol = INTR_POLARITY_HIGH;
- switch (*interrupt) {
- case 30: /* INT_USB_A */
- case 31: /* INT_USB_B */
- *trig = INTR_TRIGGER_LEVEL;
- break;
- default:
- break;
- }
-
-#ifdef SMP
- *interrupt += 32;
-#endif
-
return (0);
}
+#endif
fdt_pic_decode_t fdt_pic_table[] = {
+#ifdef DEV_GIC
+ &gic_decode_fdt,
+#else
&fdt_pic_decode_ic,
+#endif
NULL
};
diff --git a/sys/arm/amlogic/aml8726/aml8726_mmc.c b/sys/arm/amlogic/aml8726/aml8726_mmc.c
index 167d3a3..7d1ef4e 100644
--- a/sys/arm/amlogic/aml8726/aml8726_mmc.c
+++ b/sys/arm/amlogic/aml8726/aml8726_mmc.c
@@ -70,6 +70,7 @@ struct aml8726_mmc_softc {
device_t dev;
struct resource *res[2];
struct mtx mtx;
+ struct callout ch;
uint32_t port;
unsigned int ref_freq;
struct aml8726_mmc_gpio pwr_en;
@@ -81,7 +82,7 @@ struct aml8726_mmc_softc {
struct mmc_host host;
int bus_busy;
struct mmc_command *cmd;
- unsigned int timeout_remaining;
+ uint32_t stop_timeout;
};
static struct resource_spec aml8726_mmc_spec[] = {
@@ -92,6 +93,7 @@ static struct resource_spec aml8726_mmc_spec[] = {
#define AML_MMC_LOCK(sc) mtx_lock(&(sc)->mtx)
#define AML_MMC_UNLOCK(sc) mtx_unlock(&(sc)->mtx)
+#define AML_MMC_LOCK_ASSERT(sc) mtx_assert(&(sc)->mtx, MA_OWNED)
#define AML_MMC_LOCK_INIT(sc) \
mtx_init(&(sc)->mtx, device_get_nameunit((sc)->dev), \
"mmc", MTX_DEF)
@@ -107,6 +109,10 @@ static struct resource_spec aml8726_mmc_spec[] = {
#define PWR_OFF_FLAG(pol) ((pol) == 0 ? GPIO_PIN_HIGH : \
GPIO_PIN_LOW)
+#define MSECS_TO_TICKS(ms) (((ms)*hz)/1000 + 1)
+
+static void aml8726_mmc_timeout(void *arg);
+
static unsigned int
aml8726_mmc_clk(phandle_t node)
{
@@ -126,6 +132,37 @@ aml8726_mmc_clk(phandle_t node)
return ((unsigned int)prop);
}
+static uint32_t
+aml8726_mmc_freq(struct aml8726_mmc_softc *sc, uint32_t divisor)
+{
+
+ return (sc->ref_freq / ((divisor + 1) * 2));
+}
+
+static uint32_t
+aml8726_mmc_div(struct aml8726_mmc_softc *sc, uint32_t desired_freq)
+{
+ uint32_t divisor;
+
+ divisor = sc->ref_freq / (desired_freq * 2);
+
+ if (divisor == 0)
+ divisor = 1;
+
+ divisor -= 1;
+
+ if (aml8726_mmc_freq(sc, divisor) > desired_freq)
+ divisor += 1;
+
+ if (divisor > (AML_MMC_CONFIG_CMD_CLK_DIV_MASK >>
+ AML_MMC_CONFIG_CMD_CLK_DIV_SHIFT)) {
+ divisor = AML_MMC_CONFIG_CMD_CLK_DIV_MASK >>
+ AML_MMC_CONFIG_CMD_CLK_DIV_SHIFT;
+ }
+
+ return (divisor);
+}
+
static void
aml8726_mmc_mapmem(void *arg, bus_dma_segment_t *segs, int nseg, int error)
{
@@ -162,25 +199,18 @@ aml8726_mmc_power_on(struct aml8726_mmc_softc *sc)
PWR_ON_FLAG(sc->pwr_en.pol)));
}
-static int
-aml8726_mmc_restart_timer(struct aml8726_mmc_softc *sc)
+static void
+aml8726_mmc_soft_reset(struct aml8726_mmc_softc *sc, boolean_t enable_irq)
{
- uint32_t count;
- uint32_t isr;
-
- if (sc->cmd == NULL || sc->timeout_remaining == 0)
- return (0);
-
- count = (sc->timeout_remaining > 0x1fff) ? 0x1fff :
- sc->timeout_remaining;
- sc->timeout_remaining -= count;
+ uint32_t icr;
- isr = (count << AML_MMC_IRQ_STATUS_TIMER_CNT_SHIFT) |
- AML_MMC_IRQ_STATUS_TIMER_EN | AML_MMC_IRQ_STATUS_TIMEOUT_IRQ;
+ icr = AML_MMC_IRQ_CONFIG_SOFT_RESET;
- CSR_WRITE_4(sc, AML_MMC_IRQ_STATUS_REG, isr);
+ if (enable_irq == true)
+ icr |= AML_MMC_IRQ_CONFIG_CMD_DONE_EN;
- return (1);
+ CSR_WRITE_4(sc, AML_MMC_IRQ_CONFIG_REG, icr);
+ CSR_BARRIER(sc, AML_MMC_IRQ_CONFIG_REG);
}
static int
@@ -191,7 +221,6 @@ aml8726_mmc_start_command(struct aml8726_mmc_softc *sc, struct mmc_command *cmd)
uint32_t block_size;
uint32_t bus_width;
uint32_t cmdr;
- uint32_t cycles_per_msec;
uint32_t extr;
uint32_t mcfgr;
uint32_t nbits_per_pkg;
@@ -203,14 +232,9 @@ aml8726_mmc_start_command(struct aml8726_mmc_softc *sc, struct mmc_command *cmd)
return (MMC_ERR_INVALID);
/*
- * Ensure the hardware state machine is in a known state,
- * the command done interrupt is enabled, and previous
- * IRQ status bits have been cleared.
+ * Ensure the hardware state machine is in a known state.
*/
- CSR_WRITE_4(sc, AML_MMC_IRQ_CONFIG_REG,
- (AML_MMC_IRQ_CONFIG_SOFT_RESET | AML_MMC_IRQ_CONFIG_CMD_DONE_EN));
- CSR_BARRIER(sc, AML_MMC_IRQ_CONFIG_REG);
- CSR_WRITE_4(sc, AML_MMC_IRQ_STATUS_REG, AML_MMC_IRQ_STATUS_CLEAR_IRQ);
+ aml8726_mmc_soft_reset(sc, true);
/*
* Start and transmission bits are per section 4.7.2 of the:
@@ -225,6 +249,13 @@ aml8726_mmc_start_command(struct aml8726_mmc_softc *sc, struct mmc_command *cmd)
mcfgr = sc->port;
timeout = AML_MMC_CMD_TIMEOUT;
+ /*
+ * If this is a linked command, then use the previous timeout.
+ */
+ if (cmd == cmd->mrq->stop && sc->stop_timeout)
+ timeout = sc->stop_timeout;
+ sc->stop_timeout = 0;
+
if ((cmd->flags & MMC_RSP_136) != 0) {
cmdr |= AML_MMC_CMD_RESP_CRC7_FROM_8;
cmdr |= (133 << AML_MMC_CMD_RESP_BITS_SHIFT);
@@ -291,32 +322,24 @@ aml8726_mmc_start_command(struct aml8726_mmc_softc *sc, struct mmc_command *cmd)
timeout = AML_MMC_WRITE_TIMEOUT *
(data->len / block_size);
}
+
+ /*
+ * Stop terminates a multiblock read / write and thus
+ * can take as long to execute as an actual read / write.
+ */
+ if (cmd->mrq->stop != NULL)
+ sc->stop_timeout = timeout;
}
sc->cmd = cmd;
cmd->error = MMC_ERR_NONE;
- /*
- * Round up while calculating the number of cycles which
- * correspond to a millisecond. Use that to determine
- * the count from the desired timeout in milliseconds.
- *
- * The counter has a limited range which is not sufficient
- * for directly implementing worst case timeouts at high clock
- * rates so a 32 bit counter is implemented in software.
- *
- * The documentation isn't clear on when the timer starts
- * so add 48 cycles for the command and 136 cycles for the
- * response (the values are from the previously mentioned
- * standard).
- */
if (timeout > AML_MMC_MAX_TIMEOUT)
timeout = AML_MMC_MAX_TIMEOUT;
- cycles_per_msec = (ios->clock + 1000 - 1) / 1000;
- sc->timeout_remaining = 48 + 136 + timeout * cycles_per_msec;
- aml8726_mmc_restart_timer(sc);
+ callout_reset(&sc->ch, MSECS_TO_TICKS(timeout),
+ aml8726_mmc_timeout, sc);
CSR_WRITE_4(sc, AML_MMC_CMD_ARGUMENT_REG, cmd->arg);
CSR_WRITE_4(sc, AML_MMC_MULT_CONFIG_REG, mcfgr);
@@ -330,20 +353,96 @@ aml8726_mmc_start_command(struct aml8726_mmc_softc *sc, struct mmc_command *cmd)
}
static void
-aml8726_mmc_intr(void *arg)
+aml8726_mmc_finish_command(struct aml8726_mmc_softc *sc, int mmc_error)
{
- struct aml8726_mmc_softc *sc = (struct aml8726_mmc_softc *)arg;
+ int mmc_stop_error;
struct mmc_command *cmd;
struct mmc_command *stop_cmd;
struct mmc_data *data;
+
+ AML_MMC_LOCK_ASSERT(sc);
+
+ /* Clear all interrupts since the request is no longer in flight. */
+ CSR_WRITE_4(sc, AML_MMC_IRQ_STATUS_REG, AML_MMC_IRQ_STATUS_CLEAR_IRQ);
+ CSR_BARRIER(sc, AML_MMC_IRQ_STATUS_REG);
+
+ /* In some cases (e.g. finish called via timeout) this is a NOP. */
+ callout_stop(&sc->ch);
+
+ cmd = sc->cmd;
+ sc->cmd = NULL;
+
+ cmd->error = mmc_error;
+
+ data = cmd->data;
+
+ if (data && data->len &&
+ (data->flags & (MMC_DATA_READ | MMC_DATA_WRITE)) != 0) {
+ if ((data->flags & MMC_DATA_READ) != 0)
+ bus_dmamap_sync(sc->dmatag, sc->dmamap,
+ BUS_DMASYNC_POSTREAD);
+ else
+ bus_dmamap_sync(sc->dmatag, sc->dmamap,
+ BUS_DMASYNC_POSTWRITE);
+ bus_dmamap_unload(sc->dmatag, sc->dmamap);
+ }
+
+ /*
+ * If there's a linked stop command, then start the stop command.
+ * In order to establish a known state attempt the stop command
+ * even if the original request encountered an error.
+ */
+
+ stop_cmd = (cmd->mrq->stop != cmd) ? cmd->mrq->stop : NULL;
+
+ if (stop_cmd != NULL) {
+ mmc_stop_error = aml8726_mmc_start_command(sc, stop_cmd);
+ if (mmc_stop_error == MMC_ERR_NONE) {
+ AML_MMC_UNLOCK(sc);
+ return;
+ }
+ stop_cmd->error = mmc_stop_error;
+ }
+
+ AML_MMC_UNLOCK(sc);
+
+ /* Execute the callback after dropping the lock. */
+ if (cmd->mrq)
+ cmd->mrq->done(cmd->mrq);
+}
+
+static void
+aml8726_mmc_timeout(void *arg)
+{
+ struct aml8726_mmc_softc *sc = (struct aml8726_mmc_softc *)arg;
+
+ /*
+ * The command failed to complete in time so forcefully
+ * terminate it.
+ */
+ aml8726_mmc_soft_reset(sc, false);
+
+ /*
+ * Ensure the command has terminated before continuing on
+ * to things such as bus_dmamap_sync / bus_dmamap_unload.
+ */
+ while ((CSR_READ_4(sc, AML_MMC_IRQ_STATUS_REG) &
+ AML_MMC_IRQ_STATUS_CMD_BUSY) != 0)
+ cpu_spinwait();
+
+ aml8726_mmc_finish_command(sc, MMC_ERR_TIMEOUT);
+}
+
+static void
+aml8726_mmc_intr(void *arg)
+{
+ struct aml8726_mmc_softc *sc = (struct aml8726_mmc_softc *)arg;
uint32_t cmdr;
- uint32_t icr;
uint32_t isr;
uint32_t mcfgr;
uint32_t previous_byte;
uint32_t resp;
int mmc_error;
- int mmc_stop_error;
unsigned int i;
AML_MMC_LOCK(sc);
@@ -367,12 +466,6 @@ aml8726_mmc_intr(void *arg)
if ((cmdr & AML_MMC_CMD_CMD_HAS_DATA) != 0 &&
(isr & AML_MMC_IRQ_STATUS_WR_CRC16_OK) == 0)
mmc_error = MMC_ERR_BADCRC;
- } else if ((isr & AML_MMC_IRQ_STATUS_TIMEOUT_IRQ) != 0) {
- if (aml8726_mmc_restart_timer(sc) != 0) {
- AML_MMC_UNLOCK(sc);
- return;
- }
- mmc_error = MMC_ERR_TIMEOUT;
} else {
spurious:
@@ -389,49 +482,12 @@ spurious:
return;
}
- if ((isr & AML_MMC_IRQ_STATUS_CMD_BUSY) != 0 &&
- /*
- * A multiblock operation may keep the hardware
- * busy until stop transmission is executed.
- */
- (isr & AML_MMC_IRQ_STATUS_CMD_DONE_IRQ) == 0) {
- if (mmc_error == MMC_ERR_NONE)
- mmc_error = MMC_ERR_FAILED;
-
- /*
- * Issue a soft reset (while leaving the command complete
- * interrupt enabled) to terminate the command.
- *
- * Ensure the command has terminated before continuing on
- * to things such as bus_dmamap_sync / bus_dmamap_unload.
- */
-
- icr = AML_MMC_IRQ_CONFIG_SOFT_RESET |
- AML_MMC_IRQ_CONFIG_CMD_DONE_EN;
-
- CSR_WRITE_4(sc, AML_MMC_IRQ_CONFIG_REG, icr);
-
- while ((CSR_READ_4(sc, AML_MMC_IRQ_STATUS_REG) &
- AML_MMC_IRQ_STATUS_CMD_BUSY) != 0)
- cpu_spinwait();
- }
-
- /* Clear all interrupts since the request is no longer in flight. */
- CSR_WRITE_4(sc, AML_MMC_IRQ_STATUS_REG, AML_MMC_IRQ_STATUS_CLEAR_IRQ);
- CSR_BARRIER(sc, AML_MMC_IRQ_STATUS_REG);
-
- cmd = sc->cmd;
- sc->cmd = NULL;
-
- cmd->error = mmc_error;
-
- if ((cmd->flags & MMC_RSP_PRESENT) != 0 &&
- mmc_error == MMC_ERR_NONE) {
+ if ((cmdr & AML_MMC_CMD_RESP_BITS_MASK) != 0) {
mcfgr = sc->port;
mcfgr |= AML_MMC_MULT_CONFIG_RESP_READOUT_EN;
CSR_WRITE_4(sc, AML_MMC_MULT_CONFIG_REG, mcfgr);
- if ((cmd->flags & MMC_RSP_136) != 0) {
+ if ((cmdr & AML_MMC_CMD_RESP_CRC7_FROM_8) != 0) {
/*
* Controller supplies 135:8 instead of
@@ -444,48 +500,39 @@ spurious:
for (i = 0; i < 4; i++) {
resp = CSR_READ_4(sc, AML_MMC_CMD_ARGUMENT_REG);
- cmd->resp[3 - i] = (resp << 8) | previous_byte;
+ sc->cmd->resp[3 - i] = (resp << 8) |
+ previous_byte;
previous_byte = (resp >> 24) & 0xff;
}
} else
- cmd->resp[0] = CSR_READ_4(sc, AML_MMC_CMD_ARGUMENT_REG);
+ sc->cmd->resp[0] = CSR_READ_4(sc,
+ AML_MMC_CMD_ARGUMENT_REG);
}
- data = cmd->data;
-
- if (data && data->len &&
- (data->flags & (MMC_DATA_READ | MMC_DATA_WRITE)) != 0) {
- if ((data->flags & MMC_DATA_READ) != 0)
- bus_dmamap_sync(sc->dmatag, sc->dmamap,
- BUS_DMASYNC_POSTREAD);
- else
- bus_dmamap_sync(sc->dmatag, sc->dmamap,
- BUS_DMASYNC_POSTWRITE);
- bus_dmamap_unload(sc->dmatag, sc->dmamap);
- }
+ if ((isr & AML_MMC_IRQ_STATUS_CMD_BUSY) != 0 &&
+ /*
+ * A multiblock operation may keep the hardware
+ * busy until stop transmission is executed.
+ */
+ (isr & AML_MMC_IRQ_STATUS_CMD_DONE_IRQ) == 0) {
+ if (mmc_error == MMC_ERR_NONE)
+ mmc_error = MMC_ERR_FAILED;
- /*
- * If there's a linked stop command, then start the stop command.
- * In order to establish a known state attempt the stop command
- * even if the original request encountered an error.
- */
+ /*
+ * Issue a soft reset to terminate the command.
+ *
+ * Ensure the command has terminated before continuing on
+ * to things such as bus_dmamap_sync / bus_dmamap_unload.
+ */
- stop_cmd = (cmd->mrq->stop != cmd) ? cmd->mrq->stop : NULL;
+ aml8726_mmc_soft_reset(sc, false);
- if (stop_cmd != NULL) {
- mmc_stop_error = aml8726_mmc_start_command(sc, stop_cmd);
- if (mmc_stop_error == MMC_ERR_NONE) {
- AML_MMC_UNLOCK(sc);
- return;
- }
- stop_cmd->error = mmc_stop_error;
+ while ((CSR_READ_4(sc, AML_MMC_IRQ_STATUS_REG) &
+ AML_MMC_IRQ_STATUS_CMD_BUSY) != 0)
+ cpu_spinwait();
}
- AML_MMC_UNLOCK(sc);
-
- /* Execute the callback after dropping the lock. */
- if (cmd->mrq)
- cmd->mrq->done(cmd->mrq);
+ aml8726_mmc_finish_command(sc, mmc_error);
}
static int
@@ -698,8 +745,10 @@ aml8726_mmc_attach(device_t dev)
goto fail;
}
- sc->host.f_min = 200000;
- sc->host.f_max = 50000000;
+ callout_init_mtx(&sc->ch, &sc->mtx, CALLOUT_RETURNUNLOCKED);
+
+ sc->host.f_min = aml8726_mmc_freq(sc, aml8726_mmc_div(sc, 200000));
+ sc->host.f_max = aml8726_mmc_freq(sc, aml8726_mmc_div(sc, 50000000));
sc->host.host_ocr = sc->voltages[0] | sc->voltages[1];
sc->host.caps = MMC_CAP_4_BIT_DATA | MMC_CAP_HSPEED;
@@ -756,10 +805,12 @@ aml8726_mmc_detach(device_t dev)
* disable the interrupts, and clear the interrupts.
*/
(void)aml8726_mmc_power_off(sc);
- CSR_WRITE_4(sc, AML_MMC_IRQ_CONFIG_REG, AML_MMC_IRQ_CONFIG_SOFT_RESET);
- CSR_BARRIER(sc, AML_MMC_IRQ_CONFIG_REG);
+ aml8726_mmc_soft_reset(sc, false);
CSR_WRITE_4(sc, AML_MMC_IRQ_STATUS_REG, AML_MMC_IRQ_STATUS_CLEAR_IRQ);
+ /* This should be a NOP since no command was in flight. */
+ callout_stop(&sc->ch);
+
AML_MMC_UNLOCK(sc);
bus_generic_detach(dev);
@@ -787,8 +838,7 @@ aml8726_mmc_shutdown(device_t dev)
* disable the interrupts, and clear the interrupts.
*/
(void)aml8726_mmc_power_off(sc);
- CSR_WRITE_4(sc, AML_MMC_IRQ_CONFIG_REG, AML_MMC_IRQ_CONFIG_SOFT_RESET);
- CSR_BARRIER(sc, AML_MMC_IRQ_CONFIG_REG);
+ aml8726_mmc_soft_reset(sc, false);
CSR_WRITE_4(sc, AML_MMC_IRQ_STATUS_REG, AML_MMC_IRQ_STATUS_CLEAR_IRQ);
return (0);
@@ -799,7 +849,6 @@ aml8726_mmc_update_ios(device_t bus, device_t child)
{
struct aml8726_mmc_softc *sc = device_get_softc(bus);
struct mmc_ios *ios = &sc->host.ios;
- unsigned int divisor;
int error;
int i;
uint32_t cfgr;
@@ -820,15 +869,8 @@ aml8726_mmc_update_ios(device_t bus, device_t child)
return (EINVAL);
}
- divisor = sc->ref_freq / (ios->clock * 2) - 1;
- if (divisor == 0 || divisor == -1)
- divisor = 1;
- if ((sc->ref_freq / ((divisor + 1) * 2)) > ios->clock)
- divisor += 1;
- if (divisor > 0x3ff)
- divisor = 0x3ff;
-
- cfgr |= divisor;
+ cfgr |= aml8726_mmc_div(sc, ios->clock) <<
+ AML_MMC_CONFIG_CMD_CLK_DIV_SHIFT;
CSR_WRITE_4(sc, AML_MMC_CONFIG_REG, cfgr);
diff --git a/sys/arm/amlogic/aml8726/aml8726_mmc.h b/sys/arm/amlogic/aml8726/aml8726_mmc.h
index 0370943..64e3bae 100644
--- a/sys/arm/amlogic/aml8726/aml8726_mmc.h
+++ b/sys/arm/amlogic/aml8726/aml8726_mmc.h
@@ -47,20 +47,6 @@
#define AML_MMC_WRITE_TIMEOUT 500
#define AML_MMC_MAX_TIMEOUT 5000
-/*
- * Internally the timeout is implemented by counting clock cycles.
- *
- * Since the hardware implements timeouts by counting cycles
- * the minimum read / write timeout (assuming the minimum
- * conversion factor of 1 cycle per usec) is:
- *
- * (8 bits * 512 bytes per block + 16 bits CRC) = 4112 usec
- */
-#if ((AML_MMC_READ_TIMEOUT * 1000) < 4112 || \
- (AML_MMC_WRITE_TIMEOUT * 1000) < 4112)
-#error "Single block timeout is smaller than supported"
-#endif
-
#define AML_MMC_CMD_ARGUMENT_REG 0
#define AML_MMC_CMD_SEND_REG 4
diff --git a/sys/arm/amlogic/aml8726/aml8726_pic.c b/sys/arm/amlogic/aml8726/aml8726_pic.c
index 5ef1403..70257f7 100644
--- a/sys/arm/amlogic/aml8726/aml8726_pic.c
+++ b/sys/arm/amlogic/aml8726/aml8726_pic.c
@@ -121,6 +121,8 @@ aml8726_pic_eoi(void *arg)
if (nb >= AML_PIC_NIRQS)
return;
+ arm_irq_memory_barrier(nb);
+
CSR_WRITE_4(aml8726_pic_sc, AML_PIC_STAT_CLR_REG(nb), AML_PIC_BIT(nb));
CSR_BARRIER(aml8726_pic_sc, AML_PIC_STAT_CLR_REG(nb));
@@ -167,7 +169,7 @@ aml8726_pic_attach(device_t dev)
CSR_WRITE_4(sc, AML_PIC_0_FIRQ_SEL + i * 16, 0);
}
-#ifndef SMP
+#ifndef DEV_GIC
arm_post_filter = aml8726_pic_eoi;
#else
device_printf(dev, "disabled in favor of gic\n");
@@ -205,7 +207,7 @@ static devclass_t aml8726_pic_devclass;
EARLY_DRIVER_MODULE(pic, simplebus, aml8726_pic_driver, aml8726_pic_devclass,
0, 0, BUS_PASS_INTERRUPT);
-#ifndef SMP
+#ifndef DEV_GIC
int
arm_get_next_irq(int last)
{
@@ -265,8 +267,12 @@ arm_unmask_irq(uintptr_t nb)
if (nb >= AML_PIC_NIRQS)
return;
+ arm_irq_memory_barrier(nb);
+
mask = CSR_READ_4(aml8726_pic_sc, AML_PIC_MASK_REG(nb));
mask |= AML_PIC_BIT(nb);
CSR_WRITE_4(aml8726_pic_sc, AML_PIC_MASK_REG(nb), mask);
+
+ CSR_BARRIER(aml8726_pic_sc, AML_PIC_MASK_REG(nb));
}
#endif
diff --git a/sys/arm/amlogic/aml8726/aml8726_pinctrl.c b/sys/arm/amlogic/aml8726/aml8726_pinctrl.c
index db87093..63af2f1 100644
--- a/sys/arm/amlogic/aml8726/aml8726_pinctrl.c
+++ b/sys/arm/amlogic/aml8726/aml8726_pinctrl.c
@@ -146,7 +146,6 @@ aml8726_pinctrl_attach(device_t dev)
device_printf(dev, "unsupported SoC\n");
return (ENXIO);
/* NOTREACHED */
- break;
}
if (bus_alloc_resources(dev, aml8726_pinctrl_spec, sc->res)) {
diff --git a/sys/arm/amlogic/aml8726/aml8726_rng.c b/sys/arm/amlogic/aml8726/aml8726_rng.c
index b5a44e3..e3397aa 100644
--- a/sys/arm/amlogic/aml8726/aml8726_rng.c
+++ b/sys/arm/amlogic/aml8726/aml8726_rng.c
@@ -115,7 +115,7 @@ aml8726_rng_attach(device_t dev)
else
sc->ticks = 1;
- callout_init(&sc->co, CALLOUT_MPSAFE);
+ callout_init(&sc->co, 1);
callout_reset(&sc->co, sc->ticks, aml8726_rng_harvest, sc);
return (0);
diff --git a/sys/arm/amlogic/aml8726/aml8726_rtc.c b/sys/arm/amlogic/aml8726/aml8726_rtc.c
index fe12463..5af51ce 100644
--- a/sys/arm/amlogic/aml8726/aml8726_rtc.c
+++ b/sys/arm/amlogic/aml8726/aml8726_rtc.c
@@ -51,6 +51,8 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
+#include <arm/amlogic/aml8726/aml8726_soc.h>
+
#include "clock_if.h"
/*
@@ -372,44 +374,27 @@ static int
aml8726_rtc_attach(device_t dev)
{
struct aml8726_rtc_softc *sc = device_get_softc(dev);
- boolean_t init_always_valid;
- char *init_always;
- pcell_t prop;
- phandle_t node;
- ssize_t len;
sc->dev = dev;
- node = ofw_bus_get_node(dev);
-
- len = OF_getprop_alloc(node, "init-always",
- sizeof(char), (void **)&init_always);
- sc->init.always = FALSE;
- init_always_valid = FALSE;
- if (len > 0) {
- if (strncmp(init_always, "true", len) == 0) {
- sc->init.always = TRUE;
- init_always_valid = TRUE;
- } else if (strncmp(init_always, "false", len) == 0)
- init_always_valid = TRUE;
- free(init_always, M_OFWPROP);
- }
- if (init_always_valid == FALSE) {
- device_printf(dev, "missing init-always attribute in FDT\n");
- return (ENXIO);
- }
-
- if (OF_getencprop(node, "xo-init", &prop, sizeof(prop)) <= 0) {
- device_printf(dev, "missing xo-init attribute in FDT\n");
- return (ENXIO);
- }
- sc->init.xo = prop;
-
- if (OF_getencprop(node, "gpo-init", &prop, sizeof(prop)) <= 0) {
- device_printf(dev, "missing gpo-init attribute in FDT\n");
+ switch (aml8726_soc_hw_rev) {
+ case AML_SOC_HW_REV_M3:
+ sc->init.always = true;
+ sc->init.xo = 0x3c0a;
+ sc->init.gpo = 0x100000;
+ break;
+ case AML_SOC_HW_REV_M6:
+ case AML_SOC_HW_REV_M8:
+ case AML_SOC_HW_REV_M8B:
+ sc->init.always = false;
+ sc->init.xo = 0x180a;
+ sc->init.gpo = 0x500000;
+ break;
+ default:
+ device_printf(dev, "unsupported SoC\n");
return (ENXIO);
+ /* NOTREACHED */
}
- sc->init.gpo = prop;
if (bus_alloc_resources(dev, aml8726_rtc_spec, sc->res)) {
device_printf(dev, "can not allocate resources for device\n");
diff --git a/sys/arm/amlogic/aml8726/aml8726_sdxc-m8.c b/sys/arm/amlogic/aml8726/aml8726_sdxc-m8.c
index 4204275..a1bb274 100644
--- a/sys/arm/amlogic/aml8726/aml8726_sdxc-m8.c
+++ b/sys/arm/amlogic/aml8726/aml8726_sdxc-m8.c
@@ -758,7 +758,6 @@ aml8726_sdxc_attach(device_t dev)
device_printf(dev, "unsupported SoC\n");
return (ENXIO);
/* NOTREACHED */
- break;
}
node = ofw_bus_get_node(dev);
diff --git a/sys/arm/amlogic/aml8726/aml8726_uart.h b/sys/arm/amlogic/aml8726/aml8726_uart.h
index ee63325..fbdd657 100644
--- a/sys/arm/amlogic/aml8726/aml8726_uart.h
+++ b/sys/arm/amlogic/aml8726/aml8726_uart.h
@@ -94,4 +94,14 @@
#define AML_UART_MISC_RECV_IRQ_CNT_MASK 0xff
#define AML_UART_MISC_RECV_IRQ_CNT_SHIFT 0
+/*
+ * The new baud rate register is available on the
+ * aml8726-m6 and later.
+ */
+#define AML_UART_NEW_BAUD_REG 20
+#define AML_UART_NEW_BAUD_USE_XTAL_CLK (1 << 24)
+#define AML_UART_NEW_BAUD_RATE_EN (1 << 23)
+#define AML_UART_NEW_BAUD_RATE_MASK (0x7fffff << 0)
+#define AML_UART_NEW_BAUD_RATE_SHIFT 0
+
#endif /* _ARM_AMLOGIC_AML8726_UART_H */
diff --git a/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c b/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c
new file mode 100644
index 0000000..c428943
--- /dev/null
+++ b/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c
@@ -0,0 +1,428 @@
+/*-
+ * Copyright 2014-2015 John Wehle <john@feith.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.
+ *
+ * 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.
+ */
+
+/*
+ * Amlogic aml8726-m3 USB physical layer driver.
+ *
+ * Both USB physical interfaces share the same configuration register.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/resource.h>
+#include <sys/rman.h>
+
+#include <sys/gpio.h>
+
+#include <machine/bus.h>
+#include <machine/cpu.h>
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include "gpio_if.h"
+
+struct aml8726_usb_phy_gpio {
+ device_t dev;
+ uint32_t pin;
+ uint32_t pol;
+};
+
+struct aml8726_usb_phy_softc {
+ device_t dev;
+ struct resource *res[1];
+ uint32_t npwr_en;
+ struct aml8726_usb_phy_gpio *pwr_en;
+};
+
+static struct resource_spec aml8726_usb_phy_spec[] = {
+ { SYS_RES_MEMORY, 0, RF_ACTIVE },
+ { -1, 0 }
+};
+
+#define AML_USB_PHY_CFG_REG 0
+#define AML_USB_PHY_CFG_A_CLK_DETECTED (1U << 31)
+#define AML_USB_PHY_CFG_CLK_DIV_MASK (0x7f << 24)
+#define AML_USB_PHY_CFG_CLK_DIV_SHIFT 24
+#define AML_USB_PHY_CFG_B_CLK_DETECTED (1 << 22)
+#define AML_USB_PHY_CFG_A_PLL_RST (1 << 19)
+#define AML_USB_PHY_CFG_A_PHYS_RST (1 << 18)
+#define AML_USB_PHY_CFG_A_RST (1 << 17)
+#define AML_USB_PHY_CFG_B_PLL_RST (1 << 13)
+#define AML_USB_PHY_CFG_B_PHYS_RST (1 << 12)
+#define AML_USB_PHY_CFG_B_RST (1 << 11)
+#define AML_USB_PHY_CFG_CLK_EN (1 << 8)
+#define AML_USB_PHY_CFG_CLK_SEL_MASK (7 << 5)
+#define AML_USB_PHY_CFG_CLK_SEL_XTAL (0 << 5)
+#define AML_USB_PHY_CFG_CLK_SEL_XTAL_DIV2 (1 << 5)
+#define AML_USB_PHY_CFG_B_POR (1 << 1)
+#define AML_USB_PHY_CFG_A_POR (1 << 0)
+
+#define AML_USB_PHY_CFG_CLK_DETECTED \
+ (AML_USB_PHY_CFG_A_CLK_DETECTED | AML_USB_PHY_CFG_B_CLK_DETECTED)
+
+#define AML_USB_PHY_MISC_A_REG 12
+#define AML_USB_PHY_MISC_B_REG 16
+#define AML_USB_PHY_MISC_ID_OVERIDE_EN (1 << 23)
+#define AML_USB_PHY_MISC_ID_OVERIDE_DEVICE (1 << 22)
+#define AML_USB_PHY_MISC_ID_OVERIDE_HOST (0 << 22)
+
+#define CSR_WRITE_4(sc, reg, val) bus_write_4((sc)->res[0], reg, (val))
+#define CSR_READ_4(sc, reg) bus_read_4((sc)->res[0], reg)
+#define CSR_BARRIER(sc, reg) bus_barrier((sc)->res[0], reg, 4, \
+ (BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE))
+
+#define PIN_ON_FLAG(pol) ((pol) == 0 ? \
+ GPIO_PIN_LOW : GPIO_PIN_HIGH)
+#define PIN_OFF_FLAG(pol) ((pol) == 0 ? \
+ GPIO_PIN_HIGH : GPIO_PIN_LOW)
+
+static int
+aml8726_usb_phy_mode(const char *dwcotg_path, uint32_t *mode)
+{
+ char *usb_mode;
+ phandle_t node;
+ ssize_t len;
+
+ if ((node = OF_finddevice(dwcotg_path)) == 0)
+ return (ENXIO);
+
+ if (fdt_is_compatible_strict(node, "synopsys,designware-hs-otg2") == 0)
+ return (ENXIO);
+
+ *mode = 0;
+
+ len = OF_getprop_alloc(node, "dr_mode",
+ sizeof(char), (void **)&usb_mode);
+
+ if (len <= 0)
+ return (0);
+
+ if (strcasecmp(usb_mode, "host") == 0) {
+ *mode = AML_USB_PHY_MISC_ID_OVERIDE_EN |
+ AML_USB_PHY_MISC_ID_OVERIDE_HOST;
+ } else if (strcasecmp(usb_mode, "peripheral") == 0) {
+ *mode = AML_USB_PHY_MISC_ID_OVERIDE_EN |
+ AML_USB_PHY_MISC_ID_OVERIDE_DEVICE;
+ }
+
+ free(usb_mode, M_OFWPROP);
+
+ return (0);
+}
+
+static int
+aml8726_usb_phy_probe(device_t dev)
+{
+
+ if (!ofw_bus_status_okay(dev))
+ return (ENXIO);
+
+ if (!ofw_bus_is_compatible(dev, "amlogic,aml8726-m3-usb-phy"))
+ return (ENXIO);
+
+ device_set_desc(dev, "Amlogic aml8726-m3 USB PHY");
+
+ return (BUS_PROBE_DEFAULT);
+}
+
+static int
+aml8726_usb_phy_attach(device_t dev)
+{
+ struct aml8726_usb_phy_softc *sc = device_get_softc(dev);
+ int err;
+ int npwr_en;
+ pcell_t *prop;
+ phandle_t node;
+ ssize_t len;
+ uint32_t div;
+ uint32_t i;
+ uint32_t mode_a;
+ uint32_t mode_b;
+ uint32_t value;
+
+ sc->dev = dev;
+
+ if (aml8726_usb_phy_mode("/soc/usb@c9040000", &mode_a) != 0) {
+ device_printf(dev, "missing usb@c9040000 node in FDT\n");
+ return (ENXIO);
+ }
+
+ if (aml8726_usb_phy_mode("/soc/usb@c90c0000", &mode_b) != 0) {
+ device_printf(dev, "missing usb@c90c0000 node in FDT\n");
+ return (ENXIO);
+ }
+
+ if (bus_alloc_resources(dev, aml8726_usb_phy_spec, sc->res)) {
+ device_printf(dev, "can not allocate resources for device\n");
+ return (ENXIO);
+ }
+
+ node = ofw_bus_get_node(dev);
+
+ err = 0;
+
+ len = OF_getencprop_alloc(node, "usb-pwr-en",
+ 3 * sizeof(pcell_t), (void **)&prop);
+ npwr_en = (len > 0) ? len : 0;
+
+ sc->npwr_en = 0;
+ sc->pwr_en = (struct aml8726_usb_phy_gpio *)
+ malloc(npwr_en * sizeof (*sc->pwr_en), M_DEVBUF, M_WAITOK);
+
+ for (i = 0; i < npwr_en; i++) {
+ sc->pwr_en[i].dev = OF_device_from_xref(prop[i * 3]);
+ sc->pwr_en[i].pin = prop[i * 3 + 1];
+ sc->pwr_en[i].pol = prop[i * 3 + 2];
+
+ if (sc->pwr_en[i].dev == NULL) {
+ err = 1;
+ break;
+ }
+ }
+
+ free(prop, M_OFWPROP);
+
+ if (err) {
+ device_printf(dev, "unable to parse gpio\n");
+ goto fail;
+ }
+
+ /* Turn on power by setting pin and then enabling output driver. */
+ for (i = 0; i < npwr_en; i++) {
+ if (GPIO_PIN_SET(sc->pwr_en[i].dev, sc->pwr_en[i].pin,
+ PIN_ON_FLAG(sc->pwr_en[i].pol)) != 0 ||
+ GPIO_PIN_SETFLAGS(sc->pwr_en[i].dev, sc->pwr_en[i].pin,
+ GPIO_PIN_OUTPUT) != 0) {
+ device_printf(dev,
+ "could not use gpio to control power\n");
+ goto fail;
+ }
+
+ sc->npwr_en++;
+ }
+
+ /*
+ * Configure the clock source and divider.
+ */
+
+ div = 2;
+
+ value = CSR_READ_4(sc, AML_USB_PHY_CFG_REG);
+
+ value &= ~(AML_USB_PHY_CFG_CLK_DIV_MASK | AML_USB_PHY_CFG_CLK_SEL_MASK);
+
+ value &= ~(AML_USB_PHY_CFG_A_RST | AML_USB_PHY_CFG_B_RST);
+ value &= ~(AML_USB_PHY_CFG_A_PLL_RST | AML_USB_PHY_CFG_B_PLL_RST);
+ value &= ~(AML_USB_PHY_CFG_A_PHYS_RST | AML_USB_PHY_CFG_B_PHYS_RST);
+ value &= ~(AML_USB_PHY_CFG_A_POR | AML_USB_PHY_CFG_B_POR);
+
+ value |= AML_USB_PHY_CFG_CLK_SEL_XTAL;
+ value |= ((div - 1) << AML_USB_PHY_CFG_CLK_DIV_SHIFT) &
+ AML_USB_PHY_CFG_CLK_DIV_MASK;
+ value |= AML_USB_PHY_CFG_CLK_EN;
+
+ CSR_WRITE_4(sc, AML_USB_PHY_CFG_REG, value);
+ CSR_BARRIER(sc, AML_USB_PHY_CFG_REG);
+
+ /*
+ * Issue the reset sequence.
+ */
+
+ value |= (AML_USB_PHY_CFG_A_RST | AML_USB_PHY_CFG_B_RST);
+
+ CSR_WRITE_4(sc, AML_USB_PHY_CFG_REG, value);
+ CSR_BARRIER(sc, AML_USB_PHY_CFG_REG);
+
+ DELAY(200);
+
+ value &= ~(AML_USB_PHY_CFG_A_RST | AML_USB_PHY_CFG_B_RST);
+
+ CSR_WRITE_4(sc, AML_USB_PHY_CFG_REG, value);
+ CSR_BARRIER(sc, AML_USB_PHY_CFG_REG);
+
+ DELAY(200);
+
+ value |= (AML_USB_PHY_CFG_A_PLL_RST | AML_USB_PHY_CFG_B_PLL_RST);
+
+ CSR_WRITE_4(sc, AML_USB_PHY_CFG_REG, value);
+ CSR_BARRIER(sc, AML_USB_PHY_CFG_REG);
+
+ DELAY(200);
+
+ value &= ~(AML_USB_PHY_CFG_A_PLL_RST | AML_USB_PHY_CFG_B_PLL_RST);
+
+ CSR_WRITE_4(sc, AML_USB_PHY_CFG_REG, value);
+ CSR_BARRIER(sc, AML_USB_PHY_CFG_REG);
+
+ DELAY(200);
+
+ value |= (AML_USB_PHY_CFG_A_PHYS_RST | AML_USB_PHY_CFG_B_PHYS_RST);
+
+ CSR_WRITE_4(sc, AML_USB_PHY_CFG_REG, value);
+ CSR_BARRIER(sc, AML_USB_PHY_CFG_REG);
+
+ DELAY(200);
+
+ value &= ~(AML_USB_PHY_CFG_A_PHYS_RST | AML_USB_PHY_CFG_B_PHYS_RST);
+
+ CSR_WRITE_4(sc, AML_USB_PHY_CFG_REG, value);
+ CSR_BARRIER(sc, AML_USB_PHY_CFG_REG);
+
+ DELAY(200);
+
+ value |= (AML_USB_PHY_CFG_A_POR | AML_USB_PHY_CFG_B_POR);
+
+ CSR_WRITE_4(sc, AML_USB_PHY_CFG_REG, value);
+ CSR_BARRIER(sc, AML_USB_PHY_CFG_REG);
+
+ DELAY(200);
+
+ /*
+ * Enable by clearing the power on reset.
+ */
+
+ value &= ~(AML_USB_PHY_CFG_A_POR | AML_USB_PHY_CFG_B_POR);
+
+ CSR_WRITE_4(sc, AML_USB_PHY_CFG_REG, value);
+
+ CSR_BARRIER(sc, AML_USB_PHY_CFG_REG);
+
+ DELAY(200);
+
+ /*
+ * Check if the clock was detected.
+ */
+ value = CSR_READ_4(sc, AML_USB_PHY_CFG_REG);
+ if ((value & AML_USB_PHY_CFG_CLK_DETECTED) !=
+ AML_USB_PHY_CFG_CLK_DETECTED)
+ device_printf(dev, "PHY Clock not detected\n");
+
+ /*
+ * Configure the mode for each port.
+ */
+
+ value = CSR_READ_4(sc, AML_USB_PHY_MISC_A_REG);
+
+ value &= ~(AML_USB_PHY_MISC_ID_OVERIDE_EN |
+ AML_USB_PHY_MISC_ID_OVERIDE_DEVICE |
+ AML_USB_PHY_MISC_ID_OVERIDE_HOST);
+ value |= mode_a;
+
+ CSR_WRITE_4(sc, AML_USB_PHY_MISC_A_REG, value);
+
+ value = CSR_READ_4(sc, AML_USB_PHY_MISC_B_REG);
+
+ value &= ~(AML_USB_PHY_MISC_ID_OVERIDE_EN |
+ AML_USB_PHY_MISC_ID_OVERIDE_DEVICE |
+ AML_USB_PHY_MISC_ID_OVERIDE_HOST);
+ value |= mode_b;
+
+ CSR_WRITE_4(sc, AML_USB_PHY_MISC_B_REG, value);
+
+ CSR_BARRIER(sc, AML_USB_PHY_MISC_B_REG);
+
+ return (0);
+
+fail:
+ /* In the event of problems attempt to turn things back off. */
+ i = sc->npwr_en;
+ while (i-- != 0) {
+ GPIO_PIN_SET(sc->pwr_en[i].dev, sc->pwr_en[i].pin,
+ PIN_OFF_FLAG(sc->pwr_en[i].pol));
+ }
+
+ free (sc->pwr_en, M_DEVBUF);
+ sc->pwr_en = NULL;
+
+ bus_release_resources(dev, aml8726_usb_phy_spec, sc->res);
+
+ return (ENXIO);
+}
+
+static int
+aml8726_usb_phy_detach(device_t dev)
+{
+ struct aml8726_usb_phy_softc *sc = device_get_softc(dev);
+ uint32_t i;
+ uint32_t value;
+
+ /*
+ * Disable by issuing a power on reset.
+ */
+
+ value = CSR_READ_4(sc, AML_USB_PHY_CFG_REG);
+
+ value |= (AML_USB_PHY_CFG_A_POR | AML_USB_PHY_CFG_B_POR);
+
+ CSR_WRITE_4(sc, AML_USB_PHY_CFG_REG, value);
+
+ CSR_BARRIER(sc, AML_USB_PHY_CFG_REG);
+
+ /* Turn off power */
+ i = sc->npwr_en;
+ while (i-- != 0) {
+ (void)GPIO_PIN_SET(sc->pwr_en[i].dev, sc->pwr_en[i].pin,
+ PIN_OFF_FLAG(sc->pwr_en[i].pol));
+ }
+ free (sc->pwr_en, M_DEVBUF);
+ sc->pwr_en = NULL;
+
+ bus_release_resources(dev, aml8726_usb_phy_spec, sc->res);
+
+ return (0);
+}
+
+static device_method_t aml8726_usb_phy_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, aml8726_usb_phy_probe),
+ DEVMETHOD(device_attach, aml8726_usb_phy_attach),
+ DEVMETHOD(device_detach, aml8726_usb_phy_detach),
+
+ DEVMETHOD_END
+};
+
+static driver_t aml8726_usb_phy_driver = {
+ "usbphy",
+ aml8726_usb_phy_methods,
+ sizeof(struct aml8726_usb_phy_softc),
+};
+
+static devclass_t aml8726_usb_phy_devclass;
+
+DRIVER_MODULE(aml8726_m3usbphy, simplebus, aml8726_usb_phy_driver,
+ aml8726_usb_phy_devclass, 0, 0);
+MODULE_DEPEND(aml8726_m3usbphy, aml8726_gpio, 1, 1, 1);
diff --git a/sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c b/sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c
index 3493f14..7de23c4 100644
--- a/sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c
+++ b/sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c
@@ -181,8 +181,10 @@ aml8726_usb_phy_attach(device_t dev)
sc->pwr_en[i].pin = prop[i * 3 + 1];
sc->pwr_en[i].pol = prop[i * 3 + 2];
- if (sc->pwr_en[i].dev == NULL)
+ if (sc->pwr_en[i].dev == NULL) {
err = 1;
+ break;
+ }
}
free(prop, M_OFWPROP);
diff --git a/sys/arm/amlogic/aml8726/files.aml8726 b/sys/arm/amlogic/aml8726/files.aml8726
index ca058a5..e4bc31e 100644
--- a/sys/arm/amlogic/aml8726/files.aml8726
+++ b/sys/arm/amlogic/aml8726/files.aml8726
@@ -5,7 +5,6 @@ kern/kern_clocksource.c standard
arm/arm/bus_space_base.c standard
arm/arm/bus_space_generic.c standard
-arm/arm/gic.c standard
arm/arm/pl310.c standard
arm/amlogic/aml8726/aml8726_l2cache.c standard
@@ -14,7 +13,7 @@ arm/amlogic/aml8726/aml8726_mp.c optional smp
arm/amlogic/aml8726/aml8726_identsoc.c standard
arm/amlogic/aml8726/aml8726_ccm.c standard
arm/amlogic/aml8726/aml8726_clkmsr.c standard
-arm/amlogic/aml8726/aml8726_pic.c standard
+arm/amlogic/aml8726/aml8726_pic.c optional aml_pic
arm/amlogic/aml8726/aml8726_rtc.c standard
arm/amlogic/aml8726/aml8726_timer.c standard
arm/amlogic/aml8726/aml8726_wdt.c standard
@@ -31,6 +30,7 @@ arm/amlogic/aml8726/aml8726_sdxc-m8.c optional mmc gpio
arm/amlogic/aml8726/aml8726_pinctrl.c optional fdt_pinctrl
#arm/amlogic/aml8726/aml8726_rng.c optional random
arm/amlogic/aml8726/uart_dev_aml8726.c optional uart
+arm/amlogic/aml8726/aml8726_usb_phy-m3.c optional dwcotg usb gpio
arm/amlogic/aml8726/aml8726_usb_phy-m6.c optional dwcotg usb gpio
dev/dwc/if_dwc.c optional dwc
diff --git a/sys/arm/amlogic/aml8726/uart_dev_aml8726.c b/sys/arm/amlogic/aml8726/uart_dev_aml8726.c
index 1dda52f..5d21fb0 100644
--- a/sys/arm/amlogic/aml8726/uart_dev_aml8726.c
+++ b/sys/arm/amlogic/aml8726/uart_dev_aml8726.c
@@ -31,8 +31,8 @@
* uarts. For example ... though UART A as a 128 byte FIFO, the
* others only have a 64 byte FIFO.
*
- * Also, it's assumed that register 5 (the new baud rate register
- * present on the aml8726-m6) has not been activated.
+ * Also, it's assumed that the USE_XTAL_CLK feature (available on
+ * the aml8726-m6 and later) has not been activated.
*/
#include <sys/cdefs.h>
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
#include <dev/uart/uart_cpu_fdt.h>
#include <dev/uart/uart_bus.h>
+#include <arm/amlogic/aml8726/aml8726_soc.h>
#include <arm/amlogic/aml8726/aml8726_uart.h>
#include "uart_if.h"
@@ -89,7 +90,7 @@ aml8726_uart_divisor(int rclk, int baudrate)
/* integer version of (rclk / baudrate + .5) */
divisor = ((rclk << 1) + baudrate) / (baudrate << 1);
- if (divisor == 0 || divisor >= 65536)
+ if (divisor == 0)
return (0);
actual_baud = rclk / divisor;
@@ -109,6 +110,7 @@ aml8726_uart_param(struct uart_bas *bas, int baudrate, int databits, int stopbit
{
uint32_t cr;
uint32_t mr;
+ uint32_t nbr;
int divisor;
cr = uart_getreg(bas, AML_UART_CONTROL_REG);
@@ -147,8 +149,29 @@ aml8726_uart_param(struct uart_bas *bas, int baudrate, int databits, int stopbit
/* Set baudrate. */
if (baudrate > 0 && bas->rclk != 0) {
divisor = aml8726_uart_divisor(bas->rclk / 4, baudrate) - 1;
- if (divisor > 0xffff)
- return (EINVAL);
+
+ switch (aml8726_soc_hw_rev) {
+ case AML_SOC_HW_REV_M6:
+ case AML_SOC_HW_REV_M8:
+ case AML_SOC_HW_REV_M8B:
+ if (divisor > (AML_UART_NEW_BAUD_RATE_MASK >>
+ AML_UART_NEW_BAUD_RATE_SHIFT))
+ return (EINVAL);
+
+ nbr = uart_getreg(bas, AML_UART_NEW_BAUD_REG);
+ nbr &= ~(AML_UART_NEW_BAUD_USE_XTAL_CLK |
+ AML_UART_NEW_BAUD_RATE_MASK);
+ nbr |= AML_UART_NEW_BAUD_RATE_EN |
+ (divisor << AML_UART_NEW_BAUD_RATE_SHIFT);
+ uart_setreg(bas, AML_UART_NEW_BAUD_REG, nbr);
+
+ divisor = 0;
+ break;
+ default:
+ if (divisor > 0xffff)
+ return (EINVAL);
+ break;
+ }
cr &= ~AML_UART_CONTROL_BAUD_MASK;
cr |= (divisor & AML_UART_CONTROL_BAUD_MASK);
@@ -187,7 +210,7 @@ aml8726_uart_init(struct uart_bas *bas, int baudrate, int databits, int stopbits
uint32_t cr;
uint32_t mr;
- aml8726_uart_param(bas, baudrate, databits, stopbits, parity);
+ (void)aml8726_uart_param(bas, baudrate, databits, stopbits, parity);
cr = uart_getreg(bas, AML_UART_CONTROL_REG);
/* Disable all interrupt sources. */
@@ -466,7 +489,7 @@ aml8726_uart_bus_ioctl(struct uart_softc *sc, int request, intptr_t data)
{
struct uart_bas *bas;
int baudrate, divisor, error;
- uint32_t cr, mr;
+ uint32_t cr, mr, nbr;
bas = &sc->sc_bas;
uart_lock(sc->sc_hwmtx);
@@ -483,6 +506,20 @@ aml8726_uart_bus_ioctl(struct uart_softc *sc, int request, intptr_t data)
divisor = ((mr >> AML_UART_MISC_BAUD_EXT_SHIFT) <<
AML_UART_CONTROL_BAUD_WIDTH) | cr;
+ switch (aml8726_soc_hw_rev) {
+ case AML_SOC_HW_REV_M6:
+ case AML_SOC_HW_REV_M8:
+ case AML_SOC_HW_REV_M8B:
+ nbr = uart_getreg(bas, AML_UART_NEW_BAUD_REG);
+ if ((nbr & AML_UART_NEW_BAUD_RATE_EN) != 0) {
+ divisor = (nbr & AML_UART_NEW_BAUD_RATE_MASK) >>
+ AML_UART_NEW_BAUD_RATE_SHIFT;
+ }
+ break;
+ default:
+ break;
+ }
+
baudrate = bas->rclk / 4 / (divisor + 1);
if (baudrate > 0)
*(int*)data = baudrate;
diff --git a/sys/arm/annapurna/alpine/alpine_machdep.c b/sys/arm/annapurna/alpine/alpine_machdep.c
new file mode 100644
index 0000000..959b30f
--- /dev/null
+++ b/sys/arm/annapurna/alpine/alpine_machdep.c
@@ -0,0 +1,148 @@
+/*-
+ * Copyright (c) 2013 Ruslan Bukin <br@bsdpad.com>
+ * Copyright (c) 2015 Semihalf
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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.
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#define _ARM32_BUS_DMA_PRIVATE
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <machine/bus.h>
+#include <machine/frame.h> /* For trapframe_t, used in <machine/machdep.h> */
+#include <machine/machdep.h>
+#include <machine/pmap.h>
+#include <machine/devmap.h>
+#include <machine/platform.h>
+#include <machine/fdt.h>
+
+#include <dev/fdt/fdt_common.h>
+
+#include "opt_ddb.h"
+#include "opt_platform.h"
+
+struct mtx al_dbg_lock;
+
+#define DEVMAP_MAX_VA_ADDRESS 0xF0000000
+bus_addr_t al_devmap_pa;
+bus_addr_t al_devmap_size;
+
+#define AL_NB_SERVICE_OFFSET 0x70000
+#define AL_NB_CCU_OFFSET 0x90000
+#define AL_CCU_SNOOP_CONTROL_IOFAB_0_OFFSET 0x4000
+#define AL_CCU_SNOOP_CONTROL_IOFAB_1_OFFSET 0x5000
+#define AL_CCU_SPECULATION_CONTROL_OFFSET 0x4
+
+#define AL_NB_ACF_MISC_OFFSET 0xD0
+#define AL_NB_ACF_MISC_READ_BYPASS (1 << 30)
+
+int alpine_get_devmap_base(bus_addr_t *pa, bus_addr_t *size);
+
+vm_offset_t
+platform_lastaddr(void)
+{
+
+ return (DEVMAP_MAX_VA_ADDRESS);
+}
+
+void
+platform_probe_and_attach(void)
+{
+
+}
+
+void
+platform_gpio_init(void)
+{
+
+}
+
+void
+platform_late_init(void)
+{
+ bus_addr_t reg_baddr;
+ uint32_t val;
+
+ if (!mtx_initialized(&al_dbg_lock))
+ mtx_init(&al_dbg_lock, "ALDBG", "ALDBG", MTX_SPIN);
+
+ /* configure system fabric */
+ if (bus_space_map(fdtbus_bs_tag, al_devmap_pa, al_devmap_size, 0,
+ &reg_baddr))
+ panic("Couldn't map Register Space area");
+
+ /* do not allow reads to bypass writes to different addresses */
+ val = bus_space_read_4(fdtbus_bs_tag, reg_baddr,
+ AL_NB_SERVICE_OFFSET + AL_NB_ACF_MISC_OFFSET);
+ val &= ~AL_NB_ACF_MISC_READ_BYPASS;
+ bus_space_write_4(fdtbus_bs_tag, reg_baddr,
+ AL_NB_SERVICE_OFFSET + AL_NB_ACF_MISC_OFFSET, val);
+
+ /* enable cache snoop */
+ bus_space_write_4(fdtbus_bs_tag, reg_baddr,
+ AL_NB_CCU_OFFSET + AL_CCU_SNOOP_CONTROL_IOFAB_0_OFFSET, 1);
+ bus_space_write_4(fdtbus_bs_tag, reg_baddr,
+ AL_NB_CCU_OFFSET + AL_CCU_SNOOP_CONTROL_IOFAB_1_OFFSET, 1);
+
+ /* disable speculative fetches from masters */
+ bus_space_write_4(fdtbus_bs_tag, reg_baddr,
+ AL_NB_CCU_OFFSET + AL_CCU_SPECULATION_CONTROL_OFFSET, 7);
+
+ bus_space_unmap(fdtbus_bs_tag, reg_baddr, al_devmap_size);
+}
+
+/*
+ * Construct pmap_devmap[] with DT-derived config data.
+ */
+int
+platform_devmap_init(void)
+{
+ alpine_get_devmap_base(&al_devmap_pa, &al_devmap_size);
+ arm_devmap_add_entry(al_devmap_pa, al_devmap_size);
+ return (0);
+}
+
+struct arm32_dma_range *
+bus_dma_get_range(void)
+{
+
+ return (NULL);
+}
+
+int
+bus_dma_get_range_nb(void)
+{
+
+ return (0);
+}
diff --git a/sys/arm/annapurna/alpine/alpine_machdep_mp.c b/sys/arm/annapurna/alpine/alpine_machdep_mp.c
new file mode 100644
index 0000000..2c90917
--- /dev/null
+++ b/sys/arm/annapurna/alpine/alpine_machdep_mp.c
@@ -0,0 +1,335 @@
+/*-
+ * Copyright (c) 2013 Ruslan Bukin <br@bsdpad.com>
+ * Copyright (c) 2015 Semihalf
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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.
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/smp.h>
+#include <sys/cpuset.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <machine/smp.h>
+#include <machine/fdt.h>
+#include <machine/intr.h>
+#include <machine/cpu-v6.h>
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/ofw_cpu.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#define AL_CPU_RESUME_WATERMARK_REG 0x00
+#define AL_CPU_RESUME_FLAGS_REG 0x04
+#define AL_CPU_RESUME_PCPU_RADDR_REG(cpu) (0x08 + 0x04 + 8*(cpu))
+#define AL_CPU_RESUME_PCPU_FLAGS(cpu) (0x08 + 8*(cpu))
+
+/* Per-CPU flags */
+#define AL_CPU_RESUME_FLG_PERCPU_DONT_RESUME (1 << 2)
+
+/* The expected magic number for validating the resume addresses */
+#define AL_CPU_RESUME_MAGIC_NUM 0xf0e1d200
+#define AL_CPU_RESUME_MAGIC_NUM_MASK 0xffffff00
+
+/* The expected minimal version number for validating the capabilities */
+#define AL_CPU_RESUME_MIN_VER 0x000000c3
+#define AL_CPU_RESUME_MIN_VER_MASK 0x000000ff
+
+/* Field controlling the boot-up of companion cores */
+#define AL_NB_INIT_CONTROL (0x8)
+#define AL_NB_CONFIG_STATUS_PWR_CTRL(cpu) (0x2020 + (cpu)*0x100)
+
+#define SERDES_NUM_GROUPS 4
+#define SERDES_GROUP_SIZE 0x400
+
+extern bus_addr_t al_devmap_pa;
+extern bus_addr_t al_devmap_size;
+
+extern void mpentry(void);
+
+int alpine_serdes_resource_get(uint32_t group, bus_space_tag_t *tag,
+ bus_addr_t *baddr);
+static int platform_mp_get_core_cnt(void);
+static int alpine_get_cpu_resume_base(u_long *pbase, u_long *psize);
+static int alpine_get_nb_base(u_long *pbase, u_long *psize);
+static int alpine_get_serdes_base(u_long *pbase, u_long *psize);
+int alpine_serdes_resource_get(uint32_t group, bus_space_tag_t *tag,
+ bus_addr_t *baddr);
+static boolean_t alpine_validate_cpu(u_int, phandle_t, u_int, pcell_t *);
+
+static boolean_t
+alpine_validate_cpu(u_int id, phandle_t child, u_int addr_cell, pcell_t *reg)
+{
+ return fdt_is_compatible(child, "arm,cortex-a15");
+}
+
+static int
+platform_mp_get_core_cnt(void)
+{
+ static int ncores = 0;
+ int nchilds;
+ uint32_t reg;
+
+ /* Calculate ncores value only once */
+ if (ncores)
+ return (ncores);
+
+ reg = cp15_l2ctlr_get();
+ ncores = CPUV7_L2CTLR_NPROC(reg);
+
+ nchilds = ofw_cpu_early_foreach(alpine_validate_cpu, false);
+
+ /* Limit CPUs if DTS has configured less than available */
+ if ((nchilds > 0) && (nchilds < ncores)) {
+ printf("SMP: limiting number of active CPUs to %d out of %d\n",
+ nchilds, ncores);
+ ncores = nchilds;
+ }
+
+ return (ncores);
+}
+
+void
+platform_mp_init_secondary(void)
+{
+
+ arm_init_secondary_ic();
+}
+
+void
+platform_mp_setmaxid(void)
+{
+ int core_cnt;
+
+ core_cnt = platform_mp_get_core_cnt();
+ mp_maxid = core_cnt - 1;
+}
+
+int
+platform_mp_probe(void)
+{
+ mp_ncpus = platform_mp_get_core_cnt();
+ return (1);
+}
+
+static int
+alpine_get_cpu_resume_base(u_long *pbase, u_long *psize)
+{
+ phandle_t node;
+ u_long base = 0;
+ u_long size = 0;
+
+ if (pbase == NULL || psize == NULL)
+ return (EINVAL);
+
+ if ((node = OF_finddevice("/")) == -1)
+ return (EFAULT);
+
+ if ((node =
+ ofw_bus_find_compatible(node, "annapurna-labs,al-cpu-resume")) == 0)
+ return (EFAULT);
+
+ if (fdt_regsize(node, &base, &size))
+ return (EFAULT);
+
+ *pbase = base;
+ *psize = size;
+
+ return (0);
+}
+
+static int
+alpine_get_nb_base(u_long *pbase, u_long *psize)
+{
+ phandle_t node;
+ u_long base = 0;
+ u_long size = 0;
+
+ if (pbase == NULL || psize == NULL)
+ return (EINVAL);
+
+ if ((node = OF_finddevice("/")) == -1)
+ return (EFAULT);
+
+ if ((node =
+ ofw_bus_find_compatible(node, "annapurna-labs,al-nb-service")) == 0)
+ return (EFAULT);
+
+ if (fdt_regsize(node, &base, &size))
+ return (EFAULT);
+
+ *pbase = base;
+ *psize = size;
+
+ return (0);
+}
+
+void
+platform_mp_start_ap(void)
+{
+ uint32_t physaddr;
+ vm_offset_t vaddr;
+ uint32_t val;
+ uint32_t start_mask;
+ u_long cpu_resume_base;
+ u_long nb_base;
+ u_long cpu_resume_size;
+ u_long nb_size;
+ bus_addr_t cpu_resume_baddr;
+ bus_addr_t nb_baddr;
+ int a;
+
+ if (alpine_get_cpu_resume_base(&cpu_resume_base, &cpu_resume_size))
+ panic("Couldn't resolve cpu_resume_base address\n");
+
+ if (alpine_get_nb_base(&nb_base, &nb_size))
+ panic("Couldn't resolve_nb_base address\n");
+
+ /* Proceed with start addresses for additional CPUs */
+ if (bus_space_map(fdtbus_bs_tag, al_devmap_pa + cpu_resume_base,
+ cpu_resume_size, 0, &cpu_resume_baddr))
+ panic("Couldn't map CPU-resume area");
+ if (bus_space_map(fdtbus_bs_tag, al_devmap_pa + nb_base,
+ nb_size, 0, &nb_baddr))
+ panic("Couldn't map NB-service area");
+
+ /* Proceed with start addresses for additional CPUs */
+ val = bus_space_read_4(fdtbus_bs_tag, cpu_resume_baddr,
+ AL_CPU_RESUME_WATERMARK_REG);
+ if (((val & AL_CPU_RESUME_MAGIC_NUM_MASK) != AL_CPU_RESUME_MAGIC_NUM) ||
+ ((val & AL_CPU_RESUME_MIN_VER_MASK) < AL_CPU_RESUME_MIN_VER)) {
+ panic("CPU-resume device is not compatible");
+ }
+
+ vaddr = (vm_offset_t)mpentry;
+ physaddr = pmap_kextract(vaddr);
+
+ for (a = 1; a < platform_mp_get_core_cnt(); a++) {
+ /* Power up the core */
+ bus_space_write_4(fdtbus_bs_tag, nb_baddr,
+ AL_NB_CONFIG_STATUS_PWR_CTRL(a), 0);
+ mb();
+
+ /* Enable resume */
+ val = bus_space_read_4(fdtbus_bs_tag, cpu_resume_baddr,
+ AL_CPU_RESUME_PCPU_FLAGS(a));
+ val &= ~AL_CPU_RESUME_FLG_PERCPU_DONT_RESUME;
+ bus_space_write_4(fdtbus_bs_tag, cpu_resume_baddr,
+ AL_CPU_RESUME_PCPU_FLAGS(a), val);
+ mb();
+
+ /* Set resume physical address */
+ bus_space_write_4(fdtbus_bs_tag, cpu_resume_baddr,
+ AL_CPU_RESUME_PCPU_RADDR_REG(a), physaddr);
+ mb();
+ }
+
+ /* Release cores from reset */
+ if (bus_space_map(fdtbus_bs_tag, al_devmap_pa + nb_base,
+ nb_size, 0, &nb_baddr))
+ panic("Couldn't map NB-service area");
+
+ start_mask = (1 << platform_mp_get_core_cnt()) - 1;
+
+ /* Release cores from reset */
+ val = bus_space_read_4(fdtbus_bs_tag, nb_baddr, AL_NB_INIT_CONTROL);
+ val |= start_mask;
+ bus_space_write_4(fdtbus_bs_tag, nb_baddr, AL_NB_INIT_CONTROL, val);
+ dsb();
+
+ bus_space_unmap(fdtbus_bs_tag, nb_baddr, nb_size);
+ bus_space_unmap(fdtbus_bs_tag, cpu_resume_baddr, cpu_resume_size);
+}
+
+static int
+alpine_get_serdes_base(u_long *pbase, u_long *psize)
+{
+ phandle_t node;
+ u_long base = 0;
+ u_long size = 0;
+
+ if (pbase == NULL || psize == NULL)
+ return (EINVAL);
+
+ if ((node = OF_finddevice("/")) == -1)
+ return (EFAULT);
+
+ if ((node =
+ ofw_bus_find_compatible(node, "annapurna-labs,al-serdes")) == 0)
+ return (EFAULT);
+
+ if (fdt_regsize(node, &base, &size))
+ return (EFAULT);
+
+ *pbase = base;
+ *psize = size;
+
+ return (0);
+}
+
+int
+alpine_serdes_resource_get(uint32_t group, bus_space_tag_t *tag, bus_addr_t *baddr)
+{
+ u_long serdes_base, serdes_size;
+ int ret;
+ static bus_addr_t baddr_mapped[SERDES_NUM_GROUPS];
+
+ if (group >= SERDES_NUM_GROUPS)
+ return (EINVAL);
+
+ if (baddr_mapped[group]) {
+ *tag = fdtbus_bs_tag;
+ *baddr = baddr_mapped[group];
+ return (0);
+ }
+
+ ret = alpine_get_serdes_base(&serdes_base, &serdes_size);
+ if (ret)
+ return (ret);
+
+ ret = bus_space_map(fdtbus_bs_tag,
+ al_devmap_pa + serdes_base + group * SERDES_GROUP_SIZE,
+ (SERDES_NUM_GROUPS - group) * SERDES_GROUP_SIZE, 0, baddr);
+ if (ret)
+ return (ret);
+
+ baddr_mapped[group] = *baddr;
+
+ return (0);
+}
+
+void
+platform_ipi_send(cpuset_t cpus, u_int ipi)
+{
+
+ pic_ipi_send(cpus, ipi);
+}
diff --git a/sys/arm/annapurna/alpine/common.c b/sys/arm/annapurna/alpine/common.c
new file mode 100644
index 0000000..a0fade0
--- /dev/null
+++ b/sys/arm/annapurna/alpine/common.c
@@ -0,0 +1,158 @@
+/*-
+ * Copyright (c) 2013 Ruslan Bukin <br@bsdpad.com>
+ * Copyright (c) 2015 Semihalf.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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.
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/openfirm.h>
+
+#include <machine/bus.h>
+#include <machine/fdt.h>
+#include <machine/intr.h>
+
+#define WDTLOAD 0x000
+#define LOAD_MIN 0x00000001
+#define LOAD_MAX 0xFFFFFFFF
+#define WDTVALUE 0x004
+#define WDTCONTROL 0x008
+/* control register masks */
+#define INT_ENABLE (1 << 0)
+#define RESET_ENABLE (1 << 1)
+#define WDTLOCK 0xC00
+#define UNLOCK 0x1ACCE551
+#define LOCK 0x00000001
+
+extern bus_addr_t al_devmap_pa;
+struct fdt_fixup_entry fdt_fixup_table[] = {
+ { NULL, NULL }
+};
+
+static int alpine_get_wdt_base(uint32_t *pbase, uint32_t *psize);
+static int alpine_pic_decode_fdt(uint32_t iparent, uint32_t *intr,
+ int *interrupt, int *trig, int *pol);
+
+int alpine_get_devmap_base(bus_addr_t *pa, bus_addr_t *size);
+
+int alpine_get_devmap_base(bus_addr_t *pa, bus_addr_t *size)
+{
+ phandle_t node;
+
+ if ((node = OF_finddevice("/")) == 0)
+ return (ENXIO);
+
+ if ((node = fdt_find_compatible(node, "simple-bus", 1)) == 0)
+ return (ENXIO);
+
+ return fdt_get_range(node, 0, pa, size);
+}
+
+static int
+alpine_get_wdt_base(uint32_t *pbase, uint32_t *psize)
+{
+ phandle_t node;
+ u_long base = 0;
+ u_long size = 0;
+
+ if (pbase == NULL || psize == NULL)
+ return (EINVAL);
+
+ if ((node = OF_finddevice("/")) == -1)
+ return (EFAULT);
+
+ if ((node = fdt_find_compatible(node, "simple-bus", 1)) == 0)
+ return (EFAULT);
+
+ if ((node =
+ fdt_find_compatible(node, "arm,sp805", 1)) == 0)
+ return (EFAULT);
+
+ if (fdt_regsize(node, &base, &size))
+ return (EFAULT);
+
+ *pbase = base;
+ *psize = size;
+
+ return (0);
+}
+
+void
+cpu_reset(void)
+{
+ uint32_t wdbase, wdsize;
+ bus_addr_t wdbaddr;
+ int ret;
+
+ ret = alpine_get_wdt_base(&wdbase, &wdsize);
+ if (ret) {
+ printf("Unable to get WDT base, do power down manually...");
+ goto infinite;
+ }
+
+ ret = bus_space_map(fdtbus_bs_tag, al_devmap_pa + wdbase,
+ wdsize, 0, &wdbaddr);
+ if (ret) {
+ printf("Unable to map WDT base, do power down manually...");
+ goto infinite;
+ }
+
+ bus_space_write_4(fdtbus_bs_tag, wdbaddr, WDTLOCK, UNLOCK);
+ bus_space_write_4(fdtbus_bs_tag, wdbaddr, WDTLOAD, LOAD_MIN);
+ bus_space_write_4(fdtbus_bs_tag, wdbaddr, WDTCONTROL, INT_ENABLE | RESET_ENABLE);
+
+infinite:
+ while (1) {}
+}
+
+static int
+alpine_pic_decode_fdt(uint32_t iparent, uint32_t *intr, int *interrupt,
+ int *trig, int *pol)
+{
+ int rv = 0;
+
+ rv = gic_decode_fdt(iparent, intr, interrupt, trig, pol);
+ if (rv == 0) {
+ /* This was recognized as our PIC and decoded. */
+ interrupt = FDT_MAP_IRQ(iparent, interrupt);
+
+ /* Configure the interrupt if callback provided */
+ if (arm_config_irq)
+ (*arm_config_irq)(*interrupt, *trig, *pol);
+ }
+ return (rv);
+}
+
+fdt_pic_decode_t fdt_pic_table[] = {
+ &alpine_pic_decode_fdt,
+ NULL
+};
diff --git a/sys/arm/annapurna/alpine/files.alpine b/sys/arm/annapurna/alpine/files.alpine
new file mode 100644
index 0000000..fb9b0fe
--- /dev/null
+++ b/sys/arm/annapurna/alpine/files.alpine
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+kern/kern_clocksource.c standard
+
+arm/arm/bus_space_base.c standard
+arm/arm/bus_space_generic.c standard
+arm/arm/bus_space_asm_generic.S standard
+
+arm/versatile/sp804.c standard
+arm/versatile/versatile_timer.c standard
+dev/uart/uart_dev_ns8250.c optional uart
+dev/ofw/ofw_cpu.c standard
+
+arm/annapurna/alpine/common.c standard
+arm/annapurna/alpine/alpine_machdep.c standard
+arm/annapurna/alpine/alpine_machdep_mp.c optional smp
diff --git a/sys/arm/annapurna/alpine/hal/al_hal_common.h b/sys/arm/annapurna/alpine/hal/al_hal_common.h
new file mode 100644
index 0000000..6e27e17
--- /dev/null
+++ b/sys/arm/annapurna/alpine/hal/al_hal_common.h
@@ -0,0 +1,70 @@
+/*-
+********************************************************************************
+Copyright (C) 2015 Annapurna Labs Ltd.
+
+This file may be licensed under the terms of the Annapurna Labs Commercial
+License Agreement.
+
+Alternatively, this file can be distributed under the terms of the GNU General
+Public License V2 as published by the Free Software Foundation and can be
+found at http://www.gnu.org/licenses/gpl-2.0.html
+
+Alternatively, redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+notice, this 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 HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*******************************************************************************/
+
+/**
+ * @defgroup group_common HAL Common Layer
+ * Includes all common header files used by HAL
+ * @{
+ * @file al_hal_common.h
+ *
+ */
+
+#ifndef __AL_HAL_COMMON_H__
+#define __AL_HAL_COMMON_H__
+
+#include "al_hal_plat_types.h"
+#include "al_hal_plat_services.h"
+
+#include "al_hal_types.h"
+#include "al_hal_reg_utils.h"
+
+/* Get the maximal value out of two typed values */
+#define al_max_t(type, x, y) ({ \
+ type __max1 = (x); \
+ type __max2 = (y); \
+ __max1 > __max2 ? __max1 : __max2; })
+
+/* Get the minimal value out of two typed values */
+#define al_min_t(type, x, y) ({ \
+ type __min1 = (x); \
+ type __min2 = (y); \
+ __min1 < __min2 ? __min1 : __min2; })
+
+/* Get the number of elements in an array */
+#define AL_ARR_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
+/** @} end of Common group */
+#endif /* __AL_HAL_COMMON_H__ */
diff --git a/sys/arm/annapurna/alpine/hal/al_hal_iofic.h b/sys/arm/annapurna/alpine/hal/al_hal_iofic.h
new file mode 100644
index 0000000..5c19e0a
--- /dev/null
+++ b/sys/arm/annapurna/alpine/hal/al_hal_iofic.h
@@ -0,0 +1,222 @@
+/*-
+********************************************************************************
+Copyright (C) 2015 Annapurna Labs Ltd.
+
+This file may be licensed under the terms of the Annapurna Labs Commercial
+License Agreement.
+
+Alternatively, this file can be distributed under the terms of the GNU General
+Public License V2 as published by the Free Software Foundation and can be
+found at http://www.gnu.org/licenses/gpl-2.0.html
+
+Alternatively, redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+notice, this 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 HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*******************************************************************************/
+
+/**
+ * @defgroup group_interrupts Common I/O Fabric Interrupt Controller
+ * This HAL provides the API for programming the Common I/O Fabric Interrupt
+ * Controller (IOFIC) found in most of the units attached to the I/O Fabric of
+ * Alpine platform
+ * @{
+ * @file al_hal_iofic.h
+ *
+ * @brief Header file for the interrupt controller that's embedded in various units
+ *
+ */
+
+#ifndef __AL_HAL_IOFIC_H__
+#define __AL_HAL_IOFIC_H__
+
+#include <al_hal_common.h>
+
+/* *INDENT-OFF* */
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* *INDENT-ON* */
+
+#define AL_IOFIC_MAX_GROUPS 4
+
+/*
+ * Configurations
+ */
+
+/**
+ * Configure the interrupt controller registers, actual interrupts are still
+ * masked at this stage.
+ *
+ * @param regs_base regs pointer to interrupt controller registers
+ * @param group the interrupt group.
+ * @param flags flags of Interrupt Control Register
+ *
+ * @return 0 on success. -EINVAL otherwise.
+ */
+int al_iofic_config(void __iomem *regs_base, int group,
+ uint32_t flags);
+
+/**
+ * configure the moderation timer resolution for a given group
+ * Applies for both msix and legacy mode.
+ *
+ * @param regs_base pointer to unit registers
+ * @param group the interrupt group
+ * @param resolution resolution of the timer interval, the resolution determines the rate
+ * of decrementing the interval timer, setting value N means that the interval
+ * timer will be decremented each (N+1) * (0.68) micro seconds.
+ *
+ * @return 0 on success. -EINVAL otherwise.
+ */
+int al_iofic_moder_res_config(void __iomem *regs_base, int group,
+ uint8_t resolution);
+
+/**
+ * configure the moderation timer interval for a given legacy interrupt group
+ *
+ * @param regs_base regs pointer to unit registers
+ * @param group the interrupt group
+ * @param interval between interrupts in resolution units. 0 disable
+ *
+ * @return 0 on success. -EINVAL otherwise.
+ */
+int al_iofic_legacy_moder_interval_config(void __iomem *regs_base, int group,
+ uint8_t interval);
+
+/**
+ * configure the moderation timer interval for a given msix vector
+ *
+ * @param regs_base pointer to unit registers
+ * @param group the interrupt group
+ * @param vector vector index
+ * @param interval interval between interrupts, 0 disable
+ *
+ * @return 0 on success. -EINVAL otherwise.
+ */
+int al_iofic_msix_moder_interval_config(void __iomem *regs_base, int group,
+ uint8_t vector, uint8_t interval);
+
+/**
+* configure the vmid attributes for a given msix vector.
+*
+* @param group the interrupt group
+* @param vector index
+* @param vmid the vmid value
+* @param vmid_en take vmid from the intc
+*
+* @return 0 on success. -EINVAL otherwise.
+*/
+int al_iofic_msix_vmid_attributes_config(void __iomem *regs_base, int group,
+ uint8_t vector, uint32_t vmid, uint8_t vmid_en);
+
+/**
+ * return the offset of the unmask register for a given group.
+ * this function can be used when the upper layer wants to directly
+ * access the unmask regiter and bypass the al_iofic_unmask() API.
+ *
+ * @param regs_base regs pointer to unit registers
+ * @param group the interrupt group
+ * @return the offset of the unmask register.
+ */
+uint32_t __iomem * al_iofic_unmask_offset_get(void __iomem *regs_base, int group);
+
+/**
+ * unmask specific interrupts for a given group
+ * this functions guarantees atomic operations, it is performance optimized as
+ * it will not require read-modify-write. The unmask done using the interrupt
+ * mask clear register, so it's safe to call it while the mask is changed by
+ * the HW (auto mask) or another core.
+ *
+ * @param regs_base pointer to unit registers
+ * @param group the interrupt group
+ * @param mask bitwise of interrupts to unmask, set bits will be unmasked.
+ */
+void al_iofic_unmask(void __iomem *regs_base, int group, uint32_t mask);
+
+/**
+ * mask specific interrupts for a given group
+ * this functions modifies interrupt mask register, the callee must make sure
+ * the mask is not changed by another cpu.
+ *
+ * @param regs_base pointer to unit registers
+ * @param group the interrupt group
+ * @param mask bitwise of interrupts to mask, set bits will be masked.
+ */
+void al_iofic_mask(void __iomem *regs_base, int group, uint32_t mask);
+
+/**
+ * read the mask register for a given group
+ * this functions return the interrupt mask register
+ *
+ * @param regs_base pointer to unit registers
+ * @param group the interrupt group
+ */
+uint32_t al_iofic_read_mask(void __iomem *regs_base, int group);
+
+/**
+ * read interrupt cause register for a given group
+ * this will clear the set bits if the Clear on Read mode enabled.
+ * @param regs_base pointer to unit registers
+ * @param group the interrupt group
+ */
+uint32_t al_iofic_read_cause(void __iomem *regs_base, int group);
+
+/**
+ * clear bits in the interrupt cause register for a given group
+ *
+ * @param regs_base pointer to unit registers
+ * @param group the interrupt group
+ * @param mask bitwise of bits to be cleared, set bits will be cleared.
+ */
+void al_iofic_clear_cause(void __iomem *regs_base, int group, uint32_t mask);
+
+/**
+ * set the cause register for a given group
+ * this function set the cause register. It will generate an interrupt (if
+ * the the interrupt isn't masked )
+ *
+ * @param regs_base pointer to unit registers
+ * @param group the interrupt group
+ * @param mask bitwise of bits to be set.
+ */
+void al_iofic_set_cause(void __iomem *regs_base, int group, uint32_t mask);
+
+/**
+ * unmask specific interrupts from aborting the udma a given group
+ *
+ * @param regs_base pointer to unit registers
+ * @param group the interrupt group
+ * @param mask bitwise of interrupts to mask
+ */
+void al_iofic_abort_mask(void __iomem *regs_base, int group, uint32_t mask);
+
+/**
+ * trigger all interrupts that are waiting for moderation timers to expire
+ *
+ * @param regs_base pointer to unit registers
+ * @param group the interrupt group
+ */
+void al_iofic_interrupt_moderation_reset(void __iomem *regs_base, int group);
+
+#endif
+/** @} end of interrupt controller group */
diff --git a/sys/arm/annapurna/alpine/hal/al_hal_iofic_regs.h b/sys/arm/annapurna/alpine/hal/al_hal_iofic_regs.h
new file mode 100644
index 0000000..81ba20f
--- /dev/null
+++ b/sys/arm/annapurna/alpine/hal/al_hal_iofic_regs.h
@@ -0,0 +1,127 @@
+/*_
+********************************************************************************
+Copyright (C) 2015 Annapurna Labs Ltd.
+
+This file may be licensed under the terms of the Annapurna Labs Commercial
+License Agreement.
+
+Alternatively, this file can be distributed under the terms of the GNU General
+Public License V2 as published by the Free Software Foundation and can be
+found at http://www.gnu.org/licenses/gpl-2.0.html
+
+Alternatively, redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+notice, this 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 HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(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 __AL_HAL_IOFIC_REG_H
+#define __AL_HAL_IOFIC_REG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+* Unit Registers
+*/
+
+struct al_iofic_grp_ctrl {
+ uint32_t int_cause_grp; /* Interrupt Cause RegisterSet by hardware */
+ uint32_t rsrvd1;
+ uint32_t int_cause_set_grp; /* Interrupt Cause Set RegisterWriting 1 to a bit in t ... */
+ uint32_t rsrvd2;
+ uint32_t int_mask_grp; /* Interrupt Mask RegisterIf Auto-mask control bit =TR ... */
+ uint32_t rsrvd3;
+ uint32_t int_mask_clear_grp; /* Interrupt Mask Clear RegisterUsed when auto-mask co ... */
+ uint32_t rsrvd4;
+ uint32_t int_status_grp; /* Interrupt status RegisterThis register latch the st ... */
+ uint32_t rsrvd5;
+ uint32_t int_control_grp; /* Interrupt Control Register */
+ uint32_t rsrvd6;
+ uint32_t int_abort_msk_grp; /* Interrupt Mask RegisterEach bit in this register ma ... */
+ uint32_t rsrvd7;
+ uint32_t int_log_msk_grp; /* Interrupt Log RegisterEach bit in this register mas ... */
+ uint32_t rsrvd8;
+};
+
+struct al_iofic_grp_mod {
+ uint32_t grp_int_mod_reg; /* Interrupt moderation registerDedicated moderation in ... */
+ uint32_t grp_int_vmid_reg;
+};
+
+struct al_iofic_regs {
+ struct al_iofic_grp_ctrl ctrl[0];
+ uint32_t rsrvd1[0x400 >> 2];
+ struct al_iofic_grp_mod grp_int_mod[0][32];
+};
+
+
+/*
+* Registers Fields
+*/
+
+
+/**** int_control_grp register ****/
+/* When Clear_on_Read =1, All bits of Cause register ... */
+#define INT_CONTROL_GRP_CLEAR_ON_READ (1 << 0)
+/* (must be set only when MSIX is enabled)When Auto-Ma ... */
+#define INT_CONTROL_GRP_AUTO_MASK (1 << 1)
+/* Auto_Clear (RW)When Auto-Clear =1, the bits in the ... */
+#define INT_CONTROL_GRP_AUTO_CLEAR (1 << 2)
+/* When Set_on_Posedge =1, the bits in the interrupt c ... */
+#define INT_CONTROL_GRP_SET_ON_POSEDGE (1 << 3)
+/* When Moderation_Reset =1, all Moderation timers ass ... */
+#define INT_CONTROL_GRP_MOD_RST (1 << 4)
+/* When mask_msi_x =1, No MSI-X from this group is sen ... */
+#define INT_CONTROL_GRP_MASK_MSI_X (1 << 5)
+/* MSI-X AWID value, same ID for all cause bits */
+#define INT_CONTROL_GRP_AWID_MASK 0x00000F00
+#define INT_CONTROL_GRP_AWID_SHIFT 8
+/* This value determines the interval between interrup ... */
+#define INT_CONTROL_GRP_MOD_INTV_MASK 0x00FF0000
+#define INT_CONTROL_GRP_MOD_INTV_SHIFT 16
+/* This value determines the Moderation_Timer_Clock sp ... */
+#define INT_CONTROL_GRP_MOD_RES_MASK 0x0F000000
+#define INT_CONTROL_GRP_MOD_RES_SHIFT 24
+
+/**** grp_int_mod_reg register ****/
+/* Interrupt Moderation Interval registerDedicated reg ... */
+#define INT_MOD_INTV_MASK 0x000000FF
+#define INT_MOD_INTV_SHIFT 0
+
+/**** grp_int_vmid_reg register ****/
+/* Interrupt vmid value registerDedicated reg ... */
+#define INT_MSIX_VMID_MASK 0x0000FFFF
+#define INT_MSIX_VMID_SHIFT 0
+/* Interrupt vmid_en value registerDedicated reg ... */
+#define INT_MSIX_VMID_EN_SHIFT 31
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __AL_HAL_IOFIC_REG_H */
+
+
+
+
diff --git a/sys/arm/annapurna/alpine/hal/al_hal_nb_regs.h b/sys/arm/annapurna/alpine/hal/al_hal_nb_regs.h
new file mode 100644
index 0000000..9de3bd2
--- /dev/null
+++ b/sys/arm/annapurna/alpine/hal/al_hal_nb_regs.h
@@ -0,0 +1,1823 @@
+/*-
+********************************************************************************
+Copyright (C) 2015 Annapurna Labs Ltd.
+
+This file may be licensed under the terms of the Annapurna Labs Commercial
+License Agreement.
+
+Alternatively, this file can be distributed under the terms of the GNU General
+Public License V2 as published by the Free Software Foundation and can be
+found at http://www.gnu.org/licenses/gpl-2.0.html
+
+Alternatively, redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+notice, this 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 HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*******************************************************************************/
+
+/**
+ * @{
+ * @file al_hal_nb_regs.h
+ *
+ * @brief North Bridge service registers
+ *
+ */
+
+#ifndef __AL_HAL_NB_REGS_H__
+#define __AL_HAL_NB_REGS_H__
+
+#include "al_hal_plat_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+* Unit Registers
+*/
+
+
+
+struct al_nb_global {
+ /* [0x0] */
+ uint32_t cpus_config;
+ /* [0x4] */
+ uint32_t cpus_secure;
+ /* [0x8] Force init reset. */
+ uint32_t cpus_init_control;
+ /* [0xc] Force init reset per DECEI mode. */
+ uint32_t cpus_init_status;
+ /* [0x10] */
+ uint32_t nb_int_cause;
+ /* [0x14] */
+ uint32_t sev_int_cause;
+ /* [0x18] */
+ uint32_t pmus_int_cause;
+ /* [0x1c] */
+ uint32_t sev_mask;
+ /* [0x20] */
+ uint32_t cpus_hold_reset;
+ /* [0x24] */
+ uint32_t cpus_software_reset;
+ /* [0x28] */
+ uint32_t wd_timer0_reset;
+ /* [0x2c] */
+ uint32_t wd_timer1_reset;
+ /* [0x30] */
+ uint32_t wd_timer2_reset;
+ /* [0x34] */
+ uint32_t wd_timer3_reset;
+ /* [0x38] */
+ uint32_t ddrc_hold_reset;
+ /* [0x3c] */
+ uint32_t fabric_software_reset;
+ /* [0x40] */
+ uint32_t cpus_power_ctrl;
+ uint32_t rsrvd_0[7];
+ /* [0x60] */
+ uint32_t acf_base_high;
+ /* [0x64] */
+ uint32_t acf_base_low;
+ /* [0x68] */
+ uint32_t acf_control_override;
+ /* [0x6c] Read-only that reflects CPU Cluster Local GIC base high address */
+ uint32_t lgic_base_high;
+ /* [0x70] Read-only that reflects CPU Cluster Local GIC base low address */
+ uint32_t lgic_base_low;
+ /* [0x74] Read-only that reflects the device's IOGIC base high address. */
+ uint32_t iogic_base_high;
+ /* [0x78] Read-only that reflects IOGIC base low address */
+ uint32_t iogic_base_low;
+ /* [0x7c] */
+ uint32_t io_wr_split_control;
+ /* [0x80] */
+ uint32_t io_rd_rob_control;
+ /* [0x84] */
+ uint32_t sb_pos_error_log_1;
+ /* [0x88] */
+ uint32_t sb_pos_error_log_0;
+ /* [0x8c] */
+ uint32_t c2swb_config;
+ /* [0x90] */
+ uint32_t msix_error_log;
+ /* [0x94] */
+ uint32_t error_cause;
+ /* [0x98] */
+ uint32_t error_mask;
+ uint32_t rsrvd_1;
+ /* [0xa0] */
+ uint32_t qos_peak_control;
+ /* [0xa4] */
+ uint32_t qos_set_control;
+ /* [0xa8] */
+ uint32_t ddr_qos;
+ uint32_t rsrvd_2[9];
+ /* [0xd0] */
+ uint32_t acf_misc;
+ /* [0xd4] */
+ uint32_t config_bus_control;
+ uint32_t rsrvd_3[2];
+ /* [0xe0] */
+ uint32_t pos_id_match;
+ uint32_t rsrvd_4[3];
+ /* [0xf0] */
+ uint32_t sb_sel_override_awuser;
+ /* [0xf4] */
+ uint32_t sb_override_awuser;
+ /* [0xf8] */
+ uint32_t sb_sel_override_aruser;
+ /* [0xfc] */
+ uint32_t sb_override_aruser;
+ /* [0x100] */
+ uint32_t cpu_max_pd_timer;
+ /* [0x104] */
+ uint32_t cpu_max_pu_timer;
+ uint32_t rsrvd_5[2];
+ /* [0x110] */
+ uint32_t auto_ddr_self_refresh_counter;
+ uint32_t rsrvd_6[3];
+ /* [0x120] */
+ uint32_t coresight_pd;
+ /* [0x124] */
+ uint32_t coresight_internal_0;
+ /* [0x128] */
+ uint32_t coresight_dbgromaddr;
+ /* [0x12c] */
+ uint32_t coresight_dbgselfaddr;
+ /* [0x130] */
+ uint32_t coresght_targetid;
+ /* [0x134] */
+ uint32_t coresght_targetid0;
+ uint32_t rsrvd_7[10];
+ /* [0x160] */
+ uint32_t sb_force_same_id_cfg_0;
+ /* [0x164] */
+ uint32_t sb_mstr_force_same_id_sel_0;
+ /* [0x168] */
+ uint32_t sb_force_same_id_cfg_1;
+ /* [0x16c] */
+ uint32_t sb_mstr_force_same_id_sel_1;
+ uint32_t rsrvd[932];
+};
+struct al_nb_system_counter {
+ /* [0x0] */
+ uint32_t cnt_control;
+ /* [0x4] */
+ uint32_t cnt_base_freq;
+ /* [0x8] */
+ uint32_t cnt_low;
+ /* [0xc] */
+ uint32_t cnt_high;
+ /* [0x10] */
+ uint32_t cnt_init_low;
+ /* [0x14] */
+ uint32_t cnt_init_high;
+ uint32_t rsrvd[58];
+};
+struct al_nb_rams_control_misc {
+ /* [0x0] */
+ uint32_t ca15_rf_misc;
+ uint32_t rsrvd_0;
+ /* [0x8] */
+ uint32_t nb_rf_misc;
+ uint32_t rsrvd[61];
+};
+struct al_nb_ca15_rams_control {
+ /* [0x0] */
+ uint32_t rf_0;
+ /* [0x4] */
+ uint32_t rf_1;
+ /* [0x8] */
+ uint32_t rf_2;
+ uint32_t rsrvd;
+};
+struct al_nb_semaphores {
+ /* [0x0] This configuration is only sampled during reset of the processor */
+ uint32_t lockn;
+};
+struct al_nb_debug {
+ /* [0x0] */
+ uint32_t ca15_outputs_1;
+ /* [0x4] */
+ uint32_t ca15_outputs_2;
+ uint32_t rsrvd_0[2];
+ /* [0x10] */
+ uint32_t cpu_msg[4];
+ /* [0x20] */
+ uint32_t rsv0_config;
+ /* [0x24] */
+ uint32_t rsv1_config;
+ uint32_t rsrvd_1[2];
+ /* [0x30] */
+ uint32_t rsv0_status;
+ /* [0x34] */
+ uint32_t rsv1_status;
+ uint32_t rsrvd_2[2];
+ /* [0x40] */
+ uint32_t ddrc;
+ /* [0x44] */
+ uint32_t ddrc_phy_smode_control;
+ /* [0x48] */
+ uint32_t ddrc_phy_smode_status;
+ uint32_t rsrvd_3[5];
+ /* [0x60] */
+ uint32_t pmc;
+ uint32_t rsrvd_4[3];
+ /* [0x70] */
+ uint32_t cpus_general;
+ /* [0x74] */
+ uint32_t cpus_general_1;
+ uint32_t rsrvd_5[2];
+ /* [0x80] */
+ uint32_t cpus_int_out;
+ uint32_t rsrvd_6[3];
+ /* [0x90] */
+ uint32_t latch_pc_req;
+ uint32_t rsrvd_7;
+ /* [0x98] */
+ uint32_t latch_pc_low;
+ /* [0x9c] */
+ uint32_t latch_pc_high;
+ uint32_t rsrvd_8[24];
+ /* [0x100] */
+ uint32_t track_dump_ctrl;
+ /* [0x104] */
+ uint32_t track_dump_rdata_0;
+ /* [0x108] */
+ uint32_t track_dump_rdata_1;
+ uint32_t rsrvd_9[5];
+ /* [0x120] */
+ uint32_t track_events;
+ uint32_t rsrvd_10[3];
+ /* [0x130] */
+ uint32_t pos_track_dump_ctrl;
+ /* [0x134] */
+ uint32_t pos_track_dump_rdata_0;
+ /* [0x138] */
+ uint32_t pos_track_dump_rdata_1;
+ uint32_t rsrvd_11;
+ /* [0x140] */
+ uint32_t c2swb_track_dump_ctrl;
+ /* [0x144] */
+ uint32_t c2swb_track_dump_rdata_0;
+ /* [0x148] */
+ uint32_t c2swb_track_dump_rdata_1;
+ uint32_t rsrvd_12;
+ /* [0x150] */
+ uint32_t cpus_track_dump_ctrl;
+ /* [0x154] */
+ uint32_t cpus_track_dump_rdata_0;
+ /* [0x158] */
+ uint32_t cpus_track_dump_rdata_1;
+ uint32_t rsrvd_13;
+ /* [0x160] */
+ uint32_t c2swb_bar_ovrd_high;
+ /* [0x164] */
+ uint32_t c2swb_bar_ovrd_low;
+ uint32_t rsrvd[38];
+};
+struct al_nb_cpun_config_status {
+ /* [0x0] This configuration is only sampled during reset of the processor. */
+ uint32_t config;
+ /* [0x4] This configuration is only sampled during reset of the processor. */
+ uint32_t config_aarch64;
+ /* [0x8] */
+ uint32_t local_cause_mask;
+ uint32_t rsrvd_0;
+ /* [0x10] */
+ uint32_t pmus_cause_mask;
+ /* [0x14] */
+ uint32_t sei_cause_mask;
+ uint32_t rsrvd_1[2];
+ /* [0x20] Specifies the state of the CPU with reference to power modes. */
+ uint32_t power_ctrl;
+ /* [0x24] */
+ uint32_t power_status;
+ /* [0x28] */
+ uint32_t resume_addr_l;
+ /* [0x2c] */
+ uint32_t resume_addr_h;
+ uint32_t rsrvd_2[4];
+ /* [0x40] */
+ uint32_t warm_rst_ctl;
+ uint32_t rsrvd_3;
+ /* [0x48] */
+ uint32_t rvbar_low;
+ /* [0x4c] */
+ uint32_t rvbar_high;
+ /* [0x50] */
+ uint32_t pmu_snapshot;
+ uint32_t rsrvd_4[3];
+ /* [0x60] */
+ uint32_t cpu_msg_in;
+ uint32_t rsrvd[39];
+};
+struct al_nb_mc_pmu {
+ /* [0x0] PMU Global Control Register */
+ uint32_t pmu_control;
+ /* [0x4] PMU Global Control Register */
+ uint32_t overflow;
+ uint32_t rsrvd[62];
+};
+struct al_nb_mc_pmu_counters {
+ /* [0x0] Counter Configuration Register */
+ uint32_t cfg;
+ /* [0x4] Counter Control Register */
+ uint32_t cntl;
+ /* [0x8] Counter Control Register */
+ uint32_t low;
+ /* [0xc] Counter Control Register */
+ uint32_t high;
+ uint32_t rsrvd[4];
+};
+struct al_nb_nb_version {
+ /* [0x0] Northbridge Revision */
+ uint32_t version;
+ uint32_t rsrvd;
+};
+struct al_nb_sriov {
+ /* [0x0] */
+ uint32_t cpu_vmid[4];
+ uint32_t rsrvd[4];
+};
+struct al_nb_dram_channels {
+ /* [0x0] */
+ uint32_t dram_0_control;
+ uint32_t rsrvd_0;
+ /* [0x8] */
+ uint32_t dram_0_status;
+ uint32_t rsrvd_1;
+ /* [0x10] */
+ uint32_t ddr_int_cause;
+ uint32_t rsrvd_2;
+ /* [0x18] */
+ uint32_t ddr_cause_mask;
+ uint32_t rsrvd_3;
+ /* [0x20] */
+ uint32_t address_map;
+ uint32_t rsrvd_4[3];
+ /* [0x30] */
+ uint32_t reorder_id_mask_0;
+ /* [0x34] */
+ uint32_t reorder_id_value_0;
+ /* [0x38] */
+ uint32_t reorder_id_mask_1;
+ /* [0x3c] */
+ uint32_t reorder_id_value_1;
+ /* [0x40] */
+ uint32_t reorder_id_mask_2;
+ /* [0x44] */
+ uint32_t reorder_id_value_2;
+ /* [0x48] */
+ uint32_t reorder_id_mask_3;
+ /* [0x4c] */
+ uint32_t reorder_id_value_3;
+ /* [0x50] */
+ uint32_t mrr_control_status;
+ uint32_t rsrvd[43];
+};
+struct al_nb_ddr_0_mrr {
+ /* [0x0] Counter Configuration Register */
+ uint32_t val;
+};
+struct al_nb_push_packet {
+ /* [0x0] */
+ uint32_t pp_config;
+ uint32_t rsrvd_0[3];
+ /* [0x10] */
+ uint32_t pp_ext_awuser;
+ uint32_t rsrvd_1[3];
+ /* [0x20] */
+ uint32_t pp_base_low;
+ /* [0x24] */
+ uint32_t pp_base_high;
+ uint32_t rsrvd_2[2];
+ /* [0x30] */
+ uint32_t pp_sel_awuser;
+ uint32_t rsrvd[51];
+};
+
+struct al_nb_regs {
+ struct al_nb_global global; /* [0x0] */
+ struct al_nb_system_counter system_counter; /* [0x1000] */
+ struct al_nb_rams_control_misc rams_control_misc; /* [0x1100] */
+ struct al_nb_ca15_rams_control ca15_rams_control[5]; /* [0x1200] */
+ uint32_t rsrvd_0[108];
+ struct al_nb_semaphores semaphores[64]; /* [0x1400] */
+ uint32_t rsrvd_1[320];
+ struct al_nb_debug debug; /* [0x1a00] */
+ uint32_t rsrvd_2[256];
+ struct al_nb_cpun_config_status cpun_config_status[4]; /* [0x2000] */
+ uint32_t rsrvd_3[1792];
+ struct al_nb_mc_pmu mc_pmu; /* [0x4000] */
+ struct al_nb_mc_pmu_counters mc_pmu_counters[4]; /* [0x4100] */
+ uint32_t rsrvd_4[160];
+ struct al_nb_nb_version nb_version; /* [0x4400] */
+ uint32_t rsrvd_5[126];
+ struct al_nb_sriov sriov; /* [0x4600] */
+ uint32_t rsrvd_6[120];
+ struct al_nb_dram_channels dram_channels; /* [0x4800] */
+ struct al_nb_ddr_0_mrr ddr_0_mrr[9]; /* [0x4900] */
+ uint32_t rsrvd_7[439];
+ uint32_t rsrvd_8[1024]; /* [0x5000] */
+ struct al_nb_push_packet push_packet; /* [0x6000] */
+};
+
+
+/*
+* Registers Fields
+*/
+
+
+/**** CPUs_Config register ****/
+/* Disable broadcast of barrier onto system bus.
+Connect to Processor Cluster SYSBARDISABLE. */
+#define NB_GLOBAL_CPUS_CONFIG_SYSBARDISABLE (1 << 0)
+/* Enable broadcast of inner shareable transactions from CPUs.
+Connect to Processor Cluster BROADCASTINNER. */
+#define NB_GLOBAL_CPUS_CONFIG_BROADCASTINNER (1 << 1)
+/* Disable broadcast of cache maintenance system bus.
+Connect to Processor Cluster BROADCASTCACHEMAIN */
+#define NB_GLOBAL_CPUS_CONFIG_BROADCASTCACHEMAINT (1 << 2)
+/* Enable broadcast of outer shareable transactions from CPUs.
+Connect to Processor Cluster BROADCASTOUTER. */
+#define NB_GLOBAL_CPUS_CONFIG_BROADCASTOUTER (1 << 3)
+/* Defines the internal CPU GIC operating frequency ratio with the main CPU clock.
+0x0: 1:1
+0x1: 1:2
+0x2: 1:3
+0x3: 1:4
+
+Note: This is not in used with CA57 */
+#define NB_GLOBAL_CPUS_CONFIG_PERIPHCLKEN_MASK 0x00000030
+#define NB_GLOBAL_CPUS_CONFIG_PERIPHCLKEN_SHIFT 4
+/* Disables the GIC CPU interface logic and routes the legacy nIRQ, nFIQ, nVIRQ, and nVFIQ
+signals directly to the processor:
+0 Enable the GIC CPU interface logic.
+1 Disable the GIC CPU interface logic.
+The processor only samples this signal as it exits reset. */
+#define NB_GLOBAL_CPUS_CONFIG_GIC_DISABLE (1 << 6)
+/* Disable L1 data cache and L2 snoop tag RAMs automatic invalidate on reset functionality */
+#define NB_GLOBAL_CPUS_CONFIG_DBG_L1_RESET_DISABLE (1 << 7)
+/* Value read in the Cluster ID Affinity Level-1 field, bits[15:8], of the Multiprocessor Affinity
+Register (MPIDR).
+This signal is only sampled during reset of the processor. */
+#define NB_GLOBAL_CPUS_CONFIG_CLUSTERIDAFF1_MASK 0x00FF0000
+#define NB_GLOBAL_CPUS_CONFIG_CLUSTERIDAFF1_SHIFT 16
+/* Value read in the Cluster ID Affinity Level-2 field, bits[23:16], of the Multiprocessor Affinity
+Register (MPIDR).
+This signal is only sampled during reset of the processor.. */
+#define NB_GLOBAL_CPUS_CONFIG_CLUSTERIDAFF2_MASK 0xFF000000
+#define NB_GLOBAL_CPUS_CONFIG_CLUSTERIDAFF2_SHIFT 24
+
+/**** CPUs_Secure register ****/
+/* DBGEN
+ */
+#define NB_GLOBAL_CPUS_SECURE_DBGEN (1 << 0)
+/* NIDEN
+ */
+#define NB_GLOBAL_CPUS_SECURE_NIDEN (1 << 1)
+/* SPIDEN
+ */
+#define NB_GLOBAL_CPUS_SECURE_SPIDEN (1 << 2)
+/* SPNIDEN
+ */
+#define NB_GLOBAL_CPUS_SECURE_SPNIDEN (1 << 3)
+/* Disable write access to some secure GIC registers */
+#define NB_GLOBAL_CPUS_SECURE_CFGSDISABLE (1 << 4)
+/* Disable write access to some secure IOGIC registers */
+#define NB_GLOBAL_CPUS_SECURE_IOGIC_CFGSDISABLE (1 << 5)
+
+/**** CPUs_Init_Control register ****/
+/* CPU Init Done
+Specifies which CPUs' inits are done and can exit poreset.
+By default, CPU0 only exits poreset when the CPUs cluster exits power-on-reset and then kicks other CPUs.
+If this bit is cleared for a specific CPU, setting it by primary CPU as part of the initialization process will initiate power-on-reset to this specific CPU. */
+#define NB_GLOBAL_CPUS_INIT_CONTROL_CPUS_INITDONE_MASK 0x0000000F
+#define NB_GLOBAL_CPUS_INIT_CONTROL_CPUS_INITDONE_SHIFT 0
+/* DBGPWRDNREQ Mask
+When CPU does not exist, its DBGPWRDNREQ must be asserted.
+If corresponding mask bit is set, the DBGPWDNREQ is deasserted. */
+#define NB_GLOBAL_CPUS_INIT_CONTROL_DBGPWRDNREQ_MASK_MASK 0x000000F0
+#define NB_GLOBAL_CPUS_INIT_CONTROL_DBGPWRDNREQ_MASK_SHIFT 4
+/* Force CPU init power-on-reset exit.
+For debug purposes only. */
+#define NB_GLOBAL_CPUS_INIT_CONTROL_FORCE_CPUPOR_MASK 0x00000F00
+#define NB_GLOBAL_CPUS_INIT_CONTROL_FORCE_CPUPOR_SHIFT 8
+/* Force dbgpwrdup signal high
+If dbgpwrdup is clear on the processor interface it indicates that the process debug resources are not available for APB access. */
+#define NB_GLOBAL_CPUS_INIT_CONTROL_FORCE_DBGPWRDUP_MASK 0x0000F000
+#define NB_GLOBAL_CPUS_INIT_CONTROL_FORCE_DBGPWRDUP_SHIFT 12
+
+/**** CPUs_Init_Status register ****/
+/* Specifies which CPUs are enabled in the device configuration.
+sample at rst_cpus_exist[3:0] reset strap. */
+#define NB_GLOBAL_CPUS_INIT_STATUS_CPUS_EXIST_MASK 0x0000000F
+#define NB_GLOBAL_CPUS_INIT_STATUS_CPUS_EXIST_SHIFT 0
+
+/**** NB_Int_Cause register ****/
+/*
+ * Each bit corresponds to an IRQ.
+ * value is 1 for level irq, 0 for trigger irq
+ * Level IRQ indices: 12-13, 23, 24, 26-29
+ */
+#define NB_GLOBAL_NB_INT_CAUSE_LEVEL_IRQ_MASK 0x3D803000
+/* Cross trigger interrupt */
+#define NB_GLOBAL_NB_INT_CAUSE_NCTIIRQ_MASK 0x0000000F
+#define NB_GLOBAL_NB_INT_CAUSE_NCTIIRQ_SHIFT 0
+/* Communications channel receive. Receive portion of Data Transfer Register full flag */
+#define NB_GLOBAL_NB_INT_CAUSE_COMMRX_MASK 0x000000F0
+#define NB_GLOBAL_NB_INT_CAUSE_COMMRX_SHIFT 4
+/* Communication channel transmit. Transmit portion of Data Transfer Register empty flag. */
+#define NB_GLOBAL_NB_INT_CAUSE_COMMTX_MASK 0x00000F00
+#define NB_GLOBAL_NB_INT_CAUSE_COMMTX_SHIFT 8
+/* Reserved, read undefined must write as zeros. */
+#define NB_GLOBAL_NB_INT_CAUSE_RESERVED_15_15 (1 << 15)
+/* Error indicator for AXI write transactions with a BRESP error condition. Writing 0 to bit[29] of the L2ECTLR clears the error indicator connected to CA15 nAXIERRIRQ. */
+#define NB_GLOBAL_NB_INT_CAUSE_CPU_AXIERRIRQ (1 << 16)
+/* Error indicator for: L2 RAM double-bit ECC error, illegal writes to the GIC memory-map region. */
+#define NB_GLOBAL_NB_INT_CAUSE_CPU_INTERRIRQ (1 << 17)
+/* Coherent fabric error summary interrupt */
+#define NB_GLOBAL_NB_INT_CAUSE_ACF_ERRORIRQ (1 << 18)
+/* DDR Controller ECC Correctable error summary interrupt */
+#define NB_GLOBAL_NB_INT_CAUSE_MCTL_ECC_CORR_ERR (1 << 19)
+/* DDR Controller ECC Uncorrectable error summary interrupt */
+#define NB_GLOBAL_NB_INT_CAUSE_MCTL_ECC_UNCORR_ERR (1 << 20)
+/* DRAM parity error interrupt */
+#define NB_GLOBAL_NB_INT_CAUSE_MCTL_PARITY_ERR (1 << 21)
+/* Reserved, not functional */
+#define NB_GLOBAL_NB_INT_CAUSE_MCTL_WDATARAM_PAR (1 << 22)
+/* Error cause summary interrupt */
+#define NB_GLOBAL_NB_INT_CAUSE_ERR_CAUSE_SUM_A0 (1 << 23)
+/* SB PoS error */
+#define NB_GLOBAL_NB_INT_CAUSE_SB_POS_ERR (1 << 24)
+/* Received msix is not mapped to local GIC or IO-GIC spin */
+#define NB_GLOBAL_NB_INT_CAUSE_MSIX_ERR_INT_M0 (1 << 25)
+/* Coresight timestamp overflow */
+#define NB_GLOBAL_NB_INT_CAUSE_CORESIGHT_TS_OVERFLOW_M0 (1 << 26)
+
+/**** SEV_Int_Cause register ****/
+/* SMMU 0/1 global non-secure fault interrupt */
+#define NB_GLOBAL_SEV_INT_CAUSE_SMMU_GBL_FLT_IRPT_NS_MASK 0x00000003
+#define NB_GLOBAL_SEV_INT_CAUSE_SMMU_GBL_FLT_IRPT_NS_SHIFT 0
+/* SMMU 0/1 non-secure context interrupt */
+#define NB_GLOBAL_SEV_INT_CAUSE_SMMU_CXT_IRPT_NS_MASK 0x0000000C
+#define NB_GLOBAL_SEV_INT_CAUSE_SMMU_CXT_IRPT_NS_SHIFT 2
+/* SMMU0/1 Non-secure configuration access fault interrupt */
+#define NB_GLOBAL_SEV_INT_CAUSE_SMMU_CFG_FLT_IRPT_S_MASK 0x00000030
+#define NB_GLOBAL_SEV_INT_CAUSE_SMMU_CFG_FLT_IRPT_S_SHIFT 4
+/* Reserved. Read undefined; must write as zeros. */
+#define NB_GLOBAL_SEV_INT_CAUSE_RESERVED_11_6_MASK 0x00000FC0
+#define NB_GLOBAL_SEV_INT_CAUSE_RESERVED_11_6_SHIFT 6
+/* Reserved. Read undefined; must write as zeros. */
+#define NB_GLOBAL_SEV_INT_CAUSE_RESERVED_31_20_MASK 0xFFF00000
+#define NB_GLOBAL_SEV_INT_CAUSE_RESERVED_31_20_SHIFT 20
+
+/**** PMUs_Int_Cause register ****/
+/* CPUs PMU Overflow interrupt */
+#define NB_GLOBAL_PMUS_INT_CAUSE_CPUS_OVFL_MASK 0x0000000F
+#define NB_GLOBAL_PMUS_INT_CAUSE_CPUS_OVFL_SHIFT 0
+/* Northbridge PMU overflow */
+#define NB_GLOBAL_PMUS_INT_CAUSE_NB_OVFL (1 << 4)
+/* Memory Controller PMU overflow */
+#define NB_GLOBAL_PMUS_INT_CAUSE_MCTL_OVFL (1 << 5)
+/* Coherency Interconnect PMU overflow */
+#define NB_GLOBAL_PMUS_INT_CAUSE_CCI_OVFL_MASK 0x000007C0
+#define NB_GLOBAL_PMUS_INT_CAUSE_CCI_OVFL_SHIFT 6
+/* Coherency Interconnect PMU overflow */
+#define NB_GLOBAL_PMUS_INT_CAUSE_SMMU_OVFL_MASK 0x00001800
+#define NB_GLOBAL_PMUS_INT_CAUSE_SMMU_OVFL_SHIFT 11
+/* Reserved. Read undefined; must write as zeros. */
+#define NB_GLOBAL_PMUS_INT_CAUSE_RESERVED_23_13_MASK 0x00FFE000
+#define NB_GLOBAL_PMUS_INT_CAUSE_RESERVED_23_13_SHIFT 13
+/* Southbridge PMUs overflow */
+#define NB_GLOBAL_PMUS_INT_CAUSE_SB_PMUS_OVFL_MASK 0xFF000000
+#define NB_GLOBAL_PMUS_INT_CAUSE_SB_PMUS_OVFL_SHIFT 24
+
+/**** CPUs_Hold_Reset register ****/
+/* Shared L2 memory system, interrupt controller and timer logic reset.
+Reset is applied only when all processors are in STNDBYWFI state. */
+#define NB_GLOBAL_CPUS_HOLD_RESET_L2RESET (1 << 0)
+/* Shared debug domain reset */
+#define NB_GLOBAL_CPUS_HOLD_RESET_PRESETDBG (1 << 1)
+/* Individual CPU debug, PTM, watchpoint and breakpoint logic reset */
+#define NB_GLOBAL_CPUS_HOLD_RESET_CPU_DBGRESET_MASK 0x000000F0
+#define NB_GLOBAL_CPUS_HOLD_RESET_CPU_DBGRESET_SHIFT 4
+/* Individual CPU core and VFP/NEON logic reset.
+Reset is applied only when specific CPU is in STNDBYWFI state. */
+#define NB_GLOBAL_CPUS_HOLD_RESET_CPU_CORERESET_MASK 0x00000F00
+#define NB_GLOBAL_CPUS_HOLD_RESET_CPU_CORERESET_SHIFT 8
+/* Individual CPU por-on-reset.
+Reset is applied only when specific CPU is in STNDBYWFI state. */
+#define NB_GLOBAL_CPUS_HOLD_RESET_CPU_PORESET_MASK 0x0000F000
+#define NB_GLOBAL_CPUS_HOLD_RESET_CPU_PORESET_SHIFT 12
+/* Wait for interrupt mask.
+If set, reset is applied without waiting for the specified CPU's STNDBYWFI state. */
+#define NB_GLOBAL_CPUS_HOLD_RESET_WFI_MASK_MASK 0x000F0000
+#define NB_GLOBAL_CPUS_HOLD_RESET_WFI_MASK_SHIFT 16
+
+/**** CPUs_Software_Reset register ****/
+/* Write 1. Apply the software reset. */
+#define NB_GLOBAL_CPUS_SOFTWARE_RESET_SWRESET_REQ (1 << 0)
+/* Defines the level of software reset.
+0x0 - cpu_core: Individual CPU core reset.
+0x1 - cpu_poreset: Individual CPU power-on-reset.
+0x2 - cpu_dbg: Individual CPU debug reset.
+0x3 - cluster_no_dbg: A Cluster reset puts each core into core reset (no dbg) and also resets the interrupt controller and L2 logic.
+0x4 - cluster: A Cluster reset puts each core into power-on-reset and also resets the interrupt controller and L2 logic. Debug is active.
+0x5 - cluster_poreset: A Cluster power-on-reset puts each core into power-on-reset and also resets the interrupt controller and L2 logic. This include the cluster debug logic. */
+#define NB_GLOBAL_CPUS_SOFTWARE_RESET_LEVEL_MASK 0x0000000E
+#define NB_GLOBAL_CPUS_SOFTWARE_RESET_LEVEL_SHIFT 1
+/* Individual CPU core reset. */
+#define NB_GLOBAL_CPUS_SOFTWARE_RESET_LEVEL_CPU_CORE \
+ (0x0 << NB_GLOBAL_CPUS_SOFTWARE_RESET_LEVEL_SHIFT)
+/* Individual CPU power-on-reset. */
+#define NB_GLOBAL_CPUS_SOFTWARE_RESET_LEVEL_CPU_PORESET \
+ (0x1 << NB_GLOBAL_CPUS_SOFTWARE_RESET_LEVEL_SHIFT)
+/* Individual CPU debug reset. */
+#define NB_GLOBAL_CPUS_SOFTWARE_RESET_LEVEL_CPU_DBG \
+ (0x2 << NB_GLOBAL_CPUS_SOFTWARE_RESET_LEVEL_SHIFT)
+/* A Cluster reset puts each core into core reset (no dbg) and a ... */
+#define NB_GLOBAL_CPUS_SOFTWARE_RESET_LEVEL_CLUSTER_NO_DBG \
+ (0x3 << NB_GLOBAL_CPUS_SOFTWARE_RESET_LEVEL_SHIFT)
+/* A Cluster reset puts each core into power-on-reset and also r ... */
+#define NB_GLOBAL_CPUS_SOFTWARE_RESET_LEVEL_CLUSTER \
+ (0x4 << NB_GLOBAL_CPUS_SOFTWARE_RESET_LEVEL_SHIFT)
+/* A Cluster power-on-reset puts each core into power-on-reset a ... */
+#define NB_GLOBAL_CPUS_SOFTWARE_RESET_LEVEL_CLUSTER_PORESET \
+ (0x5 << NB_GLOBAL_CPUS_SOFTWARE_RESET_LEVEL_SHIFT)
+/* Defines which cores to reset when no cluster_poreset is requested. */
+#define NB_GLOBAL_CPUS_SOFTWARE_RESET_CORES_MASK 0x000000F0
+#define NB_GLOBAL_CPUS_SOFTWARE_RESET_CORES_SHIFT 4
+/* CPUn wait for interrupt enable.
+Defines which CPU WFI indication to wait for before applying the software reset. */
+#define NB_GLOBAL_CPUS_SOFTWARE_RESET_WFI_MASK_MASK 0x000F0000
+#define NB_GLOBAL_CPUS_SOFTWARE_RESET_WFI_MASK_SHIFT 16
+
+/**** WD_Timer0_Reset register ****/
+/* Shared L2 memory system, interrupt controller and timer logic reset */
+#define NB_GLOBAL_WD_TIMER0_RESET_L2RESET (1 << 0)
+/* Shared debug domain reset */
+#define NB_GLOBAL_WD_TIMER0_RESET_PRESETDBG (1 << 1)
+/* Individual CPU debug PTM, watchpoint and breakpoint logic reset */
+#define NB_GLOBAL_WD_TIMER0_RESET_CPU_DBGRESET_MASK 0x000000F0
+#define NB_GLOBAL_WD_TIMER0_RESET_CPU_DBGRESET_SHIFT 4
+/* Individual CPU core and VFP/NEON logic reset */
+#define NB_GLOBAL_WD_TIMER0_RESET_CPU_CORERESET_MASK 0x00000F00
+#define NB_GLOBAL_WD_TIMER0_RESET_CPU_CORERESET_SHIFT 8
+/* Individual CPU por-on-reset */
+#define NB_GLOBAL_WD_TIMER0_RESET_CPU_PORESET_MASK 0x0000F000
+#define NB_GLOBAL_WD_TIMER0_RESET_CPU_PORESET_SHIFT 12
+
+/**** WD_Timer1_Reset register ****/
+/* Shared L2 memory system, interrupt controller and timer logic reset */
+#define NB_GLOBAL_WD_TIMER1_RESET_L2RESET (1 << 0)
+/* Shared debug domain reset */
+#define NB_GLOBAL_WD_TIMER1_RESET_PRESETDBG (1 << 1)
+/* Individual CPU debug PTM, watchpoint and breakpoint logic reset */
+#define NB_GLOBAL_WD_TIMER1_RESET_CPU_DBGRESET_MASK 0x000000F0
+#define NB_GLOBAL_WD_TIMER1_RESET_CPU_DBGRESET_SHIFT 4
+/* Individual CPU core and VFP/NEON logic reset */
+#define NB_GLOBAL_WD_TIMER1_RESET_CPU_CORERESET_MASK 0x00000F00
+#define NB_GLOBAL_WD_TIMER1_RESET_CPU_CORERESET_SHIFT 8
+/* Individual CPU por-on-reset */
+#define NB_GLOBAL_WD_TIMER1_RESET_CPU_PORESET_MASK 0x0000F000
+#define NB_GLOBAL_WD_TIMER1_RESET_CPU_PORESET_SHIFT 12
+
+/**** WD_Timer2_Reset register ****/
+/* Shared L2 memory system, interrupt controller and timer logic reset */
+#define NB_GLOBAL_WD_TIMER2_RESET_L2RESET (1 << 0)
+/* Shared debug domain reset */
+#define NB_GLOBAL_WD_TIMER2_RESET_PRESETDBG (1 << 1)
+/* Individual CPU debug, PTM, watchpoint and breakpoint logic reset */
+#define NB_GLOBAL_WD_TIMER2_RESET_CPU_DBGRESET_MASK 0x000000F0
+#define NB_GLOBAL_WD_TIMER2_RESET_CPU_DBGRESET_SHIFT 4
+/* Individual CPU core and VFP/NEON logic reset */
+#define NB_GLOBAL_WD_TIMER2_RESET_CPU_CORERESET_MASK 0x00000F00
+#define NB_GLOBAL_WD_TIMER2_RESET_CPU_CORERESET_SHIFT 8
+/* Individual CPU por-on-reset */
+#define NB_GLOBAL_WD_TIMER2_RESET_CPU_PORESET_MASK 0x0000F000
+#define NB_GLOBAL_WD_TIMER2_RESET_CPU_PORESET_SHIFT 12
+
+/**** WD_Timer3_Reset register ****/
+/* Shared L2 memory system, interrupt controller and timer logic reset */
+#define NB_GLOBAL_WD_TIMER3_RESET_L2RESET (1 << 0)
+/* Shared debug domain reset */
+#define NB_GLOBAL_WD_TIMER3_RESET_PRESETDBG (1 << 1)
+/* Individual CPU debug, PTM, watchpoint and breakpoint logic reset */
+#define NB_GLOBAL_WD_TIMER3_RESET_CPU_DBGRESET_MASK 0x000000F0
+#define NB_GLOBAL_WD_TIMER3_RESET_CPU_DBGRESET_SHIFT 4
+/* Individual CPU core and VFP/NEON logic reset */
+#define NB_GLOBAL_WD_TIMER3_RESET_CPU_CORERESET_MASK 0x00000F00
+#define NB_GLOBAL_WD_TIMER3_RESET_CPU_CORERESET_SHIFT 8
+/* Individual CPU por-on-reset */
+#define NB_GLOBAL_WD_TIMER3_RESET_CPU_PORESET_MASK 0x0000F000
+#define NB_GLOBAL_WD_TIMER3_RESET_CPU_PORESET_SHIFT 12
+
+/**** DDRC_Hold_Reset register ****/
+/* DDR Control and PHY memory mapped registers reset control
+0 - Reset is deasserted.
+1 - Reset is asserted (active). */
+#define NB_GLOBAL_DDRC_HOLD_RESET_APB_SYNC_RESET (1 << 0)
+/* DDR Control Core reset control
+0 - Reset is deasserted.
+1 - Reset is asserted.
+This field must be set to 0 to start the initialization process after configuring the DDR Controller registers. */
+#define NB_GLOBAL_DDRC_HOLD_RESET_CORE_SYNC_RESET (1 << 1)
+/* DDR Control AXI Interface reset control
+0 - Reset is deasserted.
+1 - Reset is asserted.
+This field must not be set to 0 while core_sync_reset is set to 1. */
+#define NB_GLOBAL_DDRC_HOLD_RESET_AXI_SYNC_RESET (1 << 2)
+/* DDR PUB Controller reset control
+0 - Reset is deasserted.
+1 - Reset is asserted.
+This field must be set to 0 to start the initialization process after configuring the PUB Controller registers. */
+#define NB_GLOBAL_DDRC_HOLD_RESET_PUB_CTL_SYNC_RESET (1 << 3)
+/* DDR PUB SDR Controller reset control
+0 - Reset is deasserted.
+1 - Reset is asserted.
+This field must be set to 0 to start the initialization process after configuring the PUB Controller registers. */
+#define NB_GLOBAL_DDRC_HOLD_RESET_PUB_SDR_SYNC_RESET (1 << 4)
+/* DDR PHY reset control
+0 - Reset is deasserted.
+1 - Reset is asserted. */
+#define NB_GLOBAL_DDRC_HOLD_RESET_PHY_SYNC_RESET (1 << 5)
+/* Memory initialization input to DDR SRAM for parity check support */
+#define NB_GLOBAL_DDRC_HOLD_RESET_DDR_UNIT_MEM_INIT (1 << 6)
+
+/**** Fabric_Software_Reset register ****/
+/* Write 1 apply the software reset. */
+#define NB_GLOBAL_FABRIC_SOFTWARE_RESET_SWRESET_REQ (1 << 0)
+/* Defines the level of software reset:
+0x0 - fabric: Fabric reset
+0x1 - gic: GIC reset
+0x2 - smmu: SMMU reset */
+#define NB_GLOBAL_FABRIC_SOFTWARE_RESET_LEVEL_MASK 0x0000000E
+#define NB_GLOBAL_FABRIC_SOFTWARE_RESET_LEVEL_SHIFT 1
+/* Fabric reset */
+#define NB_GLOBAL_FABRIC_SOFTWARE_RESET_LEVEL_FABRIC \
+ (0x0 << NB_GLOBAL_FABRIC_SOFTWARE_RESET_LEVEL_SHIFT)
+/* GIC reset */
+#define NB_GLOBAL_FABRIC_SOFTWARE_RESET_LEVEL_GIC \
+ (0x1 << NB_GLOBAL_FABRIC_SOFTWARE_RESET_LEVEL_SHIFT)
+/* SMMU reset */
+#define NB_GLOBAL_FABRIC_SOFTWARE_RESET_LEVEL_SMMU \
+ (0x2 << NB_GLOBAL_FABRIC_SOFTWARE_RESET_LEVEL_SHIFT)
+/* CPUn waiting for interrupt enable.
+Defines which CPU WFI indication to wait before applying the software reset. */
+#define NB_GLOBAL_FABRIC_SOFTWARE_RESET_WFI_MASK_MASK 0x000F0000
+#define NB_GLOBAL_FABRIC_SOFTWARE_RESET_WFI_MASK_SHIFT 16
+
+/**** CPUs_Power_Ctrl register ****/
+/* L2 WFI enable
+When all the processors are in WFI mode or powered-down, the shared L2 memory system Power Management controller resumes clock on any interrupt.
+Power management controller resumes clock on snoop request.
+NOT IMPLEMENTED */
+#define NB_GLOBAL_CPUS_POWER_CTRL_L2WFI_EN (1 << 0)
+/* L2 WFI status */
+#define NB_GLOBAL_CPUS_POWER_CTRL_L2WFI_STATUS (1 << 1)
+/* L2 RAMs Power Down
+Power down the L2 RAMs. L2 caches must be flushed prior to entering this state. */
+#define NB_GLOBAL_CPUS_POWER_CTRL_L2RAMS_PWRDN_EN (1 << 2)
+/* L2 RAMs power down status */
+#define NB_GLOBAL_CPUS_POWER_CTRL_L2RAMS_PWRDN_STATUS (1 << 3)
+/* CPU state condition to enable L2 RAM power down
+0 - Power down
+1 - WFI
+NOT IMPLEMENTED */
+#define NB_GLOBAL_CPUS_POWER_CTRL_L2RAMS_PWRDN_CPUS_STATE_MASK 0x000000F0
+#define NB_GLOBAL_CPUS_POWER_CTRL_L2RAMS_PWRDN_CPUS_STATE_SHIFT 4
+/* Enable external debugger over power-down.
+Provides support for external debug over power down. If any or all of the processors are powered down, the SoC can still use the debug facilities if the debug PCLKDBG domain is powered up. */
+#define NB_GLOBAL_CPUS_POWER_CTRL_EXT_DEBUGGER_OVER_PD_EN (1 << 8)
+/* L2 hardware flush request. This signal indicates:
+0 L2 hardware flush request is not asserted. flush is performed by SW
+1 L2 hardware flush request is asserted by power management block as part of cluster rams power down flow. HW starts L2 flush flow when all CPUs are in WFI */
+#define NB_GLOBAL_CPUS_POWER_CTRL_L2FLUSH_EN (1 << 9)
+/* Force wakeup the CPU in L2RAM power down
+INTERNAL DEBUG PURPOSE ONLY */
+#define NB_GLOBAL_CPUS_POWER_CTRL_FORCE_CPUS_OK_PWRUP (1 << 27)
+/* L2 RAMs power down SM status */
+#define NB_GLOBAL_CPUS_POWER_CTRL_L2RAMS_PWRDN_SM_STATUS_MASK 0xF0000000
+#define NB_GLOBAL_CPUS_POWER_CTRL_L2RAMS_PWRDN_SM_STATUS_SHIFT 28
+
+/**** ACF_Base_High register ****/
+/* Coherency Fabric registers base [39:32]. */
+#define NB_GLOBAL_ACF_BASE_HIGH_BASE_39_32_MASK 0x000000FF
+#define NB_GLOBAL_ACF_BASE_HIGH_BASE_39_32_SHIFT 0
+/* Coherency Fabric registers base [31:15] */
+#define NB_GLOBAL_ACF_BASE_LOW_BASED_31_15_MASK 0xFFFF8000
+#define NB_GLOBAL_ACF_BASE_LOW_BASED_31_15_SHIFT 15
+
+/**** ACF_Control_Override register ****/
+/* Override the AWCACHE[0] and ARCACHE[0] outputs to be
+non-bufferable. One bit exists for each master interface.
+Connected to BUFFERABLEOVERRIDE[2:0] */
+#define NB_GLOBAL_ACF_CONTROL_OVERRIDE_BUFFOVRD_MASK 0x00000007
+#define NB_GLOBAL_ACF_CONTROL_OVERRIDE_BUFFOVRD_SHIFT 0
+/* Overrides the ARQOS and AWQOS input signals. One bit exists for each slave
+interface.
+Connected to QOSOVERRIDE[4:0] */
+#define NB_GLOBAL_ACF_CONTROL_OVERRIDE_QOSOVRD_MASK 0x000000F8
+#define NB_GLOBAL_ACF_CONTROL_OVERRIDE_QOSOVRD_SHIFT 3
+/* If LOW, then AC requests are never issued on the corresponding slave
+interface. One bit exists for each slave interface.
+Connected to ACCHANNELEN[4:0]. */
+#define NB_GLOBAL_ACF_CONTROL_OVERRIDE_ACE_CH_EN_MASK 0x00001F00
+#define NB_GLOBAL_ACF_CONTROL_OVERRIDE_ACE_CH_EN_SHIFT 8
+/* Internal register:
+Enables 4k hazard of post-barrier vs pre-barrier transactions. Otherwise, 64B hazard granularity is applied. */
+#define NB_GLOBAL_ACF_CONTROL_OVERRIDE_DMB_4K_HAZARD_EN (1 << 13)
+
+/**** LGIC_Base_High register ****/
+/* GIC registers base [39:32].
+This value is sampled into the CP15 Configuration Base Address Register (CBAR) at reset. */
+#define NB_GLOBAL_LGIC_BASE_HIGH_BASE_39_32_MASK 0x000000FF
+#define NB_GLOBAL_LGIC_BASE_HIGH_BASE_39_32_SHIFT 0
+#define NB_GLOBAL_LGIC_BASE_HIGH_BASE_43_32_MASK_PKR 0x00000FFF
+#define NB_GLOBAL_LGIC_BASE_HIGH_BASE_43_32_SHIFT_PKR 0
+/* GIC registers base [31:15].
+This value is sampled into the CP15 Configuration Base Address Register (CBAR) at reset */
+#define NB_GLOBAL_LGIC_BASE_LOW_BASED_31_15_MASK 0xFFFF8000
+#define NB_GLOBAL_LGIC_BASE_LOW_BASED_31_15_SHIFT 15
+
+/**** IOGIC_Base_High register ****/
+/* IOGIC registers base [39:32] */
+#define NB_GLOBAL_IOGIC_BASE_HIGH_BASE_39_32_MASK 0x000000FF
+#define NB_GLOBAL_IOGIC_BASE_HIGH_BASE_39_32_SHIFT 0
+/* IOGIC registers base [31:15] */
+#define NB_GLOBAL_IOGIC_BASE_LOW_BASED_31_15_MASK 0xFFFF8000
+#define NB_GLOBAL_IOGIC_BASE_LOW_BASED_31_15_SHIFT 15
+
+/**** IO_Wr_Split_Control register ****/
+/* Write splitters bypass.
+[0] Splitter 0 bypass enable
+[1] Splitter 1 bypass enable */
+#define NB_GLOBAL_IO_WR_SPLIT_CONTROL_WR_SPLT_BYPASS_MASK 0x00000003
+#define NB_GLOBAL_IO_WR_SPLIT_CONTROL_WR_SPLT_BYPASS_SHIFT 0
+/* Write splitters store and forward.
+If store and forward is disabled, splitter does not check non-active BE in the middle of a transaction. */
+#define NB_GLOBAL_IO_WR_SPLIT_CONTROL_WR_SPLT_ST_FW_MASK 0x0000000C
+#define NB_GLOBAL_IO_WR_SPLIT_CONTROL_WR_SPLT_ST_FW_SHIFT 2
+/* Write splitters unmodify snoop type.
+Disables modifying snoop type from Clean & Invalidate to Invalidate when conditions enable it. Only split operation to 64B is applied. */
+#define NB_GLOBAL_IO_WR_SPLIT_CONTROL_WR_SPLT_UNMODIFY_SNP_MASK 0x00000030
+#define NB_GLOBAL_IO_WR_SPLIT_CONTROL_WR_SPLT_UNMODIFY_SNP_SHIFT 4
+/* Write splitters unsplit non-coherent access.
+Disables splitting of non-coherent access to cache-line chunks. */
+#define NB_GLOBAL_IO_WR_SPLIT_CONTROL_WR_SPLT_UNSPLIT_NOSNP_MASK 0x000000C0
+#define NB_GLOBAL_IO_WR_SPLIT_CONTROL_WR_SPLT_UNSPLIT_NOSNP_SHIFT 6
+/* Write splitter rate limit. */
+#define NB_GLOBAL_IO_WR_SPLIT_CONTROL_WR0_SPLT_RATE_LIMIT_MASK 0x00001F00
+#define NB_GLOBAL_IO_WR_SPLIT_CONTROL_WR0_SPLT_RATE_LIMIT_SHIFT 8
+/* Write splitter rate limit */
+#define NB_GLOBAL_IO_WR_SPLIT_CONTROL_WR1_SPLT_RATE_LIMIT_MASK 0x0003E000
+#define NB_GLOBAL_IO_WR_SPLIT_CONTROL_WR1_SPLT_RATE_LIMIT_SHIFT 13
+/* Write splitters 64bit remap enable
+Enables remapping of 64bit transactions */
+#define NB_GLOBAL_IO_WR_SPLIT_CONTROL_WR_SPLT_REMAP_64BIT_EN_MASK 0x000C0000
+#define NB_GLOBAL_IO_WR_SPLIT_CONTROL_WR_SPLT_REMAP_64BIT_EN_SHIFT 18
+/* Clear is not supported. This bit was changed to wr_pack_disable.
+In default mode, AWADDR waits for WDATA. */
+#define NB_GLOBAL_IO_WR_SPLIT_CONTROL_WR_SPLT_CLEAR_MASK 0xC0000000
+#define NB_GLOBAL_IO_WR_SPLIT_CONTROL_WR_SPLT_CLEAR_SHIFT 30
+
+/**** IO_Rd_ROB_Control register ****/
+/* Read ROB Bypass
+[0] Rd ROB 0 bypass enable.
+[1] Rd ROB 1 bypass enable. */
+#define NB_GLOBAL_IO_RD_ROB_CONTROL_RD_ROB_BYPASS_MASK 0x00000003
+#define NB_GLOBAL_IO_RD_ROB_CONTROL_RD_ROB_BYPASS_SHIFT 0
+/* Read ROB in order.
+Return data in the order of request acceptance. */
+#define NB_GLOBAL_IO_RD_ROB_CONTROL_RD_ROB_INORDER_MASK 0x0000000C
+#define NB_GLOBAL_IO_RD_ROB_CONTROL_RD_ROB_INORDER_SHIFT 2
+/* Read ROB response rate
+When enabled drops one cycle from back to back read responses */
+#define NB_GLOBAL_IO_RD_ROB_CONTROL_RD_ROB_RSP_RATE_MASK 0x00000030
+#define NB_GLOBAL_IO_RD_ROB_CONTROL_RD_ROB_RSP_RATE_SHIFT 4
+/* Read splitter rate limit */
+#define NB_GLOBAL_IO_RD_ROB_CONTROL_RD0_ROB_RATE_LIMIT_MASK 0x00001F00
+#define NB_GLOBAL_IO_RD_ROB_CONTROL_RD0_ROB_RATE_LIMIT_SHIFT 8
+/* Read splitter rate limit */
+#define NB_GLOBAL_IO_RD_ROB_CONTROL_RD1_ROB_RATE_LIMIT_MASK 0x0003E000
+#define NB_GLOBAL_IO_RD_ROB_CONTROL_RD1_ROB_RATE_LIMIT_SHIFT 13
+
+/**** SB_PoS_Error_Log_1 register ****/
+/* Error Log 1
+[7:0] address_high
+[16:8] request id
+[18:17] bresp */
+#define NB_GLOBAL_SB_POS_ERROR_LOG_1_ERR_LOG_MASK 0x7FFFFFFF
+#define NB_GLOBAL_SB_POS_ERROR_LOG_1_ERR_LOG_SHIFT 0
+/* Valid logged error
+Set on SB PoS error occurrence on capturing the error information. Subsequent errors will not be captured until the valid bit is cleared.
+The SB PoS reports on write errors.
+When valid, an interrupt is set in the NB Cause Register. */
+#define NB_GLOBAL_SB_POS_ERROR_LOG_1_VALID (1 << 31)
+
+/**** MSIx_Error_Log register ****/
+/* Error Log
+Corresponds to MSIx address message [30:0]. */
+#define NB_GLOBAL_MSIX_ERROR_LOG_ERR_LOG_MASK 0x7FFFFFFF
+#define NB_GLOBAL_MSIX_ERROR_LOG_ERR_LOG_SHIFT 0
+/* Valid logged error */
+#define NB_GLOBAL_MSIX_ERROR_LOG_VALID (1 << 31)
+
+/**** Error_Cause register ****/
+/* Received msix is not mapped to local GIC or IO-GIC spin */
+#define NB_GLOBAL_ERROR_CAUSE_MSIX_ERR_INT (1 << 2)
+/* Coresight timestamp overflow */
+#define NB_GLOBAL_ERROR_CAUSE_CORESIGHT_TS_OVERFLOW (1 << 3)
+/* Write data parity error from SB channel 0. */
+#define NB_GLOBAL_ERROR_CAUSE_SB0_WRDATA_PERR (1 << 4)
+/* Write data parity error from SB channel 1. */
+#define NB_GLOBAL_ERROR_CAUSE_SB1_WRDATA_PERR (1 << 5)
+/* Read data parity error from SB slaves. */
+#define NB_GLOBAL_ERROR_CAUSE_SB_SLV_RDATA_PERR (1 << 6)
+/* Local GIC uncorrectable ECC error */
+#define NB_GLOBAL_ERROR_CAUSE_LOCAL_GIC_ECC_FATAL (1 << 7)
+/* SB PoS error */
+#define NB_GLOBAL_ERROR_CAUSE_SB_POS_ERR (1 << 8)
+/* Coherent fabric error summary interrupt */
+#define NB_GLOBAL_ERROR_CAUSE_ACF_ERRORIRQ (1 << 9)
+/* Error indicator for AXI write transactions with a BRESP error condition. Writing 0 to bit[29] of the L2ECTLR clears the error indicator connected to CA15 nAXIERRIRQ. */
+#define NB_GLOBAL_ERROR_CAUSE_CPU_AXIERRIRQ (1 << 10)
+/* Error indicator for: L2 RAM double-bit ECC error, illegal writes to the GIC memory-map region. */
+#define NB_GLOBAL_ERROR_CAUSE_CPU_INTERRIRQ (1 << 12)
+/* DDR cause summery interrupt */
+#define NB_GLOBAL_ERROR_CAUSE_DDR_CAUSE_SUM (1 << 14)
+
+/**** QoS_Peak_Control register ****/
+/* Peak Read Low Threshold
+When the number of outstanding read transactions from SB masters is below this value, the CPU is assigned high-priority QoS. */
+#define NB_GLOBAL_QOS_PEAK_CONTROL_PEAK_RD_L_THRESHOLD_MASK 0x0000007F
+#define NB_GLOBAL_QOS_PEAK_CONTROL_PEAK_RD_L_THRESHOLD_SHIFT 0
+/* Peak Read High Threshold
+When the number of outstanding read transactions from SB masters exceeds this value, the CPU is assigned high-priority QoS. */
+#define NB_GLOBAL_QOS_PEAK_CONTROL_PEAK_RD_H_THRESHOLD_MASK 0x00007F00
+#define NB_GLOBAL_QOS_PEAK_CONTROL_PEAK_RD_H_THRESHOLD_SHIFT 8
+/* Peak Write Low Threshold
+When the number of outstanding write transactions from SB masters is below this value, the CPU is assigned high-priority QoS */
+#define NB_GLOBAL_QOS_PEAK_CONTROL_PEAK_WR_L_THRESHOLD_MASK 0x007F0000
+#define NB_GLOBAL_QOS_PEAK_CONTROL_PEAK_WR_L_THRESHOLD_SHIFT 16
+/* Peak Write High Threshold
+When the number of outstanding write transactions from SB masters exceeds this value, the CPU is assigned high-priority QoS. */
+#define NB_GLOBAL_QOS_PEAK_CONTROL_PEAK_WR_H_THRESHOLD_MASK 0x7F000000
+#define NB_GLOBAL_QOS_PEAK_CONTROL_PEAK_WR_H_THRESHOLD_SHIFT 24
+
+/**** QoS_Set_Control register ****/
+/* CPU Low priority Read QoS */
+#define NB_GLOBAL_QOS_SET_CONTROL_CPU_LP_ARQOS_MASK 0x0000000F
+#define NB_GLOBAL_QOS_SET_CONTROL_CPU_LP_ARQOS_SHIFT 0
+/* CPU High priority Read QoS */
+#define NB_GLOBAL_QOS_SET_CONTROL_CPU_HP_ARQOS_MASK 0x000000F0
+#define NB_GLOBAL_QOS_SET_CONTROL_CPU_HP_ARQOS_SHIFT 4
+/* CPU Low priority Write QoS */
+#define NB_GLOBAL_QOS_SET_CONTROL_CPU_LP_AWQOS_MASK 0x00000F00
+#define NB_GLOBAL_QOS_SET_CONTROL_CPU_LP_AWQOS_SHIFT 8
+/* CPU High priority Write QoS */
+#define NB_GLOBAL_QOS_SET_CONTROL_CPU_HP_AWQOS_MASK 0x0000F000
+#define NB_GLOBAL_QOS_SET_CONTROL_CPU_HP_AWQOS_SHIFT 12
+/* SB Low priority Read QoS */
+#define NB_GLOBAL_QOS_SET_CONTROL_SB_LP_ARQOS_MASK 0x000F0000
+#define NB_GLOBAL_QOS_SET_CONTROL_SB_LP_ARQOS_SHIFT 16
+/* SB Low-priority Write QoS */
+#define NB_GLOBAL_QOS_SET_CONTROL_SB_LP_AWQOS_MASK 0x00F00000
+#define NB_GLOBAL_QOS_SET_CONTROL_SB_LP_AWQOS_SHIFT 20
+
+/**** DDR_QoS register ****/
+/* High Priority Read Threshold
+Limits the number of outstanding high priority reads in the system through the memory controller.
+This parameter is programmed in conjunction with number of outstanding high priority reads supported by the DDR controller. */
+#define NB_GLOBAL_DDR_QOS_HIGH_PRIO_THRESHOLD_MASK 0x0000007F
+#define NB_GLOBAL_DDR_QOS_HIGH_PRIO_THRESHOLD_SHIFT 0
+/* DDR Low Priority QoS
+Fabric priority below this value is mapped to DDR low priority queue. */
+#define NB_GLOBAL_DDR_QOS_LP_QOS_MASK 0x00000F00
+#define NB_GLOBAL_DDR_QOS_LP_QOS_SHIFT 8
+
+/**** ACF_Misc register ****/
+/* Disable DDR Write Chop
+Performance optimization feature to chop non-active data beats to the DDR. */
+#define NB_GLOBAL_ACF_MISC_DDR_WR_CHOP_DIS (1 << 0)
+/* Disable SB-2-SB path through NB fabric. */
+#define NB_GLOBAL_ACF_MISC_SB2SB_PATH_DIS (1 << 1)
+/* Disable ETR tracing to non-DDR. */
+#define NB_GLOBAL_ACF_MISC_ETR2SB_PATH_DIS (1 << 2)
+/* Disable ETR tracing to non-DDR. */
+#define NB_GLOBAL_ACF_MISC_CPU2MSIX_DIS (1 << 3)
+/* Disable CPU generation of MSIx
+By default, the CPU can set any MSIx message results by setting any SPIn bit in the local and IO-GIC. */
+#define NB_GLOBAL_ACF_MISC_MSIX_TERMINATE_DIS (1 << 4)
+/* Disable snoop override for MSIx
+By default, an MSIx transaction is downgraded to non-coherent. */
+#define NB_GLOBAL_ACF_MISC_MSIX_SNOOPOVRD_DIS (1 << 5)
+/* POS bypass */
+#define NB_GLOBAL_ACF_MISC_POS_BYPASS (1 << 6)
+/* PoS ReadStronglyOrdered enable
+SO read forces flushing of all prior writes */
+#define NB_GLOBAL_ACF_MISC_POS_RSO_EN (1 << 7)
+/* WRAP to INC transfer enable */
+#define NB_GLOBAL_ACF_MISC_POS_WRAP2INC (1 << 8)
+/* PoS DSB flush Disable
+On DSB from CPU, PoS blocks the progress of post-barrier reads and writes until all pre-barrier writes have been completed. */
+#define NB_GLOBAL_ACF_MISC_POS_DSB_FLUSH_DIS (1 << 9)
+/* PoS DMB Flush Disable
+On DMB from CPU, the PoS blocks the progress of post-barrier non-buffereable reads or writes when there are outstanding non-bufferable writes that have not yet been completed.
+Other access types are hazard check against the pre-barrier requests. */
+#define NB_GLOBAL_ACF_MISC_POS_DMB_FLUSH_DIS (1 << 10)
+/* change DMB functionality to DSB (block and drain) */
+#define NB_GLOBAL_ACF_MISC_POS_DMB_TO_DSB_EN (1 << 11)
+/* Disable write after read stall when accessing IO fabric slaves. */
+#define NB_GLOBAL_ACF_MISC_M0_WAR_STALL_DIS (1 << 12)
+/* Disable write after read stall when accessing DDR */
+#define NB_GLOBAL_ACF_MISC_M1_WAR_STALL_DIS (1 << 13)
+/* Disable counter (wait 1000 NB cycles) before applying PoS enable/disable configuration */
+#define NB_GLOBAL_ACF_MISC_POS_CONFIG_CNT_DIS (1 << 14)
+/* Disable wr spliter A0 bug fixes */
+#define NB_GLOBAL_ACF_MISC_WRSPLT_ALPINE_M0_MODE (1 << 16)
+/* Disable wr spliter PKR bug fixes */
+#define NB_GLOBAL_ACF_MISC_WRSPLT_ALPINE_A0_MODE (1 << 17)
+/* Override the address parity calucation for write transactions going to IO-fabric */
+#define NB_GLOBAL_ACF_MISC_NB_NIC_AWADDR_PAR_OVRD (1 << 18)
+/* Override the data parity calucation for write transactions going to IO-fabric */
+#define NB_GLOBAL_ACF_MISC_NB_NIC_WDATA_PAR_OVRD (1 << 19)
+/* Override the address parity calucation for read transactions going to IO-fabric */
+#define NB_GLOBAL_ACF_MISC_NB_NIC_ARADDR_PAR_OVRD (1 << 20)
+/* Halts CPU AXI interface (Ar/Aw channels), not allowing the CPU to send additional transactions */
+#define NB_GLOBAL_ACF_MISC_CPU_AXI_HALT (1 << 23)
+/* Disable early arbar termination when fabric write buffer is enabled. */
+#define NB_GLOBAL_ACF_MISC_CCIWB_EARLY_ARBAR_TERM_DIS (1 << 24)
+/* Enable wire interrupts connectivity to IO-GIC IRQs */
+#define NB_GLOBAL_ACF_MISC_IOGIC_CHIP_SPI_EN (1 << 25)
+/* Enable DMB flush request to NB to SB PoS when barrier is terminted inside the processor cluster */
+#define NB_GLOBAL_ACF_MISC_CPU_DSB_FLUSH_DIS (1 << 26)
+/* Enable DMB flush request to NB to SB PoS when barrier is terminted inside the processor cluster */
+#define NB_GLOBAL_ACF_MISC_CPU_DMB_FLUSH_DIS (1 << 27)
+/* Peakrock only: remap CPU address above 40 bits to Slave Error
+INTERNAL */
+#define NB_GLOBAL_ACF_MISC_ADDR43_40_REMAP_DIS (1 << 28)
+/* Enable CPU WriteUnique to WriteNoSnoop trasform */
+#define NB_GLOBAL_ACF_MISC_CPU_WU2WNS_EN (1 << 29)
+/* Disable device after device check */
+#define NB_GLOBAL_ACF_MISC_WR_POS_DEV_AFTER_DEV_DIS (1 << 30)
+/* Disable wrap to inc on write */
+#define NB_GLOBAL_ACF_MISC_WR_INC2WRAP_EN (1 << 31)
+
+/**** Config_Bus_Control register ****/
+/* Write slave error enable */
+#define NB_GLOBAL_CONFIG_BUS_CONTROL_WR_SLV_ERR_EN (1 << 0)
+/* Write decode error enable */
+#define NB_GLOBAL_CONFIG_BUS_CONTROL_WR_DEC_ERR_EN (1 << 1)
+/* Read slave error enable */
+#define NB_GLOBAL_CONFIG_BUS_CONTROL_RD_SLV_ERR_EN (1 << 2)
+/* Read decode error enable */
+#define NB_GLOBAL_CONFIG_BUS_CONTROL_RD_DEC_ERR_EN (1 << 3)
+/* Ignore Write ID */
+#define NB_GLOBAL_CONFIG_BUS_CONTROL_IGNORE_WR_ID (1 << 4)
+/* Timeout limit before terminating configuration bus access with slave error */
+#define NB_GLOBAL_CONFIG_BUS_CONTROL_TIMEOUT_LIMIT_MASK 0xFFFFFF00
+#define NB_GLOBAL_CONFIG_BUS_CONTROL_TIMEOUT_LIMIT_SHIFT 8
+
+/**** Pos_ID_Match register ****/
+/* Enable Device (GRE and nGRE) after Device ID hazard */
+#define NB_GLOBAL_POS_ID_MATCH_ENABLE (1 << 0)
+/* ID Field Mask
+If set, corresonpding ID bits are not used for ID match */
+#define NB_GLOBAL_POS_ID_MATCH_MASK_MASK 0xFFFF0000
+#define NB_GLOBAL_POS_ID_MATCH_MASK_SHIFT 16
+
+/**** sb_sel_override_awuser register ****/
+/* Select whether to use transaction awuser or sb_override_awuser value for awuser field on outgoing write transactions to SB.
+Each bit if set to 1 selects the corresponding sb_override_awuser bit. Otherwise, selects the corersponding transaction awuser bit. */
+#define NB_GLOBAL_SB_SEL_OVERRIDE_AWUSER_SEL_MASK 0x03FFFFFF
+#define NB_GLOBAL_SB_SEL_OVERRIDE_AWUSER_SEL_SHIFT 0
+
+/**** sb_override_awuser register ****/
+/* Awuser to use on overriden transactions
+Only applicable if sel_override_awuser.sel is set to 1'b1 for the coressponding bit */
+#define NB_GLOBAL_SB_OVERRIDE_AWUSER_AWUSER_MASK 0x03FFFFFF
+#define NB_GLOBAL_SB_OVERRIDE_AWUSER_AWUSER_SHIFT 0
+
+/**** sb_sel_override_aruser register ****/
+/* Select whether to use transaction aruser or sb_override_aruser value for aruser field on outgoing read transactions to SB.
+Each bit if set to 1 selects the corresponding sb_override_aruser bit. Otherwise, selects the corersponding transaction aruser bit. */
+#define NB_GLOBAL_SB_SEL_OVERRIDE_ARUSER_SEL_MASK 0x03FFFFFF
+#define NB_GLOBAL_SB_SEL_OVERRIDE_ARUSER_SEL_SHIFT 0
+
+/**** sb_override_aruser register ****/
+/* Aruser to use on overriden transactions
+Only applicable if sb_sel_override_aruser.sel is set to 1'b1 for the coressponding bit */
+#define NB_GLOBAL_SB_OVERRIDE_ARUSER_ARUSER_MASK 0x03FFFFFF
+#define NB_GLOBAL_SB_OVERRIDE_ARUSER_ARUSER_SHIFT 0
+
+/**** Coresight_PD register ****/
+/* ETF0 RAM force power down */
+#define NB_GLOBAL_CORESIGHT_PD_ETF0_RAM_FORCE_PD (1 << 0)
+/* ETF1 RAM force power down */
+#define NB_GLOBAL_CORESIGHT_PD_ETF1_RAM_FORCE_PD (1 << 1)
+/* ETF0 RAM force clock gate */
+#define NB_GLOBAL_CORESIGHT_PD_ETF0_RAM_FORCE_CG (1 << 2)
+/* ETF1 RAM force clock gate */
+#define NB_GLOBAL_CORESIGHT_PD_ETF1_RAM_FORCE_CG (1 << 3)
+/* APBIC clock enable */
+#define NB_GLOBAL_CORESIGHT_PD_APBICLKEN (1 << 4)
+/* DAP system clock enable */
+#define NB_GLOBAL_CORESIGHT_PD_DAP_SYS_CLKEN (1 << 5)
+
+/**** Coresight_INTERNAL_0 register ****/
+
+#define NB_GLOBAL_CORESIGHT_INTERNAL_0_CTIAPBSBYPASS (1 << 0)
+/* CA15 CTM and Coresight CTI operate at same clock, bypass modes can be enabled but it's being set to bypass disable to break timing path. */
+#define NB_GLOBAL_CORESIGHT_INTERNAL_0_CISBYPASS (1 << 1)
+/* CA15 CTM and Coresight CTI operate according to the same clock.
+Bypass modes can be enabled, but it is set to bypass disable, to break the timing path. */
+#define NB_GLOBAL_CORESIGHT_INTERNAL_0_CIHSBYPASS_MASK 0x0000003C
+#define NB_GLOBAL_CORESIGHT_INTERNAL_0_CIHSBYPASS_SHIFT 2
+
+/**** Coresight_DBGROMADDR register ****/
+/* Valid signal for DBGROMADDR.
+Connected to DBGROMADDRV */
+#define NB_GLOBAL_CORESIGHT_DBGROMADDR_VALID (1 << 0)
+/* Specifies bits [39:12] of the ROM table physical address. */
+#define NB_GLOBAL_CORESIGHT_DBGROMADDR_ADDR_39_12_MASK 0x3FFFFFFC
+#define NB_GLOBAL_CORESIGHT_DBGROMADDR_ADDR_39_12_SHIFT 2
+
+/**** Coresight_DBGSELFADDR register ****/
+/* Valid signal for DBGROMADDR.
+Connected to DBGROMADDRV */
+#define NB_GLOBAL_CORESIGHT_DBGSELFADDR_VALID (1 << 0)
+/* Specifies bits [18:17] of the two's complement signed offset from the ROM table physical address to the physical address where the debug registers are memory-mapped.
+Note: The CA15 debug unit starts at offset 0x1 within the Coresight cluster. */
+#define NB_GLOBAL_CORESIGHT_DBGSELFADDR_ADDR_18_17_MASK 0x00000180
+#define NB_GLOBAL_CORESIGHT_DBGSELFADDR_ADDR_18_17_SHIFT 7
+/* Specifies bits [39:19] of the two's complement signed offset from the ROM table physical address to the physical address where the debug registers are memory-mapped.
+Note: The CA15 debug unit starts at offset 0x1 within the Coresight cluster, so this offset if fixed to zero. */
+#define NB_GLOBAL_CORESIGHT_DBGSELFADDR_ADDR_39_19_MASK 0x3FFFFE00
+#define NB_GLOBAL_CORESIGHT_DBGSELFADDR_ADDR_39_19_SHIFT 9
+
+/**** SB_force_same_id_cfg_0 register ****/
+/* Enables force same id mechanism for SB port 0 */
+#define NB_GLOBAL_SB_FORCE_SAME_ID_CFG_0_FORCE_SAME_ID_EN (1 << 0)
+/* Enables MSIx stall when write transactions from same ID mechanism are in progress for SB port 0 */
+#define NB_GLOBAL_SB_FORCE_SAME_ID_CFG_0_FORCE_SAME_ID_MSIX_STALL_EN (1 << 1)
+/* Mask for choosing which ID bits to match for indicating the originating master */
+#define NB_GLOBAL_SB_FORCE_SAME_ID_CFG_0_SB_MSTR_ID_MASK_MASK 0x000000F8
+#define NB_GLOBAL_SB_FORCE_SAME_ID_CFG_0_SB_MSTR_ID_MASK_SHIFT 3
+
+/**** SB_force_same_id_cfg_1 register ****/
+/* Enables force same id mechanism for SB port 1 */
+#define NB_GLOBAL_SB_FORCE_SAME_ID_CFG_1_FORCE_SAME_ID_EN (1 << 0)
+/* Enables MSIx stall when write transactions from same ID mechanism are in progress for SB port 1 */
+#define NB_GLOBAL_SB_FORCE_SAME_ID_CFG_1_FORCE_SAME_ID_MSIX_STALL_EN (1 << 1)
+/* Mask for choosing which ID bits to match for indicating the originating master */
+#define NB_GLOBAL_SB_FORCE_SAME_ID_CFG_1_SB_MSTR_ID_MASK_MASK 0x000000F8
+#define NB_GLOBAL_SB_FORCE_SAME_ID_CFG_1_SB_MSTR_ID_MASK_SHIFT 3
+
+/**** Cnt_Control register ****/
+/* System counter enable
+Counter is enabled after reset. */
+#define NB_SYSTEM_COUNTER_CNT_CONTROL_EN (1 << 0)
+/* System counter restart
+Initial value is reloaded from Counter_Init_L and Counter_Init_H registers.
+Transition from 0 to 1 reloads the register. */
+#define NB_SYSTEM_COUNTER_CNT_CONTROL_RESTART (1 << 1)
+/* Disable CTI trigger out that halt the counter progress */
+#define NB_SYSTEM_COUNTER_CNT_CONTROL_CTI_TRIGOUT_HALT_DIS (1 << 2)
+/* System counter tick
+Specifies the counter tick rate relative to the Northbridge clock, e.g., the counter is incremented every 16 NB cycles if programmed to 0x0f. */
+#define NB_SYSTEM_COUNTER_CNT_CONTROL_SCALE_MASK 0x0000FF00
+#define NB_SYSTEM_COUNTER_CNT_CONTROL_SCALE_SHIFT 8
+
+/**** CA15_RF_Misc register ****/
+
+#define NB_RAMS_CONTROL_MISC_CA15_RF_MISC_NONECPU_RF_MISC_MASK 0x0000000F
+#define NB_RAMS_CONTROL_MISC_CA15_RF_MISC_NONECPU_RF_MISC_SHIFT 0
+
+#define NB_RAMS_CONTROL_MISC_CA15_RF_MISC_CPU_RF_MISC_MASK 0x00FFFF00
+#define NB_RAMS_CONTROL_MISC_CA15_RF_MISC_CPU_RF_MISC_SHIFT 8
+/* Pause for CPUs from the time all power is up to the time the SRAMs start opening. */
+#define NB_RAMS_CONTROL_MISC_CA15_RF_MISC_PWR_UP_PAUSE_MASK 0xF8000000
+#define NB_RAMS_CONTROL_MISC_CA15_RF_MISC_PWR_UP_PAUSE_SHIFT 27
+
+/**** NB_RF_Misc register ****/
+/* SMMU TLB RAMs force power down */
+#define NB_RAMS_CONTROL_MISC_NB_RF_MISC_SMMU_RAM_FORCE_PD (1 << 0)
+
+/**** Lockn register ****/
+/* Semaphore Lock
+CPU reads it:
+If current value ==0, return 0 to CPU but set bit to 1. (CPU knows it captured the semaphore.)
+If current value ==1, return 1 to CPU. (CPU knows it is already used and waits.)
+CPU writes 0 to it to release the semaphore. */
+#define NB_SEMAPHORES_LOCKN_LOCK (1 << 0)
+
+/**** CA15_outputs_1 register ****/
+/*
+ */
+#define NB_DEBUG_CA15_OUTPUTS_1_STANDBYWFI_MASK 0x0000000F
+#define NB_DEBUG_CA15_OUTPUTS_1_STANDBYWFI_SHIFT 0
+/*
+ */
+#define NB_DEBUG_CA15_OUTPUTS_1_CPU_PWR_DN_ACK_MASK 0x000000F0
+#define NB_DEBUG_CA15_OUTPUTS_1_CPU_PWR_DN_ACK_SHIFT 4
+/*
+ */
+#define NB_DEBUG_CA15_OUTPUTS_1_IRQOUT_N_MASK 0x00000F00
+#define NB_DEBUG_CA15_OUTPUTS_1_IRQOUT_N_SHIFT 8
+/*
+ */
+#define NB_DEBUG_CA15_OUTPUTS_1_FIQOUT_N_MASK 0x0000F000
+#define NB_DEBUG_CA15_OUTPUTS_1_FIQOUT_N_SHIFT 12
+/*
+ */
+#define NB_DEBUG_CA15_OUTPUTS_1_CNTHPIRQ_N_MASK 0x000F0000
+#define NB_DEBUG_CA15_OUTPUTS_1_CNTHPIRQ_N_SHIFT 16
+/*
+ */
+#define NB_DEBUG_CA15_OUTPUTS_1_NCNTPNSIRQ_N_MASK 0x00F00000
+#define NB_DEBUG_CA15_OUTPUTS_1_NCNTPNSIRQ_N_SHIFT 20
+/*
+ */
+#define NB_DEBUG_CA15_OUTPUTS_1_NCNTPSIRQ_N_MASK 0x0F000000
+#define NB_DEBUG_CA15_OUTPUTS_1_NCNTPSIRQ_N_SHIFT 24
+/*
+ */
+#define NB_DEBUG_CA15_OUTPUTS_1_NCNTVIRQ_N_MASK 0xF0000000
+#define NB_DEBUG_CA15_OUTPUTS_1_NCNTVIRQ_N_SHIFT 28
+
+/**** CA15_outputs_2 register ****/
+/*
+ */
+#define NB_DEBUG_CA15_OUTPUTS_2_STANDBYWFIL2 (1 << 0)
+/*
+ */
+#define NB_DEBUG_CA15_OUTPUTS_2_L2RAM_PWR_DN_ACK (1 << 1)
+/* Indicates for each CPU if coherency is enabled
+ */
+#define NB_DEBUG_CA15_OUTPUTS_2_SMPEN_MASK 0x0000003C
+#define NB_DEBUG_CA15_OUTPUTS_2_SMPEN_SHIFT 2
+
+/**** cpu_msg register ****/
+/* Status/ASCII code */
+#define NB_DEBUG_CPU_MSG_STATUS_MASK 0x000000FF
+#define NB_DEBUG_CPU_MSG_STATUS_SHIFT 0
+/* Toggle with each ASCII write */
+#define NB_DEBUG_CPU_MSG_ASCII_TOGGLE (1 << 8)
+/* Signals ASCII */
+#define NB_DEBUG_CPU_MSG_ASCII (1 << 9)
+
+#define NB_DEBUG_CPU_MSG_RESERVED_11_10_MASK 0x00000C00
+#define NB_DEBUG_CPU_MSG_RESERVED_11_10_SHIFT 10
+/* Signals new section started in S/W */
+#define NB_DEBUG_CPU_MSG_SECTION_START (1 << 12)
+
+#define NB_DEBUG_CPU_MSG_RESERVED_13 (1 << 13)
+/* Signals a single CPU is done. */
+#define NB_DEBUG_CPU_MSG_CPU_DONE (1 << 14)
+/* Signals test is done */
+#define NB_DEBUG_CPU_MSG_TEST_DONE (1 << 15)
+
+/**** ddrc register ****/
+/* External DLL calibration request. Also compensates for VT variations, such as an external request for the controller (can be performed automatically by the controller at the normal settings). */
+#define NB_DEBUG_DDRC_DLL_CALIB_EXT_REQ (1 << 0)
+/* External request to perform short (long is performed during initialization) and/or ODT calibration. */
+#define NB_DEBUG_DDRC_ZQ_SHORT_CALIB_EXT_REQ (1 << 1)
+/* External request to perform a refresh command to a specific bank. Usually performed automatically by the controller, however, the controller supports disabling of the automatic mechanism, and use of an external pulse instead. */
+#define NB_DEBUG_DDRC_RANK_REFRESH_EXT_REQ_MASK 0x0000003C
+#define NB_DEBUG_DDRC_RANK_REFRESH_EXT_REQ_SHIFT 2
+
+/**** ddrc_phy_smode_control register ****/
+/* DDR PHY special mode */
+#define NB_DEBUG_DDRC_PHY_SMODE_CONTROL_CTL_MASK 0x0000FFFF
+#define NB_DEBUG_DDRC_PHY_SMODE_CONTROL_CTL_SHIFT 0
+
+/**** ddrc_phy_smode_status register ****/
+/* DDR PHY special mode */
+#define NB_DEBUG_DDRC_PHY_SMODE_STATUS_STT_MASK 0x0000FFFF
+#define NB_DEBUG_DDRC_PHY_SMODE_STATUS_STT_SHIFT 0
+
+/**** pmc register ****/
+/* Enable system control on NB DRO */
+#define NB_DEBUG_PMC_SYS_EN (1 << 0)
+/* NB PMC HVT35 counter value */
+#define NB_DEBUG_PMC_HVT35_VAL_14_0_MASK 0x0000FFFE
+#define NB_DEBUG_PMC_HVT35_VAL_14_0_SHIFT 1
+/* NB PMC SVT31 counter value */
+#define NB_DEBUG_PMC_SVT31_VAL_14_0_MASK 0x7FFF0000
+#define NB_DEBUG_PMC_SVT31_VAL_14_0_SHIFT 16
+
+/**** cpus_general register ****/
+/* Swaps sysaddr[16:14] with sysaddr[19:17] for DDR access*/
+#define NB_DEBUG_CPUS_GENERAL_ADDR_MAP_ECO (1 << 23)
+
+/**** cpus_int_out register ****/
+/* Defines which CPUs' FIQ will be triggered out through the cpus_int_out[1] pinout. */
+#define NB_DEBUG_CPUS_INT_OUT_FIQ_EN_MASK 0x0000000F
+#define NB_DEBUG_CPUS_INT_OUT_FIQ_EN_SHIFT 0
+/* Defines which CPUs' IRQ will be triggered out through the cpus_int_out[0] pinout. */
+#define NB_DEBUG_CPUS_INT_OUT_IRQ_EN_MASK 0x000000F0
+#define NB_DEBUG_CPUS_INT_OUT_IRQ_EN_SHIFT 4
+/* Defines which CPUs' SEI will be triggered out through the cpus_int_out[0] pinout. */
+#define NB_DEBUG_CPUS_INT_OUT_IRQ_SEI_EN_MASK 0x00000F00
+#define NB_DEBUG_CPUS_INT_OUT_IRQ_SEI_EN_SHIFT 8
+
+/**** latch_pc_req register ****/
+/* If set, request to latch execution PC from processor cluster */
+#define NB_DEBUG_LATCH_PC_REQ_EN (1 << 0)
+/* target CPU id to latch its execution PC */
+#define NB_DEBUG_LATCH_PC_REQ_CPU_ID_MASK 0x000000F0
+#define NB_DEBUG_LATCH_PC_REQ_CPU_ID_SHIFT 4
+
+/**** latch_pc_low register ****/
+/* Set by hardware when the processor cluster ack the PC latch request.
+Clear on read latch_pc_high */
+#define NB_DEBUG_LATCH_PC_LOW_VALID (1 << 0)
+/* Latched PC value [31:1] */
+#define NB_DEBUG_LATCH_PC_LOW_VAL_MASK 0xFFFFFFFE
+#define NB_DEBUG_LATCH_PC_LOW_VAL_SHIFT 1
+
+/**** track_dump_ctrl register ****/
+/* [24:16]: Queue entry pointer
+[2] Target queue: 1'b0: HazardTrack or 1'b1: AmiRMI queues
+[1:0]: CCI target master: 2'b00: M0, 2'b01: M1, 2'b10: M2 */
+#define NB_DEBUG_TRACK_DUMP_CTRL_PTR_MASK 0x7FFFFFFF
+#define NB_DEBUG_TRACK_DUMP_CTRL_PTR_SHIFT 0
+/* Track Dump Request
+If set, queue entry info is latched on track_dump_rdata register.
+Program the pointer and target queue.
+This is a full handshake register.
+Read <valid> bit from track_dump_rdata register. If set, clear the request field before triggering a new request. */
+#define NB_DEBUG_TRACK_DUMP_CTRL_REQ (1 << 31)
+
+/**** track_dump_rdata_0 register ****/
+/* Valid */
+#define NB_DEBUG_TRACK_DUMP_RDATA_0_VALID (1 << 0)
+/* Low data */
+#define NB_DEBUG_TRACK_DUMP_RDATA_0_DATA_MASK 0xFFFFFFFE
+#define NB_DEBUG_TRACK_DUMP_RDATA_0_DATA_SHIFT 1
+
+/**** pos_track_dump_ctrl register ****/
+/* [24:16]: queue entry pointer */
+#define NB_DEBUG_POS_TRACK_DUMP_CTRL_PTR_MASK 0x7FFFFFFF
+#define NB_DEBUG_POS_TRACK_DUMP_CTRL_PTR_SHIFT 0
+/* Track Dump Request
+If set, queue entry info is latched on track_dump_rdata register.
+Program the pointer and target queue.
+This is a full handshake register
+Read <valid> bit from track_dump_rdata register. If set, clear the request field before triggering a new request. */
+#define NB_DEBUG_POS_TRACK_DUMP_CTRL_REQ (1 << 31)
+
+/**** pos_track_dump_rdata_0 register ****/
+/* Valid */
+#define NB_DEBUG_POS_TRACK_DUMP_RDATA_0_VALID (1 << 0)
+/* Low data */
+#define NB_DEBUG_POS_TRACK_DUMP_RDATA_0_DATA_MASK 0xFFFFFFFE
+#define NB_DEBUG_POS_TRACK_DUMP_RDATA_0_DATA_SHIFT 1
+
+/**** c2swb_track_dump_ctrl register ****/
+/* [24:16]: Queue entry pointer */
+#define NB_DEBUG_C2SWB_TRACK_DUMP_CTRL_PTR_MASK 0x7FFFFFFF
+#define NB_DEBUG_C2SWB_TRACK_DUMP_CTRL_PTR_SHIFT 0
+/* Track Dump Request
+If set, queue entry info is latched on track_dump_rdata register.
+Program the pointer and target queue.
+This is a full handshake register
+Read <valid> bit from track_dump_rdata register. If set, clear the request field before triggering a new request. */
+#define NB_DEBUG_C2SWB_TRACK_DUMP_CTRL_REQ (1 << 31)
+
+/**** c2swb_track_dump_rdata_0 register ****/
+/* Valid */
+#define NB_DEBUG_C2SWB_TRACK_DUMP_RDATA_0_VALID (1 << 0)
+/* Low data */
+#define NB_DEBUG_C2SWB_TRACK_DUMP_RDATA_0_DATA_MASK 0xFFFFFFFE
+#define NB_DEBUG_C2SWB_TRACK_DUMP_RDATA_0_DATA_SHIFT 1
+
+/**** cpus_track_dump_ctrl register ****/
+/* [24:16]: Queue entry pointer
+[3:2] Target queue - 0:ASI, 1: AMI
+[1:0]: Target Processor Cluster - 0: Cluster0, 1: Cluster1 */
+#define NB_DEBUG_CPUS_TRACK_DUMP_CTRL_PTR_MASK 0x7FFFFFFF
+#define NB_DEBUG_CPUS_TRACK_DUMP_CTRL_PTR_SHIFT 0
+/* Track Dump Request
+If set, queue entry info is latched on track_dump_rdata register.
+Program the pointer and target queue.
+This is a full handshake register
+Read <valid> bit from track_dump_rdata register. If set, clear the request field before triggering a new request. */
+#define NB_DEBUG_CPUS_TRACK_DUMP_CTRL_REQ (1 << 31)
+
+/**** cpus_track_dump_rdata_0 register ****/
+/* Valid */
+#define NB_DEBUG_CPUS_TRACK_DUMP_RDATA_0_VALID (1 << 0)
+/* Low data */
+#define NB_DEBUG_CPUS_TRACK_DUMP_RDATA_0_DATA_MASK 0xFFFFFFFE
+#define NB_DEBUG_CPUS_TRACK_DUMP_RDATA_0_DATA_SHIFT 1
+
+/**** c2swb_bar_ovrd_high register ****/
+/* Read barrier is progressed downstream when not terminated in the CCI.
+By specification, barrier address is 0x0.
+This register enables barrier address OVRD to a programmable value. */
+#define NB_DEBUG_C2SWB_BAR_OVRD_HIGH_RD_ADDR_OVRD_EN (1 << 0)
+/* Address bits 39:32 */
+#define NB_DEBUG_C2SWB_BAR_OVRD_HIGH_ADDR_39_32_MASK 0x00FF0000
+#define NB_DEBUG_C2SWB_BAR_OVRD_HIGH_ADDR_39_32_SHIFT 16
+
+/**** Config register ****/
+/* Individual processor control of the endianness configuration at reset. It sets the initial value of the EE bit in the CP15 System Control Register (SCTLR) related to CFGEND<n> input:
+little - 0x0: Little endian
+bit - 0x1: Bit endian */
+#define NB_CPUN_CONFIG_STATUS_CONFIG_ENDIAN (1 << 0)
+/* Individual processor control of the default exception handling state. It sets the initial value of the TE bit in the CP15 System Control Register (SCTLR) related to CFGTE<n> input:
+arm: 0x0: Exception operates ARM code.
+Thumb: 0x1: Exception operates Thumb code. */
+#define NB_CPUN_CONFIG_STATUS_CONFIG_TE (1 << 1)
+/* Individual processor control of the location of the exception vectors at reset. It sets the initial value of the V bit in the CP15 System Control Register (SCTLR).
+Connected to VINITHIGH<n> input.
+low - 0x0: Exception vectors start at address 0x00000000.
+high - 0x1: Exception vectors start at address 0xFFFF0000. */
+#define NB_CPUN_CONFIG_STATUS_CONFIG_VINITHI (1 << 2)
+/* Individual processor control to disable write access to some secure CP15 registers
+connected to CP15SDISABLE<n> input. */
+#define NB_CPUN_CONFIG_STATUS_CONFIG_CP15DISABLE (1 << 3)
+/* Force Write init implementation to ConfigAARch64 register */
+#define NB_CPUN_CONFIG_STATUS_CONFIG_AARCH64_REG_FORCE_WINIT (1 << 4)
+/* Force Write Once implementation to ConfigAARch64 register. */
+#define NB_CPUN_CONFIG_STATUS_CONFIG_AARCH64_REG_FORCE_WONCE (1 << 5)
+
+/**** Config_AARch64 register ****/
+/* Individual processor register width state. The register width states are:
+0 AArch32.
+1 AArch64.
+This signal is only sampled during reset of the processor.
+This is Write Init register */
+#define NB_CPUN_CONFIG_STATUS_CONFIG_AARCH64_AA64_NAA32 (1 << 0)
+/* Individual processor Cryptography engine disable:
+0 Enable the Cryptography engine.
+1 Disable the Cryptography engine.
+This signal is only sampled during reset of the processor */
+#define NB_CPUN_CONFIG_STATUS_CONFIG_AARCH64_CRYPTO_DIS (1 << 1)
+
+/**** Power_Ctrl register ****/
+/* Individual CPU power mode transition request
+If requested to enter power mode other than normal mode, low power state is resumed whenever CPU reenters STNDBYWFI state:
+normal: 0x0: normal power state
+deep_idle: 0x2: Dormant power mode state
+poweredoff: 0x3: Powered-off power mode */
+#define NB_CPUN_CONFIG_STATUS_POWER_CTRL_PM_REQ_MASK 0x00000003
+#define NB_CPUN_CONFIG_STATUS_POWER_CTRL_PM_REQ_SHIFT 0
+/* Normal power mode state */
+#define NB_CPUN_CONFIG_STATUS_POWER_CTRL_PM_REQ_NORMAL \
+ (0x0 << NB_CPUN_CONFIG_STATUS_POWER_CTRL_PM_REQ_SHIFT)
+/* Dormant power mode state */
+#define NB_CPUN_CONFIG_STATUS_POWER_CTRL_PM_REQ_DEEP_IDLE \
+ (0x2 << NB_CPUN_CONFIG_STATUS_POWER_CTRL_PM_REQ_SHIFT)
+/* Powered-off power mode */
+#define NB_CPUN_CONFIG_STATUS_POWER_CTRL_PM_REQ_POWEREDOFF \
+ (0x3 << NB_CPUN_CONFIG_STATUS_POWER_CTRL_PM_REQ_SHIFT)
+/* Power down regret disable
+When power down regret is enabled, the powerdown enter flow can be halted whenever a valid wakeup event occurs. */
+#define NB_CPUN_CONFIG_STATUS_POWER_CTRL_PWRDN_RGRT_DIS (1 << 16)
+/* Power down emulation enable
+If set, the entire power down sequence is applied, but the CPU is placed in soft reset instead of hardware power down. */
+#define NB_CPUN_CONFIG_STATUS_POWER_CTRL_PWRDN_EMULATE (1 << 17)
+/* Disable wakeup from Local--GIC FIQ. */
+#define NB_CPUN_CONFIG_STATUS_POWER_CTRL_WU_LGIC_FIQ_DIS (1 << 18)
+/* Disable wakeup from Local-GIC IRQ. */
+#define NB_CPUN_CONFIG_STATUS_POWER_CTRL_WU_LGIC_IRQ_DIS (1 << 19)
+/* Disable wakeup from IO-GIC FIQ. */
+#define NB_CPUN_CONFIG_STATUS_POWER_CTRL_WU_IOGIC_FIQ_DIS (1 << 20)
+/* Disable wakeup from IO-GIC IRQ. */
+#define NB_CPUN_CONFIG_STATUS_POWER_CTRL_WU_IOGIC_IRQ_DIS (1 << 21)
+/* Disable scheduling of interrrupts in GIC(500) to non-active CPU */
+#define NB_CPUN_CONFIG_STATUS_POWER_CTRL_IOGIC_DIS_CPU (1 << 22)
+
+/**** Power_Status register ****/
+/* Read-only bits that reflect the individual CPU power mode status.
+Default value for non-exist CPU is 2b11:
+normal - 0x0: Normal mode
+por - 0x1: por on reset mode
+deep_idle - 0x2: Dormant power mode state
+poweredoff - 0x3: Powered-off power mode */
+#define NB_CPUN_CONFIG_STATUS_POWER_STATUS_CPU_PM_MASK 0x00000003
+#define NB_CPUN_CONFIG_STATUS_POWER_STATUS_CPU_PM_SHIFT 0
+/* Normal power mode state */
+#define NB_CPUN_CONFIG_STATUS_POWER_STATUS_CPU_PM_NORMAL \
+ (0x0 << NB_CPUN_CONFIG_STATUS_POWER_STATUS_CPU_PM_SHIFT)
+/* Idle power mode state (WFI) */
+#define NB_CPUN_CONFIG_STATUS_POWER_STATUS_CPU_PM_IDLE \
+ (0x1 << NB_CPUN_CONFIG_STATUS_POWER_STATUS_CPU_PM_SHIFT)
+/* Dormant power mode state */
+#define NB_CPUN_CONFIG_STATUS_POWER_STATUS_CPU_PM_DEEP_IDLE \
+ (0x2 << NB_CPUN_CONFIG_STATUS_POWER_STATUS_CPU_PM_SHIFT)
+/* Powered-off power mode */
+#define NB_CPUN_CONFIG_STATUS_POWER_STATUS_CPU_PM_POWEREDOFF \
+ (0x3 << NB_CPUN_CONFIG_STATUS_POWER_STATUS_CPU_PM_SHIFT)
+/* WFI status */
+#define NB_CPUN_CONFIG_STATUS_POWER_STATUS_WFI (1 << 2)
+/* WFE status */
+#define NB_CPUN_CONFIG_STATUS_POWER_STATUS_WFE (1 << 3)
+
+/**** Warm_Rst_Ctl register ****/
+/* Disable CPU Warm Reset when warmrstreq is asserted
+
+When the Reset Request bit in the RMR or RMR_EL3 register is set to 1 in the CPU Core , the processor asserts the WARMRSTREQ signal and the SoC reset controller use this request to trigger a Warm reset of the processor and change the register width state. */
+#define NB_CPUN_CONFIG_STATUS_WARM_RST_CTL_REQ_DIS (1 << 0)
+/* Disable waiting WFI on Warm Reset */
+#define NB_CPUN_CONFIG_STATUS_WARM_RST_CTL_WFI_DIS (1 << 1)
+/* CPU Core AARach64 reset vector bar
+This is Write Once register (controlled by aarch64_reg_force_* fields) */
+#define NB_CPUN_CONFIG_STATUS_RVBAR_LOW_ADDR_31_2_MASK 0xFFFFFFFC
+#define NB_CPUN_CONFIG_STATUS_RVBAR_LOW_ADDR_31_2_SHIFT 2
+
+/**** Rvbar_High register ****/
+/* CPU Core AARach64 reset vector bar high bits
+This is Write Once register (controlled by aarch64_reg_force_* fields) */
+#define NB_CPUN_CONFIG_STATUS_RVBAR_HIGH_ADDR_43_32_MASK 0x00000FFF
+#define NB_CPUN_CONFIG_STATUS_RVBAR_HIGH_ADDR_43_32_SHIFT 0
+
+/**** pmu_snapshot register ****/
+/* PMU Snapshot Request */
+#define NB_CPUN_CONFIG_STATUS_PMU_SNAPSHOT_REQ (1 << 0)
+/* 0: HW deassert requests when received ack
+1: SW deasserts request when received done */
+#define NB_CPUN_CONFIG_STATUS_PMU_SNAPSHOT_MODE (1 << 1)
+/* Snapshot process completed */
+#define NB_CPUN_CONFIG_STATUS_PMU_SNAPSHOT_DONE (1 << 31)
+
+/**** cpu_msg_in register ****/
+/* CPU read this register to receive input (char) from simulation. */
+#define NB_CPUN_CONFIG_STATUS_CPU_MSG_IN_DATA_MASK 0x000000FF
+#define NB_CPUN_CONFIG_STATUS_CPU_MSG_IN_DATA_SHIFT 0
+/* Indicates the data is valid.
+Cleared on read */
+#define NB_CPUN_CONFIG_STATUS_CPU_MSG_IN_VALID (1 << 8)
+
+/**** PMU_Control register ****/
+/* Disable all counters
+When this bit is clear, counter state is determined through the specific counter control register */
+#define NB_MC_PMU_PMU_CONTROL_DISABLE_ALL (1 << 0)
+/* Pause all counters.
+When this bit is clear, counter state is determined through the specific counter control register. */
+#define NB_MC_PMU_PMU_CONTROL_PAUSE_ALL (1 << 1)
+/* Overflow interrupt enable:
+disable - 0x0: Disable interrupt on overflow.
+enable - 0x1: Enable interrupt on overflow. */
+#define NB_MC_PMU_PMU_CONTROL_OVRF_INTR_EN (1 << 2)
+/* Number of monitored events supported by the PMU. */
+#define NB_MC_PMU_PMU_CONTROL_NUM_OF_EVENTS_MASK 0x00FC0000
+#define NB_MC_PMU_PMU_CONTROL_NUM_OF_EVENTS_SHIFT 18
+#define NB_MC_PMU_PMU_CONTROL_NUM_OF_EVENTS_SHIFT_ALPINE 19
+/* Number of counters implemented by PMU. */
+#define NB_MC_PMU_PMU_CONTROL_NUM_OF_CNTS_MASK 0x0F000000
+#define NB_MC_PMU_PMU_CONTROL_NUM_OF_CNTS_SHIFT 24
+
+/**** Cfg register ****/
+/* Event select */
+#define NB_MC_PMU_COUNTERS_CFG_EVENT_SEL_MASK 0x0000003F
+#define NB_MC_PMU_COUNTERS_CFG_EVENT_SEL_SHIFT 0
+/* Enable setting of counter low overflow status bit:
+disable - 0x0: Disable setting.
+enable - 0x1: Enable setting. */
+#define NB_MC_PMU_COUNTERS_CFG_OVRF_LOW_STT_EN (1 << 6)
+/* Enable setting of counter high overflow status bit:
+disable - 0x0: Disable setting.
+enable - 0x1: Enable setting. */
+#define NB_MC_PMU_COUNTERS_CFG_OVRF_HIGH_STT_EN (1 << 7)
+/* Enable pause on trigger in assertion:
+disable - 0x0: Disable pause.
+enable - 0x1: Enable pause. */
+#define NB_MC_PMU_COUNTERS_CFG_TRIGIN_PAUSE_EN (1 << 8)
+/* Enable increment trigger out for trace.
+Trigger is generated whenever counter reaches <granule> value:
+disable - 0x0: Disable trigger out.
+enable - 0x1: Enable trigger out. */
+#define NB_MC_PMU_COUNTERS_CFG_TRIGOUT_EN (1 << 9)
+/* Trigger out granule value
+Specifies the number of events counted between two consecutive trigger out events
+0x0: 1 - Trigger out on every event occurrence.
+0x1: 2 - Trigger out on every two events.
+...
+0xn: 2^(n-1) - Trigger out on event 2^(n-1) events.
+...
+0x1F: 2^31 */
+#define NB_MC_PMU_COUNTERS_CFG_TRIGOUT_GRANULA_MASK 0x00007C00
+#define NB_MC_PMU_COUNTERS_CFG_TRIGOUT_GRANULA_SHIFT 10
+/* Pause on overflow bitmask
+If set for counter <i>, current counter pauses counting when counter<i> is overflowed, including self-pause.
+Bit [16]: counter 0
+Bit [17]: counter 1
+Note: This field must be changed for larger counters. */
+#define NB_MC_PMU_COUNTERS_CFG_PAUSE_ON_OVRF_BITMASK_MASK 0x000F0000
+#define NB_MC_PMU_COUNTERS_CFG_PAUSE_ON_OVRF_BITMASK_SHIFT 16
+
+/**** Cntl register ****/
+/* Set the counter state to disable, enable, or pause:
+0x0 - disable: Disable counter.
+0x1 - enable: Enable counter.
+0x3 - pause: Pause counter. */
+#define NB_MC_PMU_COUNTERS_CNTL_CNT_STATE_MASK 0x00000003
+#define NB_MC_PMU_COUNTERS_CNTL_CNT_STATE_SHIFT 0
+/* Disable counter. */
+#define NB_MC_PMU_COUNTERS_CNTL_CNT_STATE_DISABLE \
+ (0x0 << NB_MC_PMU_COUNTERS_CNTL_CNT_STATE_SHIFT)
+/* Enable counter. */
+#define NB_MC_PMU_COUNTERS_CNTL_CNT_STATE_ENABLE \
+ (0x1 << NB_MC_PMU_COUNTERS_CNTL_CNT_STATE_SHIFT)
+/* Pause counter. */
+#define NB_MC_PMU_COUNTERS_CNTL_CNT_STATE_PAUSE \
+ (0x3 << NB_MC_PMU_COUNTERS_CNTL_CNT_STATE_SHIFT)
+
+/**** High register ****/
+/* Counter high value */
+#define NB_MC_PMU_COUNTERS_HIGH_COUNTER_MASK 0x0000FFFF
+#define NB_MC_PMU_COUNTERS_HIGH_COUNTER_SHIFT 0
+
+/**** version register ****/
+/* Revision number (Minor) */
+#define NB_NB_VERSION_VERSION_RELEASE_NUM_MINOR_MASK 0x000000FF
+#define NB_NB_VERSION_VERSION_RELEASE_NUM_MINOR_SHIFT 0
+/* Revision number (Major) */
+#define NB_NB_VERSION_VERSION_RELEASE_NUM_MAJOR_MASK 0x0000FF00
+#define NB_NB_VERSION_VERSION_RELEASE_NUM_MAJOR_SHIFT 8
+/* Date of release */
+#define NB_NB_VERSION_VERSION_DATE_DAY_MASK 0x001F0000
+#define NB_NB_VERSION_VERSION_DATE_DAY_SHIFT 16
+/* Month of release */
+#define NB_NB_VERSION_VERSION_DATA_MONTH_MASK 0x01E00000
+#define NB_NB_VERSION_VERSION_DATA_MONTH_SHIFT 21
+/* Year of release (starting from 2000) */
+#define NB_NB_VERSION_VERSION_DATE_YEAR_MASK 0x3E000000
+#define NB_NB_VERSION_VERSION_DATE_YEAR_SHIFT 25
+/* Reserved */
+#define NB_NB_VERSION_VERSION_RESERVED_MASK 0xC0000000
+#define NB_NB_VERSION_VERSION_RESERVED_SHIFT 30
+
+/**** cpu_vmid register ****/
+/* Target VMID */
+#define NB_SRIOV_CPU_VMID_VAL_MASK 0x000000FF
+#define NB_SRIOV_CPU_VMID_VAL_SHIFT 0
+
+/**** DRAM_0_Control register ****/
+/* Controller Idle
+Indicates to the DDR PHY, if set, that the memory controller is idle */
+#define NB_DRAM_CHANNELS_DRAM_0_CONTROL_DDR_PHY_CTL_IDLE (1 << 0)
+/* Disable clear exclusive monitor request from DDR controller to CPU
+Clear request is triggered whenever an exlusive monitor inside the DDR controller is being invalidated. */
+#define NB_DRAM_CHANNELS_DRAM_0_CONTROL_DDR_EXMON_REQ_DIS (1 << 1)
+
+/**** DRAM_0_Status register ****/
+/* Bypass Mode: Indicates if set that the PHY is in PLL bypass mod */
+#define NB_DRAM_CHANNELS_DRAM_0_STATUS_DDR_PHY_BYP_MODE (1 << 0)
+/* Number of available AXI transactions (used positions) in the DDR controller read address FIFO. */
+#define NB_DRAM_CHANNELS_DRAM_0_STATUS_RAQ_WCOUNT_MASK 0x00000030
+#define NB_DRAM_CHANNELS_DRAM_0_STATUS_RAQ_WCOUNT_SHIFT 4
+/* Number of available AXI transactions (used positions) in the DDR controller write address FIFO */
+#define NB_DRAM_CHANNELS_DRAM_0_STATUS_WAQ_WCOUNT_0_MASK 0x000000C0
+#define NB_DRAM_CHANNELS_DRAM_0_STATUS_WAQ_WCOUNT_0_SHIFT 6
+/* Number of available Low priority read CAM slots (free positions) in the DDR controller.
+Each slots holds a DRAM burst */
+#define NB_DRAM_CHANNELS_DRAM_0_STATUS_LPR_CREDIT_CNT_MASK 0x00007F00
+#define NB_DRAM_CHANNELS_DRAM_0_STATUS_LPR_CREDIT_CNT_SHIFT 8
+/* Number of available High priority read CAM slots (free positions) in the DDR controller.
+Each slots holds a DRAM burst */
+#define NB_DRAM_CHANNELS_DRAM_0_STATUS_HPR_CREDIT_CNT_MASK 0x003F8000
+#define NB_DRAM_CHANNELS_DRAM_0_STATUS_HPR_CREDIT_CNT_SHIFT 15
+/* Number of available write CAM slots (free positions) in the DDR controller.
+Each slots holds a DRAM burst */
+#define NB_DRAM_CHANNELS_DRAM_0_STATUS_WR_CREDIT_CNT_MASK 0x1FC00000
+#define NB_DRAM_CHANNELS_DRAM_0_STATUS_WR_CREDIT_CNT_SHIFT 22
+
+/**** DDR_Int_Cause register ****/
+/* This interrupt is asserted when a correctable ECC error is detected */
+#define NB_DRAM_CHANNELS_DDR_INT_CAUSE_ECC_CORRECTED_ERR (1 << 0)
+/* This interrupt is asserted when a uncorrectable ECC error is detected */
+#define NB_DRAM_CHANNELS_DDR_INT_CAUSE_ECC_UNCORRECTED_ERR (1 << 1)
+/* This interrupt is asserted when a parity or CRC error is detected on the DFI interface */
+#define NB_DRAM_CHANNELS_DDR_INT_CAUSE_DFI_ALERT_ERR (1 << 2)
+/* On-Chip Write data parity error interrupt on output */
+#define NB_DRAM_CHANNELS_DDR_INT_CAUSE_PAR_WDATA_OUT_ERR (1 << 3)
+/* This interrupt is asserted when a parity error due to MRS is detected on the DFI interface */
+#define NB_DRAM_CHANNELS_DDR_INT_CAUSE_DFI_ALERT_ERR_FATL (1 << 4)
+/* This interrupt is asserted when the CRC/parity retry counter reaches it maximum value */
+#define NB_DRAM_CHANNELS_DDR_INT_CAUSE_DFI_ALERT_ERR_MAX_REACHED (1 << 5)
+/* AXI Read address parity error interrupt.
+This interrupt is asserted when an on-chip parity error occurred on the DDR controller AXI read address. */
+#define NB_DRAM_CHANNELS_DDR_INT_CAUSE_PAR_RADDR_ERR (1 << 6)
+/* AXI Read data parity error interrupt.
+This interrupt is asserted when an on-chip parity error occurred on the DDR controller AXI read data */
+#define NB_DRAM_CHANNELS_DDR_INT_CAUSE_PAR_RDATA_ERR (1 << 7)
+/* AXI Write address parity error interrupt.
+This interrupt is asserted when an on-chip parity error occurred on the DDR controller AXI write address. */
+#define NB_DRAM_CHANNELS_DDR_INT_CAUSE_PAR_WADDR_ERR (1 << 8)
+/* AXI Write data parity error interrupt on input.
+This interrupt is asserted when an on-chip parity error occurred on the DDR controller AXI write data */
+#define NB_DRAM_CHANNELS_DDR_INT_CAUSE_PAR_WDATA_IN_ERR (1 << 9)
+
+/**** Address_Map register ****/
+/* Controls which system address bit will be mapped to DDR row bit 2.
+This field is only used when addrmap_part_en == 1 */
+#define NB_DRAM_CHANNELS_ADDRESS_MAP_ADDRMAP_ROW_B2_MASK 0x0000000F
+#define NB_DRAM_CHANNELS_ADDRESS_MAP_ADDRMAP_ROW_B2_SHIFT 0
+/* Controls which system address bit will be mapped to DDR row bit 3.
+This field is only used when addrmap_part_en == 1 */
+#define NB_DRAM_CHANNELS_ADDRESS_MAP_ADDRMAP_ROW_B3_MASK 0x000003C0
+#define NB_DRAM_CHANNELS_ADDRESS_MAP_ADDRMAP_ROW_B3_SHIFT 6
+/* Controls which system address bit will be mapped to DDR row bit 4.
+This field is only used when addrmap_part_en == 1 */
+#define NB_DRAM_CHANNELS_ADDRESS_MAP_ADDRMAP_ROW_B4_MASK 0x0000F000
+#define NB_DRAM_CHANNELS_ADDRESS_MAP_ADDRMAP_ROW_B4_SHIFT 12
+/* Controls which system address bit will be mapped to DDR row bit 5.
+This field is only used when addrmap_part_en == 1 */
+#define NB_DRAM_CHANNELS_ADDRESS_MAP_ADDRMAP_ROW_B5_MASK 0x003C0000
+#define NB_DRAM_CHANNELS_ADDRESS_MAP_ADDRMAP_ROW_B5_SHIFT 18
+/* Enables partitioning of the address mapping control.
+When set, addrmap_row_b2-5 are used inside DDR controler instead of the built in address mapping registers */
+#define NB_DRAM_CHANNELS_ADDRESS_MAP_ADDRMAP_PART_EN (1 << 31)
+
+/**** Reorder_ID_Mask register ****/
+/* DDR Read Reorder buffer ID mask.
+If incoming read transaction ID ANDed with mask is equal Reorder_ID_Value, then the transaction is mapped to the DDR controller bypass channel.
+Setting this register to 0 will disable the check */
+#define NB_DRAM_CHANNELS_REORDER_ID_MASK_MASK_MASK 0x003FFFFF
+#define NB_DRAM_CHANNELS_REORDER_ID_MASK_MASK_SHIFT 0
+
+/**** Reorder_ID_Value register ****/
+/* DDR Read Reorder buffer ID value
+If incoming read transaction ID ANDed with Reorder_ID_Mask is equal to this register, then the transaction is mapped to the DDR controller bypass channel */
+#define NB_DRAM_CHANNELS_REORDER_ID_VALUE_VALUE_MASK 0x003FFFFF
+#define NB_DRAM_CHANNELS_REORDER_ID_VALUE_VALUE_SHIFT 0
+
+/**** MRR_Control_Status register ****/
+/* DDR4 Mode Register Read Data Valid */
+#define NB_DRAM_CHANNELS_MRR_CONTROL_STATUS_MRR_VLD (1 << 0)
+/* MRR Ack, when asserted it clears the mrr_val indication and ready to load new MRR data. Write 1 to clear and then 0 */
+#define NB_DRAM_CHANNELS_MRR_CONTROL_STATUS_MRR_ACK (1 << 16)
+
+/**** pp_config register ****/
+/* Bypass PP module (formality equivalent) */
+#define NB_PUSH_PACKET_PP_CONFIG_FM_BYPASS (1 << 0)
+/* Bypass PP module */
+#define NB_PUSH_PACKET_PP_CONFIG_BYPASS (1 << 1)
+/* Force Cleanup of entries */
+#define NB_PUSH_PACKET_PP_CONFIG_CLEAR (1 << 2)
+/* Enable forwarding DECERR response */
+#define NB_PUSH_PACKET_PP_CONFIG_DECERR_EN (1 << 3)
+/* Enable forwarding SLVERR response */
+#define NB_PUSH_PACKET_PP_CONFIG_SLVERR_EN (1 << 4)
+/* Enable forwarding of data parity generation */
+#define NB_PUSH_PACKET_PP_CONFIG_PAR_GEN_EN (1 << 5)
+/* Select channel on 8K boundaries ([15:13]) instead of 64k boundaries ([18:16]). */
+#define NB_PUSH_PACKET_PP_CONFIG_SEL_8K (1 << 6)
+/* Forces awuser to be as configured in ext_awuser register.
+Not functional */
+#define NB_PUSH_PACKET_PP_CONFIG_SEL_EXT_AWUSER (1 << 7)
+/* Enables PP channel.
+1 bit per channel */
+#define NB_PUSH_PACKET_PP_CONFIG_CHANNEL_ENABLE_MASK 0x00030000
+#define NB_PUSH_PACKET_PP_CONFIG_CHANNEL_ENABLE_SHIFT 16
+
+#define NB_PUSH_PACKET_PP_CONFIG_CHANNEL_ENABLE(i) \
+ (1 << (NB_PUSH_PACKET_PP_CONFIG_CHANNEL_ENABLE_SHIFT + i))
+
+/**** pp_ext_awuser register ****/
+/* Awuser to use on PP transactions
+Only applicable if config.sel_ext_awuser is set to 1'b1
+Parity bits are still generated per transaction */
+#define NB_PUSH_PACKET_PP_EXT_AWUSER_AWUSER_MASK 0x03FFFFFF
+#define NB_PUSH_PACKET_PP_EXT_AWUSER_AWUSER_SHIFT 0
+
+/**** pp_sel_awuser register ****/
+/* Select whether to use addr[63:48] or PP awmisc as vmid.
+Each bit if set to 1 selects the corresponding address bit. Otherwise, selects the corersponding awmis bit. */
+#define NB_PUSH_PACKET_PP_SEL_AWUSER_SEL_MASK 0x0000FFFF
+#define NB_PUSH_PACKET_PP_SEL_AWUSER_SEL_SHIFT 0
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __AL_HAL_NB_REGS_H__ */
+
+/** @} end of ... group */
+
+
diff --git a/sys/arm/annapurna/alpine/hal/al_hal_pbs_regs.h b/sys/arm/annapurna/alpine/hal/al_hal_pbs_regs.h
new file mode 100644
index 0000000..b1f9c4f
--- /dev/null
+++ b/sys/arm/annapurna/alpine/hal/al_hal_pbs_regs.h
@@ -0,0 +1,2751 @@
+/*-
+********************************************************************************
+Copyright (C) 2015 Annapurna Labs Ltd.
+
+This file may be licensed under the terms of the Annapurna Labs Commercial
+License Agreement.
+
+Alternatively, this file can be distributed under the terms of the GNU General
+Public License V2 as published by the Free Software Foundation and can be
+found at http://www.gnu.org/licenses/gpl-2.0.html
+
+Alternatively, redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+notice, this 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 HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*******************************************************************************/
+
+/**
+ * @{
+ * @file al_hal_pbs_regs.h
+ *
+ * @brief ... registers
+ *
+ */
+
+#ifndef __AL_HAL_PBS_REGS_H__
+#define __AL_HAL_PBS_REGS_H__
+
+#include "al_hal_plat_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+* Unit Registers
+*/
+
+
+
+struct al_pbs_unit {
+ /* [0x0] Conf_bus, Configuration of the SB */
+ uint32_t conf_bus;
+ /* [0x4] PASW high */
+ uint32_t dram_0_nb_bar_high;
+ /* [0x8] PASW low */
+ uint32_t dram_0_nb_bar_low;
+ /* [0xc] PASW high */
+ uint32_t dram_1_nb_bar_high;
+ /* [0x10] PASW low */
+ uint32_t dram_1_nb_bar_low;
+ /* [0x14] PASW high */
+ uint32_t dram_2_nb_bar_high;
+ /* [0x18] PASW low */
+ uint32_t dram_2_nb_bar_low;
+ /* [0x1c] PASW high */
+ uint32_t dram_3_nb_bar_high;
+ /* [0x20] PASW low */
+ uint32_t dram_3_nb_bar_low;
+ /* [0x24] PASW high */
+ uint32_t msix_nb_bar_high;
+ /* [0x28] PASW low */
+ uint32_t msix_nb_bar_low;
+ /* [0x2c] PASW high */
+ uint32_t dram_0_sb_bar_high;
+ /* [0x30] PASW low */
+ uint32_t dram_0_sb_bar_low;
+ /* [0x34] PASW high */
+ uint32_t dram_1_sb_bar_high;
+ /* [0x38] PASW low */
+ uint32_t dram_1_sb_bar_low;
+ /* [0x3c] PASW high */
+ uint32_t dram_2_sb_bar_high;
+ /* [0x40] PASW low */
+ uint32_t dram_2_sb_bar_low;
+ /* [0x44] PASW high */
+ uint32_t dram_3_sb_bar_high;
+ /* [0x48] PASW low */
+ uint32_t dram_3_sb_bar_low;
+ /* [0x4c] PASW high */
+ uint32_t msix_sb_bar_high;
+ /* [0x50] PASW low */
+ uint32_t msix_sb_bar_low;
+ /* [0x54] PASW high */
+ uint32_t pcie_mem0_bar_high;
+ /* [0x58] PASW low */
+ uint32_t pcie_mem0_bar_low;
+ /* [0x5c] PASW high */
+ uint32_t pcie_mem1_bar_high;
+ /* [0x60] PASW low */
+ uint32_t pcie_mem1_bar_low;
+ /* [0x64] PASW high */
+ uint32_t pcie_mem2_bar_high;
+ /* [0x68] PASW low */
+ uint32_t pcie_mem2_bar_low;
+ /* [0x6c] PASW high */
+ uint32_t pcie_ext_ecam0_bar_high;
+ /* [0x70] PASW low */
+ uint32_t pcie_ext_ecam0_bar_low;
+ /* [0x74] PASW high */
+ uint32_t pcie_ext_ecam1_bar_high;
+ /* [0x78] PASW low */
+ uint32_t pcie_ext_ecam1_bar_low;
+ /* [0x7c] PASW high */
+ uint32_t pcie_ext_ecam2_bar_high;
+ /* [0x80] PASW low */
+ uint32_t pcie_ext_ecam2_bar_low;
+ /* [0x84] PASW high */
+ uint32_t pbs_nor_bar_high;
+ /* [0x88] PASW low */
+ uint32_t pbs_nor_bar_low;
+ /* [0x8c] PASW high */
+ uint32_t pbs_spi_bar_high;
+ /* [0x90] PASW low */
+ uint32_t pbs_spi_bar_low;
+ uint32_t rsrvd_0[3];
+ /* [0xa0] PASW high */
+ uint32_t pbs_nand_bar_high;
+ /* [0xa4] PASW low */
+ uint32_t pbs_nand_bar_low;
+ /* [0xa8] PASW high */
+ uint32_t pbs_int_mem_bar_high;
+ /* [0xac] PASW low */
+ uint32_t pbs_int_mem_bar_low;
+ /* [0xb0] PASW high */
+ uint32_t pbs_boot_bar_high;
+ /* [0xb4] PASW low */
+ uint32_t pbs_boot_bar_low;
+ /* [0xb8] PASW high */
+ uint32_t nb_int_bar_high;
+ /* [0xbc] PASW low */
+ uint32_t nb_int_bar_low;
+ /* [0xc0] PASW high */
+ uint32_t nb_stm_bar_high;
+ /* [0xc4] PASW low */
+ uint32_t nb_stm_bar_low;
+ /* [0xc8] PASW high */
+ uint32_t pcie_ecam_int_bar_high;
+ /* [0xcc] PASW low */
+ uint32_t pcie_ecam_int_bar_low;
+ /* [0xd0] PASW high */
+ uint32_t pcie_mem_int_bar_high;
+ /* [0xd4] PASW low */
+ uint32_t pcie_mem_int_bar_low;
+ /* [0xd8] Control */
+ uint32_t winit_cntl;
+ /* [0xdc] Control */
+ uint32_t latch_bars;
+ /* [0xe0] Control */
+ uint32_t pcie_conf_0;
+ /* [0xe4] Control */
+ uint32_t pcie_conf_1;
+ /* [0xe8] Control */
+ uint32_t serdes_mux_pipe;
+ /* [0xec] Control */
+ uint32_t dma_io_master_map;
+ /* [0xf0] Status */
+ uint32_t i2c_pld_status_high;
+ /* [0xf4] Status */
+ uint32_t i2c_pld_status_low;
+ /* [0xf8] Status */
+ uint32_t spi_dbg_status_high;
+ /* [0xfc] Status */
+ uint32_t spi_dbg_status_low;
+ /* [0x100] Status */
+ uint32_t spi_mst_status_high;
+ /* [0x104] Status */
+ uint32_t spi_mst_status_low;
+ /* [0x108] Log */
+ uint32_t mem_pbs_parity_err_high;
+ /* [0x10c] Log */
+ uint32_t mem_pbs_parity_err_low;
+ /* [0x110] Log */
+ uint32_t boot_strap;
+ /* [0x114] Conf */
+ uint32_t cfg_axi_conf_0;
+ /* [0x118] Conf */
+ uint32_t cfg_axi_conf_1;
+ /* [0x11c] Conf */
+ uint32_t cfg_axi_conf_2;
+ /* [0x120] Conf */
+ uint32_t cfg_axi_conf_3;
+ /* [0x124] Conf */
+ uint32_t spi_mst_conf_0;
+ /* [0x128] Conf */
+ uint32_t spi_mst_conf_1;
+ /* [0x12c] Conf */
+ uint32_t spi_slv_conf_0;
+ /* [0x130] Conf */
+ uint32_t apb_mem_conf_int;
+ /* [0x134] PASW remap register */
+ uint32_t sb2nb_cfg_dram_remap;
+ /* [0x138] Control */
+ uint32_t pbs_mux_sel_0;
+ /* [0x13c] Control */
+ uint32_t pbs_mux_sel_1;
+ /* [0x140] Control */
+ uint32_t pbs_mux_sel_2;
+ /* [0x144] Control */
+ uint32_t pbs_mux_sel_3;
+ /* [0x148] PASW high */
+ uint32_t sb_int_bar_high;
+ /* [0x14c] PASW low */
+ uint32_t sb_int_bar_low;
+ /* [0x150] log */
+ uint32_t ufc_pbs_parity_err_high;
+ /* [0x154] log */
+ uint32_t ufc_pbs_parity_err_low;
+ /* [0x158] Cntl - internal */
+ uint32_t gen_conf;
+ /* [0x15c] Device ID and Rev ID */
+ uint32_t chip_id;
+ /* [0x160] Status - internal */
+ uint32_t uart0_debug;
+ /* [0x164] Status - internal */
+ uint32_t uart1_debug;
+ /* [0x168] Status - internal */
+ uint32_t uart2_debug;
+ /* [0x16c] Status - internal */
+ uint32_t uart3_debug;
+ /* [0x170] Control - internal */
+ uint32_t uart0_conf_status;
+ /* [0x174] Control - internal */
+ uint32_t uart1_conf_status;
+ /* [0x178] Control - internal */
+ uint32_t uart2_conf_status;
+ /* [0x17c] Control - internal */
+ uint32_t uart3_conf_status;
+ /* [0x180] Control - internal */
+ uint32_t gpio0_conf_status;
+ /* [0x184] Control - internal */
+ uint32_t gpio1_conf_status;
+ /* [0x188] Control - internal */
+ uint32_t gpio2_conf_status;
+ /* [0x18c] Control - internal */
+ uint32_t gpio3_conf_status;
+ /* [0x190] Control - internal */
+ uint32_t gpio4_conf_status;
+ /* [0x194] Control - internal */
+ uint32_t i2c_gen_conf_status;
+ /* [0x198] Control - internal */
+ uint32_t i2c_gen_debug;
+ /* [0x19c] Cntl */
+ uint32_t watch_dog_reset_out;
+ /* [0x1a0] Cntl */
+ uint32_t otp_magic_num;
+ /*
+ * [0x1a4] Control - internal
+ */
+ uint32_t otp_cntl;
+ /* [0x1a8] Cfg - internal */
+ uint32_t otp_cfg_0;
+ /* [0x1ac] Cfg - internal */
+ uint32_t otp_cfg_1;
+ /* [0x1b0] Cfg - internal */
+ uint32_t otp_cfg_3;
+ /* [0x1b4] Cfg */
+ uint32_t cfg_nand_0;
+ /* [0x1b8] Cfg */
+ uint32_t cfg_nand_1;
+ /* [0x1bc] Cfg-- timing parameters internal. */
+ uint32_t cfg_nand_2;
+ /* [0x1c0] Cfg - internal */
+ uint32_t cfg_nand_3;
+ /* [0x1c4] PASW high */
+ uint32_t nb_nic_regs_bar_high;
+ /* [0x1c8] PASW low */
+ uint32_t nb_nic_regs_bar_low;
+ /* [0x1cc] PASW high */
+ uint32_t sb_nic_regs_bar_high;
+ /* [0x1d0] PASW low */
+ uint32_t sb_nic_regs_bar_low;
+ /* [0x1d4] Control */
+ uint32_t serdes_mux_multi_0;
+ /* [0x1d8] Control */
+ uint32_t serdes_mux_multi_1;
+ /* [0x1dc] Control - not in use any more - internal */
+ uint32_t pbs_ulpi_mux_conf;
+ /* [0x1e0] Cntl */
+ uint32_t wr_once_dbg_dis_ovrd_reg;
+ /* [0x1e4] Cntl - internal */
+ uint32_t gpio5_conf_status;
+ /* [0x1e8] PASW high */
+ uint32_t pcie_mem3_bar_high;
+ /* [0x1ec] PASW low */
+ uint32_t pcie_mem3_bar_low;
+ /* [0x1f0] PASW high */
+ uint32_t pcie_mem4_bar_high;
+ /* [0x1f4] PASW low */
+ uint32_t pcie_mem4_bar_low;
+ /* [0x1f8] PASW high */
+ uint32_t pcie_mem5_bar_high;
+ /* [0x1fc] PASW low */
+ uint32_t pcie_mem5_bar_low;
+ /* [0x200] PASW high */
+ uint32_t pcie_ext_ecam3_bar_high;
+ /* [0x204] PASW low */
+ uint32_t pcie_ext_ecam3_bar_low;
+ /* [0x208] PASW high */
+ uint32_t pcie_ext_ecam4_bar_high;
+ /* [0x20c] PASW low */
+ uint32_t pcie_ext_ecam4_bar_low;
+ /* [0x210] PASW high */
+ uint32_t pcie_ext_ecam5_bar_high;
+ /* [0x214] PASW low */
+ uint32_t pcie_ext_ecam5_bar_low;
+ /* [0x218] PASW high */
+ uint32_t low_latency_sram_bar_high;
+ /* [0x21c] PASW low */
+ uint32_t low_latency_sram_bar_low;
+ /* [0x220] Control */
+ uint32_t pbs_mux_sel_4;
+ /* [0x224] Control */
+ uint32_t pbs_mux_sel_5;
+ /* [0x228] Control */
+ uint32_t serdes_mux_eth;
+ /* [0x22c] Control */
+ uint32_t serdes_mux_pcie;
+ /* [0x230] Control */
+ uint32_t serdes_mux_sata;
+ uint32_t rsrvd[7];
+};
+struct al_pbs_low_latency_sram_remap {
+ /* [0x0] PBS MEM Remap */
+ uint32_t bar1_orig;
+ /* [0x4] PBS MEM Remap */
+ uint32_t bar1_remap;
+ /* [0x8] ETH0 MEM Remap */
+ uint32_t bar2_orig;
+ /* [0xc] ETH0 MEM Remap */
+ uint32_t bar2_remap;
+ /* [0x10] ETH1 MEM Remap */
+ uint32_t bar3_orig;
+ /* [0x14] ETH1 MEM Remap */
+ uint32_t bar3_remap;
+ /* [0x18] ETH2 MEM Remap */
+ uint32_t bar4_orig;
+ /* [0x1c] ETH2 MEM Remap */
+ uint32_t bar4_remap;
+ /* [0x20] ETH3 MEM Remap */
+ uint32_t bar5_orig;
+ /* [0x24] ETH3 MEM Remap */
+ uint32_t bar5_remap;
+ /* [0x28] CRYPTO0 MEM Remap */
+ uint32_t bar6_orig;
+ /* [0x2c] CRYPTO0 MEM Remap */
+ uint32_t bar6_remap;
+ /* [0x30] RAID0 MEM Remap */
+ uint32_t bar7_orig;
+ /* [0x34] RAID0 MEM Remap */
+ uint32_t bar7_remap;
+ /* [0x38] CRYPTO1 MEM Remap */
+ uint32_t bar8_orig;
+ /* [0x3c] CRYPTO1 MEM Remap */
+ uint32_t bar8_remap;
+ /* [0x40] RAID1 MEM Remap */
+ uint32_t bar9_orig;
+ /* [0x44] RAID2 MEM Remap */
+ uint32_t bar9_remap;
+ /* [0x48] RESERVED MEM Remap */
+ uint32_t bar10_orig;
+ /* [0x4c] RESERVED MEM Remap */
+ uint32_t bar10_remap;
+};
+struct al_pbs_target_id_enforcement {
+ /* [0x0] target enforcement */
+ uint32_t cpu;
+ /* [0x4] target enforcement mask (bits which are 0 are not compared) */
+ uint32_t cpu_mask;
+ /* [0x8] target enforcement */
+ uint32_t debug_nb;
+ /* [0xc] target enforcement mask (bits which are 0 are not compared) */
+ uint32_t debug_nb_mask;
+ /* [0x10] target enforcement */
+ uint32_t debug_sb;
+ /* [0x14] target enforcement mask (bits which are 0 are not compared) */
+ uint32_t debug_sb_mask;
+ /* [0x18] target enforcement */
+ uint32_t eth_0;
+ /* [0x1c] target enforcement mask (bits which are 0 are not compared) */
+ uint32_t eth_0_mask;
+ /* [0x20] target enforcement */
+ uint32_t eth_1;
+ /* [0x24] target enforcement mask (bits which are 0 are not compared) */
+ uint32_t eth_1_mask;
+ /* [0x28] target enforcement */
+ uint32_t eth_2;
+ /* [0x2c] target enforcement mask (bits which are 0 are not compared) */
+ uint32_t eth_2_mask;
+ /* [0x30] target enforcement */
+ uint32_t eth_3;
+ /* [0x34] target enforcement mask (bits which are 0 are not compared) */
+ uint32_t eth_3_mask;
+ /* [0x38] target enforcement */
+ uint32_t sata_0;
+ /* [0x3c] target enforcement mask (bits which are 0 are not compared) */
+ uint32_t sata_0_mask;
+ /* [0x40] target enforcement */
+ uint32_t sata_1;
+ /* [0x44] target enforcement mask (bits which are 0 are not compared) */
+ uint32_t sata_1_mask;
+ /* [0x48] target enforcement */
+ uint32_t crypto_0;
+ /* [0x4c] target enforcement mask (bits which are 0 are not compared) */
+ uint32_t crypto_0_mask;
+ /* [0x50] target enforcement */
+ uint32_t crypto_1;
+ /* [0x54] target enforcement mask (bits which are 0 are not compared) */
+ uint32_t crypto_1_mask;
+ /* [0x58] target enforcement */
+ uint32_t pcie_0;
+ /* [0x5c] target enforcement mask (bits which are 0 are not compared) */
+ uint32_t pcie_0_mask;
+ /* [0x60] target enforcement */
+ uint32_t pcie_1;
+ /* [0x64] target enforcement mask (bits which are 0 are not compared) */
+ uint32_t pcie_1_mask;
+ /* [0x68] target enforcement */
+ uint32_t pcie_2;
+ /* [0x6c] target enforcement mask (bits which are 0 are not compared) */
+ uint32_t pcie_2_mask;
+ /* [0x70] target enforcement */
+ uint32_t pcie_3;
+ /* [0x74] target enforcement mask (bits which are 0 are not compared) */
+ uint32_t pcie_3_mask;
+ /* [0x78] Control */
+ uint32_t latch;
+ uint32_t rsrvd[9];
+};
+
+struct al_pbs_regs {
+ struct al_pbs_unit unit; /* [0x0] */
+struct al_pbs_low_latency_sram_remap low_latency_sram_remap;
+/* [0x250] */
+ uint32_t rsrvd_0[88];
+ struct al_pbs_target_id_enforcement target_id_enforcement; /* [0x400] */
+};
+
+
+/*
+* Registers Fields
+*/
+
+
+/**** conf_bus register ****/
+/* Read slave error enable */
+#define PBS_UNIT_CONF_BUS_RD_SLVERR_EN (1 << 0)
+/* Write slave error enable */
+#define PBS_UNIT_CONF_BUS_WR_SLVERR_EN (1 << 1)
+/* Read decode error enable */
+#define PBS_UNIT_CONF_BUS_RD_DECERR_EN (1 << 2)
+/* Write decode error enable */
+#define PBS_UNIT_CONF_BUS_WR_DECERR_EN (1 << 3)
+/* For debug clear the APB SM */
+#define PBS_UNIT_CONF_BUS_CLR_APB_FSM (1 << 4)
+/* For debug clear the WFIFO */
+#define PBS_UNIT_CONF_BUS_CLR_WFIFO_CLEAR (1 << 5)
+/* Arbiter between read and write channel */
+#define PBS_UNIT_CONF_BUS_WRR_CNT_MASK 0x000001C0
+#define PBS_UNIT_CONF_BUS_WRR_CNT_SHIFT 6
+
+
+/* general PASWS */
+/* window size = 2 ^ (15 + win_size), zero value disable the win ... */
+#define PBS_PASW_WIN_SIZE_MASK 0x0000003F
+#define PBS_PASW_WIN_SIZE_SHIFT 0
+/* reserved fields */
+#define PBS_PASW_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_PASW_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_PASW_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_PASW_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** dram_0_nb_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_DRAM_0_NB_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_DRAM_0_NB_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_DRAM_0_NB_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_DRAM_0_NB_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_DRAM_0_NB_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_DRAM_0_NB_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** dram_1_nb_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_DRAM_1_NB_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_DRAM_1_NB_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_DRAM_1_NB_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_DRAM_1_NB_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_DRAM_1_NB_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_DRAM_1_NB_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** dram_2_nb_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_DRAM_2_NB_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_DRAM_2_NB_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_DRAM_2_NB_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_DRAM_2_NB_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_DRAM_2_NB_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_DRAM_2_NB_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** dram_3_nb_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_DRAM_3_NB_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_DRAM_3_NB_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_DRAM_3_NB_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_DRAM_3_NB_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_DRAM_3_NB_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_DRAM_3_NB_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** msix_nb_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_MSIX_NB_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_MSIX_NB_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_MSIX_NB_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_MSIX_NB_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_MSIX_NB_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_MSIX_NB_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** dram_0_sb_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_DRAM_0_SB_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_DRAM_0_SB_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_DRAM_0_SB_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_DRAM_0_SB_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_DRAM_0_SB_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_DRAM_0_SB_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** dram_1_sb_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_DRAM_1_SB_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_DRAM_1_SB_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_DRAM_1_SB_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_DRAM_1_SB_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_DRAM_1_SB_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_DRAM_1_SB_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** dram_2_sb_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_DRAM_2_SB_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_DRAM_2_SB_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_DRAM_2_SB_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_DRAM_2_SB_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_DRAM_2_SB_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_DRAM_2_SB_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** dram_3_sb_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_DRAM_3_SB_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_DRAM_3_SB_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_DRAM_3_SB_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_DRAM_3_SB_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_DRAM_3_SB_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_DRAM_3_SB_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** msix_sb_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_MSIX_SB_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_MSIX_SB_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_MSIX_SB_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_MSIX_SB_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_MSIX_SB_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_MSIX_SB_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pcie_mem0_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PCIE_MEM0_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PCIE_MEM0_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PCIE_MEM0_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PCIE_MEM0_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_PCIE_MEM0_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PCIE_MEM0_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pcie_mem1_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PCIE_MEM1_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PCIE_MEM1_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PCIE_MEM1_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PCIE_MEM1_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_PCIE_MEM1_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PCIE_MEM1_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pcie_mem2_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PCIE_MEM2_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PCIE_MEM2_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PCIE_MEM2_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PCIE_MEM2_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_PCIE_MEM2_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PCIE_MEM2_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pcie_ext_ecam0_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PCIE_EXT_ECAM0_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PCIE_EXT_ECAM0_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PCIE_EXT_ECAM0_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PCIE_EXT_ECAM0_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_PCIE_EXT_ECAM0_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PCIE_EXT_ECAM0_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pcie_ext_ecam1_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PCIE_EXT_ECAM1_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PCIE_EXT_ECAM1_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PCIE_EXT_ECAM1_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PCIE_EXT_ECAM1_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_PCIE_EXT_ECAM1_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PCIE_EXT_ECAM1_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pcie_ext_ecam2_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PCIE_EXT_ECAM2_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PCIE_EXT_ECAM2_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PCIE_EXT_ECAM2_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PCIE_EXT_ECAM2_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_PCIE_EXT_ECAM2_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PCIE_EXT_ECAM2_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pbs_nor_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PBS_NOR_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PBS_NOR_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PBS_NOR_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PBS_NOR_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_PBS_NOR_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PBS_NOR_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pbs_spi_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PBS_SPI_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PBS_SPI_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PBS_SPI_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PBS_SPI_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_PBS_SPI_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PBS_SPI_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pbs_nand_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PBS_NAND_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PBS_NAND_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PBS_NAND_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PBS_NAND_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_PBS_NAND_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PBS_NAND_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pbs_int_mem_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PBS_INT_MEM_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PBS_INT_MEM_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PBS_INT_MEM_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PBS_INT_MEM_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_PBS_INT_MEM_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PBS_INT_MEM_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pbs_boot_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PBS_BOOT_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PBS_BOOT_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PBS_BOOT_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PBS_BOOT_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_PBS_BOOT_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PBS_BOOT_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** nb_int_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_NB_INT_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_NB_INT_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_NB_INT_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_NB_INT_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_NB_INT_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_NB_INT_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** nb_stm_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_NB_STM_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_NB_STM_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_NB_STM_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_NB_STM_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_NB_STM_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_NB_STM_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pcie_ecam_int_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PCIE_ECAM_INT_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PCIE_ECAM_INT_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PCIE_ECAM_INT_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PCIE_ECAM_INT_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_PCIE_ECAM_INT_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PCIE_ECAM_INT_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pcie_mem_int_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PCIE_MEM_INT_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PCIE_MEM_INT_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PCIE_MEM_INT_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PCIE_MEM_INT_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_PCIE_MEM_INT_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PCIE_MEM_INT_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** winit_cntl register ****/
+/* When set, enables access to winit regs, in normal mode. */
+#define PBS_UNIT_WINIT_CNTL_ENABLE_WINIT_REGS_ACCESS (1 << 0)
+/* Reserved */
+#define PBS_UNIT_WINIT_CNTL_RSRVD_MASK 0xFFFFFFFE
+#define PBS_UNIT_WINIT_CNTL_RSRVD_SHIFT 1
+
+/**** latch_bars register ****/
+/*
+ * Software clears this bit before any bar update, and set it after all bars
+ * updated.
+ */
+#define PBS_UNIT_LATCH_BARS_ENABLE (1 << 0)
+/* Reserved */
+#define PBS_UNIT_LATCH_BARS_RSRVD_MASK 0xFFFFFFFE
+#define PBS_UNIT_LATCH_BARS_RSRVD_SHIFT 1
+
+/**** pcie_conf_0 register ****/
+/* NOT_use, config internal inside each PCIe core */
+#define PBS_UNIT_PCIE_CONF_0_DEVS_TYPE_MASK 0x00000FFF
+#define PBS_UNIT_PCIE_CONF_0_DEVS_TYPE_SHIFT 0
+/* sys_aux_det value */
+#define PBS_UNIT_PCIE_CONF_0_SYS_AUX_PWR_DET_VEC_MASK 0x00007000
+#define PBS_UNIT_PCIE_CONF_0_SYS_AUX_PWR_DET_VEC_SHIFT 12
+/* Reserved */
+#define PBS_UNIT_PCIE_CONF_0_RSRVD_MASK 0xFFFF8000
+#define PBS_UNIT_PCIE_CONF_0_RSRVD_SHIFT 15
+
+/**** pcie_conf_1 register ****/
+/*
+ * Which PCIe exists? The PCIe device is under reset until the corresponding bit
+ * is set.
+ */
+#define PBS_UNIT_PCIE_CONF_1_PCIE_EXIST_MASK 0x0000003F
+#define PBS_UNIT_PCIE_CONF_1_PCIE_EXIST_SHIFT 0
+/* Reserved */
+#define PBS_UNIT_PCIE_CONF_1_RSRVD_MASK 0xFFFFFFC0
+#define PBS_UNIT_PCIE_CONF_1_RSRVD_SHIFT 6
+
+/**** serdes_mux_pipe register ****/
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_SERDES_2_MASK 0x00000007
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_SERDES_2_SHIFT 0
+/* Reserved */
+#define PBS_UNIT_SERDES_MUX_PIPE_RSRVD_3 (1 << 3)
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_SERDES_3_MASK 0x00000070
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_SERDES_3_SHIFT 4
+/* Reserved */
+#define PBS_UNIT_SERDES_MUX_PIPE_RSRVD_7 (1 << 7)
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_PCI_B_0_MASK 0x00000300
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_PCI_B_0_SHIFT 8
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_PCI_B_1_MASK 0x00000C00
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_PCI_B_1_SHIFT 10
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_PCI_C_0_MASK 0x00003000
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_PCI_C_0_SHIFT 12
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_PCI_C_1_MASK 0x0000C000
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_PCI_C_1_SHIFT 14
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_USB_A_0_MASK 0x00030000
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_USB_A_0_SHIFT 16
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_USB_B_0_MASK 0x000C0000
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_USB_B_0_SHIFT 18
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_CLKI_SER_2_MASK 0x00300000
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_CLKI_SER_2_SHIFT 20
+/* Reserved */
+#define PBS_UNIT_SERDES_MUX_PIPE_RSRVD_23_22_MASK 0x00C00000
+#define PBS_UNIT_SERDES_MUX_PIPE_RSRVD_23_22_SHIFT 22
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_CLKI_SER_3_MASK 0x07000000
+#define PBS_UNIT_SERDES_MUX_PIPE_SELECT_OH_CLKI_SER_3_SHIFT 24
+/* Reserved */
+#define PBS_UNIT_SERDES_MUX_PIPE_RSRVD_MASK 0xF8000000
+#define PBS_UNIT_SERDES_MUX_PIPE_RSRVD_SHIFT 27
+
+/*
+ * 2'b01 - select pcie_b[0]
+ * 2'b10 - select pcie_a[2]
+ */
+#define PBS_UNIT_SERDES_MUX_PIPE_PKR_SELECT_OH_SERDES_2_MASK 0x00000003
+#define PBS_UNIT_SERDES_MUX_PIPE_PKR_SELECT_OH_SERDES_2_SHIFT 0
+/*
+ * 2'b01 - select pcie_b[1]
+ * 2'b10 - select pcie_a[3]
+ */
+#define PBS_UNIT_SERDES_MUX_PIPE_PKR_SELECT_OH_SERDES_3_MASK 0x00000030
+#define PBS_UNIT_SERDES_MUX_PIPE_PKR_SELECT_OH_SERDES_3_SHIFT 4
+/*
+ * 2'b01 - select pcie_b[0]
+ * 2'b10 - select pcie_a[4]
+ */
+#define PBS_UNIT_SERDES_MUX_PIPE_PKR_SELECT_OH_SERDES_4_MASK 0x00000300
+#define PBS_UNIT_SERDES_MUX_PIPE_PKR_SELECT_OH_SERDES_4_SHIFT 8
+/*
+ * 2'b01 - select pcie_b[1]
+ * 2'b10 - select pcie_a[5]
+ */
+#define PBS_UNIT_SERDES_MUX_PIPE_PKR_SELECT_OH_SERDES_5_MASK 0x00003000
+#define PBS_UNIT_SERDES_MUX_PIPE_PKR_SELECT_OH_SERDES_5_SHIFT 12
+/*
+ * 2'b01 - select pcie_b[2]
+ * 2'b10 - select pcie_a[6]
+ */
+#define PBS_UNIT_SERDES_MUX_PIPE_PKR_SELECT_OH_SERDES_6_MASK 0x00030000
+#define PBS_UNIT_SERDES_MUX_PIPE_PKR_SELECT_OH_SERDES_6_SHIFT 16
+/*
+ * 2'b01 - select pcie_b[3]
+ * 2'b10 - select pcie_a[7]
+ */
+#define PBS_UNIT_SERDES_MUX_PIPE_PKR_SELECT_OH_SERDES_7_MASK 0x00300000
+#define PBS_UNIT_SERDES_MUX_PIPE_PKR_SELECT_OH_SERDES_7_SHIFT 20
+/*
+ * 2'b01 - select pcie_d[0]
+ * 2'b10 - select pcie_c[2]
+ */
+#define PBS_UNIT_SERDES_MUX_PIPE_PKR_SELECT_OH_SERDES_10_MASK 0x03000000
+#define PBS_UNIT_SERDES_MUX_PIPE_PKR_SELECT_OH_SERDES_10_SHIFT 24
+/*
+ * 2'b01 - select pcie_d[1]
+ * 2'b10 - select pcie_c[3]
+ */
+#define PBS_UNIT_SERDES_MUX_PIPE_PKR_SELECT_OH_SERDES_11_MASK 0x30000000
+#define PBS_UNIT_SERDES_MUX_PIPE_PKR_SELECT_OH_SERDES_11_SHIFT 28
+
+/**** dma_io_master_map register ****/
+/*
+ * [0]: When set, maps all the io_dma transactions to the NB/DRAM, regardless of
+ * the window hit.
+ * [1]: When set, maps all the eth_0 transactions to the NB/DRAM, regardless of
+ * the window hit.
+ * [2]: When set, maps all the eth_2 transaction to the NB/DRAM, regardless of
+ * the window hit.
+ * [3]: When set, maps all the sata_0 transactions to the NB/DRAM, regardless of
+ * the window hit.
+ * [4]: When set, maps all the sata_1 transactions to the NB/DRAM, regardless of
+ * the window hit.
+ * [5]: When set, maps all the pcie_0 master transactions to the NB/DRAM,
+ * regardless of the window hit.
+ * [6]: When set, maps all the SPI debug port transactions to the NB/DRAM,
+ * regardless of the window hit.
+ * [7]: When set, maps all the CPU debug port transactions to the NB/DRAM,
+ * regardless of the window hit.
+ * [8] When set, maps all the Crypto transactions to the NB/DRAM, regardless of
+ * the window hit.
+ * [15:9] - Reserved
+ */
+#define PBS_UNIT_DMA_IO_MASTER_MAP_CNTL_MASK 0x0000FFFF
+#define PBS_UNIT_DMA_IO_MASTER_MAP_CNTL_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_DMA_IO_MASTER_MAP_RSRVD_MASK 0xFFFF0000
+#define PBS_UNIT_DMA_IO_MASTER_MAP_RSRVD_SHIFT 16
+
+/**** i2c_pld_status_high register ****/
+/* I2C pre-load status */
+#define PBS_UNIT_I2C_PLD_STATUS_HIGH_STATUS_MASK 0x000000FF
+#define PBS_UNIT_I2C_PLD_STATUS_HIGH_STATUS_SHIFT 0
+
+/**** spi_dbg_status_high register ****/
+/* SPI DBG load status */
+#define PBS_UNIT_SPI_DBG_STATUS_HIGH_STATUS_MASK 0x000000FF
+#define PBS_UNIT_SPI_DBG_STATUS_HIGH_STATUS_SHIFT 0
+
+/**** spi_mst_status_high register ****/
+/* SP IMST load status */
+#define PBS_UNIT_SPI_MST_STATUS_HIGH_STATUS_MASK 0x000000FF
+#define PBS_UNIT_SPI_MST_STATUS_HIGH_STATUS_SHIFT 0
+
+/**** mem_pbs_parity_err_high register ****/
+/* Address latch in the case of a parity error */
+#define PBS_UNIT_MEM_PBS_PARITY_ERR_HIGH_ADDR_MASK 0x000000FF
+#define PBS_UNIT_MEM_PBS_PARITY_ERR_HIGH_ADDR_SHIFT 0
+
+/**** cfg_axi_conf_0 register ****/
+/* Sets the AXI field in the I2C preloader interface. */
+#define PBS_UNIT_CFG_AXI_CONF_0_DBG_RD_ID_MASK 0x0000007F
+#define PBS_UNIT_CFG_AXI_CONF_0_DBG_RD_ID_SHIFT 0
+/* Sets the AXI field in the I2C preloader interface. */
+#define PBS_UNIT_CFG_AXI_CONF_0_DBG_WR_ID_MASK 0x00003F80
+#define PBS_UNIT_CFG_AXI_CONF_0_DBG_WR_ID_SHIFT 7
+/* Sets the AXI field in the I2C preloader interface. */
+#define PBS_UNIT_CFG_AXI_CONF_0_PLD_WR_ID_MASK 0x001FC000
+#define PBS_UNIT_CFG_AXI_CONF_0_PLD_WR_ID_SHIFT 14
+/* Sets the AXI field in the SPI debug interface. */
+#define PBS_UNIT_CFG_AXI_CONF_0_DBG_AWCACHE_MASK 0x01E00000
+#define PBS_UNIT_CFG_AXI_CONF_0_DBG_AWCACHE_SHIFT 21
+/* Sets the AXI field in the SPI debug interface. */
+#define PBS_UNIT_CFG_AXI_CONF_0_DBG_ARCACHE_MASK 0x1E000000
+#define PBS_UNIT_CFG_AXI_CONF_0_DBG_ARCACHE_SHIFT 25
+/* Sets the AXI field in the SPI debug interface. */
+#define PBS_UNIT_CFG_AXI_CONF_0_DBG_AXPROT_MASK 0xE0000000
+#define PBS_UNIT_CFG_AXI_CONF_0_DBG_AXPROT_SHIFT 29
+
+/**** cfg_axi_conf_1 register ****/
+/* Sets the AXI field in the SPI debug interface. */
+#define PBS_UNIT_CFG_AXI_CONF_1_DBG_ARUSER_MASK 0x03FFFFFF
+#define PBS_UNIT_CFG_AXI_CONF_1_DBG_ARUSER_SHIFT 0
+/* Sets the AXI field in the SPI debug interface. */
+#define PBS_UNIT_CFG_AXI_CONF_1_DBG_ARQOS_MASK 0x3C000000
+#define PBS_UNIT_CFG_AXI_CONF_1_DBG_ARQOS_SHIFT 26
+
+/**** cfg_axi_conf_2 register ****/
+/* Sets the AXI field in the SPI debug interface. */
+#define PBS_UNIT_CFG_AXI_CONF_2_DBG_AWUSER_MASK 0x03FFFFFF
+#define PBS_UNIT_CFG_AXI_CONF_2_DBG_AWUSER_SHIFT 0
+/* Sets the AXI field in the SPI debug interface. */
+#define PBS_UNIT_CFG_AXI_CONF_2_DBG_AWQOS_MASK 0x3C000000
+#define PBS_UNIT_CFG_AXI_CONF_2_DBG_AWQOS_SHIFT 26
+
+/**** spi_mst_conf_0 register ****/
+/*
+ * Sets the SPI master Configuration. For details see the SPI section in the
+ * documentation.
+ */
+#define PBS_UNIT_SPI_MST_CONF_0_CFG_SPI_MST_SRL (1 << 0)
+/*
+ * Sets the SPI master Configuration. For details see the SPI section in the
+ * documentation.
+ */
+#define PBS_UNIT_SPI_MST_CONF_0_CFG_SPI_MST_SCPOL (1 << 1)
+/*
+ * Sets the SPI master Configuration. For details see the SPI section in the
+ * documentation.
+ */
+#define PBS_UNIT_SPI_MST_CONF_0_CFG_SPI_MST_SCPH (1 << 2)
+/*
+ * Set the SPI master configuration. For details see the SPI section in the
+ * documentation.
+ */
+#define PBS_UNIT_SPI_MST_CONF_0_CFG_SPI_MST_SER_MASK 0x00000078
+#define PBS_UNIT_SPI_MST_CONF_0_CFG_SPI_MST_SER_SHIFT 3
+/*
+ * Set the SPI master configuration. For details see the SPI section in the
+ * documentation.
+ */
+#define PBS_UNIT_SPI_MST_CONF_0_CFG_SPI_MST_BAUD_MASK 0x007FFF80
+#define PBS_UNIT_SPI_MST_CONF_0_CFG_SPI_MST_BAUD_SHIFT 7
+/*
+ * Sets the SPI master configuration. For details see the SPI section in the
+ * documentation.
+ */
+#define PBS_UNIT_SPI_MST_CONF_0_CFG_SPI_MST_RD_CMD_MASK 0x7F800000
+#define PBS_UNIT_SPI_MST_CONF_0_CFG_SPI_MST_RD_CMD_SHIFT 23
+
+/**** spi_mst_conf_1 register ****/
+/*
+ * Sets the SPI master Configuration. For details see the SPI section in the
+ * documentation.
+ */
+#define PBS_UNIT_SPI_MST_CONF_1_CFG_SPI_MST_WR_CMD_MASK 0x000000FF
+#define PBS_UNIT_SPI_MST_CONF_1_CFG_SPI_MST_WR_CMD_SHIFT 0
+/*
+ * Sets the SPI master Configuration. For details see the SPI section in the
+ * documentation.
+ */
+#define PBS_UNIT_SPI_MST_CONF_1_CFG_SPI_MST_ADDR_BYTES_NUM_MASK 0x00000700
+#define PBS_UNIT_SPI_MST_CONF_1_CFG_SPI_MST_ADDR_BYTES_NUM_SHIFT 8
+/*
+ * Sets the SPI master Configuration. For details see the SPI section in the
+ * documentation.
+ */
+#define PBS_UNIT_SPI_MST_CONF_1_CFG_SPI_MST_TMODE_MASK 0x00001800
+#define PBS_UNIT_SPI_MST_CONF_1_CFG_SPI_MST_TMODE_SHIFT 11
+/*
+ * Sets the SPI master Configuration. For details see the SPI section in the
+ * documentation.
+ */
+#define PBS_UNIT_SPI_MST_CONF_1_CFG_SPI_MST_FAST_RD (1 << 13)
+
+/**** spi_slv_conf_0 register ****/
+/*
+ * Sets the SPI slave configuration. For details see the SPI section in the
+ * documentation.
+ */
+#define PBS_UNIT_SPI_SLV_CONF_0_CFG_SPI_SLV_BAUD_MASK 0x0000FFFF
+#define PBS_UNIT_SPI_SLV_CONF_0_CFG_SPI_SLV_BAUD_SHIFT 0
+/* Value. The reset value is according to bootstrap. */
+#define PBS_UNIT_SPI_SLV_CONF_0_CFG_SPI_SLV_SCPOL (1 << 16)
+/* Value. The reset value is according to bootstrap. */
+#define PBS_UNIT_SPI_SLV_CONF_0_CFG_SPI_SLV_SCPH (1 << 17)
+/*
+ * Sets the SPI slave configuration. For details see the SPI section in the
+ * documentation.
+ */
+#define PBS_UNIT_SPI_SLV_CONF_0_CFG_SPI_SLV_SER_MASK 0x03FC0000
+#define PBS_UNIT_SPI_SLV_CONF_0_CFG_SPI_SLV_SER_SHIFT 18
+/*
+ * Sets the SPI slave configuration. For details see the SPI section in the
+ * documentation.
+ */
+#define PBS_UNIT_SPI_SLV_CONF_0_CFG_SPI_SLV_SRL (1 << 26)
+/*
+ * Sets the SPI slave configuration. For details see the SPI section in the
+ * documentation.
+ */
+#define PBS_UNIT_SPI_SLV_CONF_0_CFG_SPI_SLV_TMODE_MASK 0x18000000
+#define PBS_UNIT_SPI_SLV_CONF_0_CFG_SPI_SLV_TMODE_SHIFT 27
+
+/**** apb_mem_conf_int register ****/
+/* Value-- internal */
+#define PBS_UNIT_APB_MEM_CONF_INT_CFG_PBS_WRR_CNT_MASK 0x00000007
+#define PBS_UNIT_APB_MEM_CONF_INT_CFG_PBS_WRR_CNT_SHIFT 0
+/* Value-- internal */
+#define PBS_UNIT_APB_MEM_CONF_INT_CFG_I2C_PLD_APB_MIX_ARB (1 << 3)
+/* Value-- internal */
+#define PBS_UNIT_APB_MEM_CONF_INT_CFG_SPI_DBG_APB_MIX_ARB (1 << 4)
+/* Value-- internal */
+#define PBS_UNIT_APB_MEM_CONF_INT_CFG_SPI_MST_APB_MIX_ARB (1 << 5)
+/* Value-- internal */
+#define PBS_UNIT_APB_MEM_CONF_INT_CFG_I2C_PLD_CLEAR_FSM (1 << 6)
+/* Value-- internal */
+#define PBS_UNIT_APB_MEM_CONF_INT_CFG_SPI_DBG_CLEAR_FSM (1 << 7)
+/* Value-- internal */
+#define PBS_UNIT_APB_MEM_CONF_INT_CFG_SPI_MST_CLEAR_FSM (1 << 8)
+/* Value-- internal */
+#define PBS_UNIT_APB_MEM_CONF_INT_CFG_PBS_AXI_FSM_CLEAR (1 << 9)
+/* Value-- internal */
+#define PBS_UNIT_APB_MEM_CONF_INT_CFG_PBS_AXI_FIFOS_CLEAR (1 << 10)
+/* Enables parity protection on the integrated SRAM. */
+#define PBS_UNIT_APB_MEM_CONF_INT_CFG_BOOTROM_PARITY_EN (1 << 11)
+/*
+ * When set, reports a slave error whenthe slave returns an AXI slave error, for
+ * configuration access to the internal configuration space.
+ */
+#define PBS_UNIT_APB_MEM_CONF_INT_CFG_RD_SLV_ERR_EN (1 << 12)
+/*
+ * When set, reports a decode error when timeout has occurred for configuration
+ * access to the internal configuration space.
+ */
+#define PBS_UNIT_APB_MEM_CONF_INT_CFG_RD_DEC_ERR_EN (1 << 13)
+/*
+ * When set, reports a slave error, when the slave returns an AXI slave error,
+ * for configuration access to the internal configuration space.
+ */
+#define PBS_UNIT_APB_MEM_CONF_INT_CFG_WR_SLV_ERR_EN (1 << 14)
+/*
+ * When set, reports a decode error when timeout has occurred for configuration
+ * access to the internal configuration space.
+ */
+#define PBS_UNIT_APB_MEM_CONF_INT_CFG_WR_DEC_ERR_EN (1 << 15)
+
+/**** sb_int_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_SB_INT_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_SB_INT_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_SB_INT_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_SB_INT_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_SB_INT_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_SB_INT_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** ufc_pbs_parity_err_high register ****/
+/*
+ * Address latch in the case of a parity error in the Flash Controller internal
+ * memories.
+ */
+#define PBS_UNIT_UFC_PBS_PARITY_ERR_HIGH_ADDR_MASK 0x000000FF
+#define PBS_UNIT_UFC_PBS_PARITY_ERR_HIGH_ADDR_SHIFT 0
+
+/**** chip_id register ****/
+/* [15:0] : Dev Rev ID */
+#define PBS_UNIT_CHIP_ID_DEV_REV_ID_MASK 0x0000FFFF
+#define PBS_UNIT_CHIP_ID_DEV_REV_ID_SHIFT 0
+/* [31:16] : 0x0 - Dev ID */
+#define PBS_UNIT_CHIP_ID_DEV_ID_MASK 0xFFFF0000
+#define PBS_UNIT_CHIP_ID_DEV_ID_SHIFT 16
+
+#define PBS_UNIT_CHIP_ID_DEV_ID_ALPINE 0
+#define PBS_UNIT_CHIP_ID_DEV_ID_PEAKROCK 1
+#define PBS_UNIT_CHIP_ID_DEV_ID_COYOTE 2
+
+/**** uart0_conf_status register ****/
+/*
+ * Conf:
+ * // [0] -- DSR_N RW bit
+ * // [1] -- DCD_N RW bit
+ * // [2] -- RI_N bit
+ * // [3] -- dma_tx_ack_n
+ * // [4] -- dma_rx_ack_n
+ */
+#define PBS_UNIT_UART0_CONF_STATUS_CONF_MASK 0x0000FFFF
+#define PBS_UNIT_UART0_CONF_STATUS_CONF_SHIFT 0
+/*
+ * Status:
+ * // [16] -- dtr_n RO bit
+ * // [17] -- OUT1_N RO bit
+ * // [18] -- OUT2_N RO bit
+ * // [19] -- dma_tx_req_n RO bit
+ * // [20] -- dma_tx_single_n RO bit
+ * // [21] -- dma_rx_req_n RO bit
+ * // [22] -- dma_rx_single_n RO bit
+ * // [23] -- uart_lp_req_pclk RO bit
+ * // [24] -- baudout_n RO bit
+ */
+#define PBS_UNIT_UART0_CONF_STATUS_STATUS_MASK 0xFFFF0000
+#define PBS_UNIT_UART0_CONF_STATUS_STATUS_SHIFT 16
+
+/**** uart1_conf_status register ****/
+/*
+ * Conf: // [0] -- DSR_N RW bit // [1] -- DCD_N RW bit // [2] -- RI_N bit // [3]
+ * -- dma_tx_ack_n // [4] - dma_rx_ack_n
+ */
+#define PBS_UNIT_UART1_CONF_STATUS_CONF_MASK 0x0000FFFF
+#define PBS_UNIT_UART1_CONF_STATUS_CONF_SHIFT 0
+/*
+ * Status: // [16] -- dtr_n RO bit // [17] -- OUT1_N RO bit // [18] -- OUT2_N RO
+ * bit // [19] -- dma_tx_req_n RO bit // [20] -- dma_tx_single_n RO bit // [21]
+ * -- dma_rx_req_n RO bit // [22] -- dma_rx_single_n RO bit // [23] --
+ * uart_lp_req_pclk RO bit // [24] -- baudout_n RO bit
+ */
+#define PBS_UNIT_UART1_CONF_STATUS_STATUS_MASK 0xFFFF0000
+#define PBS_UNIT_UART1_CONF_STATUS_STATUS_SHIFT 16
+
+/**** uart2_conf_status register ****/
+/*
+ * Conf: // [0] -- DSR_N RW bit // [1] -- DCD_N RW bit // [2] -- RI_N bit // [3]
+ * -- dma_tx_ack_n // [4] - dma_rx_ack_n
+ */
+#define PBS_UNIT_UART2_CONF_STATUS_CONF_MASK 0x0000FFFF
+#define PBS_UNIT_UART2_CONF_STATUS_CONF_SHIFT 0
+/*
+ * Status: // [16] -- dtr_n RO bit // [17] -- OUT1_N RO bit // [18] -- OUT2_N RO
+ * bit // [19] -- dma_tx_req_n RO bit // [20] -- dma_tx_single_n RO bit // [21]
+ * -- dma_rx_req_n RO bit // [22] -- dma_rx_single_n RO bit // [23] --
+ * uart_lp_req_pclk RO bit // [24] -- baudout_n RO bit
+ */
+#define PBS_UNIT_UART2_CONF_STATUS_STATUS_MASK 0xFFFF0000
+#define PBS_UNIT_UART2_CONF_STATUS_STATUS_SHIFT 16
+
+/**** uart3_conf_status register ****/
+/*
+ * Conf: // [0] -- DSR_N RW bit // [1] -- DCD_N RW bit // [2] -- RI_N bit // [3]
+ * -- dma_tx_ack_n // [4] - dma_rx_ack_n
+ */
+#define PBS_UNIT_UART3_CONF_STATUS_CONF_MASK 0x0000FFFF
+#define PBS_UNIT_UART3_CONF_STATUS_CONF_SHIFT 0
+/*
+ * Status: // [16] -- dtr_n RO bit // [17] -- OUT1_N RO bit // [18] -- OUT2_N RO
+ * bit // [19] -- dma_tx_req_n RO bit // [20] -- dma_tx_single_n RO bit // [21]
+ * -- dma_rx_req_n RO bit // [22] -- dma_rx_single_n RO bit // [23] --
+ * uart_lp_req_pclk RO bit // [24] -- baudout_n RO bit
+ */
+#define PBS_UNIT_UART3_CONF_STATUS_STATUS_MASK 0xFFFF0000
+#define PBS_UNIT_UART3_CONF_STATUS_STATUS_SHIFT 16
+
+/**** gpio0_conf_status register ****/
+/*
+ * Cntl:
+ * // [7:0] nGPAFEN; // from regfile
+ * // [15:8] GPAFOUT; // from regfile
+ */
+#define PBS_UNIT_GPIO0_CONF_STATUS_CONF_MASK 0x0000FFFF
+#define PBS_UNIT_GPIO0_CONF_STATUS_CONF_SHIFT 0
+/*
+ * Status:
+ * // [24:16] GPAFIN; // to regfile
+ */
+#define PBS_UNIT_GPIO0_CONF_STATUS_STATUS_MASK 0xFFFF0000
+#define PBS_UNIT_GPIO0_CONF_STATUS_STATUS_SHIFT 16
+
+/**** gpio1_conf_status register ****/
+/*
+ * Cntl:
+ * // [7:0] nGPAFEN; // from regfile
+ * // [15:8] GPAFOUT; // from regfile
+ */
+#define PBS_UNIT_GPIO1_CONF_STATUS_CONF_MASK 0x0000FFFF
+#define PBS_UNIT_GPIO1_CONF_STATUS_CONF_SHIFT 0
+/*
+ * Status:
+ * // [24:16] GPAFIN; // to regfile
+ */
+#define PBS_UNIT_GPIO1_CONF_STATUS_STATUS_MASK 0xFFFF0000
+#define PBS_UNIT_GPIO1_CONF_STATUS_STATUS_SHIFT 16
+
+/**** gpio2_conf_status register ****/
+/*
+ * Cntl:
+ * // [7:0] nGPAFEN; // from regfile
+ * // [15:8] GPAFOUT; // from regfile
+ */
+#define PBS_UNIT_GPIO2_CONF_STATUS_CONF_MASK 0x0000FFFF
+#define PBS_UNIT_GPIO2_CONF_STATUS_CONF_SHIFT 0
+/*
+ * Status:
+ * // [24:16] GPAFIN; // to regfile
+ */
+#define PBS_UNIT_GPIO2_CONF_STATUS_STATUS_MASK 0xFFFF0000
+#define PBS_UNIT_GPIO2_CONF_STATUS_STATUS_SHIFT 16
+
+/**** gpio3_conf_status register ****/
+/*
+ * Cntl:
+ * // [7:0] nGPAFEN; // from regfile
+ * // [15:8] GPAFOUT; // from regfile
+ */
+#define PBS_UNIT_GPIO3_CONF_STATUS_CONF_MASK 0x0000FFFF
+#define PBS_UNIT_GPIO3_CONF_STATUS_CONF_SHIFT 0
+/*
+ * Status:
+ * // [24:16] GPAFIN; // to regfile
+ */
+#define PBS_UNIT_GPIO3_CONF_STATUS_STATUS_MASK 0xFFFF0000
+#define PBS_UNIT_GPIO3_CONF_STATUS_STATUS_SHIFT 16
+
+/**** gpio4_conf_status register ****/
+/*
+ * Cntl:
+ * // [7:0] nGPAFEN; // from regfile
+ * // [15:8] GPAFOUT; // from regfile
+ */
+#define PBS_UNIT_GPIO4_CONF_STATUS_CONF_MASK 0x0000FFFF
+#define PBS_UNIT_GPIO4_CONF_STATUS_CONF_SHIFT 0
+/*
+ * Status:
+ * // [24:16] GPAFIN; // to regfile
+ */
+#define PBS_UNIT_GPIO4_CONF_STATUS_STATUS_MASK 0xFFFF0000
+#define PBS_UNIT_GPIO4_CONF_STATUS_STATUS_SHIFT 16
+
+/**** i2c_gen_conf_status register ****/
+/*
+ * cntl
+ * // [0] -- dma_tx_ack
+ * // [1] -- dma_rx_ack
+ */
+#define PBS_UNIT_I2C_GEN_CONF_STATUS_CONF_MASK 0x0000FFFF
+#define PBS_UNIT_I2C_GEN_CONF_STATUS_CONF_SHIFT 0
+/*
+ * Status
+ *
+ * // [16] -- dma_tx_req RO bit
+ * // [17] -- dma_tx_single RO bit
+ * // [18] -- dma_rx_req RO bit
+ * // [19] -- dma_rx_single RO bit
+ */
+#define PBS_UNIT_I2C_GEN_CONF_STATUS_STATUS_MASK 0xFFFF0000
+#define PBS_UNIT_I2C_GEN_CONF_STATUS_STATUS_SHIFT 16
+
+/**** watch_dog_reset_out register ****/
+/*
+ * [0] If set to 1'b1, WD0 cannot generate reset_out_n
+ * [1] If set to 1'b1, WD1 cannot generate reset_out_n
+ * [2] If set to 1'b1, WD2 cannot generate reset_out_n
+ * [3] If set to 1'b1, WD3 cannot generate reset_out_n
+ * [4] If set to 1'b1, WD4 cannot generate reset_out_n
+ * [5] If set to 1'b1, WD5 cannot generate reset_out_n
+ * [6] If set to 1'b1, WD6 cannot generate reset_out_n
+ * [7] If set to 1'b1, WD7 cannot generate reset_out_n
+ */
+#define PBS_UNIT_WATCH_DOG_RESET_OUT_DISABLE_MASK 0x000000FF
+#define PBS_UNIT_WATCH_DOG_RESET_OUT_DISABLE_SHIFT 0
+
+/**** otp_cntl register ****/
+/* from reg file Config To bypass the copy from OTPW to OTPR */
+#define PBS_UNIT_OTP_CNTL_IGNORE_OTPW (1 << 0)
+/* Not in use.Comes from bond. */
+#define PBS_UNIT_OTP_CNTL_IGNORE_PRELOAD (1 << 1)
+/* Margin read from the fuse box */
+#define PBS_UNIT_OTP_CNTL_OTPW_MARGIN_READ (1 << 2)
+/* Indicates when OTPis busy. */
+#define PBS_UNIT_OTP_CNTL_OTP_BUSY (1 << 3)
+
+/**** otp_cfg_0 register ****/
+/* Cfg to OTP cntl. */
+#define PBS_UNIT_OTP_CFG_0_CFG_OTPW_PWRDN_CNT_MASK 0x0000FFFF
+#define PBS_UNIT_OTP_CFG_0_CFG_OTPW_PWRDN_CNT_SHIFT 0
+/* Cfg to OTP cntl. */
+#define PBS_UNIT_OTP_CFG_0_CFG_OTPW_READ_CNT_MASK 0xFFFF0000
+#define PBS_UNIT_OTP_CFG_0_CFG_OTPW_READ_CNT_SHIFT 16
+
+/**** otp_cfg_1 register ****/
+/* Cfg to OTP cntl. */
+#define PBS_UNIT_OTP_CFG_1_CFG_OTPW_PGM_CNT_MASK 0x0000FFFF
+#define PBS_UNIT_OTP_CFG_1_CFG_OTPW_PGM_CNT_SHIFT 0
+/* Cfg to OTP cntl. */
+#define PBS_UNIT_OTP_CFG_1_CFG_OTPW_PREP_CNT_MASK 0xFFFF0000
+#define PBS_UNIT_OTP_CFG_1_CFG_OTPW_PREP_CNT_SHIFT 16
+
+/**** otp_cfg_3 register ****/
+/* Cfg to OTP cntl. */
+#define PBS_UNIT_OTP_CFG_3_CFG_OTPW_PS18_CNT_MASK 0x0000FFFF
+#define PBS_UNIT_OTP_CFG_3_CFG_OTPW_PS18_CNT_SHIFT 0
+/* Cfg to OTP cntl. */
+#define PBS_UNIT_OTP_CFG_3_CFG_OTPW_PWRUP_CNT_MASK 0xFFFF0000
+#define PBS_UNIT_OTP_CFG_3_CFG_OTPW_PWRUP_CNT_SHIFT 16
+
+/**** nb_nic_regs_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_NB_NIC_REGS_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_NB_NIC_REGS_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_NB_NIC_REGS_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_NB_NIC_REGS_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_NB_NIC_REGS_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_NB_NIC_REGS_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** sb_nic_regs_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_SB_NIC_REGS_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_SB_NIC_REGS_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_SB_NIC_REGS_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_SB_NIC_REGS_BAR_LOW_RSRVD_SHIFT 6
+/* bar low address 16 MSB bits */
+#define PBS_UNIT_SB_NIC_REGS_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_SB_NIC_REGS_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** serdes_mux_multi_0 register ****/
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_SELECT_OH_SERDES_8_MASK 0x00000007
+#define PBS_UNIT_SERDES_MUX_MULTI_0_SELECT_OH_SERDES_8_SHIFT 0
+/* Reserved */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_RSRVD_3 (1 << 3)
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_SELECT_OH_SERDES_9_MASK 0x00000070
+#define PBS_UNIT_SERDES_MUX_MULTI_0_SELECT_OH_SERDES_9_SHIFT 4
+/* Reserved */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_RSRVD_7 (1 << 7)
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_SELECT_OH_SERDES_10_MASK 0x00000700
+#define PBS_UNIT_SERDES_MUX_MULTI_0_SELECT_OH_SERDES_10_SHIFT 8
+/* Reserved */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_RSRVD_11 (1 << 11)
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_SELECT_OH_SERDES_11_MASK 0x00007000
+#define PBS_UNIT_SERDES_MUX_MULTI_0_SELECT_OH_SERDES_11_SHIFT 12
+/* Reserved */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_RSRVD_15 (1 << 15)
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_SELECT_OH_SERDES_12_MASK 0x00030000
+#define PBS_UNIT_SERDES_MUX_MULTI_0_SELECT_OH_SERDES_12_SHIFT 16
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_SELECT_OH_SERDES_13_MASK 0x000C0000
+#define PBS_UNIT_SERDES_MUX_MULTI_0_SELECT_OH_SERDES_13_SHIFT 18
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_SELECT_OH_SERDES_14_MASK 0x00300000
+#define PBS_UNIT_SERDES_MUX_MULTI_0_SELECT_OH_SERDES_14_SHIFT 20
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_SELECT_OH_SERDES_15_MASK 0x00C00000
+#define PBS_UNIT_SERDES_MUX_MULTI_0_SELECT_OH_SERDES_15_SHIFT 22
+/* Reserved */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_RSRVD_MASK 0xFF000000
+#define PBS_UNIT_SERDES_MUX_MULTI_0_RSRVD_SHIFT 24
+
+/*
+ * 2'b01 - select sata_b[0]
+ * 2'b10 - select eth_a[0]
+ */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_PKR_SELECT_OH_SERDES_8_MASK 0x00000003
+#define PBS_UNIT_SERDES_MUX_MULTI_0_PKR_SELECT_OH_SERDES_8_SHIFT 0
+/*
+ * 3'b001 - select sata_b[1]
+ * 3'b010 - select eth_b[0]
+ * 3'b100 - select eth_a[1]
+ */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_PKR_SELECT_OH_SERDES_9_MASK 0x00000070
+#define PBS_UNIT_SERDES_MUX_MULTI_0_PKR_SELECT_OH_SERDES_9_SHIFT 4
+/*
+ * 3'b001 - select sata_b[2]
+ * 3'b010 - select eth_c[0]
+ * 3'b100 - select eth_a[2]
+ */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_PKR_SELECT_OH_SERDES_10_MASK 0x00000700
+#define PBS_UNIT_SERDES_MUX_MULTI_0_PKR_SELECT_OH_SERDES_10_SHIFT 8
+/*
+ * 3'b001 - select sata_b[3]
+ * 3'b010 - select eth_d[0]
+ * 3'b100 - select eth_a[3]
+ */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_PKR_SELECT_OH_SERDES_11_MASK 0x00007000
+#define PBS_UNIT_SERDES_MUX_MULTI_0_PKR_SELECT_OH_SERDES_11_SHIFT 12
+/*
+ * 2'b01 - select eth_a[0]
+ * 2'b10 - select sata_a[0]
+ */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_PKR_SELECT_OH_SERDES_12_MASK 0x00030000
+#define PBS_UNIT_SERDES_MUX_MULTI_0_PKR_SELECT_OH_SERDES_12_SHIFT 16
+/*
+ * 3'b001 - select eth_b[0]
+ * 3'b010 - select eth_c[1]
+ * 3'b100 - select sata_a[1]
+ */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_PKR_SELECT_OH_SERDES_13_MASK 0x00700000
+#define PBS_UNIT_SERDES_MUX_MULTI_0_PKR_SELECT_OH_SERDES_13_SHIFT 20
+/*
+ * 3'b001 - select eth_a[0]
+ * 3'b010 - select eth_c[2]
+ * 3'b100 - select sata_a[2]
+ */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_PKR_SELECT_OH_SERDES_14_MASK 0x07000000
+#define PBS_UNIT_SERDES_MUX_MULTI_0_PKR_SELECT_OH_SERDES_14_SHIFT 24
+/*
+ * 3'b001 - select eth_d[0]
+ * 3'b010 - select eth_c[3]
+ * 3'b100 - select sata_a[3]
+ */
+#define PBS_UNIT_SERDES_MUX_MULTI_0_PKR_SELECT_OH_SERDES_15_MASK 0x70000000
+#define PBS_UNIT_SERDES_MUX_MULTI_0_PKR_SELECT_OH_SERDES_15_SHIFT 28
+
+/**** serdes_mux_multi_1 register ****/
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_MULTI_1_SELECT_OH_ETH_A_0_MASK 0x00000003
+#define PBS_UNIT_SERDES_MUX_MULTI_1_SELECT_OH_ETH_A_0_SHIFT 0
+/* Reserved */
+#define PBS_UNIT_SERDES_MUX_MULTI_1_RSRVD_3_2_MASK 0x0000000C
+#define PBS_UNIT_SERDES_MUX_MULTI_1_RSRVD_3_2_SHIFT 2
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_MULTI_1_SELECT_OH_ETH_B_0_MASK 0x00000070
+#define PBS_UNIT_SERDES_MUX_MULTI_1_SELECT_OH_ETH_B_0_SHIFT 4
+/* Reserved */
+#define PBS_UNIT_SERDES_MUX_MULTI_1_RSRVD_7 (1 << 7)
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_MULTI_1_SELECT_OH_ETH_C_0_MASK 0x00000300
+#define PBS_UNIT_SERDES_MUX_MULTI_1_SELECT_OH_ETH_C_0_SHIFT 8
+/* Reserved */
+#define PBS_UNIT_SERDES_MUX_MULTI_1_RSRVD_11_10_MASK 0x00000C00
+#define PBS_UNIT_SERDES_MUX_MULTI_1_RSRVD_11_10_SHIFT 10
+/* SerDes one hot mux control. For details see datasheet. */
+#define PBS_UNIT_SERDES_MUX_MULTI_1_SELECT_OH_ETH_D_0_MASK 0x00007000
+#define PBS_UNIT_SERDES_MUX_MULTI_1_SELECT_OH_ETH_D_0_SHIFT 12
+/* Reserved */
+#define PBS_UNIT_SERDES_MUX_MULTI_1_RSRVD_MASK 0xFFFF8000
+#define PBS_UNIT_SERDES_MUX_MULTI_1_RSRVD_SHIFT 15
+
+/**** pbs_ulpi_mux_conf register ****/
+/*
+ * Value 0 - Select dedicated pins for the USB-1 inputs.
+ * Value 1 - Select PBS mux pins for the USB-1 inputs.
+ * [0] ULPI_B_CLK
+ * [1] ULPI_B_DIR
+ * [2] ULPI_B_NXT
+ * [10:3] ULPI_B_DATA[7:0]
+ */
+#define PBS_UNIT_PBS_ULPI_MUX_CONF_SEL_UPLI_IN_PBSMUX_MASK 0x000007FF
+#define PBS_UNIT_PBS_ULPI_MUX_CONF_SEL_UPLI_IN_PBSMUX_SHIFT 0
+/*
+ * [3] - Force to zero
+ * [2] == 1 - Force register selection
+ * [1 : 0] -Binary selection of the input in bypass mode
+ */
+#define PBS_UNIT_PBS_ULPI_MUX_CONF_REG_MDIO_BYPASS_SEL_MASK 0x0000F000
+#define PBS_UNIT_PBS_ULPI_MUX_CONF_REG_MDIO_BYPASS_SEL_SHIFT 12
+/*
+ * [0] Sets the clk_ulpi OE for USB0, 1'b0 set to input, 1'b1 set to output.
+ * [1] Sets the clk_ulpi OE for USB01, 1'b0 set to input, 1'b1 set to output.
+ */
+#define PBS_UNIT_PBS_ULPI_MUX_CONF_RSRVD_MASK 0xFFFF0000
+#define PBS_UNIT_PBS_ULPI_MUX_CONF_RSRVD_SHIFT 16
+
+/**** wr_once_dbg_dis_ovrd_reg register ****/
+/* This register can be written only once. Use in the secure boot process. */
+#define PBS_UNIT_WR_ONCE_DBG_DIS_OVRD_REG_WR_ONCE_DBG_DIS_OVRD (1 << 0)
+
+#define PBS_UNIT_WR_ONCE_DBG_DIS_OVRD_REG_RSRVD_MASK 0xFFFFFFFE
+#define PBS_UNIT_WR_ONCE_DBG_DIS_OVRD_REG_RSRVD_SHIFT 1
+
+/**** gpio5_conf_status register ****/
+/*
+ * Cntl: // [7:0] nGPAFEN; // from regfile // [15:8] GPAFOUT; // from regfile
+ */
+#define PBS_UNIT_GPIO5_CONF_STATUS_CONF_MASK 0x0000FFFF
+#define PBS_UNIT_GPIO5_CONF_STATUS_CONF_SHIFT 0
+/* Status: // [24:16] GPAFIN; // to regfile */
+#define PBS_UNIT_GPIO5_CONF_STATUS_STATUS_MASK 0xFFFF0000
+#define PBS_UNIT_GPIO5_CONF_STATUS_STATUS_SHIFT 16
+
+/**** pcie_mem3_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PCIE_MEM3_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PCIE_MEM3_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PCIE_MEM3_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PCIE_MEM3_BAR_LOW_RSRVD_SHIFT 6
+/* Reserved */
+#define PBS_UNIT_PCIE_MEM3_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PCIE_MEM3_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pcie_mem4_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PCIE_MEM4_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PCIE_MEM4_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PCIE_MEM4_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PCIE_MEM4_BAR_LOW_RSRVD_SHIFT 6
+/* Reserved */
+#define PBS_UNIT_PCIE_MEM4_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PCIE_MEM4_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pcie_mem5_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PCIE_MEM5_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PCIE_MEM5_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PCIE_MEM5_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PCIE_MEM5_BAR_LOW_RSRVD_SHIFT 6
+/* Reserved */
+#define PBS_UNIT_PCIE_MEM5_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PCIE_MEM5_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pcie_ext_ecam3_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PCIE_EXT_ECAM3_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PCIE_EXT_ECAM3_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PCIE_EXT_ECAM3_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PCIE_EXT_ECAM3_BAR_LOW_RSRVD_SHIFT 6
+/* Reserved */
+#define PBS_UNIT_PCIE_EXT_ECAM3_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PCIE_EXT_ECAM3_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pcie_ext_ecam4_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PCIE_EXT_ECAM4_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PCIE_EXT_ECAM4_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PCIE_EXT_ECAM4_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PCIE_EXT_ECAM4_BAR_LOW_RSRVD_SHIFT 6
+/* Reserved */
+#define PBS_UNIT_PCIE_EXT_ECAM4_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PCIE_EXT_ECAM4_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pcie_ext_ecam5_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_PCIE_EXT_ECAM5_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_PCIE_EXT_ECAM5_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_PCIE_EXT_ECAM5_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_PCIE_EXT_ECAM5_BAR_LOW_RSRVD_SHIFT 6
+/* Reserved */
+#define PBS_UNIT_PCIE_EXT_ECAM5_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_PCIE_EXT_ECAM5_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** low_latency_sram_bar_low register ****/
+/* Window size = 2 ^ (15 + win_size). Zero value: disable the window. */
+#define PBS_UNIT_LOW_LATENCY_SRAM_BAR_LOW_WIN_SIZE_MASK 0x0000003F
+#define PBS_UNIT_LOW_LATENCY_SRAM_BAR_LOW_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_UNIT_LOW_LATENCY_SRAM_BAR_LOW_RSRVD_MASK 0x0000FFC0
+#define PBS_UNIT_LOW_LATENCY_SRAM_BAR_LOW_RSRVD_SHIFT 6
+/* Reserved */
+#define PBS_UNIT_LOW_LATENCY_SRAM_BAR_LOW_ADDR_HIGH_MASK 0xFFFF0000
+#define PBS_UNIT_LOW_LATENCY_SRAM_BAR_LOW_ADDR_HIGH_SHIFT 16
+
+/**** pbs_sb2nb_cfg_dram_remap register ****/
+#define PBS_UNIT_SB2NB_REMAP_BASE_ADDR_SHIFT 5
+#define PBS_UNIT_SB2NB_REMAP_BASE_ADDR_MASK 0x0000FFE0
+#define PBS_UNIT_SB2NB_REMAP_TRANSL_BASE_ADDR_SHIFT 21
+#define PBS_UNIT_SB2NB_REMAP_TRANSL_BASE_ADDR_MASK 0xFFE00000
+
+/* For remapping are used bits [39 - 29] of DRAM 40bit Physical address */
+#define PBS_UNIT_DRAM_SRC_REMAP_BASE_ADDR_SHIFT 29
+#define PBS_UNIT_DRAM_DST_REMAP_BASE_ADDR_SHIFT 29
+#define PBS_UNIT_DRAM_REMAP_BASE_ADDR_MASK 0xFFE0000000UL
+
+
+/**** serdes_mux_eth register ****/
+/*
+ * 2'b01 - eth_a[0] from serdes_8
+ * 2'b10 - eth_a[0] from serdes_14
+ */
+#define PBS_UNIT_SERDES_MUX_ETH_PKR_SELECT_OH_ETH_A_0_MASK 0x00000003
+#define PBS_UNIT_SERDES_MUX_ETH_PKR_SELECT_OH_ETH_A_0_SHIFT 0
+/*
+ * 2'b01 - eth_b[0] from serdes_9
+ * 2'b10 - eth_b[0] from serdes_13
+ */
+#define PBS_UNIT_SERDES_MUX_ETH_PKR_SELECT_OH_ETH_B_0_MASK 0x00000030
+#define PBS_UNIT_SERDES_MUX_ETH_PKR_SELECT_OH_ETH_B_0_SHIFT 4
+/*
+ * 2'b01 - eth_c[0] from serdes_10
+ * 2'b10 - eth_c[0] from serdes_12
+ */
+#define PBS_UNIT_SERDES_MUX_ETH_PKR_SELECT_OH_ETH_C_0_MASK 0x00000300
+#define PBS_UNIT_SERDES_MUX_ETH_PKR_SELECT_OH_ETH_C_0_SHIFT 8
+/*
+ * 2'b01 - eth_d[0] from serdes_11
+ * 2'b10 - eth_d[0] from serdes_15
+ */
+#define PBS_UNIT_SERDES_MUX_ETH_PKR_SELECT_OH_ETH_D_0_MASK 0x00003000
+#define PBS_UNIT_SERDES_MUX_ETH_PKR_SELECT_OH_ETH_D_0_SHIFT 12
+/* which lane's is master clk */
+#define PBS_UNIT_SERDES_MUX_ETH_PKR_SELECT_OH_ETH_A_ICK_MASTER_MASK 0x00030000
+#define PBS_UNIT_SERDES_MUX_ETH_PKR_SELECT_OH_ETH_A_ICK_MASTER_SHIFT 16
+/* which lane's is master clk */
+#define PBS_UNIT_SERDES_MUX_ETH_PKR_SELECT_OH_ETH_C_ICK_MASTER_MASK 0x00300000
+#define PBS_UNIT_SERDES_MUX_ETH_PKR_SELECT_OH_ETH_C_ICK_MASTER_SHIFT 20
+/* enable xlaui on eth a */
+#define PBS_UNIT_SERDES_MUX_ETH_PKR_SELECT_OH_ETH_A_XLAUI_ENABLE (1 << 24)
+/* enable xlaui on eth c */
+#define PBS_UNIT_SERDES_MUX_ETH_PKR_SELECT_OH_ETH_C_XLAUI_ENABLE (1 << 28)
+
+/**** serdes_mux_pcie register ****/
+/*
+ * 2'b01 - select pcie_b[0] from serdes 2
+ * 2'b10 - select pcie_b[0] from serdes 4
+ */
+#define PBS_UNIT_SERDES_MUX_PCIE_PKR_SELECT_OH_PCIE_B_0_MASK 0x00000003
+#define PBS_UNIT_SERDES_MUX_PCIE_PKR_SELECT_OH_PCIE_B_0_SHIFT 0
+/*
+ * 2'b01 - select pcie_b[1] from serdes 3
+ * 2'b10 - select pcie_b[1] from serdes 5
+ */
+#define PBS_UNIT_SERDES_MUX_PCIE_PKR_SELECT_OH_PCIE_B_1_MASK 0x00000030
+#define PBS_UNIT_SERDES_MUX_PCIE_PKR_SELECT_OH_PCIE_B_1_SHIFT 4
+/*
+ * 2'b01 - select pcie_d[0] from serdes 10
+ * 2'b10 - select pcie_d[0] from serdes 12
+ */
+#define PBS_UNIT_SERDES_MUX_PCIE_PKR_SELECT_OH_PCIE_D_0_MASK 0x00000300
+#define PBS_UNIT_SERDES_MUX_PCIE_PKR_SELECT_OH_PCIE_D_0_SHIFT 8
+/*
+ * 2'b01 - select pcie_d[1] from serdes 11
+ * 2'b10 - select pcie_d[1] from serdes 13
+ */
+#define PBS_UNIT_SERDES_MUX_PCIE_PKR_SELECT_OH_PCIE_D_1_MASK 0x00003000
+#define PBS_UNIT_SERDES_MUX_PCIE_PKR_SELECT_OH_PCIE_D_1_SHIFT 12
+
+/**** serdes_mux_sata register ****/
+/*
+ * 2'b01 - select sata_a from serdes group 1
+ * 2'b10 - select sata_a from serdes group 3
+ */
+#define PBS_UNIT_SERDES_MUX_SATA_SELECT_OH_SATA_A_MASK 0x00000003
+#define PBS_UNIT_SERDES_MUX_SATA_SELECT_OH_SATA_A_SHIFT 0
+/* Reserved */
+#define PBS_UNIT_SERDES_MUX_SATA_RESERVED_3_2_MASK 0x0000000C
+#define PBS_UNIT_SERDES_MUX_SATA_RESERVED_3_2_SHIFT 2
+/* Reserved */
+#define PBS_UNIT_SERDES_MUX_SATA_RESERVED_MASK 0xFFFFFFF0
+#define PBS_UNIT_SERDES_MUX_SATA_RESERVED_SHIFT 4
+
+/**** bar1_orig register ****/
+/*
+ * Window size = 2 ^ (11 + win_size).
+ * Zero value: disable the window.
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR1_ORIG_WIN_SIZE_MASK 0x00000007
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR1_ORIG_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR1_ORIG_RSRVD_MASK 0x00000FF8
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR1_ORIG_RSRVD_SHIFT 3
+/*
+ * offset within the SRAM, in resolution of 4KB.
+ * Only offsets which are inside the boundaries of the SRAM bar are allowed
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR1_ORIG_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR1_ORIG_ADDR_HIGH_SHIFT 12
+
+/**** bar1_remap register ****/
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR1_REMAP_RSRVD_MASK 0x00000FFF
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR1_REMAP_RSRVD_SHIFT 0
+/* remapped address */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR1_REMAP_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR1_REMAP_ADDR_HIGH_SHIFT 12
+
+/**** bar2_orig register ****/
+/*
+ * Window size = 2 ^ (11 + win_size).
+ * Zero value: disable the window.
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR2_ORIG_WIN_SIZE_MASK 0x00000007
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR2_ORIG_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR2_ORIG_RSRVD_MASK 0x00000FF8
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR2_ORIG_RSRVD_SHIFT 3
+/*
+ * offset within the SRAM, in resolution of 4KB.
+ * Only offsets which are inside the boundaries of the SRAM bar are allowed
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR2_ORIG_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR2_ORIG_ADDR_HIGH_SHIFT 12
+
+/**** bar2_remap register ****/
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR2_REMAP_RSRVD_MASK 0x00000FFF
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR2_REMAP_RSRVD_SHIFT 0
+/* remapped address */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR2_REMAP_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR2_REMAP_ADDR_HIGH_SHIFT 12
+
+/**** bar3_orig register ****/
+/*
+ * Window size = 2 ^ (11 + win_size).
+ * Zero value: disable the window.
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR3_ORIG_WIN_SIZE_MASK 0x00000007
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR3_ORIG_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR3_ORIG_RSRVD_MASK 0x00000FF8
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR3_ORIG_RSRVD_SHIFT 3
+/*
+ * offset within the SRAM, in resolution of 4KB.
+ * Only offsets which are inside the boundaries of the SRAM bar are allowed
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR3_ORIG_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR3_ORIG_ADDR_HIGH_SHIFT 12
+
+/**** bar3_remap register ****/
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR3_REMAP_RSRVD_MASK 0x00000FFF
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR3_REMAP_RSRVD_SHIFT 0
+/* remapped address */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR3_REMAP_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR3_REMAP_ADDR_HIGH_SHIFT 12
+
+/**** bar4_orig register ****/
+/*
+ * Window size = 2 ^ (11 + win_size).
+ * Zero value: disable the window.
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR4_ORIG_WIN_SIZE_MASK 0x00000007
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR4_ORIG_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR4_ORIG_RSRVD_MASK 0x00000FF8
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR4_ORIG_RSRVD_SHIFT 3
+/*
+ * offset within the SRAM, in resolution of 4KB.
+ * Only offsets which are inside the boundaries of the SRAM bar are allowed
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR4_ORIG_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR4_ORIG_ADDR_HIGH_SHIFT 12
+
+/**** bar4_remap register ****/
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR4_REMAP_RSRVD_MASK 0x00000FFF
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR4_REMAP_RSRVD_SHIFT 0
+/* remapped address */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR4_REMAP_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR4_REMAP_ADDR_HIGH_SHIFT 12
+
+/**** bar5_orig register ****/
+/*
+ * Window size = 2 ^ (11 + win_size).
+ * Zero value: disable the window.
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR5_ORIG_WIN_SIZE_MASK 0x00000007
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR5_ORIG_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR5_ORIG_RSRVD_MASK 0x00000FF8
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR5_ORIG_RSRVD_SHIFT 3
+/*
+ * offset within the SRAM, in resolution of 4KB.
+ * Only offsets which are inside the boundaries of the SRAM bar are allowed
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR5_ORIG_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR5_ORIG_ADDR_HIGH_SHIFT 12
+
+/**** bar5_remap register ****/
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR5_REMAP_RSRVD_MASK 0x00000FFF
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR5_REMAP_RSRVD_SHIFT 0
+/* remapped address */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR5_REMAP_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR5_REMAP_ADDR_HIGH_SHIFT 12
+
+/**** bar6_orig register ****/
+/*
+ * Window size = 2 ^ (11 + win_size).
+ * Zero value: disable the window.
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR6_ORIG_WIN_SIZE_MASK 0x00000007
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR6_ORIG_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR6_ORIG_RSRVD_MASK 0x00000FF8
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR6_ORIG_RSRVD_SHIFT 3
+/*
+ * offset within the SRAM, in resolution of 4KB.
+ * Only offsets which are inside the boundaries of the SRAM bar are allowed
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR6_ORIG_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR6_ORIG_ADDR_HIGH_SHIFT 12
+
+/**** bar6_remap register ****/
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR6_REMAP_RSRVD_MASK 0x00000FFF
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR6_REMAP_RSRVD_SHIFT 0
+/* remapped address */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR6_REMAP_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR6_REMAP_ADDR_HIGH_SHIFT 12
+
+/**** bar7_orig register ****/
+/*
+ * Window size = 2 ^ (11 + win_size).
+ * Zero value: disable the window.
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR7_ORIG_WIN_SIZE_MASK 0x00000007
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR7_ORIG_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR7_ORIG_RSRVD_MASK 0x00000FF8
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR7_ORIG_RSRVD_SHIFT 3
+/*
+ * offset within the SRAM, in resolution of 4KB.
+ * Only offsets which are inside the boundaries of the SRAM bar are allowed
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR7_ORIG_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR7_ORIG_ADDR_HIGH_SHIFT 12
+
+/**** bar7_remap register ****/
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR7_REMAP_RSRVD_MASK 0x00000FFF
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR7_REMAP_RSRVD_SHIFT 0
+/* remapped address */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR7_REMAP_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR7_REMAP_ADDR_HIGH_SHIFT 12
+
+/**** bar8_orig register ****/
+/*
+ * Window size = 2 ^ (11 + win_size).
+ * Zero value: disable the window.
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR8_ORIG_WIN_SIZE_MASK 0x00000007
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR8_ORIG_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR8_ORIG_RSRVD_MASK 0x00000FF8
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR8_ORIG_RSRVD_SHIFT 3
+/*
+ * offset within the SRAM, in resolution of 4KB.
+ * Only offsets which are inside the boundaries of the SRAM bar are allowed
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR8_ORIG_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR8_ORIG_ADDR_HIGH_SHIFT 12
+
+/**** bar8_remap register ****/
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR8_REMAP_RSRVD_MASK 0x00000FFF
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR8_REMAP_RSRVD_SHIFT 0
+/* remapped address */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR8_REMAP_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR8_REMAP_ADDR_HIGH_SHIFT 12
+
+/**** bar9_orig register ****/
+/*
+ * Window size = 2 ^ (11 + win_size).
+ * Zero value: disable the window.
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR9_ORIG_WIN_SIZE_MASK 0x00000007
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR9_ORIG_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR9_ORIG_RSRVD_MASK 0x00000FF8
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR9_ORIG_RSRVD_SHIFT 3
+/*
+ * offset within the SRAM, in resolution of 4KB.
+ * Only offsets which are inside the boundaries of the SRAM bar are allowed
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR9_ORIG_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR9_ORIG_ADDR_HIGH_SHIFT 12
+
+/**** bar9_remap register ****/
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR9_REMAP_RSRVD_MASK 0x00000FFF
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR9_REMAP_RSRVD_SHIFT 0
+/* remapped address */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR9_REMAP_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR9_REMAP_ADDR_HIGH_SHIFT 12
+
+/**** bar10_orig register ****/
+/*
+ * Window size = 2 ^ (11 + win_size).
+ * Zero value: disable the window.
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR10_ORIG_WIN_SIZE_MASK 0x00000007
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR10_ORIG_WIN_SIZE_SHIFT 0
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR10_ORIG_RSRVD_MASK 0x00000FF8
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR10_ORIG_RSRVD_SHIFT 3
+/*
+ * offset within the SRAM, in resolution of 4KB.
+ * Only offsets which are inside the boundaries of the SRAM bar are allowed
+ */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR10_ORIG_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR10_ORIG_ADDR_HIGH_SHIFT 12
+
+/**** bar10_remap register ****/
+/* Reserved fields */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR10_REMAP_RSRVD_MASK 0x00000FFF
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR10_REMAP_RSRVD_SHIFT 0
+/* remapped address */
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR10_REMAP_ADDR_HIGH_MASK 0xFFFFF000
+#define PBS_LOW_LATENCY_SRAM_REMAP_BAR10_REMAP_ADDR_HIGH_SHIFT 12
+
+/**** cpu register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_DRAM_SHIFT 28
+
+/**** cpu_mask register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_MASK_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_MASK_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_MASK_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_MASK_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_MASK_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_MASK_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_MASK_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_MASK_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_MASK_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_MASK_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_MASK_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_MASK_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_MASK_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_MASK_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_MASK_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_CPU_MASK_DRAM_SHIFT 28
+
+/**** debug_nb register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_DRAM_SHIFT 28
+
+/**** debug_nb_mask register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_MASK_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_MASK_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_MASK_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_MASK_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_MASK_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_MASK_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_MASK_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_MASK_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_MASK_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_MASK_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_MASK_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_MASK_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_MASK_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_MASK_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_MASK_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_NB_MASK_DRAM_SHIFT 28
+
+/**** debug_sb register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_DRAM_SHIFT 28
+
+/**** debug_sb_mask register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_MASK_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_MASK_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_MASK_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_MASK_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_MASK_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_MASK_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_MASK_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_MASK_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_MASK_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_MASK_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_MASK_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_MASK_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_MASK_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_MASK_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_MASK_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_DEBUG_SB_MASK_DRAM_SHIFT 28
+
+/**** eth_0 register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_DRAM_SHIFT 28
+
+/**** eth_0_mask register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_MASK_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_MASK_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_MASK_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_MASK_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_MASK_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_MASK_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_MASK_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_MASK_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_MASK_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_MASK_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_MASK_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_MASK_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_MASK_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_MASK_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_MASK_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_0_MASK_DRAM_SHIFT 28
+
+/**** eth_1 register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_DRAM_SHIFT 28
+
+/**** eth_1_mask register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_MASK_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_MASK_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_MASK_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_MASK_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_MASK_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_MASK_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_MASK_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_MASK_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_MASK_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_MASK_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_MASK_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_MASK_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_MASK_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_MASK_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_MASK_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_1_MASK_DRAM_SHIFT 28
+
+/**** eth_2 register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_DRAM_SHIFT 28
+
+/**** eth_2_mask register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_MASK_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_MASK_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_MASK_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_MASK_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_MASK_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_MASK_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_MASK_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_MASK_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_MASK_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_MASK_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_MASK_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_MASK_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_MASK_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_MASK_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_MASK_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_2_MASK_DRAM_SHIFT 28
+
+/**** eth_3 register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_DRAM_SHIFT 28
+
+/**** eth_3_mask register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_MASK_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_MASK_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_MASK_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_MASK_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_MASK_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_MASK_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_MASK_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_MASK_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_MASK_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_MASK_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_MASK_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_MASK_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_MASK_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_MASK_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_MASK_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_ETH_3_MASK_DRAM_SHIFT 28
+
+/**** sata_0 register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_DRAM_SHIFT 28
+
+/**** sata_0_mask register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_MASK_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_MASK_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_MASK_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_MASK_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_MASK_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_MASK_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_MASK_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_MASK_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_MASK_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_MASK_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_MASK_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_MASK_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_MASK_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_MASK_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_MASK_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_0_MASK_DRAM_SHIFT 28
+
+/**** sata_1 register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_DRAM_SHIFT 28
+
+/**** sata_1_mask register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_MASK_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_MASK_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_MASK_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_MASK_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_MASK_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_MASK_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_MASK_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_MASK_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_MASK_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_MASK_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_MASK_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_MASK_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_MASK_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_MASK_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_MASK_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_SATA_1_MASK_DRAM_SHIFT 28
+
+/**** crypto_0 register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_DRAM_SHIFT 28
+
+/**** crypto_0_mask register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_MASK_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_MASK_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_MASK_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_MASK_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_MASK_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_MASK_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_MASK_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_MASK_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_MASK_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_MASK_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_MASK_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_MASK_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_MASK_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_MASK_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_MASK_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_0_MASK_DRAM_SHIFT 28
+
+/**** crypto_1 register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_DRAM_SHIFT 28
+
+/**** crypto_1_mask register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_MASK_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_MASK_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_MASK_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_MASK_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_MASK_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_MASK_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_MASK_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_MASK_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_MASK_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_MASK_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_MASK_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_MASK_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_MASK_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_MASK_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_MASK_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_CRYPTO_1_MASK_DRAM_SHIFT 28
+
+/**** pcie_0 register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_DRAM_SHIFT 28
+
+/**** pcie_0_mask register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_MASK_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_MASK_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_MASK_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_MASK_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_MASK_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_MASK_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_MASK_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_MASK_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_MASK_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_MASK_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_MASK_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_MASK_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_MASK_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_MASK_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_MASK_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_0_MASK_DRAM_SHIFT 28
+
+/**** pcie_1 register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_DRAM_SHIFT 28
+
+/**** pcie_1_mask register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_MASK_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_MASK_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_MASK_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_MASK_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_MASK_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_MASK_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_MASK_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_MASK_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_MASK_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_MASK_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_MASK_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_MASK_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_MASK_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_MASK_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_MASK_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_1_MASK_DRAM_SHIFT 28
+
+/**** pcie_2 register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_DRAM_SHIFT 28
+
+/**** pcie_2_mask register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_MASK_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_MASK_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_MASK_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_MASK_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_MASK_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_MASK_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_MASK_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_MASK_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_MASK_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_MASK_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_MASK_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_MASK_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_MASK_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_MASK_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_MASK_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_2_MASK_DRAM_SHIFT 28
+
+/**** pcie_3 register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_DRAM_SHIFT 28
+
+/**** pcie_3_mask register ****/
+/* map transactions according to address decoding */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_MASK_NO_ENFORCEMENT_MASK 0x0000000F
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_MASK_NO_ENFORCEMENT_SHIFT 0
+/* map transactions to pcie_0 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_MASK_PCIE_0_MASK 0x000000F0
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_MASK_PCIE_0_SHIFT 4
+/* map transactions to pcie_1 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_MASK_PCIE_1_MASK 0x00000F00
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_MASK_PCIE_1_SHIFT 8
+/* map transactions to pcie_2 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_MASK_PCIE_2_MASK 0x0000F000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_MASK_PCIE_2_SHIFT 12
+/* map transactions to pcie_3 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_MASK_PCIE_3_MASK 0x000F0000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_MASK_PCIE_3_SHIFT 16
+/* map transactions to pcie_4 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_MASK_PCIE_4_MASK 0x00F00000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_MASK_PCIE_4_SHIFT 20
+/* map transactions to pcie_5 */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_MASK_PCIE_5_MASK 0x0F000000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_MASK_PCIE_5_SHIFT 24
+/* map transactions to dram */
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_MASK_DRAM_MASK 0xF0000000
+#define PBS_TARGET_ID_ENFORCEMENT_PCIE_3_MASK_DRAM_SHIFT 28
+
+/**** latch register ****/
+/*
+ * Software clears this bit before any bar update, and set it after all bars
+ * updated.
+ */
+#define PBS_TARGET_ID_ENFORCEMENT_LATCH_ENABLE (1 << 0)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __AL_HAL_PBS_REGS_H__ */
+
+/** @} end of ... group */
+
+
diff --git a/sys/arm/annapurna/alpine/hal/al_hal_pcie.c b/sys/arm/annapurna/alpine/hal/al_hal_pcie.c
new file mode 100644
index 0000000..3a221d3
--- /dev/null
+++ b/sys/arm/annapurna/alpine/hal/al_hal_pcie.c
@@ -0,0 +1,2788 @@
+/*-
+********************************************************************************
+Copyright (C) 2015 Annapurna Labs Ltd.
+
+This file may be licensed under the terms of the Annapurna Labs Commercial
+License Agreement.
+
+Alternatively, this file can be distributed under the terms of the GNU General
+Public License V2 as published by the Free Software Foundation and can be
+found at http://www.gnu.org/licenses/gpl-2.0.html
+
+Alternatively, redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+notice, this 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 HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(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>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+
+#include "al_hal_pcie.h"
+#include "al_hal_pbs_regs.h"
+#include "al_hal_unit_adapter_regs.h"
+
+/**
+ * Parameter definitions
+ */
+#define AL_PCIE_AXI_REGS_OFFSET 0x0
+
+#define AL_PCIE_LTSSM_STATE_L0 0x11
+#define AL_PCIE_LTSSM_STATE_L0S 0x12
+#define AL_PCIE_DEVCTL_PAYLOAD_128B 0x00
+#define AL_PCIE_DEVCTL_PAYLOAD_256B 0x20
+
+#define AL_PCIE_SECBUS_DEFAULT 0x1
+#define AL_PCIE_SUBBUS_DEFAULT 0x1
+#define AL_PCIE_LINKUP_WAIT_INTERVAL 50 /* measured in usec */
+#define AL_PCIE_LINKUP_WAIT_INTERVALS_PER_SEC 20
+
+#define AL_PCIE_LINKUP_RETRIES 8
+
+#define AL_PCIE_MAX_32_MEMORY_BAR_SIZE (0x100000000ULL)
+#define AL_PCIE_MIN_MEMORY_BAR_SIZE (1 << 12)
+#define AL_PCIE_MIN_IO_BAR_SIZE (1 << 8)
+
+/**
+ * inbound header credits and outstanding outbound reads defaults
+ */
+/** RC - Revisions 1/2 */
+#define AL_PCIE_REV_1_2_RC_OB_OS_READS_DEFAULT (8)
+#define AL_PCIE_REV_1_2_RC_NOF_CPL_HDR_DEFAULT (41)
+#define AL_PCIE_REV_1_2_RC_NOF_NP_HDR_DEFAULT (25)
+#define AL_PCIE_REV_1_2_RC_NOF_P_HDR_DEFAULT (31)
+/** EP - Revisions 1/2 */
+#define AL_PCIE_REV_1_2_EP_OB_OS_READS_DEFAULT (15)
+#define AL_PCIE_REV_1_2_EP_NOF_CPL_HDR_DEFAULT (76)
+#define AL_PCIE_REV_1_2_EP_NOF_NP_HDR_DEFAULT (6)
+#define AL_PCIE_REV_1_2_EP_NOF_P_HDR_DEFAULT (15)
+/** RC - Revision 3 */
+#define AL_PCIE_REV_3_RC_OB_OS_READS_DEFAULT (32)
+#define AL_PCIE_REV_3_RC_NOF_CPL_HDR_DEFAULT (161)
+#define AL_PCIE_REV_3_RC_NOF_NP_HDR_DEFAULT (38)
+#define AL_PCIE_REV_3_RC_NOF_P_HDR_DEFAULT (60)
+/** EP - Revision 3 */
+#define AL_PCIE_REV_3_EP_OB_OS_READS_DEFAULT (32)
+#define AL_PCIE_REV_3_EP_NOF_CPL_HDR_DEFAULT (161)
+#define AL_PCIE_REV_3_EP_NOF_NP_HDR_DEFAULT (38)
+#define AL_PCIE_REV_3_EP_NOF_P_HDR_DEFAULT (60)
+
+/**
+ * MACROS
+ */
+#define AL_PCIE_PARSE_LANES(v) (((1 << v) - 1) << \
+ PCIE_REVX_AXI_MISC_PCIE_GLOBAL_CONF_NOF_ACT_LANES_SHIFT)
+
+/**
+ * Static functions
+ */
+static void
+al_pcie_port_wr_to_ro_set(struct al_pcie_port *pcie_port, al_bool enable)
+{
+ /* when disabling writes to RO, make sure any previous writes to
+ * config space were committed
+ */
+ if (enable == AL_FALSE)
+ al_local_data_memory_barrier();
+
+ al_reg_write32(&pcie_port->regs->port_regs->rd_only_wr_en,
+ (enable == AL_TRUE) ? 1 : 0);
+
+ /* when enabling writes to RO, make sure it is committed before trying
+ * to write to RO config space
+ */
+ if (enable == AL_TRUE)
+ al_local_data_memory_barrier();
+}
+
+/** helper function to access dbi_cs2 registers */
+static void
+al_reg_write32_dbi_cs2(
+ struct al_pcie_port *pcie_port,
+ uint32_t *offset,
+ uint32_t val)
+{
+ uintptr_t cs2_bit =
+ (pcie_port->rev_id == AL_PCIE_REV_ID_3) ? 0x4000 : 0x1000;
+
+ al_reg_write32((uint32_t *)((uintptr_t)offset | cs2_bit), val);
+}
+
+static unsigned int
+al_pcie_speed_gen_code(enum al_pcie_link_speed speed)
+{
+ if (speed == AL_PCIE_LINK_SPEED_GEN1)
+ return 1;
+ if (speed == AL_PCIE_LINK_SPEED_GEN2)
+ return 2;
+ if (speed == AL_PCIE_LINK_SPEED_GEN3)
+ return 3;
+ /* must not be reached */
+ return 0;
+}
+
+static inline void
+al_pcie_port_link_speed_ctrl_set(
+ struct al_pcie_port *pcie_port,
+ enum al_pcie_link_speed max_speed)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+
+ al_pcie_port_wr_to_ro_set(pcie_port, AL_TRUE);
+
+ if (max_speed != AL_PCIE_LINK_SPEED_DEFAULT) {
+ uint16_t max_speed_val = (uint16_t)al_pcie_speed_gen_code(max_speed);
+ al_reg_write32_masked(
+ (uint32_t __iomem *)(regs->core_space[0].pcie_link_cap_base),
+ 0xF, max_speed_val);
+ al_reg_write32_masked(
+ (uint32_t __iomem *)(regs->core_space[0].pcie_cap_base
+ + (AL_PCI_EXP_LNKCTL2 >> 2)),
+ 0xF, max_speed_val);
+ }
+
+ al_pcie_port_wr_to_ro_set(pcie_port, AL_FALSE);
+}
+
+static int
+al_pcie_port_link_config(
+ struct al_pcie_port *pcie_port,
+ const struct al_pcie_link_params *link_params)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ uint8_t max_lanes = pcie_port->max_lanes;
+
+ if ((link_params->max_payload_size != AL_PCIE_MPS_DEFAULT) &&
+ (link_params->max_payload_size != AL_PCIE_MPS_128) &&
+ (link_params->max_payload_size != AL_PCIE_MPS_256)) {
+ al_err("PCIe %d: unsupported Max Payload Size (%u)\n",
+ pcie_port->port_id, link_params->max_payload_size);
+ return -EINVAL;
+ }
+
+ al_dbg("PCIe %d: link config: max speed gen %d, max lanes %d, reversal %s\n",
+ pcie_port->port_id, link_params->max_speed,
+ pcie_port->max_lanes, link_params->enable_reversal? "enable" : "disable");
+
+ al_pcie_port_link_speed_ctrl_set(pcie_port, link_params->max_speed);
+
+ /* Change Max Payload Size, if needed.
+ * The Max Payload Size is only valid for PF0.
+ */
+ if (link_params->max_payload_size != AL_PCIE_MPS_DEFAULT)
+ al_reg_write32_masked(regs->core_space[0].pcie_dev_ctrl_status,
+ PCIE_PORT_DEV_CTRL_STATUS_MPS_MASK,
+ link_params->max_payload_size <<
+ PCIE_PORT_DEV_CTRL_STATUS_MPS_SHIFT);
+
+ /** Snap from PCIe core spec:
+ * Link Mode Enable. Sets the number of lanes in the link that you want
+ * to connect to the link partner. When you have unused lanes in your
+ * system, then you must change the value in this register to reflect
+ * the number of lanes. You must also change the value in the
+ * "Predetermined Number of Lanes" field of the "Link Width and Speed
+ * Change Control Register".
+ * 000001: x1
+ * 000011: x2
+ * 000111: x4
+ * 001111: x8
+ * 011111: x16
+ * 111111: x32 (not supported)
+ */
+ al_reg_write32_masked(&regs->port_regs->gen2_ctrl,
+ PCIE_PORT_GEN2_CTRL_NUM_OF_LANES_MASK,
+ max_lanes << PCIE_PORT_GEN2_CTRL_NUM_OF_LANES_SHIFT);
+ al_reg_write32_masked(&regs->port_regs->port_link_ctrl,
+ PCIE_PORT_LINK_CTRL_LINK_CAPABLE_MASK,
+ (max_lanes + (max_lanes-1))
+ << PCIE_PORT_LINK_CTRL_LINK_CAPABLE_SHIFT);
+
+ /* TODO: add support for reversal mode */
+ if (link_params->enable_reversal) {
+ al_err("PCIe %d: enabling reversal mode not implemented\n",
+ pcie_port->port_id);
+ return -ENOSYS;
+ }
+ return 0;
+}
+
+static void
+al_pcie_port_ram_parity_int_config(
+ struct al_pcie_port *pcie_port,
+ al_bool enable)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+
+ al_reg_write32(&regs->app.parity->en_core,
+ (enable == AL_TRUE) ? 0xffffffff : 0x0);
+
+ al_reg_write32_masked(&regs->app.int_grp_b->mask,
+ PCIE_W_INT_GRP_B_CAUSE_B_PARITY_ERROR_CORE,
+ (enable != AL_TRUE) ?
+ PCIE_W_INT_GRP_B_CAUSE_B_PARITY_ERROR_CORE : 0);
+
+}
+
+static void
+al_pcie_port_axi_parity_int_config(
+ struct al_pcie_port *pcie_port,
+ al_bool enable)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ uint32_t parity_enable_mask = 0xffffffff;
+
+ /**
+ * Addressing RMN: 5603
+ *
+ * RMN description:
+ * u4_ram2p signal false parity error
+ *
+ * Software flow:
+ * Disable parity check for this memory
+ */
+ if (pcie_port->rev_id >= AL_PCIE_REV_ID_3)
+ parity_enable_mask &= ~PCIE_AXI_PARITY_EN_AXI_U4_RAM2P;
+
+ al_reg_write32(regs->axi.parity.en_axi,
+ (enable == AL_TRUE) ? parity_enable_mask : 0x0);
+
+ if (pcie_port->rev_id == AL_PCIE_REV_ID_3) {
+ al_reg_write32_masked(regs->axi.ctrl.global,
+ PCIE_REV3_AXI_CTRL_GLOBAL_PARITY_CALC_EN_MSTR |
+ PCIE_REV3_AXI_CTRL_GLOBAL_PARITY_ERR_EN_RD |
+ PCIE_REV3_AXI_CTRL_GLOBAL_PARITY_CALC_EN_SLV |
+ PCIE_REV3_AXI_CTRL_GLOBAL_PARITY_ERR_EN_WR,
+ (enable == AL_TRUE) ?
+ PCIE_REV3_AXI_CTRL_GLOBAL_PARITY_CALC_EN_MSTR |
+ PCIE_REV3_AXI_CTRL_GLOBAL_PARITY_ERR_EN_RD |
+ PCIE_REV3_AXI_CTRL_GLOBAL_PARITY_CALC_EN_SLV |
+ PCIE_REV3_AXI_CTRL_GLOBAL_PARITY_ERR_EN_WR :
+ PCIE_REV3_AXI_CTRL_GLOBAL_PARITY_CALC_EN_SLV);
+ } else {
+ al_reg_write32_masked(regs->axi.ctrl.global,
+ PCIE_REV1_2_AXI_CTRL_GLOBAL_PARITY_CALC_EN_MSTR |
+ PCIE_REV1_2_AXI_CTRL_GLOBAL_PARITY_ERR_EN_RD |
+ PCIE_REV1_2_AXI_CTRL_GLOBAL_PARITY_CALC_EN_SLV |
+ PCIE_REV1_2_AXI_CTRL_GLOBAL_PARITY_ERR_EN_WR,
+ (enable == AL_TRUE) ?
+ PCIE_REV1_2_AXI_CTRL_GLOBAL_PARITY_CALC_EN_MSTR |
+ PCIE_REV1_2_AXI_CTRL_GLOBAL_PARITY_ERR_EN_RD |
+ PCIE_REV1_2_AXI_CTRL_GLOBAL_PARITY_CALC_EN_SLV |
+ PCIE_REV1_2_AXI_CTRL_GLOBAL_PARITY_ERR_EN_WR :
+ PCIE_REV1_2_AXI_CTRL_GLOBAL_PARITY_CALC_EN_SLV);
+ }
+
+ al_reg_write32_masked(&regs->axi.int_grp_a->mask,
+ PCIE_AXI_INT_GRP_A_CAUSE_PARITY_ERR_DATA_PATH_RD |
+ PCIE_AXI_INT_GRP_A_CAUSE_PARITY_ERR_OUT_ADDR_RD |
+ PCIE_AXI_INT_GRP_A_CAUSE_PARITY_ERR_OUT_ADDR_WR |
+ PCIE_AXI_INT_GRP_A_CAUSE_PARITY_ERR_OUT_DATA_WR |
+ PCIE_AXI_INT_GRP_A_CAUSE_PARITY_ERROR_AXI,
+ (enable != AL_TRUE) ?
+ (PCIE_AXI_INT_GRP_A_CAUSE_PARITY_ERR_DATA_PATH_RD |
+ PCIE_AXI_INT_GRP_A_CAUSE_PARITY_ERR_OUT_ADDR_RD |
+ PCIE_AXI_INT_GRP_A_CAUSE_PARITY_ERR_OUT_ADDR_WR |
+ PCIE_AXI_INT_GRP_A_CAUSE_PARITY_ERR_OUT_DATA_WR |
+ PCIE_AXI_INT_GRP_A_CAUSE_PARITY_ERROR_AXI) : 0);
+}
+
+static void
+al_pcie_port_relaxed_pcie_ordering_config(
+ struct al_pcie_port *pcie_port,
+ struct al_pcie_relaxed_ordering_params *relaxed_ordering_params)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ enum al_pcie_operating_mode op_mode = al_pcie_operating_mode_get(pcie_port);
+ /**
+ * Default:
+ * - RC: Rx relaxed ordering only
+ * - EP: TX relaxed ordering only
+ */
+ al_bool tx_relaxed_ordering = (op_mode == AL_PCIE_OPERATING_MODE_RC ? AL_FALSE : AL_TRUE);
+ al_bool rx_relaxed_ordering = (op_mode == AL_PCIE_OPERATING_MODE_RC ? AL_TRUE : AL_FALSE);
+
+ if (relaxed_ordering_params) {
+ tx_relaxed_ordering = relaxed_ordering_params->enable_tx_relaxed_ordering;
+ rx_relaxed_ordering = relaxed_ordering_params->enable_rx_relaxed_ordering;
+ }
+
+ /** PCIe ordering:
+ * - disable outbound completion must be stalled behind outbound write
+ * ordering rule enforcement is disabled for root-port
+ * - disables read completion on the master port push slave writes for end-point
+ */
+ al_reg_write32_masked(
+ regs->axi.ordering.pos_cntl,
+ PCIE_AXI_POS_ORDER_BYPASS_CMPL_AFTER_WR_FIX |
+ PCIE_AXI_POS_ORDER_EP_CMPL_AFTER_WR_DIS |
+ PCIE_AXI_POS_ORDER_EP_CMPL_AFTER_WR_SUPPORT_INTERLV_DIS |
+ PCIE_AXI_POS_ORDER_SEGMENT_BUFFER_DONT_WAIT_FOR_P_WRITES,
+ (tx_relaxed_ordering ?
+ (PCIE_AXI_POS_ORDER_BYPASS_CMPL_AFTER_WR_FIX |
+ PCIE_AXI_POS_ORDER_SEGMENT_BUFFER_DONT_WAIT_FOR_P_WRITES) : 0) |
+ (rx_relaxed_ordering ?
+ (PCIE_AXI_POS_ORDER_EP_CMPL_AFTER_WR_DIS |
+ PCIE_AXI_POS_ORDER_EP_CMPL_AFTER_WR_SUPPORT_INTERLV_DIS) : 0));
+}
+
+static int
+al_pcie_rev_id_get(
+ void __iomem *pbs_reg_base,
+ void __iomem *pcie_reg_base)
+{
+ uint32_t chip_id;
+ uint16_t chip_id_dev;
+ uint8_t rev_id;
+ struct al_pbs_regs *pbs_regs = pbs_reg_base;
+
+ /* get revision ID from PBS' chip_id register */
+ chip_id = al_reg_read32(&pbs_regs->unit.chip_id);
+ chip_id_dev = AL_REG_FIELD_GET(chip_id,
+ PBS_UNIT_CHIP_ID_DEV_ID_MASK,
+ PBS_UNIT_CHIP_ID_DEV_ID_SHIFT);
+
+ if (chip_id_dev == PBS_UNIT_CHIP_ID_DEV_ID_ALPINE) {
+ rev_id = AL_REG_FIELD_GET(
+ chip_id,
+ PBS_UNIT_CHIP_ID_DEV_REV_ID_MASK,
+ PBS_UNIT_CHIP_ID_DEV_REV_ID_SHIFT);
+ } else if (chip_id_dev == PBS_UNIT_CHIP_ID_DEV_ID_PEAKROCK) {
+ struct al_pcie_revx_regs __iomem *regs =
+ (struct al_pcie_revx_regs __iomem *)pcie_reg_base;
+ uint32_t dev_id;
+
+ dev_id = al_reg_read32(&regs->axi.device_id.device_rev_id) &
+ PCIE_AXI_DEVICE_ID_REG_DEV_ID_MASK;
+ if (dev_id == PCIE_AXI_DEVICE_ID_REG_DEV_ID_X4) {
+ rev_id = AL_PCIE_REV_ID_2;
+ } else if (dev_id == PCIE_AXI_DEVICE_ID_REG_DEV_ID_X8) {
+ rev_id = AL_PCIE_REV_ID_3;
+ } else {
+ al_warn("%s: Revision ID is unknown\n",
+ __func__);
+ return -EINVAL;
+ }
+ } else {
+ al_warn("%s: Revision ID is unknown\n",
+ __func__);
+ return -EINVAL;
+ }
+ return rev_id;
+}
+
+static int
+al_pcie_port_lat_rply_timers_config(
+ struct al_pcie_port *pcie_port,
+ const struct al_pcie_latency_replay_timers *lat_rply_timers)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ uint32_t reg = 0;
+
+ AL_REG_FIELD_SET(reg, 0xFFFF, 0, lat_rply_timers->round_trip_lat_limit);
+ AL_REG_FIELD_SET(reg, 0xFFFF0000, 16, lat_rply_timers->replay_timer_limit);
+
+ al_reg_write32(&regs->port_regs->ack_lat_rply_timer, reg);
+ return 0;
+}
+
+static void
+al_pcie_ib_hcrd_os_ob_reads_config_default(
+ struct al_pcie_port *pcie_port)
+{
+
+ struct al_pcie_ib_hcrd_os_ob_reads_config ib_hcrd_os_ob_reads_config;
+
+ switch (al_pcie_operating_mode_get(pcie_port)) {
+ case AL_PCIE_OPERATING_MODE_RC:
+ if (pcie_port->rev_id == AL_PCIE_REV_ID_3) {
+ ib_hcrd_os_ob_reads_config.nof_outstanding_ob_reads =
+ AL_PCIE_REV_3_RC_OB_OS_READS_DEFAULT;
+ ib_hcrd_os_ob_reads_config.nof_cpl_hdr =
+ AL_PCIE_REV_3_RC_NOF_CPL_HDR_DEFAULT;
+ ib_hcrd_os_ob_reads_config.nof_np_hdr =
+ AL_PCIE_REV_3_RC_NOF_NP_HDR_DEFAULT;
+ ib_hcrd_os_ob_reads_config.nof_p_hdr =
+ AL_PCIE_REV_3_RC_NOF_P_HDR_DEFAULT;
+ } else {
+ ib_hcrd_os_ob_reads_config.nof_outstanding_ob_reads =
+ AL_PCIE_REV_1_2_RC_OB_OS_READS_DEFAULT;
+ ib_hcrd_os_ob_reads_config.nof_cpl_hdr =
+ AL_PCIE_REV_1_2_RC_NOF_CPL_HDR_DEFAULT;
+ ib_hcrd_os_ob_reads_config.nof_np_hdr =
+ AL_PCIE_REV_1_2_RC_NOF_NP_HDR_DEFAULT;
+ ib_hcrd_os_ob_reads_config.nof_p_hdr =
+ AL_PCIE_REV_1_2_RC_NOF_P_HDR_DEFAULT;
+ }
+ break;
+
+ case AL_PCIE_OPERATING_MODE_EP:
+ if (pcie_port->rev_id == AL_PCIE_REV_ID_3) {
+ ib_hcrd_os_ob_reads_config.nof_outstanding_ob_reads =
+ AL_PCIE_REV_3_EP_OB_OS_READS_DEFAULT;
+ ib_hcrd_os_ob_reads_config.nof_cpl_hdr =
+ AL_PCIE_REV_3_EP_NOF_CPL_HDR_DEFAULT;
+ ib_hcrd_os_ob_reads_config.nof_np_hdr =
+ AL_PCIE_REV_3_EP_NOF_NP_HDR_DEFAULT;
+ ib_hcrd_os_ob_reads_config.nof_p_hdr =
+ AL_PCIE_REV_3_EP_NOF_P_HDR_DEFAULT;
+ } else {
+ ib_hcrd_os_ob_reads_config.nof_outstanding_ob_reads =
+ AL_PCIE_REV_1_2_EP_OB_OS_READS_DEFAULT;
+ ib_hcrd_os_ob_reads_config.nof_cpl_hdr =
+ AL_PCIE_REV_1_2_EP_NOF_CPL_HDR_DEFAULT;
+ ib_hcrd_os_ob_reads_config.nof_np_hdr =
+ AL_PCIE_REV_1_2_EP_NOF_NP_HDR_DEFAULT;
+ ib_hcrd_os_ob_reads_config.nof_p_hdr =
+ AL_PCIE_REV_1_2_EP_NOF_P_HDR_DEFAULT;
+ }
+ break;
+
+ default:
+ al_err("PCIe %d: outstanding outbound transactions could not be configured - unknown operating mode\n",
+ pcie_port->port_id);
+ al_assert(0);
+ }
+
+ al_pcie_port_ib_hcrd_os_ob_reads_config(pcie_port, &ib_hcrd_os_ob_reads_config);
+};
+
+/** return AL_TRUE is link started (LTSSM enabled) and AL_FALSE otherwise */
+static al_bool
+al_pcie_is_link_started(struct al_pcie_port *pcie_port)
+{
+ struct al_pcie_regs *regs = (struct al_pcie_regs *)pcie_port->regs;
+
+ uint32_t port_init = al_reg_read32(regs->app.global_ctrl.port_init);
+ uint8_t ltssm_en = AL_REG_FIELD_GET(port_init,
+ PCIE_W_GLOBAL_CTRL_PORT_INIT_APP_LTSSM_EN_MASK,
+ PCIE_W_GLOBAL_CTRL_PORT_INIT_APP_LTSSM_EN_SHIFT);
+
+ return ltssm_en;
+}
+
+/** return AL_TRUE if link is up, AL_FALSE otherwise */
+static al_bool
+al_pcie_check_link(
+ struct al_pcie_port *pcie_port,
+ uint8_t *ltssm_ret)
+{
+ struct al_pcie_regs *regs = (struct al_pcie_regs *)pcie_port->regs;
+ uint32_t info_0;
+ uint8_t ltssm_state;
+
+ info_0 = al_reg_read32(&regs->app.debug->info_0);
+
+ ltssm_state = AL_REG_FIELD_GET(info_0,
+ PCIE_W_DEBUG_INFO_0_LTSSM_STATE_MASK,
+ PCIE_W_DEBUG_INFO_0_LTSSM_STATE_SHIFT);
+
+ al_dbg("PCIe %d: Port Debug 0: 0x%08x. LTSSM state :0x%x\n",
+ pcie_port->port_id, info_0, ltssm_state);
+
+ if (ltssm_ret)
+ *ltssm_ret = ltssm_state;
+
+ if ((ltssm_state == AL_PCIE_LTSSM_STATE_L0) ||
+ (ltssm_state == AL_PCIE_LTSSM_STATE_L0S))
+ return AL_TRUE;
+ return AL_FALSE;
+}
+
+static int
+al_pcie_port_gen2_params_config(struct al_pcie_port *pcie_port,
+ const struct al_pcie_gen2_params *gen2_params)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ uint32_t gen2_ctrl;
+
+ al_dbg("PCIe %d: Gen2 params config: Tx Swing %s, interrupt on link Eq %s, set Deemphasis %s\n",
+ pcie_port->port_id,
+ gen2_params->tx_swing_low ? "Low" : "Full",
+ gen2_params->tx_compliance_receive_enable? "enable" : "disable",
+ gen2_params->set_deemphasis? "enable" : "disable");
+
+ gen2_ctrl = al_reg_read32(&regs->port_regs->gen2_ctrl);
+
+ if (gen2_params->tx_swing_low)
+ AL_REG_BIT_SET(gen2_ctrl, PCIE_PORT_GEN2_CTRL_TX_SWING_LOW_SHIFT);
+ else
+ AL_REG_BIT_CLEAR(gen2_ctrl, PCIE_PORT_GEN2_CTRL_TX_SWING_LOW_SHIFT);
+
+ if (gen2_params->tx_compliance_receive_enable)
+ AL_REG_BIT_SET(gen2_ctrl, PCIE_PORT_GEN2_CTRL_TX_COMPLIANCE_RCV_SHIFT);
+ else
+ AL_REG_BIT_CLEAR(gen2_ctrl, PCIE_PORT_GEN2_CTRL_TX_COMPLIANCE_RCV_SHIFT);
+
+ if (gen2_params->set_deemphasis)
+ AL_REG_BIT_SET(gen2_ctrl, PCIE_PORT_GEN2_CTRL_DEEMPHASIS_SET_SHIFT);
+ else
+ AL_REG_BIT_CLEAR(gen2_ctrl, PCIE_PORT_GEN2_CTRL_DEEMPHASIS_SET_SHIFT);
+
+ al_reg_write32(&regs->port_regs->gen2_ctrl, gen2_ctrl);
+
+ return 0;
+}
+
+
+static uint16_t
+gen3_lane_eq_param_to_val(const struct al_pcie_gen3_lane_eq_params *eq_params)
+{
+ uint16_t eq_control = 0;
+
+ eq_control = eq_params->downstream_port_transmitter_preset & 0xF;
+ eq_control |= (eq_params->downstream_port_receiver_preset_hint & 0x7) << 4;
+ eq_control |= (eq_params->upstream_port_transmitter_preset & 0xF) << 8;
+ eq_control |= (eq_params->upstream_port_receiver_preset_hint & 0x7) << 12;
+
+ return eq_control;
+}
+
+static int
+al_pcie_port_gen3_params_config(struct al_pcie_port *pcie_port,
+ const struct al_pcie_gen3_params *gen3_params)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ uint32_t reg = 0;
+ uint16_t __iomem *lanes_eq_base = (uint16_t __iomem *)(regs->core_space[0].pcie_sec_ext_cap_base + (0xC >> 2));
+ int i;
+
+ al_dbg("PCIe %d: Gen3 params config: Equalization %s, interrupt on link Eq %s\n",
+ pcie_port->port_id,
+ gen3_params->perform_eq ? "enable" : "disable",
+ gen3_params->interrupt_enable_on_link_eq_request? "enable" : "disable");
+
+ if (gen3_params->perform_eq)
+ AL_REG_BIT_SET(reg, 0);
+ if (gen3_params->interrupt_enable_on_link_eq_request)
+ AL_REG_BIT_SET(reg, 1);
+
+ al_reg_write32(regs->core_space[0].pcie_sec_ext_cap_base + (4 >> 2),
+ reg);
+
+ al_pcie_port_wr_to_ro_set(pcie_port, AL_TRUE);
+
+ for (i = 0; i < gen3_params->eq_params_elements; i += 2) {
+ uint32_t eq_control =
+ (uint32_t)gen3_lane_eq_param_to_val(gen3_params->eq_params + i) |
+ (uint32_t)gen3_lane_eq_param_to_val(gen3_params->eq_params + i + 1) << 16;
+
+ al_dbg("PCIe %d: Set EQ (0x%08x) for lane %d, %d\n", pcie_port->port_id, eq_control, i, i + 1);
+ al_reg_write32((uint32_t *)(lanes_eq_base + i), eq_control);
+ }
+
+ al_pcie_port_wr_to_ro_set(pcie_port, AL_FALSE);
+
+ reg = al_reg_read32(&regs->port_regs->gen3_ctrl);
+ if (gen3_params->eq_disable)
+ AL_REG_BIT_SET(reg, PCIE_PORT_GEN3_CTRL_EQ_DISABLE_SHIFT);
+ else
+ AL_REG_BIT_CLEAR(reg, PCIE_PORT_GEN3_CTRL_EQ_DISABLE_SHIFT);
+
+ if (gen3_params->eq_phase2_3_disable)
+ AL_REG_BIT_SET(reg, PCIE_PORT_GEN3_CTRL_EQ_PHASE_2_3_DISABLE_SHIFT);
+ else
+ AL_REG_BIT_CLEAR(reg, PCIE_PORT_GEN3_CTRL_EQ_PHASE_2_3_DISABLE_SHIFT);
+
+ al_reg_write32(&regs->port_regs->gen3_ctrl, reg);
+
+ reg = 0;
+ AL_REG_FIELD_SET(reg, PCIE_PORT_GEN3_EQ_LF_MASK,
+ PCIE_PORT_GEN3_EQ_LF_SHIFT,
+ gen3_params->local_lf);
+ AL_REG_FIELD_SET(reg, PCIE_PORT_GEN3_EQ_FS_MASK,
+ PCIE_PORT_GEN3_EQ_FS_SHIFT,
+ gen3_params->local_fs);
+
+ al_reg_write32(&regs->port_regs->gen3_eq_fs_lf, reg);
+
+ reg = 0;
+ AL_REG_FIELD_SET(reg, PCIE_AXI_MISC_ZERO_LANEX_PHY_MAC_LOCAL_LF_MASK,
+ PCIE_AXI_MISC_ZERO_LANEX_PHY_MAC_LOCAL_LF_SHIFT,
+ gen3_params->local_lf);
+ AL_REG_FIELD_SET(reg, PCIE_AXI_MISC_ZERO_LANEX_PHY_MAC_LOCAL_FS_MASK,
+ PCIE_AXI_MISC_ZERO_LANEX_PHY_MAC_LOCAL_FS_SHIFT,
+ gen3_params->local_fs);
+ al_reg_write32(regs->axi.conf.zero_lane0, reg);
+ al_reg_write32(regs->axi.conf.zero_lane1, reg);
+ al_reg_write32(regs->axi.conf.zero_lane2, reg);
+ al_reg_write32(regs->axi.conf.zero_lane3, reg);
+ if (pcie_port->rev_id == AL_PCIE_REV_ID_3) {
+ al_reg_write32(regs->axi.conf.zero_lane4, reg);
+ al_reg_write32(regs->axi.conf.zero_lane5, reg);
+ al_reg_write32(regs->axi.conf.zero_lane6, reg);
+ al_reg_write32(regs->axi.conf.zero_lane7, reg);
+ }
+
+ /*
+ * Gen3 EQ Control Register:
+ * - Preset Request Vector - request 9
+ * - Behavior After 24 ms Timeout (when optimal settings are not
+ * found): Recovery.Equalization.RcvrLock
+ * - Phase2_3 2 ms Timeout Disable
+ * - Feedback Mode - Figure Of Merit
+ */
+ reg = 0x00020031;
+ al_reg_write32(&regs->port_regs->gen3_eq_ctrl, reg);
+
+ return 0;
+}
+
+static int
+al_pcie_port_tl_credits_config(
+ struct al_pcie_port *pcie_port,
+ const struct al_pcie_tl_credits_params *tl_credits __attribute__((__unused__)))
+{
+ al_err("PCIe %d: transport layer credits config not implemented\n",
+ pcie_port->port_id);
+
+ return -ENOSYS;
+
+}
+
+static int
+al_pcie_port_pf_params_config(struct al_pcie_pf *pcie_pf,
+ const struct al_pcie_pf_config_params *pf_params)
+{
+ struct al_pcie_port *pcie_port = pcie_pf->pcie_port;
+ struct al_pcie_regs *regs = pcie_port->regs;
+ unsigned int pf_num = pcie_pf->pf_num;
+ int bar_idx;
+ int ret;
+
+ al_pcie_port_wr_to_ro_set(pcie_port, AL_TRUE);
+
+ /* Disable D1 and D3hot capabilities */
+ if (pf_params->cap_d1_d3hot_dis)
+ al_reg_write32_masked(
+ regs->core_space[pf_num].pcie_pm_cap_base,
+ AL_FIELD_MASK(26, 25) | AL_FIELD_MASK(31, 28), 0);
+
+ /* Disable FLR capability */
+ if (pf_params->cap_flr_dis)
+ al_reg_write32_masked(
+ regs->core_space[pf_num].pcie_dev_cap_base,
+ AL_BIT(28), 0);
+
+ /* Disable ASPM capability */
+ if (pf_params->cap_aspm_dis) {
+ al_reg_write32_masked(
+ regs->core_space[pf_num].pcie_cap_base + (AL_PCI_EXP_LNKCAP >> 2),
+ AL_PCI_EXP_LNKCAP_ASPMS, 0);
+ } else if (pcie_port->rev_id == AL_PCIE_REV_ID_0) {
+ al_warn("%s: ASPM support is enabled, please disable it\n",
+ __func__);
+ ret = -EINVAL;
+ goto done;
+ }
+
+ if (!pf_params->bar_params_valid) {
+ ret = 0;
+ goto done;
+ }
+
+ for (bar_idx = 0; bar_idx < 6;){ /* bar_idx will be incremented depending on bar type */
+ const struct al_pcie_ep_bar_params *params = pf_params->bar_params + bar_idx;
+ uint32_t mask = 0;
+ uint32_t ctrl = 0;
+ uint32_t __iomem *bar_addr = &regs->core_space[pf_num].config_header[(AL_PCI_BASE_ADDRESS_0 >> 2) + bar_idx];
+
+ if (params->enable) {
+ uint64_t size = params->size;
+
+ if (params->memory_64_bit) {
+ const struct al_pcie_ep_bar_params *next_params = params + 1;
+ /* 64 bars start at even index (BAR0, BAR 2 or BAR 4) */
+ if (bar_idx & 1) {
+ ret = -EINVAL;
+ goto done;
+ }
+
+ /* next BAR must be disabled */
+ if (next_params->enable) {
+ ret = -EINVAL;
+ goto done;
+ }
+
+ /* 64 bar must be memory bar */
+ if (!params->memory_space) {
+ ret = -EINVAL;
+ goto done;
+ }
+ } else {
+ if (size > AL_PCIE_MAX_32_MEMORY_BAR_SIZE)
+ return -EINVAL;
+ /* 32 bit space can't be prefetchable */
+ if (params->memory_is_prefetchable) {
+ ret = -EINVAL;
+ goto done;
+ }
+ }
+
+ if (params->memory_space) {
+ if (size < AL_PCIE_MIN_MEMORY_BAR_SIZE) {
+ al_err("PCIe %d: memory BAR %d: size (0x%llx) less that minimal allowed value\n",
+ pcie_port->port_id, bar_idx, size);
+ ret = -EINVAL;
+ goto done;
+ }
+ } else {
+ /* IO can't be prefetchable */
+ if (params->memory_is_prefetchable) {
+ ret = -EINVAL;
+ goto done;
+ }
+
+ if (size < AL_PCIE_MIN_IO_BAR_SIZE) {
+ al_err("PCIe %d: IO BAR %d: size (0x%llx) less that minimal allowed value\n",
+ pcie_port->port_id, bar_idx, size);
+ ret = -EINVAL;
+ goto done;
+ }
+ }
+
+ /* size must be power of 2 */
+ if (size & (size - 1)) {
+ al_err("PCIe %d: BAR %d:size (0x%llx) must be "
+ "power of 2\n",
+ pcie_port->port_id, bar_idx, size);
+ ret = -EINVAL;
+ goto done;
+ }
+
+ /* If BAR is 64-bit, disable the next BAR before
+ * configuring this one
+ */
+ if (params->memory_64_bit)
+ al_reg_write32_dbi_cs2(pcie_port, bar_addr + 1, 0);
+
+ mask = 1; /* enable bit*/
+ mask |= (params->size - 1) & 0xFFFFFFFF;
+
+ al_reg_write32_dbi_cs2(pcie_port, bar_addr , mask);
+
+ if (params->memory_space == AL_FALSE)
+ ctrl = AL_PCI_BASE_ADDRESS_SPACE_IO;
+ if (params->memory_64_bit)
+ ctrl |= AL_PCI_BASE_ADDRESS_MEM_TYPE_64;
+ if (params->memory_is_prefetchable)
+ ctrl |= AL_PCI_BASE_ADDRESS_MEM_PREFETCH;
+ al_reg_write32(bar_addr, ctrl);
+
+ if (params->memory_64_bit) {
+ mask = ((params->size - 1) >> 32) & 0xFFFFFFFF;
+ al_reg_write32_dbi_cs2(pcie_port, bar_addr + 1, mask);
+ }
+
+ } else {
+ al_reg_write32_dbi_cs2(pcie_port, bar_addr , mask);
+ }
+ if (params->enable && params->memory_64_bit)
+ bar_idx += 2;
+ else
+ bar_idx += 1;
+ }
+
+ if (pf_params->exp_bar_params.enable) {
+ if (pcie_port->rev_id != AL_PCIE_REV_ID_3) {
+ al_err("PCIe %d: Expansion BAR enable not supported\n", pcie_port->port_id);
+ ret = -ENOSYS;
+ goto done;
+ } else {
+ /* Enable exp ROM */
+ uint32_t __iomem *exp_rom_bar_addr =
+ &regs->core_space[pf_num].config_header[AL_PCI_EXP_ROM_BASE_ADDRESS >> 2];
+ uint32_t mask = 1; /* enable bit*/
+ mask |= (pf_params->exp_bar_params.size - 1) & 0xFFFFFFFF;
+ al_reg_write32_dbi_cs2(pcie_port, exp_rom_bar_addr , mask);
+ }
+ } else if (pcie_port->rev_id == AL_PCIE_REV_ID_3) {
+ /* Disable exp ROM */
+ uint32_t __iomem *exp_rom_bar_addr =
+ &regs->core_space[pf_num].config_header[AL_PCI_EXP_ROM_BASE_ADDRESS >> 2];
+ al_reg_write32_dbi_cs2(pcie_port, exp_rom_bar_addr , 0);
+ }
+
+ /* Open CPU generated msi and legacy interrupts in pcie wrapper logic */
+ if ((pcie_port->rev_id == AL_PCIE_REV_ID_0) ||
+ (pcie_port->rev_id == AL_PCIE_REV_ID_1)) {
+ al_reg_write32(regs->app.soc_int[pf_num].mask_inta_leg_0, (1 << 21));
+ } else if ((pcie_port->rev_id == AL_PCIE_REV_ID_2) ||
+ (pcie_port->rev_id == AL_PCIE_REV_ID_3)) {
+ al_reg_write32(regs->app.soc_int[pf_num].mask_inta_leg_3, (1 << 18));
+ } else {
+ al_assert(0);
+ ret = -ENOSYS;
+ goto done;
+ }
+
+ /**
+ * Addressing RMN: 1547
+ *
+ * RMN description:
+ * 1. Whenever writing to 0x2xx offset, the write also happens to
+ * 0x3xx address, meaning two registers are written instead of one.
+ * 2. Read and write from 0x3xx work ok.
+ *
+ * Software flow:
+ * Backup the value of the app.int_grp_a.mask_a register, because
+ * app.int_grp_a.mask_clear_a gets overwritten during the write to
+ * app.soc.mask_msi_leg_0 register.
+ * Restore the original value after the write to app.soc.mask_msi_leg_0
+ * register.
+ */
+ if (pcie_port->rev_id == AL_PCIE_REV_ID_0) {
+ uint32_t backup;
+
+ backup = al_reg_read32(&regs->app.int_grp_a->mask);
+ al_reg_write32(regs->app.soc_int[pf_num].mask_msi_leg_0, (1 << 22));
+ al_reg_write32(&regs->app.int_grp_a->mask, backup);
+ } else if (pcie_port->rev_id == AL_PCIE_REV_ID_1) {
+ al_reg_write32(regs->app.soc_int[pf_num].mask_msi_leg_0, (1 << 22));
+ } else if ((pcie_port->rev_id == AL_PCIE_REV_ID_2) ||
+ (pcie_port->rev_id == AL_PCIE_REV_ID_3)) {
+ al_reg_write32(regs->app.soc_int[pf_num].mask_msi_leg_3, (1 << 19));
+ } else {
+ al_assert(0);
+ ret = -ENOSYS;
+ goto done;
+ }
+
+ ret = 0;
+
+done:
+ al_pcie_port_wr_to_ro_set(pcie_port, AL_FALSE);
+
+ return ret;
+}
+
+static void
+al_pcie_port_features_config(
+ struct al_pcie_port *pcie_port,
+ const struct al_pcie_features *features)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+
+ al_assert(pcie_port->rev_id > AL_PCIE_REV_ID_0);
+
+ al_reg_write32_masked(
+ &regs->app.ctrl_gen->features,
+ PCIE_W_CTRL_GEN_FEATURES_SATA_EP_MSI_FIX,
+ features->sata_ep_msi_fix ?
+ PCIE_W_CTRL_GEN_FEATURES_SATA_EP_MSI_FIX : 0);
+}
+
+static int
+al_pcie_port_sris_config(
+ struct al_pcie_port *pcie_port,
+ struct al_pcie_sris_params *sris_params,
+ enum al_pcie_link_speed link_speed)
+{
+ int rc = 0;
+ struct al_pcie_regs *regs = pcie_port->regs;
+
+ if (sris_params->use_defaults) {
+ sris_params->kp_counter_gen3 = (pcie_port->rev_id > AL_PCIE_REV_ID_1) ?
+ PCIE_SRIS_KP_COUNTER_GEN3_DEFAULT_VAL : 0;
+ sris_params->kp_counter_gen21 = PCIE_SRIS_KP_COUNTER_GEN21_DEFAULT_VAL;
+
+ al_dbg("PCIe %d: configuring SRIS with default values kp_gen3[%d] kp_gen21[%d]\n",
+ pcie_port->port_id,
+ sris_params->kp_counter_gen3,
+ sris_params->kp_counter_gen21);
+ }
+
+ switch (pcie_port->rev_id) {
+ case AL_PCIE_REV_ID_3:
+ case AL_PCIE_REV_ID_2:
+ al_reg_write32_masked(regs->app.global_ctrl.sris_kp_counter,
+ PCIE_W_GLOBAL_CTRL_SRIS_KP_COUNTER_VALUE_GEN3_SRIS_MASK |
+ PCIE_W_GLOBAL_CTRL_SRIS_KP_COUNTER_VALUE_GEN21_SRIS_MASK |
+ PCIE_W_GLOBAL_CTRL_SRIS_KP_COUNTER_VALUE_PCIE_X4_SRIS_EN,
+ (sris_params->kp_counter_gen3 <<
+ PCIE_W_GLOBAL_CTRL_SRIS_KP_COUNTER_VALUE_GEN3_SRIS_SHIFT) |
+ (sris_params->kp_counter_gen21 <<
+ PCIE_W_GLOBAL_CTRL_SRIS_KP_COUNTER_VALUE_GEN21_SRIS_SHIFT) |
+ PCIE_W_GLOBAL_CTRL_SRIS_KP_COUNTER_VALUE_PCIE_X4_SRIS_EN);
+ break;
+
+ case AL_PCIE_REV_ID_1:
+ if ((link_speed == AL_PCIE_LINK_SPEED_GEN3) && (sris_params->kp_counter_gen3)) {
+ al_err("PCIe %d: cannot config Gen%d SRIS with rev_id[%d]\n",
+ pcie_port->port_id, al_pcie_speed_gen_code(link_speed),
+ pcie_port->rev_id);
+ return -EINVAL;
+ }
+
+ al_reg_write32_masked(&regs->port_regs->filter_mask_reg_1,
+ PCIE_FLT_MASK_SKP_INT_VAL_MASK,
+ sris_params->kp_counter_gen21);
+ break;
+
+ default:
+ al_err("PCIe %d: SRIS config is not supported in rev_id[%d]\n",
+ pcie_port->port_id, pcie_port->rev_id);
+ al_assert(0);
+ return -EINVAL;
+ }
+
+ return rc;
+}
+
+static void
+al_pcie_port_ib_hcrd_config(struct al_pcie_port *pcie_port)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+
+ al_reg_write32_masked(
+ &regs->port_regs->vc0_posted_rcv_q_ctrl,
+ RADM_PQ_HCRD_VC0_MASK,
+ (pcie_port->ib_hcrd_config.nof_p_hdr - 1)
+ << RADM_PQ_HCRD_VC0_SHIFT);
+
+ al_reg_write32_masked(
+ &regs->port_regs->vc0_non_posted_rcv_q_ctrl,
+ RADM_NPQ_HCRD_VC0_MASK,
+ (pcie_port->ib_hcrd_config.nof_np_hdr - 1)
+ << RADM_NPQ_HCRD_VC0_SHIFT);
+}
+
+static unsigned int
+al_pcie_port_max_num_of_pfs_get(struct al_pcie_port *pcie_port)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ uint32_t max_func_num;
+ uint32_t max_num_of_pfs;
+
+ /**
+ * Only in REV3, when port is already enabled, max_num_of_pfs is already
+ * initialized, return it. Otherwise, return default: 1 PF
+ */
+ if ((pcie_port->rev_id == AL_PCIE_REV_ID_3)
+ && al_pcie_port_is_enabled(pcie_port)) {
+ max_func_num = al_reg_read32(&regs->port_regs->timer_ctrl_max_func_num);
+ max_num_of_pfs = AL_REG_FIELD_GET(max_func_num, PCIE_PORT_GEN3_MAX_FUNC_NUM, 0) + 1;
+ return max_num_of_pfs;
+ }
+ return 1;
+}
+
+/******************************************************************************/
+/***************************** API Implementation *****************************/
+/******************************************************************************/
+
+/*************************** PCIe Initialization API **************************/
+
+/**
+ * Initializes a PCIe port handle structure
+ * Caution: this function should not read/write to any register except for
+ * reading RO register (REV_ID for example)
+ */
+int
+al_pcie_port_handle_init(
+ struct al_pcie_port *pcie_port,
+ void __iomem *pcie_reg_base,
+ void __iomem *pbs_reg_base,
+ unsigned int port_id)
+{
+ int i, ret;
+
+ pcie_port->pcie_reg_base = pcie_reg_base;
+ pcie_port->regs = &pcie_port->regs_ptrs;
+ pcie_port->ex_regs = NULL;
+ pcie_port->pbs_regs = pbs_reg_base;
+ pcie_port->port_id = port_id;
+ pcie_port->max_lanes = 0;
+
+ ret = al_pcie_rev_id_get(pbs_reg_base, pcie_reg_base);
+ if (ret < 0)
+ return ret;
+
+ pcie_port->rev_id = ret;
+
+ /* Zero all regs */
+ al_memset(pcie_port->regs, 0, sizeof(struct al_pcie_regs));
+
+ if ((pcie_port->rev_id == AL_PCIE_REV_ID_0) ||
+ (pcie_port->rev_id == AL_PCIE_REV_ID_1)) {
+ struct al_pcie_rev1_regs __iomem *regs =
+ (struct al_pcie_rev1_regs __iomem *)pcie_reg_base;
+
+ pcie_port->regs->axi.ctrl.global = &regs->axi.ctrl.global;
+ pcie_port->regs->axi.ctrl.master_arctl = &regs->axi.ctrl.master_arctl;
+ pcie_port->regs->axi.ctrl.master_awctl = &regs->axi.ctrl.master_awctl;
+ pcie_port->regs->axi.ctrl.slv_ctl = &regs->axi.ctrl.slv_ctl;
+ pcie_port->regs->axi.ob_ctrl.cfg_target_bus = &regs->axi.ob_ctrl.cfg_target_bus;
+ pcie_port->regs->axi.ob_ctrl.cfg_control = &regs->axi.ob_ctrl.cfg_control;
+ pcie_port->regs->axi.ob_ctrl.io_start_l = &regs->axi.ob_ctrl.io_start_l;
+ pcie_port->regs->axi.ob_ctrl.io_start_h = &regs->axi.ob_ctrl.io_start_h;
+ pcie_port->regs->axi.ob_ctrl.io_limit_l = &regs->axi.ob_ctrl.io_limit_l;
+ pcie_port->regs->axi.ob_ctrl.io_limit_h = &regs->axi.ob_ctrl.io_limit_h;
+ pcie_port->regs->axi.pcie_global.conf = &regs->axi.pcie_global.conf;
+ pcie_port->regs->axi.conf.zero_lane0 = &regs->axi.conf.zero_lane0;
+ pcie_port->regs->axi.conf.zero_lane1 = &regs->axi.conf.zero_lane1;
+ pcie_port->regs->axi.conf.zero_lane2 = &regs->axi.conf.zero_lane2;
+ pcie_port->regs->axi.conf.zero_lane3 = &regs->axi.conf.zero_lane3;
+ pcie_port->regs->axi.status.lane[0] = &regs->axi.status.lane0;
+ pcie_port->regs->axi.status.lane[1] = &regs->axi.status.lane1;
+ pcie_port->regs->axi.status.lane[2] = &regs->axi.status.lane2;
+ pcie_port->regs->axi.status.lane[3] = &regs->axi.status.lane3;
+ pcie_port->regs->axi.parity.en_axi = &regs->axi.parity.en_axi;
+ pcie_port->regs->axi.ordering.pos_cntl = &regs->axi.ordering.pos_cntl;
+ pcie_port->regs->axi.pre_configuration.pcie_core_setup = &regs->axi.pre_configuration.pcie_core_setup;
+ pcie_port->regs->axi.init_fc.cfg = &regs->axi.init_fc.cfg;
+ pcie_port->regs->axi.int_grp_a = &regs->axi.int_grp_a;
+
+ pcie_port->regs->app.global_ctrl.port_init = &regs->app.global_ctrl.port_init;
+ pcie_port->regs->app.global_ctrl.pm_control = &regs->app.global_ctrl.pm_control;
+ pcie_port->regs->app.global_ctrl.events_gen[0] = &regs->app.global_ctrl.events_gen;
+ pcie_port->regs->app.debug = &regs->app.debug;
+ pcie_port->regs->app.soc_int[0].mask_inta_leg_0 = &regs->app.soc_int.mask_inta_leg_0;
+ pcie_port->regs->app.soc_int[0].mask_msi_leg_0 = &regs->app.soc_int.mask_msi_leg_0;
+ pcie_port->regs->app.ctrl_gen = &regs->app.ctrl_gen;
+ pcie_port->regs->app.parity = &regs->app.parity;
+ pcie_port->regs->app.atu.in_mask_pair = regs->app.atu.in_mask_pair;
+ pcie_port->regs->app.atu.out_mask_pair = regs->app.atu.out_mask_pair;
+
+ if (pcie_port->rev_id == AL_PCIE_REV_ID_0) {
+ pcie_port->regs->app.int_grp_a = &regs->app.int_grp_a_m0;
+ pcie_port->regs->app.int_grp_b = &regs->app.int_grp_b_m0;
+ } else {
+ pcie_port->regs->app.int_grp_a = &regs->app.int_grp_a;
+ pcie_port->regs->app.int_grp_b = &regs->app.int_grp_b;
+ }
+
+ pcie_port->regs->core_space[0].config_header = regs->core_space.config_header;
+ pcie_port->regs->core_space[0].pcie_pm_cap_base = &regs->core_space.pcie_pm_cap_base;
+ pcie_port->regs->core_space[0].pcie_cap_base = &regs->core_space.pcie_cap_base;
+ pcie_port->regs->core_space[0].pcie_dev_cap_base = &regs->core_space.pcie_dev_cap_base;
+ pcie_port->regs->core_space[0].pcie_dev_ctrl_status = &regs->core_space.pcie_dev_ctrl_status;
+ pcie_port->regs->core_space[0].pcie_link_cap_base = &regs->core_space.pcie_link_cap_base;
+ pcie_port->regs->core_space[0].msix_cap_base = &regs->core_space.msix_cap_base;
+ pcie_port->regs->core_space[0].aer = &regs->core_space.aer;
+ pcie_port->regs->core_space[0].pcie_sec_ext_cap_base = &regs->core_space.pcie_sec_ext_cap_base;
+
+ pcie_port->regs->port_regs = &regs->core_space.port_regs;
+
+ } else if (pcie_port->rev_id == AL_PCIE_REV_ID_2) {
+ struct al_pcie_rev2_regs __iomem *regs =
+ (struct al_pcie_rev2_regs __iomem *)pcie_reg_base;
+
+ pcie_port->regs->axi.ctrl.global = &regs->axi.ctrl.global;
+ pcie_port->regs->axi.ctrl.master_arctl = &regs->axi.ctrl.master_arctl;
+ pcie_port->regs->axi.ctrl.master_awctl = &regs->axi.ctrl.master_awctl;
+ pcie_port->regs->axi.ctrl.slv_ctl = &regs->axi.ctrl.slv_ctl;
+ pcie_port->regs->axi.ob_ctrl.cfg_target_bus = &regs->axi.ob_ctrl.cfg_target_bus;
+ pcie_port->regs->axi.ob_ctrl.cfg_control = &regs->axi.ob_ctrl.cfg_control;
+ pcie_port->regs->axi.ob_ctrl.io_start_l = &regs->axi.ob_ctrl.io_start_l;
+ pcie_port->regs->axi.ob_ctrl.io_start_h = &regs->axi.ob_ctrl.io_start_h;
+ pcie_port->regs->axi.ob_ctrl.io_limit_l = &regs->axi.ob_ctrl.io_limit_l;
+ pcie_port->regs->axi.ob_ctrl.io_limit_h = &regs->axi.ob_ctrl.io_limit_h;
+ pcie_port->regs->axi.pcie_global.conf = &regs->axi.pcie_global.conf;
+ pcie_port->regs->axi.conf.zero_lane0 = &regs->axi.conf.zero_lane0;
+ pcie_port->regs->axi.conf.zero_lane1 = &regs->axi.conf.zero_lane1;
+ pcie_port->regs->axi.conf.zero_lane2 = &regs->axi.conf.zero_lane2;
+ pcie_port->regs->axi.conf.zero_lane3 = &regs->axi.conf.zero_lane3;
+ pcie_port->regs->axi.status.lane[0] = &regs->axi.status.lane0;
+ pcie_port->regs->axi.status.lane[1] = &regs->axi.status.lane1;
+ pcie_port->regs->axi.status.lane[2] = &regs->axi.status.lane2;
+ pcie_port->regs->axi.status.lane[3] = &regs->axi.status.lane3;
+ pcie_port->regs->axi.parity.en_axi = &regs->axi.parity.en_axi;
+ pcie_port->regs->axi.ordering.pos_cntl = &regs->axi.ordering.pos_cntl;
+ pcie_port->regs->axi.pre_configuration.pcie_core_setup = &regs->axi.pre_configuration.pcie_core_setup;
+ pcie_port->regs->axi.init_fc.cfg = &regs->axi.init_fc.cfg;
+ pcie_port->regs->axi.int_grp_a = &regs->axi.int_grp_a;
+
+ pcie_port->regs->app.global_ctrl.port_init = &regs->app.global_ctrl.port_init;
+ pcie_port->regs->app.global_ctrl.pm_control = &regs->app.global_ctrl.pm_control;
+ pcie_port->regs->app.global_ctrl.events_gen[0] = &regs->app.global_ctrl.events_gen;
+ pcie_port->regs->app.global_ctrl.corr_err_sts_int = &regs->app.global_ctrl.pended_corr_err_sts_int;
+ pcie_port->regs->app.global_ctrl.uncorr_err_sts_int = &regs->app.global_ctrl.pended_uncorr_err_sts_int;
+ pcie_port->regs->app.debug = &regs->app.debug;
+ pcie_port->regs->app.ap_user_send_msg = &regs->app.ap_user_send_msg;
+ pcie_port->regs->app.soc_int[0].mask_inta_leg_0 = &regs->app.soc_int.mask_inta_leg_0;
+ pcie_port->regs->app.soc_int[0].mask_inta_leg_3 = &regs->app.soc_int.mask_inta_leg_3;
+ pcie_port->regs->app.soc_int[0].mask_msi_leg_0 = &regs->app.soc_int.mask_msi_leg_0;
+ pcie_port->regs->app.soc_int[0].mask_msi_leg_3 = &regs->app.soc_int.mask_msi_leg_3;
+ pcie_port->regs->app.ctrl_gen = &regs->app.ctrl_gen;
+ pcie_port->regs->app.parity = &regs->app.parity;
+ pcie_port->regs->app.atu.in_mask_pair = regs->app.atu.in_mask_pair;
+ pcie_port->regs->app.atu.out_mask_pair = regs->app.atu.out_mask_pair;
+ pcie_port->regs->app.status_per_func[0] = &regs->app.status_per_func;
+ pcie_port->regs->app.int_grp_a = &regs->app.int_grp_a;
+ pcie_port->regs->app.int_grp_b = &regs->app.int_grp_b;
+
+ pcie_port->regs->core_space[0].config_header = regs->core_space.config_header;
+ pcie_port->regs->core_space[0].pcie_pm_cap_base = &regs->core_space.pcie_pm_cap_base;
+ pcie_port->regs->core_space[0].pcie_cap_base = &regs->core_space.pcie_cap_base;
+ pcie_port->regs->core_space[0].pcie_dev_cap_base = &regs->core_space.pcie_dev_cap_base;
+ pcie_port->regs->core_space[0].pcie_dev_ctrl_status = &regs->core_space.pcie_dev_ctrl_status;
+ pcie_port->regs->core_space[0].pcie_link_cap_base = &regs->core_space.pcie_link_cap_base;
+ pcie_port->regs->core_space[0].msix_cap_base = &regs->core_space.msix_cap_base;
+ pcie_port->regs->core_space[0].aer = &regs->core_space.aer;
+ pcie_port->regs->core_space[0].pcie_sec_ext_cap_base = &regs->core_space.pcie_sec_ext_cap_base;
+
+ pcie_port->regs->port_regs = &regs->core_space.port_regs;
+
+ } else if (pcie_port->rev_id == AL_PCIE_REV_ID_3) {
+ struct al_pcie_rev3_regs __iomem *regs =
+ (struct al_pcie_rev3_regs __iomem *)pcie_reg_base;
+ pcie_port->regs->axi.ctrl.global = &regs->axi.ctrl.global;
+ pcie_port->regs->axi.ctrl.master_arctl = &regs->axi.ctrl.master_arctl;
+ pcie_port->regs->axi.ctrl.master_awctl = &regs->axi.ctrl.master_awctl;
+ pcie_port->regs->axi.ctrl.slv_ctl = &regs->axi.ctrl.slv_ctl;
+ pcie_port->regs->axi.ob_ctrl.cfg_target_bus = &regs->axi.ob_ctrl.cfg_target_bus;
+ pcie_port->regs->axi.ob_ctrl.cfg_control = &regs->axi.ob_ctrl.cfg_control;
+ pcie_port->regs->axi.ob_ctrl.io_start_l = &regs->axi.ob_ctrl.io_start_l;
+ pcie_port->regs->axi.ob_ctrl.io_start_h = &regs->axi.ob_ctrl.io_start_h;
+ pcie_port->regs->axi.ob_ctrl.io_limit_l = &regs->axi.ob_ctrl.io_limit_l;
+ pcie_port->regs->axi.ob_ctrl.io_limit_h = &regs->axi.ob_ctrl.io_limit_h;
+ pcie_port->regs->axi.pcie_global.conf = &regs->axi.pcie_global.conf;
+ pcie_port->regs->axi.conf.zero_lane0 = &regs->axi.conf.zero_lane0;
+ pcie_port->regs->axi.conf.zero_lane1 = &regs->axi.conf.zero_lane1;
+ pcie_port->regs->axi.conf.zero_lane2 = &regs->axi.conf.zero_lane2;
+ pcie_port->regs->axi.conf.zero_lane3 = &regs->axi.conf.zero_lane3;
+ pcie_port->regs->axi.conf.zero_lane4 = &regs->axi.conf.zero_lane4;
+ pcie_port->regs->axi.conf.zero_lane5 = &regs->axi.conf.zero_lane5;
+ pcie_port->regs->axi.conf.zero_lane6 = &regs->axi.conf.zero_lane6;
+ pcie_port->regs->axi.conf.zero_lane7 = &regs->axi.conf.zero_lane7;
+ pcie_port->regs->axi.status.lane[0] = &regs->axi.status.lane0;
+ pcie_port->regs->axi.status.lane[1] = &regs->axi.status.lane1;
+ pcie_port->regs->axi.status.lane[2] = &regs->axi.status.lane2;
+ pcie_port->regs->axi.status.lane[3] = &regs->axi.status.lane3;
+ pcie_port->regs->axi.status.lane[4] = &regs->axi.status.lane4;
+ pcie_port->regs->axi.status.lane[5] = &regs->axi.status.lane5;
+ pcie_port->regs->axi.status.lane[6] = &regs->axi.status.lane6;
+ pcie_port->regs->axi.status.lane[7] = &regs->axi.status.lane7;
+ pcie_port->regs->axi.parity.en_axi = &regs->axi.parity.en_axi;
+ pcie_port->regs->axi.ordering.pos_cntl = &regs->axi.ordering.pos_cntl;
+ pcie_port->regs->axi.pre_configuration.pcie_core_setup = &regs->axi.pre_configuration.pcie_core_setup;
+ pcie_port->regs->axi.init_fc.cfg = &regs->axi.init_fc.cfg;
+ pcie_port->regs->axi.int_grp_a = &regs->axi.int_grp_a;
+ pcie_port->regs->axi.axi_attr_ovrd.write_msg_ctrl_0 = &regs->axi.axi_attr_ovrd.write_msg_ctrl_0;
+ pcie_port->regs->axi.axi_attr_ovrd.write_msg_ctrl_1 = &regs->axi.axi_attr_ovrd.write_msg_ctrl_1;
+ pcie_port->regs->axi.axi_attr_ovrd.pf_sel = &regs->axi.axi_attr_ovrd.pf_sel;
+
+ for (i = 0; i < AL_MAX_NUM_OF_PFS; i++) {
+ pcie_port->regs->axi.pf_axi_attr_ovrd[i].func_ctrl_0 = &regs->axi.pf_axi_attr_ovrd[i].func_ctrl_0;
+ pcie_port->regs->axi.pf_axi_attr_ovrd[i].func_ctrl_1 = &regs->axi.pf_axi_attr_ovrd[i].func_ctrl_1;
+ pcie_port->regs->axi.pf_axi_attr_ovrd[i].func_ctrl_2 = &regs->axi.pf_axi_attr_ovrd[i].func_ctrl_2;
+ pcie_port->regs->axi.pf_axi_attr_ovrd[i].func_ctrl_3 = &regs->axi.pf_axi_attr_ovrd[i].func_ctrl_3;
+ pcie_port->regs->axi.pf_axi_attr_ovrd[i].func_ctrl_4 = &regs->axi.pf_axi_attr_ovrd[i].func_ctrl_4;
+ pcie_port->regs->axi.pf_axi_attr_ovrd[i].func_ctrl_5 = &regs->axi.pf_axi_attr_ovrd[i].func_ctrl_5;
+ pcie_port->regs->axi.pf_axi_attr_ovrd[i].func_ctrl_6 = &regs->axi.pf_axi_attr_ovrd[i].func_ctrl_6;
+ pcie_port->regs->axi.pf_axi_attr_ovrd[i].func_ctrl_7 = &regs->axi.pf_axi_attr_ovrd[i].func_ctrl_7;
+ pcie_port->regs->axi.pf_axi_attr_ovrd[i].func_ctrl_8 = &regs->axi.pf_axi_attr_ovrd[i].func_ctrl_8;
+ pcie_port->regs->axi.pf_axi_attr_ovrd[i].func_ctrl_9 = &regs->axi.pf_axi_attr_ovrd[i].func_ctrl_9;
+ }
+
+ pcie_port->regs->axi.msg_attr_axuser_table.entry_vec = &regs->axi.msg_attr_axuser_table.entry_vec;
+
+ pcie_port->regs->app.global_ctrl.port_init = &regs->app.global_ctrl.port_init;
+ pcie_port->regs->app.global_ctrl.pm_control = &regs->app.global_ctrl.pm_control;
+ pcie_port->regs->app.global_ctrl.corr_err_sts_int = &regs->app.global_ctrl.pended_corr_err_sts_int;
+ pcie_port->regs->app.global_ctrl.uncorr_err_sts_int = &regs->app.global_ctrl.pended_uncorr_err_sts_int;
+
+ for (i = 0; i < AL_MAX_NUM_OF_PFS; i++) {
+ pcie_port->regs->app.global_ctrl.events_gen[i] = &regs->app.events_gen_per_func[i].events_gen;
+ }
+
+ pcie_port->regs->app.global_ctrl.sris_kp_counter = &regs->app.global_ctrl.sris_kp_counter_value;
+ pcie_port->regs->app.debug = &regs->app.debug;
+
+ for (i = 0; i < AL_MAX_NUM_OF_PFS; i++) {
+ pcie_port->regs->app.soc_int[i].mask_inta_leg_0 = &regs->app.soc_int_per_func[i].mask_inta_leg_0;
+ pcie_port->regs->app.soc_int[i].mask_inta_leg_3 = &regs->app.soc_int_per_func[i].mask_inta_leg_3;
+ pcie_port->regs->app.soc_int[i].mask_msi_leg_0 = &regs->app.soc_int_per_func[i].mask_msi_leg_0;
+ pcie_port->regs->app.soc_int[i].mask_msi_leg_3 = &regs->app.soc_int_per_func[i].mask_msi_leg_3;
+ }
+
+ pcie_port->regs->app.ap_user_send_msg = &regs->app.ap_user_send_msg;
+ pcie_port->regs->app.ctrl_gen = &regs->app.ctrl_gen;
+ pcie_port->regs->app.parity = &regs->app.parity;
+ pcie_port->regs->app.atu.in_mask_pair = regs->app.atu.in_mask_pair;
+ pcie_port->regs->app.atu.out_mask_pair = regs->app.atu.out_mask_pair;
+
+ for (i = 0; i < AL_MAX_NUM_OF_PFS; i++)
+ pcie_port->regs->app.status_per_func[i] = &regs->app.status_per_func[i];
+
+ pcie_port->regs->app.int_grp_a = &regs->app.int_grp_a;
+ pcie_port->regs->app.int_grp_b = &regs->app.int_grp_b;
+ pcie_port->regs->app.int_grp_c = &regs->app.int_grp_c;
+ pcie_port->regs->app.int_grp_d = &regs->app.int_grp_d;
+
+ for (i = 0; i < AL_MAX_NUM_OF_PFS; i++) {
+ pcie_port->regs->core_space[i].config_header = regs->core_space.func[i].config_header;
+ pcie_port->regs->core_space[i].pcie_pm_cap_base = &regs->core_space.func[i].pcie_pm_cap_base;
+ pcie_port->regs->core_space[i].pcie_cap_base = &regs->core_space.func[i].pcie_cap_base;
+ pcie_port->regs->core_space[i].pcie_dev_cap_base = &regs->core_space.func[i].pcie_dev_cap_base;
+ pcie_port->regs->core_space[i].pcie_dev_ctrl_status = &regs->core_space.func[i].pcie_dev_ctrl_status;
+ pcie_port->regs->core_space[i].pcie_link_cap_base = &regs->core_space.func[i].pcie_link_cap_base;
+ pcie_port->regs->core_space[i].msix_cap_base = &regs->core_space.func[i].msix_cap_base;
+ pcie_port->regs->core_space[i].aer = &regs->core_space.func[i].aer;
+ pcie_port->regs->core_space[i].tph_cap_base = &regs->core_space.func[i].tph_cap_base;
+
+ }
+
+ /* secondary extension capability only for PF0 */
+ pcie_port->regs->core_space[0].pcie_sec_ext_cap_base = &regs->core_space.func[0].pcie_sec_ext_cap_base;
+
+ pcie_port->regs->port_regs = &regs->core_space.func[0].port_regs;
+
+ } else {
+ al_warn("%s: Revision ID is unknown\n",
+ __func__);
+ return -EINVAL;
+ }
+
+ /* set maximum number of physical functions */
+ pcie_port->max_num_of_pfs = al_pcie_port_max_num_of_pfs_get(pcie_port);
+
+ al_dbg("pcie port handle initialized. port id: %d, rev_id %d, regs base %p\n",
+ port_id, pcie_port->rev_id, pcie_reg_base);
+ return 0;
+}
+
+/**
+ * Initializes a PCIe Physical function handle structure
+ * Caution: this function should not read/write to any register except for
+ * reading RO register (REV_ID for example)
+ */
+int
+al_pcie_pf_handle_init(
+ struct al_pcie_pf *pcie_pf,
+ struct al_pcie_port *pcie_port,
+ unsigned int pf_num)
+{
+ enum al_pcie_operating_mode op_mode = al_pcie_operating_mode_get(pcie_port);
+ al_assert(pf_num < pcie_port->max_num_of_pfs);
+
+ if (op_mode != AL_PCIE_OPERATING_MODE_EP) {
+ al_err("PCIe %d: can't init PF handle with operating mode [%d]\n",
+ pcie_port->port_id, op_mode);
+ return -EINVAL;
+ }
+
+ pcie_pf->pf_num = pf_num;
+ pcie_pf->pcie_port = pcie_port;
+
+ al_dbg("PCIe %d: pf handle initialized. pf number: %d, rev_id %d, regs %p\n",
+ pcie_port->port_id, pcie_pf->pf_num, pcie_port->rev_id,
+ pcie_port->regs);
+ return 0;
+}
+
+/************************** Pre PCIe Port Enable API **************************/
+
+/** configure pcie operating mode (root complex or endpoint) */
+int
+al_pcie_port_operating_mode_config(
+ struct al_pcie_port *pcie_port,
+ enum al_pcie_operating_mode mode)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ uint32_t reg, device_type, new_device_type;
+
+ if (al_pcie_port_is_enabled(pcie_port)) {
+ al_err("PCIe %d: already enabled, cannot set operating mode\n",
+ pcie_port->port_id);
+ return -EINVAL;
+ }
+
+ reg = al_reg_read32(regs->axi.pcie_global.conf);
+
+ device_type = AL_REG_FIELD_GET(reg,
+ PCIE_AXI_MISC_PCIE_GLOBAL_CONF_DEV_TYPE_MASK,
+ PCIE_AXI_MISC_PCIE_GLOBAL_CONF_DEV_TYPE_SHIFT);
+ if (mode == AL_PCIE_OPERATING_MODE_EP) {
+ new_device_type = PCIE_AXI_MISC_PCIE_GLOBAL_CONF_DEV_TYPE_EP;
+ } else if (mode == AL_PCIE_OPERATING_MODE_RC) {
+ new_device_type = PCIE_AXI_MISC_PCIE_GLOBAL_CONF_DEV_TYPE_RC;
+
+ if (pcie_port->rev_id == AL_PCIE_REV_ID_3) {
+ /* config 1 PF in RC mode */
+ al_reg_write32_masked(regs->axi.axi_attr_ovrd.pf_sel,
+ PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_PF_BIT0_OVRD_FROM_AXUSER |
+ PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_PF_BIT0_OVRD_FROM_REG |
+ PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_PF_BIT0_ADDR_OFFSET_MASK |
+ PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_CFG_PF_BIT0_OVRD |
+ PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_PF_BIT1_OVRD_FROM_AXUSER |
+ PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_PF_BIT1_OVRD_FROM_REG |
+ PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_PF_BIT1_ADDR_OFFSET_MASK |
+ PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_CFG_PF_BIT1_OVRD,
+ PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_PF_BIT0_OVRD_FROM_REG |
+ PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_PF_BIT1_OVRD_FROM_REG);
+ }
+ } else {
+ al_err("PCIe %d: unknown operating mode: %d\n", pcie_port->port_id, mode);
+ return -EINVAL;
+ }
+
+ if (new_device_type == device_type) {
+ al_dbg("PCIe %d: operating mode already set to %s\n",
+ pcie_port->port_id, (mode == AL_PCIE_OPERATING_MODE_EP) ?
+ "EndPoint" : "Root Complex");
+ return 0;
+ }
+ al_info("PCIe %d: set operating mode to %s\n",
+ pcie_port->port_id, (mode == AL_PCIE_OPERATING_MODE_EP) ?
+ "EndPoint" : "Root Complex");
+ AL_REG_FIELD_SET(reg, PCIE_AXI_MISC_PCIE_GLOBAL_CONF_DEV_TYPE_MASK,
+ PCIE_AXI_MISC_PCIE_GLOBAL_CONF_DEV_TYPE_SHIFT,
+ new_device_type);
+
+ al_reg_write32(regs->axi.pcie_global.conf, reg);
+
+ return 0;
+}
+
+int
+al_pcie_port_max_lanes_set(struct al_pcie_port *pcie_port, uint8_t lanes)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+
+ if (al_pcie_port_is_enabled(pcie_port)) {
+ al_err("PCIe %d: already enabled, cannot set max lanes\n",
+ pcie_port->port_id);
+ return -EINVAL;
+ }
+
+ /* convert to bitmask format (4 ->'b1111, 2 ->'b11, 1 -> 'b1) */
+ uint32_t active_lanes_val = AL_PCIE_PARSE_LANES(lanes);
+
+ al_reg_write32_masked(regs->axi.pcie_global.conf,
+ (pcie_port->rev_id == AL_PCIE_REV_ID_3) ?
+ PCIE_REV3_AXI_MISC_PCIE_GLOBAL_CONF_NOF_ACT_LANES_MASK :
+ PCIE_REV1_2_AXI_MISC_PCIE_GLOBAL_CONF_NOF_ACT_LANES_MASK,
+ active_lanes_val);
+
+ pcie_port->max_lanes = lanes;
+ return 0;
+}
+
+int
+al_pcie_port_max_num_of_pfs_set(
+ struct al_pcie_port *pcie_port,
+ uint8_t max_num_of_pfs)
+{
+ if (al_pcie_port_is_enabled(pcie_port)) {
+ al_err("PCIe %d: already enabled, cannot set max num of PFs\n",
+ pcie_port->port_id);
+ return -EINVAL;
+ }
+
+ if (pcie_port->rev_id == AL_PCIE_REV_ID_3)
+ al_assert(max_num_of_pfs <= REV3_MAX_NUM_OF_PFS);
+ else
+ al_assert(max_num_of_pfs == REV1_2_MAX_NUM_OF_PFS);
+
+ pcie_port->max_num_of_pfs = max_num_of_pfs;
+
+ return 0;
+}
+
+/* Inbound header credits and outstanding outbound reads configuration */
+int
+al_pcie_port_ib_hcrd_os_ob_reads_config(
+ struct al_pcie_port *pcie_port,
+ struct al_pcie_ib_hcrd_os_ob_reads_config *ib_hcrd_os_ob_reads_config)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+
+ if (al_pcie_port_is_enabled(pcie_port)) {
+ al_err("PCIe %d: already enabled, cannot configure IB credits and OB OS reads\n",
+ pcie_port->port_id);
+ return -EINVAL;
+ }
+
+ al_assert(ib_hcrd_os_ob_reads_config->nof_np_hdr > 0);
+
+ al_assert(ib_hcrd_os_ob_reads_config->nof_p_hdr > 0);
+
+ al_assert(ib_hcrd_os_ob_reads_config->nof_cpl_hdr > 0);
+
+ if (pcie_port->rev_id == AL_PCIE_REV_ID_3) {
+ al_assert(
+ (ib_hcrd_os_ob_reads_config->nof_cpl_hdr +
+ ib_hcrd_os_ob_reads_config->nof_np_hdr +
+ ib_hcrd_os_ob_reads_config->nof_p_hdr) ==
+ AL_PCIE_REV3_IB_HCRD_SUM);
+
+ al_reg_write32_masked(
+ regs->axi.init_fc.cfg,
+ PCIE_AXI_REV3_INIT_FC_CFG_NOF_P_HDR_MASK |
+ PCIE_AXI_REV3_INIT_FC_CFG_NOF_NP_HDR_MASK |
+ PCIE_AXI_REV3_INIT_FC_CFG_NOF_CPL_HDR_MASK,
+ (ib_hcrd_os_ob_reads_config->nof_p_hdr <<
+ PCIE_AXI_REV3_INIT_FC_CFG_NOF_P_HDR_SHIFT) |
+ (ib_hcrd_os_ob_reads_config->nof_np_hdr <<
+ PCIE_AXI_REV3_INIT_FC_CFG_NOF_NP_HDR_SHIFT) |
+ (ib_hcrd_os_ob_reads_config->nof_cpl_hdr <<
+ PCIE_AXI_REV3_INIT_FC_CFG_NOF_CPL_HDR_SHIFT));
+ } else {
+ al_assert(
+ (ib_hcrd_os_ob_reads_config->nof_cpl_hdr +
+ ib_hcrd_os_ob_reads_config->nof_np_hdr +
+ ib_hcrd_os_ob_reads_config->nof_p_hdr) ==
+ AL_PCIE_REV_1_2_IB_HCRD_SUM);
+
+ al_reg_write32_masked(
+ regs->axi.init_fc.cfg,
+ PCIE_AXI_REV1_2_INIT_FC_CFG_NOF_P_HDR_MASK |
+ PCIE_AXI_REV1_2_INIT_FC_CFG_NOF_NP_HDR_MASK |
+ PCIE_AXI_REV1_2_INIT_FC_CFG_NOF_CPL_HDR_MASK,
+ (ib_hcrd_os_ob_reads_config->nof_p_hdr <<
+ PCIE_AXI_REV1_2_INIT_FC_CFG_NOF_P_HDR_SHIFT) |
+ (ib_hcrd_os_ob_reads_config->nof_np_hdr <<
+ PCIE_AXI_REV1_2_INIT_FC_CFG_NOF_NP_HDR_SHIFT) |
+ (ib_hcrd_os_ob_reads_config->nof_cpl_hdr <<
+ PCIE_AXI_REV1_2_INIT_FC_CFG_NOF_CPL_HDR_SHIFT));
+ }
+
+ al_reg_write32_masked(
+ regs->axi.pre_configuration.pcie_core_setup,
+ PCIE_AXI_CORE_SETUP_NOF_READS_ONSLAVE_INTRF_PCIE_CORE_MASK,
+ ib_hcrd_os_ob_reads_config->nof_outstanding_ob_reads <<
+ PCIE_AXI_CORE_SETUP_NOF_READS_ONSLAVE_INTRF_PCIE_CORE_SHIFT);
+
+ /* Store 'nof_p_hdr' and 'nof_np_hdr' to be set in the core later */
+ pcie_port->ib_hcrd_config.nof_np_hdr =
+ ib_hcrd_os_ob_reads_config->nof_np_hdr;
+ pcie_port->ib_hcrd_config.nof_p_hdr =
+ ib_hcrd_os_ob_reads_config->nof_p_hdr;
+
+ return 0;
+}
+
+enum al_pcie_operating_mode
+al_pcie_operating_mode_get(
+ struct al_pcie_port *pcie_port)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ uint32_t reg, device_type;
+
+ al_assert(pcie_port);
+
+ reg = al_reg_read32(regs->axi.pcie_global.conf);
+
+ device_type = AL_REG_FIELD_GET(reg,
+ PCIE_AXI_MISC_PCIE_GLOBAL_CONF_DEV_TYPE_MASK,
+ PCIE_AXI_MISC_PCIE_GLOBAL_CONF_DEV_TYPE_SHIFT);
+
+ switch (device_type) {
+ case PCIE_AXI_MISC_PCIE_GLOBAL_CONF_DEV_TYPE_EP:
+ return AL_PCIE_OPERATING_MODE_EP;
+ case PCIE_AXI_MISC_PCIE_GLOBAL_CONF_DEV_TYPE_RC:
+ return AL_PCIE_OPERATING_MODE_RC;
+ default:
+ al_err("PCIe %d: unknown device type (%d) in global conf register.\n",
+ pcie_port->port_id, device_type);
+ }
+ return AL_PCIE_OPERATING_MODE_UNKNOWN;
+}
+
+/**************************** PCIe Port Enable API ****************************/
+
+/** Enable PCIe port (deassert reset) */
+int
+al_pcie_port_enable(struct al_pcie_port *pcie_port)
+{
+ struct al_pbs_regs *pbs_reg_base =
+ (struct al_pbs_regs *)pcie_port->pbs_regs;
+ struct al_pcie_regs *regs = pcie_port->regs;
+ unsigned int port_id = pcie_port->port_id;
+
+ /* pre-port-enable default functionality should be here */
+
+ /**
+ * Set inbound header credit and outstanding outbound reads defaults
+ * Must be called before port enable (PCIE_EXIST)
+ */
+ al_pcie_ib_hcrd_os_ob_reads_config_default(pcie_port);
+
+ /*
+ * Disable ATS capability
+ * - must be done before core reset deasserted
+ * - rev_id 0 - no effect, but no harm
+ */
+ if ((pcie_port->rev_id == AL_PCIE_REV_ID_0) ||
+ (pcie_port->rev_id == AL_PCIE_REV_ID_1) ||
+ (pcie_port->rev_id == AL_PCIE_REV_ID_2)) {
+ al_reg_write32_masked(
+ regs->axi.ordering.pos_cntl,
+ PCIE_AXI_CORE_SETUP_ATS_CAP_DIS,
+ PCIE_AXI_CORE_SETUP_ATS_CAP_DIS);
+ }
+
+ /* Deassert core reset */
+ al_reg_write32_masked(
+ &pbs_reg_base->unit.pcie_conf_1,
+ 1 << (port_id + PBS_UNIT_PCIE_CONF_1_PCIE_EXIST_SHIFT),
+ 1 << (port_id + PBS_UNIT_PCIE_CONF_1_PCIE_EXIST_SHIFT));
+
+ return 0;
+}
+
+/** Disable PCIe port (assert reset) */
+void
+al_pcie_port_disable(struct al_pcie_port *pcie_port)
+{
+ struct al_pbs_regs *pbs_reg_base =
+ (struct al_pbs_regs *)pcie_port->pbs_regs;
+ unsigned int port_id = pcie_port->port_id;
+
+ if (!al_pcie_port_is_enabled(pcie_port)) {
+ al_warn("PCIe %d: trying to disable a non-enabled port\n",
+ pcie_port->port_id);
+ }
+
+ /* Assert core reset */
+ al_reg_write32_masked(
+ &pbs_reg_base->unit.pcie_conf_1,
+ 1 << (port_id + PBS_UNIT_PCIE_CONF_1_PCIE_EXIST_SHIFT),
+ 0);
+}
+
+int
+al_pcie_port_memory_shutdown_set(
+ struct al_pcie_port *pcie_port,
+ al_bool enable)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ uint32_t mask = (pcie_port->rev_id == AL_PCIE_REV_ID_3) ?
+ PCIE_REV3_AXI_MISC_PCIE_GLOBAL_CONF_MEM_SHUTDOWN :
+ PCIE_REV1_2_AXI_MISC_PCIE_GLOBAL_CONF_MEM_SHUTDOWN;
+
+ if (!al_pcie_port_is_enabled(pcie_port)) {
+ al_err("PCIe %d: not enabled, cannot shutdown memory\n",
+ pcie_port->port_id);
+ return -EINVAL;
+ }
+
+ al_reg_write32_masked(regs->axi.pcie_global.conf,
+ mask, enable == AL_TRUE ? mask : 0);
+
+ return 0;
+}
+
+al_bool
+al_pcie_port_is_enabled(struct al_pcie_port *pcie_port)
+{
+ struct al_pbs_regs *pbs_reg_base = (struct al_pbs_regs *)pcie_port->pbs_regs;
+ uint32_t pcie_exist = al_reg_read32(&pbs_reg_base->unit.pcie_conf_1);
+
+ uint32_t ports_enabled = AL_REG_FIELD_GET(pcie_exist,
+ PBS_UNIT_PCIE_CONF_1_PCIE_EXIST_MASK,
+ PBS_UNIT_PCIE_CONF_1_PCIE_EXIST_SHIFT);
+
+ return (AL_REG_FIELD_GET(ports_enabled, AL_BIT(pcie_port->port_id),
+ pcie_port->port_id) == 1);
+}
+
+/*************************** PCIe Configuration API ***************************/
+
+/** configure pcie port (link params, etc..) */
+int
+al_pcie_port_config(struct al_pcie_port *pcie_port,
+ const struct al_pcie_port_config_params *params)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ enum al_pcie_operating_mode op_mode;
+ int status = 0;
+ int i;
+
+ if (!al_pcie_port_is_enabled(pcie_port)) {
+ al_err("PCIe %d: port not enabled, cannot configure port\n",
+ pcie_port->port_id);
+ return -EINVAL;
+ }
+
+ if (al_pcie_is_link_started(pcie_port)) {
+ al_err("PCIe %d: link already started, cannot configure port\n",
+ pcie_port->port_id);
+ return -EINVAL;
+ }
+
+ al_assert(pcie_port);
+ al_assert(params);
+
+ al_dbg("PCIe %d: port config\n", pcie_port->port_id);
+
+ op_mode = al_pcie_operating_mode_get(pcie_port);
+
+ /* if max lanes not specifies, read it from register */
+ if (pcie_port->max_lanes == 0) {
+ uint32_t global_conf = al_reg_read32(regs->axi.pcie_global.conf);
+ uint32_t act_lanes = AL_REG_FIELD_GET(global_conf,
+ (pcie_port->rev_id == AL_PCIE_REV_ID_3) ?
+ PCIE_REV3_AXI_MISC_PCIE_GLOBAL_CONF_NOF_ACT_LANES_MASK :
+ PCIE_REV1_2_AXI_MISC_PCIE_GLOBAL_CONF_NOF_ACT_LANES_MASK,
+ PCIE_REVX_AXI_MISC_PCIE_GLOBAL_CONF_NOF_ACT_LANES_SHIFT);
+
+ switch(act_lanes) {
+ case 0x1:
+ pcie_port->max_lanes = 1;
+ break;
+ case 0x3:
+ pcie_port->max_lanes = 2;
+ break;
+ case 0xf:
+ pcie_port->max_lanes = 4;
+ break;
+ case 0xff:
+ pcie_port->max_lanes = 8;
+ break;
+ default:
+ pcie_port->max_lanes = 0;
+ al_err("PCIe %d: invalid max lanes val (0x%x)\n", pcie_port->port_id, act_lanes);
+ break;
+ }
+ }
+
+ if (params->link_params)
+ status = al_pcie_port_link_config(pcie_port, params->link_params);
+ if (status)
+ goto done;
+
+ /* Change max read request size to 256 bytes
+ * Max Payload Size is remained untouched- it is the responsibility of
+ * the host to change the MPS, if needed.
+ */
+ for (i = 0; i < AL_MAX_NUM_OF_PFS; i++) {
+ al_reg_write32_masked(regs->core_space[i].pcie_dev_ctrl_status,
+ PCIE_PORT_DEV_CTRL_STATUS_MRRS_MASK,
+ PCIE_PORT_DEV_CTRL_STATUS_MRRS_VAL_256);
+ if (pcie_port->rev_id != AL_PCIE_REV_ID_3)
+ break;
+ }
+
+ if (pcie_port->rev_id == AL_PCIE_REV_ID_3) {
+ /* Set maximum physical function numbers */
+ al_reg_write32_masked(
+ &regs->port_regs->timer_ctrl_max_func_num,
+ PCIE_PORT_GEN3_MAX_FUNC_NUM,
+ pcie_port->max_num_of_pfs - 1);
+
+ al_pcie_port_wr_to_ro_set(pcie_port, AL_TRUE);
+
+ /**
+ * in EP mode, when we have more than 1 PF we need to assert
+ * multi-pf support so the host scan all PFs
+ */
+ if ((op_mode == AL_PCIE_OPERATING_MODE_EP) && (pcie_port->max_num_of_pfs > 1)) {
+ al_reg_write32_masked((uint32_t __iomem *)
+ (&regs->core_space[0].config_header[0] +
+ (PCIE_BIST_HEADER_TYPE_BASE >> 2)),
+ PCIE_BIST_HEADER_TYPE_MULTI_FUNC_MASK,
+ PCIE_BIST_HEADER_TYPE_MULTI_FUNC_MASK);
+ }
+
+ /* Disable TPH next pointer */
+ for (i = 0; i < AL_MAX_NUM_OF_PFS; i++) {
+ al_reg_write32_masked(regs->core_space[i].tph_cap_base,
+ PCIE_TPH_NEXT_POINTER, 0);
+ }
+
+ al_pcie_port_wr_to_ro_set(pcie_port, AL_FALSE);
+ }
+
+
+ status = al_pcie_port_snoop_config(pcie_port, params->enable_axi_snoop);
+ if (status)
+ goto done;
+
+ al_pcie_port_ram_parity_int_config(pcie_port, params->enable_ram_parity_int);
+
+ al_pcie_port_axi_parity_int_config(pcie_port, params->enable_axi_parity_int);
+
+ al_pcie_port_relaxed_pcie_ordering_config(pcie_port, params->relaxed_ordering_params);
+
+ if (params->lat_rply_timers)
+ status = al_pcie_port_lat_rply_timers_config(pcie_port, params->lat_rply_timers);
+ if (status)
+ goto done;
+
+ if (params->gen2_params)
+ status = al_pcie_port_gen2_params_config(pcie_port, params->gen2_params);
+ if (status)
+ goto done;
+
+ if (params->gen3_params)
+ status = al_pcie_port_gen3_params_config(pcie_port, params->gen3_params);
+ if (status)
+ goto done;
+
+ if (params->tl_credits)
+ status = al_pcie_port_tl_credits_config(pcie_port, params->tl_credits);
+ if (status)
+ goto done;
+
+ if (params->features)
+ al_pcie_port_features_config(pcie_port, params->features);
+
+ if (params->sris_params)
+ status = al_pcie_port_sris_config(pcie_port, params->sris_params,
+ params->link_params->max_speed);
+ if (status)
+ goto done;
+
+ al_pcie_port_ib_hcrd_config(pcie_port);
+
+ if (params->fast_link_mode) {
+ al_reg_write32_masked(&regs->port_regs->port_link_ctrl,
+ 1 << PCIE_PORT_LINK_CTRL_FAST_LINK_EN_SHIFT,
+ 1 << PCIE_PORT_LINK_CTRL_FAST_LINK_EN_SHIFT);
+ }
+
+ if (params->enable_axi_slave_err_resp)
+ al_reg_write32_masked(&regs->port_regs->axi_slave_err_resp,
+ 1 << PCIE_PORT_AXI_SLAVE_ERR_RESP_ALL_MAPPING_SHIFT,
+ 1 << PCIE_PORT_AXI_SLAVE_ERR_RESP_ALL_MAPPING_SHIFT);
+
+ /**
+ * Addressing RMN: 5477
+ *
+ * RMN description:
+ * address-decoder logic performs sub-target decoding even for transactions
+ * which undergo target enforcement. thus, in case transaction's address is
+ * inside any ECAM bar, the sub-target decoding will be set to ECAM, which
+ * causes wrong handling by PCIe unit
+ *
+ * Software flow:
+ * on EP mode only, turning on the iATU-enable bit (with the relevant mask
+ * below) allows the PCIe unit to discard the ECAM bit which was asserted
+ * by-mistake in the address-decoder
+ */
+ if (op_mode == AL_PCIE_OPERATING_MODE_EP) {
+ al_reg_write32_masked(regs->axi.ob_ctrl.cfg_target_bus,
+ PCIE_AXI_MISC_OB_CTRL_CFG_TARGET_BUS_MASK_MASK,
+ (0) << PCIE_AXI_MISC_OB_CTRL_CFG_TARGET_BUS_MASK_SHIFT);
+ al_reg_write32_masked(regs->axi.ob_ctrl.cfg_control,
+ PCIE_AXI_MISC_OB_CTRL_CFG_CONTROL_IATU_EN,
+ PCIE_AXI_MISC_OB_CTRL_CFG_CONTROL_IATU_EN);
+ }
+
+ if (op_mode == AL_PCIE_OPERATING_MODE_RC) {
+ /**
+ * enable memory and I/O access from port when in RC mode
+ * in RC mode, only core_space[0] is valid.
+ */
+ al_reg_write16_masked(
+ (uint16_t __iomem *)(&regs->core_space[0].config_header[0] + (0x4 >> 2)),
+ 0x7, /* Mem, MSE, IO */
+ 0x7);
+
+ /* change the class code to match pci bridge */
+ al_pcie_port_wr_to_ro_set(pcie_port, AL_TRUE);
+
+ al_reg_write32_masked(
+ (uint32_t __iomem *)(&regs->core_space[0].config_header[0]
+ + (PCI_CLASS_REVISION >> 2)),
+ 0xFFFFFF00,
+ 0x06040000);
+
+ al_pcie_port_wr_to_ro_set(pcie_port, AL_FALSE);
+
+ /**
+ * Addressing RMN: 5702
+ *
+ * RMN description:
+ * target bus mask default value in HW is: 0xFE, this enforces
+ * setting the target bus for ports 1 and 3 when running on RC
+ * mode since bit[20] in ECAM address in these cases is set
+ *
+ * Software flow:
+ * on RC mode only, set target-bus value to 0xFF to prevent this
+ * enforcement
+ */
+ al_reg_write32_masked(regs->axi.ob_ctrl.cfg_target_bus,
+ PCIE_AXI_MISC_OB_CTRL_CFG_TARGET_BUS_MASK_MASK,
+ PCIE_AXI_MISC_OB_CTRL_CFG_TARGET_BUS_MASK_MASK);
+ }
+done:
+ al_dbg("PCIe %d: port config %s\n", pcie_port->port_id, status? "failed": "done");
+
+ return status;
+}
+
+int
+al_pcie_pf_config(
+ struct al_pcie_pf *pcie_pf,
+ const struct al_pcie_pf_config_params *params)
+{
+ struct al_pcie_port *pcie_port;
+ int status = 0;
+
+ al_assert(pcie_pf);
+ al_assert(params);
+
+ pcie_port = pcie_pf->pcie_port;
+
+ if (!al_pcie_port_is_enabled(pcie_port)) {
+ al_err("PCIe %d: port not enabled, cannot configure port\n", pcie_port->port_id);
+ return -EINVAL;
+ }
+
+ al_dbg("PCIe %d: pf %d config\n", pcie_port->port_id, pcie_pf->pf_num);
+
+ if (params)
+ status = al_pcie_port_pf_params_config(pcie_pf, params);
+ if (status)
+ goto done;
+
+done:
+ al_dbg("PCIe %d: pf %d config %s\n",
+ pcie_port->port_id, pcie_pf->pf_num, status ? "failed" : "done");
+
+ return status;
+}
+
+/************************** PCIe Link Operations API **************************/
+
+/* start pcie link */
+int
+al_pcie_link_start(struct al_pcie_port *pcie_port)
+{
+ struct al_pcie_regs *regs = (struct al_pcie_regs *)pcie_port->regs;
+
+ if (!al_pcie_port_is_enabled(pcie_port)) {
+ al_err("PCIe %d: port not enabled, cannot start link\n",
+ pcie_port->port_id);
+ return -EINVAL;
+ }
+
+ al_dbg("PCIe_%d: start port link.\n", pcie_port->port_id);
+
+ al_reg_write32_masked(
+ regs->app.global_ctrl.port_init,
+ PCIE_W_GLOBAL_CTRL_PORT_INIT_APP_LTSSM_EN_MASK,
+ PCIE_W_GLOBAL_CTRL_PORT_INIT_APP_LTSSM_EN_MASK);
+
+ return 0;
+}
+
+/* stop pcie link */
+int
+al_pcie_link_stop(struct al_pcie_port *pcie_port)
+{
+ struct al_pcie_regs *regs = (struct al_pcie_regs *)pcie_port->regs;
+
+ if (!al_pcie_is_link_started(pcie_port)) {
+ al_warn("PCIe %d: trying to stop a non-started link\n",
+ pcie_port->port_id);
+ }
+
+ al_dbg("PCIe_%d: stop port link.\n", pcie_port->port_id);
+
+ al_reg_write32_masked(
+ regs->app.global_ctrl.port_init,
+ PCIE_W_GLOBAL_CTRL_PORT_INIT_APP_LTSSM_EN_MASK,
+ ~PCIE_W_GLOBAL_CTRL_PORT_INIT_APP_LTSSM_EN_MASK);
+
+ return 0;
+}
+
+/* wait for link up indication */
+int
+al_pcie_link_up_wait(struct al_pcie_port *pcie_port, uint32_t timeout_ms)
+{
+ int wait_count = timeout_ms * AL_PCIE_LINKUP_WAIT_INTERVALS_PER_SEC;
+
+ while (wait_count-- > 0) {
+ if (al_pcie_check_link(pcie_port, NULL)) {
+ al_info("PCIe_%d: <<<<<<<<< Link up >>>>>>>>>\n", pcie_port->port_id);
+ return 0;
+ } else
+ al_dbg("PCIe_%d: No link up, %d attempts remaining\n",
+ pcie_port->port_id, wait_count);
+
+ al_udelay(AL_PCIE_LINKUP_WAIT_INTERVAL);
+ }
+ al_info("PCIE_%d: link is not established in time\n",
+ pcie_port->port_id);
+
+ return ETIMEDOUT;
+}
+
+/** get link status */
+int
+al_pcie_link_status(struct al_pcie_port *pcie_port,
+ struct al_pcie_link_status *status)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ uint16_t pcie_lnksta;
+
+ al_assert(status);
+
+ status->link_up = al_pcie_check_link(pcie_port, &status->ltssm_state);
+
+ if (!status->link_up) {
+ status->speed = AL_PCIE_LINK_SPEED_DEFAULT;
+ status->lanes = 0;
+ return 0;
+ }
+
+ pcie_lnksta = al_reg_read16((uint16_t __iomem *)regs->core_space[0].pcie_cap_base + (AL_PCI_EXP_LNKSTA >> 1));
+
+ switch(pcie_lnksta & AL_PCI_EXP_LNKSTA_CLS) {
+ case AL_PCI_EXP_LNKSTA_CLS_2_5GB:
+ status->speed = AL_PCIE_LINK_SPEED_GEN1;
+ break;
+ case AL_PCI_EXP_LNKSTA_CLS_5_0GB:
+ status->speed = AL_PCIE_LINK_SPEED_GEN2;
+ break;
+ case AL_PCI_EXP_LNKSTA_CLS_8_0GB:
+ status->speed = AL_PCIE_LINK_SPEED_GEN3;
+ break;
+ default:
+ status->speed = AL_PCIE_LINK_SPEED_DEFAULT;
+ al_err("PCIe %d: unknown link speed indication. PCIE LINK STATUS %x\n",
+ pcie_port->port_id, pcie_lnksta);
+ }
+ status->lanes = (pcie_lnksta & AL_PCI_EXP_LNKSTA_NLW) >> AL_PCI_EXP_LNKSTA_NLW_SHIFT;
+ al_info("PCIe %d: Link up. speed gen%d negotiated width %d\n",
+ pcie_port->port_id, status->speed, status->lanes);
+
+ return 0;
+}
+
+/** get lane status */
+void
+al_pcie_lane_status_get(
+ struct al_pcie_port *pcie_port,
+ unsigned int lane,
+ struct al_pcie_lane_status *status)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ uint32_t lane_status;
+ uint32_t *reg_ptr;
+
+ al_assert(pcie_port);
+ al_assert(status);
+ al_assert((pcie_port->rev_id != AL_PCIE_REV_ID_1) || (lane < REV1_2_MAX_NUM_LANES));
+ al_assert((pcie_port->rev_id != AL_PCIE_REV_ID_2) || (lane < REV1_2_MAX_NUM_LANES));
+ al_assert((pcie_port->rev_id != AL_PCIE_REV_ID_3) || (lane < REV3_MAX_NUM_LANES));
+
+ reg_ptr = regs->axi.status.lane[lane];
+
+ /* Reset field is valid only when same value is read twice */
+ do {
+ lane_status = al_reg_read32(reg_ptr);
+ status->is_reset = !!(lane_status & PCIE_AXI_STATUS_LANE_IS_RESET);
+ } while (status->is_reset != (!!(al_reg_read32(reg_ptr) & PCIE_AXI_STATUS_LANE_IS_RESET)));
+
+ status->requested_speed =
+ (lane_status & PCIE_AXI_STATUS_LANE_REQUESTED_SPEED_MASK) >>
+ PCIE_AXI_STATUS_LANE_REQUESTED_SPEED_SHIFT;
+}
+
+/** trigger hot reset */
+int
+al_pcie_link_hot_reset(struct al_pcie_port *pcie_port, al_bool enable)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ uint32_t events_gen;
+ al_bool app_reset_state;
+ enum al_pcie_operating_mode op_mode = al_pcie_operating_mode_get(pcie_port);
+
+ if (op_mode != AL_PCIE_OPERATING_MODE_RC) {
+ al_err("PCIe %d: hot-reset is applicable only for RC mode\n", pcie_port->port_id);
+ return -EINVAL;
+ }
+
+ if (!al_pcie_is_link_started(pcie_port)) {
+ al_err("PCIe %d: link not started, cannot trigger hot-reset\n", pcie_port->port_id);
+ return -EINVAL;
+ }
+
+ events_gen = al_reg_read32(regs->app.global_ctrl.events_gen[0]);
+ app_reset_state = events_gen & PCIE_W_GLOBAL_CTRL_EVENTS_GEN_APP_RST_INIT;
+
+ if (enable && app_reset_state) {
+ al_err("PCIe %d: link is already in hot-reset state\n", pcie_port->port_id);
+ return -EINVAL;
+ } else if ((!enable) && (!(app_reset_state))) {
+ al_err("PCIe %d: link is already in non-hot-reset state\n", pcie_port->port_id);
+ return -EINVAL;
+ } else {
+ al_dbg("PCIe %d: %s hot-reset\n", pcie_port->port_id,
+ (enable ? "enabling" : "disabling"));
+ /* hot-reset functionality is implemented only for function 0 */
+ al_reg_write32_masked(regs->app.global_ctrl.events_gen[0],
+ PCIE_W_GLOBAL_CTRL_EVENTS_GEN_APP_RST_INIT,
+ (enable ? PCIE_W_GLOBAL_CTRL_EVENTS_GEN_APP_RST_INIT
+ : ~PCIE_W_GLOBAL_CTRL_EVENTS_GEN_APP_RST_INIT));
+ return 0;
+ }
+}
+
+/** disable port link */
+int
+al_pcie_link_disable(struct al_pcie_port *pcie_port, al_bool disable)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ uint32_t pcie_lnkctl;
+ al_bool link_disable_state;
+ enum al_pcie_operating_mode op_mode = al_pcie_operating_mode_get(pcie_port);
+
+ if (op_mode != AL_PCIE_OPERATING_MODE_RC) {
+ al_err("PCIe %d: hot-reset is applicable only for RC mode\n", pcie_port->port_id);
+ return -EINVAL;
+ }
+
+ if (!al_pcie_is_link_started(pcie_port)) {
+ al_err("PCIe %d: link not started, cannot disable link\n", pcie_port->port_id);
+ return -EINVAL;
+ }
+
+ pcie_lnkctl = al_reg_read32(regs->core_space[0].pcie_cap_base + (AL_PCI_EXP_LNKCTL >> 1));
+ link_disable_state = pcie_lnkctl & AL_PCI_EXP_LNKCTL_LNK_DIS;
+
+ if (disable && link_disable_state) {
+ al_err("PCIe %d: link is already in disable state\n", pcie_port->port_id);
+ return -EINVAL;
+ } else if ((!disable) && (!(link_disable_state))) {
+ al_err("PCIe %d: link is already in enable state\n", pcie_port->port_id);
+ return -EINVAL;
+ }
+
+ al_dbg("PCIe %d: %s port\n", pcie_port->port_id, (disable ? "disabling" : "enabling"));
+ al_reg_write32_masked(regs->core_space[0].pcie_cap_base + (AL_PCI_EXP_LNKCTL >> 1),
+ AL_PCI_EXP_LNKCTL_LNK_DIS,
+ (disable ? AL_PCI_EXP_LNKCTL_LNK_DIS : ~AL_PCI_EXP_LNKCTL_LNK_DIS));
+ return 0;
+}
+
+/** retrain link */
+int
+al_pcie_link_retrain(struct al_pcie_port *pcie_port)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ enum al_pcie_operating_mode op_mode = al_pcie_operating_mode_get(pcie_port);
+
+ if (op_mode != AL_PCIE_OPERATING_MODE_RC) {
+ al_err("PCIe %d: link-retrain is applicable only for RC mode\n",
+ pcie_port->port_id);
+ return -EINVAL;
+ }
+
+ if (!al_pcie_is_link_started(pcie_port)) {
+ al_err("PCIe %d: link not started, cannot link-retrain\n", pcie_port->port_id);
+ return -EINVAL;
+ }
+
+ al_reg_write32_masked(regs->core_space[0].pcie_cap_base + (AL_PCI_EXP_LNKCTL >> 1),
+ AL_PCI_EXP_LNKCTL_LNK_RTRN, AL_PCI_EXP_LNKCTL_LNK_RTRN);
+
+ return 0;
+}
+
+/* trigger speed change */
+int
+al_pcie_link_change_speed(struct al_pcie_port *pcie_port,
+ enum al_pcie_link_speed new_speed)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+
+ if (!al_pcie_is_link_started(pcie_port)) {
+ al_err("PCIe %d: link not started, cannot change speed\n", pcie_port->port_id);
+ return -EINVAL;
+ }
+
+ al_dbg("PCIe %d: changing speed to %d\n", pcie_port->port_id, new_speed);
+
+ al_pcie_port_link_speed_ctrl_set(pcie_port, new_speed);
+
+ al_reg_write32_masked(&regs->port_regs->gen2_ctrl,
+ PCIE_PORT_GEN2_CTRL_DIRECT_SPEED_CHANGE,
+ PCIE_PORT_GEN2_CTRL_DIRECT_SPEED_CHANGE);
+
+ return 0;
+}
+
+/* TODO: check if this function needed */
+int
+al_pcie_link_change_width(struct al_pcie_port *pcie_port,
+ uint8_t width __attribute__((__unused__)))
+{
+ al_err("PCIe %d: link change width not implemented\n",
+ pcie_port->port_id);
+
+ return -ENOSYS;
+}
+
+/**************************** Post Link Start API *****************************/
+
+/************************** Snoop Configuration API ***************************/
+
+int
+al_pcie_port_snoop_config(struct al_pcie_port *pcie_port, al_bool enable_axi_snoop)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+
+ /* Set snoop mode */
+ al_info("PCIE_%d: snoop mode %s\n",
+ pcie_port->port_id, enable_axi_snoop ? "enable" : "disable");
+
+ if (enable_axi_snoop) {
+ al_reg_write32_masked(regs->axi.ctrl.master_arctl,
+ PCIE_AXI_CTRL_MASTER_ARCTL_OVR_SNOOP | PCIE_AXI_CTRL_MASTER_ARCTL_SNOOP,
+ PCIE_AXI_CTRL_MASTER_ARCTL_OVR_SNOOP | PCIE_AXI_CTRL_MASTER_ARCTL_SNOOP);
+
+ al_reg_write32_masked(regs->axi.ctrl.master_awctl,
+ PCIE_AXI_CTRL_MASTER_AWCTL_OVR_SNOOP | PCIE_AXI_CTRL_MASTER_AWCTL_SNOOP,
+ PCIE_AXI_CTRL_MASTER_AWCTL_OVR_SNOOP | PCIE_AXI_CTRL_MASTER_AWCTL_SNOOP);
+ } else {
+ al_reg_write32_masked(regs->axi.ctrl.master_arctl,
+ PCIE_AXI_CTRL_MASTER_ARCTL_OVR_SNOOP | PCIE_AXI_CTRL_MASTER_ARCTL_SNOOP,
+ PCIE_AXI_CTRL_MASTER_ARCTL_OVR_SNOOP);
+
+ al_reg_write32_masked(regs->axi.ctrl.master_awctl,
+ PCIE_AXI_CTRL_MASTER_AWCTL_OVR_SNOOP | PCIE_AXI_CTRL_MASTER_AWCTL_SNOOP,
+ PCIE_AXI_CTRL_MASTER_AWCTL_OVR_SNOOP);
+ }
+ return 0;
+}
+
+/************************** Configuration Space API ***************************/
+
+/** get base address of pci configuration space header */
+int
+al_pcie_config_space_get(struct al_pcie_pf *pcie_pf,
+ uint8_t __iomem **addr)
+{
+ struct al_pcie_regs *regs = pcie_pf->pcie_port->regs;
+
+ *addr = (uint8_t __iomem *)&regs->core_space[pcie_pf->pf_num].config_header[0];
+ return 0;
+}
+
+/* Read data from the local configuration space */
+uint32_t
+al_pcie_local_cfg_space_read(
+ struct al_pcie_pf *pcie_pf,
+ unsigned int reg_offset)
+{
+ struct al_pcie_regs *regs = pcie_pf->pcie_port->regs;
+ uint32_t data;
+
+ data = al_reg_read32(&regs->core_space[pcie_pf->pf_num].config_header[reg_offset]);
+
+ return data;
+}
+
+/* Write data to the local configuration space */
+void
+al_pcie_local_cfg_space_write(
+ struct al_pcie_pf *pcie_pf,
+ unsigned int reg_offset,
+ uint32_t data,
+ al_bool cs2,
+ al_bool allow_ro_wr)
+{
+ struct al_pcie_port *pcie_port = pcie_pf->pcie_port;
+ struct al_pcie_regs *regs = pcie_port->regs;
+ unsigned int pf_num = pcie_pf->pf_num;
+ uint32_t *offset = &regs->core_space[pf_num].config_header[reg_offset];
+
+ if (allow_ro_wr)
+ al_pcie_port_wr_to_ro_set(pcie_port, AL_TRUE);
+
+ if (cs2 == AL_FALSE)
+ al_reg_write32(offset, data);
+ else
+ al_reg_write32_dbi_cs2(pcie_port, offset, data);
+
+ if (allow_ro_wr)
+ al_pcie_port_wr_to_ro_set(pcie_port, AL_FALSE);
+}
+
+/** set target_bus and mask_target_bus */
+int
+al_pcie_target_bus_set(
+ struct al_pcie_port *pcie_port,
+ uint8_t target_bus,
+ uint8_t mask_target_bus)
+{
+ struct al_pcie_regs *regs = (struct al_pcie_regs *)pcie_port->regs;
+ uint32_t reg;
+
+ reg = al_reg_read32(regs->axi.ob_ctrl.cfg_target_bus);
+ AL_REG_FIELD_SET(reg, PCIE_AXI_MISC_OB_CTRL_CFG_TARGET_BUS_MASK_MASK,
+ PCIE_AXI_MISC_OB_CTRL_CFG_TARGET_BUS_MASK_SHIFT,
+ mask_target_bus);
+ AL_REG_FIELD_SET(reg, PCIE_AXI_MISC_OB_CTRL_CFG_TARGET_BUS_BUSNUM_MASK,
+ PCIE_AXI_MISC_OB_CTRL_CFG_TARGET_BUS_BUSNUM_SHIFT,
+ target_bus);
+ al_reg_write32(regs->axi.ob_ctrl.cfg_target_bus, reg);
+ return 0;
+}
+
+/** get target_bus and mask_target_bus */
+int
+al_pcie_target_bus_get(
+ struct al_pcie_port *pcie_port,
+ uint8_t *target_bus,
+ uint8_t *mask_target_bus)
+{
+ struct al_pcie_regs *regs = (struct al_pcie_regs *)pcie_port->regs;
+ uint32_t reg;
+
+ al_assert(target_bus);
+ al_assert(mask_target_bus);
+
+ reg = al_reg_read32(regs->axi.ob_ctrl.cfg_target_bus);
+
+ *mask_target_bus = AL_REG_FIELD_GET(reg,
+ PCIE_AXI_MISC_OB_CTRL_CFG_TARGET_BUS_MASK_MASK,
+ PCIE_AXI_MISC_OB_CTRL_CFG_TARGET_BUS_MASK_SHIFT);
+ *target_bus = AL_REG_FIELD_GET(reg,
+ PCIE_AXI_MISC_OB_CTRL_CFG_TARGET_BUS_BUSNUM_MASK,
+ PCIE_AXI_MISC_OB_CTRL_CFG_TARGET_BUS_BUSNUM_SHIFT);
+ return 0;
+}
+
+/** Set secondary bus number */
+int
+al_pcie_secondary_bus_set(struct al_pcie_port *pcie_port, uint8_t secbus)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+
+ uint32_t secbus_val = (secbus <<
+ PCIE_AXI_MISC_OB_CTRL_CFG_CONTROL_SEC_BUS_SHIFT);
+
+ al_reg_write32_masked(
+ regs->axi.ob_ctrl.cfg_control,
+ PCIE_AXI_MISC_OB_CTRL_CFG_CONTROL_SEC_BUS_MASK,
+ secbus_val);
+ return 0;
+}
+
+/** Set sub-ordinary bus number */
+int
+al_pcie_subordinary_bus_set(struct al_pcie_port *pcie_port, uint8_t subbus)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+
+ uint32_t subbus_val = (subbus <<
+ PCIE_AXI_MISC_OB_CTRL_CFG_CONTROL_SUBBUS_SHIFT);
+
+ al_reg_write32_masked(
+ regs->axi.ob_ctrl.cfg_control,
+ PCIE_AXI_MISC_OB_CTRL_CFG_CONTROL_SUBBUS_MASK,
+ subbus_val);
+ return 0;
+}
+
+/* Enable/disable deferring incoming configuration requests */
+void
+al_pcie_app_req_retry_set(
+ struct al_pcie_port *pcie_port,
+ al_bool en)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ uint32_t mask = (pcie_port->rev_id == AL_PCIE_REV_ID_3) ?
+ PCIE_W_REV3_GLOBAL_CTRL_PM_CONTROL_APP_REQ_RETRY_EN :
+ PCIE_W_REV1_2_GLOBAL_CTRL_PM_CONTROL_APP_REQ_RETRY_EN;
+
+ al_reg_write32_masked(regs->app.global_ctrl.pm_control,
+ mask, (en == AL_TRUE) ? mask : 0);
+}
+
+/*************** Internal Address Translation Unit (ATU) API ******************/
+
+/** program internal ATU region entry */
+int
+al_pcie_atu_region_set(
+ struct al_pcie_port *pcie_port,
+ struct al_pcie_atu_region *atu_region)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ enum al_pcie_operating_mode op_mode = al_pcie_operating_mode_get(pcie_port);
+ uint32_t reg = 0;
+
+ /**
+ * Addressing RMN: 5384
+ *
+ * RMN description:
+ * From SNPS (also included in the data book) Dynamic iATU Programming
+ * With AHB/AXI Bridge Module When the bridge slave interface clock
+ * (hresetn or slv_aclk) is asynchronous to the PCIe native core clock
+ * (core_clk), you must not update the iATU registers while operations
+ * are in progress on the AHB/AXI bridge slave interface. The iATU
+ * registers are in the core_clk clock domain. The register outputs are
+ * used in the AHB/AXI bridge slave interface clock domain. There is no
+ * synchronization logic between these registers and the AHB/AXI bridge
+ * slave interface.
+ *
+ * Software flow:
+ * Do not allow configuring Outbound iATU after link is started
+ */
+ if ((atu_region->direction == AL_PCIE_ATU_DIR_OUTBOUND)
+ && (al_pcie_is_link_started(pcie_port))) {
+ if (!atu_region->enforce_ob_atu_region_set) {
+ al_err("PCIe %d: setting OB iATU after link is started is not allowed\n",
+ pcie_port->port_id);
+ return -EINVAL;
+ } else {
+ al_info("PCIe %d: setting OB iATU even after link is started\n",
+ pcie_port->port_id);
+ }
+ }
+
+ /*TODO : add sanity check */
+ AL_REG_FIELD_SET(reg, 0xF, 0, atu_region->index);
+ AL_REG_BIT_VAL_SET(reg, 31, atu_region->direction);
+ al_reg_write32(&regs->port_regs->iatu.index, reg);
+
+ al_reg_write32(&regs->port_regs->iatu.lower_base_addr,
+ (uint32_t)(atu_region->base_addr & 0xFFFFFFFF));
+ al_reg_write32(&regs->port_regs->iatu.upper_base_addr,
+ (uint32_t)((atu_region->base_addr >> 32)& 0xFFFFFFFF));
+ al_reg_write32(&regs->port_regs->iatu.lower_target_addr,
+ (uint32_t)(atu_region->target_addr & 0xFFFFFFFF));
+ al_reg_write32(&regs->port_regs->iatu.upper_target_addr,
+ (uint32_t)((atu_region->target_addr >> 32)& 0xFFFFFFFF));
+
+ /* configure the limit, not needed when working in BAR match mode */
+ if (atu_region->match_mode == 0) {
+ uint32_t limit_reg_val;
+ if (pcie_port->rev_id > AL_PCIE_REV_ID_0) {
+ uint32_t *limit_ext_reg =
+ (atu_region->direction == AL_PCIE_ATU_DIR_OUTBOUND) ?
+ &regs->app.atu.out_mask_pair[atu_region->index / 2] :
+ &regs->app.atu.in_mask_pair[atu_region->index / 2];
+ uint32_t limit_ext_reg_mask =
+ (atu_region->index % 2) ?
+ PCIE_W_ATU_MASK_EVEN_ODD_ATU_MASK_40_32_ODD_MASK :
+ PCIE_W_ATU_MASK_EVEN_ODD_ATU_MASK_40_32_EVEN_MASK;
+ unsigned int limit_ext_reg_shift =
+ (atu_region->index % 2) ?
+ PCIE_W_ATU_MASK_EVEN_ODD_ATU_MASK_40_32_ODD_SHIFT :
+ PCIE_W_ATU_MASK_EVEN_ODD_ATU_MASK_40_32_EVEN_SHIFT;
+ uint64_t limit_sz_msk =
+ atu_region->limit - atu_region->base_addr;
+ uint32_t limit_ext_reg_val = (uint32_t)(((limit_sz_msk) >>
+ 32) & 0xFFFFFFFF);
+
+ if (limit_ext_reg_val) {
+ limit_reg_val = (uint32_t)((limit_sz_msk) & 0xFFFFFFFF);
+ al_assert(limit_reg_val == 0xFFFFFFFF);
+ } else {
+ limit_reg_val = (uint32_t)(atu_region->limit &
+ 0xFFFFFFFF);
+ }
+
+ al_reg_write32_masked(
+ limit_ext_reg,
+ limit_ext_reg_mask,
+ limit_ext_reg_val << limit_ext_reg_shift);
+ } else {
+ limit_reg_val = (uint32_t)(atu_region->limit & 0xFFFFFFFF);
+ }
+
+ al_reg_write32(&regs->port_regs->iatu.limit_addr,
+ limit_reg_val);
+ }
+
+ reg = 0;
+ AL_REG_FIELD_SET(reg, 0x1F, 0, atu_region->tlp_type);
+ AL_REG_FIELD_SET(reg, 0x3 << 9, 9, atu_region->attr);
+
+
+ if ((pcie_port->rev_id == AL_PCIE_REV_ID_3)
+ && (op_mode == AL_PCIE_OPERATING_MODE_EP)
+ && (atu_region->function_match_bypass_mode)) {
+ AL_REG_FIELD_SET(reg,
+ PCIE_IATU_CR1_FUNC_NUM_MASK,
+ PCIE_IATU_CR1_FUNC_NUM_SHIFT,
+ atu_region->function_match_bypass_mode_number);
+ }
+
+ al_reg_write32(&regs->port_regs->iatu.cr1, reg);
+
+ /* Enable/disable the region. */
+ reg = 0;
+ AL_REG_FIELD_SET(reg, 0xFF, 0, atu_region->msg_code);
+ AL_REG_FIELD_SET(reg, 0x700, 8, atu_region->bar_number);
+ AL_REG_FIELD_SET(reg, 0x3 << 24, 24, atu_region->response);
+ AL_REG_BIT_VAL_SET(reg, 16, atu_region->enable_attr_match_mode == AL_TRUE);
+ AL_REG_BIT_VAL_SET(reg, 21, atu_region->enable_msg_match_mode == AL_TRUE);
+ AL_REG_BIT_VAL_SET(reg, 28, atu_region->cfg_shift_mode == AL_TRUE);
+ AL_REG_BIT_VAL_SET(reg, 29, atu_region->invert_matching == AL_TRUE);
+ if (atu_region->tlp_type == AL_PCIE_TLP_TYPE_MEM || atu_region->tlp_type == AL_PCIE_TLP_TYPE_IO)
+ AL_REG_BIT_VAL_SET(reg, 30, !!atu_region->match_mode);
+ AL_REG_BIT_VAL_SET(reg, 31, !!atu_region->enable);
+
+ /* In outbound, enable function bypass
+ * In inbound, enable function match mode
+ * Note: this is the same bit, has different meanings in ob/ib ATUs
+ */
+ if (op_mode == AL_PCIE_OPERATING_MODE_EP)
+ AL_REG_FIELD_SET(reg,
+ PCIE_IATU_CR2_FUNC_NUM_TRANS_BYPASS_FUNC_MATCH_ENABLE_MASK,
+ PCIE_IATU_CR2_FUNC_NUM_TRANS_BYPASS_FUNC_MATCH_ENABLE_SHIFT,
+ atu_region->function_match_bypass_mode ? 0x1 : 0x0);
+
+ al_reg_write32(&regs->port_regs->iatu.cr2, reg);
+
+ return 0;
+}
+
+/** obtains internal ATU region base/target addresses */
+void
+al_pcie_atu_region_get_fields(
+ struct al_pcie_port *pcie_port,
+ enum al_pcie_atu_dir direction, uint8_t index,
+ al_bool *enable, uint64_t *base_addr, uint64_t *target_addr)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+ uint64_t high_addr;
+ uint32_t reg = 0;
+
+ AL_REG_FIELD_SET(reg, 0xF, 0, index);
+ AL_REG_BIT_VAL_SET(reg, 31, direction);
+ al_reg_write32(&regs->port_regs->iatu.index, reg);
+
+ *base_addr = al_reg_read32(&regs->port_regs->iatu.lower_base_addr);
+ high_addr = al_reg_read32(&regs->port_regs->iatu.upper_base_addr);
+ high_addr <<= 32;
+ *base_addr |= high_addr;
+
+ *target_addr = al_reg_read32(&regs->port_regs->iatu.lower_target_addr);
+ high_addr = al_reg_read32(&regs->port_regs->iatu.upper_target_addr);
+ high_addr <<= 32;
+ *target_addr |= high_addr;
+
+ reg = al_reg_read32(&regs->port_regs->iatu.cr1);
+ *enable = AL_REG_BIT_GET(reg, 31) ? AL_TRUE : AL_FALSE;
+}
+
+void
+al_pcie_axi_io_config(
+ struct al_pcie_port *pcie_port,
+ al_phys_addr_t start,
+ al_phys_addr_t end)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+
+ al_reg_write32(regs->axi.ob_ctrl.io_start_h,
+ (uint32_t)((start >> 32) & 0xFFFFFFFF));
+
+ al_reg_write32(regs->axi.ob_ctrl.io_start_l,
+ (uint32_t)(start & 0xFFFFFFFF));
+
+ al_reg_write32(regs->axi.ob_ctrl.io_limit_h,
+ (uint32_t)((end >> 32) & 0xFFFFFFFF));
+
+ al_reg_write32(regs->axi.ob_ctrl.io_limit_l,
+ (uint32_t)(end & 0xFFFFFFFF));
+
+ al_reg_write32_masked(regs->axi.ctrl.slv_ctl,
+ PCIE_AXI_CTRL_SLV_CTRL_IO_BAR_EN,
+ PCIE_AXI_CTRL_SLV_CTRL_IO_BAR_EN);
+}
+
+/************** Interrupt generation (Endpoint mode Only) API *****************/
+
+/** generate INTx Assert/DeAssert Message */
+int
+al_pcie_legacy_int_gen(
+ struct al_pcie_pf *pcie_pf,
+ al_bool assert,
+ enum al_pcie_legacy_int_type type)
+{
+ struct al_pcie_regs *regs = pcie_pf->pcie_port->regs;
+ unsigned int pf_num = pcie_pf->pf_num;
+ uint32_t reg;
+
+ al_assert(type == AL_PCIE_LEGACY_INTA); /* only INTA supported */
+ reg = al_reg_read32(regs->app.global_ctrl.events_gen[pf_num]);
+ AL_REG_BIT_VAL_SET(reg, 3, !!assert);
+ al_reg_write32(regs->app.global_ctrl.events_gen[pf_num], reg);
+
+ return 0;
+}
+
+/** generate MSI interrupt */
+int
+al_pcie_msi_int_gen(struct al_pcie_pf *pcie_pf, uint8_t vector)
+{
+ struct al_pcie_regs *regs = pcie_pf->pcie_port->regs;
+ unsigned int pf_num = pcie_pf->pf_num;
+ uint32_t reg;
+
+ /* set msi vector and clear MSI request */
+ reg = al_reg_read32(regs->app.global_ctrl.events_gen[pf_num]);
+ AL_REG_BIT_CLEAR(reg, 4);
+ AL_REG_FIELD_SET(reg,
+ PCIE_W_GLOBAL_CTRL_EVENTS_GEN_MSI_VECTOR_MASK,
+ PCIE_W_GLOBAL_CTRL_EVENTS_GEN_MSI_VECTOR_SHIFT,
+ vector);
+ al_reg_write32(regs->app.global_ctrl.events_gen[pf_num], reg);
+ /* set MSI request */
+ AL_REG_BIT_SET(reg, 4);
+ al_reg_write32(regs->app.global_ctrl.events_gen[pf_num], reg);
+
+ return 0;
+}
+
+/** configure MSIX capability */
+int
+al_pcie_msix_config(
+ struct al_pcie_pf *pcie_pf,
+ struct al_pcie_msix_params *msix_params)
+{
+ struct al_pcie_regs *regs = pcie_pf->pcie_port->regs;
+ unsigned int pf_num = pcie_pf->pf_num;
+ uint32_t msix_reg0;
+
+ al_pcie_port_wr_to_ro_set(pcie_pf->pcie_port, AL_TRUE);
+
+ msix_reg0 = al_reg_read32(regs->core_space[pf_num].msix_cap_base);
+
+ msix_reg0 &= ~(AL_PCI_MSIX_MSGCTRL_TBL_SIZE << AL_PCI_MSIX_MSGCTRL_TBL_SIZE_SHIFT);
+ msix_reg0 |= ((msix_params->table_size - 1) & AL_PCI_MSIX_MSGCTRL_TBL_SIZE) <<
+ AL_PCI_MSIX_MSGCTRL_TBL_SIZE_SHIFT;
+ al_reg_write32(regs->core_space[pf_num].msix_cap_base, msix_reg0);
+
+ /* Table offset & BAR */
+ al_reg_write32(regs->core_space[pf_num].msix_cap_base + (AL_PCI_MSIX_TABLE >> 2),
+ (msix_params->table_offset & AL_PCI_MSIX_TABLE_OFFSET) |
+ (msix_params->table_bar & AL_PCI_MSIX_TABLE_BAR));
+ /* PBA offset & BAR */
+ al_reg_write32(regs->core_space[pf_num].msix_cap_base + (AL_PCI_MSIX_PBA >> 2),
+ (msix_params->pba_offset & AL_PCI_MSIX_PBA_OFFSET) |
+ (msix_params->pba_bar & AL_PCI_MSIX_PBA_BAR));
+
+ al_pcie_port_wr_to_ro_set(pcie_pf->pcie_port, AL_FALSE);
+
+ return 0;
+}
+
+/** check whether MSIX is enabled */
+al_bool
+al_pcie_msix_enabled(struct al_pcie_pf *pcie_pf)
+{
+ struct al_pcie_regs *regs = pcie_pf->pcie_port->regs;
+ uint32_t msix_reg0 = al_reg_read32(regs->core_space[pcie_pf->pf_num].msix_cap_base);
+
+ if (msix_reg0 & AL_PCI_MSIX_MSGCTRL_EN)
+ return AL_TRUE;
+ return AL_FALSE;
+}
+
+/** check whether MSIX is masked */
+al_bool
+al_pcie_msix_masked(struct al_pcie_pf *pcie_pf)
+{
+ struct al_pcie_regs *regs = pcie_pf->pcie_port->regs;
+ uint32_t msix_reg0 = al_reg_read32(regs->core_space[pcie_pf->pf_num].msix_cap_base);
+
+ if (msix_reg0 & AL_PCI_MSIX_MSGCTRL_MASK)
+ return AL_TRUE;
+ return AL_FALSE;
+}
+
+/******************** Advanced Error Reporting (AER) API **********************/
+
+/** configure AER capability */
+int
+al_pcie_aer_config(
+ struct al_pcie_pf *pcie_pf,
+ struct al_pcie_aer_params *params)
+{
+ struct al_pcie_regs *regs = pcie_pf->pcie_port->regs;
+ struct al_pcie_core_aer_regs *aer_regs = regs->core_space[pcie_pf->pf_num].aer;
+ uint32_t reg_val;
+
+ reg_val = al_reg_read32(&aer_regs->header);
+
+ if (((reg_val & PCIE_AER_CAP_ID_MASK) >> PCIE_AER_CAP_ID_SHIFT) !=
+ PCIE_AER_CAP_ID_VAL)
+ return -EIO;
+
+ if (((reg_val & PCIE_AER_CAP_VER_MASK) >> PCIE_AER_CAP_VER_SHIFT) !=
+ PCIE_AER_CAP_VER_VAL)
+ return -EIO;
+
+ al_reg_write32(&aer_regs->corr_err_mask, ~params->enabled_corr_err);
+
+ al_reg_write32(&aer_regs->uncorr_err_mask,
+ (~params->enabled_uncorr_non_fatal_err) |
+ (~params->enabled_uncorr_fatal_err));
+
+ al_reg_write32(&aer_regs->uncorr_err_severity,
+ params->enabled_uncorr_fatal_err);
+
+ al_reg_write32(&aer_regs->cap_and_ctrl,
+ (params->ecrc_gen_en ? PCIE_AER_CTRL_STAT_ECRC_GEN_EN : 0) |
+ (params->ecrc_chk_en ? PCIE_AER_CTRL_STAT_ECRC_CHK_EN : 0));
+
+ al_reg_write32_masked(
+ regs->core_space[pcie_pf->pf_num].pcie_dev_ctrl_status,
+ PCIE_PORT_DEV_CTRL_STATUS_CORR_ERR_REPORT_EN |
+ PCIE_PORT_DEV_CTRL_STATUS_NON_FTL_ERR_REPORT_EN |
+ PCIE_PORT_DEV_CTRL_STATUS_FTL_ERR_REPORT_EN |
+ PCIE_PORT_DEV_CTRL_STATUS_UNSUP_REQ_REPORT_EN,
+ (params->enabled_corr_err ?
+ PCIE_PORT_DEV_CTRL_STATUS_CORR_ERR_REPORT_EN : 0) |
+ (params->enabled_uncorr_non_fatal_err ?
+ PCIE_PORT_DEV_CTRL_STATUS_NON_FTL_ERR_REPORT_EN : 0) |
+ (params->enabled_uncorr_fatal_err ?
+ PCIE_PORT_DEV_CTRL_STATUS_FTL_ERR_REPORT_EN : 0) |
+ ((params->enabled_uncorr_non_fatal_err &
+ AL_PCIE_AER_UNCORR_UNSUPRT_REQ_ERR) ?
+ PCIE_PORT_DEV_CTRL_STATUS_UNSUP_REQ_REPORT_EN : 0) |
+ ((params->enabled_uncorr_fatal_err &
+ AL_PCIE_AER_UNCORR_UNSUPRT_REQ_ERR) ?
+ PCIE_PORT_DEV_CTRL_STATUS_UNSUP_REQ_REPORT_EN : 0));
+
+ return 0;
+}
+
+/** AER uncorretable errors get and clear */
+unsigned int
+al_pcie_aer_uncorr_get_and_clear(struct al_pcie_pf *pcie_pf)
+{
+ struct al_pcie_regs *regs = pcie_pf->pcie_port->regs;
+ struct al_pcie_core_aer_regs *aer_regs = regs->core_space[pcie_pf->pf_num].aer;
+ uint32_t reg_val;
+
+ reg_val = al_reg_read32(&aer_regs->uncorr_err_stat);
+ al_reg_write32(&aer_regs->uncorr_err_stat, reg_val);
+
+ return reg_val;
+}
+
+/** AER corretable errors get and clear */
+unsigned int
+al_pcie_aer_corr_get_and_clear(struct al_pcie_pf *pcie_pf)
+{
+ struct al_pcie_regs *regs = pcie_pf->pcie_port->regs;
+ struct al_pcie_core_aer_regs *aer_regs = regs->core_space[pcie_pf->pf_num].aer;
+ uint32_t reg_val;
+
+ reg_val = al_reg_read32(&aer_regs->corr_err_stat);
+ al_reg_write32(&aer_regs->corr_err_stat, reg_val);
+
+ return reg_val;
+}
+
+#if (AL_PCIE_AER_ERR_TLP_HDR_NUM_DWORDS != 4)
+#error Wrong assumption!
+#endif
+
+/** AER get the header for the TLP corresponding to a detected error */
+void
+al_pcie_aer_err_tlp_hdr_get(
+ struct al_pcie_pf *pcie_pf,
+ uint32_t hdr[AL_PCIE_AER_ERR_TLP_HDR_NUM_DWORDS])
+{
+ struct al_pcie_regs *regs = pcie_pf->pcie_port->regs;
+ struct al_pcie_core_aer_regs *aer_regs = regs->core_space[pcie_pf->pf_num].aer;
+ int i;
+
+ for (i = 0; i < AL_PCIE_AER_ERR_TLP_HDR_NUM_DWORDS; i++)
+ hdr[i] = al_reg_read32(&aer_regs->header_log[i]);
+}
+
+/********************** Loopback mode (RC and Endpoint modes) ************/
+
+/** enter local pipe loopback mode */
+int
+al_pcie_local_pipe_loopback_enter(struct al_pcie_port *pcie_port)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+
+ al_dbg("PCIe %d: Enter LOCAL PIPE Loopback mode", pcie_port->port_id);
+
+ al_reg_write32_masked(&regs->port_regs->pipe_loopback_ctrl,
+ 1 << PCIE_PORT_PIPE_LOOPBACK_CTRL_PIPE_LB_EN_SHIFT,
+ 1 << PCIE_PORT_PIPE_LOOPBACK_CTRL_PIPE_LB_EN_SHIFT);
+
+ al_reg_write32_masked(&regs->port_regs->port_link_ctrl,
+ 1 << PCIE_PORT_LINK_CTRL_LB_EN_SHIFT,
+ 1 << PCIE_PORT_LINK_CTRL_LB_EN_SHIFT);
+
+ return 0;
+}
+
+/**
+ * @brief exit local pipe loopback mode
+ *
+ * @param pcie_port pcie port handle
+ * @return 0 if no error found
+ */
+int
+al_pcie_local_pipe_loopback_exit(struct al_pcie_port *pcie_port)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+
+ al_dbg("PCIe %d: Exit LOCAL PIPE Loopback mode", pcie_port->port_id);
+
+ al_reg_write32_masked(&regs->port_regs->pipe_loopback_ctrl,
+ 1 << PCIE_PORT_PIPE_LOOPBACK_CTRL_PIPE_LB_EN_SHIFT,
+ 0);
+
+ al_reg_write32_masked(&regs->port_regs->port_link_ctrl,
+ 1 << PCIE_PORT_LINK_CTRL_LB_EN_SHIFT,
+ 0);
+ return 0;
+}
+
+/** enter remote loopback mode */
+int
+al_pcie_remote_loopback_enter(struct al_pcie_port *pcie_port)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+
+ al_dbg("PCIe %d: Enter REMOTE Loopback mode", pcie_port->port_id);
+
+ al_reg_write32_masked(&regs->port_regs->port_link_ctrl,
+ 1 << PCIE_PORT_PIPE_LOOPBACK_CTRL_PIPE_LB_EN_SHIFT,
+ 1 << PCIE_PORT_PIPE_LOOPBACK_CTRL_PIPE_LB_EN_SHIFT);
+
+ return 0;
+}
+
+/**
+ * @brief exit remote loopback mode
+ *
+ * @param pcie_port pcie port handle
+ * @return 0 if no error found
+ */
+int
+al_pcie_remote_loopback_exit(struct al_pcie_port *pcie_port)
+{
+ struct al_pcie_regs *regs = pcie_port->regs;
+
+ al_dbg("PCIe %d: Exit REMOTE Loopback mode", pcie_port->port_id);
+
+ al_reg_write32_masked(&regs->port_regs->port_link_ctrl,
+ 1 << PCIE_PORT_LINK_CTRL_LB_EN_SHIFT,
+ 0);
+ return 0;
+}
diff --git a/sys/arm/annapurna/alpine/hal/al_hal_pcie.h b/sys/arm/annapurna/alpine/hal/al_hal_pcie.h
new file mode 100644
index 0000000..1ddc8eb
--- /dev/null
+++ b/sys/arm/annapurna/alpine/hal/al_hal_pcie.h
@@ -0,0 +1,1157 @@
+/*-
+********************************************************************************
+Copyright (C) 2015 Annapurna Labs Ltd.
+
+This file may be licensed under the terms of the Annapurna Labs Commercial
+License Agreement.
+
+Alternatively, this file can be distributed under the terms of the GNU General
+Public License V2 as published by the Free Software Foundation and can be
+found at http://www.gnu.org/licenses/gpl-2.0.html
+
+Alternatively, redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+notice, this 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 HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*******************************************************************************/
+
+/**
+ * @defgroup grouppcie PCI Express Controller
+ * @{
+ * @section overview Overview
+ * This header file provide API for the HAL driver of the pcie port, the driver
+ * provides the following functionalities:
+ * - Port initialization
+ * - Link operation
+ * - Interrupts transactions generation (Endpoint mode).
+ * - Configuration Access management functions
+ * - Internal Translation Unit programming
+ *
+ * This API does not provide the following:
+ * - PCIe transactions generation and reception (except interrupts as mentioned
+ * above) as this functionality is done by the port without need for sw
+ * intervention.
+ * - Configuration Access: those transactions are generated automatically by
+ * the port (ECAM or ATU mode) when the CPU issues memory transaction
+ * through the fabric toward the PCIe port. This API provides management
+ * function for controlling the Configuration Access type and bus destination
+ * - Interrupt Handling.
+ * - Message Generation: common used messages are automatically generated, also,
+ * the ATU generic mechanism for generating various kind of messages.
+ * - PCIe Port Management: both link and port power management features can be
+ * managed using the PCI/PCIe standard power management and PCIe capabilities
+ * registers.
+ * - PCIe link and protocol error handling: the feature can be managed using
+ * the Advanced Error Handling PCIe capability registers.
+ *
+ * @section flows Software Flows
+ * @subsection init Initialization
+ * - allocation and set zeros al_pcie_port and al_pcie_pf structures handles
+ * - call al_pcie_port_handle_init() with pointer to the allocated
+ * al_pcie_port handle, address of the port internal registers space, and
+ * port id.
+ * - call al_pcie_pf_handle_init() with pointer to the al_pcie_port handle
+ * and pf_number.
+ * - set the port mode, End-Point or Root-Compex (default).
+ * - set number of lanes connected to the controller.
+ * - enable the controller using the al_pcie_port_enable(). note that this
+ * function expect the virtual address of the PBS Functional Registers.
+ * - wait for 2000 South-bridge cycles.
+ * - prepare al_pcie_port_config_params and al_pcie_pf_config_params
+ * structures depending on chip, board and system configuration.
+ * for example, when using the port as root complex, the operating_mode
+ * field should be set to AL_PCIE_OPERATING_MODE_RC. In this example we
+ * prepare the following configuration:
+ * For port configuration
+ * - Root Complex mode
+ * - Set the Max Link Speed to Gen2
+ * - Set the max lanes width to 2 (x2)
+ * - Disable reversal mode
+ * - Enable Snoops to support I/O Hardware cache coherency
+ * - Enable pcie core RAM parity
+ * - Enable pcie core AXI parity
+ * - Keep transaction layer default credits
+ * For pf configuration
+ * - No EP parameters
+ * - No SR-IOV parameters
+ * so the structures we prepare:
+ * @code
+ * - struct al_pcie_link_params link_params = {
+ * AL_PCIE_LINK_SPEED_GEN2,
+ * AL_FALSE, // disable reversal mode
+ * AL_PCIE_MPS_DEFAULT};
+ *
+ * - struct al_pcie_port_config_params config_params = {
+ * &link_params,
+ * AL_TRUE, // enable Snoop for inbound memory transactions
+ * AL_TRUE, // enable pcie port RAM parity
+ * AL_TRUE, // enable pcie port AXI parity
+ * NULL, // use default latency/replay timers
+ * NULL, // use default gen2 pipe params
+ * NULL, // gen3_params not needed when max speed set to Gen2
+ * NULL, // don't change TL credits
+ * NULL, // end point params not needed
+ * AL_FALSE, //no fast link
+ * AL_FALSE}; //return 0xFFFFFFFF for read transactions with
+ * //pci target error
+ * @endcode
+ * - now call al_pcie_port_config() with pcie_port and port_config_params
+ * @subsection link-init Link Initialization
+ * - once the port configured, we can start PCIe link:
+ * - call al_pcie_link_start()
+ * - call al_pcie_link_up_wait()
+ * - allocate al_pcie_link_status struct and call al_pcie_link_status() and
+ * check the link is established.
+ *
+ * @subsection cap Configuration Access Preparation
+ * - Once the link is established, we can prepare the port for pci
+ * configuration access, this stage requires system knowledge about the PCI
+ * buses enumeration. For example, if 5 buses were discovered on previously
+ * scanned root complex port, then we should start enumeration from bus 5 (PCI
+ * secondary bus), the sub-ordinary bus will be temporarily set to maximum
+ * value (255) until the scan process under this bus is finished, then it will
+ * updated to the maximum bus value found. So we use the following sequence:
+ * - call al_pcie_secondary_bus_set() with sec-bus = 5
+ * - call al_pcie_subordinary_bus_set() with sub-bus = 255
+ *
+ * @subsection cfg Configuration (Cfg) Access Generation
+ * - we assume using ECAM method, in this method, the software issues pcie Cfg
+ * access by accessing the ECAM memory space of the pcie port. For example, to
+ * issue 4 byte Cfg Read from bus B, Device D, Function F and register R, the
+ * software issues 4 byte read access to the following physical address
+ * ECAM base address of the port + (B << 20) + (D << 15) + (F << 12) + R.
+ * But, as the default size of the ECAM address space is less than
+ * needed full range (256MB), we modify the target_bus value prior to Cfg
+ * access in order make the port generate Cfg access with bus value set to the
+ * value of the target_bus rather than bits 27:20 of the physical address.
+ * - call al_pcie_target_bus_set() with target_bus set to the required bus of
+ * the next Cfg access to be issued, mask_target_bus will be set to 0xff.
+ * no need to call that function if the next Cfg access bus equals to the last
+ * value set to target_bus.
+ *
+ * @file al_hal_pcie.h
+ * @brief HAL Driver Header for the Annapurna Labs PCI Express port.
+ */
+
+#ifndef _AL_HAL_PCIE_H_
+#define _AL_HAL_PCIE_H_
+
+#include "al_hal_common.h"
+#include "al_hal_pcie_regs.h"
+
+/******************************************************************************/
+/********************************* Constants **********************************/
+/******************************************************************************/
+
+/** Inbound header credits sum - rev 0/1/2 */
+#define AL_PCIE_REV_1_2_IB_HCRD_SUM 97
+/** Inbound header credits sum - rev 3 */
+#define AL_PCIE_REV3_IB_HCRD_SUM 259
+
+/** Number of extended registers */
+#define AL_PCIE_EX_REGS_NUM 40
+
+/*******************************************************************************
+ * PCIe AER uncorrectable error bits
+ * To be used with the following functions:
+ * - al_pcie_aer_config
+ * - al_pcie_aer_uncorr_get_and_clear
+ ******************************************************************************/
+/** Data Link Protocol Error */
+#define AL_PCIE_AER_UNCORR_DLP_ERR AL_BIT(4)
+/** Poisoned TLP */
+#define AL_PCIE_AER_UNCORR_POISIONED_TLP AL_BIT(12)
+/** Flow Control Protocol Error */
+#define AL_PCIE_AER_UNCORR_FLOW_CTRL_ERR AL_BIT(13)
+/** Completion Timeout */
+#define AL_PCIE_AER_UNCORR_COMPL_TO AL_BIT(14)
+/** Completer Abort */
+#define AL_PCIE_AER_UNCORR_COMPL_ABT AL_BIT(15)
+/** Unexpected Completion */
+#define AL_PCIE_AER_UNCORR_UNEXPCTED_COMPL AL_BIT(16)
+/** Receiver Overflow */
+#define AL_PCIE_AER_UNCORR_RCV_OVRFLW AL_BIT(17)
+/** Malformed TLP */
+#define AL_PCIE_AER_UNCORR_MLFRM_TLP AL_BIT(18)
+/** ECRC Error */
+#define AL_PCIE_AER_UNCORR_ECRC_ERR AL_BIT(19)
+/** Unsupported Request Error */
+#define AL_PCIE_AER_UNCORR_UNSUPRT_REQ_ERR AL_BIT(20)
+/** Uncorrectable Internal Error */
+#define AL_PCIE_AER_UNCORR_INT_ERR AL_BIT(22)
+/** AtomicOp Egress Blocked */
+#define AL_PCIE_AER_UNCORR_ATOMIC_EGRESS_BLK AL_BIT(24)
+
+/*******************************************************************************
+ * PCIe AER correctable error bits
+ * To be used with the following functions:
+ * - al_pcie_aer_config
+ * - al_pcie_aer_corr_get_and_clear
+ ******************************************************************************/
+/** Receiver Error */
+#define AL_PCIE_AER_CORR_RCV_ERR AL_BIT(0)
+/** Bad TLP */
+#define AL_PCIE_AER_CORR_BAD_TLP AL_BIT(6)
+/** Bad DLLP */
+#define AL_PCIE_AER_CORR_BAD_DLLP AL_BIT(7)
+/** REPLAY_NUM Rollover */
+#define AL_PCIE_AER_CORR_RPLY_NUM_ROLL_OVR AL_BIT(8)
+/** Replay Timer Timeout */
+#define AL_PCIE_AER_CORR_RPLY_TMR_TO AL_BIT(12)
+/** Advisory Non-Fatal Error */
+#define AL_PCIE_AER_CORR_ADVISORY_NON_FTL_ERR AL_BIT(13)
+/** Corrected Internal Error */
+#define AL_PCIE_AER_CORR_INT_ERR AL_BIT(14)
+
+/** The AER erroneous TLP header length [num DWORDs] */
+#define AL_PCIE_AER_ERR_TLP_HDR_NUM_DWORDS 4
+
+/******************************************************************************/
+/************************* Data Structures and Types **************************/
+/******************************************************************************/
+
+/**
+ * al_pcie_ib_hcrd_config: data structure internally used in order to config
+ * inbound posted/non-posted parameters.
+ * Note: it's required to have this structure in pcie_port handle since it has
+ * a state (required/not-required) which is determined by outbound
+ * outstanding configuration
+ */
+struct al_pcie_ib_hcrd_config {
+ /* Internally used - see 'al_pcie_ib_hcrd_os_ob_reads_config' */
+ unsigned int nof_np_hdr;
+
+ /* Internally used - see 'al_pcie_ib_hcrd_os_ob_reads_config' */
+ unsigned int nof_p_hdr;
+};
+
+/* The Max Payload Size. Measured in bytes.
+ * DEFAULT: do not change the current MPS
+ */
+enum al_pcie_max_payload_size {
+ AL_PCIE_MPS_DEFAULT,
+ AL_PCIE_MPS_128 = 0,
+ AL_PCIE_MPS_256 = 1,
+ AL_PCIE_MPS_512 = 2,
+ AL_PCIE_MPS_1024 = 3,
+ AL_PCIE_MPS_2048 = 4,
+ AL_PCIE_MPS_4096 = 5,
+};
+
+/**
+ * al_pcie_port: data structure used by the HAL to handle a specific pcie port.
+ * this structure is allocated and set to zeros by the upper layer, then it is
+ * initialized by the al_pcie_port_handle_init() that should be called before any
+ * other function of this API. later, this handle passed to the API functions.
+ */
+struct al_pcie_port {
+ void __iomem *pcie_reg_base;
+ struct al_pcie_regs regs_ptrs;
+ struct al_pcie_regs *regs;
+ uint32_t *ex_regs_ptrs[AL_PCIE_EX_REGS_NUM];
+ void *ex_regs;
+ void __iomem *pbs_regs;
+
+ /* Revision ID */
+ uint8_t rev_id;
+ unsigned int port_id;
+ uint8_t max_lanes;
+ uint8_t max_num_of_pfs;
+
+ /* Internally used */
+ struct al_pcie_ib_hcrd_config ib_hcrd_config;
+};
+
+/**
+ * al_pcie_pf: the pf handle, a data structure used to handle PF specific
+ * functionality. Initialized using "al_pcie_pf_handle_init()"
+ */
+struct al_pcie_pf {
+ unsigned int pf_num;
+ struct al_pcie_port *pcie_port;
+};
+
+/** Operating mode (endpoint, root complex) */
+enum al_pcie_operating_mode {
+ AL_PCIE_OPERATING_MODE_EP,
+ AL_PCIE_OPERATING_MODE_RC,
+ AL_PCIE_OPERATING_MODE_UNKNOWN
+};
+
+/* The maximum link speed, measured GT/s (Giga transfer / second)
+ * DEFAULT: do not change the current speed
+ * GEN1: 2.5 GT/s
+ * GEN2: 5 GT/s
+ * GEN3: 8GT/s
+ *
+ * Note: The values of this enumerator are important for proper behavior
+ */
+enum al_pcie_link_speed {
+ AL_PCIE_LINK_SPEED_DEFAULT,
+ AL_PCIE_LINK_SPEED_GEN1 = 1,
+ AL_PCIE_LINK_SPEED_GEN2 = 2,
+ AL_PCIE_LINK_SPEED_GEN3 = 3
+};
+
+/** PCIe capabilities that supported by a specific port */
+struct al_pcie_max_capability {
+ al_bool end_point_mode_supported;
+ al_bool root_complex_mode_supported;
+ enum al_pcie_link_speed max_speed;
+ uint8_t max_lanes;
+ al_bool reversal_supported;
+ uint8_t atu_regions_num;
+ uint32_t atu_min_size;
+};
+
+/** PCIe link related parameters */
+struct al_pcie_link_params {
+ enum al_pcie_link_speed max_speed;
+ al_bool enable_reversal;
+ enum al_pcie_max_payload_size max_payload_size;
+
+};
+
+/** PCIe gen2 link parameters */
+struct al_pcie_gen2_params {
+ al_bool tx_swing_low; /* set tx swing low when true, and tx swing full when false */
+ al_bool tx_compliance_receive_enable;
+ al_bool set_deemphasis;
+};
+
+/** PCIe gen 3 standard per lane equalization parameters */
+struct al_pcie_gen3_lane_eq_params {
+ uint8_t downstream_port_transmitter_preset;
+ uint8_t downstream_port_receiver_preset_hint;
+ uint8_t upstream_port_transmitter_preset;
+ uint8_t upstream_port_receiver_preset_hint;
+};
+
+/** PCIe gen 3 equalization parameters */
+struct al_pcie_gen3_params {
+ al_bool perform_eq;
+ al_bool interrupt_enable_on_link_eq_request;
+ struct al_pcie_gen3_lane_eq_params *eq_params; /* array of lanes params */
+ int eq_params_elements; /* number of elements in the eq_params array */
+
+ al_bool eq_disable; /* disables the equalization feature */
+ al_bool eq_phase2_3_disable; /* Equalization Phase 2 and Phase 3 */
+ /* Disable (RC mode only) */
+ uint8_t local_lf; /* Full Swing (FS) Value for Gen3 Transmit Equalization */
+ /* Value Range: 12 through 63 (decimal).*/
+
+ uint8_t local_fs; /* Low Frequency (LF) Value for Gen3 Transmit Equalization */
+};
+
+/** Transport Layer credits parameters */
+struct al_pcie_tl_credits_params {
+};
+
+/** Various configuration features */
+struct al_pcie_features {
+ /**
+ * Enable MSI fix from the SATA to the PCIe EP
+ * Only valid for port 0, when enabled as EP
+ */
+ al_bool sata_ep_msi_fix;
+};
+
+/**
+ * Inbound posted/non-posted header credits and outstanding outbound reads
+ * completion header configuration
+ *
+ * Constraints:
+ * - nof_cpl_hdr + nof_np_hdr + nof_p_hdr ==
+ * AL_PCIE_REV_1_2_IB_HCRD_SUM/AL_PCIE_REV3_IB_HCRD_SUM
+ * - nof_cpl_hdr > 0
+ * - nof_p_hdr > 0
+ * - nof_np_hdr > 0
+ */
+struct al_pcie_ib_hcrd_os_ob_reads_config {
+ /** Max number of outstanding outbound reads */
+ uint8_t nof_outstanding_ob_reads;
+
+ /**
+ * This value set the possible outstanding headers CMPLs , the core
+ * can get (the core always advertise infinite credits for CMPLs).
+ */
+ unsigned int nof_cpl_hdr;
+
+ /**
+ * This value set the possible outstanding headers reads (non-posted
+ * transactions), the core can get (it set the value in the init FC
+ * process).
+ */
+ unsigned int nof_np_hdr;
+
+ /**
+ * This value set the possible outstanding headers writes (posted
+ * transactions), the core can get (it set the value in the init FC
+ * process).
+ */
+ unsigned int nof_p_hdr;
+};
+
+/** PCIe Ack/Nak Latency and Replay timers */
+struct al_pcie_latency_replay_timers {
+ uint16_t round_trip_lat_limit;
+ uint16_t replay_timer_limit;
+};
+
+/* SRIS KP counter values */
+struct al_pcie_sris_params {
+ /** set to AL_TRUE to use defaults and ignore the other parameters */
+ al_bool use_defaults;
+ uint16_t kp_counter_gen3; /* only for Gen3 */
+ uint16_t kp_counter_gen21;
+};
+
+/** Relaxed ordering params */
+struct al_pcie_relaxed_ordering_params {
+ al_bool enable_tx_relaxed_ordering;
+ al_bool enable_rx_relaxed_ordering;
+};
+
+/** PCIe port configuration parameters
+ * This structure includes the parameters that the HAL should apply to the port
+ * (by al_pcie_port_config()).
+ * The fields that are pointers (e.g. link_params) can be set to NULL, in that
+ * case, the al_pcie_port_config() will keep the current HW settings.
+ */
+struct al_pcie_port_config_params {
+ struct al_pcie_link_params *link_params;
+ al_bool enable_axi_snoop;
+ al_bool enable_ram_parity_int;
+ al_bool enable_axi_parity_int;
+ struct al_pcie_latency_replay_timers *lat_rply_timers;
+ struct al_pcie_gen2_params *gen2_params;
+ struct al_pcie_gen3_params *gen3_params;
+ struct al_pcie_tl_credits_params *tl_credits;
+ struct al_pcie_features *features;
+ /* Sets all internal timers to Fast Mode for speeding up simulation.*/
+ al_bool fast_link_mode;
+ /*
+ * when true, the PCI unit will return Slave Error/Decoding Error to the master unit in case
+ * of error. when false, the value 0xFFFFFFFF will be returned without error indication.
+ */
+ al_bool enable_axi_slave_err_resp;
+ struct al_pcie_sris_params *sris_params;
+ struct al_pcie_relaxed_ordering_params *relaxed_ordering_params;
+};
+
+/** BAR register configuration parameters (Endpoint Mode only) */
+struct al_pcie_ep_bar_params {
+ al_bool enable;
+ al_bool memory_space; /**< memory or io */
+ al_bool memory_64_bit; /**< is memory space is 64 bit */
+ al_bool memory_is_prefetchable;
+ uint64_t size; /* the bar size in bytes */
+};
+
+/** PF config params (EP mode only) */
+struct al_pcie_pf_config_params {
+ al_bool cap_d1_d3hot_dis;
+ al_bool cap_flr_dis;
+ al_bool cap_aspm_dis;
+ al_bool bar_params_valid;
+ struct al_pcie_ep_bar_params bar_params[6];
+ struct al_pcie_ep_bar_params exp_bar_params;/* expansion ROM BAR*/
+};
+
+/** PCIe link status */
+struct al_pcie_link_status {
+ al_bool link_up;
+ enum al_pcie_link_speed speed;
+ uint8_t lanes;
+ uint8_t ltssm_state;
+};
+
+/** PCIe lane status */
+struct al_pcie_lane_status {
+ al_bool is_reset;
+ enum al_pcie_link_speed requested_speed;
+};
+
+/** PCIe MSIX capability configuration parameters */
+struct al_pcie_msix_params {
+ uint16_t table_size;
+ uint16_t table_offset;
+ uint8_t table_bar;
+ uint16_t pba_offset;
+ uint16_t pba_bar;
+};
+
+/** PCIE AER capability parameters */
+struct al_pcie_aer_params {
+ /** ECRC Generation Enable */
+ al_bool ecrc_gen_en;
+ /** ECRC Check Enable */
+ al_bool ecrc_chk_en;
+
+ /**
+ * Enabled reporting of correctable errors (bit mask)
+ * See 'AL_PCIE_AER_CORR_*' for details
+ * 0 - no reporting at all
+ */
+ unsigned int enabled_corr_err;
+ /**
+ * Enabled reporting of non-fatal uncorrectable errors (bit mask)
+ * See 'AL_PCIE_AER_UNCORR_*' for details
+ * 0 - no reporting at all
+ */
+ unsigned int enabled_uncorr_non_fatal_err;
+ /**
+ * Enabled reporting of fatal uncorrectable errors (bit mask)
+ * See 'AL_PCIE_AER_UNCORR_*' for details
+ * 0 - no reporting at all
+ */
+ unsigned int enabled_uncorr_fatal_err;
+};
+
+/******************************************************************************/
+/********************************** PCIe API **********************************/
+/******************************************************************************/
+
+/*************************** PCIe Initialization API **************************/
+
+/**
+ * Initializes a PCIe port handle structure.
+ *
+ * @param pcie_port an allocated, non-initialized instance.
+ * @param pcie_reg_base the virtual base address of the port internal
+ * registers
+ * @param pbs_reg_base the virtual base address of the pbs functional
+ * registers
+ * @param port_id the port id (used mainly for debug messages)
+ *
+ * @return 0 if no error found.
+ */
+int al_pcie_port_handle_init(struct al_pcie_port *pcie_port,
+ void __iomem *pcie_reg_base,
+ void __iomem *pbs_reg_base,
+ unsigned int port_id);
+
+/**
+ * Initializes a PCIe pf handle structure
+ * @param pcie_pf an allocated, non-initialized instance of pf handle
+ * @param pcie_port pcie port handle
+ * @param pf_num physical function number
+ * @return 0 if no error found
+ */
+int al_pcie_pf_handle_init(
+ struct al_pcie_pf *pcie_pf,
+ struct al_pcie_port *pcie_port,
+ unsigned int pf_num);
+
+/************************** Pre PCIe Port Enable API **************************/
+
+/**
+ * @brief set current pcie operating mode (root complex or endpoint)
+ * This function can be called only before enabling the controller using
+ * al_pcie_port_enable().
+ *
+ * @param pcie_port pcie port handle
+ * @param mode pcie operating mode
+ *
+ * @return 0 if no error found.
+ */
+int al_pcie_port_operating_mode_config(struct al_pcie_port *pcie_port,
+ enum al_pcie_operating_mode mode);
+
+/**
+ * Configure number of lanes connected to this port.
+ * This function can be called only before enabling the controller using al_pcie_port_enable().
+ *
+ * @param pcie_port pcie port handle
+ * @param lanes number of lanes
+ * Note: this function must be called before any al_pcie_port_config() calls
+ *
+ * @return 0 if no error found.
+ */
+int al_pcie_port_max_lanes_set(struct al_pcie_port *pcie_port, uint8_t lanes);
+
+/**
+ * Set maximum physical function numbers
+ * @param pcie_port pcie port handle
+ * @param max_num_of_pfs number of physical functions
+ * Note: this function must be called before any al_pcie_pf_config() calls
+ */
+int al_pcie_port_max_num_of_pfs_set(
+ struct al_pcie_port *pcie_port,
+ uint8_t max_num_of_pfs);
+
+/**
+ * @brief Inbound posted/non-posted header credits and outstanding outbound
+ * reads completion header configuration
+ *
+ * @param pcie_port pcie port handle
+ * @param ib_hcrd_os_ob_reads_config
+ * Inbound header credits and outstanding outbound reads
+ * configuration
+ */
+int al_pcie_port_ib_hcrd_os_ob_reads_config(
+ struct al_pcie_port *pcie_port,
+ struct al_pcie_ib_hcrd_os_ob_reads_config *ib_hcrd_os_ob_reads_config);
+
+/** return PCIe operating mode
+ * @param pcie_port pcie port handle
+ * @return operating mode
+ */
+enum al_pcie_operating_mode al_pcie_operating_mode_get(
+ struct al_pcie_port *pcie_port);
+
+/**************************** PCIe Port Enable API ****************************/
+
+/** Enable PCIe unit (deassert reset)
+ *
+ * @param pcie_port pcie port handle
+ *
+ * @return 0 if no error found.
+ */
+int al_pcie_port_enable(struct al_pcie_port *pcie_port);
+
+/** Disable PCIe unit (assert reset)
+ *
+ * @param pcie_port pcie port handle
+ */
+void al_pcie_port_disable(struct al_pcie_port *pcie_port);
+
+/**
+ * Port memory shutdown/up
+ * Caution: This function can be called only when the controller is disabled
+ *
+ * @param pcie_port pcie port handle
+ * @param enable memory shutdown enable or disable
+ *
+ */
+int al_pcie_port_memory_shutdown_set(
+ struct al_pcie_port *pcie_port,
+ al_bool enable);
+
+/**
+ * Check if port enabled or not
+ * @param pcie_port pcie port handle
+ * @return AL_TRUE of port enabled and AL_FALSE otherwise
+ */
+al_bool al_pcie_port_is_enabled(struct al_pcie_port *pcie_port);
+
+/*************************** PCIe Configuration API ***************************/
+
+/**
+ * @brief configure pcie port (mode, link params, etc..)
+ * this function must be called before initializing the link
+ *
+ * @param pcie_port pcie port handle
+ * @param params configuration structure.
+ *
+ * @return 0 if no error found
+ */
+int al_pcie_port_config(struct al_pcie_port *pcie_port,
+ const struct al_pcie_port_config_params *params);
+
+/**
+ * @brief Configure a specific PF (EP params, sriov params, ...)
+ * this function must be called before any datapath transactions
+ *
+ * @param pcie_pf pcie pf handle
+ * @param params configuration structure.
+ *
+ * @return 0 if no error found
+ */
+int al_pcie_pf_config(
+ struct al_pcie_pf *pcie_pf,
+ const struct al_pcie_pf_config_params *params);
+
+/************************** PCIe Link Operations API **************************/
+
+/**
+ * @brief start pcie link
+ *
+ * @param pcie_port pcie port handle
+ *
+ * @return 0 if no error found
+ */
+int al_pcie_link_start(struct al_pcie_port *pcie_port);
+
+/**
+ * @brief stop pcie link
+ *
+ * @param pcie_port pcie port handle
+ *
+ * @return 0 if no error found
+ */
+int al_pcie_link_stop(struct al_pcie_port *pcie_port);
+
+/**
+ * @brief trigger link-disable
+ *
+ * @param pcie_port pcie port handle
+ * @param disable AL_TRUE to disable the link and AL_FALSE to enable it
+ *
+ * Note: this functionality differs from "al_pcie_link_stop" as it's a spec
+ * functionality where both sides of the PCIe agrees to disable the link
+ * @return 0 if no error found
+ */
+int al_pcie_link_disable(struct al_pcie_port *pcie_port, al_bool disable);
+
+/**
+ * @brief wait for link up indication
+ * this function waits for link up indication, it polls LTSSM state until link is ready
+ *
+ * @param pcie_port pcie port handle
+ * @param timeout_ms maximum timeout in milli-seconds to wait for link up
+ *
+ * @return 0 if link up indication detected
+ * -ETIME if not.
+ */
+int al_pcie_link_up_wait(struct al_pcie_port *pcie_port, uint32_t timeout_ms);
+
+/**
+ * @brief get link status
+ *
+ * @param pcie_port pcie port handle
+ * @param status structure for link status
+ *
+ * @return 0 if no error found
+ */
+int al_pcie_link_status(struct al_pcie_port *pcie_port, struct al_pcie_link_status *status);
+
+/**
+ * @brief get lane status
+ *
+ * @param pcie_port
+ * pcie port handle
+ * @param lane
+ * PCIe lane
+ * @param status
+ * Pointer to returned structure for lane status
+ *
+ */
+void al_pcie_lane_status_get(
+ struct al_pcie_port *pcie_port,
+ unsigned int lane,
+ struct al_pcie_lane_status *status);
+
+/**
+ * @brief trigger hot reset
+ *
+ * @param pcie_port pcie port handle
+ * @param enable AL_TRUE to enable hot-reset and AL_FALSE to disable it
+ *
+ * @return 0 if no error found
+ */
+int al_pcie_link_hot_reset(struct al_pcie_port *pcie_port, al_bool enable);
+
+/**
+ * @brief trigger link-retain
+ * this function initiates Link retraining by directing the Physical Layer LTSSM
+ * to the Recovery state. If the LTSSM is already in Recovery or Configuration,
+ * re-entering Recovery is permitted but not required.
+
+ * @param pcie_port pcie port handle
+ *
+ * Note: there's no need to disable initiating link-retrain
+ * @return 0 if no error found
+ */
+int al_pcie_link_retrain(struct al_pcie_port *pcie_port);
+
+/**
+ * @brief change port speed
+ * this function changes the port speed, it doesn't wait for link re-establishment
+ *
+ * @param pcie_port pcie port handle
+ * @param new_speed the new speed gen to set
+ *
+ * @return 0 if no error found
+ */
+int al_pcie_link_change_speed(struct al_pcie_port *pcie_port, enum al_pcie_link_speed new_speed);
+
+/* TODO: check if this function needed */
+int al_pcie_link_change_width(struct al_pcie_port *pcie_port, uint8_t width);
+
+/**************************** Post Link Start API *****************************/
+
+/************************** Snoop Configuration API ***************************/
+
+/**
+ * @brief configure pcie port axi snoop
+ *
+ * @param pcie_port pcie port handle
+ * @param enable_axi_snoop enable snoop.
+ *
+ * @return 0 if no error found
+ */
+/* TODO: Can this API be called after port enable? */
+int al_pcie_port_snoop_config(struct al_pcie_port *pcie_port,
+ al_bool enable_axi_snoop);
+
+/************************** Configuration Space API ***************************/
+
+/**
+ * Configuration Space Access Through PCI-E_ECAM_Ext PASW (RC mode only)
+ */
+
+/**
+ * @brief get base address of pci configuration space header
+ * @param pcie_pf pcie pf handle
+ * @param addr pointer for returned address;
+ * @return 0 if no error found
+ */
+int al_pcie_config_space_get(
+ struct al_pcie_pf *pcie_pf,
+ uint8_t __iomem **addr);
+
+/**
+ * Read data from the local configuration space
+ *
+ * @param pcie_pf pcie pf handle
+ * @param reg_offset Configuration space register offset
+ * @return Read data
+ */
+uint32_t al_pcie_local_cfg_space_read(
+ struct al_pcie_pf *pcie_pf,
+ unsigned int reg_offset);
+
+/**
+ * Write data to the local configuration space
+ *
+ * @param pcie_pf PCIe pf handle
+ * @param reg_offset Configuration space register offset
+ * @param data Data to write
+ * @param cs2 Should be AL_TRUE if dbi_cs2 must be asserted
+ * to enable writing to this register, according to
+ * the PCIe Core specifications
+ * @param allow_ro_wr AL_TRUE to allow writing into read-only regs
+ *
+ */
+void al_pcie_local_cfg_space_write(
+ struct al_pcie_pf *pcie_pf,
+ unsigned int reg_offset,
+ uint32_t data,
+ al_bool cs2,
+ al_bool allow_ro_wr);
+
+/**
+ * @brief set target_bus and mask_target_bus
+ * @param pcie_port pcie port handle
+ * @param target_bus
+ * @param mask_target_bus
+ * @return 0 if no error found
+ */
+int al_pcie_target_bus_set(struct al_pcie_port *pcie_port,
+ uint8_t target_bus,
+ uint8_t mask_target_bus);
+
+/**
+ * @brief get target_bus and mask_target_bus
+ * @param pcie_port pcie port handle
+ * @param target_bus
+ * @param mask_target_bus
+ * @return 0 if no error found
+ */
+int al_pcie_target_bus_get(struct al_pcie_port *pcie_port,
+ uint8_t *target_bus,
+ uint8_t *mask_target_bus);
+
+/**
+ * Set secondary bus number
+ *
+ * @param pcie_port pcie port handle
+ * @param secbus pci secondary bus number
+ *
+ * @return 0 if no error found.
+ */
+int al_pcie_secondary_bus_set(struct al_pcie_port *pcie_port, uint8_t secbus);
+
+/**
+ * Set subordinary bus number
+ *
+ * @param pcie_port pcie port handle
+ * @param subbus the highest bus number of all of the buses that can be reached
+ * downstream of the PCIE instance.
+ *
+ * @return 0 if no error found.
+ */
+int al_pcie_subordinary_bus_set(struct al_pcie_port *pcie_port,uint8_t subbus);
+
+/**
+ * @brief Enable/disable deferring incoming configuration requests until
+ * initialization is complete. When enabled, the core completes incoming
+ * configuration requests with a Configuration Request Retry Status.
+ * Other incoming Requests complete with Unsupported Request status.
+ *
+ * @param pcie_port pcie port handle
+ * @param en enable/disable
+ */
+void al_pcie_app_req_retry_set(struct al_pcie_port *pcie_port, al_bool en);
+
+/*************** Internal Address Translation Unit (ATU) API ******************/
+
+enum al_pcie_atu_dir {
+ AL_PCIE_ATU_DIR_OUTBOUND = 0,
+ AL_PCIE_ATU_DIR_INBOUND = 1,
+};
+
+enum al_pcie_atu_tlp {
+ AL_PCIE_TLP_TYPE_MEM = 0,
+ AL_PCIE_TLP_TYPE_IO = 2,
+ AL_PCIE_TLP_TYPE_CFG0 = 4,
+ AL_PCIE_TLP_TYPE_CFG1 = 5,
+ AL_PCIE_TLP_TYPE_MSG = 0x10,
+ AL_PCIE_TLP_TYPE_RESERVED = 0x1f
+};
+
+enum al_pcie_atu_response {
+ AL_PCIE_RESPONSE_NORMAL = 0,
+ AL_PCIE_RESPONSE_UR = 1,
+ AL_PCIE_RESPONSE_CA = 2
+};
+
+struct al_pcie_atu_region {
+ al_bool enable;
+ /* outbound or inbound */
+ enum al_pcie_atu_dir direction;
+ /* region index */
+ uint8_t index;
+ uint64_t base_addr;
+ /** limit marks the region's end address. only bits [39:0] are valid
+ * given the Alpine PoC maximum physical address space
+ */
+ uint64_t limit;
+ /** the address that matches will be translated to this address + offset
+ */
+ uint64_t target_addr;
+ al_bool invert_matching;
+ /* pcie tlp type*/
+ enum al_pcie_atu_tlp tlp_type;
+ /* pcie frame header attr field*/
+ uint8_t attr;
+ /**
+ * outbound specific params
+ */
+ /* pcie message code */
+ uint8_t msg_code;
+ al_bool cfg_shift_mode;
+ /**
+ * inbound specific params
+ */
+ uint8_t bar_number;
+ /* BAR match mode, used in EP for MEM and IO tlps*/
+ uint8_t match_mode;
+ /**
+ * For outbound: enables taking the function number of the translated
+ * TLP from the PCIe core. For inbound: enables ATU function match mode
+ * Note: this boolean is ignored in RC mode
+ */
+ al_bool function_match_bypass_mode;
+ /**
+ * The function number to match/bypass (see previous parameter)
+ * Note: this parameter is ignored when previous param is FALSE
+ */
+ uint8_t function_match_bypass_mode_number;
+ /* response code */
+ enum al_pcie_atu_response response;
+ al_bool enable_attr_match_mode;
+ al_bool enable_msg_match_mode;
+ /**
+ * USE WITH CAUTION: setting this boolean to AL_TRUE allows setting the
+ * outbound ATU even after link is already started. DO NOT SET this
+ * boolean to AL_TRUE unless there have been NO traffic before calling
+ * al_pcie_atu_region_set function
+ */
+ al_bool enforce_ob_atu_region_set;
+};
+
+/**
+ * @brief program internal ATU region entry
+ * @param pcie_port pcie port handle
+ * @param atu_region data structure that contains the region index and the
+ * translation parameters
+ * @return 0 if no error
+ */
+int al_pcie_atu_region_set(
+ struct al_pcie_port *pcie_port,
+ struct al_pcie_atu_region *atu_region);
+
+/**
+ * @brief get internal ATU is enabled and base/target addresses
+ * @param pcie_port pcie port handle
+ * @param direction input: iATU direction (IB/OB)
+ * @param index input: iATU index
+ * @param enable output: AL_TRUE if the iATU is enabled
+ * @param base_addr output: the iATU base address
+ * @param target_addr output: the iATU target address
+ */
+void al_pcie_atu_region_get_fields(
+ struct al_pcie_port *pcie_port,
+ enum al_pcie_atu_dir direction, uint8_t index,
+ al_bool *enable, uint64_t *base_addr, uint64_t *target_addr);
+
+/**
+ * @brief Configure axi io bar.
+ * every hit to this bar will override size to 4 bytes.
+ * @param pcie_port pcie port handle
+ * @param start the first address of the memory
+ * @param end the last address of the memory
+ * @return
+ */
+void al_pcie_axi_io_config(
+ struct al_pcie_port *pcie_port,
+ al_phys_addr_t start,
+ al_phys_addr_t end);
+
+/************** Interrupt generation (Endpoint mode Only) API *****************/
+
+enum al_pcie_legacy_int_type{
+ AL_PCIE_LEGACY_INTA = 0,
+ AL_PCIE_LEGACY_INTB,
+ AL_PCIE_LEGACY_INTC,
+ AL_PCIE_LEGACY_INTD
+};
+
+/**
+ * @brief generate INTx Assert/DeAssert Message
+ * @param pcie_pf pcie pf handle
+ * @param assert when true, Assert Message is sent
+ * @param type type of message (INTA, INTB, etc)
+ * @return 0 if no error found
+ */
+int al_pcie_legacy_int_gen(
+ struct al_pcie_pf *pcie_pf,
+ al_bool assert,
+ enum al_pcie_legacy_int_type type);
+
+/**
+ * @brief generate MSI interrupt
+ * @param pcie_pf pcie pf handle
+ * @param vector the vector index to send interrupt for.
+ * @return 0 if no error found
+ */
+int al_pcie_msi_int_gen(struct al_pcie_pf *pcie_pf, uint8_t vector);
+
+/**
+ * @brief configure MSIX capability
+ * @param pcie_pf pcie pf handle
+ * @param msix_params MSIX capability configuration parameters
+ * @return 0 if no error found
+ */
+int al_pcie_msix_config(
+ struct al_pcie_pf *pcie_pf,
+ struct al_pcie_msix_params *msix_params);
+
+/**
+ * @brief check whether MSIX capability is enabled
+ * @param pcie_pf pcie pf handle
+ * @return AL_TRUE if MSIX capability is enabled, AL_FALSE otherwise
+ */
+al_bool al_pcie_msix_enabled(struct al_pcie_pf *pcie_pf);
+
+/**
+ * @brief check whether MSIX capability is masked
+ * @param pcie_pf pcie pf handle
+ * @return AL_TRUE if MSIX capability is masked, AL_FALSE otherwise
+ */
+al_bool al_pcie_msix_masked(struct al_pcie_pf *pcie_pf);
+
+/******************** Advanced Error Reporting (AER) API **********************/
+
+/**
+ * @brief configure AER capability
+ * @param pcie_pf pcie pf handle
+ * @param params AER capability configuration parameters
+ * @return 0 if no error found
+ */
+int al_pcie_aer_config(
+ struct al_pcie_pf *pcie_pf,
+ struct al_pcie_aer_params *params);
+
+/**
+ * @brief AER uncorretable errors get and clear
+ * @param pcie_pf pcie pf handle
+ * @return bit mask of uncorrectable errors - see 'AL_PCIE_AER_UNCORR_*' for
+ * details
+ */
+unsigned int al_pcie_aer_uncorr_get_and_clear(struct al_pcie_pf *pcie_pf);
+
+/**
+ * @brief AER corretable errors get and clear
+ * @param pcie_pf pcie pf handle
+ * @return bit mask of correctable errors - see 'AL_PCIE_AER_CORR_*' for
+ * details
+ */
+unsigned int al_pcie_aer_corr_get_and_clear(struct al_pcie_pf *pcie_pf);
+
+/**
+ * @brief AER get the header for the TLP corresponding to a detected error
+ * @param pcie_pf pcie pf handle
+ * @param hdr pointer to an array for getting the header
+ */
+void al_pcie_aer_err_tlp_hdr_get(
+ struct al_pcie_pf *pcie_pf,
+ uint32_t hdr[AL_PCIE_AER_ERR_TLP_HDR_NUM_DWORDS]);
+
+/******************** Loop-Back mode (RC and Endpoint modes) ******************/
+
+/**
+ * @brief enter local pipe loop-back mode
+ * This mode will connect the pipe RX signals to TX.
+ * no need to start link when using this mode.
+ * Gen3 equalization must be disabled before enabling this mode
+ * The caller must make sure the port is ready to accept the TLPs it sends to
+ * itself. for example, BARs should be initialized before sending memory TLPs.
+ *
+ * @param pcie_port pcie port handle
+ * @return 0 if no error found
+ */
+int al_pcie_local_pipe_loopback_enter(struct al_pcie_port *pcie_port);
+
+/**
+ * @brief exit local pipe loopback mode
+ *
+ * @param pcie_port pcie port handle
+ * @return 0 if no error found
+ */
+int al_pcie_local_pipe_loopback_exit(struct al_pcie_port *pcie_port);
+
+/**
+ * @brief enter master remote loopback mode
+ * No need to configure the link partner to enter slave remote loopback mode
+ * as this should be done as response to special training sequence directives
+ * when master works in remote loopback mode.
+ * The caller must make sure the port is ready to accept the TLPs it sends to
+ * itself. for example, BARs should be initialized before sending memory TLPs.
+ *
+ * @param pcie_port pcie port handle
+ * @return 0 if no error found
+ */
+int al_pcie_remote_loopback_enter(struct al_pcie_port *pcie_port);
+
+/**
+ * @brief exit remote loopback mode
+ *
+ * @param pcie_port pcie port handle
+ * @return 0 if no error found
+ */
+int al_pcie_remote_loopback_exit(struct al_pcie_port *pcie_port);
+
+#endif
+/** @} end of grouppcie group */
diff --git a/sys/arm/annapurna/alpine/hal/al_hal_pcie_axi_reg.h b/sys/arm/annapurna/alpine/hal/al_hal_pcie_axi_reg.h
new file mode 100644
index 0000000..04d4bfd
--- /dev/null
+++ b/sys/arm/annapurna/alpine/hal/al_hal_pcie_axi_reg.h
@@ -0,0 +1,1501 @@
+/*-
+********************************************************************************
+Copyright (C) 2015 Annapurna Labs Ltd.
+
+This file may be licensed under the terms of the Annapurna Labs Commercial
+License Agreement.
+
+Alternatively, this file can be distributed under the terms of the GNU General
+Public License V2 as published by the Free Software Foundation and can be
+found at http://www.gnu.org/licenses/gpl-2.0.html
+
+Alternatively, redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+notice, this 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 HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(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 __AL_PCIE_HAL_AXI_REG_H__
+#define __AL_PCIE_HAL_AXI_REG_H__
+
+#include "al_hal_plat_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+* Unit Registers
+*/
+
+
+
+struct al_pcie_rev1_2_axi_ctrl {
+ /* [0x0] */
+ uint32_t global;
+ uint32_t rsrvd_0;
+ /* [0x8] */
+ uint32_t master_bctl;
+ /* [0xc] */
+ uint32_t master_rctl;
+ /* [0x10] */
+ uint32_t master_ctl;
+ /* [0x14] */
+ uint32_t master_arctl;
+ /* [0x18] */
+ uint32_t master_awctl;
+ /* [0x1c] */
+ uint32_t slave_rctl;
+ /* [0x20] */
+ uint32_t slv_wctl;
+ /* [0x24] */
+ uint32_t slv_ctl;
+ /* [0x28] */
+ uint32_t dbi_ctl;
+ /* [0x2c] */
+ uint32_t vmid_mask;
+ uint32_t rsrvd[4];
+};
+struct al_pcie_rev3_axi_ctrl {
+ /* [0x0] */
+ uint32_t global;
+ uint32_t rsrvd_0;
+ /* [0x8] */
+ uint32_t master_bctl;
+ /* [0xc] */
+ uint32_t master_rctl;
+ /* [0x10] */
+ uint32_t master_ctl;
+ /* [0x14] */
+ uint32_t master_arctl;
+ /* [0x18] */
+ uint32_t master_awctl;
+ /* [0x1c] */
+ uint32_t slave_rctl;
+ /* [0x20] */
+ uint32_t slv_wctl;
+ /* [0x24] */
+ uint32_t slv_ctl;
+ /* [0x28] */
+ uint32_t dbi_ctl;
+ /* [0x2c] */
+ uint32_t vmid_mask;
+};
+struct al_pcie_rev1_axi_ob_ctrl {
+ /* [0x0] */
+ uint32_t cfg_target_bus;
+ /* [0x4] */
+ uint32_t cfg_control;
+ /* [0x8] */
+ uint32_t io_start_l;
+ /* [0xc] */
+ uint32_t io_start_h;
+ /* [0x10] */
+ uint32_t io_limit_l;
+ /* [0x14] */
+ uint32_t io_limit_h;
+ /* [0x18] */
+ uint32_t msg_start_l;
+ /* [0x1c] */
+ uint32_t msg_start_h;
+ /* [0x20] */
+ uint32_t msg_limit_l;
+ /* [0x24] */
+ uint32_t msg_limit_h;
+ uint32_t rsrvd[6];
+};
+struct al_pcie_rev2_axi_ob_ctrl {
+ /* [0x0] */
+ uint32_t cfg_target_bus;
+ /* [0x4] */
+ uint32_t cfg_control;
+ /* [0x8] */
+ uint32_t io_start_l;
+ /* [0xc] */
+ uint32_t io_start_h;
+ /* [0x10] */
+ uint32_t io_limit_l;
+ /* [0x14] */
+ uint32_t io_limit_h;
+ /* [0x18] */
+ uint32_t msg_start_l;
+ /* [0x1c] */
+ uint32_t msg_start_h;
+ /* [0x20] */
+ uint32_t msg_limit_l;
+ /* [0x24] */
+ uint32_t msg_limit_h;
+ /*
+ * [0x28] this register override the VMID field in the AXUSER [19:4],
+ * for the AXI master port.
+ */
+ uint32_t vmid_reg_ovrd;
+ /* [0x2c] this register override the ADDR[63:32] AXI master port. */
+ uint32_t addr_high_reg_ovrd_value;
+ /* [0x30] this register override the ADDR[63:32] AXI master port. */
+ uint32_t addr_high_reg_ovrd_sel;
+ /*
+ * [0x34] Define the size to replace in the master axi address bits
+ * [63:32]
+ */
+ uint32_t addr_size_replace;
+ uint32_t rsrvd[2];
+};
+struct al_pcie_rev3_axi_ob_ctrl {
+ /* [0x0] */
+ uint32_t cfg_target_bus;
+ /* [0x4] */
+ uint32_t cfg_control;
+ /* [0x8] */
+ uint32_t io_start_l;
+ /* [0xc] */
+ uint32_t io_start_h;
+ /* [0x10] */
+ uint32_t io_limit_l;
+ /* [0x14] */
+ uint32_t io_limit_h;
+ /* [0x18] */
+ uint32_t aw_msg_start_l;
+ /* [0x1c] */
+ uint32_t aw_msg_start_h;
+ /* [0x20] */
+ uint32_t aw_msg_limit_l;
+ /* [0x24] */
+ uint32_t aw_msg_limit_h;
+ /* [0x28] */
+ uint32_t ar_msg_start_l;
+ /* [0x2c] */
+ uint32_t ar_msg_start_h;
+ /* [0x30] */
+ uint32_t ar_msg_limit_l;
+ /* [0x34] */
+ uint32_t ar_msg_limit_h;
+ /* [0x38] */
+ uint32_t io_addr_mask_h;
+ /* [0x3c] */
+ uint32_t ar_msg_addr_mask_h;
+ /* [0x40] */
+ uint32_t aw_msg_addr_mask_h;
+ /*
+ * [0x44] this register override the VMID field in the AXUSER [19:4],
+ * for the AXI master port.
+ */
+ uint32_t vmid_reg_ovrd;
+ /* [0x48] this register override the ADDR[63:32] AXI master port. */
+ uint32_t addr_high_reg_ovrd_value;
+ /* [0x4c] this register override the ADDR[63:32] AXI master port. */
+ uint32_t addr_high_reg_ovrd_sel;
+ /*
+ * [0x50] Define the size to replace in the master axi address bits
+ * [63:32]
+ */
+ uint32_t addr_size_replace;
+ uint32_t rsrvd[3];
+};
+struct al_pcie_revx_axi_msg {
+ /* [0x0] */
+ uint32_t addr_high;
+ /* [0x4] */
+ uint32_t addr_low;
+ /* [0x8] */
+ uint32_t type;
+};
+struct al_pcie_revx_axi_pcie_status {
+ /* [0x0] */
+ uint32_t debug;
+};
+struct al_pcie_revx_axi_rd_parity {
+ /* [0x0] */
+ uint32_t log_high;
+ /* [0x4] */
+ uint32_t log_low;
+};
+struct al_pcie_revx_axi_rd_cmpl {
+ /* [0x0] */
+ uint32_t cmpl_log_high;
+ /* [0x4] */
+ uint32_t cmpl_log_low;
+};
+struct al_pcie_revx_axi_rd_to {
+ /* [0x0] */
+ uint32_t to_log_high;
+ /* [0x4] */
+ uint32_t to_log_low;
+};
+struct al_pcie_revx_axi_wr_cmpl {
+ /* [0x0] */
+ uint32_t wr_cmpl_log_high;
+ /* [0x4] */
+ uint32_t wr_cmpl_log_low;
+};
+struct al_pcie_revx_axi_wr_to {
+ /* [0x0] */
+ uint32_t wr_to_log_high;
+ /* [0x4] */
+ uint32_t wr_to_log_low;
+};
+struct al_pcie_revx_axi_pcie_global {
+ /* [0x0] */
+ uint32_t conf;
+};
+struct al_pcie_rev1_2_axi_status {
+ /* [0x0] */
+ uint32_t lane0;
+ /* [0x4] */
+ uint32_t lane1;
+ /* [0x8] */
+ uint32_t lane2;
+ /* [0xc] */
+ uint32_t lane3;
+};
+struct al_pcie_rev3_axi_status {
+ /* [0x0] */
+ uint32_t lane0;
+ /* [0x4] */
+ uint32_t lane1;
+ /* [0x8] */
+ uint32_t lane2;
+ /* [0xc] */
+ uint32_t lane3;
+ /* [0x10] */
+ uint32_t lane4;
+ /* [0x14] */
+ uint32_t lane5;
+ /* [0x18] */
+ uint32_t lane6;
+ /* [0x1c] */
+ uint32_t lane7;
+ uint32_t rsrvd[8];
+};
+struct al_pcie_rev1_2_axi_conf {
+ /* [0x0] */
+ uint32_t zero_lane0;
+ /* [0x4] */
+ uint32_t zero_lane1;
+ /* [0x8] */
+ uint32_t zero_lane2;
+ /* [0xc] */
+ uint32_t zero_lane3;
+ /* [0x10] */
+ uint32_t one_lane0;
+ /* [0x14] */
+ uint32_t one_lane1;
+ /* [0x18] */
+ uint32_t one_lane2;
+ /* [0x1c] */
+ uint32_t one_lane3;
+};
+struct al_pcie_rev3_axi_conf {
+ /* [0x0] */
+ uint32_t zero_lane0;
+ /* [0x4] */
+ uint32_t zero_lane1;
+ /* [0x8] */
+ uint32_t zero_lane2;
+ /* [0xc] */
+ uint32_t zero_lane3;
+ /* [0x10] */
+ uint32_t zero_lane4;
+ /* [0x14] */
+ uint32_t zero_lane5;
+ /* [0x18] */
+ uint32_t zero_lane6;
+ /* [0x1c] */
+ uint32_t zero_lane7;
+ /* [0x20] */
+ uint32_t one_lane0;
+ /* [0x24] */
+ uint32_t one_lane1;
+ /* [0x28] */
+ uint32_t one_lane2;
+ /* [0x2c] */
+ uint32_t one_lane3;
+ /* [0x30] */
+ uint32_t one_lane4;
+ /* [0x34] */
+ uint32_t one_lane5;
+ /* [0x38] */
+ uint32_t one_lane6;
+ /* [0x3c] */
+ uint32_t one_lane7;
+ uint32_t rsrvd[16];
+};
+
+struct al_pcie_revx_axi_msg_attr_axuser_table {
+ /* [0x0] 4 option, the index comes from */
+ uint32_t entry_vec;
+};
+
+struct al_pcie_revx_axi_parity {
+ /* [0x0] */
+ uint32_t en_axi;
+ /* [0x4] */
+ uint32_t status_axi;
+};
+struct al_pcie_revx_axi_pos_logged {
+ /* [0x0] */
+ uint32_t error_low;
+ /* [0x4] */
+ uint32_t error_high;
+};
+struct al_pcie_revx_axi_ordering {
+ /* [0x0] */
+ uint32_t pos_cntl;
+};
+struct al_pcie_revx_axi_link_down {
+ /* [0x0] */
+ uint32_t reset_extend;
+};
+struct al_pcie_revx_axi_pre_configuration {
+ /* [0x0] */
+ uint32_t pcie_core_setup;
+};
+struct al_pcie_revx_axi_init_fc {
+ /*
+ * Revision 1/2:
+ * [0x0] The sum of all the fields below must be 97
+ * Revision 3:
+ * [0x0] The sum of all the fields below must be 259
+ * */
+ uint32_t cfg;
+};
+struct al_pcie_revx_axi_int_grp_a_axi {
+ /*
+ * [0x0] Interrupt Cause Register
+ * Set by hardware.
+ * - If MSI-X is enabled, and auto_clear control bit =TRUE,
+ * automatically cleared after MSI-X message associated with this
+ * specific interrupt bit is sent (MSI-X acknowledge is received).
+ * - Software can set a bit in this register by writing 1 to the
+ * associated bit in the Interrupt Cause Set register.
+ * Write-0 clears a bit. Write-1 has no effect.
+ * - On CPU Read -- If clear_on_read control bit =TRUE, automatically
+ * cleared (all bits are cleared).
+ * When there is a conflict, and on the same clock cycle hardware tries
+ * to set a bit in the Interrupt Cause register, the specific bit is set
+ * to ensure the interrupt indication is not lost.
+ */
+ uint32_t cause;
+ uint32_t rsrvd_0;
+ /*
+ * [0x8] Interrupt Cause Set Register
+ * Writing 1 to a bit in this register sets its corresponding cause bit,
+ * enabling software to generate a hardware interrupt. Write 0 has no
+ * effect.
+ */
+ uint32_t cause_set;
+ uint32_t rsrvd_1;
+ /*
+ * [0x10] Interrupt Mask Register
+ * If Auto-mask control bit =TRUE, automatically set to 1 after MSI-X
+ * message associate to the associate interrupt bit is sent (AXI write
+ * acknowledge is received)
+ */
+ uint32_t mask;
+ uint32_t rsrvd_2;
+ /*
+ * [0x18] Interrupt Mask Clear Register
+ * Used when auto-mask control bit=True. It enables the CPU to clear a
+ * specific bit, preventing a scenario in which the CPU overrides
+ * another bit with 1 (old value) that hardware has just cleared to 0.
+ * Writing 0 to this register clears its corresponding mask bit. Write 1
+ * has no effect.
+ */
+ uint32_t mask_clear;
+ uint32_t rsrvd_3;
+ /*
+ * [0x20] Interrupt Status Register
+ * This register latches the status of the interrupt source.
+ */
+ uint32_t status;
+ uint32_t rsrvd_4;
+ /* [0x28] Interrupt Control Register */
+ uint32_t control;
+ uint32_t rsrvd_5;
+ /*
+ * [0x30] Interrupt Mask Register
+ * Each bit in this register masks the corresponding cause bit for
+ * generating an Abort signal. Its default value is determined by unit
+ * instantiation.
+ * Abort = Wire-OR of Cause & !Interrupt_Abort_Mask).
+ * This register provides an error handling configuration for error
+ * interrupts.
+ */
+ uint32_t abort_mask;
+ uint32_t rsrvd_6;
+ /*
+ * [0x38] Interrupt Log Register
+ * Each bit in this register masks the corresponding cause bit for
+ * capturing the log registers. Its default value is determined by unit
+ * instantiatio.n
+ * Log_capture = Wire-OR of Cause & !Interrupt_Log_Mask).
+ * This register provides an error handling configuration for error
+ * interrupts.
+ */
+ uint32_t log_mask;
+ uint32_t rsrvd;
+};
+
+struct al_pcie_rev3_axi_eq_ovrd_tx_rx_values {
+ /* [0x0] */
+ uint32_t cfg_0;
+ /* [0x4] */
+ uint32_t cfg_1;
+ /* [0x8] */
+ uint32_t cfg_2;
+ /* [0xc] */
+ uint32_t cfg_3;
+ /* [0x10] */
+ uint32_t cfg_4;
+ /* [0x14] */
+ uint32_t cfg_5;
+ /* [0x18] */
+ uint32_t cfg_6;
+ /* [0x1c] */
+ uint32_t cfg_7;
+ /* [0x20] */
+ uint32_t cfg_8;
+ /* [0x24] */
+ uint32_t cfg_9;
+ /* [0x28] */
+ uint32_t cfg_10;
+ /* [0x2c] */
+ uint32_t cfg_11;
+ uint32_t rsrvd[12];
+};
+struct al_pcie_rev3_axi_dbg_outstading_trans_axi {
+ /* [0x0] */
+ uint32_t read_master_counter;
+ /* [0x4] */
+ uint32_t write_master_counter;
+ /* [0x8] */
+ uint32_t read_slave_counter;
+};
+struct al_pcie_revx_axi_device_id {
+ /* [0x0] */
+ uint32_t device_rev_id;
+};
+struct al_pcie_revx_axi_power_mang_ovrd_cntl {
+ /* [0x0] */
+ uint32_t cfg_static_nof_elidle;
+ /* [0x4] */
+ uint32_t cfg_l0s_wait_ovrd;
+ /* [0x8] */
+ uint32_t cfg_l12_wait_ovrd;
+ /* [0xc] */
+ uint32_t cfg_l0s_delay_in_p0s;
+ /* [0x10] */
+ uint32_t cfg_l12_delay_in_p12;
+ /* [0x14] */
+ uint32_t cfg_l12_delay_in_p12_clk_rst;
+ /* [0x18] */
+ uint32_t cfg_delay_powerdown_bus;
+ uint32_t rsrvd;
+};
+struct al_pcie_rev3_axi_dbg_outstading_trans_axi_write {
+ /* [0x0] */
+ uint32_t slave_counter;
+};
+struct al_pcie_rev3_axi_attr_ovrd {
+ /*
+ * [0x0] In case of hit on the io message bar and
+ * a*_cfg_outbound_msg_no_snoop_n, the message attributes come from this
+ * register
+ */
+ uint32_t write_msg_ctrl_0;
+ /* [0x4] in case of message this register set the below attributes */
+ uint32_t write_msg_ctrl_1;
+ /*
+ * [0x8] In case of hit on the io message bar and
+ * a*_cfg_outbound_msg_no_snoop_n, the message attributes come from this
+ * register
+ */
+ uint32_t read_msg_ctrl_0;
+ /* [0xc] in case of message this register set the below attributes */
+ uint32_t read_msg_ctrl_1;
+ /* [0x10] in case of message this register set the below attributes */
+ uint32_t pf_sel;
+ uint32_t rsrvd[3];
+};
+struct al_pcie_rev3_axi_pf_axi_attr_ovrd {
+ /*
+ * [0x0] In case of hit on the io message bar and
+ * a*_cfg_outbound_msg_no_snoop_n, the message attributes come from this
+ * register
+ */
+ uint32_t func_ctrl_0;
+ /* [0x4] in case of message this register set the below attributes */
+ uint32_t func_ctrl_1;
+ /*
+ * [0x8] In case of hit on the io message bar and
+ * a*_cfg_outbound_msg_no_snoop_n, the message attributes come from this
+ * register
+ */
+ uint32_t func_ctrl_2;
+ /*
+ * [0xc] In case of hit on the io message bar and
+ * a*_cfg_outbound_msg_no_snoop_n, the message attributes come from this
+ * register
+ */
+ uint32_t func_ctrl_3;
+ /*
+ * [0x10] In case of hit on the io message bar and
+ * a*_cfg_outbound_msg_no_snoop_n, the message attributes come from this
+ * register
+ */
+ uint32_t func_ctrl_4;
+ /*
+ * [0x14] In case of hit on the io message bar and
+ * a*_cfg_outbound_msg_no_snoop_n, the message attributes come from this
+ * register
+ */
+ uint32_t func_ctrl_5;
+ /*
+ * [0x18] In case of hit on the io message bar and
+ * a*_cfg_outbound_msg_no_snoop_n, the message attributes come from this
+ * register
+ */
+ uint32_t func_ctrl_6;
+ /*
+ * [0x1c] In case of hit on the io message bar and
+ * a*_cfg_outbound_msg_no_snoop_n, the message attributes come from this
+ * register
+ */
+ uint32_t func_ctrl_7;
+ /*
+ * [0x20] In case of hit on the io message bar and
+ * a*_cfg_outbound_msg_no_snoop_n, the message attributes come from this
+ * register
+ */
+ uint32_t func_ctrl_8;
+ /*
+ * [0x24] In case of hit on the io message bar and
+ * a*_cfg_outbound_msg_no_snoop_n, the message attributes come from this
+ * register
+ */
+ uint32_t func_ctrl_9;
+ uint32_t rsrvd[6];
+};
+
+struct al_pcie_revx_axi_regs {
+ uint32_t rsrvd_0[91];
+ struct al_pcie_revx_axi_device_id device_id; /* [0x16c] */
+};
+
+struct al_pcie_rev1_axi_regs {
+ struct al_pcie_rev1_2_axi_ctrl ctrl; /* [0x0] */
+ struct al_pcie_rev1_axi_ob_ctrl ob_ctrl; /* [0x40] */
+ uint32_t rsrvd_0[4];
+ struct al_pcie_revx_axi_msg msg; /* [0x90] */
+ struct al_pcie_revx_axi_pcie_status pcie_status; /* [0x9c] */
+ struct al_pcie_revx_axi_rd_parity rd_parity; /* [0xa0] */
+ struct al_pcie_revx_axi_rd_cmpl rd_cmpl; /* [0xa8] */
+ struct al_pcie_revx_axi_rd_to rd_to; /* [0xb0] */
+ struct al_pcie_revx_axi_wr_cmpl wr_cmpl; /* [0xb8] */
+ struct al_pcie_revx_axi_wr_to wr_to; /* [0xc0] */
+ struct al_pcie_revx_axi_pcie_global pcie_global; /* [0xc8] */
+ struct al_pcie_rev1_2_axi_status status; /* [0xcc] */
+ struct al_pcie_rev1_2_axi_conf conf; /* [0xdc] */
+ struct al_pcie_revx_axi_parity parity; /* [0xfc] */
+ struct al_pcie_revx_axi_pos_logged pos_logged; /* [0x104] */
+ struct al_pcie_revx_axi_ordering ordering; /* [0x10c] */
+ struct al_pcie_revx_axi_link_down link_down; /* [0x110] */
+ struct al_pcie_revx_axi_pre_configuration pre_configuration; /* [0x114] */
+ struct al_pcie_revx_axi_init_fc init_fc; /* [0x118] */
+ uint32_t rsrvd_1[20];
+ struct al_pcie_revx_axi_device_id device_id; /* [0x16c] */
+ uint32_t rsrvd_2[36];
+ struct al_pcie_revx_axi_int_grp_a_axi int_grp_a; /* [0x200] */
+};
+
+struct al_pcie_rev2_axi_regs {
+ struct al_pcie_rev1_2_axi_ctrl ctrl; /* [0x0] */
+ struct al_pcie_rev2_axi_ob_ctrl ob_ctrl; /* [0x40] */
+ uint32_t rsrvd_0[4];
+ struct al_pcie_revx_axi_msg msg; /* [0x90] */
+ struct al_pcie_revx_axi_pcie_status pcie_status; /* [0x9c] */
+ struct al_pcie_revx_axi_rd_parity rd_parity; /* [0xa0] */
+ struct al_pcie_revx_axi_rd_cmpl rd_cmpl; /* [0xa8] */
+ struct al_pcie_revx_axi_rd_to rd_to; /* [0xb0] */
+ struct al_pcie_revx_axi_wr_cmpl wr_cmpl; /* [0xb8] */
+ struct al_pcie_revx_axi_wr_to wr_to; /* [0xc0] */
+ struct al_pcie_revx_axi_pcie_global pcie_global; /* [0xc8] */
+ struct al_pcie_rev1_2_axi_status status; /* [0xcc] */
+ struct al_pcie_rev1_2_axi_conf conf; /* [0xdc] */
+ struct al_pcie_revx_axi_parity parity; /* [0xfc] */
+ struct al_pcie_revx_axi_pos_logged pos_logged; /* [0x104] */
+ struct al_pcie_revx_axi_ordering ordering; /* [0x10c] */
+ struct al_pcie_revx_axi_link_down link_down; /* [0x110] */
+ struct al_pcie_revx_axi_pre_configuration pre_configuration; /* [0x114] */
+ struct al_pcie_revx_axi_init_fc init_fc; /* [0x118] */
+ uint32_t rsrvd_1[20];
+ struct al_pcie_revx_axi_device_id device_id; /* [0x16c] */
+ uint32_t rsrvd_2[36];
+ struct al_pcie_revx_axi_int_grp_a_axi int_grp_a; /* [0x200] */
+};
+
+struct al_pcie_rev3_axi_regs {
+ struct al_pcie_rev3_axi_ctrl ctrl; /* [0x0] */
+ struct al_pcie_rev3_axi_ob_ctrl ob_ctrl;/* [0x30] */
+ struct al_pcie_revx_axi_msg msg; /* [0x90] */
+ struct al_pcie_revx_axi_pcie_status pcie_status; /* [0x9c] */
+ struct al_pcie_revx_axi_rd_parity rd_parity; /* [0xa0] */
+ struct al_pcie_revx_axi_rd_cmpl rd_cmpl; /* [0xa8] */
+ struct al_pcie_revx_axi_rd_to rd_to; /* [0xb0] */
+ struct al_pcie_revx_axi_wr_cmpl wr_cmpl; /* [0xb8] */
+ struct al_pcie_revx_axi_wr_to wr_to; /* [0xc0] */
+ struct al_pcie_revx_axi_pcie_global pcie_global; /* [0xc8] */
+ uint32_t rsrvd_0;
+ struct al_pcie_revx_axi_parity parity; /* [0xd0] */
+ struct al_pcie_revx_axi_pos_logged pos_logged; /* [0xd8] */
+ struct al_pcie_revx_axi_ordering ordering; /* [0xe0] */
+ struct al_pcie_revx_axi_link_down link_down; /* [0xe4] */
+ struct al_pcie_revx_axi_pre_configuration pre_configuration;/* [0xe8] */
+ struct al_pcie_revx_axi_init_fc init_fc; /* [0xec] */
+ uint32_t rsrvd_1[4];
+ struct al_pcie_rev3_axi_eq_ovrd_tx_rx_values eq_ovrd_tx_rx_values;/* [0x100] */
+ struct al_pcie_rev3_axi_dbg_outstading_trans_axi dbg_outstading_trans_axi;/* [0x160] */
+ struct al_pcie_revx_axi_device_id device_id; /* [0x16c] */
+ struct al_pcie_revx_axi_power_mang_ovrd_cntl power_mang_ovrd_cntl;/* [0x170] */
+ struct al_pcie_rev3_axi_dbg_outstading_trans_axi_write dbg_outstading_trans_axi_write;/* [0x190] */
+ uint32_t rsrvd_2[3];
+ struct al_pcie_rev3_axi_attr_ovrd axi_attr_ovrd; /* [0x1a0] */
+ struct al_pcie_rev3_axi_pf_axi_attr_ovrd pf_axi_attr_ovrd[REV3_MAX_NUM_OF_PFS];/* [0x1c0] */
+ uint32_t rsrvd_3[64];
+ struct al_pcie_rev3_axi_status status; /* [0x3c0] */
+ struct al_pcie_rev3_axi_conf conf; /* [0x400] */
+ uint32_t rsrvd_4[32];
+ struct al_pcie_revx_axi_msg_attr_axuser_table msg_attr_axuser_table; /* [0x500] */
+ uint32_t rsrvd_5[191];
+ struct al_pcie_revx_axi_int_grp_a_axi int_grp_a; /* [0x800] */
+};
+
+/*
+* Registers Fields
+*/
+
+/**** Device ID register ****/
+#define PCIE_AXI_DEVICE_ID_REG_DEV_ID_MASK AL_FIELD_MASK(31, 16)
+#define PCIE_AXI_DEVICE_ID_REG_DEV_ID_SHIFT 16
+#define PCIE_AXI_DEVICE_ID_REG_DEV_ID_X4 (0 << PCIE_AXI_DEVICE_ID_REG_DEV_ID_SHIFT)
+#define PCIE_AXI_DEVICE_ID_REG_DEV_ID_X8 (2 << PCIE_AXI_DEVICE_ID_REG_DEV_ID_SHIFT)
+#define PCIE_AXI_DEVICE_ID_REG_REV_ID_MASK AL_FIELD_MASK(15, 0)
+#define PCIE_AXI_DEVICE_ID_REG_REV_ID_SHIFT 0
+
+/**** Global register ****/
+/*
+ * Not in use.
+ * Disable completion after inbound posted ordering enforcement to AXI bridge.
+ */
+#define PCIE_AXI_CTRL_GLOBAL_CPL_AFTER_P_ORDER_DIS (1 << 0)
+/*
+ * Not in use.
+ * Enforce completion after write ordering on AXI bridge. Only for CPU read
+ * requests.
+ */
+#define PCIE_AXI_CTRL_GLOBAL_CPU_CPL_ONLY_EN (1 << 1)
+/* When linked down, map all transactions to PCIe to DEC ERR. */
+#define PCIE_AXI_CTRL_GLOBAL_BLOCK_PCIE_SLAVE_EN (1 << 2)
+/*
+ * Wait for the NIC to flush before enabling reset to the PCIe core, on a link
+ * down event.
+ */
+#define PCIE_AXI_CTRL_GLOBAL_WAIT_SLV_FLUSH_EN (1 << 3)
+/*
+ * When the BME is cleared and this bit is set, it causes all transactions that
+ * do not get to the PCIe to be returned with DECERR.
+ */
+#define PCIE_REV1_2_AXI_CTRL_GLOBAL_MEM_BAR_MAP_TO_ERR (1 << 4)
+#define PCIE_REV3_AXI_CTRL_GLOBAL_MEM_BAR_MAP_TO_ERR_MASK 0x00000FF0
+#define PCIE_REV3_AXI_CTRL_GLOBAL_MEM_BAR_MAP_TO_ERR_SHIFT 4
+/*
+ * Wait for the DBI port (the port that enables access to the internal PCIe core
+ * registers) to flush before enabling reset to the PCIe core on link down
+ * event.
+ */
+#define PCIE_REV1_2_AXI_CTRL_GLOBAL_WAIT_DBI_FLUSH_EN (1 << 5)
+#define PCIE_REV3_AXI_CTRL_GLOBAL_WAIT_DBI_FLUSH_EN (1 << 12)
+/* Reserved. Read undefined; must read as zeros. */
+#define PCIE_REV3_AXI_CTRL_GLOBAL_CFG_FLUSH_DBI_AXI (1 << 13)
+/* Reserved. Read undefined; must read as zeros. */
+#define PCIE_REV3_AXI_CTRL_GLOBAL_CFG_HOLD_LNKDWN_RESET_SW (1 << 14)
+/* Reserved. Read undefined; must read as zeros. */
+#define PCIE_REV3_AXI_CTRL_GLOBAL_CFG_MASK_CORECLK_ACT_CLK_RST (1 << 15)
+/* Reserved. Read undefined; must read as zeros. */
+#define PCIE_REV3_AXI_CTRL_GLOBAL_CFG_MASK_RXELECIDLE_CLK_RST (1 << 16)
+/* Reserved. Read undefined; must read as zeros. */
+#define PCIE_REV3_AXI_CTRL_GLOBAL_CFG_ALLOW_NONSTICKY_RESET_WHEN_LNKDOWN_CLK_RST (1 << 17)
+
+/*
+ * When set, adds parity on the write and read address channels, and write data
+ * channel.
+ */
+#define PCIE_REV1_2_AXI_CTRL_GLOBAL_PARITY_CALC_EN_MSTR (1 << 16)
+#define PCIE_REV3_AXI_CTRL_GLOBAL_PARITY_CALC_EN_MSTR (1 << 18)
+/* When set, enables parity check on the read data. */
+#define PCIE_REV1_2_AXI_CTRL_GLOBAL_PARITY_ERR_EN_RD (1 << 17)
+#define PCIE_REV3_AXI_CTRL_GLOBAL_PARITY_ERR_EN_RD (1 << 19)
+/*
+ * When set, adds parity on the RD data channel.
+ */
+#define PCIE_REV1_2_AXI_CTRL_GLOBAL_PARITY_CALC_EN_SLV (1 << 18)
+#define PCIE_REV3_AXI_CTRL_GLOBAL_PARITY_CALC_EN_SLV (1 << 20)
+/*
+ * When set, enables parity check on the write data.
+ */
+#define PCIE_REV1_2_AXI_CTRL_GLOBAL_PARITY_ERR_EN_WR (1 << 19)
+#define PCIE_REV3_AXI_CTRL_GLOBAL_PARITY_ERR_EN_WR (1 << 21)
+/*
+ * When set, error track for timeout and parity is disabled, i.e., the logged
+ * address for parity/timeout/cmpl errors on the AXI master port is not valid,
+ * and timeout and completion errors check are disabled.
+ */
+#define PCIE_REV1_2_AXI_CTRL_GLOBAL_ERROR_TRACK_DIS (1 << 20)
+#define PCIE_REV3_AXI_CTRL_GLOBAL_ERROR_TRACK_DIS (1 << 22)
+
+/**** Master_Arctl register ****/
+/* override arcache */
+#define PCIE_AXI_CTRL_MASTER_ARCTL_OVR_ARCACHE (1 << 0)
+/* arache value */
+#define PCIE_AXI_CTRL_MASTER_ARCTL_ARACHE_VA_MASK 0x0000001E
+#define PCIE_AXI_CTRL_MASTER_ARCTL_ARACHE_VA_SHIFT 1
+/* arprot override */
+#define PCIE_AXI_CTRL_MASTER_ARCTL_ARPROT_OVR (1 << 5)
+/* arprot value */
+#define PCIE_AXI_CTRL_MASTER_ARCTL_ARPROT_VALUE_MASK 0x000001C0
+#define PCIE_AXI_CTRL_MASTER_ARCTL_ARPROT_VALUE_SHIFT 6
+/* vmid val */
+#define PCIE_AXI_CTRL_MASTER_ARCTL_VMID_VAL_MASK 0x01FFFE00
+#define PCIE_AXI_CTRL_MASTER_ARCTL_VMID_VAL_SHIFT 9
+/* IPA value */
+#define PCIE_AXI_CTRL_MASTER_ARCTL_IPA_VAL (1 << 25)
+/* overide snoop inidcation, if not set take it from mstr_armisc ... */
+#define PCIE_AXI_CTRL_MASTER_ARCTL_OVR_SNOOP (1 << 26)
+/*
+snoop indication value when override */
+#define PCIE_AXI_CTRL_MASTER_ARCTL_SNOOP (1 << 27)
+/*
+arqos value */
+#define PCIE_AXI_CTRL_MASTER_ARCTL_ARQOS_MASK 0xF0000000
+#define PCIE_AXI_CTRL_MASTER_ARCTL_ARQOS_SHIFT 28
+
+/**** Master_Awctl register ****/
+/* override arcache */
+#define PCIE_AXI_CTRL_MASTER_AWCTL_OVR_ARCACHE (1 << 0)
+/* awache value */
+#define PCIE_AXI_CTRL_MASTER_AWCTL_AWACHE_VA_MASK 0x0000001E
+#define PCIE_AXI_CTRL_MASTER_AWCTL_AWACHE_VA_SHIFT 1
+/* awprot override */
+#define PCIE_AXI_CTRL_MASTER_AWCTL_AWPROT_OVR (1 << 5)
+/* awprot value */
+#define PCIE_AXI_CTRL_MASTER_AWCTL_AWPROT_VALUE_MASK 0x000001C0
+#define PCIE_AXI_CTRL_MASTER_AWCTL_AWPROT_VALUE_SHIFT 6
+/* vmid val */
+#define PCIE_AXI_CTRL_MASTER_AWCTL_VMID_VAL_MASK 0x01FFFE00
+#define PCIE_AXI_CTRL_MASTER_AWCTL_VMID_VAL_SHIFT 9
+/* IPA value */
+#define PCIE_AXI_CTRL_MASTER_AWCTL_IPA_VAL (1 << 25)
+/* overide snoop inidcation, if not set take it from mstr_armisc ... */
+#define PCIE_AXI_CTRL_MASTER_AWCTL_OVR_SNOOP (1 << 26)
+/*
+snoop indication value when override */
+#define PCIE_AXI_CTRL_MASTER_AWCTL_SNOOP (1 << 27)
+/*
+awqos value */
+#define PCIE_AXI_CTRL_MASTER_AWCTL_AWQOS_MASK 0xF0000000
+#define PCIE_AXI_CTRL_MASTER_AWCTL_AWQOS_SHIFT 28
+
+/**** slv_ctl register ****/
+#define PCIE_AXI_CTRL_SLV_CTRL_IO_BAR_EN (1 << 6)
+
+/**** Cfg_Target_Bus register ****/
+/*
+ * Defines which MSBs to complete the number of the bust that arrived from ECAM.
+ * If set to 0, take the bit from the ECAM bar, otherwise from the busnum of
+ * this register.
+ * The LSB for the bus number comes on the addr[*:20].
+ */
+#define PCIE_AXI_MISC_OB_CTRL_CFG_TARGET_BUS_MASK_MASK 0x000000FF
+#define PCIE_AXI_MISC_OB_CTRL_CFG_TARGET_BUS_MASK_SHIFT 0
+/* Target bus number for outbound configuration type0 and type1 access */
+#define PCIE_AXI_MISC_OB_CTRL_CFG_TARGET_BUS_BUSNUM_MASK 0x0000FF00
+#define PCIE_AXI_MISC_OB_CTRL_CFG_TARGET_BUS_BUSNUM_SHIFT 8
+
+/**** Cfg_Control register ****/
+/* Primary bus number */
+#define PCIE_AXI_MISC_OB_CTRL_CFG_CONTROL_PBUS_MASK 0x000000FF
+#define PCIE_AXI_MISC_OB_CTRL_CFG_CONTROL_PBUS_SHIFT 0
+/*
+ *
+ * Subordinate bus number
+ */
+#define PCIE_AXI_MISC_OB_CTRL_CFG_CONTROL_SUBBUS_MASK 0x0000FF00
+#define PCIE_AXI_MISC_OB_CTRL_CFG_CONTROL_SUBBUS_SHIFT 8
+/* Secondary bus nnumber */
+#define PCIE_AXI_MISC_OB_CTRL_CFG_CONTROL_SEC_BUS_MASK 0x00FF0000
+#define PCIE_AXI_MISC_OB_CTRL_CFG_CONTROL_SEC_BUS_SHIFT 16
+/* Enable outbound configuration access through iATU. */
+#define PCIE_AXI_MISC_OB_CTRL_CFG_CONTROL_IATU_EN (1 << 31)
+
+/**** IO_Start_H register ****/
+/*
+ *
+ * Outbound ATIU I/O start address high
+ */
+#define PCIE_AXI_MISC_OB_CTRL_IO_START_H_ADDR_MASK 0x000003FF
+#define PCIE_AXI_MISC_OB_CTRL_IO_START_H_ADDR_SHIFT 0
+
+/**** IO_Limit_H register ****/
+/*
+ *
+ * Outbound ATIU I/O limit address high
+ */
+#define PCIE_AXI_MISC_OB_CTRL_IO_LIMIT_H_ADDR_MASK 0x000003FF
+#define PCIE_AXI_MISC_OB_CTRL_IO_LIMIT_H_ADDR_SHIFT 0
+
+/**** Msg_Start_H register ****/
+/*
+ *
+ * Outbound ATIU msg-no-data start address high
+ */
+#define PCIE_AXI_MISC_OB_CTRL_MSG_START_H_ADDR_MASK 0x000003FF
+#define PCIE_AXI_MISC_OB_CTRL_MSG_START_H_ADDR_SHIFT 0
+
+/**** Msg_Limit_H register ****/
+/*
+ *
+ * Outbound ATIU msg-no-data limit address high
+ */
+#define PCIE_AXI_MISC_OB_CTRL_MSG_LIMIT_H_ADDR_MASK 0x000003FF
+#define PCIE_AXI_MISC_OB_CTRL_MSG_LIMIT_H_ADDR_SHIFT 0
+
+/**** vmid_reg_ovrd register ****/
+/*
+ * select if to take the value from register or from address[63:48]:
+ * 1'b1: register value.
+ * 1'b0: from address[63:48]
+ */
+#define PCIE_AXI_MISC_OB_CTRL_VMID_REG_OVRD_SEL_MASK 0x0000FFFF
+#define PCIE_AXI_MISC_OB_CTRL_VMID_REG_OVRD_SEL_SHIFT 0
+/* vmid override value. */
+#define PCIE_AXI_MISC_OB_CTRL_VMID_REG_OVRD_VALUE_MASK 0xFFFF0000
+#define PCIE_AXI_MISC_OB_CTRL_VMID_REG_OVRD_VALUE_SHIFT 16
+
+/**** addr_size_replace register ****/
+/*
+ * Size in bits to replace from bit [63:64-N], when equal zero no replace is
+ * done.
+ */
+#define PCIE_AXI_MISC_OB_CTRL_ADDR_SIZE_REPLACE_VALUE_MASK 0x0000FFFF
+#define PCIE_AXI_MISC_OB_CTRL_ADDR_SIZE_REPLACE_VALUE_SHIFT 0
+/* Reserved. */
+#define PCIE_AXI_MISC_OB_CTRL_ADDR_SIZE_REPLACE_RSRVD_MASK 0xFFFF0000
+#define PCIE_AXI_MISC_OB_CTRL_ADDR_SIZE_REPLACE_RSRVD_SHIFT 16
+
+/**** type register ****/
+/* Type of message */
+#define PCIE_AXI_MISC_MSG_TYPE_TYPE_MASK 0x00FFFFFF
+#define PCIE_AXI_MISC_MSG_TYPE_TYPE_SHIFT 0
+/* Reserved */
+#define PCIE_AXI_MISC_MSG_TYPE_RSRVD_MASK 0xFF000000
+#define PCIE_AXI_MISC_MSG_TYPE_RSRVD_SHIFT 24
+
+/**** debug register ****/
+/* Causes ACI PCIe reset, including ,master/slave/DBI (registers). */
+#define PCIE_AXI_MISC_PCIE_STATUS_DEBUG_AXI_BRIDGE_RESET (1 << 0)
+/*
+ * Causes reset of the entire PCIe core (including the AXI bridge).
+ * When set, the software must not address the PCI core (through the MEM space
+ * and REG space).
+ */
+#define PCIE_AXI_MISC_PCIE_STATUS_DEBUG_CORE_RESET (1 << 1)
+/*
+ * Indicates that the SB is empty from the request to the PCIe (not including
+ * registers).
+ */
+#define PCIE_AXI_MISC_PCIE_STATUS_DEBUG_SB_FLUSH_OB_STATUS (1 << 2)
+/* MAP and transaction to the PCIe core to ERROR. */
+#define PCIE_AXI_MISC_PCIE_STATUS_DEBUG_SB_MAP_TO_ERR (1 << 3)
+/* Indicates that the pcie_core clock is gated off */
+#define PCIE_AXI_MISC_PCIE_STATUS_DEBUG_CORE_CLK_GATE_OFF (1 << 4)
+/* Reserved */
+#define PCIE_AXI_MISC_PCIE_STATUS_DEBUG_RSRVD_MASK 0xFFFFFFE0
+#define PCIE_AXI_MISC_PCIE_STATUS_DEBUG_RSRVD_SHIFT 5
+
+/**** conf register ****/
+/*
+ * Device Type
+ * Indicates the specific type of this PCI Express Function. It is also used to
+ * set the
+ * Device/Port Type field.
+ *
+ * 4'b0000: PCI Express Endpoint
+ * 4'b0001: Legacy PCI Express Endpoint
+ * 4'b0100: Root Port of PCI Express Root Complex
+ *
+ * Must be programmed before link training sequence, according to the reset
+ * strap.
+ * Change this register should be when the pci_exist (in the PBS regfile) is
+ * zero.
+ */
+#define PCIE_AXI_MISC_PCIE_GLOBAL_CONF_DEV_TYPE_MASK 0x0000000F
+#define PCIE_AXI_MISC_PCIE_GLOBAL_CONF_DEV_TYPE_SHIFT 0
+/*
+ * [i] - Lane i active
+ * Change this register should be when the pci_exist (in the PBS regfile) is
+ * zero.
+ */
+#define PCIE_REV1_2_AXI_MISC_PCIE_GLOBAL_CONF_NOF_ACT_LANES_MASK 0x000000F0
+#define PCIE_REV1_2_AXI_MISC_PCIE_GLOBAL_CONF_RESERVED_MASK 0xFFFFFF00
+#define PCIE_REV1_2_AXI_MISC_PCIE_GLOBAL_CONF_RESERVED_SHIFT 8
+#define PCIE_REVX_AXI_MISC_PCIE_GLOBAL_CONF_NOF_ACT_LANES_SHIFT 4
+#define PCIE_REV3_AXI_MISC_PCIE_GLOBAL_CONF_NOF_ACT_LANES_MASK 0x000FFFF0
+#define PCIE_REV3_AXI_MISC_PCIE_GLOBAL_CONF_RESERVED_MASK 0xFFF00000
+#define PCIE_REV3_AXI_MISC_PCIE_GLOBAL_CONF_RESERVED_SHIFT 20
+
+#define PCIE_REV1_2_AXI_MISC_PCIE_GLOBAL_CONF_MEM_SHUTDOWN 0x100
+#define PCIE_REV3_AXI_MISC_PCIE_GLOBAL_CONF_MEM_SHUTDOWN 0x100000
+
+/**** laneX register ****/
+#define PCIE_AXI_STATUS_LANE_IS_RESET AL_BIT(13)
+#define PCIE_AXI_STATUS_LANE_REQUESTED_SPEED_MASK AL_FIELD_MASK(2, 0)
+#define PCIE_AXI_STATUS_LANE_REQUESTED_SPEED_SHIFT 0
+
+/**** zero_laneX register ****/
+/* phy_mac_local_fs */
+#define PCIE_AXI_MISC_ZERO_LANEX_PHY_MAC_LOCAL_FS_MASK 0x0000003f
+#define PCIE_AXI_MISC_ZERO_LANEX_PHY_MAC_LOCAL_FS_SHIFT 0
+/* phy_mac_local_lf */
+#define PCIE_AXI_MISC_ZERO_LANEX_PHY_MAC_LOCAL_LF_MASK 0x00000fc0
+#define PCIE_AXI_MISC_ZERO_LANEX_PHY_MAC_LOCAL_LF_SHIFT 6
+
+/**** en_axi register ****/
+/* u4_ram2p */
+#define PCIE_AXI_PARITY_EN_AXI_U4_RAM2P AL_BIT(1)
+
+/**** pos_cntl register ****/
+/* Disables POS. */
+#define PCIE_AXI_POS_ORDER_AXI_POS_BYPASS (1 << 0)
+/* Clear the POS data structure. */
+#define PCIE_AXI_POS_ORDER_AXI_POS_CLEAR (1 << 1)
+/* Read push all write. */
+#define PCIE_AXI_POS_ORDER_AXI_POS_RSO_ENABLE (1 << 2)
+/*
+ * Causes the PCIe core to wait for all the BRESPs before issuing a read
+ * request.
+ */
+#define PCIE_AXI_POS_ORDER_AXI_DW_RD_FLUSH_WR (1 << 3)
+/*
+ * When set, to 1'b1 supports interleaving data return from the PCIe core. Valid
+ * only when cfg_bypass_cmpl_after_write_fix is set.
+ */
+#define PCIE_AXI_POS_ORDER_RD_CMPL_AFTER_WR_SUPPORT_RD_INTERLV (1 << 4)
+/* When set, to 1'b1 disables read completion after write ordering. */
+#define PCIE_AXI_POS_ORDER_BYPASS_CMPL_AFTER_WR_FIX (1 << 5)
+/*
+ * When set, disables EP mode read cmpl on the master port push slave writes,
+ * when each read response from the master is not interleaved.
+ */
+#define PCIE_AXI_POS_ORDER_EP_CMPL_AFTER_WR_DIS (1 << 6)
+/* When set, disables EP mode read cmpl on the master port push slave writes. */
+#define PCIE_AXI_POS_ORDER_EP_CMPL_AFTER_WR_SUPPORT_INTERLV_DIS (1 << 7)
+/* should be zero */
+#define PCIE_AXI_POS_ORDER_9_8 AL_FIELD_MASK(9, 8)
+/* Give the segmentation buffer not to wait for P writes to end in the AXI
+ * bridge before releasing the CMPL.
+ */
+#define PCIE_AXI_POS_ORDER_SEGMENT_BUFFER_DONT_WAIT_FOR_P_WRITES AL_BIT(10)
+/* should be zero */
+#define PCIE_AXI_POS_ORDER_11 AL_BIT(11)
+/**
+ * When set cause pcie core to send ready in the middle of the read data
+ * burst returning from the DRAM to the PCIe core
+ */
+#define PCIE_AXI_POS_ORDER_SEND_READY_ON_READ_DATA_BURST AL_BIT(12)
+/* When set disable the ATS CAP. */
+#define PCIE_AXI_CORE_SETUP_ATS_CAP_DIS AL_BIT(13)
+/* When set disable D3/D2/D1 PME support */
+#define PCIE_AXI_POS_ORDER_DISABLE_DX_PME AL_BIT(14)
+/* When set enable nonsticky reset when linkdown hot reset */
+#define PCIE_AXI_POS_ORDER_ENABLE_NONSTICKY_RESET_ON_HOT_RESET AL_BIT(15)
+/* When set, terminate message with data as UR request */
+#define PCIE_AXI_TERMINATE_DATA_MSG_AS_UR_REQ AL_BIT(16)
+
+/**** pcie_core_setup register ****/
+/*
+ * This Value delay the rate change to the serdes, until the EIOS is sent by the
+ * serdes. Should be program before the pcie_exist, is asserted.
+ */
+#define PCIE_AXI_CORE_SETUP_DELAY_MAC_PHY_RATE_MASK 0x000000FF
+#define PCIE_AXI_CORE_SETUP_DELAY_MAC_PHY_RATE_SHIFT 0
+/*
+ * Limit the number of outstanding AXI reads that the PCIe core can get. Should
+ * be program before the pcie_exist, is asserted.
+ */
+#define PCIE_AXI_CORE_SETUP_NOF_READS_ONSLAVE_INTRF_PCIE_CORE_MASK 0x0000FF00
+#define PCIE_AXI_CORE_SETUP_NOF_READS_ONSLAVE_INTRF_PCIE_CORE_SHIFT 8
+/* Enable the sriov feature. */
+#define PCIE_AXI_REV1_2_CORE_SETUP_SRIOV_ENABLE AL_BIT(16)
+/* not in use */
+#define PCIE_AXI_REV3_CORE_SETUP_NOT_IN_USE (1 << 16)
+/* Reserved. Read undefined; must read as zeros. */
+#define PCIE_AXI_REV3_CORE_SETUP_CFG_DELAY_AFTER_PCIE_EXIST_MASK 0x0FFE0000
+#define PCIE_AXI_REV3_CORE_SETUP_CFG_DELAY_AFTER_PCIE_EXIST_SHIFT 17
+
+/**** cfg register ****/
+/* This value set the possible out standing headers writes (post ... */
+#define PCIE_AXI_REV1_2_INIT_FC_CFG_NOF_P_HDR_MASK 0x0000007F
+#define PCIE_AXI_REV1_2_INIT_FC_CFG_NOF_P_HDR_SHIFT 0
+/* This value set the possible out standing headers reads (non-p ... */
+#define PCIE_AXI_REV1_2_INIT_FC_CFG_NOF_NP_HDR_MASK 0x00003F80
+#define PCIE_AXI_REV1_2_INIT_FC_CFG_NOF_NP_HDR_SHIFT 7
+/* This value set the possible out standing headers CMPLs , the ... */
+#define PCIE_AXI_REV1_2_INIT_FC_CFG_NOF_CPL_HDR_MASK 0x001FC000
+#define PCIE_AXI_REV1_2_INIT_FC_CFG_NOF_CPL_HDR_SHIFT 14
+
+#define PCIE_AXI_REV1_2_INIT_FC_CFG_RSRVD_MASK 0xFFE00000
+#define PCIE_AXI_REV1_2_INIT_FC_CFG_RSRVD_SHIFT 21
+
+/* This value set the possible out standing headers writes (post ... */
+#define PCIE_AXI_REV3_INIT_FC_CFG_NOF_P_HDR_MASK 0x000001FF
+#define PCIE_AXI_REV3_INIT_FC_CFG_NOF_P_HDR_SHIFT 0
+/* This value set the possible out standing headers reads (non-p ... */
+#define PCIE_AXI_REV3_INIT_FC_CFG_NOF_NP_HDR_MASK 0x0003FE00
+#define PCIE_AXI_REV3_INIT_FC_CFG_NOF_NP_HDR_SHIFT 9
+/* This value set the possible out standing headers CMPLs , the ... */
+#define PCIE_AXI_REV3_INIT_FC_CFG_NOF_CPL_HDR_MASK 0x07FC0000
+#define PCIE_AXI_REV3_INIT_FC_CFG_NOF_CPL_HDR_SHIFT 18
+ /*
+ * [27] cfg_cpl_p_rr: do round robin on the SB output btw Posted and CPL.
+ * [28] cfg_np_pass_p_rr, in case RR between CPL AND P, allow to pass NP in case
+ * p is empty.
+ * [29] cfg_np_part_of_rr_arb: NP also is a part of the round robin arbiter.
+ */
+#define PCIE_AXI_REV3_INIT_FC_CFG_RSRVD_MASK 0xF8000000
+#define PCIE_AXI_REV3_INIT_FC_CFG_RSRVD_SHIFT 27
+
+/**** write_msg_ctrl_0 register ****/
+/*
+ * choose if 17 in the AXUSER indicate message hint (1'b1) or no snoop
+ * indication (1'b0)
+ */
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_0_AW_CFG_OUTBOUND_MSG_NO_SNOOP_N (1 << 0)
+/* this bit define if the message is with data or without */
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_0_AW_CFG_MSG_WITH_DATA (1 << 1)
+/* message code for message with data. */
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_0_AW_CFG_MSG_CODE_DATA_MASK 0x000003FC
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_0_AW_CFG_MSG_CODE_DATA_SHIFT 2
+/* message code for message without data. */
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_0_AW_CFG_MSG_CODE_MASK 0x0003FC00
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_0_AW_CFG_MSG_CODE_SHIFT 10
+/* message ST value */
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_0_AW_CFG_MSG_ST_MASK 0x03FC0000
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_0_AW_CFG_MSG_ST_SHIFT 18
+/* message NO-SNOOP */
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_0_AW_CFG_MSG_NO_SNOOP (1 << 26)
+/* message TH bit */
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_0_AW_CFG_MSG_TH (1 << 27)
+/* message PH bits */
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_0_AW_CFG_MSG_PH_MASK 0x30000000
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_0_AW_CFG_MSG_PH_SHIFT 28
+/* Rsrvd */
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_0_RSRVD_MASK 0xC0000000
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_0_RSRVD_SHIFT 30
+
+/**** write_msg_ctrl_1 register ****/
+/* message type */
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_1_AW_CFG_MISC_MSG_TYPE_VALUE_MASK 0x0000001F
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_1_AW_CFG_MISC_MSG_TYPE_VALUE_SHIFT 0
+/* this bit define if the message is with data or without */
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_1_AW_CFG_MSG_DATA_TYPE_VALUE_MASK 0x000003E0
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_1_AW_CFG_MSG_DATA_TYPE_VALUE_SHIFT 5
+/* override axi size for message with no data. */
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_1_AW_CFG_MSG_NO_DATA_AXI_SIZE_OVRD (1 << 10)
+/* override the AXI size to the pcie core for message with no data. */
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_1_AW_CFG_MSG_NO_DATA_AXI_SIZE_MSG_MASK 0x00003800
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_1_AW_CFG_MSG_NO_DATA_AXI_SIZE_MSG_SHIFT 11
+/* override axi size for message with data. */
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_1_AW_CFG_MSG_DATA_AXI_SIZE_OVRD (1 << 14)
+/* override the AXI size to the pcie core for message with data. */
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_1_AW_CFG_MSG_DATA_AXI_SIZE_MSG_MASK 0x00038000
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_1_AW_CFG_MSG_DATA_AXI_SIZE_MSG_SHIFT 15
+/* Rsrvd */
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_1_RSRVD_MASK 0xFFFC0000
+#define PCIE_AXI_AXI_ATTR_OVRD_WR_MSG_CTRL_1_RSRVD_SHIFT 18
+
+/**** read_msg_ctrl_0 register ****/
+/*
+ * choose if 17 in the AXUSER indicate message hint (1'b1) or no snoop
+ * indication (1'b0)
+ */
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_0_AR_CFG_OUTBOUND_MSG_NO_SNOOP_N (1 << 0)
+/* this bit define if the message is with data or without */
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_0_AR_CFG_MSG_WITH_DATA (1 << 1)
+/* message code for message with data. */
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_0_AR_CFG_MSG_CODE_DATA_MASK 0x000003FC
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_0_AR_CFG_MSG_CODE_DATA_SHIFT 2
+/* message code for message without data. */
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_0_AR_CFG_MSG_CODE_MASK 0x0003FC00
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_0_AR_CFG_MSG_CODE_SHIFT 10
+/* message ST value */
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_0_AR_CFG_MSG_ST_MASK 0x03FC0000
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_0_AR_CFG_MSG_ST_SHIFT 18
+/* message NO-SNOOP */
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_0_AR_CFG_MSG_NO_SNOOP (1 << 26)
+/* message TH bit */
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_0_AR_CFG_MSG_TH (1 << 27)
+/* message PH bits */
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_0_AR_CFG_MSG_PH_MASK 0x30000000
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_0_AR_CFG_MSG_PH_SHIFT 28
+/* Rsrvd */
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_0_RSRVD_MASK 0xC0000000
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_0_RSRVD_SHIFT 30
+
+/**** read_msg_ctrl_1 register ****/
+/* message type */
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_1_AR_CFG_MISC_MSG_TYPE_VALUE_MASK 0x0000001F
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_1_AR_CFG_MISC_MSG_TYPE_VALUE_SHIFT 0
+/* this bit define if the message is with data or without */
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_1_AR_CFG_MSG_DATA_TYPE_VALUE_MASK 0x000003E0
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_1_AR_CFG_MSG_DATA_TYPE_VALUE_SHIFT 5
+/* override axi size for message with no data. */
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_1_AR_CFG_MSG_NO_DATA_AXI_SIZE_OVRD (1 << 10)
+/* override the AXI size to the pcie core for message with no data. */
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_1_AR_CFG_MSG_NO_DATA_AXI_SIZE_MSG_MASK 0x00003800
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_1_AR_CFG_MSG_NO_DATA_AXI_SIZE_MSG_SHIFT 11
+/* override axi size for message with data. */
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_1_AR_CFG_MSG_DATA_AXI_SIZE_OVRD (1 << 14)
+/* override the AXI size to the pcie core for message with data. */
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_1_AR_CFG_MSG_DATA_AXI_SIZE_MSG_MASK 0x00038000
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_1_AR_CFG_MSG_DATA_AXI_SIZE_MSG_SHIFT 15
+/* Rsrvd */
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_1_RSRVD_MASK 0xFFFC0000
+#define PCIE_AXI_AXI_ATTR_OVRD_READ_MSG_CTRL_1_RSRVD_SHIFT 18
+
+/**** pf_sel register ****/
+/* message type */
+#define PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_PF_BIT0_OVRD_FROM_AXUSER (1 << 0)
+/* this bit define if the message is with data or without */
+#define PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_PF_BIT0_OVRD_FROM_REG (1 << 1)
+/* override axi size for message with no data. */
+#define PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_PF_BIT0_ADDR_OFFSET_MASK 0x0000003C
+#define PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_PF_BIT0_ADDR_OFFSET_SHIFT 2
+/* override the AXI size to the pcie core for message with no data. */
+#define PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_CFG_PF_BIT0_OVRD (1 << 6)
+/* Rsrvd */
+#define PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_RSRVD_7 (1 << 7)
+/* message type */
+#define PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_PF_BIT1_OVRD_FROM_AXUSER (1 << 8)
+/* this bit define if the message is with data or without */
+#define PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_PF_BIT1_OVRD_FROM_REG (1 << 9)
+/* override axi size for message with no data. */
+#define PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_PF_BIT1_ADDR_OFFSET_MASK 0x00003C00
+#define PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_PF_BIT1_ADDR_OFFSET_SHIFT 10
+/* override the AXI size to the pcie core for message with no data. */
+#define PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_CFG_PF_BIT1_OVRD (1 << 14)
+/* Rsrvd */
+#define PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_RSRVD_MASK 0xFFFF8000
+#define PCIE_AXI_AXI_ATTR_OVRD_PF_SEL_RSRVD_SHIFT 15
+
+ /**** func_ctrl_0 register ****/
+/* choose the field from the axuser */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_0_PF_VEC_TH_OVRD_FROM_AXUSER (1 << 0)
+/* choose the field from register */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_0_PF_VEC_TH_OVRD_FROM_REG (1 << 1)
+/* field offset from the address portions according to the spec */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_0_PF_VEC_TH_ADDR_OFFSET_MASK 0x0000003C
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_0_PF_VEC_TH_ADDR_OFFSET_SHIFT 2
+/* register value override */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_0_CFG_TH_OVRD (1 << 6)
+/* choose the field from the axuser */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_0_PF_VEC_ST_VEC_OVRD_FROM_AXUSER_MASK 0x00007F80
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_0_PF_VEC_ST_VEC_OVRD_FROM_AXUSER_SHIFT 7
+/* choose the field from register */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_0_PF_VEC_ST_VEC_OVRD_FROM_REG_MASK 0x007F8000
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_0_PF_VEC_ST_VEC_OVRD_FROM_REG_SHIFT 15
+/* register value override */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_0_CFG_ST_VEC_OVRD_MASK 0x7F800000
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_0_CFG_ST_VEC_OVRD_SHIFT 23
+/* Rsrvd */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_0_RSRVD (1 << 31)
+
+/**** func_ctrl_2 register ****/
+/* choose the field from the axuser */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_PF_VEC_PH_VEC_OVRD_FROM_AXUSER_MASK 0x00000003
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_PF_VEC_PH_VEC_OVRD_FROM_AXUSER_SHIFT 0
+/* choose the field from register */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_PF_VEC_PH_VEC_OVRD_FROM_REG_MASK 0x0000000C
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_PF_VEC_PH_VEC_OVRD_FROM_REG_SHIFT 2
+/* in case the field take from the address, offset field for each bit. */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_PF_VEC_PH_VEC_ADDR_OFFSET_MASK 0x00000FF0
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_PF_VEC_PH_VEC_ADDR_OFFSET_SHIFT 4
+/* register value override */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_CFG_PH_VEC_OVRD_MASK 0x00003000
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_CFG_PH_VEC_OVRD_SHIFT 12
+/* Rsrvd */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_RSRVD_14_15_MASK 0x0000C000
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_RSRVD_14_15_SHIFT 14
+/* choose the field from the axuser */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_PF_VEC_VMID89_VEC_OVRD_FROM_AXUSER_MASK 0x00030000
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_PF_VEC_VMID89_VEC_OVRD_FROM_AXUSER_SHIFT 16
+/* choose the field from register */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_PF_VEC_VMID89_VEC_OVRD_FROM_REG_MASK 0x000C0000
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_PF_VEC_VMID89_VEC_OVRD_FROM_REG_SHIFT 18
+/* in case the field take from the address, offset field for each bit. */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_PF_VEC_VMID89_VEC_ADDR_OFFSET_MASK 0x0FF00000
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_PF_VEC_VMID89_VEC_ADDR_OFFSET_SHIFT 20
+/* register value override */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_CFG_VMID89_VEC_OVRD_MASK 0x30000000
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_CFG_VMID89_VEC_OVRD_SHIFT 28
+/* Rsrvd */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_RSRVD_MASK 0xC0000000
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_2_RSRVD_SHIFT 30
+
+/**** func_ctrl_3 register ****/
+/*
+ * When set take the corresponding bit address from register
+ * pf_vec_mem_addr44_53_ovrd
+ */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_3_PF_VEC_MEM_ADDR44_53_SEL_MASK 0x000003FF
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_3_PF_VEC_MEM_ADDR44_53_SEL_SHIFT 0
+/* override value. */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_3_PF_VEC_MEM_ADDR44_53_OVRD_MASK 0x000FFC00
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_3_PF_VEC_MEM_ADDR44_53_OVRD_SHIFT 10
+/*
+ * When set take the corresponding bit address from register
+ * pf_vec_mem_addr54_63_ovrd
+ */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_3_PF_VEC_MEM_ADDR54_63_SEL_MASK 0x3FF00000
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_3_PF_VEC_MEM_ADDR54_63_SEL_SHIFT 20
+/* Rsrvd */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_3_RSRVD_MASK 0xC0000000
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_3_RSRVD_SHIFT 30
+
+/**** func_ctrl_4 register ****/
+/* When set take the corresponding bit address from vmid value. */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_4_PF_VEC_MEM_ADDR54_63_SEL_VMID_MASK 0x000003FF
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_4_PF_VEC_MEM_ADDR54_63_SEL_VMID_SHIFT 0
+/* override value. */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_4_PF_VEC_MEM_ADDR54_63_OVRD_MASK 0x000FFC00
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_4_PF_VEC_MEM_ADDR54_63_OVRD_SHIFT 10
+/* Rsrvd */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_4_RSRVD_MASK 0xFFF00000
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_4_RSRVD_SHIFT 20
+
+/**** func_ctrl_5 register ****/
+/*
+ * When set take the corresponding bit address [63:44] from
+ * aw_pf_vec_msg_addr_ovrd
+ */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_5_AW_PF_VEC_MSG_ADDR_SEL_MASK 0x000FFFFF
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_5_AW_PF_VEC_MSG_ADDR_SEL_SHIFT 0
+/* Rsrvd */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_5_RSRVD_MASK 0xFFF00000
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_5_RSRVD_SHIFT 20
+
+/**** func_ctrl_6 register ****/
+/* override value. */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_6_AW_PF_VEC_MSG_ADDR_OVRD_MASK 0x000FFFFF
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_6_AW_PF_VEC_MSG_ADDR_OVRD_SHIFT 0
+/* Rsrvd */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_6_RSRVD_MASK 0xFFF00000
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_6_RSRVD_SHIFT 20
+
+/**** func_ctrl_7 register ****/
+/*
+ * When set take the corresponding bit address [63:44] from
+ * ar_pf_vec_msg_addr_ovrd
+ */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_7_AR_PF_VEC_MSG_ADDR_SEL_MASK 0x000FFFFF
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_7_AR_PF_VEC_MSG_ADDR_SEL_SHIFT 0
+/* Rsrvd */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_7_RSRVD_MASK 0xFFF00000
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_7_RSRVD_SHIFT 20
+
+/**** func_ctrl_8 register ****/
+/* override value. */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_8_AR_PF_VEC_MSG_ADDR_OVRD_MASK 0x000FFFFF
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_8_AR_PF_VEC_MSG_ADDR_OVRD_SHIFT 0
+/* Rsrvd */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_8_RSRVD_MASK 0xFFF00000
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_8_RSRVD_SHIFT 20
+
+/**** func_ctrl_9 register ****/
+/* no snoop override */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_9_PF_VEC_NO_SNOOP_OVRD (1 << 0)
+/* no snoop override value */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_9_PF_VEC_NO_SNOOP_OVRD_VALUE (1 << 1)
+/* atu bypass override */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_9_PF_VEC_ATU_BYPASS_OVRD (1 << 2)
+/* atu bypass override value */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_9_PF_VEC_ATU_BYPASS_OVRD_VALUE (1 << 3)
+/* Rsrvd */
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_9_RSRVD_MASK 0xFFFFFFF0
+#define PCIE_AXI_PF_AXI_ATTR_OVRD_FUNC_CTRL_9_RSRVD_SHIFT 4
+
+/**** entry_vec register ****/
+/* entry0 */
+#define PCIE_AXI_MSG_ATTR_AXUSER_TABLE_ENTRY_VEC_ENTRY_0_MASK 0x0000001F
+#define PCIE_AXI_MSG_ATTR_AXUSER_TABLE_ENTRY_VEC_ENTRY_0_SHIFT 0
+/* entry1 */
+#define PCIE_AXI_MSG_ATTR_AXUSER_TABLE_ENTRY_VEC_ENTRY_1_MASK 0x000003E0
+#define PCIE_AXI_MSG_ATTR_AXUSER_TABLE_ENTRY_VEC_ENTRY_1_SHIFT 5
+/* entry2 */
+#define PCIE_AXI_MSG_ATTR_AXUSER_TABLE_ENTRY_VEC_ENTRY_2_MASK 0x00007C00
+#define PCIE_AXI_MSG_ATTR_AXUSER_TABLE_ENTRY_VEC_ENTRY_2_SHIFT 10
+/* entry3 */
+#define PCIE_AXI_MSG_ATTR_AXUSER_TABLE_ENTRY_VEC_ENTRY_3_MASK 0x000F8000
+#define PCIE_AXI_MSG_ATTR_AXUSER_TABLE_ENTRY_VEC_ENTRY_3_SHIFT 15
+/* atu bypass for message "write" */
+#define PCIE_AXI_MSG_ATTR_AXUSER_TABLE_ENTRY_VEC_AW_MSG_ATU_BYPASS (1 << 20)
+/* atu bypass for message "read" */
+#define PCIE_AXI_MSG_ATTR_AXUSER_TABLE_ENTRY_VEC_AR_MSG_ATU_BYPASS (1 << 21)
+/* Rsrvd */
+#define PCIE_AXI_MSG_ATTR_AXUSER_TABLE_ENTRY_VEC_RSRVD_MASK 0xFFC00000
+#define PCIE_AXI_MSG_ATTR_AXUSER_TABLE_ENTRY_VEC_RSRVD_SHIFT 22
+
+/**** int_cause_grp_A_axi register ****/
+/*
+ * Master Response Composer Lookup Error
+ * Overflow that occurred in a lookup table of the Outbound responses. This
+ * indicates that there was a violation for the number of outstanding NP
+ * requests issued for the Inbound direction.
+ * Write zero to clear.
+ */
+#define PCIE_AXI_INT_GRP_A_CAUSE_GM_COMPOSER_LOOKUP_ERR (1 << 0)
+/*
+ * Indicates a PARITY ERROR on the master data read channel.
+ * Write zero to clear.
+ */
+#define PCIE_AXI_INT_GRP_A_CAUSE_PARITY_ERR_DATA_PATH_RD (1 << 2)
+/*
+ * Indicates a PARITY ERROR on the slave addr read channel.
+ * Write zero to clear.
+ */
+#define PCIE_AXI_INT_GRP_A_CAUSE_PARITY_ERR_OUT_ADDR_RD (1 << 3)
+/*
+ * Indicates a PARITY ERROR on the slave addr write channel.
+ * Write zero to clear.
+ */
+#define PCIE_AXI_INT_GRP_A_CAUSE_PARITY_ERR_OUT_ADDR_WR (1 << 4)
+/*
+ * Indicates a PARITY ERROR on the slave data write channel.
+ * Write zero to clear.
+ */
+#define PCIE_AXI_INT_GRP_A_CAUSE_PARITY_ERR_OUT_DATA_WR (1 << 5)
+/* Reserved */
+#define PCIE_AXI_INT_GRP_A_CAUSE_RESERVED_6 (1 << 6)
+/*
+ * Software error: ECAM write request with invalid bus number.
+ * Write Zero to clear
+ */
+#define PCIE_AXI_INT_GRP_A_CAUSE_SW_ECAM_ERR_RD (1 << 7)
+/*
+ * Software error: ECAM read request with invalid bus number.
+ * Write Zero to clear.
+ */
+#define PCIE_AXI_INT_GRP_A_CAUSE_SW_ECAM_ERR_WR (1 << 8)
+/* Indicates an ERROR in the PCIe application cause register. */
+#define PCIE_AXI_INT_GRP_A_CAUSE_PCIE_CORE_INT (1 << 9)
+/*
+ * Whenever the Master AXI finishes writing a message, it sets this bit.
+ * Whenever the int is cleared, the message information MSG_* regs are no longer
+ * valid.
+ */
+#define PCIE_AXI_INT_GRP_A_CAUSE_MSTR_AXI_GETOUT_MSG (1 << 10)
+/* Read AXI compilation has ERROR. */
+#define PCIE_AXI_INT_GRP_A_CAUSE_RD_CMPL_ERR (1 << 11)
+/* Write AXI compilation has ERROR. */
+#define PCIE_AXI_INT_GRP_A_CAUSE_WR_CMPL_ERR (1 << 12)
+/* Read AXI compilation has timed out. */
+#define PCIE_AXI_INT_GRP_A_CAUSE_RD_CMPL_TO (1 << 13)
+/* Write AXI compilation has timed out. */
+#define PCIE_AXI_INT_GRP_A_CAUSE_WR_CMPL_TO (1 << 14)
+/* Parity error AXI domain */
+#define PCIE_AXI_INT_GRP_A_CAUSE_PARITY_ERROR_AXI (1 << 15)
+/* POS error interrupt */
+#define PCIE_AXI_INT_GRP_A_CAUSE_POS_AXI_BRESP (1 << 16)
+/* The outstanding write counter become full should never happen */
+#define PCIE_AXI_INT_GRP_A_CAUSE_WRITE_CNT_FULL_ERR (1 << 17)
+/* BRESP received before the write counter increment. */
+#define PCIE_AXI_INT_GRP_A_CAUSE_BRESP_BEFORE_WR_CNT_INC_ERR (1 << 18)
+
+/**** int_control_grp_A_axi register ****/
+/* When Clear_on_Read =1, all bits of the Cause register are cleared on read. */
+#define PCIE_AXI_INT_GRP_A_CTRL_CLEAR_ON_READ (1 << 0)
+/*
+ * (Must be set only when MSIX is enabled.)
+ * When Auto-Mask =1 and an MSI-X ACK for this bit is received, its
+ * corresponding bit in the mask register is set, masking future interrupts.
+ */
+#define PCIE_AXI_INT_GRP_A_CTRL_AUTO_MASK (1 << 1)
+/*
+ * Auto_Clear (RW)
+ * When Auto-Clear =1, the bits in the Interrupt Cause register are auto-cleared
+ * after MSI-X is acknowledged. Must be used only if MSI-X is enabled.
+ */
+#define PCIE_AXI_INT_GRP_A_CTRL_AUTO_CLEAR (1 << 2)
+/*
+ * When set,_on_Posedge =1, the bits in the Interrupt Cause register are set on
+ * the posedge of the interrupt source, i.e., when interrupt source =1 and
+ * Interrupt Status = 0.
+ * When set,_on_Posedge =0, the bits in the Interrupt Cause register are set
+ * when interrupt source =1.
+ */
+#define PCIE_AXI_INT_GRP_A_CTRL_SET_ON_POS (1 << 3)
+/*
+ * When Moderation_Reset =1, all Moderation timers associated with the interrupt
+ * cause bits are cleared to 0, enabling immediate interrupt assertion if any
+ * unmasked cause bit is set to 1. This bit is self-negated.
+ */
+#define PCIE_AXI_INT_GRP_A_CTRL_MOD_RST (1 << 4)
+/*
+ * When mask_msi_x =1, no MSI-X from this group is sent. This bit is set to 1
+ * when the associate summary bit in this group is used to generate a single
+ * MSI-X for this group.
+ */
+#define PCIE_AXI_INT_GRP_A_CTRL_MASK_MSI_X (1 << 5)
+/* MSI-X AWID value. Same ID for all cause bits. */
+#define PCIE_AXI_INT_GRP_A_CTRL_AWID_MASK 0x00000F00
+#define PCIE_AXI_INT_GRP_A_CTRL_AWID_SHIFT 8
+/*
+ * This value determines the interval between interrupts. Writing ZERO disables
+ * Moderation.
+ */
+#define PCIE_AXI_INT_GRP_A_CTRL_MOD_INTV_MASK 0x00FF0000
+#define PCIE_AXI_INT_GRP_A_CTRL_MOD_INTV_SHIFT 16
+/*
+ * This value determines the Moderation_Timer_Clock speed.
+ * 0- Moderation-timer is decremented every 1x256 SB clock cycles ~1uS.
+ * 1- Moderation-timer is decremented every 2x256 SB clock cycles ~2uS.
+ * N- Moderation-timer is decremented every Nx256 SB clock cycles ~(N+1) uS.
+ */
+#define PCIE_AXI_INT_GRP_A_CTRL_MOD_RES_MASK 0x0F000000
+#define PCIE_AXI_INT_GRP_A_CTRL_MOD_RES_SHIFT 24
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __AL_HAL_pcie_axi_REG_H */
+
+/** @} end of ... group */
diff --git a/sys/arm/annapurna/alpine/hal/al_hal_pcie_interrupts.h b/sys/arm/annapurna/alpine/hal/al_hal_pcie_interrupts.h
new file mode 100644
index 0000000..357971c
--- /dev/null
+++ b/sys/arm/annapurna/alpine/hal/al_hal_pcie_interrupts.h
@@ -0,0 +1,271 @@
+/*-
+********************************************************************************
+Copyright (C) 2015 Annapurna Labs Ltd.
+
+This file may be licensed under the terms of the Annapurna Labs Commercial
+License Agreement.
+
+Alternatively, this file can be distributed under the terms of the GNU General
+Public License V2 as published by the Free Software Foundation and can be
+found at http://www.gnu.org/licenses/gpl-2.0.html
+
+Alternatively, redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+notice, this 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 HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(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 _AL_HAL_PCIE_INTERRUPTS_H_
+#define _AL_HAL_PCIE_INTERRUPTS_H_
+
+#include "al_hal_common.h"
+#include "al_hal_pcie.h"
+#include "al_hal_iofic.h"
+
+/**
+ * @defgroup group_pcie_interrupts PCIe interrupts
+ * @ingroup grouppcie
+ * @{
+ * The PCIe interrupts HAL can be used to control PCIe unit interrupts.
+ * There are 5 groups of interrupts: app group A, B, C, D and AXI.
+ * Only 2 interrupts go from the pcie unit to the GIC:
+ * 1. Summary for all the int groups (AXI+APP CORE).
+ * 2. INTA assert/deassert (RC only).
+ * For the specific GIC interrupt line, please check the architecture reference
+ * manual.
+ * The reset mask state of all interrupts is: Masked
+ *
+ * @file al_hal_pcie_interrupts.h
+ *
+ */
+
+/**
+ * PCIe interrupt groups
+ */
+enum al_pcie_int_group {
+ AL_PCIE_INT_GRP_A,
+ AL_PCIE_INT_GRP_B,
+ AL_PCIE_INT_GRP_C, /* Rev3 only */
+ AL_PCIE_INT_GRP_D, /* Rev3 only */
+ AL_PCIE_INT_GRP_AXI_A,
+};
+
+/**
+ * App group A interrupts mask - don't change
+ * All interrupts not listed below should be masked
+ */
+enum al_pcie_app_int_grp_a {
+ /** [RC only] Deassert_INTD received */
+ AL_PCIE_APP_INT_DEASSERT_INTD = AL_BIT(0),
+ /** [RC only] Deassert_INTC received */
+ AL_PCIE_APP_INT_DEASSERT_INTC = AL_BIT(1),
+ /** [RC only] Deassert_INTB received */
+ AL_PCIE_APP_INT_DEASSERT_INTB = AL_BIT(2),
+ /**
+ * [RC only] Deassert_INTA received - there's a didcated GIC interrupt
+ * line that reflects the status of ASSERT/DEASSERT of INTA
+ */
+ AL_PCIE_APP_INT_DEASSERT_INTA = AL_BIT(3),
+ /** [RC only] Assert_INTD received */
+ AL_PCIE_APP_INT_ASSERT_INTD = AL_BIT(4),
+ /** [RC only] Assert_INTC received */
+ AL_PCIE_APP_INT_ASSERT_INTC = AL_BIT(5),
+ /** [RC only] Assert_INTB received */
+ AL_PCIE_APP_INT_ASSERT_INTB = AL_BIT(6),
+ /**
+ * [RC only] Assert_INTA received - there's a didcated GIC interrupt
+ * line that reflects the status of ASSERT/DEASSERT of INTA
+ */
+ AL_PCIE_APP_INT_ASSERT_INTA = AL_BIT(7),
+ /** [RC only] MSI Controller Interrupt */
+ AL_PCIE_APP_INT_MSI_CNTR_RCV_INT = AL_BIT(8),
+ /** [EP only] MSI sent grant */
+ AL_PCIE_APP_INT_MSI_TRNS_GNT = AL_BIT(9),
+ /** [RC only] System error detected (ERR_COR, ERR_FATAL, ERR_NONFATAL) */
+ AL_PCIE_APP_INT_SYS_ERR_RC = AL_BIT(10),
+ /** [EP only] Software initiates FLR on a Physical Function */
+ AL_PCIE_APP_INT_FLR_PF_ACTIVE = AL_BIT(11),
+ /** [RC only] Root Error Command register assertion notification */
+ AL_PCIE_APP_INT_AER_RC_ERR = AL_BIT(12),
+ /** [RC only] Root Error Command register assertion notification With MSI or MSIX enabled */
+ AL_PCIE_APP_INT_AER_RC_ERR_MSI = AL_BIT(13),
+ /** [RC only] PME Status bit assertion in the Root Status register With INTA */
+ AL_PCIE_APP_INT_PME_INT = AL_BIT(15),
+ /** [RC only] PME Status bit assertion in the Root Status register With MSI or MSIX enabled */
+ AL_PCIE_APP_INT_PME_MSI = AL_BIT(16),
+ /** [RC/EP] The core assert link down event, whenever the link is going down */
+ AL_PCIE_APP_INT_LINK_DOWN = AL_BIT(21),
+ /** [EP only] When the EP gets a command to shut down, signal the software to block any new TLP. */
+ AL_PCIE_APP_INT_PM_XTLH_BLOCK_TLP = AL_BIT(22),
+ /** [RC/EP] PHY/MAC link up */
+ AL_PCIE_APP_INT_XMLH_LINK_UP = AL_BIT(23),
+ /** [RC/EP] Data link up */
+ AL_PCIE_APP_INT_RDLH_LINK_UP = AL_BIT(24),
+ /** [RC/EP] The LTSSM is in RCVRY_LOCK state. */
+ AL_PCIE_APP_INT_LTSSM_RCVRY_STATE = AL_BIT(25),
+ /**
+ * [RC/EP] CFG write transaction to the configuration space by the RC peer
+ * For RC the int/ will be set from DBI write (internal SoC write)]
+ */
+ AL_PCIE_APP_INT_CFG_WR = AL_BIT(26),
+ /** [EP only] CFG access in EP mode */
+ AL_PCIE_APP_INT_CFG_ACCESS = AL_BIT(31),
+};
+
+/**
+ * App group B interrupts mask - don't change
+ * All interrupts not listed below should be masked
+ */
+enum al_pcie_app_int_grp_b {
+ /** [RC only] PM_PME Message received */
+ AL_PCIE_APP_INT_GRP_B_PM_PME_MSG_RCVD = AL_BIT(0),
+ /** [RC only] PME_TO_Ack Message received */
+ AL_PCIE_APP_INT_GRP_B_PME_TO_ACK_MSG_RCVD = AL_BIT(1),
+ /** [EP only] PME_Turn_Off Message received */
+ AL_PCIE_APP_INT_GRP_B_PME_TURN_OFF_MSG_RCVD = AL_BIT(2),
+ /** [RC only] ERR_CORR Message received */
+ AL_PCIE_APP_INT_GRP_B_CORR_ERR_MSG_RCVD = AL_BIT(3),
+ /** [RC only] ERR_NONFATAL Message received */
+ AL_PCIE_APP_INT_GRP_B_NON_FTL_ERR_MSG_RCVD = AL_BIT(4),
+ /** [RC only] ERR_FATAL Message received */
+ AL_PCIE_APP_INT_GRP_B_FTL_ERR_MSG_RCVD = AL_BIT(5),
+ /**
+ * [RC/EP] Vendor Defined Message received
+ * Asserted when a vevdor message is received (with no data), buffers 2
+ * messages only, and latch the headers in registers
+ */
+ AL_PCIE_APP_INT_GRP_B_VNDR_MSG_A_RCVD = AL_BIT(6),
+ /**
+ * [RC/EP] Vendor Defined Message received
+ * Asserted when a vevdor message is received (with no data), buffers 2
+ * messages only, and latch the headers in registers
+ */
+ AL_PCIE_APP_INT_GRP_B_VNDR_MSG_B_RCVD = AL_BIT(7),
+ /** [EP only] Link Autonomous Bandwidth Status is updated */
+ AL_PCIE_APP_INT_GRP_B_LNK_BW_UPD = AL_BIT(12),
+ /** [EP only] Link Equalization Request bit in the Link Status 2 Register has been set */
+ AL_PCIE_APP_INT_GRP_B_LNK_EQ_REQ = AL_BIT(13),
+ /** [RC/EP] OB Vendor message request is granted by the PCIe core */
+ AL_PCIE_APP_INT_GRP_B_OB_VNDR_MSG_REQ_GRNT = AL_BIT(14),
+ /** [RC only] CPL timeout from the PCIe core indiication */
+ AL_PCIE_APP_INT_GRP_B_CPL_TO = AL_BIT(15),
+ /** [RC/EP] Slave Response Composer Lookup Error */
+ AL_PCIE_APP_INT_GRP_B_SLV_RESP_COMP_LKUP_ERR = AL_BIT(16),
+ /** [RC/EP] Parity Error */
+ AL_PCIE_APP_INT_GRP_B_PARITY_ERR = AL_BIT(17),
+ /** [EP only] Speed change request */
+ AL_PCIE_APP_INT_GRP_B_SPEED_CHANGE = AL_BIT(31),
+};
+
+/**
+ * AXI interrupts mask - don't change
+ * These are internal errors that can happen on the internal chip interface
+ * between the PCIe port and the I/O Fabric over the AXI bus. The notion of
+ * master and slave refer to the PCIe port master interface towards the I/O
+ * Fabric (i.e. for inbound PCIe writes/reads toward the I/O Fabric), while the
+ * slave interface refer to the I/O Fabric to PCIe port interface where the
+ * internal chip DMAs and CPU cluster is initiating transactions.
+ * All interrupts not listed below should be masked.
+ */
+enum al_pcie_axi_int {
+ /** [RC/EP] Master Response Composer Lookup Error */
+ AL_PCIE_AXI_INT_MSTR_RESP_COMP_LKUP_ERR = AL_BIT(0),
+ /** [RC/EP] PARITY ERROR on the master data read channel */
+ AL_PCIE_AXI_INT_PARITY_ERR_MSTR_DATA_RD_CHNL = AL_BIT(2),
+ /** [RC/EP] PARITY ERROR on the slave addr read channel */
+ AL_PCIE_AXI_INT_PARITY_ERR_SLV_ADDR_RD_CHNL = AL_BIT(3),
+ /** [RC/EP] PARITY ERROR on the slave addr write channel */
+ AL_PCIE_AXI_INT_PARITY_ERR_SLV_ADDR_WR_CHNL = AL_BIT(4),
+ /** [RC/EP] PARITY ERROR on the slave data write channel */
+ AL_PCIE_AXI_INT_PARITY_ERR_SLV_DATA_WR_CHNL = AL_BIT(5),
+ /** [RC only] Software error: ECAM write request with invalid bus number */
+ AL_PCIE_AXI_INT_ECAM_WR_REQ_INVLD_BUS_NUM = AL_BIT(7),
+ /** [RC only] Software error: ECAM read request with invalid bus number */
+ AL_PCIE_AXI_INT_ECAM_RD_REQ_INVLD_BUS_NUM = AL_BIT(8),
+ /** [RC/EP] Read AXI completion has ERROR */
+ AL_PCIE_AXI_INT_RD_AXI_COMPL_ERR = AL_BIT(11),
+ /** [RC/EP] Write AXI completion has ERROR */
+ AL_PCIE_AXI_INT_WR_AXI_COMPL_ERR = AL_BIT(12),
+ /** [RC/EP] Read AXI completion has timed out */
+ AL_PCIE_AXI_INT_RD_AXI_COMPL_TO = AL_BIT(13),
+ /** [RC/EP] Write AXI completion has timed out */
+ AL_PCIE_AXI_INT_WR_AXI_COMPL_TO = AL_BIT(14),
+ /** [RC/EP] Parity error AXI domain */
+ AL_PCIE_AXI_INT_AXI_DOM_PARITY_ERR = AL_BIT(15),
+ /** [RC/EP] POS error interrupt */
+ AL_PCIE_AXI_INT_POS_ERR = AL_BIT(16),
+};
+
+/**
+ * @brief Initialize and configure PCIe controller interrupts
+ * Doesn't change the mask state of the interrupts
+ * The reset mask state of all interrupts is: Masked
+ *
+ * @param pcie_port pcie port handle
+ */
+void al_pcie_ints_config(struct al_pcie_port *pcie_port);
+
+/**
+ * Unmask PCIe app group interrupts
+ * @param pcie_port pcie_port pcie port handle
+ * @param int_group interrupt group
+ * @param int_mask int_mask interrupts to unmask ('1' to unmask)
+ */
+void al_pcie_app_int_grp_unmask(
+ struct al_pcie_port *pcie_port,
+ enum al_pcie_int_group int_group,
+ uint32_t int_mask);
+
+/**
+ * Mask PCIe app group interrupts
+ * @param pcie_port pcie_port pcie port handle
+ * @param int_group interrupt group
+ * @param int_mask int_mask interrupts to unmask ('1' to mask)
+ */
+void al_pcie_app_int_grp_mask(
+ struct al_pcie_port *pcie_port,
+ enum al_pcie_int_group int_group,
+ uint32_t int_mask);
+
+/**
+ * Clear the PCIe app group interrupt cause
+ * @param pcie_port pcie port handle
+ * @param int_group interrupt group
+ * @param int_cause interrupt cause
+ */
+void al_pcie_app_int_grp_cause_clear(
+ struct al_pcie_port *pcie_port,
+ enum al_pcie_int_group int_group,
+ uint32_t int_cause);
+
+/**
+ * Read PCIe app group interrupt cause
+ * @param pcie_port pcie port handle
+ * @param int_group interrupt group
+ * @return interrupt cause or 0 in case the group is not supported
+ */
+uint32_t al_pcie_app_int_grp_cause_read(
+ struct al_pcie_port *pcie_port,
+ enum al_pcie_int_group int_group);
+
+#endif
+/** @} end of group_pcie_interrupts group */
diff --git a/sys/arm/annapurna/alpine/hal/al_hal_pcie_regs.h b/sys/arm/annapurna/alpine/hal/al_hal_pcie_regs.h
new file mode 100644
index 0000000..15c5735
--- /dev/null
+++ b/sys/arm/annapurna/alpine/hal/al_hal_pcie_regs.h
@@ -0,0 +1,594 @@
+/*-
+********************************************************************************
+Copyright (C) 2015 Annapurna Labs Ltd.
+
+This file may be licensed under the terms of the Annapurna Labs Commercial
+License Agreement.
+
+Alternatively, this file can be distributed under the terms of the GNU General
+Public License V2 as published by the Free Software Foundation and can be
+found at http://www.gnu.org/licenses/gpl-2.0.html
+
+Alternatively, redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+notice, this 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 HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(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 __AL_HAL_PCIE_REGS_H__
+#define __AL_HAL_PCIE_REGS_H__
+
+/* Note: Definitions before the includes so axi/wrapper regs sees them */
+
+/** Maximum physical functions supported */
+#define REV1_2_MAX_NUM_OF_PFS 1
+#define REV3_MAX_NUM_OF_PFS 4
+#define AL_MAX_NUM_OF_PFS 4 /* the maximum between all Revisions */
+
+#include "al_hal_pcie_axi_reg.h"
+#ifndef AL_PCIE_EX
+#include "al_hal_pcie_w_reg.h"
+#else
+#include "al_hal_pcie_w_reg_ex.h"
+#endif
+
+/**
+ * Revision IDs:
+ * ID_0: SlickRock M0
+ * ID_1: SlickRock A0
+ * ID_2: PeakRock x4
+ * ID_3: PeakRock x8
+ */
+#define AL_PCIE_REV_ID_0 0
+#define AL_PCIE_REV_ID_1 1
+#define AL_PCIE_REV_ID_2 2
+#define AL_PCIE_REV_ID_3 3
+
+#define AL_PCIE_AXI_REGS_OFFSET 0x0
+#define AL_PCIE_REV_1_2_APP_REGS_OFFSET 0x1000
+#define AL_PCIE_REV_3_APP_REGS_OFFSET 0x2000
+#define AL_PCIE_REV_1_2_CORE_CONF_BASE_OFFSET 0x2000
+#define AL_PCIE_REV_3_CORE_CONF_BASE_OFFSET 0x10000
+
+/** Maximum number of lanes supported */
+#define REV1_2_MAX_NUM_LANES 4
+#define REV3_MAX_NUM_LANES 8
+#define AL_MAX_NUM_OF_LANES 8 /* the maximum between all Revisions */
+
+struct al_pcie_core_iatu_regs {
+ uint32_t index;
+ uint32_t cr1;
+ uint32_t cr2;
+ uint32_t lower_base_addr;
+ uint32_t upper_base_addr;
+ uint32_t limit_addr;
+ uint32_t lower_target_addr;
+ uint32_t upper_target_addr;
+ uint32_t cr3;
+ uint32_t rsrvd[(0x270 - 0x224) >> 2];
+};
+
+struct al_pcie_core_port_regs {
+ uint32_t ack_lat_rply_timer;
+ uint32_t reserved1[(0x10 - 0x4) >> 2];
+ uint32_t port_link_ctrl;
+ uint32_t reserved2[(0x18 - 0x14) >> 2];
+ uint32_t timer_ctrl_max_func_num;
+ uint32_t filter_mask_reg_1;
+ uint32_t reserved3[(0x48 - 0x20) >> 2];
+ uint32_t vc0_posted_rcv_q_ctrl;
+ uint32_t vc0_non_posted_rcv_q_ctrl;
+ uint32_t vc0_comp_rcv_q_ctrl;
+ uint32_t reserved4[(0x10C - 0x54) >> 2];
+ uint32_t gen2_ctrl;
+ uint32_t reserved5[(0x190 - 0x110) >> 2];
+ uint32_t gen3_ctrl;
+ uint32_t gen3_eq_fs_lf;
+ uint32_t gen3_eq_preset_to_coef_map;
+ uint32_t gen3_eq_preset_idx;
+ uint32_t reserved6;
+ uint32_t gen3_eq_status;
+ uint32_t gen3_eq_ctrl;
+ uint32_t reserved7[(0x1B8 - 0x1AC) >> 2];
+ uint32_t pipe_loopback_ctrl;
+ uint32_t rd_only_wr_en;
+ uint32_t reserved8[(0x1D0 - 0x1C0) >> 2];
+ uint32_t axi_slave_err_resp;
+ uint32_t reserved9[(0x200 - 0x1D4) >> 2];
+ struct al_pcie_core_iatu_regs iatu;
+ uint32_t reserved10[(0x448 - 0x270) >> 2];
+};
+
+struct al_pcie_core_aer_regs {
+ /* 0x0 - PCI Express Extended Capability Header */
+ uint32_t header;
+ /* 0x4 - Uncorrectable Error Status Register */
+ uint32_t uncorr_err_stat;
+ /* 0x8 - Uncorrectable Error Mask Register */
+ uint32_t uncorr_err_mask;
+ /* 0xc - Uncorrectable Error Severity Register */
+ uint32_t uncorr_err_severity;
+ /* 0x10 - Correctable Error Status Register */
+ uint32_t corr_err_stat;
+ /* 0x14 - Correctable Error Mask Register */
+ uint32_t corr_err_mask;
+ /* 0x18 - Advanced Error Capabilities and Control Register */
+ uint32_t cap_and_ctrl;
+ /* 0x1c - Header Log Registers */
+ uint32_t header_log[4];
+ /* 0x2c - Root Error Command Register */
+ uint32_t root_err_cmd;
+ /* 0x30 - Root Error Status Register */
+ uint32_t root_err_stat;
+ /* 0x34 - Error Source Identification Register */
+ uint32_t err_src_id;
+};
+
+struct al_pcie_core_reg_space_rev_1_2 {
+ uint32_t config_header[0x40 >> 2];
+ uint32_t pcie_pm_cap_base;
+ uint32_t reserved1[(0x70 - 0x44) >> 2];
+ uint32_t pcie_cap_base;
+ uint32_t pcie_dev_cap_base;
+ uint32_t pcie_dev_ctrl_status;
+ uint32_t pcie_link_cap_base;
+ uint32_t reserved2[(0xB0 - 0x80) >> 2];
+ uint32_t msix_cap_base;
+ uint32_t reserved3[(0x100 - 0xB4) >> 2];
+ struct al_pcie_core_aer_regs aer;
+ uint32_t reserved4[(0x150 -
+ (0x100 +
+ sizeof(struct al_pcie_core_aer_regs))) >> 2];
+ uint32_t pcie_sec_ext_cap_base;
+ uint32_t reserved5[(0x700 - 0x154) >> 2];
+ struct al_pcie_core_port_regs port_regs;
+ uint32_t reserved6[(0x1000 -
+ (0x700 +
+ sizeof(struct al_pcie_core_port_regs))) >> 2];
+};
+
+struct al_pcie_core_reg_space_rev_3 {
+ uint32_t config_header[0x40 >> 2];
+ uint32_t pcie_pm_cap_base;
+ uint32_t reserved1[(0x70 - 0x44) >> 2];
+ uint32_t pcie_cap_base;
+ uint32_t pcie_dev_cap_base;
+ uint32_t pcie_dev_ctrl_status;
+ uint32_t pcie_link_cap_base;
+ uint32_t reserved2[(0xB0 - 0x80) >> 2];
+ uint32_t msix_cap_base;
+ uint32_t reserved3[(0x100 - 0xB4) >> 2];
+ struct al_pcie_core_aer_regs aer;
+ uint32_t reserved4[(0x158 -
+ (0x100 +
+ sizeof(struct al_pcie_core_aer_regs))) >> 2];
+ /* pcie_sec_cap is only applicable for function 0 */
+ uint32_t pcie_sec_ext_cap_base;
+ uint32_t reserved5[(0x178 - 0x15C) >> 2];
+ /* tph capability is only applicable for rev3 */
+ uint32_t tph_cap_base;
+ uint32_t reserved6[(0x700 - 0x17C) >> 2];
+ /* port_regs is only applicable for function 0 */
+ struct al_pcie_core_port_regs port_regs;
+ uint32_t reserved7[(0x1000 -
+ (0x700 +
+ sizeof(struct al_pcie_core_port_regs))) >> 2];
+};
+
+struct al_pcie_rev3_core_reg_space {
+ struct al_pcie_core_reg_space_rev_3 func[REV3_MAX_NUM_OF_PFS];
+};
+
+struct al_pcie_core_reg_space {
+ uint32_t *config_header;
+ uint32_t *pcie_pm_cap_base;
+ uint32_t *pcie_cap_base;
+ uint32_t *pcie_dev_cap_base;
+ uint32_t *pcie_dev_ctrl_status;
+ uint32_t *pcie_link_cap_base;
+ uint32_t *msix_cap_base;
+ struct al_pcie_core_aer_regs *aer;
+ uint32_t *pcie_sec_ext_cap_base;
+ uint32_t *tph_cap_base;
+};
+
+struct al_pcie_revx_regs {
+ struct al_pcie_revx_axi_regs __iomem axi;
+};
+
+struct al_pcie_rev1_regs {
+ struct al_pcie_rev1_axi_regs __iomem axi;
+ uint32_t reserved1[(AL_PCIE_REV_1_2_APP_REGS_OFFSET -
+ (AL_PCIE_AXI_REGS_OFFSET +
+ sizeof(struct al_pcie_rev1_axi_regs))) >> 2];
+ struct al_pcie_rev1_w_regs __iomem app;
+ uint32_t reserved2[(AL_PCIE_REV_1_2_CORE_CONF_BASE_OFFSET -
+ (AL_PCIE_REV_1_2_APP_REGS_OFFSET +
+ sizeof(struct al_pcie_rev1_w_regs))) >> 2];
+ struct al_pcie_core_reg_space_rev_1_2 core_space;
+};
+
+struct al_pcie_rev2_regs {
+ struct al_pcie_rev2_axi_regs __iomem axi;
+ uint32_t reserved1[(AL_PCIE_REV_1_2_APP_REGS_OFFSET -
+ (AL_PCIE_AXI_REGS_OFFSET +
+ sizeof(struct al_pcie_rev2_axi_regs))) >> 2];
+ struct al_pcie_rev2_w_regs __iomem app;
+ uint32_t reserved2[(AL_PCIE_REV_1_2_CORE_CONF_BASE_OFFSET -
+ (AL_PCIE_REV_1_2_APP_REGS_OFFSET +
+ sizeof(struct al_pcie_rev2_w_regs))) >> 2];
+ struct al_pcie_core_reg_space_rev_1_2 core_space;
+};
+
+struct al_pcie_rev3_regs {
+ struct al_pcie_rev3_axi_regs __iomem axi;
+ uint32_t reserved1[(AL_PCIE_REV_3_APP_REGS_OFFSET -
+ (AL_PCIE_AXI_REGS_OFFSET +
+ sizeof(struct al_pcie_rev3_axi_regs))) >> 2];
+ struct al_pcie_rev3_w_regs __iomem app;
+ uint32_t reserved2[(AL_PCIE_REV_3_CORE_CONF_BASE_OFFSET -
+ (AL_PCIE_REV_3_APP_REGS_OFFSET +
+ sizeof(struct al_pcie_rev3_w_regs))) >> 2];
+ struct al_pcie_rev3_core_reg_space core_space;
+};
+
+struct al_pcie_axi_ctrl {
+ uint32_t *global;
+ uint32_t *master_arctl;
+ uint32_t *master_awctl;
+ uint32_t *slv_ctl;
+};
+
+struct al_pcie_axi_ob_ctrl {
+ uint32_t *cfg_target_bus;
+ uint32_t *cfg_control;
+ uint32_t *io_start_l;
+ uint32_t *io_start_h;
+ uint32_t *io_limit_l;
+ uint32_t *io_limit_h;
+};
+
+struct al_pcie_axi_pcie_global {
+ uint32_t *conf;
+};
+
+struct al_pcie_axi_conf {
+ uint32_t *zero_lane0;
+ uint32_t *zero_lane1;
+ uint32_t *zero_lane2;
+ uint32_t *zero_lane3;
+ uint32_t *zero_lane4;
+ uint32_t *zero_lane5;
+ uint32_t *zero_lane6;
+ uint32_t *zero_lane7;
+};
+
+struct al_pcie_axi_status {
+ uint32_t *lane[AL_MAX_NUM_OF_LANES];
+};
+
+struct al_pcie_axi_parity {
+ uint32_t *en_axi;
+};
+
+struct al_pcie_axi_ordering {
+ uint32_t *pos_cntl;
+};
+
+struct al_pcie_axi_pre_configuration {
+ uint32_t *pcie_core_setup;
+};
+
+struct al_pcie_axi_init_fc {
+ uint32_t *cfg;
+};
+
+struct al_pcie_axi_attr_ovrd {
+ uint32_t *write_msg_ctrl_0;
+ uint32_t *write_msg_ctrl_1;
+ uint32_t *pf_sel;
+};
+
+struct al_pcie_axi_pf_axi_attr_ovrd {
+ uint32_t *func_ctrl_0;
+ uint32_t *func_ctrl_1;
+ uint32_t *func_ctrl_2;
+ uint32_t *func_ctrl_3;
+ uint32_t *func_ctrl_4;
+ uint32_t *func_ctrl_5;
+ uint32_t *func_ctrl_6;
+ uint32_t *func_ctrl_7;
+ uint32_t *func_ctrl_8;
+ uint32_t *func_ctrl_9;
+};
+
+struct al_pcie_axi_msg_attr_axuser_table {
+ uint32_t *entry_vec;
+};
+
+struct al_pcie_axi_regs {
+ struct al_pcie_axi_ctrl ctrl;
+ struct al_pcie_axi_ob_ctrl ob_ctrl;
+ struct al_pcie_axi_pcie_global pcie_global;
+ struct al_pcie_axi_conf conf;
+ struct al_pcie_axi_status status;
+ struct al_pcie_axi_parity parity;
+ struct al_pcie_axi_ordering ordering;
+ struct al_pcie_axi_pre_configuration pre_configuration;
+ struct al_pcie_axi_init_fc init_fc;
+ struct al_pcie_revx_axi_int_grp_a_axi *int_grp_a;
+ /* Rev3 only */
+ struct al_pcie_axi_attr_ovrd axi_attr_ovrd;
+ struct al_pcie_axi_pf_axi_attr_ovrd pf_axi_attr_ovrd[REV3_MAX_NUM_OF_PFS];
+ struct al_pcie_axi_msg_attr_axuser_table msg_attr_axuser_table;
+};
+
+struct al_pcie_w_global_ctrl {
+ uint32_t *port_init;
+ uint32_t *pm_control;
+ uint32_t *events_gen[REV3_MAX_NUM_OF_PFS];
+ uint32_t *corr_err_sts_int;
+ uint32_t *uncorr_err_sts_int;
+ uint32_t *sris_kp_counter;
+};
+
+struct al_pcie_w_soc_int {
+ uint32_t *mask_inta_leg_0;
+ uint32_t *mask_inta_leg_3; /* Rev 2/3 only */
+ uint32_t *mask_msi_leg_0;
+ uint32_t *mask_msi_leg_3; /* Rev 2/3 only */
+};
+struct al_pcie_w_atu {
+ uint32_t *in_mask_pair;
+ uint32_t *out_mask_pair;
+};
+
+struct al_pcie_w_regs {
+ struct al_pcie_w_global_ctrl global_ctrl;
+ struct al_pcie_revx_w_debug *debug;
+ struct al_pcie_revx_w_ap_user_send_msg *ap_user_send_msg;
+ struct al_pcie_w_soc_int soc_int[REV3_MAX_NUM_OF_PFS];
+ struct al_pcie_revx_w_cntl_gen *ctrl_gen;
+ struct al_pcie_revx_w_parity *parity;
+ struct al_pcie_w_atu atu;
+ struct al_pcie_revx_w_status_per_func *status_per_func[REV3_MAX_NUM_OF_PFS];
+ struct al_pcie_revx_w_int_grp *int_grp_a;
+ struct al_pcie_revx_w_int_grp *int_grp_b;
+ struct al_pcie_revx_w_int_grp *int_grp_c;
+ struct al_pcie_revx_w_int_grp *int_grp_d;
+};
+
+struct al_pcie_regs {
+ struct al_pcie_axi_regs axi;
+ struct al_pcie_w_regs app;
+ struct al_pcie_core_port_regs *port_regs;
+ struct al_pcie_core_reg_space core_space[REV3_MAX_NUM_OF_PFS];
+};
+
+#define PCIE_AXI_MISC_PCIE_GLOBAL_CONF_DEV_TYPE_EP 0
+#define PCIE_AXI_MISC_PCIE_GLOBAL_CONF_DEV_TYPE_RC 4
+
+#define PCIE_PORT_GEN2_CTRL_DIRECT_SPEED_CHANGE AL_BIT(17)
+#define PCIE_PORT_GEN2_CTRL_TX_SWING_LOW_SHIFT 18
+#define PCIE_PORT_GEN2_CTRL_TX_COMPLIANCE_RCV_SHIFT 19
+#define PCIE_PORT_GEN2_CTRL_DEEMPHASIS_SET_SHIFT 20
+#define PCIE_PORT_GEN2_CTRL_NUM_OF_LANES_MASK AL_FIELD_MASK(12, 8)
+#define PCIE_PORT_GEN2_CTRL_NUM_OF_LANES_SHIFT 8
+
+#define PCIE_PORT_GEN3_CTRL_EQ_PHASE_2_3_DISABLE_SHIFT 9
+#define PCIE_PORT_GEN3_CTRL_EQ_DISABLE_SHIFT 16
+
+#define PCIE_PORT_GEN3_EQ_LF_SHIFT 0
+#define PCIE_PORT_GEN3_EQ_LF_MASK 0x3f
+#define PCIE_PORT_GEN3_EQ_FS_SHIFT 6
+#define PCIE_PORT_GEN3_EQ_FS_MASK (0x3f << PCIE_PORT_GEN3_EQ_FS_SHIFT)
+
+#define PCIE_PORT_LINK_CTRL_LB_EN_SHIFT 2
+#define PCIE_PORT_LINK_CTRL_FAST_LINK_EN_SHIFT 7
+#define PCIE_PORT_LINK_CTRL_LINK_CAPABLE_MASK AL_FIELD_MASK(21, 16)
+#define PCIE_PORT_LINK_CTRL_LINK_CAPABLE_SHIFT 16
+
+#define PCIE_PORT_PIPE_LOOPBACK_CTRL_PIPE_LB_EN_SHIFT 31
+
+#define PCIE_PORT_AXI_SLAVE_ERR_RESP_ALL_MAPPING_SHIFT 0
+
+/** timer_ctrl_max_func_num register
+ * Max physical function number (for example: 0 for 1PF, 3 for 4PFs)
+ */
+#define PCIE_PORT_GEN3_MAX_FUNC_NUM AL_FIELD_MASK(7, 0)
+
+/* filter_mask_reg_1 register */
+/**
+ * SKP Interval Value.
+ * The number of symbol times to wait between transmitting SKP ordered sets
+ */
+#define PCIE_FLT_MASK_SKP_INT_VAL_MASK AL_FIELD_MASK(10, 0)
+
+/*
+ * 0: Treat Function MisMatched TLPs as UR
+ * 1: Treat Function MisMatched TLPs as Supported
+ */
+#define CX_FLT_MASK_UR_FUNC_MISMATCH AL_BIT(16)
+
+/*
+ * 0: Treat CFG type1 TLPs as UR for EP; Supported for RC
+ * 1: Treat CFG type1 TLPs as Supported for EP; UR for RC
+ */
+#define CX_FLT_MASK_CFG_TYPE1_RE_AS_UR AL_BIT(19)
+
+/*
+ * 0: Enforce requester id match for received CPL TLPs.
+ * A violation results in cpl_abort, and possibly AER of unexp_cpl_err,
+ * cpl_rcvd_ur, cpl_rcvd_ca
+ * 1: Mask requester id match for received CPL TLPs
+ */
+#define CX_FLT_MASK_CPL_REQID_MATCH AL_BIT(22)
+
+/*
+ * 0: Enforce function match for received CPL TLPs.
+ * A violation results in cpl_abort, and possibly AER of unexp_cpl_err,
+ * cpl_rcvd_ur, cpl_rcvd_ca
+ * 1: Mask function match for received CPL TLPs
+ */
+#define CX_FLT_MASK_CPL_FUNC_MATCH AL_BIT(23)
+
+/* vc0_posted_rcv_q_ctrl register */
+#define RADM_PQ_HCRD_VC0_MASK AL_FIELD_MASK(19, 12)
+#define RADM_PQ_HCRD_VC0_SHIFT 12
+
+/* vc0_non_posted_rcv_q_ctrl register */
+#define RADM_NPQ_HCRD_VC0_MASK AL_FIELD_MASK(19, 12)
+#define RADM_NPQ_HCRD_VC0_SHIFT 12
+
+/* vc0_comp_rcv_q_ctrl register */
+#define RADM_CPLQ_HCRD_VC0_MASK AL_FIELD_MASK(19, 12)
+#define RADM_CPLQ_HCRD_VC0_SHIFT 12
+
+/**** iATU, Control Register 1 ****/
+
+/**
+ * When the Address and BAR matching logic in the core indicate that a MEM-I/O
+ * transaction matches a BAR in the function corresponding to this value, then
+ * address translation proceeds. This check is only performed if the "Function
+ * Number Match Enable" bit of the "iATU Control 2 Register" is set
+ */
+#define PCIE_IATU_CR1_FUNC_NUM_MASK AL_FIELD_MASK(24, 20)
+#define PCIE_IATU_CR1_FUNC_NUM_SHIFT 20
+
+/**** iATU, Control Register 2 ****/
+/** For outbound regions, the Function Number Translation Bypass mode enables
+ * taking the function number of the translated TLP from the PCIe core
+ * interface and not from the "Function Number" field of CR1.
+ * For inbound regions, this bit should be asserted when physical function
+ * match mode needs to be enabled
+ */
+#define PCIE_IATU_CR2_FUNC_NUM_TRANS_BYPASS_FUNC_MATCH_ENABLE_MASK AL_BIT(19)
+#define PCIE_IATU_CR2_FUNC_NUM_TRANS_BYPASS_FUNC_MATCH_ENABLE_SHIFT 19
+
+/* pcie_dev_ctrl_status register */
+#define PCIE_PORT_DEV_CTRL_STATUS_CORR_ERR_REPORT_EN AL_BIT(0)
+#define PCIE_PORT_DEV_CTRL_STATUS_NON_FTL_ERR_REPORT_EN AL_BIT(1)
+#define PCIE_PORT_DEV_CTRL_STATUS_FTL_ERR_REPORT_EN AL_BIT(2)
+#define PCIE_PORT_DEV_CTRL_STATUS_UNSUP_REQ_REPORT_EN AL_BIT(3)
+
+#define PCIE_PORT_DEV_CTRL_STATUS_MPS_MASK AL_FIELD_MASK(7, 5)
+#define PCIE_PORT_DEV_CTRL_STATUS_MPS_SHIFT 5
+#define PCIE_PORT_DEV_CTRL_STATUS_MPS_VAL_256 (1 << PCIE_PORT_DEV_CTRL_STATUS_MPS_SHIFT)
+
+#define PCIE_PORT_DEV_CTRL_STATUS_MRRS_MASK AL_FIELD_MASK(14, 12)
+#define PCIE_PORT_DEV_CTRL_STATUS_MRRS_SHIFT 12
+#define PCIE_PORT_DEV_CTRL_STATUS_MRRS_VAL_256 (1 << PCIE_PORT_DEV_CTRL_STATUS_MRRS_SHIFT)
+
+/******************************************************************************
+ * AER registers
+ ******************************************************************************/
+/* PCI Express Extended Capability ID */
+#define PCIE_AER_CAP_ID_MASK AL_FIELD_MASK(15, 0)
+#define PCIE_AER_CAP_ID_SHIFT 0
+#define PCIE_AER_CAP_ID_VAL 1
+/* Capability Version */
+#define PCIE_AER_CAP_VER_MASK AL_FIELD_MASK(19, 16)
+#define PCIE_AER_CAP_VER_SHIFT 16
+#define PCIE_AER_CAP_VER_VAL 2
+
+/* First Error Pointer */
+#define PCIE_AER_CTRL_STAT_FIRST_ERR_PTR_MASK AL_FIELD_MASK(4, 0)
+#define PCIE_AER_CTRL_STAT_FIRST_ERR_PTR_SHIFT 0
+/* ECRC Generation Capability */
+#define PCIE_AER_CTRL_STAT_ECRC_GEN_SUPPORTED AL_BIT(5)
+/* ECRC Generation Enable */
+#define PCIE_AER_CTRL_STAT_ECRC_GEN_EN AL_BIT(6)
+/* ECRC Check Capable */
+#define PCIE_AER_CTRL_STAT_ECRC_CHK_SUPPORTED AL_BIT(7)
+/* ECRC Check Enable */
+#define PCIE_AER_CTRL_STAT_ECRC_CHK_EN AL_BIT(8)
+
+/* Correctable Error Reporting Enable */
+#define PCIE_AER_ROOT_ERR_CMD_CORR_ERR_RPRT_EN AL_BIT(0)
+/* Non-Fatal Error Reporting Enable */
+#define PCIE_AER_ROOT_ERR_CMD_NON_FTL_ERR_RPRT_EN AL_BIT(1)
+/* Fatal Error Reporting Enable */
+#define PCIE_AER_ROOT_ERR_CMD_FTL_ERR_RPRT_EN AL_BIT(2)
+
+/* ERR_COR Received */
+#define PCIE_AER_ROOT_ERR_STAT_CORR_ERR AL_BIT(0)
+/* Multiple ERR_COR Received */
+#define PCIE_AER_ROOT_ERR_STAT_CORR_ERR_MULTI AL_BIT(1)
+/* ERR_FATAL/NONFATAL Received */
+#define PCIE_AER_ROOT_ERR_STAT_FTL_NON_FTL_ERR AL_BIT(2)
+/* Multiple ERR_FATAL/NONFATAL Received */
+#define PCIE_AER_ROOT_ERR_STAT_FTL_NON_FTL_ERR_MULTI AL_BIT(3)
+/* First Uncorrectable Fatal */
+#define PCIE_AER_ROOT_ERR_STAT_FIRST_UNCORR_FTL AL_BIT(4)
+/* Non-Fatal Error Messages Received */
+#define PCIE_AER_ROOT_ERR_STAT_NON_FTL_RCVD AL_BIT(5)
+/* Fatal Error Messages Received */
+#define PCIE_AER_ROOT_ERR_STAT_FTL_RCVD AL_BIT(6)
+/* Advanced Error Interrupt Message Number */
+#define PCIE_AER_ROOT_ERR_STAT_ERR_INT_MSG_NUM_MASK AL_FIELD_MASK(31, 27)
+#define PCIE_AER_ROOT_ERR_STAT_ERR_INT_MSG_NUM_SHIFT 27
+
+/* ERR_COR Source Identification */
+#define PCIE_AER_SRC_ID_CORR_ERR_MASK AL_FIELD_MASK(15, 0)
+#define PCIE_AER_SRC_ID_CORR_ERR_SHIFT 0
+/* ERR_FATAL/NONFATAL Source Identification */
+#define PCIE_AER_SRC_ID_CORR_ERR_FTL_NON_FTL_MASK AL_FIELD_MASK(31, 16)
+#define PCIE_AER_SRC_ID_CORR_ERR_FTL_NON_FTL_SHIFT 16
+
+/* AER message */
+#define PCIE_AER_MSG_REQID_MASK AL_FIELD_MASK(31, 16)
+#define PCIE_AER_MSG_REQID_SHIFT 16
+#define PCIE_AER_MSG_TYPE_MASK AL_FIELD_MASK(15, 8)
+#define PCIE_AER_MSG_TYPE_SHIFT 8
+#define PCIE_AER_MSG_RESERVED AL_FIELD_MASK(7, 1)
+#define PCIE_AER_MSG_VALID AL_BIT(0)
+/* AER message ack */
+#define PCIE_AER_MSG_ACK AL_BIT(0)
+/* AER errors definitions */
+#define AL_PCIE_AER_TYPE_CORR (0x30)
+#define AL_PCIE_AER_TYPE_NON_FATAL (0x31)
+#define AL_PCIE_AER_TYPE_FATAL (0x33)
+/* Requester ID Bus */
+#define AL_PCIE_REQID_BUS_NUM_SHIFT (8)
+
+/******************************************************************************
+ * TPH registers
+ ******************************************************************************/
+#define PCIE_TPH_NEXT_POINTER AL_FIELD_MASK(31, 20)
+
+/******************************************************************************
+ * Config Header registers
+ ******************************************************************************/
+/**
+ * see BIST_HEADER_TYPE_LATENCY_CACHE_LINE_SIZE_REG in core spec
+ * Note: valid only for EP mode
+ */
+#define PCIE_BIST_HEADER_TYPE_BASE 0xc
+#define PCIE_BIST_HEADER_TYPE_MULTI_FUNC_MASK AL_BIT(23)
+
+/******************************************************************************
+ * SRIS KP counters default values
+ ******************************************************************************/
+#define PCIE_SRIS_KP_COUNTER_GEN3_DEFAULT_VAL (0x24)
+#define PCIE_SRIS_KP_COUNTER_GEN21_DEFAULT_VAL (0x4B)
+
+#endif
diff --git a/sys/arm/annapurna/alpine/hal/al_hal_pcie_w_reg.h b/sys/arm/annapurna/alpine/hal/al_hal_pcie_w_reg.h
new file mode 100644
index 0000000..44e9d95
--- /dev/null
+++ b/sys/arm/annapurna/alpine/hal/al_hal_pcie_w_reg.h
@@ -0,0 +1,1505 @@
+/*-
+********************************************************************************
+Copyright (C) 2015 Annapurna Labs Ltd.
+
+This file may be licensed under the terms of the Annapurna Labs Commercial
+License Agreement.
+
+Alternatively, this file can be distributed under the terms of the GNU General
+Public License V2 as published by the Free Software Foundation and can be
+found at http://www.gnu.org/licenses/gpl-2.0.html
+
+Alternatively, redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+notice, this 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 HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(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 __AL_HAL_PCIE_W_REG_H__
+#define __AL_HAL_PCIE_W_REG_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+* Unit Registers
+*/
+
+
+
+struct al_pcie_rev1_w_global_ctrl {
+ /* [0x0] */
+ uint32_t port_init;
+ /* [0x4] */
+ uint32_t port_status;
+ /* [0x8] */
+ uint32_t pm_control;
+ uint32_t rsrvd_0;
+ /* [0x10] */
+ uint32_t events_gen;
+ uint32_t rsrvd[3];
+};
+struct al_pcie_rev2_w_global_ctrl {
+ /* [0x0] */
+ uint32_t port_init;
+ /* [0x4] */
+ uint32_t port_status;
+ /* [0x8] */
+ uint32_t pm_control;
+ uint32_t rsrvd_0;
+ /* [0x10] */
+ uint32_t events_gen;
+ /* [0x14] */
+ uint32_t pended_corr_err_sts_int;
+ /* [0x18] */
+ uint32_t pended_uncorr_err_sts_int;
+ /* [0x1c] */
+ uint32_t sris_kp_counter_value;
+};
+struct al_pcie_rev3_w_global_ctrl {
+ /* [0x0] */
+ uint32_t port_init;
+ /* [0x4] */
+ uint32_t port_status;
+ /* [0x8] */
+ uint32_t pm_control;
+ /* [0xc] */
+ uint32_t pended_corr_err_sts_int;
+ /* [0x10] */
+ uint32_t pended_uncorr_err_sts_int;
+ /* [0x14] */
+ uint32_t sris_kp_counter_value;
+ uint32_t rsrvd[2];
+};
+
+struct al_pcie_rev3_w_events_gen_per_func {
+ /* [0x0] */
+ uint32_t events_gen;
+};
+struct al_pcie_rev3_w_pm_state_per_func {
+ /* [0x0] */
+ uint32_t pm_state_per_func;
+};
+struct al_pcie_rev3_w_cfg_bars_ovrd {
+ /* [0x0] */
+ uint32_t bar0_mask_lsb;
+ /* [0x4] */
+ uint32_t bar0_mask_msb;
+ /* [0x8] */
+ uint32_t bar0_limit_lsb;
+ /* [0xc] */
+ uint32_t bar0_limit_msb;
+ /* [0x10] */
+ uint32_t bar0_start_lsb;
+ /* [0x14] */
+ uint32_t bar0_start_msb;
+ /* [0x18] */
+ uint32_t bar0_ctrl;
+ /* [0x1c] */
+ uint32_t bar1_mask_lsb;
+ /* [0x20] */
+ uint32_t bar1_mask_msb;
+ /* [0x24] */
+ uint32_t bar1_limit_lsb;
+ /* [0x28] */
+ uint32_t bar1_limit_msb;
+ /* [0x2c] */
+ uint32_t bar1_start_lsb;
+ /* [0x30] */
+ uint32_t bar1_start_msb;
+ /* [0x34] */
+ uint32_t bar1_ctrl;
+ /* [0x38] */
+ uint32_t bar2_mask_lsb;
+ /* [0x3c] */
+ uint32_t bar2_mask_msb;
+ /* [0x40] */
+ uint32_t bar2_limit_lsb;
+ /* [0x44] */
+ uint32_t bar2_limit_msb;
+ /* [0x48] */
+ uint32_t bar2_start_lsb;
+ /* [0x4c] */
+ uint32_t bar2_start_msb;
+ /* [0x50] */
+ uint32_t bar2_ctrl;
+ /* [0x54] */
+ uint32_t bar3_mask_lsb;
+ /* [0x58] */
+ uint32_t bar3_mask_msb;
+ /* [0x5c] */
+ uint32_t bar3_limit_lsb;
+ /* [0x60] */
+ uint32_t bar3_limit_msb;
+ /* [0x64] */
+ uint32_t bar3_start_lsb;
+ /* [0x68] */
+ uint32_t bar3_start_msb;
+ /* [0x6c] */
+ uint32_t bar3_ctrl;
+ /* [0x70] */
+ uint32_t bar4_mask_lsb;
+ /* [0x74] */
+ uint32_t bar4_mask_msb;
+ /* [0x78] */
+ uint32_t bar4_limit_lsb;
+ /* [0x7c] */
+ uint32_t bar4_limit_msb;
+ /* [0x80] */
+ uint32_t bar4_start_lsb;
+ /* [0x84] */
+ uint32_t bar4_start_msb;
+ /* [0x88] */
+ uint32_t bar4_ctrl;
+ /* [0x8c] */
+ uint32_t bar5_mask_lsb;
+ /* [0x90] */
+ uint32_t bar5_mask_msb;
+ /* [0x94] */
+ uint32_t bar5_limit_lsb;
+ /* [0x98] */
+ uint32_t bar5_limit_msb;
+ /* [0x9c] */
+ uint32_t bar5_start_lsb;
+ /* [0xa0] */
+ uint32_t bar5_start_msb;
+ /* [0xa4] */
+ uint32_t bar5_ctrl;
+ uint32_t rsrvd[2];
+};
+
+struct al_pcie_revx_w_debug {
+ /* [0x0] */
+ uint32_t info_0;
+ /* [0x4] */
+ uint32_t info_1;
+ /* [0x8] */
+ uint32_t info_2;
+ /* [0xc] */
+ uint32_t info_3;
+};
+struct al_pcie_revx_w_ob_ven_msg {
+ /* [0x0] */
+ uint32_t control;
+ /* [0x4] */
+ uint32_t param_1;
+ /* [0x8] */
+ uint32_t param_2;
+ /* [0xc] */
+ uint32_t data_high;
+ uint32_t rsrvd_0;
+ /* [0x14] */
+ uint32_t data_low;
+};
+struct al_pcie_revx_w_ap_user_send_msg {
+ /* [0x0] */
+ uint32_t req_info;
+ /* [0x4] */
+ uint32_t ack_info;
+};
+struct al_pcie_revx_w_link_down {
+ /* [0x0] */
+ uint32_t reset_delay;
+ /* [0x4] */
+ uint32_t reset_extend_rsrvd;
+};
+struct al_pcie_revx_w_cntl_gen {
+ /* [0x0] */
+ uint32_t features;
+};
+struct al_pcie_revx_w_parity {
+ /* [0x0] */
+ uint32_t en_core;
+ /* [0x4] */
+ uint32_t status_core;
+};
+struct al_pcie_revx_w_last_wr {
+ /* [0x0] */
+ uint32_t cfg_addr;
+};
+struct al_pcie_rev1_2_w_atu {
+ /* [0x0] */
+ uint32_t in_mask_pair[6];
+ /* [0x18] */
+ uint32_t out_mask_pair[6];
+};
+struct al_pcie_rev3_w_atu {
+ /* [0x0] */
+ uint32_t in_mask_pair[12];
+ /* [0x30] */
+ uint32_t out_mask_pair[8];
+ /* [0x50] */
+ uint32_t reg_out_mask;
+ uint32_t rsrvd[11];
+};
+struct al_pcie_rev3_w_cfg_func_ext {
+ /* [0x0] */
+ uint32_t cfg;
+};
+struct al_pcie_rev3_w_app_hdr_interface_send {
+ /* [0x0] */
+ uint32_t app_hdr_31_0;
+ /* [0x4] */
+ uint32_t app_hdr_63_32;
+ /* [0x8] */
+ uint32_t app_hdr_95_64;
+ /* [0xc] */
+ uint32_t app_hdr_127_96;
+ /* [0x10] */
+ uint32_t app_err_bus;
+ /* [0x14] */
+ uint32_t app_func_num_advisory;
+ /* [0x18] */
+ uint32_t app_hdr_cmd;
+};
+struct al_pcie_rev3_w_diag_command {
+ /* [0x0] */
+ uint32_t diag_ctrl;
+};
+struct al_pcie_rev1_w_soc_int {
+ /* [0x0] */
+ uint32_t status_0;
+ /* [0x4] */
+ uint32_t status_1;
+ /* [0x8] */
+ uint32_t status_2;
+ /* [0xc] */
+ uint32_t mask_inta_leg_0;
+ /* [0x10] */
+ uint32_t mask_inta_leg_1;
+ /* [0x14] */
+ uint32_t mask_inta_leg_2;
+ /* [0x18] */
+ uint32_t mask_msi_leg_0;
+ /* [0x1c] */
+ uint32_t mask_msi_leg_1;
+ /* [0x20] */
+ uint32_t mask_msi_leg_2;
+ /* [0x24] */
+ uint32_t msi_leg_cntl;
+};
+struct al_pcie_rev2_w_soc_int {
+ /* [0x0] */
+ uint32_t status_0;
+ /* [0x4] */
+ uint32_t status_1;
+ /* [0x8] */
+ uint32_t status_2;
+ /* [0xc] */
+ uint32_t status_3;
+ /* [0x10] */
+ uint32_t mask_inta_leg_0;
+ /* [0x14] */
+ uint32_t mask_inta_leg_1;
+ /* [0x18] */
+ uint32_t mask_inta_leg_2;
+ /* [0x1c] */
+ uint32_t mask_inta_leg_3;
+ /* [0x20] */
+ uint32_t mask_msi_leg_0;
+ /* [0x24] */
+ uint32_t mask_msi_leg_1;
+ /* [0x28] */
+ uint32_t mask_msi_leg_2;
+ /* [0x2c] */
+ uint32_t mask_msi_leg_3;
+ /* [0x30] */
+ uint32_t msi_leg_cntl;
+};
+struct al_pcie_rev3_w_soc_int_per_func {
+ /* [0x0] */
+ uint32_t status_0;
+ /* [0x4] */
+ uint32_t status_1;
+ /* [0x8] */
+ uint32_t status_2;
+ /* [0xc] */
+ uint32_t status_3;
+ /* [0x10] */
+ uint32_t mask_inta_leg_0;
+ /* [0x14] */
+ uint32_t mask_inta_leg_1;
+ /* [0x18] */
+ uint32_t mask_inta_leg_2;
+ /* [0x1c] */
+ uint32_t mask_inta_leg_3;
+ /* [0x20] */
+ uint32_t mask_msi_leg_0;
+ /* [0x24] */
+ uint32_t mask_msi_leg_1;
+ /* [0x28] */
+ uint32_t mask_msi_leg_2;
+ /* [0x2c] */
+ uint32_t mask_msi_leg_3;
+ /* [0x30] */
+ uint32_t msi_leg_cntl;
+};
+
+struct al_pcie_revx_w_ap_err {
+ /*
+ * [0x0] latch the header in case of any error occur in the core, read
+ * on clear of the last register in the bind.
+ */
+ uint32_t hdr_log;
+};
+struct al_pcie_revx_w_status_per_func {
+ /*
+ * [0x0] latch the header in case of any error occure in the core, read
+ * on clear of the last register in the bind.
+ */
+ uint32_t status_per_func;
+};
+struct al_pcie_revx_w_int_grp {
+ /*
+ * [0x0] Interrupt Cause Register
+ * Set by hardware
+ * - If MSI-X is enabled and auto_clear control bit =TRUE, automatically
+ * cleared after MSI-X message associated with this specific interrupt
+ * bit is sent (MSI-X acknowledge is received).
+ * - Software can set a bit in this register by writing 1 to the
+ * associated bit in the Interrupt Cause Set register
+ * Write-0 clears a bit. Write-1 has no effect.
+ * - On CPU Read - If clear_on_read control bit =TRUE, automatically
+ * cleared (all bits are cleared).
+ * When there is a conflict and on the same clock cycle, hardware tries
+ * to set a bit in the Interrupt Cause register, the specific bit is set
+ * to ensure the interrupt indication is not lost.
+ */
+ uint32_t cause;
+ uint32_t rsrvd_0;
+ /*
+ * [0x8] Interrupt Cause Set Register
+ * Writing 1 to a bit in this register sets its corresponding cause bit,
+ * enabling software to generate a hardware interrupt. Write 0 has no
+ * effect.
+ */
+ uint32_t cause_set;
+ uint32_t rsrvd_1;
+ /*
+ * [0x10] Interrupt Mask Register
+ * If Auto-mask control bit =TRUE, automatically set to 1 after MSI-X
+ * message associatd with the associated interrupt bit is sent (AXI
+ * write acknowledge is received).
+ */
+ uint32_t mask;
+ uint32_t rsrvd_2;
+ /*
+ * [0x18] Interrupt Mask Clear Register
+ * Used when auto-mask control bit=True. Enables CPU to clear a specific
+ * bit. It prevents a scenario in which the CPU overrides another bit
+ * with 1 (old value) that hardware has just cleared to 0.
+ * Write 0 to this register clears its corresponding mask bit. Write 1
+ * has no effect.
+ */
+ uint32_t mask_clear;
+ uint32_t rsrvd_3;
+ /*
+ * [0x20] Interrupt Status Register
+ * This register latches the status of the interrupt source.
+ */
+ uint32_t status;
+ uint32_t rsrvd_4;
+ /* [0x28] Interrupt Control Register */
+ uint32_t control;
+ uint32_t rsrvd_5;
+ /*
+ * [0x30] Interrupt Mask Register
+ * Each bit in this register masks the corresponding cause bit for
+ * generating an Abort signal. Its default value is determined by unit
+ * instantiation.
+ * (Abort = Wire-OR of Cause & !Interrupt_Abort_Mask)
+ * This register provides error handling configuration for error
+ * interrupts
+ */
+ uint32_t abort_mask;
+ uint32_t rsrvd_6;
+ /*
+ * [0x38] Interrupt Log Register
+ * Each bit in this register masks the corresponding cause bit for
+ * capturing the log registers. Its default value is determined by unit
+ * instantiation.
+ * (Log_capture = Wire-OR of Cause & !Interrupt_Log_Mask)
+ * This register provides error handling configuration for error
+ * interrupts.
+ */
+ uint32_t log_mask;
+ uint32_t rsrvd;
+};
+
+struct al_pcie_rev1_w_regs {
+ struct al_pcie_rev1_w_global_ctrl global_ctrl; /* [0x0] */
+ uint32_t rsrvd_0[24];
+ struct al_pcie_revx_w_debug debug; /* [0x80] */
+ struct al_pcie_revx_w_ob_ven_msg ob_ven_msg; /* [0x90] */
+ uint32_t rsrvd_1[86];
+ struct al_pcie_rev1_w_soc_int soc_int; /* [0x200] */
+ struct al_pcie_revx_w_link_down link_down; /* [0x228] */
+ struct al_pcie_revx_w_cntl_gen ctrl_gen; /* [0x230] */
+ struct al_pcie_revx_w_parity parity; /* [0x234] */
+ struct al_pcie_revx_w_last_wr last_wr; /* [0x23c] */
+ struct al_pcie_rev1_2_w_atu atu; /* [0x240] */
+ uint32_t rsrvd_2[36];
+ struct al_pcie_revx_w_int_grp int_grp_a_m0; /* [0x300] */
+ struct al_pcie_revx_w_int_grp int_grp_b_m0; /* [0x340] */
+ uint32_t rsrvd_3[32];
+ struct al_pcie_revx_w_int_grp int_grp_a; /* [0x400] */
+ struct al_pcie_revx_w_int_grp int_grp_b; /* [0x440] */
+};
+
+struct al_pcie_rev2_w_regs {
+ struct al_pcie_rev2_w_global_ctrl global_ctrl; /* [0x0] */
+ uint32_t rsrvd_0[24];
+ struct al_pcie_revx_w_debug debug; /* [0x80] */
+ struct al_pcie_revx_w_ob_ven_msg ob_ven_msg; /* [0x90] */
+ struct al_pcie_revx_w_ap_user_send_msg ap_user_send_msg; /* [0xa8] */
+ uint32_t rsrvd_1[20];
+ struct al_pcie_rev2_w_soc_int soc_int; /* [0x100] */
+ uint32_t rsrvd_2[61];
+ struct al_pcie_revx_w_link_down link_down; /* [0x228] */
+ struct al_pcie_revx_w_cntl_gen ctrl_gen; /* [0x230] */
+ struct al_pcie_revx_w_parity parity; /* [0x234] */
+ struct al_pcie_revx_w_last_wr last_wr; /* [0x23c] */
+ struct al_pcie_rev1_2_w_atu atu; /* [0x240] */
+ uint32_t rsrvd_3[6];
+ struct al_pcie_revx_w_ap_err ap_err[4]; /* [0x288] */
+ uint32_t rsrvd_4[26];
+ struct al_pcie_revx_w_status_per_func status_per_func; /* [0x300] */
+ uint32_t rsrvd_5[63];
+ struct al_pcie_revx_w_int_grp int_grp_a; /* [0x400] */
+ struct al_pcie_revx_w_int_grp int_grp_b; /* [0x440] */
+};
+
+struct al_pcie_rev3_w_regs {
+ struct al_pcie_rev3_w_global_ctrl global_ctrl; /* [0x0] */
+ uint32_t rsrvd_0[24];
+ struct al_pcie_revx_w_debug debug; /* [0x80] */
+ struct al_pcie_revx_w_ob_ven_msg ob_ven_msg; /* [0x90] */
+ struct al_pcie_revx_w_ap_user_send_msg ap_user_send_msg; /* [0xa8] */
+ uint32_t rsrvd_1[94];
+ struct al_pcie_revx_w_link_down link_down; /* [0x228] */
+ struct al_pcie_revx_w_cntl_gen ctrl_gen; /* [0x230] */
+ struct al_pcie_revx_w_parity parity; /* [0x234] */
+ struct al_pcie_revx_w_last_wr last_wr; /* [0x23c] */
+ struct al_pcie_rev3_w_atu atu; /* [0x240] */
+ uint32_t rsrvd_2[8];
+ struct al_pcie_rev3_w_cfg_func_ext cfg_func_ext; /* [0x2e0] */
+ struct al_pcie_rev3_w_app_hdr_interface_send app_hdr_interface_send;/* [0x2e4] */
+ struct al_pcie_rev3_w_diag_command diag_command; /* [0x300] */
+ uint32_t rsrvd_3[3];
+ struct al_pcie_rev3_w_soc_int_per_func soc_int_per_func[REV3_MAX_NUM_OF_PFS]; /* [0x310] */
+ uint32_t rsrvd_4[44];
+ struct al_pcie_rev3_w_events_gen_per_func events_gen_per_func[REV3_MAX_NUM_OF_PFS]; /* [0x490] */
+ uint32_t rsrvd_5[4];
+ struct al_pcie_rev3_w_pm_state_per_func pm_state_per_func[REV3_MAX_NUM_OF_PFS];/* [0x4b0] */
+ uint32_t rsrvd_6[16];
+ struct al_pcie_rev3_w_cfg_bars_ovrd cfg_bars_ovrd[REV3_MAX_NUM_OF_PFS]; /* [0x500] */
+ uint32_t rsrvd_7[176];
+ uint32_t rsrvd_8[16];
+ struct al_pcie_revx_w_ap_err ap_err[5]; /* [0xac0] */
+ uint32_t rsrvd_9[11];
+ struct al_pcie_revx_w_status_per_func status_per_func[4]; /* [0xb00] */
+ uint32_t rsrvd_10[316];
+ struct al_pcie_revx_w_int_grp int_grp_a; /* [0x1000] */
+ struct al_pcie_revx_w_int_grp int_grp_b; /* [0x1040] */
+ struct al_pcie_revx_w_int_grp int_grp_c; /* [0x1080] */
+ struct al_pcie_revx_w_int_grp int_grp_d; /* [0x10c0] */
+};
+
+/*
+* Registers Fields
+*/
+
+
+/**** Port_Init register ****/
+/* Enable port to start LTSSM Link Training */
+#define PCIE_W_GLOBAL_CTRL_PORT_INIT_APP_LTSSM_EN_MASK (1 << 0)
+#define PCIE_W_GLOBAL_CTRL_PORT_INIT_APP_LTSSM_EN_SHIFT (0)
+/*
+ * Device Type
+ * Indicates the specific type of this PCIe Function. It is also used to set the
+ * Device/Port Type field.
+ * 4'b0000: PCIe Endpoint
+ * 4'b0001: Legacy PCIe Endpoint
+ * 4'b0100: Root Port of PCIe Root Complex
+ * Must be programmed before link training sequence. According to the reset
+ * strap
+ */
+#define PCIE_W_GLOBAL_CTRL_PORT_INIT_DEVICE_TYPE_MASK 0x000000F0
+#define PCIE_W_GLOBAL_CTRL_PORT_INIT_DEVICE_TYPE_SHIFT 4
+/*
+ * Performs Manual Lane reversal for transmit Lanes.
+ * Must be programmed before link training sequence.
+ */
+#define PCIE_W_GLOBAL_CTRL_PORT_INIT_TX_LANE_FLIP_EN (1 << 8)
+/*
+ * Performs Manual Lane reversal for receive Lanes.
+ * Must be programmed before link training sequence.
+ */
+#define PCIE_W_GLOBAL_CTRL_PORT_INIT_RX_LANE_FLIP_EN (1 << 9)
+/*
+ * Auxiliary Power Detected
+ * Indicates that auxiliary power (Vaux) is present. This one move to reset
+ * strap from
+ */
+#define PCIE_W_GLOBAL_CTRL_PORT_INIT_SYS_AUX_PWR_DET_NOT_USE (1 << 10)
+
+/**** Port_Status register ****/
+/* PHY Link up/down indicator */
+#define PCIE_W_GLOBAL_CTRL_PORT_STS_PHY_LINK_UP (1 << 0)
+/*
+ * Data Link Layer up/down indicator
+ * This status from the Flow Control Initialization State Machine indicates that
+ * Flow Control has been initiated and the Data Link Layer is ready to transmit
+ * and receive packets.
+ */
+#define PCIE_W_GLOBAL_CTRL_PORT_STS_DL_LINK_UP (1 << 1)
+/* Reset request due to link down status. */
+#define PCIE_W_GLOBAL_CTRL_PORT_STS_LINK_REQ_RST (1 << 2)
+/* Power management is in L0s state.. */
+#define PCIE_W_GLOBAL_CTRL_PORT_STS_PM_LINKST_IN_L0S (1 << 3)
+/* Power management is in L1 state. */
+#define PCIE_W_GLOBAL_CTRL_PORT_STS_PM_LINKST_IN_L1 (1 << 4)
+/* Power management is in L2 state. */
+#define PCIE_W_GLOBAL_CTRL_PORT_STS_PM_LINKST_IN_L2 (1 << 5)
+/* Power management is exiting L2 state. */
+#define PCIE_W_GLOBAL_CTRL_PORT_STS_PM_LINKST_L2_EXIT (1 << 6)
+/* Power state of the device. */
+#define PCIE_W_GLOBAL_CTRL_PORT_STS_PM_DSTATE_MASK 0x00000380
+#define PCIE_W_GLOBAL_CTRL_PORT_STS_PM_DSTATE_SHIFT 7
+/* tie to zero. */
+#define PCIE_W_GLOBAL_CTRL_PORT_STS_XMLH_IN_RL0S (1 << 10)
+/* Timeout count before flush */
+#define PCIE_W_GLOBAL_CTRL_PORT_STS_LINK_TOUT_FLUSH_NOT (1 << 11)
+/* Segmentation buffer not empty */
+#define PCIE_W_GLOBAL_CTRL_PORT_STS_RADM_Q_NOT_EMPTY (1 << 12)
+/*
+ * Clock Turnoff Request
+ * Allows clock generation module to turn off core_clk based on the current
+ * power management state:
+ * 0: core_clk is required to be active for the current power state.
+ * 1: The current power state allows core_clk to be shut down.
+ * This does not indicate the clock requirement for the PHY.
+ */
+#define PCIE_W_GLOBAL_CTRL_PORT_STS_CORE_CLK_REQ_N (1 << 31)
+
+/**** PM_Control register ****/
+/*
+ * Wake Up. Used by application logic to wake up the PMC state machine from a
+ * D1, D2, or D3 power state. EP mode only. Change the value from 0 to 1 to send
+ * the message. Per function the upper bits are not use for ocie core less than
+ * 8 functions
+ */
+#define PCIE_W_REV1_2_GLOBAL_CTRL_PM_CONTROL_PM_XMT_PME (1 << 0)
+#define PCIE_W_REV3_GLOBAL_CTRL_PM_CONTROL_PM_XMT_PME_FUNC_MASK 0x000000FF
+#define PCIE_W_REV3_GLOBAL_CTRL_PM_CONTROL_PM_XMT_PME_FUNC_SHIFT 0
+/*
+ * Request to Enter ASPM L1.
+ * The core ignores the L1 entry request on app_req_entr_l1 when it is busy
+ * processing a transaction.
+ */
+#define PCIE_W_REV1_2_GLOBAL_CTRL_PM_CONTROL_REQ_ENTR_L1 (1 << 3)
+#define PCIE_W_REV3_GLOBAL_CTRL_PM_CONTROL_REQ_ENTR_L1 (1 << 8)
+/*
+ * Request to exit ASPM L1.
+ * Only effective if L1 is enabled.
+ */
+#define PCIE_W_REV1_2_GLOBAL_CTRL_PM_CONTROL_REQ_EXIT_L1 (1 << 4)
+#define PCIE_W_REV3_GLOBAL_CTRL_PM_CONTROL_REQ_EXIT_L1 (1 << 9)
+/*
+ * Indication that component is ready to enter the L23 state. The core delays
+ * sending PM_Enter_L23 (in response to PM_Turn_Off) until this signal becomes
+ * active.
+ * EP mode
+ */
+#define PCIE_W_REV1_2_GLOBAL_CTRL_PM_CONTROL_READY_ENTR_L23 (1 << 5)
+#define PCIE_W_REV3_GLOBAL_CTRL_PM_CONTROL_READY_ENTR_L23 (1 << 10)
+/*
+ * Request to generate a PM_Turn_Off Message to communicate transition to L2/L3
+ * Ready state to downstream components. Host must wait PM_Turn_Off_Ack messages
+ * acceptance RC mode.
+ */
+#define PCIE_W_REV1_2_GLOBAL_CTRL_PM_CONTROL_PM_XMT_TURNOFF (1 << 6)
+#define PCIE_W_REV3_GLOBAL_CTRL_PM_CONTROL_PM_XMT_TURNOFF (1 << 11)
+/*
+ * Provides a capability to defer incoming Configuration Requests until
+ * initialization is complete. When app_req_retry_en is asserted, the core
+ * completes incoming Configuration Requests with a Configuration Request Retry
+ * Status. Other incoming Requests complete with Unsupported Request status.
+ */
+#define PCIE_W_REV1_2_GLOBAL_CTRL_PM_CONTROL_APP_REQ_RETRY_EN (1 << 7)
+#define PCIE_W_REV3_GLOBAL_CTRL_PM_CONTROL_APP_REQ_RETRY_EN (1 << 12)
+/*
+ * Core core gate enable
+ * If set, core_clk is gated off whenever a clock turnoff request allows the
+ * clock generation module to turn off core_clk (Port_Status.core_clk_req_n
+ * field), and the PHY supports a request to disable clock gating. If not, the
+ * core clock turns off in P2 mode in any case (PIPE).
+ */
+#define PCIE_W_GLOBAL_CTRL_PM_CONTROL_CORE_CLK_GATE (1 << 31)
+
+/**** sris_kp_counter_value register ****/
+/* skp counter when SRIS disable */
+#define PCIE_W_GLOBAL_CTRL_SRIS_KP_COUNTER_VALUE_GEN3_NO_SRIS_MASK 0x000001FF
+#define PCIE_W_GLOBAL_CTRL_SRIS_KP_COUNTER_VALUE_GEN3_NO_SRIS_SHIFT 0
+/* skp counter when SRIS enable */
+#define PCIE_W_GLOBAL_CTRL_SRIS_KP_COUNTER_VALUE_GEN3_SRIS_MASK 0x0003FE00
+#define PCIE_W_GLOBAL_CTRL_SRIS_KP_COUNTER_VALUE_GEN3_SRIS_SHIFT 9
+/* skp counter when SRIS enable for gen3 */
+#define PCIE_W_GLOBAL_CTRL_SRIS_KP_COUNTER_VALUE_GEN21_SRIS_MASK 0x1FFC0000
+#define PCIE_W_GLOBAL_CTRL_SRIS_KP_COUNTER_VALUE_GEN21_SRIS_SHIFT 18
+/* mask the interrupt to the soc in case correctable error occur in the ARI. */
+#define PCIE_W_GLOBAL_CTRL_SRIS_KP_COUNTER_VALUE_RSRVD_MASK 0x60000000
+#define PCIE_W_GLOBAL_CTRL_SRIS_KP_COUNTER_VALUE_RSRVD_SHIFT 29
+/* not in use in the pcie_x8 core. */
+#define PCIE_W_GLOBAL_CTRL_SRIS_KP_COUNTER_VALUE_PCIE_X4_SRIS_EN (1 << 31)
+
+/**** Events_Gen register ****/
+/* INT_D. Not supported */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_ASSERT_INTD (1 << 0)
+/* INT_C. Not supported */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_ASSERT_INTC (1 << 1)
+/* INT_B. Not supported */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_ASSERT_INTB (1 << 2)
+/* Transmit INT_A Interrupt ControlEvery transition from 0 to 1 ... */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_ASSERT_INTA (1 << 3)
+/* A request to generate an outbound MSI interrupt when MSI is e ... */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_MSI_TRNS_REQ (1 << 4)
+/* Set the MSI vector before issuing msi_trans_req. */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_MSI_VECTOR_MASK 0x000003E0
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_MSI_VECTOR_SHIFT 5
+/* The application requests hot reset to a downstream device */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_APP_RST_INIT (1 << 10)
+/* The application request unlock message to be sent */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_UNLOCK_GEN (1 << 30)
+/* Indicates that FLR on a Physical Function has been completed */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_FLR_PF_DONE (1 << 31)
+
+/**** Cpl_TO_Info register ****/
+/* The Traffic Class of the timed out CPL */
+#define PCIE_W_LCL_LOG_CPL_TO_INFO_TC_MASK 0x00000003
+#define PCIE_W_LCL_LOG_CPL_TO_INFO_TC_SHIFT 0
+/* Indicates which Virtual Function (VF) had a CPL timeout */
+#define PCIE_W_LCL_LOG_CPL_TO_INFO_FUN_NUM_MASK 0x000000FC
+#define PCIE_W_LCL_LOG_CPL_TO_INFO_FUN_NUM_SHIFT 2
+/* The Tag field of the timed out CPL */
+#define PCIE_W_LCL_LOG_CPL_TO_INFO_TAG_MASK 0x0000FF00
+#define PCIE_W_LCL_LOG_CPL_TO_INFO_TAG_SHIFT 8
+/* The Attributes field of the timed out CPL */
+#define PCIE_W_LCL_LOG_CPL_TO_INFO_ATTR_MASK 0x00030000
+#define PCIE_W_LCL_LOG_CPL_TO_INFO_ATTR_SHIFT 16
+/* The Len field of the timed out CPL */
+#define PCIE_W_LCL_LOG_CPL_TO_INFO_LEN_MASK 0x3FFC0000
+#define PCIE_W_LCL_LOG_CPL_TO_INFO_LEN_SHIFT 18
+/*
+ * Write 1 to this field to clear the information logged in the register. New
+ * logged information will only be valid when the interrupt is cleared .
+ */
+#define PCIE_W_LCL_LOG_CPL_TO_INFO_VALID (1 << 31)
+#define PCIE_W_LCL_LOG_CPL_TO_INFO_VALID_SHIFT (31)
+
+/**** Rcv_Msg0_0 register ****/
+/* The Requester ID of the received message */
+#define PCIE_W_LCL_LOG_RCV_MSG0_0_REQ_ID_MASK 0x0000FFFF
+#define PCIE_W_LCL_LOG_RCV_MSG0_0_REQ_ID_SHIFT 0
+/*
+ * Valid logged message
+ * Writing 1 to this bit enables new message capturing. Write one to clear
+ */
+#define PCIE_W_LCL_LOG_RCV_MSG0_0_VALID (1 << 31)
+
+/**** Rcv_Msg1_0 register ****/
+/* The Requester ID of the received message */
+#define PCIE_W_LCL_LOG_RCV_MSG1_0_REQ_ID_MASK 0x0000FFFF
+#define PCIE_W_LCL_LOG_RCV_MSG1_0_REQ_ID_SHIFT 0
+/*
+ * Valid logged message
+ * Writing 1 to this bit enables new message capturing. Write one to clear
+ */
+#define PCIE_W_LCL_LOG_RCV_MSG1_0_VALID (1 << 31)
+
+/**** Core_Queues_Status register ****/
+/*
+ * Indicates which entries in the CPL lookup table
+ * have valid entries stored. NOT supported.
+ */
+#define PCIE_W_LCL_LOG_CORE_Q_STATUS_CPL_LUT_VALID_MASK 0x0000FFFF
+#define PCIE_W_LCL_LOG_CORE_Q_STATUS_CPL_LUT_VALID_SHIFT 0
+
+/**** Cpl_to register ****/
+#define PCIE_W_LCL_LOG_CPL_TO_REQID_MASK 0x0000FFFF
+#define PCIE_W_LCL_LOG_CPL_TO_REQID_SHIFT 0
+
+/**** Debug_Info_0 register ****/
+/* Indicates the current power state */
+#define PCIE_W_DEBUG_INFO_0_PM_CURRENT_STATE_MASK 0x00000007
+#define PCIE_W_DEBUG_INFO_0_PM_CURRENT_STATE_SHIFT 0
+/* Current state of the LTSSM */
+#define PCIE_W_DEBUG_INFO_0_LTSSM_STATE_MASK 0x000001F8
+#define PCIE_W_DEBUG_INFO_0_LTSSM_STATE_SHIFT 3
+/* Decode of the Recovery. Equalization LTSSM state */
+#define PCIE_W_DEBUG_INFO_0_LTSSM_STATE_RCVRY_EQ (1 << 9)
+/* State of selected internal signals, for debug purposes only */
+#define PCIE_W_DEBUG_INFO_0_CXPL_DEBUG_INFO_EI_MASK 0x03FFFC00
+#define PCIE_W_DEBUG_INFO_0_CXPL_DEBUG_INFO_EI_SHIFT 10
+
+/**** control register ****/
+/* Indication to send vendor message; when clear the message was sent. */
+#define PCIE_W_OB_VEN_MSG_CONTROL_REQ (1 << 0)
+
+/**** param_1 register ****/
+/* Vendor message parameters */
+#define PCIE_W_OB_VEN_MSG_PARAM_1_FMT_MASK 0x00000003
+#define PCIE_W_OB_VEN_MSG_PARAM_1_FMT_SHIFT 0
+/* Vendor message parameters */
+#define PCIE_W_OB_VEN_MSG_PARAM_1_TYPE_MASK 0x0000007C
+#define PCIE_W_OB_VEN_MSG_PARAM_1_TYPE_SHIFT 2
+/* Vendor message parameters */
+#define PCIE_W_OB_VEN_MSG_PARAM_1_TC_MASK 0x00000380
+#define PCIE_W_OB_VEN_MSG_PARAM_1_TC_SHIFT 7
+/* Vendor message parameters */
+#define PCIE_W_OB_VEN_MSG_PARAM_1_TD (1 << 10)
+/* Vendor message parameters */
+#define PCIE_W_OB_VEN_MSG_PARAM_1_EP (1 << 11)
+/* Vendor message parameters */
+#define PCIE_W_OB_VEN_MSG_PARAM_1_ATTR_MASK 0x00003000
+#define PCIE_W_OB_VEN_MSG_PARAM_1_ATTR_SHIFT 12
+/* Vendor message parameters */
+#define PCIE_W_OB_VEN_MSG_PARAM_1_LEN_MASK 0x00FFC000
+#define PCIE_W_OB_VEN_MSG_PARAM_1_LEN_SHIFT 14
+/* Vendor message parameters */
+#define PCIE_W_OB_VEN_MSG_PARAM_1_TAG_MASK 0xFF000000
+#define PCIE_W_OB_VEN_MSG_PARAM_1_TAG_SHIFT 24
+
+/**** param_2 register ****/
+/* Vendor message parameters */
+#define PCIE_W_OB_VEN_MSG_PARAM_2_REQ_ID_MASK 0x0000FFFF
+#define PCIE_W_OB_VEN_MSG_PARAM_2_REQ_ID_SHIFT 0
+/* Vendor message parameters */
+#define PCIE_W_OB_VEN_MSG_PARAM_2_CODE_MASK 0x00FF0000
+#define PCIE_W_OB_VEN_MSG_PARAM_2_CODE_SHIFT 16
+/* Vendor message parameters */
+#define PCIE_W_OB_VEN_MSG_PARAM_2_RSVD_31_24_MASK 0xFF000000
+#define PCIE_W_OB_VEN_MSG_PARAM_2_RSVD_31_24_SHIFT 24
+
+/**** ack_info register ****/
+/* Vendor message parameters */
+#define PCIE_W_AP_USER_SEND_MSG_ACK_INFO_ACK (1 << 0)
+
+/**** features register ****/
+/* Enable MSI fix from the SATA to the PCIe EP - Only valid for port zero */
+#define PCIE_W_CTRL_GEN_FEATURES_SATA_EP_MSI_FIX AL_BIT(16)
+
+/**** in/out_mask_x_y register ****/
+/* When bit [i] set to 1 it maks the compare in the atu_in/out wind ... */
+#define PCIE_W_ATU_MASK_EVEN_ODD_ATU_MASK_40_32_EVEN_MASK 0x0000FFFF
+#define PCIE_W_ATU_MASK_EVEN_ODD_ATU_MASK_40_32_EVEN_SHIFT 0
+/* When bit [i] set to 1 it maks the compare in the atu_in/out wind ... */
+#define PCIE_W_ATU_MASK_EVEN_ODD_ATU_MASK_40_32_ODD_MASK 0xFFFF0000
+#define PCIE_W_ATU_MASK_EVEN_ODD_ATU_MASK_40_32_ODD_SHIFT 16
+
+/**** cfg register ****/
+/*
+ * The 2-bit TPH Requester Enabled field of each TPH
+ * Requester Control register.
+ */
+#define PCIE_W_CFG_FUNC_EXT_CFG_CFG_TPH_REQ_EN_MASK 0x000000FF
+#define PCIE_W_CFG_FUNC_EXT_CFG_CFG_TPH_REQ_EN_SHIFT 0
+/* SRIS mode enable. */
+#define PCIE_W_CFG_FUNC_EXT_CFG_APP_SRIS_MODE (1 << 8)
+/*
+ *
+ */
+#define PCIE_W_CFG_FUNC_EXT_CFG_RSRVD_MASK 0xFFFFFE00
+#define PCIE_W_CFG_FUNC_EXT_CFG_RSRVD_SHIFT 9
+
+/**** app_func_num_advisory register ****/
+/*
+ * The number of the function that is reporting the error
+ * indicated app_err_bus, valid when app_hdr_valid is asserted.
+ * Correctable and Uncorrected Internal errors (app_err_bus[10:9]) are
+ * not function specific, and are recorded for all physical functions,
+ * regardless of the value this bus. Function numbering starts at '0'.
+ */
+#define PCIE_W_APP_HDR_INTERFACE_SEND_APP_FUNC_NUM_ADVISORY_APP_ERR_FUNC_NUM_MASK 0x0000FFFF
+#define PCIE_W_APP_HDR_INTERFACE_SEND_APP_FUNC_NUM_ADVISORY_APP_ERR_FUNC_NUM_SHIFT 0
+/*
+ * Description: Indicates that your application error is an advisory
+ * error. Your application should assert app_err_advisory under either
+ * of the following conditions:
+ * - The core is configured to mask completion timeout errors, your
+ * application is reporting a completion timeout error app_err_bus,
+ * and your application intends to resend the request. In such cases
+ * the error is an advisory error, as described in PCI Express 3.0
+ * Specification. When your application does not intend to resend
+ * the request, then your application must keep app_err_advisory
+ * de-asserted when reporting a completion timeout error.
+ * - The core is configured to forward poisoned TLPs to your
+ * application and your application is going to treat the poisoned
+ * TLP as a normal TLP, as described in PCI Express 3.0
+ * Specification. Upon receipt of a poisoned TLP, your application
+ * must report the error app_err_bus, and either assert
+ * app_err_advisory (to indicate an advisory error) or de-assert
+ * app_err_advisory (to indicate that your application is dropping the
+ * TLP).
+ * For more details, see the PCI Express 3.0 Specification to determine
+ * when an application error is an advisory error.
+ */
+#define PCIE_W_APP_HDR_INTERFACE_SEND_APP_FUNC_NUM_ADVISORY_APP_ERR_ADVISORY (1 << 16)
+/*
+ * Rsrvd.
+ */
+#define PCIE_W_APP_HDR_INTERFACE_SEND_APP_FUNC_NUM_ADVISORY_RSRVD_MASK 0xFFFE0000
+#define PCIE_W_APP_HDR_INTERFACE_SEND_APP_FUNC_NUM_ADVISORY_RSRVD_SHIFT 17
+
+/**** app_hdr_cmd register ****/
+/*
+ * When set the header is send (need to clear before sending the next message).
+ */
+#define PCIE_W_APP_HDR_INTERFACE_SEND_APP_HDR_CMD_APP_HDR_VALID (1 << 0)
+/*
+ * Rsrvd.
+ */
+#define PCIE_W_APP_HDR_INTERFACE_SEND_APP_HDR_CMD_RSRVD_MASK 0xFFFFFFFE
+#define PCIE_W_APP_HDR_INTERFACE_SEND_APP_HDR_CMD_RSRVD_SHIFT 1
+
+/**** diag_ctrl register ****/
+/*
+ * The 2-bit TPH Requester Enabled field of each TPH
+ * Requester Control register.
+ */
+#define PCIE_W_DIAG_COMMAND_DIAG_CTRL_DIAG_CTRL_BUS_MASK 0x00000007
+#define PCIE_W_DIAG_COMMAND_DIAG_CTRL_DIAG_CTRL_BUS_SHIFT 0
+/*
+ *
+ */
+#define PCIE_W_DIAG_COMMAND_DIAG_CTRL_RSRVD_MASK 0xFFFFFFF8
+#define PCIE_W_DIAG_COMMAND_DIAG_CTRL_RSRVD_SHIFT 3
+
+
+/**** Events_Gen register ****/
+/* INT_D. Not supported */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_ASSERT_INTD (1 << 0)
+/* INT_C. Not supported */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_ASSERT_INTC (1 << 1)
+/* INT_B. Not supported */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_ASSERT_INTB (1 << 2)
+/*
+ * Transmit INT_A Interrupt Control
+ * Every transition from 0 to 1 schedules an Assert_ INT interrupt message for
+ * transmit.
+ * Every transition from 1 to 0, schedules a Deassert_INT interrupt message for
+ * transmit. Which interrupt, the PCIe only use INTA message.
+ */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_ASSERT_INTA (1 << 3)
+/*
+ * A request to generate an outbound MSI interrupt when MSI is enabled. Change
+ * from 1'b0 to 1'b1 to create an MSI write to be sent.
+ */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_MSI_TRNS_REQ (1 << 4)
+/* Set the MSI vector before issuing msi_trans_req. */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_MSI_VECTOR_MASK 0x000003E0
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_MSI_VECTOR_SHIFT 5
+/*
+ * The application requests hot reset to a downstream device. Change the value
+ * from 0 to 1 to send hot reset. Only func 0 is supported.
+ */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_APP_RST_INIT (1 << 10)
+/*
+ * The application request unlock message to be sent. Change the value from 0 to
+ * 1 to send the message. Only func 0 is supported.
+ */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_UNLOCK_GEN (1 << 30)
+/* Indicates that FLR on a Physical Function has been completed. */
+#define PCIE_W_GLOBAL_CTRL_EVENTS_GEN_FLR_PF_DONE (1 << 31)
+
+/**** pm_state_per_func register ****/
+/*
+ * Description: The current power management D-state of the
+ * function:
+ * \u25a0 000b: D0
+ * \u25a0 001b: D1
+ * \u25a0 010b: D2
+ * \u25a0 011b: D3
+ * \u25a0 100b: Uninitialized
+ * \u25a0 Other values: Not applicable
+ * There are 3 bits of pm_dstate for each configured function.
+ */
+#define PCIE_W_PM_STATE_PER_FUNC_PM_STATE_PER_FUNC_PM_DSTATE_MASK 0x0000000F
+#define PCIE_W_PM_STATE_PER_FUNC_PM_STATE_PER_FUNC_PM_DSTATE_SHIFT 0
+/*
+ * PME Status bit from the PMCSR. There is 1 bit of
+ * pm_status for each configured function
+ */
+#define PCIE_W_PM_STATE_PER_FUNC_PM_STATE_PER_FUNC_PM_STATUS (1 << 4)
+/*
+ * PME Enable bit in the PMCSR. There is 1 bit of
+ * pm_pme_en for each configured function.
+ */
+#define PCIE_W_PM_STATE_PER_FUNC_PM_STATE_PER_FUNC_PM_PME_EN (1 << 5)
+/*
+ * Auxiliary Power Enable bit in the Device Control
+ * register. There is 1 bit of aux_pm_en for each configured function.
+ */
+#define PCIE_W_PM_STATE_PER_FUNC_PM_STATE_PER_FUNC_AUX_PME_EN (1 << 6)
+/*
+ * This field should be set according to the MAX_FUNC_NUM set in the PCIe core,
+ * it uses as mask (bit per function) to the dsate when set to zero.
+ */
+#define PCIE_W_PM_STATE_PER_FUNC_PM_STATE_PER_FUNC_ASPM_PF_ENABLE_MAX_FUNC_NUMBER (1 << 7)
+/*
+ * This field should be set according to the MAX_FUNC_NUM set in the PCIe core,
+ * it uses as mask (bit per function) to the ASPM contrl bit, when set to zero.
+ */
+#define PCIE_W_PM_STATE_PER_FUNC_PM_STATE_PER_FUNC_DSATE_PF_ENABLE_MAX_FUNC_NUMBER (1 << 8)
+
+/**** bar0_ctrl register ****/
+/* bar is en and override the internal PF bar. */
+#define PCIE_W_CFG_BARS_OVRD_BAR0_CTRL_BAR_EN_MASK 0x00000003
+#define PCIE_W_CFG_BARS_OVRD_BAR0_CTRL_BAR_EN_SHIFT 0
+/* bar is io */
+#define PCIE_W_CFG_BARS_OVRD_BAR0_CTRL_BAR_IO_MASK 0x0000000C
+#define PCIE_W_CFG_BARS_OVRD_BAR0_CTRL_BAR_IO_SHIFT 2
+/* Reserved. */
+#define PCIE_W_CFG_BARS_OVRD_BAR0_CTRL_RSRVS_MASK 0xFFFFFFF0
+#define PCIE_W_CFG_BARS_OVRD_BAR0_CTRL_RSRVS_SHIFT 4
+
+/**** bar1_ctrl register ****/
+/* bar is en and override the internal PF bar. */
+#define PCIE_W_CFG_BARS_OVRD_BAR1_CTRL_BAR_EN_MASK 0x00000003
+#define PCIE_W_CFG_BARS_OVRD_BAR1_CTRL_BAR_EN_SHIFT 0
+/* bar is io */
+#define PCIE_W_CFG_BARS_OVRD_BAR1_CTRL_BAR_IO_MASK 0x0000000C
+#define PCIE_W_CFG_BARS_OVRD_BAR1_CTRL_BAR_IO_SHIFT 2
+/* Reserved. */
+#define PCIE_W_CFG_BARS_OVRD_BAR1_CTRL_RSRVS_MASK 0xFFFFFFF0
+#define PCIE_W_CFG_BARS_OVRD_BAR1_CTRL_RSRVS_SHIFT 4
+
+/**** bar2_ctrl register ****/
+/* bar is en and override the internal PF bar. */
+#define PCIE_W_CFG_BARS_OVRD_BAR2_CTRL_BAR_EN_MASK 0x00000003
+#define PCIE_W_CFG_BARS_OVRD_BAR2_CTRL_BAR_EN_SHIFT 0
+/* bar is io */
+#define PCIE_W_CFG_BARS_OVRD_BAR2_CTRL_BAR_IO_MASK 0x0000000C
+#define PCIE_W_CFG_BARS_OVRD_BAR2_CTRL_BAR_IO_SHIFT 2
+/* Reserved. */
+#define PCIE_W_CFG_BARS_OVRD_BAR2_CTRL_RSRVS_MASK 0xFFFFFFF0
+#define PCIE_W_CFG_BARS_OVRD_BAR2_CTRL_RSRVS_SHIFT 4
+
+/**** bar3_ctrl register ****/
+/* bar is en and override the internal PF bar. */
+#define PCIE_W_CFG_BARS_OVRD_BAR3_CTRL_BAR_EN_MASK 0x00000003
+#define PCIE_W_CFG_BARS_OVRD_BAR3_CTRL_BAR_EN_SHIFT 0
+/* bar is io */
+#define PCIE_W_CFG_BARS_OVRD_BAR3_CTRL_BAR_IO_MASK 0x0000000C
+#define PCIE_W_CFG_BARS_OVRD_BAR3_CTRL_BAR_IO_SHIFT 2
+/* Reserved. */
+#define PCIE_W_CFG_BARS_OVRD_BAR3_CTRL_RSRVS_MASK 0xFFFFFFF0
+#define PCIE_W_CFG_BARS_OVRD_BAR3_CTRL_RSRVS_SHIFT 4
+
+/**** bar4_ctrl register ****/
+/* bar is en and override the internal PF bar. */
+#define PCIE_W_CFG_BARS_OVRD_BAR4_CTRL_BAR_EN_MASK 0x00000003
+#define PCIE_W_CFG_BARS_OVRD_BAR4_CTRL_BAR_EN_SHIFT 0
+/* bar is io */
+#define PCIE_W_CFG_BARS_OVRD_BAR4_CTRL_BAR_IO_MASK 0x0000000C
+#define PCIE_W_CFG_BARS_OVRD_BAR4_CTRL_BAR_IO_SHIFT 2
+/* Reserved. */
+#define PCIE_W_CFG_BARS_OVRD_BAR4_CTRL_RSRVS_MASK 0xFFFFFFF0
+#define PCIE_W_CFG_BARS_OVRD_BAR4_CTRL_RSRVS_SHIFT 4
+
+/**** bar5_ctrl register ****/
+/* bar is en and override the internal PF bar. */
+#define PCIE_W_CFG_BARS_OVRD_BAR5_CTRL_BAR_EN_MASK 0x00000003
+#define PCIE_W_CFG_BARS_OVRD_BAR5_CTRL_BAR_EN_SHIFT 0
+/* bar is io */
+#define PCIE_W_CFG_BARS_OVRD_BAR5_CTRL_BAR_IO_MASK 0x0000000C
+#define PCIE_W_CFG_BARS_OVRD_BAR5_CTRL_BAR_IO_SHIFT 2
+/* Reserved. */
+#define PCIE_W_CFG_BARS_OVRD_BAR5_CTRL_RSRVS_MASK 0xFFFFFFF0
+#define PCIE_W_CFG_BARS_OVRD_BAR5_CTRL_RSRVS_SHIFT 4
+
+/**** cause_A register ****/
+/* Deassert_INTD received. Write zero to clear this bit. */
+#define PCIE_W_INT_GRP_A_CAUSE_A_DEASSERT_INTD (1 << 0)
+/* Deassert_INTC received. Write zero to clear this bit. */
+#define PCIE_W_INT_GRP_A_CAUSE_A_DEASSERT_INTC (1 << 1)
+/* Deassert_INTB received. Write zero to clear this bit. */
+#define PCIE_W_INT_GRP_A_CAUSE_A_DEASSERT_INTB (1 << 2)
+/* Deassert_INTA received. Write zero to clear this bit. */
+#define PCIE_W_INT_GRP_A_CAUSE_A_DEASSERT_INTA (1 << 3)
+/* Assert_INTD received. Write zero to clear this bit. */
+#define PCIE_W_INT_GRP_A_CAUSE_A_ASSERT_INTD (1 << 4)
+/* Assert_INTC received. Write zero to clear this bit. */
+#define PCIE_W_INT_GRP_A_CAUSE_A_ASSERT_INTC (1 << 5)
+/* Assert_INTC received. Write zero to clear this bit. */
+#define PCIE_W_INT_GRP_A_CAUSE_A_ASSERT_INTB (1 << 6)
+/* Assert_INTA received. Write zero to clear this bit. */
+#define PCIE_W_INT_GRP_A_CAUSE_A_ASSERT_INTA (1 << 7)
+/*
+ * MSI Controller Interrupt
+ * MSI interrupt is being received. Write zero to clear this bit
+ */
+#define PCIE_W_INT_GRP_A_CAUSE_A_MSI_CNTR_RCV_INT (1 << 8)
+/*
+ * MSI sent grant. Write zero to clear this bit.
+ */
+#define PCIE_W_INT_GRP_A_CAUSE_A_MSI_TRNS_GNT (1 << 9)
+/*
+ * System error detected
+ * Indicates if any device in the hierarchy reports any of the following errors
+ * and the associated enable bit is set in the Root Control register:
+ * ERR_COR
+ * ERR_FATAL
+ * ERR_NONFATAL
+ * Also asserted when an internal error is detected. Write zero to clear this
+ * bit.
+ */
+#define PCIE_W_INT_GRP_A_CAUSE_A_SYS_ERR_RC (1 << 10)
+/*
+ * Set when software initiates FLR on a Physical Function by writing to the
+ * Initiate FLR register bit of that function Write zero to clear this bit.
+ */
+#define PCIE_W_REV1_2_INT_GRP_A_CAUSE_A_FLR_PF_ACTIVE (1 << 11)
+#define PCIE_W_REV3_INT_GRP_A_CAUSE_A_RSRVD_11 (1 << 11)
+/*
+ * Reported error condition causes a bit to be set in the Root Error Status
+ * register and the associated error message reporting enable bit is set in the
+ * Root Error Command Register. Write zero to clear this bit.
+ */
+#define PCIE_W_REV1_2_INT_GRP_A_CAUSE_A_AER_RC_ERR (1 << 12)
+#define PCIE_W_REV3_INT_GRP_A_CAUSE_A_RSRVD_12 (1 << 12)
+/*
+ * The core asserts aer_rc_err_msi when all of the following conditions are
+ * true:
+ * - MSI or MSI-X is enabled.
+ * - A reported error condition causes a bit to be set in the Root Error Status
+ * register.
+ * - The associated error message reporting enable bit is set in the Root Error
+ * Command register Write zero to clear this bit
+ */
+#define PCIE_W_REV1_2_INT_GRP_A_CAUSE_A_AER_RC_ERR_MSI (1 << 13)
+#define PCIE_W_REV3_INT_GRP_A_CAUSE_A_RSRVD_13 (1 << 13)
+/*
+ * Wake Up. Wake up from power management unit.
+ * The core generates wake to request the system to restore power and clock when
+ * a beacon has been detected. wake is an active high signal and its rising edge
+ * should be detected to drive the WAKE# on the connector Write zero to clear
+ * this bit
+ */
+#define PCIE_W_INT_GRP_A_CAUSE_A_WAKE (1 << 14)
+/*
+ * The core asserts cfg_pme_int when all of the following conditions are true:
+ * - INTx Assertion Disable bit in the Command register is 0.
+ * - PME Interrupt Enable bit in the Root Control register is set to 1.
+ * - PME Status bit in the Root Status register is set to 1. Write zero to clear
+ * this bit
+ */
+#define PCIE_W_REV1_2_INT_GRP_A_CAUSE_A_PME_INT (1 << 15)
+#define PCIE_W_REV3_INT_GRP_A_CAUSE_A_RSRVD_15 (1 << 15)
+/*
+ * The core asserts cfg_pme_msi when all of the following conditions are true:
+ * - MSI or MSI-X is enabled.
+ * - PME Interrupt Enable bit in the Root Control register is set to 1.
+ * - PME Status bit in the Root Status register is set to 1. Write zero to clear
+ * this bit
+ */
+#define PCIE_W_REV1_2_INT_GRP_A_CAUSE_A_PME_MSI (1 << 16)
+#define PCIE_W_REV3_INT_GRP_A_CAUSE_A_RSRVD_16 (1 << 16)
+/*
+ * The core asserts hp_pme when all of the following conditions are true:
+ * - The PME Enable bit in the Power Management Control and Status register is
+ * set to 1.
+ * - Any bit in the Slot Status register transitions from 0 to 1 and the
+ * associated event notification is enabled in the Slot Control register. Write
+ * zero to clear this bit
+ */
+#define PCIE_W_INT_GRP_A_CAUSE_A_HP_PME (1 << 17)
+/*
+ * The core asserts hp_int when all of the following conditions are true:
+ * - INTx Assertion Disable bit in the Command register is 0.
+ * - Hot-Plug interrupts are enabled in the Slot Control register.
+ * - Any bit in the Slot Status register is equal to 1, and the associated event
+ * notification is enabled in the Slot Control register. Write zero to clear
+ * this bit
+ */
+#define PCIE_W_REV1_2_INT_GRP_A_CAUSE_A_HP_INT (1 << 18)
+/* The outstanding write counter become full should never happen */
+#define PCIE_W_REV3_INT_GRP_A_CAUSE_A_WRITE_COUNTER_FULL_ERR (1 << 18)
+
+
+/*
+ * The core asserts hp_msi when the logical AND of the following conditions
+ * transitions from false to true:
+ * - MSI or MSI-X is enabled.
+ * - Hot-Plug interrupts are enabled in the Slot Control register.
+ * - Any bit in the Slot Status register transitions from 0 to 1 and the
+ * associated event notification is enabled in the Slot Control register.
+ */
+#define PCIE_W_INT_GRP_A_CAUSE_A_HP_MSI (1 << 19)
+/* Read VPD registers notification */
+#define PCIE_W_REV1_2_INT_GRP_A_CAUSE_A_VPD_INT (1 << 20)
+/* not use */
+#define PCIE_W_REV3_INT_GRP_A_CAUSE_A_NOT_USE (1 << 20)
+
+/*
+ * The core assert link down event, whenever the link is going down. Write zero
+ * to clear this bit, pulse signal
+ */
+#define PCIE_W_INT_GRP_A_CAUSE_A_LINK_DOWN_EVENT (1 << 21)
+/*
+ * When the EP gets a command to shut down, signal the software to block any new
+ * TLP.
+ */
+#define PCIE_W_INT_GRP_A_CAUSE_A_PM_XTLH_BLOCK_TLP (1 << 22)
+/* PHY/MAC link up */
+#define PCIE_W_INT_GRP_A_CAUSE_A_XMLH_LINK_UP (1 << 23)
+/* Data link up */
+#define PCIE_W_INT_GRP_A_CAUSE_A_RDLH_LINK_UP (1 << 24)
+/* The ltssm is in RCVRY_LOCK state. */
+#define PCIE_W_INT_GRP_A_CAUSE_A_LTSSM_RCVRY_STATE (1 << 25)
+/*
+ * Config write transaction to the config space by the RC peer, enable this
+ * interrupt only for EP mode.
+ */
+#define PCIE_W_INT_GRP_A_CAUSE_A_CFG_WR_EVENT (1 << 26)
+/* AER error */
+#define PCIE_W_INT_GRP_A_CAUSE_A_AP_PENDED_CORR_ERR_STS_INT (1 << 28)
+/* AER error */
+#define PCIE_W_INT_GRP_A_CAUSE_A_AP_PENDED_UNCORR_ERR_STS_INT (1 << 29)
+
+/**** control_A register ****/
+/* When Clear_on_Read =1, all bits of Cause register are cleared on read. */
+#define PCIE_W_INT_GRP_A_CONTROL_A_CLEAR_ON_READ (1 << 0)
+/*
+ * (Must be set only when MSIX is enabled.)
+ * When Auto-Mask =1 and an MSI-X ACK for this bit is received, its
+ * corresponding bit in the Mask register is set, masking future interrupts.
+ */
+#define PCIE_W_INT_GRP_A_CONTROL_A_AUTO_MASK (1 << 1)
+/*
+ * Auto_Clear (RW)
+ * When Auto-Clear =1, the bits in the Interrupt Cause register are auto-cleared
+ * after MSI-X is acknowledged. Must be used only if MSI-X is enabled.
+ */
+#define PCIE_W_INT_GRP_A_CONTROL_A_AUTO_CLEAR (1 << 2)
+/*
+ * When Set_on_Posedge =1, the bits in the Interrupt Cause register are set on
+ * the posedge of the interrupt source, i.e., when interrupt source =1 and
+ * Interrupt Status = 0.
+ * When Set_on_Posedge =0, the bits in the Interrupt Cause register are set when
+ * interrupt source =1.
+ */
+#define PCIE_W_INT_GRP_A_CONTROL_A_SET_ON_POSEDGE (1 << 3)
+/*
+ * When Moderation_Reset =1, all Moderation timers associated with the interrupt
+ * cause bits are cleared to 0, enabling immediate interrupt assertion if any
+ * unmasked cause bit is set to 1. This bit is self-negated.
+ */
+#define PCIE_W_INT_GRP_A_CONTROL_A_MOD_RST (1 << 4)
+/*
+ * When mask_msi_x =1, no MSI-X from this group is sent. This bit must be set to
+ * 1 when the associated summary bit in this group is used to generate a single
+ * MSI-X for this group.
+ */
+#define PCIE_W_INT_GRP_A_CONTROL_A_MASK_MSI_X (1 << 5)
+/* MSI-X AWID value. Same ID for all cause bits. */
+#define PCIE_W_INT_GRP_A_CONTROL_A_AWID_MASK 0x00000F00
+#define PCIE_W_INT_GRP_A_CONTROL_A_AWID_SHIFT 8
+/*
+ * This value determines the interval between interrupts; writing ZERO disables
+ * Moderation.
+ */
+#define PCIE_W_INT_GRP_A_CONTROL_A_MOD_INTV_MASK 0x00FF0000
+#define PCIE_W_INT_GRP_A_CONTROL_A_MOD_INTV_SHIFT 16
+/*
+ * This value determines the Moderation_Timer_Clock speed.
+ * 0- Moderation-timer is decremented every 1x256 SB clock cycles ~1uS.
+ * 1- Moderation-timer is decremented every 2x256 SB clock cycles ~2uS.
+ * N- Moderation-timer is decremented every Nx256 SB clock cycles ~(N+1) uS.
+ */
+#define PCIE_W_INT_GRP_A_CONTROL_A_MOD_RES_MASK 0x0F000000
+#define PCIE_W_INT_GRP_A_CONTROL_A_MOD_RES_SHIFT 24
+
+/**** cause_B register ****/
+/* Indicates that the core received a PM_PME Message. Write Zero to clear. */
+#define PCIE_W_INT_GRP_B_CAUSE_B_MSG_PM_PME (1 << 0)
+/*
+ * Indicates that the core received a PME_TO_Ack Message. Write Zero to clear.
+ */
+#define PCIE_W_INT_GRP_B_CAUSE_B_MSG_PM_TO_ACK (1 << 1)
+/*
+ * Indicates that the core received an PME_Turn_Off Message. Write Zero to
+ * clear.
+ * EP mode only
+ */
+#define PCIE_W_INT_GRP_B_CAUSE_B_MSG_PM_TURNOFF (1 << 2)
+/* Indicates that the core received an ERR_CORR Message. Write Zero to clear. */
+#define PCIE_W_INT_GRP_B_CAUSE_B_MSG_CORRECTABLE_ERR (1 << 3)
+/*
+ * Indicates that the core received an ERR_NONFATAL Message. Write Zero to
+ * clear.
+ */
+#define PCIE_W_INT_GRP_B_CAUSE_B_MSG_NONFATAL_ERR (1 << 4)
+/*
+ * Indicates that the core received an ERR_FATAL Message. Write Zero to clear.
+ */
+#define PCIE_W_INT_GRP_B_CAUSE_B_MSG_FATAL_ERR (1 << 5)
+/*
+ * Indicates that the core received a Vendor Defined Message. Write Zero to
+ * clear.
+ */
+#define PCIE_W_INT_GRP_B_CAUSE_B_MSG_VENDOR_0 (1 << 6)
+/*
+ * Indicates that the core received a Vendor Defined Message. Write Zero to
+ * clear.
+ */
+#define PCIE_W_INT_GRP_B_CAUSE_B_MSG_VENDOR_1 (1 << 7)
+/* Indicates that the core received an Unlock Message. Write Zero to clear. */
+#define PCIE_W_INT_GRP_B_CAUSE_B_MSG_UNLOCK (1 << 8)
+/*
+ * Notification when the Link Autonomous Bandwidth Status register (Link Status
+ * register bit 15) is updated and the Link Autonomous Bandwidth Interrupt
+ * Enable (Link Control register bit 11) is set. This bit is not applicable to,
+ * and is reserved, for Endpoint device. Write Zero to clear
+ */
+#define PCIE_W_INT_GRP_B_CAUSE_B_LINK_AUTO_BW_INT (1 << 12)
+/*
+ * Notification that the Link Equalization Request bit in the Link Status 2
+ * Register has been set. Write Zero to clear.
+ */
+#define PCIE_W_INT_GRP_B_CAUSE_B_LINK_EQ_REQ_INT (1 << 13)
+/*
+ * OB Vendor message request is granted by the PCIe core Write Zero to clear.
+ */
+#define PCIE_W_INT_GRP_B_CAUSE_B_VENDOR_MSG_GRANT (1 << 14)
+/* CPL timeout from the PCIe core inidication. Write Zero to clear */
+#define PCIE_W_INT_GRP_B_CAUSE_B_CMP_TIME_OUT (1 << 15)
+/*
+ * Slave Response Composer Lookup Error
+ * Indicates that an overflow occurred in a lookup table of the Inbound
+ * responses. This indicates that there was a violation of the number of
+ * outstanding NP requests issued for the Outbound direction. Write zero to
+ * clear
+ */
+#define PCIE_W_INT_GRP_B_CAUSE_B_RADMX_CMPOSER_LOOKUP_ERR (1 << 16)
+/* Parity Error */
+#define PCIE_W_INT_GRP_B_CAUSE_B_PARITY_ERROR_CORE (1 << 17)
+
+/**** control_B register ****/
+/* When Clear_on_Read =1, all bits of the Cause register are cleared on read. */
+#define PCIE_W_INT_GRP_B_CONTROL_B_CLEAR_ON_READ (1 << 0)
+/*
+ * (Must be set only when MSIX is enabled.)
+ * When Auto-Mask =1 and an MSI-X ACK for this bit is received, its
+ * corresponding bit in the Mask register is set, masking future interrupts.
+ */
+#define PCIE_W_INT_GRP_B_CONTROL_B_AUTO_MASK (1 << 1)
+/*
+ * Auto_Clear (RW)
+ * When Auto-Clear =1, the bits in the Interrupt Cause register are auto-cleared
+ * after MSI-X is acknowledged. Must be used only if MSI-X is enabled.
+ */
+#define PCIE_W_INT_GRP_B_CONTROL_B_AUTO_CLEAR (1 << 2)
+/*
+ * When Set_on_Posedge =1, the bits in the interrupt Cause register are set on
+ * the posedge of the interrupt source, i.e., when Interrupt Source =1 and
+ * Interrupt Status = 0.
+ * When Set_on_Posedge =0, the bits in the Interrupt Cause register are set when
+ * Interrupt Source =1.
+ */
+#define PCIE_W_INT_GRP_B_CONTROL_B_SET_ON_POSEDGE (1 << 3)
+/*
+ * When Moderation_Reset =1, all Moderation timers associated with the interrupt
+ * cause bits are cleared to 0, enabling an immediate interrupt assertion if any
+ * unmasked cause bit is set to 1. This bit is self-negated.
+ */
+#define PCIE_W_INT_GRP_B_CONTROL_B_MOD_RST (1 << 4)
+/*
+ * When mask_msi_x =1, no MSI-X from this group is sent. This bit must be set to
+ * 1 when the associated summary bit in this group is used to generate a single
+ * MSI-X for this group.
+ */
+#define PCIE_W_INT_GRP_B_CONTROL_B_MASK_MSI_X (1 << 5)
+/* MSI-X AWID value. Same ID for all cause bits. */
+#define PCIE_W_INT_GRP_B_CONTROL_B_AWID_MASK 0x00000F00
+#define PCIE_W_INT_GRP_B_CONTROL_B_AWID_SHIFT 8
+/*
+ * This value determines the interval between interrupts. Writing ZERO disables
+ * Moderation.
+ */
+#define PCIE_W_INT_GRP_B_CONTROL_B_MOD_INTV_MASK 0x00FF0000
+#define PCIE_W_INT_GRP_B_CONTROL_B_MOD_INTV_SHIFT 16
+/*
+ * This value determines the Moderation_Timer_Clock speed.
+ * 0- Moderation-timer is decremented every 1x256 SB clock cycles ~1uS.
+ * 1- Moderation-timer is decremented every 2x256 SB clock cycles ~2uS.
+ * N- Moderation-timer is decremented every Nx256 SB clock cycles ~(N+1) uS.
+ */
+#define PCIE_W_INT_GRP_B_CONTROL_B_MOD_RES_MASK 0x0F000000
+#define PCIE_W_INT_GRP_B_CONTROL_B_MOD_RES_SHIFT 24
+
+/**** cause_C register ****/
+/* VPD interrupt, ot read/write frpm EEPROM */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_VPD_INT_FUNC_MASK 0x0000000F
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_VPD_INT_FUNC_SHIFT 0
+/* flr PF active */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_CFG_FLR_PF_ACTIVE_MASK 0x000000F0
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_CFG_FLR_PF_ACTIVE_SHIFT 4
+/* System ERR RC. */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_CFG_SYS_ERR_RC_MASK 0x00000F00
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_CFG_SYS_ERR_RC_SHIFT 8
+/* AER RC INT */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_CFG_AER_RC_ERR_INT_MASK 0x0000F000
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_CFG_AER_RC_ERR_INT_SHIFT 12
+/* AER RC MSI */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_CFG_AER_RC_ERR_MSI_MASK 0x000F0000
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_CFG_AER_RC_ERR_MSI_SHIFT 16
+/* PME MSI */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_CFG_PME_MSI_MASK 0x00F00000
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_CFG_PME_MSI_SHIFT 20
+/* PME int */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_CFG_PME_INT_MASK 0x0F000000
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_CFG_PME_INT_SHIFT 24
+/* SB overflow */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_RADM_QOVERFLOW (1 << 28)
+/* ecrc was injected through the diag_ctrl bus */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_ECRC_INJECTED (1 << 29)
+/* lcrc was injected through the diag_ctrl bus */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_LCRC_INJECTED (1 << 30)
+/* lcrc was injected through the diag_ctrl bus */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CAUSE_GRP_C_RSRVD (1 << 31)
+
+/**** control_C register ****/
+/* When Clear_on_Read =1, all bits of Cause register are cleared on read. */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CONTROL_GRP_C_CLEAR_ON_READ (1 << 0)
+/*
+ * (Must be set only when MSIX is enabled.)
+ * When Auto-Mask =1 and an MSI-X ACK for this bit is received, its
+ * corresponding bit in the Mask register is set, masking future interrupts.
+ */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CONTROL_GRP_C_AUTO_MASK (1 << 1)
+/*
+ * Auto_Clear (RW)
+ * When Auto-Clear =1, the bits in the Interrupt Cause register are auto-cleared
+ * after MSI-X is acknowledged. Must be used only if MSI-X is enabled.
+ */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CONTROL_GRP_C_AUTO_CLEAR (1 << 2)
+/*
+ * When Set_on_Posedge =1, the bits in the Interrupt Cause register are set on
+ * the posedge of the interrupt source, i.e., when interrupt source =1 and
+ * Interrupt Status = 0.
+ * When Set_on_Posedge =0, the bits in the Interrupt Cause register are set when
+ * interrupt source =1.
+ */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CONTROL_GRP_C_SET_ON_POSEDGE (1 << 3)
+/*
+ * When Moderation_Reset =1, all Moderation timers associated with the interrupt
+ * cause bits are cleared to 0, enabling immediate interrupt assertion if any
+ * unmasked cause bit is set to 1. This bit is self-negated.
+ */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CONTROL_GRP_C_MOD_RST (1 << 4)
+/*
+ * When mask_msi_x =1, no MSI-X from this group is sent. This bit must be set to
+ * 1 when the associated summary bit in this group is used to generate a single
+ * MSI-X for this group.
+ */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CONTROL_GRP_C_MASK_MSI_X (1 << 5)
+/* MSI-X AWID value. Same ID for all cause bits. */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CONTROL_GRP_C_AWID_MASK 0x00000F00
+#define PCIE_W_INTERRUPT_GRP_C_INT_CONTROL_GRP_C_AWID_SHIFT 8
+/*
+ * This value determines the interval between interrupts; writing ZERO disables
+ * Moderation.
+ */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CONTROL_GRP_C_MOD_INTV_MASK 0x00FF0000
+#define PCIE_W_INTERRUPT_GRP_C_INT_CONTROL_GRP_C_MOD_INTV_SHIFT 16
+/*
+ * This value determines the Moderation_Timer_Clock speed.
+ * 0- Moderation-timer is decremented every 1x256 SB clock cycles ~1uS.
+ * 1- Moderation-timer is decremented every 2x256 SB clock cycles ~2uS.
+ * N- Moderation-timer is decremented every Nx256 SB clock cycles ~(N+1) uS.
+ */
+#define PCIE_W_INTERRUPT_GRP_C_INT_CONTROL_GRP_C_MOD_RES_MASK 0x0F000000
+#define PCIE_W_INTERRUPT_GRP_C_INT_CONTROL_GRP_C_MOD_RES_SHIFT 24
+
+/**** control_D register ****/
+/* When Clear_on_Read =1, all bits of Cause register are cleared on read. */
+#define PCIE_W_INTERRUPT_GRP_D_INT_CONTROL_GRP_D_CLEAR_ON_READ (1 << 0)
+/*
+ * (Must be set only when MSIX is enabled.)
+ * When Auto-Mask =1 and an MSI-X ACK for this bit is received, its
+ * corresponding bit in the Mask register is set, masking future interrupts.
+ */
+#define PCIE_W_INTERRUPT_GRP_D_INT_CONTROL_GRP_D_AUTO_MASK (1 << 1)
+/*
+ * Auto_Clear (RW)
+ * When Auto-Clear =1, the bits in the Interrupt Cause register are auto-cleared
+ * after MSI-X is acknowledged. Must be used only if MSI-X is enabled.
+ */
+#define PCIE_W_INTERRUPT_GRP_D_INT_CONTROL_GRP_D_AUTO_CLEAR (1 << 2)
+/*
+ * When Set_on_Posedge =1, the bits in the Interrupt Cause register are set on
+ * the posedge of the interrupt source, i.e., when interrupt source =1 and
+ * Interrupt Status = 0.
+ * When Set_on_Posedge =0, the bits in the Interrupt Cause register are set when
+ * interrupt source =1.
+ */
+#define PCIE_W_INTERRUPT_GRP_D_INT_CONTROL_GRP_D_SET_ON_POSEDGE (1 << 3)
+/*
+ * When Moderation_Reset =1, all Moderation timers associated with the interrupt
+ * cause bits are cleared to 0, enabling immediate interrupt assertion if any
+ * unmasked cause bit is set to 1. This bit is self-negated.
+ */
+#define PCIE_W_INTERRUPT_GRP_D_INT_CONTROL_GRP_D_MOD_RST (1 << 4)
+/*
+ * When mask_msi_x =1, no MSI-X from this group is sent. This bit must be set to
+ * 1 when the associated summary bit in this group is used to generate a single
+ * MSI-X for this group.
+ */
+#define PCIE_W_INTERRUPT_GRP_D_INT_CONTROL_GRP_D_MASK_MSI_X (1 << 5)
+/* MSI-X AWID value. Same ID for all cause bits. */
+#define PCIE_W_INTERRUPT_GRP_D_INT_CONTROL_GRP_D_AWID_MASK 0x00000F00
+#define PCIE_W_INTERRUPT_GRP_D_INT_CONTROL_GRP_D_AWID_SHIFT 8
+/*
+ * This value determines the interval between interrupts; writing ZERO disables
+ * Moderation.
+ */
+#define PCIE_W_INTERRUPT_GRP_D_INT_CONTROL_GRP_D_MOD_INTV_MASK 0x00FF0000
+#define PCIE_W_INTERRUPT_GRP_D_INT_CONTROL_GRP_D_MOD_INTV_SHIFT 16
+/*
+ * This value determines the Moderation_Timer_Clock speed.
+ * 0- Moderation-timer is decremented every 1x256 SB clock cycles ~1uS.
+ * 1- Moderation-timer is decremented every 2x256 SB clock cycles ~2uS.
+ * N- Moderation-timer is decremented every Nx256 SB clock cycles ~(N+1) uS.
+ */
+#define PCIE_W_INTERRUPT_GRP_D_INT_CONTROL_GRP_D_MOD_RES_MASK 0x0F000000
+#define PCIE_W_INTERRUPT_GRP_D_INT_CONTROL_GRP_D_MOD_RES_SHIFT 24
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __AL_HAL_PCIE_W_REG_H */
+
+/** @} end of ... group */
+
+
diff --git a/sys/arm/annapurna/alpine/hal/al_hal_plat_services.h b/sys/arm/annapurna/alpine/hal/al_hal_plat_services.h
new file mode 100644
index 0000000..217bb92
--- /dev/null
+++ b/sys/arm/annapurna/alpine/hal/al_hal_plat_services.h
@@ -0,0 +1,419 @@
+/*-
+*******************************************************************************
+Copyright (C) 2015 Annapurna Labs Ltd.
+
+This file may be licensed under the terms of the Annapurna Labs Commercial
+License Agreement.
+
+Alternatively, this file can be distributed under the terms of the GNU General
+Public License V2 as published by the Free Software Foundation and can be
+found at http://www.gnu.org/licenses/gpl-2.0.html
+
+Alternatively, redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+notice, this 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 HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*******************************************************************************/
+
+/**
+ * @defgroup group_services Platform Services API
+ * @{
+ * The Platform Services API provides miscellaneous system services to HAL
+ * drivers, such as:
+ * - Registers read/write
+ * - Assertions
+ * - Memory barriers
+ * - Endianness conversions
+ *
+ * And more.
+ * @file plat_api/sample/al_hal_plat_services.h
+ *
+ * @brief API for Platform services provided for to HAL drivers
+ *
+ *
+ */
+
+#ifndef __PLAT_SERVICES_H__
+#define __PLAT_SERVICES_H__
+
+#include <machine/atomic.h>
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/endian.h>
+#include <sys/errno.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+
+/* Prototypes for all the bus_space structure functions */
+bs_protos(generic);
+bs_protos(generic_armv4);
+
+#define __UNUSED __attribute__((unused))
+
+/* *INDENT-OFF* */
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* *INDENT-ON* */
+
+/*
+ * WMA: This is a hack which allows not modifying the __iomem accessing HAL code.
+ * On ARMv7, bus_handle holds the information about VA of accessed memory. It
+ * is possible to use direct load/store instruction instead of bus_dma machinery.
+ * WARNING: This is not guaranteed to stay that way forever, nor that
+ * on other architectures these variables behave similarly. Keep that
+ * in mind during porting to other systems.
+ */
+/**
+ * Read MMIO 8 bits register
+ * @param offset register offset
+ *
+ * @return register value
+ */
+static uint8_t al_reg_read8(uint8_t * offset);
+
+/**
+ * Read MMIO 16 bits register
+ * @param offset register offset
+ *
+ * @return register value
+ */
+static uint16_t al_reg_read16(uint16_t * offset);
+
+/**
+ * Read MMIO 32 bits register
+ * @param offset register offset
+ *
+ * @return register value
+ */
+static uint32_t al_reg_read32(uint32_t * offset);
+
+/**
+ * Read MMIO 64 bits register
+ * @param offset register offset
+ *
+ * @return register value
+ */
+uint64_t al_reg_read64(uint64_t * offset);
+
+/**
+ * Relaxed read MMIO 32 bits register
+ *
+ * Relaxed register read/write functions don't involve cpu instructions that
+ * force syncronization, nor ordering between the register access and memory
+ * data access.
+ * These instructions are used in performance critical code to avoid the
+ * overhead of the synchronization instructions.
+ *
+ * @param offset register offset
+ *
+ * @return register value
+ */
+#define al_bus_dma_to_va(bus_tag, bus_handle) ((void*)bus_handle)
+
+/**
+ * Relaxed read MMIO 32 bits register
+ *
+ * Relaxed register read/write functions don't involve cpu instructions that
+ * force syncronization, nor ordering between the register access and memory
+ * data access.
+ * These instructions are used in performance critical code to avoid the
+ * overhead of the synchronization instructions.
+ *
+ * @param offset register offset
+ *
+ * @return register value
+ */
+#define al_reg_read32_relaxed(l) generic_bs_r_4(NULL, (bus_space_handle_t)l, 0)
+
+/**
+ * Relaxed write to MMIO 32 bits register
+ *
+ * Relaxed register read/write functions don't involve cpu instructions that
+ * force syncronization, nor ordering between the register access and memory
+ * data access.
+ * These instructions are used in performance critical code to avoid the
+ * overhead of the synchronization instructions.
+ *
+ * @param offset register offset
+ * @param val value to write to the register
+ */
+#define al_reg_write32_relaxed(l,v) generic_bs_w_4(NULL, (bus_space_handle_t)l, 0, v)
+
+/**
+ * Write to MMIO 8 bits register
+ * @param offset register offset
+ * @param val value to write to the register
+ */
+#define al_reg_write8(l,v) do { dsb(); generic_bs_w_1(NULL, (bus_space_handle_t)l, 0, v); dmb(); } while (0)
+
+/**
+ * Write to MMIO 16 bits register
+ * @param offset register offset
+ * @param val value to write to the register
+ */
+#define al_reg_write16(l,v) do { dsb(); generic_bs_w_2(NULL, (bus_space_handle_t)l, 0, v); dmb(); } while (0)
+
+/**
+ * Write to MMIO 32 bits register
+ * @param offset register offset
+ * @param val value to write to the register
+ */
+#define al_reg_write32(l,v) do { dsb(); generic_bs_w_4(NULL, (bus_space_handle_t)l, 0, v); dmb(); } while (0)
+
+/**
+ * Write to MMIO 64 bits register
+ * @param offset register offset
+ * @param val value to write to the register
+ */
+#define al_reg_write64(l,v) do { dsb(); generic_bs_w_8(NULL, (bus_space_handle_t)l, 0, v); dmb(); } while (0)
+
+static inline uint8_t
+al_reg_read8(uint8_t *l)
+{
+ dsb();
+
+ return (generic_bs_r_1(NULL, (bus_space_handle_t)l, 0));
+}
+
+static inline uint16_t
+al_reg_read16(uint16_t *l)
+{
+ dsb();
+
+ return (generic_bs_r_2(NULL, (bus_space_handle_t)l, 0));
+}
+
+static inline uint32_t
+al_reg_read32(uint32_t *l)
+{
+ dsb();
+
+ return (generic_bs_r_4(NULL, (bus_space_handle_t)l, 0));
+}
+
+#define AL_DBG_LEVEL_NONE 0
+#define AL_DBG_LEVEL_ERR 1
+#define AL_DBG_LEVEL_WARN 2
+#define AL_DBG_LEVEL_INFO 3
+#define AL_DBG_LEVEL_DBG 4
+
+#define AL_DBG_LEVEL AL_DBG_LEVEL_ERR
+
+extern struct mtx al_dbg_lock;
+
+#define AL_DBG_LOCK() mtx_lock_spin(&al_dbg_lock)
+#define AL_DBG_UNLOCK() mtx_unlock_spin(&al_dbg_lock)
+
+/**
+ * print message
+ *
+ * @param format The format string
+ * @param ... Additional arguments
+ */
+#define al_print(type, fmt, ...) do { if (AL_DBG_LEVEL >= AL_DBG_LEVEL_NONE) { AL_DBG_LOCK(); printf(fmt, ##__VA_ARGS__); AL_DBG_UNLOCK(); } } while(0)
+
+/**
+ * print error message
+ *
+ * @param format
+ */
+#define al_err(...) do { if (AL_DBG_LEVEL >= AL_DBG_LEVEL_ERR) { AL_DBG_LOCK(); printf(__VA_ARGS__); AL_DBG_UNLOCK(); } } while(0)
+
+/**
+ * print warning message
+ *
+ * @param format
+ */
+#define al_warn(...) do { if (AL_DBG_LEVEL >= AL_DBG_LEVEL_WARN) { AL_DBG_LOCK(); printf(__VA_ARGS__); AL_DBG_UNLOCK(); } } while(0)
+
+/**
+ * print info message
+ *
+ * @param format
+ */
+#define al_info(...) do { if (AL_DBG_LEVEL >= AL_DBG_LEVEL_INFO) { AL_DBG_LOCK(); printf(__VA_ARGS__); AL_DBG_UNLOCK(); } } while(0)
+
+/**
+ * print debug message
+ *
+ * @param format
+ */
+#define al_dbg(...) do { if (AL_DBG_LEVEL >= AL_DBG_LEVEL_DBG) { AL_DBG_LOCK(); printf(__VA_ARGS__); AL_DBG_UNLOCK(); } } while(0)
+
+/**
+ * Assertion
+ *
+ * @param condition
+ */
+#define al_assert(COND) \
+ do { \
+ if (!(COND)) \
+ al_err( \
+ "%s:%d:%s: Assertion failed! (%s)\n", \
+ __FILE__, __LINE__, __func__, #COND); \
+ } while(AL_FALSE)
+
+/**
+ * Make sure data will be visible by other masters (other CPUS and DMA).
+ * usually this is achieved by the ARM DMB instruction.
+ */
+static void al_data_memory_barrier(void);
+
+/**
+ * Make sure data will be visible by DMA masters, no restriction for other cpus
+ */
+static inline void
+al_data_memory_barrier(void)
+{
+ dsb();
+}
+
+/**
+ * Make sure data will be visible in order by other cpus masters.
+ */
+static inline void
+al_smp_data_memory_barrier(void)
+{
+ dsb();
+}
+
+/**
+ * Make sure write data will be visible in order by other cpus masters.
+ */
+static inline void
+al_local_data_memory_barrier(void)
+{
+ dsb();
+}
+
+/**
+ * al_udelay - micro sec delay
+ */
+#define al_udelay(u) DELAY(u)
+
+/**
+ * al_msleep - mili sec delay
+ */
+#define al_msleep(m) DELAY((m) * 1000)
+
+/**
+ * swap half word to little endian
+ *
+ * @param x 16 bit value
+ *
+ * @return the value in little endian
+ */
+#define swap16_to_le(x) htole16(x)
+/**
+ * swap word to little endian
+ *
+ * @param x 32 bit value
+ *
+ * @return the value in little endian
+ */
+#define swap32_to_le(x) htole32(x)
+
+/**
+ * swap 8 bytes to little endian
+ *
+ * @param x 64 bit value
+ *
+ * @return the value in little endian
+ */
+#define swap64_to_le(x) htole64(x)
+
+/**
+ * swap half word from little endian
+ *
+ * @param x 16 bit value
+ *
+ * @return the value in the cpu endianess
+ */
+#define swap16_from_le(x) le16toh(x)
+
+/**
+ * swap word from little endian
+ *
+ * @param x 32 bit value
+ *
+ * @return the value in the cpu endianess
+ */
+#define swap32_from_le(x) le32toh(x)
+
+/**
+ * swap 8 bytes from little endian
+ *
+ * @param x 64 bit value
+ *
+ * @return the value in the cpu endianess
+ */
+#define swap64_from_le(x) le64toh(x)
+
+/**
+ * Memory set
+ *
+ * @param p memory pointer
+ * @param val value for setting
+ * @param cnt number of bytes to set
+ */
+#define al_memset(p, val, cnt) memset(p, val, cnt)
+
+/**
+ * Memory copy
+ *
+ * @param p1 memory pointer
+ * @param p2 memory pointer
+ * @param cnt number of bytes to copy
+ */
+#define al_memcpy(p1, p2, cnt) memcpy(p1, p2, cnt)
+
+/**
+ * Memory compare
+ *
+ * @param p1 memory pointer
+ * @param p2 memory pointer
+ * @param cnt number of bytes to compare
+ */
+#define al_memcmp(p1, p2, cnt) memcmp(p1, p2, cnt)
+
+/**
+ * String compare
+ *
+ * @param s1 string pointer
+ * @param s2 string pointer
+ */
+#define al_strcmp(s1, s2) strcmp(s1, s2)
+
+#define al_get_cpu_id() 0
+
+/* *INDENT-OFF* */
+#ifdef __cplusplus
+}
+#endif
+/* *INDENT-ON* */
+/** @} end of Platform Services API group */
+#endif /* __PLAT_SERVICES_H__ */
diff --git a/sys/arm/annapurna/alpine/hal/al_hal_plat_types.h b/sys/arm/annapurna/alpine/hal/al_hal_plat_types.h
new file mode 100644
index 0000000..43896ae
--- /dev/null
+++ b/sys/arm/annapurna/alpine/hal/al_hal_plat_types.h
@@ -0,0 +1,94 @@
+/*-
+********************************************************************************
+Copyright (C) 2015 Annapurna Labs Ltd.
+
+This file may be licensed under the terms of the Annapurna Labs Commercial
+License Agreement.
+
+Alternatively, this file can be distributed under the terms of the GNU General
+Public License V2 as published by the Free Software Foundation and can be
+found at http://www.gnu.org/licenses/gpl-2.0.html
+
+Alternatively, redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+notice, this 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 HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*******************************************************************************/
+
+/**
+ * @defgroup group_services Platform Services API
+ * @{
+ * @file plat_api/sample/al_hal_plat_types.h
+ *
+ */
+
+#ifndef __PLAT_TYPES_H__
+#define __PLAT_TYPES_H__
+
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <machine/bus.h>
+#include <sys/bus.h>
+
+/* *INDENT-OFF* */
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* *INDENT-ON* */
+
+/* Basic data types */
+typedef int al_bool; /** boolean */
+#define AL_TRUE 1
+#define AL_FALSE 0
+
+
+/* define types */
+#ifndef AL_HAVE_TYPES
+typedef unsigned char uint8_t; /** unsigned 8 bits */
+typedef unsigned short uint16_t; /** unsigned 16 bits */
+typedef unsigned int uint32_t; /** unsigned 32 bits */
+typedef unsigned long long uint64_t; /** unsigned 64 bits */
+
+typedef signed char int8_t; /** signed 8 bits */
+typedef short int int16_t; /** signed 16 bits */
+typedef signed int int32_t; /** signed 32 bits */
+
+/** An unsigned int that is guaranteed to be the same size as a pointer */
+/** C99 standard */
+typedef unsigned long uintptr_t;
+#endif
+
+
+/** in LPAE mode, the address address is 40 bit, we extend it to 64 bit */
+typedef uint64_t al_phys_addr_t;
+
+/** this defines the cpu endiancess. */
+#define PLAT_ARCH_IS_LITTLE() AL_TRUE
+
+/* *INDENT-OFF* */
+#ifdef __cplusplus
+}
+#endif
+/* *INDENT-ON* */
+/** @} end of Platform Services API group */
+
+#endif /* __PLAT_TYPES_H__ */
diff --git a/sys/arm/annapurna/alpine/hal/al_hal_reg_utils.h b/sys/arm/annapurna/alpine/hal/al_hal_reg_utils.h
new file mode 100644
index 0000000..f29c3c5
--- /dev/null
+++ b/sys/arm/annapurna/alpine/hal/al_hal_reg_utils.h
@@ -0,0 +1,188 @@
+/*-
+********************************************************************************
+Copyright (C) 2015 Annapurna Labs Ltd.
+
+This file may be licensed under the terms of the Annapurna Labs Commercial
+License Agreement.
+
+Alternatively, this file can be distributed under the terms of the GNU General
+Public License V2 as published by the Free Software Foundation and can be
+found at http://www.gnu.org/licenses/gpl-2.0.html
+
+Alternatively, redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+notice, this 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 HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*******************************************************************************/
+
+/**
+ * @defgroup group_common HAL Common Layer
+ * @{
+ * @file al_hal_reg_utils.h
+ *
+ * @brief Register utilities used by HALs and platform layer
+ *
+ *
+ */
+
+#ifndef __AL_HAL_REG_UTILS_H__
+#define __AL_HAL_REG_UTILS_H__
+
+#include "al_hal_plat_types.h"
+#include "al_hal_plat_services.h"
+
+/* *INDENT-OFF* */
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* *INDENT-ON* */
+
+#define AL_BIT(b) (1UL << (b))
+
+#define AL_ADDR_LOW(x) ((uint32_t)((al_phys_addr_t)(x)))
+#define AL_ADDR_HIGH(x) ((uint32_t)((((al_phys_addr_t)(x)) >> 16) >> 16))
+
+/** get field out of 32 bit register */
+#define AL_REG_FIELD_GET(reg, mask, shift) (((reg) & (mask)) >> (shift))
+
+/** set field of 32 bit register */
+#define AL_REG_FIELD_SET(reg, mask, shift, val) \
+ (reg) = \
+ (((reg) & (~(mask))) | \
+ ((((unsigned)(val)) << (shift)) & (mask)))
+
+/** set field of 64 bit register */
+#define AL_REG_FIELD_SET_64(reg, mask, shift, val) \
+ ((reg) = \
+ (((reg) & (~(mask))) | \
+ ((((uint64_t)(val)) << (shift)) & (mask))))
+
+/** get single bit out of 32 bit register */
+#define AL_REG_BIT_GET(reg, shift) \
+ AL_REG_FIELD_GET(reg, AL_BIT(shift), shift)
+
+#define AL_REG_BITS_FIELD(shift, val) \
+ (((unsigned)(val)) << (shift))
+
+/** set single bit field of 32 bit register to a given value */
+#define AL_REG_BIT_VAL_SET(reg, shift, val) \
+ AL_REG_FIELD_SET(reg, AL_BIT(shift), shift, val)
+
+/** set single bit of 32 bit register to 1 */
+#define AL_REG_BIT_SET(reg, shift) \
+ AL_REG_BIT_VAL_SET(reg, shift, 1)
+
+/** clear single bit of 32 bit register */
+#define AL_REG_BIT_CLEAR(reg, shift) \
+ AL_REG_BIT_VAL_SET(reg, shift, 0)
+
+
+#define AL_BIT_MASK(n) \
+ (AL_BIT(n) - 1)
+
+#define AL_FIELD_MASK(msb, lsb) \
+ (AL_BIT(msb) + AL_BIT_MASK(msb) - AL_BIT_MASK(lsb))
+
+/** clear bits specified by clear_mask */
+#define AL_REG_MASK_CLEAR(reg, clear_mask) \
+ ((reg) = (((reg) & (~(clear_mask)))))
+
+/** set bits specified by clear_mask */
+#define AL_REG_MASK_SET(reg, clear_mask) \
+ ((reg) = (((reg) | (clear_mask))))
+
+
+/** clear bits specified by clear_mask, and set bits specified by set_mask */
+#define AL_REG_CLEAR_AND_SET(reg, clear_mask, set_mask) \
+ (reg) = (((reg) & (~(clear_mask))) | (set_mask))
+
+#define AL_ALIGN_UP(val, size) \
+ ((size) * (((val) + (size) - 1) / (size)))
+
+/** take bits selected by mask from one data, the rest from background */
+#define AL_MASK_VAL(mask, data, background) \
+ (((mask) & (data)) | ((~mask) & (background)))
+
+/**
+ * 8 bits register masked write
+ *
+ * @param reg
+ * register address
+ * @param mask
+ * bits not selected (1) by mask will be left unchanged
+ * @param data
+ * data to write. bits not selected by mask ignored.
+ */
+static inline void
+al_reg_write8_masked(uint8_t __iomem *reg, uint8_t mask, uint8_t data)
+{
+ uint8_t temp;
+ temp = al_reg_read8(reg);
+ al_reg_write8(reg, AL_MASK_VAL(mask, data, temp));
+}
+
+
+/**
+ * 16 bits register masked write
+ *
+ * @param reg
+ * register address
+ * @param mask
+ * bits not selected (1) by mask will be left unchanged
+ * @param data
+ * data to write. bits not selected by mask ignored.
+ */
+static inline void
+al_reg_write16_masked(uint16_t __iomem *reg, uint16_t mask, uint16_t data)
+{
+ uint16_t temp;
+ temp = al_reg_read16(reg);
+ al_reg_write16(reg, AL_MASK_VAL(mask, data, temp));
+}
+
+
+/**
+ * 32 bits register masked write
+ *
+ * @param reg
+ * register address
+ * @param mask
+ * bits not selected (1) by mask will be left unchanged
+ * @param data
+ * data to write. bits not selected by mask ignored.
+ */
+static inline void
+al_reg_write32_masked(uint32_t __iomem *reg, uint32_t mask, uint32_t data)
+{
+ uint32_t temp;
+ temp = al_reg_read32(reg);
+ al_reg_write32(reg, AL_MASK_VAL(mask, data, temp));
+}
+
+/* *INDENT-OFF* */
+#ifdef __cplusplus
+}
+#endif
+/* *INDENT-ON* */
+/** @} end of Common group */
+#endif
+
diff --git a/sys/arm/annapurna/alpine/hal/al_hal_types.h b/sys/arm/annapurna/alpine/hal/al_hal_types.h
new file mode 100644
index 0000000..cea839d
--- /dev/null
+++ b/sys/arm/annapurna/alpine/hal/al_hal_types.h
@@ -0,0 +1,117 @@
+/*-
+********************************************************************************
+Copyright (C) 2015 Annapurna Labs Ltd.
+
+This file may be licensed under the terms of the Annapurna Labs Commercial
+License Agreement.
+
+Alternatively, this file can be distributed under the terms of the GNU General
+Public License V2 as published by the Free Software Foundation and can be
+found at http://www.gnu.org/licenses/gpl-2.0.html
+
+Alternatively, redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+notice, this 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 HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*******************************************************************************/
+
+/**
+ * @defgroup group_common HAL Common Layer
+ * @{
+ * @file al_hal_types.h
+ *
+ * @brief macros used by HALs and platform layer
+ *
+ */
+
+#ifndef __AL_HAL_TYPES_H__
+#define __AL_HAL_TYPES_H__
+
+#include "al_hal_plat_types.h"
+#include "al_hal_plat_services.h"
+
+/* *INDENT-OFF* */
+#ifdef __cplusplus
+extern "C" {
+#endif
+/* *INDENT-ON* */
+
+/* Common defines */
+
+#if (!AL_TRUE) || (AL_FALSE)
+#error "AL_TRUE must be non zero and AL_FALSE must be zero"
+#endif
+
+typedef int AL_RETURN;
+
+#if !defined(NULL)
+#define NULL (void *)0
+#endif
+
+#if !defined(likely)
+#define likely(x) (__builtin_expect(!!(x), 1))
+#define unlikely(x) (__builtin_expect(!!(x), 0))
+#endif
+
+
+#ifdef __GNUC__
+#if !defined(__packed)
+#define __packed __attribute__ ((packed))
+#endif
+ /* packed and alinged types */
+#define __packed_a4 __attribute__ ((packed, aligned(4)))
+#define __packed_a8 __attribute__ ((packed, aligned(8)))
+#define __packed_a16 __attribute__ ((packed, aligned(16)))
+
+#else
+#if !defined(__packed)
+#error "__packed is not defined!!"
+#endif
+#endif
+
+#if !defined(__iomem)
+#define __iomem
+#endif
+
+#if !defined(__cache_aligned)
+#ifdef __GNUC__
+#define __cache_aligned __attribute__ ((__aligned__(64)))
+#else
+#define __cache_aligned
+#endif
+#endif
+
+#if !defined(INLINE)
+#ifdef __GNUC__
+#define INLINE inline
+#else
+#define INLINE
+#endif
+#endif
+
+/* *INDENT-OFF* */
+#ifdef __cplusplus
+}
+#endif
+/* *INDENT-ON* */
+/** @} end of Common group */
+#endif /* __TYPES_H__ */
diff --git a/sys/arm/annapurna/alpine/hal/al_hal_unit_adapter_regs.h b/sys/arm/annapurna/alpine/hal/al_hal_unit_adapter_regs.h
new file mode 100644
index 0000000..740b959
--- /dev/null
+++ b/sys/arm/annapurna/alpine/hal/al_hal_unit_adapter_regs.h
@@ -0,0 +1,314 @@
+/*-
+********************************************************************************
+Copyright (C) 2015 Annapurna Labs Ltd.
+
+This file may be licensed under the terms of the Annapurna Labs Commercial
+License Agreement.
+
+Alternatively, this file can be distributed under the terms of the GNU General
+Public License V2 as published by the Free Software Foundation and can be
+found at http://www.gnu.org/licenses/gpl-2.0.html
+
+Alternatively, redistribution and use in source and binary forms, with or
+without modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright
+notice, this 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 HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(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 __AL_HAL_UNIT_ADAPTER_REGS_H__
+#define __AL_HAL_UNIT_ADAPTER_REGS_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define AL_PCI_COMMAND 0x04 /* 16 bits */
+#define AL_PCI_COMMAND_IO 0x1 /* Enable response in I/O space */
+#define AL_PCI_COMMAND_MEMORY 0x2 /* Enable response in Memory space */
+#define AL_PCI_COMMAND_MASTER 0x4 /* Enable bus mastering */
+
+#define PCI_CLASS_REVISION 0x08 /* High 24 bits are class, low 8 revision */
+
+#define AL_PCI_BASE_ADDRESS_SPACE_IO 0x01
+#define AL_PCI_BASE_ADDRESS_MEM_TYPE_64 0x04 /* 64 bit address */
+#define AL_PCI_BASE_ADDRESS_MEM_PREFETCH 0x08 /* prefetchable? */
+#define AL_PCI_BASE_ADDRESS_DEVICE_ID 0x0c
+
+#define AL_PCI_BASE_ADDRESS_0 0x10
+#define AL_PCI_BASE_ADDRESS_0_HI 0x14
+#define AL_PCI_BASE_ADDRESS_2 0x18
+#define AL_PCI_BASE_ADDRESS_2_HI 0x1c
+#define AL_PCI_BASE_ADDRESS_4 0x20
+#define AL_PCI_BASE_ADDRESS_4_HI 0x24
+
+#define AL_PCI_EXP_ROM_BASE_ADDRESS 0x30
+
+#define AL_PCI_AXI_CFG_AND_CTR_0 0x110
+#define AL_PCI_AXI_CFG_AND_CTR_1 0x130
+#define AL_PCI_AXI_CFG_AND_CTR_2 0x150
+#define AL_PCI_AXI_CFG_AND_CTR_3 0x170
+
+#define AL_PCI_APP_CONTROL 0x220
+
+#define AL_PCI_SRIOV_TOTAL_AND_INITIAL_VFS 0x30c
+
+#define AL_PCI_VF_BASE_ADDRESS_0 0x324
+
+
+#define AL_PCI_EXP_CAP_BASE 0x40
+#define AL_PCI_EXP_DEVCAP 4 /* Device capabilities */
+#define AL_PCI_EXP_DEVCAP_PAYLOAD 0x07 /* Max_Payload_Size */
+#define AL_PCI_EXP_DEVCAP_PHANTOM 0x18 /* Phantom functions */
+#define AL_PCI_EXP_DEVCAP_EXT_TAG 0x20 /* Extended tags */
+#define AL_PCI_EXP_DEVCAP_L0S 0x1c0 /* L0s Acceptable Latency */
+#define AL_PCI_EXP_DEVCAP_L1 0xe00 /* L1 Acceptable Latency */
+#define AL_PCI_EXP_DEVCAP_ATN_BUT 0x1000 /* Attention Button Present */
+#define AL_PCI_EXP_DEVCAP_ATN_IND 0x2000 /* Attention Indicator Present */
+#define AL_PCI_EXP_DEVCAP_PWR_IND 0x4000 /* Power Indicator Present */
+#define AL_PCI_EXP_DEVCAP_RBER 0x8000 /* Role-Based Error Reporting */
+#define AL_PCI_EXP_DEVCAP_PWR_VAL 0x3fc0000 /* Slot Power Limit Value */
+#define AL_PCI_EXP_DEVCAP_PWR_SCL 0xc000000 /* Slot Power Limit Scale */
+#define AL_PCI_EXP_DEVCAP_FLR 0x10000000 /* Function Level Reset */
+#define AL_PCI_EXP_DEVCTL 8 /* Device Control */
+#define AL_PCI_EXP_DEVCTL_CERE 0x0001 /* Correctable Error Reporting En. */
+#define AL_PCI_EXP_DEVCTL_NFERE 0x0002 /* Non-Fatal Error Reporting Enable */
+#define AL_PCI_EXP_DEVCTL_FERE 0x0004 /* Fatal Error Reporting Enable */
+#define AL_PCI_EXP_DEVCTL_URRE 0x0008 /* Unsupported Request Reporting En. */
+#define AL_PCI_EXP_DEVCTL_RELAX_EN 0x0010 /* Enable relaxed ordering */
+#define AL_PCI_EXP_DEVCTL_PAYLOAD 0x00e0 /* Max_Payload_Size */
+#define AL_PCI_EXP_DEVCTL_EXT_TAG 0x0100 /* Extended Tag Field Enable */
+#define AL_PCI_EXP_DEVCTL_PHANTOM 0x0200 /* Phantom Functions Enable */
+#define AL_PCI_EXP_DEVCTL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */
+#define AL_PCI_EXP_DEVCTL_NOSNOOP_EN 0x0800 /* Enable No Snoop */
+#define AL_PCI_EXP_DEVCTL_READRQ 0x7000 /* Max_Read_Request_Size */
+#define AL_PCI_EXP_DEVCTL_BCR_FLR 0x8000 /* Bridge Configuration Retry / FLR */
+#define AL_PCI_EXP_DEVSTA 0xA /* Device Status */
+#define AL_PCI_EXP_DEVSTA_CED 0x01 /* Correctable Error Detected */
+#define AL_PCI_EXP_DEVSTA_NFED 0x02 /* Non-Fatal Error Detected */
+#define AL_PCI_EXP_DEVSTA_FED 0x04 /* Fatal Error Detected */
+#define AL_PCI_EXP_DEVSTA_URD 0x08 /* Unsupported Request Detected */
+#define AL_PCI_EXP_DEVSTA_AUXPD 0x10 /* AUX Power Detected */
+#define AL_PCI_EXP_DEVSTA_TRPND 0x20 /* Transactions Pending */
+#define AL_PCI_EXP_LNKCAP 0xC /* Link Capabilities */
+#define AL_PCI_EXP_LNKCAP_SLS 0xf /* Supported Link Speeds */
+#define AL_PCI_EXP_LNKCAP_SLS_2_5GB 0x1 /* LNKCAP2 SLS Vector bit 0 (2.5GT/s) */
+#define AL_PCI_EXP_LNKCAP_SLS_5_0GB 0x2 /* LNKCAP2 SLS Vector bit 1 (5.0GT/s) */
+#define AL_PCI_EXP_LNKCAP_MLW 0x3f0 /* Maximum Link Width */
+#define AL_PCI_EXP_LNKCAP_ASPMS 0xc00 /* ASPM Support */
+#define AL_PCI_EXP_LNKCAP_L0SEL 0x7000 /* L0s Exit Latency */
+#define AL_PCI_EXP_LNKCAP_L1EL 0x38000 /* L1 Exit Latency */
+#define AL_PCI_EXP_LNKCAP_CLKPM 0x40000 /* L1 Clock Power Management */
+#define AL_PCI_EXP_LNKCAP_SDERC 0x80000 /* Surprise Down Error Reporting Capable */
+#define AL_PCI_EXP_LNKCAP_DLLLARC 0x100000 /* Data Link Layer Link Active Reporting Capable */
+#define AL_PCI_EXP_LNKCAP_LBNC 0x200000 /* Link Bandwidth Notification Capability */
+#define AL_PCI_EXP_LNKCAP_PN 0xff000000 /* Port Number */
+
+#define AL_PCI_EXP_LNKCTL 0x10 /* Link Control */
+#define AL_PCI_EXP_LNKCTL_LNK_DIS 0x4 /* Link Disable Status */
+#define AL_PCI_EXP_LNKCTL_LNK_RTRN 0x5 /* Link Retrain Status */
+
+#define AL_PCI_EXP_LNKSTA 0x12 /* Link Status */
+#define AL_PCI_EXP_LNKSTA_CLS 0x000f /* Current Link Speed */
+#define AL_PCI_EXP_LNKSTA_CLS_2_5GB 0x01 /* Current Link Speed 2.5GT/s */
+#define AL_PCI_EXP_LNKSTA_CLS_5_0GB 0x02 /* Current Link Speed 5.0GT/s */
+#define AL_PCI_EXP_LNKSTA_CLS_8_0GB 0x03 /* Current Link Speed 8.0GT/s */
+#define AL_PCI_EXP_LNKSTA_NLW 0x03f0 /* Nogotiated Link Width */
+#define AL_PCI_EXP_LNKSTA_NLW_SHIFT 4 /* start of NLW mask in link status */
+#define AL_PCI_EXP_LNKSTA_LT 0x0800 /* Link Training */
+#define AL_PCI_EXP_LNKSTA_SLC 0x1000 /* Slot Clock Configuration */
+#define AL_PCI_EXP_LNKSTA_DLLLA 0x2000 /* Data Link Layer Link Active */
+#define AL_PCI_EXP_LNKSTA_LBMS 0x4000 /* Link Bandwidth Management Status */
+#define AL_PCI_EXP_LNKSTA_LABS 0x8000 /* Link Autonomous Bandwidth Status */
+
+#define AL_PCI_EXP_LNKCTL2 0x30 /* Link Control 2 */
+
+#define AL_PCI_MSIX_MSGCTRL 0 /* MSIX message control reg */
+#define AL_PCI_MSIX_MSGCTRL_TBL_SIZE 0x7ff /* MSIX table size */
+#define AL_PCI_MSIX_MSGCTRL_TBL_SIZE_SHIFT 16 /* MSIX table size shift */
+#define AL_PCI_MSIX_MSGCTRL_EN 0x80000000 /* MSIX enable */
+#define AL_PCI_MSIX_MSGCTRL_MASK 0x40000000 /* MSIX mask */
+
+#define AL_PCI_MSIX_TABLE 0x4 /* MSIX table offset and bar reg */
+#define AL_PCI_MSIX_TABLE_OFFSET 0xfffffff8 /* MSIX table offset */
+#define AL_PCI_MSIX_TABLE_BAR 0x7 /* MSIX table BAR */
+
+#define AL_PCI_MSIX_PBA 0x8 /* MSIX pba offset and bar reg */
+#define AL_PCI_MSIX_PBA_OFFSET 0xfffffff8 /* MSIX pba offset */
+#define AL_PCI_MSIX_PBA_BAR 0x7 /* MSIX pba BAR */
+
+
+/* Adapter power management register 0 */
+#define AL_ADAPTER_PM_0 0x80
+#define AL_ADAPTER_PM_0_PM_NEXT_CAP_MASK 0xff00
+#define AL_ADAPTER_PM_0_PM_NEXT_CAP_SHIFT 8
+#define AL_ADAPTER_PM_0_PM_NEXT_CAP_VAL_MSIX 0x90
+
+/* Adapter power management register 1 */
+#define AL_ADAPTER_PM_1 0x84
+#define AL_ADAPTER_PM_1_PME_EN 0x100 /* PM enable */
+#define AL_ADAPTER_PM_1_PWR_STATE_MASK 0x3 /* PM state mask */
+#define AL_ADAPTER_PM_1_PWR_STATE_D3 0x3 /* PM D3 state */
+
+/* Sub Master Configuration & Control */
+#define AL_ADAPTER_SMCC 0x110
+#define AL_ADAPTER_SMCC_CONF_2 0x114
+
+/* Interrupt_Cause register */
+#define AL_ADAPTER_INT_CAUSE 0x1B0
+#define AL_ADAPTER_INT_CAUSE_WR_ERR AL_BIT(1)
+#define AL_ADAPTER_INT_CAUSE_RD_ERR AL_BIT(0)
+
+/* AXI_Master_Write_Error_Attribute_Latch register */
+/* AXI_Master_Read_Error_Attribute_Latch register */
+#define AL_ADAPTER_AXI_MSTR_WR_ERR_ATTR 0x1B4
+#define AL_ADAPTER_AXI_MSTR_RD_ERR_ATTR 0x1B8
+
+#define AL_ADAPTER_AXI_MSTR_RD_WR_ERR_ATTR_COMP_STAT_MASK AL_FIELD_MASK(1, 0)
+#define AL_ADAPTER_AXI_MSTR_RD_WR_ERR_ATTR_COMP_STAT_SHIFT 0
+#define AL_ADAPTER_AXI_MSTR_RD_WR_ERR_ATTR_MSTR_ID_MASK AL_FIELD_MASK(4, 2)
+#define AL_ADAPTER_AXI_MSTR_RD_WR_ERR_ATTR_MSTR_ID_SHIFT 2
+#define AL_ADAPTER_AXI_MSTR_RD_WR_ERR_ATTR_ADDR_TO AL_BIT(8)
+#define AL_ADAPTER_AXI_MSTR_RD_WR_ERR_ATTR_COMP_ERR AL_BIT(9)
+#define AL_ADAPTER_AXI_MSTR_RD_WR_ERR_ATTR_COMP_TO AL_BIT(10)
+#define AL_ADAPTER_AXI_MSTR_RD_WR_ERR_ATTR_ERR_BLK AL_BIT(11)
+#define AL_ADAPTER_AXI_MSTR_RD_ERR_ATTR_RD_PARITY_ERR AL_BIT(12)
+
+/* Interrupt_Cause_mask register */
+#define AL_ADAPTER_INT_CAUSE_MASK 0x1BC
+#define AL_ADAPTER_INT_CAUSE_MASK_WR_ERR AL_BIT(1)
+#define AL_ADAPTER_INT_CAUSE_MASK_RD_ERR AL_BIT(0)
+
+/* AXI_Master_write_error_address_Latch register */
+#define AL_ADAPTER_AXI_MSTR_WR_ERR_LO_LATCH 0x1C0
+
+/* AXI_Master_write_error_address_high_Latch register */
+#define AL_ADAPTER_AXI_MSTR_WR_ERR_HI_LATCH 0x1C4
+
+/* AXI_Master_read_error_address_Latch register */
+#define AL_ADAPTER_AXI_MSTR_RD_ERR_LO_LATCH 0x1C8
+
+/* AXI_Master_read_error_address_high_Latch register */
+#define AL_ADAPTER_AXI_MSTR_RD_ERR_HI_LATCH 0x1CC
+
+/* AXI_Master_Timeout register */
+#define AL_ADAPTER_AXI_MSTR_TO 0x1D0
+#define AL_ADAPTER_AXI_MSTR_TO_WR_MASK AL_FIELD_MASK(31, 16)
+#define AL_ADAPTER_AXI_MSTR_TO_WR_SHIFT 16
+#define AL_ADAPTER_AXI_MSTR_TO_RD_MASK AL_FIELD_MASK(15, 0)
+#define AL_ADAPTER_AXI_MSTR_TO_RD_SHIFT 0
+
+/*
+ * Generic control registers
+ */
+
+/* Control 0 */
+#define AL_ADAPTER_GENERIC_CONTROL_0 0x1E0
+/* Control 2 */
+#define AL_ADAPTER_GENERIC_CONTROL_2 0x1E8
+/* Control 3 */
+#define AL_ADAPTER_GENERIC_CONTROL_3 0x1EC
+/* Control 9 */
+#define AL_ADAPTER_GENERIC_CONTROL_9 0x218
+/* Control 10 */
+#define AL_ADAPTER_GENERIC_CONTROL_10 0x21C
+/* Control 11 */
+#define AL_ADAPTER_GENERIC_CONTROL_11 0x220
+/* Control 12 */
+#define AL_ADAPTER_GENERIC_CONTROL_12 0x224
+/* Control 13 */
+#define AL_ADAPTER_GENERIC_CONTROL_13 0x228
+/* Control 14 */
+#define AL_ADAPTER_GENERIC_CONTROL_14 0x22C
+/* Control 15 */
+#define AL_ADAPTER_GENERIC_CONTROL_15 0x230
+/* Control 16 */
+#define AL_ADAPTER_GENERIC_CONTROL_16 0x234
+/* Control 17 */
+#define AL_ADAPTER_GENERIC_CONTROL_17 0x238
+/* Control 18 */
+#define AL_ADAPTER_GENERIC_CONTROL_18 0x23C
+/* Control 19 */
+#define AL_ADAPTER_GENERIC_CONTROL_19 0x240
+
+/* Enable clock gating */
+#define AL_ADAPTER_GENERIC_CONTROL_0_CLK_GATE_EN 0x01
+/* When set, all transactions through the PCI conf & mem BARs get timeout */
+#define AL_ADAPTER_GENERIC_CONTROL_0_ADAPTER_DIS 0x40
+#define AL_ADAPTER_GENERIC_CONTROL_0_ETH_RESET_1GMAC AL_BIT(18)
+#define AL_ADAPTER_GENERIC_CONTROL_0_ETH_RESET_1GMAC_ON_FLR AL_BIT(26)
+
+/*
+ * SATA registers only
+ */
+/* Select 125MHz free running clock from IOFAB main PLL as SATA OOB clock
+ * instead of using power management ref clock
+ */
+#define AL_ADAPTER_GENERIC_CONTROL_10_SATA_OOB_CLK_SEL AL_BIT(26)
+/* AXUSER selection and value per bit (1 = address, 0 = register) */
+/* Rx */
+#define AL_ADPTR_GEN_CTL_12_SATA_AWUSER_VAL_MASK AL_FIELD_MASK(15, 0)
+#define AL_ADPTR_GEN_CTL_12_SATA_AWUSER_VAL_SHIFT 0
+#define AL_ADPTR_GEN_CTL_12_SATA_AWUSER_SEL_MASK AL_FIELD_MASK(31, 16)
+#define AL_ADPTR_GEN_CTL_12_SATA_AWUSER_SEL_SHIFT 16
+/* Tx */
+#define AL_ADPTR_GEN_CTL_13_SATA_ARUSER_VAL_MASK AL_FIELD_MASK(15, 0)
+#define AL_ADPTR_GEN_CTL_13_SATA_ARUSER_VAL_SHIFT 0
+#define AL_ADPTR_GEN_CTL_13_SATA_ARUSER_SEL_MASK AL_FIELD_MASK(31, 16)
+#define AL_ADPTR_GEN_CTL_13_SATA_ARUSER_SEL_SHIFT 16
+/* Central VMID enabler. If set, then each entry will be used as programmed */
+#define AL_ADPTR_GEN_CTL_14_SATA_MSIX_VMID_SEL AL_BIT(0)
+/* Allow access to store VMID values per entry */
+#define AL_ADPTR_GEN_CTL_14_SATA_MSIX_VMID_ACCESS_EN AL_BIT(1)
+/* VMID Address select */
+/* Tx */
+#define AL_ADPTR_GEN_CTL_14_SATA_VM_ARADDR_SEL_MASK AL_FIELD_MASK(13, 8)
+#define AL_ADPTR_GEN_CTL_14_SATA_VM_ARADDR_SEL_SHIFT 8
+/* Rx */
+#define AL_ADPTR_GEN_CTL_14_SATA_VM_AWADDR_SEL_MASK AL_FIELD_MASK(21, 16)
+#define AL_ADPTR_GEN_CTL_14_SATA_VM_AWADDR_SEL_SHIFT 16
+/* Address Value */
+/* Rx */
+#define AL_ADPTR_GEN_CTL_15_SATA_VM_AWDDR_HI AL_FIELD_MASK(31, 0)
+/* Tx */
+#define AL_ADPTR_GEN_CTL_16_SATA_VM_ARDDR_HI AL_FIELD_MASK(31, 0)
+
+/*
+ * ROB registers
+ */
+/* Read ROB_Enable, when disabled the read ROB is bypassed */
+#define AL_ADPTR_GEN_CTL_19_READ_ROB_EN AL_BIT(0)
+/* Read force in-order of every read transaction */
+#define AL_ADPTR_GEN_CTL_19_READ_ROB_FORCE_INORDER AL_BIT(1)
+/* Read software reset */
+#define AL_ADPTR_GEN_CTL_19_READ_ROB_SW_RESET AL_BIT(15)
+/* Write ROB_Enable, when disabled_the_Write ROB is bypassed */
+#define AL_ADPTR_GEN_CTL_19_WRITE_ROB_EN AL_BIT(16)
+/* Write force in-order of every write transaction */
+#define AL_ADPTR_GEN_CTL_19_WRITE_ROB_FORCE_INORDER AL_BIT(17)
+/* Write software reset */
+#define AL_ADPTR_GEN_CTL_19_WRITE_ROB_SW_RESET AL_BIT(31)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/sys/arm/annapurna/alpine/std.alpine b/sys/arm/annapurna/alpine/std.alpine
new file mode 100644
index 0000000..b577475
--- /dev/null
+++ b/sys/arm/annapurna/alpine/std.alpine
@@ -0,0 +1,23 @@
+# $FreeBSD$
+
+makeoption ARM_LITTLE_ENDIAN
+
+cpu CPU_CORTEXA
+machine arm armv6
+makeoptions CONF_CFLAGS="-march=armv7a -DAL_HAVE_TYPES"
+
+makeoptions KERNPHYSADDR=0x00200000
+options KERNPHYSADDR=0x00200000
+
+makeoptions KERNVIRTADDR=0xa0200000
+options KERNVIRTADDR=0xa0200000
+
+makeoptions KERNBASE=0xa0000000
+options KERNBASE=0xa0000000
+
+options ARM_L2_PIPT
+
+options IPI_IRQ_START=0
+options IPI_IRQ_END=15
+
+files "../annapurna/alpine/files.alpine"
diff --git a/sys/arm/arm/autoconf.c b/sys/arm/arm/autoconf.c
index 4176398..f18f67d 100644
--- a/sys/arm/arm/autoconf.c
+++ b/sys/arm/arm/autoconf.c
@@ -94,6 +94,7 @@ static void
configure_final(void *dummy)
{
+ enable_interrupts(PSR_I | PSR_F);
cninit_finish();
cold = 0;
}
diff --git a/sys/arm/arm/busdma_machdep-v6.c b/sys/arm/arm/busdma_machdep-v6.c
index ed501c5..7236c5a 100644
--- a/sys/arm/arm/busdma_machdep-v6.c
+++ b/sys/arm/arm/busdma_machdep-v6.c
@@ -1685,8 +1685,8 @@ add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr,
if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) {
/* Page offset needs to be preserved. */
- bpage->vaddr |= vaddr & PAGE_MASK;
- bpage->busaddr |= vaddr & PAGE_MASK;
+ bpage->vaddr |= addr & PAGE_MASK;
+ bpage->busaddr |= addr & PAGE_MASK;
}
bpage->datavaddr = vaddr;
bpage->dataaddr = addr;
diff --git a/sys/arm/arm/busdma_machdep.c b/sys/arm/arm/busdma_machdep.c
index 265292d..acd8f81 100644
--- a/sys/arm/arm/busdma_machdep.c
+++ b/sys/arm/arm/busdma_machdep.c
@@ -1441,8 +1441,8 @@ add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr,
if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) {
/* Page offset needs to be preserved. */
- bpage->vaddr |= vaddr & PAGE_MASK;
- bpage->busaddr |= vaddr & PAGE_MASK;
+ bpage->vaddr |= addr & PAGE_MASK;
+ bpage->busaddr |= addr & PAGE_MASK;
}
bpage->datavaddr = vaddr;
bpage->dataaddr = addr;
diff --git a/sys/arm/arm/cpufunc.c b/sys/arm/arm/cpufunc.c
index a3c8239..f3d9a52 100644
--- a/sys/arm/arm/cpufunc.c
+++ b/sys/arm/arm/cpufunc.c
@@ -99,8 +99,6 @@ u_int arm_cache_level;
u_int arm_cache_type[14];
u_int arm_cache_loc;
-/* 1 == use cpu_sleep(), 0 == don't */
-int cpu_do_powersave;
int ctrl;
#ifdef CPU_ARM9
@@ -675,7 +673,7 @@ struct cpu_functions cortexa_cpufuncs = {
cpufunc_nullop, /* flush_brnchtgt_C */
(void *)cpufunc_nullop, /* flush_brnchtgt_E */
- armv7_sleep, /* sleep */
+ armv7_cpu_sleep, /* sleep */
/* Soft functions */
@@ -838,11 +836,6 @@ set_cpufuncs()
cputype = cpufunc_id();
cputype &= CPU_ID_CPU_MASK;
- /*
- * NOTE: cpu_do_powersave defaults to off. If we encounter a
- * CPU type where we want to use it by default, then we set it.
- */
-
#ifdef CPU_ARM9
if (((cputype & CPU_ID_IMPLEMENTOR_MASK) == CPU_ID_ARM_LTD ||
(cputype & CPU_ID_IMPLEMENTOR_MASK) == CPU_ID_TI) &&
@@ -922,8 +915,6 @@ set_cpufuncs()
get_cachetype_cp15();
pmap_pte_init_mmu_v6();
- /* Use powersave on this CPU. */
- cpu_do_powersave = 1;
goto out;
}
#endif /* CPU_CORTEXA */
@@ -946,9 +937,6 @@ set_cpufuncs()
get_cachetype_cp15();
pmap_pte_init_generic();
- /* Use powersave on this CPU. */
- cpu_do_powersave = 1;
-
goto out;
}
#endif /* CPU_FA526 */
@@ -985,9 +973,6 @@ set_cpufuncs()
get_cachetype_cp15();
pmap_pte_init_xscale();
- /* Use powersave on this CPU. */
- cpu_do_powersave = 1;
-
goto out;
}
#endif /* CPU_XSCALE_PXA2X0 */
diff --git a/sys/arm/arm/cpufunc_asm_armv7.S b/sys/arm/arm/cpufunc_asm_armv7.S
index 25f052f..1e7d7e2 100644
--- a/sys/arm/arm/cpufunc_asm_armv7.S
+++ b/sys/arm/arm/cpufunc_asm_armv7.S
@@ -266,6 +266,9 @@ END(armv7_icache_sync_all)
ENTRY_NP(armv7_icache_sync_range)
ldr ip, .Larmv7_icache_line_size
ldr ip, [ip]
+ sub r3, ip, #1 /* Address need not be aligned, but */
+ and r2, r0, r3 /* round length up if op spans line */
+ add r1, r1, r2 /* boundary: len += addr & linemask; */
.Larmv7_sync_next:
mcr CP15_DCCMVAC(r0)
mcr CP15_ICIMVAU(r0)
@@ -363,9 +366,3 @@ ENTRY(armv7_idcache_inv_all)
bx lr @ return
END(armv7_idcache_inv_all)
-ENTRY_NP(armv7_sleep)
- dsb
- wfi
- bx lr
-END(armv7_sleep)
-
diff --git a/sys/arm/arm/cpuinfo.c b/sys/arm/arm/cpuinfo.c
index 4617003..d989906 100644
--- a/sys/arm/arm/cpuinfo.c
+++ b/sys/arm/arm/cpuinfo.c
@@ -131,8 +131,17 @@ cpuinfo_init(void)
cpuinfo.security_ext = (cpuinfo.id_pfr1 >> 4) & 0xF;
/* L1 Cache sizes */
- cpuinfo.dcache_line_size = 1 << (CPU_CT_DMINLINE(cpuinfo.ctr ) + 2);
+ if (CPU_CT_FORMAT(cpuinfo.ctr) == CPU_CT_ARMV7) {
+ cpuinfo.dcache_line_size =
+ 1 << (CPU_CT_DMINLINE(cpuinfo.ctr) + 2);
+ cpuinfo.icache_line_size =
+ 1 << (CPU_CT_IMINLINE(cpuinfo.ctr) + 2);
+ } else {
+ cpuinfo.dcache_line_size =
+ 1 << (CPU_CT_xSIZE_LEN(CPU_CT_DSIZE(cpuinfo.ctr)) + 3);
+ cpuinfo.icache_line_size =
+ 1 << (CPU_CT_xSIZE_LEN(CPU_CT_ISIZE(cpuinfo.ctr)) + 3);
+ }
cpuinfo.dcache_line_mask = cpuinfo.dcache_line_size - 1;
- cpuinfo.icache_line_size= 1 << (CPU_CT_IMINLINE(cpuinfo.ctr ) + 2);
cpuinfo.icache_line_mask = cpuinfo.icache_line_size - 1;
}
diff --git a/sys/arm/arm/db_disasm.c b/sys/arm/arm/db_disasm.c
index d7581fd..2eabf38 100644
--- a/sys/arm/arm/db_disasm.c
+++ b/sys/arm/arm/db_disasm.c
@@ -70,7 +70,7 @@ db_disasm_printaddr(u_int address)
}
vm_offset_t
-db_disasm(vm_offset_t loc, boolean_t altfmt)
+db_disasm(vm_offset_t loc, bool altfmt)
{
return disasm(&db_disasm_interface, loc, altfmt);
diff --git a/sys/arm/arm/elf_machdep.c b/sys/arm/arm/elf_machdep.c
index 9085d67..598decc 100644
--- a/sys/arm/arm/elf_machdep.c
+++ b/sys/arm/arm/elf_machdep.c
@@ -105,7 +105,6 @@ elf32_arm_abi_supported(struct image_params *imgp)
{
const Elf_Ehdr *hdr = (const Elf_Ehdr *)imgp->image_header;
-#ifdef __ARM_EABI__
/*
* When configured for EABI, FreeBSD supports EABI vesions 4 and 5.
*/
@@ -115,17 +114,6 @@ elf32_arm_abi_supported(struct image_params *imgp)
EF_ARM_EABI_VERSION(hdr->e_flags), imgp->args->fname);
return (FALSE);
}
-#else
- /*
- * When configured for OABI, that's all we do, so reject EABI binaries.
- */
- if (EF_ARM_EABI_VERSION(hdr->e_flags) != EF_ARM_EABI_VERSION_UNKNOWN) {
- if (bootverbose)
- uprintf("Attempting to execute EABI binary (rev %d) image %s",
- EF_ARM_EABI_VERSION(hdr->e_flags), imgp->args->fname);
- return (FALSE);
- }
-#endif
return (TRUE);
}
diff --git a/sys/arm/arm/exception.S b/sys/arm/arm/exception.S
index 6b856fc..b85dcfc 100644
--- a/sys/arm/arm/exception.S
+++ b/sys/arm/arm/exception.S
@@ -364,7 +364,6 @@ END(data_abort_entry)
* on exit (without transitioning back through the undefined mode stack).
*/
ASENTRY_NP(undefined_entry)
- sub lr, lr, #4 /* Adjust the lr. Transition to scv32 */
PUSHFRAMEINSVC /* mode stack, build trapframe there. */
adr lr, exception_exit /* Return from handler via standard */
mov r0, sp /* exception exit routine. Pass the */
diff --git a/sys/arm/arm/fusu.S b/sys/arm/arm/fusu.S
index dec49ed..ab7fb58 100644
--- a/sys/arm/arm/fusu.S
+++ b/sys/arm/arm/fusu.S
@@ -33,6 +33,7 @@
*
*/
+#include <machine/acle-compat.h>
#include <machine/asm.h>
#include <machine/armreg.h>
#include "assym.s"
@@ -40,7 +41,7 @@ __FBSDID("$FreeBSD$");
.syntax unified
-#ifdef _ARM_ARCH_6
+#if __ARM_ARCH >= 6
#define GET_PCB(tmp) \
mrc p15, 0, tmp, c13, c0, 4; \
add tmp, tmp, #(TD_PCB)
@@ -68,7 +69,7 @@ EENTRY_NP(casuword32)
stmfd sp!, {r4, r5}
adr r4, .Lcasuwordfault
str r4, [r3, #PCB_ONFAULT]
-#ifdef _ARM_ARCH_6
+#if __ARM_ARCH >= 6
1:
cmp r0, #KERNBASE
mvnhs r0, #0
diff --git a/sys/arm/arm/generic_timer.c b/sys/arm/arm/generic_timer.c
index d246a87..56db9ca 100644
--- a/sys/arm/arm/generic_timer.c
+++ b/sys/arm/arm/generic_timer.c
@@ -31,7 +31,7 @@
*/
/**
- * Cortex-A15 (and probably A7) Generic Timer
+ * Cortex-A7, Cortex-A15, ARMv8 and later Generic Timer
*/
#include <sys/cdefs.h>
diff --git a/sys/arm/arm/intr.c b/sys/arm/arm/intr.c
index be8e87c..9505915 100644
--- a/sys/arm/arm/intr.c
+++ b/sys/arm/arm/intr.c
@@ -78,7 +78,7 @@ int (*arm_config_irq)(int irq, enum intr_trigger trig,
/* Data for statistics reporting. */
u_long intrcnt[NIRQ];
-char intrnames[NIRQ * INTRNAME_LEN];
+char intrnames[(NIRQ * INTRNAME_LEN) + 1];
size_t sintrcnt = sizeof(intrcnt);
size_t sintrnames = sizeof(intrnames);
diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c
index 68d31a9..01e8fe3 100644
--- a/sys/arm/arm/machdep.c
+++ b/sys/arm/arm/machdep.c
@@ -87,6 +87,7 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_page.h>
#include <vm/vm_pager.h>
+#include <machine/acle-compat.h>
#include <machine/armreg.h>
#include <machine/atags.h>
#include <machine/cpu.h>
@@ -114,7 +115,57 @@ __FBSDID("$FreeBSD$");
#ifdef DDB
#include <ddb/ddb.h>
-#endif
+
+#if __ARM_ARCH >= 6
+#include <machine/cpu-v6.h>
+
+DB_SHOW_COMMAND(cp15, db_show_cp15)
+{
+ u_int reg;
+
+ reg = cp15_midr_get();
+ db_printf("Cpu ID: 0x%08x\n", reg);
+ reg = cp15_ctr_get();
+ db_printf("Current Cache Lvl ID: 0x%08x\n",reg);
+
+ reg = cp15_sctlr_get();
+ db_printf("Ctrl: 0x%08x\n",reg);
+ reg = cp15_actlr_get();
+ db_printf("Aux Ctrl: 0x%08x\n",reg);
+
+ reg = cp15_id_pfr0_get();
+ db_printf("Processor Feat 0: 0x%08x\n", reg);
+ reg = cp15_id_pfr1_get();
+ db_printf("Processor Feat 1: 0x%08x\n", reg);
+ reg = cp15_id_dfr0_get();
+ db_printf("Debug Feat 0: 0x%08x\n", reg);
+ reg = cp15_id_afr0_get();
+ db_printf("Auxiliary Feat 0: 0x%08x\n", reg);
+ reg = cp15_id_mmfr0_get();
+ db_printf("Memory Model Feat 0: 0x%08x\n", reg);
+ reg = cp15_id_mmfr1_get();
+ db_printf("Memory Model Feat 1: 0x%08x\n", reg);
+ reg = cp15_id_mmfr2_get();
+ db_printf("Memory Model Feat 2: 0x%08x\n", reg);
+ reg = cp15_id_mmfr3_get();
+ db_printf("Memory Model Feat 3: 0x%08x\n", reg);
+ reg = cp15_ttbr_get();
+ db_printf("TTB0: 0x%08x\n", reg);
+}
+
+DB_SHOW_COMMAND(vtop, db_show_vtop)
+{
+ u_int reg;
+
+ if (have_addr) {
+ cp15_ats1cpr_set(addr);
+ reg = cp15_par_get();
+ db_printf("Physical address reg: 0x%08x\n",reg);
+ } else
+ db_printf("show vtop <virt_addr>\n");
+}
+#endif /* __ARM_ARCH >= 6 */
+#endif /* DDB */
#ifdef DEBUG
#define debugf(fmt, args...) printf(fmt, ##args)
@@ -287,6 +338,13 @@ sendsig(catcher, ksi, mask)
tf->tf_pc = (register_t)catcher;
tf->tf_usr_sp = (register_t)fp;
tf->tf_usr_lr = (register_t)(PS_STRINGS - *(p->p_sysent->sv_szsigcode));
+ /* Set the mode to enter in the signal handler */
+#if __ARM_ARCH >= 7
+ if ((register_t)catcher & 1)
+ tf->tf_spsr |= PSR_T;
+ else
+ tf->tf_spsr &= ~PSR_T;
+#endif
CTR3(KTR_SIG, "sendsig: return td=%p pc=%#x sp=%#x", td, tf->tf_usr_lr,
tf->tf_usr_sp);
@@ -576,6 +634,10 @@ ptrace_single_step(struct thread *td)
struct proc *p;
int error;
+ /* TODO: This needs to be updated for Thumb-2 */
+ if ((td->td_frame->tf_spsr & PSR_T) != 0)
+ return (EINVAL);
+
KASSERT(td->td_md.md_ptrace_instr == 0,
("Didn't clear single step"));
p = td->td_proc;
@@ -599,6 +661,10 @@ ptrace_clear_single_step(struct thread *td)
{
struct proc *p;
+ /* TODO: This needs to be updated for Thumb-2 */
+ if ((td->td_frame->tf_spsr & PSR_T) != 0)
+ return (EINVAL);
+
if (td->td_md.md_ptrace_instr) {
p = td->td_proc;
PROC_UNLOCK(p);
@@ -953,7 +1019,6 @@ freebsd_parse_boot_param(struct arm_boot_params *abp)
ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t);
db_fetch_ksymtab(ksym_start, ksym_end);
#endif
- preload_addr_relocate = KERNVIRTADDR - abp->abp_physaddr;
return lastaddr;
}
#endif
@@ -1055,7 +1120,6 @@ kenv_next(char *cp)
static void
print_kenv(void)
{
- int len;
char *cp;
debugf("loader passed (static) kenv:\n");
@@ -1065,7 +1129,6 @@ print_kenv(void)
}
debugf(" kern_envp = 0x%08x\n", (uint32_t)kern_envp);
- len = 0;
for (cp = kern_envp; cp != NULL; cp = kenv_next(cp))
debugf(" %x %s\n", (uint32_t)cp, cp);
}
diff --git a/sys/arm/arm/mp_machdep.c b/sys/arm/arm/mp_machdep.c
index 55ba355..88104f0 100644
--- a/sys/arm/arm/mp_machdep.c
+++ b/sys/arm/arm/mp_machdep.c
@@ -185,8 +185,11 @@ init_secondary(int cpu)
atomic_add_rel_32(&mp_naps, 1);
/* Spin until the BSP releases the APs */
- while (!aps_ready)
- ;
+ while (!atomic_load_acq_int(&aps_ready)) {
+#if __ARM_ARCH >= 7
+ __asm __volatile("wfe");
+#endif
+ }
/* Initialize curthread */
KASSERT(PCPU_GET(idlethread) != NULL, ("no idle thread"));
@@ -309,12 +312,6 @@ ipi_handler(void *arg)
CTR1(KTR_SMP, "%s: IPI_TLB", __func__);
cpufuncs.cf_tlb_flushID();
break;
-#ifdef ARM_NEW_PMAP
- case IPI_LAZYPMAP:
- CTR1(KTR_SMP, "%s: IPI_LAZYPMAP", __func__);
- pmap_lazyfix_action();
- break;
-#endif
default:
panic("Unknown IPI 0x%0x on cpu %d", ipi, curcpu);
}
@@ -359,6 +356,10 @@ release_aps(void *dummy __unused)
arm_unmask_irq(i);
}
atomic_store_rel_int(&aps_ready, 1);
+ /* Wake the other threads up */
+#if __ARM_ARCH >= 7
+ armv7_sev();
+#endif
printf("Release APs\n");
diff --git a/sys/arm/arm/pmap-v6-new.c b/sys/arm/arm/pmap-v6-new.c
index 53896d4..8fd6222 100644
--- a/sys/arm/arm/pmap-v6-new.c
+++ b/sys/arm/arm/pmap-v6-new.c
@@ -2166,104 +2166,6 @@ pmap_pinit(pmap_t pmap)
return (1);
}
-#ifdef SMP
-/*
- * Deal with a SMP shootdown of other users of the pmap that we are
- * trying to dispose of. This can be a bit hairy.
- */
-static cpuset_t *lazymask;
-static ttb_entry_t lazyttb;
-static volatile u_int lazywait;
-
-void
-pmap_lazyfix_action(void)
-{
-
-#ifdef COUNT_IPIS
- (*ipi_lazypmap_counts[PCPU_GET(cpuid)])++;
-#endif
- spinlock_enter();
- if (cp15_ttbr_get() == lazyttb) {
- cp15_ttbr_set(curthread->td_pcb->pcb_pagedir);
- }
- CPU_CLR_ATOMIC(PCPU_GET(cpuid), lazymask);
- atomic_store_rel_int(&lazywait, 1);
- spinlock_exit();
-
-}
-
-static void
-pmap_lazyfix_self(u_int cpuid)
-{
-
- spinlock_enter();
- if (cp15_ttbr_get() == lazyttb) {
- cp15_ttbr_set(curthread->td_pcb->pcb_pagedir);
- }
- CPU_CLR_ATOMIC(cpuid, lazymask);
- spinlock_exit();
-}
-
-static void
-pmap_lazyfix(pmap_t pmap)
-{
- cpuset_t mymask, mask;
- u_int cpuid, spins;
- int lsb;
-
- mask = pmap->pm_active;
- while (!CPU_EMPTY(&mask)) {
- spins = 50000000;
-
- /* Find least significant set bit. */
- lsb = CPU_FFS(&mask);
- MPASS(lsb != 0);
- lsb--;
- CPU_SETOF(lsb, &mask);
- mtx_lock_spin(&smp_ipi_mtx);
-
- lazyttb = pmap_ttb_get(pmap);
- cpuid = PCPU_GET(cpuid);
-
- /* Use a cpuset just for having an easy check. */
- CPU_SETOF(cpuid, &mymask);
- if (!CPU_CMP(&mask, &mymask)) {
- lazymask = &pmap->pm_active;
- pmap_lazyfix_self(cpuid);
- } else {
- atomic_store_rel_int((u_int *)&lazymask,
- (u_int)&pmap->pm_active);
- atomic_store_rel_int(&lazywait, 0);
- ipi_selected(mask, IPI_LAZYPMAP);
- while (lazywait == 0) {
- if (--spins == 0)
- break;
- }
- }
- mtx_unlock_spin(&smp_ipi_mtx);
- if (spins == 0)
- printf("%s: spun for 50000000\n", __func__);
- mask = pmap->pm_active;
- }
-}
-#else /* SMP */
-/*
- * Cleaning up on uniprocessor is easy. For various reasons, we're
- * unlikely to have to even execute this code, including the fact
- * that the cleanup is deferred until the parent does a wait(2), which
- * means that another userland process has run.
- */
-static void
-pmap_lazyfix(pmap_t pmap)
-{
-
- if (!CPU_EMPTY(&pmap->pm_active)) {
- cp15_ttbr_set(curthread->td_pcb->pcb_pagedir);
- CPU_ZERO(&pmap->pm_active);
- }
-}
-#endif /* SMP */
-
#ifdef INVARIANTS
static boolean_t
pt2tab_user_is_empty(pt2_entry_t *tab)
@@ -2292,8 +2194,9 @@ pmap_release(pmap_t pmap)
pmap->pm_stats.resident_count));
KASSERT(pt2tab_user_is_empty(pmap->pm_pt2tab),
("%s: has allocated user PT2(s)", __func__));
+ KASSERT(CPU_EMPTY(&pmap->pm_active),
+ ("%s: pmap %p is active on some CPU(s)", __func__, pmap));
- pmap_lazyfix(pmap);
mtx_lock_spin(&allpmaps_lock);
LIST_REMOVE(pmap, pm_list);
mtx_unlock_spin(&allpmaps_lock);
@@ -6094,13 +5997,13 @@ pmap_set_pcb_pagedir(pmap_t pmap, struct pcb *pcb)
/*
- * Clean L1 data cache range on a single page, which is not mapped yet.
+ * Clean L1 data cache range by physical address.
+ * The range must be within a single page.
*/
static void
pmap_dcache_wb_pou(vm_paddr_t pa, vm_size_t size, vm_memattr_t ma)
{
struct sysmaps *sysmaps;
- vm_offset_t va;
KASSERT(((pa & PAGE_MASK) + size) <= PAGE_SIZE,
("%s: not on single page", __func__));
@@ -6111,9 +6014,8 @@ pmap_dcache_wb_pou(vm_paddr_t pa, vm_size_t size, vm_memattr_t ma)
if (*sysmaps->CMAP3)
panic("%s: CMAP3 busy", __func__);
pte2_store(sysmaps->CMAP3, PTE2_KERN_NG(pa, PTE2_AP_KRW, ma));
- va = (vm_offset_t)sysmaps->CADDR3;
- tlb_flush_local(va);
- dcache_wb_pou(va, size);
+ tlb_flush_local((vm_offset_t)sysmaps->CADDR3);
+ dcache_wb_pou((vm_offset_t)sysmaps->CADDR3 + (pa & PAGE_MASK), size);
pte2_clear(sysmaps->CMAP3);
sched_unpin();
mtx_unlock(&sysmaps->lock);
diff --git a/sys/arm/arm/pmap.c b/sys/arm/arm/pmap.c
index e1429a1..55e1aab 100644
--- a/sys/arm/arm/pmap.c
+++ b/sys/arm/arm/pmap.c
@@ -4310,7 +4310,13 @@ pmap_copy_page(vm_page_t src, vm_page_t dst)
pmap_copy_page_func(VM_PAGE_TO_PHYS(src), VM_PAGE_TO_PHYS(dst));
}
-int unmapped_buf_allowed = 1;
+/*
+ * We have code to do unmapped I/O. However, it isn't quite right and
+ * causes un-page-aligned I/O to devices to fail (most notably newfs
+ * or fsck). We give up a little performance to not allow unmapped I/O
+ * to gain stability.
+ */
+int unmapped_buf_allowed = 0;
void
pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
diff --git a/sys/arm/arm/pmu.c b/sys/arm/arm/pmu.c
index c224525..1b079c0 100644
--- a/sys/arm/arm/pmu.c
+++ b/sys/arm/arm/pmu.c
@@ -58,13 +58,16 @@ __FBSDID("$FreeBSD$");
#include <machine/cpu.h>
#include <machine/intr.h>
+#define MAX_RLEN 8
+
struct pmu_softc {
- struct resource *res[1];
+ struct resource *res[MAX_RLEN];
device_t dev;
- void *ih;
+ void *ih[MAX_RLEN];
};
static struct ofw_compat_data compat_data[] = {
+ {"arm,armv8-pmuv3", 1},
{"arm,cortex-a17-pmu", 1},
{"arm,cortex-a15-pmu", 1},
{"arm,cortex-a12-pmu", 1},
@@ -81,6 +84,13 @@ static struct ofw_compat_data compat_data[] = {
static struct resource_spec pmu_spec[] = {
{ SYS_RES_IRQ, 0, RF_ACTIVE },
+ { SYS_RES_IRQ, 1, RF_ACTIVE | RF_OPTIONAL },
+ { SYS_RES_IRQ, 2, RF_ACTIVE | RF_OPTIONAL },
+ { SYS_RES_IRQ, 3, RF_ACTIVE | RF_OPTIONAL },
+ { SYS_RES_IRQ, 4, RF_ACTIVE | RF_OPTIONAL },
+ { SYS_RES_IRQ, 5, RF_ACTIVE | RF_OPTIONAL },
+ { SYS_RES_IRQ, 6, RF_ACTIVE | RF_OPTIONAL },
+ { SYS_RES_IRQ, 7, RF_ACTIVE | RF_OPTIONAL },
{ -1, 0 }
};
@@ -119,6 +129,7 @@ pmu_attach(device_t dev)
{
struct pmu_softc *sc;
int err;
+ int i;
sc = device_get_softc(dev);
sc->dev = dev;
@@ -129,11 +140,16 @@ pmu_attach(device_t dev)
}
/* Setup interrupt handler */
- err = bus_setup_intr(dev, sc->res[0], INTR_MPSAFE | INTR_TYPE_MISC,
- pmu_intr, NULL, NULL, &sc->ih);
- if (err) {
- device_printf(dev, "Unable to setup interrupt handler.\n");
- return (ENXIO);
+ for (i = 0; i < MAX_RLEN; i++) {
+ if (sc->res[i] == NULL)
+ break;
+
+ err = bus_setup_intr(dev, sc->res[i], INTR_MPSAFE | INTR_TYPE_MISC,
+ pmu_intr, NULL, NULL, &sc->ih[i]);
+ if (err) {
+ device_printf(dev, "Unable to setup interrupt handler.\n");
+ return (ENXIO);
+ }
}
return (0);
diff --git a/sys/arm/arm/stdatomic.c b/sys/arm/arm/stdatomic.c
index c12a4ab..211f26a 100644
--- a/sys/arm/arm/stdatomic.c
+++ b/sys/arm/arm/stdatomic.c
@@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
#include <sys/stdatomic.h>
#include <sys/types.h>
+#include <machine/acle-compat.h>
#include <machine/cpufunc.h>
#include <machine/sysarch.h>
@@ -66,16 +67,14 @@ do_sync(void)
__asm volatile ("" : : : "memory");
}
-#elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__)
+#elif __ARM_ARCH >= 7
static inline void
do_sync(void)
{
__asm volatile ("dmb" : : : "memory");
}
-#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
- defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || \
- defined(__ARM_ARCH_6ZK__)
+#elif __ARM_ARCH >= 6
static inline void
do_sync(void)
{
@@ -90,14 +89,8 @@ do_sync(void)
* New C11 __atomic_* API.
*/
-#if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
- defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || \
- defined(__ARM_ARCH_6ZK__) || \
- defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__)
-
-/* These systems should be supported by the compiler. */
-
-#else /* __ARM_ARCH_5__ */
+/* ARMv6+ systems should be supported by the compiler. */
+#if __ARM_ARCH <= 5
/* Clang doesn't allow us to reimplement builtins without this. */
#ifdef __clang__
@@ -331,7 +324,7 @@ EMIT_ALL_OPS_N(4, uint32_t, "ldr", "str", "streq")
#endif /* _KERNEL */
-#endif
+#endif /* __ARM_ARCH */
#endif /* __CLANG_ATOMICS || __GNUC_ATOMICS */
@@ -365,10 +358,7 @@ EMIT_ALL_OPS_N(4, uint32_t, "ldr", "str", "streq")
* Old __sync_* API.
*/
-#if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
- defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || \
- defined(__ARM_ARCH_6ZK__) || \
- defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__)
+#if __ARM_ARCH >= 6
/* Implementations for old GCC versions, lacking support for atomics. */
@@ -686,7 +676,7 @@ __strong_reference(__sync_fetch_and_xor_2_c, __sync_fetch_and_xor_2);
__strong_reference(__sync_fetch_and_xor_4_c, __sync_fetch_and_xor_4);
#endif
-#else /* __ARM_ARCH_5__ */
+#else /* __ARM_ARCH < 6 */
#ifdef _KERNEL
@@ -881,7 +871,7 @@ __strong_reference(__sync_fetch_and_or_4_c, __sync_fetch_and_or_4);
__strong_reference(__sync_fetch_and_xor_1_c, __sync_fetch_and_xor_1);
__strong_reference(__sync_fetch_and_xor_2_c, __sync_fetch_and_xor_2);
__strong_reference(__sync_fetch_and_xor_4_c, __sync_fetch_and_xor_4);
-#endif
+#endif /* __ARM_ARCH */
#endif /* _KERNEL */
diff --git a/sys/arm/arm/swtch.S b/sys/arm/arm/swtch.S
index 0a0e97e..4773557 100644
--- a/sys/arm/arm/swtch.S
+++ b/sys/arm/arm/swtch.S
@@ -81,6 +81,7 @@
#include "assym.s"
#include "opt_sched.h"
+#include <machine/acle-compat.h>
#include <machine/asm.h>
#include <machine/asmacros.h>
#include <machine/armreg.h>
@@ -88,7 +89,7 @@
__FBSDID("$FreeBSD$");
-#if defined(_ARM_ARCH_6) && defined(SMP)
+#if __ARM_ARCH >= 6 && defined(SMP)
#define GET_PCPU(tmp, tmp2) \
mrc p15, 0, tmp, c0, c0, 5; \
and tmp, tmp, #0xf; \
@@ -623,14 +624,6 @@ ENTRY(cpu_switch)
cmp r0, r1 /* Switching to the TTB? */
beq sw0 /* same TTB, skip */
-#if 1 /* Lazy context switch */
- /* Don't switch mapping for kernel threads */
- ldr r1, =pmap_kern_ttb
- ldr r1, [r1] /* r1 = kernel TTB */
- cmp r0, r1 /* Switching to kernel TTB? */
- beq sw0 /* kernel TTB, skip */
-#endif
-
#ifdef INVARIANTS
cmp r0, #0 /* new thread? */
beq badsw4 /* no, panic */
diff --git a/sys/arm/arm/syscall.c b/sys/arm/arm/syscall.c
index 9a82b59..061fda4f 100644
--- a/sys/arm/arm/syscall.c
+++ b/sys/arm/arm/syscall.c
@@ -171,16 +171,7 @@ swi_handler(struct trapframe *frame)
td->td_frame = frame;
td->td_pticks = 0;
- /*
- * Make sure the program counter is correctly aligned so we
- * don't take an alignment fault trying to read the opcode.
- * XXX: Fix for Thumb mode
- */
- if (__predict_false(((frame->tf_pc - INSN_SIZE) & 3) != 0)) {
- call_trapsignal(td, SIGILL, 0);
- userret(td, frame);
- return;
- }
+
/*
* Enable interrupts if they were enabled before the exception.
* Since all syscalls *should* come from user mode it will always
diff --git a/sys/arm/arm/undefined.c b/sys/arm/arm/undefined.c
index 0980018..3b32bc3 100644
--- a/sys/arm/arm/undefined.c
+++ b/sys/arm/arm/undefined.c
@@ -86,6 +86,19 @@ __FBSDID("$FreeBSD$");
#include <machine/db_machdep.h>
#endif
+#define ARM_COPROC_INSN(insn) (((insn) & (1 << 27)) != 0)
+#define ARM_VFP_INSN(insn) ((((insn) & 0xfe000000) == 0xf2000000) || \
+ (((insn) & 0xff100000) == 0xf4000000))
+#define ARM_COPROC(insn) (((insn) >> 8) & 0xf)
+
+#define THUMB_32BIT_INSN(insn) ((insn) >= 0xe800)
+#define THUMB_COPROC_INSN(insn) (((insn) & (3 << 26)) == (3 << 26))
+#define THUMB_COPROC_UNDEFINED(insn) (((insn) & 0x3e << 20) == 0)
+#define THUMB_VFP_INSN(insn) (((insn) & (3 << 24)) == (3 << 24))
+#define THUMB_COPROC(insn) (((insn) >> 8) & 0xf)
+
+#define COPROC_VFP 10
+
#ifdef KDTRACE_HOOKS
int (*dtrace_invop_jump_addr)(struct trapframe *);
#endif
@@ -179,6 +192,7 @@ undefinedinstruction(struct trapframe *frame)
int fault_code;
int coprocessor;
struct undefined_handler *uh;
+ int error;
#ifdef VERBOSE_ARM32
int s;
#endif
@@ -192,6 +206,12 @@ undefinedinstruction(struct trapframe *frame)
PCPU_INC(cnt.v_trap);
+#if __ARM_ARCH >= 7
+ if ((frame->tf_spsr & PSR_T) != 0)
+ frame->tf_pc -= THUMB_INSN_SIZE;
+ else
+#endif
+ frame->tf_pc -= INSN_SIZE;
fault_pc = frame->tf_pc;
/*
@@ -200,11 +220,72 @@ undefinedinstruction(struct trapframe *frame)
*/
td = curthread == NULL ? &thread0 : curthread;
- /*
- * Make sure the program counter is correctly aligned so we
- * don't take an alignment fault trying to read the opcode.
- */
- if (__predict_false((fault_pc & 3) != 0)) {
+ coprocessor = 0;
+ if ((frame->tf_spsr & PSR_T) == 0) {
+ /*
+ * Make sure the program counter is correctly aligned so we
+ * don't take an alignment fault trying to read the opcode.
+ */
+ if (__predict_false((fault_pc & 3) != 0)) {
+ ksiginfo_init_trap(&ksi);
+ ksi.ksi_signo = SIGILL;
+ ksi.ksi_code = ILL_ILLADR;
+ ksi.ksi_addr = (u_int32_t *)(intptr_t) fault_pc;
+ trapsignal(td, &ksi);
+ userret(td, frame);
+ return;
+ }
+
+ /*
+ * Should use fuword() here .. but in the interests of
+ * squeezing every bit of speed we will just use ReadWord().
+ * We know the instruction can be read as was just executed
+ * so this will never fail unless the kernel is screwed up
+ * in which case it does not really matter does it ?
+ */
+
+ fault_instruction = *(u_int32_t *)fault_pc;
+
+ /* Check for coprocessor instruction */
+
+ /*
+ * According to the datasheets you only need to look at bit
+ * 27 of the instruction to tell the difference between and
+ * undefined instruction and a coprocessor instruction
+ * following an undefined instruction trap.
+ */
+
+ if (ARM_COPROC_INSN(fault_instruction))
+ coprocessor = ARM_COPROC(fault_instruction);
+ else { /* check for special instructions */
+ if (ARM_VFP_INSN(fault_instruction))
+ coprocessor = COPROC_VFP; /* vfp / simd */
+ }
+ } else {
+#if __ARM_ARCH >= 7
+ fault_instruction = *(uint16_t *)fault_pc;
+ if (THUMB_32BIT_INSN(fault_instruction)) {
+ fault_instruction <<= 16;
+ fault_instruction |= *(uint16_t *)(fault_pc + 2);
+
+ /*
+ * Is it a Coprocessor, Advanced SIMD, or
+ * Floating-point instruction.
+ */
+ if (THUMB_COPROC_INSN(fault_instruction)) {
+ if (THUMB_COPROC_UNDEFINED(fault_instruction)) {
+ /* undefined insn */
+ } else if (THUMB_VFP_INSN(fault_instruction))
+ coprocessor = COPROC_VFP;
+ else
+ coprocessor =
+ THUMB_COPROC(fault_instruction);
+ }
+ }
+#else
+ /*
+ * No support for Thumb-2 on this cpu
+ */
ksiginfo_init_trap(&ksi);
ksi.ksi_signo = SIGILL;
ksi.ksi_code = ILL_ILLADR;
@@ -212,41 +293,8 @@ undefinedinstruction(struct trapframe *frame)
trapsignal(td, &ksi);
userret(td, frame);
return;
- }
-
- /*
- * Should use fuword() here .. but in the interests of squeezing every
- * bit of speed we will just use ReadWord(). We know the instruction
- * can be read as was just executed so this will never fail unless the
- * kernel is screwed up in which case it does not really matter does
- * it ?
- */
-
- fault_instruction = *(u_int32_t *)fault_pc;
-
- /* Update vmmeter statistics */
-#if 0
- uvmexp.traps++;
#endif
- /* Check for coprocessor instruction */
-
- /*
- * According to the datasheets you only need to look at bit 27 of the
- * instruction to tell the difference between and undefined
- * instruction and a coprocessor instruction following an undefined
- * instruction trap.
- */
-
- coprocessor = 0;
- if ((fault_instruction & (1 << 27)) != 0)
- coprocessor = (fault_instruction >> 8) & 0x0f;
-#ifdef VFP
- else { /* check for special instructions */
- if (((fault_instruction & 0xfe000000) == 0xf2000000) ||
- ((fault_instruction & 0xff100000) == 0xf4000000))
- coprocessor = 10; /* vfp / simd */
}
-#endif /* VFP */
if ((frame->tf_spsr & PSR_MODE) == PSR_USR32_MODE) {
/*
@@ -264,13 +312,24 @@ undefinedinstruction(struct trapframe *frame)
fault_code) == 0)
break;
- if (fault_code & FAULT_USER && fault_instruction == PTRACE_BREAKPOINT) {
- PROC_LOCK(td->td_proc);
- _PHOLD(td->td_proc);
- ptrace_clear_single_step(td);
- _PRELE(td->td_proc);
- PROC_UNLOCK(td->td_proc);
- return;
+ if (fault_code & FAULT_USER) {
+ /* TODO: No support for ptrace from Thumb-2 */
+ if ((frame->tf_spsr & PSR_T) == 0 &&
+ fault_instruction == PTRACE_BREAKPOINT) {
+ PROC_LOCK(td->td_proc);
+ _PHOLD(td->td_proc);
+ error = ptrace_clear_single_step(td);
+ _PRELE(td->td_proc);
+ PROC_UNLOCK(td->td_proc);
+ if (error != 0) {
+ ksiginfo_init_trap(&ksi);
+ ksi.ksi_signo = SIGILL;
+ ksi.ksi_code = ILL_ILLOPC;
+ ksi.ksi_addr = (u_int32_t *)(intptr_t) fault_pc;
+ trapsignal(td, &ksi);
+ }
+ return;
+ }
}
if (uh == NULL && (fault_code & FAULT_USER)) {
diff --git a/sys/arm/arm/vm_machdep.c b/sys/arm/arm/vm_machdep.c
index 2ab58ea..5e4ee0c 100644
--- a/sys/arm/arm/vm_machdep.c
+++ b/sys/arm/arm/vm_machdep.c
@@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
#include <vm/uma.h>
#include <vm/uma_int.h>
+#include <machine/acle-compat.h>
#include <machine/md_var.h>
#include <machine/vfp.h>
@@ -204,7 +205,12 @@ cpu_set_syscall_retval(struct thread *td, int error)
/*
* Reconstruct the pc to point at the swi.
*/
- frame->tf_pc -= INSN_SIZE;
+#if __ARM_ARCH >= 7
+ if ((frame->tf_spsr & PSR_T) != 0)
+ frame->tf_pc -= THUMB_INSN_SIZE;
+ else
+#endif
+ frame->tf_pc -= INSN_SIZE;
break;
case EJUSTRETURN:
/* nothing to do */
diff --git a/sys/arm/at91/at91_pio.c b/sys/arm/at91/at91_pio.c
index ff36097..0de46c5 100644
--- a/sys/arm/at91/at91_pio.c
+++ b/sys/arm/at91/at91_pio.c
@@ -646,5 +646,9 @@ static driver_t at91_pio_driver = {
sizeof(struct at91_pio_softc),
};
+#ifdef FDT
EARLY_DRIVER_MODULE(at91_pio, at91_pinctrl, at91_pio_driver, at91_pio_devclass,
NULL, NULL, BUS_PASS_INTERRUPT);
+#else
+DRIVER_MODULE(at91_pio, atmelarm, at91_pio_driver, at91_pio_devclass, NULL, NULL);
+#endif
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c b/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c
index 2ea5b49..1466313 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_cpufreq.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (C) 2013-2014 Daisuke Aoyama <aoyama@peach.ne.jp>
+ * Copyright (C) 2013-2015 Daisuke Aoyama <aoyama@peach.ne.jp>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -60,21 +60,28 @@ __FBSDID("$FreeBSD$");
#define DPRINTF(fmt, ...)
#endif
-#define HZ2MHZ(freq) ((freq) / (1000 * 1000))
-#define MHZ2HZ(freq) ((freq) * (1000 * 1000))
-#define OFFSET2MVOLT(val) (1200 + ((val) * 25))
-#define MVOLT2OFFSET(val) (((val) - 1200) / 25)
-
-#define DEFAULT_ARM_FREQUENCY 700
-#define DEFAULT_CORE_FREQUENCY 250
-#define DEFAULT_SDRAM_FREQUENCY 400
-#define DEFAULT_LOWEST_FREQ 300
-#define TRANSITION_LATENCY 1000
-#define MIN_OVER_VOLTAGE -16
-#define MAX_OVER_VOLTAGE 6
-#define MSG_ERROR -999999999
-#define MHZSTEP 100
-#define HZSTEP (MHZ2HZ(MHZSTEP))
+#define HZ2MHZ(freq) ((freq) / (1000 * 1000))
+#define MHZ2HZ(freq) ((freq) * (1000 * 1000))
+
+#ifdef SOC_BCM2836
+#define OFFSET2MVOLT(val) (((val) / 1000))
+#define MVOLT2OFFSET(val) (((val) * 1000))
+#define DEFAULT_ARM_FREQUENCY 600
+#define DEFAULT_LOWEST_FREQ 600
+#else
+#define OFFSET2MVOLT(val) (1200 + ((val) * 25))
+#define MVOLT2OFFSET(val) (((val) - 1200) / 25)
+#define DEFAULT_ARM_FREQUENCY 700
+#define DEFAULT_LOWEST_FREQ 300
+#endif
+#define DEFAULT_CORE_FREQUENCY 250
+#define DEFAULT_SDRAM_FREQUENCY 400
+#define TRANSITION_LATENCY 1000
+#define MIN_OVER_VOLTAGE -16
+#define MAX_OVER_VOLTAGE 6
+#define MSG_ERROR -999999999
+#define MHZSTEP 100
+#define HZSTEP (MHZ2HZ(MHZSTEP))
#define TZ_ZEROC 2732
#define VC_LOCK(sc) do { \
@@ -1418,7 +1425,10 @@ static int
bcm2835_cpufreq_probe(device_t dev)
{
+ if (device_get_unit(dev) != 0)
+ return (ENXIO);
device_set_desc(dev, "CPU Frequency Control");
+
return (0);
}
@@ -1740,6 +1750,23 @@ bcm2835_cpufreq_make_freq_list(device_t dev, struct cf_setting *sets,
if (min_freq > cpufreq_lowest_freq)
min_freq = cpufreq_lowest_freq;
+#ifdef SOC_BCM2836
+ /* XXX RPi2 have only 900/600MHz */
+ idx = 0;
+ volts = sc->min_voltage_core;
+ sets[idx].freq = freq;
+ sets[idx].volts = volts;
+ sets[idx].lat = TRANSITION_LATENCY;
+ sets[idx].dev = dev;
+ idx++;
+ if (freq != min_freq) {
+ sets[idx].freq = min_freq;
+ sets[idx].volts = volts;
+ sets[idx].lat = TRANSITION_LATENCY;
+ sets[idx].dev = dev;
+ idx++;
+ }
+#else
/* from freq to min_freq */
for (idx = 0; idx < *count && freq >= min_freq; idx++) {
if (freq > sc->arm_min_freq)
@@ -1752,7 +1779,8 @@ bcm2835_cpufreq_make_freq_list(device_t dev, struct cf_setting *sets,
sets[idx].dev = dev;
freq -= MHZSTEP;
}
- *count = ++idx;
+#endif
+ *count = idx;
return (0);
}
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_fb.c b/sys/arm/broadcom/bcm2835/bcm2835_fb.c
index 3270da1..6e6cfda 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_fb.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_fb.c
@@ -29,46 +29,27 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/bio.h>
#include <sys/bus.h>
-#include <sys/conf.h>
-#include <sys/endian.h>
+#include <sys/consio.h>
+#include <sys/fbio.h>
+#include <sys/kdb.h>
#include <sys/kernel.h>
-#include <sys/kthread.h>
-#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
-#include <sys/mutex.h>
-#include <sys/queue.h>
-#include <sys/resource.h>
-#include <sys/rman.h>
-#include <sys/time.h>
-#include <sys/timetc.h>
-#include <sys/fbio.h>
-#include <sys/consio.h>
-
-#include <sys/kdb.h>
-#include <machine/bus.h>
-#include <machine/cpu.h>
-#include <machine/cpufunc.h>
-#include <machine/resource.h>
-#include <machine/intr.h>
+#include <vm/vm.h>
+#include <vm/pmap.h>
+#include <dev/fb/fbreg.h>
#include <dev/fdt/fdt_common.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
-
-#include <dev/fb/fbreg.h>
#include <dev/syscons/syscons.h>
-#include <arm/broadcom/bcm2835/bcm2835_mbox.h>
-#include <arm/broadcom/bcm2835/bcm2835_vcbus.h>
+#include <arm/broadcom/bcm2835/bcm2835_mbox_prop.h>
#include "mbox_if.h"
-#define BCMFB_FONT_HEIGHT 16
-
struct argb {
uint8_t a;
uint8_t r;
@@ -101,40 +82,15 @@ static u_char mouse_pointer[16] = {
0x0c, 0x0c, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00
};
-#define FB_WIDTH 640
-#define FB_HEIGHT 480
-#define FB_DEPTH 24
-
-struct bcm_fb_config {
- uint32_t xres;
- uint32_t yres;
- uint32_t vxres;
- uint32_t vyres;
- uint32_t pitch;
- uint32_t bpp;
- uint32_t xoffset;
- uint32_t yoffset;
- /* Filled by videocore */
- uint32_t base;
- uint32_t screen_size;
-};
+#define BCMFB_FONT_HEIGHT 16
+#define BCMFB_FONT_WIDTH 8
+#define FB_WIDTH 640
+#define FB_HEIGHT 480
+#define FB_DEPTH 24
struct bcmsc_softc {
- device_t dev;
- struct cdev * cdev;
- struct mtx mtx;
- bus_dma_tag_t dma_tag;
- bus_dmamap_t dma_map;
- struct bcm_fb_config* fb_config;
- bus_addr_t fb_config_phys;
- struct intr_config_hook init_hook;
-
-};
-
-struct video_adapter_softc {
/* Videoadpater part */
video_adapter_t va;
- int console;
intptr_t fb_addr;
intptr_t fb_paddr;
@@ -149,199 +105,75 @@ struct video_adapter_softc {
unsigned int ymargin;
unsigned char *font;
+ int fbswap;
int initialized;
};
-static struct bcmsc_softc *bcmsc_softc;
-static struct video_adapter_softc va_softc;
-
-#define bcm_fb_lock(_sc) mtx_lock(&(_sc)->mtx)
-#define bcm_fb_unlock(_sc) mtx_unlock(&(_sc)->mtx)
-#define bcm_fb_lock_assert(sc) mtx_assert(&(_sc)->mtx, MA_OWNED)
+static struct bcmsc_softc bcmsc;
static int bcm_fb_probe(device_t);
static int bcm_fb_attach(device_t);
-static void bcm_fb_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int err);
static void bcmfb_update_margins(video_adapter_t *adp);
static int bcmfb_configure(int);
-static void
-bcm_fb_init(void *arg)
-{
- struct bcmsc_softc *sc = arg;
- struct video_adapter_softc *va_sc = &va_softc;
- int err;
- volatile struct bcm_fb_config* fb_config = sc->fb_config;
- phandle_t node;
- pcell_t cell;
- device_t mbox;
-
- node = ofw_bus_get_node(sc->dev);
-
- fb_config->xres = 0;
- fb_config->yres = 0;
- fb_config->bpp = 0;
-
- if ((OF_getprop(node, "broadcom,width", &cell, sizeof(cell))) > 0)
- fb_config->xres = (int)fdt32_to_cpu(cell);
- if (fb_config->xres == 0)
- fb_config->xres = FB_WIDTH;
-
- if ((OF_getprop(node, "broadcom,height", &cell, sizeof(cell))) > 0)
- fb_config->yres = (uint32_t)fdt32_to_cpu(cell);
- if (fb_config->yres == 0)
- fb_config->yres = FB_HEIGHT;
-
- if ((OF_getprop(node, "broadcom,depth", &cell, sizeof(cell))) > 0)
- fb_config->bpp = (uint32_t)fdt32_to_cpu(cell);
- if (fb_config->bpp == 0)
- fb_config->bpp = FB_DEPTH;
-
- fb_config->vxres = 0;
- fb_config->vyres = 0;
- fb_config->xoffset = 0;
- fb_config->yoffset = 0;
- fb_config->base = 0;
- fb_config->pitch = 0;
- fb_config->screen_size = 0;
-
- bus_dmamap_sync(sc->dma_tag, sc->dma_map,
- BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
-
- mbox = devclass_get_device(devclass_find("mbox"), 0);
- if (mbox) {
- MBOX_WRITE(mbox, BCM2835_MBOX_CHAN_FB, sc->fb_config_phys);
- MBOX_READ(mbox, BCM2835_MBOX_CHAN_FB, &err);
- }
- bus_dmamap_sync(sc->dma_tag, sc->dma_map,
- BUS_DMASYNC_POSTREAD);
-
- if (fb_config->base != 0) {
- device_printf(sc->dev, "%dx%d(%dx%d@%d,%d) %dbpp\n",
- fb_config->xres, fb_config->yres,
- fb_config->vxres, fb_config->vyres,
- fb_config->xoffset, fb_config->yoffset,
- fb_config->bpp);
-
-
- device_printf(sc->dev, "pitch %d, base 0x%08x, screen_size %d\n",
- fb_config->pitch, fb_config->base,
- fb_config->screen_size);
-
- va_sc->fb_addr = (intptr_t)pmap_mapdev(fb_config->base, fb_config->screen_size);
- va_sc->fb_paddr = fb_config->base;
- va_sc->fb_size = fb_config->screen_size;
- va_sc->depth = fb_config->bpp;
- va_sc->stride = fb_config->pitch;
-
- va_sc->width = fb_config->xres;
- va_sc->height = fb_config->yres;
- bcmfb_update_margins(&va_sc->va);
- }
- else {
- device_printf(sc->dev, "Failed to set framebuffer info\n");
- }
-
- config_intrhook_disestablish(&sc->init_hook);
-}
-
static int
bcm_fb_probe(device_t dev)
{
- int error = 0;
+ int error;
if (!ofw_bus_is_compatible(dev, "broadcom,bcm2835-fb"))
return (ENXIO);
-
device_set_desc(dev, "BCM2835 framebuffer device");
-
error = sc_probe_unit(device_get_unit(dev),
device_get_flags(dev) | SC_AUTODETECT_KBD);
if (error != 0)
return (error);
-
return (BUS_PROBE_DEFAULT);
}
static int
bcm_fb_attach(device_t dev)
{
- struct bcmsc_softc *sc = device_get_softc(dev);
- int dma_size = sizeof(struct bcm_fb_config);
- int err;
-
- if (bcmsc_softc)
- return (ENXIO);
+ struct bcm2835_fb_config fb;
+ struct bcmsc_softc *sc;
- bcmsc_softc = sc;
-
- sc->dev = dev;
- mtx_init(&sc->mtx, "bcm2835fb", "fb", MTX_DEF);
-
- err = bus_dma_tag_create(
- bus_get_dma_tag(sc->dev),
- PAGE_SIZE, 0, /* alignment, boundary */
- BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
- BUS_SPACE_MAXADDR, /* highaddr */
- NULL, NULL, /* filter, filterarg */
- dma_size, 1, /* maxsize, nsegments */
- dma_size, 0, /* maxsegsize, flags */
- NULL, NULL, /* lockfunc, lockarg */
- &sc->dma_tag);
-
- err = bus_dmamem_alloc(sc->dma_tag, (void **)&sc->fb_config,
- 0, &sc->dma_map);
- if (err) {
- device_printf(dev, "cannot allocate framebuffer\n");
- goto fail;
- }
-
- err = bus_dmamap_load(sc->dma_tag, sc->dma_map, sc->fb_config,
- dma_size, bcm_fb_dmamap_cb, &sc->fb_config_phys, BUS_DMA_NOWAIT);
-
- if (err) {
- device_printf(dev, "cannot load DMA map\n");
- goto fail;
- }
+ sc = (struct bcmsc_softc *)vid_get_adapter(vid_find_adapter(
+ "bcmfb", 0));
+ if (sc != NULL)
+ device_set_softc(dev, sc);
+ else
+ sc = device_get_softc(dev);
- err = (sc_attach_unit(device_get_unit(dev),
- device_get_flags(dev) | SC_AUTODETECT_KBD));
+ memset(&fb, 0, sizeof(fb));
+ if (bcm2835_mbox_fb_get_w_h(dev, &fb) != 0)
+ return (ENXIO);
+ fb.bpp = FB_DEPTH;
+ if (bcm2835_mbox_fb_init(dev, &fb) != 0)
+ return (ENXIO);
- if (err) {
+ sc->fb_addr = (intptr_t)pmap_mapdev(fb.base, fb.size);
+ sc->fb_paddr = fb.base;
+ sc->fb_size = fb.size;
+ sc->depth = fb.bpp;
+ sc->stride = fb.pitch;
+ sc->width = fb.xres;
+ sc->height = fb.yres;
+ bcmfb_update_margins(&sc->va);
+
+ if (sc_attach_unit(device_get_unit(dev),
+ device_get_flags(dev) | SC_AUTODETECT_KBD) != 0) {
device_printf(dev, "failed to attach syscons\n");
- goto fail;
+ return (ENXIO);
}
- /*
- * We have to wait until interrupts are enabled.
- * Mailbox relies on it to get data from VideoCore
- */
- sc->init_hook.ich_func = bcm_fb_init;
- sc->init_hook.ich_arg = sc;
-
- if (config_intrhook_establish(&sc->init_hook) != 0) {
- device_printf(dev, "failed to establish intrhook\n");
- return (ENOMEM);
- }
+ device_printf(dev, "%dx%d(%dx%d@%d,%d) %dbpp\n", fb.xres, fb.yres,
+ fb.vxres, fb.vyres, fb.xoffset, fb.yoffset, fb.bpp);
+ device_printf(dev,
+ "fbswap: %d, pitch %d, base 0x%08x, screen_size %d\n",
+ sc->fbswap, fb.pitch, fb.base, fb.size);
return (0);
-
-fail:
- return (ENXIO);
-}
-
-
-static void
-bcm_fb_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int err)
-{
- bus_addr_t *addr;
-
- if (err)
- return;
-
- addr = (bus_addr_t*)arg;
- *addr = PHYS_TO_VCBUS(segs[0].ds_addr);
}
static device_method_t bcm_fb_methods[] = {
@@ -504,13 +336,13 @@ bcmrend_set_cursor(scr_stat* scp, int base, int height, int blink)
static void
bcmrend_draw_cursor(scr_stat* scp, int off, int blink, int on, int flip)
{
- video_adapter_t* adp = scp->sc->adp;
- struct video_adapter_softc *sc;
- int row, col;
+ int bytes, col, i, j, row;
+ struct bcmsc_softc *sc;
uint8_t *addr;
- int i, j, bytes;
+ video_adapter_t *adp;
- sc = (struct video_adapter_softc *)adp;
+ adp = scp->sc->adp;
+ sc = (struct bcmsc_softc *)adp;
if (scp->curs_attr.height <= 0)
return;
@@ -529,8 +361,7 @@ bcmrend_draw_cursor(scr_stat* scp, int off, int blink, int on, int flip)
+ (row + sc->ymargin)*(sc->stride)
+ (sc->depth/8) * (col + sc->xmargin);
- bytes = sc->depth/8;
-
+ bytes = sc->depth / 8;
/* our cursor consists of simply inverting the char under it */
for (i = 0; i < adp->va_info.vi_cheight; i++) {
for (j = 0; j < adp->va_info.vi_cwidth; j++) {
@@ -577,56 +408,80 @@ extern u_char dflt_font_16[];
static void
bcmfb_update_margins(video_adapter_t *adp)
{
- struct video_adapter_softc *sc;
+ struct bcmsc_softc *sc;
video_info_t *vi;
- sc = (struct video_adapter_softc *)adp;
+ sc = (struct bcmsc_softc *)adp;
vi = &adp->va_info;
sc->xmargin = (sc->width - (vi->vi_width * vi->vi_cwidth)) / 2;
- sc->ymargin = (sc->height - (vi->vi_height * vi->vi_cheight))/2;
+ sc->ymargin = (sc->height - (vi->vi_height * vi->vi_cheight)) / 2;
}
static int
bcmfb_configure(int flags)
{
- struct video_adapter_softc *va_sc;
-
- va_sc = &va_softc;
- phandle_t display, root;
+ char bootargs[2048], *n, *p, *v;
pcell_t cell;
+ phandle_t chosen, display, root;
+ struct bcmsc_softc *sc;
- if (va_sc->initialized)
+ sc = &bcmsc;
+ if (sc->initialized)
return (0);
- va_sc->width = 0;
- va_sc->height = 0;
+ sc->width = 0;
+ sc->height = 0;
/*
* It seems there is no way to let syscons framework know
* that framebuffer resolution has changed. So just try
- * to fetch data from FDT and go with defaults if failed
+ * to fetch data from FDT bootargs, FDT display data and
+ * finally go with defaults if everything else has failed.
*/
+ chosen = OF_finddevice("/chosen");
+ if (chosen != 0 &&
+ OF_getprop(chosen, "bootargs", &bootargs, sizeof(bootargs)) > 0) {
+ p = bootargs;
+ while ((v = strsep(&p, " ")) != NULL) {
+ if (*v == '\0')
+ continue;
+ n = strsep(&v, "=");
+ if (strcmp(n, "bcm2708_fb.fbwidth") == 0 && v != NULL)
+ sc->width = (unsigned int)strtol(v, NULL, 0);
+ else if (strcmp(n, "bcm2708_fb.fbheight") == 0 &&
+ v != NULL)
+ sc->height = (unsigned int)strtol(v, NULL, 0);
+ else if (strcmp(n, "bcm2708_fb.fbswap") == 0 &&
+ v != NULL)
+ if (*v == '1')
+ sc->fbswap = 1;
+ }
+ }
+
root = OF_finddevice("/");
if ((root != 0) &&
(display = fdt_find_compatible(root, "broadcom,bcm2835-fb", 1))) {
- if ((OF_getprop(display, "broadcom,width",
- &cell, sizeof(cell))) > 0)
- va_sc->width = (int)fdt32_to_cpu(cell);
+ if (sc->width == 0) {
+ if ((OF_getprop(display, "broadcom,width",
+ &cell, sizeof(cell))) > 0)
+ sc->width = (int)fdt32_to_cpu(cell);
+ }
- if ((OF_getprop(display, "broadcom,height",
- &cell, sizeof(cell))) > 0)
- va_sc->height = (int)fdt32_to_cpu(cell);
+ if (sc->height == 0) {
+ if ((OF_getprop(display, "broadcom,height",
+ &cell, sizeof(cell))) > 0)
+ sc->height = (int)fdt32_to_cpu(cell);
+ }
}
- if (va_sc->width == 0)
- va_sc->width = FB_WIDTH;
- if (va_sc->height == 0)
- va_sc->height = FB_HEIGHT;
-
- bcmfb_init(0, &va_sc->va, 0);
+ if (sc->width == 0)
+ sc->width = FB_WIDTH;
+ if (sc->height == 0)
+ sc->height = FB_HEIGHT;
- va_sc->initialized = 1;
+ bcmfb_init(0, &sc->va, 0);
+ sc->initialized = 1;
return (0);
}
@@ -641,20 +496,19 @@ bcmfb_probe(int unit, video_adapter_t **adp, void *arg, int flags)
static int
bcmfb_init(int unit, video_adapter_t *adp, int flags)
{
- struct video_adapter_softc *sc;
+ struct bcmsc_softc *sc;
video_info_t *vi;
- sc = (struct video_adapter_softc *)adp;
+ sc = (struct bcmsc_softc *)adp;
vi = &adp->va_info;
vid_init_struct(adp, "bcmfb", -1, unit);
sc->font = dflt_font_16;
vi->vi_cheight = BCMFB_FONT_HEIGHT;
- vi->vi_cwidth = 8;
-
- vi->vi_width = sc->width/8;
- vi->vi_height = sc->height/vi->vi_cheight;
+ vi->vi_cwidth = BCMFB_FONT_WIDTH;
+ vi->vi_width = sc->width / vi->vi_cwidth;
+ vi->vi_height = sc->height / vi->vi_cheight;
/*
* Clamp width/height to syscons maximums
@@ -665,8 +519,7 @@ bcmfb_init(int unit, video_adapter_t *adp, int flags)
vi->vi_height = ROW;
sc->xmargin = (sc->width - (vi->vi_width * vi->vi_cwidth)) / 2;
- sc->ymargin = (sc->height - (vi->vi_height * vi->vi_cheight))/2;
-
+ sc->ymargin = (sc->height - (vi->vi_height * vi->vi_cheight)) / 2;
adp->va_window = (vm_offset_t) bcmfb_static_window;
adp->va_flags |= V_ADP_FONT /* | V_ADP_COLOR | V_ADP_MODECHANGE */;
@@ -706,8 +559,9 @@ static int
bcmfb_load_font(video_adapter_t *adp, int page, int size, int width,
u_char *data, int c, int count)
{
- struct video_adapter_softc *sc = (struct video_adapter_softc *)adp;
+ struct bcmsc_softc *sc;
+ sc = (struct bcmsc_softc *)adp;
sc->font = data;
return (0);
@@ -780,9 +634,9 @@ static int
bcmfb_blank_display(video_adapter_t *adp, int mode)
{
- struct video_adapter_softc *sc;
+ struct bcmsc_softc *sc;
- sc = (struct video_adapter_softc *)adp;
+ sc = (struct bcmsc_softc *)adp;
if (sc && sc->fb_addr)
memset((void*)sc->fb_addr, 0, sc->fb_size);
@@ -793,9 +647,9 @@ static int
bcmfb_mmap(video_adapter_t *adp, vm_ooffset_t offset, vm_paddr_t *paddr,
int prot, vm_memattr_t *memattr)
{
- struct video_adapter_softc *sc;
+ struct bcmsc_softc *sc;
- sc = (struct video_adapter_softc *)adp;
+ sc = (struct bcmsc_softc *)adp;
/*
* This might be a legacy VGA mem request: if so, just point it at the
@@ -812,10 +666,10 @@ bcmfb_mmap(video_adapter_t *adp, vm_ooffset_t offset, vm_paddr_t *paddr,
static int
bcmfb_ioctl(video_adapter_t *adp, u_long cmd, caddr_t data)
{
- struct video_adapter_softc *sc;
+ struct bcmsc_softc *sc;
struct fbtype *fb;
- sc = (struct video_adapter_softc *)adp;
+ sc = (struct bcmsc_softc *)adp;
switch (cmd) {
case FBIOGTYPE:
@@ -897,16 +751,13 @@ bcmfb_putp(video_adapter_t *adp, vm_offset_t off, uint32_t p, uint32_t a,
static int
bcmfb_putc(video_adapter_t *adp, vm_offset_t off, uint8_t c, uint8_t a)
{
- struct video_adapter_softc *sc;
- int row;
- int col;
- int i, j, k;
- uint8_t *addr;
+ int bytes, col, i, j, k, row;
+ struct bcmsc_softc *sc;
u_char *p;
- uint8_t fg, bg, color;
+ uint8_t *addr, fg, bg, color;
uint16_t rgb;
- sc = (struct video_adapter_softc *)adp;
+ sc = (struct bcmsc_softc *)adp;
if (sc->fb_addr == 0)
return (0);
@@ -921,6 +772,7 @@ bcmfb_putc(video_adapter_t *adp, vm_offset_t off, uint8_t c, uint8_t a)
fg = a & 0xf ;
bg = (a >> 4) & 0xf;
+ bytes = sc->depth / 8;
for (i = 0; i < BCMFB_FONT_HEIGHT; i++) {
for (j = 0, k = 7; j < 8; j++, k--) {
if ((p[i] & (1 << k)) == 0)
@@ -930,22 +782,32 @@ bcmfb_putc(video_adapter_t *adp, vm_offset_t off, uint8_t c, uint8_t a)
switch (sc->depth) {
case 32:
- addr[4*j+0] = bcmfb_palette[color].r;
- addr[4*j+1] = bcmfb_palette[color].g;
- addr[4*j+2] = bcmfb_palette[color].b;
- addr[4*j+3] = bcmfb_palette[color].a;
- break;
case 24:
- addr[3*j] = bcmfb_palette[color].r;
- addr[3*j+1] = bcmfb_palette[color].g;
- addr[3*j+2] = bcmfb_palette[color].b;
+ if (sc->fbswap) {
+ addr[bytes * j + 0] =
+ bcmfb_palette[color].b;
+ addr[bytes * j + 1] =
+ bcmfb_palette[color].g;
+ addr[bytes * j + 2] =
+ bcmfb_palette[color].r;
+ } else {
+ addr[bytes * j + 0] =
+ bcmfb_palette[color].r;
+ addr[bytes * j + 1] =
+ bcmfb_palette[color].g;
+ addr[bytes * j + 2] =
+ bcmfb_palette[color].b;
+ }
+ if (sc->depth == 32)
+ addr[bytes * j + 3] =
+ bcmfb_palette[color].a;
break;
case 16:
rgb = (bcmfb_palette[color].r >> 3) << 11;
rgb |= (bcmfb_palette[color].g >> 2) << 5;
rgb |= (bcmfb_palette[color].b >> 3);
- addr[2*j] = rgb & 0xff;
- addr[2*j + 1] = (rgb >> 8) & 0xff;
+ addr[bytes * j] = rgb & 0xff;
+ addr[bytes * j + 1] = (rgb >> 8) & 0xff;
default:
/* Not supported yet */
break;
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_fbd.c b/sys/arm/broadcom/bcm2835/bcm2835_fbd.c
index f41e6e2..34a7af8 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_fbd.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_fbd.c
@@ -35,170 +35,35 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/bio.h>
#include <sys/bus.h>
-#include <sys/conf.h>
-#include <sys/endian.h>
+#include <sys/fbio.h>
#include <sys/kernel.h>
-#include <sys/kthread.h>
-#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
-#include <sys/mutex.h>
-#include <sys/queue.h>
-#include <sys/resource.h>
-#include <sys/rman.h>
-#include <sys/time.h>
-#include <sys/timetc.h>
-#include <sys/fbio.h>
-#include <sys/consio.h>
-
-#include <sys/kdb.h>
#include <vm/vm.h>
#include <vm/pmap.h>
-#include <machine/bus.h>
-#include <machine/cpu.h>
-#include <machine/cpufunc.h>
-#include <machine/fdt.h>
-#include <machine/resource.h>
-#include <machine/intr.h>
-
#include <dev/fdt/fdt_common.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
#include <dev/fb/fbreg.h>
#include <dev/vt/vt.h>
+#include <dev/vt/colors/vt_termcolors.h>
-#include <arm/broadcom/bcm2835/bcm2835_mbox.h>
-#include <arm/broadcom/bcm2835/bcm2835_vcbus.h>
+#include <arm/broadcom/bcm2835/bcm2835_mbox_prop.h>
#include "fb_if.h"
#include "mbox_if.h"
-#define FB_WIDTH 640
-#define FB_HEIGHT 480
-#define FB_DEPTH 24
-
-struct bcm_fb_config {
- uint32_t xres;
- uint32_t yres;
- uint32_t vxres;
- uint32_t vyres;
- uint32_t pitch;
- uint32_t bpp;
- uint32_t xoffset;
- uint32_t yoffset;
- /* Filled by videocore */
- uint32_t base;
- uint32_t screen_size;
-};
+#define FB_DEPTH 24
struct bcmsc_softc {
- device_t dev;
struct fb_info *info;
- bus_dma_tag_t dma_tag;
- bus_dmamap_t dma_map;
- struct bcm_fb_config* fb_config;
- bus_addr_t fb_config_phys;
- struct intr_config_hook init_hook;
};
static int bcm_fb_probe(device_t);
static int bcm_fb_attach(device_t);
-static void bcm_fb_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg,
- int err);
-
-static void
-bcm_fb_init(void *arg)
-{
- volatile struct bcm_fb_config *fb_config;
- struct bcmsc_softc *sc;
- struct fb_info *info;
- phandle_t node;
- pcell_t cell;
- device_t mbox;
- device_t fbd;
- int err = 0;
-
- sc = arg;
- fb_config = sc->fb_config;
- node = ofw_bus_get_node(sc->dev);
-
- fb_config->xres = 0;
- fb_config->yres = 0;
- fb_config->bpp = 0;
- fb_config->vxres = 0;
- fb_config->vyres = 0;
- fb_config->xoffset = 0;
- fb_config->yoffset = 0;
- fb_config->base = 0;
- fb_config->pitch = 0;
- fb_config->screen_size = 0;
-
- if ((OF_getprop(node, "broadcom,width", &cell, sizeof(cell))) > 0)
- fb_config->xres = (int)fdt32_to_cpu(cell);
- if (fb_config->xres == 0)
- fb_config->xres = FB_WIDTH;
-
- if ((OF_getprop(node, "broadcom,height", &cell, sizeof(cell))) > 0)
- fb_config->yres = (uint32_t)fdt32_to_cpu(cell);
- if (fb_config->yres == 0)
- fb_config->yres = FB_HEIGHT;
-
- if ((OF_getprop(node, "broadcom,depth", &cell, sizeof(cell))) > 0)
- fb_config->bpp = (uint32_t)fdt32_to_cpu(cell);
- if (fb_config->bpp == 0)
- fb_config->bpp = FB_DEPTH;
-
- bus_dmamap_sync(sc->dma_tag, sc->dma_map,
- BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
-
- mbox = devclass_get_device(devclass_find("mbox"), 0);
- if (mbox) {
- MBOX_WRITE(mbox, BCM2835_MBOX_CHAN_FB, sc->fb_config_phys);
- MBOX_READ(mbox, BCM2835_MBOX_CHAN_FB, &err);
- }
- bus_dmamap_sync(sc->dma_tag, sc->dma_map,
- BUS_DMASYNC_POSTREAD);
-
- if (fb_config->base != 0) {
- device_printf(sc->dev, "%dx%d(%dx%d@%d,%d) %dbpp\n",
- fb_config->xres, fb_config->yres,
- fb_config->vxres, fb_config->vyres,
- fb_config->xoffset, fb_config->yoffset,
- fb_config->bpp);
-
- device_printf(sc->dev, "pitch %d, base 0x%08x, screen_size %d\n",
- fb_config->pitch, fb_config->base,
- fb_config->screen_size);
-
- info = malloc(sizeof(struct fb_info), M_DEVBUF,
- M_WAITOK | M_ZERO);
- info->fb_name = device_get_nameunit(sc->dev);
- info->fb_vbase = (intptr_t)pmap_mapdev(fb_config->base,
- fb_config->screen_size);
- info->fb_pbase = fb_config->base;
- info->fb_size = fb_config->screen_size;
- info->fb_bpp = info->fb_depth = fb_config->bpp;
- info->fb_stride = fb_config->pitch;
- info->fb_width = fb_config->xres;
- info->fb_height = fb_config->yres;
-
- sc->info = info;
-
- fbd = device_add_child(sc->dev, "fbd",
- device_get_unit(sc->dev));
- if (fbd == NULL)
- device_printf(sc->dev, "Failed to add fbd child\n");
- else if (device_probe_and_attach(fbd) != 0)
- device_printf(sc->dev, "Failed to attach fbd device\n");
- } else {
- device_printf(sc->dev, "Failed to set framebuffer info\n");
- }
-
- config_intrhook_disestablish(&sc->init_hook);
-}
static int
bcm_fb_probe(device_t dev)
@@ -214,66 +79,82 @@ bcm_fb_probe(device_t dev)
static int
bcm_fb_attach(device_t dev)
{
- struct bcmsc_softc *sc = device_get_softc(dev);
- int dma_size = sizeof(struct bcm_fb_config);
- int err;
-
- sc->dev = dev;
+ char bootargs[2048], *n, *p, *v;
+ device_t fbd;
+ int fbswap;
+ phandle_t chosen;
+ struct bcm2835_fb_config fb;
+ struct bcmsc_softc *sc;
+ struct fb_info *info;
- err = bus_dma_tag_create(
- bus_get_dma_tag(sc->dev),
- PAGE_SIZE, 0, /* alignment, boundary */
- BUS_SPACE_MAXADDR_32BIT, /* lowaddr */
- BUS_SPACE_MAXADDR, /* highaddr */
- NULL, NULL, /* filter, filterarg */
- dma_size, 1, /* maxsize, nsegments */
- dma_size, 0, /* maxsegsize, flags */
- NULL, NULL, /* lockfunc, lockarg */
- &sc->dma_tag);
+ sc = device_get_softc(dev);
+ memset(&fb, 0, sizeof(fb));
+ if (bcm2835_mbox_fb_get_w_h(dev, &fb) != 0)
+ return (ENXIO);
+ fb.bpp = FB_DEPTH;
+ if (bcm2835_mbox_fb_init(dev, &fb) != 0)
+ return (ENXIO);
- err = bus_dmamem_alloc(sc->dma_tag, (void **)&sc->fb_config, 0,
- &sc->dma_map);
- if (err) {
- device_printf(dev, "cannot allocate framebuffer\n");
- goto fail;
+ info = malloc(sizeof(struct fb_info), M_DEVBUF, M_WAITOK | M_ZERO);
+ info->fb_name = device_get_nameunit(dev);
+ info->fb_vbase = (intptr_t)pmap_mapdev(fb.base, fb.size);
+ info->fb_pbase = fb.base;
+ info->fb_size = fb.size;
+ info->fb_bpp = info->fb_depth = fb.bpp;
+ info->fb_stride = fb.pitch;
+ info->fb_width = fb.xres;
+ info->fb_height = fb.yres;
+ sc->info = info;
+
+ /* Newer firmware versions needs an inverted color palette. */
+ fbswap = 0;
+ chosen = OF_finddevice("/chosen");
+ if (chosen != 0 &&
+ OF_getprop(chosen, "bootargs", &bootargs, sizeof(bootargs)) > 0) {
+ p = bootargs;
+ while ((v = strsep(&p, " ")) != NULL) {
+ if (*v == '\0')
+ continue;
+ n = strsep(&v, "=");
+ if (strcmp(n, "bcm2708_fb.fbswap") == 0 && v != NULL)
+ if (*v == '1')
+ fbswap = 1;
+ }
+ }
+ if (fbswap) {
+ switch (info->fb_bpp) {
+ case 24:
+ vt_generate_cons_palette(info->fb_cmap,
+ COLOR_FORMAT_RGB, 0xff, 0, 0xff, 8, 0xff, 16);
+ info->fb_cmsize = 16;
+ break;
+ case 32:
+ vt_generate_cons_palette(info->fb_cmap,
+ COLOR_FORMAT_RGB, 0xff, 16, 0xff, 8, 0xff, 0);
+ info->fb_cmsize = 16;
+ break;
+ }
}
- err = bus_dmamap_load(sc->dma_tag, sc->dma_map, sc->fb_config,
- dma_size, bcm_fb_dmamap_cb, &sc->fb_config_phys, BUS_DMA_NOWAIT);
-
- if (err) {
- device_printf(dev, "cannot load DMA map\n");
- goto fail;
+ fbd = device_add_child(dev, "fbd", device_get_unit(dev));
+ if (fbd == NULL) {
+ device_printf(dev, "Failed to add fbd child\n");
+ free(info, M_DEVBUF);
+ return (ENXIO);
+ } else if (device_probe_and_attach(fbd) != 0) {
+ device_printf(dev, "Failed to attach fbd device\n");
+ device_delete_child(dev, fbd);
+ free(info, M_DEVBUF);
+ return (ENXIO);
}
- /*
- * We have to wait until interrupts are enabled.
- * Mailbox relies on it to get data from VideoCore
- */
- sc->init_hook.ich_func = bcm_fb_init;
- sc->init_hook.ich_arg = sc;
-
- if (config_intrhook_establish(&sc->init_hook) != 0) {
- device_printf(dev, "failed to establish intrhook\n");
- return (ENOMEM);
- }
+ device_printf(dev, "%dx%d(%dx%d@%d,%d) %dbpp\n", fb.xres, fb.yres,
+ fb.vxres, fb.vyres, fb.xoffset, fb.yoffset, fb.bpp);
+ device_printf(dev,
+ "fbswap: %d, pitch %d, base 0x%08x, screen_size %d\n",
+ fbswap, fb.pitch, fb.base, fb.size);
return (0);
-
-fail:
- return (ENXIO);
-}
-
-static void
-bcm_fb_dmamap_cb(void *arg, bus_dma_segment_t *segs, int nseg, int err)
-{
- bus_addr_t *addr;
-
- if (err)
- return;
-
- addr = (bus_addr_t*)arg;
- *addr = PHYS_TO_VCBUS(segs[0].ds_addr);
}
static struct fb_info *
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_mbox.c b/sys/arm/broadcom/bcm2835/bcm2835_mbox.c
index af600ca..5940ad6 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_mbox.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_mbox.c
@@ -318,6 +318,47 @@ bcm2835_mbox_init_dma(device_t dev, size_t len, bus_dma_tag_t *tag,
return (buf);
}
+static int
+bcm2835_mbox_err(device_t dev, bus_addr_t msg_phys, uint32_t resp_phys,
+ struct bcm2835_mbox_hdr *msg, size_t len)
+{
+ int idx;
+ struct bcm2835_mbox_tag_hdr *tag;
+ uint8_t *last;
+
+ if ((uint32_t)msg_phys != resp_phys) {
+ device_printf(dev, "response channel mismatch\n");
+ return (EIO);
+ }
+ if (msg->code != BCM2835_MBOX_CODE_RESP_SUCCESS) {
+ device_printf(dev, "mbox response error\n");
+ return (EIO);
+ }
+
+ /* Loop until the end tag. */
+ tag = (struct bcm2835_mbox_tag_hdr *)(msg + 1);
+ last = (uint8_t *)msg + len;
+ for (idx = 0; tag->tag != 0; idx++) {
+ if ((tag->val_len & BCM2835_MBOX_TAG_VAL_LEN_RESPONSE) == 0) {
+ device_printf(dev, "tag %d response error\n", idx);
+ return (EIO);
+ }
+ /* Clear the response bit. */
+ tag->val_len &= ~BCM2835_MBOX_TAG_VAL_LEN_RESPONSE;
+
+ /* Next tag. */
+ tag = (struct bcm2835_mbox_tag_hdr *)((uint8_t *)tag +
+ sizeof(*tag) + tag->val_buf_size);
+
+ if ((uint8_t *)tag > last) {
+ device_printf(dev, "mbox buffer size error\n");
+ return (EIO);
+ }
+ }
+
+ return (0);
+}
+
int
bcm2835_mbox_set_power_state(device_t dev, uint32_t device_id, boolean_t on)
{
@@ -413,3 +454,136 @@ bcm2835_mbox_get_clock_rate(device_t dev, uint32_t clock_id, uint32_t *hz)
return (0);
}
+
+int
+bcm2835_mbox_fb_get_w_h(device_t dev, struct bcm2835_fb_config *fb)
+{
+ device_t mbox;
+ int err;
+ bus_dma_tag_t msg_tag;
+ bus_dmamap_t msg_map;
+ bus_addr_t msg_phys;
+ struct msg_fb_get_w_h *msg;
+ uint32_t reg;
+
+ /* get mbox device */
+ mbox = devclass_get_device(devclass_find("mbox"), 0);
+ if (mbox == NULL) {
+ device_printf(dev, "can't find mbox\n");
+ return (ENXIO);
+ }
+
+ /* Allocate memory for the message */
+ msg = bcm2835_mbox_init_dma(dev, sizeof(*msg), &msg_tag, &msg_map,
+ &msg_phys);
+ if (msg == NULL)
+ return (ENOMEM);
+
+ memset(msg, 0, sizeof(*msg));
+ msg->hdr.buf_size = sizeof(*msg);
+ msg->hdr.code = BCM2835_MBOX_CODE_REQ;
+ BCM2835_MBOX_INIT_TAG(&msg->physical_w_h, GET_PHYSICAL_W_H);
+ msg->physical_w_h.tag_hdr.val_len = 0;
+ BCM2835_MBOX_INIT_TAG(&msg->virtual_w_h, GET_VIRTUAL_W_H);
+ msg->virtual_w_h.tag_hdr.val_len = 0;
+ BCM2835_MBOX_INIT_TAG(&msg->offset, GET_VIRTUAL_OFFSET);
+ msg->offset.tag_hdr.val_len = 0;
+ msg->end_tag = 0;
+
+ bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_PREWRITE);
+ MBOX_WRITE(mbox, BCM2835_MBOX_CHAN_PROP, (uint32_t)msg_phys);
+ bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_POSTWRITE);
+
+ bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_PREREAD);
+ MBOX_READ(mbox, BCM2835_MBOX_CHAN_PROP, &reg);
+ bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_POSTREAD);
+
+ err = bcm2835_mbox_err(dev, msg_phys, reg, &msg->hdr, sizeof(*msg));
+ if (err == 0) {
+ fb->xres = msg->physical_w_h.body.resp.width;
+ fb->yres = msg->physical_w_h.body.resp.height;
+ fb->vxres = msg->virtual_w_h.body.resp.width;
+ fb->vyres = msg->virtual_w_h.body.resp.height;
+ fb->xoffset = msg->offset.body.resp.x;
+ fb->yoffset = msg->offset.body.resp.y;
+ }
+
+ bus_dmamap_unload(msg_tag, msg_map);
+ bus_dmamem_free(msg_tag, msg, msg_map);
+ bus_dma_tag_destroy(msg_tag);
+
+ return (err);
+}
+
+int
+bcm2835_mbox_fb_init(device_t dev, struct bcm2835_fb_config *fb)
+{
+ device_t mbox;
+ int err;
+ bus_dma_tag_t msg_tag;
+ bus_dmamap_t msg_map;
+ bus_addr_t msg_phys;
+ struct msg_fb_setup *msg;
+ uint32_t reg;
+
+ /* get mbox device */
+ mbox = devclass_get_device(devclass_find("mbox"), 0);
+ if (mbox == NULL) {
+ device_printf(dev, "can't find mbox\n");
+ return (ENXIO);
+ }
+
+ /* Allocate memory for the message */
+ msg = bcm2835_mbox_init_dma(dev, sizeof(*msg), &msg_tag, &msg_map,
+ &msg_phys);
+ if (msg == NULL)
+ return (ENOMEM);
+
+ memset(msg, 0, sizeof(*msg));
+ msg->hdr.buf_size = sizeof(*msg);
+ msg->hdr.code = BCM2835_MBOX_CODE_REQ;
+ BCM2835_MBOX_INIT_TAG(&msg->physical_w_h, SET_PHYSICAL_W_H);
+ msg->physical_w_h.body.req.width = fb->xres;
+ msg->physical_w_h.body.req.height = fb->yres;
+ BCM2835_MBOX_INIT_TAG(&msg->virtual_w_h, SET_VIRTUAL_W_H);
+ msg->virtual_w_h.body.req.width = fb->vxres;
+ msg->virtual_w_h.body.req.height = fb->vyres;
+ BCM2835_MBOX_INIT_TAG(&msg->offset, GET_VIRTUAL_OFFSET);
+ msg->offset.body.req.x = fb->xoffset;
+ msg->offset.body.req.y = fb->yoffset;
+ BCM2835_MBOX_INIT_TAG(&msg->depth, SET_DEPTH);
+ msg->depth.body.req.bpp = fb->bpp;
+ BCM2835_MBOX_INIT_TAG(&msg->alpha, SET_ALPHA_MODE);
+ msg->alpha.body.req.alpha = BCM2835_MBOX_ALPHA_MODE_IGNORED;
+ BCM2835_MBOX_INIT_TAG(&msg->buffer, ALLOCATE_BUFFER);
+ msg->buffer.body.req.alignment = PAGE_SIZE;
+ BCM2835_MBOX_INIT_TAG(&msg->pitch, GET_PITCH);
+ msg->end_tag = 0;
+
+ bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_PREWRITE);
+ MBOX_WRITE(mbox, BCM2835_MBOX_CHAN_PROP, (uint32_t)msg_phys);
+ bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_POSTWRITE);
+
+ bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_PREREAD);
+ MBOX_READ(mbox, BCM2835_MBOX_CHAN_PROP, &reg);
+ bus_dmamap_sync(msg_tag, msg_map, BUS_DMASYNC_POSTREAD);
+
+ err = bcm2835_mbox_err(dev, msg_phys, reg, &msg->hdr, sizeof(*msg));
+ if (err == 0) {
+ fb->xres = msg->physical_w_h.body.resp.width;
+ fb->yres = msg->physical_w_h.body.resp.height;
+ fb->vxres = msg->virtual_w_h.body.resp.width;
+ fb->vyres = msg->virtual_w_h.body.resp.height;
+ fb->xoffset = msg->offset.body.resp.x;
+ fb->yoffset = msg->offset.body.resp.y;
+ fb->pitch = msg->pitch.body.resp.pitch;
+ fb->base = msg->buffer.body.resp.fb_address;
+ fb->size = msg->buffer.body.resp.fb_size;
+ }
+
+ bus_dmamap_unload(msg_tag, msg_map);
+ bus_dmamem_free(msg_tag, msg, msg_map);
+ bus_dma_tag_destroy(msg_tag);
+
+ return (err);
+}
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_mbox_prop.h b/sys/arm/broadcom/bcm2835/bcm2835_mbox_prop.h
index 76f2a16..a425f2a 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_mbox_prop.h
+++ b/sys/arm/broadcom/bcm2835/bcm2835_mbox_prop.h
@@ -52,6 +52,12 @@ struct bcm2835_mbox_tag_hdr {
uint32_t val_len;
};
+#define BCM2835_MBOX_INIT_TAG(tag_, tagid_) do { \
+ (tag_)->tag_hdr.tag = BCM2835_MBOX_TAG_##tagid_; \
+ (tag_)->tag_hdr.val_buf_size = sizeof((tag_)->body); \
+ (tag_)->tag_hdr.val_len = sizeof((tag_)->body.req); \
+} while (0)
+
#define BCM2835_MBOX_POWER_ID_EMMC 0x00000000
#define BCM2835_MBOX_POWER_ID_UART0 0x00000001
#define BCM2835_MBOX_POWER_ID_UART1 0x00000002
@@ -322,4 +328,151 @@ struct msg_get_max_temperature {
uint32_t end_tag;
};
+#define BCM2835_MBOX_TAG_GET_PHYSICAL_W_H 0x00040003
+#define BCM2835_MBOX_TAG_SET_PHYSICAL_W_H 0x00048003
+#define BCM2835_MBOX_TAG_GET_VIRTUAL_W_H 0x00040004
+#define BCM2835_MBOX_TAG_SET_VIRTUAL_W_H 0x00048004
+
+struct bcm2835_mbox_tag_fb_w_h {
+ struct bcm2835_mbox_tag_hdr tag_hdr;
+ union {
+ struct {
+ uint32_t width;
+ uint32_t height;
+ } req;
+ struct {
+ uint32_t width;
+ uint32_t height;
+ } resp;
+ } body;
+};
+
+#define BCM2835_MBOX_TAG_GET_DEPTH 0x00040005
+#define BCM2835_MBOX_TAG_SET_DEPTH 0x00048005
+
+struct bcm2835_mbox_tag_depth {
+ struct bcm2835_mbox_tag_hdr tag_hdr;
+ union {
+ struct {
+ uint32_t bpp;
+ } req;
+ struct {
+ uint32_t bpp;
+ } resp;
+ } body;
+};
+
+#define BCM2835_MBOX_TAG_GET_ALPHA_MODE 0x00040007
+#define BCM2835_MBOX_TAG_SET_ALPHA_MODE 0x00048007
+
+#define BCM2835_MBOX_ALPHA_MODE_0_OPAQUE 0
+#define BCM2835_MBOX_ALPHA_MODE_0_TRANSPARENT 1
+#define BCM2835_MBOX_ALPHA_MODE_IGNORED 2
+
+struct bcm2835_mbox_tag_alpha_mode {
+ struct bcm2835_mbox_tag_hdr tag_hdr;
+ union {
+ struct {
+ uint32_t alpha;
+ } req;
+ struct {
+ uint32_t alpha;
+ } resp;
+ } body;
+};
+
+#define BCM2835_MBOX_TAG_GET_VIRTUAL_OFFSET 0x00040009
+#define BCM2835_MBOX_TAG_SET_VIRTUAL_OFFSET 0x00048009
+
+struct bcm2835_mbox_tag_virtual_offset {
+ struct bcm2835_mbox_tag_hdr tag_hdr;
+ union {
+ struct {
+ uint32_t x;
+ uint32_t y;
+ } req;
+ struct {
+ uint32_t x;
+ uint32_t y;
+ } resp;
+ } body;
+};
+
+#define BCM2835_MBOX_TAG_GET_PITCH 0x00040008
+
+struct bcm2835_mbox_tag_pitch {
+ struct bcm2835_mbox_tag_hdr tag_hdr;
+ union {
+ struct {
+ } req;
+ struct {
+ uint32_t pitch;
+ } resp;
+ } body;
+};
+
+#define BCM2835_MBOX_TAG_ALLOCATE_BUFFER 0x00040001
+
+struct bcm2835_mbox_tag_allocate_buffer {
+ struct bcm2835_mbox_tag_hdr tag_hdr;
+ union {
+ struct {
+ uint32_t alignment;
+ } req;
+ struct {
+ uint32_t fb_address;
+ uint32_t fb_size;
+ } resp;
+ } body;
+};
+
+#define BCM2835_MBOX_TAG_RELEASE_BUFFER 0x00048001
+
+struct bcm2835_mbox_tag_release_buffer {
+ struct bcm2835_mbox_tag_hdr tag_hdr;
+ union {
+ struct {
+ } req;
+ struct {
+ } resp;
+ } body;
+};
+
+struct bcm2835_fb_config {
+ uint32_t xres;
+ uint32_t yres;
+ uint32_t vxres;
+ uint32_t vyres;
+ uint32_t xoffset;
+ uint32_t yoffset;
+ uint32_t bpp;
+ uint32_t pitch;
+ uint32_t base;
+ uint32_t size;
+};
+
+struct msg_fb_get_w_h {
+ struct bcm2835_mbox_hdr hdr;
+ struct bcm2835_mbox_tag_fb_w_h physical_w_h;
+ struct bcm2835_mbox_tag_fb_w_h virtual_w_h;
+ struct bcm2835_mbox_tag_virtual_offset offset;
+ uint32_t end_tag;
+};
+
+int bcm2835_mbox_fb_get_w_h(device_t, struct bcm2835_fb_config *);
+
+struct msg_fb_setup {
+ struct bcm2835_mbox_hdr hdr;
+ struct bcm2835_mbox_tag_fb_w_h physical_w_h;
+ struct bcm2835_mbox_tag_fb_w_h virtual_w_h;
+ struct bcm2835_mbox_tag_virtual_offset offset;
+ struct bcm2835_mbox_tag_depth depth;
+ struct bcm2835_mbox_tag_alpha_mode alpha;
+ struct bcm2835_mbox_tag_allocate_buffer buffer;
+ struct bcm2835_mbox_tag_pitch pitch;
+ uint32_t end_tag;
+};
+
+int bcm2835_mbox_fb_init(device_t, struct bcm2835_fb_config *);
+
#endif /* _BCM2835_MBOX_PROP_H_ */
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c b/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
index 1024a48..e950ec6 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
@@ -68,15 +68,8 @@ __FBSDID("$FreeBSD$");
#define dprintf(fmt, args...)
#endif
-/* DMA doesn't yet work with the bcm3826 */
-#ifdef SOC_BCM2836
-#define PIO_MODE 1
-#else
-#define PIO_MODE 0
-#endif
-
static int bcm2835_sdhci_hs = 1;
-static int bcm2835_sdhci_pio_mode = PIO_MODE;
+static int bcm2835_sdhci_pio_mode = 0;
TUNABLE_INT("hw.bcm2835.sdhci.hs", &bcm2835_sdhci_hs);
TUNABLE_INT("hw.bcm2835.sdhci.pio_mode", &bcm2835_sdhci_pio_mode);
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h b/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h
index cb871f2..7b79b1a 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h
+++ b/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h
@@ -37,14 +37,20 @@
#define BCM2835_VCBUS_IO_BASE 0x7E000000
#define BCM2835_VCBUS_SDRAM_UNCACHED 0xC0000000
+#ifdef SOC_BCM2836
+#define BCM2835_ARM_IO_BASE 0x3f000000
+#define BCM2835_VCBUS_SDRAM_BASE BCM2835_VCBUS_SDRAM_UNCACHED
+#else
#define BCM2835_ARM_IO_BASE 0x20000000
-#define BCM2835_ARM_IO_SIZE 0x02000000
+#define BCM2835_VCBUS_SDRAM_BASE BCM2835_VCBUS_SDRAM_CACHED
+#endif
+#define BCM2835_ARM_IO_SIZE 0x01000000
/*
* Convert physical address to VC bus address. Should be used
* when submitting address over mailbox interface
*/
-#define PHYS_TO_VCBUS(pa) ((pa) + BCM2835_VCBUS_SDRAM_CACHED)
+#define PHYS_TO_VCBUS(pa) ((pa) + BCM2835_VCBUS_SDRAM_BASE)
/* Check whether pa bellong top IO window */
#define BCM2835_ARM_IS_IO(pa) (((pa) >= BCM2835_ARM_IO_BASE) && \
@@ -61,6 +67,6 @@
* when address is returned by VC over mailbox interface. e.g.
* framebuffer base
*/
-#define VCBUS_TO_PHYS(vca) ((vca) - BCM2835_VCBUS_SDRAM_CACHED)
+#define VCBUS_TO_PHYS(vca) ((vca) - BCM2835_VCBUS_SDRAM_BASE)
#endif /* _BCM2835_VCBUS_H_ */
diff --git a/sys/arm/broadcom/bcm2835/bcm2836.c b/sys/arm/broadcom/bcm2835/bcm2836.c
index 3e89eae..58ad8e4 100644
--- a/sys/arm/broadcom/bcm2835/bcm2836.c
+++ b/sys/arm/broadcom/bcm2835/bcm2836.c
@@ -52,7 +52,9 @@ __FBSDID("$FreeBSD$");
#define ARM_LOCAL_INT_TIMER(n) (0x40 + (n) * 4)
#define ARM_LOCAL_INT_MAILBOX(n) (0x50 + (n) * 4)
#define ARM_LOCAL_INT_PENDING(n) (0x60 + (n) * 4)
-#define INT_PENDING_MASK 0x0f
+#define INT_PENDING_MASK 0x01f
+#define MAILBOX0_IRQ 4
+#define MAILBOX0_IRQEN (1 << 0)
/*
* A driver for features of the bcm2836.
@@ -141,12 +143,27 @@ void
bcm2836_mask_irq(uintptr_t irq)
{
uint32_t reg;
+#ifdef SMP
+ int cpu;
+#endif
int i;
- for (i = 0; i < 4; i++) {
- reg = bus_read_4(softc->sc_mem, ARM_LOCAL_INT_TIMER(i));
- reg &= ~(1 << irq);
- bus_write_4(softc->sc_mem, ARM_LOCAL_INT_TIMER(i), reg);
+ if (irq < MAILBOX0_IRQ) {
+ for (i = 0; i < 4; i++) {
+ reg = bus_read_4(softc->sc_mem,
+ ARM_LOCAL_INT_TIMER(i));
+ reg &= ~(1 << irq);
+ bus_write_4(softc->sc_mem,
+ ARM_LOCAL_INT_TIMER(i), reg);
+ }
+#ifdef SMP
+ } else if (irq == MAILBOX0_IRQ) {
+ /* Mailbox 0 for IPI */
+ cpu = PCPU_GET(cpuid);
+ reg = bus_read_4(softc->sc_mem, ARM_LOCAL_INT_MAILBOX(cpu));
+ reg &= ~MAILBOX0_IRQEN;
+ bus_write_4(softc->sc_mem, ARM_LOCAL_INT_MAILBOX(cpu), reg);
+#endif
}
}
@@ -154,12 +171,27 @@ void
bcm2836_unmask_irq(uintptr_t irq)
{
uint32_t reg;
+#ifdef SMP
+ int cpu;
+#endif
int i;
- for (i = 0; i < 4; i++) {
- reg = bus_read_4(softc->sc_mem, ARM_LOCAL_INT_TIMER(i));
- reg |= (1 << irq);
- bus_write_4(softc->sc_mem, ARM_LOCAL_INT_TIMER(i), reg);
+ if (irq < MAILBOX0_IRQ) {
+ for (i = 0; i < 4; i++) {
+ reg = bus_read_4(softc->sc_mem,
+ ARM_LOCAL_INT_TIMER(i));
+ reg |= (1 << irq);
+ bus_write_4(softc->sc_mem,
+ ARM_LOCAL_INT_TIMER(i), reg);
+ }
+#ifdef SMP
+ } else if (irq == MAILBOX0_IRQ) {
+ /* Mailbox 0 for IPI */
+ cpu = PCPU_GET(cpuid);
+ reg = bus_read_4(softc->sc_mem, ARM_LOCAL_INT_MAILBOX(cpu));
+ reg |= MAILBOX0_IRQEN;
+ bus_write_4(softc->sc_mem, ARM_LOCAL_INT_MAILBOX(cpu), reg);
+#endif
}
}
diff --git a/sys/arm/broadcom/bcm2835/bcm2836_mp.c b/sys/arm/broadcom/bcm2835/bcm2836_mp.c
new file mode 100644
index 0000000..717f242
--- /dev/null
+++ b/sys/arm/broadcom/bcm2835/bcm2836_mp.c
@@ -0,0 +1,206 @@
+/*-
+ * Copyright (C) 2015 Daisuke Aoyama <aoyama@peach.ne.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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ *
+ * 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/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/smp.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <machine/smp.h>
+#include <machine/bus.h>
+#include <machine/fdt.h>
+#include <machine/intr.h>
+
+#ifdef DEBUG
+#define DPRINTF(fmt, ...) do { \
+ printf("%s:%u: ", __func__, __LINE__); \
+ printf(fmt, ##__VA_ARGS__); \
+} while (0)
+#else
+#define DPRINTF(fmt, ...)
+#endif
+
+#define ARM_LOCAL_BASE 0x40000000
+#define ARM_LOCAL_SIZE 0x00001000
+
+/* mailbox registers */
+#define MBOXINTRCTRL_CORE(n) (0x00000050 + (0x04 * (n)))
+#define MBOX0SET_CORE(n) (0x00000080 + (0x10 * (n)))
+#define MBOX1SET_CORE(n) (0x00000084 + (0x10 * (n)))
+#define MBOX2SET_CORE(n) (0x00000088 + (0x10 * (n)))
+#define MBOX3SET_CORE(n) (0x0000008C + (0x10 * (n)))
+#define MBOX0CLR_CORE(n) (0x000000C0 + (0x10 * (n)))
+#define MBOX1CLR_CORE(n) (0x000000C4 + (0x10 * (n)))
+#define MBOX2CLR_CORE(n) (0x000000C8 + (0x10 * (n)))
+#define MBOX3CLR_CORE(n) (0x000000CC + (0x10 * (n)))
+
+static bus_space_handle_t bs_periph;
+
+#define BSRD4(addr) \
+ bus_space_read_4(fdtbus_bs_tag, bs_periph, (addr))
+#define BSWR4(addr, val) \
+ bus_space_write_4(fdtbus_bs_tag, bs_periph, (addr), (val))
+
+void
+platform_mp_init_secondary(void)
+{
+
+}
+
+void
+platform_mp_setmaxid(void)
+{
+
+ DPRINTF("platform_mp_setmaxid\n");
+ if (mp_ncpus != 0)
+ return;
+
+ mp_ncpus = 4;
+ mp_maxid = mp_ncpus - 1;
+ DPRINTF("mp_maxid=%d\n", mp_maxid);
+}
+
+int
+platform_mp_probe(void)
+{
+
+ DPRINTF("platform_mp_probe\n");
+ CPU_SETOF(0, &all_cpus);
+ if (mp_ncpus == 0)
+ platform_mp_setmaxid();
+ return (mp_ncpus > 1);
+}
+
+void
+platform_mp_start_ap(void)
+{
+ uint32_t val;
+ int i, retry;
+
+ DPRINTF("platform_mp_start_ap\n");
+
+ /* initialize */
+ if (bus_space_map(fdtbus_bs_tag, ARM_LOCAL_BASE, ARM_LOCAL_SIZE,
+ 0, &bs_periph) != 0)
+ panic("can't map local peripheral\n");
+ for (i = 0; i < mp_ncpus; i++) {
+ /* clear mailbox 0/3 */
+ BSWR4(MBOX0CLR_CORE(i), 0xffffffff);
+ BSWR4(MBOX3CLR_CORE(i), 0xffffffff);
+ }
+ wmb();
+ cpu_idcache_wbinv_all();
+ cpu_l2cache_wbinv_all();
+
+ /* boot secondary CPUs */
+ for (i = 1; i < mp_ncpus; i++) {
+ /* set entry point to mailbox 3 */
+ BSWR4(MBOX3SET_CORE(i),
+ (uint32_t)pmap_kextract((vm_offset_t)mpentry));
+ wmb();
+
+ /* wait for bootup */
+ retry = 1000;
+ do {
+ /* check entry point */
+ val = BSRD4(MBOX3CLR_CORE(i));
+ if (val == 0)
+ break;
+ DELAY(100);
+ retry--;
+ if (retry <= 0) {
+ printf("can't start for CPU%d\n", i);
+ break;
+ }
+ } while (1);
+
+ /* dsb and sev */
+ armv7_sev();
+
+ /* recode AP in CPU map */
+ CPU_SET(i, &all_cpus);
+ }
+}
+
+void
+pic_ipi_send(cpuset_t cpus, u_int ipi)
+{
+ int i;
+
+ dsb();
+ for (i = 0; i < mp_ncpus; i++) {
+ if (CPU_ISSET(i, &cpus))
+ BSWR4(MBOX0SET_CORE(i), 1 << ipi);
+ }
+ wmb();
+}
+
+int
+pic_ipi_read(int i)
+{
+ uint32_t val;
+ int cpu, ipi;
+
+ cpu = PCPU_GET(cpuid);
+ dsb();
+ if (i != -1) {
+ val = BSRD4(MBOX0CLR_CORE(cpu));
+ if (val == 0)
+ return (0);
+ ipi = ffs(val) - 1;
+ return (ipi);
+ }
+ return (0x3ff);
+}
+
+void
+pic_ipi_clear(int ipi)
+{
+ int cpu;
+
+ cpu = PCPU_GET(cpuid);
+ dsb();
+ BSWR4(MBOX0CLR_CORE(cpu), 1 << ipi);
+ wmb();
+}
+
+void
+platform_ipi_send(cpuset_t cpus, u_int ipi)
+{
+
+ pic_ipi_send(cpus, ipi);
+}
diff --git a/sys/arm/broadcom/bcm2835/files.bcm2836 b/sys/arm/broadcom/bcm2835/files.bcm2836
index f797cf7..36f4d24 100644
--- a/sys/arm/broadcom/bcm2835/files.bcm2836
+++ b/sys/arm/broadcom/bcm2835/files.bcm2836
@@ -3,3 +3,4 @@
arm/arm/generic_timer.c standard
arm/broadcom/bcm2835/bcm2836.c standard
+arm/broadcom/bcm2835/bcm2836_mp.c optional smp
diff --git a/sys/arm/broadcom/bcm2835/std.bcm2836 b/sys/arm/broadcom/bcm2835/std.bcm2836
index bb112be..862be75 100644
--- a/sys/arm/broadcom/bcm2835/std.bcm2836
+++ b/sys/arm/broadcom/bcm2835/std.bcm2836
@@ -6,6 +6,7 @@ makeoptions CONF_CFLAGS="-march=armv7a"
options SOC_BCM2836
options ARM_L2_PIPT
+options IPI_IRQ_START=76
files "../broadcom/bcm2835/files.bcm2836"
files "../broadcom/bcm2835/files.bcm283x"
diff --git a/sys/arm/conf/ALPINE b/sys/arm/conf/ALPINE
new file mode 100644
index 0000000..626dcfa
--- /dev/null
+++ b/sys/arm/conf/ALPINE
@@ -0,0 +1,78 @@
+# Kernel configuration for Alpine Board.
+#
+# For more information on this file, please read the config(5) manual page,
+# and/or the handbook section on Kernel Configuration Files:
+#
+# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/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 ../../conf/NOTES and NOTES files.
+# If you are in doubt as to the purpose or necessity of a line, check first
+# in NOTES.
+#
+# $FreeBSD$
+
+ident ALPINE
+
+include "std.armv6"
+include "../annapurna/alpine/std.alpine"
+
+makeoptions MODULES_OVERRIDE=""
+makeoptions WERROR="-Werror"
+
+options HZ=100
+options SCHED_4BSD # 4BSD scheduler
+options SMP # Enable multiple cores
+
+# Debugging
+makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols
+options BREAK_TO_DEBUGGER
+options KDB
+options DDB #Enable the kernel debugger
+
+# Interrupt controller
+device gic
+
+# Pseudo devices
+device loop
+device random
+device pty
+device md
+device gpio
+
+# ATA controllers
+device ahci # AHCI-compatible SATA controllers
+device ata # Legacy ATA/SATA controllers
+options ATA_STATIC_ID # Static device numbering
+
+# ATA/SCSI peripherals
+device scbus # SCSI bus (required for ATA/SCSI)
+device ch # SCSI media changers
+device da # Direct Access (disks)
+device sa # Sequential Access (tape etc)
+device cd # CD
+device pass # Passthrough device (direct ATA/SCSI access)
+device ses # Enclosure Services (SES and SAF-TE)
+#device ctl # CAM Target Layer
+
+# Serial ports
+device uart
+
+# Ethernet
+device ether
+device mii
+device bpf
+options DEVICE_POLLING
+
+# USB ethernet support, requires miibus
+device miibus
+
+#FDT
+options FDT
+options FDT_DTB_STATIC
+makeoptions FDT_DTS_FILE=annapurna-alpine.dts
diff --git a/sys/arm/conf/AML8726 b/sys/arm/conf/AML8726
index 7272db4..693dae5 100644
--- a/sys/arm/conf/AML8726
+++ b/sys/arm/conf/AML8726
@@ -19,44 +19,14 @@
# $FreeBSD$
ident AML8726
+
+include "std.armv6"
include "../amlogic/aml8726/std.aml8726"
options HZ=100
options SCHED_ULE # ULE scheduler
-options PREEMPTION # Enable kernel thread preemption
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options QUOTA # Enable disk quotas for UFS
-options NFSCL # Network Filesystem Client
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options TMPFS # Efficient memory filesystem
-options GEOM_PART_GPT # GUID Partition Tables
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!]
-options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
-options KTRACE # ktrace(1) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
options PRINTF_BUFR_SIZE=128 # Prevent printf output being interspersed.
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
-options FREEBSD_BOOT_LOADER # Process metadata passed from loader(8)
options LINUX_BOOT_ABI
-options VFP # Enable floating point hardware support
-options SMP # Enable multiple cores
# Debugging
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
@@ -81,6 +51,9 @@ options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
#options BOOTP_NFSV3
#options BOOTP_WIRED_TO=axe0
+# Interrupt controller
+device aml_pic
+
# MMC/SD/SDIO Card slot support
device mmc # mmc/sd bus
device mmcsd # mmc/sd flash cards
diff --git a/sys/arm/conf/APALIS-IMX6 b/sys/arm/conf/APALIS-IMX6
index ceb21c7..ce8a0d5 100644
--- a/sys/arm/conf/APALIS-IMX6
+++ b/sys/arm/conf/APALIS-IMX6
@@ -19,7 +19,7 @@
#NO_UNIVERSE
-include "IMX6"
+include "IMX6"
ident APALIS-IMX6
makeoptions MODULES_OVERRIDE=""
diff --git a/sys/arm/conf/ARMADAXP b/sys/arm/conf/ARMADAXP
index f611e09..6d51c16 100644
--- a/sys/arm/conf/ARMADAXP
+++ b/sys/arm/conf/ARMADAXP
@@ -19,43 +19,16 @@
# $FreeBSD$
ident MV-88F78XX0
-include "../mv/armadaxp/std.mv78x60"
+
+include "std.armv6"
+include "../mv/armadaxp/std.mv78x60"
options SOC_MV_ARMADAXP
makeoptions WERROR="-Werror"
options HZ=1000
-#options SCHED_ULE # ULE scheduler
options SCHED_ULE # ULE scheduler
-options PREEMPTION # Enable kernel thread preemption
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options QUOTA # Enable disk quotas for UFS
-options NFSCL # Network Filesystem Client
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options TMPFS # Efficient memory filesystem
-options GEOM_PART_GPT # GUID Partition Tables
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options KTRACE # ktrace(1) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
-options VFP # Enable floating point hardware support
options SMP # Enable multiple cores
# Debugging for use in -current
diff --git a/sys/arm/conf/ARNDALE b/sys/arm/conf/ARNDALE
index 964f9e4..1c16d13 100644
--- a/sys/arm/conf/ARNDALE
+++ b/sys/arm/conf/ARNDALE
@@ -19,7 +19,7 @@
#NO_UNIVERSE
-include "EXYNOS5250"
+include "EXYNOS5250"
ident ARNDALE
#FDT
diff --git a/sys/arm/conf/ARNDALE-OCTA b/sys/arm/conf/ARNDALE-OCTA
index ad937ee..a4faaa0 100644
--- a/sys/arm/conf/ARNDALE-OCTA
+++ b/sys/arm/conf/ARNDALE-OCTA
@@ -19,7 +19,7 @@
#NO_UNIVERSE
-include "EXYNOS5420"
+include "EXYNOS5420"
ident ARNDALE-OCTA
#FDT
diff --git a/sys/arm/conf/ATMEL b/sys/arm/conf/ATMEL
index 572cf4a..c3b6035 100644
--- a/sys/arm/conf/ATMEL
+++ b/sys/arm/conf/ATMEL
@@ -6,7 +6,8 @@
ident ATMEL
-include "../at91/std.atmel"
+include "std.arm"
+include "../at91/std.atmel"
# Typical values for most SoCs and board configurations. Will not work for
# at91sam9g45 or on some boards with non u-boot boot loaders.
@@ -77,10 +78,24 @@ options PRINTF_BUFR_SIZE=128 # Prevent printf output being interspersed.
#options MAC # TrustedBSD MAC Framework
#options INCLUDE_CONFIG_FILE # Include this file in kernel
-# required for netbooting
+# Debugging support. Always need this:
+options KDB # Enable kernel debugger support
+# For minimum debugger support (stable branch) use:
+options KDB_TRACE # Print a stack trace for a panic
+# For full debugger support use this instead:
+options DDB # Enable the kernel debugger
+options GDB # Support remote GDB
+#options DEADLKRES # Enable the deadlock resolver
+#options INVARIANTS # Enable calls of extra sanity checking
+#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
+#options WITNESS # Enable checks to detect deadlocks and cycles
+#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
+#options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
+
+# NFS root from boopt/dhcp
options BOOTP
-options BOOTP_COMPAT
options BOOTP_NFSROOT
+options BOOTP_COMPAT
options BOOTP_NFSV3
options BOOTP_WIRED_TO=ate0
@@ -94,20 +109,6 @@ options NO_SWAPPING
options NO_SYSCTL_DESCR
options RWLOCK_NOINLINE
-# Debugging support. Always need this:
-options KDB # Enable kernel debugger support.
-# For minimum debugger support (stable branch) use:
-options KDB_TRACE # Print a stack trace for a panic.
-# For full debugger support use this instead:
-options DDB # Support DDB.
-options GDB # Support remote GDB.
-#options DEADLKRES # Enable the deadlock resolver
-#options INVARIANTS # Enable calls of extra sanity checking
-#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
-#options WITNESS # Enable checks to detect deadlocks and cycles
-#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
-#options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
-
# The `bpf' device enables the Berkeley Packet Filter.
# Be aware of the administrative consequences of enabling this!
# Note that 'bpf' is required for DHCP.
@@ -115,7 +116,7 @@ device bpf # Berkeley packet filter
# Ethernet
device mii # Minimal MII support
-device ate # Atmel AT91 Ethernet friver
+device ate # Atmel AT91 Ethernet driver
# I2C
device at91_twi # Atmel AT91 Two-wire Interface
diff --git a/sys/arm/conf/AVILA b/sys/arm/conf/AVILA
index cbf27a2..fd4d62a 100644
--- a/sys/arm/conf/AVILA
+++ b/sys/arm/conf/AVILA
@@ -20,9 +20,10 @@
ident AVILA
-include "../xscale/ixp425/std.ixp425"
+include "std.arm"
+include "../xscale/ixp425/std.ixp425"
# NB: memory mapping is defined in std.avila
-include "../xscale/ixp425/std.avila"
+include "../xscale/ixp425/std.avila"
options XSCALE_CACHE_READ_WRITE_ALLOCATE
#To statically compile in device wiring instead of /boot/device.hints
hints "AVILA.hints" # Default places to look for devices.
diff --git a/sys/arm/conf/BEAGLEBONE b/sys/arm/conf/BEAGLEBONE
index 8234533..6b8ab64 100644
--- a/sys/arm/conf/BEAGLEBONE
+++ b/sys/arm/conf/BEAGLEBONE
@@ -23,7 +23,8 @@
ident BEAGLEBONE
-include "../ti/am335x/std.am335x"
+include "std.armv6"
+include "../ti/am335x/std.am335x"
makeoptions MODULES_EXTRA="dtb/am335x"
@@ -35,38 +36,7 @@ makeoptions MODULES_EXTRA+="opensolaris dtrace dtrace/lockstat dtrace/profile dt
options HZ=100
options SCHED_4BSD # 4BSD scheduler
-options PREEMPTION # Enable kernel thread preemption
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options QUOTA # Enable disk quotas for UFS
-options NFSCL # Network Filesystem Client
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options TMPFS # Efficient memory filesystem
-options GEOM_PART_GPT # GUID Partition Tables
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!]
-options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
-options KTRACE # ktrace(1) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
options PLATFORM
-options FREEBSD_BOOT_LOADER # Process metadata passed from loader(8)
-options VFP # Enable floating point hardware support
# Debugging for use in -current
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
@@ -163,5 +133,8 @@ device axe # ASIX Electronics USB Ethernet
device usb_template # Control of the gadget
device usfs
+# Pinmux
+device fdt_pinctrl
+
# Flattened Device Tree
options FDT # Configure using FDT/DTB data
diff --git a/sys/arm/conf/BWCT b/sys/arm/conf/BWCT
index a9e0e78..a539923 100644
--- a/sys/arm/conf/BWCT
+++ b/sys/arm/conf/BWCT
@@ -21,19 +21,16 @@
ident BWCT
+include "std.arm"
options VERBOSE_INIT_ARM
-include "../at91/std.bwct"
+include "../at91/std.bwct"
#To statically compile in device wiring instead of /boot/device.hints
hints "BWCT.hints"
makeoptions MODULES_OVERRIDE=""
#makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
-options DDB
-options KDB
-options BREAK_TO_DEBUGGER
-options ALT_BREAK_TO_DEBUGGER
options SCHED_4BSD # 4BSD scheduler
options INET # InterNETworking
@@ -44,43 +41,27 @@ options SOFTUPDATES # Enable FFS soft updates support
#options UFS_DIRHASH # Improve performance on big directories
#options MD_ROOT # MD is a potential root device
#options MD_ROOT_SIZE=4096 # 4MB ram disk
-#options ROOTDEVNAME=\"ufs:md0\"
-#options ROOTDEVNAME=\"ufs:/dev/mmcsd0s1a\"
options NFSCL # Network Filesystem Client
#options NFSD # Network Filesystem Server
#options NFSLOCKD # Network Lock Manager
options NFS_ROOT # NFS usable as /, requires NFSCL
-options BOOTP_NFSROOT
-options BOOTP
-
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
options TMPFS # Efficient memory filesystem
#options MSDOSFS # MSDOS Filesystem
#options CD9660 # ISO 9660 Filesystem
#options PROCFS # Process filesystem (requires PSEUDOFS)
options PSEUDOFS # Pseudo-filesystem framework
+options GEOM_PART_BSD # BSD partition scheme
+options GEOM_PART_MBR # MBR partition scheme
#options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
#options KTRACE # ktrace(1) support
options SYSVSHM # SYSV-style shared memory
options SYSVMSG # SYSV-style message queues
options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
-#options NO_SYSCTL_DESCR
-options MUTEX_NOINLINE
-options RWLOCK_NOINLINE
-options NO_FFS_SNAPSHOT
-options NO_SWAPPING
-device loop
-device random
-device ether
-device vlan
-device uart
-device ate
-device mii
-device rlswitch
+options _KPOSIX_PRIORITY_SCHEDULING #POSIX P1003_1B real-time extensions
# Debugging for use in -current
+options KDB # Enable kernel debugger support
+options DDB # Enable the kernel debugger
#options DEADLKRES # Enable the deadlock resolver
#options INVARIANTS # Enable calls of extra sanity checking
#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
@@ -88,27 +69,64 @@ device rlswitch
#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
#options DIAGNOSTIC
-device md
-device at91_twi # TWI: Two Wire Interface
-device at91_spi # SPI:
-device at91_ssc
-device at91_mci
-device mmc # mmc/sd bus
-device mmcsd # mmc/sd flash cards
-# iic
-device iic
-device iicbus
+options BOOTP
+options BOOTP_NFSROOT
+
+#options ROOTDEVNAME=\"ufs:md0\"
+#options ROOTDEVNAME=\"ufs:/dev/mmcsd0s1a\"
+
+# kernel/memory size reduction
+options MUTEX_NOINLINE
+options NO_FFS_SNAPSHOT
+options NO_SWAPPING
+#options NO_SYSCTL_DESCR
+options RWLOCK_NOINLINE
+
+# The `bpf' device enables the Berkeley Packet Filter.
+# Be aware of the administrative consequences of enabling this!
+# Note that 'bpf' is required for DHCP.
+device bpf # Berkeley packet filter
+
+# Ethernet
+device mii # Minimal MII support
+device ate # Atmel AT91 Ethernet driver
+device rlswitch
+
+# I2C
+device at91_twi # Atmel AT91 Two-wire Interface
+device iic # I2C generic I/O device driver
+device iicbus # I2C bus system
device ds1672 # DS1672 on I2C bus
#device iicsmb # smb over i2c bridge
#device smbus # Bus support, required for smb below.
#device smb
-# SPI bus
-device spibus
-#device at45d # at45db642 and maybe others
-device bpf # Berkeley packet filter
+# MMC/SD
+device at91_mci # Atmel AT91 Multimedia Card Interface
+device mmc # MMC/SD bus
+device mmcsd # MMC/SD memory card
+
+# DataFlash
+device at91_spi # Atmel AT91 Serial Peripheral Interface
+device spibus # SPI bus
+#device at45d # Atmel AT45D
+
+# Pseudo devices.
+device loop # Network loopback
+device random # Entropy device
+device ether # Ethernet support
+device vlan # 802.1Q VLAN support
+device md # Memory "disks"
+# Serial (COM) ports
+device uart # Multi-uart driver
+options BREAK_TO_DEBUGGER
+options ALT_BREAK_TO_DEBUGGER
+
+# USB support
#options USB_DEBUG
#device ohci
#device usb
#device umass # Disks/Mass storage - Requires scbus and da
+
+device at91_ssc
diff --git a/sys/arm/conf/CAMBRIA b/sys/arm/conf/CAMBRIA
index af29b23..c25521b 100644
--- a/sys/arm/conf/CAMBRIA
+++ b/sys/arm/conf/CAMBRIA
@@ -20,9 +20,10 @@
ident CAMBRIA
-include "../xscale/ixp425/std.ixp435"
+include "std.arm"
+include "../xscale/ixp425/std.ixp435"
# NB: memory mapping is defined in std.avila
-include "../xscale/ixp425/std.avila"
+include "../xscale/ixp425/std.avila"
options XSCALE_CACHE_READ_WRITE_ALLOCATE
#To statically compile in device wiring instead of /boot/device.hints
hints "CAMBRIA.hints" # Default places to look for devices.
diff --git a/sys/arm/conf/CHROMEBOOK b/sys/arm/conf/CHROMEBOOK
index 9459151..059f243 100644
--- a/sys/arm/conf/CHROMEBOOK
+++ b/sys/arm/conf/CHROMEBOOK
@@ -17,7 +17,7 @@
#
# $FreeBSD$
-include "EXYNOS5250"
+include "EXYNOS5250"
ident CHROMEBOOK
hints "CHROMEBOOK.hints"
diff --git a/sys/arm/conf/CHROMEBOOK-PEACH-PIT b/sys/arm/conf/CHROMEBOOK-PEACH-PIT
index e01128c..87284c2 100644
--- a/sys/arm/conf/CHROMEBOOK-PEACH-PIT
+++ b/sys/arm/conf/CHROMEBOOK-PEACH-PIT
@@ -19,7 +19,7 @@
#NO_UNIVERSE
-include "EXYNOS5420"
+include "EXYNOS5420"
ident CHROMEBOOK-PEACH-PIT
hints "CHROMEBOOK-PEACH-PIT.hints"
diff --git a/sys/arm/conf/CHROMEBOOK-SNOW b/sys/arm/conf/CHROMEBOOK-SNOW
index e9242d1..aee3dc0 100644
--- a/sys/arm/conf/CHROMEBOOK-SNOW
+++ b/sys/arm/conf/CHROMEBOOK-SNOW
@@ -19,7 +19,7 @@
#NO_UNIVERSE
-include "CHROMEBOOK"
+include "CHROMEBOOK"
ident CHROMEBOOK-SNOW
#FDT
diff --git a/sys/arm/conf/CHROMEBOOK-SPRING b/sys/arm/conf/CHROMEBOOK-SPRING
index 1b791ac..9714d34 100644
--- a/sys/arm/conf/CHROMEBOOK-SPRING
+++ b/sys/arm/conf/CHROMEBOOK-SPRING
@@ -19,7 +19,7 @@
#NO_UNIVERSE
-include "CHROMEBOOK"
+include "CHROMEBOOK"
ident CHROMEBOOK-SPRING
#FDT
diff --git a/sys/arm/conf/CNS11XXNAS b/sys/arm/conf/CNS11XXNAS
index 5ba2217..710a471 100644
--- a/sys/arm/conf/CNS11XXNAS
+++ b/sys/arm/conf/CNS11XXNAS
@@ -20,13 +20,14 @@
ident CNS11XXNAS
+include "std.arm"
#options PHYSADDR=0x10000000
#options KERNPHYSADDR=0x10200000
#options KERNVIRTADDR=0xc0200000 # Used in ldscript.arm
#options FLASHADDR=0x50000000
#options LOADERRAMADDR=0x00000000
-include "../cavium/cns11xx/std.econa"
+include "../cavium/cns11xx/std.econa"
makeoptions MODULES_OVERRIDE=""
diff --git a/sys/arm/conf/COLIBRI-VF50 b/sys/arm/conf/COLIBRI-VF50
index 9f73f69..81581f6 100644
--- a/sys/arm/conf/COLIBRI-VF50
+++ b/sys/arm/conf/COLIBRI-VF50
@@ -19,7 +19,7 @@
#NO_UNIVERSE
-include "VYBRID"
+include "VYBRID"
ident COLIBRI-VF50
#FDT
diff --git a/sys/arm/conf/COSMIC b/sys/arm/conf/COSMIC
index 72ae5c2..61b99a7 100644
--- a/sys/arm/conf/COSMIC
+++ b/sys/arm/conf/COSMIC
@@ -19,7 +19,7 @@
#NO_UNIVERSE
-include "VYBRID"
+include "VYBRID"
ident COSMIC
#FDT
diff --git a/sys/arm/conf/CRB b/sys/arm/conf/CRB
index 641ba9f..69b0ebd 100644
--- a/sys/arm/conf/CRB
+++ b/sys/arm/conf/CRB
@@ -19,12 +19,13 @@
ident CRB
+include "std.arm"
options PHYSADDR=0x00000000
options KERNPHYSADDR=0x00200000
options KERNVIRTADDR=0xc0200000 # Used in ldscript.arm
options COUNTS_PER_SEC=400000000
-include "../xscale/i8134x/std.crb"
+include "../xscale/i8134x/std.crb"
makeoptions MODULES_OVERRIDE=""
#makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
diff --git a/sys/arm/conf/CUBIEBOARD b/sys/arm/conf/CUBIEBOARD
index 945f0ae..04c1502 100644
--- a/sys/arm/conf/CUBIEBOARD
+++ b/sys/arm/conf/CUBIEBOARD
@@ -21,41 +21,11 @@
ident CUBIEBOARD
-include "../allwinner/std.a10"
+include "std.armv6"
+include "../allwinner/std.a10"
options HZ=100
options SCHED_4BSD # 4BSD scheduler
-options PREEMPTION # Enable kernel thread preemption
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options QUOTA # Enable disk quotas for UFS
-options NFSCL # Network Filesystem Client
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options TMPFS # Efficient memory filesystem
-options GEOM_PART_GPT # GUID Partition Tables
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!]
-options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
-options KTRACE # ktrace(1) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
-options FREEBSD_BOOT_LOADER # Process metadata passed from loader(8)
-options VFP # Enable floating point hardware support
# Debugging for use in -current
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
@@ -83,8 +53,8 @@ options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
options ROOTDEVNAME=\"ufs:/dev/da0s2\"
# MMC/SD/SDIO Card slot support
-#device mmc # mmc/sd bus
-#device mmcsd # mmc/sd flash cards
+device mmc # mmc/sd bus
+device mmcsd # mmc/sd flash cards
# ATA controllers
#device ahci # AHCI-compatible SATA controllers
@@ -126,8 +96,6 @@ device umass
device loop
device ether
device mii
-device smscphy
-#device cpsw
device bpf
device emac
diff --git a/sys/arm/conf/CUBIEBOARD2 b/sys/arm/conf/CUBIEBOARD2
index d370dda..86dbb2e 100644
--- a/sys/arm/conf/CUBIEBOARD2
+++ b/sys/arm/conf/CUBIEBOARD2
@@ -21,41 +21,11 @@
ident CUBIEBOARD2
-include "../allwinner/a20/std.a20"
+include "std.armv6"
+include "../allwinner/a20/std.a20"
options HZ=100
options SCHED_ULE # ULE scheduler
-options PREEMPTION # Enable kernel thread preemption
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options QUOTA # Enable disk quotas for UFS
-options NFSCL # Network Filesystem Client
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options TMPFS # Efficient memory filesystem
-options GEOM_PART_GPT # GUID Partition Tables
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!]
-options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
-options KTRACE # ktrace(1) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
-options FREEBSD_BOOT_LOADER # Process metadata passed from loader(8)
-options VFP # Enable floating point hardware support
options SMP # Enable multiple cores
# Debugging for use in -current
@@ -83,9 +53,12 @@ options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
# Boot device is 2nd slice on MMC/SD card
options ROOTDEVNAME=\"ufs:/dev/da0s2\"
+# Interrupt controller
+device gic
+
# MMC/SD/SDIO Card slot support
-#device mmc # mmc/sd bus
-#device mmcsd # mmc/sd flash cards
+device mmc # mmc/sd bus
+device mmcsd # mmc/sd flash cards
# ATA controllers
#device ahci # AHCI-compatible SATA controllers
@@ -127,8 +100,6 @@ device umass
device loop
device ether
device mii
-device smscphy
-#device cpsw
device bpf
device emac
diff --git a/sys/arm/conf/DB-78XXX b/sys/arm/conf/DB-78XXX
index 4fee206..e59e426 100644
--- a/sys/arm/conf/DB-78XXX
+++ b/sys/arm/conf/DB-78XXX
@@ -5,7 +5,8 @@
#
ident DB-88F78XX
-include "../mv/discovery/std.db78xxx"
+include "std.arm"
+include "../mv/discovery/std.db78xxx"
options SOC_MV_DISCOVERY
diff --git a/sys/arm/conf/DB-88F5XXX b/sys/arm/conf/DB-88F5XXX
index 6ccb360..f1729f0 100644
--- a/sys/arm/conf/DB-88F5XXX
+++ b/sys/arm/conf/DB-88F5XXX
@@ -5,7 +5,8 @@
#
ident DB-88F5XXX
-include "../mv/orion/std.db88f5xxx"
+include "std.arm"
+include "../mv/orion/std.db88f5xxx"
options SOC_MV_ORION
diff --git a/sys/arm/conf/DB-88F6XXX b/sys/arm/conf/DB-88F6XXX
index c59f1c1..ec3eff0 100644
--- a/sys/arm/conf/DB-88F6XXX
+++ b/sys/arm/conf/DB-88F6XXX
@@ -5,51 +5,53 @@
#
ident DB-88F6XXX
-include "../mv/kirkwood/std.db88f6xxx"
+include "std.arm"
+include "../mv/kirkwood/std.db88f6xxx"
options SOC_MV_KIRKWOOD
-#makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
makeoptions WERROR="-Werror"
options SCHED_4BSD # 4BSD scheduler
options INET # InterNETworking
options INET6 # IPv6 communications protocols
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options TMPFS # Efficient memory filesystem
options FFS # Berkeley Fast Filesystem
options NANDFS # NAND Filesystem
options NFSCL # Network Filesystem Client
options NFSLOCKD # Network Lock Manager
options NFS_ROOT # NFS usable as /, requires NFSCL
-options BOOTP
-options BOOTP_NFSROOT
-options BOOTP_NFSV3
-options BOOTP_WIRED_TO=mge0
-
-#options ROOTDEVNAME=\"ufs:/dev/da0a\"
-
+options TMPFS # Efficient memory filesystem
+options GEOM_PART_BSD # BSD partition scheme
+options GEOM_PART_MBR # MBR partition scheme
options SYSVSHM # SYSV-style shared memory
options SYSVMSG # SYSV-style message queues
options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # Posix P1003_1B real-time extensions
+options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
options MUTEX_NOINLINE
options RWLOCK_NOINLINE
options NO_FFS_SNAPSHOT
options NO_SWAPPING
-# Debugging
+# Debugging for use in -current
+#makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
options ALT_BREAK_TO_DEBUGGER
-options DDB
+options KDB # Enable kernel debugger support
+options DDB # Enable the kernel debugger
#options DEADLKRES # Enable the deadlock resolver
-#options DIAGNOSTIC
#options INVARIANTS # Enable calls of extra sanity checking
#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
-options KDB
options WITNESS # Enable checks to detect deadlocks and cycles
options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
#options WITNESS_KDB
+#options DIAGNOSTIC
+
+# NFS root from boopt/dhcp
+options BOOTP
+options BOOTP_NFSROOT
+options BOOTP_NFSV3
+options BOOTP_WIRED_TO=mge0
+
+#options ROOTDEVNAME=\"ufs:/dev/da0a\"
device pci
@@ -92,6 +94,6 @@ device mvs
device nand
# Flattened Device Tree
-options FDT
+options FDT # Configure using FDT/DTB data
options FDT_DTB_STATIC
makeoptions FDT_DTS_FILE=db88f6281.dts
diff --git a/sys/arm/conf/DIGI-CCWMX53 b/sys/arm/conf/DIGI-CCWMX53
index 20dec9c..65239c1 100644
--- a/sys/arm/conf/DIGI-CCWMX53
+++ b/sys/arm/conf/DIGI-CCWMX53
@@ -19,7 +19,7 @@
#NO_UNIVERSE
-include "IMX53"
+include "IMX53"
ident DIGI-CCWMX53
makeoptions WITHOUT_MODULES="ahc"
diff --git a/sys/arm/conf/DOCKSTAR b/sys/arm/conf/DOCKSTAR
index aea158c..16eeef9 100644
--- a/sys/arm/conf/DOCKSTAR
+++ b/sys/arm/conf/DOCKSTAR
@@ -21,35 +21,57 @@
ident DOCKSTAR
-include "../mv/kirkwood/std.db88f6xxx"
-
-makeoptions FDT_DTS_FILE=dockstar.dts
+include "std.arm"
+include "../mv/kirkwood/std.db88f6xxx"
options SOC_MV_KIRKWOOD
options SCHED_4BSD # 4BSD scheduler
options INET # InterNETworking
options INET6 # IPv6 communications protocols
-options SOFTUPDATES
-options CD9660 # ISO 9660 filesystem
options FFS # Berkeley Fast Filesystem
-options TMPFS # Efficient memory filesystem
-options MSDOSFS # MS DOS File System (FAT, FAT32)
+options SOFTUPDATES # Enable FFS soft updates support
+options NFSCL # Network Filesystem Client
+options NFSLOCKD # Network Lock Manager
+#options NFS_ROOT # NFS usable as /, requires NFSCL
+options MSDOSFS # MSDOS Filesystem
+options CD9660 # ISO 9660 filesystem
options NULLFS # NULL filesystem
+options TMPFS # Efficient memory filesystem
+options GEOM_PART_GPT # GUID Partition Tables
+options GEOM_PART_BSD # BSD partition scheme
+options GEOM_PART_MBR # MBR partition scheme
+options GEOM_LABEL # Provides labelization
+options GEOM_ELI # Disk encryption
options SYSVSHM # SYSV-style shared memory
options SYSVMSG # SYSV-style message queues
options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # Posix P1003_1B real-time extensions
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options GEOM_ELI # Disk encryption.
-options GEOM_LABEL # Providers labelization.
-options GEOM_PART_GPT # GPT partitioning
+options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-# Flattened Device Tree
-device fdt
-options FDT
-options FDT_DTB_STATIC
+# Debugging for use in -current
+makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
+options BREAK_TO_DEBUGGER
+options ALT_BREAK_TO_DEBUGGER
+options KDB # Enable kernel debugger support
+options DDB # Enable the kernel debugger
+options INVARIANTS # Enable calls of extra sanity checking
+options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
+#options WITNESS # Enable checks to detect deadlocks and cycles
+#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
+#options WITNESS_KDB
+#options DIAGNOSTIC
+
+# Enable these options for nfs root configured via BOOTP.
+#options BOOTP
+#options BOOTP_NFSROOT
+#options BOOTP_NFSV3
+#options BOOTP_WIRED_TO=mge0
+
+# If not using BOOTP, use something like one of these...
+#options ROOTDEVNAME=\"ufs:/dev/da0a\"
+options ROOTDEVNAME=\"ufs:/dev/da0s1a\"
+#options ROOTDEVNAME=\"ufs:/dev/da0p10\"
+#options ROOTDEVNAME=\"nfs:192.168.0.254/dreamplug\"
# Misc pseudo devices
device bpf # Required for DHCP
@@ -137,31 +159,7 @@ options ALTQ_PRIQ # Priority Queueing
options ALTQ_NOPCC # Required if the TSC is unusable
#options ALTQ_DEBUG
-# Debugging
-makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
-options BREAK_TO_DEBUGGER
-options ALT_BREAK_TO_DEBUGGER
-options DDB
-options KDB
-#options DIAGNOSTIC
-options INVARIANTS # Enable calls of extra sanity checking
-options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
-#options WITNESS # Enable checks to detect deadlocks and cycles
-#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
-#options WITNESS_KDB
-
-# Enable these options for nfs root configured via BOOTP.
-options NFSCL # Network Filesystem Client
-options NFSLOCKD # Network Lock Manager
-#options NFS_ROOT # NFS usable as /, requires NFSCL
-#options BOOTP
-#options BOOTP_NFSROOT
-#options BOOTP_NFSV3
-#options BOOTP_WIRED_TO=mge0
-
-# If not using BOOTP, use something like one of these...
-#options ROOTDEVNAME=\"ufs:/dev/da0a\"
-options ROOTDEVNAME=\"ufs:/dev/da0s1a\"
-#options ROOTDEVNAME=\"ufs:/dev/da0p10\"
-#options ROOTDEVNAME=\"nfs:192.168.0.254/dreamplug\"
-
+# Flattened Device Tree
+options FDT # Configure using FDT/DTB data
+options FDT_DTB_STATIC
+makeoptions FDT_DTS_FILE=dockstar.dts
diff --git a/sys/arm/conf/DREAMPLUG-1001 b/sys/arm/conf/DREAMPLUG-1001
index 0448d4f..247eadb 100644
--- a/sys/arm/conf/DREAMPLUG-1001
+++ b/sys/arm/conf/DREAMPLUG-1001
@@ -24,35 +24,57 @@
ident DREAMPLUG-1001
-include "../mv/kirkwood/std.db88f6xxx"
-
-makeoptions FDT_DTS_FILE=dreamplug-1001.dts
+include "std.arm"
+include "../mv/kirkwood/std.db88f6xxx"
options SOC_MV_KIRKWOOD
options SCHED_4BSD # 4BSD scheduler
options INET # InterNETworking
options INET6 # IPv6 communications protocols
-options SOFTUPDATES
-options TMPFS # Efficient memory filesystem
-options CD9660 # ISO 9660 filesystem
options FFS # Berkeley Fast Filesystem
-options MSDOSFS # MS DOS File System (FAT, FAT32)
+options SOFTUPDATES # Enable FFS soft updates support
+options NFSCL # Network Filesystem Client
+options NFSLOCKD # Network Lock Manager
+#options NFS_ROOT # NFS usable as /, requires NFSCL
+options MSDOSFS # MSDOS Filesystem
+options CD9660 # ISO 9660 filesystem
options NULLFS # NULL filesystem
+options TMPFS # Efficient memory filesystem
+options GEOM_PART_GPT # GUID Partition Tables
+options GEOM_PART_BSD # BSD partition scheme
+options GEOM_PART_MBR # MBR partition scheme
+options GEOM_LABEL # Provides labelization
+options GEOM_ELI # Disk encryption
options SYSVSHM # SYSV-style shared memory
options SYSVMSG # SYSV-style message queues
options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # Posix P1003_1B real-time extensions
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options GEOM_ELI # Disk encryption.
-options GEOM_LABEL # Providers labelization.
-options GEOM_PART_GPT # GPT partitioning
+options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-# Flattened Device Tree
-device fdt
-options FDT
-options FDT_DTB_STATIC
+# Debugging for use in -current
+makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
+options BREAK_TO_DEBUGGER
+options ALT_BREAK_TO_DEBUGGER
+options KDB # Enable kernel debugger support
+options DDB # Enable the kernel debugger
+options INVARIANTS # Enable calls of extra sanity checking
+options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
+#options WITNESS # Enable checks to detect deadlocks and cycles
+#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
+#options WITNESS_KDB
+#options DIAGNOSTIC
+
+# Enable these options for nfs root configured via BOOTP.
+#options BOOTP
+#options BOOTP_NFSROOT
+#options BOOTP_NFSV3
+#options BOOTP_WIRED_TO=mge0
+
+# If not using BOOTP, use something like one of these...
+#options ROOTDEVNAME=\"ufs:/dev/da1a\"
+options ROOTDEVNAME=\"ufs:/dev/da1s1a\"
+#options ROOTDEVNAME=\"ufs:/dev/da1p10\"
+#options ROOTDEVNAME=\"nfs:192.168.0.254/dreamplug\"
# Misc pseudo devices
device bpf # Required for DHCP
@@ -145,34 +167,6 @@ options ALTQ_PRIQ # Priority Queueing
options ALTQ_NOPCC # Required if the TSC is unusable
#options ALTQ_DEBUG
-# Debugging
-makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
-options BREAK_TO_DEBUGGER
-options ALT_BREAK_TO_DEBUGGER
-options DDB
-options KDB
-#options DIAGNOSTIC
-options INVARIANTS # Enable calls of extra sanity checking
-options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
-#options WITNESS # Enable checks to detect deadlocks and cycles
-#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
-#options WITNESS_KDB
-
-# Enable these options for nfs root configured via BOOTP.
-options NFSCL # Network Filesystem Client
-options NFSLOCKD # Network Lock Manager
-#options NFS_ROOT # NFS usable as /, requires NFSCL
-#options BOOTP
-#options BOOTP_NFSROOT
-#options BOOTP_NFSV3
-#options BOOTP_WIRED_TO=mge0
-
-# If not using BOOTP, use something like one of these...
-#options ROOTDEVNAME=\"ufs:/dev/da1a\"
-options ROOTDEVNAME=\"ufs:/dev/da1s1a\"
-#options ROOTDEVNAME=\"ufs:/dev/da1p10\"
-#options ROOTDEVNAME=\"nfs:192.168.0.254/dreamplug\"
-
# To use this configuration with the (rare) model 1001N (nand flash),
# create a kernel config file that looks like this:
#
@@ -181,3 +175,7 @@ options ROOTDEVNAME=\"ufs:/dev/da1s1a\"
# makeoptions FDT_DTS_FILE=dreamplug-1001N.dts
# device nand
+# Flattened Device Tree
+options FDT # Configure using FDT/DTB data
+options FDT_DTB_STATIC
+makeoptions FDT_DTS_FILE=dreamplug-1001.dts
diff --git a/sys/arm/conf/EA3250 b/sys/arm/conf/EA3250
index d2d691b..8f13505 100644
--- a/sys/arm/conf/EA3250
+++ b/sys/arm/conf/EA3250
@@ -5,7 +5,8 @@
#
ident EA3250
-include "../lpc/std.lpc"
+include "std.arm"
+include "../lpc/std.lpc"
hints "EA3250.hints"
makeoptions MODULES_OVERRIDE=""
diff --git a/sys/arm/conf/EB9200 b/sys/arm/conf/EB9200
index a5ec5eb..6625783 100644
--- a/sys/arm/conf/EB9200
+++ b/sys/arm/conf/EB9200
@@ -16,15 +16,14 @@
ident EB9200
-include "../at91/std.eb9200"
+include "std.arm"
+include "../at91/std.eb9200"
# The AT91 platform doesn't use /boot/loader, so we have to statically wire
# hints.
hints "EB9200.hints"
makeoptions MODULES_OVERRIDE=""
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
-options DDB
-options KDB
options SCHED_4BSD # 4BSD scheduler
options INET # InterNETworking
@@ -40,75 +39,92 @@ options NFSCL # Network Filesystem Client
options NFSD # Network Filesystem Server
options NFSLOCKD # Network Lock Manager
options NFS_ROOT # NFS usable as /, requires NFSCL
-options BOOTP_NFSROOT
-options BOOTP
-
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
options TMPFS # Efficient memory filesystem
#options MSDOSFS # MSDOS Filesystem
#options CD9660 # ISO 9660 Filesystem
#options PROCFS # Process filesystem (requires PSEUDOFS)
options PSEUDOFS # Pseudo-filesystem framework
+options GEOM_PART_BSD # BSD partition scheme
+options GEOM_PART_MBR # MBR partition scheme
#options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
#options KTRACE # ktrace(1) support
options SYSVSHM # SYSV-style shared memory
options SYSVMSG # SYSV-style message queues
options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # Posix P1003_1B real-time extensions
-#options NO_SYSCTL_DESCR
+options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
+
+# Debugging for use in -current
+options KDB # Enable kernel debugger support
+options DDB # Enable the kernel debugger
+#options DEADLKRES # Enable the deadlock resolver
+#options INVARIANTS # Enable calls of extra sanity checking
+#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
+#options WITNESS # Enable checks to detect deadlocks and cycles
+#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
+
+# NFS root from boopt/dhcp
+options BOOTP
+options BOOTP_NFSROOT
+
# Disable the inlining of mutex, rwlock and sx locks. These eat up a lot
# of space.
options MUTEX_NOINLINE
-options RWLOCK_NOINLINE
options SX_NOINLINE
options NO_FFS_SNAPSHOT
options NO_SWAPPING
-device random
-device loop
-device ether
-device uart
-device ate
+#options NO_SYSCTL_DESCR
+options RWLOCK_NOINLINE
+
+# The `bpf' device enables the Berkeley Packet Filter.
+# Be aware of the administrative consequences of enabling this!
+# Note that 'bpf' is required for DHCP.
+device bpf # Berkeley packet filter
+
+# Ethernet
+device ate # Atmel AT91 Ethernet driver
device miibus
#device lxtphy
-device at91_cfata
-device ata
-
-# Debugging for use in -current
-#options DEADLKRES # Enable the deadlock resolver
-#options INVARIANTS # Enable calls of extra sanity checking
-#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
-#options WITNESS # Enable checks to detect deadlocks and cycles
-#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
+# I2C
+device at91_twi # Atmel AT91 Two-wire Interface
+device iic # I2C generic I/O device driver
+device iicbus # I2C bus system
+device icee
-device md
-device at91_twi # TWI: Two Wire Interface
-device at91_spi # SPI:
-device spibus
# MMC/SD
-device at91_mci
-device mmc
-device mmcsd
-# iic
-device iic
-device iicbus
-device icee
+device at91_mci # Atmel AT91 Multimedia Card Interface
+device mmc # MMC/SD bus
+device mmcsd # MMC/SD memory card
+
+device at91_spi # Atmel AT91 Serial Peripheral Interface
+device spibus # SPI bus
+
+# Pseudo devices.
+device loop # Network loopback
+device random # Entropy device
+device ether # Ethernet support
+device md # Memory "disks"
-device bpf
-# USB support
-options USB_DEBUG # enable debug msgs
-device ohci # OHCI localbus->USB interface
-device usb # USB Bus (required)
-device umass # Disks/Mass storage - Requires scbus and da
# SCSI peripherals
device scbus # SCSI bus (required for ATA/SCSI)
device da # Direct Access (disks)
device cd # CD
device pass # Passthrough device (direct ATA/SCSI access)
+# Serial (COM) ports
+device uart # Multi-uart driver
+
+# USB support
+options USB_DEBUG # enable debug msgs
+device ohci # OHCI USB interface
+device usb # USB Bus (required)
+device umass # Disks/Mass storage - Requires scbus and da
+
# USB device (gadget) support
#device at91_dci # Atmel's usb device
#device usfs # emulate a flash
#device cdce # emulate an ethernet
#device usb_template # Control of the gadget
+
+device at91_cfata
+device ata
diff --git a/sys/arm/conf/EFIKA_MX b/sys/arm/conf/EFIKA_MX
index a4690f6..dc22943 100644
--- a/sys/arm/conf/EFIKA_MX
+++ b/sys/arm/conf/EFIKA_MX
@@ -20,6 +20,7 @@
ident EFIKA_MX
+include "std.armv6"
include "../freescale/imx/std.imx51"
makeoptions WITHOUT_MODULES="ahc"
@@ -27,43 +28,13 @@ makeoptions WITHOUT_MODULES="ahc"
options SOC_IMX51
options SCHED_4BSD # 4BSD scheduler
-options PREEMPTION # Enable kernel thread preemption
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options QUOTA # Enable disk quotas for UFS
#options MD_ROOT # MD is a potential root device
-options NFSCL # Network Filesystem Client
#options NFSD # Network Filesystem Server
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options TMPFS # Efficient memory filesystem
-options GEOM_PART_GPT # GUID Partition Tables
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options GEOM_LABEL # Provides labelization
#options COMPAT_FREEBSD5 # Compatible with FreeBSD5
#options COMPAT_FREEBSD6 # Compatible with FreeBSD6
#options COMPAT_FREEBSD7 # Compatible with FreeBSD7
-options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
-options KTRACE # ktrace(1) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
options PLATFORM
options INCLUDE_CONFIG_FILE # Include this file in kernel
-options VFP # Enable floating point hardware support
# Debugging for use in -current
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
diff --git a/sys/arm/conf/EP80219 b/sys/arm/conf/EP80219
index 35bcb17..301849c 100644
--- a/sys/arm/conf/EP80219
+++ b/sys/arm/conf/EP80219
@@ -19,12 +19,13 @@
ident EP80219
+include "std.arm"
options PHYSADDR=0xa0000000
options KERNPHYSADDR=0xa0200000
options KERNVIRTADDR=0xc0200000 # Used in ldscript.arm
#options ARM32_NEW_VM_LAYOUT
-include "../xscale/i80321/std.ep80219"
+include "../xscale/i80321/std.ep80219"
makeoptions MODULES_OVERRIDE=""
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
diff --git a/sys/arm/conf/ETHERNUT5 b/sys/arm/conf/ETHERNUT5
index 376336a..4604ff2 100644
--- a/sys/arm/conf/ETHERNUT5
+++ b/sys/arm/conf/ETHERNUT5
@@ -21,7 +21,8 @@
ident ETHERNUT5
-include "../at91/std.ethernut5"
+include "std.arm"
+include "../at91/std.ethernut5"
# To statically compile in device wiring instead of /boot/device.hints
hints "ETHERNUT5.hints"
@@ -43,13 +44,13 @@ options NFSCL # Network Filesystem Client
#options NFSD # Network Filesystem Server
options NFSLOCKD # Network Lock Manager
options NFS_ROOT # NFS usable as /, requires NFSCL
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
options TMPFS # Efficient memory filesystem
#options MSDOSFS # MSDOS Filesystem
#options CD9660 # ISO 9660 Filesystem
#options PROCFS # Process filesystem (requires PSEUDOFS)
#options PSEUDOFS # Pseudo-filesystem framework
+options GEOM_PART_BSD # BSD partition scheme
+options GEOM_PART_MBR # MBR partition scheme
#options GEOM_PART_GPT # GUID Partition Tables.
#options GEOM_LABEL # Provides labelization
#options COMPAT_FREEBSD5 # Compatible with FreeBSD5
@@ -70,10 +71,24 @@ options PRINTF_BUFR_SIZE=128 # Prevent printf output being interspersed.
#options MAC # TrustedBSD MAC Framework
#options INCLUDE_CONFIG_FILE # Include this file in kernel
-# required for netbooting
+# Debugging support. Always need this:
+#options KDB # Enable kernel debugger support.
+# For minimum debugger support (stable branch) use:
+#options KDB_TRACE # Print a stack trace for a panic.
+# For full debugger support use this instead:
+#options DDB # Enable the kernel debugger
+#options GDB # Support remote GDB
+#options DEADLKRES # Enable the deadlock resolver
+#options INVARIANTS # Enable calls of extra sanity checking
+#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
+#options WITNESS # Enable checks to detect deadlocks and cycles
+#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
+#options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
+
+# NFS root from boopt/dhcp
options BOOTP
-options BOOTP_COMPAT
options BOOTP_NFSROOT
+options BOOTP_COMPAT
options BOOTP_NFSV3
options BOOTP_WIRED_TO=ate0
@@ -87,20 +102,6 @@ options NO_SWAPPING
options NO_SYSCTL_DESCR
options RWLOCK_NOINLINE
-# Debugging support. Always need this:
-#options KDB # Enable kernel debugger support.
-# For minimum debugger support (stable branch) use:
-#options KDB_TRACE # Print a stack trace for a panic.
-# For full debugger support use this instead:
-#options DDB # Support DDB.
-#options GDB # Support remote GDB.
-#options DEADLKRES # Enable the deadlock resolver
-#options INVARIANTS # Enable calls of extra sanity checking
-#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
-#options WITNESS # Enable checks to detect deadlocks and cycles
-#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
-#options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
-
# The `bpf' device enables the Berkeley Packet Filter.
# Be aware of the administrative consequences of enabling this!
# Note that 'bpf' is required for DHCP.
diff --git a/sys/arm/conf/EXYNOS5.common b/sys/arm/conf/EXYNOS5.common
index cd6e76f..446d272 100644
--- a/sys/arm/conf/EXYNOS5.common
+++ b/sys/arm/conf/EXYNOS5.common
@@ -20,6 +20,7 @@
makeoptions WERROR="-Werror"
+include "std.armv6"
options HZ=100
options SCHED_ULE # ULE scheduler
options PREEMPTION # Enable kernel thread preemption
@@ -84,6 +85,9 @@ device mmc # mmc/sd bus
device mmcsd # mmc/sd flash cards
device dwmmc
+# Interrupt controller
+device gic
+
# Pseudo devices
device loop
diff --git a/sys/arm/conf/EXYNOS5250 b/sys/arm/conf/EXYNOS5250
index 156d856..e22239f 100644
--- a/sys/arm/conf/EXYNOS5250
+++ b/sys/arm/conf/EXYNOS5250
@@ -18,8 +18,8 @@
# $FreeBSD$
ident EXYNOS5250
-include "EXYNOS5.common"
-include "../samsung/exynos/std.exynos5250"
+include "EXYNOS5.common"
+include "../samsung/exynos/std.exynos5250"
#FDT
options FDT
diff --git a/sys/arm/conf/EXYNOS5420 b/sys/arm/conf/EXYNOS5420
index 0f2c2c7..b55151a 100644
--- a/sys/arm/conf/EXYNOS5420
+++ b/sys/arm/conf/EXYNOS5420
@@ -18,8 +18,8 @@
# $FreeBSD$
ident EXYNOS5420
-include "EXYNOS5.common"
-include "../samsung/exynos/std.exynos5420"
+include "EXYNOS5.common"
+include "../samsung/exynos/std.exynos5420"
#FDT
options FDT
diff --git a/sys/arm/conf/GUMSTIX b/sys/arm/conf/GUMSTIX
index 97d0ac7..048bd3c 100644
--- a/sys/arm/conf/GUMSTIX
+++ b/sys/arm/conf/GUMSTIX
@@ -19,6 +19,7 @@
# $FreeBSD$
ident GUMSTIX
+include "std.arm"
cpu CPU_XSCALE_PXA2X0
# This probably wants to move somewhere else. Maybe we can create a basic
@@ -30,7 +31,7 @@ options PHYSADDR=0xa0000000
options KERNPHYSADDR=0xa0200000
options KERNVIRTADDR=0xc0200000 # Used in ldscript.arm
-include "../xscale/pxa/std.pxa"
+include "../xscale/pxa/std.pxa"
makeoptions MODULES_OVERRIDE=""
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
diff --git a/sys/arm/conf/HL200 b/sys/arm/conf/HL200
index 3c0f4e8..091ab39 100644
--- a/sys/arm/conf/HL200
+++ b/sys/arm/conf/HL200
@@ -21,15 +21,14 @@
ident HL200
-include "../at91/std.hl200"
+include "std.arm"
+include "../at91/std.hl200"
#To statically compile in device wiring instead of /boot/device.hints
hints "KB920X.hints"
makeoptions MODULES_OVERRIDE=""
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
-options DDB
-options KDB
options SCHED_4BSD # 4BSD scheduler
options INET # InterNETworking
@@ -40,67 +39,92 @@ options FFS # Berkeley Fast Filesystem
#options UFS_DIRHASH # Improve performance on big directories
#options MD_ROOT # MD is a potential root device
#options MD_ROOT_SIZE=4096 # 4MB ram disk
-#options ROOTDEVNAME=\"ufs:/dev/mmcsd0s1a\"
options NFSCL # Network Filesystem Client
#options NFSD # Network Filesystem Server
#options NFSLOCKD # Network Lock Manager
options NFS_ROOT # NFS usable as /, requires NFSCL
-options BOOTP_NFSROOT
-options BOOTP
-options BOOTP_NFSV3
-options BOOTP_WIRED_TO=ate0
-options BOOTP_COMPAT
-
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
options TMPFS # Efficient memory filesystem
#options MSDOSFS # MSDOS Filesystem
#options CD9660 # ISO 9660 Filesystem
#options PROCFS # Process filesystem (requires PSEUDOFS)
options PSEUDOFS # Pseudo-filesystem framework
+options GEOM_PART_BSD # BSD partition scheme
+options GEOM_PART_MBR # MBR partition scheme
#options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
#options KTRACE # ktrace(1) support
options SYSVSHM # SYSV-style shared memory
options SYSVMSG # SYSV-style message queues
options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # Posix P1003_1B real-time extensions
-#options NO_SYSCTL_DESCR
-options MUTEX_NOINLINE
-options RWLOCK_NOINLINE
-options NO_FFS_SNAPSHOT
-options NO_SWAPPING
-device random
-device loop
-device ether
-device uart
-device ate
-device mii
-device lxtphy
+options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
# Debugging for use in -current
+options KDB # Enable kernel debugger support
+options DDB # Enable the kernel debugger
#options DEADLKRES # Enable the deadlock resolver
#options INVARIANTS # Enable calls of extra sanity checking
#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
#options WITNESS # Enable checks to detect deadlocks and cycles
#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
-device md
-device at91_twi # TWI: Two Wire Interface
-device at91_spi # SPI:
-device spibus
-# MMC/SD
-device at91_mci
-device mmc
-device mmcsd
-# iic
-device iic
-device iicbus
+options BOOTP
+options BOOTP_NFSROOT
+options BOOTP_COMPAT
+options BOOTP_NFSV3
+options BOOTP_WIRED_TO=ate0
+
+# alternatively, boot from a MMC/SD memory card
+#options ROOTDEVNAME=\"ufs:/dev/mmcsd0s1a\"
+
+# kernel/memory size reduction
+options MUTEX_NOINLINE
+options NO_FFS_SNAPSHOT
+options NO_SWAPPING
+#options NO_SYSCTL_DESCR
+options RWLOCK_NOINLINE
+
+# The `bpf' device enables the Berkeley Packet Filter.
+# Be aware of the administrative consequences of enabling this!
+# Note that 'bpf' is required for DHCP.
+device bpf # Berkeley packet filter
+
+# Ethernet
+device mii # Minimal MII support
+device ate # Atmel AT91 Ethernet driver
+device lxtphy
+
+# I2C
+device at91_twi # Atmel AT91 Two-wire Interface
+device iic # I2C generic I/O device driver
+device iicbus # I2C bus system
device icee
-device bpf
+# MMC/SD
+device at91_mci # Atmel AT91 Multimedia Card Interface
+device mmc # MMC/SD bus
+device mmcsd # MMC/SD memory card
+
+# DataFlash
+device at91_spi # Atmel AT91 Serial Peripheral Interface
+device spibus # SPI bus
+
+# Pseudo devices.
+device loop # Network loopback
+device random # Entropy device
+device ether # Ethernet support
+device md # Memory "disks"
+
+# SCSI peripherals
+device scbus # SCSI bus (required for ATA/SCSI)
+device da # Direct Access (disks)
+device cd # CD
+device pass # Passthrough device (direct ATA/SCSI access)
+
+# Serial (COM) ports
+device uart # Multi-uart driver
+
# USB support
options USB_DEBUG # enable debug msgs
-device ohci # OHCI localbus->USB interface
+device ohci # OHCI USB interface
device usb # USB Bus (required)
#device udbp # USB Double Bulk Pipe devices
device uhid # "Human Interface Devices"
@@ -131,11 +155,7 @@ device rum # Ralink Technology RT2501USB wireless NICs
device uath # Atheros AR5523 wireless NICs
device ural # Ralink Technology RT2500USB wireless NICs
device zyd # ZyDAS zd1211/zd1211b wireless NICs
-# SCSI peripherals
-device scbus # SCSI bus (required for ATA/SCSI)
-device da # Direct Access (disks)
-device cd # CD
-device pass # Passthrough device (direct ATA/SCSI access)
+
# Wireless NIC cards
device wlan # 802.11 support
device wlan_wep # 802.11 WEP support
diff --git a/sys/arm/conf/HL201 b/sys/arm/conf/HL201
index 6a477af..f107235 100644
--- a/sys/arm/conf/HL201
+++ b/sys/arm/conf/HL201
@@ -21,13 +21,12 @@
ident HL201
-include "../at91/std.hl201"
+include "std.arm"
+include "../at91/std.hl201"
makeoptions MODULES_OVERRIDE=""
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
-options DDB
-options KDB
options SCHED_4BSD # 4BSD scheduler
options INET # InterNETworking
@@ -39,62 +38,86 @@ options FFS # Berkeley Fast Filesystem
#options MD_ROOT # MD is a potential root device
#options MD_ROOT_SIZE=4096 # 4MB ram disk
options NANDFS # NAND file system
-options ROOTDEVNAME=\"ufs:/dev/mmcsd0s1a\"
options NFSCL # Network Filesystem Client
#options NFSD # Network Filesystem Server
#options NFSLOCKD # Network Lock Manager
options NFS_ROOT # NFS usable as /, requires NFSCL
-#options BOOTP_NFSROOT
-#options BOOTP
-#options BOOTP_NFSV3
-#options BOOTP_WIRED_TO=ate0
-#options BOOTP_COMPAT
-
-options ALT_BREAK_TO_DEBUGGER
-
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
options TMPFS # Efficient memory filesystem
#options MSDOSFS # MSDOS Filesystem
#options CD9660 # ISO 9660 Filesystem
#options PROCFS # Process filesystem (requires PSEUDOFS)
options PSEUDOFS # Pseudo-filesystem framework
+options GEOM_PART_BSD # BSD partition scheme
+options GEOM_PART_MBR # MBR partition scheme
#options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
#options KTRACE # ktrace(1) support
options SYSVSHM # SYSV-style shared memory
options SYSVMSG # SYSV-style message queues
options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # Posix P1003_1B real-time extensions
-options MUTEX_NOINLINE
-options RWLOCK_NOINLINE
-options NO_FFS_SNAPSHOT
-options NO_SWAPPING
-device random
-device loop
-device ether
-device uart
-device ate
-device at91_wdt
-device mii
-device lxtphy
-
-# I2C
-device at91_twi # Atmel AT91 Two-wire Interface
-device iic # I2C generic I/O device driver
-device iicbus # I2C bus system
+options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
# Debugging for use in -current
+options KDB # Enable kernel debugger support
+options DDB # Enable the kernel debugger
#options INVARIANTS # Enable calls of extra sanity checking
#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
#options WITNESS # Enable checks to detect deadlocks and cycles
#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
#options DIAGNOSTIC
-device md
-device bpf
+# NFS root from boopt/dhcp
+#options BOOTP
+#options BOOTP_NFSROOT
+#options BOOTP_COMPAT
+#options BOOTP_NFSV3
+#options BOOTP_WIRED_TO=ate0
+
+options ROOTDEVNAME=\"ufs:/dev/mmcsd0s1a\"
+
+# kernel/memory size reduction
+options MUTEX_NOINLINE
+options NO_FFS_SNAPSHOT
+options NO_SWAPPING
+options RWLOCK_NOINLINE
+
+# The `bpf' device enables the Berkeley Packet Filter.
+# Be aware of the administrative consequences of enabling this!
+# Note that 'bpf' is required for DHCP.
+device bpf # Berkeley packet filter
+
+# Ethernet
+device mii # Minimal MII support
+device ate # Atmel AT91 Ethernet driver
+device lxtphy
+
+# I2C
+device at91_twi # Atmel AT91 Two-wire Interface
+device iic # I2C generic I/O device driver
+device iicbus # I2C bus system
+
+# DataFlash
+device at91_spi # Atmel AT91 Serial Peripheral Interface
+device spibus # SPI bus
+device at45d # Atmel AT45D
+
+# Pseudo devices.
+device loop # Network loopback
+device random # Entropy device
+device ether # Ethernet support
+device md # Memory "disks"
+
+# SCSI peripherals
+device scbus # SCSI bus (required for ATA/SCSI)
+device da # Direct Access (disks)
+device cd # CD
+device pass # Passthrough device (direct ATA/SCSI access)
+
+# Serial (COM) ports
+device uart # Multi-uart driver
+options ALT_BREAK_TO_DEBUGGER
# USB support
-device ohci # OHCI localbus->USB interface
+device ohci # OHCI USB interface
device usb # USB Bus (required)
#device udbp # USB Double Bulk Pipe devices
device uhid # "Human Interface Devices"
@@ -115,11 +138,7 @@ device miibus
#device uath # Atheros AR5523 wireless NICs
#device ural # Ralink Technology RT2500USB wireless NICs
#device zyd # ZyDAS zd1211/zd1211b wireless NICs
-# SCSI peripherals
-device scbus # SCSI bus (required for ATA/SCSI)
-device da # Direct Access (disks)
-device cd # CD
-device pass # Passthrough device (direct ATA/SCSI access)
+
# Wireless NIC cards
#device wlan # 802.11 support
#device wlan_wep # 802.11 WEP support
@@ -128,15 +147,12 @@ device pass # Passthrough device (direct ATA/SCSI access)
#device wlan_amrr # AMRR transmit rate control algorithm
options ROOTDEVNAME=\"ufs:da0s1a\"
+# watchdog
+device at91_wdt # Atmel AT91 Watchdog Timer
+
# NAND Flash - my board as 128MB Samsung part, YMMV.
device nand # NAND interface on CS3
-# SPI: Data Flash
-device at91_spi # SPI:
-device spibus
-device at45d # at45db642 and maybe others
-
-
# Coming soon, but not yet
options FDT
options FDT_DTB_STATIC
diff --git a/sys/arm/conf/IMX53 b/sys/arm/conf/IMX53
index 9f78f30..d07d6ad 100644
--- a/sys/arm/conf/IMX53
+++ b/sys/arm/conf/IMX53
@@ -20,47 +20,18 @@
ident IMX53
+include "std.armv6"
include "../freescale/imx/std.imx53"
options SOC_IMX53
options SCHED_4BSD # 4BSD scheduler
-options PREEMPTION # Enable kernel thread preemption
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options QUOTA # Enable disk quotas for UFS
-options NFSCL # Network Filesystem Client
#options NFSD # Network Filesystem Server
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options TMPFS # Efficient memory filesystem
-options GEOM_PART_GPT # GUID Partition Tables
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options GEOM_LABEL # Provides labelization
#options COMPAT_FREEBSD5 # Compatible with FreeBSD5
#options COMPAT_FREEBSD6 # Compatible with FreeBSD6
#options COMPAT_FREEBSD7 # Compatible with FreeBSD7
-options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
-options KTRACE # ktrace(1) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
options PLATFORM
options INCLUDE_CONFIG_FILE # Include this file in kernel
-options VFP # Enable floating point hardware support
# Debugging for use in -current
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
diff --git a/sys/arm/conf/IMX53-QSB b/sys/arm/conf/IMX53-QSB
index fdde591..5fa907c 100644
--- a/sys/arm/conf/IMX53-QSB
+++ b/sys/arm/conf/IMX53-QSB
@@ -19,7 +19,7 @@
#NO_UNIVERSE
-include "IMX53"
+include "IMX53"
ident IMX53-QSB
options HZ=250 # 4ms scheduling quantum
diff --git a/sys/arm/conf/IMX6 b/sys/arm/conf/IMX6
index f1baf29..f670336 100644
--- a/sys/arm/conf/IMX6
+++ b/sys/arm/conf/IMX6
@@ -19,45 +19,16 @@
# $FreeBSD$
ident IMX6
+include "std.armv6"
include "../freescale/imx/std.imx6"
options SOC_IMX6
options HZ=500 # Scheduling quantum is 2 milliseconds.
options SCHED_ULE # ULE scheduler
-options PREEMPTION # Enable kernel thread preemption
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options QUOTA # Enable disk quotas for UFS
-options NFSCL # Network Filesystem Client
#options NFSD # Network Filesystem Server
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options TMPFS # Efficient memory filesystem
-options GEOM_PART_GPT # GUID Partition Tables
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options GEOM_LABEL # Provides labelization
-options KTRACE # ktrace(1) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
options INCLUDE_CONFIG_FILE # Include this file in kernel
options PLATFORM
-options FREEBSD_BOOT_LOADER # Process metadata passed from loader(8)
-options VFP # Enable floating point hardware support
options SMP # Enable multiple cores
# Debugging for use in -current
@@ -87,6 +58,9 @@ options ALT_BREAK_TO_DEBUGGER # Use <CR><tilde><ctrl-b> to enter debugger.
# U-Boot stuff lives on slice 1, FreeBSD on slice 2.
options ROOTDEVNAME=\"ufs:mmcsd0s2a\"
+# Interrupt controller
+device gic
+
# Pseudo devices.
device loop # Network loopback
device random # Entropy device
diff --git a/sys/arm/conf/IQ31244 b/sys/arm/conf/IQ31244
index 2066fb8..ae8eae8 100644
--- a/sys/arm/conf/IQ31244
+++ b/sys/arm/conf/IQ31244
@@ -19,13 +19,14 @@
ident IQ31244
+include "std.arm"
options PHYSADDR=0xa0000000
options KERNPHYSADDR=0xa0200000
options KERNVIRTADDR=0xc0200000 # Used in ldscript.arm
options FLASHADDR=0xf0000000
options LOADERRAMADDR=0x00000000
-include "../xscale/i80321/std.iq31244"
+include "../xscale/i80321/std.iq31244"
makeoptions MODULES_OVERRIDE=""
#makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
diff --git a/sys/arm/conf/KB920X b/sys/arm/conf/KB920X
index 1fc23be..07aa62c 100644
--- a/sys/arm/conf/KB920X
+++ b/sys/arm/conf/KB920X
@@ -22,15 +22,14 @@
ident KB920X
-include "../at91/std.kb920x"
+include "std.arm"
+include "../at91/std.kb920x"
# The AT91 platform doesn't use /boot/loader, so we have to statically wire
# hints.
hints "KB920X.hints"
makeoptions MODULES_OVERRIDE=""
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
-options DDB
-options KDB
options SCHED_4BSD # 4BSD scheduler
options INET # InterNETworking
@@ -41,67 +40,98 @@ options FFS # Berkeley Fast Filesystem
#options UFS_DIRHASH # Improve performance on big directories
#options MD_ROOT # MD is a potential root device
#options MD_ROOT_SIZE=4096 # 4MB ram disk
-options ROOTDEVNAME=\"ufs:/dev/mmcsd0s1a\"
options NFSCL # Network Filesystem Client
#options NFSD # Network Filesystem Server
#options NFSLOCKD # Network Lock Manager
#options NFS_ROOT # NFS usable as /, requires NFSCL
-#options BOOTP_NFSROOT
-#options BOOTP
-
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
options TMPFS # Efficient memory filesystem
#options MSDOSFS # MSDOS Filesystem
#options CD9660 # ISO 9660 Filesystem
#options PROCFS # Process filesystem (requires PSEUDOFS)
options PSEUDOFS # Pseudo-filesystem framework
+options GEOM_PART_BSD # BSD partition scheme
+options GEOM_PART_MBR # MBR partition scheme
#options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
#options KTRACE # ktrace(1) support
options SYSVSHM # SYSV-style shared memory
options SYSVMSG # SYSV-style message queues
options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # Posix P1003_1B real-time extensions
-#options NO_SYSCTL_DESCR
-# Disable the inlining of mutex, rwlock and sx locks. These eat up a lot
-# of space.
-options MUTEX_NOINLINE
-options RWLOCK_NOINLINE
-options SX_NOINLINE
-options NO_FFS_SNAPSHOT
-options NO_SWAPPING
-device random
-device loop
-device ether
-device uart
-device ate
-device mii
-device lxtphy
+options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
# Debugging for use in -current
+options KDB # Enable kernel debugger support
+options DDB # Enable the kernel debugger
#options DEADLKRES # Enable the deadlock resolver
#options INVARIANTS # Enable calls of extra sanity checking
#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
#options WITNESS # Enable checks to detect deadlocks and cycles
#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
-device md
-device at91_twi # TWI: Two Wire Interface
-device at91_spi # SPI:
-device spibus
-# MMC/SD
-device at91_mci
-device mmc
-device mmcsd
-# iic
-device iic
-device iicbus
+# NFS root from boopt/dhcp
+#options BOOTP
+#options BOOTP_NFSROOT
+
+# alternatively, boot from a MMC/SD memory card
+options ROOTDEVNAME=\"ufs:/dev/mmcsd0s1a\"
+
+# kernel/memory size reduction
+options MUTEX_NOINLINE
+options SX_NOINLINE
+options NO_FFS_SNAPSHOT
+options NO_SWAPPING
+#options NO_SYSCTL_DESCR
+options RWLOCK_NOINLINE
+
+# The `bpf' device enables the Berkeley Packet Filter.
+# Be aware of the administrative consequences of enabling this!
+# Note that 'bpf' is required for DHCP.
+device bpf # Berkeley packet filter
+
+# Ethernet
+device mii # Minimal MII support
+device ate # Atmel AT91 Ethernet driver
+device lxtphy
+
+# I2C
+device at91_twi # Atmel AT91 Two-wire Interface
+device iic # I2C generic I/O device driver
+device iicbus # I2C bus system
device icee
-device bpf
+# MMC/SD
+device at91_mci # Atmel AT91 Multimedia Card Interface
+device mmc # MMC/SD bus
+device mmcsd # MMC/SD memory card
+
+# DataFlash
+device at91_spi # Atmel AT91 Serial Peripheral Interface
+device spibus # SPI bus
+
+# Pseudo devices.
+device loop # Network loopback
+device random # Entropy device
+device ether # Ethernet support
+device md # Memory "disks"
+
+# SCSI peripherals
+device scbus # SCSI bus (required for ATA/SCSI)
+device da # Direct Access (disks)
+device cd # CD
+device pass # Passthrough device (direct ATA/SCSI access)
+
+# Serial (COM) ports
+device uart # Multi-uart driver
+
+# Wireless NIC cards
+device wlan # 802.11 support
+device wlan_wep # 802.11 WEP support
+device wlan_ccmp # 802.11 CCMP support
+device wlan_tkip # 802.11 TKIP support
+device wlan_amrr # AMRR transmit rate control algorithm
+
# USB support
options USB_DEBUG # enable debug msgs
-device ohci # OHCI localbus->USB interface
+device ohci # OHCI USB interface
device usb # USB Bus (required)
#device udbp # USB Double Bulk Pipe devices
device uhid # "Human Interface Devices"
@@ -131,17 +161,6 @@ device rum # Ralink Technology RT2501USB wireless NICs
device uath # Atheros AR5523 wireless NICs
device ural # Ralink Technology RT2500USB wireless NICs
device zyd # ZyDAS zd1211/zd1211b wireless NICs
-# SCSI peripherals
-device scbus # SCSI bus (required for ATA/SCSI)
-device da # Direct Access (disks)
-device cd # CD
-device pass # Passthrough device (direct ATA/SCSI access)
-# Wireless NIC cards
-device wlan # 802.11 support
-device wlan_wep # 802.11 WEP support
-device wlan_ccmp # 802.11 CCMP support
-device wlan_tkip # 802.11 TKIP support
-device wlan_amrr # AMRR transmit rate control algorithm
# USB device (gadget) support
device at91_dci # Atmel's usb device
diff --git a/sys/arm/conf/LN2410SBC b/sys/arm/conf/LN2410SBC
index b2f64a0..a154c32 100644
--- a/sys/arm/conf/LN2410SBC
+++ b/sys/arm/conf/LN2410SBC
@@ -19,6 +19,7 @@
ident LN2410SBC
+include "std.arm"
include "../samsung/s3c2xx0/std.ln2410sbc"
#To statically compile in device wiring instead of /boot/device.hints
#hints "GENERIC.hints" # Default places to look for devices.
diff --git a/sys/arm/conf/NSLU b/sys/arm/conf/NSLU
index e12c5a5..665910a 100644
--- a/sys/arm/conf/NSLU
+++ b/sys/arm/conf/NSLU
@@ -21,6 +21,7 @@
ident NSLU
+include "std.arm"
# XXX What is defined in std.avila does not exactly match the following:
#options PHYSADDR=0x10000000
#options KERNPHYSADDR=0x10200000
@@ -28,9 +29,9 @@ ident NSLU
#options FLASHADDR=0x50000000
#options LOADERRAMADDR=0x00000000
-include "../xscale/ixp425/std.ixp425"
+include "../xscale/ixp425/std.ixp425"
# NB: memory mapping is defined in std.avila (see also comment above)
-include "../xscale/ixp425/std.avila"
+include "../xscale/ixp425/std.avila"
options XSCALE_CACHE_READ_WRITE_ALLOCATE
#To statically compile in device wiring instead of /boot/device.hints
hints "NSLU.hints" # Default places to look for devices.
diff --git a/sys/arm/conf/ODROIDC1 b/sys/arm/conf/ODROIDC1
index 7bb7b56..88836e3 100644
--- a/sys/arm/conf/ODROIDC1
+++ b/sys/arm/conf/ODROIDC1
@@ -22,5 +22,10 @@
include "AML8726"
ident ODROIDC1
+options SMP # Enable multiple cores
+
+# Interrupt controller
+device gic
+
options FDT_DTB_STATIC
makeoptions FDT_DTS_FILE=odroidc1.dts
diff --git a/sys/arm/conf/PANDABOARD b/sys/arm/conf/PANDABOARD
index e0b5d14..0e1dec0 100644
--- a/sys/arm/conf/PANDABOARD
+++ b/sys/arm/conf/PANDABOARD
@@ -27,42 +27,12 @@ ident PANDABOARD
hints "PANDABOARD.hints"
+include "std.armv6"
include "../ti/omap4/pandaboard/std.pandaboard"
options HZ=100
options SCHED_ULE # ULE scheduler
-options PREEMPTION # Enable kernel thread preemption
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options QUOTA # Enable disk quotas for UFS
-options NFSCL # Network Filesystem Client
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options TMPFS # Efficient memory filesystem
-options GEOM_PART_GPT # GUID Partition Tables
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!]
-options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
-options KTRACE # ktrace(1) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
options PLATFORM
-options FREEBSD_BOOT_LOADER # Process metadata passed from loader(8)
-options VFP # Enable floating point hardware support
options SMP # Enable multiple cores
# Debugging for use in -current
@@ -87,6 +57,10 @@ options DDB # Enable the kernel debugger
#options BOOTP_NFSV3
#options BOOTP_WIRED_TO=ue0
+device fdt_pinctrl
+# Interrupt controller
+device gic
+
# MMC/SD/SDIO Card slot support
device mmc # mmc/sd bus
device mmcsd # mmc/sd flash cards
@@ -108,6 +82,7 @@ device pl310 # PL310 L2 cache controller
# GPIO
device gpio
+device gpioled
# The following enables MFS as root, this seems similar to an initramfs or initrd
# as used in Linux.
diff --git a/sys/arm/conf/QILA9G20 b/sys/arm/conf/QILA9G20
index 7559c31..5117566 100644
--- a/sys/arm/conf/QILA9G20
+++ b/sys/arm/conf/QILA9G20
@@ -22,15 +22,14 @@
ident QILA9G20
-include "../at91/std.qila9g20"
+include "std.arm"
+include "../at91/std.qila9g20"
#To statically compile in device wiring instead of /boot/device.hints
hints "QILA9G20.hints"
makeoptions MODULES_OVERRIDE=""
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
-options DDB
-options KDB
options SCHED_4BSD # 4BSD scheduler
options INET # InterNETworking
@@ -45,76 +44,81 @@ options NFSCL # Network Filesystem Client
#options NFSD # Network Filesystem Server
#options NFSLOCKD # Network Lock Manager
#options NFS_ROOT # NFS usable as /, requires NFSCL
-#options BOOTP_NFSROOT
-#options BOOTP
-#options BOOTP_NFSV3
-#options BOOTP_WIRED_TO=ate0
-#options BOOTP_COMPAT
-
-options ROOTDEVNAME=\"ufs:/dev/mmcsd0s1a\"
-
-options ALT_BREAK_TO_DEBUGGER
-
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
options TMPFS # Efficient memory filesystem
#options MSDOSFS # MSDOS Filesystem
#options CD9660 # ISO 9660 Filesystem
#options PROCFS # Process filesystem (requires PSEUDOFS)
#options PSEUDOFS # Pseudo-filesystem framework
+options GEOM_PART_BSD # BSD partition scheme
+options GEOM_PART_MBR # MBR partition scheme
#options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
#options KTRACE # ktrace(1) support
options SYSVSHM # SYSV-style shared memory
options SYSVMSG # SYSV-style message queues
options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING #Posix P1003_1B real-time extensions
-options MUTEX_NOINLINE
-options RWLOCK_NOINLINE
-options NO_FFS_SNAPSHOT
-options NO_SWAPPING
+options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
# Debugging for use in -current
+options KDB # Enable kernel debugger support
+options DDB # Enable the kernel debugger
#options INVARIANTS # Enable calls of extra sanity checking
#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
#options WITNESS # Enable checks to detect deadlocks and cycles
#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
#options DIAGNOSTIC
-device random
-device loop
-device bpf
-device ether
-device md
+# NFS root from boopt/dhcp
+#options BOOTP
+#options BOOTP_NFSROOT
+#options BOOTP_COMPAT
+#options BOOTP_NFSV3
+#options BOOTP_WIRED_TO=ate0
-device uart # Serial Ports
+# alternatively, boot from a MMC/SD memory card
+options ROOTDEVNAME=\"ufs:/dev/mmcsd0s1a\"
-# Ethernet
-device ate # Ethernet Driver
-device mii
-option AT91_ATE_USE_RMII
+# kernel/memory size reduction
+options MUTEX_NOINLINE
+options NO_FFS_SNAPSHOT
+options NO_SWAPPING
+options RWLOCK_NOINLINE
+
+# The `bpf' device enables the Berkeley Packet Filter.
+# Be aware of the administrative consequences of enabling this!
+# Note that 'bpf' is required for DHCP.
+device bpf # Berkeley packet filter
-device at91_twi # TWI: Two Wire Interface (EEPROM)
-device at91_wdt # WDT: Watchdog timer
+# Ethernet
+device mii # Minimal MII support
+device ate # Atmel AT91 Ethernet driver
+options AT91_ATE_USE_RMII
+
+# I2C
+device at91_twi # Atmel AT91 Two-wire Interface
+device iic # I2C generic I/O device driver
+device iicbus # I2C bus system
+device icee
# NOTE: SPI DataFlash and mci/mmc/mmcsd have hardware
# confilict on this card. Use one or the other.
# see board_sam9g20ek.c
-# SPI: Data Flash
-#device at91_spi # SPI:
-#device spibus
-#device at45d # at45db642 and maybe others
-
# MMC/SD
-device at91_mci
-device mmc
-device mmcsd
-option AT91_MCI_HAS_4WIRE
-
-# iic
-device iic
-device iicbus
-device icee
+device at91_mci # Atmel AT91 Multimedia Card Interface
+options AT91_MCI_HAS_4WIRE
+device mmc # MMC/SD bus
+device mmcsd # MMC/SD memory card
+
+# DataFlash
+#device at91_spi # Atmel AT91 Serial Peripheral Interface
+#device spibus # SPI bus
+#device at45d # Atmel AT45D
+
+# Pseudo devices.
+device loop # Network loopback
+device random # Entropy device
+device ether # Ethernet support
+device md # Memory "disks"
# SCSI peripherals
device scbus # SCSI bus (required for ATA/SCSI)
@@ -122,8 +126,12 @@ device da # Direct Access (disks)
device cd # CD
device pass # Passthrough device (direct ATA/SCSI access)
+# Serial (COM) ports
+device uart # Multi-uart driver
+options ALT_BREAK_TO_DEBUGGER
+
# USB support
-device ohci # OHCI localbus->USB interface
+device ohci # OHCI USB interface
device usb # USB Bus (required)
device umass # Disks/Mass storage - Requires scbus and da
device uhid # "Human Interface Devices"
@@ -153,3 +161,5 @@ device udav # Davicom DM9601E USB
#device wlan_tkip # 802.11 TKIP support
#device wlan_amrr # AMRR transmit rate control algorithm
+# watchdog
+device at91_wdt # Atmel AT91 Watchdog Timer
diff --git a/sys/arm/conf/QUARTZ b/sys/arm/conf/QUARTZ
index 04f1b5c..9c98185 100644
--- a/sys/arm/conf/QUARTZ
+++ b/sys/arm/conf/QUARTZ
@@ -19,7 +19,7 @@
#NO_UNIVERSE
-include "VYBRID"
+include "VYBRID"
ident QUARTZ
#FDT
diff --git a/sys/arm/conf/RADXA b/sys/arm/conf/RADXA
index ad5eadf..8801f67 100644
--- a/sys/arm/conf/RADXA
+++ b/sys/arm/conf/RADXA
@@ -20,7 +20,7 @@
#NO_UNIVERSE
-include "RK3188"
+include "RK3188"
ident RADXA
# Flattened Device Tree
diff --git a/sys/arm/conf/RADXA-LITE b/sys/arm/conf/RADXA-LITE
index c07462d..7252941 100644
--- a/sys/arm/conf/RADXA-LITE
+++ b/sys/arm/conf/RADXA-LITE
@@ -20,7 +20,7 @@
#NO_UNIVERSE
-include "RK3188"
+include "RK3188"
ident RADXA-LITE
# Flattened Device Tree
diff --git a/sys/arm/conf/RK3188 b/sys/arm/conf/RK3188
index 64065d3..540b49e 100644
--- a/sys/arm/conf/RK3188
+++ b/sys/arm/conf/RK3188
@@ -20,41 +20,11 @@
ident RK3188
-include "../rockchip/std.rk30xx"
+include "std.armv6"
+include "../rockchip/std.rk30xx"
options HZ=100
options SCHED_ULE # ULE scheduler
-options PREEMPTION # Enable kernel thread preemption
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options QUOTA # Enable disk quotas for UFS
-options NFSCL # Network Filesystem Client
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options TMPFS # Efficient memory filesystem
-options GEOM_PART_GPT # GUID Partition Tables
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!]
-options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
-options KTRACE # ktrace(1) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
-options FREEBSD_BOOT_LOADER # Process metadata passed from loader(8)
-options VFP # Enable floating point hardware support
options SMP # Enable multiple cores
# Debugging for use in -current
@@ -75,6 +45,9 @@ options DIAGNOSTIC
# Root mount from MMC/SD card
options ROOTDEVNAME=\"ufs:/dev/mmcsd0\"
+# Interrupt controller
+device gic
+
# MMC/SD/SDIO Card slot support
device mmc # mmc/sd bus
device mmcsd # mmc/sd flash cards
diff --git a/sys/arm/conf/RPI-B b/sys/arm/conf/RPI-B
index 0604a97..9193bca 100644
--- a/sys/arm/conf/RPI-B
+++ b/sys/arm/conf/RPI-B
@@ -20,43 +20,13 @@
ident RPI-B
-include "../broadcom/bcm2835/std.rpi"
-include "../broadcom/bcm2835/std.bcm2835"
+include "std.armv6"
+include "../broadcom/bcm2835/std.rpi"
+include "../broadcom/bcm2835/std.bcm2835"
options HZ=100
options SCHED_4BSD # 4BSD scheduler
-options PREEMPTION # Enable kernel thread preemption
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options QUOTA # Enable disk quotas for UFS
-options NFSCL # Network Filesystem Client
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options TMPFS # Efficient memory filesystem
-options GEOM_PART_GPT # GUID Partition Tables
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!]
-options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
-options KTRACE # ktrace(1) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
options PLATFORM
-options FREEBSD_BOOT_LOADER # Process metadata passed from loader(8)
-options VFP # Enable floating point hardware support
# Debugging for use in -current
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
diff --git a/sys/arm/conf/RPI2 b/sys/arm/conf/RPI2
index 18d97d7..27caac9 100644
--- a/sys/arm/conf/RPI2
+++ b/sys/arm/conf/RPI2
@@ -1,5 +1,5 @@
#
-# RPI-B -- Custom configuration for the Raspberry Pi
+# RPI2 -- Custom configuration for the Raspberry Pi 2
#
# For more information on this file, please read the config(5) manual page,
# and/or the handbook section on Kernel Configuration Files:
@@ -18,45 +18,16 @@
#
# $FreeBSD$
-ident RPI-B
+ident RPI2
-include "../broadcom/bcm2835/std.rpi"
-include "../broadcom/bcm2835/std.bcm2836"
+include "std.armv6"
+include "../broadcom/bcm2835/std.rpi"
+include "../broadcom/bcm2835/std.bcm2836"
options HZ=100
-options SCHED_4BSD # 4BSD scheduler
-options PREEMPTION # Enable kernel thread preemption
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options QUOTA # Enable disk quotas for UFS
-options NFSCL # Network Filesystem Client
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options TMPFS # Efficient memory filesystem
-options GEOM_PART_GPT # GUID Partition Tables
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!]
-options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
-options KTRACE # ktrace(1) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
+options SCHED_ULE # ULE scheduler
+options SMP # Enable multiple cores
options PLATFORM
-options FREEBSD_BOOT_LOADER # Process metadata passed from loader(8)
-options VFP # Enable floating point hardware support
# Debugging for use in -current
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
@@ -130,8 +101,8 @@ device smsc
device spibus
device bcm2835_spi
-#device vchiq
-#device sound
+device vchiq
+device sound
# Flattened Device Tree
options FDT # Configure using FDT/DTB data
diff --git a/sys/arm/conf/SAM9260EK b/sys/arm/conf/SAM9260EK
index 7e88ee1..a3c7759 100644
--- a/sys/arm/conf/SAM9260EK
+++ b/sys/arm/conf/SAM9260EK
@@ -21,7 +21,8 @@
ident SAM9260EK
-include "../at91/std.sam9260ek"
+include "std.arm"
+include "../at91/std.sam9260ek"
# To statically compile in device wiring instead of /boot/device.hints
hints "SAM9260EK.hints"
@@ -72,10 +73,24 @@ options PRINTF_BUFR_SIZE=128 # Prevent printf output being interspersed.
#options MAC # TrustedBSD MAC Framework
#options INCLUDE_CONFIG_FILE # Include this file in kernel
-# required for netbooting
+# Debugging support. Always need this:
+#options KDB # Enable kernel debugger support
+# For minimum debugger support (stable branch) use:
+#options KDB_TRACE # Print a stack trace for a panic
+# For full debugger support use this instead:
+#options DDB # Enable the kernel debugger
+#options GDB # Support remote GDB
+#options DEADLKRES # Enable the deadlock resolver
+#options INVARIANTS # Enable calls of extra sanity checking
+#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
+#options WITNESS # Enable checks to detect deadlocks and cycles
+#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
+#options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
+
+# NFS root from boopt/dhcp
#options BOOTP
-#options BOOTP_COMPAT
#options BOOTP_NFSROOT
+#options BOOTP_COMPAT
#options BOOTP_NFSV3
#options BOOTP_WIRED_TO=ate0
@@ -92,20 +107,6 @@ options NO_SWAPPING
options NO_SYSCTL_DESCR
options RWLOCK_NOINLINE
-# Debugging support. Always need this:
-#options KDB # Enable kernel debugger support.
-# For minimum debugger support (stable branch) use:
-#options KDB_TRACE # Print a stack trace for a panic.
-# For full debugger support use this instead:
-#options DDB # Support DDB.
-#options GDB # Support remote GDB.
-#options DEADLKRES # Enable the deadlock resolver
-#options INVARIANTS # Enable calls of extra sanity checking
-#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
-#options WITNESS # Enable checks to detect deadlocks and cycles
-#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
-#options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
-
# The `bpf' device enables the Berkeley Packet Filter.
# Be aware of the administrative consequences of enabling this!
# Note that 'bpf' is required for DHCP.
diff --git a/sys/arm/conf/SAM9G20EK b/sys/arm/conf/SAM9G20EK
index 7f3d15c..a6816ec 100644
--- a/sys/arm/conf/SAM9G20EK
+++ b/sys/arm/conf/SAM9G20EK
@@ -1,4 +1,5 @@
# Kernel configuration for Atmel AT91SAM9G20EK Rev B. development card
+# Many after-market boards follow its conventions.
#
# For more information on this file, please read the handbook section on
# Kernel Configuration Files:
@@ -19,21 +20,18 @@
ident SAM9G20EK
-include "../at91/std.sam9g20ek"
+include "std.arm"
+include "../at91/std.sam9g20ek"
#To statically compile in device wiring instead of /boot/device.hints
hints "SAM9G20EK.hints"
makeoptions MODULES_OVERRIDE=""
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
-options DDB
-options KDB
options SCHED_4BSD # 4BSD scheduler
options INET # InterNETworking
#options INET6 # IPv6 communications protocols
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
options TMPFS # Efficient memory filesystem
options FFS # Berkeley Fast Filesystem
#options SOFTUPDATES # Enable FFS soft updates support
@@ -43,80 +41,86 @@ options FFS # Berkeley Fast Filesystem
#options MD_ROOT_SIZE=4096 # 4MB ram disk
options NANDFS # NAND file system
options NFSCL # Network Filesystem Client
-#options NFSD # Network Filesystem Server
-#options NFSLOCKD # Network Lock Manager
+options NFSD # Network Filesystem Server
+options NFSLOCKD # Network Lock Manager
#options NFS_ROOT # NFS usable as /, requires NFSCL
-#options BOOTP_NFSROOT
-#options BOOTP
-#options BOOTP_NFSV3
-#options BOOTP_WIRED_TO=ate0
-#options BOOTP_COMPAT
-
-options ROOTDEVNAME=\"ufs:/dev/mmcsd0s1a\"
-
-options ALT_BREAK_TO_DEBUGGER
-
#options MSDOSFS # MSDOS Filesystem
#options CD9660 # ISO 9660 Filesystem
#options PROCFS # Process filesystem (requires PSEUDOFS)
#options PSEUDOFS # Pseudo-filesystem framework
+options GEOM_PART_BSD # BSD partition scheme
+options GEOM_PART_MBR # MBR partition scheme
#options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
#options KTRACE # ktrace(1) support
options SYSVSHM # SYSV-style shared memory
options SYSVMSG # SYSV-style message queues
options SYSVSEM # SYSV-style semaphores
options _KPOSIX_PRIORITY_SCHEDULING # Posix P1003_1B real-time extensions
-options MUTEX_NOINLINE
-options RWLOCK_NOINLINE
-options NO_FFS_SNAPSHOT
-options NO_SWAPPING
-# Debugging for use in -current
+# Debugging support. Always need this:
+options KDB # Enable kernel debugger support
+options DDB # Enable the kernel debugger
+# Always turn these off, even in -current builds, they are too slow.
#options INVARIANTS # Enable calls of extra sanity checking
#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
#options WITNESS # Enable checks to detect deadlocks and cycles
#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
#options DIAGNOSTIC
-device random
-device loop
-device bpf
-device ether
-device md
+# NFS root from boopt/dhcp
+#options BOOTP
+#options BOOTP_NFSROOT
+#options BOOTP_COMPAT
+#options BOOTP_NFSV3
+#options BOOTP_WIRED_TO=ate0
+
+# s2 because s1 is reserved for the DOS parittions sometimes needed to
+# boot off SD cards on the G20 and newer chips.
+options ROOTDEVNAME=\"ufs:/dev/mmcsd0s2a\"
-device uart # Serial Ports
+# kernel/memory size reduction
+options MUTEX_NOINLINE
+options NO_FFS_SNAPSHOT
+options NO_SWAPPING
+options NO_SYSCTL_DESCR
+options RWLOCK_NOINLINE
-# Ethernet
-device ate # Ethernet Driver
-device mii
-option AT91_ATE_USE_RMII
+# The `bpf' device enables the Berkeley Packet Filter.
+# Be aware of the administrative consequences of enabling this!
+# Note that 'bpf' is required for DHCP.
+device bpf # Berkeley packet filter
-device at91_twi # TWI: Two Wire Interface (EEPROM)
-device at91_wdt # WDT: Watchdog timer
+# Ethernet
+device mii # Minimal MII support
+device ate # Atmel AT91 Ethernet driver
+options AT91_ATE_USE_RMII
+
+# I2C
+device at91_twi # Atmel AT91 Two-wire Interface
+device iic # I2C generic I/O device driver
+device iicbus # I2C bus system
+device icee
-# NAND Flash - Reference design has Samsung 256MB but others possible
-device nand # NAND interface on CS3
+# MMC/SD
+device at91_mci # Atmel AT91 Multimedia Card Interface
+options AT91_MCI_HAS_4WIRE
+options AT91_MCI_SLOT_B
+device mmc # MMC/SD bus
+device mmcsd # MMC/SD memory card
+# DataFlash
# NOTE: SPI DataFlash and mci/mmc/mmcsd have hardware
# confilict on this card. Use one or the other.
# see board_sam9g20ek.c
-
-# SPI: Data Flash
-#device at91_spi # SPI:
-#device spibus
+#device at91_spi # Atmel AT91 Serial Peripheral Interface
+#device spibus # SPI bus
#device at45d # at45db642 and maybe others
-# MMC/SD
-device at91_mci
-device mmc
-device mmcsd
-option AT91_MCI_SLOT_B
-option AT91_MCI_HAS_4WIRE
-
-# iic
-device iic
-device iicbus
-device icee
+# Pseudo devices.
+device loop # Network loopback
+device random # Entropy device
+device ether # Ethernet support
+device md # Memory "disks"
# SCSI peripherals
device scbus # SCSI bus (required for ATA/SCSI)
@@ -124,8 +128,12 @@ device da # Direct Access (disks)
device cd # CD
device pass # Passthrough device (direct ATA/SCSI access)
+# Serial (COM) ports
+device uart # Multi-uart driver
+options ALT_BREAK_TO_DEBUGGER
+
# USB support
-device ohci # OHCI localbus->USB interface
+device ohci # OHCI USB interface
device usb # USB Bus (required)
device umass # Disks/Mass storage - Requires scbus and da
device uhid # "Human Interface Devices"
@@ -154,3 +162,9 @@ device uhid # "Human Interface Devices"
#device wlan_ccmp # 802.11 CCMP support
#device wlan_tkip # 802.11 TKIP support
#device wlan_amrr # AMRR transmit rate control algorithm
+
+# watchdog
+device at91_wdt # Atmel AT91 Watchdog Timer
+
+# NAND Flash - Reference design has Samsung 256MB but others possible
+device nand # NAND interface on CS3
diff --git a/sys/arm/conf/SAM9X25EK b/sys/arm/conf/SAM9X25EK
index 419e456..ff2e97c 100644
--- a/sys/arm/conf/SAM9X25EK
+++ b/sys/arm/conf/SAM9X25EK
@@ -21,7 +21,8 @@
ident SAM9X25EK
-include "../at91/std.sam9x25ek"
+include "std.arm"
+include "../at91/std.sam9x25ek"
#To statically compile in device wiring instead of /boot/device.hints
hints "SAM9G20EK.hints"
@@ -34,9 +35,6 @@ options KDB
options SCHED_4BSD # 4BSD scheduler
options INET # InterNETworking
#options INET6 # IPv6 communications protocols
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options TMPFS # Efficient memory filesystem
options FFS # Berkeley Fast Filesystem
#options SOFTUPDATES # Enable FFS soft updates support
#options UFS_ACL # Support for access control lists
@@ -47,30 +45,20 @@ options NFSCL # Network Filesystem Client
#options NFSD # Network Filesystem Server
#options NFSLOCKD # Network Lock Manager
#options NFS_ROOT # NFS usable as /, requires NFSCL
-#options BOOTP_NFSROOT
-#options BOOTP
-#options BOOTP_NFSV3
-#options BOOTP_WIRED_TO=ate0
-#options BOOTP_COMPAT
-
-options ROOTDEVNAME=\"ufs:/dev/mmcsd0s1a\"
-
-options ALT_BREAK_TO_DEBUGGER
-
+options TMPFS # Efficient memory filesystem
#options MSDOSFS # MSDOS Filesystem
#options CD9660 # ISO 9660 Filesystem
#options PROCFS # Process filesystem (requires PSEUDOFS)
#options PSEUDOFS # Pseudo-filesystem framework
+options GEOM_PART_BSD # BSD partition scheme
+options GEOM_PART_MBR # MBR partition scheme
#options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
#options KTRACE # ktrace(1) support
options SYSVSHM # SYSV-style shared memory
options SYSVMSG # SYSV-style message queues
options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # Posix P1003_1B real-time extensions
-options MUTEX_NOINLINE
-options RWLOCK_NOINLINE
-options NO_FFS_SNAPSHOT
-options NO_SWAPPING
+options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
+
# Debugging for use in -current
#options INVARIANTS # Enable calls of extra sanity checking
@@ -79,43 +67,60 @@ options NO_SWAPPING
#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
#options DIAGNOSTIC
-device random
-device pty
-device loop
-device bpf
-device ether
-device md
+# NFS root from boopt/dhcp
+#options BOOTP
+#options BOOTP_NFSROOT
+#options BOOTP_COMPAT
+#options BOOTP_NFSV3
+#options BOOTP_WIRED_TO=ate0
+
+# alternatively, boot from a MMC/SD memory card
+options ROOTDEVNAME=\"ufs:/dev/mmcsd0s1a\"
+
+# kernel/memory size reduction
+options MUTEX_NOINLINE
+options NO_FFS_SNAPSHOT
+options NO_SWAPPING
+options RWLOCK_NOINLINE
-device uart # Serial Ports
+# The `bpf' device enables the Berkeley Packet Filter.
+# Be aware of the administrative consequences of enabling this!
+# Note that 'bpf' is required for DHCP.
+device bpf # Berkeley packet filter
# Ethernet
-device ate # Ethernet Driver
-device mii
-option AT91_ATE_USE_RMII
+device mii # Minimal MII support
+device ate # Atmel AT91 Ethernet driver
+options AT91_ATE_USE_RMII
-#device at91_twi # TWI: Two Wire Interface (EEPROM)
-device at91_wdt # WDT: Watchdog timer
+# I2C
+#device at91_twi # Atmel AT91 Two-wire Interface
+device iic
+device iicbus
+device icee
# NOTE: SPI DataFlash and mci/mmc/mmcsd have hardware
# confilict on this card. Use one or the other.
# see board_sam9g20ek.c
-# SPI: Data Flash
-#device at91_spi # SPI:
-#device spibus
-#device at45d # at45db642 and maybe others
-
# MMC/SD
-device at91_mci
-device mmc
-device mmcsd
-#option AT91_MCI_SLOT_B
-option AT91_MCI_HAS_4WIRE
-
-# iic
-device iic
-device iicbus
-device icee
+device at91_mci # Atmel AT91 Multimedia Card Interface
+options AT91_MCI_HAS_4WIRE
+#options AT91_MCI_SLOT_B
+device mmc # MMC/SD bus
+device mmcsd # MMC/SD memory card
+
+# DataFlash
+#device at91_spi # Atmel AT91 Serial Peripheral Interface
+#device spibus # SPI bus
+#device at45d # Atmel AT45D
+
+# Pseudo devices.
+device loop # Network loopback
+device random # Entropy device
+device ether # Ethernet support
+device md # Memory "disks"
+device pty
# SCSI peripherals
device scbus # SCSI bus (required for ATA/SCSI)
@@ -123,8 +128,12 @@ device da # Direct Access (disks)
device cd # CD
device pass # Passthrough device (direct ATA/SCSI access)
+# Serial (COM) ports
+device uart # Multi-uart driver
+options ALT_BREAK_TO_DEBUGGER
+
# USB support
-#device ohci # OHCI localbus->USB interface
+#device ohci # OHCI USB interface
#device usb # USB Bus (required)
#device umass # Disks/Mass storage - Requires scbus and da
#device uhid # "Human Interface Devices"
@@ -154,3 +163,5 @@ device miibus
#device wlan_tkip # 802.11 TKIP support
#device wlan_amrr # AMRR transmit rate control algorithm
+# watchdog
+device at91_wdt # Atmel AT91 Watchdog Timer
diff --git a/sys/arm/conf/SHEEVAPLUG b/sys/arm/conf/SHEEVAPLUG
index 9d8ea26..507ba75 100644
--- a/sys/arm/conf/SHEEVAPLUG
+++ b/sys/arm/conf/SHEEVAPLUG
@@ -6,49 +6,52 @@
#NO_UNIVERSE
ident SHEEVAPLUG
-include "../mv/kirkwood/std.db88f6xxx"
+include "std.arm"
+include "../mv/kirkwood/std.db88f6xxx"
options SOC_MV_KIRKWOOD
-#makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
makeoptions WERROR="-Werror"
+options HZ=1000
options SCHED_4BSD # 4BSD scheduler
options INET # InterNETworking
options INET6 # IPv6 communications protocols
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options TMPFS # Efficient memory filesystem
options FFS # Berkeley Fast Filesystem
options NANDFS # NAND Filesystem
options NFSCL # Network Filesystem Client
options NFSLOCKD # Network Lock Manager
options NFS_ROOT # NFS usable as /, requires NFSCL
-options BOOTP
-options BOOTP_NFSROOT
-options BOOTP_NFSV3
-options BOOTP_WIRED_TO=mge0
-
-# Root fs on USB device
-#options ROOTDEVNAME=\"ufs:/dev/da0a\"
-
+options TMPFS # Efficient memory filesystem
+options GEOM_PART_BSD # BSD partition scheme
+options GEOM_PART_MBR # MBR partition scheme
options SYSVSHM # SYSV-style shared memory
options SYSVMSG # SYSV-style message queues
options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # Posix P1003_1B real-time extensions
+options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
options MUTEX_NOINLINE
options RWLOCK_NOINLINE
options NO_FFS_SNAPSHOT
options NO_SWAPPING
-# Debugging
+# Debugging for use in -current
+#makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
options ALT_BREAK_TO_DEBUGGER
-options DDB
-options KDB
+options KDB # Enable kernel debugger support
+options DDB # Enable the kernel debugger
+
+# NFS root from boopt/dhcp
+options BOOTP
+options BOOTP_NFSROOT
+options BOOTP_NFSV3
+options BOOTP_WIRED_TO=mge0
+
+# Root fs on USB device
+#options ROOTDEVNAME=\"ufs:/dev/da0a\"
# Pseudo devices
-device random
device loop
+device random
# Serial ports
device uart
@@ -59,7 +62,6 @@ device mge # Marvell Gigabit Ethernet controller
device mii
device e1000phy
device bpf
-options HZ=1000
options DEVICE_POLLING
device vlan
@@ -80,6 +82,6 @@ device da
device nand
# Flattened Device Tree
-options FDT
+options FDT # Configure using FDT/DTB data
options FDT_DTB_STATIC
makeoptions FDT_DTS_FILE=sheevaplug.dts
diff --git a/sys/arm/conf/SN9G45 b/sys/arm/conf/SN9G45
index dec6681..28d2c25 100644
--- a/sys/arm/conf/SN9G45
+++ b/sys/arm/conf/SN9G45
@@ -21,15 +21,14 @@
ident SN9G45
-include "../at91/std.sn9g45"
+include "std.arm"
+include "../at91/std.sn9g45"
#To statically compile in device wiring instead of /boot/device.hints
#hints "SN9G45.hints"
makeoptions MODULES_OVERRIDE=""
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
-options DDB
-options KDB
options SCHED_4BSD # 4BSD scheduler
options INET # InterNETworking
@@ -44,55 +43,60 @@ options NFSCL # Network Filesystem Client
#options NFSD # Network Filesystem Server
#options NFSLOCKD # Network Lock Manager
#options NFS_ROOT # NFS usable as /, requires NFSCL
-#options BOOTP_NFSROOT
-#options BOOTP
-#options BOOTP_NFSV3
-#options BOOTP_WIRED_TO=ate0
-#options BOOTP_COMPAT
-
-options ROOTDEVNAME=\"ufs:/dev/da0s1\"
-
-options ALT_BREAK_TO_DEBUGGER
-
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
options TMPFS # Efficient memory filesystem
#options MSDOSFS # MSDOS Filesystem
#options CD9660 # ISO 9660 Filesystem
#options PROCFS # Process filesystem (requires PSEUDOFS)
#options PSEUDOFS # Pseudo-filesystem framework
+options GEOM_PART_BSD # BSD partition scheme
+options GEOM_PART_MBR # MBR partition scheme
options SCSI_DELAY=1000 # Delay (in ms) before probing SCSI
#options KTRACE # ktrace(1) support
options SYSVSHM # SYSV-style shared memory
options SYSVMSG # SYSV-style message queues
options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # Posix P1003_1B real-time extensions
-options MUTEX_NOINLINE
-options RWLOCK_NOINLINE
-options NO_FFS_SNAPSHOT
-options NO_SWAPPING
+options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
# Debugging for use in -current
+options KDB # Enable kernel debugger support
+options DDB # Enable the kernel debugger
#options INVARIANTS # Enable calls of extra sanity checking
#options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
#options WITNESS # Enable checks to detect deadlocks and cycles
#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
#options DIAGNOSTIC
-device random
-device loop
-device bpf
-device ether
-device md
+# NFS root from boopt/dhcp
+#options BOOTP
+#options BOOTP_NFSROOT
+#options BOOTP_COMPAT
+#options BOOTP_NFSV3
+#options BOOTP_WIRED_TO=ate0
+
+# alternatively, boot from a MMC/SD memory card
+options ROOTDEVNAME=\"ufs:/dev/da0s1\"
+
+# kernel/memory size reduction
+options MUTEX_NOINLINE
+options NO_FFS_SNAPSHOT
+options NO_SWAPPING
+options RWLOCK_NOINLINE
-device uart # Serial Ports
+# The `bpf' device enables the Berkeley Packet Filter.
+# Be aware of the administrative consequences of enabling this!
+# Note that 'bpf' is required for DHCP.
+device bpf # Berkeley packet filter
# Ethernet
-device ate # Ethernet Driver
-device mii
-option AT91_ATE_USE_RMII
+device mii # Minimal MII support
+device ate # Atmel AT91 Ethernet driver
+options AT91_ATE_USE_RMII
-device at91_wdt # WDT: Watchdog timer
+# Pseudo devices.
+device loop # Network loopback
+device random # Entropy device
+device ether # Ethernet support
+device md # Memory "disks"
# SCSI peripherals
device scbus # SCSI bus (required for ATA/SCSI)
@@ -100,8 +104,12 @@ device da # Direct Access (disks)
device cd # CD
device pass # Passthrough device (direct ATA/SCSI access)
+# Serial (COM) ports
+device uart # Multi-uart driver
+options ALT_BREAK_TO_DEBUGGER
+
# USB support
-device ohci # OHCI localbus->USB interface
+device ohci # OHCI USB interface
device usb # USB Bus (required)
device umass # Disks/Mass storage - Requires scbus and da
device uhid # "Human Interface Devices"
@@ -131,3 +139,5 @@ device udav # Davicom DM9601E USB
#device wlan_tkip # 802.11 TKIP support
#device wlan_amrr # AMRR transmit rate control algorithm
+# watchdog
+device at91_wdt # Atmel AT91 Watchdog Timer
diff --git a/sys/arm/conf/SOCKIT.common b/sys/arm/conf/SOCKIT.common
index ac71169..8c6e475 100644
--- a/sys/arm/conf/SOCKIT.common
+++ b/sys/arm/conf/SOCKIT.common
@@ -18,6 +18,7 @@
#
# $FreeBSD$
+include "std.armv6"
include "../altera/socfpga/std.socfpga"
makeoptions MODULES_OVERRIDE=""
@@ -26,37 +27,6 @@ makeoptions WERROR="-Werror"
options HZ=100
options SCHED_ULE # ULE scheduler
-options PREEMPTION # Enable kernel thread preemption
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options QUOTA # Enable disk quotas for UFS
-options NFSCL # Network Filesystem Client
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options TMPFS # Efficient memory filesystem
-options GEOM_PART_GPT # GUID Partition Tables
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!]
-options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
-options KTRACE # ktrace(1) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
-options FREEBSD_BOOT_LOADER # Process metadata passed from loader(8)
-options VFP # Enable floating point hardware support
options SMP # Enable multiple cores
# Debugging for use in -current
@@ -81,6 +51,9 @@ options INVARIANT_SUPPORT # Extra sanity checks of internal structures, require
#options BOOTP_NFSV3
#options BOOTP_WIRED_TO=ue0
+# Interrupt controller
+device gic
+
# MMC/SD/SDIO Card slot support
device mmc # mmc/sd bus
device mmcsd # mmc/sd flash cards
diff --git a/sys/arm/conf/TS7800 b/sys/arm/conf/TS7800
index 87a40d5..1a565c4 100644
--- a/sys/arm/conf/TS7800
+++ b/sys/arm/conf/TS7800
@@ -5,7 +5,8 @@
#
ident TS7800
-include "../mv/orion/std.ts7800"
+include "std.arm"
+include "../mv/orion/std.ts7800"
options SOC_MV_ORION
diff --git a/sys/arm/conf/VERSATILEPB b/sys/arm/conf/VERSATILEPB
index c02d18c..d1fc77a 100644
--- a/sys/arm/conf/VERSATILEPB
+++ b/sys/arm/conf/VERSATILEPB
@@ -22,6 +22,7 @@ ident VERSATILEPB
machine arm armv6
cpu CPU_ARM1176
+include "std.armv6"
files "../versatile/files.versatile"
makeoptions MODULES_OVERRIDE=""
@@ -33,38 +34,7 @@ options PHYSADDR=0x00000000
options HZ=100
options SCHED_4BSD # 4BSD scheduler
-options PREEMPTION # Enable kernel thread preemption
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options QUOTA # Enable disk quotas for UFS
-options NFSCL # Network Filesystem Client
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options TMPFS # Efficient memory filesystem
-options GEOM_PART_GPT # GUID Partition Tables
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!]
-options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
-options KTRACE # ktrace(1) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
-options FREEBSD_BOOT_LOADER # Process metadata passed from loader(8)
options LINUX_BOOT_ABI # Process metadata passed from Linux boot loaders
-options VFP # Enable floating point hardware support
# Debugging for use in -current
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
diff --git a/sys/arm/conf/VIRT b/sys/arm/conf/VIRT
index c4f9405..3206fda 100644
--- a/sys/arm/conf/VIRT
+++ b/sys/arm/conf/VIRT
@@ -20,44 +20,12 @@
ident VIRT
-include "../qemu/std.virt"
+include "std.armv6"
+include "../qemu/std.virt"
options HZ=100
options SCHED_4BSD # 4BSD scheduler
-options PREEMPTION # Enable kernel thread preemption
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options QUOTA # Enable disk quotas for UFS
-options NFSCL # Network Filesystem Client
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options TMPFS # Efficient memory filesystem
-options GEOM_PART_GPT # GUID Partition Tables
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options GEOM_LABEL # Provides labelization
-options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!]
-options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
-options KTRACE # ktrace(1) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
options PLATFORM
-options FREEBSD_BOOT_LOADER # Process metadata passed from loader(8)
-options VFP # Enable floating point hardware support
-options ARM_NEW_PMAP # Enable the new v6 pmap
# Debugging for use in -current
makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
@@ -75,6 +43,9 @@ options INVARIANT_SUPPORT # Extra sanity checks of internal structures, require
#options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
#options DIAGNOSTIC
+# Interrupt controller
+device gic
+
device bpf
device loop
device ether
@@ -84,9 +55,9 @@ device snp
device pl011
device psci
-device virtio
-device virtio_mmio
-device virtio_blk
+device virtio
+device virtio_mmio
+device virtio_blk
device vtnet
device md
diff --git a/sys/arm/conf/VSATV102 b/sys/arm/conf/VSATV102
index b5de5f9..f845594 100644
--- a/sys/arm/conf/VSATV102
+++ b/sys/arm/conf/VSATV102
@@ -22,5 +22,10 @@
include "AML8726"
ident VSATV102
+options SMP # Enable multiple cores
+
+# Interrupt controller
+device gic
+
options FDT_DTB_STATIC
makeoptions FDT_DTS_FILE=vsatv102-m6.dts
diff --git a/sys/arm/conf/VYBRID b/sys/arm/conf/VYBRID
index eda4815..a31ef07 100644
--- a/sys/arm/conf/VYBRID
+++ b/sys/arm/conf/VYBRID
@@ -19,44 +19,14 @@
# $FreeBSD$
ident VYBRID
-include "../freescale/vybrid/std.vybrid"
+include "std.armv6"
+include "../freescale/vybrid/std.vybrid"
makeoptions WERROR="-Werror"
options HZ=100
options SCHED_4BSD # 4BSD scheduler
-options PREEMPTION # Enable kernel thread preemption
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options QUOTA # Enable disk quotas for UFS
-options NFSCL # Network Filesystem Client
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
#options NANDFS # NAND Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options TMPFS # Efficient memory filesystem
-options GEOM_PART_GPT # GUID Partition Tables
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!]
-options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
-options KTRACE # ktrace(1) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
-options FREEBSD_BOOT_LOADER # Process metadata passed from loader(8)
-options VFP # Enable floating point hardware support
#options SMP # Enable multiple cores
# Debugging for use in -current
@@ -90,6 +60,9 @@ options RWLOCK_NOINLINE
options NO_FFS_SNAPSHOT
options NO_SWAPPING
+# Interrupt controller
+device gic
+
# MMC/SD/SDIO Card slot support
device mmc # mmc/sd bus
device mmcsd # mmc/sd flash cards
diff --git a/sys/arm/conf/WANDBOARD-DUAL b/sys/arm/conf/WANDBOARD-DUAL
deleted file mode 100644
index 66e2535..0000000
--- a/sys/arm/conf/WANDBOARD-DUAL
+++ /dev/null
@@ -1,28 +0,0 @@
-# Kernel configuration for Wandboard-Dual
-#
-# For more information on this file, please read the config(5) manual page,
-# and/or the handbook section on Kernel Configuration Files:
-#
-# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/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 ../../conf/NOTES and NOTES files.
-# If you are in doubt as to the purpose or necessity of a line, check first
-# in NOTES.
-#
-# $FreeBSD$
-
-#NO_UNIVERSE
-
-include "IMX6"
-ident WANDBOARD-DUAL
-
-# Flattened Device Tree
-options FDT_DTB_STATIC
-makeoptions FDT_DTS_FILE=wandboard-dual.dts
-
diff --git a/sys/arm/conf/WANDBOARD-QUAD b/sys/arm/conf/WANDBOARD-QUAD
deleted file mode 100644
index 830a445..0000000
--- a/sys/arm/conf/WANDBOARD-QUAD
+++ /dev/null
@@ -1,28 +0,0 @@
-# Kernel configuration for Wandboard-Quad
-#
-# For more information on this file, please read the config(5) manual page,
-# and/or the handbook section on Kernel Configuration Files:
-#
-# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/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 ../../conf/NOTES and NOTES files.
-# If you are in doubt as to the purpose or necessity of a line, check first
-# in NOTES.
-#
-# $FreeBSD$
-
-#NO_UNIVERSE
-
-include "IMX6"
-ident WANDBOARD-QUAD
-
-# Flattened Device Tree
-options FDT_DTB_STATIC
-makeoptions FDT_DTS_FILE=wandboard-quad.dts
-
diff --git a/sys/arm/conf/WANDBOARD-SOLO b/sys/arm/conf/WANDBOARD-SOLO
deleted file mode 100644
index ad56365..0000000
--- a/sys/arm/conf/WANDBOARD-SOLO
+++ /dev/null
@@ -1,28 +0,0 @@
-# Kernel configuration for Wandboard-Solo
-#
-# For more information on this file, please read the config(5) manual page,
-# and/or the handbook section on Kernel Configuration Files:
-#
-# http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/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 ../../conf/NOTES and NOTES files.
-# If you are in doubt as to the purpose or necessity of a line, check first
-# in NOTES.
-#
-# $FreeBSD$
-
-include "IMX6"
-ident WANDBOARD-SOLO
-
-nooptions SMP
-
-# Flattened Device Tree
-options FDT_DTB_STATIC
-makeoptions FDT_DTS_FILE=wandboard-solo.dts
-
diff --git a/sys/arm/conf/ZEDBOARD b/sys/arm/conf/ZEDBOARD
index 94148f4..a0fe66a 100644
--- a/sys/arm/conf/ZEDBOARD
+++ b/sys/arm/conf/ZEDBOARD
@@ -21,40 +21,11 @@
ident ZEDBOARD
+include "std.armv6"
include "../xilinx/zedboard/std.zedboard"
options SCHED_ULE # ULE scheduler
-options PREEMPTION # Enable kernel thread preemption
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options QUOTA # Enable disk quotas for UFS
-options NFSCL # Network Filesystem Client
#options NFSSD # Network Filesystem Server
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options TMPFS # Efficient memory filesystem
-options GEOM_PART_GPT # GUID Partition Tables
-options GEOM_PART_BSD # BSD partition scheme
-options GEOM_PART_MBR # MBR partition scheme
-options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
-options KTRACE # ktrace(1) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
-options FREEBSD_BOOT_LOADER # Process metadata passed from loader(8)
-options VFP # Enable floating point hardware support
options SMP # Enable multiple cores
# Debugging for use in -current
@@ -79,6 +50,9 @@ options DDB # Enable the kernel debugger
options ROOTDEVNAME=\"ufs:mmcsd0s2a\"
+# Interrupt controller
+device gic
+
device loop
device random
device ether
diff --git a/sys/arm/conf/std.arm b/sys/arm/conf/std.arm
new file mode 100644
index 0000000..88675f0
--- /dev/null
+++ b/sys/arm/conf/std.arm
@@ -0,0 +1,5 @@
+# Standard kernel config items for all ARMv4/v5 systems.
+#
+# $FreeBSD$
+
+
diff --git a/sys/arm/conf/std.armv6 b/sys/arm/conf/std.armv6
new file mode 100644
index 0000000..c06ceae
--- /dev/null
+++ b/sys/arm/conf/std.armv6
@@ -0,0 +1,38 @@
+# Standard kernel config items for all ARMv6/v7 systems.
+#
+# $FreeBSD$
+
+options PREEMPTION # Enable kernel thread preemption
+options INET # InterNETworking
+options INET6 # IPv6 communications protocols
+options SCTP # Stream Control Transmission Protocol
+options FFS # Berkeley Fast Filesystem
+options SOFTUPDATES # Enable FFS soft updates support
+options UFS_ACL # Support for access control lists
+options UFS_DIRHASH # Improve performance on big directories
+options UFS_GJOURNAL # Enable gjournal-based UFS journaling
+options QUOTA # Enable disk quotas for UFS
+options NFSCL # Network Filesystem Client
+options NFSLOCKD # Network Lock Manager
+options NFS_ROOT # NFS usable as /, requires NFSCL
+options MSDOSFS # MSDOS Filesystem
+options CD9660 # ISO 9660 Filesystem
+options PROCFS # Process filesystem (requires PSEUDOFS)
+options PSEUDOFS # Pseudo-filesystem framework
+options TMPFS # Efficient memory filesystem
+options GEOM_PART_GPT # GUID Partition Tables
+options GEOM_PART_BSD # BSD partition scheme
+options GEOM_PART_MBR # MBR partition scheme
+options GEOM_LABEL # Provides labelization
+options COMPAT_43 # Compatible with BSD 4.3 [KEEP THIS!]
+options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
+options KTRACE # ktrace(1) support
+options SYSVSHM # SYSV-style shared memory
+options SYSVMSG # SYSV-style message queues
+options SYSVSEM # SYSV-style semaphores
+options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
+options KBD_INSTALL_CDEV # install a CDEV entry in /dev
+options FREEBSD_BOOT_LOADER # Process metadata passed from loader(8)
+options VFP # Enable floating point hardware support
+
+options ARM_NEW_PMAP # Use new pmap code.
diff --git a/sys/arm/freescale/imx/files.imx6 b/sys/arm/freescale/imx/files.imx6
index f38eca4..0a67ea1 100644
--- a/sys/arm/freescale/imx/files.imx6
+++ b/sys/arm/freescale/imx/files.imx6
@@ -10,7 +10,6 @@ kern/kern_clocksource.c standard
#
# Standard imx6 devices and support.
#
-arm/arm/gic.c standard
arm/arm/pl310.c standard
arm/arm/bus_space_base.c standard
arm/arm/mpcore_timer.c standard
diff --git a/sys/arm/freescale/imx/imx6_anatop.c b/sys/arm/freescale/imx/imx6_anatop.c
index a384501..16a09d3 100644
--- a/sys/arm/freescale/imx/imx6_anatop.c
+++ b/sys/arm/freescale/imx/imx6_anatop.c
@@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$");
#include <arm/arm/mpcore_timervar.h>
#include <arm/freescale/fsl_ocotpreg.h>
#include <arm/freescale/fsl_ocotpvar.h>
+#include <arm/freescale/imx/imx_ccmvar.h>
#include <arm/freescale/imx/imx6_anatopreg.h>
#include <arm/freescale/imx/imx6_anatopvar.h>
@@ -116,12 +117,16 @@ static struct imx6_anatop_softc *imx6_anatop_sc;
/*
* Table of "operating points".
* These are combinations of frequency and voltage blessed by Freescale.
+ * While the datasheet says the ARM voltage can be as low as 925mV at
+ * 396MHz, it also says that the ARM and SOC voltages can't differ by
+ * more than 200mV, and the minimum SOC voltage is 1150mV, so that
+ * dictates the 950mV entry in this table.
*/
static struct oppt {
uint32_t mhz;
uint32_t mv;
} imx6_oppt_table[] = {
-/* { 396, 925}, XXX: need functional ccm code for this speed */
+ { 396, 950},
{ 792, 1150},
{ 852, 1225},
{ 996, 1225},
@@ -158,14 +163,15 @@ imx6_anatop_write_4(bus_size_t offset, uint32_t value)
static void
vdd_set(struct imx6_anatop_softc *sc, int mv)
{
- int newtarg, oldtarg;
+ int newtarg, newtargSoc, oldtarg;
uint32_t delay, pmureg;
static boolean_t init_done = false;
/*
* The datasheet says VDD_PU and VDD_SOC must be equal, and VDD_ARM
- * can't be more than 50mV above or 200mV below them. For now to keep
- * things simple we set all three to the same value.
+ * can't be more than 50mV above or 200mV below them. We keep them the
+ * same except in the case of the lowest operating point, which is
+ * handled as a special case below.
*/
pmureg = imx6_anatop_read_4(IMX6_ANALOG_PMU_REG_CORE);
@@ -180,19 +186,29 @@ vdd_set(struct imx6_anatop_softc *sc, int mv)
newtarg = (mv - 700) / 25;
/*
+ * The SOC voltage can't go below 1150mV, and thus because of the 200mV
+ * rule, the ARM voltage can't go below 950mV. The 950 is encoded in
+ * our oppt table, here we handle the SOC 1150 rule as a special case.
+ * (1150-700/25=18).
+ */
+ newtargSoc = (newtarg < 18) ? 18 : newtarg;
+
+ /*
* The first time through the 3 voltages might not be equal so use a
* long conservative delay. After that we need to delay 3uS for every
- * 25mV step upward. No need to delay at all when lowering.
+ * 25mV step upward; we actually delay 6uS because empirically, it works
+ * and the 3uS per step recommended by the docs doesn't (3uS fails when
+ * going from 400->1200, but works for smaller changes).
*/
if (init_done) {
if (newtarg == oldtarg)
return;
else if (newtarg > oldtarg)
- delay = (newtarg - oldtarg) * 3;
+ delay = (newtarg - oldtarg) * 6;
else
delay = 0;
} else {
- delay = 700 / 25 * 3;
+ delay = (700 / 25) * 6;
init_done = true;
}
@@ -205,7 +221,7 @@ vdd_set(struct imx6_anatop_softc *sc, int mv)
pmureg |= newtarg << IMX6_ANALOG_PMU_REG0_TARG_SHIFT;
pmureg |= newtarg << IMX6_ANALOG_PMU_REG1_TARG_SHIFT;
- pmureg |= newtarg << IMX6_ANALOG_PMU_REG2_TARG_SHIFT;
+ pmureg |= newtargSoc << IMX6_ANALOG_PMU_REG2_TARG_SHIFT;
imx6_anatop_write_4(IMX6_ANALOG_PMU_REG_CORE, pmureg);
DELAY(delay);
@@ -213,24 +229,29 @@ vdd_set(struct imx6_anatop_softc *sc, int mv)
}
static inline uint32_t
-cpufreq_mhz_from_div(struct imx6_anatop_softc *sc, uint32_t div)
+cpufreq_mhz_from_div(struct imx6_anatop_softc *sc, uint32_t corediv,
+ uint32_t plldiv)
{
- return (sc->refosc_mhz * (div / 2));
+ return ((sc->refosc_mhz * (plldiv / 2)) / (corediv + 1));
}
-static inline uint32_t
-cpufreq_mhz_to_div(struct imx6_anatop_softc *sc, uint32_t cpu_mhz)
+static inline void
+cpufreq_mhz_to_div(struct imx6_anatop_softc *sc, uint32_t cpu_mhz,
+ uint32_t *corediv, uint32_t *plldiv)
{
- return (cpu_mhz / (sc->refosc_mhz / 2));
+ *corediv = (cpu_mhz < 650) ? 1 : 0;
+ *plldiv = ((*corediv + 1) * cpu_mhz) / (sc->refosc_mhz / 2);
}
static inline uint32_t
cpufreq_actual_mhz(struct imx6_anatop_softc *sc, uint32_t cpu_mhz)
{
+ uint32_t corediv, plldiv;
- return (cpufreq_mhz_from_div(sc, cpufreq_mhz_to_div(sc, cpu_mhz)));
+ cpufreq_mhz_to_div(sc, cpu_mhz, &corediv, &plldiv);
+ return (cpufreq_mhz_from_div(sc, corediv, plldiv));
}
static struct oppt *
@@ -256,7 +277,7 @@ cpufreq_nearest_oppt(struct imx6_anatop_softc *sc, uint32_t cpu_newmhz)
static void
cpufreq_set_clock(struct imx6_anatop_softc * sc, struct oppt *op)
{
- uint32_t timeout, wrk32;
+ uint32_t corediv, plldiv, timeout, wrk32;
/* If increasing the frequency, we must first increase the voltage. */
if (op->mhz > sc->cpu_curmhz) {
@@ -272,6 +293,7 @@ cpufreq_set_clock(struct imx6_anatop_softc * sc, struct oppt *op)
* - Wait for the LOCK bit to come on; it takes ~50 loop iterations.
* - Turn off bypass mode; cpu should now be running at the new speed.
*/
+ cpufreq_mhz_to_div(sc, op->mhz, &corediv, &plldiv);
imx6_anatop_write_4(IMX6_ANALOG_CCM_PLL_ARM_CLR,
IMX6_ANALOG_CCM_PLL_ARM_CLK_SRC_MASK);
imx6_anatop_write_4(IMX6_ANALOG_CCM_PLL_ARM_SET,
@@ -279,7 +301,7 @@ cpufreq_set_clock(struct imx6_anatop_softc * sc, struct oppt *op)
wrk32 = imx6_anatop_read_4(IMX6_ANALOG_CCM_PLL_ARM);
wrk32 &= ~IMX6_ANALOG_CCM_PLL_ARM_DIV_MASK;
- wrk32 |= cpufreq_mhz_to_div(sc, op->mhz);
+ wrk32 |= plldiv;
imx6_anatop_write_4(IMX6_ANALOG_CCM_PLL_ARM, wrk32);
timeout = 10000;
@@ -290,6 +312,7 @@ cpufreq_set_clock(struct imx6_anatop_softc * sc, struct oppt *op)
imx6_anatop_write_4(IMX6_ANALOG_CCM_PLL_ARM_CLR,
IMX6_ANALOG_CCM_PLL_ARM_BYPASS);
+ imx_ccm_set_cacrr(corediv);
/* If lowering the frequency, it is now safe to lower the voltage. */
if (op->mhz < sc->cpu_curmhz)
@@ -297,7 +320,7 @@ cpufreq_set_clock(struct imx6_anatop_softc * sc, struct oppt *op)
sc->cpu_curmhz = op->mhz;
/* Tell the mpcore timer that its frequency has changed. */
- arm_tmr_change_frequency(
+ arm_tmr_change_frequency(
cpufreq_actual_mhz(sc, sc->cpu_curmhz) * 1000000 / 2);
}
@@ -748,11 +771,12 @@ imx6_anatop_probe(device_t dev)
uint32_t
imx6_get_cpu_clock()
{
- uint32_t div;
+ uint32_t corediv, plldiv;
- div = imx6_anatop_read_4(IMX6_ANALOG_CCM_PLL_ARM) &
+ corediv = imx_ccm_get_cacrr();
+ plldiv = imx6_anatop_read_4(IMX6_ANALOG_CCM_PLL_ARM) &
IMX6_ANALOG_CCM_PLL_ARM_DIV_MASK;
- return (cpufreq_mhz_from_div(imx6_anatop_sc, div));
+ return (cpufreq_mhz_from_div(imx6_anatop_sc, corediv, plldiv));
}
static device_method_t imx6_anatop_methods[] = {
diff --git a/sys/arm/freescale/imx/imx6_ccm.c b/sys/arm/freescale/imx/imx6_ccm.c
index 8d7f14f..488c55a 100644
--- a/sys/arm/freescale/imx/imx6_ccm.c
+++ b/sys/arm/freescale/imx/imx6_ccm.c
@@ -320,6 +320,20 @@ imx_ccm_ahb_hz(void)
return (132000000);
}
+uint32_t
+imx_ccm_get_cacrr(void)
+{
+
+ return (RD4(ccm_sc, CCM_CACCR));
+}
+
+void
+imx_ccm_set_cacrr(uint32_t divisor)
+{
+
+ WR4(ccm_sc, CCM_CACCR, divisor);
+}
+
static device_method_t ccm_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, ccm_probe),
diff --git a/sys/arm/freescale/imx/imx6_ccmreg.h b/sys/arm/freescale/imx/imx6_ccmreg.h
index 31d92ca..85dd372 100644
--- a/sys/arm/freescale/imx/imx6_ccmreg.h
+++ b/sys/arm/freescale/imx/imx6_ccmreg.h
@@ -29,6 +29,7 @@
#ifndef IMX6_CCMREG_H
#define IMX6_CCMREG_H
+#define CCM_CACCR 0x010
#define CCM_CSCMR1 0x01C
#define SSI1_CLK_SEL_S 10
#define SSI2_CLK_SEL_S 12
@@ -64,6 +65,5 @@
#define CCM_CCGR5 0x07C
#define CCM_CCGR6 0x080
#define CCM_CMEOR 0x088
-
#endif
diff --git a/sys/arm/freescale/imx/imx_ccmvar.h b/sys/arm/freescale/imx/imx_ccmvar.h
index f159437..91a3e45 100644
--- a/sys/arm/freescale/imx/imx_ccmvar.h
+++ b/sys/arm/freescale/imx/imx_ccmvar.h
@@ -53,4 +53,8 @@ void imx_ccm_usb_enable(device_t _usbdev);
void imx_ccm_usbphy_enable(device_t _phydev);
void imx_ccm_ssi_configure(device_t _ssidev);
+/* Routines to get and set the arm clock root divisor register. */
+uint32_t imx_ccm_get_cacrr(void);
+void imx_ccm_set_cacrr(uint32_t _divisor);
+
#endif
diff --git a/sys/arm/freescale/imx/imx_sdhci.c b/sys/arm/freescale/imx/imx_sdhci.c
index f197309..290a031 100644
--- a/sys/arm/freescale/imx/imx_sdhci.c
+++ b/sys/arm/freescale/imx/imx_sdhci.c
@@ -745,7 +745,7 @@ imx_sdhci_attach(device_t dev)
sc->force_card_present = true;
}
- callout_init(&sc->r1bfix_callout, true);
+ callout_init(&sc->r1bfix_callout, 1);
sdhci_init_slot(dev, &sc->slot, 0);
bus_generic_probe(dev);
diff --git a/sys/arm/freescale/vybrid/files.vybrid b/sys/arm/freescale/vybrid/files.vybrid
index 194a975..23617a4 100644
--- a/sys/arm/freescale/vybrid/files.vybrid
+++ b/sys/arm/freescale/vybrid/files.vybrid
@@ -6,7 +6,6 @@ arm/arm/bus_space_generic.c standard
arm/arm/bus_space_asm_generic.S standard
arm/arm/bus_space_base.c standard
-arm/arm/gic.c standard
arm/arm/mpcore_timer.c standard
arm/freescale/vybrid/vf_machdep.c standard
diff --git a/sys/arm/include/armreg.h b/sys/arm/include/armreg.h
index 3163ba5..9358703 100644
--- a/sys/arm/include/armreg.h
+++ b/sys/arm/include/armreg.h
@@ -346,6 +346,9 @@
#define CPUV7_CT_xSIZE_ASSOC(x) (((x) >> 3) & 0x3ff) /* associativity */
#define CPUV7_CT_xSIZE_SET(x) (((x) >> 13) & 0x7fff) /* num sets */
+#define CPUV7_L2CTLR_NPROC_SHIFT 24
+#define CPUV7_L2CTLR_NPROC(r) ((((r) >> CPUV7_L2CTLR_NPROC_SHIFT) & 3) + 1)
+
#define CPU_CLIDR_CTYPE(reg,x) (((reg) >> ((x) * 3)) & 0x7)
#define CPU_CLIDR_LOUIS(reg) (((reg) >> 21) & 0x7)
#define CPU_CLIDR_LOC(reg) (((reg) >> 24) & 0x7)
diff --git a/sys/arm/include/asm.h b/sys/arm/include/asm.h
index 53453d9..0c25d7b 100644
--- a/sys/arm/include/asm.h
+++ b/sys/arm/include/asm.h
@@ -87,7 +87,13 @@
*/
#define GLOBAL(x) .global x
-#define _LEENTRY(x) .type x,_ASM_TYPE_FUNCTION; x:
+#ifdef __thumb__
+#define _FUNC_MODE .code 16; .thumb_func
+#else
+#define _FUNC_MODE .code 32
+#endif
+
+#define _LEENTRY(x) .type x,_ASM_TYPE_FUNCTION; _FUNC_MODE; x:
#define _LEEND(x) /* nothing */
#define _EENTRY(x) GLOBAL(x); _LEENTRY(x)
#define _EEND(x) _LEEND(x)
@@ -126,7 +132,7 @@
ldr x, [x, got]
#define GOT_INIT(got,gotsym,pclabel) \
ldr got, gotsym; \
- pclabel: add got, got, pc
+ pclabel: add got, pc
#ifdef __thumb__
#define GOT_INITSYM(gotsym,pclabel) \
.align 2; \
diff --git a/sys/arm/include/atomic.h b/sys/arm/include/atomic.h
index 57fdf71..48b4a33 100644
--- a/sys/arm/include/atomic.h
+++ b/sys/arm/include/atomic.h
@@ -151,10 +151,10 @@ atomic_set_64(volatile uint64_t *p, uint64_t val)
__asm __volatile(
"1: \n"
- " ldrexd %[tmp], [%[ptr]]\n"
+ " ldrexd %Q[tmp], %R[tmp], [%[ptr]]\n"
" orr %Q[tmp], %Q[val]\n"
" orr %R[tmp], %R[val]\n"
- " strexd %[exf], %[tmp], [%[ptr]]\n"
+ " strexd %[exf], %Q[tmp], %R[tmp], [%[ptr]]\n"
" teq %[exf], #0\n"
" it ne \n"
" bne 1b\n"
@@ -204,10 +204,10 @@ atomic_clear_64(volatile uint64_t *p, uint64_t val)
__asm __volatile(
"1: \n"
- " ldrexd %[tmp], [%[ptr]]\n"
+ " ldrexd %Q[tmp], %R[tmp], [%[ptr]]\n"
" bic %Q[tmp], %Q[val]\n"
" bic %R[tmp], %R[val]\n"
- " strexd %[exf], %[tmp], [%[ptr]]\n"
+ " strexd %[exf], %Q[tmp], %R[tmp], [%[ptr]]\n"
" teq %[exf], #0\n"
" it ne \n"
" bne 1b\n"
@@ -263,13 +263,13 @@ atomic_cmpset_64(volatile uint64_t *p, uint64_t cmpval, uint64_t newval)
__asm __volatile(
"1: \n"
- " ldrexd %[tmp], [%[ptr]]\n"
+ " ldrexd %Q[tmp], %R[tmp], [%[ptr]]\n"
" teq %Q[tmp], %Q[cmpval]\n"
" itee eq \n"
" teqeq %R[tmp], %R[cmpval]\n"
" movne %[ret], #0\n"
" bne 2f\n"
- " strexd %[ret], %[newval], [%[ptr]]\n"
+ " strexd %[ret], %Q[newval], %R[newval], [%[ptr]]\n"
" teq %[ret], #0\n"
" it ne \n"
" bne 1b\n"
@@ -381,10 +381,10 @@ atomic_add_64(volatile uint64_t *p, uint64_t val)
__asm __volatile(
"1: \n"
- " ldrexd %[tmp], [%[ptr]]\n"
+ " ldrexd %Q[tmp], %R[tmp], [%[ptr]]\n"
" adds %Q[tmp], %Q[val]\n"
- " adc %R[tmp], %R[val]\n"
- " strexd %[exf], %[tmp], [%[ptr]]\n"
+ " adc %R[tmp], %R[tmp], %R[val]\n"
+ " strexd %[exf], %Q[tmp], %R[tmp], [%[ptr]]\n"
" teq %[exf], #0\n"
" it ne \n"
" bne 1b\n"
@@ -433,10 +433,10 @@ atomic_subtract_64(volatile uint64_t *p, uint64_t val)
__asm __volatile(
"1: \n"
- " ldrexd %[tmp], [%[ptr]]\n"
+ " ldrexd %Q[tmp], %R[tmp], [%[ptr]]\n"
" subs %Q[tmp], %Q[val]\n"
- " sbc %R[tmp], %R[val]\n"
- " strexd %[exf], %[tmp], [%[ptr]]\n"
+ " sbc %R[tmp], %R[tmp], %R[val]\n"
+ " strexd %[exf], %Q[tmp], %R[tmp], [%[ptr]]\n"
" teq %[exf], #0\n"
" it ne \n"
" bne 1b\n"
@@ -536,10 +536,10 @@ atomic_fetchadd_64(volatile uint64_t *p, uint64_t val)
__asm __volatile(
"1: \n"
- " ldrexd %[ret], [%[ptr]]\n"
+ " ldrexd %Q[tmp], %R[tmp], [%[ptr]]\n"
" adds %Q[tmp], %Q[ret], %Q[val]\n"
" adc %R[tmp], %R[ret], %R[val]\n"
- " strexd %[exf], %[tmp], [%[ptr]]\n"
+ " strexd %[exf], %Q[tmp], %R[tmp], [%[ptr]]\n"
" teq %[exf], #0\n"
" it ne \n"
" bne 1b\n"
@@ -560,10 +560,10 @@ atomic_readandclear_64(volatile uint64_t *p)
__asm __volatile(
"1: \n"
- " ldrexd %[ret], [%[ptr]]\n"
+ " ldrexd %Q[ret], %R[ret], [%[ptr]]\n"
" mov %Q[tmp], #0\n"
" mov %R[tmp], #0\n"
- " strexd %[exf], %[tmp], [%[ptr]]\n"
+ " strexd %[exf], %Q[tmp], %R[tmp], [%[ptr]]\n"
" teq %[exf], #0\n"
" it ne \n"
" bne 1b\n"
@@ -587,7 +587,7 @@ atomic_load_64(volatile uint64_t *p)
*/
__asm __volatile(
"1: \n"
- " ldrexd %[ret], [%[ptr]]\n"
+ " ldrexd %Q[ret], %R[ret], [%[ptr]]\n"
" clrex \n"
: [ret] "=&r" (ret)
: [ptr] "r" (p)
@@ -618,8 +618,8 @@ atomic_store_64(volatile uint64_t *p, uint64_t val)
*/
__asm __volatile(
"1: \n"
- " ldrexd %[tmp], [%[ptr]]\n"
- " strexd %[exf], %[val], [%[ptr]]\n"
+ " ldrexd %Q[tmp], %R[tmp], [%[ptr]]\n"
+ " strexd %[exf], %Q[tmp], %R[tmp], [%[ptr]]\n"
" teq %[exf], #0\n"
" it ne \n"
" bne 1b\n"
diff --git a/sys/arm/include/cpu-v6.h b/sys/arm/include/cpu-v6.h
index 6c226a3..3481513 100644
--- a/sys/arm/include/cpu-v6.h
+++ b/sys/arm/include/cpu-v6.h
@@ -29,12 +29,16 @@
#ifndef MACHINE_CPU_V6_H
#define MACHINE_CPU_V6_H
+/* There are no user serviceable parts here, they may change without notice */
+#ifndef _KERNEL
+#error Only include this file in the kernel
+#else
+
#include "machine/atomic.h"
#include "machine/cpufunc.h"
#include "machine/cpuinfo.h"
#include "machine/sysreg.h"
-
#define CPU_ASID_KERNEL 0
vm_offset_t dcache_wb_pou_checked(vm_offset_t, vm_size_t);
@@ -143,6 +147,13 @@ _RF0(cp15_ttbr_get, CP15_TTBR0(%0))
_RF0(cp15_dfar_get, CP15_DFAR(%0))
#if __ARM_ARCH >= 7
_RF0(cp15_ifar_get, CP15_IFAR(%0))
+_RF0(cp15_l2ctlr_get, CP15_L2CTLR(%0))
+#endif
+#if __ARM_ARCH >= 6
+_RF0(cp15_actlr_get, CP15_ACTLR(%0))
+_WF1(cp15_ats1cpr_set, CP15_ATS1CPR(%0));
+_RF0(cp15_par_get, CP15_PAR);
+_RF0(cp15_sctlr_get, CP15_SCTLR(%0))
#endif
/*CPU id registers */
@@ -269,24 +280,29 @@ tlb_flush_all_ng_local(void)
/* Flush single TLB entry (even global). */
static __inline void
-tlb_flush_local(vm_offset_t sva)
+tlb_flush_local(vm_offset_t va)
{
+ KASSERT((va & PAGE_MASK) == 0, ("%s: va %#x not aligned", __func__, va));
+
dsb();
- _CP15_TLBIMVA((sva & ~PAGE_MASK ) | CPU_ASID_KERNEL);
+ _CP15_TLBIMVA(va | CPU_ASID_KERNEL);
dsb();
}
/* Flush range of TLB entries (even global). */
static __inline void
-tlb_flush_range_local(vm_offset_t sva, vm_size_t size)
+tlb_flush_range_local(vm_offset_t va, vm_size_t size)
{
- vm_offset_t va;
- vm_offset_t eva = sva + size;
+ vm_offset_t eva = va + size;
+
+ KASSERT((va & PAGE_MASK) == 0, ("%s: va %#x not aligned", __func__, va));
+ KASSERT((size & PAGE_MASK) == 0, ("%s: size %#x not aligned", __func__,
+ size));
dsb();
- for (va = sva; va < eva; va += PAGE_SIZE)
- _CP15_TLBIMVA((va & ~PAGE_MASK ) | CPU_ASID_KERNEL);
+ for (; va < eva; va += PAGE_SIZE)
+ _CP15_TLBIMVA(va | CPU_ASID_KERNEL);
dsb();
}
@@ -312,22 +328,27 @@ tlb_flush_all_ng(void)
}
static __inline void
-tlb_flush(vm_offset_t sva)
+tlb_flush(vm_offset_t va)
{
+ KASSERT((va & PAGE_MASK) == 0, ("%s: va %#x not aligned", __func__, va));
+
dsb();
- _CP15_TLBIMVAAIS(sva);
+ _CP15_TLBIMVAAIS(va);
dsb();
}
static __inline void
-tlb_flush_range(vm_offset_t sva, vm_size_t size)
+tlb_flush_range(vm_offset_t va, vm_size_t size)
{
- vm_offset_t va;
- vm_offset_t eva = sva + size;
+ vm_offset_t eva = va + size;
+
+ KASSERT((va & PAGE_MASK) == 0, ("%s: va %#x not aligned", __func__, va));
+ KASSERT((size & PAGE_MASK) == 0, ("%s: size %#x not aligned", __func__,
+ size));
dsb();
- for (va = sva; va < eva; va += PAGE_SIZE)
+ for (; va < eva; va += PAGE_SIZE)
_CP15_TLBIMVAAIS(va);
dsb();
}
@@ -335,8 +356,8 @@ tlb_flush_range(vm_offset_t sva, vm_size_t size)
#define tlb_flush_all() tlb_flush_all_local()
#define tlb_flush_all_ng() tlb_flush_all_ng_local()
-#define tlb_flush(sva) tlb_flush_local(sva)
-#define tlb_flush_range(sva, size) tlb_flush_range_local(sva, size)
+#define tlb_flush(va) tlb_flush_local(va)
+#define tlb_flush_range(va, size) tlb_flush_range_local(va, size)
#endif /* SMP */
@@ -346,13 +367,13 @@ tlb_flush_range(vm_offset_t sva, vm_size_t size)
/* Sync I and D caches to PoU */
static __inline void
-icache_sync(vm_offset_t sva, vm_size_t size)
+icache_sync(vm_offset_t va, vm_size_t size)
{
- vm_offset_t va;
- vm_offset_t eva = sva + size;
+ vm_offset_t eva = va + size;
dsb();
- for (va = sva; va < eva; va += cpuinfo.dcache_line_size) {
+ va &= ~cpuinfo.dcache_line_mask;
+ for ( ; va < eva; va += cpuinfo.dcache_line_size) {
#if __ARM_ARCH >= 7 && defined SMP
_CP15_DCCMVAU(va);
#else
@@ -397,13 +418,13 @@ bpb_inv_all(void)
/* Write back D-cache to PoU */
static __inline void
-dcache_wb_pou(vm_offset_t sva, vm_size_t size)
+dcache_wb_pou(vm_offset_t va, vm_size_t size)
{
- vm_offset_t va;
- vm_offset_t eva = sva + size;
+ vm_offset_t eva = va + size;
dsb();
- for (va = sva; va < eva; va += cpuinfo.dcache_line_size) {
+ va &= ~cpuinfo.dcache_line_mask;
+ for ( ; va < eva; va += cpuinfo.dcache_line_size) {
#if __ARM_ARCH >= 7 && defined SMP
_CP15_DCCMVAU(va);
#else
@@ -413,40 +434,46 @@ dcache_wb_pou(vm_offset_t sva, vm_size_t size)
dsb();
}
-/* Invalidate D-cache to PoC */
+/*
+ * Invalidate D-cache to PoC
+ *
+ * Caches are invalidated from outermost to innermost as fresh cachelines
+ * flow in this direction. In given range, if there was no dirty cacheline
+ * in any cache before, no stale cacheline should remain in them after this
+ * operation finishes.
+ */
static __inline void
-dcache_inv_poc(vm_offset_t sva, vm_paddr_t pa, vm_size_t size)
+dcache_inv_poc(vm_offset_t va, vm_paddr_t pa, vm_size_t size)
{
- vm_offset_t va;
- vm_offset_t eva = sva + size;
-
- /* invalidate L1 first */
- for (va = sva; va < eva; va += cpuinfo.dcache_line_size) {
- _CP15_DCIMVAC(va);
- }
- dsb();
+ vm_offset_t eva = va + size;
- /* then L2 */
- cpu_l2cache_inv_range(pa, size);
dsb();
+ /* invalidate L2 first */
+ cpu_l2cache_inv_range(pa, size);
- /* then L1 again */
- for (va = sva; va < eva; va += cpuinfo.dcache_line_size) {
+ /* then L1 */
+ va &= ~cpuinfo.dcache_line_mask;
+ for ( ; va < eva; va += cpuinfo.dcache_line_size) {
_CP15_DCIMVAC(va);
}
dsb();
}
-/* Write back D-cache to PoC */
+/*
+ * Write back D-cache to PoC
+ *
+ * Caches are written back from innermost to outermost as dirty cachelines
+ * flow in this direction. In given range, no dirty cacheline should remain
+ * in any cache after this operation finishes.
+ */
static __inline void
-dcache_wb_poc(vm_offset_t sva, vm_paddr_t pa, vm_size_t size)
+dcache_wb_poc(vm_offset_t va, vm_paddr_t pa, vm_size_t size)
{
- vm_offset_t va;
- vm_offset_t eva = sva + size;
+ vm_offset_t eva = va + size;
dsb();
-
- for (va = sva; va < eva; va += cpuinfo.dcache_line_size) {
+ va &= ~cpuinfo.dcache_line_mask;
+ for ( ; va < eva; va += cpuinfo.dcache_line_size) {
_CP15_DCCMVAC(va);
}
dsb();
@@ -462,9 +489,9 @@ dcache_wbinv_poc(vm_offset_t sva, vm_paddr_t pa, vm_size_t size)
vm_offset_t eva = sva + size;
dsb();
-
/* write back L1 first */
- for (va = sva; va < eva; va += cpuinfo.dcache_line_size) {
+ va = sva & ~cpuinfo.dcache_line_mask;
+ for ( ; va < eva; va += cpuinfo.dcache_line_size) {
_CP15_DCCMVAC(va);
}
dsb();
@@ -473,7 +500,8 @@ dcache_wbinv_poc(vm_offset_t sva, vm_paddr_t pa, vm_size_t size)
cpu_l2cache_wbinv_range(pa, size);
/* then invalidate L1 */
- for (va = sva; va < eva; va += cpuinfo.dcache_line_size) {
+ va = sva & ~cpuinfo.dcache_line_mask;
+ for ( ; va < eva; va += cpuinfo.dcache_line_size) {
_CP15_DCIMVAC(va);
}
dsb();
@@ -492,4 +520,6 @@ cp15_ttbr_set(uint32_t reg)
tlb_flush_all_ng_local();
}
+#endif /* _KERNEL */
+
#endif /* !MACHINE_CPU_V6_H */
diff --git a/sys/arm/include/cpufunc.h b/sys/arm/include/cpufunc.h
index 4d355d4..5d1a72a 100644
--- a/sys/arm/include/cpufunc.h
+++ b/sys/arm/include/cpufunc.h
@@ -376,7 +376,6 @@ void armv7_setup (void);
void armv7_context_switch (void);
void armv7_drain_writebuf (void);
void armv7_sev (void);
-void armv7_sleep (int unused);
u_int armv7_auxctrl (u_int, u_int);
void armadaxp_idcache_wbinv_all (void);
diff --git a/sys/arm/include/elf.h b/sys/arm/include/elf.h
index abe7b47..9262682 100644
--- a/sys/arm/include/elf.h
+++ b/sys/arm/include/elf.h
@@ -63,21 +63,21 @@ __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). */
-#define AT_ENTRY 9 /* Where interpreter should transfer control. */
-#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_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). */
+#define AT_ENTRY 9 /* Where interpreter should transfer control. */
+#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_EXECPATH 15 /* Path to the executable. */
#define AT_CANARY 16 /* Canary for SSP */
#define AT_CANARYLEN 17 /* Length of the canary. */
@@ -87,10 +87,11 @@ __ElfType(Auxinfo);
#define AT_PAGESIZESLEN 21 /* Number of pagesizes. */
#define AT_TIMEKEEP 22 /* Pointer to timehands. */
#define AT_STACKPROT 23 /* Initial stack protection. */
+#define AT_EHDRFLAGS 24 /* e_flags field from elf hdr */
-#define AT_COUNT 24 /* Count of defined aux entry types. */
+#define AT_COUNT 25 /* Count of defined aux entry types. */
-#define R_ARM_COUNT 33 /* Count of defined relocation types. */
+#define R_ARM_COUNT 33 /* Count of defined relocation types. */
/* Define "machine" characteristics */
@@ -104,16 +105,16 @@ __ElfType(Auxinfo);
#define ELF_TARG_VER 1
/* Defines specific for arm headers */
-#define EF_ARM_EABI_VERSION(x) (((x) & EF_ARM_EABIMASK) >> 24)
-#define EF_ARM_EABI_VERSION_UNKNOWN 0
-#define EF_ARM_EABI_FREEBSD_MIN 4
+#define EF_ARM_EABI_VERSION(x) (((x) & EF_ARM_EABIMASK) >> 24)
+#define EF_ARM_EABI_VERSION_UNKNOWN 0
+#define EF_ARM_EABI_FREEBSD_MIN 4
/*
* Magic number for the elf trampoline, chosen wisely to be an immediate
* value.
*/
-#define MAGIC_TRAMP_NUMBER 0x5c000003
+#define MAGIC_TRAMP_NUMBER 0x5c000003
-#define ET_DYN_LOAD_ADDR 0x12000
+#define ET_DYN_LOAD_ADDR 0x12000
#endif /* !_MACHINE_ELF_H_ */
diff --git a/sys/arm/include/pl310.h b/sys/arm/include/pl310.h
index f7c75e9..fd75d44 100644
--- a/sys/arm/include/pl310.h
+++ b/sys/arm/include/pl310.h
@@ -133,7 +133,7 @@
#define PREFETCH_CTRL_DATA_PREFETCH (1 << 28)
#define PREFETCH_CTRL_INSTR_PREFETCH (1 << 29)
#define PREFETCH_CTRL_DL (1 << 30)
-#define PL310_POWER_CTRL 0xF60
+#define PL310_POWER_CTRL 0xF80
#define POWER_CTRL_ENABLE_GATING (1 << 0)
#define POWER_CTRL_ENABLE_STANDBY (1 << 1)
diff --git a/sys/arm/include/pmap-v6.h b/sys/arm/include/pmap-v6.h
index bb58682..304dec6 100644
--- a/sys/arm/include/pmap-v6.h
+++ b/sys/arm/include/pmap-v6.h
@@ -193,7 +193,6 @@ void pmap_unmapdev(vm_offset_t, vm_size_t);
void pmap_kenter_device(vm_offset_t, vm_size_t, vm_paddr_t);
void pmap_kremove_device(vm_offset_t, vm_size_t);
void pmap_set_pcb_pagedir(pmap_t , struct pcb *);
-void pmap_lazyfix_action(void);
void pmap_tlb_flush(pmap_t , vm_offset_t );
void pmap_tlb_flush_range(pmap_t , vm_offset_t , vm_size_t );
diff --git a/sys/arm/include/proc.h b/sys/arm/include/proc.h
index 4ffbec5..a86df35 100644
--- a/sys/arm/include/proc.h
+++ b/sys/arm/include/proc.h
@@ -68,15 +68,20 @@ struct mdproc {
#endif
#define MAXARGS 8
+/*
+ * This holds the syscall state for a single system call.
+ * As some syscall arguments may be 64-bit aligned we need to ensure the
+ * args value is 64-bit aligned. The ABI will then ensure any 64-bit
+ * arguments are already correctly aligned, even if they were passed in
+ * via registers, we just need to make sure we copy them to an algned
+ * buffer.
+ */
struct syscall_args {
u_int code;
struct sysent *callp;
register_t args[MAXARGS];
int narg;
u_int nap;
-#ifndef __ARM_EABI__
- u_int32_t insn;
-#endif
-};
+} __aligned(8);
#endif /* !_MACHINE_PROC_H_ */
diff --git a/sys/arm/include/smp.h b/sys/arm/include/smp.h
index 1abe398..bce8b4f 100644
--- a/sys/arm/include/smp.h
+++ b/sys/arm/include/smp.h
@@ -14,7 +14,6 @@
#define IPI_HARDCLOCK 6
#define IPI_TLB 7
#define IPI_CACHE 8
-#define IPI_LAZYPMAP 9
void init_secondary(int cpu);
void mpentry(void);
diff --git a/sys/arm/include/sysreg.h b/sys/arm/include/sysreg.h
index f29991a..fb13487 100644
--- a/sys/arm/include/sysreg.h
+++ b/sys/arm/include/sysreg.h
@@ -212,6 +212,7 @@
#if __ARM_ARCH == 6 && defined(CPU_ARM1176)
#define CP15_PMCCNTR(rr) p15, 0, rr, c15, c12, 1 /* PM Cycle Count Register */
#elif __ARM_ARCH > 6
+#define CP15_L2CTLR(rr) p15, 1, rr, c9, c0, 2 /* L2 Control Register */
#define CP15_PMCR(rr) p15, 0, rr, c9, c12, 0 /* Performance Monitor Control Register */
#define CP15_PMCNTENSET(rr) p15, 0, rr, c9, c12, 1 /* PM Count Enable Set Register */
#define CP15_PMCNTENCLR(rr) p15, 0, rr, c9, c12, 2 /* PM Count Enable Clear Register */
diff --git a/sys/arm/qemu/files.qemu b/sys/arm/qemu/files.qemu
index d23524e..888c4c7 100644
--- a/sys/arm/qemu/files.qemu
+++ b/sys/arm/qemu/files.qemu
@@ -10,7 +10,6 @@ kern/kern_clocksource.c standard
#
# Standard qemu virt devices and support.
#
-arm/arm/gic.c standard
arm/arm/generic_timer.c standard
arm/qemu/virt_common.c standard
arm/qemu/virt_machdep.c standard
diff --git a/sys/arm/rockchip/files.rk30xx b/sys/arm/rockchip/files.rk30xx
index bfce36c..de2fe9e 100644
--- a/sys/arm/rockchip/files.rk30xx
+++ b/sys/arm/rockchip/files.rk30xx
@@ -4,7 +4,6 @@ kern/kern_clocksource.c standard
arm/arm/bus_space_asm_generic.S standard
arm/arm/bus_space_generic.c standard
-arm/arm/gic.c standard
arm/arm/mpcore_timer.c standard
arm/arm/bus_space_base.c standard
diff --git a/sys/arm/samsung/exynos/files.exynos5 b/sys/arm/samsung/exynos/files.exynos5
index 2e84f6c..347f3e5 100644
--- a/sys/arm/samsung/exynos/files.exynos5
+++ b/sys/arm/samsung/exynos/files.exynos5
@@ -6,7 +6,6 @@ arm/arm/bus_space_generic.c standard
arm/arm/bus_space_asm_generic.S standard
arm/arm/bus_space_base.c standard
-arm/arm/gic.c standard
arm/arm/generic_timer.c standard
arm/samsung/exynos/exynos5_mct.c standard
diff --git a/sys/arm/ti/aintc.c b/sys/arm/ti/aintc.c
index d54594c..fe41723 100644
--- a/sys/arm/ti/aintc.c
+++ b/sys/arm/ti/aintc.c
@@ -69,7 +69,6 @@ static struct resource_spec ti_aintc_spec[] = {
{ -1, 0 }
};
-
static struct ti_aintc_softc *ti_aintc_sc = NULL;
#define aintc_read_4(_sc, reg) \
@@ -77,6 +76,12 @@ static struct ti_aintc_softc *ti_aintc_sc = NULL;
#define aintc_write_4(_sc, reg, val) \
bus_space_write_4((_sc)->aintc_bst, (_sc)->aintc_bsh, (reg), (val))
+/* List of compatible strings for FDT tree */
+static struct ofw_compat_data compat_data[] = {
+ {"ti,am33xx-intc", 1},
+ {"ti,omap2-intc", 1},
+ {NULL, 0},
+};
static void
aintc_post_filter(void *arg)
@@ -92,9 +97,9 @@ ti_aintc_probe(device_t dev)
if (!ofw_bus_status_okay(dev))
return (ENXIO);
-
- if (!ofw_bus_is_compatible(dev, "ti,aintc"))
+ if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
return (ENXIO);
+
device_set_desc(dev, "TI AINTC Interrupt Controller");
return (BUS_PROBE_DEFAULT);
}
diff --git a/sys/arm/ti/am335x/am335x_dmtimer.c b/sys/arm/ti/am335x/am335x_dmtimer.c
index 7ba171e..d93cc50 100644
--- a/sys/arm/ti/am335x/am335x_dmtimer.c
+++ b/sys/arm/ti/am335x/am335x_dmtimer.c
@@ -54,7 +54,8 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
#include <arm/ti/ti_prcm.h>
-#include <arm/ti/ti_scm.h>
+#include <arm/ti/ti_hwmods.h>
+#include <arm/ti/ti_pinmux.h>
#define AM335X_NUM_TIMERS 8
@@ -109,78 +110,38 @@ __FBSDID("$FreeBSD$");
#define DEFAULT_ET_TIMER 2
#define DEFAULT_TC_TIMER 3
+#define DMTIMER_READ4(sc, reg) (bus_read_4((sc)->tmr_mem_res, (reg)))
+#define DMTIMER_WRITE4(sc, reg, val) (bus_write_4((sc)->tmr_mem_res, (reg), (val)))
+
struct am335x_dmtimer_softc {
- struct resource * tmr_mem_res[AM335X_NUM_TIMERS];
- struct resource * tmr_irq_res[AM335X_NUM_TIMERS];
+ device_t dev;
+ int tmr_mem_rid;
+ struct resource * tmr_mem_res;
+ int tmr_irq_rid;
+ struct resource * tmr_irq_res;
+ void *tmr_irq_handler;
uint32_t sysclk_freq;
- uint32_t tc_num; /* Which timer number is tc. */
- uint32_t tc_tclr; /* Cached tc TCLR register. */
- struct resource * tc_memres; /* Resources for tc timer. */
- uint32_t et_num; /* Which timer number is et. */
- uint32_t et_tclr; /* Cached et TCLR register. */
- struct resource * et_memres; /* Resources for et timer. */
+ uint32_t tclr; /* Cached TCLR register. */
int pps_curmode; /* Edge mode now set in hw. */
struct task pps_task; /* For pps_event handling. */
struct cdev * pps_cdev;
struct pps_state pps;
- struct timecounter tc;
- struct eventtimer et;
-};
-static struct am335x_dmtimer_softc *am335x_dmtimer_sc;
-
-static struct resource_spec am335x_dmtimer_mem_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
- { SYS_RES_MEMORY, 1, RF_ACTIVE },
- { SYS_RES_MEMORY, 2, RF_ACTIVE },
- { SYS_RES_MEMORY, 3, RF_ACTIVE },
- { SYS_RES_MEMORY, 4, RF_ACTIVE },
- { SYS_RES_MEMORY, 5, RF_ACTIVE },
- { SYS_RES_MEMORY, 6, RF_ACTIVE },
- { SYS_RES_MEMORY, 7, RF_ACTIVE },
- { -1, 0, 0 }
+ union {
+ struct timecounter tc;
+ struct eventtimer et;
+ } func;
};
-static struct resource_spec am335x_dmtimer_irq_spec[] = {
- { SYS_RES_IRQ, 0, RF_ACTIVE },
- { SYS_RES_IRQ, 1, RF_ACTIVE },
- { SYS_RES_IRQ, 2, RF_ACTIVE },
- { SYS_RES_IRQ, 3, RF_ACTIVE },
- { SYS_RES_IRQ, 4, RF_ACTIVE },
- { SYS_RES_IRQ, 5, RF_ACTIVE },
- { SYS_RES_IRQ, 6, RF_ACTIVE },
- { SYS_RES_IRQ, 7, RF_ACTIVE },
- { -1, 0, 0 }
-};
-
-static inline uint32_t
-am335x_dmtimer_tc_read_4(struct am335x_dmtimer_softc *sc, uint32_t reg)
-{
-
- return (bus_read_4(sc->tc_memres, reg));
-}
-
-static inline void
-am335x_dmtimer_tc_write_4(struct am335x_dmtimer_softc *sc, uint32_t reg,
- uint32_t val)
-{
-
- bus_write_4(sc->tc_memres, reg, val);
-}
-
-static inline uint32_t
-am335x_dmtimer_et_read_4(struct am335x_dmtimer_softc *sc, uint32_t reg)
-{
- return (bus_read_4(sc->et_memres, reg));
-}
+static struct am335x_dmtimer_softc *am335x_dmtimer_et_sc = NULL;
+static struct am335x_dmtimer_softc *am335x_dmtimer_tc_sc = NULL;
-static inline void
-am335x_dmtimer_et_write_4(struct am335x_dmtimer_softc *sc, uint32_t reg,
- uint32_t val)
-{
- bus_write_4(sc->et_memres, reg, val);
-}
+#ifdef PPS_SYNC
+/* -1 - not detected, 0 - not found, > 0 - timerX module */
+static int am335x_dmtimer_pps_module = -1;
+static const char *am335x_dmtimer_pps_hwmod = NULL;
+#endif
/*
* PPS driver routines, included when the kernel is built with option PPS_SYNC.
@@ -215,19 +176,19 @@ am335x_dmtimer_set_capture_mode(struct am335x_dmtimer_softc *sc, bool force_off)
return;
sc->pps_curmode = newmode;
- sc->tc_tclr &= ~DMT_TCLR_CAPTRAN_MASK;
+ sc->tclr &= ~DMT_TCLR_CAPTRAN_MASK;
switch (newmode) {
case PPS_CAPTUREASSERT:
- sc->tc_tclr |= DMT_TCLR_CAPTRAN_LOHI;
+ sc->tclr |= DMT_TCLR_CAPTRAN_LOHI;
break;
case PPS_CAPTURECLEAR:
- sc->tc_tclr |= DMT_TCLR_CAPTRAN_HILO;
+ sc->tclr |= DMT_TCLR_CAPTRAN_HILO;
break;
default:
/* It can't be BOTH, so it's disabled. */
break;
}
- am335x_dmtimer_tc_write_4(sc, DMT_TCLR, sc->tc_tclr);
+ DMTIMER_WRITE4(sc, DMT_TCLR, sc->tclr);
}
static void
@@ -244,10 +205,10 @@ am335x_dmtimer_tc_poll_pps(struct timecounter *tc)
* TCAR status to re-arm the capture for the next second, we have to
* write to the IRQ status register, not the RAW register. Quirky.
*/
- if (am335x_dmtimer_tc_read_4(sc, DMT_IRQSTATUS_RAW) & DMT_IRQ_TCAR) {
+ if (DMTIMER_READ4(sc, DMT_IRQSTATUS_RAW) & DMT_IRQ_TCAR) {
pps_capture(&sc->pps);
- sc->pps.capcount = am335x_dmtimer_tc_read_4(sc, DMT_TCAR1);
- am335x_dmtimer_tc_write_4(sc, DMT_IRQSTATUS, DMT_IRQ_TCAR);
+ sc->pps.capcount = DMTIMER_READ4(sc, DMT_TCAR1);
+ DMTIMER_WRITE4(sc, DMT_IRQSTATUS, DMT_IRQ_TCAR);
taskqueue_enqueue_fast(taskqueue_fast, &sc->pps_task);
}
}
@@ -339,21 +300,15 @@ static struct cdevsw am335x_dmtimer_pps_cdevsw = {
.d_name = PPS_CDEV_NAME,
};
-/*
- * Set up the PPS cdev and the the kernel timepps stuff.
- *
- * Note that this routine cannot touch the hardware, because bus space resources
- * are not fully set up yet when this is called.
- */
-static int
-am335x_dmtimer_pps_init(device_t dev, struct am335x_dmtimer_softc *sc)
+static void
+am335x_dmtimer_pps_find()
{
- int i, timer_num, unit;
+ int i;
unsigned int padstate;
const char * padmux;
struct padinfo {
char * ballname;
- char * muxname;
+ const char * muxname;
int timer_num;
} padinfo[] = {
{"GPMC_ADVn_ALE", "timer4", 4},
@@ -370,21 +325,47 @@ am335x_dmtimer_pps_init(device_t dev, struct am335x_dmtimer_softc *sc)
* is configured for input. The right symbolic values aren't exported
* yet from ti_scm.h.
*/
- timer_num = 0;
- for (i = 0; i < nitems(padinfo) && timer_num == 0; ++i) {
- if (ti_scm_padconf_get(padinfo[i].ballname, &padmux,
+ am335x_dmtimer_pps_module = 0;
+ for (i = 0; i < nitems(padinfo) && am335x_dmtimer_pps_module == 0; ++i) {
+ if (ti_pinmux_padconf_get(padinfo[i].ballname, &padmux,
&padstate) == 0) {
if (strcasecmp(padinfo[i].muxname, padmux) == 0 &&
- (padstate & (0x01 << 5)))
- timer_num = padinfo[i].timer_num;
+ (padstate & (0x01 << 5))) {
+ am335x_dmtimer_pps_module = padinfo[i].timer_num;
+ am335x_dmtimer_pps_hwmod = padinfo[i].muxname;
+ }
}
}
- if (timer_num == 0) {
- device_printf(dev, "No DMTimer found with capture pin "
+
+ if (am335x_dmtimer_pps_module == 0) {
+ printf("am335x_dmtimer: No DMTimer found with capture pin "
"configured as input; PPS driver disabled.\n");
- return (DEFAULT_TC_TIMER);
}
+}
+
+/*
+ * Set up the PPS cdev and the the kernel timepps stuff.
+ *
+ * Note that this routine cannot touch the hardware, because bus space resources
+ * are not fully set up yet when this is called.
+ */
+static void
+am335x_dmtimer_pps_init(device_t dev, struct am335x_dmtimer_softc *sc)
+{
+ int unit;
+
+ if (am335x_dmtimer_pps_module == -1)
+ am335x_dmtimer_pps_find();
+
+ /* No PPS input */
+ if (am335x_dmtimer_pps_module == 0)
+ return;
+
+ /* Not PPS-enabled input */
+ if ((am335x_dmtimer_pps_module > 0) &&
+ (!ti_hwmods_contains(dev, am335x_dmtimer_pps_hwmod)))
+ return;
/*
* Indicate our capabilities (pretty much just capture of either edge).
@@ -398,35 +379,21 @@ am335x_dmtimer_pps_init(device_t dev, struct am335x_dmtimer_softc *sc)
* Set up to capture the PPS via timecounter polling, and init the task
* that does deferred pps_event() processing after capture.
*/
- sc->tc.tc_poll_pps = am335x_dmtimer_tc_poll_pps;
+ sc->func.tc.tc_poll_pps = am335x_dmtimer_tc_poll_pps;
TASK_INIT(&sc->pps_task, 0, am335x_dmtimer_process_pps_event, sc);
/* Create the PPS cdev. */
- unit = device_get_unit(dev);
sc->pps_cdev = make_dev(&am335x_dmtimer_pps_cdevsw, unit,
- UID_ROOT, GID_WHEEL, 0600, PPS_CDEV_NAME "%d", unit);
+ UID_ROOT, GID_WHEEL, 0600, PPS_CDEV_NAME);
sc->pps_cdev->si_drv1 = sc;
+ unit = device_get_unit(sc->pps_cdev);
device_printf(dev, "Using DMTimer%d for PPS device /dev/%s%d\n",
- timer_num, PPS_CDEV_NAME, unit);
-
- return (timer_num);
+ am335x_dmtimer_pps_module, PPS_CDEV_NAME, unit);
}
-#else /* PPS_SYNC */
+#endif
-static int
-am335x_dmtimer_pps_init(device_t dev, struct am335x_dmtimer_softc *sc)
-{
-
- /*
- * When PPS support is not compiled in, there's no need to use a timer
- * that has an associated capture-input pin, so use the default.
- */
- return (DEFAULT_TC_TIMER);
-}
-
-#endif /* PPS_SYNC */
/*
* End of PPS driver code.
*/
@@ -438,7 +405,7 @@ am335x_dmtimer_tc_get_timecount(struct timecounter *tc)
sc = tc->tc_priv;
- return (am335x_dmtimer_tc_read_4(sc, DMT_TCRR));
+ return (DMTIMER_READ4(sc, DMT_TCRR));
}
static int
@@ -462,13 +429,13 @@ am335x_dmtimer_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
* from the et_event_cb() routine dispatched from our own handler, but
* it's not clear to me that that's the only case possible.
*/
- sc->et_tclr &= ~(DMT_TCLR_START | DMT_TCLR_AUTOLOAD);
- am335x_dmtimer_et_write_4(sc, DMT_TCLR, sc->et_tclr);
- am335x_dmtimer_et_write_4(sc, DMT_IRQSTATUS, DMT_IRQ_OVF);
+ sc->tclr &= ~(DMT_TCLR_START | DMT_TCLR_AUTOLOAD);
+ DMTIMER_WRITE4(sc, DMT_TCLR, sc->tclr);
+ DMTIMER_WRITE4(sc, DMT_IRQSTATUS, DMT_IRQ_OVF);
if (period != 0) {
reload_count = ((uint32_t)et->et_frequency * period) >> 32;
- sc->et_tclr |= DMT_TCLR_AUTOLOAD;
+ sc->tclr |= DMT_TCLR_AUTOLOAD;
} else {
reload_count = 0;
}
@@ -482,13 +449,13 @@ am335x_dmtimer_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
* Set auto-reload and current-count values. This timer hardware counts
* up from the initial/reload value and interrupts on the zero rollover.
*/
- am335x_dmtimer_et_write_4(sc, DMT_TLDR, 0xFFFFFFFF - reload_count);
- am335x_dmtimer_et_write_4(sc, DMT_TCRR, 0xFFFFFFFF - initial_count);
+ DMTIMER_WRITE4(sc, DMT_TLDR, 0xFFFFFFFF - reload_count);
+ DMTIMER_WRITE4(sc, DMT_TCRR, 0xFFFFFFFF - initial_count);
/* Enable overflow interrupt, and start the timer. */
- am335x_dmtimer_et_write_4(sc, DMT_IRQENABLE_SET, DMT_IRQ_OVF);
- sc->et_tclr |= DMT_TCLR_START;
- am335x_dmtimer_et_write_4(sc, DMT_TCLR, sc->et_tclr);
+ DMTIMER_WRITE4(sc, DMT_IRQENABLE_SET, DMT_IRQ_OVF);
+ sc->tclr |= DMT_TCLR_START;
+ DMTIMER_WRITE4(sc, DMT_TCLR, sc->tclr);
return (0);
}
@@ -501,10 +468,10 @@ am335x_dmtimer_stop(struct eventtimer *et)
sc = et->et_priv;
/* Stop timer, disable and clear interrupt. */
- sc->et_tclr &= ~(DMT_TCLR_START | DMT_TCLR_AUTOLOAD);
- am335x_dmtimer_et_write_4(sc, DMT_TCLR, sc->et_tclr);
- am335x_dmtimer_et_write_4(sc, DMT_IRQENABLE_CLR, DMT_IRQ_OVF);
- am335x_dmtimer_et_write_4(sc, DMT_IRQSTATUS, DMT_IRQ_OVF);
+ sc->tclr &= ~(DMT_TCLR_START | DMT_TCLR_AUTOLOAD);
+ DMTIMER_WRITE4(sc, DMT_TCLR, sc->tclr);
+ DMTIMER_WRITE4(sc, DMT_IRQENABLE_CLR, DMT_IRQ_OVF);
+ DMTIMER_WRITE4(sc, DMT_IRQSTATUS, DMT_IRQ_OVF);
return (0);
}
@@ -516,13 +483,96 @@ am335x_dmtimer_intr(void *arg)
sc = arg;
/* Ack the interrupt, and invoke the callback if it's still enabled. */
- am335x_dmtimer_et_write_4(sc, DMT_IRQSTATUS, DMT_IRQ_OVF);
- if (sc->et.et_active)
- sc->et.et_event_cb(&sc->et, sc->et.et_arg);
+ DMTIMER_WRITE4(sc, DMT_IRQSTATUS, DMT_IRQ_OVF);
+ if (sc->func.et.et_active)
+ sc->func.et.et_event_cb(&sc->func.et, sc->func.et.et_arg);
return (FILTER_HANDLED);
}
+/*
+ * Checks if timer is suitable to be system timer
+ */
+static int
+am335x_dmtimer_system_compatible(device_t dev)
+{
+ phandle_t node;
+
+ node = ofw_bus_get_node(dev);
+ if (OF_hasprop(node, "ti,timer-alwon"))
+ return (0);
+
+ return (1);
+}
+
+static int
+am335x_dmtimer_init_et(struct am335x_dmtimer_softc *sc)
+{
+ if (am335x_dmtimer_et_sc != NULL)
+ return (EEXIST);
+
+#ifdef PPS_SYNC
+ if ((am335x_dmtimer_pps_module > 0) &&
+ (!ti_hwmods_contains(sc->dev, am335x_dmtimer_pps_hwmod))) {
+ device_printf(sc->dev, "not PPS enabled\n");
+ return (ENXIO);
+ }
+#endif
+
+ /* Setup eventtimer interrupt handler. */
+ if (bus_setup_intr(sc->dev, sc->tmr_irq_res, INTR_TYPE_CLK,
+ am335x_dmtimer_intr, NULL, sc, &sc->tmr_irq_handler) != 0) {
+ device_printf(sc->dev, "Unable to setup the clock irq handler.\n");
+ return (ENXIO);
+ }
+
+ sc->func.et.et_name = "AM335x Eventtimer";
+ sc->func.et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT;
+ sc->func.et.et_quality = 1000;
+ sc->func.et.et_frequency = sc->sysclk_freq;
+ sc->func.et.et_min_period =
+ ((0x00000005LLU << 32) / sc->func.et.et_frequency);
+ sc->func.et.et_max_period =
+ (0xfffffffeLLU << 32) / sc->func.et.et_frequency;
+ sc->func.et.et_start = am335x_dmtimer_start;
+ sc->func.et.et_stop = am335x_dmtimer_stop;
+ sc->func.et.et_priv = sc;
+ et_register(&sc->func.et);
+
+ am335x_dmtimer_et_sc = sc;
+
+ return (0);
+}
+
+static int
+am335x_dmtimer_init_tc(struct am335x_dmtimer_softc *sc)
+{
+ if (am335x_dmtimer_tc_sc != NULL)
+ return (EEXIST);
+
+ /* Set up timecounter, start it, register it. */
+ DMTIMER_WRITE4(sc, DMT_TSICR, DMT_TSICR_RESET);
+ while (DMTIMER_READ4(sc, DMT_TIOCP_CFG) & DMT_TIOCP_RESET)
+ continue;
+
+ sc->tclr |= DMT_TCLR_START | DMT_TCLR_AUTOLOAD;
+ DMTIMER_WRITE4(sc, DMT_TLDR, 0);
+ DMTIMER_WRITE4(sc, DMT_TCRR, 0);
+ DMTIMER_WRITE4(sc, DMT_TCLR, sc->tclr);
+
+ sc->func.tc.tc_name = "AM335x Timecounter";
+ sc->func.tc.tc_get_timecount = am335x_dmtimer_tc_get_timecount;
+ sc->func.tc.tc_counter_mask = ~0u;
+ sc->func.tc.tc_frequency = sc->sysclk_freq;
+ sc->func.tc.tc_quality = 1000;
+ sc->func.tc.tc_priv = sc;
+ tc_init(&sc->func.tc);
+
+ am335x_dmtimer_tc_sc = sc;
+
+ return (0);
+}
+
static int
am335x_dmtimer_probe(device_t dev)
{
@@ -530,7 +580,8 @@ am335x_dmtimer_probe(device_t dev)
if (!ofw_bus_status_okay(dev))
return (ENXIO);
- if (ofw_bus_is_compatible(dev, "ti,am335x-dmtimer")) {
+ if (ofw_bus_is_compatible(dev, "ti,am335x-timer-1ms") ||
+ ofw_bus_is_compatible(dev, "ti,am335x-timer")) {
device_set_desc(dev, "AM335x DMTimer");
return(BUS_PROBE_DEFAULT);
}
@@ -542,8 +593,9 @@ static int
am335x_dmtimer_attach(device_t dev)
{
struct am335x_dmtimer_softc *sc;
- void *ihl;
int err;
+ clk_ident_t timer_id;
+ int enable;
/*
* Note that if this routine returns an error status rather than running
@@ -552,9 +604,7 @@ am335x_dmtimer_attach(device_t dev)
*/
sc = device_get_softc(dev);
-
- if (am335x_dmtimer_sc != NULL)
- return (EINVAL);
+ sc->dev = dev;
/* Get the base clock frequency. */
err = ti_prcm_clk_get_source_freq(SYS_CLK, &sc->sysclk_freq);
@@ -564,81 +614,60 @@ am335x_dmtimer_attach(device_t dev)
}
/* Request the memory resources. */
- err = bus_alloc_resources(dev, am335x_dmtimer_mem_spec,
- sc->tmr_mem_res);
- if (err) {
+ sc->tmr_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
+ &sc->tmr_mem_rid, RF_ACTIVE);
+ if (sc->tmr_mem_res == NULL) {
device_printf(dev, "Error: could not allocate mem resources\n");
return (ENXIO);
}
/* Request the IRQ resources. */
- err = bus_alloc_resources(dev, am335x_dmtimer_irq_spec,
- sc->tmr_irq_res);
+ sc->tmr_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ,
+ &sc->tmr_irq_rid, RF_ACTIVE);
if (err) {
+ bus_release_resource(dev, SYS_RES_MEMORY, sc->tmr_mem_rid,
+ sc->tmr_mem_res);
device_printf(dev, "Error: could not allocate irq resources\n");
return (ENXIO);
}
- /*
- * Use the default eventtimer. Let the PPS init routine decide which
- * timer to use for the timecounter.
- */
- sc->et_num = DEFAULT_ET_TIMER;
- sc->tc_num = am335x_dmtimer_pps_init(dev, sc);
-
- sc->et_memres = sc->tmr_mem_res[sc->et_num];
- sc->tc_memres = sc->tmr_mem_res[sc->tc_num];
-
- /* Enable clocks and power on the chosen devices. */
- err = ti_prcm_clk_set_source(DMTIMER0_CLK + sc->et_num, SYSCLK_CLK);
- err |= ti_prcm_clk_enable(DMTIMER0_CLK + sc->et_num);
- err |= ti_prcm_clk_set_source(DMTIMER0_CLK + sc->tc_num, SYSCLK_CLK);
- err |= ti_prcm_clk_enable(DMTIMER0_CLK + sc->tc_num);
- if (err) {
- device_printf(dev, "Error: could not enable timer clock\n");
- return (ENXIO);
+#ifdef PPS_SYNC
+ am335x_dmtimer_pps_init(dev, sc);
+#endif
+
+ enable = 0;
+ /* Try to use as a timecounter or event timer */
+ if (am335x_dmtimer_system_compatible(dev)) {
+ if (am335x_dmtimer_init_tc(sc) == 0)
+ enable = 1;
+ else if (am335x_dmtimer_init_et(sc) == 0)
+ enable = 1;
}
- /* Setup eventtimer interrupt handler. */
- if (bus_setup_intr(dev, sc->tmr_irq_res[sc->et_num], INTR_TYPE_CLK,
- am335x_dmtimer_intr, NULL, sc, &ihl) != 0) {
- device_printf(dev, "Unable to setup the clock irq handler.\n");
- return (ENXIO);
- }
+ if (enable) {
+ /* Enable clocks and power on the chosen devices. */
+ timer_id = ti_hwmods_get_clock(dev);
+ if (timer_id == INVALID_CLK_IDENT) {
+ bus_release_resource(dev, SYS_RES_MEMORY, sc->tmr_mem_rid,
+ sc->tmr_mem_res);
+ bus_release_resource(dev, SYS_RES_IRQ, sc->tmr_irq_rid,
+ sc->tmr_irq_res);
+ device_printf(dev, "failed to get device id using ti,hwmods\n");
+ return (ENXIO);
+ }
- /* Set up timecounter, start it, register it. */
- am335x_dmtimer_tc_write_4(sc, DMT_TSICR, DMT_TSICR_RESET);
- while (am335x_dmtimer_tc_read_4(sc, DMT_TIOCP_CFG) & DMT_TIOCP_RESET)
- continue;
+ err = ti_prcm_clk_set_source(timer_id, SYSCLK_CLK);
+ err |= ti_prcm_clk_enable(timer_id);
- sc->tc_tclr |= DMT_TCLR_START | DMT_TCLR_AUTOLOAD;
- am335x_dmtimer_tc_write_4(sc, DMT_TLDR, 0);
- am335x_dmtimer_tc_write_4(sc, DMT_TCRR, 0);
- am335x_dmtimer_tc_write_4(sc, DMT_TCLR, sc->tc_tclr);
-
- sc->tc.tc_name = "AM335x Timecounter";
- sc->tc.tc_get_timecount = am335x_dmtimer_tc_get_timecount;
- sc->tc.tc_counter_mask = ~0u;
- sc->tc.tc_frequency = sc->sysclk_freq;
- sc->tc.tc_quality = 1000;
- sc->tc.tc_priv = sc;
- tc_init(&sc->tc);
-
- sc->et.et_name = "AM335x Eventtimer";
- sc->et.et_flags = ET_FLAGS_PERIODIC | ET_FLAGS_ONESHOT;
- sc->et.et_quality = 1000;
- sc->et.et_frequency = sc->sysclk_freq;
- sc->et.et_min_period =
- ((0x00000005LLU << 32) / sc->et.et_frequency);
- sc->et.et_max_period =
- (0xfffffffeLLU << 32) / sc->et.et_frequency;
- sc->et.et_start = am335x_dmtimer_start;
- sc->et.et_stop = am335x_dmtimer_stop;
- sc->et.et_priv = sc;
- et_register(&sc->et);
-
- /* Store a pointer to the softc for use in DELAY(). */
- am335x_dmtimer_sc = sc;
+ if (err) {
+ bus_release_resource(dev, SYS_RES_MEMORY, sc->tmr_mem_rid,
+ sc->tmr_mem_res);
+ bus_release_resource(dev, SYS_RES_IRQ, sc->tmr_irq_rid,
+ sc->tmr_irq_res);
+ device_printf(dev, "Error: could not enable timer clock\n");
+ return (ENXIO);
+ }
+ }
return (0);
}
@@ -667,7 +696,7 @@ DELAY(int usec)
int32_t counts;
uint32_t first, last;
- sc = am335x_dmtimer_sc;
+ sc = am335x_dmtimer_tc_sc;
if (sc == NULL) {
for (; usec > 0; usec--)
@@ -680,10 +709,10 @@ DELAY(int usec)
/* Get the number of times to count */
counts = (usec + 1) * (sc->sysclk_freq / 1000000);
- first = am335x_dmtimer_tc_read_4(sc, DMT_TCRR);
+ first = DMTIMER_READ4(sc, DMT_TCRR);
while (counts > 0) {
- last = am335x_dmtimer_tc_read_4(sc, DMT_TCRR);
+ last = DMTIMER_READ4(sc, DMT_TCRR);
if (last > first) {
counts -= (int32_t)(last - first);
} else {
diff --git a/sys/arm/ti/am335x/am335x_ecap.c b/sys/arm/ti/am335x/am335x_ecap.c
new file mode 100644
index 0000000..eba5f72
--- /dev/null
+++ b/sys/arm/ti/am335x/am335x_ecap.c
@@ -0,0 +1,201 @@
+/*-
+ * Copyright (c) 2013 Oleksandr Tymoshenko <gonzo@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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/limits.h>
+#include <sys/lock.h>
+#include <sys/module.h>
+#include <sys/mutex.h>
+#include <sys/resource.h>
+#include <sys/rman.h>
+#include <sys/sysctl.h>
+
+#include <machine/bus.h>
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include "am335x_pwm.h"
+
+#define ECAP_TSCTR 0x00
+#define ECAP_CAP1 0x08
+#define ECAP_CAP2 0x0C
+#define ECAP_CAP3 0x10
+#define ECAP_CAP4 0x14
+#define ECAP_ECCTL2 0x2A
+#define ECCTL2_MODE_APWM (1 << 9)
+#define ECCTL2_SYNCO_SEL (3 << 6)
+#define ECCTL2_TSCTRSTOP_FREERUN (1 << 4)
+
+#define ECAP_READ2(_sc, reg) bus_read_2((_sc)->sc_mem_res, reg);
+#define ECAP_WRITE2(_sc, reg, value) \
+ bus_write_2((_sc)->sc_mem_res, reg, value);
+#define ECAP_READ4(_sc, reg) bus_read_4((_sc)->sc_mem_res, reg);
+#define ECAP_WRITE4(_sc, reg, value) \
+ bus_write_4((_sc)->sc_mem_res, reg, value);
+
+#define PWM_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
+#define PWM_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
+#define PWM_LOCK_INIT(_sc) mtx_init(&(_sc)->sc_mtx, \
+ device_get_nameunit(_sc->sc_dev), "am335x_ecap softc", MTX_DEF)
+#define PWM_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_mtx)
+
+static device_probe_t am335x_ecap_probe;
+static device_attach_t am335x_ecap_attach;
+static device_detach_t am335x_ecap_detach;
+
+struct am335x_ecap_softc {
+ device_t sc_dev;
+ struct mtx sc_mtx;
+ struct resource *sc_mem_res;
+ int sc_mem_rid;
+};
+
+static device_method_t am335x_ecap_methods[] = {
+ DEVMETHOD(device_probe, am335x_ecap_probe),
+ DEVMETHOD(device_attach, am335x_ecap_attach),
+ DEVMETHOD(device_detach, am335x_ecap_detach),
+
+ DEVMETHOD_END
+};
+
+static driver_t am335x_ecap_driver = {
+ "am335x_ecap",
+ am335x_ecap_methods,
+ sizeof(struct am335x_ecap_softc),
+};
+
+static devclass_t am335x_ecap_devclass;
+
+/*
+ * API function to set period/duty cycles for ECAPx
+ */
+int
+am335x_pwm_config_ecap(int unit, int period, int duty)
+{
+ device_t dev;
+ struct am335x_ecap_softc *sc;
+ uint16_t reg;
+
+ dev = devclass_get_device(am335x_ecap_devclass, unit);
+ if (dev == NULL)
+ return (ENXIO);
+
+ if (duty > period)
+ return (EINVAL);
+
+ if (period == 0)
+ return (EINVAL);
+
+ sc = device_get_softc(dev);
+ PWM_LOCK(sc);
+
+ reg = ECAP_READ2(sc, ECAP_ECCTL2);
+ reg |= ECCTL2_MODE_APWM | ECCTL2_TSCTRSTOP_FREERUN | ECCTL2_SYNCO_SEL;
+ ECAP_WRITE2(sc, ECAP_ECCTL2, reg);
+
+ /* CAP3 in APWM mode is APRD shadow register */
+ ECAP_WRITE4(sc, ECAP_CAP3, period - 1);
+
+ /* CAP4 in APWM mode is ACMP shadow register */
+ ECAP_WRITE4(sc, ECAP_CAP4, duty);
+ /* Restart counter */
+ ECAP_WRITE4(sc, ECAP_TSCTR, 0);
+
+ PWM_UNLOCK(sc);
+
+ return (0);
+}
+
+static int
+am335x_ecap_probe(device_t dev)
+{
+
+ if (!ofw_bus_status_okay(dev))
+ return (ENXIO);
+
+ if (!ofw_bus_is_compatible(dev, "ti,am33xx-ecap"))
+ return (ENXIO);
+
+ device_set_desc(dev, "AM335x eCAP");
+
+ return (BUS_PROBE_DEFAULT);
+}
+
+static int
+am335x_ecap_attach(device_t dev)
+{
+ struct am335x_ecap_softc *sc;
+
+ sc = device_get_softc(dev);
+ sc->sc_dev = dev;
+
+ PWM_LOCK_INIT(sc);
+
+ sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
+ &sc->sc_mem_rid, RF_ACTIVE);
+ if (sc->sc_mem_res == NULL) {
+ device_printf(dev, "cannot allocate memory resources\n");
+ goto fail;
+ }
+
+ return (0);
+
+fail:
+ PWM_LOCK_DESTROY(sc);
+ return (ENXIO);
+}
+
+static int
+am335x_ecap_detach(device_t dev)
+{
+ struct am335x_ecap_softc *sc;
+
+ sc = device_get_softc(dev);
+
+ PWM_LOCK(sc);
+ if (sc->sc_mem_res)
+ bus_release_resource(dev, SYS_RES_MEMORY,
+ sc->sc_mem_rid, sc->sc_mem_res);
+ PWM_UNLOCK(sc);
+
+ PWM_LOCK_DESTROY(sc);
+
+
+ return (0);
+}
+
+DRIVER_MODULE(am335x_ecap, am335x_pwmss, am335x_ecap_driver, am335x_ecap_devclass, 0, 0);
+MODULE_VERSION(am335x_ecap, 1);
+MODULE_DEPEND(am335x_ecap, am335x_pwmss, 1, 1, 1);
diff --git a/sys/arm/ti/am335x/am335x_pwm.c b/sys/arm/ti/am335x/am335x_ehrpwm.c
index b544d64..331331f 100644
--- a/sys/arm/ti/am335x/am335x_pwm.c
+++ b/sys/arm/ti/am335x/am335x_ehrpwm.c
@@ -46,11 +46,7 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
-#include <arm/ti/ti_prcm.h>
-#include <arm/ti/ti_scm.h>
-
#include "am335x_pwm.h"
-#include "am335x_scm.h"
/* In ticks */
#define DEFAULT_PWM_PERIOD 1000
@@ -59,47 +55,12 @@ __FBSDID("$FreeBSD$");
#define PWM_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
#define PWM_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
#define PWM_LOCK_INIT(_sc) mtx_init(&(_sc)->sc_mtx, \
- device_get_nameunit(_sc->sc_dev), "am335x_pwm softc", MTX_DEF)
+ device_get_nameunit(_sc->sc_dev), "am335x_ehrpwm softc", MTX_DEF)
#define PWM_LOCK_DESTROY(_sc) mtx_destroy(&(_sc)->sc_mtx)
-static struct resource_spec am335x_pwm_mem_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE }, /* PWMSS */
- { SYS_RES_MEMORY, 1, RF_ACTIVE }, /* eCAP */
- { SYS_RES_MEMORY, 2, RF_ACTIVE }, /* eQEP */
- { SYS_RES_MEMORY, 3, RF_ACTIVE }, /*ePWM */
- { -1, 0, 0 }
-};
-
-#define PWMSS_READ4(_sc, reg) bus_read_4((_sc)->sc_mem_res[0], reg);
-#define PWMSS_WRITE4(_sc, reg, value) \
- bus_write_4((_sc)->sc_mem_res[0], reg, value);
-
-#define ECAP_READ2(_sc, reg) bus_read_2((_sc)->sc_mem_res[1], reg);
-#define ECAP_WRITE2(_sc, reg, value) \
- bus_write_2((_sc)->sc_mem_res[1], reg, value);
-#define ECAP_READ4(_sc, reg) bus_read_4((_sc)->sc_mem_res[1], reg);
-#define ECAP_WRITE4(_sc, reg, value) \
- bus_write_4((_sc)->sc_mem_res[1], reg, value);
-
-#define EPWM_READ2(_sc, reg) bus_read_2((_sc)->sc_mem_res[3], reg);
+#define EPWM_READ2(_sc, reg) bus_read_2((_sc)->sc_mem_res, reg);
#define EPWM_WRITE2(_sc, reg, value) \
- bus_write_2((_sc)->sc_mem_res[3], reg, value);
-
-#define PWMSS_IDVER 0x00
-#define PWMSS_SYSCONFIG 0x04
-#define PWMSS_CLKCONFIG 0x08
-#define CLKCONFIG_EPWMCLK_EN (1 << 8)
-#define PWMSS_CLKSTATUS 0x0C
-
-#define ECAP_TSCTR 0x00
-#define ECAP_CAP1 0x08
-#define ECAP_CAP2 0x0C
-#define ECAP_CAP3 0x10
-#define ECAP_CAP4 0x14
-#define ECAP_ECCTL2 0x2A
-#define ECCTL2_MODE_APWM (1 << 9)
-#define ECCTL2_SYNCO_SEL (3 << 6)
-#define ECCTL2_TSCTRSTOP_FREERUN (1 << 4)
+ bus_write_2((_sc)->sc_mem_res, reg, value);
#define EPWM_TBCTL 0x00
#define TBCTL_FREERUN (2 << 14)
@@ -169,17 +130,17 @@ static struct resource_spec am335x_pwm_mem_spec[] = {
#define HRCTL_DELMODE_FALL 2
#define HRCTL_DELMODE_RISE 1
-static device_probe_t am335x_pwm_probe;
-static device_attach_t am335x_pwm_attach;
-static device_detach_t am335x_pwm_detach;
-
-static int am335x_pwm_clkdiv[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
+static device_probe_t am335x_ehrpwm_probe;
+static device_attach_t am335x_ehrpwm_attach;
+static device_detach_t am335x_ehrpwm_detach;
+
+static int am335x_ehrpwm_clkdiv[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
-struct am335x_pwm_softc {
+struct am335x_ehrpwm_softc {
device_t sc_dev;
struct mtx sc_mtx;
- struct resource *sc_mem_res[4];
- int sc_id;
+ struct resource *sc_mem_res;
+ int sc_mem_rid;
/* sysctl for configuration */
int sc_pwm_clkdiv;
int sc_pwm_freq;
@@ -193,79 +154,39 @@ struct am335x_pwm_softc {
uint32_t sc_pwm_dutyB;
};
-static device_method_t am335x_pwm_methods[] = {
- DEVMETHOD(device_probe, am335x_pwm_probe),
- DEVMETHOD(device_attach, am335x_pwm_attach),
- DEVMETHOD(device_detach, am335x_pwm_detach),
+static device_method_t am335x_ehrpwm_methods[] = {
+ DEVMETHOD(device_probe, am335x_ehrpwm_probe),
+ DEVMETHOD(device_attach, am335x_ehrpwm_attach),
+ DEVMETHOD(device_detach, am335x_ehrpwm_detach),
DEVMETHOD_END
};
-static driver_t am335x_pwm_driver = {
- "am335x_pwm",
- am335x_pwm_methods,
- sizeof(struct am335x_pwm_softc),
+static driver_t am335x_ehrpwm_driver = {
+ "am335x_ehrpwm",
+ am335x_ehrpwm_methods,
+ sizeof(struct am335x_ehrpwm_softc),
};
-static devclass_t am335x_pwm_devclass;
-
-/*
- * API function to set period/duty cycles for ECASx
- */
-int
-am335x_pwm_config_ecas(int unit, int period, int duty)
-{
- device_t dev;
- struct am335x_pwm_softc *sc;
- uint16_t reg;
-
- dev = devclass_get_device(am335x_pwm_devclass, unit);
- if (dev == NULL)
- return (ENXIO);
-
- if (duty > period)
- return (EINVAL);
-
- if (period == 0)
- return (EINVAL);
-
- sc = device_get_softc(dev);
- PWM_LOCK(sc);
-
- reg = ECAP_READ2(sc, ECAP_ECCTL2);
- reg |= ECCTL2_MODE_APWM | ECCTL2_TSCTRSTOP_FREERUN | ECCTL2_SYNCO_SEL;
- ECAP_WRITE2(sc, ECAP_ECCTL2, reg);
-
- /* CAP3 in APWM mode is APRD shadow register */
- ECAP_WRITE4(sc, ECAP_CAP3, period - 1);
-
- /* CAP4 in APWM mode is ACMP shadow register */
- ECAP_WRITE4(sc, ECAP_CAP4, duty);
- /* Restart counter */
- ECAP_WRITE4(sc, ECAP_TSCTR, 0);
-
- PWM_UNLOCK(sc);
-
- return (0);
-}
+static devclass_t am335x_ehrpwm_devclass;
static void
-am335x_pwm_freq(struct am335x_pwm_softc *sc)
+am335x_ehrpwm_freq(struct am335x_ehrpwm_softc *sc)
{
int clkdiv;
- clkdiv = am335x_pwm_clkdiv[sc->sc_pwm_clkdiv];
+ clkdiv = am335x_ehrpwm_clkdiv[sc->sc_pwm_clkdiv];
sc->sc_pwm_freq = PWM_CLOCK / (1 * clkdiv) / sc->sc_pwm_period;
}
static int
-am335x_pwm_sysctl_freq(SYSCTL_HANDLER_ARGS)
+am335x_ehrpwm_sysctl_freq(SYSCTL_HANDLER_ARGS)
{
int clkdiv, error, freq, i, period;
- struct am335x_pwm_softc *sc;
+ struct am335x_ehrpwm_softc *sc;
uint32_t reg;
- sc = (struct am335x_pwm_softc *)arg1;
+ sc = (struct am335x_ehrpwm_softc *)arg1;
PWM_LOCK(sc);
freq = sc->sc_pwm_freq;
@@ -280,8 +201,8 @@ am335x_pwm_sysctl_freq(SYSCTL_HANDLER_ARGS)
PWM_LOCK(sc);
if (freq != sc->sc_pwm_freq) {
- for (i = nitems(am335x_pwm_clkdiv) - 1; i >= 0; i--) {
- clkdiv = am335x_pwm_clkdiv[i];
+ for (i = nitems(am335x_ehrpwm_clkdiv) - 1; i >= 0; i--) {
+ clkdiv = am335x_ehrpwm_clkdiv[i];
period = PWM_CLOCK / clkdiv / freq;
if (period > USHRT_MAX)
break;
@@ -300,7 +221,7 @@ am335x_pwm_sysctl_freq(SYSCTL_HANDLER_ARGS)
EPWM_WRITE2(sc, EPWM_TBCTL, reg);
/* Update the period settings. */
EPWM_WRITE2(sc, EPWM_TBPRD, sc->sc_pwm_period - 1);
- am335x_pwm_freq(sc);
+ am335x_ehrpwm_freq(sc);
}
PWM_UNLOCK(sc);
@@ -308,16 +229,16 @@ am335x_pwm_sysctl_freq(SYSCTL_HANDLER_ARGS)
}
static int
-am335x_pwm_sysctl_clkdiv(SYSCTL_HANDLER_ARGS)
+am335x_ehrpwm_sysctl_clkdiv(SYSCTL_HANDLER_ARGS)
{
int error, i, clkdiv;
- struct am335x_pwm_softc *sc;
+ struct am335x_ehrpwm_softc *sc;
uint32_t reg;
- sc = (struct am335x_pwm_softc *)arg1;
+ sc = (struct am335x_ehrpwm_softc *)arg1;
PWM_LOCK(sc);
- clkdiv = am335x_pwm_clkdiv[sc->sc_pwm_clkdiv];
+ clkdiv = am335x_ehrpwm_clkdiv[sc->sc_pwm_clkdiv];
PWM_UNLOCK(sc);
error = sysctl_handle_int(oidp, &clkdiv, sizeof(clkdiv), req);
@@ -325,16 +246,16 @@ am335x_pwm_sysctl_clkdiv(SYSCTL_HANDLER_ARGS)
return (error);
PWM_LOCK(sc);
- if (clkdiv != am335x_pwm_clkdiv[sc->sc_pwm_clkdiv]) {
- for (i = 0; i < nitems(am335x_pwm_clkdiv); i++)
- if (clkdiv >= am335x_pwm_clkdiv[i])
+ if (clkdiv != am335x_ehrpwm_clkdiv[sc->sc_pwm_clkdiv]) {
+ for (i = 0; i < nitems(am335x_ehrpwm_clkdiv); i++)
+ if (clkdiv >= am335x_ehrpwm_clkdiv[i])
sc->sc_pwm_clkdiv = i;
reg = EPWM_READ2(sc, EPWM_TBCTL);
reg &= ~TBCTL_CLKDIV_MASK;
reg |= TBCTL_CLKDIV(sc->sc_pwm_clkdiv);
EPWM_WRITE2(sc, EPWM_TBCTL, reg);
- am335x_pwm_freq(sc);
+ am335x_ehrpwm_freq(sc);
}
PWM_UNLOCK(sc);
@@ -342,12 +263,12 @@ am335x_pwm_sysctl_clkdiv(SYSCTL_HANDLER_ARGS)
}
static int
-am335x_pwm_sysctl_duty(SYSCTL_HANDLER_ARGS)
+am335x_ehrpwm_sysctl_duty(SYSCTL_HANDLER_ARGS)
{
- struct am335x_pwm_softc *sc = (struct am335x_pwm_softc*)arg1;
+ struct am335x_ehrpwm_softc *sc = (struct am335x_ehrpwm_softc*)arg1;
int error;
uint32_t duty;
-
+
if (oidp == sc->sc_chanA_oid)
duty = sc->sc_pwm_dutyA;
else
@@ -377,12 +298,12 @@ am335x_pwm_sysctl_duty(SYSCTL_HANDLER_ARGS)
}
static int
-am335x_pwm_sysctl_period(SYSCTL_HANDLER_ARGS)
+am335x_ehrpwm_sysctl_period(SYSCTL_HANDLER_ARGS)
{
- struct am335x_pwm_softc *sc = (struct am335x_pwm_softc*)arg1;
+ struct am335x_ehrpwm_softc *sc = (struct am335x_ehrpwm_softc*)arg1;
int error;
uint32_t period;
-
+
period = sc->sc_pwm_period;
error = sysctl_handle_int(oidp, &period, 0, req);
@@ -404,85 +325,70 @@ am335x_pwm_sysctl_period(SYSCTL_HANDLER_ARGS)
/* Update the period settings. */
sc->sc_pwm_period = period;
EPWM_WRITE2(sc, EPWM_TBPRD, period - 1);
- am335x_pwm_freq(sc);
+ am335x_ehrpwm_freq(sc);
PWM_UNLOCK(sc);
return (error);
}
static int
-am335x_pwm_probe(device_t dev)
+am335x_ehrpwm_probe(device_t dev)
{
if (!ofw_bus_status_okay(dev))
return (ENXIO);
- if (!ofw_bus_is_compatible(dev, "ti,am335x-pwm"))
+ if (!ofw_bus_is_compatible(dev, "ti,am33xx-ehrpwm"))
return (ENXIO);
- device_set_desc(dev, "AM335x PWM");
+ device_set_desc(dev, "AM335x EHRPWM");
return (BUS_PROBE_DEFAULT);
}
static int
-am335x_pwm_attach(device_t dev)
+am335x_ehrpwm_attach(device_t dev)
{
- struct am335x_pwm_softc *sc;
- int err;
+ struct am335x_ehrpwm_softc *sc;
uint32_t reg;
- phandle_t node;
- pcell_t did;
struct sysctl_ctx_list *ctx;
struct sysctl_oid *tree;
sc = device_get_softc(dev);
sc->sc_dev = dev;
- /* Get the PWM module id */
- node = ofw_bus_get_node(dev);
- if ((OF_getprop(node, "pwm-device-id", &did, sizeof(did))) <= 0) {
- device_printf(dev, "missing pwm-device-id attribute in FDT\n");
- return (ENXIO);
- }
- sc->sc_id = fdt32_to_cpu(did);
PWM_LOCK_INIT(sc);
- err = bus_alloc_resources(dev, am335x_pwm_mem_spec,
- sc->sc_mem_res);
- if (err) {
+ sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
+ &sc->sc_mem_rid, RF_ACTIVE);
+ if (sc->sc_mem_res == NULL) {
device_printf(dev, "cannot allocate memory resources\n");
goto fail;
}
- ti_prcm_clk_enable(PWMSS0_CLK + sc->sc_id);
- ti_scm_reg_read_4(SCM_PWMSS_CTRL, &reg);
- reg |= (1 << sc->sc_id);
- ti_scm_reg_write_4(SCM_PWMSS_CTRL, reg);
-
/* Init backlight interface */
ctx = device_get_sysctl_ctx(sc->sc_dev);
tree = device_get_sysctl_tree(sc->sc_dev);
sc->sc_clkdiv_oid = SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
"clkdiv", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
- am335x_pwm_sysctl_clkdiv, "I", "PWM clock prescaler");
+ am335x_ehrpwm_sysctl_clkdiv, "I", "PWM clock prescaler");
sc->sc_freq_oid = SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
"freq", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
- am335x_pwm_sysctl_freq, "I", "PWM frequency");
+ am335x_ehrpwm_sysctl_freq, "I", "PWM frequency");
sc->sc_period_oid = SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
"period", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
- am335x_pwm_sysctl_period, "I", "PWM period");
+ am335x_ehrpwm_sysctl_period, "I", "PWM period");
sc->sc_chanA_oid = SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
"dutyA", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
- am335x_pwm_sysctl_duty, "I", "Channel A duty cycles");
+ am335x_ehrpwm_sysctl_duty, "I", "Channel A duty cycles");
sc->sc_chanB_oid = SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
"dutyB", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
- am335x_pwm_sysctl_duty, "I", "Channel B duty cycles");
+ am335x_ehrpwm_sysctl_duty, "I", "Channel B duty cycles");
/* CONFIGURE EPWM1 */
reg = EPWM_READ2(sc, EPWM_TBCTL);
@@ -492,7 +398,7 @@ am335x_pwm_attach(device_t dev)
sc->sc_pwm_period = DEFAULT_PWM_PERIOD;
sc->sc_pwm_dutyA = 0;
sc->sc_pwm_dutyB = 0;
- am335x_pwm_freq(sc);
+ am335x_ehrpwm_freq(sc);
EPWM_WRITE2(sc, EPWM_TBPRD, sc->sc_pwm_period - 1);
EPWM_WRITE2(sc, EPWM_CMPA, sc->sc_pwm_dutyA);
@@ -512,24 +418,24 @@ am335x_pwm_attach(device_t dev)
return (0);
fail:
PWM_LOCK_DESTROY(sc);
- if (sc->sc_mem_res[0])
- bus_release_resources(dev, am335x_pwm_mem_spec,
- sc->sc_mem_res);
+ if (sc->sc_mem_res)
+ bus_release_resource(dev, SYS_RES_MEMORY,
+ sc->sc_mem_rid, sc->sc_mem_res);
return(ENXIO);
}
static int
-am335x_pwm_detach(device_t dev)
+am335x_ehrpwm_detach(device_t dev)
{
- struct am335x_pwm_softc *sc;
+ struct am335x_ehrpwm_softc *sc;
sc = device_get_softc(dev);
PWM_LOCK(sc);
- if (sc->sc_mem_res[0])
- bus_release_resources(dev, am335x_pwm_mem_spec,
- sc->sc_mem_res);
+ if (sc->sc_mem_res)
+ bus_release_resource(dev, SYS_RES_MEMORY,
+ sc->sc_mem_rid, sc->sc_mem_res);
PWM_UNLOCK(sc);
PWM_LOCK_DESTROY(sc);
@@ -537,6 +443,6 @@ am335x_pwm_detach(device_t dev)
return (0);
}
-DRIVER_MODULE(am335x_pwm, simplebus, am335x_pwm_driver, am335x_pwm_devclass, 0, 0);
-MODULE_VERSION(am335x_pwm, 1);
-MODULE_DEPEND(am335x_pwm, simplebus, 1, 1, 1);
+DRIVER_MODULE(am335x_ehrpwm, am335x_pwmss, am335x_ehrpwm_driver, am335x_ehrpwm_devclass, 0, 0);
+MODULE_VERSION(am335x_ehrpwm, 1);
+MODULE_DEPEND(am335x_ehrpwm, am335x_pwmss, 1, 1, 1);
diff --git a/sys/arm/ti/am335x/am335x_gpio.c b/sys/arm/ti/am335x/am335x_gpio.c
index 6aded04..a635c37 100644
--- a/sys/arm/ti/am335x/am335x_gpio.c
+++ b/sys/arm/ti/am335x/am335x_gpio.c
@@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$");
#include <arm/ti/ti_cpuid.h>
#include <arm/ti/ti_gpio.h>
-#include <arm/ti/ti_scm.h>
+#include <arm/ti/ti_pinmux.h>
#include <arm/ti/am335x/am335x_scm_padconf.h>
@@ -86,6 +86,8 @@ static int
am335x_gpio_set_flags(device_t dev, uint32_t gpio, uint32_t flags)
{
unsigned int state = 0;
+ struct ti_gpio_softc *sc = device_get_softc(dev);
+
if (flags & GPIO_PIN_OUTPUT) {
if (flags & GPIO_PIN_PULLUP)
state = PADCONF_OUTPUT_PULLUP;
@@ -99,15 +101,16 @@ am335x_gpio_set_flags(device_t dev, uint32_t gpio, uint32_t flags)
else
state = PADCONF_INPUT;
}
- return ti_scm_padconf_set_gpiomode(gpio, state);
+ return ti_pinmux_padconf_set_gpiomode(sc->sc_bank*32 + gpio, state);
}
static int
am335x_gpio_get_flags(device_t dev, uint32_t gpio, uint32_t *flags)
{
unsigned int state;
+ struct ti_gpio_softc *sc = device_get_softc(dev);
- if (ti_scm_padconf_get_gpiomode(gpio, &state) != 0) {
+ if (ti_pinmux_padconf_get_gpiomode(sc->sc_bank*32 + gpio, &state) != 0) {
*flags = 0;
return (EINVAL);
} else {
diff --git a/sys/arm/ti/am335x/am335x_lcd.c b/sys/arm/ti/am335x/am335x_lcd.c
index 053567e..df5c537 100644
--- a/sys/arm/ti/am335x/am335x_lcd.c
+++ b/sys/arm/ti/am335x/am335x_lcd.c
@@ -242,7 +242,7 @@ am335x_lcd_sysctl_backlight(SYSCTL_HANDLER_ARGS)
backlight = 100;
LCD_LOCK(sc);
- error = am335x_pwm_config_ecas(PWM_UNIT, PWM_PERIOD,
+ error = am335x_pwm_config_ecap(PWM_UNIT, PWM_PERIOD,
backlight*PWM_PERIOD/100);
if (error == 0)
sc->sc_backlight = backlight;
@@ -252,12 +252,10 @@ am335x_lcd_sysctl_backlight(SYSCTL_HANDLER_ARGS)
}
static int
-am335x_read_panel_property(device_t dev, const char *name, uint32_t *val)
+am335x_read_property(device_t dev, phandle_t node, const char *name, uint32_t *val)
{
- phandle_t node;
pcell_t cell;
- node = ofw_bus_get_node(dev);
if ((OF_getprop(node, name, &cell, sizeof(cell))) <= 0) {
device_printf(dev, "missing '%s' attribute in LCD panel info\n",
name);
@@ -270,85 +268,116 @@ am335x_read_panel_property(device_t dev, const char *name, uint32_t *val)
}
static int
-am335x_read_panel_info(device_t dev, struct panel_info *panel)
+am335x_read_timing(device_t dev, phandle_t node, struct panel_info *panel)
{
int error;
+ phandle_t timings_node, timing_node, native;
+
+ timings_node = fdt_find_child(node, "display-timings");
+ if (timings_node == 0) {
+ device_printf(dev, "no \"display-timings\" node\n");
+ return (-1);
+ }
+
+ if (OF_searchencprop(timings_node, "native-mode", &native,
+ sizeof(native)) == -1) {
+ device_printf(dev, "no \"native-mode\" reference in \"timings\" node\n");
+ return (-1);
+ }
+
+ timing_node = OF_node_from_xref(native);
error = 0;
- if ((error = am335x_read_panel_property(dev,
- "panel_width", &panel->panel_width)))
+ if ((error = am335x_read_property(dev, timing_node,
+ "hactive", &panel->panel_width)))
goto out;
- if ((error = am335x_read_panel_property(dev,
- "panel_height", &panel->panel_height)))
+ if ((error = am335x_read_property(dev, timing_node,
+ "vactive", &panel->panel_height)))
goto out;
- if ((error = am335x_read_panel_property(dev,
- "panel_hfp", &panel->panel_hfp)))
+ if ((error = am335x_read_property(dev, timing_node,
+ "hfront-porch", &panel->panel_hfp)))
goto out;
- if ((error = am335x_read_panel_property(dev,
- "panel_hbp", &panel->panel_hbp)))
+ if ((error = am335x_read_property(dev, timing_node,
+ "hback-porch", &panel->panel_hbp)))
goto out;
- if ((error = am335x_read_panel_property(dev,
- "panel_hsw", &panel->panel_hsw)))
+ if ((error = am335x_read_property(dev, timing_node,
+ "hsync-len", &panel->panel_hsw)))
goto out;
- if ((error = am335x_read_panel_property(dev,
- "panel_vfp", &panel->panel_vfp)))
+ if ((error = am335x_read_property(dev, timing_node,
+ "vfront-porch", &panel->panel_vfp)))
goto out;
- if ((error = am335x_read_panel_property(dev,
- "panel_vbp", &panel->panel_vbp)))
+ if ((error = am335x_read_property(dev, timing_node,
+ "vback-porch", &panel->panel_vbp)))
goto out;
- if ((error = am335x_read_panel_property(dev,
- "panel_vsw", &panel->panel_vsw)))
+ if ((error = am335x_read_property(dev, timing_node,
+ "vsync-len", &panel->panel_vsw)))
goto out;
- if ((error = am335x_read_panel_property(dev,
- "panel_pxl_clk", &panel->panel_pxl_clk)))
+ if ((error = am335x_read_property(dev, timing_node,
+ "clock-frequency", &panel->panel_pxl_clk)))
goto out;
- if ((error = am335x_read_panel_property(dev,
- "panel_invert_pxl_clk", &panel->panel_invert_pxl_clk)))
+ if ((error = am335x_read_property(dev, timing_node,
+ "pixelclk-active", &panel->pixelclk_active)))
goto out;
- if ((error = am335x_read_panel_property(dev,
- "ac_bias", &panel->ac_bias)))
+ if ((error = am335x_read_property(dev, timing_node,
+ "hsync-active", &panel->hsync_active)))
goto out;
- if ((error = am335x_read_panel_property(dev,
- "ac_bias_intrpt", &panel->ac_bias_intrpt)))
+ if ((error = am335x_read_property(dev, timing_node,
+ "vsync-active", &panel->vsync_active)))
goto out;
- if ((error = am335x_read_panel_property(dev,
- "dma_burst_sz", &panel->dma_burst_sz)))
+out:
+ return (error);
+}
+
+static int
+am335x_read_panel_info(device_t dev, phandle_t node, struct panel_info *panel)
+{
+ int error;
+ phandle_t panel_info_node;
+
+ panel_info_node = fdt_find_child(node, "panel-info");
+ if (panel_info_node == 0)
+ return (-1);
+
+ error = 0;
+
+ if ((error = am335x_read_property(dev, panel_info_node,
+ "ac-bias", &panel->ac_bias)))
goto out;
- if ((error = am335x_read_panel_property(dev,
- "bpp", &panel->bpp)))
+ if ((error = am335x_read_property(dev, panel_info_node,
+ "ac-bias-intrpt", &panel->ac_bias_intrpt)))
goto out;
- if ((error = am335x_read_panel_property(dev,
- "fdd", &panel->fdd)))
+ if ((error = am335x_read_property(dev, panel_info_node,
+ "dma-burst-sz", &panel->dma_burst_sz)))
goto out;
- if ((error = am335x_read_panel_property(dev,
- "invert_line_clock", &panel->invert_line_clock)))
+ if ((error = am335x_read_property(dev, panel_info_node,
+ "bpp", &panel->bpp)))
goto out;
- if ((error = am335x_read_panel_property(dev,
- "invert_frm_clock", &panel->invert_frm_clock)))
+ if ((error = am335x_read_property(dev, panel_info_node,
+ "fdd", &panel->fdd)))
goto out;
- if ((error = am335x_read_panel_property(dev,
- "sync_edge", &panel->sync_edge)))
+ if ((error = am335x_read_property(dev, panel_info_node,
+ "sync-edge", &panel->sync_edge)))
goto out;
- error = am335x_read_panel_property(dev,
- "sync_ctrl", &panel->sync_ctrl);
+ error = am335x_read_property(dev, panel_info_node,
+ "sync-ctrl", &panel->sync_ctrl);
out:
return (error);
@@ -423,7 +452,7 @@ am335x_lcd_probe(device_t dev)
if (!ofw_bus_status_okay(dev))
return (ENXIO);
- if (!ofw_bus_is_compatible(dev, "ti,am335x-lcd"))
+ if (!ofw_bus_is_compatible(dev, "ti,am33xx-tilcdc"))
return (ENXIO);
device_set_desc(dev, "AM335x LCD controller");
@@ -454,12 +483,32 @@ am335x_lcd_attach(device_t dev)
uint32_t hbp, hfp, hsw;
uint32_t vbp, vfp, vsw;
uint32_t width, height;
+ phandle_t root, panel_node;
sc = device_get_softc(dev);
sc->sc_dev = dev;
- if (am335x_read_panel_info(dev, &panel))
+ root = OF_finddevice("/");
+ if (root == 0) {
+ device_printf(dev, "failed to get FDT root node\n");
+ return (ENXIO);
+ }
+
+ panel_node = fdt_find_compatible(root, "ti,tilcdc,panel", 1);
+ if (panel_node == 0) {
+ device_printf(dev, "failed to find compatible panel in FDT blob\n");
return (ENXIO);
+ }
+
+ if (am335x_read_panel_info(dev, panel_node, &panel)) {
+ device_printf(dev, "failed to read panel info\n");
+ return (ENXIO);
+ }
+
+ if (am335x_read_timing(dev, panel_node, &panel)) {
+ device_printf(dev, "failed to read timings\n");
+ return (ENXIO);
+ }
int ref_freq = 0;
ti_prcm_clk_enable(LCDC_CLK);
@@ -593,11 +642,11 @@ am335x_lcd_attach(device_t dev)
timing2 |= RASTER_TIMING_2_PHSVS_RISE;
else
timing2 |= RASTER_TIMING_2_PHSVS_FALL;
- if (panel.invert_line_clock)
+ if (panel.hsync_active == 0)
timing2 |= RASTER_TIMING_2_IHS;
- if (panel.invert_frm_clock)
+ if (panel.vsync_active == 0)
timing2 |= RASTER_TIMING_2_IVS;
- if (panel.panel_invert_pxl_clk)
+ if (panel.pixelclk_active == 0)
timing2 |= RASTER_TIMING_2_IPC;
/* AC bias */
@@ -676,7 +725,7 @@ am335x_lcd_attach(device_t dev)
am335x_lcd_sysctl_backlight, "I", "LCD backlight");
sc->sc_backlight = 0;
/* Check if eCAS interface is available at this point */
- if (am335x_pwm_config_ecas(PWM_UNIT,
+ if (am335x_pwm_config_ecap(PWM_UNIT,
PWM_PERIOD, PWM_PERIOD) == 0)
sc->sc_backlight = 100;
diff --git a/sys/arm/ti/am335x/am335x_lcd.h b/sys/arm/ti/am335x/am335x_lcd.h
index afc8901..e3c82db 100644
--- a/sys/arm/ti/am335x/am335x_lcd.h
+++ b/sys/arm/ti/am335x/am335x_lcd.h
@@ -42,12 +42,12 @@ struct panel_info {
uint32_t dma_burst_sz;
uint32_t bpp;
uint32_t fdd;
- uint32_t invert_line_clock;
- uint32_t invert_frm_clock;
+ uint32_t hsync_active;
+ uint32_t vsync_active;
uint32_t sync_edge;
uint32_t sync_ctrl;
uint32_t panel_pxl_clk;
- uint32_t panel_invert_pxl_clk;
+ uint32_t pixelclk_active;
};
int am335x_lcd_syscons_setup(vm_offset_t vaddr, vm_paddr_t paddr,
diff --git a/sys/arm/ti/am335x/am335x_musb.c b/sys/arm/ti/am335x/am335x_musb.c
new file mode 100644
index 0000000..b92be0d
--- /dev/null
+++ b/sys/arm/ti/am335x/am335x_musb.c
@@ -0,0 +1,417 @@
+/*-
+ * Copyright (c) 2013 Oleksandr Tymoshenko <gonzo@freebsd.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/stdint.h>
+#include <sys/stddef.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/types.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/condvar.h>
+#include <sys/sysctl.h>
+#include <sys/sx.h>
+#include <sys/unistd.h>
+#include <sys/callout.h>
+#include <sys/malloc.h>
+#include <sys/priv.h>
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbdi.h>
+
+#include <dev/usb/usb_core.h>
+#include <dev/usb/usb_busdma.h>
+#include <dev/usb/usb_process.h>
+#include <dev/usb/usb_util.h>
+
+#define USB_DEBUG_VAR usbssdebug
+
+#include <dev/usb/usb_controller.h>
+#include <dev/usb/usb_bus.h>
+#include <dev/usb/controller/musb_otg.h>
+#include <dev/usb/usb_debug.h>
+
+#include <sys/rman.h>
+
+#include <arm/ti/ti_prcm.h>
+#include <arm/ti/ti_scm.h>
+#include <arm/ti/am335x/am335x_scm.h>
+
+#define USBCTRL_REV 0x00
+#define USBCTRL_CTRL 0x14
+#define USBCTRL_STAT 0x18
+#define USBCTRL_IRQ_STAT0 0x30
+#define IRQ_STAT0_RXSHIFT 16
+#define IRQ_STAT0_TXSHIFT 0
+#define USBCTRL_IRQ_STAT1 0x34
+#define IRQ_STAT1_DRVVBUS (1 << 8)
+#define USBCTRL_INTEN_SET0 0x38
+#define USBCTRL_INTEN_SET1 0x3C
+#define USBCTRL_INTEN_USB_ALL 0x1ff
+#define USBCTRL_INTEN_USB_SOF (1 << 3)
+#define USBCTRL_INTEN_CLR0 0x40
+#define USBCTRL_INTEN_CLR1 0x44
+#define USBCTRL_UTMI 0xE0
+#define USBCTRL_UTMI_FSDATAEXT (1 << 1)
+#define USBCTRL_MODE 0xE8
+#define USBCTRL_MODE_IDDIG (1 << 8)
+#define USBCTRL_MODE_IDDIGMUX (1 << 7)
+
+/* USBSS resource + 2 MUSB ports */
+
+#define RES_USBCORE 0
+#define RES_USBCTRL 1
+
+#define USB_WRITE4(sc, idx, reg, val) do { \
+ bus_write_4((sc)->sc_mem_res[idx], (reg), (val)); \
+} while (0)
+
+#define USB_READ4(sc, idx, reg) bus_read_4((sc)->sc_mem_res[idx], (reg))
+
+#define USBCTRL_WRITE4(sc, reg, val) \
+ USB_WRITE4((sc), RES_USBCTRL, (reg), (val))
+#define USBCTRL_READ4(sc, reg) \
+ USB_READ4((sc), RES_USBCTRL, (reg))
+
+static struct resource_spec am335x_musbotg_mem_spec[] = {
+ { SYS_RES_MEMORY, 0, RF_ACTIVE },
+ { SYS_RES_MEMORY, 1, RF_ACTIVE },
+ { -1, 0, 0 }
+};
+
+#ifdef USB_DEBUG
+static int usbssdebug = 0;
+
+static SYSCTL_NODE(_hw_usb, OID_AUTO, am335x_usbss, CTLFLAG_RW, 0, "AM335x USBSS");
+SYSCTL_INT(_hw_usb_am335x_usbss, OID_AUTO, debug, CTLFLAG_RW,
+ &usbssdebug, 0, "Debug level");
+#endif
+
+static device_probe_t musbotg_probe;
+static device_attach_t musbotg_attach;
+static device_detach_t musbotg_detach;
+
+struct musbotg_super_softc {
+ struct musbotg_softc sc_otg;
+ struct resource *sc_mem_res[2];
+ int sc_irq_rid;
+};
+
+static void
+musbotg_vbus_poll(struct musbotg_super_softc *sc)
+{
+ uint32_t stat;
+
+ if (sc->sc_otg.sc_mode == MUSB2_DEVICE_MODE)
+ musbotg_vbus_interrupt(&sc->sc_otg, 1);
+ else {
+ stat = USBCTRL_READ4(sc, USBCTRL_STAT);
+ musbotg_vbus_interrupt(&sc->sc_otg, stat & 1);
+ }
+}
+
+/*
+ * Arg to musbotg_clocks_on and musbot_clocks_off is
+ * a uint32_t * pointing to the SCM register offset.
+ */
+static uint32_t USB_CTRL[] = {SCM_USB_CTRL0, SCM_USB_CTRL1};
+
+static void
+musbotg_clocks_on(void *arg)
+{
+ struct musbotg_softc *sc;
+ uint32_t c, reg;
+
+ sc = arg;
+ reg = USB_CTRL[sc->sc_id];
+
+ ti_scm_reg_read_4(reg, &c);
+ c &= ~3; /* Enable power */
+ c |= 1 << 19; /* VBUS detect enable */
+ c |= 1 << 20; /* Session end enable */
+ ti_scm_reg_write_4(reg, c);
+}
+
+static void
+musbotg_clocks_off(void *arg)
+{
+ struct musbotg_softc *sc;
+ uint32_t c, reg;
+
+ sc = arg;
+ reg = USB_CTRL[sc->sc_id];
+
+ /* Disable power to PHY */
+ ti_scm_reg_read_4(reg, &c);
+ ti_scm_reg_write_4(reg, c | 3);
+}
+
+static void
+musbotg_ep_int_set(struct musbotg_softc *sc, int ep, int on)
+{
+ struct musbotg_super_softc *ssc = sc->sc_platform_data;
+ uint32_t epmask;
+
+ epmask = ((1 << ep) << IRQ_STAT0_RXSHIFT);
+ epmask |= ((1 << ep) << IRQ_STAT0_TXSHIFT);
+ if (on)
+ USBCTRL_WRITE4(ssc, USBCTRL_INTEN_SET0, epmask);
+ else
+ USBCTRL_WRITE4(ssc, USBCTRL_INTEN_CLR0, epmask);
+}
+
+static void
+musbotg_wrapper_interrupt(void *arg)
+{
+ struct musbotg_softc *sc = arg;
+ struct musbotg_super_softc *ssc = sc->sc_platform_data;
+ uint32_t stat, stat0, stat1;
+
+ stat = USBCTRL_READ4(ssc, USBCTRL_STAT);
+ stat0 = USBCTRL_READ4(ssc, USBCTRL_IRQ_STAT0);
+ stat1 = USBCTRL_READ4(ssc, USBCTRL_IRQ_STAT1);
+ if (stat0)
+ USBCTRL_WRITE4(ssc, USBCTRL_IRQ_STAT0, stat0);
+ if (stat1)
+ USBCTRL_WRITE4(ssc, USBCTRL_IRQ_STAT1, stat1);
+
+ DPRINTFN(4, "port%d: stat0=%08x stat1=%08x, stat=%08x\n",
+ sc->sc_id, stat0, stat1, stat);
+
+ if (stat1 & IRQ_STAT1_DRVVBUS)
+ musbotg_vbus_interrupt(sc, stat & 1);
+
+ musbotg_interrupt(arg, ((stat0 >> 16) & 0xffff),
+ stat0 & 0xffff, stat1 & 0xff);
+}
+
+static int
+musbotg_probe(device_t dev)
+{
+ if (!ofw_bus_status_okay(dev))
+ return (ENXIO);
+
+ if (!ofw_bus_is_compatible(dev, "ti,musb-am33xx"))
+ return (ENXIO);
+
+ device_set_desc(dev, "TI AM33xx integrated USB OTG controller");
+
+ return (BUS_PROBE_DEFAULT);
+}
+
+static int
+musbotg_attach(device_t dev)
+{
+ struct musbotg_super_softc *sc = device_get_softc(dev);
+ int err;
+ uint32_t reg;
+
+ sc->sc_otg.sc_id = device_get_unit(dev);
+
+ /* Request the memory resources */
+ err = bus_alloc_resources(dev, am335x_musbotg_mem_spec,
+ sc->sc_mem_res);
+ if (err) {
+ device_printf(dev,
+ "Error: could not allocate mem resources\n");
+ return (ENXIO);
+ }
+
+ /* Request the IRQ resources */
+ sc->sc_otg.sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ,
+ &sc->sc_irq_rid, RF_ACTIVE);
+ if (sc->sc_otg.sc_irq_res == NULL) {
+ device_printf(dev,
+ "Error: could not allocate irq resources\n");
+ return (ENXIO);
+ }
+
+ /* setup MUSB OTG USB controller interface softc */
+ sc->sc_otg.sc_clocks_on = &musbotg_clocks_on;
+ sc->sc_otg.sc_clocks_off = &musbotg_clocks_off;
+ sc->sc_otg.sc_clocks_arg = &sc->sc_otg;
+
+ sc->sc_otg.sc_ep_int_set = musbotg_ep_int_set;
+
+ /* initialise some bus fields */
+ sc->sc_otg.sc_bus.parent = dev;
+ sc->sc_otg.sc_bus.devices = sc->sc_otg.sc_devices;
+ sc->sc_otg.sc_bus.devices_max = MUSB2_MAX_DEVICES;
+ sc->sc_otg.sc_bus.dma_bits = 32;
+
+ /* get all DMA memory */
+ if (usb_bus_mem_alloc_all(&sc->sc_otg.sc_bus,
+ USB_GET_DMA_TAG(dev), NULL)) {
+ device_printf(dev,
+ "Failed allocate bus mem for musb\n");
+ return (ENOMEM);
+ }
+ sc->sc_otg.sc_io_res = sc->sc_mem_res[RES_USBCORE];
+ sc->sc_otg.sc_io_tag =
+ rman_get_bustag(sc->sc_otg.sc_io_res);
+ sc->sc_otg.sc_io_hdl =
+ rman_get_bushandle(sc->sc_otg.sc_io_res);
+ sc->sc_otg.sc_io_size =
+ rman_get_size(sc->sc_otg.sc_io_res);
+
+ sc->sc_otg.sc_bus.bdev = device_add_child(dev, "usbus", -1);
+ if (!(sc->sc_otg.sc_bus.bdev)) {
+ device_printf(dev, "No busdev for musb\n");
+ goto error;
+ }
+ device_set_ivars(sc->sc_otg.sc_bus.bdev,
+ &sc->sc_otg.sc_bus);
+
+ err = bus_setup_intr(dev, sc->sc_otg.sc_irq_res,
+ INTR_TYPE_BIO | INTR_MPSAFE,
+ NULL, (driver_intr_t *)musbotg_wrapper_interrupt,
+ &sc->sc_otg, &sc->sc_otg.sc_intr_hdl);
+ if (err) {
+ sc->sc_otg.sc_intr_hdl = NULL;
+ device_printf(dev,
+ "Failed to setup interrupt for musb\n");
+ goto error;
+ }
+
+ sc->sc_otg.sc_platform_data = sc;
+ if (sc->sc_otg.sc_id == 0)
+ sc->sc_otg.sc_mode = MUSB2_DEVICE_MODE;
+ else
+ sc->sc_otg.sc_mode = MUSB2_HOST_MODE;
+
+ /*
+ * software-controlled function
+ */
+
+ if (sc->sc_otg.sc_mode == MUSB2_HOST_MODE) {
+ reg = USBCTRL_READ4(sc, USBCTRL_MODE);
+ reg |= USBCTRL_MODE_IDDIGMUX;
+ reg &= ~USBCTRL_MODE_IDDIG;
+ USBCTRL_WRITE4(sc, USBCTRL_MODE, reg);
+ USBCTRL_WRITE4(sc, USBCTRL_UTMI,
+ USBCTRL_UTMI_FSDATAEXT);
+ } else {
+ reg = USBCTRL_READ4(sc, USBCTRL_MODE);
+ reg |= USBCTRL_MODE_IDDIGMUX;
+ reg |= USBCTRL_MODE_IDDIG;
+ USBCTRL_WRITE4(sc, USBCTRL_MODE, reg);
+ }
+
+ reg = USBCTRL_INTEN_USB_ALL & ~USBCTRL_INTEN_USB_SOF;
+ USBCTRL_WRITE4(sc, USBCTRL_INTEN_SET1, reg);
+ USBCTRL_WRITE4(sc, USBCTRL_INTEN_CLR0, 0xffffffff);
+
+ err = musbotg_init(&sc->sc_otg);
+ if (!err)
+ err = device_probe_and_attach(sc->sc_otg.sc_bus.bdev);
+
+ if (err)
+ goto error;
+
+ /* poll VBUS one time */
+ musbotg_vbus_poll(sc);
+
+ return (0);
+
+error:
+ musbotg_detach(dev);
+ return (ENXIO);
+}
+
+static int
+musbotg_detach(device_t dev)
+{
+ struct musbotg_super_softc *sc = device_get_softc(dev);
+ device_t bdev;
+ int err;
+
+ if (sc->sc_otg.sc_bus.bdev) {
+ bdev = sc->sc_otg.sc_bus.bdev;
+ device_detach(bdev);
+ device_delete_child(dev, bdev);
+ }
+
+ if (sc->sc_otg.sc_irq_res && sc->sc_otg.sc_intr_hdl) {
+ /*
+ * only call musbotg_uninit() after musbotg_init()
+ */
+ musbotg_uninit(&sc->sc_otg);
+
+ err = bus_teardown_intr(dev, sc->sc_otg.sc_irq_res,
+ sc->sc_otg.sc_intr_hdl);
+ sc->sc_otg.sc_intr_hdl = NULL;
+ }
+
+ usb_bus_mem_free_all(&sc->sc_otg.sc_bus, NULL);
+
+ /* Free resources if any */
+ if (sc->sc_mem_res[0])
+ bus_release_resources(dev, am335x_musbotg_mem_spec,
+ sc->sc_mem_res);
+
+ if (sc->sc_otg.sc_irq_res)
+ bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irq_rid,
+ sc->sc_otg.sc_irq_res);
+
+ /* during module unload there are lots of children leftover */
+ device_delete_children(dev);
+
+ return (0);
+}
+
+static device_method_t musbotg_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, musbotg_probe),
+ DEVMETHOD(device_attach, musbotg_attach),
+ DEVMETHOD(device_detach, musbotg_detach),
+ DEVMETHOD(device_suspend, bus_generic_suspend),
+ DEVMETHOD(device_resume, bus_generic_resume),
+ DEVMETHOD(device_shutdown, bus_generic_shutdown),
+
+ DEVMETHOD_END
+};
+
+static driver_t musbotg_driver = {
+ .name = "musbotg",
+ .methods = musbotg_methods,
+ .size = sizeof(struct musbotg_super_softc),
+};
+
+static devclass_t musbotg_devclass;
+
+DRIVER_MODULE(musbotg, usbss, musbotg_driver, musbotg_devclass, 0, 0);
+MODULE_DEPEND(musbotg, usbss, 1, 1, 1);
diff --git a/sys/arm/ti/am335x/am335x_pmic.c b/sys/arm/ti/am335x/am335x_pmic.c
index 4509f88..18bc438 100644
--- a/sys/arm/ti/am335x/am335x_pmic.c
+++ b/sys/arm/ti/am335x/am335x_pmic.c
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/clock.h>
#include <sys/time.h>
#include <sys/bus.h>
+#include <sys/proc.h>
#include <sys/reboot.h>
#include <sys/resource.h>
#include <sys/rman.h>
@@ -58,12 +59,20 @@ __FBSDID("$FreeBSD$");
#define TPS65217D 0x6
/* TPS65217 Reisters */
-#define TPS65217_CHIPID_REG 0x00
-#define TPS65217_STATUS_REG 0x0A
-#define TPS65217_STATUS_OFF (1U << 7)
-#define TPS65217_STATUS_ACPWR (1U << 3)
-#define TPS65217_STATUS_USBPWR (1U << 2)
-#define TPS65217_STATUS_BT (1U << 0)
+#define TPS65217_CHIPID_REG 0x00
+#define TPS65217_INT_REG 0x02
+#define TPS65217_INT_PBM (1U << 6)
+#define TPS65217_INT_ACM (1U << 5)
+#define TPS65217_INT_USBM (1U << 4)
+#define TPS65217_INT_PBI (1U << 2)
+#define TPS65217_INT_ACI (1U << 1)
+#define TPS65217_INT_USBI (1U << 0)
+
+#define TPS65217_STATUS_REG 0x0A
+#define TPS65217_STATUS_OFF (1U << 7)
+#define TPS65217_STATUS_ACPWR (1U << 3)
+#define TPS65217_STATUS_USBPWR (1U << 2)
+#define TPS65217_STATUS_BT (1U << 0)
#define MAX_IIC_DATA_SIZE 2
@@ -72,6 +81,8 @@ struct am335x_pmic_softc {
device_t sc_dev;
uint32_t sc_addr;
struct intr_config_hook enum_hook;
+ struct resource *sc_irq_res;
+ void *sc_intrhand;
};
static void am335x_pmic_shutdown(void *, int);
@@ -105,17 +116,50 @@ am335x_pmic_write(device_t dev, uint8_t address, uint8_t *data, uint8_t size)
return (iicbus_transfer(dev, msg, 1));
}
+static void
+am335x_pmic_intr(void *arg)
+{
+ struct am335x_pmic_softc *sc = (struct am335x_pmic_softc *)arg;
+ uint8_t int_reg, status_reg;
+ int rv;
+ char notify_buf[16];
+
+ THREAD_SLEEPING_OK();
+ rv = am335x_pmic_read(sc->sc_dev, TPS65217_INT_REG, &int_reg, 1);
+ if (rv != 0) {
+ device_printf(sc->sc_dev, "Cannot read interrupt register\n");
+ THREAD_NO_SLEEPING();
+ return;
+ }
+ rv = am335x_pmic_read(sc->sc_dev, TPS65217_STATUS_REG, &status_reg, 1);
+ if (rv != 0) {
+ device_printf(sc->sc_dev, "Cannot read status register\n");
+ THREAD_NO_SLEEPING();
+ return;
+ }
+ THREAD_NO_SLEEPING();
+
+ if ((int_reg & TPS65217_INT_PBI) && (status_reg & TPS65217_STATUS_BT))
+ shutdown_nice(RB_POWEROFF);
+ if (int_reg & TPS65217_INT_ACI) {
+ snprintf(notify_buf, sizeof(notify_buf), "notify=0x%02x",
+ (status_reg & TPS65217_STATUS_ACPWR) ? 1 : 0);
+ devctl_notify_f("ACPI", "ACAD", "power", notify_buf, M_NOWAIT);
+ }
+}
+
static int
am335x_pmic_probe(device_t dev)
{
struct am335x_pmic_softc *sc;
- if (!ofw_bus_is_compatible(dev, "ti,am335x-pmic"))
+ if (!ofw_bus_is_compatible(dev, "ti,tps65217"))
return (ENXIO);
sc = device_get_softc(dev);
sc->sc_dev = dev;
- sc->sc_addr = iicbus_get_addr(dev);
+ /* Convert to 8-bit addressing */
+ sc->sc_addr = iicbus_get_addr(dev) << 1;
device_set_desc(dev, "TI TPS65217 Power Management IC");
@@ -130,6 +174,7 @@ am335x_pmic_start(void *xdev)
uint8_t reg;
char name[20];
char pwr[4][11] = {"Unknown", "USB", "AC", "USB and AC"};
+ int rv;
sc = device_get_softc(dev);
@@ -158,15 +203,38 @@ am335x_pmic_start(void *xdev)
SHUTDOWN_PRI_LAST);
config_intrhook_disestablish(&sc->enum_hook);
+
+ /* Unmask all interrupts and clear pending status */
+ reg = 0;
+ am335x_pmic_write(dev, TPS65217_INT_REG, &reg, 1);
+ am335x_pmic_read(dev, TPS65217_INT_REG, &reg, 1);
+
+ if (sc->sc_irq_res != NULL) {
+ rv = bus_setup_intr(dev, sc->sc_irq_res,
+ INTR_TYPE_MISC | INTR_MPSAFE, NULL, am335x_pmic_intr,
+ sc, &sc->sc_intrhand);
+ if (rv != 0)
+ device_printf(dev,
+ "Unable to setup the irq handler.\n");
+ }
}
static int
am335x_pmic_attach(device_t dev)
{
struct am335x_pmic_softc *sc;
+ int rid;
sc = device_get_softc(dev);
+ rid = 0;
+ sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
+ RF_ACTIVE);
+ if (!sc->sc_irq_res) {
+ device_printf(dev, "cannot allocate interrupt\n");
+ /* return (ENXIO); */
+ }
+
sc->enum_hook.ich_func = am335x_pmic_start;
sc->enum_hook.ich_arg = dev;
diff --git a/sys/arm/ti/am335x/am335x_prcm.c b/sys/arm/ti/am335x/am335x_prcm.c
index d9f4db1..fa47f63 100644
--- a/sys/arm/ti/am335x/am335x_prcm.c
+++ b/sys/arm/ti/am335x/am335x_prcm.c
@@ -237,32 +237,32 @@ struct ti_clock_dev ti_am335x_clk_devmap[] = {
.clk_get_source_freq = am335x_clk_get_arm_disp_freq,
},
- /* UART. Uart0 clock cannot be controlled. */
- AM335X_NOOP_CLOCK_DEV(UART0_CLK),
- AM335X_GENERIC_CLOCK_DEV(UART1_CLK),
+ /* UART */
+ AM335X_NOOP_CLOCK_DEV(UART1_CLK),
AM335X_GENERIC_CLOCK_DEV(UART2_CLK),
AM335X_GENERIC_CLOCK_DEV(UART3_CLK),
AM335X_GENERIC_CLOCK_DEV(UART4_CLK),
AM335X_GENERIC_CLOCK_DEV(UART5_CLK),
+ AM335X_GENERIC_CLOCK_DEV(UART6_CLK),
/* DMTimer */
- AM335X_GENERIC_CLOCK_DEV(DMTIMER2_CLK),
- AM335X_GENERIC_CLOCK_DEV(DMTIMER3_CLK),
- AM335X_GENERIC_CLOCK_DEV(DMTIMER4_CLK),
- AM335X_GENERIC_CLOCK_DEV(DMTIMER5_CLK),
- AM335X_GENERIC_CLOCK_DEV(DMTIMER6_CLK),
- AM335X_GENERIC_CLOCK_DEV(DMTIMER7_CLK),
-
- /* GPIO */
- AM335X_GPIO_CLOCK_DEV(GPIO0_CLK),
+ AM335X_GENERIC_CLOCK_DEV(TIMER2_CLK),
+ AM335X_GENERIC_CLOCK_DEV(TIMER3_CLK),
+ AM335X_GENERIC_CLOCK_DEV(TIMER4_CLK),
+ AM335X_GENERIC_CLOCK_DEV(TIMER5_CLK),
+ AM335X_GENERIC_CLOCK_DEV(TIMER6_CLK),
+ AM335X_GENERIC_CLOCK_DEV(TIMER7_CLK),
+
+ /* GPIO, we use hwmods as reference, not units in spec */
AM335X_GPIO_CLOCK_DEV(GPIO1_CLK),
AM335X_GPIO_CLOCK_DEV(GPIO2_CLK),
AM335X_GPIO_CLOCK_DEV(GPIO3_CLK),
+ AM335X_GPIO_CLOCK_DEV(GPIO4_CLK),
- /* I2C */
- AM335X_GENERIC_CLOCK_DEV(I2C0_CLK),
+ /* I2C we use hwmods as reference, not units in spec */
AM335X_GENERIC_CLOCK_DEV(I2C1_CLK),
AM335X_GENERIC_CLOCK_DEV(I2C2_CLK),
+ AM335X_GENERIC_CLOCK_DEV(I2C3_CLK),
/* TSC_ADC */
AM335X_GENERIC_CLOCK_DEV(TSC_ADC_CLK),
@@ -274,9 +274,9 @@ struct ti_clock_dev ti_am335x_clk_devmap[] = {
AM335X_GENERIC_CLOCK_DEV(EDMA_TPTC2_CLK),
/* MMCHS */
- AM335X_MMCHS_CLOCK_DEV(MMC0_CLK),
AM335X_MMCHS_CLOCK_DEV(MMC1_CLK),
AM335X_MMCHS_CLOCK_DEV(MMC2_CLK),
+ AM335X_MMCHS_CLOCK_DEV(MMC3_CLK),
/* PWMSS */
AM335X_GENERIC_CLOCK_DEV(PWMSS0_CLK),
@@ -319,31 +319,31 @@ struct am335x_clk_details {
static struct am335x_clk_details g_am335x_clk_details[] = {
/* UART. UART0 clock not controllable. */
- _CLK_DETAIL(UART0_CLK, 0, 0),
- _CLK_DETAIL(UART1_CLK, CM_PER_UART1_CLKCTRL, 0),
- _CLK_DETAIL(UART2_CLK, CM_PER_UART2_CLKCTRL, 0),
- _CLK_DETAIL(UART3_CLK, CM_PER_UART3_CLKCTRL, 0),
- _CLK_DETAIL(UART4_CLK, CM_PER_UART4_CLKCTRL, 0),
- _CLK_DETAIL(UART5_CLK, CM_PER_UART5_CLKCTRL, 0),
+ _CLK_DETAIL(UART1_CLK, 0, 0),
+ _CLK_DETAIL(UART2_CLK, CM_PER_UART1_CLKCTRL, 0),
+ _CLK_DETAIL(UART3_CLK, CM_PER_UART2_CLKCTRL, 0),
+ _CLK_DETAIL(UART4_CLK, CM_PER_UART3_CLKCTRL, 0),
+ _CLK_DETAIL(UART5_CLK, CM_PER_UART4_CLKCTRL, 0),
+ _CLK_DETAIL(UART6_CLK, CM_PER_UART5_CLKCTRL, 0),
/* DMTimer modules */
- _CLK_DETAIL(DMTIMER2_CLK, CM_PER_TIMER2_CLKCTRL, CLKSEL_TIMER2_CLK),
- _CLK_DETAIL(DMTIMER3_CLK, CM_PER_TIMER3_CLKCTRL, CLKSEL_TIMER3_CLK),
- _CLK_DETAIL(DMTIMER4_CLK, CM_PER_TIMER4_CLKCTRL, CLKSEL_TIMER4_CLK),
- _CLK_DETAIL(DMTIMER5_CLK, CM_PER_TIMER5_CLKCTRL, CLKSEL_TIMER5_CLK),
- _CLK_DETAIL(DMTIMER6_CLK, CM_PER_TIMER6_CLKCTRL, CLKSEL_TIMER6_CLK),
- _CLK_DETAIL(DMTIMER7_CLK, CM_PER_TIMER7_CLKCTRL, CLKSEL_TIMER7_CLK),
-
- /* GPIO modules */
- _CLK_DETAIL(GPIO0_CLK, CM_WKUP_GPIO0_CLKCTRL, 0),
- _CLK_DETAIL(GPIO1_CLK, CM_PER_GPIO1_CLKCTRL, 0),
- _CLK_DETAIL(GPIO2_CLK, CM_PER_GPIO2_CLKCTRL, 0),
- _CLK_DETAIL(GPIO3_CLK, CM_PER_GPIO3_CLKCTRL, 0),
-
- /* I2C modules */
- _CLK_DETAIL(I2C0_CLK, CM_WKUP_I2C0_CLKCTRL, 0),
- _CLK_DETAIL(I2C1_CLK, CM_PER_I2C1_CLKCTRL, 0),
- _CLK_DETAIL(I2C2_CLK, CM_PER_I2C2_CLKCTRL, 0),
+ _CLK_DETAIL(TIMER2_CLK, CM_PER_TIMER2_CLKCTRL, CLKSEL_TIMER2_CLK),
+ _CLK_DETAIL(TIMER3_CLK, CM_PER_TIMER3_CLKCTRL, CLKSEL_TIMER3_CLK),
+ _CLK_DETAIL(TIMER4_CLK, CM_PER_TIMER4_CLKCTRL, CLKSEL_TIMER4_CLK),
+ _CLK_DETAIL(TIMER5_CLK, CM_PER_TIMER5_CLKCTRL, CLKSEL_TIMER5_CLK),
+ _CLK_DETAIL(TIMER6_CLK, CM_PER_TIMER6_CLKCTRL, CLKSEL_TIMER6_CLK),
+ _CLK_DETAIL(TIMER7_CLK, CM_PER_TIMER7_CLKCTRL, CLKSEL_TIMER7_CLK),
+
+ /* GPIO modules, hwmods start with gpio1 */
+ _CLK_DETAIL(GPIO1_CLK, CM_WKUP_GPIO0_CLKCTRL, 0),
+ _CLK_DETAIL(GPIO2_CLK, CM_PER_GPIO1_CLKCTRL, 0),
+ _CLK_DETAIL(GPIO3_CLK, CM_PER_GPIO2_CLKCTRL, 0),
+ _CLK_DETAIL(GPIO4_CLK, CM_PER_GPIO3_CLKCTRL, 0),
+
+ /* I2C modules, hwmods start with i2c1 */
+ _CLK_DETAIL(I2C1_CLK, CM_WKUP_I2C0_CLKCTRL, 0),
+ _CLK_DETAIL(I2C2_CLK, CM_PER_I2C1_CLKCTRL, 0),
+ _CLK_DETAIL(I2C3_CLK, CM_PER_I2C2_CLKCTRL, 0),
/* TSC_ADC module */
_CLK_DETAIL(TSC_ADC_CLK, CM_WKUP_ADC_TSC_CLKCTRL, 0),
@@ -354,10 +354,10 @@ static struct am335x_clk_details g_am335x_clk_details[] = {
_CLK_DETAIL(EDMA_TPTC1_CLK, CM_PER_TPTC1_CLKCTRL, 0),
_CLK_DETAIL(EDMA_TPTC2_CLK, CM_PER_TPTC2_CLKCTRL, 0),
- /* MMCHS modules*/
- _CLK_DETAIL(MMC0_CLK, CM_PER_MMC0_CLKCTRL, 0),
- _CLK_DETAIL(MMC1_CLK, CM_PER_MMC1_CLKCTRL, 0),
+ /* MMCHS modules, hwmods start with mmc1*/
+ _CLK_DETAIL(MMC1_CLK, CM_PER_MMC0_CLKCTRL, 0),
_CLK_DETAIL(MMC2_CLK, CM_PER_MMC1_CLKCTRL, 0),
+ _CLK_DETAIL(MMC3_CLK, CM_PER_MMC1_CLKCTRL, 0),
/* PWMSS modules */
_CLK_DETAIL(PWMSS0_CLK, CM_PER_EPWMSS0_CLKCTRL, 0),
@@ -388,7 +388,7 @@ am335x_prcm_probe(device_t dev)
if (!ofw_bus_status_okay(dev))
return (ENXIO);
- if (ofw_bus_is_compatible(dev, "am335x,prcm")) {
+ if (ofw_bus_is_compatible(dev, "ti,am3-prcm")) {
device_set_desc(dev, "AM335x Power and Clock Management");
return(BUS_PROBE_DEFAULT);
}
@@ -416,10 +416,15 @@ am335x_prcm_attach(device_t dev)
am335x_prcm_sc = sc;
ti_cpu_reset = am335x_prcm_reset;
- am335x_clk_get_sysclk_freq(NULL, &sysclk);
- am335x_clk_get_arm_fclk_freq(NULL, &fclk);
- device_printf(dev, "Clocks: System %u.%01u MHz, CPU %u MHz\n",
- sysclk/1000000, (sysclk % 1000000)/100000, fclk/1000000);
+ if (am335x_clk_get_sysclk_freq(NULL, &sysclk) != 0)
+ sysclk = 0;
+ if (am335x_clk_get_arm_fclk_freq(NULL, &fclk) != 0)
+ fclk = 0;
+ if (sysclk && fclk)
+ device_printf(dev, "Clocks: System %u.%01u MHz, CPU %u MHz\n",
+ sysclk/1000000, (sysclk % 1000000)/100000, fclk/1000000);
+ else
+ device_printf(dev, "can't read frequencies yet (SCM device not ready?)\n");
return (0);
}
diff --git a/sys/arm/ti/am335x/am335x_pwm.h b/sys/arm/ti/am335x/am335x_pwm.h
index f0a88a5..8666b9a 100644
--- a/sys/arm/ti/am335x/am335x_pwm.h
+++ b/sys/arm/ti/am335x/am335x_pwm.h
@@ -28,6 +28,6 @@
#ifndef __AM335X_PWM_H__
#define __AM335X_PWM_H__
-int am335x_pwm_config_ecas(int unit, int period, int duty);
+int am335x_pwm_config_ecap(int unit, int period, int duty);
#endif /* __AM335X_PWM_H__ */
diff --git a/sys/arm/ti/am335x/am335x_pwmss.c b/sys/arm/ti/am335x/am335x_pwmss.c
new file mode 100644
index 0000000..4405e89
--- /dev/null
+++ b/sys/arm/ti/am335x/am335x_pwmss.c
@@ -0,0 +1,163 @@
+/*-
+ * Copyright (c) 2013 Oleksandr Tymoshenko <gonzo@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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/limits.h>
+#include <sys/lock.h>
+#include <sys/module.h>
+#include <sys/mutex.h>
+#include <sys/resource.h>
+#include <sys/rman.h>
+#include <sys/sysctl.h>
+
+#include <machine/bus.h>
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/fdt/simplebus.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include <arm/ti/ti_prcm.h>
+#include <arm/ti/ti_hwmods.h>
+#include <arm/ti/ti_scm.h>
+
+#include "am335x_pwm.h"
+#include "am335x_scm.h"
+
+#define PWMSS_IDVER 0x00
+#define PWMSS_SYSCONFIG 0x04
+#define PWMSS_CLKCONFIG 0x08
+#define CLKCONFIG_EPWMCLK_EN (1 << 8)
+#define PWMSS_CLKSTATUS 0x0C
+
+static device_probe_t am335x_pwmss_probe;
+static device_attach_t am335x_pwmss_attach;
+static device_detach_t am335x_pwmss_detach;
+
+struct am335x_pwmss_softc {
+ device_t sc_dev;
+ clk_ident_t sc_clk;
+};
+
+static device_method_t am335x_pwmss_methods[] = {
+ DEVMETHOD(device_probe, am335x_pwmss_probe),
+ DEVMETHOD(device_attach, am335x_pwmss_attach),
+ DEVMETHOD(device_detach, am335x_pwmss_detach),
+
+ DEVMETHOD_END
+};
+
+static int
+am335x_pwmss_probe(device_t dev)
+{
+
+ if (!ofw_bus_status_okay(dev))
+ return (ENXIO);
+
+ if (!ofw_bus_is_compatible(dev, "ti,am33xx-pwmss"))
+ return (ENXIO);
+
+ device_set_desc(dev, "AM335x PWM");
+
+ return (BUS_PROBE_DEFAULT);
+}
+
+static int
+am335x_pwmss_attach(device_t dev)
+{
+ struct am335x_pwmss_softc *sc;
+ uint32_t reg, id;
+ phandle_t node;
+
+ sc = device_get_softc(dev);
+ sc->sc_dev = dev;
+
+ sc->sc_clk = ti_hwmods_get_clock(dev);
+ if (sc->sc_clk == INVALID_CLK_IDENT) {
+ device_printf(dev, "failed to get device id based on ti,hwmods\n");
+ return (EINVAL);
+ }
+
+ ti_prcm_clk_enable(sc->sc_clk);
+ ti_scm_reg_read_4(SCM_PWMSS_CTRL, &reg);
+ switch (sc->sc_clk) {
+ case PWMSS0_CLK:
+ id = 0;
+ break;
+ case PWMSS1_CLK:
+ id = 1;
+ break;
+
+ case PWMSS2_CLK:
+ id = 2;
+ break;
+ default:
+ device_printf(dev, "unknown pwmss clock id: %d\n", sc->sc_clk);
+ return (EINVAL);
+ }
+ reg |= (1 << id);
+ ti_scm_reg_write_4(SCM_PWMSS_CTRL, reg);
+
+ node = ofw_bus_get_node(dev);
+
+ if (node == -1)
+ return (ENXIO);
+
+ simplebus_init(dev, node);
+
+ /*
+ * Allow devices to identify.
+ */
+ bus_generic_probe(dev);
+
+ /*
+ * Now walk the OFW tree and attach top-level devices.
+ */
+ for (node = OF_child(node); node > 0; node = OF_peer(node))
+ simplebus_add_device(dev, node, 0, NULL, -1, NULL);
+
+ return (bus_generic_attach(dev));
+}
+
+static int
+am335x_pwmss_detach(device_t dev)
+{
+
+ return (0);
+}
+
+DEFINE_CLASS_1(am335x_pwmss, am335x_pwmss_driver, am335x_pwmss_methods,
+ sizeof(struct am335x_pwmss_softc), simplebus_driver);
+static devclass_t am335x_pwmss_devclass;
+DRIVER_MODULE(am335x_pwmss, simplebus, am335x_pwmss_driver, am335x_pwmss_devclass, 0, 0);
+MODULE_VERSION(am335x_pwmss, 1);
diff --git a/sys/arm/ti/am335x/am335x_scm_padconf.c b/sys/arm/ti/am335x/am335x_scm_padconf.c
index dcadc8a..a95c8cb 100644
--- a/sys/arm/ti/am335x/am335x_scm_padconf.c
+++ b/sys/arm/ti/am335x/am335x_scm_padconf.c
@@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$");
#include <sys/gpio.h>
#include <arm/ti/tivar.h>
-#include <arm/ti/ti_scm.h>
+#include <arm/ti/ti_pinmux.h>
#include <arm/ti/am335x/am335x_scm_padconf.h>
@@ -64,7 +64,7 @@ __FBSDID("$FreeBSD$");
.muxmodes[7] = m7, \
}
-const static struct ti_scm_padstate ti_padstate_devmap[] = {
+const static struct ti_pinmux_padstate ti_padstate_devmap[] = {
{"output", PADCONF_OUTPUT },
{"output_pullup", PADCONF_OUTPUT_PULLUP },
{"input", PADCONF_INPUT },
@@ -74,228 +74,228 @@ const static struct ti_scm_padstate ti_padstate_devmap[] = {
{ .state = NULL }
};
-const static struct ti_scm_padconf ti_padconf_devmap[] = {
- _PIN(0x800, "GPMC_AD0", 32, 7,"gpmc_ad0", "mmc1_dat0", NULL, NULL, NULL, NULL, NULL, "gpio1_0"),
- _PIN(0x804, "GPMC_AD1", 33, 7,"gpmc_ad1", "mmc1_dat1", NULL, NULL, NULL, NULL, NULL, "gpio1_1"),
- _PIN(0x808, "GPMC_AD2", 34, 7,"gpmc_ad2", "mmc1_dat2", NULL, NULL, NULL, NULL, NULL, "gpio1_2"),
- _PIN(0x80C, "GPMC_AD3", 35, 7,"gpmc_ad3", "mmc1_dat3", NULL, NULL, NULL, NULL, NULL, "gpio1_3"),
- _PIN(0x810, "GPMC_AD4", 36, 7,"gpmc_ad4", "mmc1_dat4", NULL, NULL, NULL, NULL, NULL, "gpio1_4"),
- _PIN(0x814, "GPMC_AD5", 37, 7,"gpmc_ad5", "mmc1_dat5", NULL, NULL, NULL, NULL, NULL, "gpio1_5"),
- _PIN(0x818, "GPMC_AD6", 38, 7,"gpmc_ad6", "mmc1_dat6", NULL, NULL, NULL, NULL, NULL, "gpio1_6"),
- _PIN(0x81C, "GPMC_AD7", 39, 7,"gpmc_ad7", "mmc1_dat7", NULL, NULL, NULL, NULL, NULL, "gpio1_7"),
- _PIN(0x820, "GPMC_AD8", 22, 7, "gpmc_ad8", "lcd_data23", "mmc1_dat0", "mmc2_dat4", "ehrpwm2A", NULL, NULL, "gpio0_22"),
- _PIN(0x824, "GPMC_AD9", 23, 7, "gpmc_ad9", "lcd_data22", "mmc1_dat1", "mmc2_dat5", "ehrpwm2B", NULL, NULL, "gpio0_23"),
- _PIN(0x828, "GPMC_AD10", 26, 7, "gpmc_ad10", "lcd_data21", "mmc1_dat2", "mmc2_dat6", "ehrpwm2_tripzone_in", NULL, NULL, "gpio0_26"),
- _PIN(0x82C, "GPMC_AD11", 27, 7, "gpmc_ad11", "lcd_data20", "mmc1_dat3", "mmc2_dat7", "ehrpwm0_synco", NULL, NULL, "gpio0_27"),
- _PIN(0x830, "GPMC_AD12", 44, 7, "gpmc_ad12", "lcd_data19", "mmc1_dat4", "mmc2_dat0", "eQEP2A_in", "pr1_mii0_txd2", "pr1_pru0_pru_r30_14", "gpio1_12"),
- _PIN(0x834, "GPMC_AD13", 45, 7, "gpmc_ad13", "lcd_data18", "mmc1_dat5", "mmc2_dat1", "eQEP2B_in", "pr1_mii0_txd1", "pr1_pru0_pru_r30_15", "gpio1_13"),
- _PIN(0x838, "GPMC_AD14", 46, 7, "gpmc_ad14", "lcd_data17", "mmc1_dat6", "mmc2_dat2", "eQEP2_index", "pr1_mii0_txd0", "pr1_pru0_pru_r31_14", "gpio1_14"),
- _PIN(0x83C, "GPMC_AD15", 47, 7, "gpmc_ad15", "lcd_data16", "mmc1_dat7", "mmc2_dat3", "eQEP2_strobe", "pr1_ecap0_ecap_capin_apwm_o", "pr1_pru0_pru_r31_15", "gpio1_15"),
- _PIN(0x840, "GPMC_A0", 48, 7, "gpmc_a0", "gmii2_txen", "rgmii2_tctl", "rmii2_txen", "gpmc_a16", "pr1_mii_mt1_clk", "ehrpwm1_tripzone_input", "gpio1_16"),
- _PIN(0x844, "GPMC_A1", 49, 7, "gpmc_a1", "gmii2_rxdv", "rgmii2_rctl", "mmc2_dat0", "gpmc_a17", "pr1_mii1_txd3", "ehrpwm0_synco", "gpio1_17"),
- _PIN(0x848, "GPMC_A2", 50, 7, "gpmc_a2", "gmii2_txd3", "rgmii2_td3", "mmc2_dat1", "gpmc_a18", "pr1_mii1_txd2", "ehrpwm1A", "gpio1_18"),
- _PIN(0x84C, "GPMC_A3", 51, 7, "gpmc_a3", "gmii2_txd2", "rgmii2_td2", "mmc2_dat2", "gpmc_a19", "pr1_mii1_txd1", "ehrpwm1B", "gpio1_19"),
- _PIN(0x850, "GPMC_A4", 52, 7, "gpmc_a4", "gmii2_txd1", "rgmii2_td1", "rmii2_tdx1", "gpmc_a20", "pr1_mii1_txd0", "eQEP1A_in", "gpio1_20"),
- _PIN(0x854, "GPMC_A5", 53, 7, "gpmc_a5", "gmii2_txd0", "rgmii2_td0", "rmii2_txd0", "gpmc_a21", "pr1_mii1_rxd3", "eQEP1B_in", "gpio1_21"),
- _PIN(0x858, "GPMC_A6", 54, 7, "gpmc_a6", "gmii2_txclk", "rgmii2_tclk", "mmc2_dat4", "gpmc_a22", "pr1_mii1_rxd2", "eQEP1_index", "gpio1_22"),
- _PIN(0x85C, "GPMC_A7", 55, 7, "gpmc_a7", "gmii2_rxclk", "rgmii2_rclk", "mmc2_dat5", "gpmc_a23", "pr1_mii1_rxd1", "eQEP1_strobe", "gpio1_23"),
- _PIN(0x860, "GPMC_A8", 56, 7, "gpmc_a8", "gmii2_rxd3", "rgmii2_rd3", "mmc2_dat6", "gpmc_a24", "pr1_mii1_rxd0", "mcasp0_aclkx", "gpio1_24"),
- _PIN(0x864, "GPMC_A9", 57, 7, "gmpc_a9", "gmii2_rxd2", "rgmii2_rd2", "mmc2_dat7 / rmii2_crs_dv", "gpmc_a25", "pr1_mii_mr1_clk", "mcasp0_fsx", "gpio1_25"),
- _PIN(0x868, "GPMC_A10", 58, 7, "gmpc_a10", "gmii2_rxd1", "rgmii2_rd1", "rmii2_rxd1", "gpmc_a26", "pr1_mii1_rxdv", "mcasp0_arx0", "gpio1_26"),
- _PIN(0x86C, "GPMC_A11", 59, 7, "gmpc_a11", "gmii2_rxd0", "rgmii2_rd0", "rmii2_rxd0", "gpmc_a27", "pr1_mii1_rxer", "mcasp0_axr1", "gpio1_27"),
- _PIN(0x870, "GPMC_WAIT0", 30, 7, "gpmc_wait0", "gmii2_crs", "gpmc_csn4", "rmii2_crs_dv", "mmc1_sdcd", "pr1_mii1_col", "uart4_rxd", "gpio0_30"),
- _PIN(0x874, "GPMC_WPn", 31, 7, "gpmc_wpn", "gmii2_rxerr", "gpmc_csn5", "rmii2_rxerr", "mmc2_sdcd", "pr1_mii1_txen", "uart4_txd", "gpio0_31"),
- _PIN(0x878, "GPMC_BEn1", 60, 7, "gpmc_be1n", "gmii2_col", "gmpc_csn6","mmc2_dat3", "gpmc_dir", "pr1_mii1_rxlink", "mcasp0_aclkr", "gpio1_28"),
- _PIN(0x87c, "GPMC_CSn0", 61, 7, "gpmc_csn0", NULL, NULL, NULL, NULL, NULL, NULL, "gpio1_29"),
- _PIN(0x880, "GPMC_CSn1", 62, 7, "gpmc_csn1", "gpmc_clk", "mmc1_clk", "pr1_edio_data_in6", "pr1_edio_data_out6", "pr1_pru1_pru_r30_12", "pr1_pru1_pru_r31_12", "gpio1_30"),
- _PIN(0x884, "GPMC_CSn2", 63, 7, "gpmc_csn2", "gpmc_be1n", "mmc1_cmd", "pr1_edio_data_in7", "pr1_edio_data_out7", "pr1_pru1_pru_r30_13", "pr1_pru1_pru_r31_13", "gpio1_31"),
- _PIN(0x888, "GPMC_CSn3", 64, 7, "gpmc_csn3", "gpmc_a3", "rmii2_crs_dv", "mmc2_cmd", "pr1_mii0_crs", "pr1_mdio_data", "EMU4", "gpio2_0"),
- _PIN(0x88c, "GPMC_CLK", 65, 7, "gpmc_clk", "lcd_memory_clk", "gpmc_wait1", "mmc2_clk", "pr1_mii1_crs", "pr1_mdio_mdclk", "mcasp0_fsr", "gpio2_1"),
- _PIN(0x890, "GPMC_ADVn_ALE", 66, 7, "gpmc_advn_ale", NULL, "timer4", NULL, NULL, NULL, NULL, "gpio2_2"),
- _PIN(0x894, "GPMC_OEn_REn", 67, 7, "gpmc_oen_ren", NULL, "timer7", NULL, NULL, NULL, NULL, "gpio2_3"),
- _PIN(0x898, "GPMC_WEn", 68, 7, "gpmc_wen", NULL, "timer6", NULL, NULL, NULL, NULL, "gpio2_4"),
- _PIN(0x89c, "GPMC_BEn0_CLE", 67, 7, "gpmc_ben0_cle", NULL, "timer5", NULL, NULL, NULL, NULL, "gpio2_5"),
- _PIN(0x8a0, "LCD_DATA0", 68, 7, "lcd_data0", "gpmc_a0", "pr1_mii_mt0_clk", "ehrpwm2A", NULL, "pr1_pru1_pru_r30_0", "pr1_pru1_pru_r31_0", "gpio2_6"),
- _PIN(0x8a4, "LCD_DATA1", 69, 7, "lcd_data1", "gpmc_a1", "pr1_mii0_txen", "ehrpwm2B", NULL, "pr1_pru1_pru_r30_1", "pr1_pru1_pru_r31_1", "gpio2_7"),
- _PIN(0x8a8, "LCD_DATA2", 70, 7, "lcd_data2", "gpmc_a2", "pr1_mii0_txd3", "ehrpwm2_tripzone_input", NULL, "pr1_pru1_pru_r30_2", "pr1_pru1_pru_r31_2", "gpio2_8"),
- _PIN(0x8ac, "LCD_DATA3", 71, 7, "lcd_data3", "gpmc_a3", "pr1_mii0_txd2", "ehrpwm0_synco", NULL, "pr1_pru1_pru_r30_3", "pr1_pru1_pru_r31_3", "gpio2_9"),
- _PIN(0x8b0, "LCD_DATA4", 72, 7, "lcd_data4", "gpmc_a4", "pr1_mii0_txd1", "eQEP2A_in", NULL, "pr1_pru1_pru_r30_4", "pr1_pru1_pru_r31_4", "gpio2_10"),
- _PIN(0x8b4, "LCD_DATA5", 73, 7, "lcd_data5", "gpmc_a5", "pr1_mii0_txd0", "eQEP2B_in", NULL, "pr1_pru1_pru_r30_5", "pr1_pru1_pru_r31_5", "gpio2_11"),
- _PIN(0x8b8, "LCD_DATA6", 74, 7, "lcd_data6", "gpmc_a6", "pr1_edio_data_in6", "eQEP2_index", "pr1_edio_data_out6", "pr1_pru1_pru_r30_6", "pr1_pru1_pru_r31_6", "gpio2_12"),
- _PIN(0x8bc, "LCD_DATA7", 75, 7, "lcd_data7", "gpmc_a7", "pr1_edio_data_in7", "eQEP2_strobe", "pr1_edio_data_out7", "pr1_pru1_pru_r30_7", "pr1_pru1_pru_r31_7", "gpio2_13"),
- _PIN(0x8c0, "LCD_DATA8", 76, 7, "lcd_data8", "gpmc_a12", "ehrpwm1_tripzone_input", "mcasp0_aclkx", "uart5_txd", "pr1_mii0_rxd3", "uart2_ctsn", "gpio2_14"),
- _PIN(0x8c4, "LCD_DATA9", 76, 7, "lcd_data9", "gpmc_a13", "ehrpwm0_synco", "mcasp0_fsx", "uart5_rxd", "pr1_mii0_rxd2", "uart2_rtsn", "gpio2_15"),
- _PIN(0x8c8, "LCD_DATA10", 77, 7, "lcd_data10", "gpmc_a14", "ehrpwm1A", "mcasp0_axr0", NULL, "pr1_mii0_rxd1", "uart3_ctsn", "gpio2_16"),
- _PIN(0x8cc, "LCD_DATA11", 78, 7, "lcd_data11", "gpmc_a15", "ehrpwm1B", "mcasp0_ahclkr", "mcasp0_axr2", "pr1_mii0_rxd0", "uart3_rtsn", "gpio2_17"),
- _PIN(0x8d0, "LCD_DATA12", 8, 7, "lcd_data12", "gpmc_a16", "eQEP1A_in", "mcasp0_aclkr", "mcasp0_axr2", "pr1_mii0_rxlink", "uart4_ctsn", "gpio0_8"),
- _PIN(0x8d4, "LCD_DATA13", 9, 7, "lcd_data13", "gpmc_a17", "eQEP1B_in", "mcasp0_fsr", "mcasp0_axr3", "pr1_mii0_rxer", "uart4_rtsn", "gpio0_9"),
- _PIN(0x8d8, "LCD_DATA14", 10, 7, "lcd_data14", "gpmc_a18", "eQEP1_index", "mcasp0_axr1", "uart5_rxd", "pr1_mii_mr0_clk", "uart5_ctsn", "gpio0_10"),
- _PIN(0x8dc, "LCD_DATA15", 11, 7, "lcd_data15", "gpmc_a19", "eQEP1_strobe", "mcasp0_ahclkx", "mcasp0_axr3", "pr1_mii0_rxdv", "uart5_rtsn", "gpio0_11"),
- _PIN(0x8e0, "LCD_VSYNC", 86, 7, "lcd_vsync", "gpmc_a8", "gpmc_a1", "pr1_edio_data_in2", "pr1_edio_data_out2", "pr1_pru1_pru_r30_8", "pr1_pru1_pru_r31_8", "gpio2_22"),
- _PIN(0x8e4, "LCD_HSYNC", 87, 7, "lcd_hsync", "gmpc_a9", "gpmc_a2", "pr1_edio_data_in3", "pr1_edio_data_out3", "pr1_pru1_pru_r30_9", "pr1_pru1_pru_r31_9", "gpio2_23"),
- _PIN(0x8e8, "LCD_PCLK", 88, 7, "lcd_pclk", "gpmc_a10", "pr1_mii0_crs", "pr1_edio_data_in4", "pr1_edio_data_out4", "pr1_pru1_pru_r30_10", "pr1_pru1_pru_r31_10", "gpio2_24"),
- _PIN(0x8ec, "LCD_AC_BIAS_EN", 89, 7, "lcd_ac_bias_en", "gpmc_a11", "pr1_mii1_crs", "pr1_edio_data_in5", "pr1_edio_data_out5", "pr1_pru1_pru_r30_11", "pr1_pru1_pru_r31_11", "gpio2_25"),
- _PIN(0x8f0, "MMC0_DAT3", 90, 7, "mmc0_dat3", "gpmc_a20", "uart4_ctsn", "timer5", "uart1_dcdn", "pr1_pru0_pru_r30_8", "pr1_pru0_pru_r31_8", "gpio2_26"),
- _PIN(0x8f4, "MMC0_DAT2", 91, 7, "mmc0_dat2", "gpmc_a21", "uart4_rtsn", "timer6", "uart1_dsrn", "pr1_pru0_pru_r30_9", "pr1_pru0_pru_r31_9", "gpio2_27"),
- _PIN(0x8f8, "MMC0_DAT1", 92, 7, "mmc0_dat1", "gpmc_a22", "uart5_ctsn", "uart3_rxd", "uart1_dtrn", "pr1_pru0_pru_r30_10", "pr1_pru0_pru_r31_10", "gpio2_28"),
- _PIN(0x8fc, "MMC0_DAT0", 93, 7, "mmc0_dat0", "gpmc_a23", "uart5_rtsn", "uart3_txd", "uart1_rin", "pr1_pru0_pru_r30_11", "pr1_pru0_pru_r31_11", "gpio2_29"),
- _PIN(0x900, "MMC0_CLK", 94, 7, "mmc0_clk", "gpmc_a24", "uart3_ctsn", "uart2_rxd", "dcan1_tx", "pr1_pru0_pru_r30_12", "pr1_pru0_pru_r31_12", "gpio2_30"),
- _PIN(0x904, "MMC0_CMD", 95, 7, "mmc0_cmd", "gpmc_a25", "uart3_rtsn", "uart2_txd", "dcan1_rx", "pr1_pru0_pru_r30_13", "pr1_pru0_pru_r31_13", "gpio2_31"),
- _PIN(0x908, "MII1_COL", 96, 7, "gmii1_col", "rmii2_refclk", "spi1_sclk", "uart5_rxd", "mcasp1_axr2", "mmc2_dat3", "mcasp0_axr2", "gpio3_0"),
- _PIN(0x90c, "MII1_CRS", 97, 7, "gmii1_crs", "rmii1_crs_dv", "spi1_d0", "I2C1_SDA", "mcasp1_aclkx", "uart5_ctsn", "uart2_rxd", "gpio3_1"),
- _PIN(0x910, "MII1_RX_ER", 98, 7, "gmii1_rxerr", "rmii1_rxerr", "spi1_d1", "I2C1_SCL", "mcasp1_fsx", "uart5_rtsn", "uart2_txd", "gpio3_2"),
- _PIN(0x914, "MII1_TX_EN", 99, 7, "gmii1_txen", "rmii1_txen", "rgmii1_tctl", "timer4", "mcasp1_axr0", "eQEP0_index", "mmc2_cmd", "gpio3_3"),
- _PIN(0x918, "MII1_RX_DV", 100, 7, "gmii1_rxdv", "cd_memory_clk", "rgmii1_rctl", "uart5_txd", "mcasp1_aclkx", "mmc2_dat0", "mcasp0_aclkr", "gpio3_4"),
- _PIN(0x91c, "MII1_TXD3", 16, 7, "gmii1_txd3", "dcan0_tx", "rgmii1_td3", "uart4_rxd", "mcasp1_fsx", "mmc2_dat1", "mcasp0_fsr", "gpio0_16"),
- _PIN(0x920, "MII1_TXD2", 17, 7, "gmii1_txd2", "dcan0_rx", "rgmii1_td2", "uart4_txd", "mcasp1_axr0", "mmc2_dat2", "mcasp0_ahclkx", "gpio0_17"),
- _PIN(0x924, "MII1_TXD1", 21, 7, "gmii1_txd1", "rmii1_txd1", "rgmii1_td1", "mcasp1_fsr", "mcasp1_axr1", "eQEP0A_in", "mmc1_cmd", "gpio0_21"),
- _PIN(0x928, "MII1_TXD0", 28, 7, "gmii1_txd0", "rmii1_txd0", "rgmii1_td0", "mcasp1_axr2", "mcasp1_aclkr", "eQEP0B_in", "mmc1_clk", "gpio0_28"),
- _PIN(0x92c, "MII1_TX_CLK", 105, 7, "gmii1_txclk", "uart2_rxd", "rgmii1_tclk", "mmc0_dat7", "mmc1_dat0", "uart1_dcdn", "mcasp0_aclkx", "gpio3_9"),
- _PIN(0x930, "MII1_RX_CLK", 106, 7, "gmii1_rxclk", "uart2_txd", "rgmii1_rclk", "mmc0_dat6", "mmc1_dat1", "uart1_dsrn", "mcasp0_fsx", "gpio3_10"),
- _PIN(0x934, "MII1_RXD3", 82, 7, "gmii1_rxd3", "uart3_rxd", "rgmii1_rd3", "mmc0_dat5", "mmc1_dat2", "uart1_dtrn", "mcasp0_axr0", "gpio2_18"),
- _PIN(0x938, "MII1_RXD2", 83, 7, "gmii1_rxd2", "uart3_txd", "rgmii1_rd2", "mmc0_dat4", "mmc1_dat3", "uart1_rin", "mcasp0_axr1", "gpio2_19"),
- _PIN(0x93c, "MII1_RXD1", 84, 7, "gmii1_rxd1", "rmii1_rxd1", "rgmii1_rd1", "mcasp1_axr3", "mcasp1_fsr", "eQEP0_strobe", "mmc2_clk", "gpio2_20"),
- _PIN(0x940, "MII1_RXD0", 85, 7, "gmii1_rxd0", "rmii1_rxd0", "rgmii1_rd0", "mcasp1_ahclkx", "mcasp1_ahclkr", "mcasp1_aclkr", "mcasp0_axr3", "gpio2_21"),
- _PIN(0x944, "RMII1_REF_CLK", 29, 7, "rmii1_refclk", "xdma_event_intr2", "spi1_cs0", "uart5_txd", "mcasp1_axr3", "mmc0_pow", "mcasp1_ahclkx", "gpio0_29"),
- _PIN(0x948, "MDIO", 0, 7, "mdio_data", "timer6", "uart5_rxd", "uart3_ctsn", "mmc0_sdcd","mmc1_cmd", "mmc2_cmd","gpio0_0"),
- _PIN(0x94c, "MDC", 1, 7, "mdio_clk", "timer5", "uart5_txd", "uart3_rtsn", "mmc0_sdwp", "mmc1_clk", "mmc2_clk", "gpio0_1"),
- _PIN(0x950, "SPI0_SCLK", 2, 7, "spi0_sclk", "uart2_rxd", "I2C2_SDA", "ehrpwm0A", "pr1_uart0_cts_n", "pr1_edio_sof", "EMU2", "gpio0_2"),
- _PIN(0x954, "SPI0_D0", 3, 7, "spi0_d0", "uart2_txd", "I2C2_SCL", "ehrpwm0B", "pr1_uart0_rts_n", "pr1_edio_latch_in", "EMU3", "gpio0_3"),
- _PIN(0x958, "SPI0_D1", 4, 7, "spi0_d1", "mmc1_sdwp", "I2C1_SDA", "ehrpwm0_tripzone_input", "pr1_uart0_rxd", "pr1_edio_data_in0", "pr1_edio_data_out0", "gpio0_4"),
- _PIN(0x95c, "SPI0_CS0", 5, 7, "spi0_cs0", "mmc2_sdwp", "I2C1_SCL", "ehrpwm0_synci", "pr1_uart0_txd", "pr1_edio_data_in1", "pr1_edio_data_out1", "gpio0_5"),
- _PIN(0x960, "SPI0_CS1", 6, 7, "spi0_cs1", "uart3_rxd", "eCAP1_in_PWM1_out", "mcc0_pow", "xdm_event_intr2", "mmc0_sdcd", "EMU4", "gpio0_6"),
- _PIN(0x964, "ECAP0_IN_PWM0_OUT",7, 7, "eCAP0_in_PWM0_out", "uart3_txd", "spi1_cs1", "pr1_ecap0_ecap_capin_apwm_o", "spi1_sclk", "mmc0_sdwp", "xdma_event_intr2", "gpio0_7"),
- _PIN(0x968, "UART0_CTSn", 40, 7, "uart0_ctsn", "uart4_rxd", "dcan1_tx", "I2C1_SDA", "spi1_d0", "timer7", "pr1_edc_sync0_out", "gpio1_8"),
- _PIN(0x96c, "UART0_RTSn", 41, 7, "uart0_rtsn", "uart4_txd", "dcan1_rx", "I2C1_SCL", "spi1_d1", "spi1_cs0", "pr1_edc_sync1_out", "gpio1_9"),
- _PIN(0x970, "UART0_rxd", 42, 7, "uart0_rxd", "spi1_cs0", "dcan0_tx", "I2C2_SDA", "eCAP2_in_PWM2_out", "pr1_pru1_pru_r30_14", "pr1_pru1_pru_r31_14", "gpio1_10"),
- _PIN(0x974, "UART0_txd", 43, 7, "uart0_txd", "spi1_cs1", "dcan0_rx", "I2C2_SCL", "eCAP1_in_PWM1_out", "pr1_pru1_pru_r30_15", "pr1_pru1_pru_r31_15", "gpio1_11"),
- _PIN(0x978, "UART1_CTSn", 12, 7, "uart1_ctsn", "timer6_mux1", "dcan0_tx", "I2C2_SDA", "spi1_cs0", "pr1_uart0_cts_n", "pr1_edc_latch0_in", "gpio0_12"),
- _PIN(0x97c, "UART1_RTSn", 13, 7, "uart1_rtsn", "timer5_mux1", "dcan0_rx", "I2C2_SCL", "spi1_cs1", "pr1_uart0_rts_n", "pr1_edc_latch1_in", "gpio0_13"),
- _PIN(0x980, "UART1_RXD", 14, 7, "uart1_rxd", "mmc1_sdwp", "dcan1_tx", "I2C1_SDA", NULL, "pr1_uart0_rxd", "pr1_pru1_pru_r31_16", "gpio0_14"),
- _PIN(0x984, "UART1_TXD", 15, 7, "uart1_txd", "mmc2_sdwp", "dcan1_rx", "I2C1_SCL", NULL, "pr1_uart0_txd", "pr1_pru0_pru_r31_16", "gpio0_15"),
- _PIN(0x988, "I2C0_SDA", 101, 7, "I2C0_SDA", "timer4", "uart2_ctsn", "eCAP2_in_PWM2_out", NULL, NULL, NULL, "gpio3_5"),
- _PIN(0x98c, "I2C0_SCL", 102, 7, "I2C0_SCL", "timer7", "uart2_rtsn", "eCAP1_in_PWM1_out", NULL, NULL, NULL, "gpio3_6"),
- _PIN(0x990, "MCASP0_ACLKX", 110, 7, "mcasp0_aclkx", "ehrpwm0A", NULL, "spi1_sclk", "mmc0_sdcd", "pr1_pru0_pru_r30_0", "pr1_pru0_pru_r31_0", "gpio3_14"),
- _PIN(0x994, "MCASP0_FSX", 111, 7, "mcasp0_fsx", "ehrpwm0B", NULL, "spi1_d0", "mmc1_sdcd", "pr1_pru0_pru_r30_1", "pr1_pru0_pru_r31_1", "gpio3_15"),
- _PIN(0x998, "MCASP0_AXR0", 112, 7, "mcasp0_axr0", "ehrpwm0_tripzone_input", NULL, "spi1_d1", "mmc2_sdcd", "pr1_pru0_pru_r30_2", "pr1_pru0_pru_r31_2", "gpio3_16"),
- _PIN(0x99c, "MCASP0_AHCLKR", 113, 7, "mcasp0_ahclkr", "ehrpwm0_synci", "mcasp0_axr2", "spi1_cs0", "eCAP2_in_PWM2_out", "pr1_pru0_pru_r30_3", "pr1_pru0_pru_r31_3", "gpio3_17"),
- _PIN(0x9a0, "MCASP0_ACLKR", 114, 7, "mcasp0_aclkr", "eQEP0A_in", "mcasp0_axr2", "mcasp1_aclkx", "mmc0_sdwp", "pr1_pru0_pru_r30_4", "pr1_pru0_pru_r31_4", "gpio3_18"),
- _PIN(0x9a4, "MCASP0_FSR", 115, 7, "mcasp0_fsr", "eQEP0B_in", "mcasp0_axr3", "mcasp1_fsx", "EMU2", "pr1_pru0_pru_r30_5", "pr1_pru0_pru_r31_5", "gpio3_19"),
- _PIN(0x9a8, "MCASP0_AXR1", 116, 7, "mcasp0_axr1", "eQEP0_index", NULL, "mcasp1_axr0", "EMU3", "pr1_pru0_pru_r30_6", "pr1_pru0_pru_r31_6", "gpio3_20"),
- _PIN(0x9ac, "MCASP0_AHCLKX", 117, 7, "mcasp0_ahclkx", "eQEP0_strobe", "mcasp0_axr3", "mcasp1_axr1", "EMU4", "pr1_pru0_pru_r30_7", "pr1_pru0_pru_r31_7", "gpio3_21"),
- _PIN(0x9b0, "XDMA_EVENT_INTR0", 19, 7, "xdma_event_intr0", NULL, "timer4", "clkout1", "spi1_cs1", "pr1_pru1_pru_r31_16", "EMU2", "gpio0_19"),
- _PIN(0x9b4, "XDMA_EVENT_INTR1", 20, 7, "xdma_event_intr1", NULL, "tclkin", "clkout2", "timer7", "pr1_pru0_pru_r31_16", "EMU3", "gpio0_20"),
+const static struct ti_pinmux_padconf ti_padconf_devmap[] = {
+ _PIN(0x000, "GPMC_AD0", 32, 7,"gpmc_ad0", "mmc1_dat0", NULL, NULL, NULL, NULL, NULL, "gpio1_0"),
+ _PIN(0x004, "GPMC_AD1", 33, 7,"gpmc_ad1", "mmc1_dat1", NULL, NULL, NULL, NULL, NULL, "gpio1_1"),
+ _PIN(0x008, "GPMC_AD2", 34, 7,"gpmc_ad2", "mmc1_dat2", NULL, NULL, NULL, NULL, NULL, "gpio1_2"),
+ _PIN(0x00C, "GPMC_AD3", 35, 7,"gpmc_ad3", "mmc1_dat3", NULL, NULL, NULL, NULL, NULL, "gpio1_3"),
+ _PIN(0x010, "GPMC_AD4", 36, 7,"gpmc_ad4", "mmc1_dat4", NULL, NULL, NULL, NULL, NULL, "gpio1_4"),
+ _PIN(0x014, "GPMC_AD5", 37, 7,"gpmc_ad5", "mmc1_dat5", NULL, NULL, NULL, NULL, NULL, "gpio1_5"),
+ _PIN(0x018, "GPMC_AD6", 38, 7,"gpmc_ad6", "mmc1_dat6", NULL, NULL, NULL, NULL, NULL, "gpio1_6"),
+ _PIN(0x01C, "GPMC_AD7", 39, 7,"gpmc_ad7", "mmc1_dat7", NULL, NULL, NULL, NULL, NULL, "gpio1_7"),
+ _PIN(0x020, "GPMC_AD8", 22, 7, "gpmc_ad8", "lcd_data23", "mmc1_dat0", "mmc2_dat4", "ehrpwm2A", NULL, NULL, "gpio0_22"),
+ _PIN(0x024, "GPMC_AD9", 23, 7, "gpmc_ad9", "lcd_data22", "mmc1_dat1", "mmc2_dat5", "ehrpwm2B", NULL, NULL, "gpio0_23"),
+ _PIN(0x028, "GPMC_AD10", 26, 7, "gpmc_ad10", "lcd_data21", "mmc1_dat2", "mmc2_dat6", "ehrpwm2_tripzone_in", NULL, NULL, "gpio0_26"),
+ _PIN(0x02C, "GPMC_AD11", 27, 7, "gpmc_ad11", "lcd_data20", "mmc1_dat3", "mmc2_dat7", "ehrpwm0_synco", NULL, NULL, "gpio0_27"),
+ _PIN(0x030, "GPMC_AD12", 44, 7, "gpmc_ad12", "lcd_data19", "mmc1_dat4", "mmc2_dat0", "eQEP2A_in", "pr1_mii0_txd2", "pr1_pru0_pru_r30_14", "gpio1_12"),
+ _PIN(0x034, "GPMC_AD13", 45, 7, "gpmc_ad13", "lcd_data18", "mmc1_dat5", "mmc2_dat1", "eQEP2B_in", "pr1_mii0_txd1", "pr1_pru0_pru_r30_15", "gpio1_13"),
+ _PIN(0x038, "GPMC_AD14", 46, 7, "gpmc_ad14", "lcd_data17", "mmc1_dat6", "mmc2_dat2", "eQEP2_index", "pr1_mii0_txd0", "pr1_pru0_pru_r31_14", "gpio1_14"),
+ _PIN(0x03C, "GPMC_AD15", 47, 7, "gpmc_ad15", "lcd_data16", "mmc1_dat7", "mmc2_dat3", "eQEP2_strobe", "pr1_ecap0_ecap_capin_apwm_o", "pr1_pru0_pru_r31_15", "gpio1_15"),
+ _PIN(0x040, "GPMC_A0", 48, 7, "gpmc_a0", "gmii2_txen", "rgmii2_tctl", "rmii2_txen", "gpmc_a16", "pr1_mii_mt1_clk", "ehrpwm1_tripzone_input", "gpio1_16"),
+ _PIN(0x044, "GPMC_A1", 49, 7, "gpmc_a1", "gmii2_rxdv", "rgmii2_rctl", "mmc2_dat0", "gpmc_a17", "pr1_mii1_txd3", "ehrpwm0_synco", "gpio1_17"),
+ _PIN(0x048, "GPMC_A2", 50, 7, "gpmc_a2", "gmii2_txd3", "rgmii2_td3", "mmc2_dat1", "gpmc_a18", "pr1_mii1_txd2", "ehrpwm1A", "gpio1_18"),
+ _PIN(0x04C, "GPMC_A3", 51, 7, "gpmc_a3", "gmii2_txd2", "rgmii2_td2", "mmc2_dat2", "gpmc_a19", "pr1_mii1_txd1", "ehrpwm1B", "gpio1_19"),
+ _PIN(0x050, "GPMC_A4", 52, 7, "gpmc_a4", "gmii2_txd1", "rgmii2_td1", "rmii2_tdx1", "gpmc_a20", "pr1_mii1_txd0", "eQEP1A_in", "gpio1_20"),
+ _PIN(0x054, "GPMC_A5", 53, 7, "gpmc_a5", "gmii2_txd0", "rgmii2_td0", "rmii2_txd0", "gpmc_a21", "pr1_mii1_rxd3", "eQEP1B_in", "gpio1_21"),
+ _PIN(0x058, "GPMC_A6", 54, 7, "gpmc_a6", "gmii2_txclk", "rgmii2_tclk", "mmc2_dat4", "gpmc_a22", "pr1_mii1_rxd2", "eQEP1_index", "gpio1_22"),
+ _PIN(0x05C, "GPMC_A7", 55, 7, "gpmc_a7", "gmii2_rxclk", "rgmii2_rclk", "mmc2_dat5", "gpmc_a23", "pr1_mii1_rxd1", "eQEP1_strobe", "gpio1_23"),
+ _PIN(0x060, "GPMC_A8", 56, 7, "gpmc_a8", "gmii2_rxd3", "rgmii2_rd3", "mmc2_dat6", "gpmc_a24", "pr1_mii1_rxd0", "mcasp0_aclkx", "gpio1_24"),
+ _PIN(0x064, "GPMC_A9", 57, 7, "gmpc_a9", "gmii2_rxd2", "rgmii2_rd2", "mmc2_dat7 / rmii2_crs_dv", "gpmc_a25", "pr1_mii_mr1_clk", "mcasp0_fsx", "gpio1_25"),
+ _PIN(0x068, "GPMC_A10", 58, 7, "gmpc_a10", "gmii2_rxd1", "rgmii2_rd1", "rmii2_rxd1", "gpmc_a26", "pr1_mii1_rxdv", "mcasp0_arx0", "gpio1_26"),
+ _PIN(0x06C, "GPMC_A11", 59, 7, "gmpc_a11", "gmii2_rxd0", "rgmii2_rd0", "rmii2_rxd0", "gpmc_a27", "pr1_mii1_rxer", "mcasp0_axr1", "gpio1_27"),
+ _PIN(0x070, "GPMC_WAIT0", 30, 7, "gpmc_wait0", "gmii2_crs", "gpmc_csn4", "rmii2_crs_dv", "mmc1_sdcd", "pr1_mii1_col", "uart4_rxd", "gpio0_30"),
+ _PIN(0x074, "GPMC_WPn", 31, 7, "gpmc_wpn", "gmii2_rxerr", "gpmc_csn5", "rmii2_rxerr", "mmc2_sdcd", "pr1_mii1_txen", "uart4_txd", "gpio0_31"),
+ _PIN(0x078, "GPMC_BEn1", 60, 7, "gpmc_be1n", "gmii2_col", "gmpc_csn6","mmc2_dat3", "gpmc_dir", "pr1_mii1_rxlink", "mcasp0_aclkr", "gpio1_28"),
+ _PIN(0x07c, "GPMC_CSn0", 61, 7, "gpmc_csn0", NULL, NULL, NULL, NULL, NULL, NULL, "gpio1_29"),
+ _PIN(0x080, "GPMC_CSn1", 62, 7, "gpmc_csn1", "gpmc_clk", "mmc1_clk", "pr1_edio_data_in6", "pr1_edio_data_out6", "pr1_pru1_pru_r30_12", "pr1_pru1_pru_r31_12", "gpio1_30"),
+ _PIN(0x084, "GPMC_CSn2", 63, 7, "gpmc_csn2", "gpmc_be1n", "mmc1_cmd", "pr1_edio_data_in7", "pr1_edio_data_out7", "pr1_pru1_pru_r30_13", "pr1_pru1_pru_r31_13", "gpio1_31"),
+ _PIN(0x088, "GPMC_CSn3", 64, 7, "gpmc_csn3", "gpmc_a3", "rmii2_crs_dv", "mmc2_cmd", "pr1_mii0_crs", "pr1_mdio_data", "EMU4", "gpio2_0"),
+ _PIN(0x08c, "GPMC_CLK", 65, 7, "gpmc_clk", "lcd_memory_clk", "gpmc_wait1", "mmc2_clk", "pr1_mii1_crs", "pr1_mdio_mdclk", "mcasp0_fsr", "gpio2_1"),
+ _PIN(0x090, "GPMC_ADVn_ALE", 66, 7, "gpmc_advn_ale", NULL, "timer4", NULL, NULL, NULL, NULL, "gpio2_2"),
+ _PIN(0x094, "GPMC_OEn_REn", 67, 7, "gpmc_oen_ren", NULL, "timer7", NULL, NULL, NULL, NULL, "gpio2_3"),
+ _PIN(0x098, "GPMC_WEn", 68, 7, "gpmc_wen", NULL, "timer6", NULL, NULL, NULL, NULL, "gpio2_4"),
+ _PIN(0x09c, "GPMC_BEn0_CLE", 67, 7, "gpmc_ben0_cle", NULL, "timer5", NULL, NULL, NULL, NULL, "gpio2_5"),
+ _PIN(0x0a0, "LCD_DATA0", 68, 7, "lcd_data0", "gpmc_a0", "pr1_mii_mt0_clk", "ehrpwm2A", NULL, "pr1_pru1_pru_r30_0", "pr1_pru1_pru_r31_0", "gpio2_6"),
+ _PIN(0x0a4, "LCD_DATA1", 69, 7, "lcd_data1", "gpmc_a1", "pr1_mii0_txen", "ehrpwm2B", NULL, "pr1_pru1_pru_r30_1", "pr1_pru1_pru_r31_1", "gpio2_7"),
+ _PIN(0x0a8, "LCD_DATA2", 70, 7, "lcd_data2", "gpmc_a2", "pr1_mii0_txd3", "ehrpwm2_tripzone_input", NULL, "pr1_pru1_pru_r30_2", "pr1_pru1_pru_r31_2", "gpio2_8"),
+ _PIN(0x0ac, "LCD_DATA3", 71, 7, "lcd_data3", "gpmc_a3", "pr1_mii0_txd2", "ehrpwm0_synco", NULL, "pr1_pru1_pru_r30_3", "pr1_pru1_pru_r31_3", "gpio2_9"),
+ _PIN(0x0b0, "LCD_DATA4", 72, 7, "lcd_data4", "gpmc_a4", "pr1_mii0_txd1", "eQEP2A_in", NULL, "pr1_pru1_pru_r30_4", "pr1_pru1_pru_r31_4", "gpio2_10"),
+ _PIN(0x0b4, "LCD_DATA5", 73, 7, "lcd_data5", "gpmc_a5", "pr1_mii0_txd0", "eQEP2B_in", NULL, "pr1_pru1_pru_r30_5", "pr1_pru1_pru_r31_5", "gpio2_11"),
+ _PIN(0x0b8, "LCD_DATA6", 74, 7, "lcd_data6", "gpmc_a6", "pr1_edio_data_in6", "eQEP2_index", "pr1_edio_data_out6", "pr1_pru1_pru_r30_6", "pr1_pru1_pru_r31_6", "gpio2_12"),
+ _PIN(0x0bc, "LCD_DATA7", 75, 7, "lcd_data7", "gpmc_a7", "pr1_edio_data_in7", "eQEP2_strobe", "pr1_edio_data_out7", "pr1_pru1_pru_r30_7", "pr1_pru1_pru_r31_7", "gpio2_13"),
+ _PIN(0x0c0, "LCD_DATA8", 76, 7, "lcd_data8", "gpmc_a12", "ehrpwm1_tripzone_input", "mcasp0_aclkx", "uart5_txd", "pr1_mii0_rxd3", "uart2_ctsn", "gpio2_14"),
+ _PIN(0x0c4, "LCD_DATA9", 76, 7, "lcd_data9", "gpmc_a13", "ehrpwm0_synco", "mcasp0_fsx", "uart5_rxd", "pr1_mii0_rxd2", "uart2_rtsn", "gpio2_15"),
+ _PIN(0x0c8, "LCD_DATA10", 77, 7, "lcd_data10", "gpmc_a14", "ehrpwm1A", "mcasp0_axr0", NULL, "pr1_mii0_rxd1", "uart3_ctsn", "gpio2_16"),
+ _PIN(0x0cc, "LCD_DATA11", 78, 7, "lcd_data11", "gpmc_a15", "ehrpwm1B", "mcasp0_ahclkr", "mcasp0_axr2", "pr1_mii0_rxd0", "uart3_rtsn", "gpio2_17"),
+ _PIN(0x0d0, "LCD_DATA12", 8, 7, "lcd_data12", "gpmc_a16", "eQEP1A_in", "mcasp0_aclkr", "mcasp0_axr2", "pr1_mii0_rxlink", "uart4_ctsn", "gpio0_8"),
+ _PIN(0x0d4, "LCD_DATA13", 9, 7, "lcd_data13", "gpmc_a17", "eQEP1B_in", "mcasp0_fsr", "mcasp0_axr3", "pr1_mii0_rxer", "uart4_rtsn", "gpio0_9"),
+ _PIN(0x0d8, "LCD_DATA14", 10, 7, "lcd_data14", "gpmc_a18", "eQEP1_index", "mcasp0_axr1", "uart5_rxd", "pr1_mii_mr0_clk", "uart5_ctsn", "gpio0_10"),
+ _PIN(0x0dc, "LCD_DATA15", 11, 7, "lcd_data15", "gpmc_a19", "eQEP1_strobe", "mcasp0_ahclkx", "mcasp0_axr3", "pr1_mii0_rxdv", "uart5_rtsn", "gpio0_11"),
+ _PIN(0x0e0, "LCD_VSYNC", 86, 7, "lcd_vsync", "gpmc_a8", "gpmc_a1", "pr1_edio_data_in2", "pr1_edio_data_out2", "pr1_pru1_pru_r30_8", "pr1_pru1_pru_r31_8", "gpio2_22"),
+ _PIN(0x0e4, "LCD_HSYNC", 87, 7, "lcd_hsync", "gmpc_a9", "gpmc_a2", "pr1_edio_data_in3", "pr1_edio_data_out3", "pr1_pru1_pru_r30_9", "pr1_pru1_pru_r31_9", "gpio2_23"),
+ _PIN(0x0e8, "LCD_PCLK", 88, 7, "lcd_pclk", "gpmc_a10", "pr1_mii0_crs", "pr1_edio_data_in4", "pr1_edio_data_out4", "pr1_pru1_pru_r30_10", "pr1_pru1_pru_r31_10", "gpio2_24"),
+ _PIN(0x0ec, "LCD_AC_BIAS_EN", 89, 7, "lcd_ac_bias_en", "gpmc_a11", "pr1_mii1_crs", "pr1_edio_data_in5", "pr1_edio_data_out5", "pr1_pru1_pru_r30_11", "pr1_pru1_pru_r31_11", "gpio2_25"),
+ _PIN(0x0f0, "MMC0_DAT3", 90, 7, "mmc0_dat3", "gpmc_a20", "uart4_ctsn", "timer5", "uart1_dcdn", "pr1_pru0_pru_r30_8", "pr1_pru0_pru_r31_8", "gpio2_26"),
+ _PIN(0x0f4, "MMC0_DAT2", 91, 7, "mmc0_dat2", "gpmc_a21", "uart4_rtsn", "timer6", "uart1_dsrn", "pr1_pru0_pru_r30_9", "pr1_pru0_pru_r31_9", "gpio2_27"),
+ _PIN(0x0f8, "MMC0_DAT1", 92, 7, "mmc0_dat1", "gpmc_a22", "uart5_ctsn", "uart3_rxd", "uart1_dtrn", "pr1_pru0_pru_r30_10", "pr1_pru0_pru_r31_10", "gpio2_28"),
+ _PIN(0x0fc, "MMC0_DAT0", 93, 7, "mmc0_dat0", "gpmc_a23", "uart5_rtsn", "uart3_txd", "uart1_rin", "pr1_pru0_pru_r30_11", "pr1_pru0_pru_r31_11", "gpio2_29"),
+ _PIN(0x100, "MMC0_CLK", 94, 7, "mmc0_clk", "gpmc_a24", "uart3_ctsn", "uart2_rxd", "dcan1_tx", "pr1_pru0_pru_r30_12", "pr1_pru0_pru_r31_12", "gpio2_30"),
+ _PIN(0x104, "MMC0_CMD", 95, 7, "mmc0_cmd", "gpmc_a25", "uart3_rtsn", "uart2_txd", "dcan1_rx", "pr1_pru0_pru_r30_13", "pr1_pru0_pru_r31_13", "gpio2_31"),
+ _PIN(0x108, "MII1_COL", 96, 7, "gmii1_col", "rmii2_refclk", "spi1_sclk", "uart5_rxd", "mcasp1_axr2", "mmc2_dat3", "mcasp0_axr2", "gpio3_0"),
+ _PIN(0x10c, "MII1_CRS", 97, 7, "gmii1_crs", "rmii1_crs_dv", "spi1_d0", "I2C1_SDA", "mcasp1_aclkx", "uart5_ctsn", "uart2_rxd", "gpio3_1"),
+ _PIN(0x110, "MII1_RX_ER", 98, 7, "gmii1_rxerr", "rmii1_rxerr", "spi1_d1", "I2C1_SCL", "mcasp1_fsx", "uart5_rtsn", "uart2_txd", "gpio3_2"),
+ _PIN(0x114, "MII1_TX_EN", 99, 7, "gmii1_txen", "rmii1_txen", "rgmii1_tctl", "timer4", "mcasp1_axr0", "eQEP0_index", "mmc2_cmd", "gpio3_3"),
+ _PIN(0x118, "MII1_RX_DV", 100, 7, "gmii1_rxdv", "cd_memory_clk", "rgmii1_rctl", "uart5_txd", "mcasp1_aclkx", "mmc2_dat0", "mcasp0_aclkr", "gpio3_4"),
+ _PIN(0x11c, "MII1_TXD3", 16, 7, "gmii1_txd3", "dcan0_tx", "rgmii1_td3", "uart4_rxd", "mcasp1_fsx", "mmc2_dat1", "mcasp0_fsr", "gpio0_16"),
+ _PIN(0x120, "MII1_TXD2", 17, 7, "gmii1_txd2", "dcan0_rx", "rgmii1_td2", "uart4_txd", "mcasp1_axr0", "mmc2_dat2", "mcasp0_ahclkx", "gpio0_17"),
+ _PIN(0x124, "MII1_TXD1", 21, 7, "gmii1_txd1", "rmii1_txd1", "rgmii1_td1", "mcasp1_fsr", "mcasp1_axr1", "eQEP0A_in", "mmc1_cmd", "gpio0_21"),
+ _PIN(0x128, "MII1_TXD0", 28, 7, "gmii1_txd0", "rmii1_txd0", "rgmii1_td0", "mcasp1_axr2", "mcasp1_aclkr", "eQEP0B_in", "mmc1_clk", "gpio0_28"),
+ _PIN(0x12c, "MII1_TX_CLK", 105, 7, "gmii1_txclk", "uart2_rxd", "rgmii1_tclk", "mmc0_dat7", "mmc1_dat0", "uart1_dcdn", "mcasp0_aclkx", "gpio3_9"),
+ _PIN(0x130, "MII1_RX_CLK", 106, 7, "gmii1_rxclk", "uart2_txd", "rgmii1_rclk", "mmc0_dat6", "mmc1_dat1", "uart1_dsrn", "mcasp0_fsx", "gpio3_10"),
+ _PIN(0x134, "MII1_RXD3", 82, 7, "gmii1_rxd3", "uart3_rxd", "rgmii1_rd3", "mmc0_dat5", "mmc1_dat2", "uart1_dtrn", "mcasp0_axr0", "gpio2_18"),
+ _PIN(0x138, "MII1_RXD2", 83, 7, "gmii1_rxd2", "uart3_txd", "rgmii1_rd2", "mmc0_dat4", "mmc1_dat3", "uart1_rin", "mcasp0_axr1", "gpio2_19"),
+ _PIN(0x13c, "MII1_RXD1", 84, 7, "gmii1_rxd1", "rmii1_rxd1", "rgmii1_rd1", "mcasp1_axr3", "mcasp1_fsr", "eQEP0_strobe", "mmc2_clk", "gpio2_20"),
+ _PIN(0x140, "MII1_RXD0", 85, 7, "gmii1_rxd0", "rmii1_rxd0", "rgmii1_rd0", "mcasp1_ahclkx", "mcasp1_ahclkr", "mcasp1_aclkr", "mcasp0_axr3", "gpio2_21"),
+ _PIN(0x144, "RMII1_REF_CLK", 29, 7, "rmii1_refclk", "xdma_event_intr2", "spi1_cs0", "uart5_txd", "mcasp1_axr3", "mmc0_pow", "mcasp1_ahclkx", "gpio0_29"),
+ _PIN(0x148, "MDIO", 0, 7, "mdio_data", "timer6", "uart5_rxd", "uart3_ctsn", "mmc0_sdcd","mmc1_cmd", "mmc2_cmd","gpio0_0"),
+ _PIN(0x14c, "MDC", 1, 7, "mdio_clk", "timer5", "uart5_txd", "uart3_rtsn", "mmc0_sdwp", "mmc1_clk", "mmc2_clk", "gpio0_1"),
+ _PIN(0x150, "SPI0_SCLK", 2, 7, "spi0_sclk", "uart2_rxd", "I2C2_SDA", "ehrpwm0A", "pr1_uart0_cts_n", "pr1_edio_sof", "EMU2", "gpio0_2"),
+ _PIN(0x154, "SPI0_D0", 3, 7, "spi0_d0", "uart2_txd", "I2C2_SCL", "ehrpwm0B", "pr1_uart0_rts_n", "pr1_edio_latch_in", "EMU3", "gpio0_3"),
+ _PIN(0x158, "SPI0_D1", 4, 7, "spi0_d1", "mmc1_sdwp", "I2C1_SDA", "ehrpwm0_tripzone_input", "pr1_uart0_rxd", "pr1_edio_data_in0", "pr1_edio_data_out0", "gpio0_4"),
+ _PIN(0x15c, "SPI0_CS0", 5, 7, "spi0_cs0", "mmc2_sdwp", "I2C1_SCL", "ehrpwm0_synci", "pr1_uart0_txd", "pr1_edio_data_in1", "pr1_edio_data_out1", "gpio0_5"),
+ _PIN(0x160, "SPI0_CS1", 6, 7, "spi0_cs1", "uart3_rxd", "eCAP1_in_PWM1_out", "mcc0_pow", "xdm_event_intr2", "mmc0_sdcd", "EMU4", "gpio0_6"),
+ _PIN(0x164, "ECAP0_IN_PWM0_OUT",7, 7, "eCAP0_in_PWM0_out", "uart3_txd", "spi1_cs1", "pr1_ecap0_ecap_capin_apwm_o", "spi1_sclk", "mmc0_sdwp", "xdma_event_intr2", "gpio0_7"),
+ _PIN(0x168, "UART0_CTSn", 40, 7, "uart0_ctsn", "uart4_rxd", "dcan1_tx", "I2C1_SDA", "spi1_d0", "timer7", "pr1_edc_sync0_out", "gpio1_8"),
+ _PIN(0x16c, "UART0_RTSn", 41, 7, "uart0_rtsn", "uart4_txd", "dcan1_rx", "I2C1_SCL", "spi1_d1", "spi1_cs0", "pr1_edc_sync1_out", "gpio1_9"),
+ _PIN(0x170, "UART0_rxd", 42, 7, "uart0_rxd", "spi1_cs0", "dcan0_tx", "I2C2_SDA", "eCAP2_in_PWM2_out", "pr1_pru1_pru_r30_14", "pr1_pru1_pru_r31_14", "gpio1_10"),
+ _PIN(0x174, "UART0_txd", 43, 7, "uart0_txd", "spi1_cs1", "dcan0_rx", "I2C2_SCL", "eCAP1_in_PWM1_out", "pr1_pru1_pru_r30_15", "pr1_pru1_pru_r31_15", "gpio1_11"),
+ _PIN(0x178, "UART1_CTSn", 12, 7, "uart1_ctsn", "timer6_mux1", "dcan0_tx", "I2C2_SDA", "spi1_cs0", "pr1_uart0_cts_n", "pr1_edc_latch0_in", "gpio0_12"),
+ _PIN(0x17c, "UART1_RTSn", 13, 7, "uart1_rtsn", "timer5_mux1", "dcan0_rx", "I2C2_SCL", "spi1_cs1", "pr1_uart0_rts_n", "pr1_edc_latch1_in", "gpio0_13"),
+ _PIN(0x180, "UART1_RXD", 14, 7, "uart1_rxd", "mmc1_sdwp", "dcan1_tx", "I2C1_SDA", NULL, "pr1_uart0_rxd", "pr1_pru1_pru_r31_16", "gpio0_14"),
+ _PIN(0x184, "UART1_TXD", 15, 7, "uart1_txd", "mmc2_sdwp", "dcan1_rx", "I2C1_SCL", NULL, "pr1_uart0_txd", "pr1_pru0_pru_r31_16", "gpio0_15"),
+ _PIN(0x188, "I2C0_SDA", 101, 7, "I2C0_SDA", "timer4", "uart2_ctsn", "eCAP2_in_PWM2_out", NULL, NULL, NULL, "gpio3_5"),
+ _PIN(0x18c, "I2C0_SCL", 102, 7, "I2C0_SCL", "timer7", "uart2_rtsn", "eCAP1_in_PWM1_out", NULL, NULL, NULL, "gpio3_6"),
+ _PIN(0x190, "MCASP0_ACLKX", 110, 7, "mcasp0_aclkx", "ehrpwm0A", NULL, "spi1_sclk", "mmc0_sdcd", "pr1_pru0_pru_r30_0", "pr1_pru0_pru_r31_0", "gpio3_14"),
+ _PIN(0x194, "MCASP0_FSX", 111, 7, "mcasp0_fsx", "ehrpwm0B", NULL, "spi1_d0", "mmc1_sdcd", "pr1_pru0_pru_r30_1", "pr1_pru0_pru_r31_1", "gpio3_15"),
+ _PIN(0x198, "MCASP0_AXR0", 112, 7, "mcasp0_axr0", "ehrpwm0_tripzone_input", NULL, "spi1_d1", "mmc2_sdcd", "pr1_pru0_pru_r30_2", "pr1_pru0_pru_r31_2", "gpio3_16"),
+ _PIN(0x19c, "MCASP0_AHCLKR", 113, 7, "mcasp0_ahclkr", "ehrpwm0_synci", "mcasp0_axr2", "spi1_cs0", "eCAP2_in_PWM2_out", "pr1_pru0_pru_r30_3", "pr1_pru0_pru_r31_3", "gpio3_17"),
+ _PIN(0x1a0, "MCASP0_ACLKR", 114, 7, "mcasp0_aclkr", "eQEP0A_in", "mcasp0_axr2", "mcasp1_aclkx", "mmc0_sdwp", "pr1_pru0_pru_r30_4", "pr1_pru0_pru_r31_4", "gpio3_18"),
+ _PIN(0x1a4, "MCASP0_FSR", 115, 7, "mcasp0_fsr", "eQEP0B_in", "mcasp0_axr3", "mcasp1_fsx", "EMU2", "pr1_pru0_pru_r30_5", "pr1_pru0_pru_r31_5", "gpio3_19"),
+ _PIN(0x1a8, "MCASP0_AXR1", 116, 7, "mcasp0_axr1", "eQEP0_index", NULL, "mcasp1_axr0", "EMU3", "pr1_pru0_pru_r30_6", "pr1_pru0_pru_r31_6", "gpio3_20"),
+ _PIN(0x1ac, "MCASP0_AHCLKX", 117, 7, "mcasp0_ahclkx", "eQEP0_strobe", "mcasp0_axr3", "mcasp1_axr1", "EMU4", "pr1_pru0_pru_r30_7", "pr1_pru0_pru_r31_7", "gpio3_21"),
+ _PIN(0x1b0, "XDMA_EVENT_INTR0", 19, 7, "xdma_event_intr0", NULL, "timer4", "clkout1", "spi1_cs1", "pr1_pru1_pru_r31_16", "EMU2", "gpio0_19"),
+ _PIN(0x1b4, "XDMA_EVENT_INTR1", 20, 7, "xdma_event_intr1", NULL, "tclkin", "clkout2", "timer7", "pr1_pru0_pru_r31_16", "EMU3", "gpio0_20"),
#if 0
- _PIN(0x9b8, "nresetin_out", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0x9bc, "porz", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0x9c0, "nnmi", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0x9c4, "osc0_in", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0x9c8, "osc0_out", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0x9cc, "osc0_vss", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0x9d0, "tms", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0x9d4, "tdi", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0x9d8, "tdo", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0x9dc, "tck", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0x9e0, "ntrst", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x1b8, "nresetin_out", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x1bc, "porz", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x1c0, "nnmi", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x1c4, "osc0_in", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x1c8, "osc0_out", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x1cc, "osc0_vss", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x1d0, "tms", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x1d4, "tdi", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x1d8, "tdo", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x1dc, "tck", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x1e0, "ntrst", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
#endif
- _PIN(0x9e4, "EMU0", 103, 7, "EMU0", NULL, NULL, NULL, NULL, NULL, NULL, "gpio3_7"),
- _PIN(0x9e8, "EMU1", 104, 0, "EMU1", NULL, NULL, NULL, NULL, NULL, NULL, "gpio3_8"),
+ _PIN(0x1e4, "EMU0", 103, 7, "EMU0", NULL, NULL, NULL, NULL, NULL, NULL, "gpio3_7"),
+ _PIN(0x1e8, "EMU1", 104, 0, "EMU1", NULL, NULL, NULL, NULL, NULL, NULL, "gpio3_8"),
#if 0
- _PIN(0x9ec, "osc1_in", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0x9f0, "osc1_out", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0x9f4, "osc1_vss", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0x9f8, "rtc_porz", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0x9fc, "pmic_power_en", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa00, "ext_wakeup", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa04, "enz_kaldo_1p8v", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x1ec, "osc1_in", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x1f0, "osc1_out", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x1f4, "osc1_vss", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x1f8, "rtc_porz", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x1fc, "pmic_power_en", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x200, "ext_wakeup", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x204, "enz_kaldo_1p8v", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
#endif
- _PIN(0xa08, "USB0_DM", 0, 0, "USB0_DM", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa0c, "USB0_DP", 0, 0, "USB0_DP", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa10, "USB0_CE", 0, 0, "USB0_CE", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa14, "USB0_ID", 0, 0, "USB0_ID", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa18, "USB0_VBUS", 0, 0, "USB0_VBUS", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa1c, "USB0_DRVVBUS", 18, 7, "USB0_DRVVBUS", NULL, NULL, NULL, NULL, NULL, NULL, "gpio0_18"),
- _PIN(0xa20, "USB1_DM", 0, 0, "USB1_DM", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa24, "USB1_DP", 0, 0, "USB1_DP", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa28, "USB1_CE", 0, 0, "USB1_CE", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa2c, "USB1_ID", 0, 0, "USB1_ID", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa30, "USB1_VBUS", 0, 0, "USB1_VBUS", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa34, "USB1_DRVVBUS", 109, 7, "USB1_DRVVBUS", NULL, NULL, NULL, NULL, NULL, NULL, "gpio3_13"),
+ _PIN(0x208, "USB0_DM", 0, 0, "USB0_DM", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x20c, "USB0_DP", 0, 0, "USB0_DP", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x210, "USB0_CE", 0, 0, "USB0_CE", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x214, "USB0_ID", 0, 0, "USB0_ID", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x218, "USB0_VBUS", 0, 0, "USB0_VBUS", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x21c, "USB0_DRVVBUS", 18, 7, "USB0_DRVVBUS", NULL, NULL, NULL, NULL, NULL, NULL, "gpio0_18"),
+ _PIN(0x220, "USB1_DM", 0, 0, "USB1_DM", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x224, "USB1_DP", 0, 0, "USB1_DP", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x228, "USB1_CE", 0, 0, "USB1_CE", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x22c, "USB1_ID", 0, 0, "USB1_ID", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x230, "USB1_VBUS", 0, 0, "USB1_VBUS", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x234, "USB1_DRVVBUS", 109, 7, "USB1_DRVVBUS", NULL, NULL, NULL, NULL, NULL, NULL, "gpio3_13"),
#if 0
- _PIN(0xa38, "ddr_resetn", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa3c, "ddr_csn0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa40, "ddr_cke", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa44, "ddr_ck", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa48, "ddr_nck", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa4c, "ddr_casn", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa50, "ddr_rasn", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa54, "ddr_wen", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa58, "ddr_ba0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa5c, "ddr_ba1", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa60, "ddr_ba2", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa64, "ddr_a0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa68, "ddr_a1", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa6c, "ddr_a2", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa70, "ddr_a3", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa74, "ddr_a4", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa78, "ddr_a5", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa7c, "ddr_a6", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa80, "ddr_a7", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa84, "ddr_a8", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa88, "ddr_a9", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa8c, "ddr_a10", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa90, "ddr_a11", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa94, "ddr_a12", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa98, "ddr_a13", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xa9c, "ddr_a14", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xaa0, "ddr_a15", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xaa4, "ddr_odt", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xaa8, "ddr_d0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xaac, "ddr_d1", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xab0, "ddr_d2", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xab4, "ddr_d3", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xab8, "ddr_d4", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xabc, "ddr_d5", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xac0, "ddr_d6", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xac4, "ddr_d7", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xac8, "ddr_d8", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xacc, "ddr_d9", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xad0, "ddr_d10", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xad4, "ddr_d11", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xad8, "ddr_d12", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xadc, "ddr_d13", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xae0, "ddr_d14", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xae4, "ddr_d15", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xae8, "ddr_dqm0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xaec, "ddr_dqm1", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xaf0, "ddr_dqs0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xaf4, "ddr_dqsn0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xaf8, "ddr_dqs1", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xafc, "ddr_dqsn1", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb00, "ddr_vref", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb04, "ddr_vtp", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb08, "ddr_strben0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb0c, "ddr_strben1", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb2c, "ain0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb28, "ain1", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb24, "ain2", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb20, "ain3", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb1c, "ain4", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb18, "ain5", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb14, "ain6", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb10, "ain7", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb30, "vrefp", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb34, "vrefn", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb38, "avdd", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb3c, "avss", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb40, "iforce", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb44, "vsense", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PIN(0xb48, "testout", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x238, "ddr_resetn", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x23c, "ddr_csn0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x240, "ddr_cke", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x244, "ddr_ck", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x248, "ddr_nck", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x24c, "ddr_casn", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x250, "ddr_rasn", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x254, "ddr_wen", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x258, "ddr_ba0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x25c, "ddr_ba1", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x260, "ddr_ba2", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x264, "ddr_a0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x268, "ddr_a1", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x26c, "ddr_a2", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x270, "ddr_a3", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x274, "ddr_a4", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x278, "ddr_a5", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x27c, "ddr_a6", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x280, "ddr_a7", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x284, "ddr_a8", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x288, "ddr_a9", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x28c, "ddr_a10", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x290, "ddr_a11", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x294, "ddr_a12", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x298, "ddr_a13", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x29c, "ddr_a14", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2a0, "ddr_a15", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2a4, "ddr_odt", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2a8, "ddr_d0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2ac, "ddr_d1", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2b0, "ddr_d2", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2b4, "ddr_d3", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2b8, "ddr_d4", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2bc, "ddr_d5", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2c0, "ddr_d6", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2c4, "ddr_d7", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2c8, "ddr_d8", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2cc, "ddr_d9", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2d0, "ddr_d10", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2d4, "ddr_d11", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2d8, "ddr_d12", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2dc, "ddr_d13", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2e0, "ddr_d14", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2e4, "ddr_d15", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2e8, "ddr_dqm0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2ec, "ddr_dqm1", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2f0, "ddr_dqs0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2f4, "ddr_dqsn0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2f8, "ddr_dqs1", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x2fc, "ddr_dqsn1", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x300, "ddr_vref", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x304, "ddr_vtp", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x308, "ddr_strben0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x30c, "ddr_strben1", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x32c, "ain0", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x328, "ain1", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x324, "ain2", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x320, "ain3", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x31c, "ain4", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x318, "ain5", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x314, "ain6", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x310, "ain7", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x330, "vrefp", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x334, "vrefn", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x338, "avdd", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x33c, "avss", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x340, "iforce", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x344, "vsense", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PIN(0x348, "testout", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL),
#endif
{ .ballname = NULL },
};
-const struct ti_scm_device ti_scm_dev = {
+const struct ti_pinmux_device ti_pinmux_dev = {
.padconf_muxmode_mask = 0x7,
.padconf_sate_mask = 0x78,
.padstate = ti_padstate_devmap,
diff --git a/sys/arm/ti/am335x/am335x_usbss.c b/sys/arm/ti/am335x/am335x_usbss.c
index ea1b982..6ddc562 100644
--- a/sys/arm/ti/am335x/am335x_usbss.c
+++ b/sys/arm/ti/am335x/am335x_usbss.c
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
#include <sys/priv.h>
#include <dev/fdt/fdt_common.h>
+#include <dev/fdt/simplebus.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
@@ -58,8 +59,6 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb_process.h>
#include <dev/usb/usb_util.h>
-#define USB_DEBUG_VAR usbssdebug
-
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#include <dev/usb/controller/musb_otg.h>
@@ -97,164 +96,29 @@ __FBSDID("$FreeBSD$");
#define USBCTRL_MODE_IDDIG (1 << 8)
#define USBCTRL_MODE_IDDIGMUX (1 << 7)
-/* USBSS resource + 2 MUSB ports */
-
-#define RES_USBSS 0
-#define RES_USBCTRL(i) (3*i+1)
-#define RES_USBPHY(i) (3*i+2)
-#define RES_USBCORE(i) (3*i+3)
-
-#define USB_WRITE4(sc, idx, reg, val) do { \
- bus_write_4((sc)->sc_mem_res[idx], (reg), (val)); \
-} while (0)
-
-#define USB_READ4(sc, idx, reg) bus_read_4((sc)->sc_mem_res[idx], (reg))
-
#define USBSS_WRITE4(sc, reg, val) \
- USB_WRITE4((sc), RES_USBSS, (reg), (val))
+ bus_write_4((sc)->sc_mem_res, (reg), (val))
#define USBSS_READ4(sc, reg) \
- USB_READ4((sc), RES_USBSS, (reg))
-#define USBCTRL_WRITE4(sc, unit, reg, val) \
- USB_WRITE4((sc), RES_USBCTRL(unit), (reg), (val))
-#define USBCTRL_READ4(sc, unit, reg) \
- USB_READ4((sc), RES_USBCTRL(unit), (reg))
-#define USBPHY_WRITE4(sc, unit, reg, val) \
- USB_WRITE4((sc), RES_USBPHY(unit), (reg), (val))
-#define USBPHY_READ4(sc, unit, reg) \
- USB_READ4((sc), RES_USBPHY(unit), (reg))
-
-static struct resource_spec am335x_musbotg_mem_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
- { SYS_RES_MEMORY, 1, RF_ACTIVE },
- { SYS_RES_MEMORY, 2, RF_ACTIVE },
- { SYS_RES_MEMORY, 3, RF_ACTIVE },
- { SYS_RES_MEMORY, 4, RF_ACTIVE },
- { SYS_RES_MEMORY, 5, RF_ACTIVE },
- { SYS_RES_MEMORY, 6, RF_ACTIVE },
- { -1, 0, 0 }
-};
-
-static struct resource_spec am335x_musbotg_irq_spec[] = {
- { SYS_RES_IRQ, 0, RF_ACTIVE },
- { SYS_RES_IRQ, 1, RF_ACTIVE },
- { SYS_RES_IRQ, 2, RF_ACTIVE },
- { -1, 0, 0 }
-};
-
-#ifdef USB_DEBUG
-static int usbssdebug = 0;
+ bus_read_4((sc)->sc_mem_res, (reg))
-static SYSCTL_NODE(_hw_usb, OID_AUTO, am335x_usbss, CTLFLAG_RW, 0, "AM335x USBSS");
-SYSCTL_INT(_hw_usb_am335x_usbss, OID_AUTO, debug, CTLFLAG_RW,
- &usbssdebug, 0, "Debug level");
-#endif
+static device_probe_t usbss_probe;
+static device_attach_t usbss_attach;
+static device_detach_t usbss_detach;
-static device_probe_t musbotg_probe;
-static device_attach_t musbotg_attach;
-static device_detach_t musbotg_detach;
-
-struct musbotg_super_softc {
- struct musbotg_softc sc_otg[AM335X_USB_PORTS];
- struct resource *sc_mem_res[AM335X_USB_PORTS*3+1];
- struct resource *sc_irq_res[AM335X_USB_PORTS+1];
- void *sc_intr_hdl;
+struct usbss_softc {
+ struct simplebus_softc simplebus_sc;
+ struct resource *sc_mem_res;
+ int sc_mem_rid;
};
-static void
-musbotg_vbus_poll(struct musbotg_super_softc *sc, int port)
-{
- uint32_t stat;
-
- if (sc->sc_otg[port].sc_mode == MUSB2_DEVICE_MODE)
- musbotg_vbus_interrupt(&sc->sc_otg[port], 1);
- else {
- stat = USBCTRL_READ4(sc, port, USBCTRL_STAT);
- musbotg_vbus_interrupt(&sc->sc_otg[port], stat & 1);
- }
-}
-
-/*
- * Arg to musbotg_clocks_on and musbot_clocks_off is
- * a uint32_t * pointing to the SCM register offset.
- */
-static uint32_t USB_CTRL[] = {SCM_USB_CTRL0, SCM_USB_CTRL1};
-
-static void
-musbotg_clocks_on(void *arg)
-{
- uint32_t c, reg = *(uint32_t *)arg;
-
- ti_scm_reg_read_4(reg, &c);
- c &= ~3; /* Enable power */
- c |= 1 << 19; /* VBUS detect enable */
- c |= 1 << 20; /* Session end enable */
- ti_scm_reg_write_4(reg, c);
-}
-
-static void
-musbotg_clocks_off(void *arg)
-{
- uint32_t c, reg = *(uint32_t *)arg;
-
- /* Disable power to PHY */
- ti_scm_reg_read_4(reg, &c);
- ti_scm_reg_write_4(reg, c | 3);
-}
-
-static void
-musbotg_ep_int_set(struct musbotg_softc *sc, int ep, int on)
-{
- struct musbotg_super_softc *ssc = sc->sc_platform_data;
- uint32_t epmask;
-
- epmask = ((1 << ep) << IRQ_STAT0_RXSHIFT);
- epmask |= ((1 << ep) << IRQ_STAT0_TXSHIFT);
- if (on)
- USBCTRL_WRITE4(ssc, sc->sc_id,
- USBCTRL_INTEN_SET0, epmask);
- else
- USBCTRL_WRITE4(ssc, sc->sc_id,
- USBCTRL_INTEN_CLR0, epmask);
-}
-
-static void
-musbotg_usbss_interrupt(void *arg)
-{
- panic("USBSS real interrupt");
-}
-
-static void
-musbotg_wrapper_interrupt(void *arg)
-{
- struct musbotg_softc *sc = arg;
- struct musbotg_super_softc *ssc = sc->sc_platform_data;
- uint32_t stat, stat0, stat1;
- stat = USBCTRL_READ4(ssc, sc->sc_id, USBCTRL_STAT);
- stat0 = USBCTRL_READ4(ssc, sc->sc_id, USBCTRL_IRQ_STAT0);
- stat1 = USBCTRL_READ4(ssc, sc->sc_id, USBCTRL_IRQ_STAT1);
- if (stat0)
- USBCTRL_WRITE4(ssc, sc->sc_id, USBCTRL_IRQ_STAT0, stat0);
- if (stat1)
- USBCTRL_WRITE4(ssc, sc->sc_id, USBCTRL_IRQ_STAT1, stat1);
-
- DPRINTFN(4, "port%d: stat0=%08x stat1=%08x, stat=%08x\n",
- sc->sc_id, stat0, stat1, stat);
-
- if (stat1 & IRQ_STAT1_DRVVBUS)
- musbotg_vbus_interrupt(sc, stat & 1);
-
- musbotg_interrupt(arg, ((stat0 >> 16) & 0xffff),
- stat0 & 0xffff, stat1 & 0xff);
-}
-
static int
-musbotg_probe(device_t dev)
+usbss_probe(device_t dev)
{
if (!ofw_bus_status_okay(dev))
return (ENXIO);
- if (!ofw_bus_is_compatible(dev, "ti,musb-am33xx"))
+ if (!ofw_bus_is_compatible(dev, "ti,am33xx-usb"))
return (ENXIO);
device_set_desc(dev, "TI AM33xx integrated USB OTG controller");
@@ -263,31 +127,22 @@ musbotg_probe(device_t dev)
}
static int
-musbotg_attach(device_t dev)
+usbss_attach(device_t dev)
{
- struct musbotg_super_softc *sc = device_get_softc(dev);
- int err;
+ struct usbss_softc *sc = device_get_softc(dev);
int i;
- uint32_t rev, reg;
+ uint32_t rev;
+ phandle_t node;
/* Request the memory resources */
- err = bus_alloc_resources(dev, am335x_musbotg_mem_spec,
- sc->sc_mem_res);
- if (err) {
+ sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
+ &sc->sc_mem_rid, RF_ACTIVE);
+ if (sc->sc_mem_res == NULL) {
device_printf(dev,
"Error: could not allocate mem resources\n");
return (ENXIO);
}
- /* Request the IRQ resources */
- err = bus_alloc_resources(dev, am335x_musbotg_irq_spec,
- sc->sc_irq_res);
- if (err) {
- device_printf(dev,
- "Error: could not allocate irq resources\n");
- return (ENXIO);
- }
-
/* Enable device clocks. */
ti_prcm_clk_enable(MUSB0_CLK);
@@ -312,170 +167,50 @@ musbotg_attach(device_t dev)
device_printf(dev, "TI AM335X USBSS v%d.%d.%d\n",
(rev >> 8) & 7, (rev >> 6) & 3, rev & 63);
- err = bus_setup_intr(dev, sc->sc_irq_res[0],
- INTR_TYPE_BIO | INTR_MPSAFE,
- NULL, (driver_intr_t *)musbotg_usbss_interrupt, sc,
- &sc->sc_intr_hdl);
-
- if (err) {
- sc->sc_intr_hdl = NULL;
- device_printf(dev, "Failed to setup USBSS interrupt\n");
- goto error;
- }
-
- for (i = 0; i < AM335X_USB_PORTS; i++) {
- /* setup MUSB OTG USB controller interface softc */
- sc->sc_otg[i].sc_clocks_on = &musbotg_clocks_on;
- sc->sc_otg[i].sc_clocks_off = &musbotg_clocks_off;
- sc->sc_otg[i].sc_clocks_arg = &USB_CTRL[i];
-
- sc->sc_otg[i].sc_ep_int_set = musbotg_ep_int_set;
-
- /* initialise some bus fields */
- sc->sc_otg[i].sc_bus.parent = dev;
- sc->sc_otg[i].sc_bus.devices = sc->sc_otg[i].sc_devices;
- sc->sc_otg[i].sc_bus.devices_max = MUSB2_MAX_DEVICES;
- sc->sc_otg[i].sc_bus.dma_bits = 32;
-
- /* get all DMA memory */
- if (usb_bus_mem_alloc_all(&sc->sc_otg[i].sc_bus,
- USB_GET_DMA_TAG(dev), NULL)) {
- device_printf(dev,
- "Failed allocate bus mem for musb%d\n", i);
- return (ENOMEM);
- }
- sc->sc_otg[i].sc_io_res = sc->sc_mem_res[RES_USBCORE(i)];
- sc->sc_otg[i].sc_io_tag =
- rman_get_bustag(sc->sc_otg[i].sc_io_res);
- sc->sc_otg[i].sc_io_hdl =
- rman_get_bushandle(sc->sc_otg[i].sc_io_res);
- sc->sc_otg[i].sc_io_size =
- rman_get_size(sc->sc_otg[i].sc_io_res);
-
- sc->sc_otg[i].sc_irq_res = sc->sc_irq_res[i+1];
-
- sc->sc_otg[i].sc_bus.bdev = device_add_child(dev, "usbus", -1);
- if (!(sc->sc_otg[i].sc_bus.bdev)) {
- device_printf(dev, "No busdev for musb%d\n", i);
- goto error;
- }
- device_set_ivars(sc->sc_otg[i].sc_bus.bdev,
- &sc->sc_otg[i].sc_bus);
-
- err = bus_setup_intr(dev, sc->sc_otg[i].sc_irq_res,
- INTR_TYPE_BIO | INTR_MPSAFE,
- NULL, (driver_intr_t *)musbotg_wrapper_interrupt,
- &sc->sc_otg[i], &sc->sc_otg[i].sc_intr_hdl);
- if (err) {
- sc->sc_otg[i].sc_intr_hdl = NULL;
- device_printf(dev,
- "Failed to setup interrupt for musb%d\n", i);
- goto error;
- }
-
- sc->sc_otg[i].sc_id = i;
- sc->sc_otg[i].sc_platform_data = sc;
- if (i == 0)
- sc->sc_otg[i].sc_mode = MUSB2_DEVICE_MODE;
- else
- sc->sc_otg[i].sc_mode = MUSB2_HOST_MODE;
-
- /*
- * software-controlled function
- */
-
- if (sc->sc_otg[i].sc_mode == MUSB2_HOST_MODE) {
- reg = USBCTRL_READ4(sc, i, USBCTRL_MODE);
- reg |= USBCTRL_MODE_IDDIGMUX;
- reg &= ~USBCTRL_MODE_IDDIG;
- USBCTRL_WRITE4(sc, i, USBCTRL_MODE, reg);
- USBCTRL_WRITE4(sc, i, USBCTRL_UTMI,
- USBCTRL_UTMI_FSDATAEXT);
- } else {
- reg = USBCTRL_READ4(sc, i, USBCTRL_MODE);
- reg |= USBCTRL_MODE_IDDIGMUX;
- reg |= USBCTRL_MODE_IDDIG;
- USBCTRL_WRITE4(sc, i, USBCTRL_MODE, reg);
- }
-
- reg = USBCTRL_INTEN_USB_ALL & ~USBCTRL_INTEN_USB_SOF;
- USBCTRL_WRITE4(sc, i, USBCTRL_INTEN_SET1, reg);
- USBCTRL_WRITE4(sc, i, USBCTRL_INTEN_CLR0, 0xffffffff);
+ node = ofw_bus_get_node(dev);
- err = musbotg_init(&sc->sc_otg[i]);
- if (!err)
- err = device_probe_and_attach(sc->sc_otg[i].sc_bus.bdev);
+ if (node == -1) {
+ usbss_detach(dev);
+ return (ENXIO);
+ }
- if (err)
- goto error;
+ simplebus_init(dev, node);
- /* poll VBUS one time */
- musbotg_vbus_poll(sc, i);
- }
+ /*
+ * Allow devices to identify.
+ */
+ bus_generic_probe(dev);
- return (0);
+ /*
+ * Now walk the OFW tree and attach top-level devices.
+ */
+ for (node = OF_child(node); node > 0; node = OF_peer(node))
+ simplebus_add_device(dev, node, 0, NULL, -1, NULL);
-error:
- musbotg_detach(dev);
- return (ENXIO);
+ return (bus_generic_attach(dev));
}
static int
-musbotg_detach(device_t dev)
+usbss_detach(device_t dev)
{
- struct musbotg_super_softc *sc = device_get_softc(dev);
- device_t bdev;
- int err;
- int i;
-
- for (i = 0; i < AM335X_USB_PORTS; i++) {
- if (sc->sc_otg[i].sc_bus.bdev) {
- bdev = sc->sc_otg[i].sc_bus.bdev;
- device_detach(bdev);
- device_delete_child(dev, bdev);
- }
-
- if (sc->sc_otg[i].sc_irq_res && sc->sc_otg[i].sc_intr_hdl) {
- /*
- * only call musbotg_uninit() after musbotg_init()
- */
- musbotg_uninit(&sc->sc_otg[i]);
-
- err = bus_teardown_intr(dev, sc->sc_otg[i].sc_irq_res,
- sc->sc_otg[i].sc_intr_hdl);
- sc->sc_otg[i].sc_intr_hdl = NULL;
- }
-
- usb_bus_mem_free_all(&sc->sc_otg[i].sc_bus, NULL);
- }
-
- if (sc->sc_intr_hdl) {
- bus_teardown_intr(dev, sc->sc_irq_res[0],
- sc->sc_intr_hdl);
- sc->sc_intr_hdl = NULL;
- }
-
+ struct usbss_softc *sc = device_get_softc(dev);
/* Free resources if any */
- if (sc->sc_mem_res[0])
- bus_release_resources(dev, am335x_musbotg_mem_spec,
+ if (sc->sc_mem_res)
+ bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_mem_rid,
sc->sc_mem_res);
- if (sc->sc_irq_res[0])
- bus_release_resources(dev, am335x_musbotg_irq_spec,
- sc->sc_irq_res);
-
/* during module unload there are lots of children leftover */
device_delete_children(dev);
return (0);
}
-static device_method_t musbotg_methods[] = {
+static device_method_t usbss_methods[] = {
/* Device interface */
- DEVMETHOD(device_probe, musbotg_probe),
- DEVMETHOD(device_attach, musbotg_attach),
- DEVMETHOD(device_detach, musbotg_detach),
+ DEVMETHOD(device_probe, usbss_probe),
+ DEVMETHOD(device_attach, usbss_attach),
+ DEVMETHOD(device_detach, usbss_detach),
DEVMETHOD(device_suspend, bus_generic_suspend),
DEVMETHOD(device_resume, bus_generic_resume),
DEVMETHOD(device_shutdown, bus_generic_shutdown),
@@ -483,13 +218,8 @@ static device_method_t musbotg_methods[] = {
DEVMETHOD_END
};
-static driver_t musbotg_driver = {
- .name = "musbotg",
- .methods = musbotg_methods,
- .size = sizeof(struct musbotg_super_softc),
-};
-
-static devclass_t musbotg_devclass;
-
-DRIVER_MODULE(musbotg, simplebus, musbotg_driver, musbotg_devclass, 0, 0);
-MODULE_DEPEND(musbotg, usb, 1, 1, 1);
+DEFINE_CLASS_1(usbss, usbss_driver, usbss_methods,
+ sizeof(struct usbss_softc), simplebus_driver);
+static devclass_t usbss_devclass;
+DRIVER_MODULE(usbss, simplebus, usbss_driver, usbss_devclass, 0, 0);
+MODULE_DEPEND(usbss, usb, 1, 1, 1);
diff --git a/sys/arm/ti/am335x/files.am335x b/sys/arm/ti/am335x/files.am335x
index aee414f..277ee52 100644
--- a/sys/arm/ti/am335x/files.am335x
+++ b/sys/arm/ti/am335x/files.am335x
@@ -8,10 +8,13 @@ arm/ti/am335x/am335x_lcd.c optional sc | vt
arm/ti/am335x/am335x_lcd_syscons.c optional sc
arm/ti/am335x/am335x_pmic.c optional am335x_pmic
arm/ti/am335x/am335x_prcm.c standard
-arm/ti/am335x/am335x_pwm.c standard
+arm/ti/am335x/am335x_pwmss.c standard
+arm/ti/am335x/am335x_ehrpwm.c standard
+arm/ti/am335x/am335x_ecap.c standard
arm/ti/am335x/am335x_rtc.c optional am335x_rtc
arm/ti/am335x/am335x_scm_padconf.c standard
arm/ti/am335x/am335x_usbss.c optional musb fdt
+arm/ti/am335x/am335x_musb.c optional musb fdt
arm/ti/ti_edma3.c standard
arm/ti/cpsw/if_cpsw.c optional cpsw
diff --git a/sys/arm/ti/cpsw/if_cpsw.c b/sys/arm/ti/cpsw/if_cpsw.c
index 49e3065..a27393d 100644
--- a/sys/arm/ti/cpsw/if_cpsw.c
+++ b/sys/arm/ti/cpsw/if_cpsw.c
@@ -113,6 +113,7 @@ static int cpsw_ioctl(struct ifnet *, u_long command, caddr_t data);
static int cpsw_miibus_readreg(device_t, int phy, int reg);
static int cpsw_miibus_writereg(device_t, int phy, int reg, int value);
+static void cpsw_miibus_statchg(device_t);
/* Send/Receive packets. */
static void cpsw_intr_rx(void *arg);
@@ -179,6 +180,7 @@ static device_method_t cpsw_methods[] = {
/* MII interface */
DEVMETHOD(miibus_readreg, cpsw_miibus_readreg),
DEVMETHOD(miibus_writereg, cpsw_miibus_writereg),
+ DEVMETHOD(miibus_statchg, cpsw_miibus_statchg),
{ 0, 0 }
};
@@ -195,8 +197,7 @@ DRIVER_MODULE(miibus, cpsw, miibus_driver, miibus_devclass, 0, 0);
MODULE_DEPEND(cpsw, ether, 1, 1, 1);
MODULE_DEPEND(cpsw, miibus, 1, 1, 1);
-static struct resource_spec res_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
+static struct resource_spec irq_res_spec[] = {
{ SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE },
{ SYS_RES_IRQ, 1, RF_ACTIVE | RF_SHAREABLE },
{ SYS_RES_IRQ, 2, RF_ACTIVE | RF_SHAREABLE },
@@ -322,21 +323,21 @@ cpsw_debugf(const char *fmt, ...)
/*
* Read/Write macros
*/
-#define cpsw_read_4(sc, reg) bus_read_4(sc->res[0], reg)
-#define cpsw_write_4(sc, reg, val) bus_write_4(sc->res[0], reg, val)
+#define cpsw_read_4(sc, reg) bus_read_4(sc->mem_res, reg)
+#define cpsw_write_4(sc, reg, val) bus_write_4(sc->mem_res, reg, val)
#define cpsw_cpdma_bd_offset(i) (CPSW_CPPI_RAM_OFFSET + ((i)*16))
#define cpsw_cpdma_bd_paddr(sc, slot) \
- BUS_SPACE_PHYSADDR(sc->res[0], slot->bd_offset)
+ BUS_SPACE_PHYSADDR(sc->mem_res, slot->bd_offset)
#define cpsw_cpdma_read_bd(sc, slot, val) \
- bus_read_region_4(sc->res[0], slot->bd_offset, (uint32_t *) val, 4)
+ bus_read_region_4(sc->mem_res, slot->bd_offset, (uint32_t *) val, 4)
#define cpsw_cpdma_write_bd(sc, slot, val) \
- bus_write_region_4(sc->res[0], slot->bd_offset, (uint32_t *) val, 4)
+ bus_write_region_4(sc->mem_res, slot->bd_offset, (uint32_t *) val, 4)
#define cpsw_cpdma_write_bd_next(sc, slot, next_slot) \
cpsw_write_4(sc, slot->bd_offset, cpsw_cpdma_bd_paddr(sc, next_slot))
#define cpsw_cpdma_read_bd_flags(sc, slot) \
- bus_read_2(sc->res[0], slot->bd_offset + 14)
+ bus_read_2(sc->mem_res, slot->bd_offset + 14)
#define cpsw_write_hdp_slot(sc, queue, slot) \
cpsw_write_4(sc, (queue)->hdp_offset, cpsw_cpdma_bd_paddr(sc, slot))
#define CP_OFFSET (CPSW_CPDMA_TX_CP(0) - CPSW_CPDMA_TX_HDP(0))
@@ -549,9 +550,12 @@ cpsw_attach(device_t dev)
struct cpsw_softc *sc = device_get_softc(dev);
struct mii_softc *miisc;
struct ifnet *ifp;
- void *phy_sc;
- int error, phy, nsegs;
+ int phy, nsegs, error;
uint32_t reg;
+ pcell_t phy_id[3];
+ u_long mem_base, mem_size;
+ phandle_t child;
+ int len;
CPSW_DEBUGF((""));
@@ -559,21 +563,58 @@ cpsw_attach(device_t dev)
sc->dev = dev;
sc->node = ofw_bus_get_node(dev);
- /* Get phy address from fdt */
- if (fdt_get_phyaddr(sc->node, sc->dev, &phy, &phy_sc) != 0) {
+ /* TODO: handle multiple slaves */
+ phy = -1;
+
+ /* Find any slave with phy_id */
+ for (child = OF_child(sc->node); child != 0; child = OF_peer(child)) {
+ len = OF_getproplen(child, "phy_id");
+ if (len <= 0)
+ continue;
+
+ /* Get phy address from fdt */
+ if (OF_getencprop(child, "phy_id", phy_id, len) <= 0)
+ continue;
+
+ phy = phy_id[1];
+ /* TODO: get memory window for MDIO */
+
+ break;
+ }
+
+ if (phy == -1) {
device_printf(dev, "failed to get PHY address from FDT\n");
return (ENXIO);
}
+
+ mem_base = 0;
+ mem_size = 0;
+
+ if (fdt_regsize(sc->node, &mem_base, &mem_size) != 0) {
+ device_printf(sc->dev, "no regs property in cpsw node\n");
+ return (ENXIO);
+ }
+
/* Initialize mutexes */
mtx_init(&sc->tx.lock, device_get_nameunit(dev),
"cpsw TX lock", MTX_DEF);
mtx_init(&sc->rx.lock, device_get_nameunit(dev),
"cpsw RX lock", MTX_DEF);
- /* Allocate IO and IRQ resources */
- error = bus_alloc_resources(dev, res_spec, sc->res);
+ /* Allocate IRQ resources */
+ error = bus_alloc_resources(dev, irq_res_spec, sc->irq_res);
if (error) {
- device_printf(dev, "could not allocate resources\n");
+ device_printf(dev, "could not allocate IRQ resources\n");
+ cpsw_detach(dev);
+ return (ENXIO);
+ }
+
+ sc->mem_rid = 0;
+ sc->mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY,
+ &sc->mem_rid, mem_base, mem_base + CPSW_MEMWINDOW_SIZE -1,
+ CPSW_MEMWINDOW_SIZE, RF_ACTIVE);
+ if (sc->mem_res == NULL) {
+ device_printf(sc->dev, "failed to allocate memory resource\n");
cpsw_detach(dev);
return (ENXIO);
}
@@ -690,11 +731,11 @@ cpsw_attach(device_t dev)
cpsw_write_4(sc, MDIOUSERPHYSEL0, 1 << 6 | (miisc->mii_phy & 0x1F));
/* Note: We don't use sc->res[3] (TX interrupt) */
- if (cpsw_attach_interrupt(sc, sc->res[1],
+ if (cpsw_attach_interrupt(sc, sc->irq_res[0],
cpsw_intr_rx_thresh, "CPSW RX threshold interrupt") ||
- cpsw_attach_interrupt(sc, sc->res[2],
+ cpsw_attach_interrupt(sc, sc->irq_res[1],
cpsw_intr_rx, "CPSW RX interrupt") ||
- cpsw_attach_interrupt(sc, sc->res[4],
+ cpsw_attach_interrupt(sc, sc->irq_res[3],
cpsw_intr_misc, "CPSW misc interrupt")) {
cpsw_detach(dev);
return (ENXIO);
@@ -761,7 +802,8 @@ cpsw_detach(device_t dev)
KASSERT(error == 0, ("Unable to destroy DMA tag"));
/* Free IO memory handler */
- bus_release_resources(dev, res_spec, sc->res);
+ bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, sc->mem_res);
+ bus_release_resources(dev, irq_res_spec, sc->irq_res);
if (sc->ifp != NULL)
if_free(sc->ifp);
@@ -1225,6 +1267,36 @@ cpsw_miibus_writereg(device_t dev, int phy, int reg, int value)
return 0;
}
+static void
+cpsw_miibus_statchg(device_t dev)
+{
+ struct cpsw_softc *sc = device_get_softc(dev);
+ uint32_t mac_control;
+ int i;
+
+ CPSW_DEBUGF((""));
+
+ for (i = 0; i < 2; i++) {
+ mac_control = cpsw_read_4(sc, CPSW_SL_MACCONTROL(i));
+ mac_control &= ~(1 << 15 | 1 << 7);
+
+ switch(IFM_SUBTYPE(sc->mii->mii_media_active)) {
+ case IFM_1000_SX:
+ case IFM_1000_LX:
+ case IFM_1000_CX:
+ case IFM_1000_T:
+ mac_control |= 1 << 7;
+ break;
+
+ default:
+ mac_control |= 1 << 15;
+ break;
+ }
+
+ cpsw_write_4(sc, CPSW_SL_MACCONTROL(i), mac_control);
+ }
+}
+
/*
*
* Transmit/Receive Packets.
diff --git a/sys/arm/ti/cpsw/if_cpswreg.h b/sys/arm/ti/cpsw/if_cpswreg.h
index 46f8417..98d6033 100644
--- a/sys/arm/ti/cpsw/if_cpswreg.h
+++ b/sys/arm/ti/cpsw/if_cpswreg.h
@@ -118,6 +118,8 @@
#define CPSW_CPPI_RAM_OFFSET 0x2000
#define CPSW_CPPI_RAM_SIZE 0x2000
+#define CPSW_MEMWINDOW_SIZE 0x4000
+
#define CPDMA_BD_SOP (1<<15)
#define CPDMA_BD_EOP (1<<14)
#define CPDMA_BD_OWNER (1<<13)
diff --git a/sys/arm/ti/cpsw/if_cpswvar.h b/sys/arm/ti/cpsw/if_cpswvar.h
index 2aebb0f..fbd7de5 100644
--- a/sys/arm/ti/cpsw/if_cpswvar.h
+++ b/sys/arm/ti/cpsw/if_cpswvar.h
@@ -78,7 +78,9 @@ struct cpsw_softc {
device_t miibus;
struct mii_data *mii;
/* We expect 1 memory resource and 4 interrupts from the device tree. */
- struct resource *res[1 + CPSW_INTR_COUNT];
+ struct resource *mem_res;
+ int mem_rid;
+ struct resource *irq_res[CPSW_INTR_COUNT];
/* Interrupts get recorded here as we initialize them. */
/* Interrupt teardown just walks this list. */
diff --git a/sys/arm/ti/files.ti b/sys/arm/ti/files.ti
index 2be467e..c97f71b 100644
--- a/sys/arm/ti/files.ti
+++ b/sys/arm/ti/files.ti
@@ -9,9 +9,11 @@ arm/arm/pmu.c optional hwpmc
arm/ti/ti_common.c standard
arm/ti/ti_cpuid.c standard
+arm/ti/ti_hwmods.c standard
arm/ti/ti_machdep.c standard
arm/ti/ti_prcm.c standard
arm/ti/ti_scm.c standard
+arm/ti/ti_pinmux.c standard
dev/mbox/mbox_if.m optional ti_mbox
arm/ti/ti_mbox.c optional ti_mbox
arm/ti/ti_pruss.c optional ti_pruss
diff --git a/sys/arm/ti/omap4/files.omap4 b/sys/arm/ti/omap4/files.omap4
index 22d7aeb..9f0fc76 100644
--- a/sys/arm/ti/omap4/files.omap4
+++ b/sys/arm/ti/omap4/files.omap4
@@ -1,10 +1,11 @@
#$FreeBSD$
-arm/arm/gic.c standard
arm/arm/mpcore_timer.c standard
arm/ti/ti_smc.S standard
arm/ti/usb/omap_ehci.c optional usb ehci
+arm/ti/usb/omap_host.c optional usb
+arm/ti/usb/omap_tll.c optional usb
arm/ti/ti_sdma.c optional ti_sdma
arm/ti/omap4/omap4_gpio.c optional gpio
diff --git a/sys/arm/ti/omap4/omap4_gpio.c b/sys/arm/ti/omap4/omap4_gpio.c
index 9831f4e..dc32298 100644
--- a/sys/arm/ti/omap4/omap4_gpio.c
+++ b/sys/arm/ti/omap4/omap4_gpio.c
@@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
#include <arm/ti/ti_cpuid.h>
#include <arm/ti/ti_gpio.h>
-#include <arm/ti/ti_scm.h>
+#include <arm/ti/ti_pinmux.h>
#include <arm/ti/omap4/omap4_scm_padconf.h>
@@ -77,6 +77,9 @@ static int
omap4_gpio_set_flags(device_t dev, uint32_t gpio, uint32_t flags)
{
unsigned int state = 0;
+ struct ti_gpio_softc *sc;
+
+ sc = device_get_softc(dev);
/* First the SCM driver needs to be told to put the pad into GPIO mode */
if (flags & GPIO_PIN_OUTPUT)
state = PADCONF_PIN_OUTPUT;
@@ -88,16 +91,19 @@ omap4_gpio_set_flags(device_t dev, uint32_t gpio, uint32_t flags)
else
state = PADCONF_PIN_INPUT;
}
- return ti_scm_padconf_set_gpiomode(gpio, state);
+ return ti_pinmux_padconf_set_gpiomode((sc->sc_bank-1)*32 + gpio, state);
}
static int
omap4_gpio_get_flags(device_t dev, uint32_t gpio, uint32_t *flags)
{
unsigned int state;
+ struct ti_gpio_softc *sc;
+
+ sc = device_get_softc(dev);
/* Get the current pin state */
- if (ti_scm_padconf_get_gpiomode(gpio, &state) != 0) {
+ if (ti_pinmux_padconf_get_gpiomode((sc->sc_bank-1)*32 + gpio, &state) != 0) {
*flags = 0;
return (EINVAL);
} else {
diff --git a/sys/arm/ti/omap4/omap4_prcm_clks.c b/sys/arm/ti/omap4/omap4_prcm_clks.c
index 5a8a327..8b1cb6e 100644
--- a/sys/arm/ti/omap4/omap4_prcm_clks.c
+++ b/sys/arm/ti/omap4/omap4_prcm_clks.c
@@ -93,17 +93,9 @@ __FBSDID("$FreeBSD$");
#define FREQ_48MHZ 48000000
#define FREQ_32KHZ 32000
-/**
- * We need three memory regions to cover all the clock configuration registers.
- *
- * PRM Instance - 0x4A30 6000 : 0x4A30 8000
- * CM1 Instance - 0x4A00 4000 : 0x4A00 5000
- * CM2 Instance - 0x4A00 8000 : 0x4A00 A000
- *
- */
-#define PRM_INSTANCE_MEM_REGION 0
-#define CM1_INSTANCE_MEM_REGION 1
-#define CM2_INSTANCE_MEM_REGION 2
+#define PRM_INSTANCE 1
+#define CM1_INSTANCE 2
+#define CM2_INSTANCE 3
/**
* Address offsets from the PRM memory region to the top level clock control
@@ -174,19 +166,19 @@ __FBSDID("$FreeBSD$");
#define CLKCTRL_IDLEST_IDLE 0x00020000UL
#define CLKCTRL_IDLEST_DISABLED 0x00030000UL
-static struct resource_spec omap4_scm_res_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE }, /* Control memory window */
- { SYS_RES_MEMORY, 1, RF_ACTIVE }, /* Control memory window */
- { SYS_RES_MEMORY, 2, RF_ACTIVE }, /* Control memory window */
- { -1, 0 }
+static struct ofw_compat_data compat_data[] = {
+ {"ti,omap4-cm1", (uintptr_t)CM1_INSTANCE},
+ {"ti,omap4-cm2", (uintptr_t)CM2_INSTANCE},
+ {"ti,omap4-prm", (uintptr_t)PRM_INSTANCE},
+ {NULL, (uintptr_t)0},
};
struct omap4_prcm_softc {
- struct resource *sc_res[3];
+ struct resource *sc_res;
+ int sc_rid;
+ int sc_instance;
};
-static struct omap4_prcm_softc *omap4_prcm_sc;
-
static int omap4_clk_generic_activate(struct ti_clock_dev *clkdev);
static int omap4_clk_generic_deactivate(struct ti_clock_dev *clkdev);
static int omap4_clk_generic_accessible(struct ti_clock_dev *clkdev);
@@ -283,17 +275,17 @@ struct ti_clock_dev ti_omap4_clk_devmap[] = {
OMAP4_GENERIC_CLOCK_DEV(UART4_CLK),
/* Timer device source clocks */
- OMAP4_GPTIMER_CLOCK_DEV(GPTIMER1_CLK),
- OMAP4_GPTIMER_CLOCK_DEV(GPTIMER2_CLK),
- OMAP4_GPTIMER_CLOCK_DEV(GPTIMER3_CLK),
- OMAP4_GPTIMER_CLOCK_DEV(GPTIMER4_CLK),
- OMAP4_GPTIMER_CLOCK_DEV(GPTIMER5_CLK),
- OMAP4_GPTIMER_CLOCK_DEV(GPTIMER6_CLK),
- OMAP4_GPTIMER_CLOCK_DEV(GPTIMER7_CLK),
- OMAP4_GPTIMER_CLOCK_DEV(GPTIMER8_CLK),
- OMAP4_GPTIMER_CLOCK_DEV(GPTIMER9_CLK),
- OMAP4_GPTIMER_CLOCK_DEV(GPTIMER10_CLK),
- OMAP4_GPTIMER_CLOCK_DEV(GPTIMER11_CLK),
+ OMAP4_GPTIMER_CLOCK_DEV(TIMER1_CLK),
+ OMAP4_GPTIMER_CLOCK_DEV(TIMER2_CLK),
+ OMAP4_GPTIMER_CLOCK_DEV(TIMER3_CLK),
+ OMAP4_GPTIMER_CLOCK_DEV(TIMER4_CLK),
+ OMAP4_GPTIMER_CLOCK_DEV(TIMER5_CLK),
+ OMAP4_GPTIMER_CLOCK_DEV(TIMER6_CLK),
+ OMAP4_GPTIMER_CLOCK_DEV(TIMER7_CLK),
+ OMAP4_GPTIMER_CLOCK_DEV(TIMER8_CLK),
+ OMAP4_GPTIMER_CLOCK_DEV(TIMER9_CLK),
+ OMAP4_GPTIMER_CLOCK_DEV(TIMER10_CLK),
+ OMAP4_GPTIMER_CLOCK_DEV(TIMER11_CLK),
/* MMC device clocks (MMC1 and MMC2 can have different input clocks) */
OMAP4_HSMMC_CLOCK_DEV(MMC1_CLK),
@@ -344,7 +336,7 @@ struct ti_clock_dev ti_omap4_clk_devmap[] = {
struct omap4_clk_details {
clk_ident_t id;
- uint32_t mem_region;
+ uint32_t instance;
uint32_t clksel_reg;
int32_t src_freq;
@@ -352,9 +344,9 @@ struct omap4_clk_details {
uint32_t enable_mode;
};
-#define OMAP4_GENERIC_CLOCK_DETAILS(i, f, m, r, e) \
+#define OMAP4_GENERIC_CLOCK_DETAILS(i, f, di, r, e) \
{ .id = (i), \
- .mem_region = (m), \
+ .instance = (di), \
.clksel_reg = (r), \
.src_freq = (f), \
.enable_mode = (e), \
@@ -363,77 +355,77 @@ struct omap4_clk_details {
static struct omap4_clk_details g_omap4_clk_details[] = {
/* UART */
- OMAP4_GENERIC_CLOCK_DETAILS(UART1_CLK, FREQ_48MHZ, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(UART1_CLK, FREQ_48MHZ, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x0140), CLKCTRL_MODULEMODE_ENABLE),
- OMAP4_GENERIC_CLOCK_DETAILS(UART2_CLK, FREQ_48MHZ, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(UART2_CLK, FREQ_48MHZ, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x0148), CLKCTRL_MODULEMODE_ENABLE),
- OMAP4_GENERIC_CLOCK_DETAILS(UART3_CLK, FREQ_48MHZ, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(UART3_CLK, FREQ_48MHZ, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x0140), CLKCTRL_MODULEMODE_ENABLE),
- OMAP4_GENERIC_CLOCK_DETAILS(UART4_CLK, FREQ_48MHZ, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(UART4_CLK, FREQ_48MHZ, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x0148), CLKCTRL_MODULEMODE_ENABLE),
/* General purpose timers */
- OMAP4_GENERIC_CLOCK_DETAILS(GPTIMER1_CLK, -1, PRM_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(TIMER1_CLK, -1, PRM_INSTANCE,
(WKUP_CM_OFFSET + 0x040), CLKCTRL_MODULEMODE_ENABLE),
- OMAP4_GENERIC_CLOCK_DETAILS(GPTIMER2_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(TIMER2_CLK, -1, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x038), CLKCTRL_MODULEMODE_ENABLE),
- OMAP4_GENERIC_CLOCK_DETAILS(GPTIMER3_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(TIMER3_CLK, -1, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x040), CLKCTRL_MODULEMODE_ENABLE),
- OMAP4_GENERIC_CLOCK_DETAILS(GPTIMER4_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(TIMER4_CLK, -1, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x048), CLKCTRL_MODULEMODE_ENABLE),
- OMAP4_GENERIC_CLOCK_DETAILS(GPTIMER5_CLK, -1, CM1_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(TIMER5_CLK, -1, CM1_INSTANCE,
(ABE_CM1_OFFSET + 0x068), CLKCTRL_MODULEMODE_ENABLE),
- OMAP4_GENERIC_CLOCK_DETAILS(GPTIMER6_CLK, -1, CM1_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(TIMER6_CLK, -1, CM1_INSTANCE,
(ABE_CM1_OFFSET + 0x070), CLKCTRL_MODULEMODE_ENABLE),
- OMAP4_GENERIC_CLOCK_DETAILS(GPTIMER7_CLK, -1, CM1_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(TIMER7_CLK, -1, CM1_INSTANCE,
(ABE_CM1_OFFSET + 0x078), CLKCTRL_MODULEMODE_ENABLE),
- OMAP4_GENERIC_CLOCK_DETAILS(GPTIMER8_CLK, -1, CM1_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(TIMER8_CLK, -1, CM1_INSTANCE,
(ABE_CM1_OFFSET + 0x080), CLKCTRL_MODULEMODE_ENABLE),
- OMAP4_GENERIC_CLOCK_DETAILS(GPTIMER9_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(TIMER9_CLK, -1, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x050), CLKCTRL_MODULEMODE_ENABLE),
- OMAP4_GENERIC_CLOCK_DETAILS(GPTIMER10_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(TIMER10_CLK, -1, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x028), CLKCTRL_MODULEMODE_ENABLE),
- OMAP4_GENERIC_CLOCK_DETAILS(GPTIMER11_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(TIMER11_CLK, -1, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x030), CLKCTRL_MODULEMODE_ENABLE),
/* HSMMC (MMC1 and MMC2 can have different input clocks) */
- OMAP4_GENERIC_CLOCK_DETAILS(MMC1_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(MMC1_CLK, -1, CM2_INSTANCE,
(L3INIT_CM2_OFFSET + 0x028), /*CLKCTRL_MODULEMODE_ENABLE*/2),
- OMAP4_GENERIC_CLOCK_DETAILS(MMC2_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(MMC2_CLK, -1, CM2_INSTANCE,
(L3INIT_CM2_OFFSET + 0x030), /*CLKCTRL_MODULEMODE_ENABLE*/2),
- OMAP4_GENERIC_CLOCK_DETAILS(MMC3_CLK, FREQ_48MHZ, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(MMC3_CLK, FREQ_48MHZ, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x120), /*CLKCTRL_MODULEMODE_ENABLE*/2),
- OMAP4_GENERIC_CLOCK_DETAILS(MMC4_CLK, FREQ_48MHZ, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(MMC4_CLK, FREQ_48MHZ, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x128), /*CLKCTRL_MODULEMODE_ENABLE*/2),
- OMAP4_GENERIC_CLOCK_DETAILS(MMC5_CLK, FREQ_48MHZ, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(MMC5_CLK, FREQ_48MHZ, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x160), /*CLKCTRL_MODULEMODE_ENABLE*/1),
/* GPIO modules */
- OMAP4_GENERIC_CLOCK_DETAILS(GPIO1_CLK, -1, PRM_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(GPIO1_CLK, -1, PRM_INSTANCE,
(WKUP_CM_OFFSET + 0x038), CLKCTRL_MODULEMODE_AUTO),
- OMAP4_GENERIC_CLOCK_DETAILS(GPIO2_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(GPIO2_CLK, -1, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x060), CLKCTRL_MODULEMODE_AUTO),
- OMAP4_GENERIC_CLOCK_DETAILS(GPIO3_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(GPIO3_CLK, -1, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x068), CLKCTRL_MODULEMODE_AUTO),
- OMAP4_GENERIC_CLOCK_DETAILS(GPIO4_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(GPIO4_CLK, -1, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x070), CLKCTRL_MODULEMODE_AUTO),
- OMAP4_GENERIC_CLOCK_DETAILS(GPIO5_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(GPIO5_CLK, -1, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x078), CLKCTRL_MODULEMODE_AUTO),
- OMAP4_GENERIC_CLOCK_DETAILS(GPIO6_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(GPIO6_CLK, -1, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x080), CLKCTRL_MODULEMODE_AUTO),
/* sDMA block */
- OMAP4_GENERIC_CLOCK_DETAILS(SDMA_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(SDMA_CLK, -1, CM2_INSTANCE,
(CORE_CM2_OFFSET + 0x300), CLKCTRL_MODULEMODE_AUTO),
/* I2C modules */
- OMAP4_GENERIC_CLOCK_DETAILS(I2C1_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(I2C1_CLK, -1, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x0A0), CLKCTRL_MODULEMODE_ENABLE),
- OMAP4_GENERIC_CLOCK_DETAILS(I2C2_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(I2C2_CLK, -1, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x0A8), CLKCTRL_MODULEMODE_ENABLE),
- OMAP4_GENERIC_CLOCK_DETAILS(I2C3_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(I2C3_CLK, -1, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x0B0), CLKCTRL_MODULEMODE_ENABLE),
- OMAP4_GENERIC_CLOCK_DETAILS(I2C4_CLK, -1, CM2_INSTANCE_MEM_REGION,
+ OMAP4_GENERIC_CLOCK_DETAILS(I2C4_CLK, -1, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x0B8), CLKCTRL_MODULEMODE_ENABLE),
{ INVALID_CLK_IDENT, 0, 0, 0, 0 },
@@ -474,6 +466,27 @@ omap4_clk_details(clk_ident_t id)
return NULL;
}
+
+static struct omap4_prcm_softc *
+omap4_prcm_get_instance_softc(int module_instance)
+{
+ int i, maxunit;
+ devclass_t prcm_devclass;
+ device_t dev;
+ struct omap4_prcm_softc *sc;
+
+ prcm_devclass = devclass_find("omap4_prcm");
+ maxunit = devclass_get_maxunit(prcm_devclass);
+
+ for (i = 0; i < maxunit; i++) {
+ dev = devclass_get_device(prcm_devclass, i);
+ sc = device_get_softc(dev);
+ if (sc->sc_instance == module_instance)
+ return (sc);
+ }
+
+ return (NULL);
+}
/**
* omap4_clk_generic_activate - checks if a module is accessible
@@ -492,21 +505,21 @@ omap4_clk_details(clk_ident_t id)
static int
omap4_clk_generic_activate(struct ti_clock_dev *clkdev)
{
- struct omap4_prcm_softc *sc = omap4_prcm_sc;
+ struct omap4_prcm_softc *sc;
struct omap4_clk_details* clk_details;
struct resource* clk_mem_res;
uint32_t clksel;
unsigned int i;
-
- if (sc == NULL)
- return ENXIO;
-
clk_details = omap4_clk_details(clkdev->id);
if (clk_details == NULL)
return (ENXIO);
- clk_mem_res = sc->sc_res[clk_details->mem_region];
+ sc = omap4_prcm_get_instance_softc(clk_details->instance);
+ if (sc == NULL)
+ return ENXIO;
+
+ clk_mem_res = sc->sc_res;
if (clk_mem_res == NULL)
return (EINVAL);
@@ -558,20 +571,21 @@ omap4_clk_generic_activate(struct ti_clock_dev *clkdev)
static int
omap4_clk_generic_deactivate(struct ti_clock_dev *clkdev)
{
- struct omap4_prcm_softc *sc = omap4_prcm_sc;
+ struct omap4_prcm_softc *sc;
struct omap4_clk_details* clk_details;
struct resource* clk_mem_res;
uint32_t clksel;
- if (sc == NULL)
- return ENXIO;
-
clk_details = omap4_clk_details(clkdev->id);
if (clk_details == NULL)
return (ENXIO);
- clk_mem_res = sc->sc_res[clk_details->mem_region];
+ sc = omap4_prcm_get_instance_softc(clk_details->instance);
+ if (sc == NULL)
+ return ENXIO;
+
+ clk_mem_res = sc->sc_res;
if (clk_mem_res == NULL)
return (EINVAL);
@@ -626,20 +640,21 @@ omap4_clk_generic_set_source(struct ti_clock_dev *clkdev,
static int
omap4_clk_generic_accessible(struct ti_clock_dev *clkdev)
{
- struct omap4_prcm_softc *sc = omap4_prcm_sc;
+ struct omap4_prcm_softc *sc;
struct omap4_clk_details* clk_details;
struct resource* clk_mem_res;
uint32_t clksel;
- if (sc == NULL)
- return ENXIO;
-
clk_details = omap4_clk_details(clkdev->id);
if (clk_details == NULL)
return (ENXIO);
- clk_mem_res = sc->sc_res[clk_details->mem_region];
+ sc = omap4_prcm_get_instance_softc(clk_details->instance);
+ if (sc == NULL)
+ return ENXIO;
+
+ clk_mem_res = sc->sc_res;
if (clk_mem_res == NULL)
return (EINVAL);
@@ -703,19 +718,20 @@ static int
omap4_clk_gptimer_set_source(struct ti_clock_dev *clkdev,
clk_src_t clksrc)
{
- struct omap4_prcm_softc *sc = omap4_prcm_sc;
+ struct omap4_prcm_softc *sc;
struct omap4_clk_details* clk_details;
struct resource* clk_mem_res;
- if (sc == NULL)
- return ENXIO;
-
clk_details = omap4_clk_details(clkdev->id);
if (clk_details == NULL)
return (ENXIO);
- clk_mem_res = sc->sc_res[clk_details->mem_region];
+ sc = omap4_prcm_get_instance_softc(clk_details->instance);
+ if (sc == NULL)
+ return ENXIO;
+
+ clk_mem_res = sc->sc_res;
if (clk_mem_res == NULL)
return (EINVAL);
@@ -744,21 +760,22 @@ omap4_clk_gptimer_get_source_freq(struct ti_clock_dev *clkdev,
unsigned int *freq
)
{
- struct omap4_prcm_softc *sc = omap4_prcm_sc;
+ struct omap4_prcm_softc *sc;
struct omap4_clk_details* clk_details;
struct resource* clk_mem_res;
uint32_t clksel;
unsigned int src_freq;
- if (sc == NULL)
- return ENXIO;
-
clk_details = omap4_clk_details(clkdev->id);
if (clk_details == NULL)
return (ENXIO);
- clk_mem_res = sc->sc_res[clk_details->mem_region];
+ sc = omap4_prcm_get_instance_softc(clk_details->instance);
+ if (sc == NULL)
+ return ENXIO;
+
+ clk_mem_res = sc->sc_res;
if (clk_mem_res == NULL)
return (EINVAL);
@@ -793,20 +810,22 @@ static int
omap4_clk_hsmmc_set_source(struct ti_clock_dev *clkdev,
clk_src_t clksrc)
{
- struct omap4_prcm_softc *sc = omap4_prcm_sc;
+ struct omap4_prcm_softc *sc;
struct omap4_clk_details* clk_details;
struct resource* clk_mem_res;
uint32_t clksel;
- if (sc == NULL)
- return ENXIO;
-
clk_details = omap4_clk_details(clkdev->id);
if (clk_details == NULL)
return (ENXIO);
- clk_mem_res = sc->sc_res[clk_details->mem_region];
+
+ sc = omap4_prcm_get_instance_softc(clk_details->instance);
+ if (sc == NULL)
+ return ENXIO;
+
+ clk_mem_res = sc->sc_res;
if (clk_mem_res == NULL)
return (EINVAL);
@@ -852,21 +871,22 @@ omap4_clk_hsmmc_get_source_freq(struct ti_clock_dev *clkdev,
unsigned int *freq
)
{
- struct omap4_prcm_softc *sc = omap4_prcm_sc;
+ struct omap4_prcm_softc *sc;
struct omap4_clk_details* clk_details;
struct resource* clk_mem_res;
uint32_t clksel;
unsigned int src_freq;
- if (sc == NULL)
- return ENXIO;
-
clk_details = omap4_clk_details(clkdev->id);
if (clk_details == NULL)
return (ENXIO);
- clk_mem_res = sc->sc_res[clk_details->mem_region];
+ sc = omap4_prcm_get_instance_softc(clk_details->instance);
+ if (sc == NULL)
+ return ENXIO;
+
+ clk_mem_res = sc->sc_res;
if (clk_mem_res == NULL)
return (EINVAL);
@@ -913,13 +933,14 @@ omap4_clk_get_sysclk_freq(struct ti_clock_dev *clkdev,
{
uint32_t clksel;
uint32_t sysclk;
- struct omap4_prcm_softc *sc = omap4_prcm_sc;
+ struct omap4_prcm_softc *sc;
+ sc = omap4_prcm_get_instance_softc(PRM_INSTANCE);
if (sc == NULL)
return ENXIO;
/* Read the input clock freq from the configuration register (CM_SYS_CLKSEL) */
- clksel = bus_read_4(sc->sc_res[PRM_INSTANCE_MEM_REGION], CM_SYS_CLKSEL_OFFSET);
+ clksel = bus_read_4(sc->sc_res, CM_SYS_CLKSEL_OFFSET);
switch (clksel & 0x7) {
case 0x1:
/* 12Mhz */
@@ -971,15 +992,16 @@ omap4_clk_get_arm_fclk_freq(struct ti_clock_dev *clkdev,
uint32_t clksel;
uint32_t pll_mult, pll_div;
uint32_t mpuclk, sysclk;
- struct omap4_prcm_softc *sc = omap4_prcm_sc;
+ struct omap4_prcm_softc *sc;
+ sc = omap4_prcm_get_instance_softc(CM1_INSTANCE);
if (sc == NULL)
return ENXIO;
/* Read the clksel register which contains the DPLL multiple and divide
* values. These are applied to the sysclk.
*/
- clksel = bus_read_4(sc->sc_res[CM1_INSTANCE_MEM_REGION], CM_CLKSEL_DPLL_MPU);
+ clksel = bus_read_4(sc->sc_res, CM_CLKSEL_DPLL_MPU);
pll_mult = ((clksel >> 8) & 0x7ff);
pll_div = (clksel & 0x7f) + 1;
@@ -1050,12 +1072,13 @@ struct dpll_param usb_dpll_param[7] = {
static int
omap4_clk_hsusbhost_activate(struct ti_clock_dev *clkdev)
{
- struct omap4_prcm_softc *sc = omap4_prcm_sc;
+ struct omap4_prcm_softc *sc;
struct resource* clk_mem_res;
uint32_t clksel_reg_off;
uint32_t clksel;
unsigned int i;
+ sc = omap4_prcm_get_instance_softc(CM2_INSTANCE);
if (sc == NULL)
return ENXIO;
@@ -1068,7 +1091,7 @@ omap4_clk_hsusbhost_activate(struct ti_clock_dev *clkdev)
*/
/* We need the CM_L3INIT_HSUSBTLL_CLKCTRL register in CM2 register set */
- clk_mem_res = sc->sc_res[CM2_INSTANCE_MEM_REGION];
+ clk_mem_res = sc->sc_res;
clksel_reg_off = L3INIT_CM2_OFFSET + 0x68;
/* Enable the module and also enable the optional func clocks for
@@ -1103,7 +1126,7 @@ omap4_clk_hsusbhost_activate(struct ti_clock_dev *clkdev)
*/
/* We need the CM_L3INIT_HSUSBHOST_CLKCTRL register in CM2 register set */
- clk_mem_res = sc->sc_res[CM2_INSTANCE_MEM_REGION];
+ clk_mem_res = sc->sc_res;
clksel_reg_off = L3INIT_CM2_OFFSET + 0x58;
clksel = bus_read_4(clk_mem_res, clksel_reg_off);
/* Enable the module and also enable the optional func clocks */
@@ -1165,18 +1188,19 @@ omap4_clk_hsusbhost_activate(struct ti_clock_dev *clkdev)
static int
omap4_clk_hsusbhost_deactivate(struct ti_clock_dev *clkdev)
{
- struct omap4_prcm_softc *sc = omap4_prcm_sc;
+ struct omap4_prcm_softc *sc;
struct resource* clk_mem_res;
uint32_t clksel_reg_off;
uint32_t clksel;
+ sc = omap4_prcm_get_instance_softc(CM2_INSTANCE);
if (sc == NULL)
return ENXIO;
switch (clkdev->id) {
case USBTLL_CLK:
/* We need the CM_L3INIT_HSUSBTLL_CLKCTRL register in CM2 register set */
- clk_mem_res = sc->sc_res[CM2_INSTANCE_MEM_REGION];
+ clk_mem_res = sc->sc_res;
clksel_reg_off = L3INIT_CM2_OFFSET + 0x68;
clksel = bus_read_4(clk_mem_res, clksel_reg_off);
@@ -1205,7 +1229,7 @@ omap4_clk_hsusbhost_deactivate(struct ti_clock_dev *clkdev)
*/
/* We need the CM_L3INIT_HSUSBHOST_CLKCTRL register in CM2 register set */
- clk_mem_res = sc->sc_res[CM2_INSTANCE_MEM_REGION];
+ clk_mem_res = sc->sc_res;
clksel_reg_off = L3INIT_CM2_OFFSET + 0x58;
clksel = bus_read_4(clk_mem_res, clksel_reg_off);
@@ -1255,22 +1279,23 @@ omap4_clk_hsusbhost_deactivate(struct ti_clock_dev *clkdev)
static int
omap4_clk_hsusbhost_accessible(struct ti_clock_dev *clkdev)
{
- struct omap4_prcm_softc *sc = omap4_prcm_sc;
+ struct omap4_prcm_softc *sc;
struct resource* clk_mem_res;
uint32_t clksel_reg_off;
uint32_t clksel;
+ sc = omap4_prcm_get_instance_softc(CM2_INSTANCE);
if (sc == NULL)
return ENXIO;
if (clkdev->id == USBTLL_CLK) {
/* We need the CM_L3INIT_HSUSBTLL_CLKCTRL register in CM2 register set */
- clk_mem_res = sc->sc_res[CM2_INSTANCE_MEM_REGION];
+ clk_mem_res = sc->sc_res;
clksel_reg_off = L3INIT_CM2_OFFSET + 0x68;
}
else if (clkdev->id == USBHSHOST_CLK) {
/* We need the CM_L3INIT_HSUSBHOST_CLKCTRL register in CM2 register set */
- clk_mem_res = sc->sc_res[CM2_INSTANCE_MEM_REGION];
+ clk_mem_res = sc->sc_res;
clksel_reg_off = L3INIT_CM2_OFFSET + 0x58;
}
else {
@@ -1304,12 +1329,13 @@ static int
omap4_clk_hsusbhost_set_source(struct ti_clock_dev *clkdev,
clk_src_t clksrc)
{
- struct omap4_prcm_softc *sc = omap4_prcm_sc;
+ struct omap4_prcm_softc *sc;
struct resource* clk_mem_res;
uint32_t clksel_reg_off;
uint32_t clksel;
unsigned int bit;
+ sc = omap4_prcm_get_instance_softc(CM2_INSTANCE);
if (sc == NULL)
return ENXIO;
@@ -1321,7 +1347,7 @@ omap4_clk_hsusbhost_set_source(struct ti_clock_dev *clkdev,
return (EINVAL);
/* We need the CM_L3INIT_HSUSBHOST_CLKCTRL register in CM2 register set */
- clk_mem_res = sc->sc_res[CM2_INSTANCE_MEM_REGION];
+ clk_mem_res = sc->sc_res;
clksel_reg_off = L3INIT_CM2_OFFSET + 0x58;
clksel = bus_read_4(clk_mem_res, clksel_reg_off);
@@ -1342,10 +1368,15 @@ omap4_clk_hsusbhost_set_source(struct ti_clock_dev *clkdev,
static void
omap4_prcm_reset(void)
{
- struct omap4_prcm_softc *sc = omap4_prcm_sc;
- bus_write_4(sc->sc_res[0], PRM_RSTCTRL,
- bus_read_4(sc->sc_res[0], PRM_RSTCTRL) | PRM_RSTCTRL_RESET);
- bus_read_4(sc->sc_res[0], PRM_RSTCTRL);
+ struct omap4_prcm_softc *sc;
+
+ sc = omap4_prcm_get_instance_softc(PRM_INSTANCE);
+ if (sc == NULL)
+ return;
+
+ bus_write_4(sc->sc_res, PRM_RSTCTRL,
+ bus_read_4(sc->sc_res, PRM_RSTCTRL) | PRM_RSTCTRL_RESET);
+ bus_read_4(sc->sc_res, PRM_RSTCTRL);
}
/**
@@ -1363,15 +1394,31 @@ omap4_prcm_reset(void)
static int
omap4_prcm_probe(device_t dev)
{
+ const struct ofw_compat_data *ocd;
if (!ofw_bus_status_okay(dev))
return (ENXIO);
- if (!ofw_bus_is_compatible(dev, "ti,omap4_prcm"))
+ ocd = ofw_bus_search_compatible(dev, compat_data);
+ if ((int)ocd->ocd_data == 0)
return (ENXIO);
- device_set_desc(dev, "TI OMAP Power, Reset and Clock Management");
- return (0);
+ switch ((int)ocd->ocd_data) {
+ case PRM_INSTANCE:
+ device_set_desc(dev, "TI OMAP Power, Reset and Clock Management (PRM)");
+ break;
+ case CM1_INSTANCE:
+ device_set_desc(dev, "TI OMAP Power, Reset and Clock Management (C1)");
+ break;
+ case CM2_INSTANCE:
+ device_set_desc(dev, "TI OMAP Power, Reset and Clock Management (C2)");
+ break;
+ default:
+ device_printf(dev, "unknown instance type: %d\n", (int)ocd->ocd_data);
+ return (ENXIO);
+ }
+
+ return (BUS_PROBE_DEFAULT);
}
/**
@@ -1393,18 +1440,33 @@ extern uint32_t platform_arm_tmr_freq;
static int
omap4_prcm_attach(device_t dev)
{
- struct omap4_prcm_softc *sc = device_get_softc(dev);
+ struct omap4_prcm_softc *sc;
unsigned int freq;
+ const struct ofw_compat_data *ocd;
+
- if (bus_alloc_resources(dev, omap4_scm_res_spec, sc->sc_res)) {
+ sc = device_get_softc(dev);
+ ocd = ofw_bus_search_compatible(dev, compat_data);
+ sc->sc_instance = (int)ocd->ocd_data;
+
+ sc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_rid,
+ RF_ACTIVE);
+ if (sc->sc_res == NULL) {
device_printf(dev, "could not allocate resources\n");
return (ENXIO);
}
- omap4_prcm_sc = sc;
ti_cpu_reset = omap4_prcm_reset;
- omap4_clk_get_arm_fclk_freq(NULL, &freq);
- arm_tmr_change_frequency(freq / 2);
+
+ /*
+ * In order to determine ARM frequency we need both RPM and CM1
+ * instances up and running. So wait until all CRM devices are
+ * initialized. Should be replaced with proper clock framework
+ */
+ if (device_get_unit(dev) == 2) {
+ omap4_clk_get_arm_fclk_freq(NULL, &freq);
+ arm_tmr_change_frequency(freq / 2);
+ }
return (0);
}
diff --git a/sys/arm/ti/omap4/omap4_scm_padconf.c b/sys/arm/ti/omap4/omap4_scm_padconf.c
index ca81186..e43581e 100644
--- a/sys/arm/ti/omap4/omap4_scm_padconf.c
+++ b/sys/arm/ti/omap4/omap4_scm_padconf.c
@@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
-#include <arm/ti/ti_scm.h>
+#include <arm/ti/ti_pinmux.h>
#include <arm/ti/omap4/omap4_scm_padconf.h>
@@ -77,7 +77,7 @@ __FBSDID("$FreeBSD$");
.muxmodes[7] = m7, \
}
-const static struct ti_scm_padstate ti_padstate_devmap[] = {
+const static struct ti_pinmux_padstate ti_padstate_devmap[] = {
{"output", PADCONF_PIN_OUTPUT},
{"input", PADCONF_PIN_INPUT},
{"input_pullup", PADCONF_PIN_INPUT_PULLUP},
@@ -88,214 +88,214 @@ const static struct ti_scm_padstate ti_padstate_devmap[] = {
/*
* Table 18-10, p. 3470
*/
-const static struct ti_scm_padconf ti_padconf_devmap[] = {
- _PINDEF(0x0040, "c12", 0, 0, "gpmc_ad0", "sdmmc2_dat0", NULL, NULL, NULL, NULL, NULL, NULL),
- _PINDEF(0x0042, "d12", 0, 0, "gpmc_ad1", "sdmmc2_dat1", NULL, NULL, NULL, NULL, NULL, NULL),
- _PINDEF(0x0044, "c13", 0, 0, "gpmc_ad2", "sdmmc2_dat2", NULL, NULL, NULL, NULL, NULL, NULL),
- _PINDEF(0x0046, "d13", 0, 0, "gpmc_ad3", "sdmmc2_dat3", NULL, NULL, NULL, NULL, NULL, NULL),
- _PINDEF(0x0048, "c15", 0, 0, "gpmc_ad4", "sdmmc2_dat4", "sdmmc2_dir_dat0", NULL, NULL, NULL, NULL, NULL),
- _PINDEF(0x004a, "d15", 0, 0, "gpmc_ad5", "sdmmc2_dat5", "sdmmc2_dir_dat1", NULL, NULL, NULL, NULL, NULL),
- _PINDEF(0x004c, "a16", 0, 0, "gpmc_ad6", "sdmmc2_dat6", "sdmmc2_dir_cmd", NULL, NULL, NULL, NULL, NULL),
- _PINDEF(0x004e, "b16", 0, 0, "gpmc_ad7", "sdmmc2_dat7", "sdmmc2_clk_fdbk", NULL, NULL, NULL, NULL, NULL),
- _PINDEF(0x0050, "c16", 32, 3, "gpmc_ad8", "kpd_row0", "c2c_data15", "gpio_32", NULL, "sdmmc1_dat0", NULL, NULL),
- _PINDEF(0x0052, "d16", 33, 3, "gpmc_ad9", "kpd_row1", "c2c_data14", "gpio_33", NULL, "sdmmc1_dat1", NULL, NULL),
- _PINDEF(0x0054, "c17", 34, 3, "gpmc_ad10", "kpd_row2", "c2c_data13", "gpio_34", NULL, "sdmmc1_dat2", NULL, NULL),
- _PINDEF(0x0056, "d17", 35, 3, "gpmc_ad11", "kpd_row3", "c2c_data12", "gpio_35", NULL, "sdmmc1_dat3", NULL, NULL),
- _PINDEF(0x0058, "c18", 36, 3, "gpmc_ad12", "kpd_col0", "c2c_data11", "gpio_36", NULL, "sdmmc1_dat4", NULL, NULL),
- _PINDEF(0x005a, "d18", 37, 3, "gpmc_ad13", "kpd_col1", "c2c_data10", "gpio_37", NULL, "sdmmc1_dat5", NULL, NULL),
- _PINDEF(0x005c, "c19", 38, 3, "gpmc_ad14", "kpd_col2", "c2c_data9", "gpio_38", NULL, "sdmmc1_dat6", NULL, NULL),
- _PINDEF(0x005e, "d19", 39, 3, "gpmc_ad15", "kpd_col3", "c2c_data8", "gpio_39", NULL, "sdmmc1_dat7", NULL, NULL),
- _PINDEF(0x0060, "b17", 40, 3, "gpmc_a16", "kpd_row4", "c2c_datain0", "gpio_40", "venc_656_data0", NULL, NULL, "safe_mode"),
- _PINDEF(0x0062, "a18", 41, 3, "gpmc_a17", "kpd_row5", "c2c_datain1", "gpio_41", "venc_656_data1", NULL, NULL, "safe_mode"),
- _PINDEF(0x0064, "b18", 42, 3, "gpmc_a18", "kpd_row6", "c2c_datain2", "gpio_42", "venc_656_data2", NULL, NULL, "safe_mode"),
- _PINDEF(0x0066, "a19", 43, 3, "gpmc_a19", "kpd_row7", "c2c_datain3", "gpio_43", "venc_656_data3", NULL, NULL, "safe_mode"),
- _PINDEF(0x0068, "b19", 44, 3, "gpmc_a20", "kpd_col4", "c2c_datain4", "gpio_44", "venc_656_data4", NULL, NULL, "safe_mode"),
- _PINDEF(0x006a, "b20", 45, 3, "gpmc_a21", "kpd_col5", "c2c_datain5", "gpio_45", "venc_656_data5", NULL, NULL, "safe_mode"),
- _PINDEF(0x006c, "a21", 46, 3, "gpmc_a22", "kpd_col6", "c2c_datain6", "gpio_46", "venc_656_data6", NULL, NULL, "safe_mode"),
- _PINDEF(0x006e, "b21", 47, 3, "gpmc_a23", "kpd_col7", "c2c_datain7", "gpio_47", "venc_656_data7", NULL, NULL, "safe_mode"),
- _PINDEF(0x0070, "c20", 48, 3, "gpmc_a24", "kpd_col8", "c2c_clkout0", "gpio_48", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0072, "d20", 49, 3, "gpmc_a25", NULL, "c2c_clkout1", "gpio_49", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0074, "b25", 50, 3, "gpmc_ncs0", NULL, NULL, "gpio_50", "sys_ndmareq0", NULL, NULL, NULL),
- _PINDEF(0x0076, "c21", 51, 3, "gpmc_ncs1", NULL, "c2c_dataout6", "gpio_51", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0078, "d21", 52, 3, "gpmc_ncs2", "kpd_row8", "c2c_dataout7", "gpio_52", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x007a, "c22", 53, 3, "gpmc_ncs3", "gpmc_dir", "c2c_dataout4", "gpio_53", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x007c, "c25", 54, 3, "gpmc_nwp", "dsi1_te0", NULL, "gpio_54", "sys_ndmareq1", NULL, NULL, NULL),
- _PINDEF(0x007e, "b22", 55, 3, "gpmc_clk", NULL, NULL, "gpio_55", "sys_ndmareq2", "sdmmc1_cmd", NULL, NULL),
- _PINDEF(0x0080, "d25", 56, 3, "gpmc_nadv_ale", "dsi1_te1", NULL, "gpio_56", "sys_ndmareq3", "sdmmc1_clk", NULL, NULL),
- _PINDEF(0x0082, "b11", 0, 0, "gpmc_noe", "sdmmc2_clk", NULL, NULL, NULL, NULL, NULL, NULL),
- _PINDEF(0x0084, "b12", 0, 0, "gpmc_nwe", "sdmmc2_cmd", NULL, NULL, NULL, NULL, NULL, NULL),
- _PINDEF(0x0086, "c23", 59, 3, "gpmc_nbe0_cle", "dsi2_te0", NULL, "gpio_59", NULL, NULL, NULL, NULL),
- _PINDEF(0x0088, "d22", 60, 3, "gpmc_nbe1", NULL, "c2c_dataout5", "gpio_60", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x008a, "b26", 61, 3, "gpmc_wait0", "dsi2_te1", NULL, "gpio_61", NULL, NULL, NULL, NULL),
- _PINDEF(0x008c, "b23", 62, 3, "gpmc_wait1", NULL, "c2c_dataout2", "gpio_62", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x008e, "d23", 100, 3, "gpmc_wait2", "usbc1_icusb_txen", "c2c_dataout3", "gpio_100", "sys_ndmareq0", NULL, NULL, "safe_mode"),
- _PINDEF(0x0090, "a24", 101, 3, "gpmc_ncs4", "dsi1_te0", "c2c_clkin0", "gpio_101", "sys_ndmareq1", NULL, NULL, "safe_mode"),
- _PINDEF(0x0092, "b24", 102, 3, "gpmc_ncs5", "dsi1_te1", "c2c_clkin1", "gpio_102", "sys_ndmareq2", NULL, NULL, "safe_mode"),
- _PINDEF(0x0094, "c24", 103, 3, "gpmc_ncs6", "dsi2_te0", "c2c_dataout0", "gpio_103", "sys_ndmareq3", NULL, NULL, "safe_mode"),
- _PINDEF(0x0096, "d24", 104, 3, "gpmc_ncs7", "dsi2_te1", "c2c_dataout1", "gpio_104", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0098, "b9", 63, 3, "hdmi_hpd", NULL, NULL, "gpio_63", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x009a, "b10", 64, 3, "hdmi_cec", NULL, NULL, "gpio_64", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x009c, "a8", 65, 3, "hdmi_ddc_scl", NULL, NULL, "gpio_65", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x009e, "b8", 66, 3, "hdmi_ddc_sda", NULL, NULL, "gpio_66", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00a0, "r26", 0, 0, "csi21_dx0", NULL, NULL, "gpi_67", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00a2, "r25", 0, 0, "csi21_dy0", NULL, NULL, "gpi_68", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00a4, "t26", 0, 0, "csi21_dx1", NULL, NULL, "gpi_69", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00a6, "t25", 0, 0, "csi21_dy1", NULL, NULL, "gpi_70", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00a8, "u26", 0, 0, "csi21_dx2", NULL, NULL, "gpi_71", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00aa, "u25", 0, 0, "csi21_dy2", NULL, NULL, "gpi_72", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00ac, "v26", 0, 0, "csi21_dx3", NULL, NULL, "gpi_73", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00ae, "v25", 0, 0, "csi21_dy3", NULL, NULL, "gpi_74", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00b0, "w26", 0, 0, "csi21_dx4", NULL, NULL, "gpi_75", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00b2, "w25", 0, 0, "csi21_dy4", NULL, NULL, "gpi_76", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00b4, "m26", 0, 0, "csi22_dx0", NULL, NULL, "gpi_77", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00b6, "m25", 0, 0, "csi22_dy0", NULL, NULL, "gpi_78", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00b8, "n26", 0, 0, "csi22_dx1", NULL, NULL, "gpi_79", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00ba, "n25", 0, 0, "csi22_dy1", NULL, NULL, "gpi_80", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00bc, "t27", 81, 3, "cam_shutter", NULL, NULL, "gpio_81", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00be, "u27", 82, 3, "cam_strobe", NULL, NULL, "gpio_82", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00c0, "v27", 83, 3, "cam_globalreset", NULL, NULL, "gpio_83", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00c2, "ae18", 84, 3, "usbb1_ulpitll_clk", "hsi1_cawake", NULL, "gpio_84", "usbb1_ulpiphy_clk", NULL, "hw_dbg20", "safe_mode"),
- _PINDEF(0x00c4, "ag19", 85, 3, "usbb1_ulpitll_stp", "hsi1_cadata", "mcbsp4_clkr", "gpio_85", "usbb1_ulpiphy_stp", "usbb1_mm_rxdp", "hw_dbg21", "safe_mode"),
- _PINDEF(0x00c6, "af19", 86, 3, "usbb1_ulpitll_dir", "hsi1_caflag", "mcbsp4_fsr", "gpio_86", "usbb1_ulpiphy_dir", NULL, "hw_dbg22", "safe_mode"),
- _PINDEF(0x00c8, "ae19", 87, 3, "usbb1_ulpitll_nxt", "hsi1_acready", "mcbsp4_fsx", "gpio_87", "usbb1_ulpiphy_nxt", "usbb1_mm_rxdm", "hw_dbg23", "safe_mode"),
- _PINDEF(0x00ca, "af18", 88, 3, "usbb1_ulpitll_dat0", "hsi1_acwake", "mcbsp4_clkx", "gpio_88", "usbb1_ulpiphy_dat0", "usbb1_mm_txen", "hw_dbg24", "safe_mode"),
- _PINDEF(0x00cc, "ag18", 89, 3, "usbb1_ulpitll_dat1", "hsi1_acdata", "mcbsp4_dx", "gpio_89", "usbb1_ulpiphy_dat1", "usbb1_mm_txdat", "hw_dbg25", "safe_mode"),
- _PINDEF(0x00ce, "ae17", 90, 3, "usbb1_ulpitll_dat2", "hsi1_acflag", "mcbsp4_dr", "gpio_90", "usbb1_ulpiphy_dat2", "usbb1_mm_txse0", "hw_dbg26", "safe_mode"),
- _PINDEF(0x00d0, "af17", 91, 3, "usbb1_ulpitll_dat3", "hsi1_caready", NULL, "gpio_91", "usbb1_ulpiphy_dat3", "usbb1_mm_rxrcv", "hw_dbg27", "safe_mode"),
- _PINDEF(0x00d2, "ah17", 92, 3, "usbb1_ulpitll_dat4", "dmtimer8_pwm_evt", "abe_mcbsp3_dr", "gpio_92", "usbb1_ulpiphy_dat4", NULL, "hw_dbg28", "safe_mode"),
- _PINDEF(0x00d4, "ae16", 93, 3, "usbb1_ulpitll_dat5", "dmtimer9_pwm_evt", "abe_mcbsp3_dx", "gpio_93", "usbb1_ulpiphy_dat5", NULL, "hw_dbg29", "safe_mode"),
- _PINDEF(0x00d6, "af16", 94, 3, "usbb1_ulpitll_dat6", "dmtimer10_pwm_evt", "abe_mcbsp3_clkx", "gpio_94", "usbb1_ulpiphy_dat6", "abe_dmic_din3", "hw_dbg30", "safe_mode"),
- _PINDEF(0x00d8, "ag16", 95, 3, "usbb1_ulpitll_dat7", "dmtimer11_pwm_evt", "abe_mcbsp3_fsx", "gpio_95", "usbb1_ulpiphy_dat7", "abe_dmic_clk3", "hw_dbg31", "safe_mode"),
- _PINDEF(0x00da, "af14", 96, 3, "usbb1_hsic_data", NULL, NULL, "gpio_96", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00dc, "ae14", 97, 3, "usbb1_hsic_strobe", NULL, NULL, "gpio_97", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00de, "h2", 98, 3, "usbc1_icusb_dp", NULL, NULL, "gpio_98", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00e0, "h3", 99, 3, "usbc1_icusb_dm", NULL, NULL, "gpio_99", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00e2, "d2", 100, 3, "sdmmc1_clk", NULL, "dpm_emu19", "gpio_100", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00e4, "e3", 101, 3, "sdmmc1_cmd", NULL, "uart1_rx", "gpio_101", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00e6, "e4", 102, 3, "sdmmc1_dat0", NULL, "dpm_emu18", "gpio_102", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00e8, "e2", 103, 3, "sdmmc1_dat1", NULL, "dpm_emu17", "gpio_103", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00ea, "e1", 104, 3, "sdmmc1_dat2", NULL, "dpm_emu16", "gpio_104", "jtag_tms_tmsc", NULL, NULL, "safe_mode"),
- _PINDEF(0x00ec, "f4", 105, 3, "sdmmc1_dat3", NULL, "dpm_emu15", "gpio_105", "jtag_tck", NULL, NULL, "safe_mode"),
- _PINDEF(0x00ee, "f3", 106, 3, "sdmmc1_dat4", NULL, NULL, "gpio_106", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00f0, "f1", 107, 3, "sdmmc1_dat5", NULL, NULL, "gpio_107", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00f2, "g4", 108, 3, "sdmmc1_dat6", NULL, NULL, "gpio_108", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00f4, "g3", 109, 3, "sdmmc1_dat7", NULL, NULL, "gpio_109", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x00f6, "ad27", 110, 3, "abe_mcbsp2_clkx", "mcspi2_clk", "abe_mcasp_ahclkx", "gpio_110", "usbb2_mm_rxdm", NULL, NULL, "safe_mode"),
- _PINDEF(0x00f8, "ad26", 111, 3, "abe_mcbsp2_dr", "mcspi2_somi", "abe_mcasp_axr", "gpio_111", "usbb2_mm_rxdp", NULL, NULL, "safe_mode"),
- _PINDEF(0x00fa, "ad25", 112, 3, "abe_mcbsp2_dx", "mcspi2_simo", "abe_mcasp_amute", "gpio_112", "usbb2_mm_rxrcv", NULL, NULL, "safe_mode"),
- _PINDEF(0x00fc, "ac28", 113, 3, "abe_mcbsp2_fsx", "mcspi2_cs0", "abe_mcasp_afsx", "gpio_113", "usbb2_mm_txen", NULL, NULL, "safe_mode"),
- _PINDEF(0x00fe, "ac26", 114, 3, "abe_mcbsp1_clkx", "abe_slimbus1_clock", NULL, "gpio_114", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0100, "ac25", 115, 3, "abe_mcbsp1_dr", "abe_slimbus1_data", NULL, "gpio_115", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0102, "ab25", 116, 3, "abe_mcbsp1_dx", "sdmmc3_dat2", "abe_mcasp_aclkx", "gpio_116", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0104, "ac27", 117, 3, "abe_mcbsp1_fsx", "sdmmc3_dat3", "abe_mcasp_amutein", "gpio_117", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0106, "ag25", 0, 0, "abe_pdm_ul_data", "abe_mcbsp3_dr", NULL, NULL, NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0108, "af25", 0, 0, "abe_pdm_dl_data", "abe_mcbsp3_dx", NULL, NULL, NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x010a, "ae25", 0, 0, "abe_pdm_frame", "abe_mcbsp3_clkx", NULL, NULL, NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x010c, "af26", 0, 0, "abe_pdm_lb_clk", "abe_mcbsp3_fsx", NULL, NULL, NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x010e, "ah26", 118, 3, "abe_clks", NULL, NULL, "gpio_118", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0110, "ae24", 119, 3, "abe_dmic_clk1", NULL, NULL, "gpio_119", "usbb2_mm_txse0", "uart4_cts", NULL, "safe_mode"),
- _PINDEF(0x0112, "af24", 120, 3, "abe_dmic_din1", NULL, NULL, "gpio_120", "usbb2_mm_txdat", "uart4_rts", NULL, "safe_mode"),
- _PINDEF(0x0114, "ag24", 121, 3, "abe_dmic_din2", "slimbus2_clock", "abe_mcasp_axr", "gpio_121", NULL, "dmtimer11_pwm_evt", NULL, "safe_mode"),
- _PINDEF(0x0116, "ah24", 122, 3, "abe_dmic_din3", "slimbus2_data", "abe_dmic_clk2", "gpio_122", NULL, "dmtimer9_pwm_evt", NULL, "safe_mode"),
- _PINDEF(0x0118, "ab26", 123, 3, "uart2_cts", "sdmmc3_clk", NULL, "gpio_123", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x011a, "ab27", 124, 3, "uart2_rts", "sdmmc3_cmd", NULL, "gpio_124", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x011c, "aa25", 125, 3, "uart2_rx", "sdmmc3_dat0", NULL, "gpio_125", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x011e, "aa26", 126, 3, "uart2_tx", "sdmmc3_dat1", NULL, "gpio_126", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0120, "aa27", 127, 3, "hdq_sio", "i2c3_sccb", "i2c2_sccb", "gpio_127", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0122, "ae28", 0, 0, "i2c1_scl", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PINDEF(0x0124, "ae26", 0, 0, "i2c1_sda", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PINDEF(0x0126, "c26", 128, 3, "i2c2_scl", "uart1_rx", NULL, "gpio_128", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0128, "d26", 129, 3, "i2c2_sda", "uart1_tx", NULL, "gpio_129", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x012a, "w27", 130, 3, "i2c3_scl", NULL, NULL, "gpio_130", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x012c, "y27", 131, 3, "i2c3_sda", NULL, NULL, "gpio_131", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x012e, "ag21", 132, 3, "i2c4_scl", NULL, NULL, "gpio_132", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0130, "ah22", 133, 3, "i2c4_sda", NULL, NULL, "gpio_133", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0132, "af22", 134, 3, "mcspi1_clk", NULL, NULL, "gpio_134", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0134, "ae22", 135, 3, "mcspi1_somi", NULL, NULL, "gpio_135", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0136, "ag22", 136, 3, "mcspi1_simo", NULL, NULL, "gpio_136", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0138, "ae23", 137, 3, "mcspi1_cs0", NULL, NULL, "gpio_137", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x013a, "af23", 138, 3, "mcspi1_cs1", "uart1_rx", NULL, "gpio_138", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x013c, "ag23", 139, 3, "mcspi1_cs2", "uart1_cts", "slimbus2_clock", "gpio_139", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x013e, "ah23", 140, 3, "mcspi1_cs3", "uart1_rts", "slimbus2_data", "gpio_140", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0140, "f27", 141, 3, "uart3_cts_rctx", "uart1_tx", NULL, "gpio_141", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0142, "f28", 142, 3, "uart3_rts_sd", NULL, NULL, "gpio_142", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0144, "g27", 143, 3, "uart3_rx_irrx", "dmtimer8_pwm_evt", NULL, "gpio_143", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0146, "g28", 144, 3, "uart3_tx_irtx", "dmtimer9_pwm_evt", NULL, "gpio_144", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0148, "ae5", 145, 3, "sdmmc5_clk", "mcspi2_clk", "usbc1_icusb_dp", "gpio_145", NULL, "sdmmc2_clk", NULL, "safe_mode"),
- _PINDEF(0x014a, "af5", 146, 3, "sdmmc5_cmd", "mcspi2_simo", "usbc1_icusb_dm", "gpio_146", NULL, "sdmmc2_cmd", NULL, "safe_mode"),
- _PINDEF(0x014c, "ae4", 147, 3, "sdmmc5_dat0", "mcspi2_somi", "usbc1_icusb_rcv", "gpio_147", NULL, "sdmmc2_dat0", NULL, "safe_mode"),
- _PINDEF(0x014e, "af4", 148, 3, "sdmmc5_dat1", NULL, "usbc1_icusb_txen", "gpio_148", NULL, "sdmmc2_dat1", NULL, "safe_mode"),
- _PINDEF(0x0150, "ag3", 149, 3, "sdmmc5_dat2", "mcspi2_cs1", NULL, "gpio_149", NULL, "sdmmc2_dat2", NULL, "safe_mode"),
- _PINDEF(0x0152, "af3", 150, 3, "sdmmc5_dat3", "mcspi2_cs0", NULL, "gpio_150", NULL, "sdmmc2_dat3", NULL, "safe_mode"),
- _PINDEF(0x0154, "ae21", 151, 3, "mcspi4_clk", "sdmmc4_clk", "kpd_col6", "gpio_151", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0156, "af20", 152, 3, "mcspi4_simo", "sdmmc4_cmd", "kpd_col7", "gpio_152", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0158, "af21", 153, 3, "mcspi4_somi", "sdmmc4_dat0", "kpd_row6", "gpio_153", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x015a, "ae20", 154, 3, "mcspi4_cs0", "sdmmc4_dat3", "kpd_row7", "gpio_154", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x015c, "ag20", 155, 3, "uart4_rx", "sdmmc4_dat2", "kpd_row8", "gpio_155", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x015e, "ah19", 156, 3, "uart4_tx", "sdmmc4_dat1", "kpd_col8", "gpio_156", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0160, "ag12", 157, 3, "usbb2_ulpitll_clk", "usbb2_ulpiphy_clk", "sdmmc4_cmd", "gpio_157", "hsi2_cawake", NULL, NULL, "safe_mode"),
- _PINDEF(0x0162, "af12", 158, 3, "usbb2_ulpitll_stp", "usbb2_ulpiphy_stp", "sdmmc4_clk", "gpio_158", "hsi2_cadata", "dispc2_data23", NULL, "safe_mode"),
- _PINDEF(0x0164, "ae12", 159, 3, "usbb2_ulpitll_dir", "usbb2_ulpiphy_dir", "sdmmc4_dat0", "gpio_159", "hsi2_caflag", "dispc2_data22", NULL, "safe_mode"),
- _PINDEF(0x0166, "ag13", 160, 3, "usbb2_ulpitll_nxt", "usbb2_ulpiphy_nxt", "sdmmc4_dat1", "gpio_160", "hsi2_acready", "dispc2_data21", NULL, "safe_mode"),
- _PINDEF(0x0168, "ae11", 161, 3, "usbb2_ulpitll_dat0", "usbb2_ulpiphy_dat0", "sdmmc4_dat2", "gpio_161", "hsi2_acwake", "dispc2_data20", "usbb2_mm_txen", "safe_mode"),
- _PINDEF(0x016a, "af11", 162, 3, "usbb2_ulpitll_dat1", "usbb2_ulpiphy_dat1", "sdmmc4_dat3", "gpio_162", "hsi2_acdata", "dispc2_data19", "usbb2_mm_txdat", "safe_mode"),
- _PINDEF(0x016c, "ag11", 163, 3, "usbb2_ulpitll_dat2", "usbb2_ulpiphy_dat2", "sdmmc3_dat2", "gpio_163", "hsi2_acflag", "dispc2_data18", "usbb2_mm_txse0", "safe_mode"),
- _PINDEF(0x016e, "ah11", 164, 3, "usbb2_ulpitll_dat3", "usbb2_ulpiphy_dat3", "sdmmc3_dat1", "gpio_164", "hsi2_caready", "dispc2_data15", "rfbi_data15", "safe_mode"),
- _PINDEF(0x0170, "ae10", 165, 3, "usbb2_ulpitll_dat4", "usbb2_ulpiphy_dat4", "sdmmc3_dat0", "gpio_165", "mcspi3_somi", "dispc2_data14", "rfbi_data14", "safe_mode"),
- _PINDEF(0x0172, "af10", 166, 3, "usbb2_ulpitll_dat5", "usbb2_ulpiphy_dat5", "sdmmc3_dat3", "gpio_166", "mcspi3_cs0", "dispc2_data13", "rfbi_data13", "safe_mode"),
- _PINDEF(0x0174, "ag10", 167, 3, "usbb2_ulpitll_dat6", "usbb2_ulpiphy_dat6", "sdmmc3_cmd", "gpio_167", "mcspi3_simo", "dispc2_data12", "rfbi_data12", "safe_mode"),
- _PINDEF(0x0176, "ae9", 168, 3, "usbb2_ulpitll_dat7", "usbb2_ulpiphy_dat7", "sdmmc3_clk", "gpio_168", "mcspi3_clk", "dispc2_data11", "rfbi_data11", "safe_mode"),
- _PINDEF(0x0178, "af13", 169, 3, "usbb2_hsic_data", NULL, NULL, "gpio_169", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x017a, "ae13", 170, 3, "usbb2_hsic_strobe", NULL, NULL, "gpio_170", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x017c, "g26", 171, 3, "kpd_col3", "kpd_col0", NULL, "gpio_171", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x017e, "g25", 172, 3, "kpd_col4", "kpd_col1", NULL, "gpio_172", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0180, "h26", 173, 3, "kpd_col5", "kpd_col2", NULL, "gpio_173", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0182, "h25", 174, 3, "kpd_col0", "kpd_col3", NULL, "gpio_174", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0184, "j27", 0, 0, "kpd_col1", "kpd_col4", NULL, "gpio_0", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0186, "h27", 1, 3, "kpd_col2", "kpd_col5", NULL, "gpio_1", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0188, "j26", 175, 3, "kpd_row3", "kpd_row0", NULL, "gpio_175", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x018a, "j25", 176, 3, "kpd_row4", "kpd_row1", NULL, "gpio_176", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x018c, "k26", 177, 3, "kpd_row5", "kpd_row2", NULL, "gpio_177", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x018e, "k25", 178, 3, "kpd_row0", "kpd_row3", NULL, "gpio_178", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0190, "l27", 2, 3, "kpd_row1", "kpd_row4", NULL, "gpio_2", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0192, "k27", 3, 3, "kpd_row2", "kpd_row5", NULL, "gpio_3", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0194, "c3", 0, 0, "usba0_otg_ce", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
- _PINDEF(0x0196, "b5", 0, 0, "usba0_otg_dp", "uart3_rx_irrx", "uart2_rx", NULL, NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x0198, "b4", 0, 0, "usba0_otg_dm", "uart3_tx_irtx", "uart2_tx", NULL, NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x019a, "aa28", 181, 3, "fref_clk1_out", NULL, NULL, "gpio_181", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x019c, "y28", 182, 3, "fref_clk2_out", NULL, NULL, "gpio_182", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x019e, "ae6", 0, 0, "sys_nirq1", NULL, NULL, NULL, NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x01a0, "af6", 183, 3, "sys_nirq2", NULL, NULL, "gpio_183", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x01a2, "f26", 184, 3, "sys_boot0", NULL, NULL, "gpio_184", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x01a4, "e27", 185, 3, "sys_boot1", NULL, NULL, "gpio_185", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x01a6, "e26", 186, 3, "sys_boot2", NULL, NULL, "gpio_186", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x01a8, "e25", 187, 3, "sys_boot3", NULL, NULL, "gpio_187", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x01aa, "d28", 188, 3, "sys_boot4", NULL, NULL, "gpio_188", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x01ac, "d27", 189, 3, "sys_boot5", NULL, NULL, "gpio_189", NULL, NULL, NULL, "safe_mode"),
- _PINDEF(0x01ae, "m2", 11, 3, "dpm_emu0", NULL, NULL, "gpio_11", NULL, NULL, "hw_dbg0", "safe_mode"),
- _PINDEF(0x01b0, "n2", 12, 3, "dpm_emu1", NULL, NULL, "gpio_12", NULL, NULL, "hw_dbg1", "safe_mode"),
- _PINDEF(0x01b2, "p2", 13, 3, "dpm_emu2", "usba0_ulpiphy_clk", NULL, "gpio_13", NULL, "dispc2_fid", "hw_dbg2", "safe_mode"),
- _PINDEF(0x01b4, "v1", 14, 3, "dpm_emu3", "usba0_ulpiphy_stp", NULL, "gpio_14", "rfbi_data10", "dispc2_data10", "hw_dbg3", "safe_mode"),
- _PINDEF(0x01b6, "v2", 15, 3, "dpm_emu4", "usba0_ulpiphy_dir", NULL, "gpio_15", "rfbi_data9", "dispc2_data9", "hw_dbg4", "safe_mode"),
- _PINDEF(0x01b8, "w1", 16, 3, "dpm_emu5", "usba0_ulpiphy_nxt", NULL, "gpio_16", "rfbi_te_vsync0", "dispc2_data16", "hw_dbg5", "safe_mode"),
- _PINDEF(0x01ba, "w2", 17, 3, "dpm_emu6", "usba0_ulpiphy_dat0", "uart3_tx_irtx", "gpio_17", "rfbi_hsync0", "dispc2_data17", "hw_dbg6", "safe_mode"),
- _PINDEF(0x01bc, "w3", 18, 3, "dpm_emu7", "usba0_ulpiphy_dat1", "uart3_rx_irrx", "gpio_18", "rfbi_cs0", "dispc2_hsync", "hw_dbg7", "safe_mode"),
- _PINDEF(0x01be, "w4", 19, 3, "dpm_emu8", "usba0_ulpiphy_dat2", "uart3_rts_sd", "gpio_19", "rfbi_re", "dispc2_pclk", "hw_dbg8", "safe_mode"),
- _PINDEF(0x01c0, "y2", 20, 3, "dpm_emu9", "usba0_ulpiphy_dat3", "uart3_cts_rctx", "gpio_20", "rfbi_we", "dispc2_vsync", "hw_dbg9", "safe_mode"),
- _PINDEF(0x01c2, "y3", 21, 3, "dpm_emu10", "usba0_ulpiphy_dat4", NULL, "gpio_21", "rfbi_a0", "dispc2_de", "hw_dbg10", "safe_mode"),
- _PINDEF(0x01c4, "y4", 22, 3, "dpm_emu11", "usba0_ulpiphy_dat5", NULL, "gpio_22", "rfbi_data8", "dispc2_data8", "hw_dbg11", "safe_mode"),
- _PINDEF(0x01c6, "aa1", 23, 3, "dpm_emu12", "usba0_ulpiphy_dat6", NULL, "gpio_23", "rfbi_data7", "dispc2_data7", "hw_dbg12", "safe_mode"),
- _PINDEF(0x01c8, "aa2", 24, 3, "dpm_emu13", "usba0_ulpiphy_dat7", NULL, "gpio_24", "rfbi_data6", "dispc2_data6", "hw_dbg13", "safe_mode"),
- _PINDEF(0x01ca, "aa3", 25, 3, "dpm_emu14", "sys_drm_msecure", "uart1_rx", "gpio_25", "rfbi_data5", "dispc2_data5", "hw_dbg14", "safe_mode"),
- _PINDEF(0x01cc, "aa4", 26, 3, "dpm_emu15", "sys_secure_indicator", NULL, "gpio_26", "rfbi_data4", "dispc2_data4", "hw_dbg15", "safe_mode"),
- _PINDEF(0x01ce, "ab2", 27, 3, "dpm_emu16", "dmtimer8_pwm_evt", "dsi1_te0", "gpio_27", "rfbi_data3", "dispc2_data3", "hw_dbg16", "safe_mode"),
- _PINDEF(0x01d0, "ab3", 28, 3, "dpm_emu17", "dmtimer9_pwm_evt", "dsi1_te1", "gpio_28", "rfbi_data2", "dispc2_data2", "hw_dbg17", "safe_mode"),
- _PINDEF(0x01d2, "ab4", 190, 3, "dpm_emu18", "dmtimer10_pwm_evt", "dsi2_te0", "gpio_190", "rfbi_data1", "dispc2_data1", "hw_dbg18", "safe_mode"),
- _PINDEF(0x01d4, "ac4", 191, 3, "dpm_emu19", "dmtimer11_pwm_evt", "dsi2_te1", "gpio_191", "rfbi_data0", "dispc2_data0", "hw_dbg19", "safe_mode"),
+const static struct ti_pinmux_padconf ti_padconf_devmap[] = {
+ _PINDEF(0x0000, "c12", 0, 0, "gpmc_ad0", "sdmmc2_dat0", NULL, NULL, NULL, NULL, NULL, NULL),
+ _PINDEF(0x0002, "d12", 0, 0, "gpmc_ad1", "sdmmc2_dat1", NULL, NULL, NULL, NULL, NULL, NULL),
+ _PINDEF(0x0004, "c13", 0, 0, "gpmc_ad2", "sdmmc2_dat2", NULL, NULL, NULL, NULL, NULL, NULL),
+ _PINDEF(0x0006, "d13", 0, 0, "gpmc_ad3", "sdmmc2_dat3", NULL, NULL, NULL, NULL, NULL, NULL),
+ _PINDEF(0x0008, "c15", 0, 0, "gpmc_ad4", "sdmmc2_dat4", "sdmmc2_dir_dat0", NULL, NULL, NULL, NULL, NULL),
+ _PINDEF(0x000a, "d15", 0, 0, "gpmc_ad5", "sdmmc2_dat5", "sdmmc2_dir_dat1", NULL, NULL, NULL, NULL, NULL),
+ _PINDEF(0x000c, "a16", 0, 0, "gpmc_ad6", "sdmmc2_dat6", "sdmmc2_dir_cmd", NULL, NULL, NULL, NULL, NULL),
+ _PINDEF(0x000e, "b16", 0, 0, "gpmc_ad7", "sdmmc2_dat7", "sdmmc2_clk_fdbk", NULL, NULL, NULL, NULL, NULL),
+ _PINDEF(0x0010, "c16", 32, 3, "gpmc_ad8", "kpd_row0", "c2c_data15", "gpio_32", NULL, "sdmmc1_dat0", NULL, NULL),
+ _PINDEF(0x0012, "d16", 33, 3, "gpmc_ad9", "kpd_row1", "c2c_data14", "gpio_33", NULL, "sdmmc1_dat1", NULL, NULL),
+ _PINDEF(0x0014, "c17", 34, 3, "gpmc_ad10", "kpd_row2", "c2c_data13", "gpio_34", NULL, "sdmmc1_dat2", NULL, NULL),
+ _PINDEF(0x0016, "d17", 35, 3, "gpmc_ad11", "kpd_row3", "c2c_data12", "gpio_35", NULL, "sdmmc1_dat3", NULL, NULL),
+ _PINDEF(0x0018, "c18", 36, 3, "gpmc_ad12", "kpd_col0", "c2c_data11", "gpio_36", NULL, "sdmmc1_dat4", NULL, NULL),
+ _PINDEF(0x001a, "d18", 37, 3, "gpmc_ad13", "kpd_col1", "c2c_data10", "gpio_37", NULL, "sdmmc1_dat5", NULL, NULL),
+ _PINDEF(0x001c, "c19", 38, 3, "gpmc_ad14", "kpd_col2", "c2c_data9", "gpio_38", NULL, "sdmmc1_dat6", NULL, NULL),
+ _PINDEF(0x001e, "d19", 39, 3, "gpmc_ad15", "kpd_col3", "c2c_data8", "gpio_39", NULL, "sdmmc1_dat7", NULL, NULL),
+ _PINDEF(0x0020, "b17", 40, 3, "gpmc_a16", "kpd_row4", "c2c_datain0", "gpio_40", "venc_656_data0", NULL, NULL, "safe_mode"),
+ _PINDEF(0x0022, "a18", 41, 3, "gpmc_a17", "kpd_row5", "c2c_datain1", "gpio_41", "venc_656_data1", NULL, NULL, "safe_mode"),
+ _PINDEF(0x0024, "b18", 42, 3, "gpmc_a18", "kpd_row6", "c2c_datain2", "gpio_42", "venc_656_data2", NULL, NULL, "safe_mode"),
+ _PINDEF(0x0026, "a19", 43, 3, "gpmc_a19", "kpd_row7", "c2c_datain3", "gpio_43", "venc_656_data3", NULL, NULL, "safe_mode"),
+ _PINDEF(0x0028, "b19", 44, 3, "gpmc_a20", "kpd_col4", "c2c_datain4", "gpio_44", "venc_656_data4", NULL, NULL, "safe_mode"),
+ _PINDEF(0x002a, "b20", 45, 3, "gpmc_a21", "kpd_col5", "c2c_datain5", "gpio_45", "venc_656_data5", NULL, NULL, "safe_mode"),
+ _PINDEF(0x002c, "a21", 46, 3, "gpmc_a22", "kpd_col6", "c2c_datain6", "gpio_46", "venc_656_data6", NULL, NULL, "safe_mode"),
+ _PINDEF(0x002e, "b21", 47, 3, "gpmc_a23", "kpd_col7", "c2c_datain7", "gpio_47", "venc_656_data7", NULL, NULL, "safe_mode"),
+ _PINDEF(0x0030, "c20", 48, 3, "gpmc_a24", "kpd_col8", "c2c_clkout0", "gpio_48", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0032, "d20", 49, 3, "gpmc_a25", NULL, "c2c_clkout1", "gpio_49", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0034, "b25", 50, 3, "gpmc_ncs0", NULL, NULL, "gpio_50", "sys_ndmareq0", NULL, NULL, NULL),
+ _PINDEF(0x0036, "c21", 51, 3, "gpmc_ncs1", NULL, "c2c_dataout6", "gpio_51", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0038, "d21", 52, 3, "gpmc_ncs2", "kpd_row8", "c2c_dataout7", "gpio_52", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x003a, "c22", 53, 3, "gpmc_ncs3", "gpmc_dir", "c2c_dataout4", "gpio_53", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x003c, "c25", 54, 3, "gpmc_nwp", "dsi1_te0", NULL, "gpio_54", "sys_ndmareq1", NULL, NULL, NULL),
+ _PINDEF(0x003e, "b22", 55, 3, "gpmc_clk", NULL, NULL, "gpio_55", "sys_ndmareq2", "sdmmc1_cmd", NULL, NULL),
+ _PINDEF(0x0040, "d25", 56, 3, "gpmc_nadv_ale", "dsi1_te1", NULL, "gpio_56", "sys_ndmareq3", "sdmmc1_clk", NULL, NULL),
+ _PINDEF(0x0042, "b11", 0, 0, "gpmc_noe", "sdmmc2_clk", NULL, NULL, NULL, NULL, NULL, NULL),
+ _PINDEF(0x0044, "b12", 0, 0, "gpmc_nwe", "sdmmc2_cmd", NULL, NULL, NULL, NULL, NULL, NULL),
+ _PINDEF(0x0046, "c23", 59, 3, "gpmc_nbe0_cle", "dsi2_te0", NULL, "gpio_59", NULL, NULL, NULL, NULL),
+ _PINDEF(0x0048, "d22", 60, 3, "gpmc_nbe1", NULL, "c2c_dataout5", "gpio_60", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x004a, "b26", 61, 3, "gpmc_wait0", "dsi2_te1", NULL, "gpio_61", NULL, NULL, NULL, NULL),
+ _PINDEF(0x004c, "b23", 62, 3, "gpmc_wait1", NULL, "c2c_dataout2", "gpio_62", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x004e, "d23", 100, 3, "gpmc_wait2", "usbc1_icusb_txen", "c2c_dataout3", "gpio_100", "sys_ndmareq0", NULL, NULL, "safe_mode"),
+ _PINDEF(0x0050, "a24", 101, 3, "gpmc_ncs4", "dsi1_te0", "c2c_clkin0", "gpio_101", "sys_ndmareq1", NULL, NULL, "safe_mode"),
+ _PINDEF(0x0052, "b24", 102, 3, "gpmc_ncs5", "dsi1_te1", "c2c_clkin1", "gpio_102", "sys_ndmareq2", NULL, NULL, "safe_mode"),
+ _PINDEF(0x0054, "c24", 103, 3, "gpmc_ncs6", "dsi2_te0", "c2c_dataout0", "gpio_103", "sys_ndmareq3", NULL, NULL, "safe_mode"),
+ _PINDEF(0x0056, "d24", 104, 3, "gpmc_ncs7", "dsi2_te1", "c2c_dataout1", "gpio_104", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0058, "b9", 63, 3, "hdmi_hpd", NULL, NULL, "gpio_63", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x005a, "b10", 64, 3, "hdmi_cec", NULL, NULL, "gpio_64", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x005c, "a8", 65, 3, "hdmi_ddc_scl", NULL, NULL, "gpio_65", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x005e, "b8", 66, 3, "hdmi_ddc_sda", NULL, NULL, "gpio_66", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0060, "r26", 0, 0, "csi21_dx0", NULL, NULL, "gpi_67", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0062, "r25", 0, 0, "csi21_dy0", NULL, NULL, "gpi_68", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0064, "t26", 0, 0, "csi21_dx1", NULL, NULL, "gpi_69", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0066, "t25", 0, 0, "csi21_dy1", NULL, NULL, "gpi_70", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0068, "u26", 0, 0, "csi21_dx2", NULL, NULL, "gpi_71", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x006a, "u25", 0, 0, "csi21_dy2", NULL, NULL, "gpi_72", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x006c, "v26", 0, 0, "csi21_dx3", NULL, NULL, "gpi_73", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x006e, "v25", 0, 0, "csi21_dy3", NULL, NULL, "gpi_74", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0070, "w26", 0, 0, "csi21_dx4", NULL, NULL, "gpi_75", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0072, "w25", 0, 0, "csi21_dy4", NULL, NULL, "gpi_76", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0074, "m26", 0, 0, "csi22_dx0", NULL, NULL, "gpi_77", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0076, "m25", 0, 0, "csi22_dy0", NULL, NULL, "gpi_78", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0078, "n26", 0, 0, "csi22_dx1", NULL, NULL, "gpi_79", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x007a, "n25", 0, 0, "csi22_dy1", NULL, NULL, "gpi_80", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x007c, "t27", 81, 3, "cam_shutter", NULL, NULL, "gpio_81", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x007e, "u27", 82, 3, "cam_strobe", NULL, NULL, "gpio_82", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0080, "v27", 83, 3, "cam_globalreset", NULL, NULL, "gpio_83", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0082, "ae18", 84, 3, "usbb1_ulpitll_clk", "hsi1_cawake", NULL, "gpio_84", "usbb1_ulpiphy_clk", NULL, "hw_dbg20", "safe_mode"),
+ _PINDEF(0x0084, "ag19", 85, 3, "usbb1_ulpitll_stp", "hsi1_cadata", "mcbsp4_clkr", "gpio_85", "usbb1_ulpiphy_stp", "usbb1_mm_rxdp", "hw_dbg21", "safe_mode"),
+ _PINDEF(0x0086, "af19", 86, 3, "usbb1_ulpitll_dir", "hsi1_caflag", "mcbsp4_fsr", "gpio_86", "usbb1_ulpiphy_dir", NULL, "hw_dbg22", "safe_mode"),
+ _PINDEF(0x0088, "ae19", 87, 3, "usbb1_ulpitll_nxt", "hsi1_acready", "mcbsp4_fsx", "gpio_87", "usbb1_ulpiphy_nxt", "usbb1_mm_rxdm", "hw_dbg23", "safe_mode"),
+ _PINDEF(0x008a, "af18", 88, 3, "usbb1_ulpitll_dat0", "hsi1_acwake", "mcbsp4_clkx", "gpio_88", "usbb1_ulpiphy_dat0", "usbb1_mm_txen", "hw_dbg24", "safe_mode"),
+ _PINDEF(0x008c, "ag18", 89, 3, "usbb1_ulpitll_dat1", "hsi1_acdata", "mcbsp4_dx", "gpio_89", "usbb1_ulpiphy_dat1", "usbb1_mm_txdat", "hw_dbg25", "safe_mode"),
+ _PINDEF(0x008e, "ae17", 90, 3, "usbb1_ulpitll_dat2", "hsi1_acflag", "mcbsp4_dr", "gpio_90", "usbb1_ulpiphy_dat2", "usbb1_mm_txse0", "hw_dbg26", "safe_mode"),
+ _PINDEF(0x0090, "af17", 91, 3, "usbb1_ulpitll_dat3", "hsi1_caready", NULL, "gpio_91", "usbb1_ulpiphy_dat3", "usbb1_mm_rxrcv", "hw_dbg27", "safe_mode"),
+ _PINDEF(0x0092, "ah17", 92, 3, "usbb1_ulpitll_dat4", "dmtimer8_pwm_evt", "abe_mcbsp3_dr", "gpio_92", "usbb1_ulpiphy_dat4", NULL, "hw_dbg28", "safe_mode"),
+ _PINDEF(0x0094, "ae16", 93, 3, "usbb1_ulpitll_dat5", "dmtimer9_pwm_evt", "abe_mcbsp3_dx", "gpio_93", "usbb1_ulpiphy_dat5", NULL, "hw_dbg29", "safe_mode"),
+ _PINDEF(0x0096, "af16", 94, 3, "usbb1_ulpitll_dat6", "dmtimer10_pwm_evt", "abe_mcbsp3_clkx", "gpio_94", "usbb1_ulpiphy_dat6", "abe_dmic_din3", "hw_dbg30", "safe_mode"),
+ _PINDEF(0x0098, "ag16", 95, 3, "usbb1_ulpitll_dat7", "dmtimer11_pwm_evt", "abe_mcbsp3_fsx", "gpio_95", "usbb1_ulpiphy_dat7", "abe_dmic_clk3", "hw_dbg31", "safe_mode"),
+ _PINDEF(0x009a, "af14", 96, 3, "usbb1_hsic_data", NULL, NULL, "gpio_96", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x009c, "ae14", 97, 3, "usbb1_hsic_strobe", NULL, NULL, "gpio_97", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x009e, "h2", 98, 3, "usbc1_icusb_dp", NULL, NULL, "gpio_98", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00a0, "h3", 99, 3, "usbc1_icusb_dm", NULL, NULL, "gpio_99", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00a2, "d2", 100, 3, "sdmmc1_clk", NULL, "dpm_emu19", "gpio_100", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00a4, "e3", 101, 3, "sdmmc1_cmd", NULL, "uart1_rx", "gpio_101", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00a6, "e4", 102, 3, "sdmmc1_dat0", NULL, "dpm_emu18", "gpio_102", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00a8, "e2", 103, 3, "sdmmc1_dat1", NULL, "dpm_emu17", "gpio_103", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00aa, "e1", 104, 3, "sdmmc1_dat2", NULL, "dpm_emu16", "gpio_104", "jtag_tms_tmsc", NULL, NULL, "safe_mode"),
+ _PINDEF(0x00ac, "f4", 105, 3, "sdmmc1_dat3", NULL, "dpm_emu15", "gpio_105", "jtag_tck", NULL, NULL, "safe_mode"),
+ _PINDEF(0x00ae, "f3", 106, 3, "sdmmc1_dat4", NULL, NULL, "gpio_106", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00b0, "f1", 107, 3, "sdmmc1_dat5", NULL, NULL, "gpio_107", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00b2, "g4", 108, 3, "sdmmc1_dat6", NULL, NULL, "gpio_108", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00b4, "g3", 109, 3, "sdmmc1_dat7", NULL, NULL, "gpio_109", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00b6, "ad27", 110, 3, "abe_mcbsp2_clkx", "mcspi2_clk", "abe_mcasp_ahclkx", "gpio_110", "usbb2_mm_rxdm", NULL, NULL, "safe_mode"),
+ _PINDEF(0x00b8, "ad26", 111, 3, "abe_mcbsp2_dr", "mcspi2_somi", "abe_mcasp_axr", "gpio_111", "usbb2_mm_rxdp", NULL, NULL, "safe_mode"),
+ _PINDEF(0x00ba, "ad25", 112, 3, "abe_mcbsp2_dx", "mcspi2_simo", "abe_mcasp_amute", "gpio_112", "usbb2_mm_rxrcv", NULL, NULL, "safe_mode"),
+ _PINDEF(0x00bc, "ac28", 113, 3, "abe_mcbsp2_fsx", "mcspi2_cs0", "abe_mcasp_afsx", "gpio_113", "usbb2_mm_txen", NULL, NULL, "safe_mode"),
+ _PINDEF(0x00be, "ac26", 114, 3, "abe_mcbsp1_clkx", "abe_slimbus1_clock", NULL, "gpio_114", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00c0, "ac25", 115, 3, "abe_mcbsp1_dr", "abe_slimbus1_data", NULL, "gpio_115", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00c2, "ab25", 116, 3, "abe_mcbsp1_dx", "sdmmc3_dat2", "abe_mcasp_aclkx", "gpio_116", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00c4, "ac27", 117, 3, "abe_mcbsp1_fsx", "sdmmc3_dat3", "abe_mcasp_amutein", "gpio_117", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00c6, "ag25", 0, 0, "abe_pdm_ul_data", "abe_mcbsp3_dr", NULL, NULL, NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00c8, "af25", 0, 0, "abe_pdm_dl_data", "abe_mcbsp3_dx", NULL, NULL, NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00ca, "ae25", 0, 0, "abe_pdm_frame", "abe_mcbsp3_clkx", NULL, NULL, NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00cc, "af26", 0, 0, "abe_pdm_lb_clk", "abe_mcbsp3_fsx", NULL, NULL, NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00ce, "ah26", 118, 3, "abe_clks", NULL, NULL, "gpio_118", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00d0, "ae24", 119, 3, "abe_dmic_clk1", NULL, NULL, "gpio_119", "usbb2_mm_txse0", "uart4_cts", NULL, "safe_mode"),
+ _PINDEF(0x00d2, "af24", 120, 3, "abe_dmic_din1", NULL, NULL, "gpio_120", "usbb2_mm_txdat", "uart4_rts", NULL, "safe_mode"),
+ _PINDEF(0x00d4, "ag24", 121, 3, "abe_dmic_din2", "slimbus2_clock", "abe_mcasp_axr", "gpio_121", NULL, "dmtimer11_pwm_evt", NULL, "safe_mode"),
+ _PINDEF(0x00d6, "ah24", 122, 3, "abe_dmic_din3", "slimbus2_data", "abe_dmic_clk2", "gpio_122", NULL, "dmtimer9_pwm_evt", NULL, "safe_mode"),
+ _PINDEF(0x00d8, "ab26", 123, 3, "uart2_cts", "sdmmc3_clk", NULL, "gpio_123", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00da, "ab27", 124, 3, "uart2_rts", "sdmmc3_cmd", NULL, "gpio_124", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00dc, "aa25", 125, 3, "uart2_rx", "sdmmc3_dat0", NULL, "gpio_125", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00de, "aa26", 126, 3, "uart2_tx", "sdmmc3_dat1", NULL, "gpio_126", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00e0, "aa27", 127, 3, "hdq_sio", "i2c3_sccb", "i2c2_sccb", "gpio_127", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00e2, "ae28", 0, 0, "i2c1_scl", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PINDEF(0x00e4, "ae26", 0, 0, "i2c1_sda", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PINDEF(0x00e6, "c26", 128, 3, "i2c2_scl", "uart1_rx", NULL, "gpio_128", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00e8, "d26", 129, 3, "i2c2_sda", "uart1_tx", NULL, "gpio_129", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00ea, "w27", 130, 3, "i2c3_scl", NULL, NULL, "gpio_130", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00ec, "y27", 131, 3, "i2c3_sda", NULL, NULL, "gpio_131", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00ee, "ag21", 132, 3, "i2c4_scl", NULL, NULL, "gpio_132", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00f0, "ah22", 133, 3, "i2c4_sda", NULL, NULL, "gpio_133", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00f2, "af22", 134, 3, "mcspi1_clk", NULL, NULL, "gpio_134", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00f4, "ae22", 135, 3, "mcspi1_somi", NULL, NULL, "gpio_135", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00f6, "ag22", 136, 3, "mcspi1_simo", NULL, NULL, "gpio_136", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00f8, "ae23", 137, 3, "mcspi1_cs0", NULL, NULL, "gpio_137", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00fa, "af23", 138, 3, "mcspi1_cs1", "uart1_rx", NULL, "gpio_138", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00fc, "ag23", 139, 3, "mcspi1_cs2", "uart1_cts", "slimbus2_clock", "gpio_139", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x00fe, "ah23", 140, 3, "mcspi1_cs3", "uart1_rts", "slimbus2_data", "gpio_140", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0100, "f27", 141, 3, "uart3_cts_rctx", "uart1_tx", NULL, "gpio_141", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0102, "f28", 142, 3, "uart3_rts_sd", NULL, NULL, "gpio_142", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0104, "g27", 143, 3, "uart3_rx_irrx", "dmtimer8_pwm_evt", NULL, "gpio_143", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0106, "g28", 144, 3, "uart3_tx_irtx", "dmtimer9_pwm_evt", NULL, "gpio_144", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0108, "ae5", 145, 3, "sdmmc5_clk", "mcspi2_clk", "usbc1_icusb_dp", "gpio_145", NULL, "sdmmc2_clk", NULL, "safe_mode"),
+ _PINDEF(0x010a, "af5", 146, 3, "sdmmc5_cmd", "mcspi2_simo", "usbc1_icusb_dm", "gpio_146", NULL, "sdmmc2_cmd", NULL, "safe_mode"),
+ _PINDEF(0x010c, "ae4", 147, 3, "sdmmc5_dat0", "mcspi2_somi", "usbc1_icusb_rcv", "gpio_147", NULL, "sdmmc2_dat0", NULL, "safe_mode"),
+ _PINDEF(0x010e, "af4", 148, 3, "sdmmc5_dat1", NULL, "usbc1_icusb_txen", "gpio_148", NULL, "sdmmc2_dat1", NULL, "safe_mode"),
+ _PINDEF(0x0110, "ag3", 149, 3, "sdmmc5_dat2", "mcspi2_cs1", NULL, "gpio_149", NULL, "sdmmc2_dat2", NULL, "safe_mode"),
+ _PINDEF(0x0112, "af3", 150, 3, "sdmmc5_dat3", "mcspi2_cs0", NULL, "gpio_150", NULL, "sdmmc2_dat3", NULL, "safe_mode"),
+ _PINDEF(0x0114, "ae21", 151, 3, "mcspi4_clk", "sdmmc4_clk", "kpd_col6", "gpio_151", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0116, "af20", 152, 3, "mcspi4_simo", "sdmmc4_cmd", "kpd_col7", "gpio_152", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0118, "af21", 153, 3, "mcspi4_somi", "sdmmc4_dat0", "kpd_row6", "gpio_153", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x011a, "ae20", 154, 3, "mcspi4_cs0", "sdmmc4_dat3", "kpd_row7", "gpio_154", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x011c, "ag20", 155, 3, "uart4_rx", "sdmmc4_dat2", "kpd_row8", "gpio_155", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x011e, "ah19", 156, 3, "uart4_tx", "sdmmc4_dat1", "kpd_col8", "gpio_156", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0120, "ag12", 157, 3, "usbb2_ulpitll_clk", "usbb2_ulpiphy_clk", "sdmmc4_cmd", "gpio_157", "hsi2_cawake", NULL, NULL, "safe_mode"),
+ _PINDEF(0x0122, "af12", 158, 3, "usbb2_ulpitll_stp", "usbb2_ulpiphy_stp", "sdmmc4_clk", "gpio_158", "hsi2_cadata", "dispc2_data23", NULL, "safe_mode"),
+ _PINDEF(0x0124, "ae12", 159, 3, "usbb2_ulpitll_dir", "usbb2_ulpiphy_dir", "sdmmc4_dat0", "gpio_159", "hsi2_caflag", "dispc2_data22", NULL, "safe_mode"),
+ _PINDEF(0x0126, "ag13", 160, 3, "usbb2_ulpitll_nxt", "usbb2_ulpiphy_nxt", "sdmmc4_dat1", "gpio_160", "hsi2_acready", "dispc2_data21", NULL, "safe_mode"),
+ _PINDEF(0x0128, "ae11", 161, 3, "usbb2_ulpitll_dat0", "usbb2_ulpiphy_dat0", "sdmmc4_dat2", "gpio_161", "hsi2_acwake", "dispc2_data20", "usbb2_mm_txen", "safe_mode"),
+ _PINDEF(0x012a, "af11", 162, 3, "usbb2_ulpitll_dat1", "usbb2_ulpiphy_dat1", "sdmmc4_dat3", "gpio_162", "hsi2_acdata", "dispc2_data19", "usbb2_mm_txdat", "safe_mode"),
+ _PINDEF(0x012c, "ag11", 163, 3, "usbb2_ulpitll_dat2", "usbb2_ulpiphy_dat2", "sdmmc3_dat2", "gpio_163", "hsi2_acflag", "dispc2_data18", "usbb2_mm_txse0", "safe_mode"),
+ _PINDEF(0x012e, "ah11", 164, 3, "usbb2_ulpitll_dat3", "usbb2_ulpiphy_dat3", "sdmmc3_dat1", "gpio_164", "hsi2_caready", "dispc2_data15", "rfbi_data15", "safe_mode"),
+ _PINDEF(0x0130, "ae10", 165, 3, "usbb2_ulpitll_dat4", "usbb2_ulpiphy_dat4", "sdmmc3_dat0", "gpio_165", "mcspi3_somi", "dispc2_data14", "rfbi_data14", "safe_mode"),
+ _PINDEF(0x0132, "af10", 166, 3, "usbb2_ulpitll_dat5", "usbb2_ulpiphy_dat5", "sdmmc3_dat3", "gpio_166", "mcspi3_cs0", "dispc2_data13", "rfbi_data13", "safe_mode"),
+ _PINDEF(0x0134, "ag10", 167, 3, "usbb2_ulpitll_dat6", "usbb2_ulpiphy_dat6", "sdmmc3_cmd", "gpio_167", "mcspi3_simo", "dispc2_data12", "rfbi_data12", "safe_mode"),
+ _PINDEF(0x0136, "ae9", 168, 3, "usbb2_ulpitll_dat7", "usbb2_ulpiphy_dat7", "sdmmc3_clk", "gpio_168", "mcspi3_clk", "dispc2_data11", "rfbi_data11", "safe_mode"),
+ _PINDEF(0x0138, "af13", 169, 3, "usbb2_hsic_data", NULL, NULL, "gpio_169", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x013a, "ae13", 170, 3, "usbb2_hsic_strobe", NULL, NULL, "gpio_170", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x013c, "g26", 171, 3, "kpd_col3", "kpd_col0", NULL, "gpio_171", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x013e, "g25", 172, 3, "kpd_col4", "kpd_col1", NULL, "gpio_172", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0140, "h26", 173, 3, "kpd_col5", "kpd_col2", NULL, "gpio_173", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0142, "h25", 174, 3, "kpd_col0", "kpd_col3", NULL, "gpio_174", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0144, "j27", 0, 0, "kpd_col1", "kpd_col4", NULL, "gpio_0", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0146, "h27", 1, 3, "kpd_col2", "kpd_col5", NULL, "gpio_1", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0148, "j26", 175, 3, "kpd_row3", "kpd_row0", NULL, "gpio_175", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x014a, "j25", 176, 3, "kpd_row4", "kpd_row1", NULL, "gpio_176", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x014c, "k26", 177, 3, "kpd_row5", "kpd_row2", NULL, "gpio_177", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x014e, "k25", 178, 3, "kpd_row0", "kpd_row3", NULL, "gpio_178", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0150, "l27", 2, 3, "kpd_row1", "kpd_row4", NULL, "gpio_2", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0152, "k27", 3, 3, "kpd_row2", "kpd_row5", NULL, "gpio_3", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0154, "c3", 0, 0, "usba0_otg_ce", NULL, NULL, NULL, NULL, NULL, NULL, NULL),
+ _PINDEF(0x0156, "b5", 0, 0, "usba0_otg_dp", "uart3_rx_irrx", "uart2_rx", NULL, NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0158, "b4", 0, 0, "usba0_otg_dm", "uart3_tx_irtx", "uart2_tx", NULL, NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x015a, "aa28", 181, 3, "fref_clk1_out", NULL, NULL, "gpio_181", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x015c, "y28", 182, 3, "fref_clk2_out", NULL, NULL, "gpio_182", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x015e, "ae6", 0, 0, "sys_nirq1", NULL, NULL, NULL, NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0160, "af6", 183, 3, "sys_nirq2", NULL, NULL, "gpio_183", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0162, "f26", 184, 3, "sys_boot0", NULL, NULL, "gpio_184", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0164, "e27", 185, 3, "sys_boot1", NULL, NULL, "gpio_185", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0166, "e26", 186, 3, "sys_boot2", NULL, NULL, "gpio_186", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x0168, "e25", 187, 3, "sys_boot3", NULL, NULL, "gpio_187", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x016a, "d28", 188, 3, "sys_boot4", NULL, NULL, "gpio_188", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x016c, "d27", 189, 3, "sys_boot5", NULL, NULL, "gpio_189", NULL, NULL, NULL, "safe_mode"),
+ _PINDEF(0x016e, "m2", 11, 3, "dpm_emu0", NULL, NULL, "gpio_11", NULL, NULL, "hw_dbg0", "safe_mode"),
+ _PINDEF(0x0170, "n2", 12, 3, "dpm_emu1", NULL, NULL, "gpio_12", NULL, NULL, "hw_dbg1", "safe_mode"),
+ _PINDEF(0x0172, "p2", 13, 3, "dpm_emu2", "usba0_ulpiphy_clk", NULL, "gpio_13", NULL, "dispc2_fid", "hw_dbg2", "safe_mode"),
+ _PINDEF(0x0174, "v1", 14, 3, "dpm_emu3", "usba0_ulpiphy_stp", NULL, "gpio_14", "rfbi_data10", "dispc2_data10", "hw_dbg3", "safe_mode"),
+ _PINDEF(0x0176, "v2", 15, 3, "dpm_emu4", "usba0_ulpiphy_dir", NULL, "gpio_15", "rfbi_data9", "dispc2_data9", "hw_dbg4", "safe_mode"),
+ _PINDEF(0x0178, "w1", 16, 3, "dpm_emu5", "usba0_ulpiphy_nxt", NULL, "gpio_16", "rfbi_te_vsync0", "dispc2_data16", "hw_dbg5", "safe_mode"),
+ _PINDEF(0x017a, "w2", 17, 3, "dpm_emu6", "usba0_ulpiphy_dat0", "uart3_tx_irtx", "gpio_17", "rfbi_hsync0", "dispc2_data17", "hw_dbg6", "safe_mode"),
+ _PINDEF(0x017c, "w3", 18, 3, "dpm_emu7", "usba0_ulpiphy_dat1", "uart3_rx_irrx", "gpio_18", "rfbi_cs0", "dispc2_hsync", "hw_dbg7", "safe_mode"),
+ _PINDEF(0x017e, "w4", 19, 3, "dpm_emu8", "usba0_ulpiphy_dat2", "uart3_rts_sd", "gpio_19", "rfbi_re", "dispc2_pclk", "hw_dbg8", "safe_mode"),
+ _PINDEF(0x0180, "y2", 20, 3, "dpm_emu9", "usba0_ulpiphy_dat3", "uart3_cts_rctx", "gpio_20", "rfbi_we", "dispc2_vsync", "hw_dbg9", "safe_mode"),
+ _PINDEF(0x0182, "y3", 21, 3, "dpm_emu10", "usba0_ulpiphy_dat4", NULL, "gpio_21", "rfbi_a0", "dispc2_de", "hw_dbg10", "safe_mode"),
+ _PINDEF(0x0184, "y4", 22, 3, "dpm_emu11", "usba0_ulpiphy_dat5", NULL, "gpio_22", "rfbi_data8", "dispc2_data8", "hw_dbg11", "safe_mode"),
+ _PINDEF(0x0186, "aa1", 23, 3, "dpm_emu12", "usba0_ulpiphy_dat6", NULL, "gpio_23", "rfbi_data7", "dispc2_data7", "hw_dbg12", "safe_mode"),
+ _PINDEF(0x0188, "aa2", 24, 3, "dpm_emu13", "usba0_ulpiphy_dat7", NULL, "gpio_24", "rfbi_data6", "dispc2_data6", "hw_dbg13", "safe_mode"),
+ _PINDEF(0x018a, "aa3", 25, 3, "dpm_emu14", "sys_drm_msecure", "uart1_rx", "gpio_25", "rfbi_data5", "dispc2_data5", "hw_dbg14", "safe_mode"),
+ _PINDEF(0x018c, "aa4", 26, 3, "dpm_emu15", "sys_secure_indicator", NULL, "gpio_26", "rfbi_data4", "dispc2_data4", "hw_dbg15", "safe_mode"),
+ _PINDEF(0x018e, "ab2", 27, 3, "dpm_emu16", "dmtimer8_pwm_evt", "dsi1_te0", "gpio_27", "rfbi_data3", "dispc2_data3", "hw_dbg16", "safe_mode"),
+ _PINDEF(0x0190, "ab3", 28, 3, "dpm_emu17", "dmtimer9_pwm_evt", "dsi1_te1", "gpio_28", "rfbi_data2", "dispc2_data2", "hw_dbg17", "safe_mode"),
+ _PINDEF(0x0192, "ab4", 190, 3, "dpm_emu18", "dmtimer10_pwm_evt", "dsi2_te0", "gpio_190", "rfbi_data1", "dispc2_data1", "hw_dbg18", "safe_mode"),
+ _PINDEF(0x0194, "ac4", 191, 3, "dpm_emu19", "dmtimer11_pwm_evt", "dsi2_te1", "gpio_191", "rfbi_data0", "dispc2_data0", "hw_dbg19", "safe_mode"),
{ .ballname = NULL },
};
-const struct ti_scm_device ti_scm_dev = {
+const struct ti_pinmux_device ti_pinmux_dev = {
.padconf_muxmode_mask = CONTROL_PADCONF_MUXMODE_MASK,
.padconf_sate_mask = CONTROL_PADCONF_SATE_MASK,
.padstate = ti_padstate_devmap,
diff --git a/sys/arm/ti/omap4/omap4var.h b/sys/arm/ti/omap4/omap4var.h
deleted file mode 100644
index 8246e76..0000000
--- a/sys/arm/ti/omap4/omap4var.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*-
- * Copyright (c) 2010
- * Ben Gray <ben.r.gray@gmail.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 company 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 BEN GRAY ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL BEN GRAY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 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 _OMAP4VAR_H_
-#define _OMAP4VAR_H_
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/time.h>
-#include <sys/bus.h>
-#include <sys/resource.h>
-#include <sys/rman.h>
-#include <sys/sysctl.h>
-#include <sys/endian.h>
-
-#include <machine/bus.h>
-#include <machine/cpu.h>
-#include <machine/cpufunc.h>
-#include <machine/resource.h>
-#include <machine/intr.h>
-
-
-void omap4_mask_all_intr(void);
-void omap4_post_filter_intr(void *arg);
-
-struct omap4_softc {
- device_t sc_dev;
- bus_space_tag_t sc_iotag;
-
- /* Handles for the two generic interrupt controller (GIC) register mappings */
- bus_space_handle_t sc_gic_cpu_ioh;
- bus_space_handle_t sc_gic_dist_ioh;
-
- /* Handle for the PL310 L2 cache controller */
- bus_space_handle_t sc_pl310_ioh;
-
- /* Handle for the global and provate timer register set in the Cortex core */
- bus_space_handle_t sc_prv_timer_ioh;
- bus_space_handle_t sc_gbl_timer_ioh;
-
- /* SCM access */
- struct resource *sc_scm_mem;
- int sc_scm_rid;
-};
-
-struct omap4_intr_conf {
- int num;
- unsigned int priority;
- unsigned int target_cpu;
-};
-
-int omap4_setup_intr_controller(device_t dev,
- const struct omap4_intr_conf *irqs);
-int omap4_setup_gic_cpu(unsigned int prio_mask);
-
-void omap4_init_timer(device_t dev);
-
-int omap4_setup_l2cache_controller(struct omap4_softc *sc);
-void omap4_smc_call(uint32_t fn, uint32_t arg);
-
-#endif /* _OMAP4VAR_H_ */
diff --git a/sys/arm/ti/omap4/pandaboard/pandaboard.c b/sys/arm/ti/omap4/pandaboard/pandaboard.c
index e480132..20e5e8a6 100644
--- a/sys/arm/ti/omap4/pandaboard/pandaboard.c
+++ b/sys/arm/ti/omap4/pandaboard/pandaboard.c
@@ -42,7 +42,6 @@ __FBSDID("$FreeBSD$");
#include <machine/vmparam.h>
#include <machine/fdt.h>
-#include <arm/ti/omap4/omap4var.h>
#include <arm/ti/omap4/omap4_reg.h>
/* Registers in the SCRM that control the AUX clocks */
diff --git a/sys/arm/ti/ti_adc.c b/sys/arm/ti/ti_adc.c
index c5710d7..d65afc6 100644
--- a/sys/arm/ti/ti_adc.c
+++ b/sys/arm/ti/ti_adc.c
@@ -467,7 +467,7 @@ static int
ti_adc_probe(device_t dev)
{
- if (!ofw_bus_is_compatible(dev, "ti,adc"))
+ if (!ofw_bus_is_compatible(dev, "ti,am3359-tscadc"))
return (ENXIO);
device_set_desc(dev, "TI ADC controller");
diff --git a/sys/arm/ti/ti_common.c b/sys/arm/ti/ti_common.c
index 4d12c71..50072f2 100644
--- a/sys/arm/ti/ti_common.c
+++ b/sys/arm/ti/ti_common.c
@@ -44,36 +44,21 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
+#include <machine/intr.h>
#include <machine/vmparam.h>
struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
};
-#ifdef SOC_OMAP4
-static int
-fdt_gic_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
- int *pol)
-{
-
- if (!fdt_is_compatible(node, "arm,gic"))
- return (ENXIO);
-
- *interrupt = fdt32_to_cpu(intr[0]);
- *trig = INTR_TRIGGER_CONFORM;
- *pol = INTR_POLARITY_CONFORM;
-
- return (0);
-}
-#endif
-
#ifdef SOC_TI_AM335X
static int
fdt_aintc_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
int *pol)
{
- if (!fdt_is_compatible(node, "ti,aintc"))
+ if (!fdt_is_compatible(node, "ti,aintc") &&
+ !fdt_is_compatible(node, "ti,am33xx-intc"))
return (ENXIO);
*interrupt = fdt32_to_cpu(intr[0]);
@@ -86,7 +71,7 @@ fdt_aintc_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
fdt_pic_decode_t fdt_pic_table[] = {
#ifdef SOC_OMAP4
- &fdt_gic_decode_ic,
+ &gic_decode_fdt,
#endif
#ifdef SOC_TI_AM335X
&fdt_aintc_decode_ic,
diff --git a/sys/arm/ti/ti_edma3.c b/sys/arm/ti/ti_edma3.c
index 1489ff7..080e7bd 100644
--- a/sys/arm/ti/ti_edma3.c
+++ b/sys/arm/ti/ti_edma3.c
@@ -99,7 +99,11 @@ __FBSDID("$FreeBSD$");
struct ti_edma3_softc {
device_t sc_dev;
- struct resource * mem_res[TI_EDMA3_NUM_TCS+1];
+ /*
+ * We use one-element array in case if we need to add
+ * mem resources for transfer control windows
+ */
+ struct resource * mem_res[1];
struct resource * irq_res[TI_EDMA3_NUM_IRQS];
void *ih_cookie[TI_EDMA3_NUM_IRQS];
};
@@ -108,9 +112,6 @@ static struct ti_edma3_softc *ti_edma3_sc = NULL;
static struct resource_spec ti_edma3_mem_spec[] = {
{ SYS_RES_MEMORY, 0, RF_ACTIVE },
- { SYS_RES_MEMORY, 1, RF_ACTIVE },
- { SYS_RES_MEMORY, 2, RF_ACTIVE },
- { SYS_RES_MEMORY, 3, RF_ACTIVE },
{ -1, 0, 0 }
};
static struct resource_spec ti_edma3_irq_spec[] = {
@@ -123,8 +124,6 @@ static struct resource_spec ti_edma3_irq_spec[] = {
/* Read/Write macros */
#define ti_edma3_cc_rd_4(reg) bus_read_4(ti_edma3_sc->mem_res[0], reg)
#define ti_edma3_cc_wr_4(reg, val) bus_write_4(ti_edma3_sc->mem_res[0], reg, val)
-#define ti_edma3_tc_rd_4(c, reg) bus_read_4(ti_edma3_sc->mem_res[c+1], reg)
-#define ti_edma3_tc_wr_4(c, reg, val) bus_write_4(ti_edma3_sc->mem_res[c+1], reg, val)
static void ti_edma3_intr_comp(void *arg);
static void ti_edma3_intr_mperr(void *arg);
diff --git a/sys/arm/ti/ti_gpio.c b/sys/arm/ti/ti_gpio.c
index d0ce918..8e28adc 100644
--- a/sys/arm/ti/ti_gpio.c
+++ b/sys/arm/ti/ti_gpio.c
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
#include <arm/ti/ti_gpio.h>
#include <arm/ti/ti_scm.h>
#include <arm/ti/ti_prcm.h>
+#include <arm/ti/ti_hwmods.h>
#include <dev/fdt/fdt_common.h>
#include <dev/gpio/gpiobusvar.h>
@@ -101,54 +102,18 @@ __FBSDID("$FreeBSD$");
#define TI_GPIO_SETDATAOUT 0x0194
/* Other SoC Specific definitions */
-#define OMAP4_MAX_GPIO_BANKS 6
#define OMAP4_FIRST_GPIO_BANK 1
#define OMAP4_INTR_PER_BANK 1
#define OMAP4_GPIO_REV 0x50600801
-#define AM335X_MAX_GPIO_BANKS 4
#define AM335X_FIRST_GPIO_BANK 0
#define AM335X_INTR_PER_BANK 2
#define AM335X_GPIO_REV 0x50600801
#define PINS_PER_BANK 32
-#define TI_GPIO_BANK(p) ((p) / PINS_PER_BANK)
#define TI_GPIO_MASK(p) (1U << ((p) % PINS_PER_BANK))
-static struct ti_gpio_softc *ti_gpio_sc = NULL;
static int ti_gpio_detach(device_t);
static u_int
-ti_max_gpio_banks(void)
-{
- switch(ti_chip()) {
-#ifdef SOC_OMAP4
- case CHIP_OMAP_4:
- return (OMAP4_MAX_GPIO_BANKS);
-#endif
-#ifdef SOC_TI_AM335X
- case CHIP_AM335X:
- return (AM335X_MAX_GPIO_BANKS);
-#endif
- }
- return (0);
-}
-
-static u_int
-ti_max_gpio_intrs(void)
-{
- switch(ti_chip()) {
-#ifdef SOC_OMAP4
- case CHIP_OMAP_4:
- return (OMAP4_MAX_GPIO_BANKS * OMAP4_INTR_PER_BANK);
-#endif
-#ifdef SOC_TI_AM335X
- case CHIP_AM335X:
- return (AM335X_MAX_GPIO_BANKS * AM335X_INTR_PER_BANK);
-#endif
- }
- return (0);
-}
-
-static u_int
ti_first_gpio_bank(void)
{
switch(ti_chip()) {
@@ -181,47 +146,6 @@ ti_gpio_rev(void)
}
/**
- * ti_gpio_mem_spec - Resource specification used when allocating resources
- * ti_gpio_irq_spec - Resource specification used when allocating resources
- *
- * This driver module can have up to six independent memory regions, each
- * region typically controls 32 GPIO pins.
- *
- * On OMAP3 and OMAP4 there is only one physical interrupt line per bank,
- * but there are two set of registers which control the interrupt delivery
- * to internal subsystems. The first set of registers control the
- * interrupts delivery to the MPU and the second set control the
- * interrupts delivery to the DSP.
- *
- * On AM335x there are two physical interrupt lines for each GPIO module.
- * Each interrupt line is controlled by a set of registers.
- */
-static struct resource_spec ti_gpio_mem_spec[] = {
- { SYS_RES_MEMORY, 0, RF_ACTIVE },
- { SYS_RES_MEMORY, 1, RF_ACTIVE | RF_OPTIONAL },
- { SYS_RES_MEMORY, 2, RF_ACTIVE | RF_OPTIONAL },
- { SYS_RES_MEMORY, 3, RF_ACTIVE | RF_OPTIONAL },
-#if !defined(SOC_TI_AM335X)
- { SYS_RES_MEMORY, 4, RF_ACTIVE | RF_OPTIONAL },
- { SYS_RES_MEMORY, 5, RF_ACTIVE | RF_OPTIONAL },
-#endif
- { -1, 0, 0 }
-};
-static struct resource_spec ti_gpio_irq_spec[] = {
- { SYS_RES_IRQ, 0, RF_ACTIVE },
- { SYS_RES_IRQ, 1, RF_ACTIVE | RF_OPTIONAL },
- { SYS_RES_IRQ, 2, RF_ACTIVE | RF_OPTIONAL },
- { SYS_RES_IRQ, 3, RF_ACTIVE | RF_OPTIONAL },
- { SYS_RES_IRQ, 4, RF_ACTIVE | RF_OPTIONAL },
- { SYS_RES_IRQ, 5, RF_ACTIVE | RF_OPTIONAL },
-#if defined(SOC_TI_AM335X)
- { SYS_RES_IRQ, 6, RF_ACTIVE | RF_OPTIONAL },
- { SYS_RES_IRQ, 7, RF_ACTIVE | RF_OPTIONAL },
-#endif
- { -1, 0, 0 }
-};
-
-/**
* Macros for driver mutex locking
*/
#define TI_GPIO_LOCK(_sc) mtx_lock_spin(&(_sc)->sc_mtx)
@@ -244,9 +168,9 @@ static struct resource_spec ti_gpio_irq_spec[] = {
* 32-bit value read from the register.
*/
static inline uint32_t
-ti_gpio_read_4(struct ti_gpio_softc *sc, unsigned int bank, bus_size_t off)
+ti_gpio_read_4(struct ti_gpio_softc *sc, bus_size_t off)
{
- return (bus_read_4(sc->sc_mem_res[bank], off));
+ return (bus_read_4(sc->sc_mem_res, off));
}
/**
@@ -260,52 +184,52 @@ ti_gpio_read_4(struct ti_gpio_softc *sc, unsigned int bank, bus_size_t off)
* nothing
*/
static inline void
-ti_gpio_write_4(struct ti_gpio_softc *sc, unsigned int bank, bus_size_t off,
+ti_gpio_write_4(struct ti_gpio_softc *sc, bus_size_t off,
uint32_t val)
{
- bus_write_4(sc->sc_mem_res[bank], off, val);
+ bus_write_4(sc->sc_mem_res, off, val);
}
static inline void
-ti_gpio_intr_clr(struct ti_gpio_softc *sc, unsigned int bank, uint32_t mask)
+ti_gpio_intr_clr(struct ti_gpio_softc *sc, uint32_t mask)
{
/* We clear both set of registers. */
- ti_gpio_write_4(sc, bank, TI_GPIO_IRQSTATUS_CLR_0, mask);
- ti_gpio_write_4(sc, bank, TI_GPIO_IRQSTATUS_CLR_1, mask);
+ ti_gpio_write_4(sc, TI_GPIO_IRQSTATUS_CLR_0, mask);
+ ti_gpio_write_4(sc, TI_GPIO_IRQSTATUS_CLR_1, mask);
}
static inline void
-ti_gpio_intr_set(struct ti_gpio_softc *sc, unsigned int bank, uint32_t mask)
+ti_gpio_intr_set(struct ti_gpio_softc *sc, uint32_t mask)
{
/*
* On OMAP4 we unmask only the MPU interrupt and on AM335x we
* also activate only the first interrupt.
*/
- ti_gpio_write_4(sc, bank, TI_GPIO_IRQSTATUS_SET_0, mask);
+ ti_gpio_write_4(sc, TI_GPIO_IRQSTATUS_SET_0, mask);
}
static inline void
-ti_gpio_intr_ack(struct ti_gpio_softc *sc, unsigned int bank, uint32_t mask)
+ti_gpio_intr_ack(struct ti_gpio_softc *sc, uint32_t mask)
{
/*
* Acknowledge the interrupt on both registers even if we use only
* the first one.
*/
- ti_gpio_write_4(sc, bank, TI_GPIO_IRQSTATUS_0, mask);
- ti_gpio_write_4(sc, bank, TI_GPIO_IRQSTATUS_1, mask);
+ ti_gpio_write_4(sc, TI_GPIO_IRQSTATUS_0, mask);
+ ti_gpio_write_4(sc, TI_GPIO_IRQSTATUS_1, mask);
}
static inline uint32_t
-ti_gpio_intr_status(struct ti_gpio_softc *sc, unsigned int bank)
+ti_gpio_intr_status(struct ti_gpio_softc *sc)
{
uint32_t reg;
/* Get the status from both registers. */
- reg = ti_gpio_read_4(sc, bank, TI_GPIO_IRQSTATUS_0);
- reg |= ti_gpio_read_4(sc, bank, TI_GPIO_IRQSTATUS_1);
+ reg = ti_gpio_read_4(sc, TI_GPIO_IRQSTATUS_0);
+ reg |= ti_gpio_read_4(sc, TI_GPIO_IRQSTATUS_1);
return (reg);
}
@@ -337,7 +261,7 @@ static int
ti_gpio_pin_max(device_t dev, int *maxpin)
{
- *maxpin = ti_max_gpio_banks() * PINS_PER_BANK - 1;
+ *maxpin = PINS_PER_BANK - 1;
return (0);
}
@@ -346,11 +270,8 @@ static int
ti_gpio_valid_pin(struct ti_gpio_softc *sc, int pin)
{
- if (pin >= sc->sc_maxpin ||
- TI_GPIO_BANK(pin) >= ti_max_gpio_banks() ||
- sc->sc_mem_res[TI_GPIO_BANK(pin)] == NULL) {
+ if (pin >= sc->sc_maxpin || sc->sc_mem_res == NULL)
return (EINVAL);
- }
return (0);
}
@@ -489,12 +410,12 @@ ti_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags)
}
/* If configuring as an output set the "output enable" bit */
- oe = ti_gpio_read_4(sc, TI_GPIO_BANK(pin), TI_GPIO_OE);
+ oe = ti_gpio_read_4(sc, TI_GPIO_OE);
if (flags & GPIO_PIN_INPUT)
oe |= TI_GPIO_MASK(pin);
else
oe &= ~TI_GPIO_MASK(pin);
- ti_gpio_write_4(sc, TI_GPIO_BANK(pin), TI_GPIO_OE, oe);
+ ti_gpio_write_4(sc, TI_GPIO_OE, oe);
TI_GPIO_UNLOCK(sc);
return (0);
@@ -529,7 +450,7 @@ ti_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value)
reg = TI_GPIO_CLEARDATAOUT;
else
reg = TI_GPIO_SETDATAOUT;
- ti_gpio_write_4(sc, TI_GPIO_BANK(pin), reg, TI_GPIO_MASK(pin));
+ ti_gpio_write_4(sc, reg, TI_GPIO_MASK(pin));
TI_GPIO_UNLOCK(sc);
return (0);
@@ -565,12 +486,12 @@ ti_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *value)
* input register otherwise.
*/
TI_GPIO_LOCK(sc);
- oe = ti_gpio_read_4(sc, TI_GPIO_BANK(pin), TI_GPIO_OE);
+ oe = ti_gpio_read_4(sc, TI_GPIO_OE);
if (oe & TI_GPIO_MASK(pin))
reg = TI_GPIO_DATAIN;
else
reg = TI_GPIO_DATAOUT;
- val = ti_gpio_read_4(sc, TI_GPIO_BANK(pin), reg);
+ val = ti_gpio_read_4(sc, reg);
*value = (val & TI_GPIO_MASK(pin)) ? 1 : 0;
TI_GPIO_UNLOCK(sc);
@@ -601,12 +522,12 @@ ti_gpio_pin_toggle(device_t dev, uint32_t pin)
/* Toggle the pin */
TI_GPIO_LOCK(sc);
- val = ti_gpio_read_4(sc, TI_GPIO_BANK(pin), TI_GPIO_DATAOUT);
+ val = ti_gpio_read_4(sc, TI_GPIO_DATAOUT);
if (val & TI_GPIO_MASK(pin))
reg = TI_GPIO_CLEARDATAOUT;
else
reg = TI_GPIO_SETDATAOUT;
- ti_gpio_write_4(sc, TI_GPIO_BANK(pin), reg, TI_GPIO_MASK(pin));
+ ti_gpio_write_4(sc, reg, TI_GPIO_MASK(pin));
TI_GPIO_UNLOCK(sc);
return (0);
@@ -631,13 +552,8 @@ ti_gpio_intr(void *arg)
sc = (struct ti_gpio_softc *)arg;
bank_last = -1;
reg = 0; /* squelch bogus gcc warning */
+ reg = ti_gpio_intr_status(sc);
for (irq = 0; irq < sc->sc_maxpin; irq++) {
-
- /* Read interrupt status only once for each bank. */
- if (TI_GPIO_BANK(irq) != bank_last) {
- reg = ti_gpio_intr_status(sc, TI_GPIO_BANK(irq));
- bank_last = TI_GPIO_BANK(irq);
- }
if ((reg & TI_GPIO_MASK(irq)) == 0)
continue;
event = sc->sc_events[irq];
@@ -646,96 +562,57 @@ ti_gpio_intr(void *arg)
else
device_printf(sc->sc_dev, "Stray IRQ %d\n", irq);
/* Ack the IRQ Status bit. */
- ti_gpio_intr_ack(sc, TI_GPIO_BANK(irq), TI_GPIO_MASK(irq));
+ ti_gpio_intr_ack(sc, TI_GPIO_MASK(irq));
}
return (FILTER_HANDLED);
}
static int
-ti_gpio_attach_intr(device_t dev)
-{
- int i;
- struct ti_gpio_softc *sc;
-
- sc = device_get_softc(dev);
- for (i = 0; i < ti_max_gpio_intrs(); i++) {
- if (sc->sc_irq_res[i] == NULL)
- break;
-
- /*
- * Register our interrupt filter for each of the IRQ resources.
- */
- if (bus_setup_intr(dev, sc->sc_irq_res[i],
- INTR_TYPE_MISC | INTR_MPSAFE, ti_gpio_intr, NULL, sc,
- &sc->sc_irq_hdl[i]) != 0) {
- device_printf(dev,
- "WARNING: unable to register interrupt filter\n");
- return (-1);
- }
- }
-
- return (0);
-}
-
-static int
-ti_gpio_detach_intr(device_t dev)
-{
- int i;
- struct ti_gpio_softc *sc;
-
- /* Teardown our interrupt filters. */
- sc = device_get_softc(dev);
- for (i = 0; i < ti_max_gpio_intrs(); i++) {
- if (sc->sc_irq_res[i] == NULL)
- break;
-
- if (sc->sc_irq_hdl[i]) {
- bus_teardown_intr(dev, sc->sc_irq_res[i],
- sc->sc_irq_hdl[i]);
- }
- }
-
- return (0);
-}
-
-static int
-ti_gpio_bank_init(device_t dev, int bank)
+ti_gpio_bank_init(device_t dev)
{
int pin;
struct ti_gpio_softc *sc;
uint32_t flags, reg_oe, rev;
+ clk_ident_t clk;
sc = device_get_softc(dev);
/* Enable the interface and functional clocks for the module. */
- ti_prcm_clk_enable(GPIO0_CLK + ti_first_gpio_bank() + bank);
+ clk = ti_hwmods_get_clock(dev);
+ if (clk == INVALID_CLK_IDENT) {
+ device_printf(dev, "failed to get device id based on ti,hwmods\n");
+ return (EINVAL);
+ }
+
+ sc->sc_bank = clk - GPIO1_CLK + ti_first_gpio_bank();
+ ti_prcm_clk_enable(clk);
/*
* Read the revision number of the module. TI don't publish the
* actual revision numbers, so instead the values have been
* determined by experimentation.
*/
- rev = ti_gpio_read_4(sc, bank, TI_GPIO_REVISION);
+ rev = ti_gpio_read_4(sc, TI_GPIO_REVISION);
/* Check the revision. */
if (rev != ti_gpio_rev()) {
device_printf(dev, "Warning: could not determine the revision "
- "of GPIO module %d (revision:0x%08x)\n", bank, rev);
+ "of GPIO module (revision:0x%08x)\n", rev);
return (EINVAL);
}
/* Disable interrupts for all pins. */
- ti_gpio_intr_clr(sc, bank, 0xffffffff);
+ ti_gpio_intr_clr(sc, 0xffffffff);
/* Init OE register based on pads configuration. */
reg_oe = 0xffffffff;
for (pin = 0; pin < PINS_PER_BANK; pin++) {
- TI_GPIO_GET_FLAGS(dev, PINS_PER_BANK * bank + pin, &flags);
+ TI_GPIO_GET_FLAGS(dev, pin, &flags);
if (flags & GPIO_PIN_OUTPUT)
reg_oe &= ~(1UL << pin);
}
- ti_gpio_write_4(sc, bank, TI_GPIO_OE, reg_oe);
+ ti_gpio_write_4(sc, TI_GPIO_OE, reg_oe);
return (0);
}
@@ -760,35 +637,38 @@ ti_gpio_attach(device_t dev)
unsigned int i;
int err;
- if (ti_gpio_sc != NULL)
- return (ENXIO);
-
- ti_gpio_sc = sc = device_get_softc(dev);
+ sc = device_get_softc(dev);
sc->sc_dev = dev;
TI_GPIO_LOCK_INIT(sc);
ti_gpio_pin_max(dev, &sc->sc_maxpin);
sc->sc_maxpin++;
- /* There are up to 6 different GPIO register sets located in different
- * memory areas on the chip. The memory range should have been set for
- * the driver when it was added as a child.
- */
- if (bus_alloc_resources(dev, ti_gpio_mem_spec, sc->sc_mem_res) != 0) {
+ sc->sc_mem_rid = 0;
+ sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
+ &sc->sc_mem_rid, RF_ACTIVE);
+ if (!sc->sc_mem_res) {
device_printf(dev, "Error: could not allocate mem resources\n");
ti_gpio_detach(dev);
return (ENXIO);
}
- /* Request the IRQ resources */
- if (bus_alloc_resources(dev, ti_gpio_irq_spec, sc->sc_irq_res) != 0) {
+ sc->sc_irq_rid = 0;
+ sc->sc_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ,
+ &sc->sc_irq_rid, RF_ACTIVE);
+ if (!sc->sc_irq_res) {
device_printf(dev, "Error: could not allocate irq resources\n");
ti_gpio_detach(dev);
return (ENXIO);
}
- /* Setup the IRQ resources */
- if (ti_gpio_attach_intr(dev) != 0) {
- device_printf(dev, "Error: could not setup irq handlers\n");
+ /*
+ * Register our interrupt filter for each of the IRQ resources.
+ */
+ if (bus_setup_intr(dev, sc->sc_irq_res,
+ INTR_TYPE_MISC | INTR_MPSAFE, ti_gpio_intr, NULL, sc,
+ &sc->sc_irq_hdl) != 0) {
+ device_printf(dev,
+ "WARNING: unable to register interrupt filter\n");
ti_gpio_detach(dev);
return (ENXIO);
}
@@ -811,21 +691,23 @@ ti_gpio_attach(device_t dev)
sc->sc_events = malloc(sizeof(struct intr_event *) * sc->sc_maxpin,
M_DEVBUF, M_WAITOK | M_ZERO);
+ sc->sc_mask_args = malloc(sizeof(struct ti_gpio_mask_arg) * sc->sc_maxpin,
+ M_DEVBUF, M_WAITOK | M_ZERO);
+
/* We need to go through each block and ensure the clocks are running and
* the module is enabled. It might be better to do this only when the
* pins are configured which would result in less power used if the GPIO
* pins weren't used ...
*/
- for (i = 0; i < ti_max_gpio_banks(); i++) {
- if (sc->sc_mem_res[i] != NULL) {
- /* Initialize the GPIO module. */
- err = ti_gpio_bank_init(dev, i);
- if (err != 0) {
- ti_gpio_detach(dev);
- return (err);
- }
+ if (sc->sc_mem_res != NULL) {
+ /* Initialize the GPIO module. */
+ err = ti_gpio_bank_init(dev);
+ if (err != 0) {
+ ti_gpio_detach(dev);
+ return (err);
}
}
+
sc->sc_busdev = gpiobus_attach_bus(dev);
if (sc->sc_busdev == NULL) {
ti_gpio_detach(dev);
@@ -852,26 +734,30 @@ static int
ti_gpio_detach(device_t dev)
{
struct ti_gpio_softc *sc = device_get_softc(dev);
- unsigned int i;
KASSERT(mtx_initialized(&sc->sc_mtx), ("gpio mutex not initialized"));
/* Disable all interrupts */
- for (i = 0; i < ti_max_gpio_banks(); i++) {
- if (sc->sc_mem_res[i] != NULL)
- ti_gpio_intr_clr(sc, i, 0xffffffff);
- }
+ if (sc->sc_mem_res != NULL)
+ ti_gpio_intr_clr(sc, 0xffffffff);
gpiobus_detach_bus(dev);
if (sc->sc_events)
free(sc->sc_events, M_DEVBUF);
+ if (sc->sc_mask_args)
+ free(sc->sc_mask_args, M_DEVBUF);
if (sc->sc_irq_polarity)
free(sc->sc_irq_polarity, M_DEVBUF);
if (sc->sc_irq_trigger)
free(sc->sc_irq_trigger, M_DEVBUF);
/* Release the memory and IRQ resources. */
- ti_gpio_detach_intr(dev);
- bus_release_resources(dev, ti_gpio_irq_spec, sc->sc_irq_res);
- bus_release_resources(dev, ti_gpio_mem_spec, sc->sc_mem_res);
+ if (sc->sc_irq_hdl) {
+ bus_teardown_intr(dev, sc->sc_irq_res,
+ sc->sc_irq_hdl);
+ }
+ bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irq_rid,
+ sc->sc_irq_res);
+ bus_release_resource(dev, SYS_RES_MEMORY, sc->sc_mem_rid,
+ sc->sc_mem_res);
TI_GPIO_LOCK_DESTROY(sc);
return (0);
@@ -900,46 +786,57 @@ ti_gpio_intr_reg(struct ti_gpio_softc *sc, int irq)
}
static void
-ti_gpio_mask_irq(void *source)
+ti_gpio_mask_irq_internal(struct ti_gpio_softc *sc, int irq)
{
- int irq;
uint32_t reg, val;
- irq = (int)source;
- if (ti_gpio_valid_pin(ti_gpio_sc, irq) != 0)
+ if (ti_gpio_valid_pin(sc, irq) != 0)
return;
- TI_GPIO_LOCK(ti_gpio_sc);
- ti_gpio_intr_clr(ti_gpio_sc, TI_GPIO_BANK(irq), TI_GPIO_MASK(irq));
- reg = ti_gpio_intr_reg(ti_gpio_sc, irq);
+ TI_GPIO_LOCK(sc);
+ ti_gpio_intr_clr(sc, TI_GPIO_MASK(irq));
+ reg = ti_gpio_intr_reg(sc, irq);
if (reg != 0) {
- val = ti_gpio_read_4(ti_gpio_sc, TI_GPIO_BANK(irq), reg);
+ val = ti_gpio_read_4(sc, reg);
val &= ~TI_GPIO_MASK(irq);
- ti_gpio_write_4(ti_gpio_sc, TI_GPIO_BANK(irq), reg, val);
+ ti_gpio_write_4(sc, reg, val);
}
- TI_GPIO_UNLOCK(ti_gpio_sc);
+ TI_GPIO_UNLOCK(sc);
}
static void
-ti_gpio_unmask_irq(void *source)
+ti_gpio_unmask_irq_internal(struct ti_gpio_softc *sc, int irq)
{
- int irq;
uint32_t reg, val;
- irq = (int)source;
- if (ti_gpio_valid_pin(ti_gpio_sc, irq) != 0)
+ if (ti_gpio_valid_pin(sc, irq) != 0)
return;
- TI_GPIO_LOCK(ti_gpio_sc);
- reg = ti_gpio_intr_reg(ti_gpio_sc, irq);
+ TI_GPIO_LOCK(sc);
+ reg = ti_gpio_intr_reg(sc, irq);
if (reg != 0) {
- val = ti_gpio_read_4(ti_gpio_sc, TI_GPIO_BANK(irq), reg);
+ val = ti_gpio_read_4(sc, reg);
val |= TI_GPIO_MASK(irq);
- ti_gpio_write_4(ti_gpio_sc, TI_GPIO_BANK(irq), reg, val);
- ti_gpio_intr_set(ti_gpio_sc, TI_GPIO_BANK(irq),
- TI_GPIO_MASK(irq));
+ ti_gpio_write_4(sc, reg, val);
+ ti_gpio_intr_set(sc, TI_GPIO_MASK(irq));
}
- TI_GPIO_UNLOCK(ti_gpio_sc);
+ TI_GPIO_UNLOCK(sc);
+}
+
+static void
+ti_gpio_mask_irq(void *source)
+{
+ struct ti_gpio_mask_arg *arg = source;
+
+ ti_gpio_mask_irq_internal(arg->softc, arg->pin);
+}
+
+static void
+ti_gpio_unmask_irq(void *source)
+{
+ struct ti_gpio_mask_arg *arg = source;
+
+ ti_gpio_unmask_irq_internal(arg->softc, arg->pin);
}
static int
@@ -1000,15 +897,15 @@ ti_gpio_config_intr(device_t dev, int irq, enum intr_trigger trig,
reg = ti_gpio_intr_reg(sc, irq);
if (reg != 0) {
/* Apply the new settings. */
- val = ti_gpio_read_4(sc, TI_GPIO_BANK(irq), reg);
+ val = ti_gpio_read_4(sc, reg);
val |= TI_GPIO_MASK(irq);
- ti_gpio_write_4(sc, TI_GPIO_BANK(irq), reg, val);
+ ti_gpio_write_4(sc, reg, val);
}
if (reg != oldreg && oldreg != 0) {
/* Remove the old settings. */
- val = ti_gpio_read_4(sc, TI_GPIO_BANK(irq), oldreg);
+ val = ti_gpio_read_4(sc, oldreg);
val &= ~TI_GPIO_MASK(irq);
- ti_gpio_write_4(sc, TI_GPIO_BANK(irq), oldreg, val);
+ ti_gpio_write_4(sc, oldreg, val);
}
TI_GPIO_UNLOCK(sc);
@@ -1031,7 +928,9 @@ ti_gpio_setup_intr(device_t dev, device_t child, struct resource *ires,
event = sc->sc_events[pin];
if (event == NULL) {
- error = intr_event_create(&event, (void *)(uintptr_t)pin, 0,
+ sc->sc_mask_args[pin].softc = sc;
+ sc->sc_mask_args[pin].pin = pin;
+ error = intr_event_create(&event, (void *)&sc->sc_mask_args[pin], 0,
pin, ti_gpio_mask_irq, ti_gpio_unmask_irq, NULL, NULL,
"gpio%d pin%d:", device_get_unit(dev), pin);
if (error != 0)
diff --git a/sys/arm/ti/ti_gpio.h b/sys/arm/ti/ti_gpio.h
index a2c0bfb..6bd53c8 100644
--- a/sys/arm/ti/ti_gpio.h
+++ b/sys/arm/ti/ti_gpio.h
@@ -39,6 +39,11 @@
*/
#define MAX_GPIO_INTRS 8
+struct ti_gpio_mask_arg {
+ void *softc;
+ int pin;
+};
+
/**
* Structure that stores the driver context.
*
@@ -52,22 +57,21 @@ struct ti_gpio_softc {
enum intr_trigger *sc_irq_trigger;
enum intr_polarity *sc_irq_polarity;
+ int sc_bank;
int sc_maxpin;
struct mtx sc_mtx;
- /*
- * The memory resource(s) for the PRCM register set, when the device is
- * created the caller can assign up to 6 memory regions depending on
- * the SoC type.
- */
- struct resource *sc_mem_res[MAX_GPIO_BANKS];
- struct resource *sc_irq_res[MAX_GPIO_INTRS];
+ int sc_mem_rid;
+ struct resource *sc_mem_res;
+ int sc_irq_rid;
+ struct resource *sc_irq_res;
/* Interrupt events. */
struct intr_event **sc_events;
+ struct ti_gpio_mask_arg *sc_mask_args;
/* The handle for the register IRQ handlers. */
- void *sc_irq_hdl[MAX_GPIO_INTRS];
+ void *sc_irq_hdl;
};
#endif /* TI_GPIO_H */
diff --git a/sys/arm/ti/ti_hwmods.c b/sys/arm/ti/ti_hwmods.c
new file mode 100644
index 0000000..4da5f74
--- /dev/null
+++ b/sys/arm/ti/ti_hwmods.c
@@ -0,0 +1,170 @@
+/*-
+ * Copyright (c) 2015 Oleksandr Tymoshenko <gonzo@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 ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, 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>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include <machine/bus.h>
+#include <machine/fdt.h>
+
+#include <arm/ti/ti_prcm.h>
+#include <arm/ti/ti_hwmods.h>
+
+struct hwmod {
+ const char *name;
+ int clock_id;
+};
+
+struct hwmod ti_hwmods[] = {
+ {"i2c1", I2C1_CLK},
+ {"i2c2", I2C2_CLK},
+ {"i2c3", I2C3_CLK},
+ {"i2c4", I2C4_CLK},
+ {"i2c5", I2C5_CLK},
+
+ {"gpio1", GPIO1_CLK},
+ {"gpio2", GPIO2_CLK},
+ {"gpio3", GPIO3_CLK},
+ {"gpio4", GPIO4_CLK},
+ {"gpio5", GPIO5_CLK},
+ {"gpio6", GPIO6_CLK},
+ {"gpio7", GPIO7_CLK},
+
+ {"mmc1", MMC1_CLK},
+ {"mmc2", MMC2_CLK},
+ {"mmc3", MMC3_CLK},
+ {"mmc4", MMC4_CLK},
+ {"mmc5", MMC5_CLK},
+ {"mmc6", MMC6_CLK},
+
+ {"epwmss0", PWMSS0_CLK},
+ {"epwmss1", PWMSS1_CLK},
+ {"epwmss2", PWMSS2_CLK},
+
+ {"timer1", TIMER1_CLK},
+ {"timer2", TIMER2_CLK},
+ {"timer3", TIMER3_CLK},
+ {"timer4", TIMER4_CLK},
+ {"timer5", TIMER5_CLK},
+ {"timer6", TIMER6_CLK},
+ {"timer7", TIMER7_CLK},
+
+ {"uart1", UART1_CLK},
+ {"uart2", UART2_CLK},
+ {"uart3", UART3_CLK},
+ {"uart4", UART4_CLK},
+ {"uart5", UART5_CLK},
+ {"uart6", UART6_CLK},
+ {"uart7", UART7_CLK},
+
+ {NULL, 0}
+};
+
+clk_ident_t
+ti_hwmods_get_clock(device_t dev)
+{
+ phandle_t node;
+ int len, l;
+ char *name;
+ char *buf;
+ int clk;
+ struct hwmod *hw;
+
+ if ((node = ofw_bus_get_node(dev)) == 0)
+ return (INVALID_CLK_IDENT);
+
+ if ((len = OF_getprop_alloc(node, "ti,hwmods", 1, (void**)&name)) <= 0)
+ return (INVALID_CLK_IDENT);
+
+ buf = name;
+
+ clk = INVALID_CLK_IDENT;
+ while ((len > 0) && (clk == INVALID_CLK_IDENT)) {
+ for (hw = ti_hwmods; hw->name != NULL; ++hw) {
+ if (strcmp(hw->name, name) == 0) {
+ clk = hw->clock_id;
+ break;
+ }
+ }
+
+ /* Slide to the next sub-string. */
+ l = strlen(name) + 1;
+ name += l;
+ len -= l;
+ }
+
+ if (len > 0)
+ device_printf(dev, "WARNING: more then one ti,hwmod \n");
+
+ free(buf, M_OFWPROP);
+ return (clk);
+}
+
+int ti_hwmods_contains(device_t dev, const char *hwmod)
+{
+ phandle_t node;
+ int len, l;
+ char *name;
+ char *buf;
+ int result;
+
+ if ((node = ofw_bus_get_node(dev)) == 0)
+ return (0);
+
+ if ((len = OF_getprop_alloc(node, "ti,hwmods", 1, (void**)&name)) <= 0)
+ return (0);
+
+ buf = name;
+
+ result = 0;
+ while (len > 0) {
+ if (strcmp(name, hwmod) == 0) {
+ result = 1;
+ break;
+ }
+
+ /* Slide to the next sub-string. */
+ l = strlen(name) + 1;
+ name += l;
+ len -= l;
+ }
+
+ free(buf, M_OFWPROP);
+
+ return (result);
+}
diff --git a/sys/arm/ti/ti_hwmods.h b/sys/arm/ti/ti_hwmods.h
new file mode 100644
index 0000000..dffe438
--- /dev/null
+++ b/sys/arm/ti/ti_hwmods.h
@@ -0,0 +1,34 @@
+/*-
+ * Copyright (c) 2015 Oleksandr Tymoshenko <gonzo@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 ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, 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 _TI_HWMODS_H_
+#define _TI_HWMODS_H_
+
+clk_ident_t ti_hwmods_get_clock(device_t dev);
+int ti_hwmods_contains(device_t dev, const char *hwmod);
+
+#endif /* _TI_HWMODS_H_ */
diff --git a/sys/arm/ti/ti_i2c.c b/sys/arm/ti/ti_i2c.c
index ad688f3..9f12506 100644
--- a/sys/arm/ti/ti_i2c.c
+++ b/sys/arm/ti/ti_i2c.c
@@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$");
#include <arm/ti/ti_cpuid.h>
#include <arm/ti/ti_prcm.h>
+#include <arm/ti/ti_hwmods.h>
#include <arm/ti/ti_i2c.h>
#include <dev/iicbus/iiconf.h>
@@ -81,7 +82,7 @@ __FBSDID("$FreeBSD$");
struct ti_i2c_softc
{
device_t sc_dev;
- uint32_t device_id;
+ clk_ident_t clk_id;
struct resource* sc_irq_res;
struct resource* sc_mem_res;
device_t sc_iicbus;
@@ -693,7 +694,6 @@ ti_i2c_iicbus_reset(device_t dev, u_char speed, u_char addr, u_char *oldaddr)
static int
ti_i2c_activate(device_t dev)
{
- clk_ident_t clk;
int err;
struct ti_i2c_softc *sc;
@@ -703,8 +703,7 @@ ti_i2c_activate(device_t dev)
* 1. Enable the functional and interface clocks (see Section
* 23.1.5.1.1.1.1).
*/
- clk = I2C0_CLK + sc->device_id;
- err = ti_prcm_clk_enable(clk);
+ err = ti_prcm_clk_enable(sc->clk_id);
if (err)
return (err);
@@ -727,7 +726,6 @@ static void
ti_i2c_deactivate(device_t dev)
{
struct ti_i2c_softc *sc = device_get_softc(dev);
- clk_ident_t clk;
/* Disable the controller - cancel all transactions. */
ti_i2c_write_2(sc, I2C_REG_IRQENABLE_CLR, 0xffff);
@@ -755,8 +753,7 @@ ti_i2c_deactivate(device_t dev)
}
/* Finally disable the functional and interface clocks. */
- clk = I2C0_CLK + sc->device_id;
- ti_prcm_clk_disable(clk);
+ ti_prcm_clk_disable(sc->clk_id);
}
static int
@@ -815,7 +812,7 @@ ti_i2c_probe(device_t dev)
if (!ofw_bus_status_okay(dev))
return (ENXIO);
- if (!ofw_bus_is_compatible(dev, "ti,i2c"))
+ if (!ofw_bus_is_compatible(dev, "ti,omap4-i2c"))
return (ENXIO);
device_set_desc(dev, "TI I2C Controller");
@@ -837,9 +834,10 @@ ti_i2c_attach(device_t dev)
/* Get the i2c device id from FDT. */
node = ofw_bus_get_node(dev);
- if ((OF_getencprop(node, "i2c-device-id", &sc->device_id,
- sizeof(sc->device_id))) <= 0) {
- device_printf(dev, "missing i2c-device-id attribute in FDT\n");
+ /* i2c ti,hwmods bindings is special: it start with index 1 */
+ sc->clk_id = ti_hwmods_get_clock(dev);
+ if (sc->clk_id == INVALID_CLK_IDENT) {
+ device_printf(dev, "failed to get device id using ti,hwmod\n");
return (ENXIO);
}
@@ -953,6 +951,17 @@ static device_method_t ti_i2c_methods[] = {
DEVMETHOD(device_attach, ti_i2c_attach),
DEVMETHOD(device_detach, ti_i2c_detach),
+ /* Bus interface */
+ DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
+ DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
+ 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_adjust_resource, bus_generic_adjust_resource),
+ DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource),
+ DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
+
/* OFW methods */
DEVMETHOD(ofw_bus_get_node, ti_i2c_get_node),
diff --git a/sys/arm/ti/ti_mbox.c b/sys/arm/ti/ti_mbox.c
index 1f8cde1..9729ed4 100644
--- a/sys/arm/ti/ti_mbox.c
+++ b/sys/arm/ti/ti_mbox.c
@@ -121,7 +121,7 @@ ti_mbox_probe(device_t dev)
if (!ofw_bus_status_okay(dev))
return (ENXIO);
- if (ofw_bus_is_compatible(dev, "ti,system-mbox")) {
+ if (ofw_bus_is_compatible(dev, "ti,omap4-mailbox")) {
device_set_desc(dev, "TI System Mailbox");
return (BUS_PROBE_DEFAULT);
}
diff --git a/sys/arm/ti/ti_pinmux.c b/sys/arm/ti/ti_pinmux.c
new file mode 100644
index 0000000..ff4743d
--- /dev/null
+++ b/sys/arm/ti/ti_pinmux.c
@@ -0,0 +1,445 @@
+/*
+ * Copyright (c) 2010
+ * Ben Gray <ben.r.gray@gmail.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 Ben Gray.
+ * 4. The name of the company 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 BEN GRAY ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL BEN GRAY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * Exposes pinmux module to pinctrl-compatible interface
+ */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/bus.h>
+#include <sys/resource.h>
+#include <sys/rman.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+
+#include <machine/bus.h>
+#include <machine/cpu.h>
+#include <machine/cpufunc.h>
+#include <machine/resource.h>
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/fdt/fdt_pinctrl.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include "ti_pinmux.h"
+
+struct pincfg {
+ uint32_t reg;
+ uint32_t conf;
+};
+
+static struct resource_spec ti_pinmux_res_spec[] = {
+ { SYS_RES_MEMORY, 0, RF_ACTIVE }, /* Control memory window */
+ { -1, 0 }
+};
+
+static struct ti_pinmux_softc *ti_pinmux_sc;
+
+#define ti_pinmux_read_2(sc, reg) \
+ bus_space_read_2((sc)->sc_bst, (sc)->sc_bsh, (reg))
+#define ti_pinmux_write_2(sc, reg, val) \
+ bus_space_write_2((sc)->sc_bst, (sc)->sc_bsh, (reg), (val))
+#define ti_pinmux_read_4(sc, reg) \
+ bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg))
+#define ti_pinmux_write_4(sc, reg, val) \
+ bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val))
+
+
+/**
+ * ti_padconf_devmap - Array of pins, should be defined one per SoC
+ *
+ * This array is typically defined in one of the targeted *_scm_pinumx.c
+ * files and is specific to the given SoC platform. Each entry in the array
+ * corresponds to an individual pin.
+ */
+extern const struct ti_pinmux_device ti_pinmux_dev;
+
+
+/**
+ * ti_pinmux_padconf_from_name - searches the list of pads and returns entry
+ * with matching ball name.
+ * @ballname: the name of the ball
+ *
+ * RETURNS:
+ * A pointer to the matching padconf or NULL if the ball wasn't found.
+ */
+static const struct ti_pinmux_padconf*
+ti_pinmux_padconf_from_name(const char *ballname)
+{
+ const struct ti_pinmux_padconf *padconf;
+
+ padconf = ti_pinmux_dev.padconf;
+ while (padconf->ballname != NULL) {
+ if (strcmp(ballname, padconf->ballname) == 0)
+ return(padconf);
+ padconf++;
+ }
+
+ return (NULL);
+}
+
+/**
+ * ti_pinmux_padconf_set_internal - sets the muxmode and state for a pad/pin
+ * @padconf: pointer to the pad structure
+ * @muxmode: the name of the mode to use for the pin, i.e. "uart1_rx"
+ * @state: the state to put the pad/pin in, i.e. PADCONF_PIN_???
+ *
+ *
+ * LOCKING:
+ * Internally locks it's own context.
+ *
+ * RETURNS:
+ * 0 on success.
+ * EINVAL if pin requested is outside valid range or already in use.
+ */
+static int
+ti_pinmux_padconf_set_internal(struct ti_pinmux_softc *sc,
+ const struct ti_pinmux_padconf *padconf,
+ const char *muxmode, unsigned int state)
+{
+ unsigned int mode;
+ uint16_t reg_val;
+
+ /* populate the new value for the PADCONF register */
+ reg_val = (uint16_t)(state & ti_pinmux_dev.padconf_sate_mask);
+
+ /* find the new mode requested */
+ for (mode = 0; mode < 8; mode++) {
+ if ((padconf->muxmodes[mode] != NULL) &&
+ (strcmp(padconf->muxmodes[mode], muxmode) == 0)) {
+ break;
+ }
+ }
+
+ /* couldn't find the mux mode */
+ if (mode >= 8) {
+ printf("Invalid mode \"%s\"\n", muxmode);
+ return (EINVAL);
+ }
+
+ /* set the mux mode */
+ reg_val |= (uint16_t)(mode & ti_pinmux_dev.padconf_muxmode_mask);
+
+ if (bootverbose)
+ device_printf(sc->sc_dev, "setting internal %x for %s\n",
+ reg_val, muxmode);
+ /* write the register value (16-bit writes) */
+ ti_pinmux_write_2(sc, padconf->reg_off, reg_val);
+
+ return (0);
+}
+
+/**
+ * ti_pinmux_padconf_set - sets the muxmode and state for a pad/pin
+ * @padname: the name of the pad, i.e. "c12"
+ * @muxmode: the name of the mode to use for the pin, i.e. "uart1_rx"
+ * @state: the state to put the pad/pin in, i.e. PADCONF_PIN_???
+ *
+ *
+ * LOCKING:
+ * Internally locks it's own context.
+ *
+ * RETURNS:
+ * 0 on success.
+ * EINVAL if pin requested is outside valid range or already in use.
+ */
+int
+ti_pinmux_padconf_set(const char *padname, const char *muxmode, unsigned int state)
+{
+ const struct ti_pinmux_padconf *padconf;
+
+ if (!ti_pinmux_sc)
+ return (ENXIO);
+
+ /* find the pin in the devmap */
+ padconf = ti_pinmux_padconf_from_name(padname);
+ if (padconf == NULL)
+ return (EINVAL);
+
+ return (ti_pinmux_padconf_set_internal(ti_pinmux_sc, padconf, muxmode, state));
+}
+
+/**
+ * ti_pinmux_padconf_get - gets the muxmode and state for a pad/pin
+ * @padname: the name of the pad, i.e. "c12"
+ * @muxmode: upon return will contain the name of the muxmode of the pin
+ * @state: upon return will contain the state of the pad/pin
+ *
+ *
+ * LOCKING:
+ * Internally locks it's own context.
+ *
+ * RETURNS:
+ * 0 on success.
+ * EINVAL if pin requested is outside valid range or already in use.
+ */
+int
+ti_pinmux_padconf_get(const char *padname, const char **muxmode,
+ unsigned int *state)
+{
+ const struct ti_pinmux_padconf *padconf;
+ uint16_t reg_val;
+
+ if (!ti_pinmux_sc)
+ return (ENXIO);
+
+ /* find the pin in the devmap */
+ padconf = ti_pinmux_padconf_from_name(padname);
+ if (padconf == NULL)
+ return (EINVAL);
+
+ /* read the register value (16-bit reads) */
+ reg_val = ti_pinmux_read_2(ti_pinmux_sc, padconf->reg_off);
+
+ /* save the state */
+ if (state)
+ *state = (reg_val & ti_pinmux_dev.padconf_sate_mask);
+
+ /* save the mode */
+ if (muxmode)
+ *muxmode = padconf->muxmodes[(reg_val & ti_pinmux_dev.padconf_muxmode_mask)];
+
+ return (0);
+}
+
+/**
+ * ti_pinmux_padconf_set_gpiomode - converts a pad to GPIO mode.
+ * @gpio: the GPIO pin number (0-195)
+ * @state: the state to put the pad/pin in, i.e. PADCONF_PIN_???
+ *
+ *
+ *
+ * LOCKING:
+ * Internally locks it's own context.
+ *
+ * RETURNS:
+ * 0 on success.
+ * EINVAL if pin requested is outside valid range or already in use.
+ */
+int
+ti_pinmux_padconf_set_gpiomode(uint32_t gpio, unsigned int state)
+{
+ const struct ti_pinmux_padconf *padconf;
+ uint16_t reg_val;
+
+ if (!ti_pinmux_sc)
+ return (ENXIO);
+
+ /* find the gpio pin in the padconf array */
+ padconf = ti_pinmux_dev.padconf;
+ while (padconf->ballname != NULL) {
+ if (padconf->gpio_pin == gpio)
+ break;
+ padconf++;
+ }
+ if (padconf->ballname == NULL)
+ return (EINVAL);
+
+ /* populate the new value for the PADCONF register */
+ reg_val = (uint16_t)(state & ti_pinmux_dev.padconf_sate_mask);
+
+ /* set the mux mode */
+ reg_val |= (uint16_t)(padconf->gpio_mode & ti_pinmux_dev.padconf_muxmode_mask);
+
+ /* write the register value (16-bit writes) */
+ ti_pinmux_write_2(ti_pinmux_sc, padconf->reg_off, reg_val);
+
+ return (0);
+}
+
+/**
+ * ti_pinmux_padconf_get_gpiomode - gets the current GPIO mode of the pin
+ * @gpio: the GPIO pin number (0-195)
+ * @state: upon return will contain the state
+ *
+ *
+ *
+ * LOCKING:
+ * Internally locks it's own context.
+ *
+ * RETURNS:
+ * 0 on success.
+ * EINVAL if pin requested is outside valid range or not configured as GPIO.
+ */
+int
+ti_pinmux_padconf_get_gpiomode(uint32_t gpio, unsigned int *state)
+{
+ const struct ti_pinmux_padconf *padconf;
+ uint16_t reg_val;
+
+ if (!ti_pinmux_sc)
+ return (ENXIO);
+
+ /* find the gpio pin in the padconf array */
+ padconf = ti_pinmux_dev.padconf;
+ while (padconf->ballname != NULL) {
+ if (padconf->gpio_pin == gpio)
+ break;
+ padconf++;
+ }
+ if (padconf->ballname == NULL)
+ return (EINVAL);
+
+ /* read the current register settings */
+ reg_val = ti_pinmux_read_2(ti_pinmux_sc, padconf->reg_off);
+
+ /* check to make sure the pins is configured as GPIO in the first state */
+ if ((reg_val & ti_pinmux_dev.padconf_muxmode_mask) != padconf->gpio_mode)
+ return (EINVAL);
+
+ /* read and store the reset of the state, i.e. pull-up, pull-down, etc */
+ if (state)
+ *state = (reg_val & ti_pinmux_dev.padconf_sate_mask);
+
+ return (0);
+}
+
+static int
+ti_pinmux_configure_pins(device_t dev, phandle_t cfgxref)
+{
+ struct pincfg *cfgtuples, *cfg;
+ phandle_t cfgnode;
+ int i, ntuples;
+ static struct ti_pinmux_softc *sc;
+
+ sc = device_get_softc(dev);
+ cfgnode = OF_node_from_xref(cfgxref);
+ ntuples = OF_getencprop_alloc(cfgnode, "pinctrl-single,pins", sizeof(*cfgtuples),
+ (void **)&cfgtuples);
+
+ if (ntuples < 0)
+ return (ENOENT);
+
+ if (ntuples == 0)
+ return (0); /* Empty property is not an error. */
+
+ for (i = 0, cfg = cfgtuples; i < ntuples; i++, cfg++) {
+ if (bootverbose) {
+ char name[32];
+ OF_getprop(cfgnode, "name", &name, sizeof(name));
+ printf("%16s: muxreg 0x%04x muxval 0x%02x\n",
+ name, cfg->reg, cfg->conf);
+ }
+
+ /* write the register value (16-bit writes) */
+ ti_pinmux_write_2(sc, cfg->reg, cfg->conf);
+ }
+
+ free(cfgtuples, M_OFWPROP);
+
+ return (0);
+}
+
+/*
+ * Device part of OMAP SCM driver
+ */
+
+static int
+ti_pinmux_probe(device_t dev)
+{
+ if (!ofw_bus_status_okay(dev))
+ return (ENXIO);
+
+ if (!ofw_bus_is_compatible(dev, "pinctrl-single"))
+ return (ENXIO);
+
+ if (ti_pinmux_sc) {
+ printf("%s: multiple pinctrl modules in device tree data, ignoring\n",
+ __func__);
+ return (EEXIST);
+ }
+
+ device_set_desc(dev, "TI Pinmux Module");
+ return (BUS_PROBE_DEFAULT);
+}
+
+/**
+ * ti_pinmux_attach - attaches the pinmux to the simplebus
+ * @dev: new device
+ *
+ * RETURNS
+ * Zero on sucess or ENXIO if an error occuried.
+ */
+static int
+ti_pinmux_attach(device_t dev)
+{
+ struct ti_pinmux_softc *sc = device_get_softc(dev);
+
+#if 0
+ if (ti_pinmux_sc)
+ return (ENXIO);
+#endif
+
+ sc->sc_dev = dev;
+
+ if (bus_alloc_resources(dev, ti_pinmux_res_spec, sc->sc_res)) {
+ device_printf(dev, "could not allocate resources\n");
+ return (ENXIO);
+ }
+
+ sc->sc_bst = rman_get_bustag(sc->sc_res[0]);
+ sc->sc_bsh = rman_get_bushandle(sc->sc_res[0]);
+
+ if (ti_pinmux_sc == NULL)
+ ti_pinmux_sc = sc;
+
+ fdt_pinctrl_register(dev, "pinctrl-single,pins");
+ fdt_pinctrl_configure_tree(dev);
+
+ return (0);
+}
+
+static device_method_t ti_pinmux_methods[] = {
+ DEVMETHOD(device_probe, ti_pinmux_probe),
+ DEVMETHOD(device_attach, ti_pinmux_attach),
+
+ /* fdt_pinctrl interface */
+ DEVMETHOD(fdt_pinctrl_configure, ti_pinmux_configure_pins),
+ { 0, 0 }
+};
+
+static driver_t ti_pinmux_driver = {
+ "ti_pinmux",
+ ti_pinmux_methods,
+ sizeof(struct ti_pinmux_softc),
+};
+
+static devclass_t ti_pinmux_devclass;
+
+DRIVER_MODULE(ti_pinmux, simplebus, ti_pinmux_driver, ti_pinmux_devclass, 0, 0);
diff --git a/sys/arm/ti/ti_pinmux.h b/sys/arm/ti/ti_pinmux.h
new file mode 100644
index 0000000..c299c49
--- /dev/null
+++ b/sys/arm/ti/ti_pinmux.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2010
+ * Ben Gray <ben.r.gray@gmail.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 Ben Gray.
+ * 4. The name of the company 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 BEN GRAY ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL BEN GRAY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 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 configure the PIN multiplexing on the chip.
+ *
+ * This is different from the GPIO module in that it is used to configure the
+ * pins between modules not just GPIO input output.
+ *
+ */
+#ifndef _TI_PINMUX_H_
+#define _TI_PINMUX_H_
+
+struct ti_pinmux_padconf {
+ uint16_t reg_off;
+ uint16_t gpio_pin;
+ uint16_t gpio_mode;
+ const char *ballname;
+ const char *muxmodes[8];
+};
+
+struct ti_pinmux_padstate {
+ const char *state;
+ uint16_t reg;
+};
+
+struct ti_pinmux_device {
+ uint16_t padconf_muxmode_mask;
+ uint16_t padconf_sate_mask;
+ const struct ti_pinmux_padstate *padstate;
+ const struct ti_pinmux_padconf *padconf;
+};
+
+struct ti_pinmux_softc {
+ device_t sc_dev;
+ struct resource * sc_res[4];
+ bus_space_tag_t sc_bst;
+ bus_space_handle_t sc_bsh;
+};
+
+int ti_pinmux_padconf_set(const char *padname, const char *muxmode,
+ unsigned int state);
+int ti_pinmux_padconf_get(const char *padname, const char **muxmode,
+ unsigned int *state);
+int ti_pinmux_padconf_set_gpiomode(uint32_t gpio, unsigned int state);
+int ti_pinmux_padconf_get_gpiomode(uint32_t gpio, unsigned int *state);
+
+#endif /* _TI_SCM_H_ */
diff --git a/sys/arm/ti/ti_prcm.h b/sys/arm/ti/ti_prcm.h
index 5cbdc5f..eaea990 100644
--- a/sys/arm/ti/ti_prcm.h
+++ b/sys/arm/ti/ti_prcm.h
@@ -46,6 +46,8 @@
typedef enum {
+ INVALID_CLK_IDENT = 0,
+
/* System clocks, typically you can only call ti_prcm_clk_get_source_freq()
* on these clocks as they are enabled by default.
*/
@@ -55,19 +57,19 @@ typedef enum {
MPU_CLK = 20,
/* MMC modules */
- MMC0_CLK = 100,
- MMC1_CLK,
+ MMC1_CLK = 100,
MMC2_CLK,
MMC3_CLK,
MMC4_CLK,
MMC5_CLK,
+ MMC6_CLK,
/* I2C modules */
- I2C0_CLK = 200,
- I2C1_CLK,
+ I2C1_CLK = 200,
I2C2_CLK,
I2C3_CLK,
I2C4_CLK,
+ I2C5_CLK,
/* USB module(s) */
USBTLL_CLK = 300,
@@ -81,8 +83,7 @@ typedef enum {
USBP2_HSIC_CLK,
/* UART modules */
- UART0_CLK = 400,
- UART1_CLK,
+ UART1_CLK = 400,
UART2_CLK,
UART3_CLK,
UART4_CLK,
@@ -90,20 +91,21 @@ typedef enum {
UART6_CLK,
UART7_CLK,
UART8_CLK,
+ UART9_CLK,
/* General purpose timer modules */
- GPTIMER1_CLK = 500,
- GPTIMER2_CLK,
- GPTIMER3_CLK,
- GPTIMER4_CLK,
- GPTIMER5_CLK,
- GPTIMER6_CLK,
- GPTIMER7_CLK,
- GPTIMER8_CLK,
- GPTIMER9_CLK,
- GPTIMER10_CLK,
- GPTIMER11_CLK,
- GPTIMER12_CLK,
+ TIMER1_CLK = 500,
+ TIMER2_CLK,
+ TIMER3_CLK,
+ TIMER4_CLK,
+ TIMER5_CLK,
+ TIMER6_CLK,
+ TIMER7_CLK,
+ TIMER8_CLK,
+ TIMER9_CLK,
+ TIMER10_CLK,
+ TIMER11_CLK,
+ TIMER12_CLK,
/* McBSP module(s) */
MCBSP1_CLK = 600,
@@ -113,27 +115,17 @@ typedef enum {
MCBSP5_CLK,
/* General purpose I/O modules */
- GPIO0_CLK = 700,
- GPIO1_CLK,
+ GPIO1_CLK = 700,
GPIO2_CLK,
GPIO3_CLK,
GPIO4_CLK,
GPIO5_CLK,
GPIO6_CLK,
+ GPIO7_CLK,
/* sDMA module */
SDMA_CLK = 800,
- /* DMTimer modules */
- DMTIMER0_CLK = 900,
- DMTIMER1_CLK,
- DMTIMER2_CLK,
- DMTIMER3_CLK,
- DMTIMER4_CLK,
- DMTIMER5_CLK,
- DMTIMER6_CLK,
- DMTIMER7_CLK,
-
/* CPSW modules */
CPSW_CLK = 1000,
@@ -166,9 +158,6 @@ typedef enum {
/* RTC module */
RTC_CLK = 1900,
-
- INVALID_CLK_IDENT
-
} clk_ident_t;
/*
diff --git a/sys/arm/ti/ti_pruss.c b/sys/arm/ti/ti_pruss.c
index 805476b..94cea60 100644
--- a/sys/arm/ti/ti_pruss.c
+++ b/sys/arm/ti/ti_pruss.c
@@ -70,7 +70,8 @@ static void ti_pruss_kq_read_detach(struct knote *);
static int ti_pruss_kq_read_event(struct knote *, long);
static d_kqfilter_t ti_pruss_kqfilter;
-#define TI_PRUSS_IRQS 8
+#define TI_PRUSS_IRQS 8
+
struct ti_pruss_softc {
struct mtx sc_mtx;
struct resource *sc_mem_res;
@@ -119,6 +120,7 @@ static struct resource_spec ti_pruss_irq_spec[] = {
{ SYS_RES_IRQ, 7, RF_ACTIVE },
{ -1, 0, 0 }
};
+CTASSERT(TI_PRUSS_IRQS == nitems(ti_pruss_irq_spec) - 1);
static struct ti_pruss_irq_arg {
int irq;
@@ -166,6 +168,7 @@ ti_pruss_attach(device_t dev)
sc = device_get_softc(dev);
rid = 0;
mtx_init(&sc->sc_mtx, "TI PRUSS", NULL, MTX_DEF);
+ knlist_init_mtx(&sc->sc_selinfo.si_note, &sc->sc_mtx);
sc->sc_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
RF_ACTIVE);
if (sc->sc_mem_res == NULL) {
@@ -219,6 +222,9 @@ ti_pruss_detach(device_t dev)
rman_get_rid(sc->sc_irq_res[i]),
sc->sc_irq_res[i]);
}
+ knlist_clear(&sc->sc_selinfo.si_note, 0);
+ knlist_destroy(&sc->sc_selinfo.si_note);
+ mtx_destroy(&sc->sc_mtx);
if (sc->sc_mem_res)
bus_release_resource(dev, SYS_RES_MEMORY, rman_get_rid(sc->sc_mem_res),
sc->sc_mem_res);
@@ -231,13 +237,23 @@ ti_pruss_detach(device_t dev)
static void
ti_pruss_intr(void *arg)
{
- struct ti_pruss_irq_arg *iap;
- struct ti_pruss_softc *sc;
-
- iap = arg;
- sc = iap->sc;
- DPRINTF("interrupt %p", sc);
- KNOTE_UNLOCKED(&sc->sc_selinfo.si_note, iap->irq);
+ int val;
+ struct ti_pruss_irq_arg *iap = arg;
+ struct ti_pruss_softc *sc = iap->sc;
+ /*
+ * Interrupts pr1_host_intr[0:7] are mapped to
+ * Host-2 to Host-9 of PRU-ICSS IRQ-controller.
+ */
+ const int pru_int = iap->irq + 2;
+ const int pru_int_mask = (1 << pru_int);
+
+ val = ti_pruss_reg_read(sc, PRUSS_AM33XX_INTC + PRUSS_INTC_HIER);
+ DPRINTF("interrupt %p, %d", sc, pru_int);
+ if (!(val & pru_int_mask))
+ return;
+ ti_pruss_reg_write(sc, PRUSS_AM33XX_INTC + PRUSS_INTC_HIDISR,
+ pru_int);
+ KNOTE_UNLOCKED(&sc->sc_selinfo.si_note, pru_int);
}
static int
diff --git a/sys/arm/ti/ti_pruss.h b/sys/arm/ti/ti_pruss.h
index 9b05add..4eea12e 100644
--- a/sys/arm/ti/ti_pruss.h
+++ b/sys/arm/ti/ti_pruss.h
@@ -33,4 +33,8 @@
#define PRUSS_AM33XX_REV 0x4e82A900
#define PRUSS_AM33XX_INTC 0x20000
+#define PRUSS_INTC_HIER 0x1500
+#define PRUSS_INTC_HIDISR 0x0038
+#define PRUSS_INTC_HIPIR_BASE 0x0900
+
#endif /* _TI_PRUSS_H_ */
diff --git a/sys/arm/ti/ti_scm.c b/sys/arm/ti/ti_scm.c
index 4c20d96..d22e1ec 100644
--- a/sys/arm/ti/ti_scm.c
+++ b/sys/arm/ti/ti_scm.c
@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
#include <machine/resource.h>
#include <dev/fdt/fdt_common.h>
+#include <dev/fdt/fdt_pinctrl.h>
#include <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
@@ -77,354 +78,29 @@ static struct resource_spec ti_scm_res_spec[] = {
static struct ti_scm_softc *ti_scm_sc;
-#define ti_scm_read_2(sc, reg) \
- bus_space_read_2((sc)->sc_bst, (sc)->sc_bsh, (reg))
-#define ti_scm_write_2(sc, reg, val) \
- bus_space_write_2((sc)->sc_bst, (sc)->sc_bsh, (reg), (val))
#define ti_scm_read_4(sc, reg) \
bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg))
#define ti_scm_write_4(sc, reg, val) \
bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val))
-
-/**
- * ti_padconf_devmap - Array of pins, should be defined one per SoC
- *
- * This array is typically defined in one of the targeted *_scm_pinumx.c
- * files and is specific to the given SoC platform. Each entry in the array
- * corresponds to an individual pin.
- */
-extern const struct ti_scm_device ti_scm_dev;
-
-
-/**
- * ti_scm_padconf_from_name - searches the list of pads and returns entry
- * with matching ball name.
- * @ballname: the name of the ball
- *
- * RETURNS:
- * A pointer to the matching padconf or NULL if the ball wasn't found.
- */
-static const struct ti_scm_padconf*
-ti_scm_padconf_from_name(const char *ballname)
-{
- const struct ti_scm_padconf *padconf;
-
- padconf = ti_scm_dev.padconf;
- while (padconf->ballname != NULL) {
- if (strcmp(ballname, padconf->ballname) == 0)
- return(padconf);
- padconf++;
- }
-
- return (NULL);
-}
-
-/**
- * ti_scm_padconf_set_internal - sets the muxmode and state for a pad/pin
- * @padconf: pointer to the pad structure
- * @muxmode: the name of the mode to use for the pin, i.e. "uart1_rx"
- * @state: the state to put the pad/pin in, i.e. PADCONF_PIN_???
- *
- *
- * LOCKING:
- * Internally locks it's own context.
- *
- * RETURNS:
- * 0 on success.
- * EINVAL if pin requested is outside valid range or already in use.
- */
-static int
-ti_scm_padconf_set_internal(struct ti_scm_softc *sc,
- const struct ti_scm_padconf *padconf,
- const char *muxmode, unsigned int state)
-{
- unsigned int mode;
- uint16_t reg_val;
-
- /* populate the new value for the PADCONF register */
- reg_val = (uint16_t)(state & ti_scm_dev.padconf_sate_mask);
-
- /* find the new mode requested */
- for (mode = 0; mode < 8; mode++) {
- if ((padconf->muxmodes[mode] != NULL) &&
- (strcmp(padconf->muxmodes[mode], muxmode) == 0)) {
- break;
- }
- }
-
- /* couldn't find the mux mode */
- if (mode >= 8) {
- printf("Invalid mode \"%s\"\n", muxmode);
- return (EINVAL);
- }
-
- /* set the mux mode */
- reg_val |= (uint16_t)(mode & ti_scm_dev.padconf_muxmode_mask);
-
- if (bootverbose)
- device_printf(sc->sc_dev, "setting internal %x for %s\n",
- reg_val, muxmode);
- /* write the register value (16-bit writes) */
- ti_scm_write_2(sc, padconf->reg_off, reg_val);
-
- return (0);
-}
-
-/**
- * ti_scm_padconf_set - sets the muxmode and state for a pad/pin
- * @padname: the name of the pad, i.e. "c12"
- * @muxmode: the name of the mode to use for the pin, i.e. "uart1_rx"
- * @state: the state to put the pad/pin in, i.e. PADCONF_PIN_???
- *
- *
- * LOCKING:
- * Internally locks it's own context.
- *
- * RETURNS:
- * 0 on success.
- * EINVAL if pin requested is outside valid range or already in use.
- */
-int
-ti_scm_padconf_set(const char *padname, const char *muxmode, unsigned int state)
-{
- const struct ti_scm_padconf *padconf;
-
- if (!ti_scm_sc)
- return (ENXIO);
-
- /* find the pin in the devmap */
- padconf = ti_scm_padconf_from_name(padname);
- if (padconf == NULL)
- return (EINVAL);
-
- return (ti_scm_padconf_set_internal(ti_scm_sc, padconf, muxmode, state));
-}
-
-/**
- * ti_scm_padconf_get - gets the muxmode and state for a pad/pin
- * @padname: the name of the pad, i.e. "c12"
- * @muxmode: upon return will contain the name of the muxmode of the pin
- * @state: upon return will contain the state of the pad/pin
- *
- *
- * LOCKING:
- * Internally locks it's own context.
- *
- * RETURNS:
- * 0 on success.
- * EINVAL if pin requested is outside valid range or already in use.
- */
-int
-ti_scm_padconf_get(const char *padname, const char **muxmode,
- unsigned int *state)
-{
- const struct ti_scm_padconf *padconf;
- uint16_t reg_val;
-
- if (!ti_scm_sc)
- return (ENXIO);
-
- /* find the pin in the devmap */
- padconf = ti_scm_padconf_from_name(padname);
- if (padconf == NULL)
- return (EINVAL);
-
- /* read the register value (16-bit reads) */
- reg_val = ti_scm_read_2(ti_scm_sc, padconf->reg_off);
-
- /* save the state */
- if (state)
- *state = (reg_val & ti_scm_dev.padconf_sate_mask);
-
- /* save the mode */
- if (muxmode)
- *muxmode = padconf->muxmodes[(reg_val & ti_scm_dev.padconf_muxmode_mask)];
-
- return (0);
-}
-
-/**
- * ti_scm_padconf_set_gpiomode - converts a pad to GPIO mode.
- * @gpio: the GPIO pin number (0-195)
- * @state: the state to put the pad/pin in, i.e. PADCONF_PIN_???
- *
- *
- *
- * LOCKING:
- * Internally locks it's own context.
- *
- * RETURNS:
- * 0 on success.
- * EINVAL if pin requested is outside valid range or already in use.
- */
-int
-ti_scm_padconf_set_gpiomode(uint32_t gpio, unsigned int state)
-{
- const struct ti_scm_padconf *padconf;
- uint16_t reg_val;
-
- if (!ti_scm_sc)
- return (ENXIO);
-
- /* find the gpio pin in the padconf array */
- padconf = ti_scm_dev.padconf;
- while (padconf->ballname != NULL) {
- if (padconf->gpio_pin == gpio)
- break;
- padconf++;
- }
- if (padconf->ballname == NULL)
- return (EINVAL);
-
- /* populate the new value for the PADCONF register */
- reg_val = (uint16_t)(state & ti_scm_dev.padconf_sate_mask);
-
- /* set the mux mode */
- reg_val |= (uint16_t)(padconf->gpio_mode & ti_scm_dev.padconf_muxmode_mask);
-
- /* write the register value (16-bit writes) */
- ti_scm_write_2(ti_scm_sc, padconf->reg_off, reg_val);
-
- return (0);
-}
-
-/**
- * ti_scm_padconf_get_gpiomode - gets the current GPIO mode of the pin
- * @gpio: the GPIO pin number (0-195)
- * @state: upon return will contain the state
- *
- *
- *
- * LOCKING:
- * Internally locks it's own context.
- *
- * RETURNS:
- * 0 on success.
- * EINVAL if pin requested is outside valid range or not configured as GPIO.
- */
-int
-ti_scm_padconf_get_gpiomode(uint32_t gpio, unsigned int *state)
-{
- const struct ti_scm_padconf *padconf;
- uint16_t reg_val;
-
- if (!ti_scm_sc)
- return (ENXIO);
-
- /* find the gpio pin in the padconf array */
- padconf = ti_scm_dev.padconf;
- while (padconf->ballname != NULL) {
- if (padconf->gpio_pin == gpio)
- break;
- padconf++;
- }
- if (padconf->ballname == NULL)
- return (EINVAL);
-
- /* read the current register settings */
- reg_val = ti_scm_read_2(ti_scm_sc, padconf->reg_off);
-
- /* check to make sure the pins is configured as GPIO in the first state */
- if ((reg_val & ti_scm_dev.padconf_muxmode_mask) != padconf->gpio_mode)
- return (EINVAL);
-
- /* read and store the reset of the state, i.e. pull-up, pull-down, etc */
- if (state)
- *state = (reg_val & ti_scm_dev.padconf_sate_mask);
-
- return (0);
-}
-
-/**
- * ti_scm_padconf_init_from_hints - processes the hints for padconf
- * @sc: the driver soft context
- *
- *
- *
- * LOCKING:
- * Internally locks it's own context.
- *
- * RETURNS:
- * 0 on success.
- * EINVAL if pin requested is outside valid range or already in use.
- */
-static int
-ti_scm_padconf_init_from_fdt(struct ti_scm_softc *sc)
-{
- const struct ti_scm_padconf *padconf;
- const struct ti_scm_padstate *padstates;
- int err;
- phandle_t node;
- int len;
- char *fdt_pad_config;
- int i;
- char *padname, *muxname, *padstate;
-
- node = ofw_bus_get_node(sc->sc_dev);
- len = OF_getproplen(node, "scm-pad-config");
- OF_getprop_alloc(node, "scm-pad-config", 1, (void **)&fdt_pad_config);
-
- i = len;
- while (i > 0) {
- padname = fdt_pad_config;
- fdt_pad_config += strlen(padname) + 1;
- i -= strlen(padname) + 1;
- if (i <= 0)
- break;
-
- muxname = fdt_pad_config;
- fdt_pad_config += strlen(muxname) + 1;
- i -= strlen(muxname) + 1;
- if (i <= 0)
- break;
-
- padstate = fdt_pad_config;
- fdt_pad_config += strlen(padstate) + 1;
- i -= strlen(padstate) + 1;
- if (i < 0)
- break;
-
- padconf = ti_scm_dev.padconf;
-
- while (padconf->ballname != NULL) {
- if (strcmp(padconf->ballname, padname) == 0) {
- padstates = ti_scm_dev.padstate;
- err = 1;
- while (padstates->state != NULL) {
- if (strcmp(padstates->state, padstate) == 0) {
- err = ti_scm_padconf_set_internal(sc,
- padconf, muxname, padstates->reg);
- }
- padstates++;
- }
- if (err)
- device_printf(sc->sc_dev,
- "err: failed to configure "
- "pin \"%s\" as \"%s\"\n",
- padconf->ballname,
- muxname);
- }
- padconf++;
- }
- }
- return (0);
-}
-
/*
* Device part of OMAP SCM driver
*/
-
static int
ti_scm_probe(device_t dev)
{
-
if (!ofw_bus_status_okay(dev))
return (ENXIO);
- if (!ofw_bus_is_compatible(dev, "ti,scm"))
+ if (!ofw_bus_is_compatible(dev, "syscon"))
return (ENXIO);
+ if (ti_scm_sc) {
+ printf("%s: multiple SCM modules in device tree data, ignoring\n",
+ __func__);
+ return (EEXIST);
+ }
+
device_set_desc(dev, "TI Control Module");
return (BUS_PROBE_DEFAULT);
}
@@ -444,9 +120,6 @@ ti_scm_attach(device_t dev)
{
struct ti_scm_softc *sc = device_get_softc(dev);
- if (ti_scm_sc)
- return (ENXIO);
-
sc->sc_dev = dev;
if (bus_alloc_resources(dev, ti_scm_res_spec, sc->sc_res)) {
@@ -460,8 +133,6 @@ ti_scm_attach(device_t dev)
ti_scm_sc = sc;
- ti_scm_padconf_init_from_fdt(sc);
-
return (0);
}
@@ -489,6 +160,7 @@ ti_scm_reg_write_4(uint32_t reg, uint32_t val)
static device_method_t ti_scm_methods[] = {
DEVMETHOD(device_probe, ti_scm_probe),
DEVMETHOD(device_attach, ti_scm_attach),
+
{ 0, 0 }
};
diff --git a/sys/arm/ti/ti_scm.h b/sys/arm/ti/ti_scm.h
index 7a2a5a8..1342ddc 100644
--- a/sys/arm/ti/ti_scm.h
+++ b/sys/arm/ti/ti_scm.h
@@ -43,26 +43,6 @@
#ifndef _TI_SCM_H_
#define _TI_SCM_H_
-struct ti_scm_padconf {
- uint16_t reg_off;
- uint16_t gpio_pin;
- uint16_t gpio_mode;
- const char *ballname;
- const char *muxmodes[8];
-};
-
-struct ti_scm_padstate {
- const char *state;
- uint16_t reg;
-};
-
-struct ti_scm_device {
- uint16_t padconf_muxmode_mask;
- uint16_t padconf_sate_mask;
- const struct ti_scm_padstate *padstate;
- const struct ti_scm_padconf *padconf;
-};
-
struct ti_scm_softc {
device_t sc_dev;
struct resource * sc_res[4];
@@ -70,12 +50,6 @@ struct ti_scm_softc {
bus_space_handle_t sc_bsh;
};
-int ti_scm_padconf_set(const char *padname, const char *muxmode,
- unsigned int state);
-int ti_scm_padconf_get(const char *padname, const char **muxmode,
- unsigned int *state);
-int ti_scm_padconf_set_gpiomode(uint32_t gpio, unsigned int state);
-int ti_scm_padconf_get_gpiomode(uint32_t gpio, unsigned int *state);
int ti_scm_reg_read_4(uint32_t reg, uint32_t *val);
int ti_scm_reg_write_4(uint32_t reg, uint32_t val);
diff --git a/sys/arm/ti/ti_sdhci.c b/sys/arm/ti/ti_sdhci.c
index 380a40e..bc0880d 100644
--- a/sys/arm/ti/ti_sdhci.c
+++ b/sys/arm/ti/ti_sdhci.c
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
#include <arm/ti/ti_cpuid.h>
#include <arm/ti/ti_prcm.h>
+#include <arm/ti/ti_hwmods.h>
#include "gpio_if.h"
struct ti_sdhci_softc {
@@ -66,7 +67,7 @@ struct ti_sdhci_softc {
struct resource * irq_res;
void * intr_cookie;
struct sdhci_slot slot;
- uint32_t mmchs_device_id;
+ clk_ident_t mmchs_clk_id;
uint32_t mmchs_reg_off;
uint32_t sdhci_reg_off;
uint32_t baseclk_hz;
@@ -383,19 +384,18 @@ static void
ti_sdhci_hw_init(device_t dev)
{
struct ti_sdhci_softc *sc = device_get_softc(dev);
- clk_ident_t clk;
uint32_t regval;
unsigned long timeout;
/* Enable the controller and interface/functional clocks */
- clk = MMC0_CLK + sc->mmchs_device_id;
- if (ti_prcm_clk_enable(clk) != 0) {
+ if (ti_prcm_clk_enable(sc->mmchs_clk_id) != 0) {
device_printf(dev, "Error: failed to enable MMC clock\n");
return;
}
/* Get the frequency of the source clock */
- if (ti_prcm_clk_get_source_freq(clk, &sc->baseclk_hz) != 0) {
+ if (ti_prcm_clk_get_source_freq(sc->mmchs_clk_id,
+ &sc->baseclk_hz) != 0) {
device_printf(dev, "Error: failed to get source clock freq\n");
return;
}
@@ -484,12 +484,10 @@ ti_sdhci_attach(device_t dev)
* up and added in freebsd, it doesn't exist in the published bindings.
*/
node = ofw_bus_get_node(dev);
- if ((OF_getprop(node, "mmchs-device-id", &prop, sizeof(prop))) <= 0) {
- sc->mmchs_device_id = device_get_unit(dev);
- device_printf(dev, "missing mmchs-device-id attribute in FDT, "
- "using unit number (%d)", sc->mmchs_device_id);
- } else
- sc->mmchs_device_id = fdt32_to_cpu(prop);
+ sc->mmchs_clk_id = ti_hwmods_get_clock(dev);
+ if (sc->mmchs_clk_id == INVALID_CLK_IDENT) {
+ device_printf(dev, "failed to get clock based on hwmods property\n");
+ }
/*
* The hardware can inherently do dual-voltage (1p8v, 3p0v) on the first
@@ -500,7 +498,7 @@ ti_sdhci_attach(device_t dev)
* be done once and never reset.
*/
sc->slot.host.caps |= MMC_OCR_LOW_VOLTAGE;
- if (sc->mmchs_device_id == 0 || OF_hasprop(node, "ti,dual-volt")) {
+ if (sc->mmchs_clk_id == MMC1_CLK || OF_hasprop(node, "ti,dual-volt")) {
sc->slot.host.caps |= MMC_OCR_290_300 | MMC_OCR_300_310;
}
diff --git a/sys/arm/ti/ti_sdma.c b/sys/arm/ti/ti_sdma.c
index 4e9dbfe..a8faba8 100644
--- a/sys/arm/ti/ti_sdma.c
+++ b/sys/arm/ti/ti_sdma.c
@@ -1131,7 +1131,7 @@ ti_sdma_probe(device_t dev)
if (!ofw_bus_status_okay(dev))
return (ENXIO);
- if (!ofw_bus_is_compatible(dev, "ti,sdma"))
+ if (!ofw_bus_is_compatible(dev, "ti,omap4430-sdma"))
return (ENXIO);
device_set_desc(dev, "TI sDMA Controller");
diff --git a/sys/arm/ti/usb/omap_ehci.c b/sys/arm/ti/usb/omap_ehci.c
index 0230ff9..7ce957f 100644
--- a/sys/arm/ti/usb/omap_ehci.c
+++ b/sys/arm/ti/usb/omap_ehci.c
@@ -24,65 +24,20 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-
-/**
- * Driver for the High Speed USB EHCI module on the TI OMAP3530 SoC.
- *
- * WARNING: I've only tried this driver on a limited number of USB peripherals,
- * it is still very raw and bound to have numerous bugs in it.
- *
- * This driver is based on the FreeBSD IXP4xx EHCI driver with a lot of the
- * setup sequence coming from the Linux community and their EHCI driver for
- * OMAP. Without these as a base I don't think I would have been able to get
- * this driver working.
- *
- * The driver only contains the EHCI parts, the module also supports OHCI and
- * USB on-the-go (OTG), currently neither are supported.
- *
- * CAUTION: This driver was written to run on the beaglebaord dev board, so I
- * have made some assumptions about the type of PHY used and some of the other
- * settings. Bare that in mind if you intend to use this driver on another
- * platform.
- *
- * NOTE: This module uses a few different clocks, one being a 60Mhz clock for
- * the TTL part of the module. This clock is derived from DPPL5 which must be
- * configured prior to loading this driver - it is not configured by the
- * bootloader. It took me a long time to figure this out, and caused much
- * frustration. This PLL is now setup in the timer/clocks part of the BSP,
- * check out the omap_prcm_setup_dpll5() function in omap_prcm.c for more info.
- *
- */
-
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "opt_bus.h"
-
-#include <sys/stdint.h>
-#include <sys/stddef.h>
#include <sys/param.h>
-#include <sys/queue.h>
-#include <sys/types.h>
#include <sys/systm.h>
+#include <sys/conf.h>
#include <sys/kernel.h>
-#include <sys/bus.h>
#include <sys/rman.h>
-#include <sys/linker_set.h>
#include <sys/module.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
+#include <sys/proc.h>
#include <sys/condvar.h>
-#include <sys/sysctl.h>
-#include <sys/sx.h>
-#include <sys/unistd.h>
-#include <sys/callout.h>
-#include <sys/malloc.h>
-#include <sys/priv.h>
-#include <sys/gpio.h>
#include <dev/fdt/fdt_common.h>
-#include <dev/ofw/openfirm.h>
-#include <dev/ofw/ofw_bus.h>
+#include <dev/fdt/simplebus.h>
#include <dev/ofw/ofw_bus_subr.h>
#include <dev/usb/usb.h>
@@ -98,80 +53,83 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/controller/ehci.h>
#include <dev/usb/controller/ehcireg.h>
-#include <arm/ti/tivar.h>
-#include <arm/ti/ti_prcm.h>
-#include <arm/ti/ti_scm.h>
+#include <machine/bus.h>
+#include <arm/ti/ti_prcm.h>
#include <arm/ti/usb/omap_usb.h>
-#include "gpio_if.h"
+/* EHCI */
+#define OMAP_USBHOST_HCCAPBASE 0x0000
+#define OMAP_USBHOST_HCSPARAMS 0x0004
+#define OMAP_USBHOST_HCCPARAMS 0x0008
+#define OMAP_USBHOST_USBCMD 0x0010
+#define OMAP_USBHOST_USBSTS 0x0014
+#define OMAP_USBHOST_USBINTR 0x0018
+#define OMAP_USBHOST_FRINDEX 0x001C
+#define OMAP_USBHOST_CTRLDSSEGMENT 0x0020
+#define OMAP_USBHOST_PERIODICLISTBASE 0x0024
+#define OMAP_USBHOST_ASYNCLISTADDR 0x0028
+#define OMAP_USBHOST_CONFIGFLAG 0x0050
+#define OMAP_USBHOST_PORTSC(i) (0x0054 + (0x04 * (i)))
+#define OMAP_USBHOST_INSNREG00 0x0090
+#define OMAP_USBHOST_INSNREG01 0x0094
+#define OMAP_USBHOST_INSNREG02 0x0098
+#define OMAP_USBHOST_INSNREG03 0x009C
+#define OMAP_USBHOST_INSNREG04 0x00A0
+#define OMAP_USBHOST_INSNREG05_UTMI 0x00A4
+#define OMAP_USBHOST_INSNREG05_ULPI 0x00A4
+#define OMAP_USBHOST_INSNREG06 0x00A8
+#define OMAP_USBHOST_INSNREG07 0x00AC
+#define OMAP_USBHOST_INSNREG08 0x00B0
+
+#define OMAP_USBHOST_INSNREG04_DISABLE_UNSUSPEND (1 << 5)
+
+#define OMAP_USBHOST_INSNREG05_ULPI_CONTROL_SHIFT 31
+#define OMAP_USBHOST_INSNREG05_ULPI_PORTSEL_SHIFT 24
+#define OMAP_USBHOST_INSNREG05_ULPI_OPSEL_SHIFT 22
+#define OMAP_USBHOST_INSNREG05_ULPI_REGADD_SHIFT 16
+#define OMAP_USBHOST_INSNREG05_ULPI_EXTREGADD_SHIFT 8
+#define OMAP_USBHOST_INSNREG05_ULPI_WRDATA_SHIFT 0
+
+#define ULPI_FUNC_CTRL_RESET (1 << 5)
+
+/*-------------------------------------------------------------------------*/
+
+/*
+ * Macros for Set and Clear
+ * See ULPI 1.1 specification to find the registers with Set and Clear offsets
+ */
+#define ULPI_SET(a) (a + 1)
+#define ULPI_CLR(a) (a + 2)
+
+/*-------------------------------------------------------------------------*/
+
+/*
+ * Register Map
+ */
+#define ULPI_VENDOR_ID_LOW 0x00
+#define ULPI_VENDOR_ID_HIGH 0x01
+#define ULPI_PRODUCT_ID_LOW 0x02
+#define ULPI_PRODUCT_ID_HIGH 0x03
+#define ULPI_FUNC_CTRL 0x04
+#define ULPI_IFC_CTRL 0x07
+#define ULPI_OTG_CTRL 0x0a
+#define ULPI_USB_INT_EN_RISE 0x0d
+#define ULPI_USB_INT_EN_FALL 0x10
+#define ULPI_USB_INT_STS 0x13
+#define ULPI_USB_INT_LATCH 0x14
+#define ULPI_DEBUG 0x15
+#define ULPI_SCRATCH 0x16
+
+#define OMAP_EHCI_HC_DEVSTR "TI OMAP USB 2.0 controller"
struct omap_ehci_softc {
ehci_softc_t base; /* storage for EHCI code */
-
device_t sc_dev;
- device_t sc_gpio_dev;
-
- /* TLL register set */
- struct resource* tll_mem_res;
-
- /* UHH register set */
- struct resource* uhh_mem_res;
-
- /* The revision of the HS USB HOST read from UHH_REVISION */
- uint32_t ehci_rev;
-
- /* The following details are provided by conf hints */
- int port_mode[3];
- int phy_reset[3];
- int reset_gpio_pin[3];
};
static device_attach_t omap_ehci_attach;
static device_detach_t omap_ehci_detach;
-static device_shutdown_t omap_ehci_shutdown;
-static device_suspend_t omap_ehci_suspend;
-static device_resume_t omap_ehci_resume;
-
-/**
- * omap_tll_read_4 - read a 32-bit value from the USBTLL registers
- * omap_tll_write_4 - write a 32-bit value from the USBTLL registers
- * omap_tll_readb - read an 8-bit value from the USBTLL registers
- * omap_tll_writeb - write an 8-bit value from the USBTLL registers
- * @sc: omap ehci device context
- * @off: byte offset within the register set to read from
- * @val: the value to write into the register
- *
- *
- * LOCKING:
- * None
- *
- * RETURNS:
- * nothing in case of write function, if read function returns the value read.
- */
-static inline uint32_t
-omap_tll_read_4(struct omap_ehci_softc *sc, bus_size_t off)
-{
- return bus_read_4(sc->tll_mem_res, off);
-}
-
-static inline void
-omap_tll_write_4(struct omap_ehci_softc *sc, bus_size_t off, uint32_t val)
-{
- bus_write_4(sc->tll_mem_res, off, val);
-}
-
-static inline uint8_t
-omap_tll_readb(struct omap_ehci_softc *sc, bus_size_t off)
-{
- return bus_read_1(sc->tll_mem_res, off);
-}
-
-static inline void
-omap_tll_writeb(struct omap_ehci_softc *sc, bus_size_t off, uint8_t val)
-{
- bus_write_1(sc->tll_mem_res, off, val);
-}
/**
* omap_ehci_read_4 - read a 32-bit value from the EHCI registers
@@ -192,6 +150,7 @@ omap_ehci_read_4(struct omap_ehci_softc *sc, bus_size_t off)
{
return (bus_read_4(sc->base.sc_io_res, off));
}
+
static inline void
omap_ehci_write_4(struct omap_ehci_softc *sc, bus_size_t off, uint32_t val)
{
@@ -199,86 +158,6 @@ omap_ehci_write_4(struct omap_ehci_softc *sc, bus_size_t off, uint32_t val)
}
/**
- * omap_uhh_read_4 - read a 32-bit value from the UHH registers
- * omap_uhh_write_4 - write a 32-bit value from the UHH registers
- * @sc: omap ehci device context
- * @off: byte offset within the register set to read from
- * @val: the value to write into the register
- *
- *
- * LOCKING:
- * None
- *
- * RETURNS:
- * nothing in case of write function, if read function returns the value read.
- */
-static inline uint32_t
-omap_uhh_read_4(struct omap_ehci_softc *sc, bus_size_t off)
-{
- return bus_read_4(sc->uhh_mem_res, off);
-}
-static inline void
-omap_uhh_write_4(struct omap_ehci_softc *sc, bus_size_t off, uint32_t val)
-{
- bus_write_4(sc->uhh_mem_res, off, val);
-}
-
-/**
- * omap_ehci_utmi_init - initialises the UTMI part of the controller
- * @isc: omap ehci device context
- *
- *
- *
- * LOCKING:
- * none
- *
- * RETURNS:
- * nothing
- */
-static void
-omap_ehci_utmi_init(struct omap_ehci_softc *isc, unsigned int en_mask)
-{
- unsigned int i;
- uint32_t reg;
-
- /* There are 3 TLL channels, one per USB controller so set them all up the
- * same, SDR mode, bit stuffing and no autoidle.
- */
- for (i=0; i<3; i++) {
- reg = omap_tll_read_4(isc, OMAP_USBTLL_TLL_CHANNEL_CONF(i));
-
- reg &= ~(TLL_CHANNEL_CONF_UTMIAUTOIDLE
- | TLL_CHANNEL_CONF_ULPINOBITSTUFF
- | TLL_CHANNEL_CONF_ULPIDDRMODE);
-
- omap_tll_write_4(isc, OMAP_USBTLL_TLL_CHANNEL_CONF(i), reg);
- }
-
- /* Program the common TLL register */
- reg = omap_tll_read_4(isc, OMAP_USBTLL_TLL_SHARED_CONF);
-
- reg &= ~( TLL_SHARED_CONF_USB_90D_DDR_EN
- | TLL_SHARED_CONF_USB_DIVRATIO_MASK);
- reg |= ( TLL_SHARED_CONF_FCLK_IS_ON
- | TLL_SHARED_CONF_USB_DIVRATIO_2
- | TLL_SHARED_CONF_USB_180D_SDR_EN);
-
- omap_tll_write_4(isc, OMAP_USBTLL_TLL_SHARED_CONF, reg);
-
- /* Enable channels now */
- for (i = 0; i < 3; i++) {
- reg = omap_tll_read_4(isc, OMAP_USBTLL_TLL_CHANNEL_CONF(i));
-
- /* Enable only the reg that is needed */
- if ((en_mask & (1 << i)) == 0)
- continue;
-
- reg |= TLL_CHANNEL_CONF_CHANEN;
- omap_tll_write_4(isc, OMAP_USBTLL_TLL_CHANNEL_CONF(i), reg);
- }
-}
-
-/**
* omap_ehci_soft_phy_reset - resets the phy using the reset command
* @isc: omap ehci device context
* @port: port to send the reset over
@@ -321,7 +200,6 @@ omap_ehci_soft_phy_reset(struct omap_ehci_softc *isc, unsigned int port)
}
}
}
-
/**
* omap_ehci_init - initialises the USB host EHCI controller
@@ -340,216 +218,12 @@ omap_ehci_soft_phy_reset(struct omap_ehci_softc *isc, unsigned int port)
static int
omap_ehci_init(struct omap_ehci_softc *isc)
{
- unsigned long timeout;
- int ret = 0;
- uint8_t tll_ch_mask = 0;
uint32_t reg = 0;
- int reset_performed = 0;
int i;
+ device_t uhh_dev;
+ uhh_dev = device_get_parent(isc->sc_dev);
device_printf(isc->sc_dev, "Starting TI EHCI USB Controller\n");
-
-
- /* Enable Clocks for high speed USBHOST */
- ti_prcm_clk_enable(USBHSHOST_CLK);
-
- /* Hold the PHY in reset while configuring */
- for (int i = 0; i < 3; i++) {
- if (isc->phy_reset[i]) {
- /* Configure the GPIO to drive low (hold in reset) */
- if ((isc->reset_gpio_pin[i] != -1) && (isc->sc_gpio_dev != NULL)) {
- GPIO_PIN_SETFLAGS(isc->sc_gpio_dev, isc->reset_gpio_pin[i],
- GPIO_PIN_OUTPUT);
- GPIO_PIN_SET(isc->sc_gpio_dev, isc->reset_gpio_pin[i],
- GPIO_PIN_LOW);
- reset_performed = 1;
- }
- }
- }
-
- /* Hold the PHY in RESET for enough time till DIR is high */
- if (reset_performed)
- DELAY(10);
-
- /* Read the UHH revision */
- isc->ehci_rev = omap_uhh_read_4(isc, OMAP_USBHOST_UHH_REVISION);
- device_printf(isc->sc_dev, "UHH revision 0x%08x\n", isc->ehci_rev);
-
- /* Initilise the low level interface module(s) */
- if (isc->ehci_rev == OMAP_EHCI_REV1) {
-
- /* Enable the USB TLL */
- ti_prcm_clk_enable(USBTLL_CLK);
-
- /* Perform TLL soft reset, and wait until reset is complete */
- omap_tll_write_4(isc, OMAP_USBTLL_SYSCONFIG, TLL_SYSCONFIG_SOFTRESET);
-
- /* Set the timeout to 100ms*/
- timeout = (hz < 10) ? 1 : ((100 * hz) / 1000);
-
- /* Wait for TLL reset to complete */
- while ((omap_tll_read_4(isc, OMAP_USBTLL_SYSSTATUS) &
- TLL_SYSSTATUS_RESETDONE) == 0x00) {
-
- /* Sleep for a tick */
- pause("USBRESET", 1);
-
- if (timeout-- == 0) {
- device_printf(isc->sc_dev, "TLL reset operation timed out\n");
- ret = EINVAL;
- goto err_sys_status;
- }
- }
-
- device_printf(isc->sc_dev, "TLL RESET DONE\n");
-
- /* CLOCKACTIVITY = 1 : OCP-derived internal clocks ON during idle
- * SIDLEMODE = 2 : Smart-idle mode. Sidleack asserted after Idlereq
- * assertion when no more activity on the USB.
- * ENAWAKEUP = 1 : Wakeup generation enabled
- */
- omap_tll_write_4(isc, OMAP_USBTLL_SYSCONFIG, TLL_SYSCONFIG_ENAWAKEUP |
- TLL_SYSCONFIG_AUTOIDLE |
- TLL_SYSCONFIG_SIDLE_SMART_IDLE |
- TLL_SYSCONFIG_CACTIVITY);
-
- } else if (isc->ehci_rev == OMAP_EHCI_REV2) {
-
- /* For OMAP44xx devices you have to enable the per-port clocks:
- * PHY_MODE - External ULPI clock
- * TTL_MODE - Internal UTMI clock
- * HSIC_MODE - Internal 480Mhz and 60Mhz clocks
- */
- if (isc->ehci_rev == OMAP_EHCI_REV2) {
- if (isc->port_mode[0] == EHCI_HCD_OMAP_MODE_PHY) {
- ti_prcm_clk_set_source(USBP1_PHY_CLK, EXT_CLK);
- ti_prcm_clk_enable(USBP1_PHY_CLK);
- } else if (isc->port_mode[0] == EHCI_HCD_OMAP_MODE_TLL)
- ti_prcm_clk_enable(USBP1_UTMI_CLK);
- else if (isc->port_mode[0] == EHCI_HCD_OMAP_MODE_HSIC)
- ti_prcm_clk_enable(USBP1_HSIC_CLK);
-
- if (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_PHY) {
- ti_prcm_clk_set_source(USBP2_PHY_CLK, EXT_CLK);
- ti_prcm_clk_enable(USBP2_PHY_CLK);
- } else if (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_TLL)
- ti_prcm_clk_enable(USBP2_UTMI_CLK);
- else if (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_HSIC)
- ti_prcm_clk_enable(USBP2_HSIC_CLK);
- }
- }
-
- /* Put UHH in SmartIdle/SmartStandby mode */
- reg = omap_uhh_read_4(isc, OMAP_USBHOST_UHH_SYSCONFIG);
- if (isc->ehci_rev == OMAP_EHCI_REV1) {
- reg &= ~(UHH_SYSCONFIG_SIDLEMODE_MASK |
- UHH_SYSCONFIG_MIDLEMODE_MASK);
- reg |= (UHH_SYSCONFIG_ENAWAKEUP |
- UHH_SYSCONFIG_AUTOIDLE |
- UHH_SYSCONFIG_CLOCKACTIVITY |
- UHH_SYSCONFIG_SIDLEMODE_SMARTIDLE |
- UHH_SYSCONFIG_MIDLEMODE_SMARTSTANDBY);
- } else if (isc->ehci_rev == OMAP_EHCI_REV2) {
- reg &= ~UHH_SYSCONFIG_IDLEMODE_MASK;
- reg |= UHH_SYSCONFIG_IDLEMODE_NOIDLE;
- reg &= ~UHH_SYSCONFIG_STANDBYMODE_MASK;
- reg |= UHH_SYSCONFIG_STANDBYMODE_NOSTDBY;
- }
- omap_uhh_write_4(isc, OMAP_USBHOST_UHH_SYSCONFIG, reg);
- device_printf(isc->sc_dev, "OMAP_UHH_SYSCONFIG: 0x%08x\n", reg);
-
- reg = omap_uhh_read_4(isc, OMAP_USBHOST_UHH_HOSTCONFIG);
-
- /* Setup ULPI bypass and burst configurations */
- reg |= (UHH_HOSTCONFIG_ENA_INCR4 |
- UHH_HOSTCONFIG_ENA_INCR8 |
- UHH_HOSTCONFIG_ENA_INCR16);
- reg &= ~UHH_HOSTCONFIG_ENA_INCR_ALIGN;
-
- if (isc->ehci_rev == OMAP_EHCI_REV1) {
- if (isc->port_mode[0] == EHCI_HCD_OMAP_MODE_UNKNOWN)
- reg &= ~UHH_HOSTCONFIG_P1_CONNECT_STATUS;
- if (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_UNKNOWN)
- reg &= ~UHH_HOSTCONFIG_P2_CONNECT_STATUS;
- if (isc->port_mode[2] == EHCI_HCD_OMAP_MODE_UNKNOWN)
- reg &= ~UHH_HOSTCONFIG_P3_CONNECT_STATUS;
-
- /* Bypass the TLL module for PHY mode operation */
- if ((isc->port_mode[0] == EHCI_HCD_OMAP_MODE_PHY) ||
- (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_PHY) ||
- (isc->port_mode[2] == EHCI_HCD_OMAP_MODE_PHY))
- reg &= ~UHH_HOSTCONFIG_P1_ULPI_BYPASS;
- else
- reg |= UHH_HOSTCONFIG_P1_ULPI_BYPASS;
-
- } else if (isc->ehci_rev == OMAP_EHCI_REV2) {
- reg |= UHH_HOSTCONFIG_APP_START_CLK;
-
- /* Clear port mode fields for PHY mode*/
- reg &= ~UHH_HOSTCONFIG_P1_MODE_MASK;
- reg &= ~UHH_HOSTCONFIG_P2_MODE_MASK;
-
- if (isc->port_mode[0] == EHCI_HCD_OMAP_MODE_TLL)
- reg |= UHH_HOSTCONFIG_P1_MODE_UTMI_PHY;
- else if (isc->port_mode[0] == EHCI_HCD_OMAP_MODE_HSIC)
- reg |= UHH_HOSTCONFIG_P1_MODE_HSIC;
-
- if (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_TLL)
- reg |= UHH_HOSTCONFIG_P2_MODE_UTMI_PHY;
- else if (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_HSIC)
- reg |= UHH_HOSTCONFIG_P2_MODE_HSIC;
- }
-
- omap_uhh_write_4(isc, OMAP_USBHOST_UHH_HOSTCONFIG, reg);
- device_printf(isc->sc_dev, "UHH setup done, uhh_hostconfig=0x%08x\n", reg);
-
-
- /* I found the code and comments in the Linux EHCI driver - thanks guys :)
- *
- * "An undocumented "feature" in the OMAP3 EHCI controller, causes suspended
- * ports to be taken out of suspend when the USBCMD.Run/Stop bit is cleared
- * (for example when we do ehci_bus_suspend). This breaks suspend-resume if
- * the root-hub is allowed to suspend. Writing 1 to this undocumented
- * register bit disables this feature and restores normal behavior."
- */
-#if 0
- omap_ehci_write_4(isc, OMAP_USBHOST_INSNREG04,
- OMAP_USBHOST_INSNREG04_DISABLE_UNSUSPEND);
-#endif
-
- /* If any of the ports are configured in TLL mode, enable them */
- if ((isc->port_mode[0] == EHCI_HCD_OMAP_MODE_TLL) ||
- (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_TLL) ||
- (isc->port_mode[2] == EHCI_HCD_OMAP_MODE_TLL)) {
-
- if (isc->port_mode[0] == EHCI_HCD_OMAP_MODE_TLL)
- tll_ch_mask |= 0x1;
- if (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_TLL)
- tll_ch_mask |= 0x2;
- if (isc->port_mode[2] == EHCI_HCD_OMAP_MODE_TLL)
- tll_ch_mask |= 0x4;
-
- /* Enable UTMI mode for required TLL channels */
- omap_ehci_utmi_init(isc, tll_ch_mask);
- }
-
-
- /* Release the PHY reset signal now we have configured everything */
- if (reset_performed) {
-
- /* Delay for 10ms */
- DELAY(10000);
-
- for (i = 0; i < 3; i++) {
- /* Release reset */
-
- if (isc->phy_reset[i] && (isc->reset_gpio_pin[i] != -1)
- && (isc->sc_gpio_dev != NULL)) {
- GPIO_PIN_SET(isc->sc_gpio_dev,
- isc->reset_gpio_pin[i], GPIO_PIN_HIGH);
- }
- }
- }
/* Set the interrupt threshold control, it controls the maximum rate at
* which the host controller issues interrupts. We set it to 1 microframe
@@ -561,166 +235,15 @@ omap_ehci_init(struct omap_ehci_softc *isc)
omap_ehci_write_4(isc, OMAP_USBHOST_USBCMD, reg);
/* Soft reset the PHY using PHY reset command over ULPI */
- if (isc->port_mode[0] == EHCI_HCD_OMAP_MODE_PHY)
- omap_ehci_soft_phy_reset(isc, 0);
- if (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_PHY)
- omap_ehci_soft_phy_reset(isc, 1);
-
- return(0);
-
-err_sys_status:
-
- /* Disable the TLL clocks */
- ti_prcm_clk_disable(USBTLL_CLK);
-
- /* Disable Clocks for USBHOST */
- ti_prcm_clk_disable(USBHSHOST_CLK);
-
- return(ret);
-}
-
-
-/**
- * omap_ehci_fini - shutdown the EHCI controller
- * @isc: omap ehci device context
- *
- *
- *
- * LOCKING:
- * none
- *
- * RETURNS:
- * 0 on success, a negative error code on failure.
- */
-static void
-omap_ehci_fini(struct omap_ehci_softc *isc)
-{
- unsigned long timeout;
-
- device_printf(isc->sc_dev, "Stopping TI EHCI USB Controller\n");
-
- /* Set the timeout */
- if (hz < 10)
- timeout = 1;
- else
- timeout = (100 * hz) / 1000;
-
- /* Reset the UHH, OHCI and EHCI modules */
- omap_uhh_write_4(isc, OMAP_USBHOST_UHH_SYSCONFIG, 0x0002);
- while ((omap_uhh_read_4(isc, OMAP_USBHOST_UHH_SYSSTATUS) & 0x07) == 0x00) {
- /* Sleep for a tick */
- pause("USBRESET", 1);
-
- if (timeout-- == 0) {
- device_printf(isc->sc_dev, "operation timed out\n");
- break;
- }
- }
-
+ for (i = 0; i < OMAP_HS_USB_PORTS; i++) {
+ if (omap_usb_port_mode(uhh_dev, i) == EHCI_HCD_OMAP_MODE_PHY)
+ omap_ehci_soft_phy_reset(isc, i);
- /* Set the timeout */
- if (hz < 10)
- timeout = 1;
- else
- timeout = (100 * hz) / 1000;
-
- /* Reset the TLL module */
- omap_tll_write_4(isc, OMAP_USBTLL_SYSCONFIG, 0x0002);
- while ((omap_tll_read_4(isc, OMAP_USBTLL_SYSSTATUS) & (0x01)) == 0x00) {
- /* Sleep for a tick */
- pause("USBRESET", 1);
-
- if (timeout-- == 0) {
- device_printf(isc->sc_dev, "operation timed out\n");
- break;
- }
}
-
- /* Disable functional and interface clocks for the TLL and HOST modules */
- ti_prcm_clk_disable(USBTLL_CLK);
- ti_prcm_clk_disable(USBHSHOST_CLK);
-
- device_printf(isc->sc_dev, "Clock to USB host has been disabled\n");
-
-}
-
-
-
-/**
- * omap_ehci_suspend - suspends the bus
- * @dev: omap ehci device
- *
- * Effectively boilerplate EHCI suspend code.
- *
- * TODO: There is a lot more we could do here - i.e. force the controller into
- * idle mode and disable all the clocks for start.
- *
- * LOCKING:
- * none
- *
- * RETURNS:
- * 0 on success or a positive error code
- */
-static int
-omap_ehci_suspend(device_t dev)
-{
- int err;
-
- err = bus_generic_suspend(dev);
- if (err)
- return (err);
- return (0);
-}
-
-
-/**
- * omap_ehci_resume - resumes a suspended bus
- * @dev: omap ehci device
- *
- * Effectively boilerplate EHCI resume code.
- *
- * LOCKING:
- * none
- *
- * RETURNS:
- * 0 on success or a positive error code on failure
- */
-static int
-omap_ehci_resume(device_t dev)
-{
-
- bus_generic_resume(dev);
-
- return (0);
-}
-
-
-/**
- * omap_ehci_shutdown - starts the given command
- * @dev:
- *
- * Effectively boilerplate EHCI shutdown code.
- *
- * LOCKING:
- * none.
- *
- * RETURNS:
- * 0 on success or a positive error code on failure
- */
-static int
-omap_ehci_shutdown(device_t dev)
-{
- int err;
-
- err = bus_generic_shutdown(dev);
- if (err)
- return (err);
-
- return (0);
+ return(0);
}
-
/**
* omap_ehci_probe - starts the given command
* @dev:
@@ -740,7 +263,7 @@ omap_ehci_probe(device_t dev)
if (!ofw_bus_status_okay(dev))
return (ENXIO);
- if (!ofw_bus_is_compatible(dev, "ti,usb-ehci"))
+ if (!ofw_bus_is_compatible(dev, "ti,ehci-omap"))
return (ENXIO);
device_set_desc(dev, OMAP_EHCI_HC_DEVSTR);
@@ -766,15 +289,9 @@ static int
omap_ehci_attach(device_t dev)
{
struct omap_ehci_softc *isc = device_get_softc(dev);
- phandle_t node;
- /* 3 ports with 3 cells per port */
- pcell_t phyconf[3 * 3];
- pcell_t *phyconf_ptr;
ehci_softc_t *sc = &isc->base;
int err;
int rid;
- int len, tuple_size;
- int i;
/* initialise some bus fields */
sc->sc_bus.parent = dev;
@@ -782,6 +299,8 @@ omap_ehci_attach(device_t dev)
sc->sc_bus.devices_max = EHCI_MAX_DEVICES;
sc->sc_bus.dma_bits = 32;
+ sprintf(sc->sc_vendor, "Texas Instruments");
+
/* save the device */
isc->sc_dev = dev;
@@ -791,16 +310,6 @@ omap_ehci_attach(device_t dev)
return (ENOMEM);
}
- /* When the EHCI driver is added to the tree it is expected that 3
- * memory resources and 1 interrupt resource is assigned. The memory
- * resources should be:
- * 0 => EHCI register range
- * 1 => UHH register range
- * 2 => TLL register range
- *
- * The interrupt resource is just the single interupt for the controller.
- */
-
/* Allocate resource for the EHCI register set */
rid = 0;
sc->sc_io_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
@@ -816,21 +325,6 @@ omap_ehci_attach(device_t dev)
goto error;
}
- /* Allocate resource for the UHH register set */
- rid = 1;
- isc->uhh_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
- if (!isc->uhh_mem_res) {
- device_printf(dev, "Error: Could not map UHH memory\n");
- goto error;
- }
- /* Allocate resource for the TLL register set */
- rid = 2;
- isc->tll_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
- if (!isc->tll_mem_res) {
- device_printf(dev, "Error: Could not map TLL memory\n");
- goto error;
- }
-
/* Add this device as a child of the USBus device */
sc->sc_bus.bdev = device_add_child(dev, "usbus", -1);
if (!sc->sc_bus.bdev) {
@@ -841,44 +335,6 @@ omap_ehci_attach(device_t dev)
device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus);
device_set_desc(sc->sc_bus.bdev, OMAP_EHCI_HC_DEVSTR);
- /* Set the vendor name */
- sprintf(sc->sc_vendor, "Texas Instruments");
-
- /* Get the GPIO device, we may need this if the driver needs to toggle
- * some pins for external PHY resets.
- */
- isc->sc_gpio_dev = devclass_get_device(devclass_find("gpio"), 0);
- if (isc->sc_gpio_dev == NULL) {
- device_printf(dev, "Error: failed to get the GPIO device\n");
- goto error;
- }
-
- /* Set the defaults for the hints */
- for (i = 0; i < 3; i++) {
- isc->phy_reset[i] = 0;
- isc->port_mode[i] = EHCI_HCD_OMAP_MODE_UNKNOWN;
- isc->reset_gpio_pin[i] = -1;
- }
-
- tuple_size = sizeof(pcell_t) * 3;
- node = ofw_bus_get_node(dev);
- len = OF_getprop(node, "phy-config", phyconf, sizeof(phyconf));
- if (len > 0) {
- if (len % tuple_size)
- goto error;
- if ((len / tuple_size) != 3)
- goto error;
-
- phyconf_ptr = phyconf;
- for (i = 0; i < 3; i++) {
- isc->port_mode[i] = fdt32_to_cpu(*phyconf_ptr);
- isc->phy_reset[i] = fdt32_to_cpu(*(phyconf_ptr + 1));
- isc->reset_gpio_pin[i] = fdt32_to_cpu(*(phyconf_ptr + 2));
-
- phyconf_ptr += 3;
- }
- }
-
/* Initialise the ECHI registers */
err = omap_ehci_init(isc);
if (err) {
@@ -886,13 +342,11 @@ omap_ehci_attach(device_t dev)
goto error;
}
-
/* Set the tag and size of the register set in the EHCI context */
sc->sc_io_hdl = rman_get_bushandle(sc->sc_io_res);
sc->sc_io_tag = rman_get_bustag(sc->sc_io_res);
sc->sc_io_size = rman_get_size(sc->sc_io_res);
-
/* Setup the interrupt */
err = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_BIO | INTR_MPSAFE,
NULL, (driver_intr_t *)ehci_interrupt, sc, &sc->sc_intr_hdl);
@@ -902,7 +356,6 @@ omap_ehci_attach(device_t dev)
goto error;
}
-
/* Finally we are ready to kick off the ECHI host controller */
err = ehci_init(sc);
if (err == 0) {
@@ -980,20 +433,6 @@ omap_ehci_detach(device_t dev)
sc->sc_io_res = NULL;
}
- /* Release the other register set memory maps */
- if (isc->tll_mem_res) {
- bus_release_resource(dev, SYS_RES_MEMORY, 0, isc->tll_mem_res);
- isc->tll_mem_res = NULL;
- }
- if (isc->uhh_mem_res) {
- bus_release_resource(dev, SYS_RES_MEMORY, 0, isc->uhh_mem_res);
- isc->uhh_mem_res = NULL;
- }
-
- usb_bus_mem_free_all(&sc->sc_bus, &ehci_iterate_hw_softc);
-
- omap_ehci_fini(isc);
-
return (0);
}
@@ -1002,9 +441,10 @@ static device_method_t ehci_methods[] = {
DEVMETHOD(device_probe, omap_ehci_probe),
DEVMETHOD(device_attach, omap_ehci_attach),
DEVMETHOD(device_detach, omap_ehci_detach),
- DEVMETHOD(device_suspend, omap_ehci_suspend),
- DEVMETHOD(device_resume, omap_ehci_resume),
- DEVMETHOD(device_shutdown, omap_ehci_shutdown),
+
+ DEVMETHOD(device_suspend, bus_generic_suspend),
+ DEVMETHOD(device_resume, bus_generic_resume),
+ DEVMETHOD(device_shutdown, bus_generic_shutdown),
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
@@ -1020,4 +460,4 @@ static driver_t ehci_driver = {
static devclass_t ehci_devclass;
-DRIVER_MODULE(ehci, simplebus, ehci_driver, ehci_devclass, 0, 0);
+DRIVER_MODULE(ehci, omap_uhh, ehci_driver, ehci_devclass, 0, 0);
diff --git a/sys/arm/ti/usb/omap_host.c b/sys/arm/ti/usb/omap_host.c
new file mode 100644
index 0000000..326a5b3
--- /dev/null
+++ b/sys/arm/ti/usb/omap_host.c
@@ -0,0 +1,466 @@
+/*-
+ * Copyright (c) 2015 Oleksandr Tymoshenko <gonzo@freebsd.org>
+ * Copyright (c) 2011 Ben Gray <ben.r.gray@gmail.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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY 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 AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (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>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/rman.h>
+#include <sys/module.h>
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/fdt/simplebus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include <machine/bus.h>
+
+#include <arm/ti/ti_prcm.h>
+#include <arm/ti/usb/omap_usb.h>
+
+/*
+ * USB Host Module
+ */
+
+/* UHH */
+#define OMAP_USBHOST_UHH_REVISION 0x0000
+#define OMAP_USBHOST_UHH_SYSCONFIG 0x0010
+#define OMAP_USBHOST_UHH_SYSSTATUS 0x0014
+#define OMAP_USBHOST_UHH_HOSTCONFIG 0x0040
+#define OMAP_USBHOST_UHH_DEBUG_CSR 0x0044
+
+/* UHH Register Set */
+#define UHH_SYSCONFIG_MIDLEMODE_MASK (3UL << 12)
+#define UHH_SYSCONFIG_MIDLEMODE_SMARTSTANDBY (2UL << 12)
+#define UHH_SYSCONFIG_MIDLEMODE_NOSTANDBY (1UL << 12)
+#define UHH_SYSCONFIG_MIDLEMODE_FORCESTANDBY (0UL << 12)
+#define UHH_SYSCONFIG_CLOCKACTIVITY (1UL << 8)
+#define UHH_SYSCONFIG_SIDLEMODE_MASK (3UL << 3)
+#define UHH_SYSCONFIG_SIDLEMODE_SMARTIDLE (2UL << 3)
+#define UHH_SYSCONFIG_SIDLEMODE_NOIDLE (1UL << 3)
+#define UHH_SYSCONFIG_SIDLEMODE_FORCEIDLE (0UL << 3)
+#define UHH_SYSCONFIG_ENAWAKEUP (1UL << 2)
+#define UHH_SYSCONFIG_SOFTRESET (1UL << 1)
+#define UHH_SYSCONFIG_AUTOIDLE (1UL << 0)
+
+#define UHH_HOSTCONFIG_APP_START_CLK (1UL << 31)
+#define UHH_HOSTCONFIG_P3_CONNECT_STATUS (1UL << 10)
+#define UHH_HOSTCONFIG_P2_CONNECT_STATUS (1UL << 9)
+#define UHH_HOSTCONFIG_P1_CONNECT_STATUS (1UL << 8)
+#define UHH_HOSTCONFIG_ENA_INCR_ALIGN (1UL << 5)
+#define UHH_HOSTCONFIG_ENA_INCR16 (1UL << 4)
+#define UHH_HOSTCONFIG_ENA_INCR8 (1UL << 3)
+#define UHH_HOSTCONFIG_ENA_INCR4 (1UL << 2)
+#define UHH_HOSTCONFIG_AUTOPPD_ON_OVERCUR_EN (1UL << 1)
+#define UHH_HOSTCONFIG_P1_ULPI_BYPASS (1UL << 0)
+
+/* The following are on rev2 (OMAP44xx) of the EHCI only */
+#define UHH_SYSCONFIG_IDLEMODE_MASK (3UL << 2)
+#define UHH_SYSCONFIG_IDLEMODE_NOIDLE (1UL << 2)
+#define UHH_SYSCONFIG_STANDBYMODE_MASK (3UL << 4)
+#define UHH_SYSCONFIG_STANDBYMODE_NOSTDBY (1UL << 4)
+
+#define UHH_HOSTCONFIG_P1_MODE_MASK (3UL << 16)
+#define UHH_HOSTCONFIG_P1_MODE_ULPI_PHY (0UL << 16)
+#define UHH_HOSTCONFIG_P1_MODE_UTMI_PHY (1UL << 16)
+#define UHH_HOSTCONFIG_P1_MODE_HSIC (3UL << 16)
+#define UHH_HOSTCONFIG_P2_MODE_MASK (3UL << 18)
+#define UHH_HOSTCONFIG_P2_MODE_ULPI_PHY (0UL << 18)
+#define UHH_HOSTCONFIG_P2_MODE_UTMI_PHY (1UL << 18)
+#define UHH_HOSTCONFIG_P2_MODE_HSIC (3UL << 18)
+
+/*
+ * Values of UHH_REVISION - Note: these are not given in the TRM but taken
+ * from the linux OMAP EHCI driver (thanks guys). It has been verified on
+ * a Panda and Beagle board.
+ */
+#define OMAP_UHH_REV1 0x00000010 /* OMAP3 */
+#define OMAP_UHH_REV2 0x50700100 /* OMAP4 */
+
+struct omap_uhh_softc {
+ struct simplebus_softc simplebus_sc;
+ device_t sc_dev;
+
+ /* UHH register set */
+ struct resource* uhh_mem_res;
+
+ /* The revision of the HS USB HOST read from UHH_REVISION */
+ uint32_t uhh_rev;
+
+ /* The following details are provided by conf hints */
+ int port_mode[3];
+};
+
+static device_attach_t omap_uhh_attach;
+static device_detach_t omap_uhh_detach;
+
+static inline uint32_t
+omap_uhh_read_4(struct omap_uhh_softc *sc, bus_size_t off)
+{
+ return bus_read_4(sc->uhh_mem_res, off);
+}
+
+static inline void
+omap_uhh_write_4(struct omap_uhh_softc *sc, bus_size_t off, uint32_t val)
+{
+ bus_write_4(sc->uhh_mem_res, off, val);
+}
+
+static int
+omap_uhh_init(struct omap_uhh_softc *isc)
+{
+ uint8_t tll_ch_mask;
+ uint32_t reg;
+ int i;
+
+ /* Enable Clocks for high speed USBHOST */
+ ti_prcm_clk_enable(USBHSHOST_CLK);
+
+ /* Read the UHH revision */
+ isc->uhh_rev = omap_uhh_read_4(isc, OMAP_USBHOST_UHH_REVISION);
+ device_printf(isc->sc_dev, "UHH revision 0x%08x\n", isc->uhh_rev);
+
+ if (isc->uhh_rev == OMAP_UHH_REV2) {
+ /* For OMAP44xx devices you have to enable the per-port clocks:
+ * PHY_MODE - External ULPI clock
+ * TTL_MODE - Internal UTMI clock
+ * HSIC_MODE - Internal 480Mhz and 60Mhz clocks
+ */
+ switch(isc->port_mode[0]) {
+ case EHCI_HCD_OMAP_MODE_UNKNOWN:
+ break;
+ case EHCI_HCD_OMAP_MODE_PHY:
+ if (ti_prcm_clk_set_source(USBP1_PHY_CLK, EXT_CLK))
+ device_printf(isc->sc_dev,
+ "failed to set clock source for port 0\n");
+ if (ti_prcm_clk_enable(USBP1_PHY_CLK))
+ device_printf(isc->sc_dev,
+ "failed to set clock USBP1_PHY_CLK source for port 0\n");
+ break;
+ case EHCI_HCD_OMAP_MODE_TLL:
+ if (ti_prcm_clk_enable(USBP1_UTMI_CLK))
+ device_printf(isc->sc_dev,
+ "failed to set clock USBP1_PHY_CLK source for port 0\n");
+ break;
+ case EHCI_HCD_OMAP_MODE_HSIC:
+ if (ti_prcm_clk_enable(USBP1_HSIC_CLK))
+ device_printf(isc->sc_dev,
+ "failed to set clock USBP1_PHY_CLK source for port 0\n");
+ break;
+ default:
+ device_printf(isc->sc_dev, "unknown port mode %d for port 0\n", isc->port_mode[0]);
+ }
+ switch(isc->port_mode[1]) {
+ case EHCI_HCD_OMAP_MODE_UNKNOWN:
+ break;
+ case EHCI_HCD_OMAP_MODE_PHY:
+ if (ti_prcm_clk_set_source(USBP2_PHY_CLK, EXT_CLK))
+ device_printf(isc->sc_dev,
+ "failed to set clock source for port 0\n");
+ if (ti_prcm_clk_enable(USBP2_PHY_CLK))
+ device_printf(isc->sc_dev,
+ "failed to set clock USBP2_PHY_CLK source for port 1\n");
+ break;
+ case EHCI_HCD_OMAP_MODE_TLL:
+ if (ti_prcm_clk_enable(USBP2_UTMI_CLK))
+ device_printf(isc->sc_dev,
+ "failed to set clock USBP2_UTMI_CLK source for port 1\n");
+ break;
+ case EHCI_HCD_OMAP_MODE_HSIC:
+ if (ti_prcm_clk_enable(USBP2_HSIC_CLK))
+ device_printf(isc->sc_dev,
+ "failed to set clock USBP2_HSIC_CLK source for port 1\n");
+ break;
+ default:
+ device_printf(isc->sc_dev, "unknown port mode %d for port 1\n", isc->port_mode[1]);
+ }
+ }
+
+ /* Put UHH in SmartIdle/SmartStandby mode */
+ reg = omap_uhh_read_4(isc, OMAP_USBHOST_UHH_SYSCONFIG);
+ if (isc->uhh_rev == OMAP_UHH_REV1) {
+ reg &= ~(UHH_SYSCONFIG_SIDLEMODE_MASK |
+ UHH_SYSCONFIG_MIDLEMODE_MASK);
+ reg |= (UHH_SYSCONFIG_ENAWAKEUP |
+ UHH_SYSCONFIG_AUTOIDLE |
+ UHH_SYSCONFIG_CLOCKACTIVITY |
+ UHH_SYSCONFIG_SIDLEMODE_SMARTIDLE |
+ UHH_SYSCONFIG_MIDLEMODE_SMARTSTANDBY);
+ } else if (isc->uhh_rev == OMAP_UHH_REV2) {
+ reg &= ~UHH_SYSCONFIG_IDLEMODE_MASK;
+ reg |= UHH_SYSCONFIG_IDLEMODE_NOIDLE;
+ reg &= ~UHH_SYSCONFIG_STANDBYMODE_MASK;
+ reg |= UHH_SYSCONFIG_STANDBYMODE_NOSTDBY;
+ }
+ omap_uhh_write_4(isc, OMAP_USBHOST_UHH_SYSCONFIG, reg);
+ device_printf(isc->sc_dev, "OMAP_UHH_SYSCONFIG: 0x%08x\n", reg);
+
+ reg = omap_uhh_read_4(isc, OMAP_USBHOST_UHH_HOSTCONFIG);
+
+ /* Setup ULPI bypass and burst configurations */
+ reg |= (UHH_HOSTCONFIG_ENA_INCR4 |
+ UHH_HOSTCONFIG_ENA_INCR8 |
+ UHH_HOSTCONFIG_ENA_INCR16);
+ reg &= ~UHH_HOSTCONFIG_ENA_INCR_ALIGN;
+
+ if (isc->uhh_rev == OMAP_UHH_REV1) {
+ if (isc->port_mode[0] == EHCI_HCD_OMAP_MODE_UNKNOWN)
+ reg &= ~UHH_HOSTCONFIG_P1_CONNECT_STATUS;
+ if (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_UNKNOWN)
+ reg &= ~UHH_HOSTCONFIG_P2_CONNECT_STATUS;
+ if (isc->port_mode[2] == EHCI_HCD_OMAP_MODE_UNKNOWN)
+ reg &= ~UHH_HOSTCONFIG_P3_CONNECT_STATUS;
+
+ /* Bypass the TLL module for PHY mode operation */
+ if ((isc->port_mode[0] == EHCI_HCD_OMAP_MODE_PHY) ||
+ (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_PHY) ||
+ (isc->port_mode[2] == EHCI_HCD_OMAP_MODE_PHY))
+ reg &= ~UHH_HOSTCONFIG_P1_ULPI_BYPASS;
+ else
+ reg |= UHH_HOSTCONFIG_P1_ULPI_BYPASS;
+
+ } else if (isc->uhh_rev == OMAP_UHH_REV2) {
+ reg |= UHH_HOSTCONFIG_APP_START_CLK;
+
+ /* Clear port mode fields for PHY mode*/
+ reg &= ~UHH_HOSTCONFIG_P1_MODE_MASK;
+ reg &= ~UHH_HOSTCONFIG_P2_MODE_MASK;
+
+ if (isc->port_mode[0] == EHCI_HCD_OMAP_MODE_TLL)
+ reg |= UHH_HOSTCONFIG_P1_MODE_UTMI_PHY;
+ else if (isc->port_mode[0] == EHCI_HCD_OMAP_MODE_HSIC)
+ reg |= UHH_HOSTCONFIG_P1_MODE_HSIC;
+
+ if (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_TLL)
+ reg |= UHH_HOSTCONFIG_P2_MODE_UTMI_PHY;
+ else if (isc->port_mode[1] == EHCI_HCD_OMAP_MODE_HSIC)
+ reg |= UHH_HOSTCONFIG_P2_MODE_HSIC;
+ }
+
+ omap_uhh_write_4(isc, OMAP_USBHOST_UHH_HOSTCONFIG, reg);
+ device_printf(isc->sc_dev, "UHH setup done, uhh_hostconfig=0x%08x\n", reg);
+
+
+ /* I found the code and comments in the Linux EHCI driver - thanks guys :)
+ *
+ * "An undocumented "feature" in the OMAP3 EHCI controller, causes suspended
+ * ports to be taken out of suspend when the USBCMD.Run/Stop bit is cleared
+ * (for example when we do omap_uhh_bus_suspend). This breaks suspend-resume if
+ * the root-hub is allowed to suspend. Writing 1 to this undocumented
+ * register bit disables this feature and restores normal behavior."
+ */
+#if 0
+ omap_uhh_write_4(isc, OMAP_USBHOST_INSNREG04,
+ OMAP_USBHOST_INSNREG04_DISABLE_UNSUSPEND);
+#endif
+ tll_ch_mask = 0;
+ for (i = 0; i < OMAP_HS_USB_PORTS; i++) {
+ if (isc->port_mode[i] == EHCI_HCD_OMAP_MODE_TLL)
+ tll_ch_mask |= (1 << i);
+ }
+ if (tll_ch_mask)
+ omap_tll_utmi_enable(tll_ch_mask);
+
+ return(0);
+}
+
+/**
+ * omap_uhh_fini - shutdown the EHCI controller
+ * @isc: omap ehci device context
+ *
+ *
+ *
+ * LOCKING:
+ * none
+ *
+ * RETURNS:
+ * 0 on success, a negative error code on failure.
+ */
+static void
+omap_uhh_fini(struct omap_uhh_softc *isc)
+{
+ unsigned long timeout;
+
+ device_printf(isc->sc_dev, "Stopping TI EHCI USB Controller\n");
+
+ /* Set the timeout */
+ if (hz < 10)
+ timeout = 1;
+ else
+ timeout = (100 * hz) / 1000;
+
+ /* Reset the UHH, OHCI and EHCI modules */
+ omap_uhh_write_4(isc, OMAP_USBHOST_UHH_SYSCONFIG, 0x0002);
+ while ((omap_uhh_read_4(isc, OMAP_USBHOST_UHH_SYSSTATUS) & 0x07) == 0x00) {
+ /* Sleep for a tick */
+ pause("USBRESET", 1);
+
+ if (timeout-- == 0) {
+ device_printf(isc->sc_dev, "operation timed out\n");
+ break;
+ }
+ }
+
+ /* Disable functional and interface clocks for the TLL and HOST modules */
+ ti_prcm_clk_disable(USBHSHOST_CLK);
+
+ device_printf(isc->sc_dev, "Clock to USB host has been disabled\n");
+}
+
+int
+omap_usb_port_mode(device_t dev, int port)
+{
+ struct omap_uhh_softc *isc;
+
+ isc = device_get_softc(dev);
+ if ((port < 0) || (port >= OMAP_HS_USB_PORTS))
+ return (-1);
+
+ return isc->port_mode[port];
+}
+
+static int
+omap_uhh_probe(device_t dev)
+{
+
+ if (!ofw_bus_status_okay(dev))
+ return (ENXIO);
+
+ if (!ofw_bus_is_compatible(dev, "ti,usbhs-host"))
+ return (ENXIO);
+
+ device_set_desc(dev, "TI OMAP USB 2.0 Host module");
+
+ return (BUS_PROBE_DEFAULT);
+}
+
+static int
+omap_uhh_attach(device_t dev)
+{
+ struct omap_uhh_softc *isc = device_get_softc(dev);
+ int err;
+ int rid;
+ int i;
+ phandle_t node;
+ char propname[16];
+ char *mode;
+
+ /* save the device */
+ isc->sc_dev = dev;
+
+ /* Allocate resource for the UHH register set */
+ rid = 0;
+ isc->uhh_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
+ if (!isc->uhh_mem_res) {
+ device_printf(dev, "Error: Could not map UHH memory\n");
+ goto error;
+ }
+
+ node = ofw_bus_get_node(dev);
+
+ if (node == -1)
+ goto error;
+
+ /* Get port modes from FDT */
+ for (i = 0; i < OMAP_HS_USB_PORTS; i++) {
+ isc->port_mode[i] = EHCI_HCD_OMAP_MODE_UNKNOWN;
+ snprintf(propname, sizeof(propname),
+ "port%d-mode", i+1);
+
+ if (OF_getprop_alloc(node, propname, 1, (void**)&mode) <= 0)
+ continue;
+ if (strcmp(mode, "ehci-phy") == 0)
+ isc->port_mode[i] = EHCI_HCD_OMAP_MODE_PHY;
+ else if (strcmp(mode, "ehci-tll") == 0)
+ isc->port_mode[i] = EHCI_HCD_OMAP_MODE_TLL;
+ else if (strcmp(mode, "ehci-hsic") == 0)
+ isc->port_mode[i] = EHCI_HCD_OMAP_MODE_HSIC;
+ }
+
+ /* Initialise the ECHI registers */
+ err = omap_uhh_init(isc);
+ if (err) {
+ device_printf(dev, "Error: could not setup OMAP EHCI, %d\n", err);
+ goto error;
+ }
+
+ simplebus_init(dev, node);
+
+ /*
+ * Allow devices to identify.
+ */
+ bus_generic_probe(dev);
+
+ /*
+ * Now walk the OFW tree and attach top-level devices.
+ */
+ for (node = OF_child(node); node > 0; node = OF_peer(node))
+ simplebus_add_device(dev, node, 0, NULL, -1, NULL);
+ return (bus_generic_attach(dev));
+
+error:
+ omap_uhh_detach(dev);
+ return (ENXIO);
+}
+
+static int
+omap_uhh_detach(device_t dev)
+{
+ struct omap_uhh_softc *isc = device_get_softc(dev);
+
+ /* during module unload there are lots of children leftover */
+ device_delete_children(dev);
+
+ if (isc->uhh_mem_res) {
+ bus_release_resource(dev, SYS_RES_MEMORY, 0, isc->uhh_mem_res);
+ isc->uhh_mem_res = NULL;
+ }
+
+ omap_uhh_fini(isc);
+
+ return (0);
+}
+
+static device_method_t omap_uhh_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, omap_uhh_probe),
+ DEVMETHOD(device_attach, omap_uhh_attach),
+ DEVMETHOD(device_detach, omap_uhh_detach),
+
+ DEVMETHOD(device_suspend, bus_generic_suspend),
+ DEVMETHOD(device_resume, bus_generic_resume),
+ DEVMETHOD(device_shutdown, bus_generic_shutdown),
+
+ DEVMETHOD_END
+};
+
+DEFINE_CLASS_1(omap_uhh, omap_uhh_driver, omap_uhh_methods,
+ sizeof(struct omap_uhh_softc), simplebus_driver);
+static devclass_t omap_uhh_devclass;
+DRIVER_MODULE(omap_uhh, simplebus, omap_uhh_driver, omap_uhh_devclass, 0, 0);
diff --git a/sys/arm/ti/usb/omap_tll.c b/sys/arm/ti/usb/omap_tll.c
new file mode 100644
index 0000000..9bcb7d6
--- /dev/null
+++ b/sys/arm/ti/usb/omap_tll.c
@@ -0,0 +1,364 @@
+/*-
+ * Copyright (c) 2011
+ * Ben Gray <ben.r.gray@gmail.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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY 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 AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (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>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/rman.h>
+#include <sys/module.h>
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include <machine/bus.h>
+
+#include <arm/ti/ti_prcm.h>
+#include <arm/ti/usb/omap_usb.h>
+
+/*
+ * USB TLL Module
+ */
+#define OMAP_USBTLL_REVISION 0x0000
+#define OMAP_USBTLL_SYSCONFIG 0x0010
+#define OMAP_USBTLL_SYSSTATUS 0x0014
+#define OMAP_USBTLL_IRQSTATUS 0x0018
+#define OMAP_USBTLL_IRQENABLE 0x001C
+#define OMAP_USBTLL_TLL_SHARED_CONF 0x0030
+#define OMAP_USBTLL_TLL_CHANNEL_CONF(i) (0x0040 + (0x04 * (i)))
+#define OMAP_USBTLL_SAR_CNTX(i) (0x0400 + (0x04 * (i)))
+#define OMAP_USBTLL_ULPI_VENDOR_ID_LO(i) (0x0800 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_VENDOR_ID_HI(i) (0x0801 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_PRODUCT_ID_LO(i) (0x0802 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_PRODUCT_ID_HI(i) (0x0803 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_FUNCTION_CTRL(i) (0x0804 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_FUNCTION_CTRL_SET(i) (0x0805 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_FUNCTION_CTRL_CLR(i) (0x0806 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_INTERFACE_CTRL(i) (0x0807 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_INTERFACE_CTRL_SET(i) (0x0808 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_INTERFACE_CTRL_CLR(i) (0x0809 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_OTG_CTRL(i) (0x080A + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_OTG_CTRL_SET(i) (0x080B + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_OTG_CTRL_CLR(i) (0x080C + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_USB_INT_EN_RISE(i) (0x080D + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_USB_INT_EN_RISE_SET(i) (0x080E + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_USB_INT_EN_RISE_CLR(i) (0x080F + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_USB_INT_EN_FALL(i) (0x0810 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_USB_INT_EN_FALL_SET(i) (0x0811 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_USB_INT_EN_FALL_CLR(i) (0x0812 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_USB_INT_STATUS(i) (0x0813 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_USB_INT_LATCH(i) (0x0814 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_DEBUG(i) (0x0815 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_SCRATCH_REGISTER(i) (0x0816 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_SCRATCH_REGISTER_SET(i) (0x0817 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_SCRATCH_REGISTER_CLR(i) (0x0818 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_EXTENDED_SET_ACCESS(i) (0x082F + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_UTMI_VCONTROL_EN(i) (0x0830 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_UTMI_VCONTROL_EN_SET(i) (0x0831 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_UTMI_VCONTROL_EN_CLR(i) (0x0832 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_UTMI_VCONTROL_STATUS(i) (0x0833 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_UTMI_VCONTROL_LATCH(i) (0x0834 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_UTMI_VSTATUS(i) (0x0835 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_UTMI_VSTATUS_SET(i) (0x0836 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_UTMI_VSTATUS_CLR(i) (0x0837 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_USB_INT_LATCH_NOCLR(i) (0x0838 + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_VENDOR_INT_EN(i) (0x083B + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_VENDOR_INT_EN_SET(i) (0x083C + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_VENDOR_INT_EN_CLR(i) (0x083D + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_VENDOR_INT_STATUS(i) (0x083E + (0x100 * (i)))
+#define OMAP_USBTLL_ULPI_VENDOR_INT_LATCH(i) (0x083F + (0x100 * (i)))
+
+/* TLL Register Set */
+#define TLL_SYSCONFIG_CACTIVITY (1UL << 8)
+#define TLL_SYSCONFIG_SIDLE_SMART_IDLE (2UL << 3)
+#define TLL_SYSCONFIG_SIDLE_NO_IDLE (1UL << 3)
+#define TLL_SYSCONFIG_SIDLE_FORCED_IDLE (0UL << 3)
+#define TLL_SYSCONFIG_ENAWAKEUP (1UL << 2)
+#define TLL_SYSCONFIG_SOFTRESET (1UL << 1)
+#define TLL_SYSCONFIG_AUTOIDLE (1UL << 0)
+
+#define TLL_SYSSTATUS_RESETDONE (1UL << 0)
+
+#define TLL_SHARED_CONF_USB_90D_DDR_EN (1UL << 6)
+#define TLL_SHARED_CONF_USB_180D_SDR_EN (1UL << 5)
+#define TLL_SHARED_CONF_USB_DIVRATIO_MASK (7UL << 2)
+#define TLL_SHARED_CONF_USB_DIVRATIO_128 (7UL << 2)
+#define TLL_SHARED_CONF_USB_DIVRATIO_64 (6UL << 2)
+#define TLL_SHARED_CONF_USB_DIVRATIO_32 (5UL << 2)
+#define TLL_SHARED_CONF_USB_DIVRATIO_16 (4UL << 2)
+#define TLL_SHARED_CONF_USB_DIVRATIO_8 (3UL << 2)
+#define TLL_SHARED_CONF_USB_DIVRATIO_4 (2UL << 2)
+#define TLL_SHARED_CONF_USB_DIVRATIO_2 (1UL << 2)
+#define TLL_SHARED_CONF_USB_DIVRATIO_1 (0UL << 2)
+#define TLL_SHARED_CONF_FCLK_REQ (1UL << 1)
+#define TLL_SHARED_CONF_FCLK_IS_ON (1UL << 0)
+
+#define TLL_CHANNEL_CONF_DRVVBUS (1UL << 16)
+#define TLL_CHANNEL_CONF_CHRGVBUS (1UL << 15)
+#define TLL_CHANNEL_CONF_ULPINOBITSTUFF (1UL << 11)
+#define TLL_CHANNEL_CONF_ULPIAUTOIDLE (1UL << 10)
+#define TLL_CHANNEL_CONF_UTMIAUTOIDLE (1UL << 9)
+#define TLL_CHANNEL_CONF_ULPIDDRMODE (1UL << 8)
+#define TLL_CHANNEL_CONF_ULPIOUTCLKMODE (1UL << 7)
+#define TLL_CHANNEL_CONF_TLLFULLSPEED (1UL << 6)
+#define TLL_CHANNEL_CONF_TLLCONNECT (1UL << 5)
+#define TLL_CHANNEL_CONF_TLLATTACH (1UL << 4)
+#define TLL_CHANNEL_CONF_UTMIISADEV (1UL << 3)
+#define TLL_CHANNEL_CONF_CHANEN (1UL << 0)
+
+struct omap_tll_softc {
+ device_t sc_dev;
+
+ /* TLL register set */
+ struct resource* tll_mem_res;
+ int tll_mem_rid;
+};
+
+static struct omap_tll_softc *omap_tll_sc;
+
+static int omap_tll_attach(device_t dev);
+static int omap_tll_detach(device_t dev);
+
+static inline uint32_t
+omap_tll_read_4(struct omap_tll_softc *sc, bus_size_t off)
+{
+ return bus_read_4(sc->tll_mem_res, off);
+}
+
+static inline void
+omap_tll_write_4(struct omap_tll_softc *sc, bus_size_t off, uint32_t val)
+{
+ bus_write_4(sc->tll_mem_res, off, val);
+}
+
+void
+omap_tll_utmi_enable(unsigned int en_mask)
+{
+ struct omap_tll_softc *sc;
+ unsigned int i;
+ uint32_t reg;
+
+ sc = omap_tll_sc;
+ if (sc == NULL)
+ return;
+
+ /* There are 3 TLL channels, one per USB controller so set them all up the
+ * same, SDR mode, bit stuffing and no autoidle.
+ */
+ for (i=0; i<3; i++) {
+ reg = omap_tll_read_4(sc, OMAP_USBTLL_TLL_CHANNEL_CONF(i));
+
+ reg &= ~(TLL_CHANNEL_CONF_UTMIAUTOIDLE
+ | TLL_CHANNEL_CONF_ULPINOBITSTUFF
+ | TLL_CHANNEL_CONF_ULPIDDRMODE);
+
+ omap_tll_write_4(sc, OMAP_USBTLL_TLL_CHANNEL_CONF(i), reg);
+ }
+
+ /* Program the common TLL register */
+ reg = omap_tll_read_4(sc, OMAP_USBTLL_TLL_SHARED_CONF);
+
+ reg &= ~( TLL_SHARED_CONF_USB_90D_DDR_EN
+ | TLL_SHARED_CONF_USB_DIVRATIO_MASK);
+ reg |= ( TLL_SHARED_CONF_FCLK_IS_ON
+ | TLL_SHARED_CONF_USB_DIVRATIO_2
+ | TLL_SHARED_CONF_USB_180D_SDR_EN);
+
+ omap_tll_write_4(sc, OMAP_USBTLL_TLL_SHARED_CONF, reg);
+
+ /* Enable channels now */
+ for (i = 0; i < 3; i++) {
+ reg = omap_tll_read_4(sc, OMAP_USBTLL_TLL_CHANNEL_CONF(i));
+
+ /* Enable only the reg that is needed */
+ if ((en_mask & (1 << i)) == 0)
+ continue;
+
+ reg |= TLL_CHANNEL_CONF_CHANEN;
+ omap_tll_write_4(sc, OMAP_USBTLL_TLL_CHANNEL_CONF(i), reg);
+ }
+}
+
+static int
+omap_tll_init(struct omap_tll_softc *sc)
+{
+ unsigned long timeout;
+ int ret = 0;
+
+ /* Enable the USB TLL */
+ ti_prcm_clk_enable(USBTLL_CLK);
+
+ /* Perform TLL soft reset, and wait until reset is complete */
+ omap_tll_write_4(sc, OMAP_USBTLL_SYSCONFIG, TLL_SYSCONFIG_SOFTRESET);
+
+ /* Set the timeout to 100ms*/
+ timeout = (hz < 10) ? 1 : ((100 * hz) / 1000);
+
+ /* Wait for TLL reset to complete */
+ while ((omap_tll_read_4(sc, OMAP_USBTLL_SYSSTATUS) &
+ TLL_SYSSTATUS_RESETDONE) == 0x00) {
+
+ /* Sleep for a tick */
+ pause("USBRESET", 1);
+
+ if (timeout-- == 0) {
+ device_printf(sc->sc_dev, "TLL reset operation timed out\n");
+ ret = EINVAL;
+ goto err_sys_status;
+ }
+ }
+
+ /* CLOCKACTIVITY = 1 : OCP-derived internal clocks ON during idle
+ * SIDLEMODE = 2 : Smart-idle mode. Sidleack asserted after Idlereq
+ * assertion when no more activity on the USB.
+ * ENAWAKEUP = 1 : Wakeup generation enabled
+ */
+ omap_tll_write_4(sc, OMAP_USBTLL_SYSCONFIG, TLL_SYSCONFIG_ENAWAKEUP |
+ TLL_SYSCONFIG_AUTOIDLE |
+ TLL_SYSCONFIG_SIDLE_SMART_IDLE |
+ TLL_SYSCONFIG_CACTIVITY);
+
+ return(0);
+
+err_sys_status:
+ /* Disable the TLL clocks */
+ ti_prcm_clk_disable(USBTLL_CLK);
+
+ return(ret);
+}
+
+static void
+omap_tll_disable(struct omap_tll_softc *sc)
+{
+ unsigned long timeout;
+
+ timeout = (hz < 10) ? 1 : ((100 * hz) / 1000);
+
+ /* Reset the TLL module */
+ omap_tll_write_4(sc, OMAP_USBTLL_SYSCONFIG, 0x0002);
+ while ((omap_tll_read_4(sc, OMAP_USBTLL_SYSSTATUS) & (0x01)) == 0x00) {
+ /* Sleep for a tick */
+ pause("USBRESET", 1);
+
+ if (timeout-- == 0) {
+ device_printf(sc->sc_dev, "operation timed out\n");
+ break;
+ }
+ }
+
+ /* Disable functional and interface clocks for the TLL and HOST modules */
+ ti_prcm_clk_disable(USBTLL_CLK);
+}
+
+static int
+omap_tll_probe(device_t dev)
+{
+
+ if (!ofw_bus_status_okay(dev))
+ return (ENXIO);
+
+ if (!ofw_bus_is_compatible(dev, "ti,usbhs-tll"))
+ return (ENXIO);
+
+ device_set_desc(dev, "TI OMAP USB 2.0 TLL module");
+
+ return (BUS_PROBE_DEFAULT);
+}
+
+static int
+omap_tll_attach(device_t dev)
+{
+ struct omap_tll_softc *sc;
+
+ sc = device_get_softc(dev);
+ /* save the device */
+ sc->sc_dev = dev;
+
+ /* Allocate resource for the TLL register set */
+ sc->tll_mem_rid = 0;
+ sc->tll_mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
+ &sc->tll_mem_rid, RF_ACTIVE);
+ if (!sc->tll_mem_res) {
+ device_printf(dev, "Error: Could not map TLL memory\n");
+ goto error;
+ }
+
+ omap_tll_init(sc);
+
+ omap_tll_sc = sc;
+
+ return (0);
+
+error:
+ omap_tll_detach(dev);
+ return (ENXIO);
+}
+
+static int
+omap_tll_detach(device_t dev)
+{
+ struct omap_tll_softc *sc;
+
+ sc = device_get_softc(dev);
+ omap_tll_disable(sc);
+
+ /* Release the other register set memory maps */
+ if (sc->tll_mem_res) {
+ bus_release_resource(dev, SYS_RES_MEMORY,
+ sc->tll_mem_rid, sc->tll_mem_res);
+ sc->tll_mem_res = NULL;
+ }
+
+ omap_tll_sc = NULL;
+
+ return (0);
+}
+
+static device_method_t omap_tll_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, omap_tll_probe),
+ DEVMETHOD(device_attach, omap_tll_attach),
+ DEVMETHOD(device_detach, omap_tll_detach),
+ DEVMETHOD(device_suspend, bus_generic_suspend),
+ DEVMETHOD(device_resume, bus_generic_resume),
+ DEVMETHOD(device_shutdown, bus_generic_shutdown),
+
+ {0, 0}
+};
+
+static driver_t omap_tll_driver = {
+ "omap_tll",
+ omap_tll_methods,
+ sizeof(struct omap_tll_softc),
+};
+
+static devclass_t omap_tll_devclass;
+
+DRIVER_MODULE(omap_tll, simplebus, omap_tll_driver, omap_tll_devclass, 0, 0);
diff --git a/sys/arm/ti/usb/omap_usb.h b/sys/arm/ti/usb/omap_usb.h
index bea7957..d6950d6 100644
--- a/sys/arm/ti/usb/omap_usb.h
+++ b/sys/arm/ti/usb/omap_usb.h
@@ -35,230 +35,14 @@
#ifndef _OMAP_USB_H_
#define _OMAP_USB_H_
-/*
- * USB TTL Module
- */
-#define OMAP_USBTLL_REVISION 0x0000
-#define OMAP_USBTLL_SYSCONFIG 0x0010
-#define OMAP_USBTLL_SYSSTATUS 0x0014
-#define OMAP_USBTLL_IRQSTATUS 0x0018
-#define OMAP_USBTLL_IRQENABLE 0x001C
-#define OMAP_USBTLL_TLL_SHARED_CONF 0x0030
-#define OMAP_USBTLL_TLL_CHANNEL_CONF(i) (0x0040 + (0x04 * (i)))
-#define OMAP_USBTLL_SAR_CNTX(i) (0x0400 + (0x04 * (i)))
-#define OMAP_USBTLL_ULPI_VENDOR_ID_LO(i) (0x0800 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_VENDOR_ID_HI(i) (0x0801 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_PRODUCT_ID_LO(i) (0x0802 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_PRODUCT_ID_HI(i) (0x0803 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_FUNCTION_CTRL(i) (0x0804 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_FUNCTION_CTRL_SET(i) (0x0805 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_FUNCTION_CTRL_CLR(i) (0x0806 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_INTERFACE_CTRL(i) (0x0807 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_INTERFACE_CTRL_SET(i) (0x0808 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_INTERFACE_CTRL_CLR(i) (0x0809 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_OTG_CTRL(i) (0x080A + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_OTG_CTRL_SET(i) (0x080B + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_OTG_CTRL_CLR(i) (0x080C + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_USB_INT_EN_RISE(i) (0x080D + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_USB_INT_EN_RISE_SET(i) (0x080E + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_USB_INT_EN_RISE_CLR(i) (0x080F + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_USB_INT_EN_FALL(i) (0x0810 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_USB_INT_EN_FALL_SET(i) (0x0811 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_USB_INT_EN_FALL_CLR(i) (0x0812 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_USB_INT_STATUS(i) (0x0813 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_USB_INT_LATCH(i) (0x0814 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_DEBUG(i) (0x0815 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_SCRATCH_REGISTER(i) (0x0816 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_SCRATCH_REGISTER_SET(i) (0x0817 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_SCRATCH_REGISTER_CLR(i) (0x0818 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_EXTENDED_SET_ACCESS(i) (0x082F + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_UTMI_VCONTROL_EN(i) (0x0830 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_UTMI_VCONTROL_EN_SET(i) (0x0831 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_UTMI_VCONTROL_EN_CLR(i) (0x0832 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_UTMI_VCONTROL_STATUS(i) (0x0833 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_UTMI_VCONTROL_LATCH(i) (0x0834 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_UTMI_VSTATUS(i) (0x0835 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_UTMI_VSTATUS_SET(i) (0x0836 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_UTMI_VSTATUS_CLR(i) (0x0837 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_USB_INT_LATCH_NOCLR(i) (0x0838 + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_VENDOR_INT_EN(i) (0x083B + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_VENDOR_INT_EN_SET(i) (0x083C + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_VENDOR_INT_EN_CLR(i) (0x083D + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_VENDOR_INT_STATUS(i) (0x083E + (0x100 * (i)))
-#define OMAP_USBTLL_ULPI_VENDOR_INT_LATCH(i) (0x083F + (0x100 * (i)))
-
-
-/*
- * USB Host Module
- */
-
-/* UHH */
-#define OMAP_USBHOST_UHH_REVISION 0x0000
-#define OMAP_USBHOST_UHH_SYSCONFIG 0x0010
-#define OMAP_USBHOST_UHH_SYSSTATUS 0x0014
-#define OMAP_USBHOST_UHH_HOSTCONFIG 0x0040
-#define OMAP_USBHOST_UHH_DEBUG_CSR 0x0044
-
-/* EHCI */
-#define OMAP_USBHOST_HCCAPBASE 0x0000
-#define OMAP_USBHOST_HCSPARAMS 0x0004
-#define OMAP_USBHOST_HCCPARAMS 0x0008
-#define OMAP_USBHOST_USBCMD 0x0010
-#define OMAP_USBHOST_USBSTS 0x0014
-#define OMAP_USBHOST_USBINTR 0x0018
-#define OMAP_USBHOST_FRINDEX 0x001C
-#define OMAP_USBHOST_CTRLDSSEGMENT 0x0020
-#define OMAP_USBHOST_PERIODICLISTBASE 0x0024
-#define OMAP_USBHOST_ASYNCLISTADDR 0x0028
-#define OMAP_USBHOST_CONFIGFLAG 0x0050
-#define OMAP_USBHOST_PORTSC(i) (0x0054 + (0x04 * (i)))
-#define OMAP_USBHOST_INSNREG00 0x0090
-#define OMAP_USBHOST_INSNREG01 0x0094
-#define OMAP_USBHOST_INSNREG02 0x0098
-#define OMAP_USBHOST_INSNREG03 0x009C
-#define OMAP_USBHOST_INSNREG04 0x00A0
-#define OMAP_USBHOST_INSNREG05_UTMI 0x00A4
-#define OMAP_USBHOST_INSNREG05_ULPI 0x00A4
-#define OMAP_USBHOST_INSNREG06 0x00A8
-#define OMAP_USBHOST_INSNREG07 0x00AC
-#define OMAP_USBHOST_INSNREG08 0x00B0
-
-#define OMAP_USBHOST_INSNREG04_DISABLE_UNSUSPEND (1 << 5)
-
-#define OMAP_USBHOST_INSNREG05_ULPI_CONTROL_SHIFT 31
-#define OMAP_USBHOST_INSNREG05_ULPI_PORTSEL_SHIFT 24
-#define OMAP_USBHOST_INSNREG05_ULPI_OPSEL_SHIFT 22
-#define OMAP_USBHOST_INSNREG05_ULPI_REGADD_SHIFT 16
-#define OMAP_USBHOST_INSNREG05_ULPI_EXTREGADD_SHIFT 8
-#define OMAP_USBHOST_INSNREG05_ULPI_WRDATA_SHIFT 0
-
-
-
-
-
-/* TLL Register Set */
-#define TLL_SYSCONFIG_CACTIVITY (1UL << 8)
-#define TLL_SYSCONFIG_SIDLE_SMART_IDLE (2UL << 3)
-#define TLL_SYSCONFIG_SIDLE_NO_IDLE (1UL << 3)
-#define TLL_SYSCONFIG_SIDLE_FORCED_IDLE (0UL << 3)
-#define TLL_SYSCONFIG_ENAWAKEUP (1UL << 2)
-#define TLL_SYSCONFIG_SOFTRESET (1UL << 1)
-#define TLL_SYSCONFIG_AUTOIDLE (1UL << 0)
-
-#define TLL_SYSSTATUS_RESETDONE (1UL << 0)
-
-#define TLL_SHARED_CONF_USB_90D_DDR_EN (1UL << 6)
-#define TLL_SHARED_CONF_USB_180D_SDR_EN (1UL << 5)
-#define TLL_SHARED_CONF_USB_DIVRATIO_MASK (7UL << 2)
-#define TLL_SHARED_CONF_USB_DIVRATIO_128 (7UL << 2)
-#define TLL_SHARED_CONF_USB_DIVRATIO_64 (6UL << 2)
-#define TLL_SHARED_CONF_USB_DIVRATIO_32 (5UL << 2)
-#define TLL_SHARED_CONF_USB_DIVRATIO_16 (4UL << 2)
-#define TLL_SHARED_CONF_USB_DIVRATIO_8 (3UL << 2)
-#define TLL_SHARED_CONF_USB_DIVRATIO_4 (2UL << 2)
-#define TLL_SHARED_CONF_USB_DIVRATIO_2 (1UL << 2)
-#define TLL_SHARED_CONF_USB_DIVRATIO_1 (0UL << 2)
-#define TLL_SHARED_CONF_FCLK_REQ (1UL << 1)
-#define TLL_SHARED_CONF_FCLK_IS_ON (1UL << 0)
-
-#define TLL_CHANNEL_CONF_DRVVBUS (1UL << 16)
-#define TLL_CHANNEL_CONF_CHRGVBUS (1UL << 15)
-#define TLL_CHANNEL_CONF_ULPINOBITSTUFF (1UL << 11)
-#define TLL_CHANNEL_CONF_ULPIAUTOIDLE (1UL << 10)
-#define TLL_CHANNEL_CONF_UTMIAUTOIDLE (1UL << 9)
-#define TLL_CHANNEL_CONF_ULPIDDRMODE (1UL << 8)
-#define TLL_CHANNEL_CONF_ULPIOUTCLKMODE (1UL << 7)
-#define TLL_CHANNEL_CONF_TLLFULLSPEED (1UL << 6)
-#define TLL_CHANNEL_CONF_TLLCONNECT (1UL << 5)
-#define TLL_CHANNEL_CONF_TLLATTACH (1UL << 4)
-#define TLL_CHANNEL_CONF_UTMIISADEV (1UL << 3)
-#define TLL_CHANNEL_CONF_CHANEN (1UL << 0)
-
-
-/* UHH Register Set */
-#define UHH_SYSCONFIG_MIDLEMODE_MASK (3UL << 12)
-#define UHH_SYSCONFIG_MIDLEMODE_SMARTSTANDBY (2UL << 12)
-#define UHH_SYSCONFIG_MIDLEMODE_NOSTANDBY (1UL << 12)
-#define UHH_SYSCONFIG_MIDLEMODE_FORCESTANDBY (0UL << 12)
-#define UHH_SYSCONFIG_CLOCKACTIVITY (1UL << 8)
-#define UHH_SYSCONFIG_SIDLEMODE_MASK (3UL << 3)
-#define UHH_SYSCONFIG_SIDLEMODE_SMARTIDLE (2UL << 3)
-#define UHH_SYSCONFIG_SIDLEMODE_NOIDLE (1UL << 3)
-#define UHH_SYSCONFIG_SIDLEMODE_FORCEIDLE (0UL << 3)
-#define UHH_SYSCONFIG_ENAWAKEUP (1UL << 2)
-#define UHH_SYSCONFIG_SOFTRESET (1UL << 1)
-#define UHH_SYSCONFIG_AUTOIDLE (1UL << 0)
-
-#define UHH_HOSTCONFIG_APP_START_CLK (1UL << 31)
-#define UHH_HOSTCONFIG_P3_CONNECT_STATUS (1UL << 10)
-#define UHH_HOSTCONFIG_P2_CONNECT_STATUS (1UL << 9)
-#define UHH_HOSTCONFIG_P1_CONNECT_STATUS (1UL << 8)
-#define UHH_HOSTCONFIG_ENA_INCR_ALIGN (1UL << 5)
-#define UHH_HOSTCONFIG_ENA_INCR16 (1UL << 4)
-#define UHH_HOSTCONFIG_ENA_INCR8 (1UL << 3)
-#define UHH_HOSTCONFIG_ENA_INCR4 (1UL << 2)
-#define UHH_HOSTCONFIG_AUTOPPD_ON_OVERCUR_EN (1UL << 1)
-#define UHH_HOSTCONFIG_P1_ULPI_BYPASS (1UL << 0)
-
-/* The following are on rev2 (OMAP44xx) of the EHCI only */
-#define UHH_SYSCONFIG_IDLEMODE_MASK (3UL << 2)
-#define UHH_SYSCONFIG_IDLEMODE_NOIDLE (1UL << 2)
-#define UHH_SYSCONFIG_STANDBYMODE_MASK (3UL << 4)
-#define UHH_SYSCONFIG_STANDBYMODE_NOSTDBY (1UL << 4)
-
-#define UHH_HOSTCONFIG_P1_MODE_MASK (3UL << 16)
-#define UHH_HOSTCONFIG_P1_MODE_ULPI_PHY (0UL << 16)
-#define UHH_HOSTCONFIG_P1_MODE_UTMI_PHY (1UL << 16)
-#define UHH_HOSTCONFIG_P1_MODE_HSIC (3UL << 16)
-#define UHH_HOSTCONFIG_P2_MODE_MASK (3UL << 18)
-#define UHH_HOSTCONFIG_P2_MODE_ULPI_PHY (0UL << 18)
-#define UHH_HOSTCONFIG_P2_MODE_UTMI_PHY (1UL << 18)
-#define UHH_HOSTCONFIG_P2_MODE_HSIC (3UL << 18)
-
-#define ULPI_FUNC_CTRL_RESET (1 << 5)
-
-/*-------------------------------------------------------------------------*/
-
-/*
- * Macros for Set and Clear
- * See ULPI 1.1 specification to find the registers with Set and Clear offsets
- */
-#define ULPI_SET(a) (a + 1)
-#define ULPI_CLR(a) (a + 2)
-
-/*-------------------------------------------------------------------------*/
-
-/*
- * Register Map
- */
-#define ULPI_VENDOR_ID_LOW 0x00
-#define ULPI_VENDOR_ID_HIGH 0x01
-#define ULPI_PRODUCT_ID_LOW 0x02
-#define ULPI_PRODUCT_ID_HIGH 0x03
-#define ULPI_FUNC_CTRL 0x04
-#define ULPI_IFC_CTRL 0x07
-#define ULPI_OTG_CTRL 0x0a
-#define ULPI_USB_INT_EN_RISE 0x0d
-#define ULPI_USB_INT_EN_FALL 0x10
-#define ULPI_USB_INT_STS 0x13
-#define ULPI_USB_INT_LATCH 0x14
-#define ULPI_DEBUG 0x15
-#define ULPI_SCRATCH 0x16
-
-/*
- * Values of UHH_REVISION - Note: these are not given in the TRM but taken
- * from the linux OMAP EHCI driver (thanks guys). It has been verified on
- * a Panda and Beagle board.
- */
-#define OMAP_EHCI_REV1 0x00000010 /* OMAP3 */
-#define OMAP_EHCI_REV2 0x50700100 /* OMAP4 */
-
-#define EHCI_VENDORID_OMAP3 0x42fa05
-#define OMAP_EHCI_HC_DEVSTR "TI OMAP USB 2.0 controller"
+#define OMAP_HS_USB_PORTS 3
#define EHCI_HCD_OMAP_MODE_UNKNOWN 0
#define EHCI_HCD_OMAP_MODE_PHY 1
#define EHCI_HCD_OMAP_MODE_TLL 2
#define EHCI_HCD_OMAP_MODE_HSIC 3
+void omap_tll_utmi_enable(unsigned int en_mask);
+int omap_usb_port_mode(device_t dev, int port);
+
#endif /* _OMAP_USB_H_ */
diff --git a/sys/arm/xilinx/files.zynq7 b/sys/arm/xilinx/files.zynq7
index be3e599..90fa7ef 100644
--- a/sys/arm/xilinx/files.zynq7
+++ b/sys/arm/xilinx/files.zynq7
@@ -9,7 +9,6 @@ arm/arm/bus_space_base.c standard
arm/arm/bus_space_generic.c standard
arm/arm/bus_space_asm_generic.S standard
-arm/arm/gic.c standard
arm/arm/mpcore_timer.c standard
arm/arm/pl310.c standard
diff --git a/sys/arm64/arm64/bus_machdep.c b/sys/arm64/arm64/bus_machdep.c
index d8e6646..25a675e 100644
--- a/sys/arm64/arm64/bus_machdep.c
+++ b/sys/arm64/arm64/bus_machdep.c
@@ -169,10 +169,10 @@ struct bus_space memmap_bus = {
.bs_r_8_s = NULL,
/* read multiple stream */
- .bs_rm_1_s = NULL,
- .bs_rm_2_s = NULL,
- .bs_rm_4_s = NULL,
- .bs_rm_8_s = NULL,
+ .bs_rm_1_s = generic_bs_rm_1,
+ .bs_rm_2_s = generic_bs_rm_2,
+ .bs_rm_4_s = generic_bs_rm_4,
+ .bs_rm_8_s = generic_bs_rm_8,
/* read region stream */
.bs_rr_1_s = NULL,
@@ -187,10 +187,10 @@ struct bus_space memmap_bus = {
.bs_w_8_s = NULL,
/* write multiple stream */
- .bs_wm_1_s = NULL,
- .bs_wm_2_s = NULL,
- .bs_wm_4_s = NULL,
- .bs_wm_8_s = NULL,
+ .bs_wm_1_s = generic_bs_wm_1,
+ .bs_wm_2_s = generic_bs_wm_2,
+ .bs_wm_4_s = generic_bs_wm_4,
+ .bs_wm_8_s = generic_bs_wm_8,
/* write region stream */
.bs_wr_1_s = NULL,
diff --git a/sys/arm64/arm64/bus_space_asm.S b/sys/arm64/arm64/bus_space_asm.S
index 52ad5dd..20d4128 100644
--- a/sys/arm64/arm64/bus_space_asm.S
+++ b/sys/arm64/arm64/bus_space_asm.S
@@ -63,7 +63,7 @@ ENTRY(generic_bs_rm_1)
/* Read the data. */
1: ldrb w1, [x0]
- strb w1, [x3], #2
+ strb w1, [x3], #1
subs x4, x4, #1
b.ne 1b
@@ -105,7 +105,7 @@ ENTRY(generic_bs_rm_4)
/* Read the data. */
1: ldr w1, [x0]
- str w1, [x3], #2
+ str w1, [x3], #4
subs x4, x4, #1
b.ne 1b
@@ -126,7 +126,7 @@ ENTRY(generic_bs_rm_8)
/* Read the data. */
1: ldr x1, [x0]
- str x1, [x3], #2
+ str x1, [x3], #8
subs x4, x4, #1
b.ne 1b
diff --git a/sys/arm64/arm64/busdma_bounce.c b/sys/arm64/arm64/busdma_bounce.c
new file mode 100644
index 0000000..477c819
--- /dev/null
+++ b/sys/arm64/arm64/busdma_bounce.c
@@ -0,0 +1,1080 @@
+/*-
+ * Copyright (c) 1997, 1998 Justin T. Gibbs.
+ * Copyright (c) 2015 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * Portions of this software were developed by Semihalf
+ * under sponsorship of the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/bus.h>
+#include <sys/interrupt.h>
+#include <sys/kernel.h>
+#include <sys/ktr.h>
+#include <sys/lock.h>
+#include <sys/proc.h>
+#include <sys/memdesc.h>
+#include <sys/mutex.h>
+#include <sys/sysctl.h>
+#include <sys/uio.h>
+
+#include <vm/vm.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_kern.h>
+#include <vm/vm_page.h>
+#include <vm/vm_map.h>
+
+#include <machine/atomic.h>
+#include <machine/bus.h>
+#include <machine/md_var.h>
+#include <arm64/include/bus_dma_impl.h>
+
+#define MAX_BPAGES 4096
+
+enum {
+ BUS_DMA_COULD_BOUNCE = 0x01,
+ BUS_DMA_MIN_ALLOC_COMP = 0x02,
+ BUS_DMA_KMEM_ALLOC = 0x04,
+};
+
+struct bounce_zone;
+
+struct bus_dma_tag {
+ struct bus_dma_tag_common common;
+ int map_count;
+ int bounce_flags;
+ bus_dma_segment_t *segments;
+ struct bounce_zone *bounce_zone;
+};
+
+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_addr_t dataaddr; /* client physical address */
+ bus_size_t datacount; /* client data count */
+ STAILQ_ENTRY(bounce_page) links;
+};
+
+int busdma_swi_pending;
+
+struct bounce_zone {
+ STAILQ_ENTRY(bounce_zone) links;
+ STAILQ_HEAD(bp_list, bounce_page) bounce_page_list;
+ int total_bpages;
+ int free_bpages;
+ int reserved_bpages;
+ int active_bpages;
+ int total_bounced;
+ int total_deferred;
+ int map_count;
+ bus_size_t alignment;
+ bus_addr_t lowaddr;
+ char zoneid[8];
+ char lowaddrid[20];
+ struct sysctl_ctx_list sysctl_tree;
+ struct sysctl_oid *sysctl_tree_top;
+};
+
+static struct mtx bounce_lock;
+static int total_bpages;
+static int busdma_zonecount;
+static STAILQ_HEAD(, bounce_zone) bounce_zone_list;
+
+static SYSCTL_NODE(_hw, OID_AUTO, busdma, CTLFLAG_RD, 0, "Busdma parameters");
+SYSCTL_INT(_hw_busdma, OID_AUTO, total_bpages, CTLFLAG_RD, &total_bpages, 0,
+ "Total bounce pages");
+
+struct bus_dmamap {
+ struct bp_list bpages;
+ int pagesneeded;
+ int pagesreserved;
+ bus_dma_tag_t dmat;
+ struct memdesc mem;
+ 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 void init_bounce_pages(void *dummy);
+static int alloc_bounce_zone(bus_dma_tag_t dmat);
+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,
+ int commit);
+static bus_addr_t add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map,
+ vm_offset_t vaddr, bus_addr_t addr, bus_size_t size);
+static void free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage);
+int run_filter(bus_dma_tag_t dmat, bus_addr_t paddr);
+static void _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map,
+ pmap_t pmap, void *buf, bus_size_t buflen, int flags);
+static void _bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_t map,
+ vm_paddr_t buf, bus_size_t buflen, int flags);
+static int _bus_dmamap_reserve_pages(bus_dma_tag_t dmat, bus_dmamap_t map,
+ int flags);
+
+/*
+ * Allocate a device specific dma_tag.
+ */
+static int
+bounce_bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
+ bus_addr_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_lock_t *lockfunc,
+ void *lockfuncarg, bus_dma_tag_t *dmat)
+{
+ bus_dma_tag_t newtag;
+ int error;
+
+ *dmat = NULL;
+ error = common_bus_dma_tag_create(parent != NULL ? &parent->common :
+ NULL, alignment, boundary, lowaddr, highaddr, filter, filterarg,
+ maxsize, nsegments, maxsegsz, flags, lockfunc, lockfuncarg,
+ sizeof (struct bus_dma_tag), (void **)&newtag);
+ if (error != 0)
+ return (error);
+
+ newtag->common.impl = &bus_dma_bounce_impl;
+ newtag->map_count = 0;
+ newtag->segments = NULL;
+
+ if (parent != NULL && ((newtag->common.filter != NULL) ||
+ ((parent->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0)))
+ newtag->bounce_flags |= BUS_DMA_COULD_BOUNCE;
+
+ if (newtag->common.lowaddr < ptoa((vm_paddr_t)Maxmem) ||
+ newtag->common.alignment > 1)
+ newtag->bounce_flags |= BUS_DMA_COULD_BOUNCE;
+
+ if (((newtag->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) &&
+ (flags & BUS_DMA_ALLOCNOW) != 0) {
+ struct bounce_zone *bz;
+
+ /* Must bounce */
+ if ((error = alloc_bounce_zone(newtag)) != 0) {
+ free(newtag, M_DEVBUF);
+ return (error);
+ }
+ bz = newtag->bounce_zone;
+
+ if (ptoa(bz->total_bpages) < maxsize) {
+ int pages;
+
+ pages = atop(maxsize) - bz->total_bpages;
+
+ /* Add pages to our bounce pool */
+ if (alloc_bounce_pages(newtag, pages) < pages)
+ error = ENOMEM;
+ }
+ /* Performed initial allocation */
+ newtag->bounce_flags |= BUS_DMA_MIN_ALLOC_COMP;
+ } else
+ error = 0;
+
+ if (error != 0)
+ free(newtag, M_DEVBUF);
+ else
+ *dmat = newtag;
+ CTR4(KTR_BUSDMA, "%s returned tag %p tag flags 0x%x error %d",
+ __func__, newtag, (newtag != NULL ? newtag->common.flags : 0),
+ error);
+ return (error);
+}
+
+static int
+bounce_bus_dma_tag_destroy(bus_dma_tag_t dmat)
+{
+ bus_dma_tag_t dmat_copy, parent;
+ int error;
+
+ error = 0;
+ dmat_copy = dmat;
+
+ if (dmat != NULL) {
+ if (dmat->map_count != 0) {
+ error = EBUSY;
+ goto out;
+ }
+ while (dmat != NULL) {
+ parent = (bus_dma_tag_t)dmat->common.parent;
+ atomic_subtract_int(&dmat->common.ref_count, 1);
+ if (dmat->common.ref_count == 0) {
+ if (dmat->segments != NULL)
+ free(dmat->segments, M_DEVBUF);
+ free(dmat, M_DEVBUF);
+ /*
+ * Last reference count, so
+ * release our reference
+ * count on our parent.
+ */
+ dmat = parent;
+ } else
+ dmat = NULL;
+ }
+ }
+out:
+ CTR3(KTR_BUSDMA, "%s tag %p error %d", __func__, dmat_copy, error);
+ return (error);
+}
+
+/*
+ * Allocate a handle for mapping from kva/uva/physical
+ * address space into bus device space.
+ */
+static int
+bounce_bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
+{
+ struct bounce_zone *bz;
+ int error, maxpages, pages;
+
+ error = 0;
+
+ if (dmat->segments == NULL) {
+ dmat->segments = (bus_dma_segment_t *)malloc(
+ sizeof(bus_dma_segment_t) * dmat->common.nsegments,
+ M_DEVBUF, M_NOWAIT);
+ if (dmat->segments == NULL) {
+ CTR3(KTR_BUSDMA, "%s: tag %p error %d",
+ __func__, dmat, ENOMEM);
+ return (ENOMEM);
+ }
+ }
+
+ /*
+ * Bouncing might be required if the driver asks for an active
+ * exclusion region, a data alignment that is stricter than 1, and/or
+ * an active address boundary.
+ */
+ if (dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) {
+ /* Must bounce */
+ if (dmat->bounce_zone == NULL) {
+ if ((error = alloc_bounce_zone(dmat)) != 0)
+ return (error);
+ }
+ bz = dmat->bounce_zone;
+
+ *mapp = (bus_dmamap_t)malloc(sizeof(**mapp), M_DEVBUF,
+ M_NOWAIT | M_ZERO);
+ if (*mapp == NULL) {
+ CTR3(KTR_BUSDMA, "%s: tag %p error %d",
+ __func__, dmat, ENOMEM);
+ return (ENOMEM);
+ }
+
+ /* Initialize the new map */
+ STAILQ_INIT(&((*mapp)->bpages));
+
+ /*
+ * Attempt to add pages to our pool on a per-instance
+ * basis up to a sane limit.
+ */
+ if (dmat->common.alignment > 1)
+ maxpages = MAX_BPAGES;
+ else
+ maxpages = MIN(MAX_BPAGES, Maxmem -
+ atop(dmat->common.lowaddr));
+ if ((dmat->bounce_flags & BUS_DMA_MIN_ALLOC_COMP) == 0 ||
+ (bz->map_count > 0 && bz->total_bpages < maxpages)) {
+ pages = MAX(atop(dmat->common.maxsize), 1);
+ pages = MIN(maxpages - bz->total_bpages, pages);
+ pages = MAX(pages, 1);
+ if (alloc_bounce_pages(dmat, pages) < pages)
+ error = ENOMEM;
+ if ((dmat->bounce_flags & BUS_DMA_MIN_ALLOC_COMP)
+ == 0) {
+ if (error == 0) {
+ dmat->bounce_flags |=
+ BUS_DMA_MIN_ALLOC_COMP;
+ }
+ } else
+ error = 0;
+ }
+ bz->map_count++;
+ } else {
+ *mapp = NULL;
+ }
+ if (error == 0)
+ dmat->map_count++;
+ CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d",
+ __func__, dmat, dmat->common.flags, error);
+ return (error);
+}
+
+/*
+ * Destroy a handle for mapping from kva/uva/physical
+ * address space into bus device space.
+ */
+static int
+bounce_bus_dmamap_destroy(bus_dma_tag_t dmat, bus_dmamap_t map)
+{
+
+ if (map != NULL && map != &nobounce_dmamap) {
+ if (STAILQ_FIRST(&map->bpages) != NULL) {
+ CTR3(KTR_BUSDMA, "%s: tag %p error %d",
+ __func__, dmat, EBUSY);
+ return (EBUSY);
+ }
+ if (dmat->bounce_zone)
+ dmat->bounce_zone->map_count--;
+ free(map, M_DEVBUF);
+ }
+ dmat->map_count--;
+ CTR2(KTR_BUSDMA, "%s: tag %p error 0", __func__, dmat);
+ 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.
+ */
+static int
+bounce_bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
+ bus_dmamap_t *mapp)
+{
+ /*
+ * XXX ARM64TODO:
+ * This bus_dma implementation requires IO-Coherent architecutre.
+ * If IO-Coherency is not guaranteed, the BUS_DMA_COHERENT flag has
+ * to be implented using non-cacheable memory.
+ */
+
+ vm_memattr_t attr;
+ int mflags;
+
+ if (flags & BUS_DMA_NOWAIT)
+ mflags = M_NOWAIT;
+ else
+ mflags = M_WAITOK;
+
+ /* If we succeed, no mapping/bouncing will be required */
+ *mapp = NULL;
+
+ if (dmat->segments == NULL) {
+ dmat->segments = (bus_dma_segment_t *)malloc(
+ sizeof(bus_dma_segment_t) * dmat->common.nsegments,
+ M_DEVBUF, mflags);
+ if (dmat->segments == NULL) {
+ CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d",
+ __func__, dmat, dmat->common.flags, ENOMEM);
+ return (ENOMEM);
+ }
+ }
+ if (flags & BUS_DMA_ZERO)
+ mflags |= M_ZERO;
+ if (flags & BUS_DMA_NOCACHE)
+ attr = VM_MEMATTR_UNCACHEABLE;
+ else
+ attr = VM_MEMATTR_DEFAULT;
+
+ /*
+ * XXX:
+ * (dmat->alignment < dmat->maxsize) is just a quick hack; the exact
+ * alignment guarantees of malloc need to be nailed down, and the
+ * code below should be rewritten to take that into account.
+ *
+ * In the meantime, we'll warn the user if malloc gets it wrong.
+ */
+ if ((dmat->common.maxsize <= PAGE_SIZE) &&
+ (dmat->common.alignment < dmat->common.maxsize) &&
+ dmat->common.lowaddr >= ptoa((vm_paddr_t)Maxmem) &&
+ attr == VM_MEMATTR_DEFAULT) {
+ *vaddr = malloc(dmat->common.maxsize, M_DEVBUF, mflags);
+ } else if (dmat->common.nsegments >= btoc(dmat->common.maxsize) &&
+ dmat->common.alignment <= PAGE_SIZE &&
+ (dmat->common.boundary == 0 ||
+ dmat->common.boundary >= dmat->common.lowaddr)) {
+ /* Page-based multi-segment allocations allowed */
+ *vaddr = (void *)kmem_alloc_attr(kernel_arena,
+ dmat->common.maxsize, mflags, 0ul, dmat->common.lowaddr,
+ attr);
+ dmat->bounce_flags |= BUS_DMA_KMEM_ALLOC;
+ } else {
+ *vaddr = (void *)kmem_alloc_contig(kernel_arena,
+ dmat->common.maxsize, mflags, 0ul, dmat->common.lowaddr,
+ dmat->common.alignment != 0 ? dmat->common.alignment : 1ul,
+ dmat->common.boundary, attr);
+ dmat->bounce_flags |= BUS_DMA_KMEM_ALLOC;
+ }
+ if (*vaddr == NULL) {
+ CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d",
+ __func__, dmat, dmat->common.flags, ENOMEM);
+ return (ENOMEM);
+ } else if (vtophys(*vaddr) & (dmat->common.alignment - 1)) {
+ printf("bus_dmamem_alloc failed to align memory properly.\n");
+ }
+ CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x error %d",
+ __func__, dmat, dmat->common.flags, 0);
+ return (0);
+}
+
+/*
+ * Free a piece of memory and it's allociated dmamap, that was allocated
+ * via bus_dmamem_alloc. Make the same choice for free/contigfree.
+ */
+static void
+bounce_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 and the BUS_DMA_KMEM_ALLOC flag cleared if malloc()
+ * was used and set if kmem_alloc_contig() was used.
+ */
+ if (map != NULL)
+ panic("bus_dmamem_free: Invalid map freed\n");
+ if ((dmat->bounce_flags & BUS_DMA_KMEM_ALLOC) == 0)
+ free(vaddr, M_DEVBUF);
+ else
+ kmem_free(kernel_arena, (vm_offset_t)vaddr,
+ dmat->common.maxsize);
+ CTR3(KTR_BUSDMA, "%s: tag %p flags 0x%x", __func__, dmat,
+ dmat->bounce_flags);
+}
+
+static void
+_bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf,
+ bus_size_t buflen, int flags)
+{
+ bus_addr_t curaddr;
+ bus_size_t sgsize;
+
+ if ((map != &nobounce_dmamap && map->pagesneeded == 0)) {
+ /*
+ * Count the number of bounce pages
+ * needed in order to complete this transfer
+ */
+ curaddr = buf;
+ while (buflen != 0) {
+ sgsize = MIN(buflen, dmat->common.maxsegsz);
+ if (bus_dma_run_filter(&dmat->common, curaddr)) {
+ sgsize = MIN(sgsize, PAGE_SIZE);
+ map->pagesneeded++;
+ }
+ curaddr += sgsize;
+ buflen -= sgsize;
+ }
+ CTR1(KTR_BUSDMA, "pagesneeded= %d\n", map->pagesneeded);
+ }
+}
+
+static void
+_bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, pmap_t pmap,
+ void *buf, bus_size_t buflen, int flags)
+{
+ vm_offset_t vaddr;
+ vm_offset_t vendaddr;
+ bus_addr_t paddr;
+ bus_size_t sg_len;
+
+ if ((map != &nobounce_dmamap && map->pagesneeded == 0)) {
+ CTR4(KTR_BUSDMA, "lowaddr= %d Maxmem= %d, boundary= %d, "
+ "alignment= %d", dmat->common.lowaddr,
+ ptoa((vm_paddr_t)Maxmem),
+ dmat->common.boundary, dmat->common.alignment);
+ CTR3(KTR_BUSDMA, "map= %p, nobouncemap= %p, pagesneeded= %d",
+ map, &nobounce_dmamap, map->pagesneeded);
+ /*
+ * Count the number of bounce pages
+ * needed in order to complete this transfer
+ */
+ vaddr = (vm_offset_t)buf;
+ vendaddr = (vm_offset_t)buf + buflen;
+
+ while (vaddr < vendaddr) {
+ sg_len = PAGE_SIZE - ((vm_offset_t)vaddr & PAGE_MASK);
+ if (pmap == kernel_pmap)
+ paddr = pmap_kextract(vaddr);
+ else
+ paddr = pmap_extract(pmap, vaddr);
+ if (bus_dma_run_filter(&dmat->common, paddr) != 0) {
+ sg_len = roundup2(sg_len,
+ dmat->common.alignment);
+ map->pagesneeded++;
+ }
+ vaddr += sg_len;
+ }
+ CTR1(KTR_BUSDMA, "pagesneeded= %d\n", map->pagesneeded);
+ }
+}
+
+static int
+_bus_dmamap_reserve_pages(bus_dma_tag_t dmat, bus_dmamap_t map, int flags)
+{
+
+ /* Reserve Necessary Bounce Pages */
+ mtx_lock(&bounce_lock);
+ if (flags & BUS_DMA_NOWAIT) {
+ if (reserve_bounce_pages(dmat, map, 0) != 0) {
+ mtx_unlock(&bounce_lock);
+ return (ENOMEM);
+ }
+ } else {
+ if (reserve_bounce_pages(dmat, map, 1) != 0) {
+ /* Queue us for resources */
+ STAILQ_INSERT_TAIL(&bounce_map_waitinglist, map, links);
+ mtx_unlock(&bounce_lock);
+ return (EINPROGRESS);
+ }
+ }
+ mtx_unlock(&bounce_lock);
+
+ return (0);
+}
+
+/*
+ * Add a single contiguous physical range to the segment list.
+ */
+static int
+_bus_dmamap_addseg(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t curaddr,
+ bus_size_t sgsize, bus_dma_segment_t *segs, int *segp)
+{
+ bus_addr_t baddr, bmask;
+ int seg;
+
+ /*
+ * Make sure we don't cross any boundaries.
+ */
+ bmask = ~(dmat->common.boundary - 1);
+ if (dmat->common.boundary > 0) {
+ baddr = (curaddr + dmat->common.boundary) & bmask;
+ if (sgsize > (baddr - curaddr))
+ sgsize = (baddr - curaddr);
+ }
+
+ /*
+ * Insert chunk into a segment, coalescing with
+ * previous segment if possible.
+ */
+ seg = *segp;
+ if (seg == -1) {
+ seg = 0;
+ segs[seg].ds_addr = curaddr;
+ segs[seg].ds_len = sgsize;
+ } else {
+ if (curaddr == segs[seg].ds_addr + segs[seg].ds_len &&
+ (segs[seg].ds_len + sgsize) <= dmat->common.maxsegsz &&
+ (dmat->common.boundary == 0 ||
+ (segs[seg].ds_addr & bmask) == (curaddr & bmask)))
+ segs[seg].ds_len += sgsize;
+ else {
+ if (++seg >= dmat->common.nsegments)
+ return (0);
+ segs[seg].ds_addr = curaddr;
+ segs[seg].ds_len = sgsize;
+ }
+ }
+ *segp = seg;
+ return (sgsize);
+}
+
+/*
+ * Utility function to load a physical buffer. segp contains
+ * the starting segment on entrace, and the ending segment on exit.
+ */
+static int
+bounce_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map,
+ vm_paddr_t buf, bus_size_t buflen, int flags, bus_dma_segment_t *segs,
+ int *segp)
+{
+ bus_size_t sgsize;
+ bus_addr_t curaddr;
+ int error;
+
+ if (map == NULL)
+ map = &nobounce_dmamap;
+
+ if (segs == NULL)
+ segs = dmat->segments;
+
+ if ((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) {
+ _bus_dmamap_count_phys(dmat, map, buf, buflen, flags);
+ if (map->pagesneeded != 0) {
+ error = _bus_dmamap_reserve_pages(dmat, map, flags);
+ if (error)
+ return (error);
+ }
+ }
+
+ while (buflen > 0) {
+ curaddr = buf;
+ sgsize = MIN(buflen, dmat->common.maxsegsz);
+ if (((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) &&
+ map->pagesneeded != 0 &&
+ bus_dma_run_filter(&dmat->common, curaddr)) {
+ sgsize = MIN(sgsize, PAGE_SIZE);
+ curaddr = add_bounce_page(dmat, map, 0, curaddr,
+ sgsize);
+ }
+ sgsize = _bus_dmamap_addseg(dmat, map, curaddr, sgsize, segs,
+ segp);
+ if (sgsize == 0)
+ break;
+ buf += sgsize;
+ buflen -= sgsize;
+ }
+
+ /*
+ * Did we fit?
+ */
+ return (buflen != 0 ? EFBIG : 0); /* XXX better return value here? */
+}
+
+/*
+ * Utility function to load a linear buffer. segp contains
+ * the starting segment on entrace, and the ending segment on exit.
+ */
+static int
+bounce_bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
+ bus_size_t buflen, pmap_t pmap, int flags, bus_dma_segment_t *segs,
+ int *segp)
+{
+ bus_size_t sgsize, max_sgsize;
+ bus_addr_t curaddr;
+ vm_offset_t vaddr;
+ int error;
+
+ if (map == NULL)
+ map = &nobounce_dmamap;
+
+ if (segs == NULL)
+ segs = dmat->segments;
+
+ if ((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) {
+ _bus_dmamap_count_pages(dmat, map, pmap, buf, buflen, flags);
+ if (map->pagesneeded != 0) {
+ error = _bus_dmamap_reserve_pages(dmat, map, flags);
+ if (error)
+ return (error);
+ }
+ }
+
+ vaddr = (vm_offset_t)buf;
+ while (buflen > 0) {
+ /*
+ * Get the physical address for this segment.
+ */
+ if (pmap == kernel_pmap)
+ curaddr = pmap_kextract(vaddr);
+ else
+ curaddr = pmap_extract(pmap, vaddr);
+
+ /*
+ * Compute the segment size, and adjust counts.
+ */
+ max_sgsize = MIN(buflen, dmat->common.maxsegsz);
+ sgsize = PAGE_SIZE - ((vm_offset_t)curaddr & PAGE_MASK);
+ if (((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) &&
+ map->pagesneeded != 0 &&
+ bus_dma_run_filter(&dmat->common, curaddr)) {
+ sgsize = roundup2(sgsize, dmat->common.alignment);
+ sgsize = MIN(sgsize, max_sgsize);
+ curaddr = add_bounce_page(dmat, map, vaddr, curaddr,
+ sgsize);
+ } else {
+ sgsize = MIN(sgsize, max_sgsize);
+ }
+ sgsize = _bus_dmamap_addseg(dmat, map, curaddr, sgsize, segs,
+ segp);
+ if (sgsize == 0)
+ break;
+ vaddr += sgsize;
+ buflen -= sgsize;
+ }
+
+ /*
+ * Did we fit?
+ */
+ return (buflen != 0 ? EFBIG : 0); /* XXX better return value here? */
+}
+
+static void
+bounce_bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
+ struct memdesc *mem, bus_dmamap_callback_t *callback, void *callback_arg)
+{
+
+ if (map == NULL)
+ return;
+ map->mem = *mem;
+ map->dmat = dmat;
+ map->callback = callback;
+ map->callback_arg = callback_arg;
+}
+
+static bus_dma_segment_t *
+bounce_bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t map,
+ bus_dma_segment_t *segs, int nsegs, int error)
+{
+
+ if (segs == NULL)
+ segs = dmat->segments;
+ return (segs);
+}
+
+/*
+ * Release the mapping held by map.
+ */
+static void
+bounce_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);
+ }
+}
+
+static void
+bounce_bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map,
+ bus_dmasync_op_t op)
+{
+ struct bounce_page *bpage;
+
+ /*
+ * XXX ARM64TODO:
+ * This bus_dma implementation requires IO-Coherent architecutre.
+ * If IO-Coherency is not guaranteed, cache operations have to be
+ * added to this function.
+ */
+
+ if ((bpage = STAILQ_FIRST(&map->bpages)) != NULL) {
+ /*
+ * Handle data bouncing. We might also
+ * want to add support for invalidating
+ * the caches on broken hardware
+ */
+ CTR4(KTR_BUSDMA, "%s: tag %p tag flags 0x%x op 0x%x "
+ "performing bounce", __func__, dmat,
+ dmat->common.flags, op);
+
+ if ((op & BUS_DMASYNC_PREWRITE) != 0) {
+ while (bpage != NULL) {
+ if (bpage->datavaddr != 0) {
+ bcopy((void *)bpage->datavaddr,
+ (void *)bpage->vaddr,
+ bpage->datacount);
+ } else {
+ physcopyout(bpage->dataaddr,
+ (void *)bpage->vaddr,
+ bpage->datacount);
+ }
+ bpage = STAILQ_NEXT(bpage, links);
+ }
+ dmat->bounce_zone->total_bounced++;
+ }
+
+ if ((op & BUS_DMASYNC_POSTREAD) != 0) {
+ while (bpage != NULL) {
+ if (bpage->datavaddr != 0) {
+ bcopy((void *)bpage->vaddr,
+ (void *)bpage->datavaddr,
+ bpage->datacount);
+ } else {
+ physcopyin((void *)bpage->vaddr,
+ bpage->dataaddr,
+ bpage->datacount);
+ }
+ bpage = STAILQ_NEXT(bpage, links);
+ }
+ dmat->bounce_zone->total_bounced++;
+ }
+ }
+}
+
+static void
+init_bounce_pages(void *dummy __unused)
+{
+
+ total_bpages = 0;
+ STAILQ_INIT(&bounce_zone_list);
+ STAILQ_INIT(&bounce_map_waitinglist);
+ STAILQ_INIT(&bounce_map_callbacklist);
+ mtx_init(&bounce_lock, "bounce pages lock", NULL, MTX_DEF);
+}
+SYSINIT(bpages, SI_SUB_LOCK, SI_ORDER_ANY, init_bounce_pages, NULL);
+
+static struct sysctl_ctx_list *
+busdma_sysctl_tree(struct bounce_zone *bz)
+{
+ return (&bz->sysctl_tree);
+}
+
+static struct sysctl_oid *
+busdma_sysctl_tree_top(struct bounce_zone *bz)
+{
+ return (bz->sysctl_tree_top);
+}
+
+static int
+alloc_bounce_zone(bus_dma_tag_t dmat)
+{
+ struct bounce_zone *bz;
+
+ /* Check to see if we already have a suitable zone */
+ STAILQ_FOREACH(bz, &bounce_zone_list, links) {
+ if ((dmat->common.alignment <= bz->alignment) &&
+ (dmat->common.lowaddr >= bz->lowaddr)) {
+ dmat->bounce_zone = bz;
+ return (0);
+ }
+ }
+
+ if ((bz = (struct bounce_zone *)malloc(sizeof(*bz), M_DEVBUF,
+ M_NOWAIT | M_ZERO)) == NULL)
+ return (ENOMEM);
+
+ STAILQ_INIT(&bz->bounce_page_list);
+ bz->free_bpages = 0;
+ bz->reserved_bpages = 0;
+ bz->active_bpages = 0;
+ bz->lowaddr = dmat->common.lowaddr;
+ bz->alignment = MAX(dmat->common.alignment, PAGE_SIZE);
+ bz->map_count = 0;
+ snprintf(bz->zoneid, 8, "zone%d", busdma_zonecount);
+ busdma_zonecount++;
+ snprintf(bz->lowaddrid, 18, "%#jx", (uintmax_t)bz->lowaddr);
+ STAILQ_INSERT_TAIL(&bounce_zone_list, bz, links);
+ dmat->bounce_zone = bz;
+
+ sysctl_ctx_init(&bz->sysctl_tree);
+ bz->sysctl_tree_top = SYSCTL_ADD_NODE(&bz->sysctl_tree,
+ SYSCTL_STATIC_CHILDREN(_hw_busdma), OID_AUTO, bz->zoneid,
+ CTLFLAG_RD, 0, "");
+ if (bz->sysctl_tree_top == NULL) {
+ sysctl_ctx_free(&bz->sysctl_tree);
+ return (0); /* XXX error code? */
+ }
+
+ SYSCTL_ADD_INT(busdma_sysctl_tree(bz),
+ SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
+ "total_bpages", CTLFLAG_RD, &bz->total_bpages, 0,
+ "Total bounce pages");
+ SYSCTL_ADD_INT(busdma_sysctl_tree(bz),
+ SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
+ "free_bpages", CTLFLAG_RD, &bz->free_bpages, 0,
+ "Free bounce pages");
+ SYSCTL_ADD_INT(busdma_sysctl_tree(bz),
+ SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
+ "reserved_bpages", CTLFLAG_RD, &bz->reserved_bpages, 0,
+ "Reserved bounce pages");
+ SYSCTL_ADD_INT(busdma_sysctl_tree(bz),
+ SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
+ "active_bpages", CTLFLAG_RD, &bz->active_bpages, 0,
+ "Active bounce pages");
+ SYSCTL_ADD_INT(busdma_sysctl_tree(bz),
+ SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
+ "total_bounced", CTLFLAG_RD, &bz->total_bounced, 0,
+ "Total bounce requests");
+ SYSCTL_ADD_INT(busdma_sysctl_tree(bz),
+ SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
+ "total_deferred", CTLFLAG_RD, &bz->total_deferred, 0,
+ "Total bounce requests that were deferred");
+ SYSCTL_ADD_STRING(busdma_sysctl_tree(bz),
+ SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
+ "lowaddr", CTLFLAG_RD, bz->lowaddrid, 0, "");
+ SYSCTL_ADD_UAUTO(busdma_sysctl_tree(bz),
+ SYSCTL_CHILDREN(busdma_sysctl_tree_top(bz)), OID_AUTO,
+ "alignment", CTLFLAG_RD, &bz->alignment, "");
+
+ return (0);
+}
+
+static int
+alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages)
+{
+ struct bounce_zone *bz;
+ int count;
+
+ bz = dmat->bounce_zone;
+ count = 0;
+ while (numpages > 0) {
+ struct bounce_page *bpage;
+
+ bpage = (struct bounce_page *)malloc(sizeof(*bpage), M_DEVBUF,
+ M_NOWAIT | M_ZERO);
+
+ if (bpage == NULL)
+ break;
+ bpage->vaddr = (vm_offset_t)contigmalloc(PAGE_SIZE, M_DEVBUF,
+ M_NOWAIT, 0ul, bz->lowaddr, PAGE_SIZE, 0);
+ if (bpage->vaddr == 0) {
+ free(bpage, M_DEVBUF);
+ break;
+ }
+ bpage->busaddr = pmap_kextract(bpage->vaddr);
+ mtx_lock(&bounce_lock);
+ STAILQ_INSERT_TAIL(&bz->bounce_page_list, bpage, links);
+ total_bpages++;
+ bz->total_bpages++;
+ bz->free_bpages++;
+ mtx_unlock(&bounce_lock);
+ count++;
+ numpages--;
+ }
+ return (count);
+}
+
+static int
+reserve_bounce_pages(bus_dma_tag_t dmat, bus_dmamap_t map, int commit)
+{
+ struct bounce_zone *bz;
+ int pages;
+
+ mtx_assert(&bounce_lock, MA_OWNED);
+ bz = dmat->bounce_zone;
+ pages = MIN(bz->free_bpages, map->pagesneeded - map->pagesreserved);
+ if (commit == 0 && map->pagesneeded > (map->pagesreserved + pages))
+ return (map->pagesneeded - (map->pagesreserved + pages));
+ bz->free_bpages -= pages;
+ bz->reserved_bpages += pages;
+ map->pagesreserved += pages;
+ pages = map->pagesneeded - map->pagesreserved;
+
+ return (pages);
+}
+
+static bus_addr_t
+add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr,
+ bus_addr_t addr, bus_size_t size)
+{
+ struct bounce_zone *bz;
+ struct bounce_page *bpage;
+
+ KASSERT(dmat->bounce_zone != NULL, ("no bounce zone in dma tag"));
+ KASSERT(map != NULL && map != &nobounce_dmamap,
+ ("add_bounce_page: bad map %p", map));
+
+ bz = dmat->bounce_zone;
+ 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--;
+
+ mtx_lock(&bounce_lock);
+ bpage = STAILQ_FIRST(&bz->bounce_page_list);
+ if (bpage == NULL)
+ panic("add_bounce_page: free page list is empty");
+
+ STAILQ_REMOVE_HEAD(&bz->bounce_page_list, links);
+ bz->reserved_bpages--;
+ bz->active_bpages++;
+ mtx_unlock(&bounce_lock);
+
+ if (dmat->common.flags & BUS_DMA_KEEP_PG_OFFSET) {
+ /* Page offset needs to be preserved. */
+ bpage->vaddr |= addr & PAGE_MASK;
+ bpage->busaddr |= addr & PAGE_MASK;
+ }
+ bpage->datavaddr = vaddr;
+ bpage->dataaddr = addr;
+ 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)
+{
+ struct bus_dmamap *map;
+ struct bounce_zone *bz;
+
+ bz = dmat->bounce_zone;
+ bpage->datavaddr = 0;
+ bpage->datacount = 0;
+ if (dmat->common.flags & BUS_DMA_KEEP_PG_OFFSET) {
+ /*
+ * Reset the bounce page to start at offset 0. Other uses
+ * of this bounce page may need to store a full page of
+ * data and/or assume it starts on a page boundary.
+ */
+ bpage->vaddr &= ~PAGE_MASK;
+ bpage->busaddr &= ~PAGE_MASK;
+ }
+
+ mtx_lock(&bounce_lock);
+ STAILQ_INSERT_HEAD(&bz->bounce_page_list, bpage, links);
+ bz->free_bpages++;
+ bz->active_bpages--;
+ if ((map = STAILQ_FIRST(&bounce_map_waitinglist)) != NULL) {
+ if (reserve_bounce_pages(map->dmat, map, 1) == 0) {
+ STAILQ_REMOVE_HEAD(&bounce_map_waitinglist, links);
+ STAILQ_INSERT_TAIL(&bounce_map_callbacklist,
+ map, links);
+ busdma_swi_pending = 1;
+ bz->total_deferred++;
+ swi_sched(vm_ih, 0);
+ }
+ }
+ mtx_unlock(&bounce_lock);
+}
+
+void
+busdma_swi(void)
+{
+ bus_dma_tag_t dmat;
+ struct bus_dmamap *map;
+
+ mtx_lock(&bounce_lock);
+ while ((map = STAILQ_FIRST(&bounce_map_callbacklist)) != NULL) {
+ STAILQ_REMOVE_HEAD(&bounce_map_callbacklist, links);
+ mtx_unlock(&bounce_lock);
+ dmat = map->dmat;
+ (dmat->common.lockfunc)(dmat->common.lockfuncarg, BUS_DMA_LOCK);
+ bus_dmamap_load_mem(map->dmat, map, &map->mem,
+ map->callback, map->callback_arg, BUS_DMA_WAITOK);
+ (dmat->common.lockfunc)(dmat->common.lockfuncarg,
+ BUS_DMA_UNLOCK);
+ mtx_lock(&bounce_lock);
+ }
+ mtx_unlock(&bounce_lock);
+}
+
+struct bus_dma_impl bus_dma_bounce_impl = {
+ .tag_create = bounce_bus_dma_tag_create,
+ .tag_destroy = bounce_bus_dma_tag_destroy,
+ .map_create = bounce_bus_dmamap_create,
+ .map_destroy = bounce_bus_dmamap_destroy,
+ .mem_alloc = bounce_bus_dmamem_alloc,
+ .mem_free = bounce_bus_dmamem_free,
+ .load_phys = bounce_bus_dmamap_load_phys,
+ .load_buffer = bounce_bus_dmamap_load_buffer,
+ .load_ma = bus_dmamap_load_ma_triv,
+ .map_waitok = bounce_bus_dmamap_waitok,
+ .map_complete = bounce_bus_dmamap_complete,
+ .map_unload = bounce_bus_dmamap_unload,
+ .map_sync = bounce_bus_dmamap_sync
+};
diff --git a/sys/arm64/arm64/busdma_machdep.c b/sys/arm64/arm64/busdma_machdep.c
index 4a89b1f..df7a8be 100644
--- a/sys/arm64/arm64/busdma_machdep.c
+++ b/sys/arm64/arm64/busdma_machdep.c
@@ -1,22 +1,292 @@
-/* $FreeBSD$ */
+/*-
+ * Copyright (c) 1997, 1998 Justin T. Gibbs.
+ * Copyright (c) 2013, 2015 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Portions of this software were developed by Semihalf
+ * under sponsorship of the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that 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.
+ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
-
+#include <sys/malloc.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/ktr.h>
+#include <sys/lock.h>
+#include <sys/memdesc.h>
+#include <sys/mutex.h>
+#include <sys/uio.h>
#include <vm/vm.h>
+#include <vm/vm_extern.h>
#include <vm/pmap.h>
#include <machine/bus.h>
+#include <arm64/include/bus_dma_impl.h>
+
+/*
+ * Convenience function for manipulating driver locks from busdma (during
+ * busdma_swi, for example). Drivers that don't provide their own locks
+ * should specify &Giant to dmat->lockfuncarg. Drivers that use their own
+ * non-mutex locking scheme don't have to use this at all.
+ */
+void
+busdma_lock_mutex(void *arg, bus_dma_lock_op_t op)
+{
+ struct mtx *dmtx;
+
+ dmtx = (struct mtx *)arg;
+ switch (op) {
+ case BUS_DMA_LOCK:
+ mtx_lock(dmtx);
+ break;
+ case BUS_DMA_UNLOCK:
+ mtx_unlock(dmtx);
+ break;
+ default:
+ panic("Unknown operation 0x%x for busdma_lock_mutex!", op);
+ }
+}
+
+/*
+ * dflt_lock should never get called. It gets put into the dma tag when
+ * lockfunc == NULL, which is only valid if the maps that are associated
+ * with the tag are meant to never be defered.
+ * XXX Should have a way to identify which driver is responsible here.
+ */
+void
+bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op)
+{
+
+ panic("driver error: busdma dflt_lock called");
+}
+
+/*
+ * Return true if a match is made.
+ *
+ * To find a match walk the chain of bus_dma_tag_t's looking for 'paddr'.
+ *
+ * If paddr is within the bounds of the dma tag then call the filter callback
+ * to check for a match, if there is no filter callback then assume a match.
+ */
+int
+bus_dma_run_filter(struct bus_dma_tag_common *tc, bus_addr_t paddr)
+{
+ int retval;
+
+ retval = 0;
+ do {
+ if (((paddr > tc->lowaddr && paddr <= tc->highaddr) ||
+ ((paddr & (tc->alignment - 1)) != 0)) &&
+ (tc->filter == NULL ||
+ (*tc->filter)(tc->filterarg, paddr) != 0))
+ retval = 1;
+
+ tc = tc->parent;
+ } while (retval == 0 && tc != NULL);
+ return (retval);
+}
+
+int
+common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
+ bus_size_t alignment, bus_addr_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_lock_t *lockfunc, void *lockfuncarg, size_t sz, void **dmat)
+{
+ void *newtag;
+ struct bus_dma_tag_common *common;
+
+ KASSERT(sz >= sizeof(struct bus_dma_tag_common), ("sz"));
+ /* Return a NULL tag on failure */
+ *dmat = NULL;
+ /* Basic sanity checking */
+ if (boundary != 0 && boundary < maxsegsz)
+ maxsegsz = boundary;
+ if (maxsegsz == 0)
+ return (EINVAL);
+
+ newtag = malloc(sz, M_DEVBUF, M_ZERO | M_NOWAIT);
+ if (newtag == NULL) {
+ CTR4(KTR_BUSDMA, "%s returned tag %p tag flags 0x%x error %d",
+ __func__, newtag, 0, ENOMEM);
+ return (ENOMEM);
+ }
+
+ common = newtag;
+ common->impl = &bus_dma_bounce_impl;
+ common->parent = parent;
+ common->alignment = alignment;
+ common->boundary = boundary;
+ common->lowaddr = trunc_page((vm_paddr_t)lowaddr) + (PAGE_SIZE - 1);
+ common->highaddr = trunc_page((vm_paddr_t)highaddr) + (PAGE_SIZE - 1);
+ common->filter = filter;
+ common->filterarg = filterarg;
+ common->maxsize = maxsize;
+ common->nsegments = nsegments;
+ common->maxsegsz = maxsegsz;
+ common->flags = flags;
+ common->ref_count = 1; /* Count ourself */
+ if (lockfunc != NULL) {
+ common->lockfunc = lockfunc;
+ common->lockfuncarg = lockfuncarg;
+ } else {
+ common->lockfunc = bus_dma_dflt_lock;
+ common->lockfuncarg = NULL;
+ }
+
+ /* Take into account any restrictions imposed by our parent tag */
+ if (parent != NULL) {
+ common->impl = parent->impl;
+ common->lowaddr = MIN(parent->lowaddr, common->lowaddr);
+ common->highaddr = MAX(parent->highaddr, common->highaddr);
+ if (common->boundary == 0)
+ common->boundary = parent->boundary;
+ else if (parent->boundary != 0) {
+ common->boundary = MIN(parent->boundary,
+ common->boundary);
+ }
+ if (common->filter == NULL) {
+ /*
+ * Short circuit looking at our parent directly
+ * since we have encapsulated all of its information
+ */
+ common->filter = parent->filter;
+ common->filterarg = parent->filterarg;
+ common->parent = parent->parent;
+ }
+ atomic_add_int(&parent->ref_count, 1);
+ }
+ *dmat = common;
+ return (0);
+}
+
+/*
+ * Allocate a device specific dma_tag.
+ */
+int
+bus_dma_tag_create(bus_dma_tag_t parent, bus_size_t alignment,
+ bus_addr_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_lock_t *lockfunc,
+ void *lockfuncarg, bus_dma_tag_t *dmat)
+{
+ struct bus_dma_tag_common *tc;
+ int error;
+
+ if (parent == NULL) {
+ error = bus_dma_bounce_impl.tag_create(parent, alignment,
+ boundary, lowaddr, highaddr, filter, filterarg, maxsize,
+ nsegments, maxsegsz, flags, lockfunc, lockfuncarg, dmat);
+ } else {
+ tc = (struct bus_dma_tag_common *)parent;
+ error = tc->impl->tag_create(parent, alignment,
+ boundary, lowaddr, highaddr, filter, filterarg, maxsize,
+ nsegments, maxsegsz, flags, lockfunc, lockfuncarg, dmat);
+ }
+ return (error);
+}
+
+int
+bus_dma_tag_destroy(bus_dma_tag_t dmat)
+{
+ struct bus_dma_tag_common *tc;
+
+ tc = (struct bus_dma_tag_common *)dmat;
+ return (tc->impl->tag_destroy(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)
+{
+ struct bus_dma_tag_common *tc;
+
+ tc = (struct bus_dma_tag_common *)dmat;
+ return (tc->impl->map_create(dmat, flags, 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)
+{
+ struct bus_dma_tag_common *tc;
+
+ tc = (struct bus_dma_tag_common *)dmat;
+ return (tc->impl->map_destroy(dmat, map));
+}
+
+
+/*
+ * Allocate a piece of memory that can be efficiently mapped into
+ * bus device space based on the constraints listed 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)
+{
+ struct bus_dma_tag_common *tc;
+
+ tc = (struct bus_dma_tag_common *)dmat;
+ return (tc->impl->mem_alloc(dmat, vaddr, flags, mapp));
+}
+
+/*
+ * Free a piece of memory and it's allociated dmamap, that was allocated
+ * via bus_dmamem_alloc. Make the same choice for free/contigfree.
+ */
+void
+bus_dmamem_free(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map)
+{
+ struct bus_dma_tag_common *tc;
+
+ tc = (struct bus_dma_tag_common *)dmat;
+ tc->impl->mem_free(dmat, vaddr, map);
+}
int
_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf,
bus_size_t buflen, int flags, bus_dma_segment_t *segs, int *segp)
{
+ struct bus_dma_tag_common *tc;
- panic("_bus_dmamap_load_phys");
+ tc = (struct bus_dma_tag_common *)dmat;
+ return (tc->impl->load_phys(dmat, map, buf, buflen, flags, segs,
+ segp));
}
int
@@ -24,8 +294,11 @@ _bus_dmamap_load_ma(bus_dma_tag_t dmat, bus_dmamap_t map, struct vm_page **ma,
bus_size_t tlen, int ma_offs, int flags, bus_dma_segment_t *segs,
int *segp)
{
+ struct bus_dma_tag_common *tc;
- panic("_bus_dmamap_load_ma");
+ tc = (struct bus_dma_tag_common *)dmat;
+ return (tc->impl->load_ma(dmat, map, ma, tlen, ma_offs, flags,
+ segs, segp));
}
int
@@ -33,36 +306,50 @@ _bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
bus_size_t buflen, pmap_t pmap, int flags, bus_dma_segment_t *segs,
int *segp)
{
+ struct bus_dma_tag_common *tc;
- panic("_bus_dmamap_load_buffer");
+ tc = (struct bus_dma_tag_common *)dmat;
+ return (tc->impl->load_buffer(dmat, map, buf, buflen, pmap, flags, segs,
+ segp));
}
void
__bus_dmamap_waitok(bus_dma_tag_t dmat, bus_dmamap_t map,
struct memdesc *mem, bus_dmamap_callback_t *callback, void *callback_arg)
{
+ struct bus_dma_tag_common *tc;
- panic("__bus_dmamap_waitok");
+ tc = (struct bus_dma_tag_common *)dmat;
+ tc->impl->map_waitok(dmat, map, mem, callback, callback_arg);
}
bus_dma_segment_t *
_bus_dmamap_complete(bus_dma_tag_t dmat, bus_dmamap_t map,
bus_dma_segment_t *segs, int nsegs, int error)
{
+ struct bus_dma_tag_common *tc;
- panic("_bus_dmamap_complete");
+ tc = (struct bus_dma_tag_common *)dmat;
+ return (tc->impl->map_complete(dmat, map, segs, nsegs, error));
}
+/*
+ * Release the mapping held by map.
+ */
void
_bus_dmamap_unload(bus_dma_tag_t dmat, bus_dmamap_t map)
{
+ struct bus_dma_tag_common *tc;
- panic("_bus_dmamap_unload");
+ tc = (struct bus_dma_tag_common *)dmat;
+ tc->impl->map_unload(dmat, map);
}
void
_bus_dmamap_sync(bus_dma_tag_t dmat, bus_dmamap_t map, bus_dmasync_op_t op)
{
+ struct bus_dma_tag_common *tc;
- panic("_bus_dmamap_sync");
+ tc = (struct bus_dma_tag_common *)dmat;
+ tc->impl->map_sync(dmat, map, op);
}
diff --git a/sys/arm64/arm64/db_disasm.c b/sys/arm64/arm64/db_disasm.c
new file mode 100644
index 0000000..0378483
--- /dev/null
+++ b/sys/arm64/arm64/db_disasm.c
@@ -0,0 +1,41 @@
+/*-
+ * Copyright (c) 2015 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Semihalf under
+ * the sponsorship of the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+#include <sys/param.h>
+#include <ddb/ddb.h>
+
+vm_offset_t
+db_disasm(vm_offset_t loc, bool altfmt)
+{
+ return 0;
+}
+
+/* End of db_disasm.c */
diff --git a/sys/arm64/arm64/db_interface.c b/sys/arm64/arm64/db_interface.c
new file mode 100644
index 0000000..38834af
--- /dev/null
+++ b/sys/arm64/arm64/db_interface.c
@@ -0,0 +1,168 @@
+/*-
+ * Copyright (c) 2015 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Semihalf under
+ * the sponsorship of the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+#include <sys/param.h>
+#include <sys/proc.h>
+#include <vm/vm.h>
+#include <vm/pmap.h>
+#include <vm/vm_map.h>
+
+#ifdef KDB
+#include <sys/kdb.h>
+#endif
+
+#include <ddb/ddb.h>
+#include <ddb/db_variables.h>
+
+#include <machine/cpu.h>
+#include <machine/pcb.h>
+#include <machine/vmparam.h>
+
+static int
+db_frame(struct db_variable *vp, db_expr_t *valuep, int op)
+{
+ long *reg;
+
+ if (kdb_frame == NULL)
+ return (0);
+
+ reg = (long *)((uintptr_t)kdb_frame + (db_expr_t)vp->valuep);
+ if (op == DB_VAR_GET)
+ *valuep = *reg;
+ else
+ *reg = *valuep;
+ return (1);
+}
+
+#define DB_OFFSET(x) (db_expr_t *)offsetof(struct trapframe, x)
+struct db_variable db_regs[] = {
+ { "spsr", DB_OFFSET(tf_spsr), db_frame },
+ { "x0", DB_OFFSET(tf_x[0]), db_frame },
+ { "x1", DB_OFFSET(tf_x[1]), db_frame },
+ { "x2", DB_OFFSET(tf_x[2]), db_frame },
+ { "x3", DB_OFFSET(tf_x[3]), db_frame },
+ { "x4", DB_OFFSET(tf_x[4]), db_frame },
+ { "x5", DB_OFFSET(tf_x[5]), db_frame },
+ { "x6", DB_OFFSET(tf_x[6]), db_frame },
+ { "x7", DB_OFFSET(tf_x[7]), db_frame },
+ { "x8", DB_OFFSET(tf_x[8]), db_frame },
+ { "x9", DB_OFFSET(tf_x[9]), db_frame },
+ { "x10", DB_OFFSET(tf_x[10]), db_frame },
+ { "x11", DB_OFFSET(tf_x[11]), db_frame },
+ { "x12", DB_OFFSET(tf_x[12]), db_frame },
+ { "x13", DB_OFFSET(tf_x[13]), db_frame },
+ { "x14", DB_OFFSET(tf_x[14]), db_frame },
+ { "x15", DB_OFFSET(tf_x[15]), db_frame },
+ { "x16", DB_OFFSET(tf_x[16]), db_frame },
+ { "x17", DB_OFFSET(tf_x[17]), db_frame },
+ { "x18", DB_OFFSET(tf_x[18]), db_frame },
+ { "x19", DB_OFFSET(tf_x[19]), db_frame },
+ { "x20", DB_OFFSET(tf_x[20]), db_frame },
+ { "x21", DB_OFFSET(tf_x[21]), db_frame },
+ { "x22", DB_OFFSET(tf_x[22]), db_frame },
+ { "x23", DB_OFFSET(tf_x[23]), db_frame },
+ { "x24", DB_OFFSET(tf_x[24]), db_frame },
+ { "x25", DB_OFFSET(tf_x[25]), db_frame },
+ { "x26", DB_OFFSET(tf_x[26]), db_frame },
+ { "x27", DB_OFFSET(tf_x[27]), db_frame },
+ { "x28", DB_OFFSET(tf_x[28]), db_frame },
+ { "x29", DB_OFFSET(tf_x[29]), db_frame },
+ { "lr", DB_OFFSET(tf_lr), db_frame },
+ { "elr", DB_OFFSET(tf_elr), db_frame },
+ { "sp", DB_OFFSET(tf_sp), db_frame },
+};
+
+struct db_variable *db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
+
+void
+db_show_mdpcpu(struct pcpu *pc)
+{
+}
+
+static int
+db_validate_address(vm_offset_t addr)
+{
+ struct proc *p = curproc;
+ struct pmap *pmap;
+
+ if (!p || !p->p_vmspace || !p->p_vmspace->vm_map.pmap ||
+ addr >= VM_MAXUSER_ADDRESS)
+ pmap = pmap_kernel();
+ else
+ pmap = p->p_vmspace->vm_map.pmap;
+
+ return (pmap_extract(pmap, addr) == FALSE);
+}
+
+/*
+ * Read bytes from kernel address space for debugger.
+ */
+int
+db_read_bytes(vm_offset_t addr, size_t size, char *data)
+{
+ const char *src = (const char *)addr;
+
+ while (size-- > 0) {
+ if (db_validate_address((vm_offset_t)src)) {
+ db_printf("address %p is invalid\n", src);
+ return (-1);
+ }
+ *data++ = *src++;
+ }
+ return (0);
+}
+
+/*
+ * Write bytes to kernel address space for debugger.
+ */
+int
+db_write_bytes(vm_offset_t addr, size_t size, char *data)
+{
+ char *dst;
+
+ dst = (char *)addr;
+ while (size-- > 0) {
+ if (db_validate_address((vm_offset_t)dst)) {
+ db_printf("address %p is invalid\n", dst);
+ return (-1);
+ }
+ *dst++ = *data++;
+ }
+
+ dsb();
+ /* Clean D-cache and invalidate I-cache */
+ cpu_dcache_wb_range(addr, (vm_size_t)size);
+ cpu_icache_sync_range(addr, (vm_size_t)size);
+ dsb();
+ isb();
+
+ return (0);
+}
diff --git a/sys/arm64/arm64/db_trace.c b/sys/arm64/arm64/db_trace.c
new file mode 100644
index 0000000..1e89bac
--- /dev/null
+++ b/sys/arm64/arm64/db_trace.c
@@ -0,0 +1,152 @@
+/*-
+ * Copyright (c) 2015 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Semihalf under
+ * the sponsorship of the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+#include <sys/param.h>
+#include <sys/proc.h>
+#include <sys/kdb.h>
+#include <machine/pcb.h>
+#include <ddb/ddb.h>
+#include <ddb/db_sym.h>
+
+#include <machine/armreg.h>
+#include <machine/debug_monitor.h>
+
+struct unwind_state {
+ uint64_t fp;
+ uint64_t sp;
+ uint64_t pc;
+};
+
+void
+db_md_list_watchpoints()
+{
+
+ dbg_show_watchpoint();
+}
+
+int
+db_md_clr_watchpoint(db_expr_t addr, db_expr_t size)
+{
+
+ return (dbg_remove_watchpoint(addr, size, DBG_FROM_EL1));
+}
+
+int
+db_md_set_watchpoint(db_expr_t addr, db_expr_t size)
+{
+
+ return (dbg_setup_watchpoint(addr, size, DBG_FROM_EL1,
+ HW_BREAKPOINT_RW));
+}
+
+static int
+db_unwind_frame(struct unwind_state *frame)
+{
+ uint64_t fp = frame->fp;
+
+ if (fp == 0)
+ return -1;
+
+ frame->sp = fp + 0x10;
+ /* FP to previous frame (X29) */
+ frame->fp = *(uint64_t *)(fp);
+ /* LR (X30) */
+ frame->pc = *(uint64_t *)(fp + 8) - 4;
+ return (0);
+}
+
+static void
+db_stack_trace_cmd(struct unwind_state *frame)
+{
+ c_db_sym_t sym;
+ const char *name;
+ db_expr_t value;
+ db_expr_t offset;
+
+ while (1) {
+ uint64_t pc = frame->pc;
+ int ret;
+
+ ret = db_unwind_frame(frame);
+ if (ret < 0)
+ break;
+
+ sym = db_search_symbol(pc, DB_STGY_ANY, &offset);
+ if (sym == C_DB_SYM_NULL) {
+ value = 0;
+ name = "(null)";
+ } else
+ db_symbol_values(sym, &name, &value);
+
+ db_printf("%s() at ", name);
+ db_printsym(frame->pc, DB_STGY_PROC);
+ db_printf("\n");
+
+ db_printf("\t pc = 0x%016lx lr = 0x%016lx\n", pc,
+ frame->pc);
+ db_printf("\t sp = 0x%016lx fp = 0x%016lx\n", frame->sp,
+ frame->fp);
+ /* TODO: Show some more registers */
+ db_printf("\n");
+ }
+}
+
+int
+db_trace_thread(struct thread *thr, int count)
+{
+ struct unwind_state frame;
+ struct pcb *ctx;
+
+ if (thr != curthread) {
+ ctx = kdb_thr_ctx(thr);
+
+ frame.sp = (uint64_t)ctx->pcb_sp;
+ frame.fp = (uint64_t)ctx->pcb_x[29];
+ frame.pc = (uint64_t)ctx->pcb_x[30];
+ db_stack_trace_cmd(&frame);
+ } else
+ db_trace_self();
+ return (0);
+}
+
+void
+db_trace_self(void)
+{
+ struct unwind_state frame;
+ uint64_t sp;
+
+ __asm __volatile("mov %0, sp" : "=&r" (sp));
+
+ frame.sp = sp;
+ frame.fp = (uint64_t)__builtin_frame_address(0);
+ frame.pc = (uint64_t)db_trace_self;
+ db_stack_trace_cmd(&frame);
+}
diff --git a/sys/arm64/arm64/debug_monitor.c b/sys/arm64/arm64/debug_monitor.c
new file mode 100644
index 0000000..50d663d
--- /dev/null
+++ b/sys/arm64/arm64/debug_monitor.c
@@ -0,0 +1,487 @@
+/*-
+ * Copyright (c) 2014 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Semihalf under
+ * the sponsorship of the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/kdb.h>
+#include <sys/pcpu.h>
+#include <sys/systm.h>
+
+#include <machine/armreg.h>
+#include <machine/cpu.h>
+#include <machine/debug_monitor.h>
+#include <machine/kdb.h>
+#include <machine/param.h>
+
+#include <ddb/ddb.h>
+#include <ddb/db_sym.h>
+
+enum dbg_t {
+ DBG_TYPE_BREAKPOINT = 0,
+ DBG_TYPE_WATCHPOINT = 1,
+};
+
+static int dbg_watchpoint_num;
+static int dbg_breakpoint_num;
+static int dbg_ref_count_mde[MAXCPU];
+static int dbg_ref_count_kde[MAXCPU];
+
+/* Watchpoints/breakpoints control register bitfields */
+#define DBG_WATCH_CTRL_LEN_1 (0x1 << 5)
+#define DBG_WATCH_CTRL_LEN_2 (0x3 << 5)
+#define DBG_WATCH_CTRL_LEN_4 (0xf << 5)
+#define DBG_WATCH_CTRL_LEN_8 (0xff << 5)
+#define DBG_WATCH_CTRL_LEN_MASK(x) ((x) & (0xff << 5))
+#define DBG_WATCH_CTRL_EXEC (0x0 << 3)
+#define DBG_WATCH_CTRL_LOAD (0x1 << 3)
+#define DBG_WATCH_CTRL_STORE (0x2 << 3)
+#define DBG_WATCH_CTRL_ACCESS_MASK(x) ((x) & (0x3 << 3))
+
+/* Common for breakpoint and watchpoint */
+#define DBG_WB_CTRL_EL1 (0x1 << 1)
+#define DBG_WB_CTRL_EL0 (0x2 << 1)
+#define DBG_WB_CTRL_ELX_MASK(x) ((x) & (0x3 << 1))
+#define DBG_WB_CTRL_E (0x1 << 0)
+
+#define DBG_REG_BASE_BVR 0
+#define DBG_REG_BASE_BCR (DBG_REG_BASE_BVR + 16)
+#define DBG_REG_BASE_WVR (DBG_REG_BASE_BCR + 16)
+#define DBG_REG_BASE_WCR (DBG_REG_BASE_WVR + 16)
+
+/* Watchpoint/breakpoint helpers */
+#define DBG_WB_WVR "wvr"
+#define DBG_WB_WCR "wcr"
+#define DBG_WB_BVR "bvr"
+#define DBG_WB_BCR "bcr"
+
+#define DBG_WB_READ(reg, num, val) do { \
+ __asm __volatile("mrs %0, dbg" reg #num "_el1" : "=r" (val)); \
+} while (0)
+
+#define DBG_WB_WRITE(reg, num, val) do { \
+ __asm __volatile("msr dbg" reg #num "_el1, %0" :: "r" (val)); \
+} while (0)
+
+#define READ_WB_REG_CASE(reg, num, offset, val) \
+ case (num + offset): \
+ DBG_WB_READ(reg, num, val); \
+ break
+
+#define WRITE_WB_REG_CASE(reg, num, offset, val) \
+ case (num + offset): \
+ DBG_WB_WRITE(reg, num, val); \
+ break
+
+#define SWITCH_CASES_READ_WB_REG(reg, offset, val) \
+ READ_WB_REG_CASE(reg, 0, offset, val); \
+ READ_WB_REG_CASE(reg, 1, offset, val); \
+ READ_WB_REG_CASE(reg, 2, offset, val); \
+ READ_WB_REG_CASE(reg, 3, offset, val); \
+ READ_WB_REG_CASE(reg, 4, offset, val); \
+ READ_WB_REG_CASE(reg, 5, offset, val); \
+ READ_WB_REG_CASE(reg, 6, offset, val); \
+ READ_WB_REG_CASE(reg, 7, offset, val); \
+ READ_WB_REG_CASE(reg, 8, offset, val); \
+ READ_WB_REG_CASE(reg, 9, offset, val); \
+ READ_WB_REG_CASE(reg, 10, offset, val); \
+ READ_WB_REG_CASE(reg, 11, offset, val); \
+ READ_WB_REG_CASE(reg, 12, offset, val); \
+ READ_WB_REG_CASE(reg, 13, offset, val); \
+ READ_WB_REG_CASE(reg, 14, offset, val); \
+ READ_WB_REG_CASE(reg, 15, offset, val)
+
+#define SWITCH_CASES_WRITE_WB_REG(reg, offset, val) \
+ WRITE_WB_REG_CASE(reg, 0, offset, val); \
+ WRITE_WB_REG_CASE(reg, 1, offset, val); \
+ WRITE_WB_REG_CASE(reg, 2, offset, val); \
+ WRITE_WB_REG_CASE(reg, 3, offset, val); \
+ WRITE_WB_REG_CASE(reg, 4, offset, val); \
+ WRITE_WB_REG_CASE(reg, 5, offset, val); \
+ WRITE_WB_REG_CASE(reg, 6, offset, val); \
+ WRITE_WB_REG_CASE(reg, 7, offset, val); \
+ WRITE_WB_REG_CASE(reg, 8, offset, val); \
+ WRITE_WB_REG_CASE(reg, 9, offset, val); \
+ WRITE_WB_REG_CASE(reg, 10, offset, val); \
+ WRITE_WB_REG_CASE(reg, 11, offset, val); \
+ WRITE_WB_REG_CASE(reg, 12, offset, val); \
+ WRITE_WB_REG_CASE(reg, 13, offset, val); \
+ WRITE_WB_REG_CASE(reg, 14, offset, val); \
+ WRITE_WB_REG_CASE(reg, 15, offset, val)
+
+static uint64_t
+dbg_wb_read_reg(int reg, int n)
+{
+ uint64_t val = 0;
+
+ switch (reg + n) {
+ SWITCH_CASES_READ_WB_REG(DBG_WB_WVR, DBG_REG_BASE_WVR, val);
+ SWITCH_CASES_READ_WB_REG(DBG_WB_WCR, DBG_REG_BASE_WCR, val);
+ SWITCH_CASES_READ_WB_REG(DBG_WB_BVR, DBG_REG_BASE_BVR, val);
+ SWITCH_CASES_READ_WB_REG(DBG_WB_BCR, DBG_REG_BASE_BCR, val);
+ default:
+ db_printf("trying to read from wrong debug register %d\n", n);
+ }
+
+ return val;
+}
+
+static void
+dbg_wb_write_reg(int reg, int n, uint64_t val)
+{
+ switch (reg + n) {
+ SWITCH_CASES_WRITE_WB_REG(DBG_WB_WVR, DBG_REG_BASE_WVR, val);
+ SWITCH_CASES_WRITE_WB_REG(DBG_WB_WCR, DBG_REG_BASE_WCR, val);
+ SWITCH_CASES_WRITE_WB_REG(DBG_WB_BVR, DBG_REG_BASE_BVR, val);
+ SWITCH_CASES_WRITE_WB_REG(DBG_WB_BCR, DBG_REG_BASE_BCR, val);
+ default:
+ db_printf("trying to write to wrong debug register %d\n", n);
+ }
+ isb();
+}
+
+void
+kdb_cpu_set_singlestep(void)
+{
+
+ kdb_frame->tf_spsr |= DBG_SPSR_SS;
+ WRITE_SPECIALREG(MDSCR_EL1, READ_SPECIALREG(MDSCR_EL1) |
+ DBG_MDSCR_SS | DBG_MDSCR_KDE);
+
+ /*
+ * Disable breakpoints and watchpoints, e.g. stepping
+ * over watched instruction will trigger break exception instead of
+ * single-step exception and locks CPU on that instruction for ever.
+ */
+ if (dbg_ref_count_mde[PCPU_GET(cpuid)] > 0) {
+ WRITE_SPECIALREG(MDSCR_EL1,
+ READ_SPECIALREG(MDSCR_EL1) & ~DBG_MDSCR_MDE);
+ }
+}
+
+void
+kdb_cpu_clear_singlestep(void)
+{
+
+ WRITE_SPECIALREG(MDSCR_EL1, READ_SPECIALREG(MDSCR_EL1) &
+ ~(DBG_MDSCR_SS | DBG_MDSCR_KDE));
+
+ /* Restore breakpoints and watchpoints */
+ if (dbg_ref_count_mde[PCPU_GET(cpuid)] > 0) {
+ WRITE_SPECIALREG(MDSCR_EL1,
+ READ_SPECIALREG(MDSCR_EL1) | DBG_MDSCR_MDE);
+ }
+
+ if (dbg_ref_count_kde[PCPU_GET(cpuid)] > 0) {
+ WRITE_SPECIALREG(MDSCR_EL1,
+ READ_SPECIALREG(MDSCR_EL1) | DBG_MDSCR_KDE);
+ }
+}
+
+static const char *
+dbg_watchtype_str(uint32_t type)
+{
+ switch (type) {
+ case DBG_WATCH_CTRL_EXEC:
+ return ("execute");
+ case DBG_WATCH_CTRL_STORE:
+ return ("write");
+ case DBG_WATCH_CTRL_LOAD:
+ return ("read");
+ case DBG_WATCH_CTRL_LOAD | DBG_WATCH_CTRL_STORE:
+ return ("read/write");
+ default:
+ return ("invalid");
+ }
+}
+
+static int
+dbg_watchtype_len(uint32_t len)
+{
+ switch (len) {
+ case DBG_WATCH_CTRL_LEN_1:
+ return (1);
+ case DBG_WATCH_CTRL_LEN_2:
+ return (2);
+ case DBG_WATCH_CTRL_LEN_4:
+ return (4);
+ case DBG_WATCH_CTRL_LEN_8:
+ return (8);
+ default:
+ return (0);
+ }
+}
+
+void
+dbg_show_watchpoint(void)
+{
+ uint32_t wcr, len, type;
+ uint64_t addr;
+ int i;
+
+ db_printf("\nhardware watchpoints:\n");
+ db_printf(" watch status type len address symbol\n");
+ db_printf(" ----- -------- ---------- --- ------------------ ------------------\n");
+ for (i = 0; i < dbg_watchpoint_num; i++) {
+ wcr = dbg_wb_read_reg(DBG_REG_BASE_WCR, i);
+ if ((wcr & DBG_WB_CTRL_E) != 0) {
+ type = DBG_WATCH_CTRL_ACCESS_MASK(wcr);
+ len = DBG_WATCH_CTRL_LEN_MASK(wcr);
+ addr = dbg_wb_read_reg(DBG_REG_BASE_WVR, i);
+ db_printf(" %-5d %-8s %10s %3d 0x%16lx ",
+ i, "enabled", dbg_watchtype_str(type),
+ dbg_watchtype_len(len), addr);
+ db_printsym((db_addr_t)addr, DB_STGY_ANY);
+ db_printf("\n");
+ } else {
+ db_printf(" %-5d disabled\n", i);
+ }
+ }
+}
+
+
+static int
+dbg_find_free_slot(enum dbg_t type)
+{
+ u_int max, reg, i;
+
+ switch(type) {
+ case DBG_TYPE_BREAKPOINT:
+ max = dbg_breakpoint_num;
+ reg = DBG_REG_BASE_BCR;
+
+ break;
+ case DBG_TYPE_WATCHPOINT:
+ max = dbg_watchpoint_num;
+ reg = DBG_REG_BASE_WCR;
+ break;
+ default:
+ db_printf("Unsupported debug type\n");
+ return (i);
+ }
+
+ for (i = 0; i < max; i++) {
+ if ((dbg_wb_read_reg(reg, i) & DBG_WB_CTRL_E) == 0)
+ return (i);
+ }
+
+ return (-1);
+}
+
+static int
+dbg_find_slot(enum dbg_t type, db_expr_t addr)
+{
+ u_int max, reg_addr, reg_ctrl, i;
+
+ switch(type) {
+ case DBG_TYPE_BREAKPOINT:
+ max = dbg_breakpoint_num;
+ reg_addr = DBG_REG_BASE_BVR;
+ reg_ctrl = DBG_REG_BASE_BCR;
+ break;
+ case DBG_TYPE_WATCHPOINT:
+ max = dbg_watchpoint_num;
+ reg_addr = DBG_REG_BASE_WVR;
+ reg_ctrl = DBG_REG_BASE_WCR;
+ break;
+ default:
+ db_printf("Unsupported debug type\n");
+ return (i);
+ }
+
+ for (i = 0; i < max; i++) {
+ if ((dbg_wb_read_reg(reg_addr, i) == addr) &&
+ ((dbg_wb_read_reg(reg_ctrl, i) & DBG_WB_CTRL_E) != 0))
+ return (i);
+ }
+
+ return (-1);
+}
+
+static void
+dbg_enable_monitor(enum dbg_el_t el)
+{
+ uint64_t reg_mdcr = 0;
+
+ /*
+ * There is no need to have debug monitor on permanently, thus we are
+ * refcounting and turn it on only if any of CPU is going to use that.
+ */
+ if (atomic_fetchadd_int(&dbg_ref_count_mde[PCPU_GET(cpuid)], 1) == 0)
+ reg_mdcr = DBG_MDSCR_MDE;
+
+ if ((el == DBG_FROM_EL1) &&
+ atomic_fetchadd_int(&dbg_ref_count_kde[PCPU_GET(cpuid)], 1) == 0)
+ reg_mdcr |= DBG_MDSCR_KDE;
+
+ if (reg_mdcr)
+ WRITE_SPECIALREG(MDSCR_EL1, READ_SPECIALREG(MDSCR_EL1) | reg_mdcr);
+}
+
+static void
+dbg_disable_monitor(enum dbg_el_t el)
+{
+ uint64_t reg_mdcr = 0;
+
+ if (atomic_fetchadd_int(&dbg_ref_count_mde[PCPU_GET(cpuid)], -1) == 1)
+ reg_mdcr = DBG_MDSCR_MDE;
+
+ if ((el == DBG_FROM_EL1) &&
+ atomic_fetchadd_int(&dbg_ref_count_kde[PCPU_GET(cpuid)], -1) == 1)
+ reg_mdcr |= DBG_MDSCR_KDE;
+
+ if (reg_mdcr)
+ WRITE_SPECIALREG(MDSCR_EL1, READ_SPECIALREG(MDSCR_EL1) & ~reg_mdcr);
+}
+
+int
+dbg_setup_watchpoint(db_expr_t addr, db_expr_t size, enum dbg_el_t el,
+ enum dbg_access_t access)
+{
+ uint64_t wcr_size, wcr_priv, wcr_access;
+ u_int i;
+
+ i = dbg_find_free_slot(DBG_TYPE_WATCHPOINT);
+ if (i == -1) {
+ db_printf("Can not find slot for watchpoint, max %d"
+ " watchpoints supported\n", dbg_watchpoint_num);
+ return (i);
+ }
+
+ switch(size) {
+ case 1:
+ wcr_size = DBG_WATCH_CTRL_LEN_1;
+ break;
+ case 2:
+ wcr_size = DBG_WATCH_CTRL_LEN_2;
+ break;
+ case 4:
+ wcr_size = DBG_WATCH_CTRL_LEN_4;
+ break;
+ case 8:
+ wcr_size = DBG_WATCH_CTRL_LEN_8;
+ break;
+ default:
+ db_printf("Unsupported address size for watchpoint\n");
+ return (-1);
+ }
+
+ switch(el) {
+ case DBG_FROM_EL0:
+ wcr_priv = DBG_WB_CTRL_EL0;
+ break;
+ case DBG_FROM_EL1:
+ wcr_priv = DBG_WB_CTRL_EL1;
+ break;
+ default:
+ db_printf("Unsupported exception level for watchpoint\n");
+ return (-1);
+ }
+
+ switch(access) {
+ case HW_BREAKPOINT_X:
+ wcr_access = DBG_WATCH_CTRL_EXEC;
+ break;
+ case HW_BREAKPOINT_R:
+ wcr_access = DBG_WATCH_CTRL_LOAD;
+ break;
+ case HW_BREAKPOINT_W:
+ wcr_access = DBG_WATCH_CTRL_STORE;
+ break;
+ case HW_BREAKPOINT_RW:
+ wcr_access = DBG_WATCH_CTRL_LOAD | DBG_WATCH_CTRL_STORE;
+ break;
+ default:
+ db_printf("Unsupported exception level for watchpoint\n");
+ return (-1);
+ }
+
+ dbg_wb_write_reg(DBG_REG_BASE_WVR, i, addr);
+ dbg_wb_write_reg(DBG_REG_BASE_WCR, i, wcr_size | wcr_access | wcr_priv |
+ DBG_WB_CTRL_E);
+ dbg_enable_monitor(el);
+ return (0);
+}
+
+int
+dbg_remove_watchpoint(db_expr_t addr, db_expr_t size, enum dbg_el_t el)
+{
+ u_int i;
+
+ i = dbg_find_slot(DBG_TYPE_WATCHPOINT, addr);
+ if (i == -1) {
+ db_printf("Can not find watchpoint for address 0%lx\n", addr);
+ return (i);
+ }
+
+ dbg_wb_write_reg(DBG_REG_BASE_WCR, i, 0);
+ dbg_disable_monitor(el);
+ return (0);
+}
+
+void
+dbg_monitor_init(void)
+{
+ u_int i;
+
+ /* Clear OS lock */
+ WRITE_SPECIALREG(OSLAR_EL1, 0);
+
+ /* Find out many breakpoints and watchpoints we can use */
+ dbg_watchpoint_num = ((READ_SPECIALREG(ID_AA64DFR0_EL1) >> 20) & 0xf) + 1;
+ dbg_breakpoint_num = ((READ_SPECIALREG(ID_AA64DFR0_EL1) >> 12) & 0xf) + 1;
+
+ if (bootverbose && PCPU_GET(cpuid) == 0) {
+ db_printf("%d watchpoints and %d breakpoints supported\n",
+ dbg_watchpoint_num, dbg_breakpoint_num);
+ }
+
+ /*
+ * We have limited number of {watch,break}points, each consists of
+ * two registers:
+ * - wcr/bcr regsiter configurates corresponding {watch,break}point
+ * behaviour
+ * - wvr/bvr register keeps address we are hunting for
+ *
+ * Reset all breakpoints and watchpoints.
+ */
+ for (i = 0; i < dbg_watchpoint_num; ++i) {
+ dbg_wb_write_reg(DBG_REG_BASE_WCR, i, 0);
+ dbg_wb_write_reg(DBG_REG_BASE_WVR, i, 0);
+ }
+
+ for (i = 0; i < dbg_breakpoint_num; ++i) {
+ dbg_wb_write_reg(DBG_REG_BASE_BCR, i, 0);
+ dbg_wb_write_reg(DBG_REG_BASE_BVR, i, 0);
+ }
+
+ dbg_enable();
+}
diff --git a/sys/arm64/arm64/gic_v3.c b/sys/arm64/arm64/gic_v3.c
new file mode 100644
index 0000000..1f5ff81
--- /dev/null
+++ b/sys/arm64/arm64/gic_v3.c
@@ -0,0 +1,580 @@
+/*-
+ * Copyright (c) 2015 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Semihalf under
+ * the sponsorship of the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/ktr.h>
+#include <sys/malloc.h>
+#include <sys/module.h>
+#include <sys/rman.h>
+#include <sys/pcpu.h>
+#include <sys/proc.h>
+#include <sys/cpuset.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <machine/bus.h>
+#include <machine/intr.h>
+
+#include "pic_if.h"
+
+#include "gic_v3_reg.h"
+#include "gic_v3_var.h"
+
+/* Device and PIC methods */
+static void gic_v3_dispatch(device_t, struct trapframe *);
+static void gic_v3_eoi(device_t, u_int);
+static void gic_v3_mask_irq(device_t, u_int);
+static void gic_v3_unmask_irq(device_t, u_int);
+
+static device_method_t gic_v3_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_detach, gic_v3_detach),
+
+ /* PIC interface */
+ DEVMETHOD(pic_dispatch, gic_v3_dispatch),
+ DEVMETHOD(pic_eoi, gic_v3_eoi),
+ DEVMETHOD(pic_mask, gic_v3_mask_irq),
+ DEVMETHOD(pic_unmask, gic_v3_unmask_irq),
+
+ /* End */
+ DEVMETHOD_END
+};
+
+DEFINE_CLASS_0(gic_v3, gic_v3_driver, gic_v3_methods,
+ sizeof(struct gic_v3_softc));
+
+/*
+ * Driver-specific definitions.
+ */
+MALLOC_DEFINE(M_GIC_V3, "GICv3", GIC_V3_DEVSTR);
+
+/*
+ * Helper functions and definitions.
+ */
+/* Destination registers, either Distributor or Re-Distributor */
+enum gic_v3_xdist {
+ DIST = 0,
+ REDIST,
+};
+
+/* Helper routines starting with gic_v3_ */
+static int gic_v3_dist_init(struct gic_v3_softc *);
+static int gic_v3_redist_find(struct gic_v3_softc *);
+static int gic_v3_redist_init(struct gic_v3_softc *);
+static int gic_v3_cpu_init(struct gic_v3_softc *);
+static void gic_v3_wait_for_rwp(struct gic_v3_softc *, enum gic_v3_xdist);
+
+/* A sequence of init functions for primary (boot) CPU */
+typedef int (*gic_v3_initseq_t) (struct gic_v3_softc *);
+/* Primary CPU initialization sequence */
+static gic_v3_initseq_t gic_v3_primary_init[] = {
+ gic_v3_dist_init,
+ gic_v3_redist_init,
+ gic_v3_cpu_init,
+ NULL
+};
+
+/*
+ * Device interface.
+ */
+int
+gic_v3_attach(device_t dev)
+{
+ struct gic_v3_softc *sc;
+ gic_v3_initseq_t *init_func;
+ uint32_t typer;
+ int rid;
+ int err;
+ size_t i;
+
+ sc = device_get_softc(dev);
+ sc->gic_registered = FALSE;
+ sc->dev = dev;
+ err = 0;
+
+ /* Initialize mutex */
+ mtx_init(&sc->gic_mtx, "GICv3 lock", NULL, MTX_SPIN);
+
+ /*
+ * Allocate array of struct resource.
+ * One entry for Distributor and all remaining for Re-Distributor.
+ */
+ sc->gic_res = malloc(
+ sizeof(sc->gic_res) * (sc->gic_redists.nregions + 1),
+ M_GIC_V3, M_WAITOK);
+
+ /* Now allocate corresponding resources */
+ for (i = 0, rid = 0; i < (sc->gic_redists.nregions + 1); i++, rid++) {
+ sc->gic_res[rid] = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
+ &rid, RF_ACTIVE);
+ if (sc->gic_res[rid] == NULL)
+ return (ENXIO);
+ }
+
+ /*
+ * Distributor interface
+ */
+ sc->gic_dist = sc->gic_res[0];
+
+ /*
+ * Re-Dristributor interface
+ */
+ /* Allocate space under region descriptions */
+ sc->gic_redists.regions = malloc(
+ sizeof(*sc->gic_redists.regions) * sc->gic_redists.nregions,
+ M_GIC_V3, M_WAITOK);
+
+ /* Fill-up bus_space information for each region. */
+ for (i = 0, rid = 1; i < sc->gic_redists.nregions; i++, rid++)
+ sc->gic_redists.regions[i] = sc->gic_res[rid];
+
+ /* Get the number of supported SPI interrupts */
+ typer = gic_d_read(sc, 4, GICD_TYPER);
+ sc->gic_nirqs = GICD_TYPER_I_NUM(typer);
+ if (sc->gic_nirqs > GIC_I_NUM_MAX)
+ sc->gic_nirqs = GIC_I_NUM_MAX;
+
+ /* Get the number of supported interrupt identifier bits */
+ sc->gic_idbits = GICD_TYPER_IDBITS(typer);
+
+ if (bootverbose) {
+ device_printf(dev, "SPIs: %u, IDs: %u\n",
+ sc->gic_nirqs, (1 << sc->gic_idbits) - 1);
+ }
+
+ /* Train init sequence for boot CPU */
+ for (init_func = gic_v3_primary_init; *init_func != NULL; init_func++) {
+ err = (*init_func)(sc);
+ if (err != 0)
+ return (err);
+ }
+ /*
+ * Full success.
+ * Now register PIC to the interrupts handling layer.
+ */
+ arm_register_root_pic(dev, sc->gic_nirqs);
+ sc->gic_registered = TRUE;
+
+ return (0);
+}
+
+int
+gic_v3_detach(device_t dev)
+{
+ struct gic_v3_softc *sc;
+ size_t i;
+ int rid;
+
+ sc = device_get_softc(dev);
+
+ if (device_is_attached(dev)) {
+ /*
+ * XXX: We should probably deregister PIC
+ */
+ if (sc->gic_registered)
+ panic("Trying to detach registered PIC");
+ }
+ for (rid = 0; rid < (sc->gic_redists.nregions + 1); rid++)
+ bus_release_resource(dev, SYS_RES_MEMORY, rid, sc->gic_res[rid]);
+
+ for (i = 0; i < MAXCPU; i++)
+ free(sc->gic_redists.pcpu[i], M_GIC_V3);
+
+ free(sc->gic_res, M_GIC_V3);
+ free(sc->gic_redists.regions, M_GIC_V3);
+
+ return (0);
+}
+
+/*
+ * PIC interface.
+ */
+static void
+gic_v3_dispatch(device_t dev, struct trapframe *frame)
+{
+ uint64_t active_irq;
+
+ while (1) {
+ active_irq = gic_icc_read(IAR1);
+
+ if (__predict_false(active_irq == ICC_IAR1_EL1_SPUR))
+ break;
+
+ if (__predict_true((active_irq >= GIC_FIRST_PPI &&
+ active_irq <= GIC_LAST_SPI))) {
+ arm_dispatch_intr(active_irq, frame);
+ continue;
+ }
+
+ if (active_irq <= GIC_LAST_SGI || active_irq >= GIC_FIRST_LPI) {
+ /*
+ * TODO: Implement proper SGI/LPI handling.
+ * Mask it if such is received for some reason.
+ */
+ device_printf(dev,
+ "Received unsupported interrupt type: %s\n",
+ active_irq >= GIC_FIRST_LPI ? "LPI" : "SGI");
+ PIC_MASK(dev, active_irq);
+ }
+ }
+}
+
+static void
+gic_v3_eoi(device_t dev, u_int irq)
+{
+
+ gic_icc_write(EOIR1, (uint64_t)irq);
+}
+
+static void
+gic_v3_mask_irq(device_t dev, u_int irq)
+{
+ struct gic_v3_softc *sc;
+
+ sc = device_get_softc(dev);
+
+ if (irq >= GIC_FIRST_PPI && irq <= GIC_LAST_PPI) { /* PPIs in corresponding Re-Distributor */
+ gic_r_write(sc, 4,
+ GICR_SGI_BASE_SIZE + GICD_ICENABLER(irq), GICD_I_MASK(irq));
+ gic_v3_wait_for_rwp(sc, REDIST);
+ } else if (irq >= GIC_FIRST_SPI && irq <= GIC_LAST_SPI) { /* SPIs in distributor */
+ gic_r_write(sc, 4, GICD_ICENABLER(irq), GICD_I_MASK(irq));
+ gic_v3_wait_for_rwp(sc, DIST);
+ } else
+ panic("%s: Unsupported IRQ number %u", __func__, irq);
+}
+
+static void
+gic_v3_unmask_irq(device_t dev, u_int irq)
+{
+ struct gic_v3_softc *sc;
+
+ sc = device_get_softc(dev);
+
+ if (irq >= GIC_FIRST_PPI && irq <= GIC_LAST_PPI) { /* PPIs in corresponding Re-Distributor */
+ gic_r_write(sc, 4,
+ GICR_SGI_BASE_SIZE + GICD_ISENABLER(irq), GICD_I_MASK(irq));
+ gic_v3_wait_for_rwp(sc, REDIST);
+ } else if (irq >= GIC_FIRST_SPI && irq <= GIC_LAST_SPI) { /* SPIs in distributor */
+ gic_d_write(sc, 4, GICD_ISENABLER(irq), GICD_I_MASK(irq));
+ gic_v3_wait_for_rwp(sc, DIST);
+ } else
+ panic("%s: Unsupported IRQ number %u", __func__, irq);
+}
+
+/*
+ * Helper routines
+ */
+static void
+gic_v3_wait_for_rwp(struct gic_v3_softc *sc, enum gic_v3_xdist xdist)
+{
+ struct resource *res;
+ u_int cpuid;
+ size_t us_left = 1000000;
+
+ cpuid = PCPU_GET(cpuid);
+
+ switch (xdist) {
+ case DIST:
+ res = sc->gic_dist;
+ break;
+ case REDIST:
+ res = sc->gic_redists.pcpu[cpuid];
+ break;
+ default:
+ KASSERT(0, ("%s: Attempt to wait for unknown RWP", __func__));
+ return;
+ }
+
+ while ((bus_read_4(res, GICD_CTLR) & GICD_CTLR_RWP) != 0) {
+ DELAY(1);
+ if (us_left-- == 0)
+ panic("GICD Register write pending for too long");
+ }
+}
+
+/* CPU interface. */
+static __inline void
+gic_v3_cpu_priority(uint64_t mask)
+{
+
+ /* Set prority mask */
+ gic_icc_write(PMR, mask & ICC_PMR_EL1_PRIO_MASK);
+}
+
+static int
+gic_v3_cpu_enable_sre(struct gic_v3_softc *sc)
+{
+ uint64_t sre;
+ u_int cpuid;
+
+ cpuid = PCPU_GET(cpuid);
+ /*
+ * Set the SRE bit to enable access to GIC CPU interface
+ * via system registers.
+ */
+ sre = READ_SPECIALREG(icc_sre_el1);
+ sre |= ICC_SRE_EL1_SRE;
+ WRITE_SPECIALREG(icc_sre_el1, sre);
+ isb();
+ /*
+ * Now ensure that the bit is set.
+ */
+ sre = READ_SPECIALREG(icc_sre_el1);
+ if ((sre & ICC_SRE_EL1_SRE) == 0) {
+ /* We are done. This was disabled in EL2 */
+ device_printf(sc->dev, "ERROR: CPU%u cannot enable CPU interface "
+ "via system registers\n", cpuid);
+ return (ENXIO);
+ } else if (bootverbose) {
+ device_printf(sc->dev,
+ "CPU%u enabled CPU interface via system registers\n",
+ cpuid);
+ }
+
+ return (0);
+}
+
+static int
+gic_v3_cpu_init(struct gic_v3_softc *sc)
+{
+ int err;
+
+ /* Enable access to CPU interface via system registers */
+ err = gic_v3_cpu_enable_sre(sc);
+ if (err != 0)
+ return (err);
+ /* Priority mask to minimum - accept all interrupts */
+ gic_v3_cpu_priority(GIC_PRIORITY_MIN);
+ /* Disable EOI mode */
+ gic_icc_clear(CTLR, ICC_CTLR_EL1_EOIMODE);
+ /* Enable group 1 (insecure) interrups */
+ gic_icc_set(IGRPEN1, ICC_IGRPEN0_EL1_EN);
+
+ return (0);
+}
+
+/* Distributor */
+static int
+gic_v3_dist_init(struct gic_v3_softc *sc)
+{
+ uint64_t aff;
+ u_int i;
+
+ /*
+ * 1. Disable the Distributor
+ */
+ gic_d_write(sc, 4, GICD_CTLR, 0);
+ gic_v3_wait_for_rwp(sc, DIST);
+
+ /*
+ * 2. Configure the Distributor
+ */
+ /* Set all global interrupts to be level triggered, active low. */
+ for (i = GIC_FIRST_SPI; i < sc->gic_nirqs; i += GICD_I_PER_ICFGRn)
+ gic_d_write(sc, 4, GICD_ICFGR(i), 0x00000000);
+
+ /* Set priority to all shared interrupts */
+ for (i = GIC_FIRST_SPI;
+ i < sc->gic_nirqs; i += GICD_I_PER_IPRIORITYn) {
+ /* Set highest priority */
+ gic_d_write(sc, 4, GICD_IPRIORITYR(i), GIC_PRIORITY_MAX);
+ }
+
+ /*
+ * Disable all interrupts. Leave PPI and SGIs as they are enabled in
+ * Re-Distributor registers.
+ */
+ for (i = GIC_FIRST_SPI; i < sc->gic_nirqs; i += GICD_I_PER_ISENABLERn)
+ gic_d_write(sc, 4, GICD_ICENABLER(i), 0xFFFFFFFF);
+
+ gic_v3_wait_for_rwp(sc, DIST);
+
+ /*
+ * 3. Enable Distributor
+ */
+ /* Enable Distributor with ARE, Group 1 */
+ gic_d_write(sc, 4, GICD_CTLR, GICD_CTLR_ARE_NS | GICD_CTLR_G1A |
+ GICD_CTLR_G1);
+
+ /*
+ * 4. Route all interrupts to boot CPU.
+ */
+ aff = CPU_AFFINITY(PCPU_GET(cpuid));
+ for (i = GIC_FIRST_SPI; i < sc->gic_nirqs; i++)
+ gic_d_write(sc, 4, GICD_IROUTER(i), aff);
+
+ return (0);
+}
+
+/* Re-Distributor */
+static int
+gic_v3_redist_find(struct gic_v3_softc *sc)
+{
+ struct resource r_res;
+ bus_space_handle_t r_bsh;
+ uint64_t aff;
+ uint64_t typer;
+ uint32_t pidr2;
+ u_int cpuid;
+ size_t i;
+
+ cpuid = PCPU_GET(cpuid);
+
+ /* Allocate struct resource for this CPU's Re-Distributor registers */
+ sc->gic_redists.pcpu[cpuid] =
+ malloc(sizeof(*sc->gic_redists.pcpu[0]), M_GIC_V3, M_WAITOK);
+
+ aff = CPU_AFFINITY(cpuid);
+ /* Affinity in format for comparison with typer */
+ aff = (CPU_AFF3(aff) << 24) | (CPU_AFF2(aff) << 16) |
+ (CPU_AFF1(aff) << 8) | CPU_AFF0(aff);
+
+ if (bootverbose) {
+ device_printf(sc->dev,
+ "Start searching for Re-Distributor\n");
+ }
+ /* Iterate through Re-Distributor regions */
+ for (i = 0; i < sc->gic_redists.nregions; i++) {
+ /* Take a copy of the region's resource */
+ r_res = *sc->gic_redists.regions[i];
+ r_bsh = rman_get_bushandle(&r_res);
+
+ pidr2 = bus_read_4(&r_res, GICR_PIDR2);
+ switch (pidr2 & GICR_PIDR2_ARCH_MASK) {
+ case GICR_PIDR2_ARCH_GICv3: /* fall through */
+ case GICR_PIDR2_ARCH_GICv4:
+ break;
+ default:
+ device_printf(sc->dev,
+ "No Re-Distributor found for CPU%u\n", cpuid);
+ free(sc->gic_redists.pcpu[cpuid], M_GIC_V3);
+ return (ENODEV);
+ }
+
+ do {
+ typer = bus_read_8(&r_res, GICR_TYPER);
+ if ((typer >> GICR_TYPER_AFF_SHIFT) == aff) {
+ KASSERT(sc->gic_redists.pcpu[cpuid] != NULL,
+ ("Invalid pointer to per-CPU redistributor"));
+ /* Copy res contents to its final destination */
+ *sc->gic_redists.pcpu[cpuid] = r_res;
+ if (bootverbose) {
+ device_printf(sc->dev,
+ "CPU%u Re-Distributor has been found\n",
+ cpuid);
+ }
+ return (0);
+ }
+
+ r_bsh += (GICR_RD_BASE_SIZE + GICR_SGI_BASE_SIZE);
+ if ((typer & GICR_TYPER_VLPIS) != 0) {
+ r_bsh +=
+ (GICR_VLPI_BASE_SIZE + GICR_RESERVED_SIZE);
+ }
+
+ rman_set_bushandle(&r_res, r_bsh);
+ } while ((typer & GICR_TYPER_LAST) == 0);
+ }
+
+ free(sc->gic_redists.pcpu[cpuid], M_GIC_V3);
+ device_printf(sc->dev, "No Re-Distributor found for CPU%u\n", cpuid);
+ return (ENXIO);
+}
+
+static int
+gic_v3_redist_wake(struct gic_v3_softc *sc)
+{
+ uint32_t waker;
+ size_t us_left = 1000000;
+
+ waker = gic_r_read(sc, 4, GICR_WAKER);
+ /* Wake up Re-Distributor for this CPU */
+ waker &= ~GICR_WAKER_PS;
+ gic_r_write(sc, 4, GICR_WAKER, waker);
+ /*
+ * When clearing ProcessorSleep bit it is required to wait for
+ * ChildrenAsleep to become zero following the processor power-on.
+ */
+ while ((gic_r_read(sc, 4, GICR_WAKER) & GICR_WAKER_CA) != 0) {
+ DELAY(1);
+ if (us_left-- == 0) {
+ panic("Could not wake Re-Distributor for CPU%u",
+ PCPU_GET(cpuid));
+ }
+ }
+
+ if (bootverbose) {
+ device_printf(sc->dev, "CPU%u Re-Distributor woke up\n",
+ PCPU_GET(cpuid));
+ }
+
+ return (0);
+}
+
+static int
+gic_v3_redist_init(struct gic_v3_softc *sc)
+{
+ int err;
+ size_t i;
+
+ err = gic_v3_redist_find(sc);
+ if (err != 0)
+ return (err);
+
+ err = gic_v3_redist_wake(sc);
+ if (err != 0)
+ return (err);
+
+ /* Disable SPIs */
+ gic_r_write(sc, 4, GICR_SGI_BASE_SIZE + GICR_ICENABLER0,
+ GICR_I_ENABLER_PPI_MASK);
+ /* Enable SGIs */
+ gic_r_write(sc, 4, GICR_SGI_BASE_SIZE + GICR_ISENABLER0,
+ GICR_I_ENABLER_SGI_MASK);
+
+ /* Set priority for SGIs and PPIs */
+ for (i = 0; i <= GIC_LAST_PPI; i += GICR_I_PER_IPRIORITYn) {
+ gic_r_write(sc, 4, GICR_SGI_BASE_SIZE + GICD_IPRIORITYR(i),
+ GIC_PRIORITY_MAX);
+ }
+
+ gic_v3_wait_for_rwp(sc, REDIST);
+
+ return (0);
+}
diff --git a/sys/arm64/arm64/gic_v3_fdt.c b/sys/arm64/arm64/gic_v3_fdt.c
new file mode 100644
index 0000000..e42ac9e
--- /dev/null
+++ b/sys/arm64/arm64/gic_v3_fdt.c
@@ -0,0 +1,124 @@
+/*-
+ * Copyright (c) 2015 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Semihalf under
+ * the sponsorship of the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+
+#include <dev/fdt/fdt_common.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include "pic_if.h"
+
+#include "gic_v3_reg.h"
+#include "gic_v3_var.h"
+
+/*
+ * FDT glue.
+ */
+static int gic_v3_fdt_probe(device_t);
+static int gic_v3_fdt_attach(device_t);
+
+static device_method_t gic_v3_fdt_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, gic_v3_fdt_probe),
+ DEVMETHOD(device_attach, gic_v3_fdt_attach),
+
+ /* End */
+ DEVMETHOD_END
+};
+
+DEFINE_CLASS_1(gic_v3, gic_v3_fdt_driver, gic_v3_fdt_methods,
+ sizeof(struct gic_v3_softc), gic_v3_driver);
+
+static devclass_t gic_v3_fdt_devclass;
+
+EARLY_DRIVER_MODULE(gic_v3, simplebus, gic_v3_fdt_driver, gic_v3_fdt_devclass,
+ 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
+EARLY_DRIVER_MODULE(gic_v3, ofwbus, gic_v3_fdt_driver, gic_v3_fdt_devclass,
+ 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
+
+/*
+ * Device interface.
+ */
+static int
+gic_v3_fdt_probe(device_t dev)
+{
+
+ if (!ofw_bus_status_okay(dev))
+ return (ENXIO);
+
+ if (!ofw_bus_is_compatible(dev, "arm,gic-v3"))
+ return (ENXIO);
+
+ device_set_desc(dev, GIC_V3_DEVSTR);
+ return (BUS_PROBE_DEFAULT);
+}
+
+static int
+gic_v3_fdt_attach(device_t dev)
+{
+ struct gic_v3_softc *sc;
+ pcell_t redist_regions;
+ int err;
+
+ sc = device_get_softc(dev);
+ sc->dev = dev;
+
+ /*
+ * Recover number of the Re-Distributor regions.
+ */
+ if (OF_getencprop(ofw_bus_get_node(dev), "#redistributor-regions",
+ &redist_regions, sizeof(redist_regions)) <= 0)
+ sc->gic_redists.nregions = 1;
+ else
+ sc->gic_redists.nregions = redist_regions;
+
+ err = gic_v3_attach(dev);
+ if (err)
+ goto error;
+
+ return (err);
+
+error:
+ if (bootverbose) {
+ device_printf(dev,
+ "Failed to attach. Error %d\n", err);
+ }
+ /* Failure so free resources */
+ gic_v3_detach(dev);
+
+ return (err);
+}
diff --git a/sys/arm64/arm64/gic_v3_reg.h b/sys/arm64/arm64/gic_v3_reg.h
new file mode 100644
index 0000000..7f0b550
--- /dev/null
+++ b/sys/arm64/arm64/gic_v3_reg.h
@@ -0,0 +1,185 @@
+/*-
+ * Copyright (c) 2015 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Semihalf under
+ * the sponsorship of the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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 _GIC_V3_REG_H_
+#define _GIC_V3_REG_H_
+
+/*
+ * Maximum number of interrupts
+ * supported by GIC (including SGIs, PPIs and SPIs)
+ */
+#define GIC_I_NUM_MAX (1020)
+/*
+ * Priority MAX/MIN values
+ */
+#define GIC_PRIORITY_MAX (0x00UL)
+/* Upper value is determined by LPI max priority */
+#define GIC_PRIORITY_MIN (0xFCUL)
+
+/* Numbers for software generated interrupts */
+#define GIC_FIRST_SGI (0)
+#define GIC_LAST_SGI (15)
+/* Numbers for private peripheral interrupts */
+#define GIC_FIRST_PPI (16)
+#define GIC_LAST_PPI (31)
+/* Numbers for spared peripheral interrupts */
+#define GIC_FIRST_SPI (32)
+#define GIC_LAST_SPI (1019)
+/* Numbers for local peripheral interrupts */
+#define GIC_FIRST_LPI (8192)
+
+/*
+ * Registers (v2/v3)
+ */
+#define GICD_CTLR (0x0000)
+#define GICD_CTLR_G1 (1 << 0)
+#define GICD_CTLR_G1A (1 << 1)
+#define GICD_CTLR_ARE_NS (1 << 4)
+#define GICD_CTLR_RWP (1 << 31)
+
+#define GICD_TYPER (0x0004)
+#define GICD_TYPER_IDBITS(n) ((((n) >> 19) & 0x1F) + 1)
+#define GICD_TYPER_I_NUM(n) ((((n) & 0xF1) + 1) * 32)
+
+#define GICD_ISENABLER(n) (0x0100 + (((n) >> 5) * 4))
+#define GICD_I_PER_ISENABLERn (32)
+
+#define GICD_ICENABLER(n) (0x0180 + (((n) >> 5) * 4))
+#define GICD_IPRIORITYR(n) (0x0400 + (((n) >> 2) * 4))
+#define GICD_I_PER_IPRIORITYn (4)
+
+#define GICD_I_MASK(n) (1 << ((n) % 32))
+
+#define GICD_ICFGR(n) (0x0C00 + (((n) >> 4) * 4))
+/* First bit is a polarity bit (0 - low, 1 - high) */
+#define GICD_ICFGR_POL_LOW (0 << 0)
+#define GICD_ICFGR_POL_HIGH (1 << 0)
+#define GICD_ICFGR_POL_MASK (0x1)
+/* Second bit is a trigger bit (0 - level, 1 - edge) */
+#define GICD_ICFGR_TRIG_LVL (0 << 1)
+#define GICD_ICFGR_TRIG_EDGE (1 << 1)
+#define GICD_ICFGR_TRIG_MASK (0x2)
+
+#define GICD_I_PER_ICFGRn (16)
+
+/*
+ * Registers (v3)
+ */
+#define GICD_IROUTER(n) (0x6000 + ((n) * 8))
+#define GICD_PIDR2 (0xFFE8)
+
+#define GICR_PIDR2_ARCH_MASK (0xF0)
+#define GICR_PIDR2_ARCH_GICv3 (0x30)
+#define GICR_PIDR2_ARCH_GICv4 (0x40)
+
+/* Redistributor registers */
+#define GICR_PIDR2 GICD_PIDR2
+
+#define GICR_TYPER (0x0008)
+#define GICR_TYPER_VLPIS (1 << 1)
+#define GICR_TYPER_LAST (1 << 4)
+#define GICR_TYPER_AFF_SHIFT (32)
+
+#define GICR_WAKER (0x0014)
+#define GICR_WAKER_PS (1 << 1) /* Processor sleep */
+#define GICR_WAKER_CA (1 << 2) /* Children asleep */
+
+/* Re-distributor registers for SGIs and PPIs */
+#define GICR_RD_BASE_SIZE PAGE_SIZE_64K
+#define GICR_SGI_BASE_SIZE PAGE_SIZE_64K
+#define GICR_VLPI_BASE_SIZE PAGE_SIZE_64K
+#define GICR_RESERVED_SIZE PAGE_SIZE_64K
+
+#define GICR_ISENABLER0 (0x0100)
+#define GICR_ICENABLER0 (0x0180)
+#define GICR_I_ENABLER_SGI_MASK (0x0000FFFF)
+#define GICR_I_ENABLER_PPI_MASK (0xFFFF0000)
+
+#define GICR_I_PER_IPRIORITYn (GICD_I_PER_IPRIORITYn)
+
+/*
+ * CPU interface
+ */
+
+/*
+ * Registers list (ICC_xyz_EL1):
+ *
+ * PMR - Priority Mask Register
+ * * interrupts of priority higher than specified
+ * in this mask will be signalled to the CPU.
+ * (0xff - lowest possible prio., 0x00 - highest prio.)
+ *
+ * CTLR - Control Register
+ * * controls behavior of the CPU interface and displays
+ * implemented features.
+ *
+ * IGRPEN1 - Interrupt Group 1 Enable Register
+ *
+ * IAR1 - Interrupt Acknowledge Register Group 1
+ * * contains number of the highest priority pending
+ * interrupt from the Group 1.
+ *
+ * EOIR1 - End of Interrupt Register Group 1
+ * * Writes inform CPU interface about completed Group 1
+ * interrupts processing.
+ */
+
+#define gic_icc_write(reg, val) \
+do { \
+ WRITE_SPECIALREG(ICC_ ##reg ##_EL1, val); \
+ isb(); \
+} while (0)
+
+#define gic_icc_read(reg) \
+({ \
+ uint64_t val; \
+ \
+ val = READ_SPECIALREG(ICC_ ##reg ##_EL1); \
+ (val); \
+})
+
+#define gic_icc_set(reg, mask) \
+do { \
+ uint64_t val; \
+ val = gic_icc_read(reg); \
+ val |= (mask); \
+ gic_icc_write(reg, val); \
+} while (0)
+
+#define gic_icc_clear(reg, mask) \
+do { \
+ uint64_t val; \
+ val = gic_icc_read(reg); \
+ val &= ~(mask); \
+ gic_icc_write(reg, val); \
+} while (0)
+
+#endif /* _GIC_V3_REG_H_ */
diff --git a/sys/arm64/arm64/gic_v3_var.h b/sys/arm64/arm64/gic_v3_var.h
new file mode 100644
index 0000000..2e511b4
--- /dev/null
+++ b/sys/arm64/arm64/gic_v3_var.h
@@ -0,0 +1,106 @@
+/*-
+ * Copyright (c) 2015 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Semihalf under
+ * the sponsorship of the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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 _GIC_V3_VAR_H_
+#define _GIC_V3_VAR_H_
+
+#define GIC_V3_DEVSTR "ARM Generic Interrupt Controller v3.0"
+
+DECLARE_CLASS(gic_v3_driver);
+
+struct gic_redists {
+ /*
+ * Re-Distributor region description.
+ * We will have few of those depending
+ * on the #redistributor-regions property in FDT.
+ */
+ struct resource ** regions;
+ /* Number of Re-Distributor regions */
+ u_int nregions;
+ /* Per-CPU Re-Distributor handler */
+ struct resource * pcpu[MAXCPU];
+};
+
+struct gic_v3_softc {
+ device_t dev;
+ struct resource ** gic_res;
+ struct mtx gic_mtx;
+ /* Distributor */
+ struct resource * gic_dist;
+ /* Re-Distributors */
+ struct gic_redists gic_redists;
+
+ u_int gic_nirqs;
+ u_int gic_idbits;
+
+ boolean_t gic_registered;
+};
+
+MALLOC_DECLARE(M_GIC_V3);
+
+/* Device methods */
+int gic_v3_attach(device_t dev);
+int gic_v3_detach(device_t dev);
+
+/*
+ * GIC Distributor accessors.
+ * Notice that only GIC sofc can be passed.
+ */
+#define gic_d_read(sc, len, reg) \
+({ \
+ bus_read_##len(sc->gic_dist, reg); \
+})
+
+#define gic_d_write(sc, len, reg, val) \
+({ \
+ bus_write_##len(sc->gic_dist, reg, val);\
+})
+
+/* GIC Re-Distributor accessors (per-CPU) */
+#define gic_r_read(sc, len, reg) \
+({ \
+ u_int cpu = PCPU_GET(cpuid); \
+ \
+ bus_read_##len( \
+ sc->gic_redists.pcpu[cpu], \
+ reg); \
+})
+
+#define gic_r_write(sc, len, reg, val) \
+({ \
+ u_int cpu = PCPU_GET(cpuid); \
+ \
+ bus_write_##len( \
+ sc->gic_redists.pcpu[cpu], \
+ reg, val); \
+})
+
+#endif /* _GIC_V3_VAR_H_ */
diff --git a/sys/arm64/arm64/intr_machdep.c b/sys/arm64/arm64/intr_machdep.c
index 6f1c7bb..7ff6f11 100644
--- a/sys/arm64/arm64/intr_machdep.c
+++ b/sys/arm64/arm64/intr_machdep.c
@@ -430,6 +430,10 @@ stray:
if (intr != NULL)
PIC_MASK(root_pic, intr->i_hw_irq);
+#ifdef HWPMC_HOOKS
+ if (pmc_hook && (PCPU_GET(curthread)->td_pflags & TDP_CALLCHAIN))
+ pmc_hook(PCPU_GET(curthread), PMC_FN_USER_CALLCHAIN, tf);
+#endif
}
void
diff --git a/sys/arm64/arm64/locore.S b/sys/arm64/arm64/locore.S
index bf702fa..c9a9c83 100644
--- a/sys/arm64/arm64/locore.S
+++ b/sys/arm64/arm64/locore.S
@@ -187,6 +187,20 @@ drop_to_el1:
mov x2, #(PSR_F | PSR_I | PSR_A | PSR_D | PSR_M_EL1h)
msr spsr_el2, x2
+ /* Configure GICv3 CPU interface */
+ mrs x2, id_aa64pfr0_el1
+ /* Extract GIC bits from the register */
+ ubfx x2, x2, #ID_AA64PFR0_GIC_SHIFT, #ID_AA64PFR0_GIC_BITS
+ /* GIC[3:0] == 0001 - GIC CPU interface via special regs. supported */
+ cmp x2, #(ID_AA64PFR0_GIC_CPUIF_EN >> ID_AA64PFR0_GIC_SHIFT)
+ b.ne 2f
+
+ mrs x2, icc_sre_el2
+ orr x2, x2, #ICC_SRE_EL2_EN /* Enable access from insecure EL1 */
+ msr icc_sre_el2, x2
+ isb
+2:
+
/* Set the address to return to our return address */
msr elr_el2, x30
diff --git a/sys/arm64/arm64/nexus.c b/sys/arm64/arm64/nexus.c
index 15b18b5..d6c6d2b 100644
--- a/sys/arm64/arm64/nexus.c
+++ b/sys/arm64/arm64/nexus.c
@@ -148,6 +148,10 @@ nexus_attach(device_t dev)
if (rman_init(&mem_rman) || rman_manage_region(&mem_rman, 0, ~0))
panic("nexus_probe mem_rman");
+ /* Add the ofwbus device */
+ /* ARM64TODO: Alternatively add acpi */
+ nexus_add_child(dev, 10, "ofwbus", 0);
+
/*
* First, deal with the children we know about already
*/
@@ -208,12 +212,12 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
break;
default:
- return (0);
+ return (NULL);
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
if (rv == 0)
- return (0);
+ return (NULL);
rman_set_rid(rv, *rid);
rman_set_bushandle(rv, rman_get_start(rv));
@@ -221,7 +225,7 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
if (needactivate) {
if (bus_activate_resource(child, type, *rid, rv)) {
rman_release_resource(rv);
- return (0);
+ return (NULL);
}
}
diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index 174b023..c192fa6 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -2936,6 +2936,18 @@ pmap_clear_modify(vm_page_t m)
/* TODO: We lack support for tracking if a page is modified */
}
+void *
+pmap_mapbios(vm_paddr_t pa, vm_size_t size)
+{
+
+ return ((void *)PHYS_TO_DMAP(pa));
+}
+
+void
+pmap_unmapbios(vm_paddr_t pa, vm_size_t size)
+{
+}
+
/*
* Sets the memory attribute for the specified page.
*/
diff --git a/sys/arm64/conf/GENERIC b/sys/arm64/conf/GENERIC
index 8aca411..8e20d60 100644
--- a/sys/arm64/conf/GENERIC
+++ b/sys/arm64/conf/GENERIC
@@ -65,6 +65,9 @@ options MAC # TrustedBSD MAC Framework
options KDTRACE_FRAME # Ensure frames are compiled in
options KDTRACE_HOOKS # Kernel DTrace hooks
options VFP # Floating-point support
+options RACCT # Resource accounting framework
+options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default
+options RCTL # Resource limits
device virtio
device virtio_mmio
diff --git a/sys/arm64/include/armreg.h b/sys/arm64/include/armreg.h
index 51063bb..ab1de97 100644
--- a/sys/arm64/include/armreg.h
+++ b/sys/arm64/include/armreg.h
@@ -96,6 +96,24 @@
#define EXCP_WATCHPT_EL1 0x35 /* Watchpoint, from same EL */
#define EXCP_BRK 0x3c /* Breakpoint */
+/* ICC_CTLR_EL1 */
+#define ICC_CTLR_EL1_EOIMODE (1U << 1)
+
+/* ICC_IAR1_EL1 */
+#define ICC_IAR1_EL1_SPUR (0x03ff)
+
+/* ICC_IGRPEN0_EL1 */
+#define ICC_IGRPEN0_EL1_EN (1U << 0)
+
+/* ICC_PMR_EL1 */
+#define ICC_PMR_EL1_PRIO_MASK (0xFFUL)
+
+/* ICC_SRE_EL1 */
+#define ICC_SRE_EL1_SRE (1U << 0)
+
+/* ICC_SRE_EL2 */
+#define ICC_SRE_EL2_EN (1U << 3)
+
/* ID_AA64PFR0_EL1 */
#define ID_AA64PFR0_EL0_MASK (0xf << 0)
#define ID_AA64PFR0_EL1_MASK (0xf << 4)
@@ -105,7 +123,10 @@
#define ID_AA64PFR0_FP_IMPL (0x0 << 16) /* Floating-point implemented */
#define ID_AA64PFR0_FP_NONE (0xf << 16) /* Floating-point not implemented */
#define ID_AA64PFR0_ADV_SIMD_MASK (0xf << 20)
-#define ID_AA64PFR0_GIC_MASK (0xf << 24)
+#define ID_AA64PFR0_GIC_SHIFT (24)
+#define ID_AA64PFR0_GIC_BITS (0x4) /* Number of bits in GIC field */
+#define ID_AA64PFR0_GIC_MASK (0xf << ID_AA64PFR0_GIC_SHIFT)
+#define ID_AA64PFR0_GIC_CPUIF_EN (0x1 << ID_AA64PFR0_GIC_SHIFT)
/* MAIR_EL1 - Memory Attribute Indirection Register */
#define MAIR_ATTR_MASK(idx) (0xff << ((n)* 8))
@@ -191,4 +212,22 @@
#define DBG_MDSCR_KDE (0x1 << 13)
#define DBG_MDSCR_MDE (0x1 << 15)
+/* Perfomance Monitoring Counters */
+#define PMCR_E (1 << 0) /* Enable all counters */
+#define PMCR_P (1 << 1) /* Reset all counters */
+#define PMCR_C (1 << 2) /* Clock counter reset */
+#define PMCR_D (1 << 3) /* CNTR counts every 64 clk cycles */
+#define PMCR_X (1 << 4) /* Export to ext. monitoring (ETM) */
+#define PMCR_DP (1 << 5) /* Disable CCNT if non-invasive debug*/
+#define PMCR_LC (1 << 6) /* Long cycle count enable */
+#define PMCR_IMP_SHIFT 24 /* Implementer code */
+#define PMCR_IMP_MASK (0xff << PMCR_IMP_SHIFT)
+#define PMCR_IDCODE_SHIFT 16 /* Identification code */
+#define PMCR_IDCODE_MASK (0xff << PMCR_IDCODE_SHIFT)
+#define PMCR_IDCODE_CORTEX_A57 0x01
+#define PMCR_IDCODE_CORTEX_A72 0x02
+#define PMCR_IDCODE_CORTEX_A53 0x03
+#define PMCR_N_SHIFT 11 /* Number of counters implemented */
+#define PMCR_N_MASK (0x1f << PMCR_N_SHIFT)
+
#endif /* !_MACHINE_ARMREG_H_ */
diff --git a/sys/arm64/include/bus_dma_impl.h b/sys/arm64/include/bus_dma_impl.h
new file mode 100644
index 0000000..354290e
--- /dev/null
+++ b/sys/arm64/include/bus_dma_impl.h
@@ -0,0 +1,96 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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_BUS_DMA_IMPL_H_
+#define _MACHINE_BUS_DMA_IMPL_H_
+
+struct bus_dma_tag_common {
+ struct bus_dma_impl *impl;
+ struct bus_dma_tag_common *parent;
+ bus_size_t alignment;
+ bus_addr_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;
+ bus_dma_lock_t *lockfunc;
+ void *lockfuncarg;
+ int ref_count;
+};
+
+struct bus_dma_impl {
+ int (*tag_create)(bus_dma_tag_t parent,
+ bus_size_t alignment, bus_addr_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_lock_t *lockfunc,
+ void *lockfuncarg, bus_dma_tag_t *dmat);
+ int (*tag_destroy)(bus_dma_tag_t dmat);
+ int (*map_create)(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp);
+ int (*map_destroy)(bus_dma_tag_t dmat, bus_dmamap_t map);
+ int (*mem_alloc)(bus_dma_tag_t dmat, void** vaddr, int flags,
+ bus_dmamap_t *mapp);
+ void (*mem_free)(bus_dma_tag_t dmat, void *vaddr, bus_dmamap_t map);
+ int (*load_ma)(bus_dma_tag_t dmat, bus_dmamap_t map,
+ struct vm_page **ma, bus_size_t tlen, int ma_offs, int flags,
+ bus_dma_segment_t *segs, int *segp);
+ int (*load_phys)(bus_dma_tag_t dmat, bus_dmamap_t map,
+ vm_paddr_t buf, bus_size_t buflen, int flags,
+ bus_dma_segment_t *segs, int *segp);
+ int (*load_buffer)(bus_dma_tag_t dmat, bus_dmamap_t map,
+ void *buf, bus_size_t buflen, pmap_t pmap, int flags,
+ bus_dma_segment_t *segs, int *segp);
+ void (*map_waitok)(bus_dma_tag_t dmat, bus_dmamap_t map,
+ struct memdesc *mem, bus_dmamap_callback_t *callback,
+ void *callback_arg);
+ bus_dma_segment_t *(*map_complete)(bus_dma_tag_t dmat, bus_dmamap_t map,
+ bus_dma_segment_t *segs, int nsegs, int error);
+ void (*map_unload)(bus_dma_tag_t dmat, bus_dmamap_t map);
+ void (*map_sync)(bus_dma_tag_t dmat, bus_dmamap_t map,
+ bus_dmasync_op_t op);
+};
+
+void bus_dma_dflt_lock(void *arg, bus_dma_lock_op_t op);
+int bus_dma_run_filter(struct bus_dma_tag_common *dmat, bus_addr_t paddr);
+int common_bus_dma_tag_create(struct bus_dma_tag_common *parent,
+ bus_size_t alignment,
+ bus_addr_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_lock_t *lockfunc,
+ void *lockfuncarg, size_t sz, void **dmat);
+
+extern struct bus_dma_impl bus_dma_bounce_impl;
+
+#endif
diff --git a/sys/arm64/include/pmap.h b/sys/arm64/include/pmap.h
index e5401ef..63ae34c 100644
--- a/sys/arm64/include/pmap.h
+++ b/sys/arm64/include/pmap.h
@@ -142,7 +142,9 @@ void pmap_kremove(vm_offset_t);
void pmap_kremove_device(vm_offset_t, vm_size_t);
void *pmap_mapdev(vm_offset_t, vm_size_t);
+void *pmap_mapbios(vm_paddr_t, vm_size_t);
void pmap_unmapdev(vm_offset_t, vm_size_t);
+void pmap_unmapbios(vm_offset_t, vm_size_t);
boolean_t pmap_map_io_transient(vm_page_t *, vm_offset_t *, int, boolean_t);
void pmap_unmap_io_transient(vm_page_t *, vm_offset_t *, int, boolean_t);
diff --git a/sys/arm64/include/pmc_mdep.h b/sys/arm64/include/pmc_mdep.h
index 455f7a1..5d6f40d 100644
--- a/sys/arm64/include/pmc_mdep.h
+++ b/sys/arm64/include/pmc_mdep.h
@@ -29,6 +29,14 @@
#ifndef _MACHINE_PMC_MDEP_H_
#define _MACHINE_PMC_MDEP_H_
+#define PMC_MDEP_CLASS_INDEX_ARMV8 1
+/*
+ * On the ARMv8 platform we support the following PMCs.
+ *
+ * ARMV8 ARM Cortex-A53/57/72 processors
+ */
+#include <dev/hwpmc/hwpmc_arm64.h>
+
union pmc_md_op_pmcallocate {
uint64_t __pad[4];
};
@@ -39,12 +47,21 @@ union pmc_md_op_pmcallocate {
#ifdef _KERNEL
union pmc_md_pmc {
+ struct pmc_md_arm64_pmc pm_arm64;
};
-#define PMC_TRAPFRAME_TO_PC(TF) (0) /* Stubs */
-#define PMC_TRAPFRAME_TO_FP(TF) (0)
-#define PMC_TRAPFRAME_TO_SP(TF) (0)
+#define PMC_IN_KERNEL_STACK(S,START,END) \
+ ((S) >= (START) && (S) < (END))
+#define PMC_IN_KERNEL(va) INKERNEL((va))
+#define PMC_IN_USERSPACE(va) ((va) <= VM_MAXUSER_ADDRESS)
+#define PMC_TRAPFRAME_TO_PC(TF) ((TF)->tf_lr)
+#define PMC_TRAPFRAME_TO_FP(TF) ((TF)->tf_x[29])
+/*
+ * Prototypes
+ */
+struct pmc_mdep *pmc_arm64_initialize(void);
+void pmc_arm64_finalize(struct pmc_mdep *_md);
#endif /* _KERNEL */
#endif /* !_MACHINE_PMC_MDEP_H_ */
diff --git a/sys/boot/arm/uboot/Makefile b/sys/boot/arm/uboot/Makefile
index e0ea828..dce603a 100644
--- a/sys/boot/arm/uboot/Makefile
+++ b/sys/boot/arm/uboot/Makefile
@@ -2,7 +2,8 @@
.include <src.opts.mk>
-PROG= ubldr
+FILES= ubldr ubldr.bin
+
NEWVERSWHAT= "U-Boot loader" ${MACHINE_ARCH}
BINDIR?= /boot
INSTALLFLAGS= -b
@@ -12,7 +13,7 @@ WARNS?= 1
UBLDR_LOADADDR?= 0x1000000
# Architecture-specific loader code
-SRCS= start.S conf.c vers.c
+SRCS= start.S conf.c self_reloc.c vers.c
.if !defined(LOADER_NO_DISK_SUPPORT)
LOADER_DISK_SUPPORT?= yes
@@ -76,6 +77,8 @@ LIBUBOOT_FDT= ${.OBJDIR}/../../uboot/fdt/libuboot_fdt.a
LIBFDT= ${.OBJDIR}/../../fdt/libfdt.a
.endif
+CFLAGS+= -DNETIF_OPEN_CLOSE_ONCE
+
.if ${MK_FORTH} != "no"
# Enable BootForth
BOOT_FORTH= yes
@@ -93,9 +96,7 @@ CLEANFILES+= vers.c loader.help
CFLAGS+= -ffreestanding -msoft-float
-LDFLAGS= -nostdlib -static
-LDFLAGS+= -T ldscript.generated
-LDFLAGS+= -T ${.CURDIR}/ldscript.${MACHINE_CPUARCH}
+LDFLAGS= -nostdlib -static -T ${.CURDIR}/ldscript.${MACHINE_CPUARCH}
# Pull in common loader code
.PATH: ${.CURDIR}/../../uboot/common
@@ -116,6 +117,8 @@ NO_WERROR.clang=
DPADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} ${LIBSTAND}
LDADD= ${LIBFICL} ${LIBUBOOT} ${LIBFDT} ${LIBUBOOT_FDT} -lstand
+OBJS+= ${SRCS:N*.h:R:S/$/.o/g}
+
vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
@@ -123,17 +126,24 @@ loader.help: help.common help.uboot ${.CURDIR}/../../fdt/help.fdt
cat ${.ALLSRC} | \
awk -f ${.CURDIR}/../../common/merge_help.awk > ${.TARGET}
-${PROG}: ldscript.generated ${.CURDIR}/ldscript.${MACHINE_CPUARCH}
-
-ldscript.generated::
- rm -f ldscript.generated.tmp
- echo "UBLDR_LOADADDR = ${UBLDR_LOADADDR};" >ldscript.generated.tmp
- if diff ldscript.generated ldscript.generated.tmp > /dev/null; then \
- true; \
- else \
- rm -f ldscript.generated; \
- mv ldscript.generated.tmp ldscript.generated; \
- fi
+ldscript.abs:
+ echo "UBLDR_LOADADDR = ${UBLDR_LOADADDR};" >${.TARGET}
+
+ldscript.pie:
+ echo "UBLDR_LOADADDR = 0;" >${.TARGET}
+
+ubldr: ${OBJS} ldscript.abs ${.CURDIR}/ldscript.${MACHINE_CPUARCH} ${DPADD}
+ ${CC} ${CFLAGS} -T ldscript.abs ${LDFLAGS} \
+ -o ${.TARGET} ${OBJS} ${LDADD}
+
+ubldr.pie: ${OBJS} ldscript.pie ${.CURDIR}/ldscript.${MACHINE_CPUARCH} ${DPADD}
+ ${CC} ${CFLAGS} -T ldscript.pie ${LDFLAGS} -pie -Wl,-Bsymbolic \
+ -o ${.TARGET} ${OBJS} ${LDADD}
+
+ubldr.bin: ubldr.pie
+ ${OBJCOPY} -S -O binary ubldr.pie ${.TARGET}
+
+CLEANFILES+= ldscript.abs ldscript.pie ubldr ubldr.pie ubldr.bin
.if !defined(LOADER_ONLY)
.PATH: ${.CURDIR}/../../forth
diff --git a/sys/boot/arm/uboot/ldscript.arm b/sys/boot/arm/uboot/ldscript.arm
index b3be119..1eb10a8 100644
--- a/sys/boot/arm/uboot/ldscript.arm
+++ b/sys/boot/arm/uboot/ldscript.arm
@@ -6,6 +6,15 @@ SECTIONS
{
/* Read-only sections, merged into text segment: */
. = UBLDR_LOADADDR + SIZEOF_HEADERS;
+ .text :
+ {
+ *(.text)
+ /* .gnu.warning sections are handled specially by elf32.em. */
+ *(.gnu.warning)
+ *(.gnu.linkonce.t*)
+ } =0
+ _etext = .;
+ PROVIDE (etext = .);
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
@@ -32,15 +41,6 @@ SECTIONS
.rela.sbss : { *(.rela.sbss) }
.rela.sdata2 : { *(.rela.sdata2) }
.rela.sbss2 : { *(.rela.sbss2) }
- .text :
- {
- *(.text)
- /* .gnu.warning sections are handled specially by elf32.em. */
- *(.gnu.warning)
- *(.gnu.linkonce.t*)
- } =0
- _etext = .;
- PROVIDE (etext = .);
.init : { *(.init) } =0
.fini : { *(.fini) } =0
.rodata : { *(.rodata) *(.gnu.linkonce.r*) }
diff --git a/sys/boot/arm/uboot/start.S b/sys/boot/arm/uboot/start.S
index 6e8f117..1ef21f3 100644
--- a/sys/boot/arm/uboot/start.S
+++ b/sys/boot/arm/uboot/start.S
@@ -29,12 +29,38 @@
#include <machine/asm.h>
#include <machine/armreg.h>
+ .text
+ .extern _C_LABEL(self_reloc), _C_LABEL(main)
+ .weak _DYNAMIC
+
/*
* Entry point to the loader that U-Boot passes control to.
*/
- .text
.globl _start
_start:
+
+#ifdef _ARM_ARCH_6
+ mrc p15, 0, ip, c1, c0, 0
+ orr ip, ip, #(CPU_CONTROL_UNAL_ENABLE)
+ orr ip, ip, #(CPU_CONTROL_AFLT_ENABLE)
+ mcr p15, 0, ip, c1, c0, 0
+#endif
+ /*
+ * Do self-relocation when the weak external symbol _DYNAMIC is non-NULL.
+ * When linked as a dynamic relocatable file, the linker automatically
+ * defines _DYNAMIC with a value that is the offset of the dynamic
+ * relocation info section.
+ * Note that we're still on u-boot's stack here, but the self_reloc
+ * code uses only a couple dozen bytes of stack space.
+ */
+ adr ip, .here_off /* .here_off is a symbol whose value */
+ ldr r0, [ip] /* is its own offset in the text seg. */
+ sub r0, ip, r0 /* Get its pc-relative address and */
+ ldr r1, .dynamic_off /* subtract its value and we get */
+ teq r1, #0 /* r0 = physaddr we were loaded at. */
+ addne r1, r1, r0 /* r1 = dynamic section physaddr. */
+ blne _C_LABEL(self_reloc) /* Do reloc if _DYNAMIC is non-NULL. */
+
/* Hint where to look for the API signature */
ldr ip, =uboot_address
str sp, [ip]
@@ -44,16 +70,20 @@ _start:
str r8, [ip, #0]
str r9, [ip, #4]
-#ifdef _ARM_ARCH_6
- mrc p15, 0, r2, c1, c0, 0
- orr r2, r2, #(CPU_CONTROL_UNAL_ENABLE)
- orr r2, r2, #(CPU_CONTROL_AFLT_ENABLE)
- mcr p15, 0, r2, c1, c0, 0
-#endif
-
- /* Start loader */
+ /*
+ * Start loader. This is basically a tail-recursion call; if main()
+ * returns, it returns to u-boot (which reports the value returned r0).
+ */
b main
+ /*
+ * Data for self-relocation, in the text segment for pc-rel access.
+ */
+.here_off:
+ .word .
+.dynamic_off:
+ .word _DYNAMIC
+
/*
* syscall()
*/
diff --git a/sys/boot/common/dev_net.c b/sys/boot/common/dev_net.c
index 147a809..091ed02 100644
--- a/sys/boot/common/dev_net.c
+++ b/sys/boot/common/dev_net.c
@@ -111,6 +111,8 @@ net_init(void)
static int
net_open(struct open_file *f, ...)
{
+ char temp[FNAME_SIZE];
+ struct iodesc *d;
va_list args;
char *devname; /* Device part of file name (or NULL). */
int error = 0;
@@ -140,6 +142,10 @@ net_open(struct open_file *f, ...)
printf("net_open: netif_open() succeeded\n");
#endif
}
+ /*
+ * If network params were not set by netif_open(), try to get
+ * them via bootp, rarp, etc.
+ */
if (rootip.s_addr == 0) {
/* Get root IP address, and path, etc. */
error = net_getparams(netdev_sock);
@@ -151,6 +157,20 @@ net_open(struct open_file *f, ...)
return (error);
}
}
+ /*
+ * Set the variables required by the kernel's nfs_diskless
+ * mechanism. This is the minimum set of variables required to
+ * mount a root filesystem without needing to obtain additional
+ * info from bootp or other sources.
+ */
+ d = socktodesc(netdev_sock);
+ sprintf(temp, "%6D", d->myea, ":");
+ setenv("boot.netif.hwaddr", temp, 1);
+ setenv("boot.netif.ip", inet_ntoa(myip), 1);
+ setenv("boot.netif.netmask", intoa(netmask), 1);
+ setenv("boot.netif.gateway", inet_ntoa(gateip), 1);
+ setenv("boot.nfsroot.server", inet_ntoa(rootip), 1);
+ setenv("boot.nfsroot.path", rootpath, 1);
}
netdev_opens++;
f->f_devdata = &netdev_sock;
@@ -232,10 +252,7 @@ static int
net_getparams(int sock)
{
char buf[MAXHOSTNAMELEN];
- char temp[FNAME_SIZE];
- struct iodesc *d;
- int i;
- n_long smask;
+ n_long rootaddr, smask;
#ifdef SUPPORT_BOOTP
/*
@@ -302,21 +319,9 @@ net_getparams(int sock)
return (EIO);
}
exit:
- /*
- * If present, strip the server's address off of the rootpath
- * before passing it along. This allows us to be compatible with
- * the kernel's diskless (BOOTP_NFSROOT) booting conventions
- */
- for (i = 0; rootpath[i] != '\0' && i < FNAME_SIZE; i++)
- if (rootpath[i] == ':')
- break;
- if (i && i != FNAME_SIZE && rootpath[i] == ':') {
- rootpath[i++] = '\0';
- if (inet_addr(&rootpath[0]) != INADDR_NONE)
- rootip.s_addr = inet_addr(&rootpath[0]);
- bcopy(&rootpath[i], &temp[0], strlen(&rootpath[i])+1);
- bcopy(&temp[0], &rootpath[0], strlen(&rootpath[i])+1);
- }
+ if ((rootaddr = net_parse_rootpath()) != INADDR_NONE)
+ rootip.s_addr = rootaddr;
+
#ifdef NETIF_DEBUG
if (debug) {
printf("net_open: server addr: %s\n", inet_ntoa(rootip));
@@ -324,15 +329,6 @@ exit:
}
#endif
- d = socktodesc(sock);
- sprintf(temp, "%6D", d->myea, ":");
- setenv("boot.netif.ip", inet_ntoa(myip), 1);
- setenv("boot.netif.netmask", intoa(netmask), 1);
- setenv("boot.netif.gateway", inet_ntoa(gateip), 1);
- setenv("boot.netif.hwaddr", temp, 1);
- setenv("boot.nfsroot.server", inet_ntoa(rootip), 1);
- setenv("boot.nfsroot.path", rootpath, 1);
-
return (0);
}
@@ -354,3 +350,24 @@ net_print(int verbose)
}
printf("\n");
}
+
+/*
+ * Strip the server's address off of the rootpath if present and return it in
+ * network byte order, leaving just the pathname part in the global rootpath.
+ */
+uint32_t
+net_parse_rootpath()
+{
+ int i;
+ n_long addr = INADDR_NONE;
+
+ for (i = 0; rootpath[i] != '\0' && i < FNAME_SIZE; i++)
+ if (rootpath[i] == ':')
+ break;
+ if (i && i != FNAME_SIZE && rootpath[i] == ':') {
+ rootpath[i++] = '\0';
+ addr = inet_addr(&rootpath[0]);
+ bcopy(&rootpath[i], rootpath, strlen(&rootpath[i])+1);
+ }
+ return (addr);
+}
diff --git a/sys/boot/common/dev_net.h b/sys/boot/common/dev_net.h
index 3b3d107..995b672 100644
--- a/sys/boot/common/dev_net.h
+++ b/sys/boot/common/dev_net.h
@@ -26,5 +26,11 @@
* $FreeBSD$
*/
+#ifndef _BOOT_DEV_NET_H_
+#define _BOOT_DEV_NET_H_
+
extern struct devsw netdev;
+uint32_t net_parse_rootpath(void);
+
+#endif
diff --git a/sys/boot/common/load_elf.c b/sys/boot/common/load_elf.c
index 7b2c8e7..7db1867 100644
--- a/sys/boot/common/load_elf.c
+++ b/sys/boot/common/load_elf.c
@@ -191,10 +191,17 @@ __elfN(loadfile_raw)(char *filename, u_int64_t dest,
goto oerr;
}
/*
- * Calculate destination address based on kernel entrypoint
+ * Calculate destination address based on kernel entrypoint.
+ *
+ * For ARM, the destination address is independent of any values in the
+ * elf header (an ARM kernel can be loaded at any 2MB boundary), so we
+ * leave dest set to the value calculated by archsw.arch_loadaddr() and
+ * passed in to this function.
*/
+#ifndef __arm__
if (ehdr->e_type == ET_EXEC)
dest = (ehdr->e_entry & ~PAGE_MASK);
+#endif
if ((ehdr->e_entry & ~PAGE_MASK) == 0) {
printf("elf" __XSTRING(__ELF_WORD_SIZE) "_loadfile: not a kernel (maybe static binary?)\n");
err = EPERM;
@@ -348,22 +355,18 @@ __elfN(loadimage)(struct preloaded_file *fp, elf_file_t ef, u_int64_t off)
off = 0;
#elif defined(__arm__)
/*
- * The elf headers in some kernels specify virtual addresses in all
- * header fields. More recently, the e_entry and p_paddr fields are the
- * proper physical addresses. Even when the p_paddr fields are correct,
- * the MI code below uses the p_vaddr fields with an offset added for
- * loading (doing so is arguably wrong). To make loading work, we need
- * an offset that represents the difference between physical and virtual
- * addressing. ARM kernels are always linked at 0xCnnnnnnn. Depending
- * on the headers, the offset value passed in may be physical or virtual
- * (because it typically comes from e_entry), but we always replace
- * whatever is passed in with the va<->pa offset. On the other hand, we
- * always remove the high-order part of the entry address whether it's
- * physical or virtual, because it will be adjusted later for the actual
- * physical entry point based on where the image gets loaded.
+ * The elf headers in arm kernels specify virtual addresses in all
+ * header fields, even the ones that should be physical addresses.
+ * We assume the entry point is in the first page, and masking the page
+ * offset will leave us with the virtual address the kernel was linked
+ * at. We subtract that from the load offset, making 'off' into the
+ * value which, when added to a virtual address in an elf header,
+ * translates it to a physical address. We do the va->pa conversion on
+ * the entry point address in the header now, so that later we can
+ * launch the kernel by just jumping to that address.
*/
- off = -0xc0000000;
- ehdr->e_entry &= ~0xf0000000;
+ off -= ehdr->e_entry & ~PAGE_MASK;
+ ehdr->e_entry += off;
#ifdef ELF_VERBOSE
printf("ehdr->e_entry 0x%08x, va<->pa off %llx\n", ehdr->e_entry, off);
#endif
diff --git a/sys/boot/efi/loader/reloc.c b/sys/boot/common/self_reloc.c
index fbe2043..9864a48 100644
--- a/sys/boot/efi/loader/reloc.c
+++ b/sys/boot/common/self_reloc.c
@@ -29,7 +29,6 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <elf.h>
-#include <efi.h>
#include <bootstrap.h>
#if defined(__aarch64__)
@@ -38,11 +37,11 @@ __FBSDID("$FreeBSD$");
#define ELFW_R_TYPE ELF64_R_TYPE
#define ELF_RELA
#elif defined(__arm__) || defined(__i386__)
-#define ElfW_Rel Elf32_Rel
+#define ElfW_Rel Elf32_Rel
#define ElfW_Dyn Elf32_Dyn
#define ELFW_R_TYPE ELF32_R_TYPE
#elif defined(__amd64__)
-#define ElfW_Rel Elf64_Rel
+#define ElfW_Rel Elf64_Rel
#define ElfW_Dyn Elf64_Dyn
#define ELFW_R_TYPE ELF64_R_TYPE
#else
@@ -63,14 +62,13 @@ __FBSDID("$FreeBSD$");
#endif
/*
- * A simple relocator for EFI binaries.
+ * A simple elf relocator.
*/
-EFI_STATUS
-_reloc(unsigned long ImageBase, ElfW_Dyn *dynamic, EFI_HANDLE image_handle,
- EFI_SYSTEM_TABLE *system_table)
+void
+self_reloc(Elf_Addr baseaddr, ElfW_Dyn *dynamic)
{
- unsigned long relsz, relent;
- unsigned long *newaddr;
+ Elf_Word relsz, relent;
+ Elf_Addr *newaddr;
ElfW_Rel *rel;
ElfW_Dyn *dynp;
@@ -83,8 +81,7 @@ _reloc(unsigned long ImageBase, ElfW_Dyn *dynamic, EFI_HANDLE image_handle,
switch (dynp->d_tag) {
case DT_REL:
case DT_RELA:
- rel = (ElfW_Rel *) ((unsigned long) dynp->d_un.d_ptr +
- ImageBase);
+ rel = (ElfW_Rel *)(dynp->d_un.d_ptr + baseaddr);
break;
case DT_RELSZ:
case DT_RELASZ:
@@ -110,8 +107,8 @@ _reloc(unsigned long ImageBase, ElfW_Dyn *dynamic, EFI_HANDLE image_handle,
case RELOC_TYPE_RELATIVE:
/* Address relative to the base address. */
- newaddr = (unsigned long *)(ImageBase + rel->r_offset);
- *newaddr += ImageBase;
+ newaddr = (Elf_Addr *)(rel->r_offset + baseaddr);
+ *newaddr += baseaddr;
/* Add the addend when the ABI uses them */
#ifdef ELF_RELA
*newaddr += rel->r_addend;
@@ -123,6 +120,4 @@ _reloc(unsigned long ImageBase, ElfW_Dyn *dynamic, EFI_HANDLE image_handle,
}
rel = (ElfW_Rel *) ((caddr_t) rel + relent);
}
-
- return (EFI_SUCCESS);
}
diff --git a/sys/boot/efi/boot1/Makefile b/sys/boot/efi/boot1/Makefile
index e611063..c6a6d59 100644
--- a/sys/boot/efi/boot1/Makefile
+++ b/sys/boot/efi/boot1/Makefile
@@ -13,7 +13,7 @@ PROG= loader.sym
INTERNALPROG=
# architecture-specific loader code
-SRCS= boot1.c reloc.c start.S
+SRCS= boot1.c self_reloc.c start.S
CFLAGS+= -I.
CFLAGS+= -I${.CURDIR}/../include
@@ -33,6 +33,9 @@ FILESMODE_boot1.efi= ${BINMODE}
LDSCRIPT= ${.CURDIR}/../loader/arch/${MACHINE}/ldscript.${MACHINE}
LDFLAGS= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared
+.if ${MACHINE_CPUARCH} == "aarch64"
+CFLAGS+= -msoft-float -mgeneral-regs-only
+.endif
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
CFLAGS+= -fPIC
LDFLAGS+= -Wl,-znocombreloc
diff --git a/sys/boot/efi/libefi/Makefile b/sys/boot/efi/libefi/Makefile
index 88ca242..d248927 100644
--- a/sys/boot/efi/libefi/Makefile
+++ b/sys/boot/efi/libefi/Makefile
@@ -6,6 +6,9 @@ INTERNALLIB=
SRCS= delay.c efi_console.c efinet.c efipart.c errno.c handles.c \
libefi.c time.c
+.if ${MACHINE_CPUARCH} == "aarch64"
+CFLAGS+= -msoft-float -mgeneral-regs-only
+.endif
.if ${MACHINE_ARCH} == "amd64"
CFLAGS+= -fPIC -mno-red-zone
.endif
diff --git a/sys/boot/efi/loader/Makefile b/sys/boot/efi/loader/Makefile
index 5585f78..d11021e 100644
--- a/sys/boot/efi/loader/Makefile
+++ b/sys/boot/efi/loader/Makefile
@@ -20,7 +20,7 @@ SRCS= autoload.c \
copy.c \
devicename.c \
main.c \
- reloc.c \
+ self_reloc.c \
smbios.c \
vers.c
@@ -38,6 +38,12 @@ CFLAGS+= -I${.CURDIR}/../../..
CFLAGS+= -I${.CURDIR}/../../i386/libi386
CFLAGS+= -DNO_PCI -DEFI
+# make buildenv doesn't set DESTDIR, this means LIBSTAND
+# will be wrong when crossbuilding.
+.if exists(${.OBJDIR}/../../../../lib/libstand/libstand.a)
+LIBSTAND= ${.OBJDIR}/../../../../lib/libstand/libstand.a
+.endif
+
.if ${MK_FORTH} != "no"
BOOT_FORTH= yes
CFLAGS+= -DBOOT_FORTH
diff --git a/sys/boot/efi/loader/arch/amd64/start.S b/sys/boot/efi/loader/arch/amd64/start.S
index beaeeff..774ef4f 100644
--- a/sys/boot/efi/loader/arch/amd64/start.S
+++ b/sys/boot/efi/loader/arch/amd64/start.S
@@ -53,7 +53,7 @@ _start:
popq %rdx
pushq %rcx
pushq %rdx
- call _reloc
+ call self_reloc
popq %rdi
popq %rsi
diff --git a/sys/boot/efi/loader/arch/arm/ldscript.arm b/sys/boot/efi/loader/arch/arm/ldscript.arm
index 6404c0c..4dcf302 100644
--- a/sys/boot/efi/loader/arch/arm/ldscript.arm
+++ b/sys/boot/efi/loader/arch/arm/ldscript.arm
@@ -1,6 +1,4 @@
/* $FreeBSD$ */
-OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",
- "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SECTIONS
diff --git a/sys/boot/efi/loader/arch/arm/start.S b/sys/boot/efi/loader/arch/arm/start.S
index 4160655..443de4a 100644
--- a/sys/boot/efi/loader/arch/arm/start.S
+++ b/sys/boot/efi/loader/arch/arm/start.S
@@ -153,7 +153,7 @@ _start:
ldr r1, .Ldynamic
add r1, r1, r5
- bl _C_LABEL(_reloc)
+ bl _C_LABEL(self_reloc)
/* Zero the BSS, _reloc fixed the values for us */
ldr r0, .Lbss
diff --git a/sys/boot/efi/loader/arch/arm64/Makefile.inc b/sys/boot/efi/loader/arch/arm64/Makefile.inc
index e5064cc..82d8cef 100644
--- a/sys/boot/efi/loader/arch/arm64/Makefile.inc
+++ b/sys/boot/efi/loader/arch/arm64/Makefile.inc
@@ -7,3 +7,5 @@ SRCS+= exec.c \
.PATH: ${.CURDIR}/../../arm64/libarm64
CFLAGS+=-I${.CURDIR}/../../arm64/libarm64
SRCS+= cache.c
+
+CFLAGS+= -msoft-float -mgeneral-regs-only
diff --git a/sys/boot/efi/loader/arch/arm64/start.S b/sys/boot/efi/loader/arch/arm64/start.S
index a8002fa..cd9badb 100644
--- a/sys/boot/efi/loader/arch/arm64/start.S
+++ b/sys/boot/efi/loader/arch/arm64/start.S
@@ -156,7 +156,7 @@ _start:
adr x0, ImageBase
adr x1, _DYNAMIC
- bl _reloc
+ bl self_reloc
ldp x0, x1, [sp], #16
diff --git a/sys/boot/efi/loader/arch/i386/start.S b/sys/boot/efi/loader/arch/i386/start.S
index 2be2478..b597f41 100644
--- a/sys/boot/efi/loader/arch/i386/start.S
+++ b/sys/boot/efi/loader/arch/i386/start.S
@@ -53,9 +53,7 @@ ENTRY(_start)
addl $_DYNAMIC-0b, %ebx
pushl %ebx /* dynamic */
pushl %eax /* ImageBase */
- call _reloc
- cmpl $EFI_SUCCESS, %eax
- jne 1f
+ call self_reloc
popl %ebx /* remove ImageBase from the stack */
popl %ebx /* remove dynamic from the stack */
call efi_main
diff --git a/sys/boot/efi/loader/main.c b/sys/boot/efi/loader/main.c
index 93c6059..8044db5 100644
--- a/sys/boot/efi/loader/main.c
+++ b/sys/boot/efi/loader/main.c
@@ -59,6 +59,7 @@ EFI_GUID dxe = DXE_SERVICES_TABLE_GUID;
EFI_GUID hoblist = HOB_LIST_TABLE_GUID;
EFI_GUID memtype = MEMORY_TYPE_INFORMATION_TABLE_GUID;
EFI_GUID debugimg = DEBUG_IMAGE_INFO_TABLE_GUID;
+EFI_GUID fdtdtb = FDT_TABLE_GUID;
EFI_STATUS
main(int argc, CHAR16 *argv[])
@@ -287,6 +288,8 @@ command_configuration(int argc, char *argv[])
printf("Memory Type Information Table");
else if (!memcmp(guid, &debugimg, sizeof(EFI_GUID)))
printf("Debug Image Info Table");
+ else if (!memcmp(guid, &fdtdtb, sizeof(EFI_GUID)))
+ printf("FDT Table");
else
printf("Unknown Table (%s)", guid_to_string(guid));
printf(" at %p\n", ST->ConfigurationTable[i].VendorTable);
diff --git a/sys/boot/fdt/dts/arm/am335x-evm.dts b/sys/boot/fdt/dts/arm/am335x-evm.dts
index 30239f6..3e1c4c0 100644
--- a/sys/boot/fdt/dts/arm/am335x-evm.dts
+++ b/sys/boot/fdt/dts/arm/am335x-evm.dts
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2012 Damjan Marion <dmarion@Freebsd.org>
+ * Copyright (c) 2015 Oleksandr Tymoshenko
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,158 +26,4 @@
* $FreeBSD$
*/
-/dts-v1/;
-
-/include/ "am335x.dtsi"
-
-/ {
- model = "TMDXEVM3358";
- compatible = "ti,am335x";
-
- aliases {
- soc = &SOC;
- uart0 = &uart0;
- };
-
- memory {
- device_type = "memory";
- reg = < 0x80000000 0x10000000 >; /* 256MB RAM */
- };
-
- am335x {
- scm@44e10000 {
- /* Set of triplets < padname, muxname, padstate> */
- scm-pad-config =
- /* I2C0 */
- "I2C0_SDA", "I2C0_SDA","i2c",
- "I2C0_SCL", "I2C0_SCL","i2c",
- /* Ethernet */
- "MII1_RX_ER", "gmii1_rxerr", "input_pulldown",
- "MII1_TX_EN", "gmii1_txen", "output",
- "MII1_RX_DV", "gmii1_rxdv", "input_pulldown",
- "MII1_TXD3", "gmii1_txd3", "output",
- "MII1_TXD2", "gmii1_txd2", "output",
- "MII1_TXD1", "gmii1_txd1", "output",
- "MII1_TXD0", "gmii1_txd0", "output",
- "MII1_TX_CLK", "gmii1_txclk", "input_pulldown",
- "MII1_RX_CLK", "gmii1_rxclk", "input_pulldown",
- "MII1_RXD3", "gmii1_rxd3", "input_pulldown",
- "MII1_RXD2", "gmii1_rxd2", "input_pulldown",
- "MII1_RXD1", "gmii1_rxd1", "input_pulldown",
- "MII1_RXD0", "gmii1_rxd0", "input_pulldown",
- "MDIO", "mdio_data", "input_pullup",
- "MDC", "mdio_clk", "output_pullup",
- /* MMCSD0 */
- "MMC0_CMD", "mmc0_cmd", "input_pullup",
- "MMC0_CLK", "mmc0_clk", "input_pullup",
- "MMC0_DAT0", "mmc0_dat0", "input_pullup",
- "MMC0_DAT1", "mmc0_dat1", "input_pullup",
- "MMC0_DAT2", "mmc0_dat2", "input_pullup",
- "MMC0_DAT3", "mmc0_dat3", "input_pullup",
- /* GPIO */
- "GPMC_AD10", "gpio0_26", "input_pulldown",
- "GPMC_AD11", "gpio0_27", "input_pulldown",
- "GPMC_AD0", "gpio1_0", "input_pulldown",
- "GPMC_AD1", "gpio1_1", "input_pulldown",
- "GPMC_AD2", "gpio1_2", "input_pulldown",
- "GPMC_AD3", "gpio1_3", "input_pulldown",
- "GPMC_AD4", "gpio1_4", "input_pulldown",
- "GPMC_AD5", "gpio1_5", "input_pulldown",
- "GPMC_AD6", "gpio1_6", "input_pulldown",
- "GPMC_AD7", "gpio1_7", "input_pulldown",
- "GPMC_AD12", "gpio1_12", "input_pulldown",
- "GPMC_AD13", "gpio1_13", "input_pulldown",
- "GPMC_AD14", "gpio1_14", "input_pulldown",
- "GPMC_AD15", "gpio1_15", "input_pulldown",
- "GPMC_A0", "gpio1_16", "input_pulldown",
- "GPMC_A1", "gpio1_17", "input_pulldown",
- "GPMC_A5", "gpio1_21", "output", /* User LED 1 */
- "GPMC_A6", "gpio1_22", "output", /* User LED 2 */
- "GPMC_A7", "gpio1_23", "output", /* User LED 3 */
- "GPMC_A8", "gpio1_24", "output", /* User LED 4 */
- "GPMC_BEn1", "gpio1_28", "input_pulldown",
- "GPMC_CSn0", "gpio1_29", "input_pulldown",
- "GPMC_CSn1", "gpio1_30", "input_pulldown",
- "GPMC_CSn2", "gpio1_31", "input_pulldown",
- "MCASP0_FSR", "gpio3_19", "input_pulldown",
- "MCASP0_AHCLKX", "gpio3_21", "input_pulldown",
- /* TIMERs */
- "GPMC_ADVn_ALE", "timer4", "output",
- "GPMC_BEn0_CLE", "timer5", "output",
- "GPMC_WEn", "timer6", "output",
- "GPMC_OEn_REn", "timer7", "output",
- /* USB0 and USB1 */
- "USB0_DRVVBUS", "USB0_DRVVBUS", "output",
- "USB1_DRVVBUS", "USB1_DRVVBUS", "output",
- /* LCD */
- "GPMC_AD8", "lcd_data23", "output",
- "GPMC_AD9", "lcd_data22", "output",
- "GPMC_AD10", "lcd_data21", "output",
- "GPMC_AD11", "lcd_data20", "output",
- "GPMC_AD12", "lcd_data19", "output",
- "GPMC_AD13", "lcd_data18", "output",
- "GPMC_AD14", "lcd_data17", "output",
- "GPMC_AD15", "lcd_data16", "output",
- "GPMC_CLK", "lcd_memory_clk", "output",
- "LCD_DATA0", "lcd_data0", "output",
- "LCD_DATA1", "lcd_data1", "output",
- "LCD_DATA2", "lcd_data2", "output",
- "LCD_DATA3", "lcd_data3", "output",
- "LCD_DATA4", "lcd_data4", "output",
- "LCD_DATA5", "lcd_data5", "output",
- "LCD_DATA6", "lcd_data6", "output",
- "LCD_DATA7", "lcd_data7", "output",
- "LCD_DATA8", "lcd_data8", "output",
- "LCD_DATA9", "lcd_data9", "output",
- "LCD_DATA10", "lcd_data10", "output",
- "LCD_DATA11", "lcd_data11", "output",
- "LCD_DATA12", "lcd_data12", "output",
- "LCD_DATA13", "lcd_data13", "output",
- "LCD_DATA14", "lcd_data14", "output",
- "LCD_DATA15", "lcd_data15", "output",
- "LCD_VSYNC", "lcd_vsync", "output",
- "LCD_HSYNC", "lcd_hsync", "output",
- "LCD_PCLK", "lcd_pclk", "output",
- "LCD_AC_BIAS_EN", "lcd_ac_bias_en", "output",
- "ECAP0_IN_PWM0_OUT", "eCAP0_in_PWM0_out", "output";
-
- };
-
- lcd@4830e000 {
- panel_name = "TFC_S9700RTWV35TR_01B";
- panel_width = <800>;
- panel_height = <480>;
- panel_hfp = <39>;
- panel_hbp = <39>;
- panel_hsw = <47>;
- panel_vfp = <13>;
- panel_vbp = <29>;
- panel_vsw = <2>;
- panel_pxl_clk = <30000000>;
- panel_invert_pxl_clk = <0>;
- panel_type = <1>; /* Active or passive, compatibility */
- panel_max_bpp = <32>; /* compatibility */
- panel_min_bpp = <32>; /* compatibility */
- panel_shade = <1>; /* compatibility */
- ac_bias = <255>;
- ac_bias_intrpt = <0>;
- dma_burst_sz = <16>;
- bpp = <32>;
- fdd = <128>;
- tft_alt_mode = <0>; /* compatiblity */
- stn_565_mode = <0>; /* compatibility */
- mono_8bit_mode = <0>; /* compatibilty */
- invert_line_clock = <1>;
- invert_frm_clock = <1>;
- sync_edge = <0>;
- sync_ctrl = <1>;
- raster_order = <0>; /* compatibity */
- };
-
- };
-
- chosen {
- stdin = "uart0";
- stdout = "uart0";
- };
-};
+#include "am335x-evm.dts"
diff --git a/sys/boot/fdt/dts/arm/am335x.dtsi b/sys/boot/fdt/dts/arm/am335x.dtsi
deleted file mode 100644
index fea57e9..0000000
--- a/sys/boot/fdt/dts/arm/am335x.dtsi
+++ /dev/null
@@ -1,349 +0,0 @@
-/*-
- * Copyright (c) 2012 Damjan Marion <dmarion@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$
- */
-
-/ {
- #address-cells = <1>;
- #size-cells = <1>;
-
- interrupt-parent = <&AINTC>;
-
- SOC: am335x {
- #address-cells = <1>;
- #size-cells = <1>;
- compatible = "simple-bus";
- ranges;
- bus-frequency = <0>;
-
- AINTC: interrupt-controller@48200000 {
- compatible = "ti,aintc";
- interrupt-controller;
- #address-cells = <0>;
- #interrupt-cells = <1>;
- reg = < 0x48200000 0x1000 >;
- };
-
- pmu {
- compatible = "arm,cortex-a8-pmu";
- interrupts = <3>;
- };
-
- scm@44e10000 {
- compatible = "ti,scm";
- reg = < 0x44e10000 0x2000 >;
- };
-
- prcm@44E00000 {
- compatible = "am335x,prcm";
- #address-cells = <1>;
- #size-cells = <1>;
- reg = < 0x44E00000 0x1300 >;
- };
-
- dmtimers@44E05000 {
- compatible = "ti,am335x-dmtimer";
- #address-cells = <1>;
- #size-cells = <1>;
- reg = < 0x44E05000 0x1000
- 0x44E31000 0x1000
- 0x48040000 0x1000
- 0x48042000 0x1000
- 0x48044000 0x1000
- 0x48046000 0x1000
- 0x48048000 0x1000
- 0x4804A000 0x1000 >;
- interrupts = < 66 67 68 69 92 93 94 95 >;
- interrupt-parent = <&AINTC>;
- };
-
- rtc: rtc@44E3E000 {
- compatible = "ti,da830-rtc";
- reg = <0x44E3E000 0x1000>;
- interrupts = < 75 76 >;
- interrupt-parent = <&AINTC>;
- };
-
- adc0: adc@44E0D000 {
- compatible = "ti,adc";
- reg = <0x44E0D000 0x2000>;
- interrupts = < 16 >;
- interrupt-parent = <&AINTC>;
- };
-
- wdt1@44E35000 {
- compatible = "ti,omap3-wdt";
- reg = <0x44E35000 0x1000>;
- interrupts = <91>;
- interrupt-parent = <&AINTC>;
- };
-
- GPIO: gpio {
- #gpio-cells = <3>;
- compatible = "ti,gpio";
- gpio-controller;
- reg =< 0x44E07000 0x1000
- 0x4804C000 0x1000
- 0x481AC000 0x1000
- 0x481AE000 0x1000 >;
- interrupts = < 96 97 98 99 32 33 62 63 >;
- interrupt-parent = <&AINTC>;
- interrupt-controller;
- #interrupt-cells = <1>;
- };
-
- uart0: serial@44E09000 {
- compatible = "ti,ns16550";
- reg = <0x44E09000 0x1000>;
- reg-shift = <2>;
- interrupts = < 72 >;
- interrupt-parent = <&AINTC>;
- clock-frequency = < 48000000 >;
- uart-device-id = < 0 >;
- };
-
- uart1: serial@48022000 {
- compatible = "ti,ns16550";
- reg = <0x48022000 0x1000>;
- reg-shift = <2>;
- interrupts = < 73 >;
- interrupt-parent = <&AINTC>;
- clock-frequency = < 48000000 >;
- uart-device-id = < 1 >;
- status = "disabled";
- };
-
- uart2: serial@48024000 {
- compatible = "ti,ns16550";
- reg = <0x48024000 0x1000>;
- reg-shift = <2>;
- interrupts = < 74 >;
- interrupt-parent = <&AINTC>;
- clock-frequency = < 48000000 >;
- uart-device-id = < 2 >;
- status = "disabled";
- };
-
- uart3: serial@481a6000 {
- compatible = "ti,ns16550";
- reg = <0x481A6000 0x1000>;
- reg-shift = <2>;
- interrupts = < 44 >;
- interrupt-parent = <&AINTC>;
- clock-frequency = < 48000000 >;
- uart-device-id = < 3 >;
- status = "disabled";
- };
-
- uart4: serial@481a8000 {
- compatible = "ti,ns16550";
- reg = <0x481A8000 0x1000>;
- reg-shift = <2>;
- interrupts = < 45 >;
- interrupt-parent = <&AINTC>;
- clock-frequency = < 48000000 >;
- uart-device-id = < 4 >;
- status = "disabled";
- };
-
- uart5: serial@481aa000 {
- compatible = "ti,ns16550";
- reg = <0x481AA000 0x1000>;
- reg-shift = <2>;
- interrupts = < 46 >;
- interrupt-parent = <&AINTC>;
- clock-frequency = < 48000000 >;
- uart-device-id = < 5 >;
- status = "disabled";
- };
-
- edma3@49000000 {
- compatible = "ti,edma3";
- reg =< 0x49000000 0x100000 /* Channel Controller Regs */
- 0x49800000 0x100000 /* Transfer Controller 0 Regs */
- 0x49900000 0x100000 /* Transfer Controller 1 Regs */
- 0x49a00000 0x100000 >; /* Transfer Controller 2 Regs */
- interrupts = <12 13 14>;
- interrupt-parent = <&AINTC>;
- };
-
- mmchs0@48060000 {
- compatible = "ti,omap3-hsmmc", "ti,mmchs";
- reg =<0x48060000 0x1000 >;
- interrupts = <64>;
- interrupt-parent = <&AINTC>;
- mmchs-device-id = <0>;
- mmchs-wp-gpio-pin = <0xffffffff>;
- ti,dual-volt;
- };
-
- mmchs1@481D8000 {
- compatible = "ti,omap3-hsmmc", "ti,mmchs";
- reg =<0x481D8000 0x1000 >;
- interrupts = <28>;
- interrupt-parent = <&AINTC>;
- mmchs-device-id = <1>;
- mmchs-wp-gpio-pin = <0xffffffff>;
- status = "disabled";
- };
-
- enet0: ethernet@4A100000 {
- #address-cells = <1>;
- #size-cells = <1>;
- compatible = "ti,cpsw";
- reg = <0x4A100000 0x4000>;
- interrupts = <40 41 42 43>;
- interrupt-parent = <&AINTC>;
- phy-handle = <&phy0>;
- mdio@0 {
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "ti,cpsw-mdio";
- phy0: ethernet-phy@0 {
- reg = <0x0>;
- };
- };
- };
-
- i2c0: i2c@44e0b000 {
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "ti,i2c";
- reg =< 0x44e0b000 0x1000 >;
- interrupts = <70>;
- interrupt-parent = <&AINTC>;
- i2c-device-id = <0>;
- };
-
- i2c1: i2c@4802a000 {
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "ti,i2c";
- reg =< 0x4802a000 0x1000 >;
- interrupts = <71>;
- interrupt-parent = <&AINTC>;
- i2c-device-id = <1>;
- };
-
- i2c2: i2c@4819c000 {
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "ti,i2c";
- reg =< 0x4819c000 0x1000 >;
- interrupts = <30>;
- interrupt-parent = <&AINTC>;
- i2c-device-id = <2>;
- };
-
- pwm@48300000 {
- compatible = "ti,am335x-pwm";
- #address-cells = <1>;
- #size-cells = <1>;
- reg = < 0x48300000 0x100 /* PWMSS0 */
- 0x48300100 0x80 /* eCAP0 */
- 0x48300180 0x80 /* eQEP0 */
- 0x48300200 0x60 /* ePWM0 */
- >;
- interrupts = <86 58>; /* ePWM0INT, ePWM0_TZINT */
- interrupt-parent = <&AINTC>;
- pwm-device-id = <0>;
- };
-
- pwm@48302000 {
- compatible = "ti,am335x-pwm";
- #address-cells = <1>;
- #size-cells = <1>;
- reg = < 0x48302000 0x100 /* PWMSS1 */
- 0x48302100 0x80 /* eCAP1 */
- 0x48302180 0x80 /* eQEP1 */
- 0x48302200 0x60 /* ePWM1 */
- >;
- interrupts = <87 59>; /* ePWM1INT, ePWM1_TZINT */
- interrupt-parent = <&AINTC>;
- pwm-device-id = <1>;
- };
-
- pwm@48304000 {
- compatible = "ti,am335x-pwm";
- #address-cells = <1>;
- #size-cells = <1>;
- reg = < 0x48304000 0x100 /* PWMSS2 */
- 0x48304100 0x80 /* eCAP2 */
- 0x48304180 0x80 /* eQEP2 */
- 0x48304200 0x60 /* ePWM2 */
- >;
- interrupts = <88 60>; /* ePWM2INT, ePWM2_TZINT */
- interrupt-parent = <&AINTC>;
- pwm-device-id = <2>;
- };
-
- lcd: lcd@4830e000 {
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "ti,am335x-lcd";
- reg =< 0x4830e000 0x1000 >;
- interrupts = <36>;
- interrupt-parent = <&AINTC>;
- };
-
- usb@47400000 {
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "ti,musb-am33xx";
- reg =< 0x47400000 0x1000 /* USBSS */
- 0x47401000 0x300 /* USB0 */
- 0x47401300 0x100 /* USB0_PHY */
- 0x47401400 0x400 /* USB0_CORE */
- 0x47401800 0x300 /* USB1 */
- 0x47401B00 0x100 /* USB1_PHY */
- 0x47401C00 0x400 /* USB1_CORE */
- >;
- interrupts = <17 18 19>;
- interrupt-parent = <&AINTC>;
- /* 1 - Host Mode, 0 - Device Mode */
- modemask = <2>;
- };
-
- mbox0@480C8000 {
- compatible = "am335x,system-mbox";
- reg = < 0x480C8000 0x1000 >;
- interrupts = <77>;
- interrupt-parent = <&AINTC>;
- };
-
- spinlock0@480CA000 {
- compatible = "am335x,spinlock";
- reg = < 0x480CA000 0x1000 >;
- };
-
- pruss@4A300000 {
- compatible = "ti,pruss-v2";
- reg = <0x4A300000 0x80000>;
- interrupt-parent = <&AINTC>;
- interrupts = <20 21 22 23 24 25 26 27>;
- };
- };
-};
diff --git a/sys/boot/fdt/dts/arm/annapurna-alpine.dts b/sys/boot/fdt/dts/arm/annapurna-alpine.dts
new file mode 100644
index 0000000..100d2d0
--- /dev/null
+++ b/sys/boot/fdt/dts/arm/annapurna-alpine.dts
@@ -0,0 +1,244 @@
+/*-
+ * Copyright (c) 2013 Ruslan Bukin <br@bsdpad.com>
+ * Copyright (c) 2015 Semihalf
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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$
+ */
+
+/dts-v1/;
+
+/ {
+ model = "annapurna,alpine";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ aliases {
+ serial0 = &serial0;
+ };
+
+ cpus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ cpu@0 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a15";
+ reg = <0x0>;
+ d-cache-line-size = <64>; // 64 bytes
+ i-cache-line-size = <64>; // 64 bytes
+ d-cache-size = <0x8000>; // L1, 32K
+ i-cache-size = <0x8000>; // L1, 32K
+ timebase-frequency = <0>;
+ bus-frequency = <375000000>;
+ clock-frequency = <0>;
+ };
+
+ cpu@1 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a15";
+ reg = <0x0>;
+ d-cache-line-size = <64>; // 64 bytes
+ i-cache-line-size = <64>; // 64 bytes
+ d-cache-size = <0x8000>; // L1, 32K
+ i-cache-size = <0x8000>; // L1, 32K
+ timebase-frequency = <0>;
+ bus-frequency = <375000000>;
+ clock-frequency = <0>;
+ };
+
+ cpu@2 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a15";
+ reg = <0x0>;
+ d-cache-line-size = <64>; // 64 bytes
+ i-cache-line-size = <64>; // 64 bytes
+ d-cache-size = <0x8000>; // L1, 32K
+ i-cache-size = <0x8000>; // L1, 32K
+ timebase-frequency = <0>;
+ bus-frequency = <375000000>;
+ clock-frequency = <0>;
+ };
+
+ cpu@3 {
+ device_type = "cpu";
+ compatible = "arm,cortex-a15";
+ reg = <0x0>;
+ d-cache-line-size = <64>; // 64 bytes
+ i-cache-line-size = <64>; // 64 bytes
+ d-cache-size = <0x8000>; // L1, 32K
+ i-cache-size = <0x8000>; // L1, 32K
+ timebase-frequency = <0>;
+ bus-frequency = <375000000>;
+ clock-frequency = <0>;
+ };
+ };
+
+ memory {
+ device_type = "memory";
+ reg = <0x00100000 0x7ff00000>; // 2047MB at 1MB
+ };
+
+ soc {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "simple-bus";
+ ranges = <0x0 0xfb000000 0x03000000>;
+ bus-frequency = <0>;
+
+ MPIC: interrupt-controller {
+ compatible = "arm,gic";
+ reg = < 0x1000 0x1000 >, /* Distributor Registers */
+ < 0x2000 0x2000 >; /* CPU Interface Registers */
+ interrupt-controller;
+ #address-cells = <0>;
+ #interrupt-cells = <3>;
+
+ // In intr[2], bits[3:0] are trigger type and level flags.
+ // 1 = low-to-high edge triggered
+ // 2 = high-to-low edge triggered
+ // 4 = active high level-sensitive
+ // 8 = active low level-sensitive
+ // The hardware only supports active-high-level or rising-edge.
+
+ };
+
+ generic_timer {
+ compatible = "arm,sp804";
+ reg = <0x02890000 0x1000>;
+ interrupts = <0 9 4>;
+ interrupt-parent = <&MPIC>;
+ clock-frequency = <375000000>;
+ };
+
+ cpu_resume {
+ compatible = "annapurna-labs,al-cpu-resume";
+ reg = <0x00ff5ec0 0x30>;
+ };
+
+ nb_service {
+ compatible = "annapurna-labs,al-nb-service";
+ reg = <0x00070000 0x10000>;
+ interrupts = <0 32 4>,
+ <0 33 4>,
+ <0 34 4>,
+ <0 35 4>;
+ interrupt-parent = <&MPIC>;
+ };
+
+ wdt0 {
+ compatible = "arm,sp805", "arm,primecell";
+ reg = <0x288c000 0x1000>;
+ interrupt-parent = <&MPIC>;
+ };
+
+ serial0: serial@2883000 {
+ compatible = "ns16550";
+ reg = <0x2883000 0x20>;
+ reg-shift = <2>;
+ current-speed = <115200>;
+ clock-frequency = <375000000>;
+ interrupts = <0 17 4>;
+ interrupt-parent = <&MPIC>;
+ };
+ };
+
+ pcie-internal {
+ compatible = "annapurna-labs,al-internal-pcie";
+ device_type = "pci";
+ #size-cells = <2>;
+ #address-cells = <3>;
+ interrupt-parent = <&MPIC>;
+ interrupt-map-mask = <0xf800 0 0 7>;
+ interrupt-map = <0x3000 0 0 1 &MPIC 0 32 4>, // USB adapter
+ <0x3800 0 0 1 &MPIC 0 36 4>,
+ <0x4000 0 0 1 &MPIC 0 43 4>, // SATA 0 (PCIe expander)
+ <0x4800 0 0 1 &MPIC 0 44 1>; // SATA 1 (onboard)
+
+ // ranges:
+ // - ECAM - non prefetchable config space
+ // - 32 bit non prefetchable memory space
+ ranges = <0x00000000 0x0 0xfbc00000 0xfbc00000 0x0 0x100000
+ 0x02000000 0x0 0xfe000000 0xfe000000 0x0 0x1000000>;
+
+ bus-range = <0x00 0x00>;
+ };
+
+// WORKAROUND: enabling PCIe controller when no card is plugged in
+// leads to kernel panic because u-boot disables PCIe controller if no link
+// is detected. Just be kind and compatible with Linux
+/* // External PCIe Controller 0
+ pcie-external0 {
+ compatible = "annapurna-labs,al-external-pcie";
+ reg = <0xfd800000 0x00020000>;
+ device_type = "pci";
+ #size-cells = <2>;
+ #address-cells = <3>;
+ interrupt-parent = <&MPIC>;
+ interrupt-map-mask = <0x00 0 0 7>;
+ interrupt-map = <0x0000 0 0 1 &MPIC 0 40 4>;
+
+ // ranges:
+ // Controller 0:
+ // - ECAM - non prefetchable config space: 2MB
+ // - IO - IO port space 64KB, reserve 64KB from target memory windows
+ // real IO address on the pci bus starts at 0x10000
+ // - 32 bit non prefetchable memory space: 128MB - 64KB
+
+ ranges = <0x00000000 0x0 0xfb600000 0xfb600000 0x0 0x00200000
+ 0x01000000 0x0 0x00010000 0xe0000000 0x0 0x00010000
+ 0x02000000 0x0 0xe1000000 0xe1000000 0x0 0x06f00000>;
+
+ bus-range = <0x00 0xff>;
+ };
+
+ // External PCIe Controllers 1
+ pcie-external1 {
+ compatible = "annapurna-labs,al-external-pcie";
+ reg = <0xfd820000 0x00020000>;
+ device_type = "pci";
+ #size-cells = <2>;
+ #address-cells = <3>;
+ interrupt-parent = <&MPIC>;
+ interrupt-map-mask = <0x0 0 0 7>;
+ interrupt-map = <0x0000 0 0 1 &MPIC 0 41 4>;
+
+ // ranges:
+ // - ECAM - non prefetchable config space: 2MB
+ // - IO - IO port space 64KB, reserve 64KB from target memory windows
+ // real IO address on the pci bus starts at 0x20000
+ // - 32 bit non prefetchable memory space: 64MB - 64KB
+ ranges = <0x00000000 0x0 0xfb800000 0xfb800000 0x0 0x00200000
+ 0x01000000 0x0 0x00020000 0xe8000000 0x0 0x00010000
+ 0x02000000 0x0 0xe8100000 0xe8100000 0x0 0x02ff0000>;
+
+ bus-range = <0x00 0xff>;
+ }; */
+
+ chosen {
+ stdin = "serial0";
+ stdout = "serial0";
+ stddbg = "serial0";
+ };
+};
diff --git a/sys/boot/fdt/dts/arm/beaglebone-black.dts b/sys/boot/fdt/dts/arm/beaglebone-black.dts
index ff25f9d..f5144dd 100644
--- a/sys/boot/fdt/dts/arm/beaglebone-black.dts
+++ b/sys/boot/fdt/dts/arm/beaglebone-black.dts
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2012 Damjan Marion <dmarion@Freebsd.org>
+ * Copyright (c) 2015 Oleksandr Tymoshenko <gonzo@freebsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,159 +26,6 @@
* $FreeBSD$
*/
-/dts-v1/;
-/include/ "am335x.dtsi"
-
-/ {
- model = "beaglebone-black";
- compatible = "beaglebone-black", "beaglebone", "ti,am335x";
-
-
- aliases {
- soc = &SOC;
- uart0 = &uart0;
- };
-
- memory {
- device_type = "memory";
- reg = < 0x80000000 0x20000000 >; /* 512MB RAM */
- };
-
- am335x {
- scm@44e10000 {
- /* Set of triplets < padname, muxname, padstate> */
- scm-pad-config =
- /* I2C0 */
- "I2C0_SDA", "I2C0_SDA","i2c",
- "I2C0_SCL", "I2C0_SCL","i2c",
- /* I2C1 */
- "SPI0_D1", "I2C1_SDA", "i2c",
- "SPI0_CS0", "I2C1_SCL", "i2c",
- /* I2C2 */
- "UART1_CTSn", "I2C2_SDA", "i2c",
- "UART1_RTSn", "I2C2_SCL", "i2c",
- /* Ethernet */
- "MII1_RX_ER", "gmii1_rxerr", "input_pulldown",
- "MII1_TX_EN", "gmii1_txen", "output",
- "MII1_RX_DV", "gmii1_rxdv", "input_pulldown",
- "MII1_TXD3", "gmii1_txd3", "output",
- "MII1_TXD2", "gmii1_txd2", "output",
- "MII1_TXD1", "gmii1_txd1", "output",
- "MII1_TXD0", "gmii1_txd0", "output",
- "MII1_TX_CLK", "gmii1_txclk", "input_pulldown",
- "MII1_RX_CLK", "gmii1_rxclk", "input_pulldown",
- "MII1_RXD3", "gmii1_rxd3", "input_pulldown",
- "MII1_RXD2", "gmii1_rxd2", "input_pulldown",
- "MII1_RXD1", "gmii1_rxd1", "input_pulldown",
- "MII1_RXD0", "gmii1_rxd0", "input_pulldown",
- "MDIO", "mdio_data", "input_pullup",
- "MDC", "mdio_clk", "output_pullup",
- /* MMCSD0 */
- "MMC0_CMD", "mmc0_cmd", "input_pullup",
- "MMC0_CLK", "mmc0_clk", "input_pullup",
- "MMC0_DAT0", "mmc0_dat0", "input_pullup",
- "MMC0_DAT1", "mmc0_dat1", "input_pullup",
- "MMC0_DAT2", "mmc0_dat2", "input_pullup",
- "MMC0_DAT3", "mmc0_dat3", "input_pullup",
- /* MMC1 */
- "GPMC_CSn1", "mmc1_clk", "input_pullup",
- "GPMC_CSn2", "mmc1_cmd", "input_pullup",
- "GPMC_CSn3", "gpio2_0", "output_pullup", /* Reset */
- "GPMC_AD0", "mmc1_dat0", "input_pullup",
- "GPMC_AD1", "mmc1_dat1", "input_pullup",
- "GPMC_AD2", "mmc1_dat2", "input_pullup",
- "GPMC_AD3", "mmc1_dat3", "input_pullup",
- "GPMC_AD4", "mmc1_dat4", "input_pullup",
- "GPMC_AD5", "mmc1_dat5", "input_pullup",
- "GPMC_AD6", "mmc1_dat6", "input_pullup",
- "GPMC_AD7", "mmc1_dat7", "input_pullup",
- /* GPIO */
- "ECAP0_IN_PWM0_OUT", "gpio0_7", "input_pulldown",
- "GPMC_AD10", "gpio0_26", "input_pulldown",
- "GPMC_AD11", "gpio0_27", "input_pulldown",
- "GPMC_AD12", "gpio1_12", "input_pulldown",
- "GPMC_AD13", "gpio1_13", "input_pulldown",
- "GPMC_AD14", "gpio1_14", "input_pulldown",
- "GPMC_AD15", "gpio1_15", "input_pulldown",
- "GPMC_A0", "gpio1_16", "input_pulldown",
- "GPMC_A1", "gpio1_17", "input_pulldown",
- "GPMC_A5", "gpio1_21", "output", /* User LED 1 */
- "GPMC_A6", "gpio1_22", "output", /* User LED 2 */
- "GPMC_A7", "gpio1_23", "output", /* User LED 3 */
- "GPMC_A8", "gpio1_24", "output", /* User LED 4 */
- "GPMC_BEn1", "gpio1_28", "input_pulldown",
- "GPMC_CSn0", "gpio1_29", "input_pulldown",
- "GPMC_CLK", "gpio2_1", "input_pulldown",
- "LCD_DATA0", "gpio2_6", "input_pulldown",
- "LCD_DATA1", "gpio2_7", "input_pulldown",
- "LCD_DATA2", "gpio2_8", "input_pulldown",
- "LCD_DATA3", "gpio2_9", "input_pulldown",
- "LCD_DATA4", "gpio2_10", "input_pulldown",
- "LCD_DATA5", "gpio2_11", "input_pulldown",
- "LCD_DATA6", "gpio2_12", "input_pulldown",
- "LCD_DATA7", "gpio2_13", "input_pulldown",
- "LCD_VSYNC", "gpio2_22", "input_pulldown",
- "LCD_HSYNC", "gpio2_23", "input_pulldown",
- "LCD_PCLK", "gpio2_24", "input_pulldown",
- "LCD_AC_BIAS_EN", "gpio2_25", "input_pulldown",
- "MCASP0_FSR", "gpio3_19", "input_pulldown",
- "MCASP0_AHCLKX", "gpio3_21", "input_pulldown",
- /* TIMERs */
- "GPMC_ADVn_ALE", "timer4", "output",
- "GPMC_BEn0_CLE", "timer5", "output",
- "GPMC_WEn", "timer6", "output",
- "GPMC_OEn_REn", "timer7", "output",
- /* USB0 and USB1 */
- "USB0_DRVVBUS", "USB0_DRVVBUS", "output",
- "USB1_DRVVBUS", "USB1_DRVVBUS", "output",
- /* PWM */
- "GPMC_A2", "ehrpwm1A", "output",
- "GPMC_A3", "ehrpwm1B", "output",
- "GPMC_AD8", "ehrpwm2A", "output",
- "GPMC_AD9", "ehrpwm2B", "output";
- };
-
- mmchs1@481D8000 {
- bus-width = <8>;
- status = "okay";
- non-removable;
- };
-
- i2c@44e0b000 {
- pmic@48 {
- compatible = "ti,am335x-pmic";
- reg = <0x48>;
- };
- };
- };
-
- leds {
- compatible = "gpio-leds";
-
- led1 {
- gpios = <&GPIO 53 2 0>;
- name = "led1";
- };
-
- led2 {
- gpios = <&GPIO 54 2 0>;
- name = "led2";
- };
-
- led3 {
- gpios = <&GPIO 55 2 0>;
- name = "led3";
- };
-
- led4 {
- gpios = <&GPIO 56 2 0>;
- name = "led4";
- };
- };
-
- chosen {
- stdin = "uart0";
- stdout = "uart0";
- };
-};
+#include "am335x-boneblack.dts"
+#include "beaglebone-common.dtsi"
diff --git a/sys/boot/fdt/dts/arm/beaglebone-common.dtsi b/sys/boot/fdt/dts/arm/beaglebone-common.dtsi
new file mode 100644
index 0000000..ec69d97
--- /dev/null
+++ b/sys/boot/fdt/dts/arm/beaglebone-common.dtsi
@@ -0,0 +1,45 @@
+/*-
+ * Copyright (c) 2015 Oleksandr Tymoshenko <gonzo@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$
+ */
+
+/ {
+ ocp {
+ pruss@4A300000 {
+ compatible = "ti,pruss-v2";
+ reg = <0x4A300000 0x80000>;
+ interrupt-parent = <&intc>;
+ interrupts = <20 21 22 23 24 25 26 27>;
+ };
+
+ };
+
+};
+
+&tps {
+ interrupt-parent = <&intc>;
+ interrupts = <7>;
+};
diff --git a/sys/boot/fdt/dts/arm/beaglebone.dts b/sys/boot/fdt/dts/arm/beaglebone.dts
index 83b948f..18e849d 100644
--- a/sys/boot/fdt/dts/arm/beaglebone.dts
+++ b/sys/boot/fdt/dts/arm/beaglebone.dts
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2012 Damjan Marion <dmarion@Freebsd.org>
+ * Copyright (c) 2015 Oleksandr Tymoshenko <gonzo@freebsd.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,120 +26,5 @@
* $FreeBSD$
*/
-/dts-v1/;
-
-/include/ "am335x.dtsi"
-
-/ {
- model = "beaglebone";
- compatible = "beaglebone", "ti,am335x";
-
- aliases {
- soc = &SOC;
- uart0 = &uart0;
- };
-
- memory {
- device_type = "memory";
- reg = < 0x80000000 0x10000000 >; /* 256MB RAM */
- };
-
- am335x {
- scm@44e10000 {
- /* Set of triplets < padname, muxname, padstate> */
- scm-pad-config =
- /* I2C0 */
- "I2C0_SDA", "I2C0_SDA","i2c",
- "I2C0_SCL", "I2C0_SCL","i2c",
- /* Ethernet */
- "MII1_RX_ER", "gmii1_rxerr", "input_pulldown",
- "MII1_TX_EN", "gmii1_txen", "output",
- "MII1_RX_DV", "gmii1_rxdv", "input_pulldown",
- "MII1_TXD3", "gmii1_txd3", "output",
- "MII1_TXD2", "gmii1_txd2", "output",
- "MII1_TXD1", "gmii1_txd1", "output",
- "MII1_TXD0", "gmii1_txd0", "output",
- "MII1_TX_CLK", "gmii1_txclk", "input_pulldown",
- "MII1_RX_CLK", "gmii1_rxclk", "input_pulldown",
- "MII1_RXD3", "gmii1_rxd3", "input_pulldown",
- "MII1_RXD2", "gmii1_rxd2", "input_pulldown",
- "MII1_RXD1", "gmii1_rxd1", "input_pulldown",
- "MII1_RXD0", "gmii1_rxd0", "input_pulldown",
- "MDIO", "mdio_data", "input_pullup",
- "MDC", "mdio_clk", "output_pullup",
- /* MMCSD0 */
- "MMC0_CMD", "mmc0_cmd", "input_pullup",
- "MMC0_CLK", "mmc0_clk", "input_pullup",
- "MMC0_DAT0", "mmc0_dat0", "input_pullup",
- "MMC0_DAT1", "mmc0_dat1", "input_pullup",
- "MMC0_DAT2", "mmc0_dat2", "input_pullup",
- "MMC0_DAT3", "mmc0_dat3", "input_pullup",
- /* USB0 and USB1 */
- "USB0_DRVVBUS", "USB0_DRVVBUS", "output",
- "USB1_DRVVBUS", "USB1_DRVVBUS", "output",
- /* GPIO */
- "ECAP0_IN_PWM0_OUT", "gpio0_7", "input_pulldown",
- "GPMC_AD10", "gpio0_26", "input_pulldown",
- "GPMC_AD11", "gpio0_27", "input_pulldown",
- "GPMC_AD0", "gpio1_0", "input_pulldown",
- "GPMC_AD1", "gpio1_1", "input_pulldown",
- "GPMC_AD2", "gpio1_2", "input_pulldown",
- "GPMC_AD3", "gpio1_3", "input_pulldown",
- "GPMC_AD4", "gpio1_4", "input_pulldown",
- "GPMC_AD5", "gpio1_5", "input_pulldown",
- "GPMC_AD6", "gpio1_6", "input_pulldown",
- "GPMC_AD7", "gpio1_7", "input_pulldown",
- "GPMC_AD12", "gpio1_12", "input_pulldown",
- "GPMC_AD13", "gpio1_13", "input_pulldown",
- "GPMC_AD14", "gpio1_14", "input_pulldown",
- "GPMC_AD15", "gpio1_15", "input_pulldown",
- "GPMC_A0", "gpio1_16", "input_pulldown",
- "GPMC_A1", "gpio1_17", "input_pulldown",
- "GPMC_A5", "gpio1_21", "output", /* User LED 1 */
- "GPMC_A6", "gpio1_22", "output", /* User LED 2 */
- "GPMC_A7", "gpio1_23", "output", /* User LED 3 */
- "GPMC_A8", "gpio1_24", "output", /* User LED 4 */
- "GPMC_BEn1", "gpio1_28", "input_pulldown",
- "GPMC_CSn0", "gpio1_29", "input_pulldown",
- "GPMC_CSn1", "gpio1_30", "input_pulldown",
- "GPMC_CSn2", "gpio1_31", "input_pulldown",
- "GPMC_CLK", "gpio2_1", "input_pulldown",
- "LCD_DATA0", "gpio2_6", "input_pulldown",
- "LCD_DATA1", "gpio2_7", "input_pulldown",
- "LCD_DATA2", "gpio2_8", "input_pulldown",
- "LCD_DATA3", "gpio2_9", "input_pulldown",
- "LCD_DATA4", "gpio2_10", "input_pulldown",
- "LCD_DATA5", "gpio2_11", "input_pulldown",
- "LCD_DATA6", "gpio2_12", "input_pulldown",
- "LCD_DATA7", "gpio2_13", "input_pulldown",
- "LCD_VSYNC", "gpio2_22", "input_pulldown",
- "LCD_HSYNC", "gpio2_23", "input_pulldown",
- "LCD_PCLK", "gpio2_24", "input_pulldown",
- "LCD_AC_BIAS_EN", "gpio2_25", "input_pulldown",
- "MCASP0_FSR", "gpio3_19", "input_pulldown",
- "MCASP0_AHCLKX", "gpio3_21", "input_pulldown",
- /* TIMERs */
- "GPMC_ADVn_ALE", "timer4", "output",
- "GPMC_BEn0_CLE", "timer5", "output",
- "GPMC_WEn", "timer6", "output",
- "GPMC_OEn_REn", "timer7", "output",
- /* PWM */
- "GPMC_A2", "ehrpwm1A", "output",
- "GPMC_A3", "ehrpwm1B", "output",
- "GPMC_AD8", "ehrpwm2A", "output",
- "GPMC_AD9", "ehrpwm2B", "output";
- };
-
- i2c@44e0b000 {
- pmic@24 {
- compatible = "ti,am335x-pmic";
- reg = <0x48>;
- };
- };
- };
-
- chosen {
- stdin = "uart0";
- stdout = "uart0";
- };
-};
+#include "am335x-bone.dts"
+#include "beaglebone-common.dtsi"
diff --git a/sys/boot/fdt/dts/arm/cubieboard.dts b/sys/boot/fdt/dts/arm/cubieboard.dts
index 636b5ce..d9a7c15 100644
--- a/sys/boot/fdt/dts/arm/cubieboard.dts
+++ b/sys/boot/fdt/dts/arm/cubieboard.dts
@@ -57,6 +57,10 @@
status = "okay";
};
+ mmc0: mmc@01c0f000 {
+ status = "okay";
+ };
+
emac@01c0b000 {
status = "okay";
};
diff --git a/sys/boot/fdt/dts/arm/cubieboard2.dts b/sys/boot/fdt/dts/arm/cubieboard2.dts
index ce0081e..9593b91 100644
--- a/sys/boot/fdt/dts/arm/cubieboard2.dts
+++ b/sys/boot/fdt/dts/arm/cubieboard2.dts
@@ -57,6 +57,10 @@
status = "okay";
};
+ mmc0: mmc@01c0f000 {
+ status = "okay";
+ };
+
emac@01c0b000 {
status = "okay";
};
diff --git a/sys/boot/fdt/dts/arm/odroidc1.dts b/sys/boot/fdt/dts/arm/odroidc1.dts
index c65344b..aadaef3 100644
--- a/sys/boot/fdt/dts/arm/odroidc1.dts
+++ b/sys/boot/fdt/dts/arm/odroidc1.dts
@@ -194,11 +194,6 @@
compatible = "amlogic,aml8726-rtc";
reg = <0xc8100740 20>; /* aobus 0x1d0 */
interrupts = <0 72 1>;
- interrupt-parent = <&gic>;
-
- init-always = "false";
- xo-init = <0x180a>;
- gpo-init = <0x500000>;
};
clkmsr: clkmsr@c1108758 {
@@ -246,7 +241,6 @@
compatible = "amlogic,aml8726-mmc";
reg = <0xc1108c20 32>; /* cbus 0x2308 */
interrupts = <0 28 1>;
- interrupt-parent = <&gic>;
clocks = <&clk81>;
@@ -274,7 +268,6 @@
clock-frequency = <1275000000>;
reg = <0xc1108e00 60>; /* cbus 0x2380 */
interrupts = <0 78 1>;
- interrupt-parent = <&gic>;
pinctrl-names = "default";
pinctrl-0 = <&pins_sdxc_c>;
@@ -311,7 +304,6 @@
compatible = "synopsys,designware-hs-otg2";
reg = <0xc9040000 0x40000>; /* ahbbus 0x40000*/
interrupts = <0 30 4>;
- interrupt-parent = <&gic>;
#address-cells = <1>;
#size-cells = <0>;
@@ -323,7 +315,6 @@
compatible = "synopsys,designware-hs-otg2";
reg = <0xc90c0000 0x40000>; /* ahbbus 0xc0000 */
interrupts = <0 31 4>;
- interrupt-parent = <&gic>;
#address-cells = <1>;
#size-cells = <0>;
@@ -335,7 +326,6 @@
compatible = "snps,dwmac";
reg = <0xc9410000 0x2000>; /* ahbbus 0x410000 */
interrupts = <0 8 1>;
- interrupt-parent = <&gic>;
#address-cells = <1>;
#size-cells = <0>;
@@ -352,7 +342,6 @@
<0 3 1>,
<0 12 1>,
<0 13 1>;
- interrupt-parent = <&gic>;
address = <0x7900000>; /* match memreserve */
width = <720>;
diff --git a/sys/boot/fdt/dts/arm/pandaboard-common.dtsi b/sys/boot/fdt/dts/arm/pandaboard-common.dtsi
new file mode 100644
index 0000000..911c4526
--- /dev/null
+++ b/sys/boot/fdt/dts/arm/pandaboard-common.dtsi
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 2015 Oleksandr Tymoshenko <gonzo@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$
+ */
+
+&mmc1 {
+ non-removable; /* XXX need real solution */
+};
+
+&mmc5 {
+ status = "disabled";
+};
+
+/ {
+ ocp {
+ global-timer@48240600 {
+ compatible = "arm,cortex-a9-global-timer";
+ reg = <0x48240200 0x20>;
+ interrupts = <GIC_PPI 11 (GIC_CPU_MASK_RAW(3) | IRQ_TYPE_LEVEL_HIGH)>;
+ };
+ };
+ chosen {
+ stdin = "serial2";
+ stdout = "serial2";
+ };
+};
diff --git a/sys/boot/fdt/dts/arm/pandaboard-es.dts b/sys/boot/fdt/dts/arm/pandaboard-es.dts
new file mode 100644
index 0000000..6c3f4b5
--- /dev/null
+++ b/sys/boot/fdt/dts/arm/pandaboard-es.dts
@@ -0,0 +1,31 @@
+/*-
+ * Copyright (c) 2015 Oleksandr Tymoshenko <gonzo@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 "omap4-panda-es.dts"
+#include "pandaboard-common.dtsi"
diff --git a/sys/boot/fdt/dts/arm/pandaboard.dts b/sys/boot/fdt/dts/arm/pandaboard.dts
index c89bf88..b25ca63 100644
--- a/sys/boot/fdt/dts/arm/pandaboard.dts
+++ b/sys/boot/fdt/dts/arm/pandaboard.dts
@@ -1,9 +1,7 @@
/*-
- * Copyright (c) 2011 The FreeBSD Foundation
+ * Copyright (c) 2015 Oleksandr Tymoshenko <gonzo@freebsd.org>
* All rights reserved.
*
- * Developed by Damjan Marion <damjan.marion@gmail.com>
- *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -28,159 +26,6 @@
* $FreeBSD$
*/
-/dts-v1/;
-
-/ {
- model = "pandaboard";
- compatible = "pandaboard", "ti,omap4430";
- #address-cells = <1>;
- #size-cells = <1>;
-
- interrupt-parent = <&GIC>;
-
- aliases {
- soc = &SOC;
- uart3 = &uart3;
- };
-
- memory {
- device_type = "memory";
- reg = < 0x80000000 0x40000000 >; /* 1GB RAM at 0x0 */
- };
-
- SOC: omap4430 {
- #address-cells = <1>;
- #size-cells = <1>;
- compatible = "simple-bus";
- ranges;
- bus-frequency = <0>;
-
- GIC: interrupt-controller@48241000 {
- compatible = "arm,gic";
- interrupt-controller;
- #address-cells = <0>;
- #interrupt-cells = <1>;
- reg = < 0x48241000 0x1000 >, /* Distributor Registers */
- < 0x48240100 0x0100 >; /* CPU Interface Registers */
- };
-
- omap4_prcm@4a306000 {
- compatible = "ti,omap4_prcm";
- reg =< 0x4a306000 0x2000
- 0x4a004000 0x1000
- 0x4a008000 0x8000>;
- };
-
- pl310@48242000 {
- compatible = "arm,pl310";
- reg = < 0x48242000 0x1000 >;
- interrupts = < 32 >;
- interrupt-parent = < &GIC >;
- };
- mp_tmr@48240200 {
- compatible = "arm,mpcore-timers";
- #address-cells = <1>;
- #size-cells = <0>;
- reg = < 0x48240200 0x100 >, /* Global Timer Registers */
- < 0x48240600 0x100 >; /* Private Timer Registers */
- interrupts = < 27 29 >;
- interrupt-parent = < &GIC >;
- };
-
- uart3: serial@48020000 {
- compatible = "ns16550";
- reg = <0x48020000 0x1000>;
- reg-shift = <2>;
- interrupts = < 106 >;
- interrupt-parent = <&GIC>;
- clock-frequency = < 48000000 >; /* 48Mhz clock for all uarts */
- /* (techref 17.3.1.1) */
- };
-
- scm@4a100000 {
- compatible = "ti,scm";
- reg = < 0x4a100000 0x1000 >;
- /* Set of triplets < padname, muxname, padstate> */
- scm-pad-config =
- "ag19", "usbb1_ulpiphy_stp", "output",
- "ae18", "usbb1_ulpiphy_clk", "input_pulldown",
- "af19", "usbb1_ulpiphy_dir", "input_pulldown",
- "ae19", "usbb1_ulpiphy_nxt", "input_pulldown",
- "af18", "usbb1_ulpiphy_dat0", "input_pulldown",
- "ag18", "usbb1_ulpiphy_dat1", "input_pulldown",
- "ae17", "usbb1_ulpiphy_dat2", "input_pulldown",
- "af17", "usbb1_ulpiphy_dat3", "input_pulldown",
- "ah17", "usbb1_ulpiphy_dat4", "input_pulldown",
- "ae16", "usbb1_ulpiphy_dat5", "input_pulldown",
- "af16", "usbb1_ulpiphy_dat6", "input_pulldown",
- "ag16", "usbb1_ulpiphy_dat7", "input_pulldown";
- };
-
- GPIO: gpio {
- #gpio-cells = <3>;
- compatible = "ti,gpio";
- gpio-controller;
- reg =< 0x4a310000 0x1000
- 0x48055000 0x1000
- 0x48057000 0x1000
- 0x48059000 0x1000
- 0x4805b000 0x1000
- 0x4805d000 0x1000>;
- interrupts = <61 62 63 64 65 66>;
- interrupt-parent = <&GIC>;
- };
-
- ehci {
- compatible = "ti,usb-ehci", "usb-ehci";
- /*
- * USB port PHY configuration is a tuple: <mode, reset, gpio_pin>
- * mode is one of the following values:
- * 0 - unknown
- * 1 - PHY
- * 2 - TLL
- * 3 - HSIC
- *
- * reset indicates (if non-zero) if port reset is required
- * gpio_pin - GPIO pin that is used to perform reset
- */
- phy-config = < 1 0 0
- 0 0 0
- 0 0 0>;
- reg = < 0x4a064c00 0x100 /* EHCI regs */
- 0x4a064000 0x700 /* UHH regs */
- 0x4a062000 0x1000>; /* TLL regs */
- interrupts = <109>;
- interrupt-parent = <&GIC>;
- };
-
- I2C1: i2c@x48070000 {
- compatible = "ti,i2c";
- reg =< 0x48070000 0x100 >;
- interrupts = <88>;
- interrupt-parent = <&GIC>;
- i2c-device-id = <1>;
- };
-
- sdma@x48070000 {
- compatible = "ti,sdma";
- reg =< 0x4A056000 0x1000 >;
- interrupts = <44 45 46 47>;
- interrupt-parent = <&GIC>;
- };
-
- mmc@x4809C000 {
- compatible = "ti,mmchs";
- reg =<0x4809C000 0x1000 >;
- interrupts = <115>;
- interrupt-parent = <&GIC>;
- mmchs-device-id = <1>;
- non-removable; /* XXX need real solution */
- };
-
- };
- chosen {
- stdin = "uart3";
- stdout = "uart3";
- };
-};
+#include "omap4-panda.dts"
+#include "pandaboard-common.dtsi"
diff --git a/sys/boot/fdt/dts/arm/rpi2.dts b/sys/boot/fdt/dts/arm/rpi2.dts
index 1c8c559..e32cfb0 100644
--- a/sys/boot/fdt/dts/arm/rpi2.dts
+++ b/sys/boot/fdt/dts/arm/rpi2.dts
@@ -43,6 +43,24 @@
reg = <0xf00>; /* CPU ID=0xf00 */
clock-frequency = <800000000>; /* 800MHz */
};
+ cpu@1 {
+ compatible = "arm,cortex-a7";
+ device_type = "cpu";
+ reg = <0xf01>; /* CPU ID=0xf01 */
+ clock-frequency = <800000000>; /* 800MHz */
+ };
+ cpu@2 {
+ compatible = "arm,cortex-a7";
+ device_type = "cpu";
+ reg = <0xf02>; /* CPU ID=0xf02 */
+ clock-frequency = <800000000>; /* 800MHz */
+ };
+ cpu@3 {
+ compatible = "arm,cortex-a7";
+ device_type = "cpu";
+ reg = <0xf03>; /* CPU ID=0xf03 */
+ clock-frequency = <800000000>; /* 800MHz */
+ };
};
memory {
diff --git a/sys/boot/fdt/dts/arm/sun4i-a10.dtsi b/sys/boot/fdt/dts/arm/sun4i-a10.dtsi
index 09eebaa..087e314 100644
--- a/sys/boot/fdt/dts/arm/sun4i-a10.dtsi
+++ b/sys/boot/fdt/dts/arm/sun4i-a10.dtsi
@@ -103,6 +103,14 @@
interrupt-parent = <&AINTC>;
};
+ mmc0: mmc@01c0f000 {
+ compatible = "allwinner,sun4i-a10-mmc";
+ reg = <0x01c0f000 0x1000>;
+ interrupts = <32>;
+ interrupt-parent = <&AINTC>;
+ status = "disabled";
+ };
+
sata@01c18000 {
compatible = "allwinner,sun4i-ahci";
reg = <0x01c18000 0x1000>;
diff --git a/sys/boot/fdt/dts/arm/sun7i-a20.dtsi b/sys/boot/fdt/dts/arm/sun7i-a20.dtsi
index ab4ef1e..7dd8947 100644
--- a/sys/boot/fdt/dts/arm/sun7i-a20.dtsi
+++ b/sys/boot/fdt/dts/arm/sun7i-a20.dtsi
@@ -109,6 +109,14 @@
interrupt-parent = <&GIC>;
};
+ mmc0: mmc@01c0f000 {
+ compatible = "allwinner,sun4i-a10-mmc";
+ reg = <0x01c0f000 0x1000>;
+ interrupts = <32>;
+ interrupt-parent = <&GIC>;
+ status = "disabled";
+ };
+
sata@01c18000 {
compatible = "allwinner,sun4i-a10-ahci";
reg = <0x01c18000 0x1000>;
diff --git a/sys/boot/fdt/dts/arm/vsatv102-m6.dts b/sys/boot/fdt/dts/arm/vsatv102-m6.dts
index ad3b5a1..786f80a 100644
--- a/sys/boot/fdt/dts/arm/vsatv102-m6.dts
+++ b/sys/boot/fdt/dts/arm/vsatv102-m6.dts
@@ -153,11 +153,6 @@
compatible = "amlogic,aml8726-rtc";
reg = <0xda004340 20>; /* secbus2 0xd0 */
interrupts = <0 72 1>; /* AM_IRQ2(8) */
- interrupt-parent = <&gic>;
-
- init-always = "false";
- xo-init = <0x180a>;
- gpo-init = <0x500000>;
};
clkmsr: clkmsr@c1108758 {
@@ -205,7 +200,6 @@
compatible = "amlogic,aml8726-mmc";
reg = <0xc1108c20 32>; /* cbus 0x2308 */
interrupts = <0 28 1>; /* AM_IRQ0(28) */
- interrupt-parent = <&gic>;
clocks = <&clk81>;
@@ -243,7 +237,6 @@
compatible = "synopsys,designware-hs-otg2";
reg = <0xc9040000 0x40000>; /* ahbbus 0x40000*/
interrupts = <0 30 4>; /* AM_IRQ0(30) */
- interrupt-parent = <&gic>;
#address-cells = <1>;
#size-cells = <0>;
};
@@ -253,7 +246,6 @@
compatible = "synopsys,designware-hs-otg2";
reg = <0xc90c0000 0x40000>; /* ahbbus 0xc0000 */
interrupts = <0 31 4>; /* AM_IRQ0(31) */
- interrupt-parent = <&gic>;
#address-cells = <1>;
#size-cells = <0>;
@@ -265,7 +257,6 @@
compatible = "snps,dwmac";
reg = <0xc9410000 0x2000>; /* ahbbus 0x410000 */
interrupts = <0 8 1>; /* AM_IRQ0(8) */
- interrupt-parent = <&gic>;
#address-cells = <1>;
#size-cells = <0>;
@@ -282,7 +273,6 @@
<0 3 1>, /* AM_IRQ0(3) */
<0 12 1>, /* AM_IRQ0(12) */
<0 13 1>; /* AM_IRQ0(13) */
- interrupt-parent = <&gic>;
address = <0x84900000>; /* match memreserve */
width = <720>;
diff --git a/sys/boot/forth/loader.conf b/sys/boot/forth/loader.conf
index 275a58b..240e403 100644
--- a/sys/boot/forth/loader.conf
+++ b/sys/boot/forth/loader.conf
@@ -48,6 +48,16 @@ entropy_cache_type="/boot/entropy"
#kern.random.sys.seeded="0" # Set this to 1 to start /dev/random
# without waiting for a (re)seed.
+##############################################################
+### RAM Blacklist configuration #############################
+##############################################################
+
+ram_blacklist_load="NO" # Set this to YES to load a file
+ # containing a list of addresses to
+ # exclude from the running system.
+ram_blacklist_name="/boot/blacklist.txt" # Set this to the name of the file
+ram_blacklist_type="ram_blacklist" # Required for the kernel to find
+ # the blacklist module
##############################################################
### Loader settings ########################################
diff --git a/sys/boot/i386/boot0/boot0.S b/sys/boot/i386/boot0/boot0.S
index 798ee97..708f093 100644
--- a/sys/boot/i386/boot0/boot0.S
+++ b/sys/boot/i386/boot0/boot0.S
@@ -541,11 +541,11 @@ putchr:
int $0x10 # character
popw %bx # Restore
#else /* SIO */
- movb $0x01,%ah # BIOS: Send
+ movb $0x01,%ah # BIOS: Send character
bioscom:
pushw %dx # Save
xorw %dx,%dx # Use COM1
- int $0x14 # Character
+ int $0x14 # BIOS: Serial I/O
popw %dx # Restore
#endif /* SIO */
retw # To caller
diff --git a/sys/boot/sparc64/loader/main.c b/sys/boot/sparc64/loader/main.c
index 44c4d21..ae1e559 100644
--- a/sys/boot/sparc64/loader/main.c
+++ b/sys/boot/sparc64/loader/main.c
@@ -101,7 +101,7 @@ static inline u_long itlb_get_data_sun4u(u_int, u_int);
static int itlb_enter_sun4u(u_int, u_long data, vm_offset_t);
static vm_offset_t itlb_va_to_pa_sun4u(vm_offset_t);
static void itlb_relocate_locked0_sun4u(void);
-extern vm_offset_t md_load(char *, vm_offset_t *);
+extern vm_offset_t md_load(char *, vm_offset_t *, vm_offset_t *);
static int sparc64_autoload(void);
static ssize_t sparc64_readin(const int, vm_offset_t, const size_t);
static ssize_t sparc64_copyin(const void *, vm_offset_t, size_t);
@@ -340,7 +340,7 @@ static int
__elfN(exec)(struct preloaded_file *fp)
{
struct file_metadata *fmp;
- vm_offset_t mdp;
+ vm_offset_t mdp, dtbp;
Elf_Addr entry;
Elf_Ehdr *e;
int error;
@@ -349,7 +349,7 @@ __elfN(exec)(struct preloaded_file *fp)
return (EFTYPE);
e = (Elf_Ehdr *)&fmp->md_data;
- if ((error = md_load(fp->f_args, &mdp)) != 0)
+ if ((error = md_load(fp->f_args, &mdp, &dtbp)) != 0)
return (error);
printf("jumping to kernel entry at %#lx.\n", e->e_entry);
diff --git a/sys/boot/uboot/common/main.c b/sys/boot/uboot/common/main.c
index f58d0c4..0c9853c 100644
--- a/sys/boot/uboot/common/main.c
+++ b/sys/boot/uboot/common/main.c
@@ -28,6 +28,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <sys/param.h>
#include <stand.h>
@@ -44,6 +45,9 @@ struct uboot_devdesc currdev;
struct arch_switch archsw; /* MI/MD interface boundary */
int devs_no;
+uintptr_t uboot_heap_start;
+uintptr_t uboot_heap_end;
+
struct device_type {
const char *name;
int type;
@@ -414,7 +418,9 @@ main(void)
* Initialise the heap as early as possible. Once this is done,
* alloc() is usable. The stack is buried inside us, so this is safe.
*/
- setheap((void *)end, (void *)(end + 512 * 1024));
+ uboot_heap_start = round_page((uintptr_t)end);
+ uboot_heap_end = uboot_heap_start + 512 * 1024;
+ setheap((void *)uboot_heap_start, (void *)uboot_heap_end);
/*
* Set up console.
@@ -487,6 +493,7 @@ main(void)
setenv("LINES", "24", 1); /* optional */
setenv("prompt", "loader>", 1);
+ archsw.arch_loadaddr = uboot_loadaddr;
archsw.arch_getdev = uboot_getdev;
archsw.arch_copyin = uboot_copyin;
archsw.arch_copyout = uboot_copyout;
diff --git a/sys/boot/uboot/lib/copy.c b/sys/boot/uboot/lib/copy.c
index 3adf7eb..bb658e3 100644
--- a/sys/boot/uboot/lib/copy.c
+++ b/sys/boot/uboot/lib/copy.c
@@ -27,66 +27,131 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <sys/param.h>
#include <stand.h>
#include <stdint.h>
#include "api_public.h"
#include "glue.h"
+#include "libuboot.h"
/*
* MD primitives supporting placement of module data
*/
-void *
-uboot_vm_translate(vm_offset_t o) {
+#ifdef __arm__
+#define KERN_ALIGN (2 * 1024 * 1024)
+#else
+#define KERN_ALIGN PAGE_SIZE
+#endif
+
+/*
+ * Avoid low memory, u-boot puts things like args and dtb blobs there.
+ */
+#define KERN_MINADDR max(KERN_ALIGN, (1024 * 1024))
+
+extern void _start(void); /* ubldr entry point address. */
+
+/*
+ * This is called for every object loaded (kernel, module, dtb file, etc). The
+ * expected return value is the next address at or after the given addr which is
+ * appropriate for loading the given object described by type and data. On each
+ * call the addr is the next address following the previously loaded object.
+ *
+ * The first call is for loading the kernel, and the addr argument will be zero,
+ * and we search for a big block of ram to load the kernel and modules.
+ *
+ * On subsequent calls the addr will be non-zero, and we just round it up so
+ * that each object begins on a page boundary.
+ */
+uint64_t
+uboot_loadaddr(u_int type, void *data, uint64_t addr)
+{
struct sys_info *si;
- static uintptr_t start = 0;
- static size_t size = 0;
+ uintptr_t sblock, eblock, subldr, eubldr;
+ uintptr_t biggest_block, this_block;
+ size_t biggest_size, this_size;
int i;
+ char * envstr;
+
+ if (addr == 0) {
+ /*
+ * If the loader_kernaddr environment variable is set, blindly
+ * honor it. It had better be right. We force interpretation
+ * of the value in base-16 regardless of any leading 0x prefix,
+ * because that's the U-Boot convention.
+ */
+ envstr = ub_env_get("loader_kernaddr");
+ if (envstr != NULL)
+ return (strtoul(envstr, NULL, 16));
- if (size == 0) {
+ /*
+ * Find addr/size of largest DRAM block. Carve our own address
+ * range out of the block, because loading the kernel over the
+ * top ourself is a poor memory-conservation strategy. Avoid
+ * memory at beginning of the first block of physical ram,
+ * since u-boot likes to pass args and data there. Assume that
+ * u-boot has moved itself to the very top of ram and
+ * optimistically assume that we won't run into it up there.
+ */
if ((si = ub_get_sys_info()) == NULL)
panic("could not retrieve system info");
- /* Find start/size of largest DRAM block. */
+ biggest_block = 0;
+ biggest_size = 0;
+ subldr = rounddown2((uintptr_t)_start, KERN_ALIGN);
+ eubldr = roundup2(uboot_heap_end, KERN_ALIGN);
for (i = 0; i < si->mr_no; i++) {
- if (si->mr[i].flags == MR_ATTR_DRAM
- && si->mr[i].size > size) {
- start = si->mr[i].start;
- size = si->mr[i].size;
+ if (si->mr[i].flags != MR_ATTR_DRAM)
+ continue;
+ sblock = roundup2(si->mr[i].start, KERN_ALIGN);
+ eblock = rounddown2(si->mr[i].start + si->mr[i].size,
+ KERN_ALIGN);
+ if (biggest_size == 0)
+ sblock += KERN_MINADDR;
+ if (subldr >= sblock && subldr < eblock) {
+ if (subldr - sblock > eblock - eubldr) {
+ this_block = sblock;
+ this_size = subldr - sblock;
+ } else {
+ this_block = eubldr;
+ this_size = eblock - eubldr;
+ }
+ }
+ if (biggest_size < this_size) {
+ biggest_block = this_block;
+ biggest_size = this_size;
}
}
-
- if (size <= 0)
- panic("No suitable DRAM?\n");
- /*
- printf("Loading into memory region 0x%08X-0x%08X (%d MiB)\n",
- start, start + size, size / 1024 / 1024);
- */
+ if (biggest_size == 0)
+ panic("Not enough DRAM to load kernel\n");
+#if 0
+ printf("Loading kernel into region 0x%08x-0x%08x (%u MiB)\n",
+ biggest_block, biggest_block + biggest_size - 1,
+ biggest_size / 1024 / 1024);
+#endif
+ return (biggest_block);
}
- if (o > size)
- panic("Address offset 0x%08jX bigger than size 0x%08X\n",
- (intmax_t)o, size);
- return (void *)(start + o);
+ return roundup2(addr, PAGE_SIZE);
}
ssize_t
uboot_copyin(const void *src, vm_offset_t dest, const size_t len)
{
- bcopy(src, uboot_vm_translate(dest), len);
+ bcopy(src, (void *)dest, len);
return (len);
}
ssize_t
uboot_copyout(const vm_offset_t src, void *dest, const size_t len)
{
- bcopy(uboot_vm_translate(src), dest, len);
+ bcopy((void *)src, dest, len);
return (len);
}
ssize_t
uboot_readin(const int fd, vm_offset_t dest, const size_t len)
{
- return (read(fd, uboot_vm_translate(dest), len));
+ return (read(fd, (void *)dest, len));
}
diff --git a/sys/boot/uboot/lib/elf_freebsd.c b/sys/boot/uboot/lib/elf_freebsd.c
index 6b828d3..b72d07c 100644
--- a/sys/boot/uboot/lib/elf_freebsd.c
+++ b/sys/boot/uboot/lib/elf_freebsd.c
@@ -80,7 +80,7 @@ __elfN(uboot_exec)(struct preloaded_file *fp)
if ((error = md_load(fp->f_args, &mdp)) != 0)
return (error);
- entry = uboot_vm_translate(e->e_entry);
+ entry = (void *)e->e_entry;
printf("Kernel entry at 0x%x...\n", (unsigned)entry);
dev_cleanup();
diff --git a/sys/boot/uboot/lib/libuboot.h b/sys/boot/uboot/lib/libuboot.h
index 79005f2..e4201d8 100644
--- a/sys/boot/uboot/lib/libuboot.h
+++ b/sys/boot/uboot/lib/libuboot.h
@@ -57,7 +57,10 @@ extern int devs_no;
extern struct netif_driver uboot_net;
extern struct devsw uboot_storage;
-void *uboot_vm_translate(vm_offset_t);
+extern uintptr_t uboot_heap_start;
+extern uintptr_t uboot_heap_end;
+
+uint64_t uboot_loadaddr(u_int type, void *data, uint64_t addr);
ssize_t uboot_copyin(const void *src, vm_offset_t dest, const size_t len);
ssize_t uboot_copyout(const vm_offset_t src, void *dest, const size_t len);
ssize_t uboot_readin(const int fd, vm_offset_t dest, const size_t len);
diff --git a/sys/boot/uboot/lib/net.c b/sys/boot/uboot/lib/net.c
index 902e372..20a26b7 100644
--- a/sys/boot/uboot/lib/net.c
+++ b/sys/boot/uboot/lib/net.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include "api_public.h"
#include "glue.h"
#include "libuboot.h"
+#include "dev_net.h"
static int net_probe(struct netif *, void *);
static int net_match(struct netif *, void *);
@@ -84,6 +85,109 @@ struct uboot_softc {
static struct uboot_softc uboot_softc;
+/*
+ * get_env_net_params()
+ *
+ * Attempt to obtain all the parms we need for netbooting from the U-Boot
+ * environment. If we fail to obtain the values it may still be possible to
+ * netboot; the net_dev code will attempt to get the values from bootp, rarp,
+ * and other such sources.
+ *
+ * If rootip.s_addr is non-zero net_dev assumes the required global variables
+ * are set and skips the bootp inquiry. For that reason, we don't set rootip
+ * until we've verified that we have at least the minimum required info.
+ *
+ * This is called from netif_init() which can result in it getting called
+ * multiple times, by design. The network code at higher layers zeroes out
+ * rootip when it closes a network interface, so if it gets opened again we have
+ * to obtain all this info again.
+ */
+static void
+get_env_net_params()
+{
+ char *envstr;
+ in_addr_t rootaddr, serveraddr;
+
+ /* Silently get out right away if we don't have rootpath. */
+ if (ub_env_get("rootpath") == NULL)
+ return;
+
+ /*
+ * Our own IP address must be valid. Silently get out if it's not set,
+ * but whine if it's there and we can't parse it.
+ */
+ if ((envstr = ub_env_get("ipaddr")) == NULL)
+ return;
+ if ((myip.s_addr = inet_addr(envstr)) == INADDR_NONE) {
+ printf("Could not parse ipaddr '%s'\n", envstr);
+ return;
+ }
+
+ /*
+ * Netmask is optional, default to the "natural" netmask for our IP, but
+ * whine if it was provided and we couldn't parse it.
+ */
+ if ((envstr = ub_env_get("netmask")) != NULL &&
+ (netmask = inet_addr(envstr)) == INADDR_NONE) {
+ printf("Could not parse netmask '%s'\n", envstr);
+ }
+ if (netmask == INADDR_NONE) {
+ if (IN_CLASSA(myip.s_addr))
+ netmask = IN_CLASSA_NET;
+ else if (IN_CLASSB(myip.s_addr))
+ netmask = IN_CLASSB_NET;
+ else
+ netmask = IN_CLASSC_NET;
+ }
+
+ /*
+ * Get optional serverip before rootpath; the latter can override it.
+ * Whine only if it's present but can't be parsed.
+ */
+ serveraddr = INADDR_NONE;
+ if ((envstr = ub_env_get("serverip")) != NULL) {
+ if ((serveraddr = inet_addr(envstr)) == INADDR_NONE)
+ printf("Could not parse serverip '%s'\n", envstr);
+ }
+
+ /*
+ * There must be a rootpath. It may be ip:/path or it may be just the
+ * path in which case the ip needs to be in serverip.
+ */
+ if ((envstr = ub_env_get("rootpath")) == NULL)
+ return;
+ strncpy(rootpath, envstr, sizeof(rootpath) - 1);
+ rootaddr = net_parse_rootpath();
+ if (rootaddr == INADDR_NONE)
+ rootaddr = serveraddr;
+ if (rootaddr == INADDR_NONE) {
+ printf("No server address for rootpath '%s'\n", envstr);
+ return;
+ }
+ rootip.s_addr = rootaddr;
+
+ /*
+ * Gateway IP is optional unless rootip is on a different net in which
+ * case whine if it's missing or we can't parse it, and set rootip addr
+ * to zero, which signals to other network code that network params
+ * aren't set (so it will try dhcp, bootp, etc).
+ */
+ envstr = ub_env_get("gatewayip");
+ if (!SAMENET(myip, rootip, netmask)) {
+ if (envstr == NULL) {
+ printf("Need gatewayip for a root server on a "
+ "different network.\n");
+ rootip.s_addr = 0;
+ return;
+ }
+ if ((gateip.s_addr = inet_addr(envstr) == INADDR_NONE)) {
+ printf("Could not parse gatewayip '%s'\n", envstr);
+ rootip.s_addr = 0;
+ return;
+ }
+ }
+}
+
static int
net_match(struct netif *nif, void *machdep_hint)
{
@@ -222,6 +326,11 @@ net_init(struct iodesc *desc, void *machdep_hint)
nif->nif_driver->netif_bname, nif->nif_unit);
}
+ /* Attempt to get netboot params from the u-boot env. */
+ get_env_net_params();
+ if (myip.s_addr != 0)
+ desc->myip = myip;
+
#if defined(NETIF_DEBUG)
printf("network: %s%d attached to %s\n", nif->nif_driver->netif_bname,
nif->nif_unit, ether_sprintf(desc->myea));
diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c
index a922967..b5582e9 100644
--- a/sys/cam/ctl/ctl_backend_block.c
+++ b/sys/cam/ctl/ctl_backend_block.c
@@ -521,7 +521,7 @@ ctl_be_block_biodone(struct bio *bio)
if (beio->num_errors > 0) {
if (error == EOPNOTSUPP) {
ctl_set_invalid_opcode(&io->scsiio);
- } else if (error == ENOSPC) {
+ } else if (error == ENOSPC || error == EDQUOT) {
ctl_set_space_alloc_fail(&io->scsiio);
} else if (beio->bio_cmd == BIO_FLUSH) {
/* XXX KDM is there is a better error here? */
@@ -738,7 +738,7 @@ ctl_be_block_dispatch_file(struct ctl_be_block_lun *be_lun,
ctl_scsi_path_string(io, path_str, sizeof(path_str));
printf("%s%s command returned errno %d\n", path_str,
(beio->bio_cmd == BIO_READ) ? "READ" : "WRITE", error);
- if (error == ENOSPC) {
+ if (error == ENOSPC || error == EDQUOT) {
ctl_set_space_alloc_fail(&io->scsiio);
} else
ctl_set_medium_error(&io->scsiio);
@@ -895,7 +895,7 @@ ctl_be_block_dispatch_zvol(struct ctl_be_block_lun *be_lun,
* return the I/O to the user.
*/
if (error != 0) {
- if (error == ENOSPC) {
+ if (error == ENOSPC || error == EDQUOT) {
ctl_set_space_alloc_fail(&io->scsiio);
} else
ctl_set_medium_error(&io->scsiio);
diff --git a/sys/cddl/contrib/opensolaris/common/nvpair/nvpair.c b/sys/cddl/contrib/opensolaris/common/nvpair/nvpair.c
index 53ed5f2..cd6af4e 100644
--- a/sys/cddl/contrib/opensolaris/common/nvpair/nvpair.c
+++ b/sys/cddl/contrib/opensolaris/common/nvpair/nvpair.c
@@ -1227,6 +1227,7 @@ nvpair_type_is_array(nvpair_t *nvp)
data_type_t type = NVP_TYPE(nvp);
if ((type == DATA_TYPE_BYTE_ARRAY) ||
+ (type == DATA_TYPE_INT8_ARRAY) ||
(type == DATA_TYPE_UINT8_ARRAY) ||
(type == DATA_TYPE_INT16_ARRAY) ||
(type == DATA_TYPE_UINT16_ARRAY) ||
diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
index b31e8bb..4e55160 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
@@ -14225,8 +14225,8 @@ dtrace_state_create(struct cdev *dev)
state->dts_cleaner = CYCLIC_NONE;
state->dts_deadman = CYCLIC_NONE;
#else
- callout_init(&state->dts_cleaner, CALLOUT_MPSAFE);
- callout_init(&state->dts_deadman, CALLOUT_MPSAFE);
+ callout_init(&state->dts_cleaner, 1);
+ callout_init(&state->dts_deadman, 1);
#endif
state->dts_vstate.dtvs_state = state;
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c
index 36ac27a..fb9c8a1 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_objset.c
@@ -23,6 +23,7 @@
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
* Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
+ * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
*/
/* Portions Copyright 2010 Robert Milkowski */
@@ -879,11 +880,7 @@ dmu_objset_clone_check(void *arg, dmu_tx_t *tx)
dsl_dir_rele(pdd, FTAG);
return (SET_ERROR(EEXIST));
}
- /* You can't clone across pools. */
- if (pdd->dd_pool != dp) {
- dsl_dir_rele(pdd, FTAG);
- return (SET_ERROR(EXDEV));
- }
+
error = dsl_fs_ss_limit_check(pdd, 1, ZFS_PROP_FILESYSTEM_LIMIT, NULL,
doca->doca_cred);
if (error != 0) {
@@ -896,12 +893,6 @@ dmu_objset_clone_check(void *arg, dmu_tx_t *tx)
if (error != 0)
return (error);
- /* You can't clone across pools. */
- if (origin->ds_dir->dd_pool != dp) {
- dsl_dataset_rele(origin, FTAG);
- return (SET_ERROR(EXDEV));
- }
-
/* You can only clone snapshots, not the head datasets. */
if (!dsl_dataset_is_snapshot(origin)) {
dsl_dataset_rele(origin, FTAG);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c
index d74c2cf..a0c1377 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_send.c
@@ -1142,7 +1142,8 @@ dmu_recv_begin_sync(void *arg, dmu_tx_t *tx)
}
dsobj = dsl_dataset_create_sync(ds->ds_dir, recv_clone_name,
snap, crflags, drba->drba_cred, tx);
- dsl_dataset_rele(snap, FTAG);
+ if (drba->drba_snapobj != 0)
+ dsl_dataset_rele(snap, FTAG);
dsl_dataset_rele(ds, FTAG);
} else {
dsl_dir_t *dd;
@@ -2010,7 +2011,7 @@ dmu_recv_end_check(void *arg, dmu_tx_t *tx)
error = dsl_dataset_hold_obj(dp, obj, FTAG,
&snap);
if (error != 0)
- return (error);
+ break;
if (snap->ds_dir != origin_head->ds_dir)
error = SET_ERROR(EINVAL);
if (error == 0) {
@@ -2020,7 +2021,11 @@ dmu_recv_end_check(void *arg, dmu_tx_t *tx)
obj = dsl_dataset_phys(snap)->ds_prev_snap_obj;
dsl_dataset_rele(snap, FTAG);
if (error != 0)
- return (error);
+ break;
+ }
+ if (error != 0) {
+ dsl_dataset_rele(origin_head, FTAG);
+ return (error);
}
}
error = dsl_dataset_clone_swap_check_impl(drc->drc_ds,
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c
index 7b1d6be..9891099 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_traverse.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2015 Chunwei Chen. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -306,21 +307,22 @@ traverse_visitbp(traverse_data_t *td, const dnode_phys_t *dnp,
arc_flags_t flags = ARC_FLAG_WAIT;
int i;
int epb = BP_GET_LSIZE(bp) >> DNODE_SHIFT;
+ dnode_phys_t *cdnp;
err = arc_read(NULL, td->td_spa, bp, arc_getbuf_func, &buf,
ZIO_PRIORITY_ASYNC_READ, ZIO_FLAG_CANFAIL, &flags, zb);
if (err != 0)
goto post;
- dnp = buf->b_data;
+ cdnp = buf->b_data;
for (i = 0; i < epb; i++) {
- prefetch_dnode_metadata(td, &dnp[i], zb->zb_objset,
+ prefetch_dnode_metadata(td, &cdnp[i], zb->zb_objset,
zb->zb_blkid * epb + i);
}
/* recursively visitbp() blocks below this */
for (i = 0; i < epb; i++) {
- err = traverse_dnode(td, &dnp[i], zb->zb_objset,
+ err = traverse_dnode(td, &cdnp[i], zb->zb_objset,
zb->zb_blkid * epb + i);
if (err != 0)
break;
@@ -328,7 +330,7 @@ traverse_visitbp(traverse_data_t *td, const dnode_phys_t *dnp,
} else if (BP_GET_TYPE(bp) == DMU_OT_OBJSET) {
arc_flags_t flags = ARC_FLAG_WAIT;
objset_phys_t *osp;
- dnode_phys_t *dnp;
+ dnode_phys_t *mdnp, *gdnp, *udnp;
err = arc_read(NULL, td->td_spa, bp, arc_getbuf_func, &buf,
ZIO_PRIORITY_ASYNC_READ, ZIO_FLAG_CANFAIL, &flags, zb);
@@ -336,26 +338,27 @@ traverse_visitbp(traverse_data_t *td, const dnode_phys_t *dnp,
goto post;
osp = buf->b_data;
- dnp = &osp->os_meta_dnode;
- prefetch_dnode_metadata(td, dnp, zb->zb_objset,
+ mdnp = &osp->os_meta_dnode;
+ gdnp = &osp->os_groupused_dnode;
+ udnp = &osp->os_userused_dnode;
+
+ prefetch_dnode_metadata(td, mdnp, zb->zb_objset,
DMU_META_DNODE_OBJECT);
if (arc_buf_size(buf) >= sizeof (objset_phys_t)) {
- prefetch_dnode_metadata(td, &osp->os_groupused_dnode,
- zb->zb_objset, DMU_GROUPUSED_OBJECT);
- prefetch_dnode_metadata(td, &osp->os_userused_dnode,
- zb->zb_objset, DMU_USERUSED_OBJECT);
+ prefetch_dnode_metadata(td, gdnp, zb->zb_objset,
+ DMU_GROUPUSED_OBJECT);
+ prefetch_dnode_metadata(td, udnp, zb->zb_objset,
+ DMU_USERUSED_OBJECT);
}
- err = traverse_dnode(td, dnp, zb->zb_objset,
+ err = traverse_dnode(td, mdnp, zb->zb_objset,
DMU_META_DNODE_OBJECT);
if (err == 0 && arc_buf_size(buf) >= sizeof (objset_phys_t)) {
- dnp = &osp->os_groupused_dnode;
- err = traverse_dnode(td, dnp, zb->zb_objset,
+ err = traverse_dnode(td, gdnp, zb->zb_objset,
DMU_GROUPUSED_OBJECT);
}
if (err == 0 && arc_buf_size(buf) >= sizeof (objset_phys_t)) {
- dnp = &osp->os_userused_dnode;
- err = traverse_dnode(td, dnp, zb->zb_objset,
+ err = traverse_dnode(td, udnp, zb->zb_objset,
DMU_USERUSED_OBJECT);
}
}
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c
index ce22f4e..58db4dd 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c
@@ -413,7 +413,8 @@ dsl_dataset_hold_obj(dsl_pool_t *dp, uint64_t dsobj, void *tag,
offsetof(dmu_sendarg_t, dsa_link));
if (doi.doi_type == DMU_OTN_ZAP_METADATA) {
- int zaperr = zap_contains(mos, dsobj, DS_FIELD_LARGE_BLOCKS);
+ int zaperr = zap_contains(mos, dsobj,
+ DS_FIELD_LARGE_BLOCKS);
if (zaperr != ENOENT) {
VERIFY0(zaperr);
ds->ds_large_blocks = B_TRUE;
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c
index 1862f8c..26f5c2d 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dir.c
@@ -24,6 +24,7 @@
* All rights reserved.
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
* Copyright (c) 2014 Joyent, Inc. All rights reserved.
+ * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
*/
#include <sys/dmu.h>
@@ -408,7 +409,7 @@ dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag,
/* Make sure the name is in the specified pool. */
spaname = spa_name(dp->dp_spa);
if (strcmp(buf, spaname) != 0)
- return (SET_ERROR(EINVAL));
+ return (SET_ERROR(EXDEV));
ASSERT(dsl_pool_config_held(dp));
@@ -1706,7 +1707,7 @@ dsl_dir_rename_check(void *arg, dmu_tx_t *tx)
if (dd->dd_pool != newparent->dd_pool) {
dsl_dir_rele(newparent, FTAG);
dsl_dir_rele(dd, FTAG);
- return (SET_ERROR(ENXIO));
+ return (SET_ERROR(EXDEV));
}
/* new name should not already exist */
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
index b51dd97..d072dc3 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
@@ -671,7 +671,7 @@ spa_add(const char *name, nvlist_t *config, const char *altroot)
mutex_exit(&cpu_lock);
#else /* !illumos */
#ifdef _KERNEL
- callout_init(&spa->spa_deadman_cycid, CALLOUT_MPSAFE);
+ callout_init(&spa->spa_deadman_cycid, 1);
#endif
#endif
refcount_create(&spa->spa_refcount);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
index 3fb66c8..c8e3105 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
@@ -261,10 +261,6 @@ VTOZ(vnode_t *vp)
} \
}
-/* Called on entry to each ZFS vnode and vfs operation that can not return EIO */
-#define ZFS_ENTER_NOERROR(zfsvfs) \
- rrm_enter(&(zfsvfs)->z_teardown_lock, RW_READER, FTAG)
-
/* Must be called before exiting the vop */
#define ZFS_EXIT(zfsvfs) rrm_exit(&(zfsvfs)->z_teardown_lock, FTAG)
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
index 55e3c45..8f31e3f 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
@@ -4196,7 +4196,11 @@ zfs_ioc_recv(zfs_cmd_t *zc)
return (error);
fd = zc->zc_cookie;
- fp = getf(fd, cap_rights_init(&rights, CAP_PREAD));
+#ifdef illumos
+ fp = getf(fd);
+#else
+ fget_read(curthread, fd, cap_rights_init(&rights, CAP_PREAD), &fp);
+#endif
if (fp == NULL) {
nvlist_free(props);
return (SET_ERROR(EBADF));
@@ -4442,8 +4446,12 @@ zfs_ioc_send(zfs_cmd_t *zc)
file_t *fp;
cap_rights_t rights;
- fp = getf(zc->zc_cookie,
- cap_rights_init(&rights, CAP_WRITE));
+#ifdef illumos
+ fp = getf(zc->zc_cookie);
+#else
+ fget_write(curthread, zc->zc_cookie,
+ cap_rights_init(&rights, CAP_WRITE), &fp);
+#endif
if (fp == NULL)
return (SET_ERROR(EBADF));
@@ -5039,7 +5047,12 @@ zfs_ioc_diff(zfs_cmd_t *zc)
offset_t off;
int error;
- fp = getf(zc->zc_cookie, cap_rights_init(&rights, CAP_WRITE));
+#ifdef illumos
+ fp = getf(zc->zc_cookie);
+#else
+ fget_write(curthread, zc->zc_cookie,
+ cap_rights_init(&rights, CAP_WRITE), &fp);
+#endif
if (fp == NULL)
return (SET_ERROR(EBADF));
@@ -5404,6 +5417,7 @@ static int
zfs_ioc_send_new(const char *snapname, nvlist_t *innvl, nvlist_t *outnvl)
{
cap_rights_t rights;
+ file_t *fp;
int error;
offset_t off;
char *fromname = NULL;
@@ -5420,7 +5434,11 @@ zfs_ioc_send_new(const char *snapname, nvlist_t *innvl, nvlist_t *outnvl)
largeblockok = nvlist_exists(innvl, "largeblockok");
embedok = nvlist_exists(innvl, "embedok");
- file_t *fp = getf(fd, cap_rights_init(&rights, CAP_READ));
+#ifdef illumos
+ file_t *fp = getf(fd);
+#else
+ fget_write(curthread, fd, cap_rights_init(&rights, CAP_WRITE), &fp);
+#endif
if (fp == NULL)
return (SET_ERROR(EBADF));
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_onexit.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_onexit.c
index 6a90b9c..fe02399 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_onexit.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_onexit.c
@@ -137,7 +137,7 @@ zfs_onexit_fd_hold(int fd, minor_t *minorp)
*minorp = (minor_t)(uintptr_t)data;
curthread->td_fpop = tmpfp;
if (error != 0)
- return (error);
+ return (SET_ERROR(EBADF));
return (zfs_onexit_minor_to_state(*minorp, &zo));
}
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
index 415db9e..5824828 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
@@ -1239,9 +1239,6 @@ zfs_domount(vfs_t *vfsp, char *osname)
}
vfs_mountedfrom(vfsp, osname);
- /* Grab extra reference. */
- VERIFY(VFS_ROOT(vfsp, LK_EXCLUSIVE, &vp) == 0);
- VOP_UNLOCK(vp, 0);
if (!zfsvfs->z_issnap)
zfsctl_create(zfsvfs);
@@ -1819,7 +1816,7 @@ zfs_root(vfs_t *vfsp, int flags, vnode_t **vpp)
znode_t *rootzp;
int error;
- ZFS_ENTER_NOERROR(zfsvfs);
+ ZFS_ENTER(zfsvfs);
error = zfs_zget(zfsvfs, zfsvfs->z_root, &rootzp);
if (error == 0)
@@ -1994,7 +1991,7 @@ zfs_umount(vfs_t *vfsp, int fflag)
/*
* Flush all the files.
*/
- ret = vflush(vfsp, 1, (fflag & MS_FORCE) ? FORCECLOSE : 0, td);
+ ret = vflush(vfsp, 0, (fflag & MS_FORCE) ? FORCECLOSE : 0, td);
if (ret != 0) {
if (!zfsvfs->z_issnap) {
zfsctl_create(zfsvfs);
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
index d925712..e3b314f 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
@@ -1320,15 +1320,25 @@ zfs_rezget(znode_t *zp)
}
/*
- * XXXPJD: Not sure how is that possible, but under heavy
- * zfs recv -F load it happens that z_gen is the same, but
- * vnode type is different than znode type. This would mean
- * that for example regular file was replaced with directory
- * which has the same object number.
+ * It is highly improbable but still quite possible that two
+ * objects in different datasets are created with the same
+ * object numbers and in transaction groups with the same
+ * numbers. znodes corresponding to those objects would
+ * have the same z_id and z_gen, but their other attributes
+ * may be different.
+ * zfs recv -F may replace one of such objects with the other.
+ * As a result file properties recorded in the replaced
+ * object's vnode may no longer match the received object's
+ * properties. At present the only cached property is the
+ * files type recorded in v_type.
+ * So, handle this case by leaving the old vnode and znode
+ * disassociated from the actual object. A new vnode and a
+ * znode will be created if the object is accessed
+ * (e.g. via a look-up). The old vnode and znode will be
+ * recycled when the last vnode reference is dropped.
*/
vp = ZTOV(zp);
- if (vp != NULL &&
- vp->v_type != IFTOVT((mode_t)zp->z_mode)) {
+ if (vp != NULL && vp->v_type != IFTOVT((mode_t)zp->z_mode)) {
zfs_znode_dmu_fini(zp);
ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
return (EIO);
diff --git a/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c b/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c
index f076f5d..ea01d5f 100644
--- a/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c
+++ b/sys/cddl/contrib/opensolaris/uts/powerpc/dtrace/fasttrap_isa.c
@@ -244,8 +244,8 @@ fasttrap_anarg(struct reg *rp, int argno)
DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT | CPU_DTRACE_BADADDR);
} else {
DTRACE_CPUFLAG_SET(CPU_DTRACE_NOFAULT);
- value = dtrace_fuword64((void *)(rp->fixreg[1] + 16 +
- ((argno - 8) * sizeof(uint32_t))));
+ value = dtrace_fuword64((void *)(rp->fixreg[1] + 48 +
+ ((argno - 8) * sizeof(uint64_t))));
DTRACE_CPUFLAG_CLEAR(CPU_DTRACE_NOFAULT | CPU_DTRACE_BADADDR);
}
return value;
@@ -289,7 +289,7 @@ fasttrap_usdt_args(fasttrap_probe_t *probe, struct reg *rp, int argc,
argv[i] = fuword32((void *)(rp->fixreg[1] + 8 +
(x * sizeof(uint32_t))));
else
- argv[i] = fuword32((void *)(rp->fixreg[1] + 16 +
+ argv[i] = fuword64((void *)(rp->fixreg[1] + 48 +
(x * sizeof(uint64_t))));
}
diff --git a/sys/cddl/dev/dtrace/amd64/dtrace_subr.c b/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
index 805add2..7f2ec7e 100644
--- a/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
+++ b/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
@@ -142,114 +142,6 @@ dtrace_sync(void)
}
#ifdef notyet
-int (*dtrace_pid_probe_ptr)(struct regs *);
-int (*dtrace_return_probe_ptr)(struct regs *);
-
-void
-dtrace_user_probe(struct regs *rp, caddr_t addr, processorid_t cpuid)
-{
- krwlock_t *rwp;
- proc_t *p = curproc;
- extern void trap(struct regs *, caddr_t, processorid_t);
-
- if (USERMODE(rp->r_cs) || (rp->r_ps & PS_VM)) {
- if (curthread->t_cred != p->p_cred) {
- cred_t *oldcred = curthread->t_cred;
- /*
- * DTrace accesses t_cred in probe context. t_cred
- * must always be either NULL, or point to a valid,
- * allocated cred structure.
- */
- curthread->t_cred = crgetcred();
- crfree(oldcred);
- }
- }
-
- if (rp->r_trapno == T_DTRACE_RET) {
- uint8_t step = curthread->t_dtrace_step;
- uint8_t ret = curthread->t_dtrace_ret;
- uintptr_t npc = curthread->t_dtrace_npc;
-
- if (curthread->t_dtrace_ast) {
- aston(curthread);
- curthread->t_sig_check = 1;
- }
-
- /*
- * Clear all user tracing flags.
- */
- curthread->t_dtrace_ft = 0;
-
- /*
- * If we weren't expecting to take a return probe trap, kill
- * the process as though it had just executed an unassigned
- * trap instruction.
- */
- if (step == 0) {
- tsignal(curthread, SIGILL);
- return;
- }
-
- /*
- * If we hit this trap unrelated to a return probe, we're
- * just here to reset the AST flag since we deferred a signal
- * until after we logically single-stepped the instruction we
- * copied out.
- */
- if (ret == 0) {
- rp->r_pc = npc;
- return;
- }
-
- /*
- * We need to wait until after we've called the
- * dtrace_return_probe_ptr function pointer to set %pc.
- */
- rwp = &CPU->cpu_ft_lock;
- rw_enter(rwp, RW_READER);
- if (dtrace_return_probe_ptr != NULL)
- (void) (*dtrace_return_probe_ptr)(rp);
- rw_exit(rwp);
- rp->r_pc = npc;
-
- } else if (rp->r_trapno == T_BPTFLT) {
- uint8_t instr;
- rwp = &CPU->cpu_ft_lock;
-
- /*
- * The DTrace fasttrap provider uses the breakpoint trap
- * (int 3). We let DTrace take the first crack at handling
- * this trap; if it's not a probe that DTrace knowns about,
- * we call into the trap() routine to handle it like a
- * breakpoint placed by a conventional debugger.
- */
- rw_enter(rwp, RW_READER);
- if (dtrace_pid_probe_ptr != NULL &&
- (*dtrace_pid_probe_ptr)(rp) == 0) {
- rw_exit(rwp);
- return;
- }
- rw_exit(rwp);
-
- /*
- * If the instruction that caused the breakpoint trap doesn't
- * look like an int 3 anymore, it may be that this tracepoint
- * was removed just after the user thread executed it. In
- * that case, return to user land to retry the instuction.
- */
- if (fuword8((void *)(rp->r_pc - 1), &instr) == 0 &&
- instr != FASTTRAP_INSTR) {
- rp->r_pc--;
- return;
- }
-
- trap(rp, addr, cpuid);
-
- } else {
- trap(rp, addr, cpuid);
- }
-}
-
void
dtrace_safe_synchronous_signal(void)
{
diff --git a/sys/cddl/dev/dtrace/i386/dtrace_subr.c b/sys/cddl/dev/dtrace/i386/dtrace_subr.c
index 4073317..814019e 100644
--- a/sys/cddl/dev/dtrace/i386/dtrace_subr.c
+++ b/sys/cddl/dev/dtrace/i386/dtrace_subr.c
@@ -143,122 +143,6 @@ dtrace_sync(void)
}
#ifdef notyet
-int (*dtrace_fasttrap_probe_ptr)(struct regs *);
-int (*dtrace_pid_probe_ptr)(struct regs *);
-int (*dtrace_return_probe_ptr)(struct regs *);
-
-void
-dtrace_user_probe(struct regs *rp, caddr_t addr, processorid_t cpuid)
-{
- krwlock_t *rwp;
- proc_t *p = curproc;
- extern void trap(struct regs *, caddr_t, processorid_t);
-
- if (USERMODE(rp->r_cs) || (rp->r_ps & PS_VM)) {
- if (curthread->t_cred != p->p_cred) {
- cred_t *oldcred = curthread->t_cred;
- /*
- * DTrace accesses t_cred in probe context. t_cred
- * must always be either NULL, or point to a valid,
- * allocated cred structure.
- */
- curthread->t_cred = crgetcred();
- crfree(oldcred);
- }
- }
-
- if (rp->r_trapno == T_DTRACE_RET) {
- uint8_t step = curthread->t_dtrace_step;
- uint8_t ret = curthread->t_dtrace_ret;
- uintptr_t npc = curthread->t_dtrace_npc;
-
- if (curthread->t_dtrace_ast) {
- aston(curthread);
- curthread->t_sig_check = 1;
- }
-
- /*
- * Clear all user tracing flags.
- */
- curthread->t_dtrace_ft = 0;
-
- /*
- * If we weren't expecting to take a return probe trap, kill
- * the process as though it had just executed an unassigned
- * trap instruction.
- */
- if (step == 0) {
- tsignal(curthread, SIGILL);
- return;
- }
-
- /*
- * If we hit this trap unrelated to a return probe, we're
- * just here to reset the AST flag since we deferred a signal
- * until after we logically single-stepped the instruction we
- * copied out.
- */
- if (ret == 0) {
- rp->r_pc = npc;
- return;
- }
-
- /*
- * We need to wait until after we've called the
- * dtrace_return_probe_ptr function pointer to set %pc.
- */
- rwp = &CPU->cpu_ft_lock;
- rw_enter(rwp, RW_READER);
- if (dtrace_return_probe_ptr != NULL)
- (void) (*dtrace_return_probe_ptr)(rp);
- rw_exit(rwp);
- rp->r_pc = npc;
-
- } else if (rp->r_trapno == T_DTRACE_PROBE) {
- rwp = &CPU->cpu_ft_lock;
- rw_enter(rwp, RW_READER);
- if (dtrace_fasttrap_probe_ptr != NULL)
- (void) (*dtrace_fasttrap_probe_ptr)(rp);
- rw_exit(rwp);
-
- } else if (rp->r_trapno == T_BPTFLT) {
- uint8_t instr;
- rwp = &CPU->cpu_ft_lock;
-
- /*
- * The DTrace fasttrap provider uses the breakpoint trap
- * (int 3). We let DTrace take the first crack at handling
- * this trap; if it's not a probe that DTrace knowns about,
- * we call into the trap() routine to handle it like a
- * breakpoint placed by a conventional debugger.
- */
- rw_enter(rwp, RW_READER);
- if (dtrace_pid_probe_ptr != NULL &&
- (*dtrace_pid_probe_ptr)(rp) == 0) {
- rw_exit(rwp);
- return;
- }
- rw_exit(rwp);
-
- /*
- * If the instruction that caused the breakpoint trap doesn't
- * look like an int 3 anymore, it may be that this tracepoint
- * was removed just after the user thread executed it. In
- * that case, return to user land to retry the instuction.
- */
- if (fuword8((void *)(rp->r_pc - 1), &instr) == 0 &&
- instr != FASTTRAP_INSTR) {
- rp->r_pc--;
- return;
- }
-
- trap(rp, addr, cpuid);
-
- } else {
- trap(rp, addr, cpuid);
- }
-}
-
void
dtrace_safe_synchronous_signal(void)
{
diff --git a/sys/cddl/dev/profile/profile.c b/sys/cddl/dev/profile/profile.c
index d31d5c8..dd13397 100644
--- a/sys/cddl/dev/profile/profile.c
+++ b/sys/cddl/dev/profile/profile.c
@@ -342,7 +342,7 @@ profile_create(hrtime_t interval, char *name, int kind)
prof->prof_cyclic = CYCLIC_NONE;
#else
prof->prof_interval = nsec_to_sbt(interval);
- callout_init(&prof->prof_cyclic, CALLOUT_MPSAFE);
+ callout_init(&prof->prof_cyclic, 1);
#endif
prof->prof_kind = kind;
prof->prof_id = dtrace_probe_create(profile_id,
@@ -590,7 +590,7 @@ profile_enable_omni(profile_probe_t *prof)
pcpu->profc_probe = prof;
pcpu->profc_expected = sbinuptime() + prof->prof_interval;
pcpu->profc_interval = prof->prof_interval;
- callout_init(&pcpu->profc_cyclic, CALLOUT_MPSAFE);
+ callout_init(&pcpu->profc_cyclic, 1);
callout_reset_sbt_on(&pcpu->profc_cyclic,
pcpu->profc_expected, 0, profile_fire, pcpu,
cpu, C_DIRECT_EXEC | C_ABSOLUTE);
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index 8696b36..7a33d61 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -248,7 +248,7 @@ freebsd4_freebsd32_getfsstat(struct thread *td, struct freebsd4_freebsd32_getfss
{
struct statfs *buf, *sp;
struct statfs32 stat32;
- size_t count, size;
+ size_t count, size, copycount;
int error;
count = uap->bufsize / sizeof(struct statfs32);
@@ -256,12 +256,13 @@ freebsd4_freebsd32_getfsstat(struct thread *td, struct freebsd4_freebsd32_getfss
error = kern_getfsstat(td, &buf, size, &count, UIO_SYSSPACE, uap->flags);
if (size > 0) {
sp = buf;
- while (count > 0 && error == 0) {
+ copycount = count;
+ while (copycount > 0 && error == 0) {
copy_statfs(sp, &stat32);
error = copyout(&stat32, uap->buf, sizeof(stat32));
sp++;
uap->buf++;
- count--;
+ copycount--;
}
free(buf, M_TEMP);
}
@@ -401,12 +402,17 @@ int
freebsd32_execve(struct thread *td, struct freebsd32_execve_args *uap)
{
struct image_args eargs;
+ struct vmspace *oldvmspace;
int error;
+ error = pre_execve(td, &oldvmspace);
+ if (error != 0)
+ return (error);
error = freebsd32_exec_copyin_args(&eargs, uap->fname, UIO_USERSPACE,
uap->argv, uap->envv);
if (error == 0)
error = kern_execve(td, &eargs, NULL);
+ post_execve(td, error, oldvmspace);
return (error);
}
@@ -414,14 +420,19 @@ int
freebsd32_fexecve(struct thread *td, struct freebsd32_fexecve_args *uap)
{
struct image_args eargs;
+ struct vmspace *oldvmspace;
int error;
+ error = pre_execve(td, &oldvmspace);
+ if (error != 0)
+ return (error);
error = freebsd32_exec_copyin_args(&eargs, NULL, UIO_SYSSPACE,
uap->argv, uap->envv);
if (error == 0) {
eargs.fd = uap->fd;
error = kern_execve(td, &eargs, NULL);
}
+ post_execve(td, error, oldvmspace);
return (error);
}
diff --git a/sys/compat/ndis/subr_ntoskrnl.c b/sys/compat/ndis/subr_ntoskrnl.c
index 482392d..95670ba 100644
--- a/sys/compat/ndis/subr_ntoskrnl.c
+++ b/sys/compat/ndis/subr_ntoskrnl.c
@@ -3749,7 +3749,7 @@ ntoskrnl_insert_timer(timer, ticks)
timer->k_callout = c;
- callout_init(c, CALLOUT_MPSAFE);
+ callout_init(c, 1);
callout_reset(c, ticks, ntoskrnl_timercall, timer);
}
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c
index cef1b48..c0da170 100644
--- a/sys/compat/svr4/svr4_misc.c
+++ b/sys/compat/svr4/svr4_misc.c
@@ -167,15 +167,22 @@ svr4_sys_execv(td, uap)
struct svr4_sys_execv_args *uap;
{
struct image_args eargs;
+ struct vmspace *oldvmspace;
char *path;
int error;
CHECKALTEXIST(td, uap->path, &path);
+ error = pre_execve(td, &oldvmspace);
+ if (error != 0) {
+ free(path, M_TEMP);
+ return (error);
+ }
error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, uap->argp, NULL);
free(path, M_TEMP);
if (error == 0)
error = kern_execve(td, &eargs, NULL);
+ post_execve(td, error, oldvmspace);
return (error);
}
@@ -185,16 +192,23 @@ svr4_sys_execve(td, uap)
struct svr4_sys_execve_args *uap;
{
struct image_args eargs;
+ struct vmspace *oldvmspace;
char *path;
int error;
CHECKALTEXIST(td, uap->path, &path);
+ error = pre_execve(td, &oldvmspace);
+ if (error != 0) {
+ free(path, M_TEMP);
+ return (error);
+ }
error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, uap->argp,
uap->envp);
free(path, M_TEMP);
if (error == 0)
error = kern_execve(td, &eargs, NULL);
+ post_execve(td, error, oldvmspace);
return (error);
}
diff --git a/sys/conf/NOTES b/sys/conf/NOTES
index 06c8549..8f00f59 100644
--- a/sys/conf/NOTES
+++ b/sys/conf/NOTES
@@ -576,6 +576,7 @@ options STACK
# please see hwpmc(4).
device hwpmc # Driver (also a loadable module)
+options HWPMC_DEBUG
options HWPMC_HOOKS # Other necessary kernel hooks
diff --git a/sys/conf/files b/sys/conf/files
index 905bde6..8d51fe5 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -584,7 +584,6 @@ dev/acpica/acpi_button.c optional acpi
dev/acpica/acpi_cmbat.c optional acpi
dev/acpica/acpi_cpu.c optional acpi
dev/acpica/acpi_ec.c optional acpi
-dev/acpica/acpi_hpet.c optional acpi
dev/acpica/acpi_isab.c optional acpi isa
dev/acpica/acpi_lid.c optional acpi
dev/acpica/acpi_package.c optional acpi
@@ -1780,6 +1779,8 @@ dev/ixgbe/ixgbe_82599.c optional ix ixv inet \
compile-with "${NORMAL_C} -I$S/dev/ixgbe"
dev/ixgbe/ixgbe_x540.c optional ix ixv inet \
compile-with "${NORMAL_C} -I$S/dev/ixgbe"
+dev/ixgbe/ixgbe_x550.c optional ix ixv inet \
+ compile-with "${NORMAL_C} -I$S/dev/ixgbe"
dev/ixgbe/ixgbe_dcb.c optional ix ixv inet \
compile-with "${NORMAL_C} -I$S/dev/ixgbe"
dev/ixgbe/ixgbe_dcb_82598.c optional ix ixv inet \
@@ -2677,24 +2678,24 @@ wpi.fw optional wpifw \
clean "wpi.fw"
dev/xe/if_xe.c optional xe
dev/xe/if_xe_pccard.c optional xe pccard
-dev/xen/balloon/balloon.c optional xen | xenhvm
-dev/xen/blkfront/blkfront.c optional xen | xenhvm
-dev/xen/blkback/blkback.c optional xen | xenhvm
-dev/xen/console/console.c optional xen | xenhvm
-dev/xen/console/xencons_ring.c optional xen | xenhvm
-dev/xen/control/control.c optional xen | xenhvm
-dev/xen/grant_table/grant_table.c optional xen | xenhvm
-dev/xen/netback/netback.c optional xen | xenhvm
-dev/xen/netfront/netfront.c optional xen | xenhvm
+dev/xen/balloon/balloon.c optional xenhvm
+dev/xen/blkfront/blkfront.c optional xenhvm
+dev/xen/blkback/blkback.c optional xenhvm
+dev/xen/console/console.c optional xenhvm
+dev/xen/console/xencons_ring.c optional xenhvm
+dev/xen/control/control.c optional xenhvm
+dev/xen/grant_table/grant_table.c optional xenhvm
+dev/xen/netback/netback.c optional xenhvm
+dev/xen/netfront/netfront.c optional xenhvm
dev/xen/xenpci/xenpci.c optional xenpci
-dev/xen/timer/timer.c optional xen | xenhvm
-dev/xen/pvcpu/pvcpu.c optional xen | xenhvm
-dev/xen/xenstore/xenstore.c optional xen | xenhvm
-dev/xen/xenstore/xenstore_dev.c optional xen | xenhvm
-dev/xen/xenstore/xenstored_dev.c optional xen | xenhvm
-dev/xen/evtchn/evtchn_dev.c optional xen | xenhvm
-dev/xen/privcmd/privcmd.c optional xen | xenhvm
-dev/xen/debug/debug.c optional xen | xenhvm
+dev/xen/timer/timer.c optional xenhvm
+dev/xen/pvcpu/pvcpu.c optional xenhvm
+dev/xen/xenstore/xenstore.c optional xenhvm
+dev/xen/xenstore/xenstore_dev.c optional xenhvm
+dev/xen/xenstore/xenstored_dev.c optional xenhvm
+dev/xen/evtchn/evtchn_dev.c optional xenhvm
+dev/xen/privcmd/privcmd.c optional xenhvm
+dev/xen/debug/debug.c optional xenhvm
dev/xl/if_xl.c optional xl pci
dev/xl/xlphy.c optional xl pci
fs/autofs/autofs.c optional autofs
@@ -3503,6 +3504,7 @@ netinet/sctp_sysctl.c optional inet sctp | inet6 sctp
netinet/sctp_timer.c optional inet sctp | inet6 sctp
netinet/sctp_usrreq.c optional inet sctp | inet6 sctp
netinet/sctputil.c optional inet sctp | inet6 sctp
+netinet/siftr.c optional inet siftr alq | inet6 siftr alq
netinet/tcp_debug.c optional tcpdebug
netinet/tcp_hostcache.c optional inet | inet6
netinet/tcp_input.c optional inet | inet6
@@ -4043,13 +4045,14 @@ vm/vm_reserv.c standard
vm/vm_unix.c standard
vm/vm_zeroidle.c standard
vm/vnode_pager.c standard
-xen/features.c optional xen | xenhvm
-xen/xenbus/xenbus_if.m optional xen | xenhvm
-xen/xenbus/xenbus.c optional xen | xenhvm
-xen/xenbus/xenbusb_if.m optional xen | xenhvm
-xen/xenbus/xenbusb.c optional xen | xenhvm
-xen/xenbus/xenbusb_front.c optional xen | xenhvm
-xen/xenbus/xenbusb_back.c optional xen | xenhvm
+xen/features.c optional xenhvm
+xen/xenbus/xenbus_if.m optional xenhvm
+xen/xenbus/xenbus.c optional xenhvm
+xen/xenbus/xenbusb_if.m optional xenhvm
+xen/xenbus/xenbusb.c optional xenhvm
+xen/xenbus/xenbusb_front.c optional xenhvm
+xen/xenbus/xenbusb_back.c optional xenhvm
+xen/xenmem/xenmem_if.m optional xenhvm
xdr/xdr.c optional krpc | nfslockd | nfscl | nfsd
xdr/xdr_array.c optional krpc | nfslockd | nfscl | nfsd
xdr/xdr_mbuf.c optional krpc | nfslockd | nfscl | nfsd
diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64
index 831a983..8aadcf5 100644
--- a/sys/conf/files.amd64
+++ b/sys/conf/files.amd64
@@ -145,6 +145,7 @@ crypto/via/padlock.c optional padlock
crypto/via/padlock_cipher.c optional padlock
crypto/via/padlock_hash.c optional padlock
dev/acpica/acpi_if.m standard
+dev/acpica/acpi_hpet.c optional acpi
dev/acpi_support/acpi_wmi_if.m standard
dev/agp/agp_amd64.c optional agp
dev/agp/agp_i810.c optional agp
@@ -513,10 +514,10 @@ compat/ndis/winx64_wrap.S optional ndisapi pci
libkern/memmove.c standard
libkern/memset.c standard
#
-# x86 real mode BIOS emulator, required by atkbdc/dpms/pci/vesa
+# x86 real mode BIOS emulator, required by dpms/pci/vesa
#
-compat/x86bios/x86bios.c optional x86bios | atkbd | dpms | pci | vesa
-contrib/x86emu/x86emu.c optional x86bios | atkbd | dpms | pci | vesa
+compat/x86bios/x86bios.c optional x86bios | dpms | pci | vesa
+contrib/x86emu/x86emu.c optional x86bios | dpms | pci | vesa
#
# bvm console
#
@@ -576,7 +577,7 @@ x86/x86/pvclock.c standard
x86/x86/tsc.c standard
x86/x86/delay.c standard
x86/xen/hvm.c optional xenhvm
-x86/xen/xen_intr.c optional xen | xenhvm
+x86/xen/xen_intr.c optional xenhvm
x86/xen/pv.c optional xenhvm
x86/xen/pvcpu_enum.c optional xenhvm
x86/xen/xen_apic.c optional xenhvm
diff --git a/sys/conf/files.arm b/sys/conf/files.arm
index b40f7c9..a406d33 100644
--- a/sys/conf/files.arm
+++ b/sys/conf/files.arm
@@ -37,6 +37,7 @@ arm/arm/fiq.c standard
arm/arm/fiq_subr.S standard
arm/arm/fusu.S standard
arm/arm/gdb_machdep.c optional gdb
+arm/arm/gic.c optional gic
arm/arm/identcpu.c standard
arm/arm/in_cksum.c optional inet | inet6
arm/arm/in_cksum_arm.S optional inet | inet6
diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64
index 758c9a6..8bdc93a 100644
--- a/sys/conf/files.arm64
+++ b/sys/conf/files.arm64
@@ -1,19 +1,27 @@
# $FreeBSD$
arm/arm/devmap.c standard
arm/arm/generic_timer.c standard
+arm/arm/pmu.c standard
arm64/arm64/autoconf.c standard
arm64/arm64/bcopy.c standard
arm64/arm64/bus_machdep.c standard
arm64/arm64/bus_space_asm.S standard
+arm64/arm64/busdma_bounce.c standard
arm64/arm64/busdma_machdep.c standard
arm64/arm64/clock.c standard
arm64/arm64/copyinout.S standard
arm64/arm64/copystr.c standard
arm64/arm64/cpufunc_asm.S standard
+arm64/arm64/db_disasm.c optional ddb
+arm64/arm64/db_interface.c optional ddb
+arm64/arm64/db_trace.c optional ddb
+arm64/arm64/debug_monitor.c optional kdb
arm64/arm64/dump_machdep.c standard
arm64/arm64/elf_machdep.c standard
arm64/arm64/exception.S standard
arm64/arm64/gic.c standard
+arm64/arm64/gic_v3.c standard
+arm64/arm64/gic_v3_fdt.c optional fdt
arm64/arm64/identcpu.c standard
arm64/arm64/intr_machdep.c standard
arm64/arm64/in_cksum.c optional inet | inet6
@@ -33,6 +41,8 @@ arm64/arm64/uio_machdep.c standard
arm64/arm64/vfp.c standard
arm64/arm64/vm_machdep.c standard
dev/fdt/fdt_arm64.c optional fdt
+dev/hwpmc/hwpmc_arm64.c optional hwpmc
+dev/hwpmc/hwpmc_arm64_md.c optional hwpmc
dev/ofw/ofw_cpu.c optional fdt
dev/psci/psci.c optional psci
dev/psci/psci_arm64.S optional psci
diff --git a/sys/conf/files.i386 b/sys/conf/files.i386
index 917f540..68dd6a9 100644
--- a/sys/conf/files.i386
+++ b/sys/conf/files.i386
@@ -285,6 +285,7 @@ dev/uart/uart_cpu_x86.c optional uart
dev/viawd/viawd.c optional viawd
dev/vmware/vmxnet3/if_vmx.c optional vmx
dev/acpica/acpi_if.m standard
+dev/acpica/acpi_hpet.c optional acpi
dev/acpi_support/acpi_wmi_if.m standard
dev/wbwd/wbwd.c optional wbwd
dev/wpi/if_wpi.c optional wpi
@@ -427,16 +428,15 @@ i386/bios/smapi_bios.S optional smapi
i386/i386/atomic.c standard \
compile-with "${CC} -c ${CFLAGS} ${DEFINED_PROF:S/^$/-fomit-frame-pointer/} ${.IMPSRC}"
i386/i386/autoconf.c standard
-i386/i386/bios.c optional native
-i386/i386/bioscall.s optional native
+i386/i386/bios.c standard
+i386/i386/bioscall.s standard
i386/i386/bpf_jit_machdep.c optional bpf_jitter
i386/i386/db_disasm.c optional ddb
i386/i386/db_interface.c optional ddb
i386/i386/db_trace.c optional ddb
i386/i386/elan-mmcr.c optional cpu_elan | cpu_soekris
i386/i386/elf_machdep.c standard
-i386/i386/exception.s optional native
-i386/xen/exception.s optional xen
+i386/i386/exception.s standard
i386/i386/gdb_machdep.c optional gdb
i386/i386/geode.c optional cpu_geode
i386/i386/i686_mem.c optional mem
@@ -444,22 +444,17 @@ i386/i386/in_cksum.c optional inet | inet6
i386/i386/initcpu.c standard
i386/i386/io.c optional io
i386/i386/k6_mem.c optional mem
-i386/i386/locore.s optional native no-obj
-i386/xen/locore.s optional xen no-obj
+i386/i386/locore.s standard no-obj
i386/i386/longrun.c optional cpu_enable_longrun
i386/i386/machdep.c standard
-i386/xen/xen_machdep.c optional xen
i386/i386/mem.c optional mem
i386/i386/minidump_machdep.c standard
i386/i386/mp_clock.c optional smp
-i386/i386/mp_machdep.c optional native smp
-i386/xen/mp_machdep.c optional xen smp
+i386/i386/mp_machdep.c optional smp
i386/i386/mp_watchdog.c optional mp_watchdog smp
-i386/i386/mpboot.s optional smp native
-i386/xen/mptable.c optional apic xen
+i386/i386/mpboot.s optional smp
i386/i386/perfmon.c optional perfmon
-i386/i386/pmap.c optional native
-i386/xen/pmap.c optional xen
+i386/i386/pmap.c standard
i386/i386/ptrace_machdep.c standard
i386/i386/stack_machdep.c optional ddb | stack
i386/i386/support.s standard
@@ -488,7 +483,6 @@ i386/ibcs2/ibcs2_util.c optional ibcs2
i386/ibcs2/ibcs2_xenix.c optional ibcs2
i386/ibcs2/ibcs2_xenix_sysent.c optional ibcs2
i386/ibcs2/imgact_coff.c optional ibcs2
-i386/xen/clock.c optional xen
i386/isa/elink.c optional ep | ie
i386/isa/npx.c optional npx
i386/isa/pmtimer.c optional pmtimer
@@ -531,9 +525,9 @@ i386/xbox/xboxfb.c optional xboxfb
dev/fb/boot_font.c optional xboxfb
i386/xbox/pic16l.s optional xbox
#
-# x86 real mode BIOS support, required by atkbdc/dpms/pci/vesa
+# x86 real mode BIOS support, required by dpms/pci/vesa
#
-compat/x86bios/x86bios.c optional x86bios | atkbd | dpms | pci | vesa
+compat/x86bios/x86bios.c optional x86bios | dpms | pci | vesa
#
# bvm console
#
@@ -565,9 +559,9 @@ x86/iommu/intel_qi.c optional acpi acpi_dmar pci
x86/iommu/intel_quirks.c optional acpi acpi_dmar pci
x86/iommu/intel_utils.c optional acpi acpi_dmar pci
x86/isa/atpic.c optional atpic
-x86/isa/atrtc.c optional native
-x86/isa/clock.c optional native
-x86/isa/elcr.c optional atpic | apic native
+x86/isa/atrtc.c standard
+x86/isa/clock.c standard
+x86/isa/elcr.c optional atpic | apic
x86/isa/isa.c optional isa
x86/isa/isa_dma.c optional isa
x86/isa/nmi.c standard
@@ -582,20 +576,20 @@ x86/x86/fdt_machdep.c optional fdt
x86/x86/identcpu.c standard
x86/x86/intr_machdep.c standard
x86/x86/io_apic.c optional apic
-x86/x86/legacy.c optional native
+x86/x86/legacy.c standard
x86/x86/local_apic.c optional apic
x86/x86/mca.c standard
-x86/x86/mptable.c optional apic native
-x86/x86/mptable_pci.c optional apic native pci
-x86/x86/mp_x86.c optional native smp
+x86/x86/mptable.c optional apic
+x86/x86/mptable_pci.c optional apic pci
+x86/x86/mp_x86.c optional smp
x86/x86/msi.c optional apic pci
x86/x86/nexus.c standard
x86/x86/tsc.c standard
x86/x86/pvclock.c standard
x86/x86/delay.c standard
x86/xen/hvm.c optional xenhvm
-x86/xen/xen_intr.c optional xen | xenhvm
+x86/xen/xen_intr.c optional xenhvm
x86/xen/xen_apic.c optional xenhvm
-x86/xen/xenpv.c optional xen | xenhvm
-x86/xen/xen_nexus.c optional xen | xenhvm
-x86/xen/xen_msi.c optional xen | xenhvm
+x86/xen/xenpv.c optional xenhvm
+x86/xen/xen_nexus.c optional xenhvm
+x86/xen/xen_msi.c optional xenhvm
diff --git a/sys/conf/files.powerpc b/sys/conf/files.powerpc
index ab585b0..4158f2c 100644
--- a/sys/conf/files.powerpc
+++ b/sys/conf/files.powerpc
@@ -43,6 +43,7 @@ dev/iicbus/ds1775.c optional ds1775 powermac
dev/iicbus/max6690.c optional max6690 powermac
dev/kbd/kbd.c optional sc | vt
dev/nand/nfc_fsl.c optional nand mpc85xx
+dev/nand/nfc_rb.c optional nand mpc85xx
# ofw can be either aim or fdt: fdt case handled in files. aim only powerpc specific.
dev/ofw/openfirm.c optional aim
dev/ofw/openfirmio.c optional aim
@@ -97,17 +98,16 @@ libkern/udivdi3.c optional powerpc
libkern/umoddi3.c optional powerpc
powerpc/aim/interrupt.c optional aim
powerpc/aim/locore.S optional aim no-obj
-powerpc/aim/machdep.c optional aim
+powerpc/aim/aim_machdep.c optional aim
powerpc/aim/mmu_oea.c optional aim powerpc
powerpc/aim/mmu_oea64.c optional aim
powerpc/aim/moea64_if.m optional aim
powerpc/aim/moea64_native.c optional aim
powerpc/aim/mp_cpudep.c optional aim
powerpc/aim/slb.c optional aim powerpc64
-powerpc/aim/uma_machdep.c optional aim
powerpc/booke/interrupt.c optional booke
powerpc/booke/locore.S optional booke no-obj
-powerpc/booke/machdep.c optional booke
+powerpc/booke/booke_machdep.c optional booke
powerpc/booke/machdep_e500.c optional booke_e500
powerpc/booke/mp_cpudep.c optional booke smp
powerpc/booke/platform_bare.c optional booke
@@ -138,6 +138,7 @@ powerpc/mpc85xx/mpc85xx.c optional mpc85xx
powerpc/mpc85xx/mpc85xx_gpio.c optional mpc85xx gpio
powerpc/mpc85xx/platform_mpc85xx.c optional mpc85xx
powerpc/mpc85xx/pci_mpc85xx.c optional pci mpc85xx
+powerpc/mpc85xx/pci_mpc85xx_pcib.c optional pci mpc85xx
powerpc/ofw/ofw_machdep.c standard
powerpc/ofw/ofw_pci.c optional pci
powerpc/ofw/ofw_pcibus.c optional pci
@@ -195,6 +196,7 @@ powerpc/powerpc/gdb_machdep.c optional gdb
powerpc/powerpc/in_cksum.c optional inet | inet6
powerpc/powerpc/intr_machdep.c standard
powerpc/powerpc/iommu_if.m standard
+powerpc/powerpc/machdep.c standard
powerpc/powerpc/mem.c optional mem
powerpc/powerpc/mmu_if.m standard
powerpc/powerpc/mp_machdep.c optional smp
@@ -217,6 +219,7 @@ powerpc/powerpc/syncicache.c standard
powerpc/powerpc/sys_machdep.c standard
powerpc/powerpc/trap.c standard
powerpc/powerpc/uio_machdep.c standard
+powerpc/powerpc/uma_machdep.c standard
powerpc/powerpc/vm_machdep.c standard
powerpc/ps3/ehci_ps3.c optional ps3 ehci
powerpc/ps3/ohci_ps3.c optional ps3 ohci
diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk
index 9a7ad61..8e76268 100644
--- a/sys/conf/kern.mk
+++ b/sys/conf/kern.mk
@@ -187,7 +187,7 @@ CFLAGS+= -fstack-protector
CFLAGS+= -gdwarf-2
.endif
-CFLAGS+= ${CWARNEXTRA} ${CWARNFLAGS} ${CWARNFLAGS.${.IMPSRC:T}}
+CFLAGS+= ${CWARNFLAGS} ${CWARNFLAGS.${.IMPSRC:T}}
CFLAGS+= ${CFLAGS.${COMPILER_TYPE}} ${CFLAGS.${.IMPSRC:T}}
# Tell bmake not to mistake standard targets for things to be searched for
diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk
index 99ada05..8c3b9c6 100644
--- a/sys/conf/kern.pre.mk
+++ b/sys/conf/kern.pre.mk
@@ -87,7 +87,7 @@ INCLUDES+= -I$S/dev/cxgb -I$S/dev/cxgbe
.endif
-CFLAGS= ${COPTFLAGS} ${DEBUG} ${CWARNFLAGS}
+CFLAGS= ${COPTFLAGS} ${DEBUG}
CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
CFLAGS_PARAM_INLINE_UNIT_GROWTH?=100
CFLAGS_PARAM_LARGE_FUNCTION_GROWTH?=1000
diff --git a/sys/conf/options b/sys/conf/options
index 2405442..eabd73c 100644
--- a/sys/conf/options
+++ b/sys/conf/options
@@ -432,6 +432,7 @@ ROUTETABLES opt_route.h
RSS opt_rss.h
SLIP_IFF_OPTS opt_slip.h
TCPDEBUG
+SIFTR
TCP_OFFLOAD opt_inet.h # Enable code to dispatch TCP offloading
TCP_SIGNATURE opt_inet.h
VLAN_ARRAY opt_vlan.h
@@ -691,6 +692,7 @@ ACPI_DEBUG opt_acpi.h
ACPI_MAX_TASKS opt_acpi.h
ACPI_MAX_THREADS opt_acpi.h
ACPI_DMAR opt_acpi.h
+DEV_ACPI opt_acpi.h
# ISA support
DEV_ISA opt_isa.h
@@ -859,6 +861,7 @@ DCONS_FORCE_CONSOLE opt_dcons.h
DCONS_FORCE_GDB opt_dcons.h
# HWPMC options
+HWPMC_DEBUG opt_global.h
HWPMC_HOOKS
HWPMC_MIPS_BACKTRACE opt_hwpmc_hooks.h
@@ -928,6 +931,7 @@ IPOIB_CM opt_ofed.h
# Resource Accounting
RACCT opt_global.h
+RACCT_DEFAULT_TO_DISABLED opt_global.h
# Resource Limits
RCTL opt_global.h
diff --git a/sys/conf/options.amd64 b/sys/conf/options.amd64
index f1d4b4a..0e59187 100644
--- a/sys/conf/options.amd64
+++ b/sys/conf/options.amd64
@@ -63,5 +63,7 @@ BPF_JITTER opt_bpf.h
XENHVM opt_global.h
+HYPERV opt_global.h
+
# options for the Intel C600 SAS driver (isci)
ISCI_LOGGING opt_isci.h
diff --git a/sys/conf/options.arm b/sys/conf/options.arm
index b712b02..9926706 100644
--- a/sys/conf/options.arm
+++ b/sys/conf/options.arm
@@ -21,6 +21,7 @@ CPU_XSCALE_81342 opt_global.h
CPU_XSCALE_IXP425 opt_global.h
CPU_XSCALE_IXP435 opt_global.h
CPU_XSCALE_PXA2X0 opt_global.h
+DEV_GIC opt_global.h
FLASHADDR opt_global.h
GIC_DEFAULT_ICFGR_INIT opt_global.h
IPI_IRQ_START opt_smp.h
diff --git a/sys/conf/options.arm64 b/sys/conf/options.arm64
index fff47ab..1dfcbec 100644
--- a/sys/conf/options.arm64
+++ b/sys/conf/options.arm64
@@ -1,4 +1,6 @@
# $FreeBSD$
ARM64 opt_global.h
+SOCDEV_PA opt_global.h
+SOCDEV_VA opt_global.h
VFP opt_global.h
diff --git a/sys/conf/options.i386 b/sys/conf/options.i386
index 0a1a52f..69eb7e3 100644
--- a/sys/conf/options.i386
+++ b/sys/conf/options.i386
@@ -121,9 +121,9 @@ NPX_DEBUG opt_npx.h
# BPF just-in-time compiler
BPF_JITTER opt_bpf.h
-NATIVE opt_global.h
-XEN opt_global.h
XENHVM opt_global.h
+HYPERV opt_global.h
+
# options for the Intel C600 SAS driver (isci)
ISCI_LOGGING opt_isci.h
diff --git a/sys/contrib/dev/acpica/changes.txt b/sys/contrib/dev/acpica/changes.txt
index ad9d23c..511652f 100644
--- a/sys/contrib/dev/acpica/changes.txt
+++ b/sys/contrib/dev/acpica/changes.txt
@@ -1,4 +1,52 @@
----------------------------------------
+08 April 2015. Summary of changes for version 20150515:
+
+This release implements most of ACPI 6.0 as described below.
+
+1) ACPICA kernel-resident subsystem:
+
+Implemented runtime argument checking and return value checking for all
+new ACPI 6.0 predefined names. This includes: _BTH, _CR3, _DSD, _LPI,
+_MTL, _PRR, _RDI, _RST, _TFP, _TSN.
+
+Example Code and Data Size: These are the sizes for the OS-independent
+acpica.lib produced by the Microsoft Visual C++ 9.0 32-bit compiler. The
+debug version of the code includes the debug output trace mechanism and
+has a much larger code and data size.
+
+ Current Release:
+ Non-Debug Version: 99.9K Code, 27.5K Data, 127.4K Total
+ Debug Version: 195.2K Code, 80.8K Data, 276.0K Total
+ Previous Release:
+ Non-Debug Version: 99.1K Code, 27.3K Data, 126.4K Total
+ Debug Version: 192.8K Code, 79.9K Data, 272.7K Total
+
+
+2) iASL Compiler/Disassembler and Tools:
+
+iASL compiler: Added compile-time support for all new ACPI 6.0 predefined
+names (argument count validation and return value typechecking.)
+
+iASL disassembler and table compiler: implemented support for all new
+ACPI 6.0 tables. This includes: DRTM, IORT, LPIT, NFIT, STAO, WPBT, XENV.
+
+iASL disassembler and table compiler: Added ACPI 6.0 changes to existing
+tables: FADT, MADT.
+
+iASL preprocessor: Added a new directive to enable inclusion of binary
+blobs into ASL code. The new directive is #includebinary. It takes a
+binary file as input and emits a named ascii buffer object into the ASL
+code.
+
+AcpiHelp: Added support for all new ACPI 6.0 predefined names.
+
+AcpiHelp: Added a new option, -d, to display all iASL preprocessor
+directives.
+
+AcpiHelp: Added a new option, -t, to display all known/supported ACPI
+tables.
+
+----------------------------------------
10 April 2015. Summary of changes for version 20150410:
Reverted a change introduced in version 20150408 that caused
diff --git a/sys/contrib/dev/acpica/common/adisasm.c b/sys/contrib/dev/acpica/common/adisasm.c
index 658b5be..5d0cee2 100644
--- a/sys/contrib/dev/acpica/common/adisasm.c
+++ b/sys/contrib/dev/acpica/common/adisasm.c
@@ -214,6 +214,7 @@ AdAmlDisassemble (
char **OutFilename)
{
ACPI_STATUS Status;
+ ACPI_STATUS GlobalStatus = AE_OK;
char *DisasmFilename = NULL;
char *ExternalFilename;
ACPI_EXTERNAL_FILE *ExternalFileList = AcpiGbl_ExternalFileList;
@@ -229,7 +230,7 @@ AdAmlDisassemble (
*/
if (Filename)
{
- Status = AcpiDbGetTableFromFile (Filename, &Table);
+ Status = AcpiDbGetTableFromFile (Filename, &Table, FALSE);
if (ACPI_FAILURE (Status))
{
return (Status);
@@ -250,9 +251,16 @@ AdAmlDisassemble (
continue;
}
- Status = AcpiDbGetTableFromFile (ExternalFilename, &ExternalTable);
+ Status = AcpiDbGetTableFromFile (ExternalFilename, &ExternalTable, TRUE);
if (ACPI_FAILURE (Status))
{
+ if (Status == AE_TYPE)
+ {
+ ExternalFileList = ExternalFileList->Next;
+ GlobalStatus = AE_TYPE;
+ Status = AE_OK;
+ continue;
+ }
return (Status);
}
@@ -282,6 +290,11 @@ AdAmlDisassemble (
ExternalFileList = ExternalFileList->Next;
}
+ if (ACPI_FAILURE (GlobalStatus))
+ {
+ return (GlobalStatus);
+ }
+
/* Clear external list generated by Scope in external tables */
if (AcpiGbl_ExternalFileList)
diff --git a/sys/contrib/dev/acpica/common/ahpredef.c b/sys/contrib/dev/acpica/common/ahpredef.c
index a84353b..1454880 100644
--- a/sys/contrib/dev/acpica/common/ahpredef.c
+++ b/sys/contrib/dev/acpica/common/ahpredef.c
@@ -94,6 +94,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] =
AH_PREDEF ("_BMS", "Battery Measurement Sampling Time", "Sets the battery measurement sampling time"),
AH_PREDEF ("_BQC", "Brightness Query Current", "Returns the current display brightness level"),
AH_PREDEF ("_BST", "Battery Status", "Returns a Control Method Battery status block"),
+ AH_PREDEF ("_BTH", "Battery Throttle Limit", "Thermal limit for charging and discharging"),
AH_PREDEF ("_BTM", "Battery Time", "Returns the battery runtime"),
AH_PREDEF ("_BTP", "Battery Trip Point", "Sets a Control Method Battery trip point"),
AH_PREDEF ("_CBA", "Configuration Base Address", "Sets the base address for a PCI Express host bridge"),
@@ -102,6 +103,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] =
AH_PREDEF ("_CID", "Compatible ID", "Returns a device's Plug and Play Compatible ID list"),
AH_PREDEF ("_CLS", "Class Code", "Returns PCI class code and subclass"),
AH_PREDEF ("_CPC", "Continuous Performance Control", "Returns a list of performance control interfaces"),
+ AH_PREDEF ("_CR3", "Warm/Standby Temperature", "Temperature for a fast low power state"),
AH_PREDEF ("_CRS", "Current Resource Settings", "Returns the current resource settings for a device"),
AH_PREDEF ("_CRT", "Critical Temperature", "Returns the shutdown critical temperature"),
AH_PREDEF ("_CSD", "C-State Dependencies", "Returns a list of C-state dependencies"),
@@ -175,6 +177,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] =
AH_PREDEF ("_LIN", "Lines In Use", "Handshake lines, Resource Descriptor field"),
AH_PREDEF ("_LL_", "Low Level", "Interrupt polarity, Resource Descriptor field"),
AH_PREDEF ("_LPD", "Low Power Dependencies", "Returns a list of dependencies for low power idle entry"),
+ AH_PREDEF ("_LPI", "Low Power Idle States", "Returns a list of supported low power idle states"),
AH_PREDEF ("_MAF", "Maximum Address Fixed", "Resource Descriptor field"),
AH_PREDEF ("_MAT", "Multiple APIC Table Entry", "Returns a list of MADT APIC structure entries"),
AH_PREDEF ("_MAX", "Maximum Base Address", "Resource Descriptor field"),
@@ -186,6 +189,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] =
AH_PREDEF ("_MOD", "Mode", "Interrupt mode, Resource Descriptor field"),
AH_PREDEF ("_MSG", "Message", "Sets the system message waiting status indicator"),
AH_PREDEF ("_MSM", "Memory Set Monitoring", "Sets bandwidth monitoring parameters for a memory device"),
+ AH_PREDEF ("_MTL", "Minimum Throttle Limit", "Returns the minimum throttle limit for a thermal zone"),
AH_PREDEF ("_MTP", "Memory Type", "Resource Descriptor field"),
AH_PREDEF ("_NTT", "Notification Temperature Threshold", "Returns a threshold for device temperature change that requires platform notification"),
AH_PREDEF ("_OFF", "Power Off", "Sets a power resource to the off state"),
@@ -209,7 +213,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] =
AH_PREDEF ("_PMD", "Power Metered Devices", "Returns a list of devices that are measured by the power meter device"),
AH_PREDEF ("_PMM", "Power Meter Measurement", "Returns the current value of the Power Meter"),
AH_PREDEF ("_POL", "Polarity", "Interrupt polarity, Resource Descriptor field"),
- AH_PREDEF ("_PPC", "Performance Present Capabilites", "Returns a list of the performance states currently supported by the platform"),
+ AH_PREDEF ("_PPC", "Performance Present Capabilities", "Returns a list of the performance states currently supported by the platform"),
AH_PREDEF ("_PPE", "Polling for Platform Error", "Returns the polling interval to retrieve Corrected Platform Error information"),
AH_PREDEF ("_PPI", "Pin Configuration", "Resource Descriptor field"),
AH_PREDEF ("_PR", "Processor", "Predefined scope for processor objects"),
@@ -219,6 +223,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] =
AH_PREDEF ("_PR3", "Power Resources for D3hot", "Returns a list of dependent power resources to enter state D3hot"),
AH_PREDEF ("_PRE", "Power Resources for Enumeration", "Returns a list of dependent power resources to enumerate devices on a bus"),
AH_PREDEF ("_PRL", "Power Source Redundancy List", "Returns a list of power source devices in the same redundancy grouping"),
+ AH_PREDEF ("_PRR", "Power Resource for Reset", "Execute a reset on a device"),
AH_PREDEF ("_PRS", "Possible Resource Settings", "Returns a list of a device's possible resource settings"),
AH_PREDEF ("_PRT", "PCI Routing Table", "Returns a list of PCI interrupt mappings"),
AH_PREDEF ("_PRW", "Power Resources for Wake", "Returns a list of dependent power resources for waking"),
@@ -242,10 +247,12 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] =
AH_PREDEF ("_Qxx", "EC Query", "Embedded Controller query and SMBus Alarm control method"),
AH_PREDEF ("_RBO", "Register Bit Offset", "Resource Descriptor field"),
AH_PREDEF ("_RBW", "Register Bit Width", "Resource Descriptor field"),
+ AH_PREDEF ("_RDI", "Resource Dependencies for Idle", "Returns a list of dependencies for idle states"),
AH_PREDEF ("_REG", "Region Availability", "Inform AML code of an operation region availability change"),
AH_PREDEF ("_REV", "Supported ACPI Revision", "Returns the revision of the ACPI specification that is implemented"),
AH_PREDEF ("_RMV", "Removal Status", "Returns a device's removal ability status (docking)"),
AH_PREDEF ("_RNG", "Range", "Memory range type, Resource Descriptor field"),
+ AH_PREDEF ("_RST", "Device Reset", "Executes a reset on a device"),
AH_PREDEF ("_ROM", "Read-Only Memory", "Returns a copy of the ROM data for a display device"),
AH_PREDEF ("_RT_", "Resource Type", "Resource Descriptor field"),
AH_PREDEF ("_RTV", "Relative Temperature Values", "Returns temperature value information"),
@@ -296,6 +303,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] =
AH_PREDEF ("_TC1", "Thermal Constant 1", "Returns TC1 for the passive cooling formula"),
AH_PREDEF ("_TC2", "Thermal Constant 2", "Returns TC2 for the passive cooling formula"),
AH_PREDEF ("_TDL", "T-State Depth Limit", "Returns the _TSS entry number of the lowest power throttling state"),
+ AH_PREDEF ("_TFP", "Thermal Fast Sampling Period", "Returns the sampling period for passive cooling"),
AH_PREDEF ("_TIP", "Expired Timer Wake Policy", "Returns timer policies of the wake alarm device"),
AH_PREDEF ("_TIV", "Timer Values", "Returns remaining time of the wake alarm device"),
AH_PREDEF ("_TMP", "Temperature", "Returns a thermal zone's current temperature"),
@@ -306,6 +314,7 @@ const AH_PREDEFINED_NAME AslPredefinedInfo[] =
AH_PREDEF ("_TRT", "Thermal Relationship Table", "Returns thermal relationships between platform devices"),
AH_PREDEF ("_TSD", "Throttling State Dependencies", "Returns a list of T-state dependencies"),
AH_PREDEF ("_TSF", "Type-Specific Flags", "Resource Descriptor field"),
+ AH_PREDEF ("_TSN", "Thermal Sensor Device", "Returns a reference to a thermal sensor"),
AH_PREDEF ("_TSP", "Thermal Sampling Period", "Returns the thermal sampling period for passive cooling"),
AH_PREDEF ("_TSS", "Throttling Supported States", "Returns supported throttling state information"),
AH_PREDEF ("_TST", "Temperature Sensor Threshold", "Returns the minimum separation for a device's temperature trip points"),
diff --git a/sys/contrib/dev/acpica/common/ahtable.c b/sys/contrib/dev/acpica/common/ahtable.c
new file mode 100644
index 0000000..d4ce436
--- /dev/null
+++ b/sys/contrib/dev/acpica/common/ahtable.c
@@ -0,0 +1,150 @@
+/******************************************************************************
+ *
+ * Module Name: ahtable - Table of known ACPI tables with descriptions
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2015, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that 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. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may 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
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <contrib/dev/acpica/include/accommon.h>
+
+
+/* Local prototypes */
+
+const AH_TABLE *
+AcpiAhGetTableInfo (
+ char *Signature);
+
+extern const AH_TABLE AcpiSupportedTables[];
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiAhGetTableInfo
+ *
+ * PARAMETERS: Signature - ACPI signature (4 chars) to match
+ *
+ * RETURN: Pointer to a valid AH_TABLE. Null if no match found.
+ *
+ * DESCRIPTION: Find a match in the "help" table of supported ACPI tables
+ *
+ ******************************************************************************/
+
+const AH_TABLE *
+AcpiAhGetTableInfo (
+ char *Signature)
+{
+ const AH_TABLE *Info;
+
+
+ for (Info = AcpiSupportedTables; Info->Signature; Info++)
+ {
+ if (ACPI_COMPARE_NAME (Signature, Info->Signature))
+ {
+ return (Info);
+ }
+ }
+
+ return (NULL);
+}
+
+
+/*
+ * Note: Any tables added here should be duplicated within AcpiDmTableData
+ * in the file common/dmtable.c
+ */
+const AH_TABLE AcpiSupportedTables[] =
+{
+ {ACPI_SIG_ASF, "Alert Standard Format table"},
+ {ACPI_SIG_BERT, "Boot Error Record Table"},
+ {ACPI_SIG_BGRT, "Boot Graphics Resource Table"},
+ {ACPI_SIG_BOOT, "Simple Boot Flag Table"},
+ {ACPI_SIG_CPEP, "Corrected Platform Error Polling table"},
+ {ACPI_SIG_CSRT, "Core System Resource Table"},
+ {ACPI_SIG_DBG2, "Debug Port table type 2"},
+ {ACPI_SIG_DBGP, "Debug Port table"},
+ {ACPI_SIG_DMAR, "DMA Remapping table"},
+ {ACPI_SIG_DRTM, "Dynamic Root of Trust for Measurement table"},
+ {ACPI_SIG_DSDT, "Differentiated System Description Table (AML table)"},
+ {ACPI_SIG_ECDT, "Embedded Controller Boot Resources Table"},
+ {ACPI_SIG_EINJ, "Error Injection table"},
+ {ACPI_SIG_ERST, "Error Record Serialization Table"},
+ {ACPI_SIG_FACS, "Firmware ACPI Control Structure"},
+ {ACPI_SIG_FADT, "Fixed ACPI Description Table (FADT)"},
+ {ACPI_SIG_FPDT, "Firmware Performance Data Table"},
+ {ACPI_SIG_GTDT, "Generic Timer Description Table"},
+ {ACPI_SIG_HEST, "Hardware Error Source Table"},
+ {ACPI_SIG_HPET, "High Precision Event Timer table"},
+ {ACPI_SIG_IORT, "IO Remapping Table"},
+ {ACPI_SIG_IVRS, "I/O Virtualization Reporting Structure"},
+ {ACPI_SIG_LPIT, "Low Power Idle Table"},
+ {ACPI_SIG_MADT, "Multiple APIC Description Table (MADT)"},
+ {ACPI_SIG_MCFG, "Memory Mapped Configuration table"},
+ {ACPI_SIG_MCHI, "Management Controller Host Interface table"},
+ {ACPI_SIG_MPST, "Memory Power State Table"},
+ {ACPI_SIG_MSCT, "Maximum System Characteristics Table"},
+ {ACPI_SIG_MSDM, "Microsoft Data Management table"},
+ {ACPI_SIG_MTMR, "MID Timer Table"},
+ {ACPI_SIG_NFIT, "NVDIMM Firmware Interface Table"},
+ {ACPI_SIG_PCCT, "Platform Communications Channel Table"},
+ {ACPI_SIG_PMTT, "Platform Memory Topology Table"},
+ {ACPI_RSDP_NAME,"Root System Description Pointer"},
+ {ACPI_SIG_RSDT, "Root System Description Table"},
+ {ACPI_SIG_S3PT, "S3 Performance Table"},
+ {ACPI_SIG_SBST, "Smart Battery Specification Table"},
+ {ACPI_SIG_SLIC, "Software Licensing Description Table"},
+ {ACPI_SIG_SLIT, "System Locality Information Table"},
+ {ACPI_SIG_SPCR, "Serial Port Console Redirection table"},
+ {ACPI_SIG_SPMI, "Server Platform Management Interface table"},
+ {ACPI_SIG_SRAT, "System Resource Affinity Table"},
+ {ACPI_SIG_SSDT, "Secondary System Description Table (AML table)"},
+ {ACPI_SIG_STAO, "Status Override table"},
+ {ACPI_SIG_TCPA, "Trusted Computing Platform Alliance table"},
+ {ACPI_SIG_TPM2, "Trusted Platform Module hardware interface table"},
+ {ACPI_SIG_UEFI, "UEFI Boot Optimization Table"},
+ {ACPI_SIG_VRTC, "Virtual Real-Time Clock Table"},
+ {ACPI_SIG_WAET, "Windows ACPI Emulated Devices Table"},
+ {ACPI_SIG_WDAT, "Watchdog Action Table"},
+ {ACPI_SIG_WDDT, "Watchdog Description Table"},
+ {ACPI_SIG_WDRT, "Watchdog Resource Table"},
+ {ACPI_SIG_WPBT, "Windows Platform Binary Table"},
+ {ACPI_SIG_XENV, "Xen Environment table"},
+ {ACPI_SIG_XSDT, "Extended System Description Table"},
+ {NULL, NULL}
+};
diff --git a/sys/contrib/dev/acpica/common/dmextern.c b/sys/contrib/dev/acpica/common/dmextern.c
index 0c262c4..2ea54ad 100644
--- a/sys/contrib/dev/acpica/common/dmextern.c
+++ b/sys/contrib/dev/acpica/common/dmextern.c
@@ -1286,7 +1286,9 @@ AcpiDmUnresolvedWarning (
" * compile because the disassembler did not know how many arguments\n"
" * to assign to these methods. To specify the tables needed to resolve\n"
" * external control method references, the -e option can be used to\n"
- " * specify the filenames. Example iASL invocations:\n"
+ " * specify the filenames. Note: SSDTs can be dynamically loaded at\n"
+ " * runtime and may or may not be available via the host OS.\n"
+ " * Example iASL invocations:\n"
" * iasl -e ssdt1.aml ssdt2.aml ssdt3.aml -d dsdt.aml\n"
" * iasl -e dsdt.aml ssdt2.aml -d ssdt1.aml\n"
" * iasl -e ssdt*.aml -d dsdt.aml\n"
@@ -1314,7 +1316,8 @@ AcpiDmUnresolvedWarning (
" * ACPI tables may be required to properly disassemble the code. This\n"
" * resulting disassembler output file may not compile because the\n"
" * disassembler did not know how many arguments to assign to the\n"
- " * unresolved methods.\n"
+ " * unresolved methods. Note: SSDTs can be dynamically loaded at\n"
+ " * runtime and may or may not be available via the host OS.\n"
" *\n"
" * If necessary, the -fe option can be used to specify a file containing\n"
" * control method external declarations with the associated method\n"
@@ -1345,7 +1348,9 @@ AcpiDmUnresolvedWarning (
"compile because the disassembler did not know how many arguments\n"
"to assign to these methods. To specify the tables needed to resolve\n"
"external control method references, the -e option can be used to\n"
- "specify the filenames. Example iASL invocations:\n"
+ "specify the filenames. Note: SSDTs can be dynamically loaded at\n"
+ "runtime and may or may not be available via the host OS.\n"
+ "Example iASL invocations:\n"
" iasl -e ssdt1.aml ssdt2.aml ssdt3.aml -d dsdt.aml\n"
" iasl -e dsdt.aml ssdt2.aml -d ssdt1.aml\n"
" iasl -e ssdt*.aml -d dsdt.aml\n"
@@ -1368,7 +1373,8 @@ AcpiDmUnresolvedWarning (
"ACPI tables may be required to properly disassemble the code. The\n"
"resulting disassembler output file may not compile because the\n"
"disassembler did not know how many arguments to assign to the\n"
- "unresolved methods.\n"
+ "unresolved methods. Note: SSDTs can be dynamically loaded at\n"
+ "runtime and may or may not be available via the host OS.\n"
"\n"
"If necessary, the -fe option can be used to specify a file containing\n"
"control method external declarations with the associated method\n"
diff --git a/sys/contrib/dev/acpica/common/dmtable.c b/sys/contrib/dev/acpica/common/dmtable.c
index b1875f8..3820c94 100644
--- a/sys/contrib/dev/acpica/common/dmtable.c
+++ b/sys/contrib/dev/acpica/common/dmtable.c
@@ -53,6 +53,11 @@
#define _COMPONENT ACPI_CA_DISASSEMBLER
ACPI_MODULE_NAME ("dmtable")
+const AH_TABLE *
+AcpiAhGetTableInfo (
+ char *Signature);
+
+
/* Local Prototypes */
static void
@@ -78,7 +83,7 @@ static const char *AcpiDmAsfSubnames[] =
"ASF Remote Control",
"ASF RMCP Boot Options",
"ASF Address",
- "Unknown SubTable Type" /* Reserved */
+ "Unknown Subtable Type" /* Reserved */
};
static const char *AcpiDmDmarSubnames[] =
@@ -88,7 +93,7 @@ static const char *AcpiDmDmarSubnames[] =
"Root Port ATS Capability",
"Remapping Hardware Static Affinity",
"ACPI Namespace Device Declaration",
- "Unknown SubTable Type" /* Reserved */
+ "Unknown Subtable Type" /* Reserved */
};
static const char *AcpiDmDmarScope[] =
@@ -176,7 +181,7 @@ static const char *AcpiDmGtdtSubnames[] =
{
"Generic Timer Block",
"Generic Watchdog Timer",
- "Unknown SubTable Type" /* Reserved */
+ "Unknown Subtable Type" /* Reserved */
};
static const char *AcpiDmHestSubnames[] =
@@ -191,7 +196,7 @@ static const char *AcpiDmHestSubnames[] =
"PCI Express AER (AER Endpoint)",
"PCI Express/PCI-X Bridge AER",
"Generic Hardware Error Source",
- "Unknown SubTable Type" /* Reserved */
+ "Unknown Subtable Type" /* Reserved */
};
static const char *AcpiDmHestNotifySubnames[] =
@@ -223,14 +228,27 @@ static const char *AcpiDmMadtSubnames[] =
"Generic Interrupt Distributor", /* ACPI_MADT_GENERIC_DISTRIBUTOR */
"Generic MSI Frame", /* ACPI_MADT_GENERIC_MSI_FRAME */
"Generic Interrupt Redistributor", /* ACPI_MADT_GENERIC_REDISTRIBUTOR */
- "Unknown SubTable Type" /* Reserved */
+ "Generic Interrupt Translator", /* ACPI_MADT_GENERIC_TRANSLATOR */
+ "Unknown Subtable Type" /* Reserved */
+};
+
+static const char *AcpiDmNfitSubnames[] =
+{
+ "System Physical Address Range", /* ACPI_NFIT_TYPE_SYSTEM_ADDRESS */
+ "Memory Range Map", /* ACPI_NFIT_TYPE_MEMORY_MAP */
+ "Interleave Info", /* ACPI_NFIT_TYPE_INTERLEAVE */
+ "SMBIOS Information", /* ACPI_NFIT_TYPE_SMBIOS */
+ "NVDIMM Control Region", /* ACPI_NFIT_TYPE_CONTROL_REGION */
+ "NVDIMM Block Data Window Region", /* ACPI_NFIT_TYPE_DATA_REGION */
+ "Flush Hint Address", /* ACPI_NFIT_TYPE_FLUSH_ADDRESS */
+ "Unknown Subtable Type" /* Reserved */
};
static const char *AcpiDmPcctSubnames[] =
{
"Generic Communications Subspace", /* ACPI_PCCT_TYPE_GENERIC_SUBSPACE */
- "HW-Reduced Communications Subspace",
- "Unknown SubTable Type" /* Reserved */
+ "HW-Reduced Comm Subspace", /* ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE */
+ "Unknown Subtable Type" /* Reserved */
};
static const char *AcpiDmPmttSubnames[] =
@@ -238,7 +256,7 @@ static const char *AcpiDmPmttSubnames[] =
"Socket", /* ACPI_PMTT_TYPE_SOCKET */
"Memory Controller", /* ACPI_PMTT_TYPE_CONTROLLER */
"Physical Component (DIMM)", /* ACPI_PMTT_TYPE_DIMM */
- "Unknown SubTable Type" /* Reserved */
+ "Unknown Subtable Type" /* Reserved */
};
static const char *AcpiDmSratSubnames[] =
@@ -247,21 +265,20 @@ static const char *AcpiDmSratSubnames[] =
"Memory Affinity",
"Processor Local x2APIC Affinity",
"GICC Affinity",
- "Unknown SubTable Type" /* Reserved */
+ "Unknown Subtable Type" /* Reserved */
};
static const char *AcpiDmIvrsSubnames[] =
{
"Hardware Definition Block",
"Memory Definition Block",
- "Unknown SubTable Type" /* Reserved */
+ "Unknown Subtable Type" /* Reserved */
};
static const char *AcpiDmLpitSubnames[] =
{
"Native C-state Idle Structure",
- "Simple I/O Idle Structure",
- "Unknown SubTable Type" /* Reserved */
+ "Unknown Subtable Type" /* Reserved */
};
#define ACPI_FADT_PM_RESERVED 9
@@ -304,56 +321,65 @@ static const char *AcpiDmGasAccessWidth[] =
* handler. This table must be NULL terminated. RSDP and FACS are
* special-cased elsewhere.
*
+ * Note: Any tables added here should be duplicated within AcpiSupportedTables
+ * in the file common/ahtable.c
+ *
******************************************************************************/
-ACPI_DMTABLE_DATA AcpiDmTableData[] =
+const ACPI_DMTABLE_DATA AcpiDmTableData[] =
{
- {ACPI_SIG_ASF, NULL, AcpiDmDumpAsf, DtCompileAsf, TemplateAsf, "Alert Standard Format table"},
- {ACPI_SIG_BERT, AcpiDmTableInfoBert, NULL, NULL, TemplateBert, "Boot Error Record Table"},
- {ACPI_SIG_BGRT, AcpiDmTableInfoBgrt, NULL, NULL, TemplateBgrt, "Boot Graphics Resource Table"},
- {ACPI_SIG_BOOT, AcpiDmTableInfoBoot, NULL, NULL, TemplateBoot, "Simple Boot Flag Table"},
- {ACPI_SIG_CPEP, NULL, AcpiDmDumpCpep, DtCompileCpep, TemplateCpep, "Corrected Platform Error Polling table"},
- {ACPI_SIG_CSRT, NULL, AcpiDmDumpCsrt, DtCompileCsrt, TemplateCsrt, "Core System Resource Table"},
- {ACPI_SIG_DBG2, AcpiDmTableInfoDbg2, AcpiDmDumpDbg2, DtCompileDbg2, TemplateDbg2, "Debug Port table type 2"},
- {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp, NULL, NULL, TemplateDbgp, "Debug Port table"},
- {ACPI_SIG_DMAR, NULL, AcpiDmDumpDmar, DtCompileDmar, TemplateDmar, "DMA Remapping table"},
- {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt, NULL, NULL, TemplateEcdt, "Embedded Controller Boot Resources Table"},
- {ACPI_SIG_EINJ, NULL, AcpiDmDumpEinj, DtCompileEinj, TemplateEinj, "Error Injection table"},
- {ACPI_SIG_ERST, NULL, AcpiDmDumpErst, DtCompileErst, TemplateErst, "Error Record Serialization Table"},
- {ACPI_SIG_FADT, NULL, AcpiDmDumpFadt, DtCompileFadt, TemplateFadt, "Fixed ACPI Description Table (FADT)"},
- {ACPI_SIG_FPDT, NULL, AcpiDmDumpFpdt, DtCompileFpdt, TemplateFpdt, "Firmware Performance Data Table"},
- {ACPI_SIG_GTDT, NULL, AcpiDmDumpGtdt, DtCompileGtdt, TemplateGtdt, "Generic Timer Description Table"},
- {ACPI_SIG_HEST, NULL, AcpiDmDumpHest, DtCompileHest, TemplateHest, "Hardware Error Source Table"},
- {ACPI_SIG_HPET, AcpiDmTableInfoHpet, NULL, NULL, TemplateHpet, "High Precision Event Timer table"},
- {ACPI_SIG_IVRS, NULL, AcpiDmDumpIvrs, DtCompileIvrs, TemplateIvrs, "I/O Virtualization Reporting Structure"},
- {ACPI_SIG_LPIT, NULL, AcpiDmDumpLpit, DtCompileLpit, TemplateLpit, "Low Power Idle Table"},
- {ACPI_SIG_MADT, NULL, AcpiDmDumpMadt, DtCompileMadt, TemplateMadt, "Multiple APIC Description Table (MADT)"},
- {ACPI_SIG_MCFG, NULL, AcpiDmDumpMcfg, DtCompileMcfg, TemplateMcfg, "Memory Mapped Configuration table"},
- {ACPI_SIG_MCHI, AcpiDmTableInfoMchi, NULL, NULL, TemplateMchi, "Management Controller Host Interface table"},
- {ACPI_SIG_MPST, AcpiDmTableInfoMpst, AcpiDmDumpMpst, DtCompileMpst, TemplateMpst, "Memory Power State Table"},
- {ACPI_SIG_MSCT, NULL, AcpiDmDumpMsct, DtCompileMsct, TemplateMsct, "Maximum System Characteristics Table"},
- {ACPI_SIG_MSDM, NULL, AcpiDmDumpSlic, DtCompileSlic, TemplateMsdm, "Microsoft Data Management table"},
- {ACPI_SIG_MTMR, NULL, AcpiDmDumpMtmr, DtCompileMtmr, TemplateMtmr, "MID Timer Table"},
- {ACPI_SIG_PCCT, AcpiDmTableInfoPcct, AcpiDmDumpPcct, DtCompilePcct, TemplatePcct, "Platform Communications Channel Table"},
- {ACPI_SIG_PMTT, NULL, AcpiDmDumpPmtt, DtCompilePmtt, TemplatePmtt, "Platform Memory Topology Table"},
- {ACPI_SIG_RSDT, NULL, AcpiDmDumpRsdt, DtCompileRsdt, TemplateRsdt, "Root System Description Table"},
- {ACPI_SIG_S3PT, NULL, NULL, NULL, TemplateS3pt, "S3 Performance Table"},
- {ACPI_SIG_SBST, AcpiDmTableInfoSbst, NULL, NULL, TemplateSbst, "Smart Battery Specification Table"},
- {ACPI_SIG_SLIC, NULL, AcpiDmDumpSlic, DtCompileSlic, TemplateSlic, "Software Licensing Description Table"},
- {ACPI_SIG_SLIT, NULL, AcpiDmDumpSlit, DtCompileSlit, TemplateSlit, "System Locality Information Table"},
- {ACPI_SIG_SPCR, AcpiDmTableInfoSpcr, NULL, NULL, TemplateSpcr, "Serial Port Console Redirection table"},
- {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi, NULL, NULL, TemplateSpmi, "Server Platform Management Interface table"},
- {ACPI_SIG_SRAT, NULL, AcpiDmDumpSrat, DtCompileSrat, TemplateSrat, "System Resource Affinity Table"},
- {ACPI_SIG_TCPA, AcpiDmTableInfoTcpa, NULL, NULL, TemplateTcpa, "Trusted Computing Platform Alliance table"},
- {ACPI_SIG_TPM2, AcpiDmTableInfoTpm2, NULL, NULL, TemplateTpm2, "Trusted Platform Module hardware interface table"},
- {ACPI_SIG_UEFI, AcpiDmTableInfoUefi, NULL, DtCompileUefi, TemplateUefi, "UEFI Boot Optimization Table"},
- {ACPI_SIG_VRTC, AcpiDmTableInfoVrtc, AcpiDmDumpVrtc, DtCompileVrtc, TemplateVrtc, "Virtual Real-Time Clock Table"},
- {ACPI_SIG_WAET, AcpiDmTableInfoWaet, NULL, NULL, TemplateWaet, "Windows ACPI Emulated Devices Table"},
- {ACPI_SIG_WDAT, NULL, AcpiDmDumpWdat, DtCompileWdat, TemplateWdat, "Watchdog Action Table"},
- {ACPI_SIG_WDDT, AcpiDmTableInfoWddt, NULL, NULL, TemplateWddt, "Watchdog Description Table"},
- {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt, NULL, NULL, TemplateWdrt, "Watchdog Resource Table"},
- {ACPI_SIG_XSDT, NULL, AcpiDmDumpXsdt, DtCompileXsdt, TemplateXsdt, "Extended System Description Table"},
- {NULL, NULL, NULL, NULL, NULL, NULL}
+ {ACPI_SIG_ASF, NULL, AcpiDmDumpAsf, DtCompileAsf, TemplateAsf},
+ {ACPI_SIG_BERT, AcpiDmTableInfoBert, NULL, NULL, TemplateBert},
+ {ACPI_SIG_BGRT, AcpiDmTableInfoBgrt, NULL, NULL, TemplateBgrt},
+ {ACPI_SIG_BOOT, AcpiDmTableInfoBoot, NULL, NULL, TemplateBoot},
+ {ACPI_SIG_CPEP, NULL, AcpiDmDumpCpep, DtCompileCpep, TemplateCpep},
+ {ACPI_SIG_CSRT, NULL, AcpiDmDumpCsrt, DtCompileCsrt, TemplateCsrt},
+ {ACPI_SIG_DBG2, AcpiDmTableInfoDbg2, AcpiDmDumpDbg2, DtCompileDbg2, TemplateDbg2},
+ {ACPI_SIG_DBGP, AcpiDmTableInfoDbgp, NULL, NULL, TemplateDbgp},
+ {ACPI_SIG_DMAR, NULL, AcpiDmDumpDmar, DtCompileDmar, TemplateDmar},
+ {ACPI_SIG_DRTM, NULL, AcpiDmDumpDrtm, DtCompileDrtm, TemplateDrtm},
+ {ACPI_SIG_ECDT, AcpiDmTableInfoEcdt, NULL, NULL, TemplateEcdt},
+ {ACPI_SIG_EINJ, NULL, AcpiDmDumpEinj, DtCompileEinj, TemplateEinj},
+ {ACPI_SIG_ERST, NULL, AcpiDmDumpErst, DtCompileErst, TemplateErst},
+ {ACPI_SIG_FADT, NULL, AcpiDmDumpFadt, DtCompileFadt, TemplateFadt},
+ {ACPI_SIG_FPDT, NULL, AcpiDmDumpFpdt, DtCompileFpdt, TemplateFpdt},
+ {ACPI_SIG_GTDT, NULL, AcpiDmDumpGtdt, DtCompileGtdt, TemplateGtdt},
+ {ACPI_SIG_HEST, NULL, AcpiDmDumpHest, DtCompileHest, TemplateHest},
+ {ACPI_SIG_HPET, AcpiDmTableInfoHpet, NULL, NULL, TemplateHpet},
+ {ACPI_SIG_IORT, NULL, AcpiDmDumpIort, DtCompileIort, TemplateIort},
+ {ACPI_SIG_IVRS, NULL, AcpiDmDumpIvrs, DtCompileIvrs, TemplateIvrs},
+ {ACPI_SIG_LPIT, NULL, AcpiDmDumpLpit, DtCompileLpit, TemplateLpit},
+ {ACPI_SIG_MADT, NULL, AcpiDmDumpMadt, DtCompileMadt, TemplateMadt},
+ {ACPI_SIG_MCFG, NULL, AcpiDmDumpMcfg, DtCompileMcfg, TemplateMcfg},
+ {ACPI_SIG_MCHI, AcpiDmTableInfoMchi, NULL, NULL, TemplateMchi},
+ {ACPI_SIG_MPST, AcpiDmTableInfoMpst, AcpiDmDumpMpst, DtCompileMpst, TemplateMpst},
+ {ACPI_SIG_MSCT, NULL, AcpiDmDumpMsct, DtCompileMsct, TemplateMsct},
+ {ACPI_SIG_MSDM, NULL, AcpiDmDumpSlic, DtCompileSlic, TemplateMsdm},
+ {ACPI_SIG_MTMR, NULL, AcpiDmDumpMtmr, DtCompileMtmr, TemplateMtmr},
+ {ACPI_SIG_NFIT, AcpiDmTableInfoNfit, AcpiDmDumpNfit, DtCompileNfit, TemplateNfit},
+ {ACPI_SIG_PCCT, AcpiDmTableInfoPcct, AcpiDmDumpPcct, DtCompilePcct, TemplatePcct},
+ {ACPI_SIG_PMTT, NULL, AcpiDmDumpPmtt, DtCompilePmtt, TemplatePmtt},
+ {ACPI_SIG_RSDT, NULL, AcpiDmDumpRsdt, DtCompileRsdt, TemplateRsdt},
+ {ACPI_SIG_S3PT, NULL, NULL, NULL, TemplateS3pt},
+ {ACPI_SIG_SBST, AcpiDmTableInfoSbst, NULL, NULL, TemplateSbst},
+ {ACPI_SIG_SLIC, NULL, AcpiDmDumpSlic, DtCompileSlic, TemplateSlic},
+ {ACPI_SIG_SLIT, NULL, AcpiDmDumpSlit, DtCompileSlit, TemplateSlit},
+ {ACPI_SIG_SPCR, AcpiDmTableInfoSpcr, NULL, NULL, TemplateSpcr},
+ {ACPI_SIG_SPMI, AcpiDmTableInfoSpmi, NULL, NULL, TemplateSpmi},
+ {ACPI_SIG_SRAT, NULL, AcpiDmDumpSrat, DtCompileSrat, TemplateSrat},
+ {ACPI_SIG_STAO, NULL, AcpiDmDumpStao, DtCompileStao, TemplateStao},
+ {ACPI_SIG_TCPA, AcpiDmTableInfoTcpa, NULL, NULL, TemplateTcpa},
+ {ACPI_SIG_TPM2, AcpiDmTableInfoTpm2, NULL, NULL, TemplateTpm2},
+ {ACPI_SIG_UEFI, AcpiDmTableInfoUefi, NULL, DtCompileUefi, TemplateUefi},
+ {ACPI_SIG_VRTC, AcpiDmTableInfoVrtc, AcpiDmDumpVrtc, DtCompileVrtc, TemplateVrtc},
+ {ACPI_SIG_WAET, AcpiDmTableInfoWaet, NULL, NULL, TemplateWaet},
+ {ACPI_SIG_WDAT, NULL, AcpiDmDumpWdat, DtCompileWdat, TemplateWdat},
+ {ACPI_SIG_WDDT, AcpiDmTableInfoWddt, NULL, NULL, TemplateWddt},
+ {ACPI_SIG_WDRT, AcpiDmTableInfoWdrt, NULL, NULL, TemplateWdrt},
+ {ACPI_SIG_WPBT, NULL, AcpiDmDumpWpbt, DtCompileWpbt, TemplateWpbt},
+ {ACPI_SIG_XENV, AcpiDmTableInfoXenv, NULL, NULL, TemplateXenv},
+ {ACPI_SIG_XSDT, NULL, AcpiDmDumpXsdt, DtCompileXsdt, TemplateXsdt},
+ {NULL, NULL, NULL, NULL, NULL}
};
@@ -407,18 +433,18 @@ AcpiDmGenerateChecksum (
*
******************************************************************************/
-ACPI_DMTABLE_DATA *
+const ACPI_DMTABLE_DATA *
AcpiDmGetTableData (
char *Signature)
{
- ACPI_DMTABLE_DATA *TableData;
+ const ACPI_DMTABLE_DATA *Info;
- for (TableData = AcpiDmTableData; TableData->Signature; TableData++)
+ for (Info = AcpiDmTableData; Info->Signature; Info++)
{
- if (ACPI_COMPARE_NAME (Signature, TableData->Signature))
+ if (ACPI_COMPARE_NAME (Signature, Info->Signature))
{
- return (TableData);
+ return (Info);
}
}
@@ -444,7 +470,7 @@ AcpiDmDumpDataTable (
ACPI_TABLE_HEADER *Table)
{
ACPI_STATUS Status;
- ACPI_DMTABLE_DATA *TableData;
+ const ACPI_DMTABLE_DATA *TableData;
UINT32 Length;
@@ -558,7 +584,6 @@ AcpiDmDumpDataTable (
* PARAMETERS: Offset - Current byte offset, from table start
* ByteLength - Length of the field in bytes, 0 for flags
* Name - Name of this field
- * Value - Optional value, displayed on left of ':'
*
* RETURN: None
*
@@ -692,7 +717,7 @@ AcpiDmDumpTable (
UINT16 Temp16;
UINT32 Temp32;
UINT64 Value;
- ACPI_DMTABLE_DATA *TableData;
+ const AH_TABLE *TableData;
const char *Name;
BOOLEAN LastOutputBlankLine = FALSE;
char RepairedName[8];
@@ -715,13 +740,24 @@ AcpiDmDumpTable (
Target = ACPI_ADD_PTR (UINT8, Table, Info->Offset);
CurrentOffset = TableOffset + Info->Offset;
- /* Check for beyond EOT or beyond subtable end */
+ /* Check for beyond subtable end or (worse) beyond EOT */
+
+ if (SubtableLength && (Info->Offset >= SubtableLength))
+ {
+ AcpiOsPrintf (
+ "/**** ACPI subtable terminates early - "
+ "may be older version (dump table) */\n");
- if ((CurrentOffset >= TableLength) ||
- (SubtableLength && (Info->Offset >= SubtableLength)))
+ /* Move on to next subtable */
+
+ return (AE_OK);
+ }
+
+ if (CurrentOffset >= TableLength)
{
AcpiOsPrintf (
- "**** ACPI table terminates in the middle of a data structure! (dump table)\n");
+ "/**** ACPI table terminates "
+ "in the middle of a data structure! (dump table) */\n");
return (AE_BAD_DATA);
}
@@ -754,6 +790,7 @@ AcpiDmDumpTable (
case ACPI_DMT_UINT16:
case ACPI_DMT_DMAR:
case ACPI_DMT_HEST:
+ case ACPI_DMT_NFIT:
ByteLength = 2;
break;
@@ -810,6 +847,7 @@ AcpiDmDumpTable (
ByteLength = 128;
break;
+ case ACPI_DMT_UNICODE:
case ACPI_DMT_BUFFER:
case ACPI_DMT_RAW_BUFFER:
@@ -841,16 +879,39 @@ AcpiDmDumpTable (
ByteLength = sizeof (ACPI_HEST_NOTIFY);
break;
+ case ACPI_DMT_IORTMEM:
+
+ if (!LastOutputBlankLine)
+ {
+ LastOutputBlankLine = FALSE;
+ }
+ ByteLength = sizeof (ACPI_IORT_MEMORY_ACCESS);
+ break;
+
default:
ByteLength = 0;
break;
}
+ /* Check if we are beyond a subtable, or (worse) beyond EOT */
+
if (CurrentOffset + ByteLength > TableLength)
{
+ if (SubtableLength)
+ {
+ AcpiOsPrintf (
+ "/**** ACPI subtable terminates early - "
+ "may be older version (dump table) */\n");
+
+ /* Move on to next subtable */
+
+ return (AE_OK);
+ }
+
AcpiOsPrintf (
- "**** ACPI table terminates in the middle of a data structure!\n");
+ "/**** ACPI table terminates "
+ "in the middle of a data structure! */\n");
return (AE_BAD_DATA);
}
@@ -980,10 +1041,10 @@ AcpiDmDumpTable (
AcpiDmCheckAscii (Target, RepairedName, 4);
AcpiOsPrintf ("\"%.4s\" ", RepairedName);
- TableData = AcpiDmGetTableData (ACPI_CAST_PTR (char, Target));
+ TableData = AcpiAhGetTableInfo (ACPI_CAST_PTR (char, Target));
if (TableData)
{
- AcpiOsPrintf (STRING_FORMAT, TableData->Name);
+ AcpiOsPrintf (STRING_FORMAT, TableData->Description);
}
else
{
@@ -1209,6 +1270,16 @@ AcpiDmDumpTable (
AcpiDmHestNotifySubnames[Temp8]);
break;
+ case ACPI_DMT_IORTMEM:
+
+ AcpiOsPrintf (STRING_FORMAT,
+ "IORT Memory Access Properties");
+
+ AcpiDmDumpTable (TableLength, CurrentOffset, Target,
+ sizeof (ACPI_IORT_MEMORY_ACCESS), AcpiDmTableInfoIortAcc);
+ LastOutputBlankLine = TRUE;
+ break;
+
case ACPI_DMT_MADT:
/* MADT subtable types */
@@ -1223,6 +1294,20 @@ AcpiDmDumpTable (
AcpiDmMadtSubnames[Temp8]);
break;
+ case ACPI_DMT_NFIT:
+
+ /* NFIT subtable types */
+
+ Temp16 = ACPI_GET16 (Target);
+ if (Temp16 > ACPI_NFIT_TYPE_RESERVED)
+ {
+ Temp16 = ACPI_NFIT_TYPE_RESERVED;
+ }
+
+ AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
+ AcpiDmNfitSubnames[Temp16]);
+ break;
+
case ACPI_DMT_PCCT:
/* PCCT subtable types */
@@ -1251,16 +1336,27 @@ AcpiDmDumpTable (
AcpiDmPmttSubnames[Temp8]);
break;
+ case ACPI_DMT_UNICODE:
+
+ if (ByteLength == 0)
+ {
+ AcpiOsPrintf ("/* Zero-length Data */\n");
+ break;
+ }
+
+ AcpiDmDumpUnicode (Table, CurrentOffset, ByteLength);
+ break;
+
case ACPI_DMT_RAW_BUFFER:
- /*
- * Currently only used for SLIC table
- */
- AcpiOsPrintf ("/* Proprietary data structure */ ");
- AcpiDmDumpBuffer (Table, sizeof (ACPI_TABLE_HEADER),
- ByteLength, sizeof (ACPI_TABLE_HEADER),
- "Licensing Data", TRUE);
- AcpiOsPrintf ("\n");
+ if (ByteLength == 0)
+ {
+ AcpiOsPrintf ("/* Zero-length Data */\n");
+ break;
+ }
+
+ AcpiDmDumpBuffer (Table, CurrentOffset, ByteLength,
+ CurrentOffset, NULL);
break;
case ACPI_DMT_SRAT:
diff --git a/sys/contrib/dev/acpica/common/dmtbdump.c b/sys/contrib/dev/acpica/common/dmtbdump.c
index 8a44328..94358e8 100644
--- a/sys/contrib/dev/acpica/common/dmtbdump.c
+++ b/sys/contrib/dev/acpica/common/dmtbdump.c
@@ -70,7 +70,6 @@ AcpiDmValidateFadtLength (
* AbsoluteOffset - Offset of buffer in the main ACPI table
* Header - Name of the buffer field (printed on the
* first line only.)
- * MultiLine - TRUE if a large, multi-line buffer
*
* RETURN: None
*
@@ -85,8 +84,7 @@ AcpiDmDumpBuffer (
UINT32 BufferOffset,
UINT32 Length,
UINT32 AbsoluteOffset,
- char *Header,
- BOOLEAN MultiLine)
+ char *Header)
{
UINT8 *Buffer;
UINT32 i;
@@ -104,18 +102,11 @@ AcpiDmDumpBuffer (
{
if (!(i % 16))
{
- if (MultiLine)
- {
- /* Insert a backslash - line continuation character */
+ /* Insert a backslash - line continuation character */
- AcpiOsPrintf ("\\\n ");
- }
- else
+ if (Length > 16)
{
- AcpiOsPrintf ("\n");
- AcpiDmLineHeader (AbsoluteOffset,
- ((Length - i) > 16) ? 16 : (Length - i), Header);
- Header = NULL;
+ AcpiOsPrintf ("\\\n ");
}
}
@@ -131,6 +122,74 @@ AcpiDmDumpBuffer (
/*******************************************************************************
*
+ * FUNCTION: AcpiDmDumpUnicode
+ *
+ * PARAMETERS: Table - ACPI Table or subtable
+ * BufferOffset - Offset of buffer from Table above
+ * ByteLength - Length of the buffer
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Validate and dump the contents of a buffer that contains
+ * unicode data. The output is a standard ASCII string. If it
+ * appears that the data is not unicode, the buffer is dumped
+ * as hex characters.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDumpUnicode (
+ void *Table,
+ UINT32 BufferOffset,
+ UINT32 ByteLength)
+{
+ UINT8 *Buffer;
+ UINT32 Length;
+ UINT32 i;
+
+
+ Buffer = ((UINT8 *) Table) + BufferOffset;
+ Length = ByteLength - 2; /* Last two bytes are the null terminator */
+
+ /* Ensure all low bytes are entirely printable ASCII */
+
+ for (i = 0; i < Length; i += 2)
+ {
+ if (!ACPI_IS_PRINT (Buffer[i]))
+ {
+ goto DumpRawBuffer;
+ }
+ }
+
+ /* Ensure all high bytes are zero */
+
+ for (i = 1; i < Length; i += 2)
+ {
+ if (Buffer[i])
+ {
+ goto DumpRawBuffer;
+ }
+ }
+
+ /* Dump the buffer as a normal string */
+
+ AcpiOsPrintf ("\"");
+ for (i = 0; i < Length; i += 2)
+ {
+ AcpiOsPrintf ("%c", Buffer[i]);
+ }
+ AcpiOsPrintf ("\"\n");
+ return;
+
+DumpRawBuffer:
+ AcpiDmDumpBuffer (Table, BufferOffset, ByteLength,
+ BufferOffset, NULL);
+ AcpiOsPrintf ("\n");
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: AcpiDmDumpRsdp
*
* PARAMETERS: Table - A RSDP
@@ -313,6 +372,13 @@ AcpiDmDumpFadt (
{
AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt5);
}
+
+ /* Check for FADT revision 6 fields and up (ACPI 6.0+) */
+
+ if (Table->Length > ACPI_FADT_V3_SIZE)
+ {
+ AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoFadt6);
+ }
}
/* Validate various fields in the FADT, including length */
@@ -693,10 +759,17 @@ AcpiDmDumpCsrt (
/* Resource-specific info buffer */
InfoLength = SubSubTable->Length - SubSubOffset;
-
- AcpiDmDumpBuffer (SubSubTable, SubSubOffset, InfoLength,
- Offset + SubOffset + SubSubOffset, "ResourceInfo", FALSE);
- SubSubOffset += InfoLength;
+ if (InfoLength)
+ {
+ Status = AcpiDmDumpTable (Length,
+ Offset + SubOffset + SubSubOffset, Table,
+ InfoLength, AcpiDmTableInfoCsrt2a);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+ SubSubOffset += InfoLength;
+ }
/* Point to next sub-subtable */
@@ -814,8 +887,13 @@ AcpiDmDumpDbg2 (
if (SubTable->OemDataOffset)
{
- AcpiDmDumpBuffer (SubTable, SubTable->OemDataOffset, SubTable->OemDataLength,
- Offset + SubTable->OemDataOffset, "OEM Data", FALSE);
+ Status = AcpiDmDumpTable (Length, Offset + SubTable->OemDataOffset,
+ Table, SubTable->OemDataLength,
+ AcpiDmTableInfoDbg2OemData);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
}
/* Point to next subtable */
@@ -840,7 +918,6 @@ AcpiDmDumpDbg2 (
*
******************************************************************************/
-
void
AcpiDmDumpDmar (
ACPI_TABLE_HEADER *Table)
@@ -985,6 +1062,120 @@ NextSubtable:
/*******************************************************************************
*
+ * FUNCTION: AcpiDmDumpDrtm
+ *
+ * PARAMETERS: Table - A DRTM table
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Format the contents of a DRTM.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDumpDrtm (
+ ACPI_TABLE_HEADER *Table)
+{
+ ACPI_STATUS Status;
+ UINT32 Offset;
+ ACPI_DRTM_VTABLE_LIST *DrtmVtl;
+ ACPI_DRTM_RESOURCE_LIST *DrtmRl;
+ ACPI_DRTM_DPS_ID *DrtmDps;
+ UINT32 Count;
+
+
+ /* Main table */
+
+ Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
+ AcpiDmTableInfoDrtm);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ Offset = sizeof (ACPI_TABLE_DRTM);
+
+ /* Sub-tables */
+
+ /* Dump ValidatedTable length */
+
+ DrtmVtl = ACPI_ADD_PTR (ACPI_DRTM_VTABLE_LIST, Table, Offset);
+ AcpiOsPrintf ("\n");
+ Status = AcpiDmDumpTable (Table->Length, Offset,
+ DrtmVtl, ACPI_OFFSET (ACPI_DRTM_VTABLE_LIST, ValidatedTables),
+ AcpiDmTableInfoDrtm0);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+ Offset += ACPI_OFFSET (ACPI_DRTM_VTABLE_LIST, ValidatedTables);
+
+ /* Dump Validated table addresses */
+
+ Count = 0;
+ while ((Offset < Table->Length) &&
+ (DrtmVtl->ValidatedTableCount > Count))
+ {
+ Status = AcpiDmDumpTable (Table->Length, Offset,
+ ACPI_ADD_PTR (void, Table, Offset), sizeof (UINT64),
+ AcpiDmTableInfoDrtm0a);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+ Offset += sizeof (UINT64);
+ Count++;
+ }
+
+ /* Dump ResourceList length */
+
+ DrtmRl = ACPI_ADD_PTR (ACPI_DRTM_RESOURCE_LIST, Table, Offset);
+ AcpiOsPrintf ("\n");
+ Status = AcpiDmDumpTable (Table->Length, Offset,
+ DrtmRl, ACPI_OFFSET (ACPI_DRTM_RESOURCE_LIST, Resources),
+ AcpiDmTableInfoDrtm1);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ Offset += ACPI_OFFSET (ACPI_DRTM_RESOURCE_LIST, Resources);
+
+ /* Dump the Resource List */
+
+ Count = 0;
+ while ((Offset < Table->Length) &&
+ (DrtmRl->ResourceCount > Count))
+ {
+ Status = AcpiDmDumpTable (Table->Length, Offset,
+ ACPI_ADD_PTR (void, Table, Offset),
+ sizeof (ACPI_DRTM_RESOURCE),
+ AcpiDmTableInfoDrtm1a);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ Offset += sizeof (ACPI_DRTM_RESOURCE);
+ Count++;
+ }
+
+ /* Dump DPS */
+
+ DrtmDps = ACPI_ADD_PTR (ACPI_DRTM_DPS_ID, Table, Offset);
+ AcpiOsPrintf ("\n");
+ Status = AcpiDmDumpTable (Table->Length, Offset,
+ DrtmDps, sizeof (ACPI_DRTM_DPS_ID),
+ AcpiDmTableInfoDrtm2);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: AcpiDmDumpEinj
*
* PARAMETERS: Table - A EINJ table
@@ -1429,6 +1620,230 @@ AcpiDmDumpHest (
/*******************************************************************************
*
+ * FUNCTION: AcpiDmDumpIort
+ *
+ * PARAMETERS: Table - A IORT table
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Format the contents of a IORT
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDumpIort (
+ ACPI_TABLE_HEADER *Table)
+{
+ ACPI_STATUS Status;
+ ACPI_TABLE_IORT *Iort;
+ ACPI_IORT_NODE *IortNode;
+ ACPI_IORT_ITS_GROUP *IortItsGroup = NULL;
+ ACPI_IORT_SMMU *IortSmmu = NULL;
+ UINT32 Offset;
+ UINT32 NodeOffset;
+ UINT32 Length;
+ ACPI_DMTABLE_INFO *InfoTable;
+ char *String;
+ UINT32 i;
+
+
+ /* Main table */
+
+ Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoIort);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ Iort = ACPI_CAST_PTR (ACPI_TABLE_IORT, Table);
+ Offset = sizeof (ACPI_TABLE_IORT);
+
+ /* Dump the OptionalPadding (optional) */
+
+ if (Iort->NodeOffset > Offset)
+ {
+ Status = AcpiDmDumpTable (Table->Length, Offset, Table,
+ Iort->NodeOffset - Offset, AcpiDmTableInfoIortPad);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+ }
+
+ Offset = Iort->NodeOffset;
+ while (Offset < Table->Length)
+ {
+ /* Common subtable header */
+
+ IortNode = ACPI_ADD_PTR (ACPI_IORT_NODE, Table, Offset);
+ AcpiOsPrintf ("\n");
+ Length = ACPI_OFFSET (ACPI_IORT_NODE, NodeData);
+ Status = AcpiDmDumpTable (Table->Length, Offset,
+ IortNode, Length, AcpiDmTableInfoIortHdr);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ NodeOffset = Length;
+
+ switch (IortNode->Type)
+ {
+ case ACPI_IORT_NODE_ITS_GROUP:
+
+ InfoTable = AcpiDmTableInfoIort0;
+ Length = ACPI_OFFSET (ACPI_IORT_ITS_GROUP, Identifiers);
+ IortItsGroup = ACPI_ADD_PTR (ACPI_IORT_ITS_GROUP, IortNode, NodeOffset);
+ break;
+
+ case ACPI_IORT_NODE_NAMED_COMPONENT:
+
+ InfoTable = AcpiDmTableInfoIort1;
+ Length = ACPI_OFFSET (ACPI_IORT_NAMED_COMPONENT, DeviceName);
+ String = ACPI_ADD_PTR (char, IortNode, NodeOffset + Length);
+ Length += ACPI_STRLEN (String) + 1;
+ break;
+
+ case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
+
+ InfoTable = AcpiDmTableInfoIort2;
+ Length = IortNode->Length - NodeOffset;
+ break;
+
+ case ACPI_IORT_NODE_SMMU:
+
+ InfoTable = AcpiDmTableInfoIort3;
+ Length = ACPI_OFFSET (ACPI_IORT_SMMU, Interrupts);
+ IortSmmu = ACPI_ADD_PTR (ACPI_IORT_SMMU, IortNode, NodeOffset);
+ break;
+
+ default:
+
+ AcpiOsPrintf ("\n**** Unknown IORT node type 0x%X\n",
+ IortNode->Type);
+
+ /* Attempt to continue */
+
+ if (!IortNode->Length)
+ {
+ AcpiOsPrintf ("Invalid zero length IORT node\n");
+ return;
+ }
+ goto NextSubTable;
+ }
+
+ /* Dump the node subtable header */
+
+ AcpiOsPrintf ("\n");
+ Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
+ ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
+ Length, InfoTable);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ NodeOffset += Length;
+
+ /* Dump the node specific data */
+
+ switch (IortNode->Type)
+ {
+ case ACPI_IORT_NODE_ITS_GROUP:
+
+ /* Validate IortItsGroup to avoid compiler warnings */
+
+ if (IortItsGroup)
+ {
+ for (i = 0; i < IortItsGroup->ItsCount; i++)
+ {
+ Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
+ ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
+ 4, AcpiDmTableInfoIort0a);
+ NodeOffset += 4;
+ }
+ }
+ break;
+
+ case ACPI_IORT_NODE_NAMED_COMPONENT:
+
+ /* Dump the Padding (optional) */
+
+ if (IortNode->Length > NodeOffset)
+ {
+ Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
+ Table, IortNode->Length - NodeOffset,
+ AcpiDmTableInfoIort1a);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+ }
+ break;
+
+ case ACPI_IORT_NODE_SMMU:
+
+ AcpiOsPrintf ("\n");
+
+ /* Validate IortSmmu to avoid compiler warnings */
+
+ if (IortSmmu)
+ {
+ Length = 2 * sizeof (UINT64);
+ NodeOffset = IortSmmu->GlobalInterruptOffset;
+ Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
+ ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
+ Length, AcpiDmTableInfoIort3a);
+
+ NodeOffset = IortSmmu->ContextInterruptOffset;
+ for (i = 0; i < IortSmmu->ContextInterruptCount; i++)
+ {
+ Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
+ ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
+ 8, AcpiDmTableInfoIort3b);
+ NodeOffset += 8;
+ }
+
+ NodeOffset = IortSmmu->PmuInterruptOffset;
+ for (i = 0; i < IortSmmu->PmuInterruptCount; i++)
+ {
+ Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
+ ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
+ 8, AcpiDmTableInfoIort3c);
+ NodeOffset += 8;
+ }
+ }
+ break;
+
+ default:
+
+ break;
+ }
+
+ /* Dump the ID mappings */
+
+ NodeOffset = IortNode->MappingOffset;
+ for (i = 0; i < IortNode->MappingCount; i++)
+ {
+ AcpiOsPrintf ("\n");
+ Length = sizeof (ACPI_IORT_ID_MAPPING);
+ Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
+ ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
+ Length, AcpiDmTableInfoIortMap);
+ NodeOffset += Length;
+ }
+
+NextSubTable:
+ /* Point to next node subtable */
+
+ Offset += IortNode->Length;
+ IortNode = ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, IortNode->Length);
+ }
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: AcpiDmDumpIvrs
*
* PARAMETERS: Table - A IVRS table
@@ -1654,12 +2069,6 @@ AcpiDmDumpLpit (
SubTableLength = sizeof (ACPI_LPIT_NATIVE);
break;
- case ACPI_LPIT_TYPE_SIMPLE_IO:
-
- InfoTable = AcpiDmTableInfoLpit1;
- SubTableLength = sizeof (ACPI_LPIT_IO);
- break;
-
default:
/* Cannot continue on unknown type - no length */
@@ -1808,6 +2217,11 @@ AcpiDmDumpMadt (
InfoTable = AcpiDmTableInfoMadt14;
break;
+ case ACPI_MADT_TYPE_GENERIC_TRANSLATOR:
+
+ InfoTable = AcpiDmTableInfoMadt15;
+ break;
+
default:
AcpiOsPrintf ("\n**** Unknown MADT subtable type 0x%X\n\n", SubTable->Type);
@@ -2146,6 +2560,180 @@ AcpiDmDumpMtmr (
/*******************************************************************************
*
+ * FUNCTION: AcpiDmDumpNfit
+ *
+ * PARAMETERS: Table - A NFIT table
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Format the contents of an NFIT.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDumpNfit (
+ ACPI_TABLE_HEADER *Table)
+{
+ ACPI_STATUS Status;
+ UINT32 Offset = sizeof (ACPI_TABLE_NFIT);
+ UINT32 FieldOffset = 0;
+ UINT32 Length;
+ ACPI_NFIT_HEADER *SubTable;
+ ACPI_DMTABLE_INFO *InfoTable;
+ ACPI_NFIT_INTERLEAVE *Interleave = NULL;
+ ACPI_NFIT_SMBIOS *SmbiosInfo = NULL;
+ ACPI_NFIT_FLUSH_ADDRESS *Hint = NULL;
+ UINT32 i;
+
+
+ /* Main table */
+
+ Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoNfit);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ /* Subtables */
+
+ SubTable = ACPI_ADD_PTR (ACPI_NFIT_HEADER, Table, Offset);
+ while (Offset < Table->Length)
+ {
+ /* NFIT subtable header */
+
+ AcpiOsPrintf ("\n");
+ Status = AcpiDmDumpTable (Table->Length, Offset, SubTable,
+ SubTable->Length, AcpiDmTableInfoNfitHdr);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ switch (SubTable->Type)
+ {
+ case ACPI_NFIT_TYPE_SYSTEM_ADDRESS:
+
+ InfoTable = AcpiDmTableInfoNfit0;
+ break;
+
+ case ACPI_NFIT_TYPE_MEMORY_MAP:
+
+ InfoTable = AcpiDmTableInfoNfit1;
+ break;
+
+ case ACPI_NFIT_TYPE_INTERLEAVE:
+
+ /* Has a variable number of 32-bit values at the end */
+
+ InfoTable = AcpiDmTableInfoNfit2;
+ Interleave = ACPI_CAST_PTR (ACPI_NFIT_INTERLEAVE, SubTable);
+ FieldOffset = sizeof (ACPI_NFIT_INTERLEAVE);
+ break;
+
+ case ACPI_NFIT_TYPE_SMBIOS:
+
+ SmbiosInfo = ACPI_CAST_PTR (ACPI_NFIT_SMBIOS, SubTable);
+ InfoTable = AcpiDmTableInfoNfit3;
+ break;
+
+ case ACPI_NFIT_TYPE_CONTROL_REGION:
+
+ InfoTable = AcpiDmTableInfoNfit4;
+ break;
+
+ case ACPI_NFIT_TYPE_DATA_REGION:
+
+ InfoTable = AcpiDmTableInfoNfit5;
+ break;
+
+ case ACPI_NFIT_TYPE_FLUSH_ADDRESS:
+
+ /* Has a variable number of 64-bit addresses at the end */
+
+ InfoTable = AcpiDmTableInfoNfit6;
+ Hint = ACPI_CAST_PTR (ACPI_NFIT_FLUSH_ADDRESS, SubTable);
+ FieldOffset = sizeof (ACPI_NFIT_FLUSH_ADDRESS) - sizeof (UINT64);
+ break;
+
+ default:
+ AcpiOsPrintf ("\n**** Unknown NFIT subtable type 0x%X\n", SubTable->Type);
+
+ /* Attempt to continue */
+
+ if (!SubTable->Length)
+ {
+ AcpiOsPrintf ("Invalid zero length subtable\n");
+ return;
+ }
+ goto NextSubTable;
+ }
+
+ AcpiOsPrintf ("\n");
+ Status = AcpiDmDumpTable (Table->Length, Offset, SubTable,
+ SubTable->Length, InfoTable);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ /* Per-subtable variable-length fields */
+
+ switch (SubTable->Type)
+ {
+ case ACPI_NFIT_TYPE_INTERLEAVE:
+
+ for (i = 0; i < Interleave->LineCount; i++)
+ {
+ Status = AcpiDmDumpTable (Table->Length, Offset + FieldOffset,
+ &Interleave->LineOffset[i],
+ sizeof (UINT32), AcpiDmTableInfoNfit2a);
+ FieldOffset += sizeof (UINT32);
+ }
+ break;
+
+ case ACPI_NFIT_TYPE_SMBIOS:
+
+ Length = SubTable->Length - sizeof (ACPI_NFIT_SMBIOS) + sizeof (UINT8);
+ if (Length)
+ {
+ Status = AcpiDmDumpTable (Table->Length,
+ sizeof (ACPI_NFIT_SMBIOS) - sizeof (UINT8),
+ SmbiosInfo,
+ Length, AcpiDmTableInfoNfit3a);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+ }
+
+ break;
+
+ case ACPI_NFIT_TYPE_FLUSH_ADDRESS:
+
+ for (i = 0; i < Hint->HintCount; i++)
+ {
+ Status = AcpiDmDumpTable (Table->Length, Offset + FieldOffset,
+ &Hint->HintAddress[i],
+ sizeof (UINT64), AcpiDmTableInfoNfit6a);
+ FieldOffset += sizeof (UINT64);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+NextSubTable:
+ /* Point to next subtable */
+
+ Offset += SubTable->Length;
+ SubTable = ACPI_ADD_PTR (ACPI_NFIT_HEADER, SubTable, SubTable->Length);
+ }
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: AcpiDmDumpPcct
*
* PARAMETERS: Table - A PCCT table
@@ -2720,6 +3308,56 @@ NextSubTable:
/*******************************************************************************
*
+ * FUNCTION: AcpiDmDumpStao
+ *
+ * PARAMETERS: Table - A STAO table
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Format the contents of a STAO. This is a variable-length
+ * table that contains an open-ended number of ASCII strings
+ * at the end of the table.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDumpStao (
+ ACPI_TABLE_HEADER *Table)
+{
+ ACPI_STATUS Status;
+ char *Namepath;
+ UINT32 Length = Table->Length;
+ UINT32 StringLength;
+ UINT32 Offset = sizeof (ACPI_TABLE_STAO);
+
+
+ /* Main table */
+
+ Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoStao);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ /* The rest of the table consists of Namepath strings */
+
+ while (Offset < Table->Length)
+ {
+ Namepath = ACPI_ADD_PTR (char, Table, Offset);
+ StringLength = ACPI_STRLEN (Namepath) + 1;
+
+ AcpiDmLineHeader (Offset, StringLength, "Namestring");
+ AcpiOsPrintf ("\"%s\"\n", Namepath);
+
+ /* Point to next namepath */
+
+ Offset += StringLength;
+ }
+}
+
+
+/*******************************************************************************
+ *
* FUNCTION: AcpiDmDumpVrtc
*
* PARAMETERS: Table - A VRTC table
@@ -2820,3 +3458,49 @@ AcpiDmDumpWdat (
SubTable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, SubTable, sizeof (ACPI_WDAT_ENTRY));
}
}
+
+/*******************************************************************************
+ *
+ * FUNCTION: AcpiDmDumpWpbt
+ *
+ * PARAMETERS: Table - A WPBT table
+ *
+ * RETURN: None
+ *
+ * DESCRIPTION: Format the contents of a WPBT. This table type consists
+ * of an open-ended arguments buffer at the end of the table.
+ *
+ ******************************************************************************/
+
+void
+AcpiDmDumpWpbt (
+ ACPI_TABLE_HEADER *Table)
+{
+ ACPI_STATUS Status;
+ ACPI_TABLE_WPBT *SubTable;
+ UINT32 Length = Table->Length;
+ UINT16 ArgumentsLength;
+
+
+ /* Dump the main table */
+
+ Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoWpbt);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+
+ /* Extract the arguments buffer length from the main table */
+
+ SubTable = ACPI_CAST_PTR (ACPI_TABLE_WPBT, Table);
+ ArgumentsLength = SubTable->ArgumentsLength;
+
+ /* Dump the arguments buffer */
+
+ AcpiDmDumpTable (Table->Length, 0, Table, ArgumentsLength,
+ AcpiDmTableInfoWpbt0);
+ if (ACPI_FAILURE (Status))
+ {
+ return;
+ }
+}
diff --git a/sys/contrib/dev/acpica/common/dmtbinfo.c b/sys/contrib/dev/acpica/common/dmtbinfo.c
index 4ce802b..a803c70 100644
--- a/sys/contrib/dev/acpica/common/dmtbinfo.c
+++ b/sys/contrib/dev/acpica/common/dmtbinfo.c
@@ -96,12 +96,14 @@
#define ACPI_GTDT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_GTDT,f)
#define ACPI_HEST_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_HEST,f)
#define ACPI_HPET_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_HPET,f)
+#define ACPI_IORT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_IORT,f)
#define ACPI_IVRS_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_IVRS,f)
#define ACPI_MADT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_MADT,f)
#define ACPI_MCFG_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_MCFG,f)
#define ACPI_MCHI_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_MCHI,f)
#define ACPI_MPST_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_MPST,f)
#define ACPI_MSCT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_MSCT,f)
+#define ACPI_NFIT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_NFIT,f)
#define ACPI_PCCT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_PCCT,f)
#define ACPI_PMTT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_PMTT,f)
#define ACPI_S3PT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_S3PT,f)
@@ -110,6 +112,7 @@
#define ACPI_SPCR_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_SPCR,f)
#define ACPI_SPMI_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_SPMI,f)
#define ACPI_SRAT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_SRAT,f)
+#define ACPI_STAO_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_STAO,f)
#define ACPI_TCPA_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_TCPA,f)
#define ACPI_TPM2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_TPM2,f)
#define ACPI_UEFI_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_UEFI,f)
@@ -117,6 +120,8 @@
#define ACPI_WDAT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_WDAT,f)
#define ACPI_WDDT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_WDDT,f)
#define ACPI_WDRT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_WDRT,f)
+#define ACPI_WPBT_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_WPBT,f)
+#define ACPI_XENV_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_TABLE_XENV,f)
/* Subtables */
@@ -138,6 +143,10 @@
#define ACPI_DMAR2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DMAR_ATSR,f)
#define ACPI_DMAR3_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DMAR_RHSA,f)
#define ACPI_DMAR4_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DMAR_ANDD,f)
+#define ACPI_DRTM0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DRTM_VTABLE_LIST,f)
+#define ACPI_DRTM1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DRTM_RESOURCE_LIST,f)
+#define ACPI_DRTM1a_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DRTM_RESOURCE,f)
+#define ACPI_DRTM2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_DRTM_DPS_ID,f)
#define ACPI_EINJ0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_WHEA_HEADER,f)
#define ACPI_ERST0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_WHEA_HEADER,f)
#define ACPI_FPDTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_FPDT_HEADER,f)
@@ -156,6 +165,13 @@
#define ACPI_HEST9_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_GENERIC,f)
#define ACPI_HESTN_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_NOTIFY,f)
#define ACPI_HESTB_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_HEST_IA_ERROR_BANK,f)
+#define ACPI_IORT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_ITS_GROUP,f)
+#define ACPI_IORT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_NAMED_COMPONENT,f)
+#define ACPI_IORT2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_ROOT_COMPLEX,f)
+#define ACPI_IORT3_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_SMMU,f)
+#define ACPI_IORTA_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_MEMORY_ACCESS,f)
+#define ACPI_IORTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_NODE,f)
+#define ACPI_IORTM_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IORT_ID_MAPPING,f)
#define ACPI_IVRSH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IVRS_HEADER,f)
#define ACPI_IVRS0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IVRS_HARDWARE,f)
#define ACPI_IVRS1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IVRS_MEMORY,f)
@@ -165,7 +181,6 @@
#define ACPI_IVRS8C_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_IVRS_DEVICE8C,f)
#define ACPI_LPITH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_LPIT_HEADER,f)
#define ACPI_LPIT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_LPIT_NATIVE,f)
-#define ACPI_LPIT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_LPIT_IO,f)
#define ACPI_MADT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_LOCAL_APIC,f)
#define ACPI_MADT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_IO_APIC,f)
#define ACPI_MADT2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_INTERRUPT_OVERRIDE,f)
@@ -181,6 +196,7 @@
#define ACPI_MADT12_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_GENERIC_DISTRIBUTOR,f)
#define ACPI_MADT13_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_GENERIC_MSI_FRAME,f)
#define ACPI_MADT14_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_GENERIC_REDISTRIBUTOR,f)
+#define ACPI_MADT15_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MADT_GENERIC_TRANSLATOR,f)
#define ACPI_MADTH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_SUBTABLE_HEADER,f)
#define ACPI_MCFG0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MCFG_ALLOCATION,f)
#define ACPI_MPST0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MPST_POWER_NODE,f)
@@ -190,6 +206,14 @@
#define ACPI_MPST2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MPST_POWER_DATA,f)
#define ACPI_MSCT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MSCT_PROXIMITY,f)
#define ACPI_MTMR0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_MTMR_ENTRY,f)
+#define ACPI_NFITH_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_NFIT_HEADER,f)
+#define ACPI_NFIT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_NFIT_SYSTEM_ADDRESS,f)
+#define ACPI_NFIT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_NFIT_MEMORY_MAP,f)
+#define ACPI_NFIT2_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_NFIT_INTERLEAVE,f)
+#define ACPI_NFIT3_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_NFIT_SMBIOS,f)
+#define ACPI_NFIT4_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_NFIT_CONTROL_REGION,f)
+#define ACPI_NFIT5_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_NFIT_DATA_REGION,f)
+#define ACPI_NFIT6_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_NFIT_FLUSH_ADDRESS,f)
#define ACPI_PCCT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PCCT_SUBSPACE,f)
#define ACPI_PCCT1_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PCCT_HW_REDUCED,f)
#define ACPI_PMTT0_OFFSET(f) (UINT16) ACPI_OFFSET (ACPI_PMTT_SOCKET,f)
@@ -216,6 +240,8 @@
/* Flags */
+#define ACPI_DRTM_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_DRTM,f,o)
+#define ACPI_DRTM1a_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_DRTM_RESOURCE,f,o)
#define ACPI_FADT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_FADT,f,o)
#define ACPI_FACS_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_FACS,f,o)
#define ACPI_HPET_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_HPET,f,o)
@@ -226,6 +252,9 @@
#define ACPI_GTDT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_GTDT,f,o)
#define ACPI_GTDT0a_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_GTDT_TIMER_ENTRY,f,o)
#define ACPI_GTDT1_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_GTDT_WATCHDOG,f,o)
+#define ACPI_IORT3_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_IORT_SMMU,f,o)
+#define ACPI_IORTA_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_IORT_MEMORY_ACCESS,f,o)
+#define ACPI_IORTM_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_IORT_ID_MAPPING,f,o)
#define ACPI_LPITH_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_LPIT_HEADER,f,o)
#define ACPI_MADT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_MADT,f,o)
#define ACPI_MADT0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_LOCAL_APIC,f,o)
@@ -240,6 +269,9 @@
#define ACPI_MADT13_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MADT_GENERIC_MSI_FRAME,f,o)
#define ACPI_MPST0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MPST_POWER_NODE,f,o)
#define ACPI_MPST2_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_MPST_POWER_DATA,f,o)
+#define ACPI_NFIT0_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_NFIT_SYSTEM_ADDRESS,f,o)
+#define ACPI_NFIT1_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_NFIT_MEMORY_MAP,f,o)
+#define ACPI_NFIT4_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_NFIT_CONTROL_REGION,f,o)
#define ACPI_PCCT_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_TABLE_PCCT,f,o)
#define ACPI_PCCT1_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_PCCT_HW_REDUCED,f,o)
#define ACPI_PMTTH_FLAG_OFFSET(f,o) ACPI_FLAG_OFFSET (ACPI_PMTT_HEADER,f,o)
@@ -490,6 +522,14 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoFadt5[] =
ACPI_DMT_TERMINATOR
};
+/* ACPI 6.0 Extensions (FADT version 6) */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoFadt6[] =
+{
+ {ACPI_DMT_UINT64, ACPI_FADT_OFFSET (HypervisorId), "Hypervisor ID", 0},
+ ACPI_DMT_TERMINATOR
+};
+
/*
* Remaining tables are not consumed directly by the ACPICA subsystem
@@ -680,7 +720,7 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoCpep0[] =
ACPI_DMTABLE_INFO AcpiDmTableInfoCsrt0[] =
{
- {ACPI_DMT_UINT32, ACPI_CSRT0_OFFSET (Length), "Length", 0},
+ {ACPI_DMT_UINT32, ACPI_CSRT0_OFFSET (Length), "Length", DT_LENGTH},
{ACPI_DMT_UINT32, ACPI_CSRT0_OFFSET (VendorId), "Vendor ID", 0},
{ACPI_DMT_UINT32, ACPI_CSRT0_OFFSET (SubvendorId), "Subvendor ID", 0},
{ACPI_DMT_UINT16, ACPI_CSRT0_OFFSET (DeviceId), "Device ID", 0},
@@ -715,13 +755,19 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoCsrt1[] =
ACPI_DMTABLE_INFO AcpiDmTableInfoCsrt2[] =
{
- {ACPI_DMT_UINT32, ACPI_CSRT2_OFFSET (Length), "Length", 0},
+ {ACPI_DMT_UINT32, ACPI_CSRT2_OFFSET (Length), "Length", DT_LENGTH},
{ACPI_DMT_UINT16, ACPI_CSRT2_OFFSET (Type), "Type", 0},
{ACPI_DMT_UINT16, ACPI_CSRT2_OFFSET (Subtype), "Subtype", 0},
{ACPI_DMT_UINT32, ACPI_CSRT2_OFFSET (Uid), "UID", 0},
ACPI_DMT_TERMINATOR
};
+ACPI_DMTABLE_INFO AcpiDmTableInfoCsrt2a[] =
+{
+ {ACPI_DMT_RAW_BUFFER, 0, "ResourceInfo", DT_OPTIONAL},
+ ACPI_DMT_TERMINATOR
+};
+
/*******************************************************************************
*
@@ -777,7 +823,7 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2Name[] =
ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2OemData[] =
{
- {ACPI_DMT_BUFFER, 0, "OEM Data", DT_OPTIONAL},
+ {ACPI_DMT_RAW_BUFFER, 0, "OEM Data", DT_OPTIONAL},
ACPI_DMT_TERMINATOR
};
@@ -895,7 +941,54 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoDmar4[] =
ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm[] =
{
+ {ACPI_DMT_UINT64, ACPI_DRTM_OFFSET (EntryBaseAddress), "Entry Base Address", 0},
+ {ACPI_DMT_UINT64, ACPI_DRTM_OFFSET (EntryLength), "Entry Length", 0},
+ {ACPI_DMT_UINT32, ACPI_DRTM_OFFSET (EntryAddress32), "Entry 32", 0},
+ {ACPI_DMT_UINT64, ACPI_DRTM_OFFSET (EntryAddress64), "Entry 64", 0},
+ {ACPI_DMT_UINT64, ACPI_DRTM_OFFSET (ExitAddress), "Exit Address", 0},
+ {ACPI_DMT_UINT64, ACPI_DRTM_OFFSET (LogAreaAddress), "Log Area Start", 0},
+ {ACPI_DMT_UINT32, ACPI_DRTM_OFFSET (LogAreaLength), "Log Area Length", 0},
+ {ACPI_DMT_UINT64, ACPI_DRTM_OFFSET (ArchDependentAddress), "Arch Dependent Address", 0},
+ {ACPI_DMT_UINT32, ACPI_DRTM_OFFSET (Flags), "Flags (decoded below)", 0},
+ {ACPI_DMT_FLAG0, ACPI_DRTM_FLAG_OFFSET (Flags, 0), "Namespace in TCB", 0},
+ {ACPI_DMT_FLAG1, ACPI_DRTM_FLAG_OFFSET (Flags, 0), "Gap Code on S3 Resume", 0},
+ {ACPI_DMT_FLAG2, ACPI_DRTM_FLAG_OFFSET (Flags, 0), "Gap Code on DLME_Exit", 0},
+ {ACPI_DMT_FLAG3, ACPI_DRTM_FLAG_OFFSET (Flags, 0), "PCR_Authorities Changed", 0},
+ ACPI_DMT_TERMINATOR
+};
+ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm0[] =
+{
+ {ACPI_DMT_UINT32, ACPI_DRTM0_OFFSET (ValidatedTableCount), "Validated Table Count", DT_COUNT},
+ ACPI_DMT_TERMINATOR
+};
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm0a[] =
+{
+ {ACPI_DMT_UINT64, 0, "Table Address", DT_OPTIONAL},
+ ACPI_DMT_TERMINATOR
+};
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm1[] =
+{
+ {ACPI_DMT_UINT32, ACPI_DRTM1_OFFSET (ResourceCount), "Resource Count", DT_COUNT},
+ ACPI_DMT_TERMINATOR
+};
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm1a[] =
+{
+ {ACPI_DMT_UINT56, ACPI_DRTM1a_OFFSET (Size[0]), "Size", DT_OPTIONAL},
+ {ACPI_DMT_UINT8, ACPI_DRTM1a_OFFSET (Type), "Type", 0},
+ {ACPI_DMT_FLAG0, ACPI_DRTM1a_FLAG_OFFSET (Type, 0), "Resource Type", 0},
+ {ACPI_DMT_FLAG7, ACPI_DRTM1a_FLAG_OFFSET (Type, 0), "Protections", 0},
+ {ACPI_DMT_UINT64, ACPI_DRTM1a_OFFSET (Address), "Address", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm2[] =
+{
+ {ACPI_DMT_UINT32, ACPI_DRTM2_OFFSET (DpsIdLength), "DLME Platform Id Length", DT_COUNT},
+ {ACPI_DMT_BUF16, ACPI_DRTM2_OFFSET (DpsId), "DLME Platform Id", DT_COUNT},
ACPI_DMT_TERMINATOR
};
@@ -1302,6 +1395,148 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoHpet[] =
/*******************************************************************************
*
+ * IORT - IO Remapping Table
+ *
+ ******************************************************************************/
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoIort[] =
+{
+ {ACPI_DMT_UINT32, ACPI_IORT_OFFSET (NodeCount), "Node Count", 0},
+ {ACPI_DMT_UINT32, ACPI_IORT_OFFSET (NodeOffset), "Node Offset", 0},
+ {ACPI_DMT_UINT32, ACPI_IORT_OFFSET (Reserved), "Reserved", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+/* Optional padding field */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoIortPad[] =
+{
+ {ACPI_DMT_RAW_BUFFER, 0, "Optional Padding", DT_OPTIONAL},
+ ACPI_DMT_TERMINATOR
+};
+
+/* Common Subtable header (one per Subtable) */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoIortHdr[] =
+{
+ {ACPI_DMT_UINT8, ACPI_IORTH_OFFSET (Type), "Type", 0},
+ {ACPI_DMT_UINT16, ACPI_IORTH_OFFSET (Length), "Length", DT_LENGTH},
+ {ACPI_DMT_UINT8, ACPI_IORTH_OFFSET (Revision), "Revision", 0},
+ {ACPI_DMT_UINT32, ACPI_IORTH_OFFSET (Reserved), "Reserved", 0},
+ {ACPI_DMT_UINT32, ACPI_IORTH_OFFSET (MappingCount), "Mapping Count", 0},
+ {ACPI_DMT_UINT32, ACPI_IORTH_OFFSET (MappingOffset), "Mapping Offset", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoIortMap[] =
+{
+ {ACPI_DMT_UINT32, ACPI_IORTM_OFFSET (InputBase), "Input base", DT_OPTIONAL},
+ {ACPI_DMT_UINT32, ACPI_IORTM_OFFSET (IdCount), "ID Count", 0},
+ {ACPI_DMT_UINT32, ACPI_IORTM_OFFSET (OutputBase), "Output Base", 0},
+ {ACPI_DMT_UINT32, ACPI_IORTM_OFFSET (OutputReference), "Output Reference", 0},
+ {ACPI_DMT_UINT32, ACPI_IORTM_OFFSET (Flags), "Flags (decoded below)", 0},
+ {ACPI_DMT_FLAG0, ACPI_IORTM_FLAG_OFFSET (Flags, 0), "Single Mapping", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoIortAcc[] =
+{
+ {ACPI_DMT_UINT32, ACPI_IORTA_OFFSET (CacheCoherency), "Cache Coherency", 0},
+ {ACPI_DMT_UINT8, ACPI_IORTA_OFFSET (Hints), "Hints (decoded below)", 0},
+ {ACPI_DMT_FLAG0, ACPI_IORTA_FLAG_OFFSET (Hints, 0), "Transient", 0},
+ {ACPI_DMT_FLAG1, ACPI_IORTA_FLAG_OFFSET (Hints, 0), "Write Allocate", 0},
+ {ACPI_DMT_FLAG2, ACPI_IORTA_FLAG_OFFSET (Hints, 0), "Read Allocate", 0},
+ {ACPI_DMT_FLAG3, ACPI_IORTA_FLAG_OFFSET (Hints, 0), "Override", 0},
+ {ACPI_DMT_UINT16, ACPI_IORTA_OFFSET (Reserved), "Reserved", 0},
+ {ACPI_DMT_UINT8, ACPI_IORTA_OFFSET (MemoryFlags), "Memory Flags (decoded below)", 0},
+ {ACPI_DMT_FLAG0, ACPI_IORTA_FLAG_OFFSET (MemoryFlags, 0), "Coherency", 0},
+ {ACPI_DMT_FLAG1, ACPI_IORTA_FLAG_OFFSET (MemoryFlags, 0), "Device Attribute", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+/* IORT subtables */
+
+/* 0x00: ITS Group */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoIort0[] =
+{
+ {ACPI_DMT_UINT32, ACPI_IORT0_OFFSET (ItsCount), "ItsCount", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoIort0a[] =
+{
+ {ACPI_DMT_UINT32, 0, "Identifiers", DT_OPTIONAL},
+ ACPI_DMT_TERMINATOR
+};
+
+/* 0x01: Named Component */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoIort1[] =
+{
+ {ACPI_DMT_UINT32, ACPI_IORT1_OFFSET (NodeFlags), "Node Flags", 0},
+ {ACPI_DMT_IORTMEM, ACPI_IORT1_OFFSET (MemoryProperties), "Memory Properties", 0},
+ {ACPI_DMT_UINT8, ACPI_IORT1_OFFSET (MemoryAddressLimit), "Memory Size Limit", 0},
+ {ACPI_DMT_STRING, ACPI_IORT1_OFFSET (DeviceName[0]), "Device Name", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoIort1a[] =
+{
+ {ACPI_DMT_RAW_BUFFER, 0, "Padding", DT_OPTIONAL},
+ ACPI_DMT_TERMINATOR
+};
+
+/* 0x02: PCI Root Complex */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoIort2[] =
+{
+ {ACPI_DMT_IORTMEM, ACPI_IORT2_OFFSET (MemoryProperties), "Memory Properties", 0},
+ {ACPI_DMT_UINT32, ACPI_IORT2_OFFSET (AtsAttribute), "ATS Attribute", 0},
+ {ACPI_DMT_UINT32, ACPI_IORT2_OFFSET (PciSegmentNumber), "PCI Segment Number", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+/* 0x03: SMMUv1/2 */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoIort3[] =
+{
+ {ACPI_DMT_UINT64, ACPI_IORT3_OFFSET (BaseAddress), "Base Address", 0},
+ {ACPI_DMT_UINT64, ACPI_IORT3_OFFSET (Span), "Span", 0},
+ {ACPI_DMT_UINT32, ACPI_IORT3_OFFSET (Model), "Model", 0},
+ {ACPI_DMT_UINT32, ACPI_IORT3_OFFSET (Flags), "Flags (decoded below)", 0},
+ {ACPI_DMT_FLAG0, ACPI_IORT3_FLAG_OFFSET (Flags, 0), "DVM Supported", 0},
+ {ACPI_DMT_FLAG1, ACPI_IORT3_FLAG_OFFSET (Flags, 0), "Coherent Walk", 0},
+ {ACPI_DMT_UINT32, ACPI_IORT3_OFFSET (GlobalInterruptOffset), "Global Interrupt Offset", 0},
+ {ACPI_DMT_UINT32, ACPI_IORT3_OFFSET (ContextInterruptCount), "Context Interrupt Count", 0},
+ {ACPI_DMT_UINT32, ACPI_IORT3_OFFSET (ContextInterruptOffset), "Context Interrupt Offset", 0},
+ {ACPI_DMT_UINT32, ACPI_IORT3_OFFSET (PmuInterruptCount), "PMU Interrupt Count", 0},
+ {ACPI_DMT_UINT32, ACPI_IORT3_OFFSET (PmuInterruptOffset), "PMU Interrupt Offset", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoIort3a[] =
+{
+ {ACPI_DMT_UINT64, 0, "SMMU_NSgIrpt Interrupt", 0},
+ {ACPI_DMT_UINT64, 0, "SMMU_NSgCfgIrpt Interrupt", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoIort3b[] =
+{
+ {ACPI_DMT_UINT64, 0, "Context Interrupt", DT_OPTIONAL},
+ ACPI_DMT_TERMINATOR
+};
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoIort3c[] =
+{
+ {ACPI_DMT_UINT64, 0, "PMU Interrupt", DT_OPTIONAL},
+ ACPI_DMT_TERMINATOR
+};
+
+
+/*******************************************************************************
+ *
* IVRS - I/O Virtualization Reporting Structure
*
******************************************************************************/
@@ -1432,22 +1667,6 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoLpit0[] =
ACPI_DMT_TERMINATOR
};
-/* 1: Simple I/O */
-
-ACPI_DMTABLE_INFO AcpiDmTableInfoLpit1[] =
-{
- {ACPI_DMT_GAS, ACPI_LPIT1_OFFSET (EntryTrigger), "Entry Trigger", 0},
- {ACPI_DMT_UINT32, ACPI_LPIT1_OFFSET (TriggerAction), "Trigger Action", 0},
- {ACPI_DMT_UINT64, ACPI_LPIT1_OFFSET (TriggerValue), "Trigger Value", 0},
- {ACPI_DMT_UINT64, ACPI_LPIT1_OFFSET (TriggerMask), "Trigger Mask", 0},
- {ACPI_DMT_GAS, ACPI_LPIT1_OFFSET (MinimumIdleState), "Minimum Idle State", 0},
- {ACPI_DMT_UINT32, ACPI_LPIT1_OFFSET (Residency), "Residency", 0},
- {ACPI_DMT_UINT32, ACPI_LPIT1_OFFSET (Latency), "Latency", 0},
- {ACPI_DMT_GAS, ACPI_LPIT1_OFFSET (ResidencyCounter), "Residency Counter", 0},
- {ACPI_DMT_UINT64, ACPI_LPIT1_OFFSET (CounterFrequency), "Counter Frequency", 0},
- ACPI_DMT_TERMINATOR
-};
-
/*******************************************************************************
*
@@ -1629,6 +1848,8 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt11[] =
{ACPI_DMT_UINT32, ACPI_MADT11_OFFSET (VgicInterrupt), "Virtual GIC Interrupt", 0},
{ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (GicrBaseAddress), "Redistributor Base Address", 0},
{ACPI_DMT_UINT64, ACPI_MADT11_OFFSET (ArmMpidr), "ARM MPIDR", 0},
+ {ACPI_DMT_UINT8, ACPI_MADT11_OFFSET (EfficiencyClass), "Efficiency Class", 0},
+ {ACPI_DMT_UINT24, ACPI_MADT11_OFFSET (Reserved2[0]), "Reserved", 0},
ACPI_DMT_TERMINATOR
};
@@ -1640,7 +1861,8 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt12[] =
{ACPI_DMT_UINT32, ACPI_MADT12_OFFSET (GicId), "Local GIC Hardware ID", 0},
{ACPI_DMT_UINT64, ACPI_MADT12_OFFSET (BaseAddress), "Base Address", 0},
{ACPI_DMT_UINT32, ACPI_MADT12_OFFSET (GlobalIrqBase), "Interrupt Base", 0},
- {ACPI_DMT_UINT32, ACPI_MADT12_OFFSET (Reserved2), "Reserved", 0},
+ {ACPI_DMT_UINT8, ACPI_MADT12_OFFSET (Version), "Version", 0},
+ {ACPI_DMT_UINT24, ACPI_MADT12_OFFSET (Reserved2[0]), "Reserved", 0},
ACPI_DMT_TERMINATOR
};
@@ -1668,6 +1890,16 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoMadt14[] =
ACPI_DMT_TERMINATOR
};
+/* 15: Generic Translator (ACPI 6.0) */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoMadt15[] =
+{
+ {ACPI_DMT_UINT16, ACPI_MADT15_OFFSET (Reserved), "Reserved", 0},
+ {ACPI_DMT_UINT32, ACPI_MADT15_OFFSET (TranslationId), "Translation ID", 0},
+ {ACPI_DMT_UINT64, ACPI_MADT15_OFFSET (BaseAddress), "Base Address", 0},
+ {ACPI_DMT_UINT32, ACPI_MADT15_OFFSET (Reserved2), "Reserved", 0},
+ ACPI_DMT_TERMINATOR
+};
/*******************************************************************************
*
@@ -1850,6 +2082,156 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoMtmr0[] =
/*******************************************************************************
*
+ * NFIT - NVDIMM Firmware Interface Table and Subtables - (ACPI 6.0)
+ *
+ ******************************************************************************/
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoNfit[] =
+{
+ {ACPI_DMT_UINT32, ACPI_NFIT_OFFSET (Reserved), "Reserved", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+/* Common Subtable header */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoNfitHdr[] =
+{
+ {ACPI_DMT_NFIT, ACPI_NFITH_OFFSET (Type), "Subtable Type", 0},
+ {ACPI_DMT_UINT16, ACPI_NFITH_OFFSET (Length), "Length", DT_LENGTH},
+ ACPI_DMT_TERMINATOR
+};
+
+/* 0: System Physical Address Range Structure */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoNfit0[] =
+{
+ {ACPI_DMT_UINT16, ACPI_NFIT0_OFFSET (RangeIndex), "Range Index", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT0_OFFSET (Flags), "Flags (decoded below)", DT_FLAG},
+ {ACPI_DMT_FLAG0, ACPI_NFIT0_FLAG_OFFSET (Flags,0), "Add/Online Operation Only", 0},
+ {ACPI_DMT_FLAG1, ACPI_NFIT0_FLAG_OFFSET (Flags,0), "Proximity Domain Valid", 0},
+ {ACPI_DMT_UINT32, ACPI_NFIT0_OFFSET (Reserved), "Reserved", 0},
+ {ACPI_DMT_UINT32, ACPI_NFIT0_OFFSET (ProximityDomain), "Proximity Domain", 0},
+ {ACPI_DMT_UUID, ACPI_NFIT0_OFFSET (RangeGuid[0]), "Address Range GUID", 0},
+ {ACPI_DMT_UINT64, ACPI_NFIT0_OFFSET (Address), "Address Range Base", 0},
+ {ACPI_DMT_UINT64, ACPI_NFIT0_OFFSET (Length), "Address Range Length", 0},
+ {ACPI_DMT_UINT64, ACPI_NFIT0_OFFSET (MemoryMapping), "Memory Map Attribute", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+/* 1: Memory Device to System Address Range Map Structure */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoNfit1[] =
+{
+ {ACPI_DMT_UINT32, ACPI_NFIT1_OFFSET (DeviceHandle), "Device Handle", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT1_OFFSET (PhysicalId), "Physical Id", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT1_OFFSET (RegionId), "Region Id", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT1_OFFSET (RangeIndex), "Range Index", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT1_OFFSET (RegionIndex), "Control Region Index", 0},
+ {ACPI_DMT_UINT64, ACPI_NFIT1_OFFSET (RegionSize), "Region Size", 0},
+ {ACPI_DMT_UINT64, ACPI_NFIT1_OFFSET (RegionOffset), "Region Offset", 0},
+ {ACPI_DMT_UINT64, ACPI_NFIT1_OFFSET (Address), "Address Region Base", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT1_OFFSET (InterleaveIndex), "Interleave Index", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT1_OFFSET (InterleaveWays), "Interleave Ways", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT1_OFFSET (Flags), "Flags", DT_FLAG},
+ {ACPI_DMT_FLAG0, ACPI_NFIT1_FLAG_OFFSET (Flags,0), "Save to device failed", 0},
+ {ACPI_DMT_FLAG1, ACPI_NFIT1_FLAG_OFFSET (Flags,0), "Restore from device failed", 0},
+ {ACPI_DMT_FLAG2, ACPI_NFIT1_FLAG_OFFSET (Flags,0), "Platform flush failed", 0},
+ {ACPI_DMT_FLAG3, ACPI_NFIT1_FLAG_OFFSET (Flags,0), "Device not armed", 0},
+ {ACPI_DMT_FLAG4, ACPI_NFIT1_FLAG_OFFSET (Flags,0), "Health events observed", 0},
+ {ACPI_DMT_FLAG5, ACPI_NFIT1_FLAG_OFFSET (Flags,0), "Health events enabled", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT1_OFFSET (Reserved), "Reserved", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+/* 2: Interleave Structure */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoNfit2[] =
+{
+ {ACPI_DMT_UINT16, ACPI_NFIT2_OFFSET (InterleaveIndex), "Interleave Index", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT2_OFFSET (Reserved), "Reserved", 0},
+ {ACPI_DMT_UINT32, ACPI_NFIT2_OFFSET (LineCount), "Line Count", 0},
+ {ACPI_DMT_UINT32, ACPI_NFIT2_OFFSET (LineSize), "Line Size", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoNfit2a[] =
+{
+ {ACPI_DMT_UINT32, 0, "Line Offset", DT_OPTIONAL},
+ ACPI_DMT_TERMINATOR
+};
+
+/* 3: SMBIOS Management Information Structure */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoNfit3[] =
+{
+ {ACPI_DMT_UINT32, ACPI_NFIT3_OFFSET (Reserved), "Reserved", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoNfit3a[] =
+{
+ {ACPI_DMT_RAW_BUFFER, 0, "SMBIOS Table Entries", DT_OPTIONAL},
+ ACPI_DMT_TERMINATOR
+};
+
+/* 4: NVDIMM Control Region Structure */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoNfit4[] =
+{
+ {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (RegionIndex), "Region Index", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (VendorId), "Vendor Id", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (DeviceId), "Device Id", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (RevisionId), "Revision Id", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (SubsystemVendorId), "Subsystem Vendor Id", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (SubsystemDeviceId), "Subsystem Device Id", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (SubsystemRevisionId), "Subsystem Revision Id", 0},
+ {ACPI_DMT_UINT48, ACPI_NFIT4_OFFSET (Reserved[0]), "Reserved", 0},
+ {ACPI_DMT_UINT32, ACPI_NFIT4_OFFSET (SerialNumber), "Serial Number", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (Code), "Code", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (Windows), "Window Count", 0},
+ {ACPI_DMT_UINT64, ACPI_NFIT4_OFFSET (WindowSize), "Window Size", 0},
+ {ACPI_DMT_UINT64, ACPI_NFIT4_OFFSET (CommandOffset), "Command Offset", 0},
+ {ACPI_DMT_UINT64, ACPI_NFIT4_OFFSET (CommandSize), "Command Size", 0},
+ {ACPI_DMT_UINT64, ACPI_NFIT4_OFFSET (StatusOffset), "Status Offset", 0},
+ {ACPI_DMT_UINT64, ACPI_NFIT4_OFFSET (StatusSize), "Status Size", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT4_OFFSET (Flags), "Flags", DT_FLAG},
+ {ACPI_DMT_FLAG0, ACPI_NFIT4_FLAG_OFFSET (Flags,0), "Windows buffered", 0},
+ {ACPI_DMT_UINT48, ACPI_NFIT4_OFFSET (Reserved1[0]), "Reserved1", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+/* 5: NVDIMM Block Data Window Region Structure */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoNfit5[] =
+{
+ {ACPI_DMT_UINT16, ACPI_NFIT5_OFFSET (RegionIndex), "Region Index", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT5_OFFSET (Windows), "Window Count", 0},
+ {ACPI_DMT_UINT64, ACPI_NFIT5_OFFSET (Offset), "Offset", 0},
+ {ACPI_DMT_UINT64, ACPI_NFIT5_OFFSET (Size), "Size", 0},
+ {ACPI_DMT_UINT64, ACPI_NFIT5_OFFSET (Capacity), "Capacity", 0},
+ {ACPI_DMT_UINT64, ACPI_NFIT5_OFFSET (StartAddress), "Start Address", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+/* 6: Flush Hint Address Structure */
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoNfit6[] =
+{
+ {ACPI_DMT_UINT32, ACPI_NFIT6_OFFSET (DeviceHandle), "Device Handle", 0},
+ {ACPI_DMT_UINT16, ACPI_NFIT6_OFFSET (HintCount), "Hint Count", 0},
+ {ACPI_DMT_UINT48, ACPI_NFIT6_OFFSET (Reserved[0]), "Reserved", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoNfit6a[] =
+{
+ {ACPI_DMT_UINT64, 0, "Hint Address", DT_OPTIONAL},
+ ACPI_DMT_TERMINATOR
+};
+
+
+/*******************************************************************************
+ *
* PCCT - Platform Communications Channel Table (ACPI 5.0)
*
******************************************************************************/
@@ -2210,6 +2592,25 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoSrat3[] =
/*******************************************************************************
*
+ * STAO - Status Override Table (_STA override) - ACPI 6.0
+ *
+ ******************************************************************************/
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoStao[] =
+{
+ {ACPI_DMT_UINT8, ACPI_STAO_OFFSET (IgnoreUart), "Ignore UART", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoStaoStr[] =
+{
+ {ACPI_DMT_STRING, 0, "Namepath", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+
+/*******************************************************************************
+ *
* TCPA - Trusted Computing Platform Alliance table
*
******************************************************************************/
@@ -2388,6 +2789,49 @@ ACPI_DMTABLE_INFO AcpiDmTableInfoWdrt[] =
ACPI_DMT_TERMINATOR
};
+
+/*******************************************************************************
+ *
+ * WPBT - Windows Platform Environment Table (ACPI 6.0)
+ * Version 1
+ *
+ * Conforms to "Windows Platform Binary Table (WPBT)" 29 November 2011
+ *
+ ******************************************************************************/
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoWpbt[] =
+{
+ {ACPI_DMT_UINT32, ACPI_WPBT_OFFSET (HandoffSize), "Handoff Size", 0},
+ {ACPI_DMT_UINT64, ACPI_WPBT_OFFSET (HandoffAddress), "Handoff Address", 0},
+ {ACPI_DMT_UINT8, ACPI_WPBT_OFFSET (Layout), "Layout", 0},
+ {ACPI_DMT_UINT8, ACPI_WPBT_OFFSET (Type), "Type", 0},
+ {ACPI_DMT_UINT16, ACPI_WPBT_OFFSET (ArgumentsLength), "Arguments Length", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoWpbt0[] =
+{
+ {ACPI_DMT_UNICODE, sizeof (ACPI_TABLE_WPBT), "Command-line Arguments", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+
+/*******************************************************************************
+ *
+ * XENV - Xen Environment table (ACPI 6.0)
+ *
+ ******************************************************************************/
+
+ACPI_DMTABLE_INFO AcpiDmTableInfoXenv[] =
+{
+ {ACPI_DMT_UINT64, ACPI_XENV_OFFSET (GrantTableAddress), "Grant Table Address", 0},
+ {ACPI_DMT_UINT64, ACPI_XENV_OFFSET (GrantTableSize), "Grant Table Size", 0},
+ {ACPI_DMT_UINT32, ACPI_XENV_OFFSET (EventInterrupt), "Event Interrupt", 0},
+ {ACPI_DMT_UINT8, ACPI_XENV_OFFSET (EventFlags), "Event Flags", 0},
+ ACPI_DMT_TERMINATOR
+};
+
+
/*! [Begin] no source code translation */
/*
diff --git a/sys/contrib/dev/acpica/compiler/aslascii.c b/sys/contrib/dev/acpica/compiler/aslascii.c
index e6b3311..08e4630 100644
--- a/sys/contrib/dev/acpica/compiler/aslascii.c
+++ b/sys/contrib/dev/acpica/compiler/aslascii.c
@@ -148,8 +148,7 @@ FlCheckForAcpiTable (
*
* FUNCTION: FlCheckForAscii
*
- * PARAMETERS: Handle - Open input file
- * Filename - Input filename
+ * PARAMETERS: Filename - Full input filename
* DisplayErrors - TRUE if error messages desired
*
* RETURN: Status
@@ -165,7 +164,6 @@ FlCheckForAcpiTable (
ACPI_STATUS
FlCheckForAscii (
- FILE *Handle,
char *Filename,
BOOLEAN DisplayErrors)
{
@@ -173,7 +171,12 @@ FlCheckForAscii (
ACPI_SIZE BadBytes = 0;
BOOLEAN OpeningComment = FALSE;
ASL_FILE_STATUS Status;
+ FILE *Handle;
+
+
+ /* Open file in text mode so file offset is always accurate */
+ Handle = fopen (Filename, "rb");
Status.Line = 1;
Status.Offset = 0;
@@ -214,16 +217,30 @@ FlCheckForAscii (
if ((BadBytes < 10) && (DisplayErrors))
{
AcpiOsPrintf (
- "Non-ASCII character [0x%2.2X] found in line %u, file offset 0x%.2X\n",
+ "Found non-ASCII character in source text: "
+ "0x%2.2X in line %u, file offset 0x%2.2X\n",
Byte, Status.Line, Status.Offset);
}
+ BadBytes++;
+ }
+ /* Ensure character is either printable or a "space" char */
+
+ else if (!ACPI_IS_PRINT (Byte) && !ACPI_IS_SPACE (Byte))
+ {
+ if ((BadBytes < 10) && (DisplayErrors))
+ {
+ AcpiOsPrintf (
+ "Found invalid character in source text: "
+ "0x%2.2X in line %u, file offset 0x%2.2X\n",
+ Byte, Status.Line, Status.Offset);
+ }
BadBytes++;
}
- /* Update line counter */
+ /* Update line counter as necessary */
- else if (Byte == 0x0A)
+ if (Byte == 0x0A)
{
Status.Line++;
}
@@ -231,9 +248,7 @@ FlCheckForAscii (
Status.Offset++;
}
- /* Seek back to the beginning of the source file */
-
- fseek (Handle, 0, SEEK_SET);
+ fclose (Handle);
/* Were there any non-ASCII characters in the file? */
@@ -242,8 +257,8 @@ FlCheckForAscii (
if (DisplayErrors)
{
AcpiOsPrintf (
- "%u non-ASCII characters found in input source text, could be a binary file\n",
- BadBytes);
+ "Total %u invalid characters found in input source text, "
+ "could be a binary file\n", BadBytes);
AslError (ASL_ERROR, ASL_MSG_NON_ASCII, NULL, Filename);
}
@@ -286,6 +301,7 @@ FlConsumeAnsiComment (
{
if (Byte == '/')
{
+ Status->Offset++;
return;
}
diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.h b/sys/contrib/dev/acpica/compiler/aslcompiler.h
index 7b07295..181b36c 100644
--- a/sys/contrib/dev/acpica/compiler/aslcompiler.h
+++ b/sys/contrib/dev/acpica/compiler/aslcompiler.h
@@ -172,7 +172,6 @@ FlCheckForAcpiTable (
ACPI_STATUS
FlCheckForAscii (
- FILE *Handle,
char *Filename,
BOOLEAN DisplayErrors);
diff --git a/sys/contrib/dev/acpica/compiler/aslcompiler.l b/sys/contrib/dev/acpica/compiler/aslcompiler.l
index f831233..621f5ae 100644
--- a/sys/contrib/dev/acpica/compiler/aslcompiler.l
+++ b/sys/contrib/dev/acpica/compiler/aslcompiler.l
@@ -709,9 +709,18 @@ NamePathTail [.]{NameSeg}
return (PARSEOP_NAMESTRING); }
. { count (1);
- sprintf (MsgBuffer,
- "Invalid character (0x%2.2X), expecting ASL keyword or name",
- *AslCompilertext);
+ if (ACPI_IS_PRINT (*AslCompilertext))
+ {
+ sprintf (MsgBuffer,
+ "Invalid character (%c), expecting ASL keyword or name",
+ *AslCompilertext);
+ }
+ else
+ {
+ sprintf (MsgBuffer,
+ "Invalid character (0x%2.2X), expecting ASL keyword or name",
+ *AslCompilertext);
+ }
AslCompilererror (MsgBuffer);}
<<EOF>> { if (AslPopInputFileStack ())
diff --git a/sys/contrib/dev/acpica/compiler/asldefine.h b/sys/contrib/dev/acpica/compiler/asldefine.h
index 14307c1..0697276 100644
--- a/sys/contrib/dev/acpica/compiler/asldefine.h
+++ b/sys/contrib/dev/acpica/compiler/asldefine.h
@@ -53,7 +53,7 @@
#define ASL_INVOCATION_NAME "iasl"
#define ASL_CREATOR_ID "INTL"
-#define ASL_COMPLIANCE "Supports ACPI Specification Revision 5.1"
+#define ASL_COMPLIANCE "Supports ACPI Specification Revision 6.0"
/* Configuration constants */
diff --git a/sys/contrib/dev/acpica/compiler/aslfiles.c b/sys/contrib/dev/acpica/compiler/aslfiles.c
index 63a8dbb..d8c9ed5 100644
--- a/sys/contrib/dev/acpica/compiler/aslfiles.c
+++ b/sys/contrib/dev/acpica/compiler/aslfiles.c
@@ -49,9 +49,10 @@
/* Local prototypes */
-FILE *
+static FILE *
FlOpenIncludeWithPrefix (
char *PrefixDir,
+ ACPI_PARSE_OBJECT *Op,
char *Filename);
@@ -294,9 +295,10 @@ ConvertBackslashes:
*
******************************************************************************/
-FILE *
+static FILE *
FlOpenIncludeWithPrefix (
char *PrefixDir,
+ ACPI_PARSE_OBJECT *Op,
char *Filename)
{
FILE *IncludeFile;
@@ -320,6 +322,26 @@ FlOpenIncludeWithPrefix (
return (NULL);
}
+#ifdef _MUST_HANDLE_COMMENTS
+ /*
+ * Check entire include file for any # preprocessor directives.
+ * This is because there may be some confusion between the #include
+ * preprocessor directive and the ASL Include statement.
+ */
+ while (fgets (Gbl_CurrentLineBuffer, Gbl_LineBufferSize, IncludeFile))
+ {
+ if (Gbl_CurrentLineBuffer[0] == '#')
+ {
+ AslError (ASL_ERROR, ASL_MSG_INCLUDE_FILE,
+ Op, "use #include instead");
+ }
+ }
+#endif
+
+ /* Must seek back to the start of the file */
+
+ fseek (IncludeFile, 0, SEEK_SET);
+
/* Push the include file on the open input file stack */
AslPushInputFileStack (IncludeFile, Pathname);
@@ -376,7 +398,7 @@ FlOpenIncludeFile (
(Op->Asl.Value.String[0] == '\\') ||
(Op->Asl.Value.String[1] == ':'))
{
- IncludeFile = FlOpenIncludeWithPrefix ("", Op->Asl.Value.String);
+ IncludeFile = FlOpenIncludeWithPrefix ("", Op, Op->Asl.Value.String);
if (!IncludeFile)
{
goto ErrorExit;
@@ -392,7 +414,7 @@ FlOpenIncludeFile (
*
* Construct the file pathname from the global directory name.
*/
- IncludeFile = FlOpenIncludeWithPrefix (Gbl_DirectoryPath, Op->Asl.Value.String);
+ IncludeFile = FlOpenIncludeWithPrefix (Gbl_DirectoryPath, Op, Op->Asl.Value.String);
if (IncludeFile)
{
return;
@@ -405,7 +427,7 @@ FlOpenIncludeFile (
NextDir = Gbl_IncludeDirList;
while (NextDir)
{
- IncludeFile = FlOpenIncludeWithPrefix (NextDir->Dir, Op->Asl.Value.String);
+ IncludeFile = FlOpenIncludeWithPrefix (NextDir->Dir, Op, Op->Asl.Value.String);
if (IncludeFile)
{
return;
diff --git a/sys/contrib/dev/acpica/compiler/aslmessages.c b/sys/contrib/dev/acpica/compiler/aslmessages.c
index 12a4208..c57fd2d 100644
--- a/sys/contrib/dev/acpica/compiler/aslmessages.c
+++ b/sys/contrib/dev/acpica/compiler/aslmessages.c
@@ -270,7 +270,8 @@ const char *AslPreprocessorMsgs [] =
/* ASL_MSG_TOO_MANY_ARGUMENTS */ "Too many macro arguments",
/* ASL_MSG_UNKNOWN_DIRECTIVE */ "Unknown directive",
/* ASL_MSG_UNKNOWN_PRAGMA */ "Unknown pragma",
-/* ASL_MSG_WARNING_DIRECTIVE */ "#warning"
+/* ASL_MSG_WARNING_DIRECTIVE */ "#warning",
+/* ASL_MSG_INCLUDE_FILE */ "Found a # preprocessor directive in ASL Include() file"
};
@@ -331,7 +332,7 @@ AeDecodeMessageId (
if (Index >= ACPI_ARRAY_LENGTH (AslPreprocessorMsgs))
{
- return ("[Unknown Preprocesor exception ID]");
+ return ("[Unknown Preprocessor exception ID]");
}
}
diff --git a/sys/contrib/dev/acpica/compiler/aslmessages.h b/sys/contrib/dev/acpica/compiler/aslmessages.h
index 7a04a63..9837d54 100644
--- a/sys/contrib/dev/acpica/compiler/aslmessages.h
+++ b/sys/contrib/dev/acpica/compiler/aslmessages.h
@@ -267,6 +267,7 @@ typedef enum
ASL_MSG_UNKNOWN_DIRECTIVE,
ASL_MSG_UNKNOWN_PRAGMA,
ASL_MSG_WARNING_DIRECTIVE,
+ ASL_MSG_INCLUDE_FILE
} ASL_MESSAGE_IDS;
diff --git a/sys/contrib/dev/acpica/compiler/aslprepkg.c b/sys/contrib/dev/acpica/compiler/aslprepkg.c
index 37a58df..be0a4c4 100644
--- a/sys/contrib/dev/acpica/compiler/aslprepkg.c
+++ b/sys/contrib/dev/acpica/compiler/aslprepkg.c
@@ -151,6 +151,7 @@ ApCheckPackage (
case ACPI_PTYPE2_FIXED:
case ACPI_PTYPE2_MIN:
case ACPI_PTYPE2_FIX_VAR:
+ case ACPI_PTYPE2_VAR_VAR:
default:
break;
@@ -324,6 +325,32 @@ ApCheckPackage (
break;
+ case ACPI_PTYPE2_VAR_VAR:
+
+ /* Check for minimum size (ints at beginning + 1 subpackage) */
+
+ ExpectedCount = Package->RetInfo4.Count1 + 1;
+ if (Count < ExpectedCount)
+ {
+ goto PackageTooSmall;
+ }
+
+ /* Check the non-package elements at beginning of main package */
+
+ for (i = 0; i < Package->RetInfo4.Count1; ++i)
+ {
+ Status = ApCheckObjectType (Predefined->Info.Name, Op,
+ Package->RetInfo4.ObjectType1, i);
+ Op = Op->Asl.Next;
+ }
+
+ /* Examine the variable-length list of subpackages */
+
+ ApCheckPackageList (Predefined->Info.Name, Op,
+ Package, Package->RetInfo4.Count1, Count);
+
+ break;
+
case ACPI_PTYPE2:
case ACPI_PTYPE2_FIXED:
case ACPI_PTYPE2_MIN:
@@ -427,6 +454,7 @@ ApCheckPackageElements (
* ACPI_PTYPE2_MIN
* ACPI_PTYPE2_COUNT
* ACPI_PTYPE2_FIX_VAR
+ * ACPI_PTYPE2_VAR_VAR
*
******************************************************************************/
@@ -473,9 +501,12 @@ ApCheckPackageList (
Count = (UINT32) Op->Asl.Value.Integer;
Op = Op->Asl.Next;
- /* The subpackage must have at least one element */
-
- if (!Count)
+ /*
+ * Most subpackage must have at least one element, with
+ * only rare exceptions. (_RDI)
+ */
+ if (!Count &&
+ (Package->RetInfo.Type != ACPI_PTYPE2_VAR_VAR))
{
ApZeroLengthPackage (PredefinedName, SubPackageOp);
goto NextSubpackage;
@@ -533,6 +564,25 @@ ApCheckPackageList (
Count - Package->RetInfo.Count1);
break;
+ case ACPI_PTYPE2_VAR_VAR:
+ /*
+ * Must have at least the minimum number elements.
+ * A zero PkgCount means the number of elements is variable.
+ */
+ ExpectedCount = Package->RetInfo4.PkgCount;
+ if (ExpectedCount && (Count < ExpectedCount))
+ {
+ ApPackageTooSmall (PredefinedName, SubPackageOp,
+ Count, 1);
+ break;
+ }
+
+ ApCheckPackageElements (PredefinedName, Op,
+ Package->RetInfo4.SubObjectTypes,
+ Package->RetInfo4.PkgCount,
+ 0, 0);
+ break;
+
case ACPI_PTYPE2_FIXED:
/* Each subpackage has a fixed length */
diff --git a/sys/contrib/dev/acpica/compiler/aslstartup.c b/sys/contrib/dev/acpica/compiler/aslstartup.c
index cbebd0d..85e2f88 100644
--- a/sys/contrib/dev/acpica/compiler/aslstartup.c
+++ b/sys/contrib/dev/acpica/compiler/aslstartup.c
@@ -159,10 +159,10 @@ AslDetectSourceFileType (
/* Check for 100% ASCII source file (comments are ignored) */
- Status = FlCheckForAscii (Info->Handle, Info->Filename, TRUE);
+ Status = FlCheckForAscii (Info->Filename, TRUE);
if (ACPI_FAILURE (Status))
{
- printf ("Non-ascii input file - %s\n", Info->Filename);
+ printf ("Invalid characters in input file - %s\n", Info->Filename);
if (!Gbl_IgnoreErrors)
{
diff --git a/sys/contrib/dev/acpica/compiler/aslutils.c b/sys/contrib/dev/acpica/compiler/aslutils.c
index 37d394b..dadd6b1 100644
--- a/sys/contrib/dev/acpica/compiler/aslutils.c
+++ b/sys/contrib/dev/acpica/compiler/aslutils.c
@@ -77,13 +77,11 @@ UtAttachNameseg (
*
******************************************************************************/
-#define ACPI_TABLE_HELP_FORMAT "%8u) %s %s\n"
-
void
UtDisplaySupportedTables (
void)
{
- ACPI_DMTABLE_DATA *TableData;
+ const AH_TABLE *TableData;
UINT32 i;
@@ -91,20 +89,14 @@ UtDisplaySupportedTables (
" (Compiler, Disassembler, Template Generator)\n\n",
ACPI_CA_VERSION);
- /* Special tables */
-
- printf (" Special tables and AML tables:\n");
- printf (ACPI_TABLE_HELP_FORMAT, 1, ACPI_RSDP_NAME, "Root System Description Pointer");
- printf (ACPI_TABLE_HELP_FORMAT, 2, ACPI_SIG_FACS, "Firmware ACPI Control Structure");
- printf (ACPI_TABLE_HELP_FORMAT, 3, ACPI_SIG_DSDT, "Differentiated System Description Table");
- printf (ACPI_TABLE_HELP_FORMAT, 4, ACPI_SIG_SSDT, "Secondary System Description Table");
-
- /* All data tables with common table header */
+ /* All ACPI tables with the common table header */
- printf ("\n Standard ACPI data tables:\n");
- for (TableData = AcpiDmTableData, i = 5; TableData->Signature; TableData++, i++)
+ printf ("\n Supported ACPI tables:\n");
+ for (TableData = AcpiSupportedTables, i = 1;
+ TableData->Signature; TableData++, i++)
{
- printf (ACPI_TABLE_HELP_FORMAT, i, TableData->Signature, TableData->Name);
+ printf ("%8u) %s %s\n", i,
+ TableData->Signature, TableData->Description);
}
}
diff --git a/sys/contrib/dev/acpica/compiler/dtcompile.c b/sys/contrib/dev/acpica/compiler/dtcompile.c
index 74bfc33..20da143 100644
--- a/sys/contrib/dev/acpica/compiler/dtcompile.c
+++ b/sys/contrib/dev/acpica/compiler/dtcompile.c
@@ -283,7 +283,7 @@ static ACPI_STATUS
DtCompileDataTable (
DT_FIELD **FieldList)
{
- ACPI_DMTABLE_DATA *TableData;
+ const ACPI_DMTABLE_DATA *TableData;
DT_SUBTABLE *Subtable;
char *Signature;
ACPI_TABLE_HEADER *AcpiTableHeader;
@@ -358,7 +358,7 @@ DtCompileDataTable (
TableData = AcpiDmGetTableData (Signature);
if (!TableData || Gbl_CompileGeneric)
{
- DtCompileGeneric ((void **) FieldList);
+ DtCompileGeneric ((void **) FieldList, NULL, NULL);
goto FinishHeader;
}
@@ -436,14 +436,14 @@ DtCompileTable (
DT_FIELD *LocalField;
UINT32 Length;
DT_SUBTABLE *Subtable;
- DT_SUBTABLE *InlineSubtable;
+ DT_SUBTABLE *InlineSubtable = NULL;
UINT32 FieldLength = 0;
UINT8 FieldType;
UINT8 *Buffer;
UINT8 *FlagBuffer = NULL;
char *String;
UINT32 CurrentFlagByteOffset = 0;
- ACPI_STATUS Status;
+ ACPI_STATUS Status = AE_OK;
if (!Field || !*Field)
@@ -479,6 +479,7 @@ DtCompileTable (
Buffer = Subtable->Buffer;
LocalField = *Field;
+ Subtable->Name = LocalField->Name;
/*
* Main loop walks the info table for this ACPI table or subtable
@@ -555,15 +556,32 @@ DtCompileTable (
*/
*Field = LocalField;
- if (Info->Opcode == ACPI_DMT_GAS)
+ switch (Info->Opcode)
{
+ case ACPI_DMT_GAS:
+
Status = DtCompileTable (Field, AcpiDmTableInfoGas,
&InlineSubtable, TRUE);
- }
- else
- {
+ break;
+
+ case ACPI_DMT_HESTNTFY:
+
Status = DtCompileTable (Field, AcpiDmTableInfoHestNotify,
&InlineSubtable, TRUE);
+ break;
+
+ case ACPI_DMT_IORTMEM:
+
+ Status = DtCompileTable (Field, AcpiDmTableInfoIortAcc,
+ &InlineSubtable, TRUE);
+ break;
+
+ default:
+ sprintf (MsgBuffer, "Invalid DMT opcode: 0x%.2X",
+ Info->Opcode);
+ DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, MsgBuffer);
+ Status = AE_BAD_DATA;
+ break;
}
if (ACPI_FAILURE (Status))
@@ -600,7 +618,6 @@ DtCompileTable (
Subtable->LengthField = Buffer;
Subtable->SizeOfLengthField = FieldLength;
}
-
break;
}
@@ -616,3 +633,43 @@ Error:
ACPI_FREE (Subtable);
return (Status);
}
+
+
+/******************************************************************************
+ *
+ * FUNCTION: DtCompilePadding
+ *
+ * PARAMETERS: Length - Padding field size
+ * RetSubtable - Compile result of table
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Compile a subtable for padding purpose
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+DtCompilePadding (
+ UINT32 Length,
+ DT_SUBTABLE **RetSubtable)
+{
+ DT_SUBTABLE *Subtable;
+ /* UINT8 *Buffer; */
+ char *String;
+
+
+ Subtable = UtSubtableCacheCalloc ();
+
+ if (Length > 0)
+ {
+ String = UtStringCacheCalloc (Length);
+ Subtable->Buffer = ACPI_CAST_PTR (UINT8, String);
+ }
+
+ Subtable->Length = Length;
+ Subtable->TotalLength = Length;
+ /* Buffer = Subtable->Buffer; */
+
+ *RetSubtable = Subtable;
+ return (AE_OK);
+}
diff --git a/sys/contrib/dev/acpica/compiler/dtcompiler.h b/sys/contrib/dev/acpica/compiler/dtcompiler.h
index 3a0b763..201b2db 100644
--- a/sys/contrib/dev/acpica/compiler/dtcompiler.h
+++ b/sys/contrib/dev/acpica/compiler/dtcompiler.h
@@ -115,6 +115,7 @@ typedef struct dt_subtable
struct dt_subtable *StackTop;
UINT8 *Buffer;
UINT8 *LengthField;
+ char *Name;
UINT32 Length;
UINT32 TotalLength;
UINT32 SizeOfLengthField;
@@ -170,6 +171,11 @@ DtCompileTable (
DT_SUBTABLE **RetSubtable,
BOOLEAN Required);
+ACPI_STATUS
+DtCompilePadding (
+ UINT32 Length,
+ DT_SUBTABLE **RetSubtable);
+
/* dtio - binary and text input/output */
@@ -429,6 +435,10 @@ DtCompileDmar (
void **PFieldList);
ACPI_STATUS
+DtCompileDrtm (
+ void **PFieldList);
+
+ACPI_STATUS
DtCompileEinj (
void **PFieldList);
@@ -453,6 +463,10 @@ DtCompileHest (
void **PFieldList);
ACPI_STATUS
+DtCompileIort (
+ void **PFieldList);
+
+ACPI_STATUS
DtCompileIvrs (
void **PFieldList);
@@ -481,6 +495,10 @@ DtCompileMtmr (
void **PFieldList);
ACPI_STATUS
+DtCompileNfit (
+ void **PFieldList);
+
+ACPI_STATUS
DtCompilePmtt (
void **PFieldList);
@@ -509,6 +527,10 @@ DtCompileSrat (
void **PFieldList);
ACPI_STATUS
+DtCompileStao (
+ void **PFieldList);
+
+ACPI_STATUS
DtCompileUefi (
void **PFieldList);
@@ -521,12 +543,18 @@ DtCompileWdat (
void **PFieldList);
ACPI_STATUS
+DtCompileWpbt (
+ void **PFieldList);
+
+ACPI_STATUS
DtCompileXsdt (
void **PFieldList);
ACPI_STATUS
DtCompileGeneric (
- void **PFieldList);
+ void **PFieldList,
+ char *TermFieldName,
+ UINT32 *PFieldLength);
ACPI_DMTABLE_INFO *
DtGetGenericTableInfo (
@@ -543,6 +571,7 @@ extern const unsigned char TemplateCsrt[];
extern const unsigned char TemplateDbg2[];
extern const unsigned char TemplateDbgp[];
extern const unsigned char TemplateDmar[];
+extern const unsigned char TemplateDrtm[];
extern const unsigned char TemplateEcdt[];
extern const unsigned char TemplateEinj[];
extern const unsigned char TemplateErst[];
@@ -551,6 +580,7 @@ extern const unsigned char TemplateFpdt[];
extern const unsigned char TemplateGtdt[];
extern const unsigned char TemplateHest[];
extern const unsigned char TemplateHpet[];
+extern const unsigned char TemplateIort[];
extern const unsigned char TemplateIvrs[];
extern const unsigned char TemplateLpit[];
extern const unsigned char TemplateMadt[];
@@ -560,6 +590,7 @@ extern const unsigned char TemplateMpst[];
extern const unsigned char TemplateMsct[];
extern const unsigned char TemplateMsdm[];
extern const unsigned char TemplateMtmr[];
+extern const unsigned char TemplateNfit[];
extern const unsigned char TemplatePcct[];
extern const unsigned char TemplatePmtt[];
extern const unsigned char TemplateRsdt[];
@@ -570,6 +601,7 @@ extern const unsigned char TemplateSlit[];
extern const unsigned char TemplateSpcr[];
extern const unsigned char TemplateSpmi[];
extern const unsigned char TemplateSrat[];
+extern const unsigned char TemplateStao[];
extern const unsigned char TemplateTcpa[];
extern const unsigned char TemplateTpm2[];
extern const unsigned char TemplateUefi[];
@@ -578,6 +610,8 @@ extern const unsigned char TemplateWaet[];
extern const unsigned char TemplateWdat[];
extern const unsigned char TemplateWddt[];
extern const unsigned char TemplateWdrt[];
+extern const unsigned char TemplateWpbt[];
+extern const unsigned char TemplateXenv[];
extern const unsigned char TemplateXsdt[];
#endif
diff --git a/sys/contrib/dev/acpica/compiler/dtio.c b/sys/contrib/dev/acpica/compiler/dtio.c
index bebd927..4b05bd0 100644
--- a/sys/contrib/dev/acpica/compiler/dtio.c
+++ b/sys/contrib/dev/acpica/compiler/dtio.c
@@ -978,8 +978,8 @@ DtDumpSubtableInfo (
{
DbgPrint (ASL_DEBUG_OUTPUT,
- "[%.04X] %.08X %.08X %.08X %.08X %.08X %p %p %p\n",
- Subtable->Depth, Subtable->Length, Subtable->TotalLength,
+ "[%.04X] %24s %.08X %.08X %.08X %.08X %.08X %p %p %p\n",
+ Subtable->Depth, Subtable->Name, Subtable->Length, Subtable->TotalLength,
Subtable->SizeOfLengthField, Subtable->Flags, Subtable,
Subtable->Parent, Subtable->Child, Subtable->Peer);
}
@@ -992,8 +992,8 @@ DtDumpSubtableTree (
{
DbgPrint (ASL_DEBUG_OUTPUT,
- "[%.04X] %*s%08X (%.02X) - (%.02X)\n",
- Subtable->Depth, (4 * Subtable->Depth), " ",
+ "[%.04X] %24s %*s%08X (%.02X) - (%.02X)\n",
+ Subtable->Depth, Subtable->Name, (4 * Subtable->Depth), " ",
Subtable, Subtable->Length, Subtable->TotalLength);
}
@@ -1024,12 +1024,12 @@ DtDumpSubtableList (
DbgPrint (ASL_DEBUG_OUTPUT,
"Subtable Info:\n"
- "Depth Length TotalLen LenSize Flags "
+ "Depth Name Length TotalLen LenSize Flags "
"This Parent Child Peer\n\n");
DtWalkTableTree (Gbl_RootTable, DtDumpSubtableInfo, NULL, NULL);
DbgPrint (ASL_DEBUG_OUTPUT,
- "\nSubtable Tree: (Depth, Subtable, Length, TotalLength)\n\n");
+ "\nSubtable Tree: (Depth, Name, Subtable, Length, TotalLength)\n\n");
DtWalkTableTree (Gbl_RootTable, DtDumpSubtableTree, NULL, NULL);
DbgPrint (ASL_DEBUG_OUTPUT, "\n");
diff --git a/sys/contrib/dev/acpica/compiler/dtsubtable.c b/sys/contrib/dev/acpica/compiler/dtsubtable.c
index 1e6a76a..1152656 100644
--- a/sys/contrib/dev/acpica/compiler/dtsubtable.c
+++ b/sys/contrib/dev/acpica/compiler/dtsubtable.c
@@ -321,6 +321,11 @@ DtGetSubtableLength (
Step = 9;
break;
+ case ACPI_DMT_IORTMEM:
+
+ Step = 10;
+ break;
+
default:
Step = 1;
diff --git a/sys/contrib/dev/acpica/compiler/dttable.c b/sys/contrib/dev/acpica/compiler/dttable.c
index 3fe02e8..bae80ad 100644
--- a/sys/contrib/dev/acpica/compiler/dttable.c
+++ b/sys/contrib/dev/acpica/compiler/dttable.c
@@ -65,12 +65,6 @@ static ACPI_DMTABLE_INFO TableInfoDmarPciPath[] =
};
-/* TBD: move to acmacros.h */
-
-#define ACPI_SUB_PTR(t, a, b) \
- ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8, (a)) - (ACPI_SIZE)(b)))
-
-
/* Local prototypes */
static ACPI_STATUS
@@ -454,6 +448,7 @@ DtCompileCsrt (
/* Subtables (Resource Groups) */
+ ParentTable = DtPeekSubtable ();
while (*PFieldList)
{
/* Resource group subtable */
@@ -477,9 +472,9 @@ DtCompileCsrt (
DescriptorCount = (GroupLength /
sizeof (ACPI_CSRT_DESCRIPTOR));
- ParentTable = DtPeekSubtable ();
DtInsertSubtable (ParentTable, Subtable);
DtPushSubtable (Subtable);
+ ParentTable = DtPeekSubtable ();
/* Shared info subtable (One per resource group) */
@@ -490,26 +485,44 @@ DtCompileCsrt (
return (Status);
}
- ParentTable = DtPeekSubtable ();
DtInsertSubtable (ParentTable, Subtable);
/* Sub-Subtables (Resource Descriptors) */
while (*PFieldList && DescriptorCount)
{
+
Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt2,
&Subtable, TRUE);
if (ACPI_FAILURE (Status))
{
return (Status);
}
+ DtInsertSubtable (ParentTable, Subtable);
+ DtPushSubtable (Subtable);
ParentTable = DtPeekSubtable ();
- DtInsertSubtable (ParentTable, Subtable);
+ if (*PFieldList)
+ {
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt2a,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ if (Subtable)
+ {
+ DtInsertSubtable (ParentTable, Subtable);
+ }
+ }
+ DtPopSubtable ();
+ ParentTable = DtPeekSubtable ();
+
DescriptorCount--;
}
DtPopSubtable ();
+ ParentTable = DtPeekSubtable ();
}
return (Status);
@@ -828,6 +841,135 @@ DtCompileDmar (
/******************************************************************************
*
+ * FUNCTION: DtCompileDrtm
+ *
+ * PARAMETERS: List - Current field list pointer
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Compile DRTM.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+DtCompileDrtm (
+ void **List)
+{
+ ACPI_STATUS Status;
+ DT_SUBTABLE *Subtable;
+ DT_SUBTABLE *ParentTable;
+ DT_FIELD **PFieldList = (DT_FIELD **) List;
+ UINT32 Count;
+ /* ACPI_TABLE_DRTM *Drtm; */
+ ACPI_DRTM_VTABLE_LIST *DrtmVtl;
+ ACPI_DRTM_RESOURCE_LIST *DrtmRl;
+ /* ACPI_DRTM_DPS_ID *DrtmDps; */
+
+
+ ParentTable = DtPeekSubtable ();
+
+ /* Compile DRTM header */
+
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+
+ /*
+ * Using ACPI_SUB_PTR, We needn't define a seperate structure. Care
+ * should be taken to avoid accessing ACPI_TABLE_HADER fields.
+ */
+#if 0
+ Drtm = ACPI_SUB_PTR (ACPI_TABLE_DRTM,
+ Subtable->Buffer, sizeof (ACPI_TABLE_HEADER));
+#endif
+ /* Compile VTL */
+
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm0,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ DrtmVtl = ACPI_CAST_PTR (ACPI_DRTM_VTABLE_LIST, Subtable->Buffer);
+
+ DtPushSubtable (Subtable);
+ ParentTable = DtPeekSubtable ();
+ Count = 0;
+ while (*PFieldList)
+ {
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm0a,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ if (!Subtable)
+ {
+ break;
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ Count++;
+ }
+ DrtmVtl->ValidatedTableCount = Count;
+ DtPopSubtable ();
+ ParentTable = DtPeekSubtable ();
+
+ /* Compile RL */
+
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm1,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ DrtmRl = ACPI_CAST_PTR (ACPI_DRTM_RESOURCE_LIST, Subtable->Buffer);
+
+ DtPushSubtable (Subtable);
+ ParentTable = DtPeekSubtable ();
+ Count = 0;
+ while (*PFieldList)
+ {
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm1a,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ if (!Subtable)
+ {
+ break;
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ Count++;
+ }
+ DrtmRl->ResourceCount = Count;
+ DtPopSubtable ();
+ ParentTable = DtPeekSubtable ();
+
+ /* Compile DPS */
+
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoDrtm2,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ /* DrtmDps = ACPI_CAST_PTR (ACPI_DRTM_DPS_ID, Subtable->Buffer);*/
+
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
* FUNCTION: DtCompileEinj
*
* PARAMETERS: List - Current field list pointer
@@ -946,6 +1088,18 @@ DtCompileFadt (
DtInsertSubtable (ParentTable, Subtable);
}
+
+ if (Revision >= 6)
+ {
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoFadt6,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ DtInsertSubtable (ParentTable, Subtable);
+ }
}
return (AE_OK);
@@ -1285,6 +1439,309 @@ DtCompileHest (
/******************************************************************************
*
+ * FUNCTION: DtCompileIort
+ *
+ * PARAMETERS: List - Current field list pointer
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Compile IORT.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+DtCompileIort (
+ void **List)
+{
+ ACPI_STATUS Status;
+ DT_SUBTABLE *Subtable;
+ DT_SUBTABLE *ParentTable;
+ DT_FIELD **PFieldList = (DT_FIELD **) List;
+ DT_FIELD *SubtableStart;
+ ACPI_TABLE_IORT *Iort;
+ ACPI_IORT_NODE *IortNode;
+ ACPI_IORT_ITS_GROUP *IortItsGroup;
+ ACPI_IORT_SMMU *IortSmmu;
+ UINT32 NodeNumber;
+ UINT32 NodeLength;
+ UINT32 IdMappingNumber;
+ UINT32 ItsNumber;
+ UINT32 ContextIrptNumber;
+ UINT32 PmuIrptNumber;
+ UINT32 PaddingLength;
+
+
+ ParentTable = DtPeekSubtable ();
+
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+
+ /*
+ * Using ACPI_SUB_PTR, We needn't define a seperate structure. Care
+ * should be taken to avoid accessing ACPI_TABLE_HADER fields.
+ */
+ Iort = ACPI_SUB_PTR (ACPI_TABLE_IORT,
+ Subtable->Buffer, sizeof (ACPI_TABLE_HEADER));
+
+ /*
+ * OptionalPadding - Variable-length data
+ * (Optional, size = OffsetToNodes - sizeof (ACPI_TABLE_IORT))
+ * Optionally allows the generic data types to be used for filling
+ * this field.
+ */
+ Iort->NodeOffset = sizeof (ACPI_TABLE_IORT);
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoIortPad,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ if (Subtable)
+ {
+ DtInsertSubtable (ParentTable, Subtable);
+ Iort->NodeOffset += Subtable->Length;
+ }
+ else
+ {
+ Status = DtCompileGeneric (ACPI_CAST_PTR (void *, PFieldList),
+ AcpiDmTableInfoIortHdr[0].Name, &PaddingLength);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ Iort->NodeOffset += PaddingLength;
+ }
+
+ NodeNumber = 0;
+ while (*PFieldList)
+ {
+ SubtableStart = *PFieldList;
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoIortHdr,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ IortNode = ACPI_CAST_PTR (ACPI_IORT_NODE, Subtable->Buffer);
+ NodeLength = ACPI_OFFSET (ACPI_IORT_NODE, NodeData);
+
+ DtPushSubtable (Subtable);
+ ParentTable = DtPeekSubtable ();
+
+ switch (IortNode->Type)
+ {
+ case ACPI_IORT_NODE_ITS_GROUP:
+
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort0,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ IortItsGroup = ACPI_CAST_PTR (ACPI_IORT_ITS_GROUP, Subtable->Buffer);
+ NodeLength += Subtable->Length;
+
+ ItsNumber = 0;
+ while (*PFieldList)
+ {
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort0a,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ if (!Subtable)
+ {
+ break;
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ NodeLength += Subtable->Length;
+ ItsNumber++;
+ }
+
+ IortItsGroup->ItsCount = ItsNumber;
+ break;
+
+ case ACPI_IORT_NODE_NAMED_COMPONENT:
+
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort1,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ NodeLength += Subtable->Length;
+
+ /*
+ * Padding - Variable-length data
+ * Optionally allows the offset of the ID mappings to be used
+ * for filling this field.
+ */
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort1a,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ if (Subtable)
+ {
+ DtInsertSubtable (ParentTable, Subtable);
+ NodeLength += Subtable->Length;
+ }
+ else
+ {
+ if (NodeLength > IortNode->MappingOffset)
+ {
+ return (AE_BAD_DATA);
+ }
+ if (NodeLength < IortNode->MappingOffset)
+ {
+ Status = DtCompilePadding (
+ IortNode->MappingOffset - NodeLength,
+ &Subtable);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ NodeLength = IortNode->MappingOffset;
+ }
+ }
+ break;
+
+ case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
+
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort2,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ NodeLength += Subtable->Length;
+ break;
+
+ case ACPI_IORT_NODE_SMMU:
+
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ IortSmmu = ACPI_CAST_PTR (ACPI_IORT_SMMU, Subtable->Buffer);
+ NodeLength += Subtable->Length;
+
+ /* Compile global interrupt array */
+
+ IortSmmu->GlobalInterruptOffset = NodeLength;
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3a,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ NodeLength += Subtable->Length;
+
+ /* Compile context interrupt array */
+
+ ContextIrptNumber = 0;
+ IortSmmu->ContextInterruptOffset = NodeLength;
+ while (*PFieldList)
+ {
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3b,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ if (!Subtable)
+ {
+ break;
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ NodeLength += Subtable->Length;
+ ContextIrptNumber++;
+ }
+ IortSmmu->ContextInterruptCount = ContextIrptNumber;
+
+ /* Compile PMU interrupt array */
+
+ PmuIrptNumber = 0;
+ IortSmmu->PmuInterruptOffset = NodeLength;
+ while (*PFieldList)
+ {
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3c,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ if (!Subtable)
+ {
+ break;
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ NodeLength += Subtable->Length;
+ PmuIrptNumber++;
+ }
+ IortSmmu->PmuInterruptCount = PmuIrptNumber;
+ break;
+
+ default:
+
+ DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "IORT");
+ return (AE_ERROR);
+ }
+
+ /* Compile Array of ID mappings */
+
+ IortNode->MappingOffset = NodeLength;
+ IdMappingNumber = 0;
+ while (*PFieldList)
+ {
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoIortMap,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ if (!Subtable)
+ {
+ break;
+ }
+ DtInsertSubtable (ParentTable, Subtable);
+ NodeLength += sizeof (ACPI_IORT_ID_MAPPING);
+ IdMappingNumber++;
+ }
+ IortNode->MappingCount = IdMappingNumber;
+
+ /*
+ * Node length can be determined by DT_LENGTH option
+ * IortNode->Length = NodeLength;
+ */
+ DtPopSubtable ();
+ ParentTable = DtPeekSubtable ();
+ NodeNumber++;
+ }
+ Iort->NodeCount = NodeNumber;
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
* FUNCTION: DtCompileIvrs
*
* PARAMETERS: List - Current field list pointer
@@ -1487,11 +1944,6 @@ DtCompileLpit (
InfoTable = AcpiDmTableInfoLpit0;
break;
- case ACPI_LPIT_TYPE_SIMPLE_IO:
-
- InfoTable = AcpiDmTableInfoLpit1;
- break;
-
default:
DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "LPIT");
@@ -1643,6 +2095,11 @@ DtCompileMadt (
InfoTable = AcpiDmTableInfoMadt14;
break;
+ case ACPI_MADT_TYPE_GENERIC_TRANSLATOR:
+
+ InfoTable = AcpiDmTableInfoMadt15;
+ break;
+
default:
DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "MADT");
@@ -1878,6 +2335,201 @@ DtCompileMtmr (
/******************************************************************************
*
+ * FUNCTION: DtCompileNfit
+ *
+ * PARAMETERS: List - Current field list pointer
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Compile NFIT.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+DtCompileNfit (
+ void **List)
+{
+ ACPI_STATUS Status;
+ DT_SUBTABLE *Subtable;
+ DT_SUBTABLE *ParentTable;
+ DT_FIELD **PFieldList = (DT_FIELD **) List;
+ DT_FIELD *SubtableStart;
+ ACPI_NFIT_HEADER *NfitHeader;
+ ACPI_DMTABLE_INFO *InfoTable;
+ UINT32 Count;
+ ACPI_NFIT_INTERLEAVE *Interleave = NULL;
+ ACPI_NFIT_FLUSH_ADDRESS *Hint = NULL;
+
+ /* Main table */
+
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ ParentTable = DtPeekSubtable ();
+ DtInsertSubtable (ParentTable, Subtable);
+ DtPushSubtable (Subtable);
+
+ /* Subtables */
+
+ while (*PFieldList)
+ {
+ SubtableStart = *PFieldList;
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfitHdr,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ ParentTable = DtPeekSubtable ();
+ DtInsertSubtable (ParentTable, Subtable);
+ DtPushSubtable (Subtable);
+
+ NfitHeader = ACPI_CAST_PTR (ACPI_NFIT_HEADER, Subtable->Buffer);
+
+ switch (NfitHeader->Type)
+ {
+ case ACPI_NFIT_TYPE_SYSTEM_ADDRESS:
+
+ InfoTable = AcpiDmTableInfoNfit0;
+ break;
+
+ case ACPI_NFIT_TYPE_MEMORY_MAP:
+
+ InfoTable = AcpiDmTableInfoNfit1;
+ break;
+
+ case ACPI_NFIT_TYPE_INTERLEAVE:
+
+ Interleave = ACPI_CAST_PTR (ACPI_NFIT_INTERLEAVE, Subtable->Buffer);
+ InfoTable = AcpiDmTableInfoNfit2;
+ break;
+
+ case ACPI_NFIT_TYPE_SMBIOS:
+
+ InfoTable = AcpiDmTableInfoNfit3;
+ break;
+
+ case ACPI_NFIT_TYPE_CONTROL_REGION:
+
+ InfoTable = AcpiDmTableInfoNfit4;
+ break;
+
+ case ACPI_NFIT_TYPE_DATA_REGION:
+
+ InfoTable = AcpiDmTableInfoNfit5;
+ break;
+
+ case ACPI_NFIT_TYPE_FLUSH_ADDRESS:
+
+ Hint = ACPI_CAST_PTR (ACPI_NFIT_FLUSH_ADDRESS, Subtable->Buffer);
+ InfoTable = AcpiDmTableInfoNfit6;
+ break;
+
+ default:
+
+ DtFatal (ASL_MSG_UNKNOWN_SUBTABLE, SubtableStart, "NFIT");
+ return (AE_ERROR);
+ }
+
+ Status = DtCompileTable (PFieldList, InfoTable, &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ ParentTable = DtPeekSubtable ();
+ DtInsertSubtable (ParentTable, Subtable);
+ DtPopSubtable ();
+
+ switch (NfitHeader->Type)
+ {
+ case ACPI_NFIT_TYPE_INTERLEAVE:
+
+ Count = 0;
+ DtPushSubtable (Subtable);
+ while (*PFieldList)
+ {
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit2a,
+ &Subtable, FALSE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ if (!Subtable)
+ {
+ DtPopSubtable ();
+ break;
+ }
+
+ ParentTable = DtPeekSubtable ();
+ DtInsertSubtable (ParentTable, Subtable);
+ Count++;
+ }
+
+ Interleave->LineCount = Count;
+ DtPopSubtable ();
+ break;
+
+ case ACPI_NFIT_TYPE_SMBIOS:
+
+ if (*PFieldList)
+ {
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit3a,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ if (Subtable)
+ {
+ DtInsertSubtable (ParentTable, Subtable);
+ }
+ }
+ break;
+
+ case ACPI_NFIT_TYPE_FLUSH_ADDRESS:
+
+ Count = 0;
+ DtPushSubtable (Subtable);
+ while (*PFieldList)
+ {
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoNfit6a,
+ &Subtable, FALSE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+ if (!Subtable)
+ {
+ DtPopSubtable ();
+ break;
+ }
+
+ ParentTable = DtPeekSubtable ();
+ DtInsertSubtable (ParentTable, Subtable);
+ Count++;
+ }
+
+ Hint->HintCount = (UINT16) Count;
+ DtPopSubtable ();
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
* FUNCTION: DtCompilePcct
*
* PARAMETERS: List - Current field list pointer
@@ -1901,6 +2553,8 @@ DtCompilePcct (
ACPI_DMTABLE_INFO *InfoTable;
+ /* Main table */
+
Status = DtCompileTable (PFieldList, AcpiDmTableInfoPcct,
&Subtable, TRUE);
if (ACPI_FAILURE (Status))
@@ -1911,6 +2565,8 @@ DtCompilePcct (
ParentTable = DtPeekSubtable ();
DtInsertSubtable (ParentTable, Subtable);
+ /* Subtables */
+
while (*PFieldList)
{
SubtableStart = *PFieldList;
@@ -2413,6 +3069,59 @@ DtCompileSrat (
/******************************************************************************
*
+ * FUNCTION: DtCompileStao
+ *
+ * PARAMETERS: PFieldList - Current field list pointer
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Compile STAO.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+DtCompileStao (
+ void **List)
+{
+ DT_FIELD **PFieldList = (DT_FIELD **) List;
+ DT_SUBTABLE *Subtable;
+ DT_SUBTABLE *ParentTable;
+ ACPI_STATUS Status;
+
+
+ /* Compile the main table */
+
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoStao,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ ParentTable = DtPeekSubtable ();
+ DtInsertSubtable (ParentTable, Subtable);
+
+ /* Compile each ASCII namestring as a subtable */
+
+ while (*PFieldList)
+ {
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoStaoStr,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ ParentTable = DtPeekSubtable ();
+ DtInsertSubtable (ParentTable, Subtable);
+ }
+
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
* FUNCTION: DtGetGenericTableInfo
*
* PARAMETERS: Name - Generic type name
@@ -2503,7 +3212,7 @@ DtCompileUefi (
* operators may be used.
*/
- DtCompileGeneric ((void **) PFieldList);
+ DtCompileGeneric ((void **) PFieldList, NULL, NULL);
return (AE_OK);
}
@@ -2561,6 +3270,63 @@ DtCompileWdat (
/******************************************************************************
*
+ * FUNCTION: DtCompileWpbt
+ *
+ * PARAMETERS: List - Current field list pointer
+ *
+ * RETURN: Status
+ *
+ * DESCRIPTION: Compile WPBT.
+ *
+ *****************************************************************************/
+
+ACPI_STATUS
+DtCompileWpbt (
+ void **List)
+{
+ DT_FIELD **PFieldList = (DT_FIELD **) List;
+ DT_SUBTABLE *Subtable;
+ DT_SUBTABLE *ParentTable;
+ ACPI_TABLE_WPBT *Table;
+ ACPI_STATUS Status;
+ UINT16 Length;
+
+
+ /* Compile the main table */
+
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ ParentTable = DtPeekSubtable ();
+ DtInsertSubtable (ParentTable, Subtable);
+
+ /* Compile the argument list subtable */
+
+ Status = DtCompileTable (PFieldList, AcpiDmTableInfoWpbt0,
+ &Subtable, TRUE);
+ if (ACPI_FAILURE (Status))
+ {
+ return (Status);
+ }
+
+ /* Extract the length of the Arguments buffer, insert into main table */
+
+ Length = (UINT16) Subtable->TotalLength;
+ Table = ACPI_CAST_PTR (ACPI_TABLE_WPBT, ParentTable->Buffer);
+ Table->ArgumentsLength = Length;
+
+ ParentTable = DtPeekSubtable ();
+ DtInsertSubtable (ParentTable, Subtable);
+ return (AE_OK);
+}
+
+
+/******************************************************************************
+ *
* FUNCTION: DtCompileXsdt
*
* PARAMETERS: List - Current field list pointer
@@ -2580,6 +3346,7 @@ DtCompileXsdt (
DT_FIELD *FieldList = *(DT_FIELD **) List;
UINT64 Address;
+
ParentTable = DtPeekSubtable ();
while (FieldList)
@@ -2600,6 +3367,8 @@ DtCompileXsdt (
* FUNCTION: DtCompileGeneric
*
* PARAMETERS: List - Current field list pointer
+ * Name - Field name to end generic compiling
+ * Length - Compiled table length to return
*
* RETURN: Status
*
@@ -2609,7 +3378,9 @@ DtCompileXsdt (
ACPI_STATUS
DtCompileGeneric (
- void **List)
+ void **List,
+ char *Name,
+ UINT32 *Length)
{
ACPI_STATUS Status;
DT_SUBTABLE *Subtable;
@@ -2632,8 +3403,16 @@ DtCompileGeneric (
/* Now we can actually compile the parse tree */
+ if (*Length)
+ {
+ *Length = 0;
+ }
while (*PFieldList)
{
+ if (Name && !ACPI_STRCMP ((*PFieldList)->Name, Name))
+ {
+ break;
+ }
Info = DtGetGenericTableInfo ((*PFieldList)->Name);
if (!Info)
{
@@ -2651,6 +3430,10 @@ DtCompileGeneric (
if (ACPI_SUCCESS (Status))
{
DtInsertSubtable (ParentTable, Subtable);
+ if (Length)
+ {
+ *Length += Subtable->Length;
+ }
}
else
{
diff --git a/sys/contrib/dev/acpica/compiler/dttemplate.c b/sys/contrib/dev/acpica/compiler/dttemplate.c
index 3fcf081..90b6b17 100644
--- a/sys/contrib/dev/acpica/compiler/dttemplate.c
+++ b/sys/contrib/dev/acpica/compiler/dttemplate.c
@@ -59,7 +59,7 @@ AcpiUtIsSpecialTable (
static ACPI_STATUS
DtCreateOneTemplate (
char *Signature,
- ACPI_DMTABLE_DATA *TableData);
+ const ACPI_DMTABLE_DATA *TableData);
static ACPI_STATUS
DtCreateAllTemplates (
@@ -112,7 +112,7 @@ ACPI_STATUS
DtCreateTemplates (
char *Signature)
{
- ACPI_DMTABLE_DATA *TableData;
+ const ACPI_DMTABLE_DATA *TableData;
ACPI_STATUS Status;
@@ -213,7 +213,7 @@ static ACPI_STATUS
DtCreateAllTemplates (
void)
{
- ACPI_DMTABLE_DATA *TableData;
+ const ACPI_DMTABLE_DATA *TableData;
ACPI_STATUS Status;
@@ -292,7 +292,7 @@ DtCreateAllTemplates (
static ACPI_STATUS
DtCreateOneTemplate (
char *Signature,
- ACPI_DMTABLE_DATA *TableData)
+ const ACPI_DMTABLE_DATA *TableData)
{
char *DisasmFilename;
FILE *File;
diff --git a/sys/contrib/dev/acpica/compiler/dttemplate.h b/sys/contrib/dev/acpica/compiler/dttemplate.h
index 39be761..1b27b4e 100644
--- a/sys/contrib/dev/acpica/compiler/dttemplate.h
+++ b/sys/contrib/dev/acpica/compiler/dttemplate.h
@@ -234,6 +234,29 @@ const unsigned char TemplateDmar[] =
0x00,0x00,0x00,0x00 /* 00000088 "...." */
};
+const unsigned char TemplateDrtm[] =
+{
+ 0x44,0x52,0x54,0x4D,0x94,0x00,0x00,0x00, /* 00000000 "DRTM...." */
+ 0x01,0xB9,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */
+ 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */
+ 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
+ 0x10,0x04,0x15,0x20,0x00,0x00,0x00,0x00, /* 00000020 "... ...." */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000048 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 "........" */
+ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000068 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000070 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000088 "........" */
+ 0x00,0x00,0x00,0x00 /* 00000090 "...." */
+};
+
const unsigned char TemplateEcdt[] =
{
0x45,0x43,0x44,0x54,0x42,0x00,0x00,0x00, /* 00000000 "ECDTB..." */
@@ -379,11 +402,11 @@ const unsigned char TemplateFacs[] =
const unsigned char TemplateFadt[] =
{
- 0x46,0x41,0x43,0x50,0x0C,0x01,0x00,0x00, /* 00000000 "FACP...." */
- 0x05,0x64,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".dINTEL " */
- 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */
+ 0x46,0x41,0x43,0x50,0x14,0x01,0x00,0x00, /* 00000000 "FACP...." */
+ 0x06,0x8A,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */
+ 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */
0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
- 0x15,0x11,0x13,0x20,0x01,0x00,0x00,0x00, /* 00000020 "... ...." */
+ 0x10,0x04,0x15,0x20,0x01,0x00,0x00,0x00, /* 00000020 "... ...." */
0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "........" */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 "........" */
0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */
@@ -412,7 +435,8 @@ const unsigned char TemplateFadt[] =
0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x01, /* 000000F0 "........" */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000F8 "........" */
0x01,0x08,0x00,0x01,0x00,0x00,0x00,0x00, /* 00000100 "........" */
- 0x00,0x00,0x00,0x00 /* 00000108 "...." */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000108 "........" */
+ 0x00,0x00,0x00,0x00 /* 00000110 "...." */
};
const unsigned char TemplateFpdt[] =
@@ -538,6 +562,44 @@ const unsigned char TemplateHpet[] =
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000030 "........" */
};
+const unsigned char TemplateIort[] =
+{
+ 0x49,0x4F,0x52,0x54,0x0C,0x01,0x00,0x00, /* 00000000 "IORT...." */
+ 0x00,0xBC,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */
+ 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */
+ 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
+ 0x10,0x04,0x15,0x20,0x04,0x00,0x00,0x00, /* 00000020 "... ...." */
+ 0x34,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "4......." */
+ 0x00,0x00,0x00,0x00,0x00,0x2C,0x00,0x00, /* 00000030 ".....,.." */
+ 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000038 "........" */
+ 0x18,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000040 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000048 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */
+ 0x01,0x30,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 ".0......" */
+ 0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00, /* 00000068 "....0..." */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000070 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x5C,0x5F,0x53, /* 00000078 ".....\_S" */
+ 0x42,0x2E,0x50,0x43,0x49,0x30,0x2E,0x44, /* 00000080 "B.PCI0.D" */
+ 0x45,0x56,0x30,0x00,0x00,0x00,0x00,0x00, /* 00000088 "EV0....." */
+ 0x02,0x20,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000090 ". ......" */
+ 0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00, /* 00000098 ".... ..." */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000A0 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000A8 "........" */
+ 0x03,0x5C,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B0 ".\......" */
+ 0x00,0x00,0x00,0x00,0x5C,0x00,0x00,0x00, /* 000000B8 "....\..." */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C0 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C8 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000D0 "........" */
+ 0x3C,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000D8 "<......." */
+ 0x4C,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 000000E0 "L......." */
+ 0x54,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E8 "T......." */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000F0 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000F8 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000100 "........" */
+ 0x00,0x00,0x00,0x00 /* 00000108 "...." */
+};
+
const unsigned char TemplateIvrs[] =
{
0x49,0x56,0x52,0x53,0xBC,0x00,0x00,0x00, /* 00000000 "IVRS...." */
@@ -568,73 +630,75 @@ const unsigned char TemplateIvrs[] =
const unsigned char TemplateLpit[] =
{
- 0x4C,0x50,0x49,0x54,0xB4,0x00,0x00,0x00, /* 00000000 "LPIT...." */
- 0x01,0x20,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ". INTEL " */
- 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */
+ 0x4C,0x50,0x49,0x54,0x94,0x00,0x00,0x00, /* 00000000 "LPIT...." */
+ 0x00,0xD8,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */
+ 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */
0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
- 0x25,0x03,0x14,0x20,0x00,0x00,0x00,0x00, /* 00000020 "%.. ...." */
+ 0x10,0x04,0x15,0x20,0x00,0x00,0x00,0x00, /* 00000020 "... ...." */
0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000028 "8......." */
- 0x00,0x00,0x00,0x00,0x7F,0x01,0x02,0x00, /* 00000030 "........" */
+ 0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x01, /* 00000030 "........" */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */
- 0x00,0x20,0x00,0x03,0x00,0x00,0x00,0x00, /* 00000048 ". ......" */
+ 0x7F,0x40,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000048 ".@......" */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000050 "........" */
- 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000058 "........" */
- 0x58,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000060 "X......." */
- 0x00,0x00,0x00,0x00,0x01,0x10,0x00,0x02, /* 00000068 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */
+ 0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000060 "8......." */
+ 0x00,0x00,0x00,0x00,0x01,0x08,0x00,0x01, /* 00000068 "........" */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000070 "........" */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 "........" */
- 0x00,0x00,0x00,0x00,0x01,0x10,0x00,0x02, /* 00000088 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000090 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000098 "........" */
- 0x00,0x08,0x00,0x01,0x00,0x00,0x00,0x00, /* 000000A0 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000A8 "........" */
- 0x00,0x00,0x00,0x00 /* 000000B0 "...." */
+ 0x7F,0x40,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000080 ".@......" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000088 "........" */
+ 0x00,0x00,0x00,0x00 /* 00000090 "...." */
};
-/* MADT with ACPI 5.1 subtables */
+/* MADT with ACPI 6.0 subtables */
const unsigned char TemplateMadt[] =
{
- 0x41,0x50,0x49,0x43,0x2a,0x01,0x00,0x00, /* 00000000 "APIC*..." */
- 0x04,0x34,0x49,0x4e,0x54,0x45,0x4c,0x20, /* 00000008 ".4INTEL " */
- 0x54,0x45,0x4d,0x50,0x4c,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */
- 0x01,0x00,0x00,0x00,0x49,0x4e,0x54,0x4c, /* 00000018 "....INTL" */
- 0x24,0x04,0x14,0x20,0x00,0x00,0x00,0x00, /* 00000020 "$.. ...." */
+ 0x41,0x50,0x49,0x43,0x5A,0x01,0x00,0x00, /* 00000000 "APICZ..." */
+ 0x03,0xEA,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */
+ 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */
+ 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
+ 0x10,0x04,0x15,0x20,0x00,0x00,0x00,0x00, /* 00000020 "... ...." */
0x01,0x00,0x00,0x00,0x00,0x08,0x00,0x00, /* 00000028 "........" */
- 0x01,0x00,0x00,0x00,0x01,0x0c,0x01,0x00, /* 00000030 "........" */
+ 0x01,0x00,0x00,0x00,0x01,0x0C,0x01,0x00, /* 00000030 "........" */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000038 "........" */
- 0x02,0x0a,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */
- 0x00,0x00,0x03,0x08,0x0d,0x00,0x01,0x00, /* 00000048 "........" */
+ 0x02,0x0A,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000040 "........" */
+ 0x00,0x00,0x03,0x08,0x0D,0x00,0x01,0x00, /* 00000048 "........" */
0x00,0x00,0x04,0x06,0x00,0x05,0x00,0x01, /* 00000050 "........" */
- 0x05,0x0c,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */
+ 0x05,0x0C,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */
0x00,0x00,0x00,0x00,0x06,0x10,0x00,0x00, /* 00000060 "........" */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000068 "........" */
0x00,0x00,0x00,0x00,0x07,0x16,0x00,0x00, /* 00000070 "........" */
0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, /* 00000078 "........" */
- 0x00,0x00,0x00,0x00,0x5c,0x43,0x50,0x55, /* 00000080 "....\CPU" */
+ 0x00,0x00,0x00,0x00,0x5C,0x43,0x50,0x55, /* 00000080 "....\CPU" */
0x30,0x00,0x08,0x10,0x05,0x00,0x00,0x00, /* 00000088 "0......." */
0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00, /* 00000090 "........" */
0x00,0x00,0x09,0x10,0x00,0x00,0x00,0x00, /* 00000098 "........" */
- 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000a0 "........" */
- 0x00,0x00,0x0a,0x0c,0x05,0x00,0x00,0x00, /* 000000a8 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x0b,0x4c, /* 000000b0 ".......L" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000b8 "........" */
- 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000c0 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000c8 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000d0 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000d8 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000e0 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000e8 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000f0 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000f8 "........" */
- 0x00,0x00,0x0e,0x10,0x00,0x00,0x00,0x00, /* 00000100 "........" */
+ 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000A0 "........" */
+ 0x00,0x00,0x0A,0x0C,0x05,0x00,0x00,0x00, /* 000000A8 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x0B,0x50, /* 000000B0 ".......P" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000B8 "........" */
+ 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, /* 000000C0 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000C8 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000D0 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000D8 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E0 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E8 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000F0 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000F8 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x18, /* 00000100 "........" */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000108 "........" */
- 0x00,0x00,0x0c,0x18,0x00,0x00,0x00,0x00, /* 00000110 "........" */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000118 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000110 "........" */
+ 0x00,0x00,0x01,0x00,0x00,0x00,0x0D,0x18, /* 00000118 "........" */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000120 "........" */
- 0x00,0x00 /* 00000128 ".. " */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00, /* 00000128 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x10, /* 00000130 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000138 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x14, /* 00000140 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000148 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000150 "........" */
+ 0x00,0x00 /* 00000158 ".." */
};
const unsigned char TemplateMcfg[] =
@@ -728,6 +792,56 @@ const unsigned char TemplateMsct[] =
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 /* 00000088 "........" */
};
+const unsigned char TemplateNfit[] =
+{
+ 0x4E,0x46,0x49,0x54,0x70,0x01,0x00,0x00, /* 00000000 "NFITp..." */
+ 0x01,0x53,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".SINTEL " */
+ 0x54,0x65,0x6D,0x70,0x6C,0x61,0x74,0x65, /* 00000010 "Template" */
+ 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
+ 0x10,0x04,0x15,0x20,0x00,0x00,0x00,0x00, /* 00000020 "... ...." */
+ 0x00,0x00,0x38,0x00,0x01,0x00,0x00,0x00, /* 00000028 "..8....." */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000030 "........" */
+ 0x30,0x05,0xAF,0x91,0x86,0x5D,0x0E,0x47, /* 00000038 "0....].G" */
+ 0xA6,0xB0,0x0A,0x2D,0xB9,0x40,0x82,0x49, /* 00000040 "...-.@.I" */
+ 0x00,0x00,0x00,0x7C,0x03,0x00,0x00,0x00, /* 00000048 "...|...." */
+ 0x00,0x00,0x00,0x0C,0x00,0x00,0x00,0x00, /* 00000050 "........" */
+ 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000058 "........" */
+ 0x01,0x00,0x30,0x00,0x01,0x00,0x00,0x00, /* 00000060 "..0....." */
+ 0x04,0x00,0x00,0x00,0x01,0x00,0x01,0x00, /* 00000068 "........" */
+ 0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00, /* 00000070 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000078 "........" */
+ 0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00, /* 00000080 "........" */
+ 0x01,0x00,0x03,0x00,0x2A,0x00,0x00,0x00, /* 00000088 "....*..." */
+ 0x02,0x00,0x20,0x00,0x01,0x00,0x00,0x00, /* 00000090 ".. ....." */
+ 0x04,0x00,0x00,0x00,0x00,0x01,0x00,0x00, /* 00000098 "........" */
+ 0x00,0x00,0x00,0x00,0x03,0x00,0x00,0x00, /* 000000A0 "........" */
+ 0x06,0x00,0x00,0x00,0x09,0x00,0x00,0x00, /* 000000A8 "........" */
+ 0x03,0x00,0x28,0x00,0x00,0x00,0x00,0x00, /* 000000B0 "..(....." */
+ 0xB4,0x13,0x5D,0x40,0x91,0x0B,0x29,0x93, /* 000000B8 "..]@..)." */
+ 0x67,0xE8,0x23,0x4C,0x00,0x00,0x00,0x88, /* 000000C0 "g.#L...." */
+ 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77, /* 000000C8 ".."3DUfw" */
+ 0x88,0x99,0xAA,0xBB,0xCC,0xDD,0xEE,0xFF, /* 000000D0 "........" */
+ 0x04,0x00,0x50,0x00,0x01,0x00,0x86,0x80, /* 000000D8 "..P....." */
+ 0x17,0x20,0x01,0x00,0x86,0x80,0x17,0x20, /* 000000E0 ". ..... " */
+ 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000E8 "........" */
+ 0x89,0x00,0x54,0x76,0x01,0x03,0x00,0x01, /* 000000F0 "..Tv...." */
+ 0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00, /* 000000F8 ". ......" */
+ 0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00, /* 00000100 "........" */
+ 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000108 "........" */
+ 0x00,0x10,0x80,0x00,0x00,0x00,0x00,0x00, /* 00000110 "........" */
+ 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000118 "........" */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000120 "........" */
+ 0x05,0x00,0x28,0x00,0x01,0x00,0x00,0x01, /* 00000128 "..(....." */
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000130 "........" */
+ 0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000138 ". ......" */
+ 0x00,0x00,0x00,0xE0,0x0F,0x00,0x00,0x00, /* 00000140 "........" */
+ 0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00, /* 00000148 "........" */
+ 0x06,0x00,0x20,0x00,0x01,0x00,0x00,0x00, /* 00000150 ".. ....." */
+ 0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 00000158 "........" */
+ 0x00,0x00,0x00,0x18,0x04,0x00,0x00,0x00, /* 00000160 "........" */
+ 0x00,0x00,0x00,0x18,0x06,0x00,0x00,0x00 /* 00000168 "........" */
+};
+
const unsigned char TemplateMtmr[] =
{
0x4D,0x54,0x4D,0x52,0x4C,0x00,0x00,0x00, /* 00000000 "MTMRL..." */
@@ -999,6 +1113,26 @@ const unsigned char TemplateSrat[] =
0x00,0x00 /* 00000090 ".." */
};
+const unsigned char TemplateStao[] =
+{
+ 0x53,0x54,0x41,0x4F,0x7E,0x00,0x00,0x00, /* 00000000 "STAO~..." */
+ 0x01,0x7F,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */
+ 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */
+ 0x00,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
+ 0x10,0x04,0x15,0x20,0x01,0x5C,0x5F,0x53, /* 00000020 "... .\_S" */
+ 0x42,0x30,0x2E,0x42,0x55,0x53,0x30,0x2E, /* 00000028 "B0.BUS0." */
+ 0x44,0x45,0x56,0x31,0x00,0x5C,0x5F,0x53, /* 00000030 "DEV1.\_S" */
+ 0x42,0x30,0x2E,0x42,0x55,0x53,0x30,0x2E, /* 00000038 "B0.BUS0." */
+ 0x44,0x45,0x56,0x32,0x00,0x5C,0x5F,0x53, /* 00000040 "DEV2.\_S" */
+ 0x42,0x30,0x2E,0x42,0x55,0x53,0x31,0x2E, /* 00000048 "B0.BUS1." */
+ 0x44,0x45,0x56,0x31,0x2E,0x44,0x45,0x56, /* 00000050 "DEV1.DEV" */
+ 0x32,0x00,0x5C,0x5F,0x53,0x42,0x30,0x2E, /* 00000058 "2.\_SB0." */
+ 0x42,0x55,0x53,0x31,0x2E,0x44,0x45,0x56, /* 00000060 "BUS1.DEV" */
+ 0x32,0x2E,0x44,0x45,0x56,0x32,0x00,0x5C, /* 00000068 "2.DEV2.\" */
+ 0x55,0x53,0x42,0x31,0x2E,0x48,0x55,0x42, /* 00000070 "USB1.HUB" */
+ 0x31,0x2E,0x50,0x54,0x31,0x00 /* 00000078 "1.PT1." */
+};
+
const unsigned char TemplateTcpa[] =
{
0x54,0x43,0x50,0x41,0x32,0x00,0x00,0x00, /* 00000000 "TCPA2..." */
@@ -1095,6 +1229,41 @@ const unsigned char TemplateWdrt[] =
0x00,0x00,0x00,0x00,0xFF,0xFF,0x00 /* 00000040 "......." */
};
+const unsigned char TemplateWpbt[] =
+{
+ 0x57,0x50,0x42,0x54,0x98,0x00,0x00,0x00, /* 00000000 "WPBT...." */
+ 0x01,0x83,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 "..INTEL " */
+ 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */
+ 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
+ 0x10,0x04,0x15,0x20,0x78,0x56,0x34,0x12, /* 00000020 "... xV4." */
+ 0x00,0x00,0x00,0xBB,0x00,0x00,0x00,0xAA, /* 00000028 "........" */
+ 0x33,0x88,0x64,0x00,0x34,0x00,0x20,0x00, /* 00000030 "3.d.4. ." */
+ 0x73,0x00,0x63,0x00,0x6F,0x00,0x72,0x00, /* 00000038 "s.c.o.r." */
+ 0x65,0x00,0x20,0x00,0x61,0x00,0x6E,0x00, /* 00000040 "e. .a.n." */
+ 0x64,0x00,0x20,0x00,0x37,0x00,0x20,0x00, /* 00000048 "d. .7. ." */
+ 0x79,0x00,0x65,0x00,0x61,0x00,0x72,0x00, /* 00000050 "y.e.a.r." */
+ 0x73,0x00,0x20,0x00,0x61,0x00,0x67,0x00, /* 00000058 "s. .a.g." */
+ 0x6F,0x00,0x20,0x00,0x6F,0x00,0x75,0x00, /* 00000060 "o. .o.u." */
+ 0x72,0x00,0x20,0x00,0x66,0x00,0x61,0x00, /* 00000068 "r. .f.a." */
+ 0x74,0x00,0x68,0x00,0x65,0x00,0x72,0x00, /* 00000070 "t.h.e.r." */
+ 0x73,0x00,0x20,0x00,0x62,0x00,0x72,0x00, /* 00000078 "s. .b.r." */
+ 0x6F,0x00,0x75,0x00,0x67,0x00,0x68,0x00, /* 00000080 "o.u.g.h." */
+ 0x74,0x00,0x20,0x00,0x66,0x00,0x6F,0x00, /* 00000088 "t. .f.o." */
+ 0x72,0x00,0x74,0x00,0x68,0x00,0x00,0x00 /* 00000090 "r.t.h..." */
+};
+
+const unsigned char TemplateXenv[] =
+{
+ 0x58,0x45,0x4E,0x56,0x39,0x00,0x00,0x00, /* 00000000 "XENV9..." */
+ 0x01,0x3A,0x49,0x4E,0x54,0x45,0x4C,0x20, /* 00000008 ".:INTEL " */
+ 0x54,0x45,0x4D,0x50,0x4C,0x41,0x54,0x45, /* 00000010 "TEMPLATE" */
+ 0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
+ 0x10,0x04,0x15,0x20,0x00,0x00,0x00,0x10, /* 00000020 "... ...." */
+ 0x00,0x00,0x00,0x0A,0x00,0x20,0x00,0x00, /* 00000028 "..... .." */
+ 0x00,0x00,0x00,0x0B,0x25,0x00,0xBB,0xAA, /* 00000030 "....%..." */
+ 0x03 /* 00000038 "." */
+};
+
const unsigned char TemplateXsdt[] =
{
0x58,0x53,0x44,0x54,0x64,0x00,0x00,0x00, /* 00000000 "XSDTd..." */
diff --git a/sys/contrib/dev/acpica/compiler/dtutils.c b/sys/contrib/dev/acpica/compiler/dtutils.c
index 7d3c2c8..2d5b762 100644
--- a/sys/contrib/dev/acpica/compiler/dtutils.c
+++ b/sys/contrib/dev/acpica/compiler/dtutils.c
@@ -376,6 +376,7 @@ DtGetFieldType (
case ACPI_DMT_GAS:
case ACPI_DMT_HESTNTFY:
+ case ACPI_DMT_IORTMEM:
Type = DT_FIELD_TYPE_INLINE_SUBTABLE;
break;
@@ -520,6 +521,7 @@ DtGetFieldLength (
case ACPI_DMT_UINT16:
case ACPI_DMT_DMAR:
case ACPI_DMT_HEST:
+ case ACPI_DMT_NFIT:
case ACPI_DMT_PCI_PATH:
ByteLength = 2;
@@ -587,6 +589,11 @@ DtGetFieldLength (
ByteLength = sizeof (ACPI_HEST_NOTIFY);
break;
+ case ACPI_DMT_IORTMEM:
+
+ ByteLength = sizeof (ACPI_IORT_MEMORY_ACCESS);
+ break;
+
case ACPI_DMT_BUFFER:
case ACPI_DMT_RAW_BUFFER:
diff --git a/sys/contrib/dev/acpica/compiler/preprocess.h b/sys/contrib/dev/acpica/compiler/preprocess.h
index d0642877..9dc2bdb 100644
--- a/sys/contrib/dev/acpica/compiler/preprocess.h
+++ b/sys/contrib/dev/acpica/compiler/preprocess.h
@@ -267,14 +267,18 @@ PrReplaceData (
char *BufferToAdd,
UINT32 LengthToAdd);
-void
+FILE *
PrOpenIncludeFile (
- char *Filename);
+ char *Filename,
+ char *OpenMode,
+ char **FullPathname);
FILE *
PrOpenIncludeWithPrefix (
char *PrefixDir,
- char *Filename);
+ char *Filename,
+ char *OpenMode,
+ char **FullPathname);
void
PrPushInputFileStack (
diff --git a/sys/contrib/dev/acpica/compiler/prscan.c b/sys/contrib/dev/acpica/compiler/prscan.c
index 12e9b8e..12d303c 100644
--- a/sys/contrib/dev/acpica/compiler/prscan.c
+++ b/sys/contrib/dev/acpica/compiler/prscan.c
@@ -85,28 +85,42 @@ PrDbgPrint (
char *Action,
char *DirectiveName);
+static void
+PrDoIncludeBuffer (
+ char *Pathname,
+ char *BufferName);
+
+static void
+PrDoIncludeFile (
+ char *Pathname);
+
/*
* Supported preprocessor directives
+ * Each entry is of the form "Name, ArgumentCount"
*/
static const PR_DIRECTIVE_INFO Gbl_DirectiveInfo[] =
{
- {"define", 1},
- {"elif", 0}, /* Converted to #else..#if internally */
- {"else", 0},
- {"endif", 0},
- {"error", 1},
- {"if", 1},
- {"ifdef", 1},
- {"ifndef", 1},
- {"include", 0}, /* Argument is not standard format, so 0 */
- {"line", 1},
- {"pragma", 1},
- {"undef", 1},
- {"warning", 1},
- {NULL, 0}
+ {"define", 1},
+ {"elif", 0}, /* Converted to #else..#if internally */
+ {"else", 0},
+ {"endif", 0},
+ {"error", 1},
+ {"if", 1},
+ {"ifdef", 1},
+ {"ifndef", 1},
+ {"include", 0}, /* Argument is not standard format, so just use 0 here */
+ {"includebuffer", 0}, /* Argument is not standard format, so just use 0 here */
+ {"line", 1},
+ {"loadbuffer", 0},
+ {"pragma", 1},
+ {"undef", 1},
+ {"warning", 1},
+ {NULL, 0}
};
+/* This table must match ordering of above table exactly */
+
enum Gbl_DirectiveIndexes
{
PR_DIRECTIVE_DEFINE = 0,
@@ -118,6 +132,7 @@ enum Gbl_DirectiveIndexes
PR_DIRECTIVE_IFDEF,
PR_DIRECTIVE_IFNDEF,
PR_DIRECTIVE_INCLUDE,
+ PR_DIRECTIVE_INCLUDEBUFFER,
PR_DIRECTIVE_LINE,
PR_DIRECTIVE_PRAGMA,
PR_DIRECTIVE_UNDEF,
@@ -382,13 +397,6 @@ PrPreprocessInputFile (
Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, &Next);
}
-#if 0
-/* Line prefix */
- FlPrintFile (ASL_FILE_PREPROCESSOR, "/* %14s %.5u i:%.5u */ ",
- Gbl_Files[ASL_FILE_INPUT].Filename,
- Gbl_CurrentLineNumber, Gbl_PreprocessorLineNumber);
-#endif
-
/*
* Emit a #line directive if necessary, to keep the line numbers in
* the (.i) file synchronized with the original source code file, so
@@ -433,7 +441,7 @@ PrDoDirective (
char **Next)
{
char *Token = Gbl_MainTokenBuffer;
- char *Token2;
+ char *Token2 = NULL;
char *End;
UINT64 Value;
ACPI_SIZE TokenOffset;
@@ -452,7 +460,7 @@ PrDoDirective (
PrError (ASL_ERROR, ASL_MSG_UNKNOWN_DIRECTIVE,
THIS_TOKEN_OFFSET (DirectiveToken));
- DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
+ DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
"#%s: Unknown directive\n",
Gbl_CurrentLineNumber, DirectiveToken);
return;
@@ -539,7 +547,7 @@ PrDoDirective (
/* Most directives have at least one argument */
- if (Gbl_DirectiveInfo[Directive].ArgCount == 1)
+ if (Gbl_DirectiveInfo[Directive].ArgCount >= 1)
{
Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
if (!Token)
@@ -548,6 +556,15 @@ PrDoDirective (
}
}
+ if (Gbl_DirectiveInfo[Directive].ArgCount >= 2)
+ {
+ Token2 = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
+ if (!Token2)
+ {
+ goto SyntaxError;
+ }
+ }
+
/*
* At this point, if we are ignoring the current code block,
* do not process any more directives (i.e., ignore them also.)
@@ -599,7 +616,7 @@ PrDoDirective (
Gbl_IgnoringThisCodeBlock = TRUE;
}
- DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
+ DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
"Resolved #if: %8.8X%8.8X %s\n",
Gbl_CurrentLineNumber, ACPI_FORMAT_UINT64 (Value),
Gbl_IgnoringThisCodeBlock ? "<Skipping Block>" : "<Executing Block>");
@@ -672,7 +689,7 @@ PrDoDirective (
Token2 = "";
}
#endif
- DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
+ DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
"New #define: %s->%s\n",
Gbl_CurrentLineNumber, Token, Token2);
@@ -700,11 +717,32 @@ PrDoDirective (
goto SyntaxError;
}
- DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
+ DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
"Start #include file \"%s\"\n", Gbl_CurrentLineNumber,
Token, Gbl_CurrentLineNumber);
- PrOpenIncludeFile (Token);
+ PrDoIncludeFile (Token);
+ break;
+
+ case PR_DIRECTIVE_INCLUDEBUFFER:
+
+ Token = PrGetNextToken (NULL, " \"<>", Next);
+ if (!Token)
+ {
+ goto SyntaxError;
+ }
+
+ Token2 = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
+ if (!Token2)
+ {
+ goto SyntaxError;
+ }
+
+ DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
+ "Start #includebuffer input from file \"%s\", buffer name %s\n",
+ Gbl_CurrentLineNumber, Token, Token2);
+
+ PrDoIncludeBuffer (Token, Token2);
break;
case PR_DIRECTIVE_LINE:
@@ -718,7 +756,7 @@ PrDoDirective (
return;
}
- DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
+ DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
"User #line invocation %s\n", Gbl_CurrentLineNumber,
Token);
@@ -768,7 +806,7 @@ PrDoDirective (
case PR_DIRECTIVE_UNDEF:
- DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
+ DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
"#undef: %s\n", Gbl_CurrentLineNumber, Token);
PrRemoveDefine (Token);
@@ -783,7 +821,7 @@ PrDoDirective (
default:
/* Should never get here */
- DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
+ DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
"Unrecognized directive: %u\n",
Gbl_CurrentLineNumber, Directive);
break;
@@ -954,9 +992,92 @@ PrDbgPrint (
{
DbgPrint (ASL_DEBUG_OUTPUT, "Pr(%.4u) - [%u %s] "
- "%*s %s #%s, Depth %u\n",
+ "%*s %s #%s, IfDepth %u\n",
Gbl_CurrentLineNumber, Gbl_IfDepth,
Gbl_IgnoringThisCodeBlock ? "I" : "E",
Gbl_IfDepth * 4, " ",
Action, DirectiveName, Gbl_IfDepth);
}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: PrDoIncludeFile
+ *
+ * PARAMETERS: Pathname - Name of the input file
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Open an include file, from #include.
+ *
+ ******************************************************************************/
+
+static void
+PrDoIncludeFile (
+ char *Pathname)
+{
+ char *FullPathname;
+
+
+ (void) PrOpenIncludeFile (Pathname, "r", &FullPathname);
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION: PrDoIncludeBuffer
+ *
+ * PARAMETERS: Pathname - Name of the input binary file
+ * BufferName - ACPI namepath of the buffer
+ *
+ * RETURN: None.
+ *
+ * DESCRIPTION: Create an ACPI buffer object from a binary file. The contents
+ * of the file are emitted into the buffer object as ascii
+ * hex data. From #includebuffer.
+ *
+ ******************************************************************************/
+
+static void
+PrDoIncludeBuffer (
+ char *Pathname,
+ char *BufferName)
+{
+ char *FullPathname;
+ FILE *BinaryBufferFile;
+ UINT32 i = 0;
+ UINT8 c;
+
+
+ BinaryBufferFile = PrOpenIncludeFile (Pathname, "rb", &FullPathname);
+ if (!BinaryBufferFile)
+ {
+ return;
+ }
+
+ /* Emit "Name (XXXX, Buffer() {" header */
+
+ FlPrintFile (ASL_FILE_PREPROCESSOR, "Name (%s, Buffer()\n{", BufferName);
+
+ /* Dump the entire file in ascii hex format */
+
+ while (fread (&c, 1, 1, BinaryBufferFile))
+ {
+ if (!(i % 8))
+ {
+ FlPrintFile (ASL_FILE_PREPROCESSOR, "\n ", c);
+ }
+
+ FlPrintFile (ASL_FILE_PREPROCESSOR, " 0x%2.2X,", c);
+ i++;
+ }
+
+ DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
+ "#includebuffer: read %u bytes from %s\n",
+ Gbl_CurrentLineNumber, i, FullPathname);
+
+ /* Close the Name() operator */
+
+ FlPrintFile (ASL_FILE_PREPROCESSOR, "\n})\n", BufferName);
+ fclose (BinaryBufferFile);
+}
diff --git a/sys/contrib/dev/acpica/compiler/prutils.c b/sys/contrib/dev/acpica/compiler/prutils.c
index e36ea1d..7e880b1 100644
--- a/sys/contrib/dev/acpica/compiler/prutils.c
+++ b/sys/contrib/dev/acpica/compiler/prutils.c
@@ -238,9 +238,11 @@ PrReplaceData (
*
******************************************************************************/
-void
+FILE *
PrOpenIncludeFile (
- char *Filename)
+ char *Filename,
+ char *OpenMode,
+ char **FullPathname)
{
FILE *IncludeFile;
ASL_INCLUDE_DIR *NextDir;
@@ -257,12 +259,13 @@ PrOpenIncludeFile (
(Filename[0] == '\\') ||
(Filename[1] == ':'))
{
- IncludeFile = PrOpenIncludeWithPrefix ("", Filename);
+ IncludeFile = PrOpenIncludeWithPrefix (
+ "", Filename, OpenMode, FullPathname);
if (!IncludeFile)
{
goto ErrorExit;
}
- return;
+ return (IncludeFile);
}
/*
@@ -273,10 +276,11 @@ PrOpenIncludeFile (
*
* Construct the file pathname from the global directory name.
*/
- IncludeFile = PrOpenIncludeWithPrefix (Gbl_DirectoryPath, Filename);
+ IncludeFile = PrOpenIncludeWithPrefix (
+ Gbl_DirectoryPath, Filename, OpenMode, FullPathname);
if (IncludeFile)
{
- return;
+ return (IncludeFile);
}
/*
@@ -286,10 +290,11 @@ PrOpenIncludeFile (
NextDir = Gbl_IncludeDirList;
while (NextDir)
{
- IncludeFile = PrOpenIncludeWithPrefix (NextDir->Dir, Filename);
+ IncludeFile = PrOpenIncludeWithPrefix (
+ NextDir->Dir, Filename, OpenMode, FullPathname);
if (IncludeFile)
{
- return;
+ return (IncludeFile);
}
NextDir = NextDir->Next;
@@ -300,6 +305,7 @@ PrOpenIncludeFile (
ErrorExit:
sprintf (Gbl_MainTokenBuffer, "%s, %s", Filename, strerror (errno));
PrError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, 0);
+ return (NULL);
}
@@ -320,7 +326,9 @@ ErrorExit:
FILE *
PrOpenIncludeWithPrefix (
char *PrefixDir,
- char *Filename)
+ char *Filename,
+ char *OpenMode,
+ char **FullPathname)
{
FILE *IncludeFile;
char *Pathname;
@@ -336,7 +344,7 @@ PrOpenIncludeWithPrefix (
/* Attempt to open the file, push if successful */
- IncludeFile = fopen (Pathname, "r");
+ IncludeFile = fopen (Pathname, OpenMode);
if (!IncludeFile)
{
fprintf (stderr, "Could not open include file %s\n", Pathname);
@@ -346,6 +354,7 @@ PrOpenIncludeWithPrefix (
/* Push the include file on the open input file stack */
PrPushInputFileStack (IncludeFile, Pathname);
+ *FullPathname = Pathname;
return (IncludeFile);
}
diff --git a/sys/contrib/dev/acpica/components/debugger/dbfileio.c b/sys/contrib/dev/acpica/components/debugger/dbfileio.c
index 9bf0b29..59a9a52 100644
--- a/sys/contrib/dev/acpica/components/debugger/dbfileio.c
+++ b/sys/contrib/dev/acpica/components/debugger/dbfileio.c
@@ -216,7 +216,8 @@ AeLocalLoadTable (
ACPI_STATUS
AcpiDbGetTableFromFile (
char *Filename,
- ACPI_TABLE_HEADER **ReturnTable)
+ ACPI_TABLE_HEADER **ReturnTable,
+ BOOLEAN MustBeAmlFile)
{
#ifdef ACPI_APPLICATION
ACPI_STATUS Status;
@@ -230,9 +231,18 @@ AcpiDbGetTableFromFile (
return (Status);
}
-#ifdef ACPI_DATA_TABLE_DISASSEMBLY
- IsAmlTable = AcpiUtIsAmlTable (Table);
-#endif
+ if (MustBeAmlFile)
+ {
+ IsAmlTable = AcpiUtIsAmlTable (Table);
+ if (!IsAmlTable)
+ {
+ ACPI_EXCEPTION ((AE_INFO, AE_OK,
+ "Input for -e is not an AML table: "
+ "\"%4.4s\" (must be DSDT/SSDT)",
+ Table->Signature));
+ return (AE_TYPE);
+ }
+ }
if (IsAmlTable)
{
diff --git a/sys/contrib/dev/acpica/components/debugger/dbinput.c b/sys/contrib/dev/acpica/components/debugger/dbinput.c
index 297b9e9..623bc48 100644
--- a/sys/contrib/dev/acpica/components/debugger/dbinput.c
+++ b/sys/contrib/dev/acpica/components/debugger/dbinput.c
@@ -969,7 +969,7 @@ AcpiDbCommandDispatch (
case CMD_LOAD:
- Status = AcpiDbGetTableFromFile (AcpiGbl_DbArgs[1], NULL);
+ Status = AcpiDbGetTableFromFile (AcpiGbl_DbArgs[1], NULL, FALSE);
break;
case CMD_LOCKS:
diff --git a/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c b/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c
index a687c72..9845025 100644
--- a/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c
+++ b/sys/contrib/dev/acpica/components/dispatcher/dsmethod.c
@@ -123,6 +123,7 @@ AcpiDsAutoSerializeMethod (
WalkState = AcpiDsCreateWalkState (Node->OwnerId, NULL, NULL, NULL);
if (!WalkState)
{
+ AcpiPsFreeOp (Op);
return_ACPI_STATUS (AE_NO_MEMORY);
}
@@ -131,6 +132,7 @@ AcpiDsAutoSerializeMethod (
if (ACPI_FAILURE (Status))
{
AcpiDsDeleteWalkState (WalkState);
+ AcpiPsFreeOp (Op);
return_ACPI_STATUS (Status);
}
@@ -139,10 +141,6 @@ AcpiDsAutoSerializeMethod (
/* Parse the method, scan for creation of named objects */
Status = AcpiPsParseAml (WalkState);
- if (ACPI_FAILURE (Status))
- {
- return_ACPI_STATUS (Status);
- }
AcpiPsDeleteParseTree (Op);
return_ACPI_STATUS (Status);
diff --git a/sys/contrib/dev/acpica/components/hardware/hwpci.c b/sys/contrib/dev/acpica/components/hardware/hwpci.c
index 165d26c..c19100b 100644
--- a/sys/contrib/dev/acpica/components/hardware/hwpci.c
+++ b/sys/contrib/dev/acpica/components/hardware/hwpci.c
@@ -140,7 +140,7 @@ AcpiHwDerivePciId (
ACPI_HANDLE PciRegion)
{
ACPI_STATUS Status;
- ACPI_PCI_DEVICE *ListHead = NULL;
+ ACPI_PCI_DEVICE *ListHead;
ACPI_FUNCTION_TRACE (HwDerivePciId);
@@ -198,7 +198,6 @@ AcpiHwBuildPciList (
ACPI_HANDLE ParentDevice;
ACPI_STATUS Status;
ACPI_PCI_DEVICE *ListElement;
- ACPI_PCI_DEVICE *ListHead = NULL;
/*
@@ -206,6 +205,7 @@ AcpiHwBuildPciList (
* a list of device nodes. Loop will exit when either the PCI device is
* found, or the root of the namespace is reached.
*/
+ *ReturnListHead = NULL;
CurrentDevice = PciRegion;
while (1)
{
@@ -222,7 +222,6 @@ AcpiHwBuildPciList (
if (ParentDevice == RootPciDevice)
{
- *ReturnListHead = ListHead;
return (AE_OK);
}
@@ -237,9 +236,9 @@ AcpiHwBuildPciList (
/* Put new element at the head of the list */
- ListElement->Next = ListHead;
+ ListElement->Next = *ReturnListHead;
ListElement->Device = ParentDevice;
- ListHead = ListElement;
+ *ReturnListHead = ListElement;
CurrentDevice = ParentDevice;
}
diff --git a/sys/contrib/dev/acpica/components/namespace/nsprepkg.c b/sys/contrib/dev/acpica/components/namespace/nsprepkg.c
index 5940a96..905fe64 100644
--- a/sys/contrib/dev/acpica/components/namespace/nsprepkg.c
+++ b/sys/contrib/dev/acpica/components/namespace/nsprepkg.c
@@ -321,6 +321,13 @@ AcpiNsCheckPackage (
Status = AcpiNsCheckPackageList (Info, Package, Elements, Count);
break;
+ case ACPI_PTYPE2_VAR_VAR:
+ /*
+ * Returns a variable list of packages, each with a variable list
+ * of objects.
+ */
+ break;
+
case ACPI_PTYPE2_UUID_PAIR:
/* The package must contain pairs of (UUID + type) */
@@ -490,6 +497,12 @@ AcpiNsCheckPackageList (
}
break;
+ case ACPI_PTYPE2_VAR_VAR:
+ /*
+ * Each subpackage has a fixed or variable number of elements
+ */
+ break;
+
case ACPI_PTYPE2_FIXED:
/* Each subpackage has a fixed length */
diff --git a/sys/contrib/dev/acpica/components/namespace/nsrepair.c b/sys/contrib/dev/acpica/components/namespace/nsrepair.c
index a1ffe25f..b4c2c99 100644
--- a/sys/contrib/dev/acpica/components/namespace/nsrepair.c
+++ b/sys/contrib/dev/acpica/components/namespace/nsrepair.c
@@ -523,10 +523,10 @@ AcpiNsRemoveNullElements (
case ACPI_PTYPE2_MIN:
case ACPI_PTYPE2_REV_FIXED:
case ACPI_PTYPE2_FIX_VAR:
-
break;
default:
+ case ACPI_PTYPE2_VAR_VAR:
case ACPI_PTYPE1_FIXED:
case ACPI_PTYPE1_OPTION:
return;
diff --git a/sys/contrib/dev/acpica/components/parser/psopinfo.c b/sys/contrib/dev/acpica/components/parser/psopinfo.c
index 872f58a..f7f6248 100644
--- a/sys/contrib/dev/acpica/components/parser/psopinfo.c
+++ b/sys/contrib/dev/acpica/components/parser/psopinfo.c
@@ -52,9 +52,6 @@
ACPI_MODULE_NAME ("psopinfo")
-extern const UINT8 AcpiGbl_ShortOpIndex[];
-extern const UINT8 AcpiGbl_LongOpIndex[];
-
static const UINT8 AcpiGbl_ArgumentCount[] = {0,1,1,1,1,2,2,2,2,3,3,6};
diff --git a/sys/contrib/dev/acpica/components/utilities/utfileio.c b/sys/contrib/dev/acpica/components/utilities/utfileio.c
index bef66f6..15cb3d0 100644
--- a/sys/contrib/dev/acpica/components/utilities/utfileio.c
+++ b/sys/contrib/dev/acpica/components/utilities/utfileio.c
@@ -228,11 +228,8 @@ AcpiUtReadTable (
TableHeader.Length, FileSize);
#ifdef ACPI_ASL_COMPILER
- Status = FlCheckForAscii (fp, NULL, FALSE);
- if (ACPI_SUCCESS (Status))
- {
- AcpiOsPrintf ("File appears to be ASCII only, must be binary\n");
- }
+ AcpiOsPrintf ("File is corrupt or is ASCII text -- "
+ "it must be a binary file\n");
#endif
return (AE_BAD_HEADER);
}
@@ -344,7 +341,7 @@ AcpiUtReadTableFromFile (
/* Get the entire file */
- fprintf (stderr, "Loading Acpi table from file %10s - Length %.8u (%06X)\n",
+ fprintf (stderr, "Reading ACPI table from file %10s - Length %.8u (0x%06X)\n",
Filename, FileSize, FileSize);
Status = AcpiUtReadTable (File, Table, &TableLength);
diff --git a/sys/contrib/dev/acpica/components/utilities/uthex.c b/sys/contrib/dev/acpica/components/utilities/uthex.c
index 3486008..7eede9d 100644
--- a/sys/contrib/dev/acpica/components/utilities/uthex.c
+++ b/sys/contrib/dev/acpica/components/utilities/uthex.c
@@ -82,9 +82,9 @@ AcpiUtHexToAsciiChar (
/*******************************************************************************
*
- * FUNCTION: AcpiUtHexCharToValue
+ * FUNCTION: AcpiUtAsciiCharToHex
*
- * PARAMETERS: AsciiChar - Hex character in Ascii
+ * PARAMETERS: HexChar - Hex character in Ascii
*
* RETURN: The binary value of the ascii/hex character
*
diff --git a/sys/contrib/dev/acpica/components/utilities/utxferror.c b/sys/contrib/dev/acpica/components/utilities/utxferror.c
index 89fc516..d39682b 100644
--- a/sys/contrib/dev/acpica/components/utilities/utxferror.c
+++ b/sys/contrib/dev/acpica/components/utilities/utxferror.c
@@ -123,8 +123,18 @@ AcpiException (
ACPI_MSG_REDIRECT_BEGIN;
- AcpiOsPrintf (ACPI_MSG_EXCEPTION "%s, ", AcpiFormatException (Status));
+ /* For AE_OK, just print the message */
+
+ if (ACPI_SUCCESS (Status))
+ {
+ AcpiOsPrintf (ACPI_MSG_EXCEPTION);
+
+ }
+ else
+ {
+ AcpiOsPrintf (ACPI_MSG_EXCEPTION "%s, ", AcpiFormatException (Status));
+ }
va_start (ArgList, Format);
AcpiOsVprintf (Format, ArgList);
ACPI_MSG_SUFFIX;
diff --git a/sys/contrib/dev/acpica/include/acdebug.h b/sys/contrib/dev/acpica/include/acdebug.h
index 23464d6..11cf02e 100644
--- a/sys/contrib/dev/acpica/include/acdebug.h
+++ b/sys/contrib/dev/acpica/include/acdebug.h
@@ -375,7 +375,8 @@ AcpiDbLoadAcpiTable (
ACPI_STATUS
AcpiDbGetTableFromFile (
char *Filename,
- ACPI_TABLE_HEADER **Table);
+ ACPI_TABLE_HEADER **Table,
+ BOOLEAN MustBeAmlTable);
/*
diff --git a/sys/contrib/dev/acpica/include/acdisasm.h b/sys/contrib/dev/acpica/include/acdisasm.h
index f4487e5..bbd21b7 100644
--- a/sys/contrib/dev/acpica/include/acdisasm.h
+++ b/sys/contrib/dev/acpica/include/acdisasm.h
@@ -60,7 +60,7 @@
#define ACPI_RAW_TABLE_DATA_HEADER "Raw Table Data"
-typedef const struct acpi_dmtable_info
+typedef struct acpi_dmtable_info
{
UINT8 Opcode;
UINT16 Offset;
@@ -148,9 +148,11 @@ typedef enum
ACPI_DMT_HEST,
ACPI_DMT_HESTNTFY,
ACPI_DMT_HESTNTYP,
+ ACPI_DMT_IORTMEM,
ACPI_DMT_IVRS,
ACPI_DMT_LPIT,
ACPI_DMT_MADT,
+ ACPI_DMT_NFIT,
ACPI_DMT_PCCT,
ACPI_DMT_PMTT,
ACPI_DMT_SLIC,
@@ -178,7 +180,6 @@ typedef struct acpi_dmtable_data
ACPI_DMTABLE_HANDLER TableHandler;
ACPI_CMTABLE_HANDLER CmTableHandler;
const unsigned char *Template;
- char *Name;
} ACPI_DMTABLE_DATA;
@@ -246,6 +247,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoCpep0[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoCsrt0[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoCsrt1[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoCsrt2[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoCsrt2a[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2Device[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoDbg2Addr[];
@@ -262,6 +264,11 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar2[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar3[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoDmar4[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm0[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm0a[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm1[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm1a[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoDrtm2[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoEcdt[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoEinj[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoEinj0[];
@@ -272,6 +279,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt5[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoFadt6[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoFpdtHdr[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoFpdt0[];
@@ -297,6 +305,20 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoHpet[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoLpitHdr[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoLpit0[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoLpit1[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort0[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort0a[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort1[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort1a[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort2[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort3[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort3a[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort3b[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoIort3c[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoIortAcc[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoIortHdr[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoIortMap[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoIortPad[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs0[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoIvrs1[];
@@ -321,6 +343,7 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt11[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt12[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt13[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt14[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadt15[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoMadtHdr[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoMcfg0[];
@@ -335,6 +358,18 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoMsct[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoMsct0[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoMtmr[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoMtmr0[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoNfit[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoNfitHdr[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoNfit0[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoNfit1[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoNfit2[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoNfit2a[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoNfit3[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoNfit3a[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoNfit4[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoNfit5[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoNfit6[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoNfit6a[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoPmtt[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoPmtt0[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoPmtt1[];
@@ -362,6 +397,8 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat0[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat1[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat2[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoSrat3[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoStao[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoStaoStr[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoTcpa[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoTpm2[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoUefi[];
@@ -372,14 +409,17 @@ extern ACPI_DMTABLE_INFO AcpiDmTableInfoWdat[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoWdat0[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoWddt[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoWdrt[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoWpbt[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoWpbt0[];
+extern ACPI_DMTABLE_INFO AcpiDmTableInfoXenv[];
extern ACPI_DMTABLE_INFO AcpiDmTableInfoGeneric[][2];
-
/*
- * dmtable
+ * dmtable and ahtable
*/
-extern ACPI_DMTABLE_DATA AcpiDmTableData[];
+extern const ACPI_DMTABLE_DATA AcpiDmTableData[];
+extern const AH_TABLE AcpiSupportedTables[];
UINT8
AcpiDmGenerateChecksum (
@@ -387,7 +427,7 @@ AcpiDmGenerateChecksum (
UINT32 Length,
UINT8 OriginalChecksum);
-ACPI_DMTABLE_DATA *
+const ACPI_DMTABLE_DATA *
AcpiDmGetTableData (
char *Signature);
@@ -426,8 +466,13 @@ AcpiDmDumpBuffer (
UINT32 BufferOffset,
UINT32 Length,
UINT32 AbsoluteOffset,
- char *Header,
- BOOLEAN MultiLine);
+ char *Header);
+
+void
+AcpiDmDumpUnicode (
+ void *Table,
+ UINT32 BufferOffset,
+ UINT32 ByteLength);
void
AcpiDmDumpAsf (
@@ -450,6 +495,10 @@ AcpiDmDumpDmar (
ACPI_TABLE_HEADER *Table);
void
+AcpiDmDumpDrtm (
+ ACPI_TABLE_HEADER *Table);
+
+void
AcpiDmDumpEinj (
ACPI_TABLE_HEADER *Table);
@@ -474,6 +523,10 @@ AcpiDmDumpHest (
ACPI_TABLE_HEADER *Table);
void
+AcpiDmDumpIort (
+ ACPI_TABLE_HEADER *Table);
+
+void
AcpiDmDumpIvrs (
ACPI_TABLE_HEADER *Table);
@@ -502,6 +555,10 @@ AcpiDmDumpMtmr (
ACPI_TABLE_HEADER *Table);
void
+AcpiDmDumpNfit (
+ ACPI_TABLE_HEADER *Table);
+
+void
AcpiDmDumpPcct (
ACPI_TABLE_HEADER *Table);
@@ -534,6 +591,10 @@ AcpiDmDumpSrat (
ACPI_TABLE_HEADER *Table);
void
+AcpiDmDumpStao (
+ ACPI_TABLE_HEADER *Table);
+
+void
AcpiDmDumpVrtc (
ACPI_TABLE_HEADER *Table);
@@ -542,6 +603,10 @@ AcpiDmDumpWdat (
ACPI_TABLE_HEADER *Table);
void
+AcpiDmDumpWpbt (
+ ACPI_TABLE_HEADER *Table);
+
+void
AcpiDmDumpXsdt (
ACPI_TABLE_HEADER *Table);
diff --git a/sys/contrib/dev/acpica/include/aclocal.h b/sys/contrib/dev/acpica/include/aclocal.h
index 9729930..4c96303 100644
--- a/sys/contrib/dev/acpica/include/aclocal.h
+++ b/sys/contrib/dev/acpica/include/aclocal.h
@@ -401,12 +401,24 @@ typedef struct acpi_package_info3
} ACPI_PACKAGE_INFO3;
+typedef struct acpi_package_info4
+{
+ UINT8 Type;
+ UINT8 ObjectType1;
+ UINT8 Count1;
+ UINT8 SubObjectTypes;
+ UINT8 PkgCount;
+ UINT16 Reserved;
+
+} ACPI_PACKAGE_INFO4;
+
typedef union acpi_predefined_info
{
ACPI_NAME_INFO Info;
ACPI_PACKAGE_INFO RetInfo;
ACPI_PACKAGE_INFO2 RetInfo2;
ACPI_PACKAGE_INFO3 RetInfo3;
+ ACPI_PACKAGE_INFO4 RetInfo4;
} ACPI_PREDEFINED_INFO;
@@ -1371,4 +1383,11 @@ typedef struct ah_uuid
} AH_UUID;
+typedef struct ah_table
+{
+ char *Signature;
+ char *Description;
+
+} AH_TABLE;
+
#endif /* __ACLOCAL_H__ */
diff --git a/sys/contrib/dev/acpica/include/acparser.h b/sys/contrib/dev/acpica/include/acparser.h
index 4ad2ec2..a3c7666 100644
--- a/sys/contrib/dev/acpica/include/acparser.h
+++ b/sys/contrib/dev/acpica/include/acparser.h
@@ -72,6 +72,9 @@
*
*****************************************************************************/
+extern const UINT8 AcpiGbl_ShortOpIndex[];
+extern const UINT8 AcpiGbl_LongOpIndex[];
+
/*
* psxface - Parser external interfaces
diff --git a/sys/contrib/dev/acpica/include/acpixf.h b/sys/contrib/dev/acpica/include/acpixf.h
index 8f6e089..8d972eb 100644
--- a/sys/contrib/dev/acpica/include/acpixf.h
+++ b/sys/contrib/dev/acpica/include/acpixf.h
@@ -46,7 +46,7 @@
/* Current ACPICA subsystem version in YYYYMMDD format */
-#define ACPI_CA_VERSION 0x20150410
+#define ACPI_CA_VERSION 0x20150515
#include <contrib/dev/acpica/include/acconfig.h>
#include <contrib/dev/acpica/include/actypes.h>
diff --git a/sys/contrib/dev/acpica/include/acpredef.h b/sys/contrib/dev/acpica/include/acpredef.h
index c832f51..5dae6aa 100644
--- a/sys/contrib/dev/acpica/include/acpredef.h
+++ b/sys/contrib/dev/acpica/include/acpredef.h
@@ -106,6 +106,11 @@
* count = 0 (optional)
* (Used for _DLM)
*
+ * ACPI_PTYPE2_VAR_VAR: Variable number of subpackages, each of either a
+ * constant or variable length. The subpackages are preceded by a
+ * constant number of objects.
+ * (Used for _LPI, _RDI)
+ *
* ACPI_PTYPE2_UUID_PAIR: Each subpackage is preceded by a UUID Buffer. The UUID
* defines the format of the package. Zero-length parent package is
* allowed.
@@ -125,7 +130,8 @@ enum AcpiReturnPackageTypes
ACPI_PTYPE2_MIN = 8,
ACPI_PTYPE2_REV_FIXED = 9,
ACPI_PTYPE2_FIX_VAR = 10,
- ACPI_PTYPE2_UUID_PAIR = 11
+ ACPI_PTYPE2_VAR_VAR = 11,
+ ACPI_PTYPE2_UUID_PAIR = 12
};
@@ -177,7 +183,7 @@ enum AcpiReturnPackageTypes
* These are the names that can actually be evaluated via AcpiEvaluateObject.
* Not present in this table are the following:
*
- * 1) Predefined/Reserved names that are never evaluated via
+ * 1) Predefined/Reserved names that are not usually evaluated via
* AcpiEvaluateObject:
* _Lxx and _Exx GPE methods
* _Qxx EC methods
@@ -363,6 +369,9 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] =
METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (4 Int) */
PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_INTEGER, 4,0,0,0),
+ {{"_BTH", METHOD_1ARGS (ACPI_TYPE_INTEGER), /* ACPI 6.0 */
+ METHOD_NO_RETURN_VALUE}},
+
{{"_BTM", METHOD_1ARGS (ACPI_TYPE_INTEGER),
METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
@@ -390,6 +399,9 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] =
METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Ints/Bufs) */
PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER, 0,0,0,0),
+ {{"_CR3", METHOD_0ARGS, /* ACPI 6.0 */
+ METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
+
{{"_CRS", METHOD_0ARGS,
METHOD_RETURNS (ACPI_RTYPE_BUFFER)}},
@@ -443,7 +455,7 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] =
{{"_DOS", METHOD_1ARGS (ACPI_TYPE_INTEGER),
METHOD_NO_RETURN_VALUE}},
- {{"_DSD", METHOD_0ARGS,
+ {{"_DSD", METHOD_0ARGS, /* ACPI 6.0 */
METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each: 1 Buf, 1 Pkg */
PACKAGE_INFO (ACPI_PTYPE2_UUID_PAIR, ACPI_RTYPE_BUFFER, 1, ACPI_RTYPE_PACKAGE, 1,0),
@@ -597,6 +609,11 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] =
METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (1 Int(rev), n Pkg (2 Int) */
PACKAGE_INFO (ACPI_PTYPE2_REV_FIXED, ACPI_RTYPE_INTEGER, 2,0,0,0),
+ {{"_LPI", METHOD_0ARGS, /* ACPI 6.0 */
+ METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (3 Int, n Pkg (10 Int/Buf) */
+ PACKAGE_INFO (ACPI_PTYPE2_VAR_VAR, ACPI_RTYPE_INTEGER, 3,
+ ACPI_RTYPE_INTEGER | ACPI_RTYPE_BUFFER | ACPI_RTYPE_STRING, 10,0),
+
{{"_MAT", METHOD_0ARGS,
METHOD_RETURNS (ACPI_RTYPE_BUFFER)}},
@@ -614,6 +631,9 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] =
{{"_MSM", METHOD_4ARGS (ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER),
METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
+ {{"_MTL", METHOD_0ARGS, /* ACPI 6.0 */
+ METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
+
{{"_NTT", METHOD_0ARGS,
METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
@@ -701,6 +721,10 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] =
METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Refs) */
PACKAGE_INFO (ACPI_PTYPE1_VAR, ACPI_RTYPE_REFERENCE, 0,0,0,0),
+ {{"_PRR", METHOD_0ARGS, /* ACPI 6.0 */
+ METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Fixed-length (1 Ref) */
+ PACKAGE_INFO (ACPI_PTYPE1_FIXED, ACPI_RTYPE_REFERENCE, 1,0,0,0),
+
{{"_PRS", METHOD_0ARGS,
METHOD_RETURNS (ACPI_RTYPE_BUFFER)}},
@@ -778,6 +802,11 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] =
{{"_PXM", METHOD_0ARGS,
METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
+ {{"_RDI", METHOD_0ARGS, /* ACPI 6.0 */
+ METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (1 Int, n Pkg (m Ref)) */
+ PACKAGE_INFO (ACPI_PTYPE2_VAR_VAR, ACPI_RTYPE_INTEGER, 1,
+ ACPI_RTYPE_REFERENCE,0,0),
+
{{"_REG", METHOD_2ARGS (ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER),
METHOD_NO_RETURN_VALUE}},
@@ -790,6 +819,9 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] =
{{"_ROM", METHOD_2ARGS (ACPI_TYPE_INTEGER, ACPI_TYPE_INTEGER),
METHOD_RETURNS (ACPI_RTYPE_BUFFER)}},
+ {{"_RST", METHOD_0ARGS, /* ACPI 6.0 */
+ METHOD_NO_RETURN_VALUE}},
+
{{"_RTV", METHOD_0ARGS,
METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
@@ -916,6 +948,9 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] =
{{"_TDL", METHOD_0ARGS,
METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
+ {{"_TFP", METHOD_0ARGS, /* ACPI 6.0 */
+ METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
+
{{"_TIP", METHOD_1ARGS (ACPI_TYPE_INTEGER),
METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
@@ -939,6 +974,9 @@ const ACPI_PREDEFINED_INFO AcpiGbl_PredefinedMethods[] =
METHOD_RETURNS (ACPI_RTYPE_PACKAGE)}}, /* Variable-length (Pkgs) each 5 Int with count */
PACKAGE_INFO (ACPI_PTYPE2_COUNT,ACPI_RTYPE_INTEGER, 5,0,0,0),
+ {{"_TSN", METHOD_0ARGS, /* ACPI 6.0 */
+ METHOD_RETURNS (ACPI_RTYPE_REFERENCE)}},
+
{{"_TSP", METHOD_0ARGS,
METHOD_RETURNS (ACPI_RTYPE_INTEGER)}},
diff --git a/sys/contrib/dev/acpica/include/actbl.h b/sys/contrib/dev/acpica/include/actbl.h
index 6d79808..ceef763 100644
--- a/sys/contrib/dev/acpica/include/actbl.h
+++ b/sys/contrib/dev/acpica/include/actbl.h
@@ -310,6 +310,7 @@ typedef struct acpi_table_fadt
ACPI_GENERIC_ADDRESS XGpe1Block; /* 64-bit Extended General Purpose Event 1 Reg Blk address */
ACPI_GENERIC_ADDRESS SleepControl; /* 64-bit Sleep Control register (ACPI 5.0) */
ACPI_GENERIC_ADDRESS SleepStatus; /* 64-bit Sleep Status register (ACPI 5.0) */
+ UINT64 HypervisorId; /* Hypervisor Vendor ID (ACPI 6.0) */
} ACPI_TABLE_FADT;
@@ -369,7 +370,7 @@ enum AcpiPreferredPmProfiles
PM_TABLET = 8
};
-/* Values for SleepStatus and SleepControl registers (V5 FADT) */
+/* Values for SleepStatus and SleepControl registers (V5+ FADT) */
#define ACPI_X_WAKE_STATUS 0x80
#define ACPI_X_SLEEP_TYPE_MASK 0x1C
@@ -434,15 +435,17 @@ typedef struct acpi_table_desc
* FADT is the bottom line as to what the version really is.
*
* For reference, the values below are as follows:
- * FADT V1 size: 0x074
- * FADT V2 size: 0x084
- * FADT V3 size: 0x0F4
- * FADT V4 size: 0x0F4
- * FADT V5 size: 0x10C
+ * FADT V1 size: 0x074
+ * FADT V2 size: 0x084
+ * FADT V3 size: 0x0F4
+ * FADT V4 size: 0x0F4
+ * FADT V5 size: 0x10C
+ * FADT V6 size: 0x114
*/
#define ACPI_FADT_V1_SIZE (UINT32) (ACPI_FADT_OFFSET (Flags) + 4)
#define ACPI_FADT_V2_SIZE (UINT32) (ACPI_FADT_OFFSET (MinorRevision) + 1)
#define ACPI_FADT_V3_SIZE (UINT32) (ACPI_FADT_OFFSET (SleepControl))
-#define ACPI_FADT_V5_SIZE (UINT32) (sizeof (ACPI_TABLE_FADT))
+#define ACPI_FADT_V5_SIZE (UINT32) (ACPI_FADT_OFFSET (HypervisorId))
+#define ACPI_FADT_V6_SIZE (UINT32) (sizeof (ACPI_TABLE_FADT))
#endif /* __ACTBL_H__ */
diff --git a/sys/contrib/dev/acpica/include/actbl1.h b/sys/contrib/dev/acpica/include/actbl1.h
index 66b3d07..962324a 100644
--- a/sys/contrib/dev/acpica/include/actbl1.h
+++ b/sys/contrib/dev/acpica/include/actbl1.h
@@ -73,6 +73,7 @@
#define ACPI_SIG_SBST "SBST" /* Smart Battery Specification Table */
#define ACPI_SIG_SLIT "SLIT" /* System Locality Distance Information Table */
#define ACPI_SIG_SRAT "SRAT" /* System Resource Affinity Table */
+#define ACPI_SIG_NFIT "NFIT" /* NVDIMM Firmware Interface Table */
/*
@@ -777,7 +778,8 @@ enum AcpiMadtType
ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR = 12,
ACPI_MADT_TYPE_GENERIC_MSI_FRAME = 13,
ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR = 14,
- ACPI_MADT_TYPE_RESERVED = 15 /* 15 and greater are reserved */
+ ACPI_MADT_TYPE_GENERIC_TRANSLATOR = 15,
+ ACPI_MADT_TYPE_RESERVED = 16 /* 16 and greater are reserved */
};
@@ -932,7 +934,7 @@ typedef struct acpi_madt_local_x2apic_nmi
} ACPI_MADT_LOCAL_X2APIC_NMI;
-/* 11: Generic Interrupt (ACPI 5.0) */
+/* 11: Generic Interrupt (ACPI 5.0 + ACPI 6.0 changes) */
typedef struct acpi_madt_generic_interrupt
{
@@ -950,6 +952,8 @@ typedef struct acpi_madt_generic_interrupt
UINT32 VgicInterrupt;
UINT64 GicrBaseAddress;
UINT64 ArmMpidr;
+ UINT8 EfficiencyClass;
+ UINT8 Reserved2[3];
} ACPI_MADT_GENERIC_INTERRUPT;
@@ -960,7 +964,7 @@ typedef struct acpi_madt_generic_interrupt
#define ACPI_MADT_VGIC_IRQ_MODE (1<<2) /* 02: VGIC Maintenance Interrupt mode */
-/* 12: Generic Distributor (ACPI 5.0) */
+/* 12: Generic Distributor (ACPI 5.0 + ACPI 6.0 changes) */
typedef struct acpi_madt_generic_distributor
{
@@ -969,7 +973,8 @@ typedef struct acpi_madt_generic_distributor
UINT32 GicId;
UINT64 BaseAddress;
UINT32 GlobalIrqBase;
- UINT32 Reserved2; /* Reserved - must be zero */
+ UINT8 Version;
+ UINT8 Reserved2[3]; /* Reserved - must be zero */
} ACPI_MADT_GENERIC_DISTRIBUTOR;
@@ -1005,6 +1010,19 @@ typedef struct acpi_madt_generic_redistributor
} ACPI_MADT_GENERIC_REDISTRIBUTOR;
+/* 15: Generic Translator (ACPI 6.0) */
+
+typedef struct acpi_madt_generic_translator
+{
+ ACPI_SUBTABLE_HEADER Header;
+ UINT16 Reserved; /* reserved - must be zero */
+ UINT32 TranslationId;
+ UINT64 BaseAddress;
+ UINT32 Reserved2;
+
+} ACPI_MADT_GENERIC_TRANSLATOR;
+
+
/*
* Common flags fields for MADT subtables
*/
@@ -1065,6 +1083,186 @@ typedef struct acpi_msct_proximity
/*******************************************************************************
*
+ * NFIT - NVDIMM Interface Table (ACPI 6.0)
+ * Version 1
+ *
+ ******************************************************************************/
+
+typedef struct acpi_table_nfit
+{
+ ACPI_TABLE_HEADER Header; /* Common ACPI table header */
+ UINT32 Reserved; /* Reserved, must be zero */
+
+} ACPI_TABLE_NFIT;
+
+/* Subtable header for NFIT */
+
+typedef struct acpi_nfit_header
+{
+ UINT16 Type;
+ UINT16 Length;
+
+} ACPI_NFIT_HEADER;
+
+
+/* Values for subtable type in ACPI_NFIT_HEADER */
+
+enum AcpiNfitType
+{
+ ACPI_NFIT_TYPE_SYSTEM_ADDRESS = 0,
+ ACPI_NFIT_TYPE_MEMORY_MAP = 1,
+ ACPI_NFIT_TYPE_INTERLEAVE = 2,
+ ACPI_NFIT_TYPE_SMBIOS = 3,
+ ACPI_NFIT_TYPE_CONTROL_REGION = 4,
+ ACPI_NFIT_TYPE_DATA_REGION = 5,
+ ACPI_NFIT_TYPE_FLUSH_ADDRESS = 6,
+ ACPI_NFIT_TYPE_RESERVED = 7 /* 7 and greater are reserved */
+};
+
+/*
+ * NFIT Subtables
+ */
+
+/* 0: System Physical Address Range Structure */
+
+typedef struct acpi_nfit_system_address
+{
+ ACPI_NFIT_HEADER Header;
+ UINT16 RangeIndex;
+ UINT16 Flags;
+ UINT32 Reserved; /* Reseved, must be zero */
+ UINT32 ProximityDomain;
+ UINT8 RangeGuid[16];
+ UINT64 Address;
+ UINT64 Length;
+ UINT64 MemoryMapping;
+
+} ACPI_NFIT_SYSTEM_ADDRESS;
+
+/* Flags */
+
+#define ACPI_NFIT_ADD_ONLINE_ONLY (1) /* 00: Add/Online Operation Only */
+#define ACPI_NFIT_PROXIMITY_VALID (1<<1) /* 01: Proximity Domain Valid */
+
+/* Range Type GUIDs appear in the include/acuuid.h file */
+
+
+/* 1: Memory Device to System Address Range Map Structure */
+
+typedef struct acpi_nfit_memory_map
+{
+ ACPI_NFIT_HEADER Header;
+ UINT32 DeviceHandle;
+ UINT16 PhysicalId;
+ UINT16 RegionId;
+ UINT16 RangeIndex;
+ UINT16 RegionIndex;
+ UINT64 RegionSize;
+ UINT64 RegionOffset;
+ UINT64 Address;
+ UINT16 InterleaveIndex;
+ UINT16 InterleaveWays;
+ UINT16 Flags;
+ UINT16 Reserved; /* Reserved, must be zero */
+
+} ACPI_NFIT_MEMORY_MAP;
+
+/* Flags */
+
+#define ACPI_NFIT_MEM_SAVE_FAILED (1) /* 00: Last SAVE to Memory Device failed */
+#define ACPI_NFIT_MEM_RESTORE_FAILED (1<<1) /* 01: Last RESTORE from Memory Device failed */
+#define ACPI_NFIT_MEM_FLUSH_FAILED (1<<2) /* 02: Platform flush failed */
+#define ACPI_NFIT_MEM_ARMED (1<<3) /* 03: Memory Device observed to be not armed */
+#define ACPI_NFIT_MEM_HEALTH_OBSERVED (1<<4) /* 04: Memory Device observed SMART/health events */
+#define ACPI_NFIT_MEM_HEALTH_ENABLED (1<<5) /* 05: SMART/health events enabled */
+
+
+/* 2: Interleave Structure */
+
+typedef struct acpi_nfit_interleave
+{
+ ACPI_NFIT_HEADER Header;
+ UINT16 InterleaveIndex;
+ UINT16 Reserved; /* Reserved, must be zero */
+ UINT32 LineCount;
+ UINT32 LineSize;
+ UINT32 LineOffset[1]; /* Variable length */
+
+} ACPI_NFIT_INTERLEAVE;
+
+
+/* 3: SMBIOS Management Information Structure */
+
+typedef struct acpi_nfit_smbios
+{
+ ACPI_NFIT_HEADER Header;
+ UINT32 Reserved; /* Reserved, must be zero */
+ UINT8 Data[1]; /* Variable length */
+
+} ACPI_NFIT_SMBIOS;
+
+
+/* 4: NVDIMM Control Region Structure */
+
+typedef struct acpi_nfit_control_region
+{
+ ACPI_NFIT_HEADER Header;
+ UINT16 RegionIndex;
+ UINT16 VendorId;
+ UINT16 DeviceId;
+ UINT16 RevisionId;
+ UINT16 SubsystemVendorId;
+ UINT16 SubsystemDeviceId;
+ UINT16 SubsystemRevisionId;
+ UINT8 Reserved[6]; /* Reserved, must be zero */
+ UINT32 SerialNumber;
+ UINT16 Code;
+ UINT16 Windows;
+ UINT64 WindowSize;
+ UINT64 CommandOffset;
+ UINT64 CommandSize;
+ UINT64 StatusOffset;
+ UINT64 StatusSize;
+ UINT16 Flags;
+ UINT8 Reserved1[6]; /* Reserved, must be zero */
+
+} ACPI_NFIT_CONTROL_REGION;
+
+/* Flags */
+
+#define ACPI_NFIT_CONTROL_BUFFERED (1) /* Block Data Windows implementation is buffered */
+
+
+/* 5: NVDIMM Block Data Window Region Structure */
+
+typedef struct acpi_nfit_data_region
+{
+ ACPI_NFIT_HEADER Header;
+ UINT16 RegionIndex;
+ UINT16 Windows;
+ UINT64 Offset;
+ UINT64 Size;
+ UINT64 Capacity;
+ UINT64 StartAddress;
+
+} ACPI_NFIT_DATA_REGION;
+
+
+/* 6: Flush Hint Address Structure */
+
+typedef struct acpi_nfit_flush_address
+{
+ ACPI_NFIT_HEADER Header;
+ UINT32 DeviceHandle;
+ UINT16 HintCount;
+ UINT8 Reserved[6]; /* Reserved, must be zero */
+ UINT64 HintAddress[1]; /* Variable length */
+
+} ACPI_NFIT_FLUSH_ADDRESS;
+
+
+/*******************************************************************************
+ *
* SBST - Smart Battery Specification Table
* Version 1
*
@@ -1202,6 +1400,7 @@ typedef struct acpi_srat_gicc_affinity
#define ACPI_SRAT_GICC_ENABLED (1) /* 00: Use affinity structure */
+
/* Reset to default packing */
#pragma pack()
diff --git a/sys/contrib/dev/acpica/include/actbl2.h b/sys/contrib/dev/acpica/include/actbl2.h
index 5cdf904..654495f 100644
--- a/sys/contrib/dev/acpica/include/actbl2.h
+++ b/sys/contrib/dev/acpica/include/actbl2.h
@@ -71,6 +71,7 @@
#define ACPI_SIG_DMAR "DMAR" /* DMA Remapping table */
#define ACPI_SIG_HPET "HPET" /* High Precision Event Timer table */
#define ACPI_SIG_IBFT "IBFT" /* iSCSI Boot Firmware Table */
+#define ACPI_SIG_IORT "IORT" /* IO Remapping Table */
#define ACPI_SIG_IVRS "IVRS" /* I/O Virtualization Reporting Structure */
#define ACPI_SIG_LPIT "LPIT" /* Low Power Idle Table */
#define ACPI_SIG_MCFG "MCFG" /* PCI Memory Mapped Configuration table */
@@ -753,6 +754,156 @@ typedef struct acpi_ibft_target
/*******************************************************************************
*
+ * IORT - IO Remapping Table
+ *
+ * Conforms to "IO Remapping Table System Software on ARM Platforms",
+ * Document number: ARM DEN 0049A, 2015
+ *
+ ******************************************************************************/
+
+typedef struct acpi_table_iort
+{
+ ACPI_TABLE_HEADER Header;
+ UINT32 NodeCount;
+ UINT32 NodeOffset;
+ UINT32 Reserved;
+
+} ACPI_TABLE_IORT;
+
+
+/*
+ * IORT subtables
+ */
+typedef struct acpi_iort_node
+{
+ UINT8 Type;
+ UINT16 Length;
+ UINT8 Revision;
+ UINT32 Reserved;
+ UINT32 MappingCount;
+ UINT32 MappingOffset;
+ char NodeData[1];
+
+} ACPI_IORT_NODE;
+
+/* Values for subtable Type above */
+
+enum AcpiIortNodeType
+{
+ ACPI_IORT_NODE_ITS_GROUP = 0x00,
+ ACPI_IORT_NODE_NAMED_COMPONENT = 0x01,
+ ACPI_IORT_NODE_PCI_ROOT_COMPLEX = 0x02,
+ ACPI_IORT_NODE_SMMU = 0x03
+};
+
+
+typedef struct acpi_iort_id_mapping
+{
+ UINT32 InputBase; /* Lowest value in input range */
+ UINT32 IdCount; /* Number of IDs */
+ UINT32 OutputBase; /* Lowest value in output range */
+ UINT32 OutputReference; /* A reference to the output node */
+ UINT32 Flags;
+
+} ACPI_IORT_ID_MAPPING;
+
+/* Masks for Flags field above for IORT subtable */
+
+#define ACPI_IORT_ID_SINGLE_MAPPING (1)
+
+
+typedef struct acpi_iort_memory_access
+{
+ UINT32 CacheCoherency;
+ UINT8 Hints;
+ UINT16 Reserved;
+ UINT8 MemoryFlags;
+
+} ACPI_IORT_MEMORY_ACCESS;
+
+/* Values for CacheCoherency field above */
+
+#define ACPI_IORT_NODE_COHERENT 0x00000001 /* The device node is fully coherent */
+#define ACPI_IORT_NODE_NOT_COHERENT 0x00000000 /* The device node is not coherent */
+
+/* Masks for Hints field above */
+
+#define ACPI_IORT_HT_TRANSIENT (1)
+#define ACPI_IORT_HT_WRITE (1<<1)
+#define ACPI_IORT_HT_READ (1<<2)
+#define ACPI_IORT_HT_OVERRIDE (1<<3)
+
+/* Masks for MemoryFlags field above */
+
+#define ACPI_IORT_MF_COHERENCY (1)
+#define ACPI_IORT_MF_ATTRIBUTES (1<<1)
+
+
+/*
+ * IORT node specific subtables
+ */
+typedef struct acpi_iort_its_group
+{
+ UINT32 ItsCount;
+ UINT32 Identifiers[1]; /* GIC ITS identifier arrary */
+
+} ACPI_IORT_ITS_GROUP;
+
+
+typedef struct acpi_iort_named_component
+{
+ UINT32 NodeFlags;
+ UINT64 MemoryProperties; /* Memory access properties */
+ UINT8 MemoryAddressLimit; /* Memory address size limit */
+ char DeviceName[1]; /* Path of namespace object */
+
+} ACPI_IORT_NAMED_COMPONENT;
+
+
+typedef struct acpi_iort_root_complex
+{
+ UINT64 MemoryProperties; /* Memory access properties */
+ UINT32 AtsAttribute;
+ UINT32 PciSegmentNumber;
+
+} ACPI_IORT_ROOT_COMPLEX;
+
+/* Values for AtsAttribute field above */
+
+#define ACPI_IORT_ATS_SUPPORTED 0x00000001 /* The root complex supports ATS */
+#define ACPI_IORT_ATS_UNSUPPORTED 0x00000000 /* The root complex doesn't support ATS */
+
+
+typedef struct acpi_iort_smmu
+{
+ UINT64 BaseAddress; /* SMMU base address */
+ UINT64 Span; /* Length of memory range */
+ UINT32 Model;
+ UINT32 Flags;
+ UINT32 GlobalInterruptOffset;
+ UINT32 ContextInterruptCount;
+ UINT32 ContextInterruptOffset;
+ UINT32 PmuInterruptCount;
+ UINT32 PmuInterruptOffset;
+ UINT64 Interrupts[1]; /* Interrupt array */
+
+} ACPI_IORT_SMMU;
+
+/* Values for Model field above */
+
+#define ACPI_IORT_SMMU_V1 0x00000000 /* Generic SMMUv1 */
+#define ACPI_IORT_SMMU_V2 0x00000001 /* Generic SMMUv2 */
+#define ACPI_IORT_SMMU_CORELINK_MMU400 0x00000002 /* ARM Corelink MMU-400 */
+#define ACPI_IORT_SMMU_CORELINK_MMU500 0x00000003 /* ARM Corelink MMU-500 */
+
+/* Masks for Flags field above */
+
+#define ACPI_IORT_SMMU_DVM_SUPPORTED (1)
+#define ACPI_IORT_SMMU_COHERENT_WALK (1<<1)
+
+
+/*******************************************************************************
+ *
* IVRS - I/O Virtualization Reporting Structure
* Version 1
*
@@ -953,7 +1104,7 @@ typedef struct acpi_ivrs_memory
*
* LPIT - Low Power Idle Table
*
- * Conforms to "ACPI Low Power Idle Table (LPIT) and _LPD Proposal (DRAFT)"
+ * Conforms to "ACPI Low Power Idle Table (LPIT)" July 2014.
*
******************************************************************************/
@@ -981,8 +1132,7 @@ typedef struct acpi_lpit_header
enum AcpiLpitType
{
ACPI_LPIT_TYPE_NATIVE_CSTATE = 0x00,
- ACPI_LPIT_TYPE_SIMPLE_IO = 0x01,
- ACPI_LPIT_TYPE_RESERVED = 0x02 /* 2 and above are reserved */
+ ACPI_LPIT_TYPE_RESERVED = 0x01 /* 1 and above are reserved */
};
/* Masks for Flags field above */
@@ -1008,24 +1158,6 @@ typedef struct acpi_lpit_native
} ACPI_LPIT_NATIVE;
-/* 0x01: Simple I/O based LPI structure */
-
-typedef struct acpi_lpit_io
-{
- ACPI_LPIT_HEADER Header;
- ACPI_GENERIC_ADDRESS EntryTrigger;
- UINT32 TriggerAction;
- UINT64 TriggerValue;
- UINT64 TriggerMask;
- ACPI_GENERIC_ADDRESS MinimumIdleState;
- UINT32 Residency;
- UINT32 Latency;
- ACPI_GENERIC_ADDRESS ResidencyCounter;
- UINT64 CounterFrequency;
-
-} ACPI_LPIT_IO;
-
-
/*******************************************************************************
*
* MCFG - PCI Memory Mapped Configuration table and subtable
diff --git a/sys/contrib/dev/acpica/include/actbl3.h b/sys/contrib/dev/acpica/include/actbl3.h
index f7ae670..f575d08 100644
--- a/sys/contrib/dev/acpica/include/actbl3.h
+++ b/sys/contrib/dev/acpica/include/actbl3.h
@@ -70,7 +70,10 @@
#define ACPI_SIG_PCCT "PCCT" /* Platform Communications Channel Table */
#define ACPI_SIG_PMTT "PMTT" /* Platform Memory Topology Table */
#define ACPI_SIG_RASF "RASF" /* RAS Feature table */
+#define ACPI_SIG_STAO "STAO" /* Status Override table */
#define ACPI_SIG_TPM2 "TPM2" /* Trusted Platform Module 2.0 H/W interface table */
+#define ACPI_SIG_WPBT "WPBT" /* Windows Platform Binary Table */
+#define ACPI_SIG_XENV "XENV" /* Xen Environment table */
#define ACPI_SIG_S3PT "S3PT" /* S3 Performance (sub)Table */
#define ACPI_SIG_PCCS "PCC" /* PCC Shared Memory Region */
@@ -79,7 +82,6 @@
#define ACPI_SIG_MATR "MATR" /* Memory Address Translation Table */
#define ACPI_SIG_MSDM "MSDM" /* Microsoft Data Management Table */
-#define ACPI_SIG_WPBT "WPBT" /* Windows Platform Binary Table */
/*
* All tables must be byte-packed to match the ACPI specification, since
@@ -123,6 +125,8 @@ typedef struct acpi_table_bgrt
/*******************************************************************************
*
* DRTM - Dynamic Root of Trust for Measurement table
+ * Conforms to "TCG D-RTM Architecture" June 17 2013, Version 1.0.0
+ * Table version 1
*
******************************************************************************/
@@ -141,29 +145,50 @@ typedef struct acpi_table_drtm
} ACPI_TABLE_DRTM;
-/* 1) Validated Tables List */
+/* Flag Definitions for above */
+
+#define ACPI_DRTM_ACCESS_ALLOWED (1)
+#define ACPI_DRTM_ENABLE_GAP_CODE (1<<1)
+#define ACPI_DRTM_INCOMPLETE_MEASUREMENTS (1<<2)
+#define ACPI_DRTM_AUTHORITY_ORDER (1<<3)
-typedef struct acpi_drtm_vtl_list
+
+/* 1) Validated Tables List (64-bit addresses) */
+
+typedef struct acpi_drtm_vtable_list
{
- UINT32 ValidatedTableListCount;
+ UINT32 ValidatedTableCount;
+ UINT64 ValidatedTables[1];
+
+} ACPI_DRTM_VTABLE_LIST;
-} ACPI_DRTM_VTL_LIST;
+/* 2) Resources List (of Resource Descriptors) */
-/* 2) Resources List */
+/* Resource Descriptor */
+
+typedef struct acpi_drtm_resource
+{
+ UINT8 Size[7];
+ UINT8 Type;
+ UINT64 Address;
+
+} ACPI_DRTM_RESOURCE;
typedef struct acpi_drtm_resource_list
{
- UINT32 ResourceListCount;
+ UINT32 ResourceCount;
+ ACPI_DRTM_RESOURCE Resources[1];
} ACPI_DRTM_RESOURCE_LIST;
/* 3) Platform-specific Identifiers List */
-typedef struct acpi_drtm_id_list
+typedef struct acpi_drtm_dps_id
{
- UINT32 IdListCount;
+ UINT32 DpsIdLength;
+ UINT8 DpsId[16];
-} ACPI_DRTM_ID_LIST;
+} ACPI_DRTM_DPS_ID;
/*******************************************************************************
@@ -805,6 +830,24 @@ enum AcpiRasfStatus
/*******************************************************************************
*
+ * STAO - Status Override Table (_STA override) - ACPI 6.0
+ * Version 1
+ *
+ * Conforms to "ACPI Specification for Status Override Table"
+ * 6 January 2015
+ *
+ ******************************************************************************/
+
+typedef struct acpi_table_stao
+{
+ ACPI_TABLE_HEADER Header; /* Common ACPI table header */
+ UINT8 IgnoreUart;
+
+} ACPI_TABLE_STAO;
+
+
+/*******************************************************************************
+ *
* TPM2 - Trusted Platform Module (TPM) 2.0 Hardware Interface Table
* Version 3
*
@@ -838,6 +881,47 @@ typedef struct acpi_tpm2_control
} ACPI_TPM2_CONTROL;
+/*******************************************************************************
+ *
+ * WPBT - Windows Platform Environment Table (ACPI 6.0)
+ * Version 1
+ *
+ * Conforms to "Windows Platform Binary Table (WPBT)" 29 November 2011
+ *
+ ******************************************************************************/
+
+typedef struct acpi_table_wpbt
+{
+ ACPI_TABLE_HEADER Header; /* Common ACPI table header */
+ UINT32 HandoffSize;
+ UINT64 HandoffAddress;
+ UINT8 Layout;
+ UINT8 Type;
+ UINT16 ArgumentsLength;
+
+} ACPI_TABLE_WPBT;
+
+
+/*******************************************************************************
+ *
+ * XENV - Xen Environment Table (ACPI 6.0)
+ * Version 1
+ *
+ * Conforms to "ACPI Specification for Xen Environment Table" 4 January 2015
+ *
+ ******************************************************************************/
+
+typedef struct acpi_table_xenv
+{
+ ACPI_TABLE_HEADER Header; /* Common ACPI table header */
+ UINT64 GrantTableAddress;
+ UINT64 GrantTableSize;
+ UINT32 EventInterrupt;
+ UINT8 EventFlags;
+
+} ACPI_TABLE_XENV;
+
+
/* Reset to default packing */
#pragma pack()
diff --git a/sys/contrib/dev/acpica/include/actypes.h b/sys/contrib/dev/acpica/include/actypes.h
index 79ae310..0bee2a7 100644
--- a/sys/contrib/dev/acpica/include/actypes.h
+++ b/sys/contrib/dev/acpica/include/actypes.h
@@ -538,6 +538,7 @@ typedef UINT64 ACPI_INTEGER;
#define ACPI_CAST_PTR(t, p) ((t *) (ACPI_UINTPTR_T) (p))
#define ACPI_CAST_INDIRECT_PTR(t, p) ((t **) (ACPI_UINTPTR_T) (p))
#define ACPI_ADD_PTR(t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8, (a)) + (ACPI_SIZE)(b)))
+#define ACPI_SUB_PTR(t, a, b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (UINT8, (a)) - (ACPI_SIZE)(b)))
#define ACPI_PTR_DIFF(a, b) (ACPI_SIZE) (ACPI_CAST_PTR (UINT8, (a)) - ACPI_CAST_PTR (UINT8, (b)))
/* Pointer/Integer type conversions */
diff --git a/sys/contrib/dev/acpica/include/acutils.h b/sys/contrib/dev/acpica/include/acutils.h
index 85426bf..fe6c057 100644
--- a/sys/contrib/dev/acpica/include/acutils.h
+++ b/sys/contrib/dev/acpica/include/acutils.h
@@ -339,7 +339,7 @@ extern const UINT8 _acpi_ctype[];
#define _ACPI_DI 0x04 /* '0'-'9' */
#define _ACPI_LO 0x02 /* 'a'-'z' */
#define _ACPI_PU 0x10 /* punctuation */
-#define _ACPI_SP 0x08 /* space */
+#define _ACPI_SP 0x08 /* space, tab, CR, LF, VT, FF */
#define _ACPI_UP 0x01 /* 'A'-'Z' */
#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */
diff --git a/sys/contrib/dev/acpica/include/acuuid.h b/sys/contrib/dev/acpica/include/acuuid.h
new file mode 100644
index 0000000..cfc4363
--- /dev/null
+++ b/sys/contrib/dev/acpica/include/acuuid.h
@@ -0,0 +1,64 @@
+/******************************************************************************
+ *
+ * Name: acuuid.h - ACPI-related UUID/GUID definitions
+ *
+ *****************************************************************************/
+
+/*
+ * Copyright (C) 2000 - 2015, Intel Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that 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. Redistributions in binary form must reproduce at minimum a disclaimer
+ * substantially similar to the "NO WARRANTY" disclaimer below
+ * ("Disclaimer") and any redistribution must be conditioned upon
+ * including a substantially similar Disclaimer requirement for further
+ * binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ * of any contributors may 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
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGES.
+ */
+
+#ifndef __ACUUID_H__
+#define __ACUUID_H__
+
+/*
+ * Note1: UUIDs and GUIDs are defined to be identical in ACPI.
+ *
+ * Note2: This file is standalone and should remain that way.
+ */
+
+/* NFIT/NVDIMM */
+
+#define UUID_VOLATILE_MEMORY "4F940573-DAFD-E344-B16C-3F22D252E5D0"
+#define UUID_PERSISTENT_MEMORY "79D3F066-F3B4-7440-AC43-0D3318B78CDB"
+#define UUID_CONTROL_REGION "F601F792-B413-5D40-910B-299367E8234C"
+#define UUID_DATA_REGION "3005AF91-865D-0E47-A6B0-0A2DB9408249"
+#define UUID_VOLATILE_VIRTUAL_DISK "5A53AB77-FC45-4B62-5560-F7B281D1F96E"
+#define UUID_VOLATILE_VIRTUAL_CD "30BD5A3D-7541-CE87-6D64-D2ADE523C4BB"
+#define UUID_PERSISTENT_VIRTUAL_DISK "C902EA5C-074D-69D3-269F-4496FBE096F9"
+#define UUID_PERSISTENT_VIRTUAL_CD "88810108-CD42-48BB-100F-5387D53DED3D"
+
+#endif /* __AUUID_H__ */
diff --git a/sys/contrib/dev/acpica/include/platform/acenv.h b/sys/contrib/dev/acpica/include/platform/acenv.h
index f5f3b1a..88b1ffc 100644
--- a/sys/contrib/dev/acpica/include/platform/acenv.h
+++ b/sys/contrib/dev/acpica/include/platform/acenv.h
@@ -175,6 +175,9 @@
#elif defined(_APPLE) || defined(__APPLE__)
#include "acmacosx.h"
+#elif defined(__DragonFly__)
+#include "acdragonfly.h"
+
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include <contrib/dev/acpica/include/platform/acfreebsd.h>
diff --git a/sys/contrib/dev/acpica/include/platform/acenvex.h b/sys/contrib/dev/acpica/include/platform/acenvex.h
index d08d03b..6e1130e 100644
--- a/sys/contrib/dev/acpica/include/platform/acenvex.h
+++ b/sys/contrib/dev/acpica/include/platform/acenvex.h
@@ -56,6 +56,9 @@
#if defined(_LINUX) || defined(__linux__)
#include "aclinuxex.h"
+#elif defined(__DragonFly__)
+#include "acdragonflyex.h"
+
#endif
/*! [End] no source code translation !*/
diff --git a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c
index 9028ab7..c8d2b51 100644
--- a/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c
+++ b/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_eeprom.c
@@ -4476,8 +4476,16 @@ HAL_BOOL ar9300_tuning_caps_apply(struct ath_hal *ah)
if ((eep->base_eep_header.feature_enable & 0x40) >> 6) {
tuning_caps_params &= 0x7f;
- if (AR_SREV_HORNET(ah) || AR_SREV_POSEIDON(ah) || AR_SREV_WASP(ah)) {
+ /* XXX TODO: ath9k skips it for Wasp and Honeybee/AR9531, not Poseidon */
+ if (AR_SREV_POSEIDON(ah) || AR_SREV_WASP(ah)) {
return AH_TRUE;
+ } else if (AR_SREV_HORNET(ah)) {
+ OS_REG_RMW_FIELD(ah,
+ AR_HORNET_CH0_XTAL, AR_OSPREY_CHO_XTAL_CAPINDAC,
+ tuning_caps_params);
+ OS_REG_RMW_FIELD(ah,
+ AR_HORNET_CH0_XTAL, AR_OSPREY_CHO_XTAL_CAPOUTDAC,
+ tuning_caps_params);
} else if (AR_SREV_SCORPION(ah)) {
OS_REG_RMW_FIELD(ah,
AR_SCORPION_CH0_XTAL, AR_OSPREY_CHO_XTAL_CAPINDAC,
diff --git a/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c b/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
index 3bb46cf..93ea572 100644
--- a/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
+++ b/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
@@ -189,7 +189,7 @@ ipf_timer_func(arg)
#if 0
softc->ipf_slow_ch = timeout(ipf_timer_func, softc, hz/2);
#endif
- callout_init(&softc->ipf_slow_ch, CALLOUT_MPSAFE);
+ callout_init(&softc->ipf_slow_ch, 1);
callout_reset(&softc->ipf_slow_ch,
(hz / IPF_HZ_DIVIDE) * IPF_HZ_MULT,
ipf_timer_func, softc);
@@ -235,7 +235,7 @@ ipfattach(softc)
softc->ipf_slow_ch = timeout(ipf_timer_func, softc,
(hz / IPF_HZ_DIVIDE) * IPF_HZ_MULT);
#endif
- callout_init(&softc->ipf_slow_ch, CALLOUT_MPSAFE);
+ callout_init(&softc->ipf_slow_ch, 1);
callout_reset(&softc->ipf_slow_ch, (hz / IPF_HZ_DIVIDE) * IPF_HZ_MULT,
ipf_timer_func, softc);
return 0;
diff --git a/sys/contrib/vchiq/interface/compat/vchi_bsd.c b/sys/contrib/vchiq/interface/compat/vchi_bsd.c
index 31170bc..3d939b1 100644
--- a/sys/contrib/vchiq/interface/compat/vchi_bsd.c
+++ b/sys/contrib/vchiq/interface/compat/vchi_bsd.c
@@ -80,7 +80,7 @@ void
init_timer(struct timer_list *t)
{
mtx_init(&t->mtx, "dahdi timer lock", NULL, MTX_SPIN);
- callout_init(&t->callout, CALLOUT_MPSAFE);
+ callout_init(&t->callout, 1);
t->expires = 0;
/*
* function and data are not initialized intentionally:
diff --git a/sys/ddb/db_access.c b/sys/ddb/db_access.c
index 415faa1..7001e72 100644
--- a/sys/ddb/db_access.c
+++ b/sys/ddb/db_access.c
@@ -54,7 +54,7 @@ static unsigned db_extend[] = { /* table for sign-extending */
#endif
db_expr_t
-db_get_value(db_addr_t addr, int size, boolean_t is_signed)
+db_get_value(db_addr_t addr, int size, bool is_signed)
{
char data[sizeof(u_int64_t)];
register db_expr_t value;
diff --git a/sys/ddb/db_access.h b/sys/ddb/db_access.h
index 44915e3..2b8ac71 100644
--- a/sys/ddb/db_access.h
+++ b/sys/ddb/db_access.h
@@ -36,7 +36,7 @@
/*
* Data access functions for debugger.
*/
-db_expr_t db_get_value(db_addr_t addr, int size, boolean_t is_signed);
+db_expr_t db_get_value(db_addr_t addr, int size, bool is_signed);
void db_put_value(db_addr_t addr, int size, db_expr_t value);
#endif /* !_DDB_DB_ACCESS_H_ */
diff --git a/sys/ddb/db_break.c b/sys/ddb/db_break.c
index f4c27aa..c882584 100644
--- a/sys/ddb/db_break.c
+++ b/sys/ddb/db_break.c
@@ -155,12 +155,12 @@ db_find_breakpoint_here(db_addr_t addr)
return db_find_breakpoint(db_map_addr(addr), addr);
}
-static boolean_t db_breakpoints_inserted = TRUE;
+static bool db_breakpoints_inserted = true;
#ifndef BKPT_WRITE
#define BKPT_WRITE(addr, storage) \
do { \
- *storage = db_get_value(addr, BKPT_SIZE, FALSE); \
+ *storage = db_get_value(addr, BKPT_SIZE, false); \
db_put_value(addr, BKPT_SIZE, BKPT_SET(*storage)); \
} while (0)
#endif
@@ -183,7 +183,7 @@ db_set_breakpoints(void)
if (db_map_current(bkpt->map)) {
BKPT_WRITE(bkpt->address, &bkpt->bkpt_inst);
}
- db_breakpoints_inserted = TRUE;
+ db_breakpoints_inserted = true;
}
}
@@ -200,7 +200,7 @@ db_clear_breakpoints(void)
if (db_map_current(bkpt->map)) {
BKPT_CLEAR(bkpt->address, &bkpt->bkpt_inst);
}
- db_breakpoints_inserted = FALSE;
+ db_breakpoints_inserted = false;
}
}
@@ -267,7 +267,7 @@ db_list_breakpoints(void)
/* Delete breakpoint */
/*ARGSUSED*/
void
-db_delete_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *modif)
+db_delete_cmd(db_expr_t addr, bool have_addr, db_expr_t count, char *modif)
{
db_delete_breakpoint(db_map_addr(addr), (db_addr_t)addr);
}
@@ -275,8 +275,7 @@ db_delete_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *modif)
/* Set breakpoint with skip count */
/*ARGSUSED*/
void
-db_breakpoint_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
- char *modif)
+db_breakpoint_cmd(db_expr_t addr, bool have_addr, db_expr_t count, char *modif)
{
if (count == -1)
count = 1;
@@ -286,8 +285,7 @@ db_breakpoint_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
/* list breakpoints */
void
-db_listbreak_cmd(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3,
- char *dummy4)
+db_listbreak_cmd(db_expr_t dummy1, bool dummy2, db_expr_t dummy3, char *dummy4)
{
db_list_breakpoints();
}
@@ -298,7 +296,7 @@ db_listbreak_cmd(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3,
* (or both) may be null.
*/
-boolean_t
+bool
db_map_equal(vm_map_t map1, vm_map_t map2)
{
return ((map1 == map2) ||
@@ -306,7 +304,7 @@ db_map_equal(vm_map_t map1, vm_map_t map2)
((map1 == kernel_map) && (map2 == NULL)));
}
-boolean_t
+bool
db_map_current(vm_map_t map)
{
#if 0
@@ -317,7 +315,7 @@ db_map_current(vm_map_t map)
(((thread = current_thread()) != NULL) &&
(map == thread->task->map)));
#else
- return (1);
+ return (true);
#endif
}
diff --git a/sys/ddb/db_capture.c b/sys/ddb/db_capture.c
index 50ae2cf..de958d6 100644
--- a/sys/ddb/db_capture.c
+++ b/sys/ddb/db_capture.c
@@ -331,8 +331,7 @@ db_capture_usage(void)
}
void
-db_capture_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
- char *modif)
+db_capture_cmd(db_expr_t addr, bool have_addr, db_expr_t count, char *modif)
{
int t;
diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c
index 7bed8ae..0d4f28f 100644
--- a/sys/ddb/db_command.c
+++ b/sys/ddb/db_command.c
@@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$");
/*
* Exported global variables
*/
-boolean_t db_cmd_loop_done;
+bool db_cmd_loop_done;
db_addr_t db_dot;
db_addr_t db_last_addr;
db_addr_t db_prev;
@@ -80,67 +80,67 @@ static db_cmdfcn_t db_watchdog;
*/
static struct command db_show_all_cmds[] = {
- { "trace", db_stack_trace_all, 0, 0 },
+ { "trace", db_stack_trace_all, 0, NULL },
};
struct command_table db_show_all_table =
LIST_HEAD_INITIALIZER(db_show_all_table);
static struct command db_show_cmds[] = {
{ "all", 0, 0, &db_show_all_table },
- { "registers", db_show_regs, 0, 0 },
- { "breaks", db_listbreak_cmd, 0, 0 },
- { "threads", db_show_threads, 0, 0 },
+ { "registers", db_show_regs, 0, NULL },
+ { "breaks", db_listbreak_cmd, 0, NULL },
+ { "threads", db_show_threads, 0, NULL },
};
struct command_table db_show_table = LIST_HEAD_INITIALIZER(db_show_table);
static struct command db_cmds[] = {
- { "print", db_print_cmd, 0, 0 },
- { "p", db_print_cmd, 0, 0 },
- { "examine", db_examine_cmd, CS_SET_DOT, 0 },
- { "x", db_examine_cmd, CS_SET_DOT, 0 },
- { "search", db_search_cmd, CS_OWN|CS_SET_DOT, 0 },
- { "set", db_set_cmd, CS_OWN, 0 },
- { "write", db_write_cmd, CS_MORE|CS_SET_DOT, 0 },
- { "w", db_write_cmd, CS_MORE|CS_SET_DOT, 0 },
- { "delete", db_delete_cmd, 0, 0 },
- { "d", db_delete_cmd, 0, 0 },
- { "dump", db_dump, 0, 0 },
- { "break", db_breakpoint_cmd, 0, 0 },
- { "b", db_breakpoint_cmd, 0, 0 },
- { "dwatch", db_deletewatch_cmd, 0, 0 },
- { "watch", db_watchpoint_cmd, CS_MORE,0 },
- { "dhwatch", db_deletehwatch_cmd, 0, 0 },
- { "hwatch", db_hwatchpoint_cmd, 0, 0 },
- { "step", db_single_step_cmd, 0, 0 },
- { "s", db_single_step_cmd, 0, 0 },
- { "continue", db_continue_cmd, 0, 0 },
- { "c", db_continue_cmd, 0, 0 },
- { "until", db_trace_until_call_cmd,0, 0 },
- { "next", db_trace_until_matching_cmd,0, 0 },
- { "match", db_trace_until_matching_cmd,0, 0 },
- { "trace", db_stack_trace, CS_OWN, 0 },
- { "t", db_stack_trace, CS_OWN, 0 },
+ { "print", db_print_cmd, 0, NULL },
+ { "p", db_print_cmd, 0, NULL },
+ { "examine", db_examine_cmd, CS_SET_DOT, NULL },
+ { "x", db_examine_cmd, CS_SET_DOT, NULL },
+ { "search", db_search_cmd, CS_OWN|CS_SET_DOT, NULL },
+ { "set", db_set_cmd, CS_OWN, NULL },
+ { "write", db_write_cmd, CS_MORE|CS_SET_DOT, NULL },
+ { "w", db_write_cmd, CS_MORE|CS_SET_DOT, NULL },
+ { "delete", db_delete_cmd, 0, NULL },
+ { "d", db_delete_cmd, 0, NULL },
+ { "dump", db_dump, 0, NULL },
+ { "break", db_breakpoint_cmd, 0, NULL },
+ { "b", db_breakpoint_cmd, 0, NULL },
+ { "dwatch", db_deletewatch_cmd, 0, NULL },
+ { "watch", db_watchpoint_cmd, CS_MORE,NULL },
+ { "dhwatch", db_deletehwatch_cmd, 0, NULL },
+ { "hwatch", db_hwatchpoint_cmd, 0, NULL },
+ { "step", db_single_step_cmd, 0, NULL },
+ { "s", db_single_step_cmd, 0, NULL },
+ { "continue", db_continue_cmd, 0, NULL },
+ { "c", db_continue_cmd, 0, NULL },
+ { "until", db_trace_until_call_cmd,0, NULL },
+ { "next", db_trace_until_matching_cmd,0, NULL },
+ { "match", db_trace_until_matching_cmd,0, NULL },
+ { "trace", db_stack_trace, CS_OWN, NULL },
+ { "t", db_stack_trace, CS_OWN, NULL },
/* XXX alias for all trace */
- { "alltrace", db_stack_trace_all, 0, 0 },
- { "where", db_stack_trace, CS_OWN, 0 },
- { "bt", db_stack_trace, CS_OWN, 0 },
- { "call", db_fncall, CS_OWN, 0 },
+ { "alltrace", db_stack_trace_all, 0, NULL },
+ { "where", db_stack_trace, CS_OWN, NULL },
+ { "bt", db_stack_trace, CS_OWN, NULL },
+ { "call", db_fncall, CS_OWN, NULL },
{ "show", 0, 0, &db_show_table },
- { "ps", db_ps, 0, 0 },
- { "gdb", db_gdb, 0, 0 },
- { "halt", db_halt, 0, 0 },
- { "reboot", db_reset, 0, 0 },
- { "reset", db_reset, 0, 0 },
- { "kill", db_kill, CS_OWN, 0 },
- { "watchdog", db_watchdog, CS_OWN, 0 },
- { "thread", db_set_thread, CS_OWN, 0 },
- { "run", db_run_cmd, CS_OWN, 0 },
- { "script", db_script_cmd, CS_OWN, 0 },
- { "scripts", db_scripts_cmd, 0, 0 },
- { "unscript", db_unscript_cmd, CS_OWN, 0 },
- { "capture", db_capture_cmd, CS_OWN, 0 },
- { "textdump", db_textdump_cmd, CS_OWN, 0 },
- { "findstack", db_findstack_cmd, 0, 0 },
+ { "ps", db_ps, 0, NULL },
+ { "gdb", db_gdb, 0, NULL },
+ { "halt", db_halt, 0, NULL },
+ { "reboot", db_reset, 0, NULL },
+ { "reset", db_reset, 0, NULL },
+ { "kill", db_kill, CS_OWN, NULL },
+ { "watchdog", db_watchdog, CS_OWN, NULL },
+ { "thread", db_set_thread, CS_OWN, NULL },
+ { "run", db_run_cmd, CS_OWN, NULL },
+ { "script", db_script_cmd, CS_OWN, NULL },
+ { "scripts", db_scripts_cmd, 0, NULL },
+ { "unscript", db_unscript_cmd, CS_OWN, NULL },
+ { "capture", db_capture_cmd, CS_OWN, NULL },
+ { "textdump", db_textdump_cmd, CS_OWN, NULL },
+ { "findstack", db_findstack_cmd, 0, NULL },
};
struct command_table db_cmd_table = LIST_HEAD_INITIALIZER(db_cmd_table);
@@ -151,7 +151,7 @@ static struct command *db_last_command = 0;
* and '+' points to next line.
* Otherwise: 'dot' points to next item, '..' points to last.
*/
-static boolean_t db_ed_style = TRUE;
+static bool db_ed_style = true;
/*
* Utility routine - discard tokens through end-of-line.
@@ -311,7 +311,7 @@ db_cmd_search(char *name, struct command_table *table, struct command **cmdp)
static void
db_cmd_list(struct command_table *table)
{
- register struct command *cmd;
+ struct command *cmd;
LIST_FOREACH(cmd, table, next) {
db_printf("%-16s", cmd->name);
@@ -327,7 +327,7 @@ db_command(struct command **last_cmdp, struct command_table *cmd_table,
int t;
char modif[TOK_STRING_SIZE];
db_expr_t addr, count;
- boolean_t have_addr = FALSE;
+ bool have_addr = false;
int result;
t = db_read_token();
@@ -335,12 +335,12 @@ db_command(struct command **last_cmdp, struct command_table *cmd_table,
/* empty line repeats last command, at 'next' */
cmd = *last_cmdp;
addr = (db_expr_t)db_next;
- have_addr = FALSE;
+ have_addr = false;
count = 1;
modif[0] = '\0';
}
else if (t == tEXCL) {
- db_fncall((db_expr_t)0, (boolean_t)0, (db_expr_t)0, (char *)0);
+ db_fncall((db_expr_t)0, (bool)false, (db_expr_t)0, (char *)0);
return;
}
else if (t != tIDENT) {
@@ -405,11 +405,11 @@ db_command(struct command **last_cmdp, struct command_table *cmd_table,
if (db_expression(&addr)) {
db_dot = (db_addr_t) addr;
db_last_addr = db_dot;
- have_addr = TRUE;
+ have_addr = true;
}
else {
addr = (db_expr_t) db_dot;
- have_addr = FALSE;
+ have_addr = false;
}
t = db_read_token();
if (t == tCOMMA) {
@@ -521,7 +521,7 @@ db_error(const char *s)
}
static void
-db_dump(db_expr_t dummy, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
+db_dump(db_expr_t dummy, bool dummy2, db_expr_t dummy3, char *dummy4)
{
int error;
@@ -530,7 +530,7 @@ db_dump(db_expr_t dummy, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
"run \"textdump unset\" first or \"textdump dump\" for a textdump.\n");
return;
}
- error = doadump(FALSE);
+ error = doadump(false);
if (error) {
db_printf("Cannot dump: ");
switch (error) {
@@ -571,7 +571,7 @@ db_fncall_generic(db_expr_t addr, db_expr_t *rv, int nargs, db_expr_t args[])
}
static void
-db_fncall(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
+db_fncall(db_expr_t dummy1, bool dummy2, db_expr_t dummy3, char *dummy4)
{
db_expr_t fn_addr;
db_expr_t args[DB_MAXARGS];
@@ -618,14 +618,14 @@ db_fncall(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
}
static void
-db_halt(db_expr_t dummy, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
+db_halt(db_expr_t dummy, bool dummy2, db_expr_t dummy3, char *dummy4)
{
cpu_halt();
}
static void
-db_kill(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
+db_kill(db_expr_t dummy1, bool dummy2, db_expr_t dummy3, char *dummy4)
{
db_expr_t old_radix, pid, sig;
struct proc *p;
@@ -684,7 +684,7 @@ out:
#endif
static void
-db_reset(db_expr_t addr, boolean_t have_addr, db_expr_t count __unused,
+db_reset(db_expr_t addr, bool have_addr, db_expr_t count __unused,
char *modif __unused)
{
int delay, loop;
@@ -714,7 +714,7 @@ db_reset(db_expr_t addr, boolean_t have_addr, db_expr_t count __unused,
}
static void
-db_watchdog(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
+db_watchdog(db_expr_t dummy1, bool dummy2, db_expr_t dummy3, char *dummy4)
{
db_expr_t old_radix, tout;
int err, i;
@@ -737,7 +737,7 @@ db_watchdog(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
}
static void
-db_gdb(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
+db_gdb(db_expr_t dummy1, bool dummy2, db_expr_t dummy3, char *dummy4)
{
if (kdb_dbbe_select("gdb") != 0) {
@@ -753,7 +753,7 @@ db_gdb(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
}
static void
-db_stack_trace(db_expr_t tid, boolean_t hastid, db_expr_t count, char *modif)
+db_stack_trace(db_expr_t tid, bool hastid, db_expr_t count, char *modif)
{
struct thread *td;
db_expr_t radix;
@@ -799,7 +799,7 @@ db_stack_trace(db_expr_t tid, boolean_t hastid, db_expr_t count, char *modif)
}
static void
-db_stack_trace_all(db_expr_t dummy, boolean_t dummy2, db_expr_t dummy3,
+db_stack_trace_all(db_expr_t dummy, bool dummy2, db_expr_t dummy3,
char *dummy4)
{
struct proc *p;
diff --git a/sys/ddb/db_examine.c b/sys/ddb/db_examine.c
index f10df12..d4c5ed4 100644
--- a/sys/ddb/db_examine.c
+++ b/sys/ddb/db_examine.c
@@ -52,8 +52,7 @@ static void db_search(db_addr_t, int, db_expr_t, db_expr_t, u_int);
*/
/*ARGSUSED*/
void
-db_examine_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
- char *modif)
+db_examine_cmd(db_expr_t addr, bool have_addr, db_expr_t count, char *modif)
{
if (modif[0] != '\0')
db_strcpy(db_examine_format, modif);
@@ -110,37 +109,37 @@ db_examine(db_addr_t addr, char *fmt, int count)
width = size * 4;
switch (c) {
case 'r': /* signed, current radix */
- value = db_get_value(addr, size, TRUE);
+ value = db_get_value(addr, size, true);
addr += size;
db_printf("%+-*lr", width, (long)value);
break;
case 'x': /* unsigned hex */
- value = db_get_value(addr, size, FALSE);
+ value = db_get_value(addr, size, false);
addr += size;
db_printf("%-*lx", width, (long)value);
break;
case 'z': /* signed hex */
- value = db_get_value(addr, size, TRUE);
+ value = db_get_value(addr, size, true);
addr += size;
db_printf("%-*ly", width, (long)value);
break;
case 'd': /* signed decimal */
- value = db_get_value(addr, size, TRUE);
+ value = db_get_value(addr, size, true);
addr += size;
db_printf("%-*ld", width, (long)value);
break;
case 'u': /* unsigned decimal */
- value = db_get_value(addr, size, FALSE);
+ value = db_get_value(addr, size, false);
addr += size;
db_printf("%-*lu", width, (long)value);
break;
case 'o': /* unsigned octal */
- value = db_get_value(addr, size, FALSE);
+ value = db_get_value(addr, size, false);
addr += size;
db_printf("%-*lo", width, (long)value);
break;
case 'c': /* character */
- value = db_get_value(addr, 1, FALSE);
+ value = db_get_value(addr, 1, false);
addr += 1;
if (value >= ' ' && value <= '~')
db_printf("%c", (int)value);
@@ -149,7 +148,7 @@ db_examine(db_addr_t addr, char *fmt, int count)
break;
case 's': /* null-terminated string */
for (;;) {
- value = db_get_value(addr, 1, FALSE);
+ value = db_get_value(addr, 1, false);
addr += 1;
if (value == 0)
break;
@@ -161,15 +160,15 @@ db_examine(db_addr_t addr, char *fmt, int count)
break;
case 'S': /* symbol */
value = db_get_value(addr, sizeof(void *),
- FALSE);
+ false);
addr += sizeof(void *);
db_printsym(value, DB_STGY_ANY);
break;
case 'i': /* instruction */
- addr = db_disasm(addr, FALSE);
+ addr = db_disasm(addr, false);
break;
case 'I': /* instruction, alternate form */
- addr = db_disasm(addr, TRUE);
+ addr = db_disasm(addr, true);
break;
default:
break;
@@ -190,8 +189,7 @@ static char db_print_format = 'x';
/*ARGSUSED*/
void
-db_print_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
- char *modif)
+db_print_cmd(db_expr_t addr, bool have_addr, db_expr_t count, char *modif)
{
db_expr_t value;
@@ -236,7 +234,7 @@ db_print_loc_and_inst(db_addr_t loc)
{
db_printsym(loc, DB_STGY_PROC);
db_printf(":\t");
- (void) db_disasm(loc, TRUE);
+ (void) db_disasm(loc, true);
}
/*
@@ -244,8 +242,7 @@ db_print_loc_and_inst(db_addr_t loc)
* Syntax: search [/bhl] addr value [mask] [,count]
*/
void
-db_search_cmd(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3,
- char *dummy4)
+db_search_cmd(db_expr_t dummy1, bool dummy2, db_expr_t dummy3, char *dummy4)
{
int t;
db_addr_t addr;
@@ -314,7 +311,7 @@ db_search(db_addr_t addr, int size, db_expr_t value, db_expr_t mask,
{
while (count-- != 0) {
db_prev = addr;
- if ((db_get_value(addr, size, FALSE) & mask) == value)
+ if ((db_get_value(addr, size, false) & mask) == value)
break;
addr += size;
}
diff --git a/sys/ddb/db_expr.c b/sys/ddb/db_expr.c
index 424384c..9a568a4 100644
--- a/sys/ddb/db_expr.c
+++ b/sys/ddb/db_expr.c
@@ -38,13 +38,13 @@ __FBSDID("$FreeBSD$");
#include <ddb/db_access.h>
#include <ddb/db_command.h>
-static boolean_t db_add_expr(db_expr_t *valuep);
-static boolean_t db_mult_expr(db_expr_t *valuep);
-static boolean_t db_shift_expr(db_expr_t *valuep);
-static boolean_t db_term(db_expr_t *valuep);
-static boolean_t db_unary(db_expr_t *valuep);
+static bool db_add_expr(db_expr_t *valuep);
+static bool db_mult_expr(db_expr_t *valuep);
+static bool db_shift_expr(db_expr_t *valuep);
+static bool db_term(db_expr_t *valuep);
+static bool db_unary(db_expr_t *valuep);
-static boolean_t
+static bool
db_term(db_expr_t *valuep)
{
int t;
@@ -57,32 +57,32 @@ db_term(db_expr_t *valuep)
db_error("Symbol not found\n");
/*NOTREACHED*/
}
- return (TRUE);
+ return (true);
}
if (t == tNUMBER) {
*valuep = (db_expr_t)db_tok_number;
- return (TRUE);
+ return (true);
}
if (t == tDOT) {
*valuep = (db_expr_t)db_dot;
- return (TRUE);
+ return (true);
}
if (t == tDOTDOT) {
*valuep = (db_expr_t)db_prev;
- return (TRUE);
+ return (true);
}
if (t == tPLUS) {
*valuep = (db_expr_t) db_next;
- return (TRUE);
+ return (true);
}
if (t == tDITTO) {
*valuep = (db_expr_t)db_last_addr;
- return (TRUE);
+ return (true);
}
if (t == tDOLLAR) {
if (!db_get_variable(valuep))
- return (FALSE);
- return (TRUE);
+ return (false);
+ return (true);
}
if (t == tLPAREN) {
if (!db_expression(valuep)) {
@@ -94,13 +94,13 @@ db_term(db_expr_t *valuep)
db_error("Syntax error\n");
/*NOTREACHED*/
}
- return (TRUE);
+ return (true);
}
db_unread_token(t);
- return (FALSE);
+ return (false);
}
-static boolean_t
+static bool
db_unary(db_expr_t *valuep)
{
int t;
@@ -112,7 +112,7 @@ db_unary(db_expr_t *valuep)
/*NOTREACHED*/
}
*valuep = -*valuep;
- return (TRUE);
+ return (true);
}
if (t == tSTAR) {
/* indirection */
@@ -120,21 +120,21 @@ db_unary(db_expr_t *valuep)
db_error("Syntax error\n");
/*NOTREACHED*/
}
- *valuep = db_get_value((db_addr_t)*valuep, sizeof(void *), FALSE);
- return (TRUE);
+ *valuep = db_get_value((db_addr_t)*valuep, sizeof(void *), false);
+ return (true);
}
db_unread_token(t);
return (db_term(valuep));
}
-static boolean_t
+static bool
db_mult_expr(db_expr_t *valuep)
{
db_expr_t lhs, rhs;
int t;
if (!db_unary(&lhs))
- return (FALSE);
+ return (false);
t = db_read_token();
while (t == tSTAR || t == tSLASH || t == tPCT || t == tHASH) {
@@ -160,17 +160,17 @@ db_mult_expr(db_expr_t *valuep)
}
db_unread_token(t);
*valuep = lhs;
- return (TRUE);
+ return (true);
}
-static boolean_t
+static bool
db_add_expr(db_expr_t *valuep)
{
db_expr_t lhs, rhs;
int t;
if (!db_mult_expr(&lhs))
- return (FALSE);
+ return (false);
t = db_read_token();
while (t == tPLUS || t == tMINUS) {
@@ -186,17 +186,17 @@ db_add_expr(db_expr_t *valuep)
}
db_unread_token(t);
*valuep = lhs;
- return (TRUE);
+ return (true);
}
-static boolean_t
+static bool
db_shift_expr(db_expr_t *valuep)
{
db_expr_t lhs, rhs;
int t;
if (!db_add_expr(&lhs))
- return (FALSE);
+ return (false);
t = db_read_token();
while (t == tSHIFT_L || t == tSHIFT_R) {
@@ -218,7 +218,7 @@ db_shift_expr(db_expr_t *valuep)
}
db_unread_token(t);
*valuep = lhs;
- return (TRUE);
+ return (true);
}
int
diff --git a/sys/ddb/db_input.c b/sys/ddb/db_input.c
index 327f490..a2a7b38 100644
--- a/sys/ddb/db_input.c
+++ b/sys/ddb/db_input.c
@@ -97,7 +97,7 @@ db_delete(n, bwd)
int n;
int bwd;
{
- register char *p;
+ char *p;
if (bwd) {
db_lc -= n;
@@ -112,7 +112,7 @@ db_delete(n, bwd)
db_le -= n;
}
-/* returns TRUE at end-of-line */
+/* returns true at end-of-line */
static int
db_inputchar(c)
int c;
@@ -276,7 +276,7 @@ db_inputchar(c)
cnputc('\007');
}
else if (c >= ' ' && c <= '~') {
- register char *p;
+ char *p;
for (p = db_le; p > db_lc; p--)
*p = *(p-1);
@@ -348,7 +348,7 @@ db_readline(lstart, lsize)
void
db_check_interrupt(void)
{
- register int c;
+ int c;
c = cnmaygetc();
switch (c) {
diff --git a/sys/ddb/db_main.c b/sys/ddb/db_main.c
index bee321c..5ef6962 100644
--- a/sys/ddb/db_main.c
+++ b/sys/ddb/db_main.c
@@ -63,11 +63,11 @@ KDB_BACKEND(ddb, db_init, db_trace_self_wrapper, db_trace_thread_wrapper,
*/
vm_offset_t ksymtab, kstrtab, ksymtab_size;
-boolean_t
+bool
X_db_line_at_pc(db_symtab_t *symtab, c_db_sym_t sym, char **file, int *line,
db_expr_t off)
{
- return (FALSE);
+ return (false);
}
c_db_sym_t
@@ -145,11 +145,11 @@ X_db_search_symbol(db_symtab_t *symtab, db_addr_t off, db_strategy_t strat,
return ((c_db_sym_t)match);
}
-boolean_t
+bool
X_db_sym_numargs(db_symtab_t *symtab, c_db_sym_t sym, int *nargp,
char **argp)
{
- return (FALSE);
+ return (false);
}
void
@@ -216,7 +216,7 @@ db_trap(int type, int code)
{
jmp_buf jb;
void *prev_jb;
- boolean_t bkpt, watchpt;
+ bool bkpt, watchpt;
const char *why;
/*
diff --git a/sys/ddb/db_print.c b/sys/ddb/db_print.c
index 9e45456..95550d15 100644
--- a/sys/ddb/db_print.c
+++ b/sys/ddb/db_print.c
@@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$");
#include <ddb/db_sym.h>
void
-db_show_regs(db_expr_t _1, boolean_t _2, db_expr_t _3, char *_4)
+db_show_regs(db_expr_t _1, bool _2, db_expr_t _3, char *_4)
{
struct db_variable *regp;
db_expr_t value, offset;
diff --git a/sys/ddb/db_ps.c b/sys/ddb/db_ps.c
index d28a060..3fc7afe 100644
--- a/sys/ddb/db_ps.c
+++ b/sys/ddb/db_ps.c
@@ -75,7 +75,7 @@ DB_SHOW_ALL_COMMAND(procs, db_procs_cmd)
* characters.
*/
void
-db_ps(db_expr_t addr, boolean_t hasaddr, db_expr_t count, char *modif)
+db_ps(db_expr_t addr, bool hasaddr, db_expr_t count, char *modif)
{
volatile struct proc *p, *pp;
volatile struct thread *td;
@@ -299,11 +299,11 @@ DB_SHOW_COMMAND(thread, db_show_thread)
{
struct thread *td;
struct lock_object *lock;
- boolean_t comma;
+ bool comma;
/* Determine which thread to examine. */
if (have_addr)
- td = db_lookup_thread(addr, FALSE);
+ td = db_lookup_thread(addr, false);
else
td = kdb_thread;
lock = (struct lock_object *)td->td_lock;
@@ -332,28 +332,28 @@ DB_SHOW_COMMAND(thread, db_show_thread)
break;
case TDS_INHIBITED:
db_printf("INHIBITED: {");
- comma = FALSE;
+ comma = false;
if (TD_IS_SLEEPING(td)) {
db_printf("SLEEPING");
- comma = TRUE;
+ comma = true;
}
if (TD_IS_SUSPENDED(td)) {
if (comma)
db_printf(", ");
db_printf("SUSPENDED");
- comma = TRUE;
+ comma = true;
}
if (TD_IS_SWAPPED(td)) {
if (comma)
db_printf(", ");
db_printf("SWAPPED");
- comma = TRUE;
+ comma = true;
}
if (TD_ON_LOCK(td)) {
if (comma)
db_printf(", ");
db_printf("LOCK");
- comma = TRUE;
+ comma = true;
}
if (TD_AWAITING_INTR(td)) {
if (comma)
@@ -432,8 +432,8 @@ DB_SHOW_COMMAND(proc, db_show_proc)
}
void
-db_findstack_cmd(db_expr_t addr, boolean_t have_addr,
- db_expr_t dummy3 __unused, char *dummy4 __unused)
+db_findstack_cmd(db_expr_t addr, bool have_addr, db_expr_t dummy3 __unused,
+ char *dummy4 __unused)
{
struct proc *p;
struct thread *td;
diff --git a/sys/ddb/db_run.c b/sys/ddb/db_run.c
index 406b9dd..026a9b6 100644
--- a/sys/ddb/db_run.c
+++ b/sys/ddb/db_run.c
@@ -57,7 +57,7 @@ static int db_run_mode;
#define STEP_INVISIBLE 5
#define STEP_COUNT 6
-static boolean_t db_sstep_print;
+static bool db_sstep_print;
static int db_loop_count;
static int db_call_depth;
@@ -77,17 +77,17 @@ db_breakpoint_t db_not_taken_bkpt = 0;
db_breakpoint_t db_taken_bkpt = 0;
#endif
-boolean_t
-db_stop_at_pc(boolean_t *is_breakpoint)
+bool
+db_stop_at_pc(bool *is_breakpoint)
{
- register db_addr_t pc;
- register db_breakpoint_t bkpt;
+ db_addr_t pc;
+ db_breakpoint_t bkpt;
pc = PC_REGS();
#ifdef SOFTWARE_SSTEP
if ((db_not_taken_bkpt != 0 && pc == db_not_taken_bkpt->address)
|| (db_taken_bkpt != 0 && pc == db_taken_bkpt->address))
- *is_breakpoint = FALSE;
+ *is_breakpoint = false;
#endif
db_clear_single_step();
@@ -112,8 +112,8 @@ db_stop_at_pc(boolean_t *is_breakpoint)
if (bkpt) {
if (--bkpt->count == 0) {
bkpt->count = bkpt->init_count;
- *is_breakpoint = TRUE;
- return (TRUE); /* stop here */
+ *is_breakpoint = true;
+ return (true); /* stop here */
}
} else if (*is_breakpoint) {
#ifdef BKPT_SKIP
@@ -121,14 +121,14 @@ db_stop_at_pc(boolean_t *is_breakpoint)
#endif
}
- *is_breakpoint = FALSE;
+ *is_breakpoint = false;
if (db_run_mode == STEP_INVISIBLE) {
db_run_mode = STEP_CONTINUE;
- return (FALSE); /* continue */
+ return (false); /* continue */
}
if (db_run_mode == STEP_COUNT) {
- return (FALSE); /* continue */
+ return (false); /* continue */
}
if (db_run_mode == STEP_ONCE) {
if (--db_loop_count > 0) {
@@ -137,19 +137,19 @@ db_stop_at_pc(boolean_t *is_breakpoint)
db_print_loc_and_inst(pc);
db_printf("\n");
}
- return (FALSE); /* continue */
+ return (false); /* continue */
}
}
if (db_run_mode == STEP_RETURN) {
/* continue until matching return */
db_expr_t ins;
- ins = db_get_value(pc, sizeof(int), FALSE);
+ ins = db_get_value(pc, sizeof(int), false);
if (!inst_trap_return(ins) &&
(!inst_return(ins) || --db_call_depth != 0)) {
if (db_sstep_print) {
if (inst_call(ins) || inst_return(ins)) {
- register int i;
+ int i;
db_printf("[after %6d] ", db_inst_count);
for (i = db_call_depth; --i > 0; )
@@ -160,28 +160,28 @@ db_stop_at_pc(boolean_t *is_breakpoint)
}
if (inst_call(ins))
db_call_depth++;
- return (FALSE); /* continue */
+ return (false); /* continue */
}
}
if (db_run_mode == STEP_CALLT) {
/* continue until call or return */
db_expr_t ins;
- ins = db_get_value(pc, sizeof(int), FALSE);
+ ins = db_get_value(pc, sizeof(int), false);
if (!inst_call(ins) &&
!inst_return(ins) &&
!inst_trap_return(ins)) {
- return (FALSE); /* continue */
+ return (false); /* continue */
}
}
db_run_mode = STEP_NONE;
- return (TRUE);
+ return (true);
}
void
-db_restart_at_pc(boolean_t watchpt)
+db_restart_at_pc(bool watchpt)
{
- register db_addr_t pc = PC_REGS();
+ db_addr_t pc = PC_REGS();
if ((db_run_mode == STEP_COUNT) ||
(db_run_mode == STEP_RETURN) ||
@@ -193,7 +193,7 @@ db_restart_at_pc(boolean_t watchpt)
#ifdef SOFTWARE_SSTEP
db_expr_t ins =
#endif
- db_get_value(pc, sizeof(int), FALSE);
+ db_get_value(pc, sizeof(int), false);
db_inst_count++;
db_load_count += inst_load(ins);
db_store_count += inst_store(ins);
@@ -201,7 +201,7 @@ db_restart_at_pc(boolean_t watchpt)
/* XXX works on mips, but... */
if (inst_branch(ins) || inst_call(ins)) {
ins = db_get_value(next_instr_address(pc,1),
- sizeof(int), FALSE);
+ sizeof(int), false);
db_inst_count++;
db_load_count += inst_load(ins);
db_store_count += inst_store(ins);
@@ -234,7 +234,7 @@ db_restart_at_pc(boolean_t watchpt)
* Just define the above conditional and provide
* the functions/macros defined below.
*
- * extern boolean_t
+ * extern bool
* inst_branch(), returns true if the instruction might branch
* extern unsigned
* branch_taken(), return the address the instruction might
@@ -266,7 +266,7 @@ db_set_single_step(void)
* User was stopped at pc, e.g. the instruction
* at pc was not executed.
*/
- inst = db_get_value(pc, sizeof(int), FALSE);
+ inst = db_get_value(pc, sizeof(int), false);
if (inst_branch(inst) || inst_call(inst) || inst_return(inst)) {
brpc = branch_taken(inst, pc);
if (brpc != pc) { /* self-branches are hopeless */
@@ -299,19 +299,15 @@ extern int db_cmd_loop_done;
/* single-step */
/*ARGSUSED*/
void
-db_single_step_cmd(addr, have_addr, count, modif)
- db_expr_t addr;
- boolean_t have_addr;
- db_expr_t count;
- char * modif;
+db_single_step_cmd(db_expr_t addr, bool have_addr, db_expr_t count, char *modif)
{
- boolean_t print = FALSE;
+ bool print = false;
if (count == -1)
count = 1;
if (modif[0] == 'p')
- print = TRUE;
+ print = true;
db_run_mode = STEP_ONCE;
db_loop_count = count;
@@ -326,13 +322,13 @@ db_single_step_cmd(addr, have_addr, count, modif)
/* trace and print until call/return */
/*ARGSUSED*/
void
-db_trace_until_call_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
+db_trace_until_call_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
char *modif)
{
- boolean_t print = FALSE;
+ bool print = false;
if (modif[0] == 'p')
- print = TRUE;
+ print = true;
db_run_mode = STEP_CALLT;
db_sstep_print = print;
@@ -345,13 +341,13 @@ db_trace_until_call_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
/*ARGSUSED*/
void
-db_trace_until_matching_cmd(db_expr_t addr, boolean_t have_addr,
- db_expr_t count, char *modif)
+db_trace_until_matching_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
+ char *modif)
{
- boolean_t print = FALSE;
+ bool print = false;
if (modif[0] == 'p')
- print = TRUE;
+ print = true;
db_run_mode = STEP_RETURN;
db_call_depth = 1;
@@ -366,8 +362,7 @@ db_trace_until_matching_cmd(db_expr_t addr, boolean_t have_addr,
/* continue */
/*ARGSUSED*/
void
-db_continue_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
- char *modif)
+db_continue_cmd(db_expr_t addr, bool have_addr, db_expr_t count, char *modif)
{
if (modif[0] == 'c')
db_run_mode = STEP_COUNT;
diff --git a/sys/ddb/db_script.c b/sys/ddb/db_script.c
index 34215f8..f84dfb9 100644
--- a/sys/ddb/db_script.c
+++ b/sys/ddb/db_script.c
@@ -339,7 +339,7 @@ db_script_kdbenter(const char *eventname)
* List scripts and their contents.
*/
void
-db_scripts_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
+db_scripts_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
char *modif)
{
int i;
@@ -357,7 +357,7 @@ db_scripts_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
* Execute a script.
*/
void
-db_run_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *modif)
+db_run_cmd(db_expr_t addr, bool have_addr, db_expr_t count, char *modif)
{
int t;
@@ -381,7 +381,7 @@ db_run_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *modif)
* we do not wish to use db_lex's token processing.
*/
void
-db_script_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
+db_script_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
char *modif)
{
char *buf, scriptname[DB_MAXSCRIPTNAME];
@@ -427,7 +427,7 @@ db_script_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
* Remove a named script.
*/
void
-db_unscript_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
+db_unscript_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
char *modif)
{
int error, t;
diff --git a/sys/ddb/db_sym.c b/sys/ddb/db_sym.c
index ff6889e..8386c64 100644
--- a/sys/ddb/db_sym.c
+++ b/sys/ddb/db_sym.c
@@ -58,8 +58,8 @@ static db_symtab_t *db_last_symtab; /* where last symbol was found */
static c_db_sym_t db_lookup( const char *symstr);
static char *db_qualify(c_db_sym_t sym, char *symtabname);
-static boolean_t db_symbol_is_ambiguous(c_db_sym_t sym);
-static boolean_t db_line_at_pc(c_db_sym_t, char **, int *, db_expr_t);
+static bool db_symbol_is_ambiguous(c_db_sym_t sym);
+static bool db_line_at_pc(c_db_sym_t, char **, int *, db_expr_t);
static int db_cpu = -1;
@@ -202,29 +202,29 @@ db_qualify(c_db_sym_t sym, char *symtabname)
}
-boolean_t
+bool
db_eqname(const char *src, const char *dst, int c)
{
if (!strcmp(src, dst))
- return (TRUE);
+ return (true);
if (src[0] == c)
return (!strcmp(src+1,dst));
- return (FALSE);
+ return (false);
}
-boolean_t
+bool
db_value_of_name(const char *name, db_expr_t *valuep)
{
c_db_sym_t sym;
sym = db_lookup(name);
if (sym == C_DB_SYM_NULL)
- return (FALSE);
+ return (false);
db_symbol_values(sym, &name, valuep);
- return (TRUE);
+ return (true);
}
-boolean_t
+bool
db_value_of_name_pcpu(const char *name, db_expr_t *valuep)
{
static char tmp[256];
@@ -239,15 +239,15 @@ db_value_of_name_pcpu(const char *name, db_expr_t *valuep)
snprintf(tmp, sizeof(tmp), "pcpu_entry_%s", name);
sym = db_lookup(tmp);
if (sym == C_DB_SYM_NULL)
- return (FALSE);
+ return (false);
db_symbol_values(sym, &name, &value);
if (value < DPCPU_START || value >= DPCPU_STOP)
- return (FALSE);
+ return (false);
*valuep = (db_expr_t)((uintptr_t)value + dpcpu_off[cpu]);
- return (TRUE);
+ return (true);
}
-boolean_t
+bool
db_value_of_name_vnet(const char *name, db_expr_t *valuep)
{
#ifdef VIMAGE
@@ -263,14 +263,14 @@ db_value_of_name_vnet(const char *name, db_expr_t *valuep)
snprintf(tmp, sizeof(tmp), "vnet_entry_%s", name);
sym = db_lookup(tmp);
if (sym == C_DB_SYM_NULL)
- return (FALSE);
+ return (false);
db_symbol_values(sym, &name, &value);
if (value < VNET_START || value >= VNET_STOP)
- return (FALSE);
+ return (false);
*valuep = (db_expr_t)((uintptr_t)value + vnet->vnet_data_base);
- return (TRUE);
+ return (true);
#else
- return (FALSE);
+ return (false);
#endif
}
@@ -328,35 +328,34 @@ db_lookup(const char *symstr)
}
/*
- * If TRUE, check across symbol tables for multiple occurrences
+ * If true, check across symbol tables for multiple occurrences
* of a name. Might slow things down quite a bit.
*/
-static volatile boolean_t db_qualify_ambiguous_names = FALSE;
+static volatile bool db_qualify_ambiguous_names = false;
/*
* Does this symbol name appear in more than one symbol table?
* Used by db_symbol_values to decide whether to qualify a symbol.
*/
-static boolean_t
+static bool
db_symbol_is_ambiguous(c_db_sym_t sym)
{
const char *sym_name;
register int i;
- register
- boolean_t found_once = FALSE;
+ register bool found_once = false;
if (!db_qualify_ambiguous_names)
- return FALSE;
+ return (false);
db_symbol_values(sym, &sym_name, 0);
for (i = 0; i < db_nsymtab; i++) {
if (X_db_lookup(&db_symtabs[i], sym_name)) {
if (found_once)
- return TRUE;
- found_once = TRUE;
+ return (true);
+ found_once = true;
}
}
- return FALSE;
+ return (false);
}
/*
@@ -460,14 +459,14 @@ db_printsym(db_expr_t off, db_strategy_t strategy)
}
}
-static boolean_t
+static bool
db_line_at_pc(c_db_sym_t sym, char **filename, int *linenum, db_expr_t pc)
{
- return X_db_line_at_pc( db_last_symtab, sym, filename, linenum, pc);
+ return (X_db_line_at_pc(db_last_symtab, sym, filename, linenum, pc));
}
-int
+bool
db_sym_numargs(c_db_sym_t sym, int *nargp, char **argnames)
{
- return X_db_sym_numargs(db_last_symtab, sym, nargp, argnames);
+ return (X_db_sym_numargs(db_last_symtab, sym, nargp, argnames));
}
diff --git a/sys/ddb/db_sym.h b/sys/ddb/db_sym.h
index 1d9d462..51744c5 100644
--- a/sys/ddb/db_sym.h
+++ b/sys/ddb/db_sym.h
@@ -86,20 +86,20 @@ void db_symbol_values(c_db_sym_t, const char **, db_expr_t *);
db_symbol_values(db_search_symbol(val,DB_STGY_XTRN,offp),namep,0)
/* ditto, but no locals */
-int db_eqname(const char *, const char *, int);
+bool db_eqname(const char *, const char *, int);
/* strcmp, modulo leading char */
void db_printsym(db_expr_t, db_strategy_t);
/* print closest symbol to a value */
-int db_sym_numargs(c_db_sym_t, int *, char **);
+bool db_sym_numargs(c_db_sym_t, int *, char **);
-boolean_t X_db_line_at_pc(db_symtab_t *symtab, c_db_sym_t cursym,
+bool X_db_line_at_pc(db_symtab_t *symtab, c_db_sym_t cursym,
char **filename, int *linenum, db_expr_t off);
c_db_sym_t X_db_lookup(db_symtab_t *stab, const char *symstr);
c_db_sym_t X_db_search_symbol(db_symtab_t *symtab, db_addr_t off,
db_strategy_t strategy, db_expr_t *diffp);
-int X_db_sym_numargs(db_symtab_t *, c_db_sym_t, int *, char **);
+bool X_db_sym_numargs(db_symtab_t *, c_db_sym_t, int *, char **);
void X_db_symbol_values(db_symtab_t *symtab, c_db_sym_t sym,
const char **namep, db_expr_t *valuep);
diff --git a/sys/ddb/db_textdump.c b/sys/ddb/db_textdump.c
index b4b040b..a1a99f4 100644
--- a/sys/ddb/db_textdump.c
+++ b/sys/ddb/db_textdump.c
@@ -516,8 +516,7 @@ db_textdump_usage(void)
}
void
-db_textdump_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
- char *modif)
+db_textdump_cmd(db_expr_t addr, bool have_addr, db_expr_t count, char *modif)
{
int t;
@@ -543,7 +542,7 @@ db_textdump_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
db_printf("textdump unset\n");
} else if (strcmp(db_tok_string, "dump") == 0) {
textdump_pending = 1;
- doadump(TRUE);
+ doadump(true);
} else {
db_textdump_usage();
}
diff --git a/sys/ddb/db_thread.c b/sys/ddb/db_thread.c
index f6712a0..e85d0cd 100644
--- a/sys/ddb/db_thread.c
+++ b/sys/ddb/db_thread.c
@@ -50,7 +50,7 @@ db_print_thread(void)
}
void
-db_set_thread(db_expr_t tid, boolean_t hastid, db_expr_t cnt, char *mod)
+db_set_thread(db_expr_t tid, bool hastid, db_expr_t cnt, char *mod)
{
struct thread *thr;
db_expr_t radix;
@@ -86,7 +86,7 @@ db_set_thread(db_expr_t tid, boolean_t hastid, db_expr_t cnt, char *mod)
}
void
-db_show_threads(db_expr_t addr, boolean_t hasaddr, db_expr_t cnt, char *mod)
+db_show_threads(db_expr_t addr, bool hasaddr, db_expr_t cnt, char *mod)
{
jmp_buf jb;
void *prev_jb;
@@ -115,7 +115,7 @@ db_show_threads(db_expr_t addr, boolean_t hasaddr, db_expr_t cnt, char *mod)
* process. Otherwise, we treat the addr as a pointer to a thread.
*/
struct thread *
-db_lookup_thread(db_expr_t addr, boolean_t check_pid)
+db_lookup_thread(db_expr_t addr, bool check_pid)
{
struct thread *td;
db_expr_t decaddr;
diff --git a/sys/ddb/db_variables.c b/sys/ddb/db_variables.c
index 69c11ae..bd62db5 100644
--- a/sys/ddb/db_variables.c
+++ b/sys/ddb/db_variables.c
@@ -128,7 +128,7 @@ db_write_variable(struct db_variable *vp, db_expr_t value)
}
void
-db_set_cmd(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
+db_set_cmd(db_expr_t dummy1, bool dummy2, db_expr_t dummy3, char *dummy4)
{
struct db_variable *vp;
db_expr_t value;
diff --git a/sys/ddb/db_watch.c b/sys/ddb/db_watch.c
index 8debdb7..23612fe 100644
--- a/sys/ddb/db_watch.c
+++ b/sys/ddb/db_watch.c
@@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$");
* Watchpoints.
*/
-static boolean_t db_watchpoints_inserted = TRUE;
+static bool db_watchpoints_inserted = true;
#define NWATCHPOINTS 100
static struct db_watchpoint db_watch_table[NWATCHPOINTS];
@@ -59,7 +59,7 @@ static db_watchpoint_t db_watchpoint_alloc(void);
static void db_watchpoint_free(db_watchpoint_t watch);
static void db_delete_watchpoint(vm_map_t map, db_addr_t addr);
#ifdef notused
-static boolean_t db_find_watchpoint(vm_map_t map, db_addr_t addr,
+static bool db_find_watchpoint(vm_map_t map, db_addr_t addr,
db_regs_t *regs);
#endif
static void db_list_watchpoints(void);
@@ -69,7 +69,7 @@ static void db_set_watchpoint(vm_map_t map, db_addr_t addr,
static db_watchpoint_t
db_watchpoint_alloc(void)
{
- register db_watchpoint_t watch;
+ db_watchpoint_t watch;
if ((watch = db_free_watchpoints) != 0) {
db_free_watchpoints = watch->link;
@@ -95,7 +95,7 @@ db_watchpoint_free(db_watchpoint_t watch)
static void
db_set_watchpoint(vm_map_t map, db_addr_t addr, vm_size_t size)
{
- register db_watchpoint_t watch;
+ db_watchpoint_t watch;
if (map == NULL) {
db_printf("No map.\n");
@@ -129,14 +129,14 @@ db_set_watchpoint(vm_map_t map, db_addr_t addr, vm_size_t size)
watch->link = db_watchpoint_list;
db_watchpoint_list = watch;
- db_watchpoints_inserted = FALSE;
+ db_watchpoints_inserted = false;
}
static void
db_delete_watchpoint(vm_map_t map, db_addr_t addr)
{
- register db_watchpoint_t watch;
- register db_watchpoint_t *prev;
+ db_watchpoint_t watch;
+ db_watchpoint_t *prev;
for (prev = &db_watchpoint_list;
(watch = *prev) != 0;
@@ -155,7 +155,7 @@ db_delete_watchpoint(vm_map_t map, db_addr_t addr)
static void
db_list_watchpoints(void)
{
- register db_watchpoint_t watch;
+ db_watchpoint_t watch;
if (db_watchpoint_list == 0) {
db_printf("No watchpoints set\n");
@@ -183,7 +183,7 @@ db_list_watchpoints(void)
/* Delete watchpoint */
/*ARGSUSED*/
void
-db_deletewatch_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
+db_deletewatch_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
char *modif)
{
db_delete_watchpoint(db_map_addr(addr), addr);
@@ -192,7 +192,7 @@ db_deletewatch_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
/* Set watchpoint */
/*ARGSUSED*/
void
-db_watchpoint_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
+db_watchpoint_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
char *modif)
{
vm_size_t size;
@@ -220,7 +220,7 @@ DB_SHOW_COMMAND(watches, db_listwatch_cmd)
void
db_set_watchpoints(void)
{
- register db_watchpoint_t watch;
+ db_watchpoint_t watch;
if (!db_watchpoints_inserted) {
for (watch = db_watchpoint_list;
@@ -231,21 +231,21 @@ db_set_watchpoints(void)
round_page(watch->hiaddr),
VM_PROT_READ);
- db_watchpoints_inserted = TRUE;
+ db_watchpoints_inserted = true;
}
}
void
db_clear_watchpoints(void)
{
- db_watchpoints_inserted = FALSE;
+ db_watchpoints_inserted = false;
}
#ifdef notused
-static boolean_t
+static bool
db_find_watchpoint(vm_map_t map, db_addr_t addr, db_regs_t regs)
{
- register db_watchpoint_t watch;
+ db_watchpoint_t watch;
db_watchpoint_t found = 0;
for (watch = db_watchpoint_list;
@@ -254,7 +254,7 @@ db_find_watchpoint(vm_map_t map, db_addr_t addr, db_regs_t regs)
if (db_map_equal(watch->map, map)) {
if ((watch->loaddr <= addr) &&
(addr < watch->hiaddr))
- return (TRUE);
+ return (true);
else if ((trunc_page(watch->loaddr) <= addr) &&
(addr < round_page(watch->hiaddr)))
found = watch;
@@ -267,11 +267,11 @@ db_find_watchpoint(vm_map_t map, db_addr_t addr, db_regs_t regs)
*/
if (found) {
- db_watchpoints_inserted = FALSE;
+ db_watchpoints_inserted = false;
db_single_step(regs);
}
- return (FALSE);
+ return (false);
}
#endif
@@ -280,7 +280,7 @@ db_find_watchpoint(vm_map_t map, db_addr_t addr, db_regs_t regs)
/* Delete hardware watchpoint */
/*ARGSUSED*/
void
-db_deletehwatch_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
+db_deletehwatch_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
char *modif)
{
int rc;
@@ -296,7 +296,7 @@ db_deletehwatch_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
/* Set hardware watchpoint */
/*ARGSUSED*/
void
-db_hwatchpoint_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
+db_hwatchpoint_cmd(db_expr_t addr, bool have_addr, db_expr_t count,
char *modif)
{
int rc;
diff --git a/sys/ddb/db_write_cmd.c b/sys/ddb/db_write_cmd.c
index 5cd5c95..2e0cf03 100644
--- a/sys/ddb/db_write_cmd.c
+++ b/sys/ddb/db_write_cmd.c
@@ -43,16 +43,14 @@ __FBSDID("$FreeBSD$");
*/
/*ARGSUSED*/
void
-db_write_cmd(db_expr_t address, boolean_t have_addr, db_expr_t count,
+db_write_cmd(db_expr_t address, bool have_addr, db_expr_t count,
char * modif)
{
- register
db_addr_t addr;
- register
db_expr_t old_value;
db_expr_t new_value;
- register int size;
- boolean_t wrote_one = FALSE;
+ int size;
+ bool wrote_one = false;
addr = (db_addr_t) address;
@@ -73,13 +71,13 @@ db_write_cmd(db_expr_t address, boolean_t have_addr, db_expr_t count,
}
while (db_expression(&new_value)) {
- old_value = db_get_value(addr, size, FALSE);
+ old_value = db_get_value(addr, size, false);
db_printsym(addr, DB_STGY_ANY);
db_printf("\t\t%#8lr\t=\t%#8lr\n", (long)old_value,(long)new_value);
db_put_value(addr, size, new_value);
addr += size;
- wrote_one = TRUE;
+ wrote_one = true;
}
if (!wrote_one)
diff --git a/sys/ddb/ddb.h b/sys/ddb/ddb.h
index 5aa646b..a2adcdf 100644
--- a/sys/ddb/ddb.h
+++ b/sys/ddb/ddb.h
@@ -101,7 +101,7 @@ extern struct command_table db_show_all_table;
/*
* Type signature for a function implementing a ddb command.
*/
-typedef void db_cmdfcn_t(db_expr_t addr, boolean_t have_addr, db_expr_t count,
+typedef void db_cmdfcn_t(db_expr_t addr, bool have_addr, db_expr_t count,
char *modif);
/*
@@ -156,7 +156,7 @@ SYSUNINIT(__CONCAT(_name,_suffix), SI_SUB_KLD, SI_ORDER_ANY, \
static db_cmdfcn_t _func; \
_DB_SET(_suffix, _name, _func, list, _flag, _more); \
static void \
-_func(db_expr_t addr, boolean_t have_addr, db_expr_t count, char *modif)
+_func(db_expr_t addr, bool have_addr, db_expr_t count, char *modif)
/* common idom provided for backwards compatibility */
#define DB_FUNC(_name, _func, list, _flag, _more) \
@@ -191,17 +191,17 @@ struct vm_map;
void db_check_interrupt(void);
void db_clear_watchpoints(void);
-db_addr_t db_disasm(db_addr_t loc, boolean_t altfmt);
+db_addr_t db_disasm(db_addr_t loc, bool altfmt);
/* instruction disassembler */
void db_error(const char *s);
int db_expression(db_expr_t *valuep);
int db_get_variable(db_expr_t *valuep);
void db_iprintf(const char *,...) __printflike(1, 2);
struct proc *db_lookup_proc(db_expr_t addr);
-struct thread *db_lookup_thread(db_expr_t addr, boolean_t check_pid);
+struct thread *db_lookup_thread(db_expr_t addr, bool check_pid);
struct vm_map *db_map_addr(vm_offset_t);
-boolean_t db_map_current(struct vm_map *);
-boolean_t db_map_equal(struct vm_map *, struct vm_map *);
+bool db_map_current(struct vm_map *);
+bool db_map_equal(struct vm_map *, struct vm_map *);
int db_md_set_watchpoint(db_expr_t addr, db_expr_t size);
int db_md_clr_watchpoint(db_expr_t addr, db_expr_t size);
void db_md_list_watchpoints(void);
@@ -211,17 +211,17 @@ int db_printf(const char *fmt, ...) __printflike(1, 2);
int db_read_bytes(vm_offset_t addr, size_t size, char *data);
/* machine-dependent */
int db_readline(char *lstart, int lsize);
-void db_restart_at_pc(boolean_t watchpt);
+void db_restart_at_pc(bool watchpt);
int db_set_variable(db_expr_t value);
void db_set_watchpoints(void);
void db_skip_to_eol(void);
-boolean_t db_stop_at_pc(boolean_t *is_breakpoint);
+bool db_stop_at_pc(bool *is_breakpoint);
#define db_strcpy strcpy
void db_trace_self(void);
int db_trace_thread(struct thread *, int);
-int db_value_of_name(const char *name, db_expr_t *valuep);
-int db_value_of_name_pcpu(const char *name, db_expr_t *valuep);
-int db_value_of_name_vnet(const char *name, db_expr_t *valuep);
+bool db_value_of_name(const char *name, db_expr_t *valuep);
+bool db_value_of_name_pcpu(const char *name, db_expr_t *valuep);
+bool db_value_of_name_vnet(const char *name, db_expr_t *valuep);
int db_write_bytes(vm_offset_t addr, size_t size, char *data);
void db_command_register(struct command_table *, struct command *);
void db_command_unregister(struct command_table *, struct command *);
diff --git a/sys/dev/acpi_support/acpi_ibm.c b/sys/dev/acpi_support/acpi_ibm.c
index 52cee09..c69f8bf 100644
--- a/sys/dev/acpi_support/acpi_ibm.c
+++ b/sys/dev/acpi_support/acpi_ibm.c
@@ -530,7 +530,7 @@ acpi_ibm_sysctl(SYSCTL_HANDLER_ARGS)
int error = 0;
int function;
int method;
-
+
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
sc = (struct acpi_ibm_softc *)oidp->oid_arg1;
@@ -823,7 +823,7 @@ acpi_ibm_sysctl_init(struct acpi_ibm_softc *sc, int method)
return (FALSE);
case ACPI_IBM_METHOD_FANSPEED:
- /*
+ /*
* Some models report the fan speed in levels from 0-7
* Newer models report it contiguously
*/
@@ -834,7 +834,7 @@ acpi_ibm_sysctl_init(struct acpi_ibm_softc *sc, int method)
case ACPI_IBM_METHOD_FANLEVEL:
case ACPI_IBM_METHOD_FANSTATUS:
- /*
+ /*
* Fan status is only supported on those models,
* which report fan RPM contiguously, not in levels
*/
@@ -871,10 +871,10 @@ acpi_ibm_thermal_sysctl(SYSCTL_HANDLER_ARGS)
for (int i = 0; i < 8; ++i) {
temp_cmd[3] = '0' + i;
-
- /*
+
+ /*
* The TMPx methods seem to return +/- 128 or 0
- * when the respecting sensor is not available
+ * when the respecting sensor is not available
*/
if (ACPI_FAILURE(acpi_GetInteger(sc->ec_handle, temp_cmd,
&temp[i])) || ABS(temp[i]) == 128 || temp[i] == 0)
diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index 47bc791..d5d15da 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -447,7 +447,7 @@ acpi_attach(device_t dev)
sc = device_get_softc(dev);
sc->acpi_dev = dev;
- callout_init(&sc->susp_force_to, TRUE);
+ callout_init(&sc->susp_force_to, 1);
error = ENXIO;
@@ -605,9 +605,11 @@ acpi_attach(device_t dev)
if (AcpiGbl_FADT.Flags & ACPI_FADT_RESET_REGISTER)
sc->acpi_handle_reboot = 1;
+#if !ACPI_REDUCED_HARDWARE
/* Only enable S4BIOS by default if the FACS says it is available. */
- if (AcpiGbl_FACS->Flags & ACPI_FACS_S4_BIOS_PRESENT)
+ if (AcpiGbl_FACS != NULL && AcpiGbl_FACS->Flags & ACPI_FACS_S4_BIOS_PRESENT)
sc->acpi_s4bios = 1;
+#endif
/* Probe all supported sleep states. */
acpi_sleep_states[ACPI_STATE_S0] = TRUE;
diff --git a/sys/dev/acpica/acpi_cpu.c b/sys/dev/acpica/acpi_cpu.c
index 8df2782..21fccca 100644
--- a/sys/dev/acpica/acpi_cpu.c
+++ b/sys/dev/acpica/acpi_cpu.c
@@ -47,6 +47,8 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
#if defined(__amd64__) || defined(__i386__)
#include <machine/clock.h>
+#include <machine/specialreg.h>
+#include <machine/md_var.h>
#endif
#include <sys/rman.h>
@@ -70,6 +72,10 @@ struct acpi_cx {
uint32_t power; /* Power consumed (mW). */
int res_type; /* Resource type for p_lvlx. */
int res_rid; /* Resource ID for p_lvlx. */
+ bool do_mwait;
+ uint32_t mwait_hint;
+ bool mwait_hw_coord;
+ bool mwait_bm_avoidance;
};
#define MAX_CX_STATES 8
@@ -128,6 +134,12 @@ struct acpi_cpu_device {
#define PIIX4_STOP_BREAK_MASK (PIIX4_BRLD_EN_IRQ0 | PIIX4_BRLD_EN_IRQ | PIIX4_BRLD_EN_IRQ8)
#define PIIX4_PCNTRL_BST_EN (1<<10)
+#define CST_FFH_VENDOR_INTEL 1
+#define CST_FFH_INTEL_CL_C1IO 1
+#define CST_FFH_INTEL_CL_MWAIT 2
+#define CST_FFH_MWAIT_HW_COORD 0x0001
+#define CST_FFH_MWAIT_BM_AVOID 0x0002
+
/* Allow users to ignore processor orders in MADT. */
static int cpu_unordered;
SYSCTL_INT(_debug_acpi, OID_AUTO, cpu_unordered, CTLFLAG_RDTUN,
@@ -173,12 +185,16 @@ static void acpi_cpu_startup_cx(struct acpi_cpu_softc *sc);
static void acpi_cpu_cx_list(struct acpi_cpu_softc *sc);
static void acpi_cpu_idle(sbintime_t sbt);
static void acpi_cpu_notify(ACPI_HANDLE h, UINT32 notify, void *context);
-static int acpi_cpu_quirks(void);
+static void acpi_cpu_quirks(void);
+static void acpi_cpu_quirks_piix4(void);
static int acpi_cpu_usage_sysctl(SYSCTL_HANDLER_ARGS);
static int acpi_cpu_usage_counters_sysctl(SYSCTL_HANDLER_ARGS);
static int acpi_cpu_set_cx_lowest(struct acpi_cpu_softc *sc);
static int acpi_cpu_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS);
static int acpi_cpu_global_cx_lowest_sysctl(SYSCTL_HANDLER_ARGS);
+#if defined(__i386__) || defined(__amd64__)
+static int acpi_cpu_method_sysctl(SYSCTL_HANDLER_ARGS);
+#endif
static device_method_t acpi_cpu_methods[] = {
/* Device interface */
@@ -348,7 +364,18 @@ acpi_cpu_attach(device_t dev)
* so advertise this ourselves. Note this is not the same as independent
* SMP control where each CPU can have different settings.
*/
- sc->cpu_features = ACPI_CAP_SMP_SAME | ACPI_CAP_SMP_SAME_C3;
+ sc->cpu_features = ACPI_CAP_SMP_SAME | ACPI_CAP_SMP_SAME_C3 |
+ ACPI_CAP_C1_IO_HALT;
+
+#if defined(__i386__) || defined(__amd64__)
+ /*
+ * Ask for MWAIT modes if not disabled and interrupts work
+ * reasonable with MWAIT.
+ */
+ if (!acpi_disabled("mwait") && cpu_mwait_usable())
+ sc->cpu_features |= ACPI_CAP_SMP_C1_NATIVE | ACPI_CAP_SMP_C3_NATIVE;
+#endif
+
if (devclass_get_drivers(acpi_cpu_devclass, &drivers, &drv_count) == 0) {
for (i = 0; i < drv_count; i++) {
if (ACPI_GET_FEATURES(drivers[i], &features) == 0)
@@ -720,6 +747,29 @@ acpi_cpu_generic_cx_probe(struct acpi_cpu_softc *sc)
}
}
+#if defined(__i386__) || defined(__amd64__)
+static void
+acpi_cpu_cx_cst_mwait(struct acpi_cx *cx_ptr, uint64_t address, int accsize)
+{
+
+ cx_ptr->do_mwait = true;
+ cx_ptr->mwait_hint = address & 0xffffffff;
+ cx_ptr->mwait_hw_coord = (accsize & CST_FFH_MWAIT_HW_COORD) != 0;
+ cx_ptr->mwait_bm_avoidance = (accsize & CST_FFH_MWAIT_BM_AVOID) != 0;
+}
+#endif
+
+static void
+acpi_cpu_cx_cst_free_plvlx(device_t cpu_dev, struct acpi_cx *cx_ptr)
+{
+
+ if (cx_ptr->p_lvlx == NULL)
+ return;
+ bus_release_resource(cpu_dev, cx_ptr->res_type, cx_ptr->res_rid,
+ cx_ptr->p_lvlx);
+ cx_ptr->p_lvlx = NULL;
+}
+
/*
* Parse a _CST package and set up its Cx states. Since the _CST object
* can change dynamically, our notify handler may call this function
@@ -735,6 +785,10 @@ acpi_cpu_cx_cst(struct acpi_cpu_softc *sc)
ACPI_OBJECT *pkg;
uint32_t count;
int i;
+#if defined(__i386__) || defined(__amd64__)
+ uint64_t address;
+ int vendor, class, accsize;
+#endif
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
@@ -790,6 +844,30 @@ acpi_cpu_cx_cst(struct acpi_cpu_softc *sc)
/* Validate the state to see if we should use it. */
switch (cx_ptr->type) {
case ACPI_STATE_C1:
+ acpi_cpu_cx_cst_free_plvlx(sc->cpu_dev, cx_ptr);
+#if defined(__i386__) || defined(__amd64__)
+ if (acpi_PkgFFH_IntelCpu(pkg, 0, &vendor, &class, &address,
+ &accsize) == 0 && vendor == CST_FFH_VENDOR_INTEL) {
+ if (class == CST_FFH_INTEL_CL_C1IO) {
+ /* C1 I/O then Halt */
+ cx_ptr->res_rid = sc->cpu_cx_count;
+ bus_set_resource(sc->cpu_dev, SYS_RES_IOPORT,
+ cx_ptr->res_rid, address, 1);
+ cx_ptr->p_lvlx = bus_alloc_resource_any(sc->cpu_dev,
+ SYS_RES_IOPORT, &cx_ptr->res_rid, RF_ACTIVE |
+ RF_SHAREABLE);
+ if (cx_ptr->p_lvlx == NULL) {
+ bus_delete_resource(sc->cpu_dev, SYS_RES_IOPORT,
+ cx_ptr->res_rid);
+ device_printf(sc->cpu_dev,
+ "C1 I/O failed to allocate port %d, "
+ "degrading to C1 Halt", (int)address);
+ }
+ } else if (class == CST_FFH_INTEL_CL_MWAIT) {
+ acpi_cpu_cx_cst_mwait(cx_ptr, address, accsize);
+ }
+ }
+#endif
if (sc->cpu_cx_states[0].type == ACPI_STATE_C0) {
/* This is the first C1 state. Use the reserved slot. */
sc->cpu_cx_states[0] = *cx_ptr;
@@ -818,23 +896,34 @@ acpi_cpu_cx_cst(struct acpi_cpu_softc *sc)
}
/* Free up any previous register. */
- if (cx_ptr->p_lvlx != NULL) {
- bus_release_resource(sc->cpu_dev, cx_ptr->res_type, cx_ptr->res_rid,
- cx_ptr->p_lvlx);
- cx_ptr->p_lvlx = NULL;
- }
+ acpi_cpu_cx_cst_free_plvlx(sc->cpu_dev, cx_ptr);
/* Allocate the control register for C2 or C3. */
- cx_ptr->res_rid = sc->cpu_cx_count;
- acpi_PkgGas(sc->cpu_dev, pkg, 0, &cx_ptr->res_type, &cx_ptr->res_rid,
- &cx_ptr->p_lvlx, RF_SHAREABLE);
- if (cx_ptr->p_lvlx) {
+#if defined(__i386__) || defined(__amd64__)
+ if (acpi_PkgFFH_IntelCpu(pkg, 0, &vendor, &class, &address,
+ &accsize) == 0 && vendor == CST_FFH_VENDOR_INTEL &&
+ class == CST_FFH_INTEL_CL_MWAIT) {
+ /* Native C State Instruction use (mwait) */
+ acpi_cpu_cx_cst_mwait(cx_ptr, address, accsize);
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
- "acpi_cpu%d: Got C%d - %d latency\n",
- device_get_unit(sc->cpu_dev), cx_ptr->type,
- cx_ptr->trans_lat));
+ "acpi_cpu%d: Got C%d/mwait - %d latency\n",
+ device_get_unit(sc->cpu_dev), cx_ptr->type, cx_ptr->trans_lat));
cx_ptr++;
sc->cpu_cx_count++;
+ } else
+#endif
+ {
+ cx_ptr->res_rid = sc->cpu_cx_count;
+ acpi_PkgGas(sc->cpu_dev, pkg, 0, &cx_ptr->res_type,
+ &cx_ptr->res_rid, &cx_ptr->p_lvlx, RF_SHAREABLE);
+ if (cx_ptr->p_lvlx) {
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+ "acpi_cpu%d: Got C%d - %d latency\n",
+ device_get_unit(sc->cpu_dev), cx_ptr->type,
+ cx_ptr->trans_lat));
+ cx_ptr++;
+ sc->cpu_cx_count++;
+ }
}
}
AcpiOsFree(buf.Pointer);
@@ -956,6 +1045,13 @@ acpi_cpu_startup_cx(struct acpi_cpu_softc *sc)
OID_AUTO, "cx_usage_counters", CTLTYPE_STRING | CTLFLAG_RD,
(void *)sc, 0, acpi_cpu_usage_counters_sysctl, "A",
"Cx sleep state counters");
+#if defined(__i386__) || defined(__amd64__)
+ SYSCTL_ADD_PROC(&sc->cpu_sysctl_ctx,
+ SYSCTL_CHILDREN(device_get_sysctl_tree(sc->cpu_dev)),
+ OID_AUTO, "cx_method", CTLTYPE_STRING | CTLFLAG_RD,
+ (void *)sc, 0, acpi_cpu_method_sysctl, "A",
+ "Cx entrance methods");
+#endif
/* Signal platform that we can handle _CST notification. */
if (!cpu_cx_generic && cpu_cst_cnt != 0) {
@@ -1043,7 +1139,14 @@ acpi_cpu_idle(sbintime_t sbt)
*/
if (cx_next->type == ACPI_STATE_C1) {
cputicks = cpu_ticks();
- acpi_cpu_c1();
+ if (cx_next->p_lvlx != NULL) {
+ /* C1 I/O then Halt */
+ CPU_GET_REG(cx_next->p_lvlx, 1);
+ }
+ if (cx_next->do_mwait)
+ acpi_cpu_idle_mwait(cx_next->mwait_hint);
+ else
+ acpi_cpu_c1();
end_time = ((cpu_ticks() - cputicks) << 20) / cpu_tickrate();
if (curthread->td_critnest == 0)
end_time = min(end_time, 500000 / hz);
@@ -1055,7 +1158,7 @@ acpi_cpu_idle(sbintime_t sbt)
* For C3, disable bus master arbitration and enable bus master wake
* if BM control is available, otherwise flush the CPU cache.
*/
- if (cx_next->type == ACPI_STATE_C3) {
+ if (cx_next->type == ACPI_STATE_C3 || cx_next->mwait_bm_avoidance) {
if ((cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) {
AcpiWriteBitRegister(ACPI_BITREG_ARB_DISABLE, 1);
AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 1);
@@ -1076,7 +1179,10 @@ acpi_cpu_idle(sbintime_t sbt)
start_time = 0;
cputicks = cpu_ticks();
}
- CPU_GET_REG(cx_next->p_lvlx, 1);
+ if (cx_next->do_mwait)
+ acpi_cpu_idle_mwait(cx_next->mwait_hint);
+ else
+ CPU_GET_REG(cx_next->p_lvlx, 1);
/*
* Read the end time twice. Since it may take an arbitrary time
@@ -1092,8 +1198,8 @@ acpi_cpu_idle(sbintime_t sbt)
end_time = ((cpu_ticks() - cputicks) << 20) / cpu_tickrate();
/* Enable bus master arbitration and disable bus master wakeup. */
- if (cx_next->type == ACPI_STATE_C3 &&
- (cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) {
+ if ((cx_next->type == ACPI_STATE_C3 || cx_next->mwait_bm_avoidance) &&
+ (cpu_quirks & CPU_QUIRK_NO_BM_CTRL) == 0) {
AcpiWriteBitRegister(ACPI_BITREG_ARB_DISABLE, 0);
AcpiWriteBitRegister(ACPI_BITREG_BUS_MASTER_RLD, 0);
}
@@ -1134,12 +1240,9 @@ acpi_cpu_notify(ACPI_HANDLE h, UINT32 notify, void *context)
acpi_UserNotify("PROCESSOR", sc->cpu_handle, notify);
}
-static int
+static void
acpi_cpu_quirks(void)
{
- device_t acpi_dev;
- uint32_t val;
-
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
/*
@@ -1173,6 +1276,16 @@ acpi_cpu_quirks(void)
}
/* Look for various quirks of the PIIX4 part. */
+ acpi_cpu_quirks_piix4();
+}
+
+static void
+acpi_cpu_quirks_piix4(void)
+{
+#ifdef __i386__
+ device_t acpi_dev;
+ uint32_t val;
+
acpi_dev = pci_find_device(PCI_VENDOR_INTEL, PCI_DEVICE_82371AB_3);
if (acpi_dev != NULL) {
switch (pci_get_revid(acpi_dev)) {
@@ -1221,8 +1334,7 @@ acpi_cpu_quirks(void)
break;
}
}
-
- return (0);
+#endif
}
static int
@@ -1286,6 +1398,44 @@ acpi_cpu_usage_counters_sysctl(SYSCTL_HANDLER_ARGS)
return (0);
}
+#if defined(__i386__) || defined(__amd64__)
+static int
+acpi_cpu_method_sysctl(SYSCTL_HANDLER_ARGS)
+{
+ struct acpi_cpu_softc *sc;
+ struct acpi_cx *cx;
+ struct sbuf sb;
+ char buf[128];
+ int i;
+
+ sc = (struct acpi_cpu_softc *)arg1;
+ sbuf_new(&sb, buf, sizeof(buf), SBUF_FIXEDLEN);
+ for (i = 0; i < sc->cpu_cx_count; i++) {
+ cx = &sc->cpu_cx_states[i];
+ sbuf_printf(&sb, "C%d/", i + 1);
+ if (cx->do_mwait) {
+ sbuf_cat(&sb, "mwait");
+ if (cx->mwait_hw_coord)
+ sbuf_cat(&sb, "/hwc");
+ if (cx->mwait_bm_avoidance)
+ sbuf_cat(&sb, "/bma");
+ } else if (cx->type == ACPI_STATE_C1) {
+ sbuf_cat(&sb, "hlt");
+ } else {
+ sbuf_cat(&sb, "io");
+ }
+ if (cx->type == ACPI_STATE_C1 && cx->p_lvlx != NULL)
+ sbuf_cat(&sb, "/iohlt");
+ sbuf_putc(&sb, ' ');
+ }
+ sbuf_trim(&sb);
+ sbuf_finish(&sb);
+ sysctl_handle_string(oidp, sbuf_data(&sb), sbuf_len(&sb), req);
+ sbuf_delete(&sb);
+ return (0);
+}
+#endif
+
static int
acpi_cpu_set_cx_lowest(struct acpi_cpu_softc *sc)
{
diff --git a/sys/dev/acpica/acpi_package.c b/sys/dev/acpica/acpi_package.c
index e38fea5..c1070cb 100644
--- a/sys/dev/acpica/acpi_package.c
+++ b/sys/dev/acpica/acpi_package.c
@@ -120,6 +120,28 @@ acpi_PkgGas(device_t dev, ACPI_OBJECT *res, int idx, int *type, int *rid,
return (acpi_bus_alloc_gas(dev, type, rid, &gas, dst, flags));
}
+int
+acpi_PkgFFH_IntelCpu(ACPI_OBJECT *res, int idx, int *vendor, int *class,
+ uint64_t *address, int *accsize)
+{
+ ACPI_GENERIC_ADDRESS gas;
+ ACPI_OBJECT *obj;
+
+ obj = &res->Package.Elements[idx];
+ if (obj == NULL || obj->Type != ACPI_TYPE_BUFFER ||
+ obj->Buffer.Length < sizeof(ACPI_GENERIC_ADDRESS) + 3)
+ return (EINVAL);
+
+ memcpy(&gas, obj->Buffer.Pointer + 3, sizeof(gas));
+ if (gas.SpaceId != ACPI_ADR_SPACE_FIXED_HARDWARE)
+ return (ERESTART);
+ *vendor = gas.BitWidth;
+ *class = gas.BitOffset;
+ *address = gas.Address;
+ *accsize = gas.AccessWidth;
+ return (0);
+}
+
ACPI_HANDLE
acpi_GetReference(ACPI_HANDLE scope, ACPI_OBJECT *obj)
{
diff --git a/sys/dev/acpica/acpi_throttle.c b/sys/dev/acpica/acpi_throttle.c
index ca14215..883b5d3 100644
--- a/sys/dev/acpica/acpi_throttle.c
+++ b/sys/dev/acpica/acpi_throttle.c
@@ -96,7 +96,7 @@ static void acpi_throttle_identify(driver_t *driver, device_t parent);
static int acpi_throttle_probe(device_t dev);
static int acpi_throttle_attach(device_t dev);
static int acpi_throttle_evaluate(struct acpi_throttle_softc *sc);
-static int acpi_throttle_quirks(struct acpi_throttle_softc *sc);
+static void acpi_throttle_quirks(struct acpi_throttle_softc *sc);
static int acpi_thr_settings(device_t dev, struct cf_setting *sets,
int *count);
static int acpi_thr_set(device_t dev, const struct cf_setting *set);
@@ -314,9 +314,10 @@ acpi_throttle_evaluate(struct acpi_throttle_softc *sc)
return (0);
}
-static int
+static void
acpi_throttle_quirks(struct acpi_throttle_softc *sc)
{
+#ifdef __i386__
device_t acpi_dev;
/* Look for various quirks of the PIIX4 part. */
@@ -339,8 +340,7 @@ acpi_throttle_quirks(struct acpi_throttle_softc *sc)
break;
}
}
-
- return (0);
+#endif
}
static int
diff --git a/sys/dev/acpica/acpi_timer.c b/sys/dev/acpica/acpi_timer.c
index 03ef686..296e38f 100644
--- a/sys/dev/acpica/acpi_timer.c
+++ b/sys/dev/acpica/acpi_timer.c
@@ -128,7 +128,8 @@ acpi_timer_identify(driver_t *driver, device_t parent)
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
if (acpi_disabled("timer") || (acpi_quirks & ACPI_Q_TIMER) ||
- acpi_timer_dev || acpi_timer_disabled)
+ acpi_timer_dev || acpi_timer_disabled ||
+ AcpiGbl_FADT.PmTimerLength == 0)
return_VOID;
if ((dev = BUS_ADD_CHILD(parent, 2, "acpi_timer", 0)) == NULL) {
diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h
index 2e2b96d..cbd4bd9 100644
--- a/sys/dev/acpica/acpivar.h
+++ b/sys/dev/acpica/acpivar.h
@@ -467,6 +467,8 @@ int acpi_PkgInt32(ACPI_OBJECT *res, int idx, uint32_t *dst);
int acpi_PkgStr(ACPI_OBJECT *res, int idx, void *dst, size_t size);
int acpi_PkgGas(device_t dev, ACPI_OBJECT *res, int idx, int *type,
int *rid, struct resource **dst, u_int flags);
+int acpi_PkgFFH_IntelCpu(ACPI_OBJECT *res, int idx, int *vendor,
+ int *class, uint64_t *address, int *accsize);
ACPI_HANDLE acpi_GetReference(ACPI_HANDLE scope, ACPI_OBJECT *obj);
/*
diff --git a/sys/dev/altera/jtag_uart/altera_jtag_uart_tty.c b/sys/dev/altera/jtag_uart/altera_jtag_uart_tty.c
index dd46ea0..1e9a1b8 100644
--- a/sys/dev/altera/jtag_uart/altera_jtag_uart_tty.c
+++ b/sys/dev/altera/jtag_uart/altera_jtag_uart_tty.c
@@ -454,11 +454,11 @@ altera_jtag_uart_attach(struct altera_jtag_uart_softc *sc)
aju_intr_readable_enable(sc);
AJU_UNLOCK(sc);
} else {
- callout_init(&sc->ajus_io_callout, CALLOUT_MPSAFE);
+ callout_init(&sc->ajus_io_callout, 1);
callout_reset(&sc->ajus_io_callout, AJU_IO_POLLINTERVAL,
aju_io_callout, sc);
}
- callout_init(&sc->ajus_ac_callout, CALLOUT_MPSAFE);
+ callout_init(&sc->ajus_ac_callout, 1);
callout_reset(&sc->ajus_ac_callout, AJU_AC_POLLINTERVAL,
aju_ac_callout, sc);
return (0);
diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c
index 4b7f8bc..83d9bd2 100644
--- a/sys/dev/ath/if_ath.c
+++ b/sys/dev/ath/if_ath.c
@@ -847,7 +847,7 @@ ath_attach(u_int16_t devid, struct ath_softc *sc)
sc->sc_ledstate = 1;
sc->sc_ledon = 0; /* low true */
sc->sc_ledidle = (2700*hz)/1000; /* 2.7sec */
- callout_init(&sc->sc_ledtimer, CALLOUT_MPSAFE);
+ callout_init(&sc->sc_ledtimer, 1);
/*
* Don't setup hardware-based blinking.
diff --git a/sys/dev/atkbdc/atkbd.c b/sys/dev/atkbdc/atkbd.c
index d93c1c6..a90f5d2 100644
--- a/sys/dev/atkbdc/atkbd.c
+++ b/sys/dev/atkbdc/atkbd.c
@@ -44,19 +44,6 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
#include <machine/resource.h>
-#if defined(__i386__) || defined(__amd64__)
-#include <machine/md_var.h>
-#include <machine/psl.h>
-#include <compat/x86bios/x86bios.h>
-#include <machine/pc/bios.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <vm/vm_param.h>
-
-#include <isa/isareg.h>
-#endif /* __i386__ || __amd64__ */
-
#include <sys/kbio.h>
#include <dev/kbd/kbdreg.h>
#include <dev/atkbdc/atkbdreg.h>
@@ -82,6 +69,9 @@ static int atkbd_reset(KBDC kbdc, int flags, int c);
#define HAS_QUIRK(p, q) (((atkbdc_softc_t *)(p))->quirks & q)
#define ALLOW_DISABLE_KBD(kbdc) !HAS_QUIRK(kbdc, KBDC_QUIRK_KEEP_ACTIVATED)
+#define DEFAULT_DELAY 0x1 /* 500ms */
+#define DEFAULT_RATE 0x10 /* 14Hz */
+
int
atkbd_probe_unit(device_t dev, int irq, int flags)
{
@@ -249,7 +239,7 @@ static keyboard_switch_t atkbdsw = {
KEYBOARD_DRIVER(atkbd, atkbdsw, atkbd_configure);
/* local functions */
-static int get_typematic(keyboard_t *kbd);
+static int set_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);
@@ -443,7 +433,7 @@ atkbd_init(int unit, keyboard_t **kbdp, void *arg, int flags)
goto bad;
}
atkbd_ioctl(kbd, KDSETLED, (caddr_t)&state->ks_state);
- get_typematic(kbd);
+ set_typematic(kbd);
delay[0] = kbd->kb_delay1;
delay[1] = kbd->kb_delay2;
atkbd_ioctl(kbd, KDSETREPEAT, (caddr_t)delay);
@@ -503,7 +493,7 @@ atkbd_intr(keyboard_t *kbd, void *arg)
init_keyboard(state->kbdc, &kbd->kb_type, kbd->kb_config);
KBD_FOUND_DEVICE(kbd);
atkbd_ioctl(kbd, KDSETLED, (caddr_t)&state->ks_state);
- get_typematic(kbd);
+ set_typematic(kbd);
delay[0] = kbd->kb_delay1;
delay[1] = kbd->kb_delay2;
atkbd_ioctl(kbd, KDSETREPEAT, (caddr_t)delay);
@@ -1135,57 +1125,19 @@ atkbd_reset(KBDC kbdc, int flags, int c)
/* local functions */
static int
-get_typematic(keyboard_t *kbd)
+set_typematic(keyboard_t *kbd)
{
-#if defined(__i386__) || defined(__amd64__)
- /*
- * Only some systems allow us to retrieve the keyboard repeat
- * rate previously set via the BIOS...
- */
- x86regs_t regs;
- uint8_t *p;
+ int val, error;
+ atkbd_state_t *state = kbd->kb_data;
- /*
- * Traditional entry points of int 0x15 and 0x16 are fixed
- * and later BIOSes follow them. (U)EFI CSM specification
- * also mandates these fixed entry points.
- *
- * Validate the entry points here before we proceed further.
- * It's known that some recent laptops does not have the
- * same entry point and hang on boot if we call it.
- */
- if (x86bios_get_intr(0x15) != 0xf000f859 ||
- x86bios_get_intr(0x16) != 0xf000e82e)
- return (ENODEV);
-
- /* Is BIOS system configuration table supported? */
- x86bios_init_regs(&regs);
- regs.R_AH = 0xc0;
- x86bios_intr(&regs, 0x15);
- if ((regs.R_FLG & PSL_C) != 0 || regs.R_AH != 0)
- return (ENODEV);
-
- /* Is int 0x16, function 0x09 supported? */
- p = x86bios_offset((regs.R_ES << 4) + regs.R_BX);
- if (readw(p) < 5 || (readb(p + 6) & 0x40) == 0)
- return (ENODEV);
-
- /* Is int 0x16, function 0x0306 supported? */
- x86bios_init_regs(&regs);
- regs.R_AH = 0x09;
- x86bios_intr(&regs, 0x16);
- if ((regs.R_AL & 0x08) == 0)
- return (ENODEV);
-
- x86bios_init_regs(&regs);
- regs.R_AX = 0x0306;
- x86bios_intr(&regs, 0x16);
- kbd->kb_delay1 = typematic_delay(regs.R_BH << 5);
- kbd->kb_delay2 = typematic_rate(regs.R_BL);
- return (0);
-#else
- return (ENODEV);
-#endif /* __i386__ || __amd64__ */
+ val = typematic(DEFAULT_DELAY, DEFAULT_RATE);
+ error = write_kbd(state->kbdc, KBDC_SET_TYPEMATIC, val);
+ if (error == 0) {
+ kbd->kb_delay1 = typematic_delay(val);
+ kbd->kb_delay2 = typematic_rate(val);
+ }
+
+ return (error);
}
static int
diff --git a/sys/dev/atkbdc/psm.c b/sys/dev/atkbdc/psm.c
index 6c7f47a..7f3f97d 100644
--- a/sys/dev/atkbdc/psm.c
+++ b/sys/dev/atkbdc/psm.c
@@ -483,6 +483,8 @@ static probefunc_t enable_versapad;
static void set_trackpoint_parameters(struct psm_softc *sc);
static void synaptics_passthrough_on(struct psm_softc *sc);
static void synaptics_passthrough_off(struct psm_softc *sc);
+static int synaptics_preferred_mode(struct psm_softc *sc);
+static void synaptics_set_mode(struct psm_softc *sc, int mode_byte);
static struct {
int model;
@@ -933,14 +935,8 @@ doopen(struct psm_softc *sc, int command_byte)
get_mouse_status(sc->kbdc, stat, 0, 3);
if ((SYNAPTICS_VERSION_GE(sc->synhw, 7, 5) ||
stat[1] == 0x47) &&
- stat[2] == 0x40) {
- /* Set the mode byte -- request wmode where
- * available */
- if (sc->synhw.capExtended)
- mouse_ext_command(sc->kbdc, 0xc1);
- else
- mouse_ext_command(sc->kbdc, 0xc0);
- set_mouse_sampling_rate(sc->kbdc, 20);
+ stat[2] == 0x40) {
+ synaptics_set_mode(sc, synaptics_preferred_mode(sc));
VLOG(5, (LOG_DEBUG, "psm%d: Synaptis Absolute Mode "
"hopefully restored\n",
sc->unit));
@@ -2176,6 +2172,20 @@ psmioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
(*(int *)addr > PSM_LEVEL_MAX))
return (EINVAL);
sc->mode.level = *(int *)addr;
+
+ if (sc->hw.model == MOUSE_MODEL_SYNAPTICS) {
+ /*
+ * If we are entering PSM_LEVEL_NATIVE, we want to
+ * enable sending of "extended W mode" packets to
+ * userland. Reset the mode of the touchpad so that the
+ * change in the level is picked up.
+ */
+ error = block_mouse_data(sc, &command_byte);
+ if (error)
+ return (error);
+ synaptics_set_mode(sc, synaptics_preferred_mode(sc));
+ unblock_mouse_data(sc, command_byte);
+ }
break;
case MOUSE_GETSTATUS:
@@ -2865,7 +2875,8 @@ proc_synaptics(struct psm_softc *sc, packetbuf_t *pb, mousestatus_t *ms,
/* Palm detection. */
if (!(
- (sc->synhw.capMultiFinger && (w == 0 || w == 1)) ||
+ ((sc->synhw.capMultiFinger ||
+ sc->synhw.capAdvancedGestures) && (w == 0 || w == 1)) ||
(sc->synhw.capPalmDetect && w >= 4 && w <= max_width) ||
(!sc->synhw.capPalmDetect && *z <= max_pressure) ||
(sc->synhw.capPen && w == 2))) {
@@ -4192,7 +4203,8 @@ synaptics_sysctl_create_tree(struct psm_softc *sc)
* physical area reserved for scrolling or when
* there's no multi finger support.
*/
- if (sc->synhw.verticalScroll || sc->synhw.capMultiFinger == 0)
+ if (sc->synhw.verticalScroll || (sc->synhw.capMultiFinger == 0 &&
+ sc->synhw.capAdvancedGestures == 0))
sc->syninfo.two_finger_scroll = 0;
else
sc->syninfo.two_finger_scroll = 1;
@@ -4494,6 +4506,43 @@ synaptics_sysctl_create_tree(struct psm_softc *sc)
}
static int
+synaptics_preferred_mode(struct psm_softc *sc) {
+ int mode_byte;
+
+ mode_byte = 0xc0;
+
+ /* request wmode where available */
+ if (sc->synhw.capExtended)
+ mode_byte |= 1;
+
+ /*
+ * Disable gesture processing when native packets are requested. This
+ * enables sending of encapsulated "extended W mode" packets.
+ */
+ if (sc->mode.level == PSM_LEVEL_NATIVE)
+ mode_byte |= (1 << 2);
+
+ return mode_byte;
+}
+
+static void
+synaptics_set_mode(struct psm_softc *sc, int mode_byte) {
+ mouse_ext_command(sc->kbdc, mode_byte);
+
+ /* "Commit" the Set Mode Byte command sent above. */
+ set_mouse_sampling_rate(sc->kbdc, 20);
+
+ /*
+ * Enable advanced gestures mode if supported and we are not entering
+ * passthrough mode.
+ */
+ if (sc->synhw.capAdvancedGestures && !(mode_byte & (1 << 5))) {
+ mouse_ext_command(sc->kbdc, 3);
+ set_mouse_sampling_rate(sc->kbdc, 0xc8);
+ }
+}
+
+static int
enable_synaptics(KBDC kbdc, struct psm_softc *sc)
{
synapticshw_t synhw;
@@ -4576,7 +4625,7 @@ enable_synaptics(KBDC kbdc, struct psm_softc *sc)
buttons = 0;
synhw.capExtended = (status[0] & 0x80) != 0;
if (synhw.capExtended) {
- synhw.nExtendedQueries = (status[0] & 0x70) != 0;
+ synhw.nExtendedQueries = (status[0] & 0x70) >> 4;
synhw.capMiddle = (status[0] & 0x04) != 0;
synhw.capPassthrough = (status[2] & 0x80) != 0;
synhw.capLowPower = (status[2] & 0x40) != 0;
@@ -4588,6 +4637,16 @@ enable_synaptics(KBDC kbdc, struct psm_softc *sc)
synhw.capMultiFinger = (status[2] & 0x02) != 0;
synhw.capPalmDetect = (status[2] & 0x01) != 0;
+ if (!set_mouse_scaling(kbdc, 1))
+ return (FALSE);
+ if (mouse_ext_command(kbdc, 0x08) == 0)
+ return (FALSE);
+ if (get_mouse_status(kbdc, status, 0, 3) != 3)
+ return (FALSE);
+
+ synhw.infoXupmm = status[0];
+ synhw.infoYupmm = status[2];
+
if (verbose >= 2) {
printf(" Extended capabilities:\n");
printf(" capExtended: %d\n", synhw.capExtended);
@@ -4603,6 +4662,8 @@ enable_synaptics(KBDC kbdc, struct psm_softc *sc)
printf(" capBallistics: %d\n", synhw.capBallistics);
printf(" capMultiFinger: %d\n", synhw.capMultiFinger);
printf(" capPalmDetect: %d\n", synhw.capPalmDetect);
+ printf(" infoXupmm: %d\n", synhw.infoXupmm);
+ printf(" infoYupmm: %d\n", synhw.infoYupmm);
}
/*
@@ -4610,7 +4671,9 @@ enable_synaptics(KBDC kbdc, struct psm_softc *sc)
* supports this number of extended queries. We can load
* more information about buttons using query 0x09.
*/
- if (synhw.capExtended && synhw.nExtendedQueries) {
+ if (synhw.nExtendedQueries >= 1) {
+ if (!set_mouse_scaling(kbdc, 1))
+ return (FALSE);
if (mouse_ext_command(kbdc, 0x09) == 0)
return (FALSE);
if (get_mouse_status(kbdc, status, 0, 3) != 3)
@@ -4619,6 +4682,7 @@ enable_synaptics(KBDC kbdc, struct psm_softc *sc)
synhw.horizontalScroll = (status[0] & 0x02) != 0;
synhw.verticalWheel = (status[0] & 0x08) != 0;
synhw.nExtendedButtons = (status[1] & 0xf0) >> 4;
+ synhw.capEWmode = (status[0] & 0x04) != 0;
if (verbose >= 2) {
printf(" Extended model ID:\n");
printf(" verticalScroll: %d\n",
@@ -4629,6 +4693,8 @@ enable_synaptics(KBDC kbdc, struct psm_softc *sc)
synhw.verticalWheel);
printf(" nExtendedButtons: %d\n",
synhw.nExtendedButtons);
+ printf(" capEWmode: %d\n",
+ synhw.capEWmode);
}
/*
* Add the number of extended buttons to the total
@@ -4642,7 +4708,97 @@ enable_synaptics(KBDC kbdc, struct psm_softc *sc)
* add a fourth button to the total button count.
*/
buttons = synhw.capFourButtons ? 1 : 0;
+
+ /* Read the continued capabilities bits. */
+ if (synhw.nExtendedQueries >= 4) {
+ if (!set_mouse_scaling(kbdc, 1))
+ return (FALSE);
+ if (mouse_ext_command(kbdc, 0x0c) == 0)
+ return (FALSE);
+ if (get_mouse_status(kbdc, status, 0, 3) != 3)
+ return (FALSE);
+
+ synhw.capClickPad = (status[1] & 0x01) << 1;
+ synhw.capClickPad |= (status[0] & 0x10) != 0;
+ synhw.capDeluxeLEDs = (status[1] & 0x02) != 0;
+ synhw.noAbsoluteFilter = (status[1] & 0x04) != 0;
+ synhw.capReportsV = (status[1] & 0x08) != 0;
+ synhw.capUniformClickPad = (status[1] & 0x10) != 0;
+ synhw.capReportsMin = (status[1] & 0x20) != 0;
+ synhw.capInterTouch = (status[1] & 0x40) != 0;
+ synhw.capReportsMax = (status[0] & 0x02) != 0;
+ synhw.capClearPad = (status[0] & 0x04) != 0;
+ synhw.capAdvancedGestures = (status[0] & 0x08) != 0;
+ synhw.capCoveredPad = (status[0] & 0x80) != 0;
+
+ if (synhw.capReportsMax) {
+ if (!set_mouse_scaling(kbdc, 1))
+ return (FALSE);
+ if (mouse_ext_command(kbdc, 0x0d) == 0)
+ return (FALSE);
+ if (get_mouse_status(kbdc, status, 0, 3) != 3)
+ return (FALSE);
+
+ synhw.maximumXCoord = (status[0] << 5) |
+ ((status[1] & 0x0f) << 1);
+ synhw.maximumYCoord = (status[2] << 5) |
+ ((status[1] & 0xf0) >> 3);
+ }
+ if (synhw.capReportsMin) {
+ if (!set_mouse_scaling(kbdc, 1))
+ return (FALSE);
+ if (mouse_ext_command(kbdc, 0x0f) == 0)
+ return (FALSE);
+ if (get_mouse_status(kbdc, status, 0, 3) != 3)
+ return (FALSE);
+
+ synhw.minimumXCoord = (status[0] << 5) |
+ ((status[1] & 0x0f) << 1);
+ synhw.minimumYCoord = (status[2] << 5) |
+ ((status[1] & 0xf0) >> 3);
+ }
+
+ if (verbose >= 2) {
+ printf(" Continued capabilities:\n");
+ printf(" capClickPad: %d\n",
+ synhw.capClickPad);
+ printf(" capDeluxeLEDs: %d\n",
+ synhw.capDeluxeLEDs);
+ printf(" noAbsoluteFilter: %d\n",
+ synhw.noAbsoluteFilter);
+ printf(" capReportsV: %d\n",
+ synhw.capReportsV);
+ printf(" capUniformClickPad: %d\n",
+ synhw.capUniformClickPad);
+ printf(" capReportsMin: %d\n",
+ synhw.capReportsMin);
+ printf(" capInterTouch: %d\n",
+ synhw.capInterTouch);
+ printf(" capReportsMax: %d\n",
+ synhw.capReportsMax);
+ printf(" capClearPad: %d\n",
+ synhw.capClearPad);
+ printf(" capAdvancedGestures: %d\n",
+ synhw.capAdvancedGestures);
+ printf(" capCoveredPad: %d\n",
+ synhw.capCoveredPad);
+ if (synhw.capReportsMax) {
+ printf(" maximumXCoord: %d\n",
+ synhw.maximumXCoord);
+ printf(" maximumYCoord: %d\n",
+ synhw.maximumYCoord);
+ }
+ if (synhw.capReportsMin) {
+ printf(" minimumXCoord: %d\n",
+ synhw.minimumXCoord);
+ printf(" minimumYCoord: %d\n",
+ synhw.minimumYCoord);
+ }
+ }
+ buttons += synhw.capClickPad;
+ }
}
+
if (verbose >= 2) {
if (synhw.capExtended)
printf(" Additional Buttons: %d\n", buttons);
@@ -4650,42 +4806,6 @@ enable_synaptics(KBDC kbdc, struct psm_softc *sc)
printf(" No extended capabilities\n");
}
- /* Read the continued capabilities bits. */
- if (mouse_ext_command(kbdc, 0xc) != 0 &&
- get_mouse_status(kbdc, status, 0, 3) == 3) {
- synhw.capClickPad = (status[1] & 0x01) << 1;
- synhw.capClickPad |= (status[0] & 0x10) != 0;
- synhw.capDeluxeLEDs = (status[1] & 0x02) != 0;
- synhw.noAbsoluteFilter = (status[1] & 0x04) != 0;
- synhw.capReportsV = (status[1] & 0x08) != 0;
- synhw.capUniformClickPad = (status[1] & 0x10) != 0;
- synhw.capReportsMin = (status[1] & 0x20) != 0;
- synhw.capInterTouch = (status[1] & 0x40) != 0;
- synhw.capReportsMax = (status[2] & 0x02) != 0;
- synhw.capClearPad = (status[2] & 0x04) != 0;
- synhw.capAdvancedGestures = (status[2] & 0x08) != 0;
- synhw.capCoveredPad = (status[2] & 0x80) != 0;
-
- if (verbose >= 2) {
- printf(" Continued capabilities:\n");
- printf(" capClickPad: %d\n", synhw.capClickPad);
- printf(" capDeluxeLEDs: %d\n", synhw.capDeluxeLEDs);
- printf(" noAbsoluteFilter: %d\n",
- synhw.noAbsoluteFilter);
- printf(" capReportsV: %d\n", synhw.capReportsV);
- printf(" capUniformClickPad: %d\n",
- synhw.capUniformClickPad);
- printf(" capReportsMin: %d\n", synhw.capReportsMin);
- printf(" capInterTouch: %d\n", synhw.capInterTouch);
- printf(" capReportsMax: %d\n", synhw.capReportsMax);
- printf(" capClearPad: %d\n", synhw.capClearPad);
- printf(" capAdvancedGestures: %d\n",
- synhw.capAdvancedGestures);
- printf(" capCoveredPad: %d\n", synhw.capCoveredPad);
- }
- buttons += synhw.capClickPad;
- }
-
/*
* Add the default number of 3 buttons to the total
* count of supported buttons reported above.
@@ -4713,15 +4833,10 @@ enable_synaptics(KBDC kbdc, struct psm_softc *sc)
if (!synaptics_support)
return (FALSE);
- /* Set the mode byte; request wmode where available. */
- mouse_ext_command(kbdc, synhw.capExtended ? 0xc1 : 0xc0);
-
- /* "Commit" the Set Mode Byte command sent above. */
- set_mouse_sampling_rate(kbdc, 20);
-
VLOG(3, (LOG_DEBUG, "synaptics: END init (%d buttons)\n", buttons));
if (sc != NULL) {
+ synaptics_set_mode(sc, synaptics_preferred_mode(sc));
if (trackpoint_support && synhw.capPassthrough) {
synaptics_passthrough_on(sc);
enable_trackpoint(kbdc, sc);
@@ -4738,30 +4853,17 @@ enable_synaptics(KBDC kbdc, struct psm_softc *sc)
static void
synaptics_passthrough_on(struct psm_softc *sc)
{
- int mode_byte;
-
- mode_byte = 0xc1 | (1 << 5);
- VLOG(2, (LOG_NOTICE, "psm: setting pass-through mode. %d\n",
- mode_byte));
- mouse_ext_command(sc->kbdc, mode_byte);
-
- /* "Commit" the Set Mode Byte command sent above. */
- set_mouse_sampling_rate(sc->kbdc, 20);
+ VLOG(2, (LOG_NOTICE, "psm: setting pass-through mode.\n"));
+ synaptics_set_mode(sc, synaptics_preferred_mode(sc) | (1 << 5));
}
static void
synaptics_passthrough_off(struct psm_softc *sc)
{
- int mode_byte;
-
- mode_byte = 0xc1;
VLOG(2, (LOG_NOTICE, "psm: turning pass-through mode off.\n"));
set_mouse_scaling(sc->kbdc, 2);
set_mouse_scaling(sc->kbdc, 1);
- mouse_ext_command(sc->kbdc, mode_byte);
-
- /* "Commit" the Set Mode Byte command sent above. */
- set_mouse_sampling_rate(sc->kbdc, 20);
+ synaptics_set_mode(sc, synaptics_preferred_mode(sc));
}
/* IBM/Lenovo TrackPoint */
diff --git a/sys/dev/bxe/bxe.c b/sys/dev/bxe/bxe.c
index a35d4c3..00e367a 100644
--- a/sys/dev/bxe/bxe.c
+++ b/sys/dev/bxe/bxe.c
@@ -27,7 +27,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#define BXE_DRIVER_VERSION "1.78.78"
+#define BXE_DRIVER_VERSION "1.78.79"
#include "bxe.h"
#include "ecore_sp.h"
@@ -472,6 +472,8 @@ static const struct {
4, STATS_FLAGS_FUNC, "rx_pkts"},
{ STATS_OFFSET32(rx_tpa_pkts),
4, STATS_FLAGS_FUNC, "rx_tpa_pkts"},
+ { STATS_OFFSET32(rx_jumbo_sge_pkts),
+ 4, STATS_FLAGS_FUNC, "rx_jumbo_sge_pkts"},
{ STATS_OFFSET32(rx_soft_errors),
4, STATS_FLAGS_FUNC, "rx_soft_errors"},
{ STATS_OFFSET32(rx_hw_csum_errors),
@@ -583,6 +585,8 @@ static const struct {
4, "rx_pkts"},
{ Q_STATS_OFFSET32(rx_tpa_pkts),
4, "rx_tpa_pkts"},
+ { Q_STATS_OFFSET32(rx_jumbo_sge_pkts),
+ 4, "rx_jumbo_sge_pkts"},
{ Q_STATS_OFFSET32(rx_soft_errors),
4, "rx_soft_errors"},
{ Q_STATS_OFFSET32(rx_hw_csum_errors),
@@ -3100,7 +3104,7 @@ static inline void
bxe_update_sge_prod(struct bxe_softc *sc,
struct bxe_fastpath *fp,
uint16_t sge_len,
- struct eth_end_agg_rx_cqe *cqe)
+ union eth_sgl_or_raw_data *cqe)
{
uint16_t last_max, last_elem, first_elem;
uint16_t delta = 0;
@@ -3113,17 +3117,17 @@ bxe_update_sge_prod(struct bxe_softc *sc,
/* first mark all used pages */
for (i = 0; i < sge_len; i++) {
BIT_VEC64_CLEAR_BIT(fp->sge_mask,
- RX_SGE(le16toh(cqe->sgl_or_raw_data.sgl[i])));
+ RX_SGE(le16toh(cqe->sgl[i])));
}
BLOGD(sc, DBG_LRO,
"fp[%02d] fp_cqe->sgl[%d] = %d\n",
fp->index, sge_len - 1,
- le16toh(cqe->sgl_or_raw_data.sgl[sge_len - 1]));
+ le16toh(cqe->sgl[sge_len - 1]));
/* assume that the last SGE index is the biggest */
bxe_update_last_max_sge(fp,
- le16toh(cqe->sgl_or_raw_data.sgl[sge_len - 1]));
+ le16toh(cqe->sgl[sge_len - 1]));
last_max = RX_SGE(fp->last_max_sge);
last_elem = last_max >> BIT_VEC64_ELEM_SHIFT;
@@ -3239,6 +3243,53 @@ bxe_tpa_stop_exit:
}
static uint8_t
+bxe_service_rxsgl(
+ struct bxe_fastpath *fp,
+ uint16_t len,
+ uint16_t lenonbd,
+ struct mbuf *m,
+ struct eth_fast_path_rx_cqe *cqe_fp)
+{
+ struct mbuf *m_frag;
+ uint16_t frags, frag_len;
+ uint16_t sge_idx = 0;
+ uint16_t j;
+ uint8_t i, rc = 0;
+ uint32_t frag_size;
+
+ /* adjust the mbuf */
+ m->m_len = lenonbd;
+
+ frag_size = len - lenonbd;
+ frags = SGE_PAGE_ALIGN(frag_size) >> SGE_PAGE_SHIFT;
+
+ for (i = 0, j = 0; i < frags; i += PAGES_PER_SGE, j++) {
+ sge_idx = RX_SGE(le16toh(cqe_fp->sgl_or_raw_data.sgl[j]));
+
+ m_frag = fp->rx_sge_mbuf_chain[sge_idx].m;
+ frag_len = min(frag_size, (uint32_t)(SGE_PAGE_SIZE));
+ m_frag->m_len = frag_len;
+
+ /* allocate a new mbuf for the SGE */
+ rc = bxe_alloc_rx_sge_mbuf(fp, sge_idx);
+ if (rc) {
+ /* Leave all remaining SGEs in the ring! */
+ return (rc);
+ }
+ fp->eth_q_stats.mbuf_alloc_sge--;
+
+ /* concatenate the fragment to the head mbuf */
+ m_cat(m, m_frag);
+
+ frag_size -= frag_len;
+ }
+
+ bxe_update_sge_prod(fp->sc, fp, frags, &cqe_fp->sgl_or_raw_data);
+
+ return rc;
+}
+
+static uint8_t
bxe_rxeof(struct bxe_softc *sc,
struct bxe_fastpath *fp)
{
@@ -3278,7 +3329,7 @@ bxe_rxeof(struct bxe_softc *sc,
struct eth_fast_path_rx_cqe *cqe_fp;
uint8_t cqe_fp_flags;
enum eth_rx_cqe_type cqe_fp_type;
- uint16_t len, pad;
+ uint16_t len, lenonbd, pad;
struct mbuf *m = NULL;
comp_ring_cons = RCQ(sw_cq_cons);
@@ -3293,7 +3344,7 @@ bxe_rxeof(struct bxe_softc *sc,
BLOGD(sc, DBG_RX,
"fp[%02d] Rx hw_cq_cons=%d hw_sw_cons=%d "
"BD prod=%d cons=%d CQE type=0x%x err=0x%x "
- "status=0x%x rss_hash=0x%x vlan=0x%x len=%u\n",
+ "status=0x%x rss_hash=0x%x vlan=0x%x len=%u lenonbd=%u\n",
fp->index,
hw_cq_cons,
sw_cq_cons,
@@ -3304,7 +3355,8 @@ bxe_rxeof(struct bxe_softc *sc,
cqe_fp->status_flags,
le32toh(cqe_fp->rss_hash_result),
le16toh(cqe_fp->vlan_tag),
- le16toh(cqe_fp->pkt_len_or_gro_seg_len));
+ le16toh(cqe_fp->pkt_len_or_gro_seg_len),
+ le16toh(cqe_fp->len_on_bd));
/* is this a slowpath msg? */
if (__predict_false(CQE_TYPE_SLOW(cqe_fp_type))) {
@@ -3351,7 +3403,7 @@ bxe_rxeof(struct bxe_softc *sc,
bxe_tpa_stop(sc, fp, tpa_info, queue, pages,
&cqe->end_agg_cqe, comp_ring_cons);
- bxe_update_sge_prod(sc, fp, pages, &cqe->end_agg_cqe);
+ bxe_update_sge_prod(sc, fp, pages, &cqe->end_agg_cqe.sgl_or_raw_data);
goto next_cqe;
}
@@ -3367,6 +3419,7 @@ bxe_rxeof(struct bxe_softc *sc,
}
len = le16toh(cqe_fp->pkt_len_or_gro_seg_len);
+ lenonbd = le16toh(cqe_fp->len_on_bd);
pad = cqe_fp->placement_offset;
m = rx_buf->m;
@@ -3413,6 +3466,13 @@ bxe_rxeof(struct bxe_softc *sc,
m_adj(m, pad);
m->m_pkthdr.len = m->m_len = len;
+ if (len != lenonbd){
+ rc = bxe_service_rxsgl(fp, len, lenonbd, m, cqe_fp);
+ if (rc)
+ break;
+ fp->eth_q_stats.rx_jumbo_sge_pkts++;
+ }
+
/* assign packet to this interface interface */
if_setrcvif(m, ifp);
@@ -6210,30 +6270,27 @@ static void
bxe_set_fp_rx_buf_size(struct bxe_softc *sc)
{
int i;
+ uint32_t rx_buf_size;
- BLOGD(sc, DBG_LOAD, "mtu = %d\n", sc->mtu);
+ rx_buf_size = (IP_HEADER_ALIGNMENT_PADDING + ETH_OVERHEAD + sc->mtu);
for (i = 0; i < sc->num_queues; i++) {
- /* get the Rx buffer size for RX frames */
- sc->fp[i].rx_buf_size =
- (IP_HEADER_ALIGNMENT_PADDING +
- ETH_OVERHEAD +
- sc->mtu);
-
- BLOGD(sc, DBG_LOAD, "rx_buf_size for fp[%02d] = %d\n",
- i, sc->fp[i].rx_buf_size);
-
- /* get the mbuf allocation size for RX frames */
- if (sc->fp[i].rx_buf_size <= MCLBYTES) {
+ if(rx_buf_size <= MCLBYTES){
+ sc->fp[i].rx_buf_size = rx_buf_size;
+ sc->fp[i].mbuf_alloc_size = MCLBYTES;
+ }else if (rx_buf_size <= MJUMPAGESIZE){
+ sc->fp[i].rx_buf_size = rx_buf_size;
+ sc->fp[i].mbuf_alloc_size = MJUMPAGESIZE;
+ }else if (rx_buf_size <= (MJUMPAGESIZE + MCLBYTES)){
+ sc->fp[i].rx_buf_size = MCLBYTES;
+ sc->fp[i].mbuf_alloc_size = MCLBYTES;
+ }else if (rx_buf_size <= (2 * MJUMPAGESIZE)){
+ sc->fp[i].rx_buf_size = MJUMPAGESIZE;
+ sc->fp[i].mbuf_alloc_size = MJUMPAGESIZE;
+ }else {
+ sc->fp[i].rx_buf_size = MCLBYTES;
sc->fp[i].mbuf_alloc_size = MCLBYTES;
- } else if (sc->fp[i].rx_buf_size <= BCM_PAGE_SIZE) {
- sc->fp[i].mbuf_alloc_size = PAGE_SIZE;
- } else {
- sc->fp[i].mbuf_alloc_size = MJUM9BYTES;
}
-
- BLOGD(sc, DBG_LOAD, "mbuf_alloc_size for fp[%02d] = %d\n",
- i, sc->fp[i].mbuf_alloc_size);
}
}
@@ -6792,42 +6849,40 @@ bxe_alloc_fp_buffers(struct bxe_softc *sc)
fp->rx_cq_prod = cqe_ring_prod;
fp->eth_q_stats.rx_calls = fp->eth_q_stats.rx_pkts = 0;
- if (if_getcapenable(sc->ifp) & IFCAP_LRO) {
- max_agg_queues = MAX_AGG_QS(sc);
+ max_agg_queues = MAX_AGG_QS(sc);
- fp->tpa_enable = TRUE;
+ fp->tpa_enable = TRUE;
- /* fill the TPA pool */
- for (j = 0; j < max_agg_queues; j++) {
- rc = bxe_alloc_rx_tpa_mbuf(fp, j);
- if (rc != 0) {
- BLOGE(sc, "mbuf alloc fail for fp[%02d] TPA queue %d\n",
+ /* fill the TPA pool */
+ for (j = 0; j < max_agg_queues; j++) {
+ rc = bxe_alloc_rx_tpa_mbuf(fp, j);
+ if (rc != 0) {
+ BLOGE(sc, "mbuf alloc fail for fp[%02d] TPA queue %d\n",
i, j);
- fp->tpa_enable = FALSE;
- goto bxe_alloc_fp_buffers_error;
- }
-
- fp->rx_tpa_info[j].state = BXE_TPA_STATE_STOP;
+ fp->tpa_enable = FALSE;
+ goto bxe_alloc_fp_buffers_error;
}
- if (fp->tpa_enable) {
- /* fill the RX SGE chain */
- ring_prod = 0;
- for (j = 0; j < RX_SGE_USABLE; j++) {
- rc = bxe_alloc_rx_sge_mbuf(fp, ring_prod);
- if (rc != 0) {
- BLOGE(sc, "mbuf alloc fail for fp[%02d] SGE %d\n",
- i, ring_prod);
- fp->tpa_enable = FALSE;
- ring_prod = 0;
- goto bxe_alloc_fp_buffers_error;
- }
+ fp->rx_tpa_info[j].state = BXE_TPA_STATE_STOP;
+ }
- ring_prod = RX_SGE_NEXT(ring_prod);
+ if (fp->tpa_enable) {
+ /* fill the RX SGE chain */
+ ring_prod = 0;
+ for (j = 0; j < RX_SGE_USABLE; j++) {
+ rc = bxe_alloc_rx_sge_mbuf(fp, ring_prod);
+ if (rc != 0) {
+ BLOGE(sc, "mbuf alloc fail for fp[%02d] SGE %d\n",
+ i, ring_prod);
+ fp->tpa_enable = FALSE;
+ ring_prod = 0;
+ goto bxe_alloc_fp_buffers_error;
}
- fp->rx_sge_prod = ring_prod;
+ ring_prod = RX_SGE_NEXT(ring_prod);
}
+
+ fp->rx_sge_prod = ring_prod;
}
}
@@ -11711,28 +11766,26 @@ bxe_pf_rx_q_prep(struct bxe_softc *sc,
uint16_t sge_sz = 0;
uint16_t tpa_agg_size = 0;
- if (if_getcapenable(sc->ifp) & IFCAP_LRO) {
- pause->sge_th_lo = SGE_TH_LO(sc);
- pause->sge_th_hi = SGE_TH_HI(sc);
+ pause->sge_th_lo = SGE_TH_LO(sc);
+ pause->sge_th_hi = SGE_TH_HI(sc);
- /* validate SGE ring has enough to cross high threshold */
- if (sc->dropless_fc &&
+ /* validate SGE ring has enough to cross high threshold */
+ if (sc->dropless_fc &&
(pause->sge_th_hi + FW_PREFETCH_CNT) >
(RX_SGE_USABLE_PER_PAGE * RX_SGE_NUM_PAGES)) {
- BLOGW(sc, "sge ring threshold limit\n");
- }
+ BLOGW(sc, "sge ring threshold limit\n");
+ }
- /* minimum max_aggregation_size is 2*MTU (two full buffers) */
- tpa_agg_size = (2 * sc->mtu);
- if (tpa_agg_size < sc->max_aggregation_size) {
- tpa_agg_size = sc->max_aggregation_size;
- }
+ /* minimum max_aggregation_size is 2*MTU (two full buffers) */
+ tpa_agg_size = (2 * sc->mtu);
+ if (tpa_agg_size < sc->max_aggregation_size) {
+ tpa_agg_size = sc->max_aggregation_size;
+ }
- max_sge = SGE_PAGE_ALIGN(sc->mtu) >> SGE_PAGE_SHIFT;
- max_sge = ((max_sge + PAGES_PER_SGE - 1) &
+ max_sge = SGE_PAGE_ALIGN(sc->mtu) >> SGE_PAGE_SHIFT;
+ max_sge = ((max_sge + PAGES_PER_SGE - 1) &
(~(PAGES_PER_SGE - 1))) >> PAGES_PER_SGE_SHIFT;
- sge_sz = (uint16_t)min(SGE_PAGES, 0xffff);
- }
+ sge_sz = (uint16_t)min(SGE_PAGES, 0xffff);
/* pause - not for e1 */
if (!CHIP_IS_E1(sc)) {
diff --git a/sys/dev/bxe/bxe_stats.c b/sys/dev/bxe/bxe_stats.c
index 3d33fb7..b2cc676 100644
--- a/sys/dev/bxe/bxe_stats.c
+++ b/sys/dev/bxe/bxe_stats.c
@@ -1227,6 +1227,7 @@ bxe_drv_stats_update(struct bxe_softc *sc)
UPDATE_ESTAT_QSTAT(rx_calls);
UPDATE_ESTAT_QSTAT(rx_pkts);
UPDATE_ESTAT_QSTAT(rx_tpa_pkts);
+ UPDATE_ESTAT_QSTAT(rx_jumbo_sge_pkts);
UPDATE_ESTAT_QSTAT(rx_soft_errors);
UPDATE_ESTAT_QSTAT(rx_hw_csum_errors);
UPDATE_ESTAT_QSTAT(rx_ofld_frames_csum_ip);
diff --git a/sys/dev/bxe/bxe_stats.h b/sys/dev/bxe/bxe_stats.h
index ed37f55..badb4b7 100644
--- a/sys/dev/bxe/bxe_stats.h
+++ b/sys/dev/bxe/bxe_stats.h
@@ -218,6 +218,7 @@ struct bxe_eth_stats {
uint32_t rx_calls;
uint32_t rx_pkts;
uint32_t rx_tpa_pkts;
+ uint32_t rx_jumbo_sge_pkts;
uint32_t rx_soft_errors;
uint32_t rx_hw_csum_errors;
uint32_t rx_ofld_frames_csum_ip;
@@ -318,6 +319,7 @@ struct bxe_eth_q_stats {
uint32_t rx_calls;
uint32_t rx_pkts;
uint32_t rx_tpa_pkts;
+ uint32_t rx_jumbo_sge_pkts;
uint32_t rx_soft_errors;
uint32_t rx_hw_csum_errors;
uint32_t rx_ofld_frames_csum_ip;
@@ -411,6 +413,7 @@ struct bxe_eth_q_stats_old {
uint32_t rx_calls_old;
uint32_t rx_pkts_old;
uint32_t rx_tpa_pkts_old;
+ uint32_t rx_jumbo_sge_pkts_old;
uint32_t rx_soft_errors_old;
uint32_t rx_hw_csum_errors_old;
uint32_t rx_ofld_frames_csum_ip_old;
diff --git a/sys/dev/ce/if_ce.c b/sys/dev/ce/if_ce.c
index 7d81720..8ef3e1e 100644
--- a/sys/dev/ce/if_ce.c
+++ b/sys/dev/ce/if_ce.c
@@ -104,10 +104,6 @@ __FBSDID("$FreeBSD$");
#define CE_DEBUG2(d,s) ({if (d->chan->debug>1) {\
printf ("%s: ", d->name); printf s;}})
-#ifndef CALLOUT_MPSAFE
-#define CALLOUT_MPSAFE 0
-#endif
-
#ifndef IF_DRAIN
#define IF_DRAIN(ifq) do { \
struct mbuf *m; \
@@ -609,7 +605,7 @@ static int ce_attach (device_t dev)
return (ENXIO);
}
#if __FreeBSD_version >= 500000
- callout_init (&led_timo[unit], CALLOUT_MPSAFE);
+ callout_init (&led_timo[unit], 1);
#else
callout_init (&led_timo[unit]);
#endif
@@ -661,7 +657,7 @@ static int ce_attach (device_t dev)
continue;
d = c->sys;
- callout_init (&d->timeout_handle, CALLOUT_MPSAFE);
+ callout_init (&d->timeout_handle, 1);
#ifdef NETGRAPH
if (ng_make_node_common (&typestruct, &d->node) != 0) {
printf ("%s: cannot make common node\n", d->name);
@@ -2558,7 +2554,7 @@ static int ce_modevent (module_t mod, int type, void *unused)
cdevsw_add (&ce_cdevsw);
#endif
#if __FreeBSD_version >= 500000
- callout_init (&timeout_handle, CALLOUT_MPSAFE);
+ callout_init (&timeout_handle, 1);
#else
callout_init (&timeout_handle);
#endif
diff --git a/sys/dev/cp/if_cp.c b/sys/dev/cp/if_cp.c
index 3d07ef2..44791d0 100644
--- a/sys/dev/cp/if_cp.c
+++ b/sys/dev/cp/if_cp.c
@@ -445,7 +445,7 @@ static int cp_attach (device_t dev)
splx (s);
return (ENXIO);
}
- callout_init (&led_timo[unit], CALLOUT_MPSAFE);
+ callout_init (&led_timo[unit], 1);
error = bus_setup_intr (dev, bd->cp_irq,
INTR_TYPE_NET|INTR_MPSAFE,
NULL, cp_intr, bd, &bd->cp_intrhand);
@@ -474,7 +474,7 @@ static int cp_attach (device_t dev)
d->board = b;
d->chan = c;
c->sys = d;
- callout_init (&d->timeout_handle, CALLOUT_MPSAFE);
+ callout_init (&d->timeout_handle, 1);
#ifdef NETGRAPH
if (ng_make_node_common (&typestruct, &d->node) != 0) {
printf ("%s: cannot make common node\n", d->name);
@@ -2223,7 +2223,7 @@ static int cp_modevent (module_t mod, int type, void *unused)
printf ("Failed to register ng_cp\n");
#endif
++load_count;
- callout_init (&timeout_handle, CALLOUT_MPSAFE);
+ callout_init (&timeout_handle, 1);
callout_reset (&timeout_handle, hz*5, cp_timeout, 0);
break;
case MOD_UNLOAD:
diff --git a/sys/dev/ctau/if_ct.c b/sys/dev/ctau/if_ct.c
index 2e9d2e2..e7b8927 100644
--- a/sys/dev/ctau/if_ct.c
+++ b/sys/dev/ctau/if_ct.c
@@ -646,7 +646,7 @@ static int ct_attach (device_t dev)
return ENXIO;
}
- callout_init (&led_timo[unit], CALLOUT_MPSAFE);
+ callout_init (&led_timo[unit], 1);
s = splimp ();
if (bus_setup_intr (dev, bd->irq_res,
INTR_TYPE_NET|INTR_MPSAFE,
@@ -685,7 +685,7 @@ static int ct_attach (device_t dev)
c->sys = d;
channel [b->num*NCHAN + c->num] = d;
sprintf (d->name, "ct%d.%d", b->num, c->num);
- callout_init (&d->timeout_handle, CALLOUT_MPSAFE);
+ callout_init (&d->timeout_handle, 1);
#ifdef NETGRAPH
if (ng_make_node_common (&typestruct, &d->node) != 0) {
@@ -2162,7 +2162,7 @@ static int ct_modevent (module_t mod, int type, void *unused)
printf ("Failed to register ng_ct\n");
#endif
++load_count;
- callout_init (&timeout_handle, CALLOUT_MPSAFE);
+ callout_init (&timeout_handle, 1);
callout_reset (&timeout_handle, hz*5, ct_timeout, 0);
break;
case MOD_UNLOAD:
diff --git a/sys/dev/cx/if_cx.c b/sys/dev/cx/if_cx.c
index 2327403..cac69ab 100644
--- a/sys/dev/cx/if_cx.c
+++ b/sys/dev/cx/if_cx.c
@@ -746,7 +746,7 @@ static int cx_attach (device_t dev)
return ENXIO;
}
b->sys = bd;
- callout_init (&led_timo[b->num], CALLOUT_MPSAFE);
+ callout_init (&led_timo[b->num], 1);
s = splhigh ();
if (bus_setup_intr (dev, bd->irq_res,
INTR_TYPE_NET|INTR_MPSAFE,
@@ -796,7 +796,7 @@ static int cx_attach (device_t dev)
case T_UNIV_RS232:
case T_UNIV_RS449:
case T_UNIV_V35:
- callout_init (&d->timeout_handle, CALLOUT_MPSAFE);
+ callout_init (&d->timeout_handle, 1);
#ifdef NETGRAPH
if (ng_make_node_common (&typestruct, &d->node) != 0) {
printf ("%s: cannot make common node\n", d->name);
@@ -867,7 +867,7 @@ static int cx_attach (device_t dev)
ttycreate(d->tty, TS_CALLOUT, "x%r%r", b->num, c->num);
d->devt = make_dev (&cx_cdevsw, b->num*NCHAN + c->num + 64, UID_ROOT, GID_WHEEL, 0600, "cx%d", b->num*NCHAN + c->num);
d->devt->si_drv1 = d;
- callout_init (&d->dcd_timeout_handle, CALLOUT_MPSAFE);
+ callout_init (&d->dcd_timeout_handle, 1);
}
splx (s);
@@ -2497,7 +2497,7 @@ static int cx_modevent (module_t mod, int type, void *unused)
#endif
++load_count;
- callout_init (&timeout_handle, CALLOUT_MPSAFE);
+ callout_init (&timeout_handle, 1);
callout_reset (&timeout_handle, hz*5, cx_timeout, 0);
/* Software interrupt. */
swi_add(&tty_intr_event, "cx", cx_softintr, NULL, SWI_TTY,
diff --git a/sys/dev/cxgb/cxgb_main.c b/sys/dev/cxgb/cxgb_main.c
index 1d8ebc9..c03d70c 100644
--- a/sys/dev/cxgb/cxgb_main.c
+++ b/sys/dev/cxgb/cxgb_main.c
@@ -592,7 +592,7 @@ cxgb_controller_attach(device_t dev)
/* Create a periodic callout for checking adapter status */
- callout_init(&sc->cxgb_tick_ch, TRUE);
+ callout_init(&sc->cxgb_tick_ch, 1);
if (t3_check_fw_version(sc) < 0 || force_fw_update) {
/*
@@ -1006,7 +1006,7 @@ cxgb_port_attach(device_t dev)
device_get_unit(device_get_parent(dev)), p->port_id);
PORT_LOCK_INIT(p, p->lockbuf);
- callout_init(&p->link_check_ch, CALLOUT_MPSAFE);
+ callout_init(&p->link_check_ch, 1);
TASK_INIT(&p->link_check_task, 0, check_link_status, p);
/* Allocate an ifnet object and set it up */
diff --git a/sys/dev/cxgb/cxgb_sge.c b/sys/dev/cxgb/cxgb_sge.c
index 71087cc..a749900 100644
--- a/sys/dev/cxgb/cxgb_sge.c
+++ b/sys/dev/cxgb/cxgb_sge.c
@@ -1008,7 +1008,7 @@ sge_timer_cb(void *arg)
int
t3_sge_init_adapter(adapter_t *sc)
{
- callout_init(&sc->sge_timer_ch, CALLOUT_MPSAFE);
+ callout_init(&sc->sge_timer_ch, 1);
callout_reset(&sc->sge_timer_ch, TX_RECLAIM_PERIOD, sge_timer_cb, sc);
TASK_INIT(&sc->slow_intr_task, 0, sge_slow_intr_handler, sc);
return (0);
diff --git a/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c b/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c
index eba1ab7..7b43560 100644
--- a/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c
+++ b/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_cm.c
@@ -163,7 +163,7 @@ start_ep_timer(struct iwch_ep *ep)
* XXX this looks racy
*/
get_ep(&ep->com);
- callout_init(&ep->timer, TRUE);
+ callout_init(&ep->timer, 1);
}
callout_reset(&ep->timer, ep_timeout_secs * hz, ep_timeout, ep);
}
@@ -1307,7 +1307,7 @@ iwch_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
err = (-ENOMEM);
goto out;
}
- callout_init(&ep->timer, TRUE);
+ callout_init(&ep->timer, 1);
ep->plen = conn_param->private_data_len;
if (ep->plen)
memcpy(ep->mpa_pkt + sizeof(struct mpa_message),
@@ -1598,7 +1598,7 @@ process_newconn(struct iwch_ep *parent_ep)
free(remote, M_SONAME);
get_ep(&parent_ep->com);
child_ep->parent_ep = parent_ep;
- callout_init(&child_ep->timer, TRUE);
+ callout_init(&child_ep->timer, 1);
state_set(&child_ep->com, MPA_REQ_WAIT);
start_ep_timer(child_ep);
diff --git a/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c b/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
index 9a3d75f..8f4980f 100644
--- a/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
+++ b/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
@@ -906,7 +906,7 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd,
insert_mmap(ucontext, mm2);
}
qhp->ibqp.qp_num = qhp->wq.qpid;
- callout_init(&(qhp->timer), TRUE);
+ callout_init(&(qhp->timer), 1);
CTR6(KTR_IW_CXGB, "sq_num_entries %d, rq_num_entries %d "
"qpid 0x%0x qhp %p dma_addr 0x%llx size %d",
qhp->attr.sq_num_entries, qhp->attr.rq_num_entries,
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index 4bbb55e..f5b2644 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -613,7 +613,7 @@ t4_attach(device_t dev)
mtx_init(&sc->sfl_lock, "starving freelists", 0, MTX_DEF);
TAILQ_INIT(&sc->sfl);
- callout_init(&sc->sfl_callout, CALLOUT_MPSAFE);
+ callout_init(&sc->sfl_callout, 1);
mtx_init(&sc->regwin_lock, "register and memory window", 0, MTX_DEF);
@@ -1082,7 +1082,7 @@ cxgbe_attach(device_t dev)
pi->ifp = ifp;
ifp->if_softc = pi;
- callout_init(&pi->tick, CALLOUT_MPSAFE);
+ callout_init(&pi->tick, 1);
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
diff --git a/sys/dev/dcons/dcons_os.c b/sys/dev/dcons/dcons_os.c
index bf0be0b..01e6166 100644
--- a/sys/dev/dcons/dcons_os.c
+++ b/sys/dev/dcons/dcons_os.c
@@ -374,7 +374,7 @@ dcons_attach(void)
dcons_attach_port(DCONS_CON, "dcons", 0);
dcons_attach_port(DCONS_GDB, "dgdb", DC_GDB);
- callout_init(&dcons_callout, CALLOUT_MPSAFE);
+ callout_init(&dcons_callout, 1);
polltime = hz / poll_hz;
callout_reset(&dcons_callout, polltime, dcons_timeout, NULL);
return(0);
diff --git a/sys/dev/drm2/drm_irq.c b/sys/dev/drm2/drm_irq.c
index f93cd38..bb13f90 100644
--- a/sys/dev/drm2/drm_irq.c
+++ b/sys/dev/drm2/drm_irq.c
@@ -210,7 +210,7 @@ int drm_vblank_init(struct drm_device *dev, int num_crtcs)
{
int i, ret = -ENOMEM;
- callout_init(&dev->vblank_disable_callout, CALLOUT_MPSAFE);
+ callout_init(&dev->vblank_disable_callout, 1);
mtx_init(&dev->vbl_lock, "drmvbl", NULL, MTX_DEF);
mtx_init(&dev->vblank_time_lock, "drmvtl", NULL, MTX_DEF);
diff --git a/sys/dev/drm2/i915/intel_display.c b/sys/dev/drm2/i915/intel_display.c
index aafd4fa..b460902 100644
--- a/sys/dev/drm2/i915/intel_display.c
+++ b/sys/dev/drm2/i915/intel_display.c
@@ -6449,7 +6449,7 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
intel_crtc->busy = false;
- callout_init(&intel_crtc->idle_callout, CALLOUT_MPSAFE);
+ callout_init(&intel_crtc->idle_callout, 1);
}
int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
@@ -7038,7 +7038,7 @@ void intel_modeset_init(struct drm_device *dev)
intel_setup_outputs(dev);
TASK_INIT(&dev_priv->idle_task, 0, intel_idle_update, dev_priv);
- callout_init(&dev_priv->idle_callout, CALLOUT_MPSAFE);
+ callout_init(&dev_priv->idle_callout, 1);
}
void intel_modeset_gem_init(struct drm_device *dev)
diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c
index 252571b..ab39c43 100644
--- a/sys/dev/e1000/if_em.c
+++ b/sys/dev/e1000/if_em.c
@@ -1609,6 +1609,9 @@ em_msix_link(void *arg)
++adapter->link_irq;
reg_icr = E1000_READ_REG(&adapter->hw, E1000_ICR);
+ if (reg_icr & E1000_ICR_RXO)
+ adapter->rx_overruns++;
+
if (reg_icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) {
adapter->hw.mac.get_link_status = 1;
em_handle_link(adapter, 0);
diff --git a/sys/dev/e1000/if_igb.c b/sys/dev/e1000/if_igb.c
index 49cc16a..6ac6eb6 100644
--- a/sys/dev/e1000/if_igb.c
+++ b/sys/dev/e1000/if_igb.c
@@ -1046,8 +1046,7 @@ igb_mq_start_locked(struct ifnet *ifp, struct tx_ring *txr)
}
drbr_advance(ifp, txr->br);
enq++;
- if_inc_counter(ifp, IFCOUNTER_OBYTES, next->m_pkthdr.len);
- if (next->m_flags & M_MCAST)
+ if (next->m_flags & M_MCAST && adapter->vf_ifp)
if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1);
ETHER_BPF_MTAP(ifp, next);
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
@@ -4055,7 +4054,9 @@ static bool
igb_txeof(struct tx_ring *txr)
{
struct adapter *adapter = txr->adapter;
+#ifdef DEV_NETMAP
struct ifnet *ifp = adapter->ifp;
+#endif /* DEV_NETMAP */
u32 work, processed = 0;
u16 limit = txr->process_limit;
struct igb_tx_buf *buf;
@@ -4130,7 +4131,6 @@ igb_txeof(struct tx_ring *txr)
}
++txr->packets;
++processed;
- if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
txr->watchdog_time = ticks;
/* Try the next packet */
@@ -5127,7 +5127,6 @@ igb_rxeof(struct igb_queue *que, int count, int *done)
if (eop) {
rxr->fmp->m_pkthdr.rcvif = ifp;
- if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
rxr->rx_packets++;
/* capture data for AIM */
rxr->packets++;
@@ -5560,24 +5559,94 @@ igb_led_func(void *arg, int onoff)
}
static uint64_t
+igb_get_vf_counter(if_t ifp, ift_counter cnt)
+{
+ struct adapter *adapter;
+ struct e1000_vf_stats *stats;
+#ifndef IGB_LEGACY_TX
+ struct tx_ring *txr;
+ uint64_t rv;
+#endif
+
+ adapter = if_getsoftc(ifp);
+ stats = (struct e1000_vf_stats *)adapter->stats;
+
+ switch (cnt) {
+ case IFCOUNTER_IPACKETS:
+ return (stats->gprc);
+ case IFCOUNTER_OPACKETS:
+ return (stats->gptc);
+ case IFCOUNTER_IBYTES:
+ return (stats->gorc);
+ case IFCOUNTER_OBYTES:
+ return (stats->gotc);
+ case IFCOUNTER_IMCASTS:
+ return (stats->mprc);
+ case IFCOUNTER_IERRORS:
+ return (adapter->dropped_pkts);
+ case IFCOUNTER_OERRORS:
+ return (adapter->watchdog_events);
+#ifndef IGB_LEGACY_TX
+ case IFCOUNTER_OQDROPS:
+ rv = 0;
+ txr = adapter->tx_rings;
+ for (int i = 0; i < adapter->num_queues; i++, txr++)
+ rv += txr->br->br_drops;
+ return (rv);
+#endif
+ default:
+ return (if_get_counter_default(ifp, cnt));
+ }
+}
+
+static uint64_t
igb_get_counter(if_t ifp, ift_counter cnt)
{
struct adapter *adapter;
struct e1000_hw_stats *stats;
+#ifndef IGB_LEGACY_TX
+ struct tx_ring *txr;
+ uint64_t rv;
+#endif
adapter = if_getsoftc(ifp);
+ if (adapter->vf_ifp)
+ return (igb_get_vf_counter(ifp, cnt));
+
stats = (struct e1000_hw_stats *)adapter->stats;
switch (cnt) {
+ case IFCOUNTER_IPACKETS:
+ return (stats->gprc);
+ case IFCOUNTER_OPACKETS:
+ return (stats->gptc);
+ case IFCOUNTER_IBYTES:
+ return (stats->gorc);
+ case IFCOUNTER_OBYTES:
+ return (stats->gotc);
+ case IFCOUNTER_IMCASTS:
+ return (stats->mprc);
+ case IFCOUNTER_OMCASTS:
+ return (stats->mptc);
case IFCOUNTER_IERRORS:
return (adapter->dropped_pkts + stats->rxerrc +
stats->crcerrs + stats->algnerrc +
- stats->ruc + stats->roc + stats->mpc + stats->cexterr);
+ stats->ruc + stats->roc + stats->cexterr);
case IFCOUNTER_OERRORS:
return (stats->ecol + stats->latecol +
adapter->watchdog_events);
case IFCOUNTER_COLLISIONS:
return (stats->colc);
+ case IFCOUNTER_IQDROPS:
+ return (stats->mpc);
+#ifndef IGB_LEGACY_TX
+ case IFCOUNTER_OQDROPS:
+ rv = 0;
+ txr = adapter->tx_rings;
+ for (int i = 0; i < adapter->num_queues; i++, txr++)
+ rv += txr->br->br_drops;
+ return (rv);
+#endif
default:
return (if_get_counter_default(ifp, cnt));
}
diff --git a/sys/dev/fdt/fdt_common.c b/sys/dev/fdt/fdt_common.c
index f00519e..0198d55 100644
--- a/sys/dev/fdt/fdt_common.c
+++ b/sys/dev/fdt/fdt_common.c
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
#define FDT_COMPAT_LEN 255
#define FDT_TYPE_LEN 64
+#define FDT_NAME_LEN 32
#define FDT_REG_CELLS 4
@@ -310,6 +311,22 @@ fdt_find_compatible(phandle_t start, const char *compat, int strict)
}
phandle_t
+fdt_find_child(phandle_t start, const char *child_name)
+{
+ char name[FDT_NAME_LEN];
+ phandle_t child;
+
+ for (child = OF_child(start); child != 0; child = OF_peer(child)) {
+ if (OF_getprop(child, "name", name, sizeof(name)) <= 0)
+ continue;
+ if (strcmp(name, child_name) == 0)
+ return (child);
+ }
+
+ return (0);
+}
+
+phandle_t
fdt_depth_search_compatible(phandle_t start, const char *compat, int strict)
{
phandle_t child, node;
diff --git a/sys/dev/fdt/fdt_common.h b/sys/dev/fdt/fdt_common.h
index 3d05341..6801297 100644
--- a/sys/dev/fdt/fdt_common.h
+++ b/sys/dev/fdt/fdt_common.h
@@ -81,6 +81,7 @@ u_long fdt_data_get(void *, int);
int fdt_data_to_res(pcell_t *, int, int, u_long *, u_long *);
phandle_t fdt_find_compatible(phandle_t, const char *, int);
phandle_t fdt_depth_search_compatible(phandle_t, const char *, int);
+phandle_t fdt_find_child(phandle_t, const char *);
int fdt_get_mem_regions(struct mem_region *, int *, uint32_t *);
int fdt_get_reserved_regions(struct mem_region *, int *);
int fdt_get_phyaddr(phandle_t, device_t, int *, void **);
diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c
index 585f5bf..4cf063e 100644
--- a/sys/dev/fdt/simplebus.c
+++ b/sys/dev/fdt/simplebus.c
@@ -251,7 +251,7 @@ simplebus_setup_dinfo(device_t dev, phandle_t node,
resource_list_init(&ndi->rl);
ofw_bus_reg_to_rl(dev, node, sc->acells, sc->scells, &ndi->rl);
- ofw_bus_intr_to_rl(dev, node, &ndi->rl);
+ ofw_bus_intr_to_rl(dev, node, &ndi->rl, NULL);
return (ndi);
}
diff --git a/sys/dev/glxsb/glxsb.c b/sys/dev/glxsb/glxsb.c
index 9a467ed..943ce7d 100644
--- a/sys/dev/glxsb/glxsb.c
+++ b/sys/dev/glxsb/glxsb.c
@@ -331,7 +331,7 @@ glxsb_attach(device_t dev)
sc->sc_rnghz = hz / 100;
else
sc->sc_rnghz = 1;
- callout_init(&sc->sc_rngco, CALLOUT_MPSAFE);
+ callout_init(&sc->sc_rngco, 1);
glxsb_rnd(sc);
return (0);
diff --git a/sys/dev/gpio/ofw_gpiobus.c b/sys/dev/gpio/ofw_gpiobus.c
index 368528d..6646b7d 100644
--- a/sys/dev/gpio/ofw_gpiobus.c
+++ b/sys/dev/gpio/ofw_gpiobus.c
@@ -147,7 +147,7 @@ ofw_gpiobus_setup_devinfo(device_t bus, device_t child, phandle_t node)
}
free(pins, M_DEVBUF);
/* Parse the interrupt resources. */
- if (ofw_bus_intr_to_rl(bus, node, &dinfo->opd_dinfo.rl) != 0) {
+ if (ofw_bus_intr_to_rl(bus, node, &dinfo->opd_dinfo.rl, NULL) != 0) {
ofw_gpiobus_destroy_devinfo(bus, dinfo);
return (NULL);
}
diff --git a/sys/dev/gxemul/cons/gxemul_cons.c b/sys/dev/gxemul/cons/gxemul_cons.c
index cb3b000..15deaf0 100644
--- a/sys/dev/gxemul/cons/gxemul_cons.c
+++ b/sys/dev/gxemul/cons/gxemul_cons.c
@@ -279,7 +279,7 @@ gxemul_cons_ttyinit(void *unused)
tp = tty_alloc(&gxemul_cons_ttydevsw, NULL);
tty_init_console(tp, 0);
tty_makedev(tp, NULL, "%s", "ttyu0");
- callout_init(&gxemul_cons_callout, CALLOUT_MPSAFE);
+ callout_init(&gxemul_cons_callout, 1);
callout_reset(&gxemul_cons_callout, gxemul_cons_polltime,
gxemul_cons_timeout, tp);
diff --git a/sys/dev/hifn/hifn7751.c b/sys/dev/hifn/hifn7751.c
index 8330d30..5b72482 100644
--- a/sys/dev/hifn/hifn7751.c
+++ b/sys/dev/hifn/hifn7751.c
@@ -589,7 +589,7 @@ hifn_attach(device_t dev)
if (sc->sc_flags & (HIFN_HAS_PUBLIC | HIFN_HAS_RNG))
hifn_init_pubrng(sc);
- callout_init(&sc->sc_tickto, CALLOUT_MPSAFE);
+ callout_init(&sc->sc_tickto, 1);
callout_reset(&sc->sc_tickto, hz, hifn_tick, sc);
return (0);
@@ -765,7 +765,7 @@ hifn_init_pubrng(struct hifn_softc *sc)
sc->sc_rnghz = hz / 100;
else
sc->sc_rnghz = 1;
- callout_init(&sc->sc_rngto, CALLOUT_MPSAFE);
+ callout_init(&sc->sc_rngto, 1);
callout_reset(&sc->sc_rngto, sc->sc_rnghz, hifn_rng, sc);
}
diff --git a/sys/dev/hwpmc/hwpmc_amd.c b/sys/dev/hwpmc/hwpmc_amd.c
index 1a8398c..0bee138 100644
--- a/sys/dev/hwpmc/hwpmc_amd.c
+++ b/sys/dev/hwpmc/hwpmc_amd.c
@@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$");
#include <machine/md_var.h>
#include <machine/specialreg.h>
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
enum pmc_class amd_pmc_class;
#endif
@@ -282,16 +282,16 @@ amd_read_pmc(int cpu, int ri, pmc_value_t *v)
mode = PMC_TO_MODE(pm);
- PMCDBG(MDP,REA,1,"amd-read id=%d class=%d", ri, pd->pm_descr.pd_class);
+ PMCDBG2(MDP,REA,1,"amd-read id=%d class=%d", ri, pd->pm_descr.pd_class);
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
KASSERT(pd->pm_descr.pd_class == amd_pmc_class,
("[amd,%d] unknown PMC class (%d)", __LINE__,
pd->pm_descr.pd_class));
#endif
tmp = rdmsr(pd->pm_perfctr); /* RDMSR serializes */
- PMCDBG(MDP,REA,2,"amd-read (pre-munge) id=%d -> %jd", ri, tmp);
+ PMCDBG2(MDP,REA,2,"amd-read (pre-munge) id=%d -> %jd", ri, tmp);
if (PMC_IS_SAMPLING_MODE(mode)) {
/* Sign extend 48 bit value to 64 bits. */
tmp = (pmc_value_t) (((int64_t) tmp << 16) >> 16);
@@ -299,7 +299,7 @@ amd_read_pmc(int cpu, int ri, pmc_value_t *v)
}
*v = tmp;
- PMCDBG(MDP,REA,2,"amd-read (post-munge) id=%d -> %jd", ri, *v);
+ PMCDBG2(MDP,REA,2,"amd-read (post-munge) id=%d -> %jd", ri, *v);
return 0;
}
@@ -329,7 +329,7 @@ amd_write_pmc(int cpu, int ri, pmc_value_t v)
mode = PMC_TO_MODE(pm);
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
KASSERT(pd->pm_descr.pd_class == amd_pmc_class,
("[amd,%d] unknown PMC class (%d)", __LINE__,
pd->pm_descr.pd_class));
@@ -339,7 +339,7 @@ amd_write_pmc(int cpu, int ri, pmc_value_t v)
if (PMC_IS_SAMPLING_MODE(mode))
v = AMD_RELOAD_COUNT_TO_PERFCTR_VALUE(v);
- PMCDBG(MDP,WRI,1,"amd-write cpu=%d ri=%d v=%jx", cpu, ri, v);
+ PMCDBG3(MDP,WRI,1,"amd-write cpu=%d ri=%d v=%jx", cpu, ri, v);
/* write the PMC value */
wrmsr(pd->pm_perfctr, v);
@@ -356,7 +356,7 @@ amd_config_pmc(int cpu, int ri, struct pmc *pm)
{
struct pmc_hw *phw;
- PMCDBG(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
+ PMCDBG3(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[amd,%d] illegal CPU value %d", __LINE__, cpu));
@@ -395,7 +395,7 @@ amd_switch_in(struct pmc_cpu *pc, struct pmc_process *pp)
{
(void) pc;
- PMCDBG(MDP,SWI,1, "pc=%p pp=%p enable-msr=%d", pc, pp,
+ PMCDBG3(MDP,SWI,1, "pc=%p pp=%p enable-msr=%d", pc, pp,
(pp->pp_flags & PMC_PP_ENABLE_MSR_ACCESS) != 0);
/* enable the RDPMC instruction if needed */
@@ -416,7 +416,7 @@ amd_switch_out(struct pmc_cpu *pc, struct pmc_process *pp)
(void) pc;
(void) pp; /* can be NULL */
- PMCDBG(MDP,SWO,1, "pc=%p pp=%p enable-msr=%d", pc, pp, pp ?
+ PMCDBG3(MDP,SWO,1, "pc=%p pp=%p enable-msr=%d", pc, pp, pp ?
(pp->pp_flags & PMC_PP_ENABLE_MSR_ACCESS) == 1 : 0);
/* always turn off the RDPMC instruction */
@@ -453,7 +453,7 @@ amd_allocate_pmc(int cpu, int ri, struct pmc *pm,
caps = pm->pm_caps;
- PMCDBG(MDP,ALL,1,"amd-allocate ri=%d caps=0x%x", ri, caps);
+ PMCDBG2(MDP,ALL,1,"amd-allocate ri=%d caps=0x%x", ri, caps);
if ((pd->pd_caps & caps) != caps)
return EPERM;
@@ -500,7 +500,7 @@ amd_allocate_pmc(int cpu, int ri, struct pmc *pm,
pm->pm_md.pm_amd.pm_amd_evsel = config; /* save config value */
- PMCDBG(MDP,ALL,2,"amd-allocate ri=%d -> config=0x%x", ri, config);
+ PMCDBG2(MDP,ALL,2,"amd-allocate ri=%d -> config=0x%x", ri, config);
return 0;
}
@@ -515,7 +515,7 @@ amd_allocate_pmc(int cpu, int ri, struct pmc *pm,
static int
amd_release_pmc(int cpu, int ri, struct pmc *pmc)
{
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
const struct amd_descr *pd;
#endif
struct pmc_hw *phw;
@@ -532,7 +532,7 @@ amd_release_pmc(int cpu, int ri, struct pmc *pmc)
KASSERT(phw->phw_pmc == NULL,
("[amd,%d] PHW pmc %p non-NULL", __LINE__, phw->phw_pmc));
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
pd = &amd_pmcdesc[ri];
if (pd->pm_descr.pd_class == amd_pmc_class)
KASSERT(AMD_PMC_IS_STOPPED(pd->pm_evsel),
@@ -567,7 +567,7 @@ amd_start_pmc(int cpu, int ri)
("[amd,%d] starting cpu%d,pmc%d with null pmc record", __LINE__,
cpu, ri));
- PMCDBG(MDP,STA,1,"amd-start cpu=%d ri=%d", cpu, ri);
+ PMCDBG2(MDP,STA,1,"amd-start cpu=%d ri=%d", cpu, ri);
KASSERT(AMD_PMC_IS_STOPPED(pd->pm_evsel),
("[amd,%d] pmc%d,cpu%d: Starting active PMC \"%s\"", __LINE__,
@@ -576,7 +576,7 @@ amd_start_pmc(int cpu, int ri)
/* turn on the PMC ENABLE bit */
config = pm->pm_md.pm_amd.pm_amd_evsel | AMD_PMC_ENABLE;
- PMCDBG(MDP,STA,2,"amd-start config=0x%x", config);
+ PMCDBG1(MDP,STA,2,"amd-start config=0x%x", config);
wrmsr(pd->pm_evsel, config);
return 0;
@@ -610,7 +610,7 @@ amd_stop_pmc(int cpu, int ri)
("[amd,%d] PMC%d, CPU%d \"%s\" already stopped",
__LINE__, ri, cpu, pd->pm_descr.pd_name));
- PMCDBG(MDP,STO,1,"amd-stop ri=%d", ri);
+ PMCDBG1(MDP,STO,1,"amd-stop ri=%d", ri);
/* turn off the PMC ENABLE bit */
config = pm->pm_md.pm_amd.pm_amd_evsel & ~AMD_PMC_ENABLE;
@@ -637,7 +637,7 @@ amd_intr(int cpu, struct trapframe *tf)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[amd,%d] out of range CPU %d", __LINE__, cpu));
- PMCDBG(MDP,INT,1, "cpu=%d tf=%p um=%d", cpu, (void *) tf,
+ PMCDBG3(MDP,INT,1, "cpu=%d tf=%p um=%d", cpu, (void *) tf,
TRAPF_USERMODE(tf));
retval = 0;
@@ -769,7 +769,7 @@ amd_pcpu_init(struct pmc_mdep *md, int cpu)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[amd,%d] insane cpu number %d", __LINE__, cpu));
- PMCDBG(MDP,INI,1,"amd-init cpu=%d", cpu);
+ PMCDBG1(MDP,INI,1,"amd-init cpu=%d", cpu);
amd_pcpu[cpu] = pac = malloc(sizeof(struct amd_cpu), M_PMC,
M_WAITOK|M_ZERO);
@@ -816,7 +816,7 @@ amd_pcpu_fini(struct pmc_mdep *md, int cpu)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[amd,%d] insane cpu number (%d)", __LINE__, cpu));
- PMCDBG(MDP,INI,1,"amd-cleanup cpu=%d", cpu);
+ PMCDBG1(MDP,INI,1,"amd-cleanup cpu=%d", cpu);
/*
* First, turn off all PMCs on this CPU.
@@ -835,7 +835,7 @@ amd_pcpu_fini(struct pmc_mdep *md, int cpu)
amd_pcpu[cpu] = NULL;
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
for (i = 0; i < AMD_NPMCS; i++) {
KASSERT(pac->pc_amdpmcs[i].phw_pmc == NULL,
("[amd,%d] CPU%d/PMC%d in use", __LINE__, cpu, i));
@@ -912,7 +912,7 @@ pmc_amd_initialize(void)
return NULL;
}
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
amd_pmc_class = class;
#endif
@@ -976,7 +976,7 @@ pmc_amd_initialize(void)
pmc_mdep->pmd_npmc += AMD_NPMCS;
- PMCDBG(MDP,INI,0,"%s","amd-initialize");
+ PMCDBG0(MDP,INI,0,"amd-initialize");
return (pmc_mdep);
diff --git a/sys/dev/hwpmc/hwpmc_arm64.c b/sys/dev/hwpmc/hwpmc_arm64.c
new file mode 100644
index 0000000..2e54e38
--- /dev/null
+++ b/sys/dev/hwpmc/hwpmc_arm64.c
@@ -0,0 +1,544 @@
+/*-
+ * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
+ * All rights reserved.
+ *
+ * This software was developed by the University of Cambridge Computer
+ * Laboratory with support from ARM 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.
+ *
+ * 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/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/pmc.h>
+#include <sys/pmckern.h>
+
+#include <machine/pmc_mdep.h>
+#include <machine/cpu.h>
+
+static int arm64_npmcs;
+
+struct arm64_event_code_map {
+ enum pmc_event pe_ev;
+ uint8_t pe_code;
+};
+
+/*
+ * Per-processor information.
+ */
+struct arm64_cpu {
+ struct pmc_hw *pc_arm64pmcs;
+};
+
+static struct arm64_cpu **arm64_pcpu;
+
+/*
+ * Interrupt Enable Set Register
+ */
+static __inline void
+arm64_interrupt_enable(uint32_t pmc)
+{
+ uint32_t reg;
+
+ reg = (1 << pmc);
+ WRITE_SPECIALREG(PMINTENSET_EL1, reg);
+
+ isb();
+}
+
+/*
+ * Interrupt Clear Set Register
+ */
+static __inline void
+arm64_interrupt_disable(uint32_t pmc)
+{
+ uint32_t reg;
+
+ reg = (1 << pmc);
+ WRITE_SPECIALREG(PMINTENCLR_EL1, reg);
+
+ isb();
+}
+
+/*
+ * Counter Set Enable Register
+ */
+static __inline void
+arm64_counter_enable(unsigned int pmc)
+{
+ uint32_t reg;
+
+ reg = (1 << pmc);
+ WRITE_SPECIALREG(PMCNTENSET_EL0, reg);
+
+ isb();
+}
+
+/*
+ * Counter Clear Enable Register
+ */
+static __inline void
+arm64_counter_disable(unsigned int pmc)
+{
+ uint32_t reg;
+
+ reg = (1 << pmc);
+ WRITE_SPECIALREG(PMCNTENCLR_EL0, reg);
+
+ isb();
+}
+
+/*
+ * Performance Monitors Control Register
+ */
+static uint32_t
+arm64_pmcr_read(void)
+{
+ uint32_t reg;
+
+ reg = READ_SPECIALREG(PMCR_EL0);
+
+ return (reg);
+}
+
+static void
+arm64_pmcr_write(uint32_t reg)
+{
+
+ WRITE_SPECIALREG(PMCR_EL0, reg);
+
+ isb();
+}
+
+/*
+ * Performance Count Register N
+ */
+static uint32_t
+arm64_pmcn_read(unsigned int pmc)
+{
+
+ KASSERT(pmc < arm64_npmcs, ("%s: illegal PMC number %d", __func__, pmc));
+
+ WRITE_SPECIALREG(PMSELR_EL0, pmc);
+
+ isb();
+
+ return (READ_SPECIALREG(PMXEVCNTR_EL0));
+}
+
+static void
+arm64_pmcn_write(unsigned int pmc, uint32_t reg)
+{
+
+ KASSERT(pmc < arm64_npmcs, ("%s: illegal PMC number %d", __func__, pmc));
+
+ WRITE_SPECIALREG(PMSELR_EL0, pmc);
+ WRITE_SPECIALREG(PMXEVCNTR_EL0, reg);
+
+ isb();
+}
+
+static int
+arm64_allocate_pmc(int cpu, int ri, struct pmc *pm,
+ const struct pmc_op_pmcallocate *a)
+{
+ uint32_t caps, config;
+ struct arm64_cpu *pac;
+ enum pmc_event pe;
+
+ KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
+ ("[arm64,%d] illegal CPU value %d", __LINE__, cpu));
+ KASSERT(ri >= 0 && ri < arm64_npmcs,
+ ("[arm64,%d] illegal row index %d", __LINE__, ri));
+
+ pac = arm64_pcpu[cpu];
+
+ caps = a->pm_caps;
+ if (a->pm_class != PMC_CLASS_ARMV8) {
+ return (EINVAL);
+ }
+ pe = a->pm_ev;
+
+ config = (pe & EVENT_ID_MASK);
+ pm->pm_md.pm_arm64.pm_arm64_evsel = config;
+
+ PMCDBG2(MDP, ALL, 2, "arm64-allocate ri=%d -> config=0x%x", ri, config);
+
+ return 0;
+}
+
+
+static int
+arm64_read_pmc(int cpu, int ri, pmc_value_t *v)
+{
+ pmc_value_t tmp;
+ struct pmc *pm;
+
+ KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
+ ("[arm64,%d] illegal CPU value %d", __LINE__, cpu));
+ KASSERT(ri >= 0 && ri < arm64_npmcs,
+ ("[arm64,%d] illegal row index %d", __LINE__, ri));
+
+ pm = arm64_pcpu[cpu]->pc_arm64pmcs[ri].phw_pmc;
+
+ tmp = arm64_pmcn_read(ri);
+
+ PMCDBG2(MDP, REA, 2, "arm64-read id=%d -> %jd", ri, tmp);
+ if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
+ *v = ARMV8_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp);
+ else
+ *v = tmp;
+
+ return 0;
+}
+
+static int
+arm64_write_pmc(int cpu, int ri, pmc_value_t v)
+{
+ struct pmc *pm;
+
+ KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
+ ("[arm64,%d] illegal CPU value %d", __LINE__, cpu));
+ KASSERT(ri >= 0 && ri < arm64_npmcs,
+ ("[arm64,%d] illegal row-index %d", __LINE__, ri));
+
+ pm = arm64_pcpu[cpu]->pc_arm64pmcs[ri].phw_pmc;
+
+ if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
+ v = ARMV8_RELOAD_COUNT_TO_PERFCTR_VALUE(v);
+
+ PMCDBG3(MDP, WRI, 1, "arm64-write cpu=%d ri=%d v=%jx", cpu, ri, v);
+
+ arm64_pmcn_write(ri, v);
+
+ return 0;
+}
+
+static int
+arm64_config_pmc(int cpu, int ri, struct pmc *pm)
+{
+ struct pmc_hw *phw;
+
+ PMCDBG3(MDP, CFG, 1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
+
+ KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
+ ("[arm64,%d] illegal CPU value %d", __LINE__, cpu));
+ KASSERT(ri >= 0 && ri < arm64_npmcs,
+ ("[arm64,%d] illegal row-index %d", __LINE__, ri));
+
+ phw = &arm64_pcpu[cpu]->pc_arm64pmcs[ri];
+
+ KASSERT(pm == NULL || phw->phw_pmc == NULL,
+ ("[arm64,%d] pm=%p phw->pm=%p hwpmc not unconfigured",
+ __LINE__, pm, phw->phw_pmc));
+
+ phw->phw_pmc = pm;
+
+ return 0;
+}
+
+static int
+arm64_start_pmc(int cpu, int ri)
+{
+ struct pmc_hw *phw;
+ uint32_t config;
+ struct pmc *pm;
+
+ phw = &arm64_pcpu[cpu]->pc_arm64pmcs[ri];
+ pm = phw->phw_pmc;
+ config = pm->pm_md.pm_arm64.pm_arm64_evsel;
+
+ /*
+ * Configure the event selection.
+ */
+ WRITE_SPECIALREG(PMSELR_EL0, ri);
+ WRITE_SPECIALREG(PMXEVTYPER_EL0, config);
+
+ isb();
+
+ /*
+ * Enable the PMC.
+ */
+ arm64_interrupt_enable(ri);
+ arm64_counter_enable(ri);
+
+ return 0;
+}
+
+static int
+arm64_stop_pmc(int cpu, int ri)
+{
+ struct pmc_hw *phw;
+ struct pmc *pm;
+
+ phw = &arm64_pcpu[cpu]->pc_arm64pmcs[ri];
+ pm = phw->phw_pmc;
+
+ /*
+ * Disable the PMCs.
+ */
+ arm64_counter_disable(ri);
+ arm64_interrupt_disable(ri);
+
+ return 0;
+}
+
+static int
+arm64_release_pmc(int cpu, int ri, struct pmc *pmc)
+{
+ struct pmc_hw *phw;
+
+ KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
+ ("[arm64,%d] illegal CPU value %d", __LINE__, cpu));
+ KASSERT(ri >= 0 && ri < arm64_npmcs,
+ ("[arm64,%d] illegal row-index %d", __LINE__, ri));
+
+ phw = &arm64_pcpu[cpu]->pc_arm64pmcs[ri];
+ KASSERT(phw->phw_pmc == NULL,
+ ("[arm64,%d] PHW pmc %p non-NULL", __LINE__, phw->phw_pmc));
+
+ return 0;
+}
+
+static int
+arm64_intr(int cpu, struct trapframe *tf)
+{
+ struct arm64_cpu *pc;
+ int retval, ri;
+ struct pmc *pm;
+ int error;
+ int reg;
+
+ KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
+ ("[arm64,%d] CPU %d out of range", __LINE__, cpu));
+
+ retval = 0;
+ pc = arm64_pcpu[cpu];
+
+ for (ri = 0; ri < arm64_npmcs; ri++) {
+ pm = arm64_pcpu[cpu]->pc_arm64pmcs[ri].phw_pmc;
+ if (pm == NULL)
+ continue;
+ if (!PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
+ continue;
+
+ /* Check if counter is overflowed */
+ reg = (1 << ri);
+ if ((READ_SPECIALREG(PMOVSCLR_EL0) & reg) == 0)
+ continue;
+ /* Clear Overflow Flag */
+ WRITE_SPECIALREG(PMOVSCLR_EL0, reg);
+
+ isb();
+
+ retval = 1; /* Found an interrupting PMC. */
+ if (pm->pm_state != PMC_STATE_RUNNING)
+ continue;
+
+ error = pmc_process_interrupt(cpu, PMC_HR, pm, tf,
+ TRAPF_USERMODE(tf));
+ if (error)
+ arm64_stop_pmc(cpu, ri);
+
+ /* Reload sampling count */
+ arm64_write_pmc(cpu, ri, pm->pm_sc.pm_reloadcount);
+ }
+
+ return (retval);
+}
+
+static int
+arm64_describe(int cpu, int ri, struct pmc_info *pi, struct pmc **ppmc)
+{
+ char arm64_name[PMC_NAME_MAX];
+ struct pmc_hw *phw;
+ int error;
+
+ KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
+ ("[arm64,%d], illegal CPU %d", __LINE__, cpu));
+ KASSERT(ri >= 0 && ri < arm64_npmcs,
+ ("[arm64,%d] row-index %d out of range", __LINE__, ri));
+
+ phw = &arm64_pcpu[cpu]->pc_arm64pmcs[ri];
+ snprintf(arm64_name, sizeof(arm64_name), "ARMV8-%d", ri);
+ if ((error = copystr(arm64_name, pi->pm_name, PMC_NAME_MAX,
+ NULL)) != 0)
+ return (error);
+ pi->pm_class = PMC_CLASS_ARMV8;
+ if (phw->phw_state & PMC_PHW_FLAG_IS_ENABLED) {
+ pi->pm_enabled = TRUE;
+ *ppmc = phw->phw_pmc;
+ } else {
+ pi->pm_enabled = FALSE;
+ *ppmc = NULL;
+ }
+
+ return (0);
+}
+
+static int
+arm64_get_config(int cpu, int ri, struct pmc **ppm)
+{
+
+ *ppm = arm64_pcpu[cpu]->pc_arm64pmcs[ri].phw_pmc;
+
+ return (0);
+}
+
+/*
+ * XXX don't know what we should do here.
+ */
+static int
+arm64_switch_in(struct pmc_cpu *pc, struct pmc_process *pp)
+{
+
+ return (0);
+}
+
+static int
+arm64_switch_out(struct pmc_cpu *pc, struct pmc_process *pp)
+{
+
+ return (0);
+}
+
+static int
+arm64_pcpu_init(struct pmc_mdep *md, int cpu)
+{
+ struct arm64_cpu *pac;
+ struct pmc_hw *phw;
+ struct pmc_cpu *pc;
+ uint64_t pmcr;
+ int first_ri;
+ int i;
+
+ KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
+ ("[arm64,%d] wrong cpu number %d", __LINE__, cpu));
+ PMCDBG1(MDP, INI, 1, "arm64-init cpu=%d", cpu);
+
+ arm64_pcpu[cpu] = pac = malloc(sizeof(struct arm64_cpu), M_PMC,
+ M_WAITOK | M_ZERO);
+
+ pac->pc_arm64pmcs = malloc(sizeof(struct pmc_hw) * arm64_npmcs,
+ M_PMC, M_WAITOK | M_ZERO);
+ pc = pmc_pcpu[cpu];
+ first_ri = md->pmd_classdep[PMC_MDEP_CLASS_INDEX_ARMV8].pcd_ri;
+ KASSERT(pc != NULL, ("[arm64,%d] NULL per-cpu pointer", __LINE__));
+
+ for (i = 0, phw = pac->pc_arm64pmcs; i < arm64_npmcs; i++, phw++) {
+ phw->phw_state = PMC_PHW_FLAG_IS_ENABLED |
+ PMC_PHW_CPU_TO_STATE(cpu) | PMC_PHW_INDEX_TO_STATE(i);
+ phw->phw_pmc = NULL;
+ pc->pc_hwpmcs[i + first_ri] = phw;
+ }
+
+ /* Enable unit */
+ pmcr = arm64_pmcr_read();
+ pmcr |= PMCR_E;
+ arm64_pmcr_write(pmcr);
+
+ return (0);
+}
+
+static int
+arm64_pcpu_fini(struct pmc_mdep *md, int cpu)
+{
+ uint32_t pmcr;
+
+ pmcr = arm64_pmcr_read();
+ pmcr &= ~PMCR_E;
+ arm64_pmcr_write(pmcr);
+
+ return (0);
+}
+
+struct pmc_mdep *
+pmc_arm64_initialize()
+{
+ struct pmc_mdep *pmc_mdep;
+ struct pmc_classdep *pcd;
+ int idcode;
+ int reg;
+
+ reg = arm64_pmcr_read();
+ arm64_npmcs = (reg & PMCR_N_MASK) >> PMCR_N_SHIFT;
+ idcode = (reg & PMCR_IDCODE_MASK) >> PMCR_IDCODE_SHIFT;
+
+ PMCDBG1(MDP, INI, 1, "arm64-init npmcs=%d", arm64_npmcs);
+
+ /*
+ * Allocate space for pointers to PMC HW descriptors and for
+ * the MDEP structure used by MI code.
+ */
+ arm64_pcpu = malloc(sizeof(struct arm64_cpu *) * pmc_cpu_max(),
+ M_PMC, M_WAITOK | M_ZERO);
+
+ /* Just one class */
+ pmc_mdep = pmc_mdep_alloc(1);
+
+ switch (idcode) {
+ case PMCR_IDCODE_CORTEX_A57:
+ case PMCR_IDCODE_CORTEX_A72:
+ pmc_mdep->pmd_cputype = PMC_CPU_ARMV8_CORTEX_A57;
+ break;
+ default:
+ case PMCR_IDCODE_CORTEX_A53:
+ pmc_mdep->pmd_cputype = PMC_CPU_ARMV8_CORTEX_A53;
+ break;
+ }
+
+ pcd = &pmc_mdep->pmd_classdep[PMC_MDEP_CLASS_INDEX_ARMV8];
+ pcd->pcd_caps = ARMV8_PMC_CAPS;
+ pcd->pcd_class = PMC_CLASS_ARMV8;
+ pcd->pcd_num = arm64_npmcs;
+ pcd->pcd_ri = pmc_mdep->pmd_npmc;
+ pcd->pcd_width = 32;
+
+ pcd->pcd_allocate_pmc = arm64_allocate_pmc;
+ pcd->pcd_config_pmc = arm64_config_pmc;
+ pcd->pcd_pcpu_fini = arm64_pcpu_fini;
+ pcd->pcd_pcpu_init = arm64_pcpu_init;
+ pcd->pcd_describe = arm64_describe;
+ pcd->pcd_get_config = arm64_get_config;
+ pcd->pcd_read_pmc = arm64_read_pmc;
+ pcd->pcd_release_pmc = arm64_release_pmc;
+ pcd->pcd_start_pmc = arm64_start_pmc;
+ pcd->pcd_stop_pmc = arm64_stop_pmc;
+ pcd->pcd_write_pmc = arm64_write_pmc;
+
+ pmc_mdep->pmd_intr = arm64_intr;
+ pmc_mdep->pmd_switch_in = arm64_switch_in;
+ pmc_mdep->pmd_switch_out = arm64_switch_out;
+
+ pmc_mdep->pmd_npmc += arm64_npmcs;
+
+ return (pmc_mdep);
+}
+
+void
+pmc_arm64_finalize(struct pmc_mdep *md)
+{
+
+}
diff --git a/sys/dev/hwpmc/hwpmc_arm64.h b/sys/dev/hwpmc/hwpmc_arm64.h
new file mode 100644
index 0000000..f0d43aa
--- /dev/null
+++ b/sys/dev/hwpmc/hwpmc_arm64.h
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
+ * All rights reserved.
+ *
+ * This software was developed by the University of Cambridge Computer
+ * Laboratory with support from ARM 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.
+ *
+ * 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 _DEV_HWPMC_ARMV8_H_
+#define _DEV_HWPMC_ARMV8_H_
+
+#define ARMV8_PMC_CAPS (PMC_CAP_INTERRUPT | PMC_CAP_USER | \
+ PMC_CAP_SYSTEM | PMC_CAP_EDGE | \
+ PMC_CAP_THRESHOLD | PMC_CAP_READ | \
+ PMC_CAP_WRITE | PMC_CAP_INVERT | \
+ PMC_CAP_QUALIFIER)
+
+#define ARMV8_RELOAD_COUNT_TO_PERFCTR_VALUE(R) (-(R))
+#define ARMV8_PERFCTR_VALUE_TO_RELOAD_COUNT(P) (-(P))
+#define EVENT_ID_MASK 0xFF
+
+#ifdef _KERNEL
+/* MD extension for 'struct pmc' */
+struct pmc_md_arm64_pmc {
+ uint32_t pm_arm64_evsel;
+};
+#endif /* _KERNEL */
+#endif /* _DEV_HWPMC_ARMV8_H_ */
diff --git a/sys/dev/hwpmc/hwpmc_arm64_md.c b/sys/dev/hwpmc/hwpmc_arm64_md.c
new file mode 100644
index 0000000..9037c46
--- /dev/null
+++ b/sys/dev/hwpmc/hwpmc_arm64_md.c
@@ -0,0 +1,154 @@
+/*-
+ * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
+ * All rights reserved.
+ *
+ * This software was developed by the University of Cambridge Computer
+ * Laboratory with support from ARM 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.
+ *
+ * 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/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/pmc.h>
+#include <sys/proc.h>
+#include <sys/systm.h>
+
+#include <machine/cpu.h>
+#include <machine/md_var.h>
+#include <machine/pmc_mdep.h>
+#include <machine/stack.h>
+
+#include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/pmap.h>
+
+struct pmc_mdep *
+pmc_md_initialize()
+{
+
+ return (pmc_arm64_initialize());
+}
+
+void
+pmc_md_finalize(struct pmc_mdep *md)
+{
+
+ pmc_arm64_finalize(md);
+}
+
+int
+pmc_save_kernel_callchain(uintptr_t *cc, int maxsamples,
+ struct trapframe *tf)
+{
+ uintptr_t pc, r, stackstart, stackend, fp;
+ struct thread *td;
+ int count;
+
+ KASSERT(TRAPF_USERMODE(tf) == 0,("[arm,%d] not a kernel backtrace",
+ __LINE__));
+
+ td = curthread;
+ pc = PMC_TRAPFRAME_TO_PC(tf);
+ *cc++ = pc;
+
+ if (maxsamples <= 1)
+ return (1);
+
+ stackstart = (uintptr_t) td->td_kstack;
+ stackend = (uintptr_t) td->td_kstack + td->td_kstack_pages * PAGE_SIZE;
+ fp = PMC_TRAPFRAME_TO_FP(tf);
+
+ if (!PMC_IN_KERNEL(pc) ||
+ !PMC_IN_KERNEL_STACK(fp, stackstart, stackend))
+ return (1);
+
+ for (count = 1; count < maxsamples; count++) {
+ /* Use saved lr as pc. */
+ r = fp + sizeof(uintptr_t);
+ if (!PMC_IN_KERNEL_STACK(r, stackstart, stackend))
+ break;
+ pc = *(uintptr_t *)r;
+ if (!PMC_IN_KERNEL(pc))
+ break;
+
+ *cc++ = pc;
+
+ /* Switch to next frame up */
+ r = fp;
+ if (!PMC_IN_KERNEL_STACK(r, stackstart, stackend))
+ break;
+ fp = *(uintptr_t *)r;
+ if (!PMC_IN_KERNEL_STACK(fp, stackstart, stackend))
+ break;
+ }
+
+ return (count);
+}
+
+int
+pmc_save_user_callchain(uintptr_t *cc, int maxsamples,
+ struct trapframe *tf)
+{
+ uintptr_t pc, r, oldfp, fp;
+ struct thread *td;
+ int count;
+
+ KASSERT(TRAPF_USERMODE(tf), ("[x86,%d] Not a user trap frame tf=%p",
+ __LINE__, (void *) tf));
+
+ td = curthread;
+ pc = PMC_TRAPFRAME_TO_PC(tf);
+ *cc++ = pc;
+
+ if (maxsamples <= 1)
+ return (1);
+
+ oldfp = fp = PMC_TRAPFRAME_TO_FP(tf);
+
+ if (!PMC_IN_USERSPACE(pc) ||
+ !PMC_IN_USERSPACE(fp))
+ return (1);
+
+ for (count = 1; count < maxsamples; count++) {
+ /* Use saved lr as pc. */
+ r = fp + sizeof(uintptr_t);
+ if (copyin((void *)r, &pc, sizeof(pc)) != 0)
+ break;
+ if (!PMC_IN_USERSPACE(pc))
+ break;
+
+ *cc++ = pc;
+
+ /* Switch to next frame up */
+ oldfp = fp;
+ r = fp;
+ if (copyin((void *)r, &fp, sizeof(fp)) != 0)
+ break;
+ if (fp < oldfp || !PMC_IN_USERSPACE(fp))
+ break;
+ }
+
+ return (count);
+}
diff --git a/sys/dev/hwpmc/hwpmc_armv7.c b/sys/dev/hwpmc/hwpmc_armv7.c
index 13fdc76..66d4971 100644
--- a/sys/dev/hwpmc/hwpmc_armv7.c
+++ b/sys/dev/hwpmc/hwpmc_armv7.c
@@ -201,7 +201,7 @@ armv7_allocate_pmc(int cpu, int ri, struct pmc *pm,
pm->pm_md.pm_armv7.pm_armv7_evsel = config;
- PMCDBG(MDP,ALL,2,"armv7-allocate ri=%d -> config=0x%x", ri, config);
+ PMCDBG2(MDP,ALL,2,"armv7-allocate ri=%d -> config=0x%x", ri, config);
return 0;
}
@@ -225,7 +225,7 @@ armv7_read_pmc(int cpu, int ri, pmc_value_t *v)
else
tmp = armv7_pmcn_read(ri);
- PMCDBG(MDP,REA,2,"armv7-read id=%d -> %jd", ri, tmp);
+ PMCDBG2(MDP,REA,2,"armv7-read id=%d -> %jd", ri, tmp);
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
*v = ARMV7_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp);
else
@@ -249,7 +249,7 @@ armv7_write_pmc(int cpu, int ri, pmc_value_t v)
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
v = ARMV7_RELOAD_COUNT_TO_PERFCTR_VALUE(v);
- PMCDBG(MDP,WRI,1,"armv7-write cpu=%d ri=%d v=%jx", cpu, ri, v);
+ PMCDBG3(MDP,WRI,1,"armv7-write cpu=%d ri=%d v=%jx", cpu, ri, v);
if (pm->pm_md.pm_armv7.pm_armv7_evsel == 0xFF)
cp15_pmccntr_set(v);
@@ -264,7 +264,7 @@ armv7_config_pmc(int cpu, int ri, struct pmc *pm)
{
struct pmc_hw *phw;
- PMCDBG(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
+ PMCDBG3(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[armv7,%d] illegal CPU value %d", __LINE__, cpu));
@@ -462,7 +462,7 @@ armv7_pcpu_init(struct pmc_mdep *md, int cpu)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[armv7,%d] wrong cpu number %d", __LINE__, cpu));
- PMCDBG(MDP,INI,1,"armv7-init cpu=%d", cpu);
+ PMCDBG1(MDP,INI,1,"armv7-init cpu=%d", cpu);
armv7_pcpu[cpu] = pac = malloc(sizeof(struct armv7_cpu), M_PMC,
M_WAITOK|M_ZERO);
@@ -516,7 +516,7 @@ pmc_armv7_initialize()
armv7_npmcs = (reg >> ARMV7_PMNC_N_SHIFT) & \
ARMV7_PMNC_N_MASK;
- PMCDBG(MDP,INI,1,"armv7-init npmcs=%d", armv7_npmcs);
+ PMCDBG1(MDP,INI,1,"armv7-init npmcs=%d", armv7_npmcs);
/*
* Allocate space for pointers to PMC HW descriptors and for
diff --git a/sys/dev/hwpmc/hwpmc_core.c b/sys/dev/hwpmc/hwpmc_core.c
index f50dfb6c..f22d2b3 100644
--- a/sys/dev/hwpmc/hwpmc_core.c
+++ b/sys/dev/hwpmc/hwpmc_core.c
@@ -123,7 +123,7 @@ core_pcpu_init(struct pmc_mdep *md, int cpu)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[iaf,%d] insane cpu number %d", __LINE__, cpu));
- PMCDBG(MDP,INI,1,"core-init cpu=%d", cpu);
+ PMCDBG1(MDP,INI,1,"core-init cpu=%d", cpu);
core_ri = md->pmd_classdep[PMC_MDEP_CLASS_INDEX_IAP].pcd_ri;
npmc = md->pmd_classdep[PMC_MDEP_CLASS_INDEX_IAP].pcd_num;
@@ -162,7 +162,7 @@ core_pcpu_fini(struct pmc_mdep *md, int cpu)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[core,%d] insane cpu number (%d)", __LINE__, cpu));
- PMCDBG(MDP,INI,1,"core-pcpu-fini cpu=%d", cpu);
+ PMCDBG1(MDP,INI,1,"core-pcpu-fini cpu=%d", cpu);
if ((cc = core_pcpu[cpu]) == NULL)
return (0);
@@ -203,6 +203,10 @@ core_pcpu_fini(struct pmc_mdep *md, int cpu)
static pmc_value_t
iaf_perfctr_value_to_reload_count(pmc_value_t v)
{
+
+ /* If the PMC has overflowed, return a reload count of zero. */
+ if ((v & (1ULL << (core_iaf_width - 1))) == 0)
+ return (0);
v &= (1ULL << core_iaf_width) - 1;
return (1ULL << core_iaf_width) - v;
}
@@ -223,7 +227,7 @@ iaf_allocate_pmc(int cpu, int ri, struct pmc *pm,
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[core,%d] illegal CPU %d", __LINE__, cpu));
- PMCDBG(MDP,ALL,1, "iaf-allocate ri=%d reqcaps=0x%x", ri, pm->pm_caps);
+ PMCDBG2(MDP,ALL,1, "iaf-allocate ri=%d reqcaps=0x%x", ri, pm->pm_caps);
if (ri < 0 || ri > core_iaf_npmc)
return (EINVAL);
@@ -267,7 +271,7 @@ iaf_allocate_pmc(int cpu, int ri, struct pmc *pm,
pm->pm_md.pm_iaf.pm_iaf_ctrl = (flags << (ri * 4));
- PMCDBG(MDP,ALL,2, "iaf-allocate config=0x%jx",
+ PMCDBG1(MDP,ALL,2, "iaf-allocate config=0x%jx",
(uintmax_t) pm->pm_md.pm_iaf.pm_iaf_ctrl);
return (0);
@@ -282,7 +286,7 @@ iaf_config_pmc(int cpu, int ri, struct pmc *pm)
KASSERT(ri >= 0 && ri < core_iaf_npmc,
("[core,%d] illegal row-index %d", __LINE__, ri));
- PMCDBG(MDP,CFG,1, "iaf-config cpu=%d ri=%d pm=%p", cpu, ri, pm);
+ PMCDBG3(MDP,CFG,1, "iaf-config cpu=%d ri=%d pm=%p", cpu, ri, pm);
KASSERT(core_pcpu[cpu] != NULL, ("[core,%d] null per-cpu %d", __LINE__,
cpu));
@@ -362,7 +366,7 @@ iaf_read_pmc(int cpu, int ri, pmc_value_t *v)
else
*v = tmp;
- PMCDBG(MDP,REA,1, "iaf-read cpu=%d ri=%d msr=0x%x -> v=%jx", cpu, ri,
+ PMCDBG4(MDP,REA,1, "iaf-read cpu=%d ri=%d msr=0x%x -> v=%jx", cpu, ri,
IAF_RI_TO_MSR(ri), *v);
return (0);
@@ -371,7 +375,7 @@ iaf_read_pmc(int cpu, int ri, pmc_value_t *v)
static int
iaf_release_pmc(int cpu, int ri, struct pmc *pmc)
{
- PMCDBG(MDP,REL,1, "iaf-release cpu=%d ri=%d pm=%p", cpu, ri, pmc);
+ PMCDBG3(MDP,REL,1, "iaf-release cpu=%d ri=%d pm=%p", cpu, ri, pmc);
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[core,%d] illegal CPU value %d", __LINE__, cpu));
@@ -396,7 +400,7 @@ iaf_start_pmc(int cpu, int ri)
KASSERT(ri >= 0 && ri < core_iaf_npmc,
("[core,%d] illegal row-index %d", __LINE__, ri));
- PMCDBG(MDP,STA,1,"iaf-start cpu=%d ri=%d", cpu, ri);
+ PMCDBG2(MDP,STA,1,"iaf-start cpu=%d ri=%d", cpu, ri);
iafc = core_pcpu[cpu];
pm = iafc->pc_corepmcs[ri + core_iaf_ri].phw_pmc;
@@ -414,7 +418,7 @@ iaf_start_pmc(int cpu, int ri)
IAF_GLOBAL_CTRL_MASK));
} while (iafc->pc_resync != 0);
- PMCDBG(MDP,STA,1,"iafctrl=%x(%x) globalctrl=%jx(%jx)",
+ PMCDBG4(MDP,STA,1,"iafctrl=%x(%x) globalctrl=%jx(%jx)",
iafc->pc_iafctrl, (uint32_t) rdmsr(IAF_CTRL),
iafc->pc_globalctrl, rdmsr(IA_GLOBAL_CTRL));
@@ -428,7 +432,7 @@ iaf_stop_pmc(int cpu, int ri)
struct core_cpu *iafc;
uint64_t msr = 0;
- PMCDBG(MDP,STO,1,"iaf-stop cpu=%d ri=%d", cpu, ri);
+ PMCDBG2(MDP,STO,1,"iaf-stop cpu=%d ri=%d", cpu, ri);
iafc = core_pcpu[cpu];
@@ -445,7 +449,7 @@ iaf_stop_pmc(int cpu, int ri)
iafc->pc_iafctrl &= ~fc;
- PMCDBG(MDP,STO,1,"iaf-stop iafctrl=%x", iafc->pc_iafctrl);
+ PMCDBG1(MDP,STO,1,"iaf-stop iafctrl=%x", iafc->pc_iafctrl);
msr = rdmsr(IAF_CTRL) & ~IAF_CTRL_MASK;
wrmsr(IAF_CTRL, msr | (iafc->pc_iafctrl & IAF_CTRL_MASK));
@@ -457,7 +461,7 @@ iaf_stop_pmc(int cpu, int ri)
IAF_GLOBAL_CTRL_MASK));
} while (iafc->pc_resync != 0);
- PMCDBG(MDP,STO,1,"iafctrl=%x(%x) globalctrl=%jx(%jx)",
+ PMCDBG4(MDP,STO,1,"iafctrl=%x(%x) globalctrl=%jx(%jx)",
iafc->pc_iafctrl, (uint32_t) rdmsr(IAF_CTRL),
iafc->pc_globalctrl, rdmsr(IA_GLOBAL_CTRL));
@@ -495,7 +499,7 @@ iaf_write_pmc(int cpu, int ri, pmc_value_t v)
msr = rdmsr(IAF_CTRL) & ~IAF_CTRL_MASK;
wrmsr(IAF_CTRL, msr | (cc->pc_iafctrl & IAF_CTRL_MASK));
- PMCDBG(MDP,WRI,1, "iaf-write cpu=%d ri=%d msr=0x%x v=%jx iafctrl=%jx "
+ PMCDBG6(MDP,WRI,1, "iaf-write cpu=%d ri=%d msr=0x%x v=%jx iafctrl=%jx "
"pmc=%jx", cpu, ri, IAF_RI_TO_MSR(ri), v,
(uintmax_t) rdmsr(IAF_CTRL),
(uintmax_t) rdpmc(IAF_RI_TO_MSR(ri)));
@@ -511,7 +515,7 @@ iaf_initialize(struct pmc_mdep *md, int maxcpu, int npmc, int pmcwidth)
KASSERT(md != NULL, ("[iaf,%d] md is NULL", __LINE__));
- PMCDBG(MDP,INI,1, "%s", "iaf-initialize");
+ PMCDBG0(MDP,INI,1, "iaf-initialize");
pcd = &md->pmd_classdep[PMC_MDEP_CLASS_INDEX_IAF];
@@ -1806,6 +1810,10 @@ static const int niap_events = sizeof(iap_events) / sizeof(iap_events[0]);
static pmc_value_t
iap_perfctr_value_to_reload_count(pmc_value_t v)
{
+
+ /* If the PMC has overflowed, return a reload count of zero. */
+ if ((v & (1ULL << (core_iap_width - 1))) == 0)
+ return (0);
v &= (1ULL << core_iap_width) - 1;
return (1ULL << core_iap_width) - v;
}
@@ -2289,7 +2297,7 @@ iap_config_pmc(int cpu, int ri, struct pmc *pm)
KASSERT(ri >= 0 && ri < core_iap_npmc,
("[core,%d] illegal row-index %d", __LINE__, ri));
- PMCDBG(MDP,CFG,1, "iap-config cpu=%d ri=%d pm=%p", cpu, ri, pm);
+ PMCDBG3(MDP,CFG,1, "iap-config cpu=%d ri=%d pm=%p", cpu, ri, pm);
KASSERT(core_pcpu[cpu] != NULL, ("[core,%d] null per-cpu %d", __LINE__,
cpu));
@@ -2368,7 +2376,7 @@ iap_read_pmc(int cpu, int ri, pmc_value_t *v)
else
*v = tmp & ((1ULL << core_iap_width) - 1);
- PMCDBG(MDP,REA,1, "iap-read cpu=%d ri=%d msr=0x%x -> v=%jx", cpu, ri,
+ PMCDBG4(MDP,REA,1, "iap-read cpu=%d ri=%d msr=0x%x -> v=%jx", cpu, ri,
ri, *v);
return (0);
@@ -2379,7 +2387,7 @@ iap_release_pmc(int cpu, int ri, struct pmc *pm)
{
(void) pm;
- PMCDBG(MDP,REL,1, "iap-release cpu=%d ri=%d pm=%p", cpu, ri,
+ PMCDBG3(MDP,REL,1, "iap-release cpu=%d ri=%d pm=%p", cpu, ri,
pm);
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
@@ -2412,11 +2420,11 @@ iap_start_pmc(int cpu, int ri)
("[core,%d] starting cpu%d,ri%d with no pmc configured",
__LINE__, cpu, ri));
- PMCDBG(MDP,STA,1, "iap-start cpu=%d ri=%d", cpu, ri);
+ PMCDBG2(MDP,STA,1, "iap-start cpu=%d ri=%d", cpu, ri);
evsel = pm->pm_md.pm_iap.pm_iap_evsel;
- PMCDBG(MDP,STA,2, "iap-start/2 cpu=%d ri=%d evselmsr=0x%x evsel=0x%x",
+ PMCDBG4(MDP,STA,2, "iap-start/2 cpu=%d ri=%d evselmsr=0x%x evsel=0x%x",
cpu, ri, IAP_EVSEL0 + ri, evsel);
/* Event specific configuration. */
@@ -2464,7 +2472,7 @@ iap_stop_pmc(int cpu, int ri)
("[core,%d] cpu%d ri%d no configured PMC to stop", __LINE__,
cpu, ri));
- PMCDBG(MDP,STO,1, "iap-stop cpu=%d ri=%d", cpu, ri);
+ PMCDBG2(MDP,STO,1, "iap-stop cpu=%d ri=%d", cpu, ri);
msr = rdmsr(IAP_EVSEL0 + ri) & ~IAP_EVSEL_MASK;
wrmsr(IAP_EVSEL0 + ri, msr); /* stop hw */
@@ -2501,7 +2509,7 @@ iap_write_pmc(int cpu, int ri, pmc_value_t v)
("[core,%d] cpu%d ri%d no configured PMC to stop", __LINE__,
cpu, ri));
- PMCDBG(MDP,WRI,1, "iap-write cpu=%d ri=%d msr=0x%x v=%jx", cpu, ri,
+ PMCDBG4(MDP,WRI,1, "iap-write cpu=%d ri=%d msr=0x%x v=%jx", cpu, ri,
IAP_PMC0 + ri, v);
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
@@ -2526,7 +2534,7 @@ iap_initialize(struct pmc_mdep *md, int maxcpu, int npmc, int pmcwidth,
KASSERT(md != NULL, ("[iap,%d] md is NULL", __LINE__));
- PMCDBG(MDP,INI,1, "%s", "iap-initialize");
+ PMCDBG0(MDP,INI,1, "iap-initialize");
/* Remember the set of architectural events supported. */
core_architectural_events = ~flags;
@@ -2564,7 +2572,7 @@ core_intr(int cpu, struct trapframe *tf)
int error, found_interrupt, ri;
uint64_t msr;
- PMCDBG(MDP,INT, 1, "cpu=%d tf=0x%p um=%d", cpu, (void *) tf,
+ PMCDBG3(MDP,INT, 1, "cpu=%d tf=0x%p um=%d", cpu, (void *) tf,
TRAPF_USERMODE(tf));
found_interrupt = 0;
@@ -2588,7 +2596,7 @@ core_intr(int cpu, struct trapframe *tf)
TRAPF_USERMODE(tf));
v = pm->pm_sc.pm_reloadcount;
- v = iaf_reload_count_to_perfctr_value(v);
+ v = iap_reload_count_to_perfctr_value(v);
/*
* Stop the counter, reload it but only restart it if
@@ -2623,7 +2631,7 @@ core2_intr(int cpu, struct trapframe *tf)
struct core_cpu *cc;
pmc_value_t v;
- PMCDBG(MDP,INT, 1, "cpu=%d tf=0x%p um=%d", cpu, (void *) tf,
+ PMCDBG3(MDP,INT, 1, "cpu=%d tf=0x%p um=%d", cpu, (void *) tf,
TRAPF_USERMODE(tf));
/*
@@ -2635,7 +2643,7 @@ core2_intr(int cpu, struct trapframe *tf)
intrstatus = rdmsr(IA_GLOBAL_STATUS);
intrenable = intrstatus & core_pmcmask;
- PMCDBG(MDP,INT, 1, "cpu=%d intrstatus=%jx", cpu,
+ PMCDBG2(MDP,INT, 1, "cpu=%d intrstatus=%jx", cpu,
(uintmax_t) intrstatus);
found_interrupt = 0;
@@ -2681,7 +2689,7 @@ core2_intr(int cpu, struct trapframe *tf)
/* Reload sampling count. */
wrmsr(IAF_CTR0 + n, v);
- PMCDBG(MDP,INT, 1, "iaf-intr cpu=%d error=%d v=%jx(%jx)", cpu,
+ PMCDBG4(MDP,INT, 1, "iaf-intr cpu=%d error=%d v=%jx(%jx)", cpu,
error, (uintmax_t) v, (uintmax_t) rdpmc(IAF_RI_TO_MSR(n)));
}
@@ -2706,7 +2714,7 @@ core2_intr(int cpu, struct trapframe *tf)
v = iap_reload_count_to_perfctr_value(pm->pm_sc.pm_reloadcount);
- PMCDBG(MDP,INT, 1, "iap-intr cpu=%d error=%d v=%jx", cpu, error,
+ PMCDBG3(MDP,INT, 1, "iap-intr cpu=%d error=%d v=%jx", cpu, error,
(uintmax_t) v);
/* Reload sampling count. */
@@ -2716,14 +2724,14 @@ core2_intr(int cpu, struct trapframe *tf)
/*
* Reenable all non-stalled PMCs.
*/
- PMCDBG(MDP,INT, 1, "cpu=%d intrenable=%jx", cpu,
+ PMCDBG2(MDP,INT, 1, "cpu=%d intrenable=%jx", cpu,
(uintmax_t) intrenable);
cc->pc_globalctrl |= intrenable;
wrmsr(IA_GLOBAL_CTRL, cc->pc_globalctrl & IA_GLOBAL_CTRL_MASK);
- PMCDBG(MDP,INT, 1, "cpu=%d fixedctrl=%jx globalctrl=%jx status=%jx "
+ PMCDBG5(MDP,INT, 1, "cpu=%d fixedctrl=%jx globalctrl=%jx status=%jx "
"ovf=%jx", cpu, (uintmax_t) rdmsr(IAF_CTRL),
(uintmax_t) rdmsr(IA_GLOBAL_CTRL),
(uintmax_t) rdmsr(IA_GLOBAL_STATUS),
@@ -2750,7 +2758,7 @@ pmc_core_initialize(struct pmc_mdep *md, int maxcpu, int version_override)
cpuid[CORE_CPUID_EAX] & 0xFF;
core_cputype = md->pmd_cputype;
- PMCDBG(MDP,INI,1,"core-init cputype=%d ncpu=%d ipa-version=%d",
+ PMCDBG3(MDP,INI,1,"core-init cputype=%d ncpu=%d ipa-version=%d",
core_cputype, maxcpu, ipa_version);
if (ipa_version < 1 || ipa_version > 3 ||
@@ -2788,7 +2796,7 @@ pmc_core_initialize(struct pmc_mdep *md, int maxcpu, int version_override)
core_pmcmask |= ((1ULL << core_iaf_npmc) - 1) << IAF_OFFSET;
}
- PMCDBG(MDP,INI,1,"core-init pmcmask=0x%jx iafri=%d", core_pmcmask,
+ PMCDBG2(MDP,INI,1,"core-init pmcmask=0x%jx iafri=%d", core_pmcmask,
core_iaf_ri);
core_pcpu = malloc(sizeof(*core_pcpu) * maxcpu, M_PMC,
@@ -2811,7 +2819,7 @@ pmc_core_initialize(struct pmc_mdep *md, int maxcpu, int version_override)
void
pmc_core_finalize(struct pmc_mdep *md)
{
- PMCDBG(MDP,INI,1, "%s", "core-finalize");
+ PMCDBG0(MDP,INI,1, "core-finalize");
free(core_pcpu, M_PMC);
core_pcpu = NULL;
diff --git a/sys/dev/hwpmc/hwpmc_e500.c b/sys/dev/hwpmc/hwpmc_e500.c
index d81b333..d963e73 100644
--- a/sys/dev/hwpmc/hwpmc_e500.c
+++ b/sys/dev/hwpmc/hwpmc_e500.c
@@ -304,7 +304,7 @@ e500_read_pmc(int cpu, int ri, pmc_value_t *v)
ri));
tmp = e500_pmcn_read(ri);
- PMCDBG(MDP,REA,2,"ppc-read id=%d -> %jd", ri, tmp);
+ PMCDBG2(MDP,REA,2,"ppc-read id=%d -> %jd", ri, tmp);
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
*v = POWERPC_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp);
else
@@ -328,7 +328,7 @@ e500_write_pmc(int cpu, int ri, pmc_value_t v)
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
v = POWERPC_RELOAD_COUNT_TO_PERFCTR_VALUE(v);
- PMCDBG(MDP,WRI,1,"powerpc-write cpu=%d ri=%d v=%jx", cpu, ri, v);
+ PMCDBG3(MDP,WRI,1,"powerpc-write cpu=%d ri=%d v=%jx", cpu, ri, v);
e500_pmcn_write(ri, v);
@@ -340,7 +340,7 @@ e500_config_pmc(int cpu, int ri, struct pmc *pm)
{
struct pmc_hw *phw;
- PMCDBG(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
+ PMCDBG3(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[powerpc,%d] illegal CPU value %d", __LINE__, cpu));
@@ -443,7 +443,7 @@ e500_pcpu_init(struct pmc_mdep *md, int cpu)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[powerpc,%d] wrong cpu number %d", __LINE__, cpu));
- PMCDBG(MDP,INI,1,"powerpc-init cpu=%d", cpu);
+ PMCDBG1(MDP,INI,1,"powerpc-init cpu=%d", cpu);
/* Freeze all counters. */
mtpmr(PMR_PMGC0, PMGC_FAC | PMGC_PMIE | PMGC_FCECE);
@@ -543,7 +543,7 @@ e500_allocate_pmc(int cpu, int ri, struct pmc *pm,
pm->pm_md.pm_powerpc.pm_powerpc_evsel = config;
- PMCDBG(MDP,ALL,2,"powerpc-allocate ri=%d -> config=0x%x", ri, config);
+ PMCDBG2(MDP,ALL,2,"powerpc-allocate ri=%d -> config=0x%x", ri, config);
return 0;
}
@@ -576,7 +576,7 @@ e500_intr(int cpu, struct trapframe *tf)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[powerpc,%d] out of range CPU %d", __LINE__, cpu));
- PMCDBG(MDP,INT,1, "cpu=%d tf=%p um=%d", cpu, (void *) tf,
+ PMCDBG3(MDP,INT,1, "cpu=%d tf=%p um=%d", cpu, (void *) tf,
TRAPF_USERMODE(tf));
retval = 0;
diff --git a/sys/dev/hwpmc/hwpmc_intel.c b/sys/dev/hwpmc/hwpmc_intel.c
index 486dfa0..ce49f54 100644
--- a/sys/dev/hwpmc/hwpmc_intel.c
+++ b/sys/dev/hwpmc/hwpmc_intel.c
@@ -46,14 +46,14 @@ intel_switch_in(struct pmc_cpu *pc, struct pmc_process *pp)
{
(void) pc;
- PMCDBG(MDP,SWI,1, "pc=%p pp=%p enable-msr=%d", pc, pp,
+ PMCDBG3(MDP,SWI,1, "pc=%p pp=%p enable-msr=%d", pc, pp,
pp->pp_flags & PMC_PP_ENABLE_MSR_ACCESS);
/* allow the RDPMC instruction if needed */
if (pp->pp_flags & PMC_PP_ENABLE_MSR_ACCESS)
load_cr4(rcr4() | CR4_PCE);
- PMCDBG(MDP,SWI,1, "cr4=0x%jx", (uintmax_t) rcr4());
+ PMCDBG1(MDP,SWI,1, "cr4=0x%jx", (uintmax_t) rcr4());
return 0;
}
@@ -64,7 +64,7 @@ intel_switch_out(struct pmc_cpu *pc, struct pmc_process *pp)
(void) pc;
(void) pp; /* can be NULL */
- PMCDBG(MDP,SWO,1, "pc=%p pp=%p cr4=0x%jx", pc, pp,
+ PMCDBG3(MDP,SWO,1, "pc=%p pp=%p cr4=0x%jx", pc, pp,
(uintmax_t) rcr4());
/* always turn off the RDPMC instruction */
@@ -83,7 +83,7 @@ pmc_intel_initialize(void)
KASSERT(cpu_vendor_id == CPU_VENDOR_INTEL,
("[intel,%d] Initializing non-intel processor", __LINE__));
- PMCDBG(MDP,INI,0, "intel-initialize cpuid=0x%x", cpu_id);
+ PMCDBG1(MDP,INI,0, "intel-initialize cpuid=0x%x", cpu_id);
cputype = -1;
nclasses = 2;
diff --git a/sys/dev/hwpmc/hwpmc_logging.c b/sys/dev/hwpmc/hwpmc_logging.c
index 4d14011..cc85481 100644
--- a/sys/dev/hwpmc/hwpmc_logging.c
+++ b/sys/dev/hwpmc/hwpmc_logging.c
@@ -211,9 +211,9 @@ pmclog_get_buffer(struct pmc_owner *po)
TAILQ_REMOVE(&pmc_bufferlist, plb, plb_next);
mtx_unlock_spin(&pmc_bufferlist_mtx);
- PMCDBG(LOG,GTB,1, "po=%p plb=%p", po, plb);
+ PMCDBG2(LOG,GTB,1, "po=%p plb=%p", po, plb);
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
if (plb)
KASSERT(plb->plb_ptr == plb->plb_base &&
plb->plb_base < plb->plb_fence,
@@ -261,7 +261,7 @@ pmclog_loop(void *arg)
ownercred = crhold(p->p_ucred);
PROC_UNLOCK(p);
- PMCDBG(LOG,INI,1, "po=%p kt=%p", po, po->po_kthread);
+ PMCDBG2(LOG,INI,1, "po=%p kt=%p", po, po->po_kthread);
KASSERT(po->po_kthread == curthread->td_proc,
("[pmclog,%d] proc mismatch po=%p po/kt=%p curproc=%p", __LINE__,
po, po->po_kthread, curthread->td_proc));
@@ -312,7 +312,7 @@ pmclog_loop(void *arg)
mtx_unlock(&pmc_kthread_mtx);
/* process the request */
- PMCDBG(LOG,WRI,2, "po=%p base=%p ptr=%p", po,
+ PMCDBG3(LOG,WRI,2, "po=%p base=%p ptr=%p", po,
lb->plb_base, lb->plb_ptr);
/* change our thread's credentials before issuing the I/O */
@@ -343,7 +343,7 @@ pmclog_loop(void *arg)
po->po_error = error; /* save for flush log */
- PMCDBG(LOG,WRI,2, "po=%p error=%d", po, error);
+ PMCDBG2(LOG,WRI,2, "po=%p error=%d", po, error);
break;
}
@@ -403,7 +403,7 @@ pmclog_release(struct pmc_owner *po)
mtx_unlock_spin(&po->po_mtx);
- PMCDBG(LOG,REL,1, "po=%p", po);
+ PMCDBG1(LOG,REL,1, "po=%p", po);
}
@@ -423,7 +423,7 @@ pmclog_reserve(struct pmc_owner *po, int length)
uint32_t *lh;
struct timespec ts;
- PMCDBG(LOG,ALL,1, "po=%p len=%d", po, length);
+ PMCDBG2(LOG,ALL,1, "po=%p len=%d", po, length);
KASSERT(length % sizeof(uint32_t) == 0,
("[pmclog,%d] length not a multiple of word size", __LINE__));
@@ -519,7 +519,7 @@ pmclog_schedule_io(struct pmc_owner *po)
("[pmclog,%d] buffer invariants po=%p ptr=%p fenc=%p", __LINE__,
po, po->po_curbuf->plb_ptr, po->po_curbuf->plb_fence));
- PMCDBG(LOG,SIO, 1, "po=%p", po);
+ PMCDBG1(LOG,SIO, 1, "po=%p", po);
mtx_assert(&po->po_mtx, MA_OWNED);
@@ -579,7 +579,7 @@ pmclog_configure_log(struct pmc_mdep *md, struct pmc_owner *po, int logfd)
* the former is not held here.
*/
sx_assert(&pmc_sx, SA_UNLOCKED);
- PMCDBG(LOG,CFG,1, "config po=%p logfd=%d", po, logfd);
+ PMCDBG2(LOG,CFG,1, "config po=%p logfd=%d", po, logfd);
p = po->po_owner;
@@ -649,7 +649,7 @@ pmclog_deconfigure_log(struct pmc_owner *po)
int error;
struct pmclog_buffer *lb;
- PMCDBG(LOG,CFG,1, "de-config po=%p", po);
+ PMCDBG1(LOG,CFG,1, "de-config po=%p", po);
if ((po->po_flags & PMC_PO_OWNS_LOGFILE) == 0)
return (EINVAL);
@@ -700,7 +700,7 @@ pmclog_flush(struct pmc_owner *po)
int error;
struct pmclog_buffer *lb;
- PMCDBG(LOG,FLS,1, "po=%p", po);
+ PMCDBG1(LOG,FLS,1, "po=%p", po);
/*
* If there is a pending error recorded by the logger thread,
@@ -741,7 +741,7 @@ int
pmclog_close(struct pmc_owner *po)
{
- PMCDBG(LOG,CLO,1, "po=%p", po);
+ PMCDBG1(LOG,CLO,1, "po=%p", po);
mtx_lock(&pmc_kthread_mtx);
@@ -773,7 +773,7 @@ pmclog_process_callchain(struct pmc *pm, struct pmc_sample *ps)
uint32_t flags;
struct pmc_owner *po;
- PMCDBG(LOG,SAM,1,"pm=%p pid=%d n=%d", pm, ps->ps_pid,
+ PMCDBG3(LOG,SAM,1,"pm=%p pid=%d n=%d", pm, ps->ps_pid,
ps->ps_nsamples);
recordlen = offsetof(struct pmclog_callchain, pl_pc) +
@@ -843,7 +843,7 @@ pmclog_process_pmcallocate(struct pmc *pm)
po = pm->pm_owner;
- PMCDBG(LOG,ALL,1, "pm=%p", pm);
+ PMCDBG1(LOG,ALL,1, "pm=%p", pm);
if (PMC_TO_CLASS(pm) == PMC_CLASS_SOFT) {
PMCLOG_RESERVE(po, PMCALLOCATEDYN,
@@ -874,7 +874,7 @@ pmclog_process_pmcattach(struct pmc *pm, pid_t pid, char *path)
int pathlen, recordlen;
struct pmc_owner *po;
- PMCDBG(LOG,ATT,1,"pm=%p pid=%d", pm, pid);
+ PMCDBG2(LOG,ATT,1,"pm=%p pid=%d", pm, pid);
po = pm->pm_owner;
@@ -893,7 +893,7 @@ pmclog_process_pmcdetach(struct pmc *pm, pid_t pid)
{
struct pmc_owner *po;
- PMCDBG(LOG,ATT,1,"!pm=%p pid=%d", pm, pid);
+ PMCDBG2(LOG,ATT,1,"!pm=%p pid=%d", pm, pid);
po = pm->pm_owner;
@@ -915,7 +915,7 @@ pmclog_process_proccsw(struct pmc *pm, struct pmc_process *pp, pmc_value_t v)
KASSERT(pm->pm_flags & PMC_F_LOG_PROCCSW,
("[pmclog,%d] log-process-csw called gratuitously", __LINE__));
- PMCDBG(LOG,SWO,1,"pm=%p pid=%d v=%jx", pm, pp->pp_proc->p_pid,
+ PMCDBG3(LOG,SWO,1,"pm=%p pid=%d v=%jx", pm, pp->pp_proc->p_pid,
v);
po = pm->pm_owner;
@@ -933,7 +933,7 @@ pmclog_process_procexec(struct pmc_owner *po, pmc_id_t pmid, pid_t pid,
{
int pathlen, recordlen;
- PMCDBG(LOG,EXC,1,"po=%p pid=%d path=\"%s\"", po, pid, path);
+ PMCDBG3(LOG,EXC,1,"po=%p pid=%d path=\"%s\"", po, pid, path);
pathlen = strlen(path) + 1; /* #bytes for the path */
recordlen = offsetof(struct pmclog_procexec, pl_pathname) + pathlen;
@@ -957,7 +957,7 @@ pmclog_process_procexit(struct pmc *pm, struct pmc_process *pp)
struct pmc_owner *po;
ri = PMC_TO_ROWINDEX(pm);
- PMCDBG(LOG,EXT,1,"pm=%p pid=%d v=%jx", pm, pp->pp_proc->p_pid,
+ PMCDBG3(LOG,EXT,1,"pm=%p pid=%d v=%jx", pm, pp->pp_proc->p_pid,
pp->pp_pmcs[ri].pp_pmcval);
po = pm->pm_owner;
@@ -1003,7 +1003,7 @@ pmclog_process_userlog(struct pmc_owner *po, struct pmc_op_writelog *wl)
{
int error;
- PMCDBG(LOG,WRI,1, "writelog po=%p ud=0x%x", po, wl->pm_userdata);
+ PMCDBG2(LOG,WRI,1, "writelog po=%p ud=0x%x", po, wl->pm_userdata);
error = 0;
diff --git a/sys/dev/hwpmc/hwpmc_mips.c b/sys/dev/hwpmc/hwpmc_mips.c
index 68a81e0..72f8e89 100644
--- a/sys/dev/hwpmc/hwpmc_mips.c
+++ b/sys/dev/hwpmc/hwpmc_mips.c
@@ -104,7 +104,7 @@ mips_allocate_pmc(int cpu, int ri, struct pmc *pm,
pm->pm_md.pm_mips_evsel = config;
- PMCDBG(MDP,ALL,2,"mips-allocate ri=%d -> config=0x%x", ri, config);
+ PMCDBG2(MDP,ALL,2,"mips-allocate ri=%d -> config=0x%x", ri, config);
return 0;
}
@@ -123,7 +123,7 @@ mips_read_pmc(int cpu, int ri, pmc_value_t *v)
pm = mips_pcpu[cpu]->pc_mipspmcs[ri].phw_pmc;
tmp = mips_pmcn_read(ri);
- PMCDBG(MDP,REA,2,"mips-read id=%d -> %jd", ri, tmp);
+ PMCDBG2(MDP,REA,2,"mips-read id=%d -> %jd", ri, tmp);
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
*v = tmp - (1UL << (mips_pmc_spec.ps_counter_width - 1));
@@ -148,7 +148,7 @@ mips_write_pmc(int cpu, int ri, pmc_value_t v)
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
v = (1UL << (mips_pmc_spec.ps_counter_width - 1)) - v;
- PMCDBG(MDP,WRI,1,"mips-write cpu=%d ri=%d v=%jx", cpu, ri, v);
+ PMCDBG3(MDP,WRI,1,"mips-write cpu=%d ri=%d v=%jx", cpu, ri, v);
mips_pmcn_write(ri, v);
@@ -160,7 +160,7 @@ mips_config_pmc(int cpu, int ri, struct pmc *pm)
{
struct pmc_hw *phw;
- PMCDBG(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
+ PMCDBG3(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[mips,%d] illegal CPU value %d", __LINE__, cpu));
@@ -376,7 +376,7 @@ mips_pcpu_init(struct pmc_mdep *md, int cpu)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[mips,%d] wrong cpu number %d", __LINE__, cpu));
- PMCDBG(MDP,INI,1,"mips-init cpu=%d", cpu);
+ PMCDBG1(MDP,INI,1,"mips-init cpu=%d", cpu);
mips_pcpu[cpu] = pac = malloc(sizeof(struct mips_cpu), M_PMC,
M_WAITOK|M_ZERO);
@@ -421,7 +421,7 @@ pmc_mips_initialize()
*/
mips_npmcs = 2;
- PMCDBG(MDP,INI,1,"mips-init npmcs=%d", mips_npmcs);
+ PMCDBG1(MDP,INI,1,"mips-init npmcs=%d", mips_npmcs);
/*
* Allocate space for pointers to PMC HW descriptors and for
diff --git a/sys/dev/hwpmc/hwpmc_mips24k.c b/sys/dev/hwpmc/hwpmc_mips24k.c
index 18d7f6c..7841555 100644
--- a/sys/dev/hwpmc/hwpmc_mips24k.c
+++ b/sys/dev/hwpmc/hwpmc_mips24k.c
@@ -223,7 +223,7 @@ mips_get_perfctl(int cpu, int ri, uint32_t event, uint32_t caps)
if (caps & PMC_CAP_INTERRUPT)
config |= MIPS24K_PMC_INTERRUPT_ENABLE;
- PMCDBG(MDP,ALL,2,"mips24k-get_perfctl ri=%d -> config=0x%x", ri, config);
+ PMCDBG2(MDP,ALL,2,"mips24k-get_perfctl ri=%d -> config=0x%x", ri, config);
return (config);
}
diff --git a/sys/dev/hwpmc/hwpmc_mips74k.c b/sys/dev/hwpmc/hwpmc_mips74k.c
index 3a5ff33..59f677d 100644
--- a/sys/dev/hwpmc/hwpmc_mips74k.c
+++ b/sys/dev/hwpmc/hwpmc_mips74k.c
@@ -255,7 +255,7 @@ mips_get_perfctl(int cpu, int ri, uint32_t event, uint32_t caps)
if (caps & PMC_CAP_INTERRUPT)
config |= MIPS74K_PMC_INTERRUPT_ENABLE;
- PMCDBG(MDP,ALL,2,"mips74k-get_perfctl ri=%d -> config=0x%x", ri, config);
+ PMCDBG2(MDP,ALL,2,"mips74k-get_perfctl ri=%d -> config=0x%x", ri, config);
return (config);
}
diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c
index cb8ed37..d1b56f1 100644
--- a/sys/dev/hwpmc/hwpmc_mod.c
+++ b/sys/dev/hwpmc/hwpmc_mod.c
@@ -173,7 +173,7 @@ static struct pmc_classdep **pmc_rowindex_to_classdep;
* Prototypes
*/
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
static int pmc_debugflags_sysctl_handler(SYSCTL_HANDLER_ARGS);
static int pmc_debugflags_parse(char *newstr, char *fence);
#endif
@@ -238,7 +238,7 @@ static int pmc_callchaindepth = PMC_CALLCHAIN_DEPTH;
SYSCTL_INT(_kern_hwpmc, OID_AUTO, callchaindepth, CTLFLAG_RDTUN,
&pmc_callchaindepth, 0, "depth of call chain records");
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
struct pmc_debugflags pmc_debugflags = PMC_DEBUG_DEFAULT_FLAGS;
char pmc_debugstr[PMC_DEBUG_STRSIZE];
TUNABLE_STR(PMC_SYSCTL_NAME_PREFIX "debugflags", pmc_debugstr,
@@ -337,7 +337,7 @@ static moduledata_t pmc_mod = {
DECLARE_MODULE(pmc, pmc_mod, SI_SUB_SMP, SI_ORDER_ANY);
MODULE_VERSION(pmc, PMC_VERSION);
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
enum pmc_dbgparse_state {
PMCDS_WS, /* in whitespace */
PMCDS_MAJOR, /* seen a major keyword */
@@ -651,12 +651,12 @@ pmc_ri_to_classdep(struct pmc_mdep *md, int ri, int *adjri)
static void
pmc_save_cpu_binding(struct pmc_binding *pb)
{
- PMCDBG(CPU,BND,2, "%s", "save-cpu");
+ PMCDBG0(CPU,BND,2, "save-cpu");
thread_lock(curthread);
pb->pb_bound = sched_is_bound(curthread);
pb->pb_cpu = curthread->td_oncpu;
thread_unlock(curthread);
- PMCDBG(CPU,BND,2, "save-cpu cpu=%d", pb->pb_cpu);
+ PMCDBG1(CPU,BND,2, "save-cpu cpu=%d", pb->pb_cpu);
}
/*
@@ -666,7 +666,7 @@ pmc_save_cpu_binding(struct pmc_binding *pb)
static void
pmc_restore_cpu_binding(struct pmc_binding *pb)
{
- PMCDBG(CPU,BND,2, "restore-cpu curcpu=%d restore=%d",
+ PMCDBG2(CPU,BND,2, "restore-cpu curcpu=%d restore=%d",
curthread->td_oncpu, pb->pb_cpu);
thread_lock(curthread);
if (pb->pb_bound)
@@ -674,7 +674,7 @@ pmc_restore_cpu_binding(struct pmc_binding *pb)
else
sched_unbind(curthread);
thread_unlock(curthread);
- PMCDBG(CPU,BND,2, "%s", "restore-cpu done");
+ PMCDBG0(CPU,BND,2, "restore-cpu done");
}
/*
@@ -691,7 +691,7 @@ pmc_select_cpu(int cpu)
KASSERT(pmc_cpu_is_active(cpu), ("[pmc,%d] selecting inactive "
"CPU %d", __LINE__, cpu));
- PMCDBG(CPU,SEL,2, "select-cpu cpu=%d", cpu);
+ PMCDBG1(CPU,SEL,2, "select-cpu cpu=%d", cpu);
thread_lock(curthread);
sched_bind(curthread, cpu);
thread_unlock(curthread);
@@ -700,7 +700,7 @@ pmc_select_cpu(int cpu)
("[pmc,%d] CPU not bound [cpu=%d, curr=%d]", __LINE__,
cpu, curthread->td_oncpu));
- PMCDBG(CPU,SEL,2, "select-cpu cpu=%d ok", cpu);
+ PMCDBG1(CPU,SEL,2, "select-cpu cpu=%d ok", cpu);
}
/*
@@ -742,14 +742,14 @@ pmc_remove_owner(struct pmc_owner *po)
sx_assert(&pmc_sx, SX_XLOCKED);
- PMCDBG(OWN,ORM,1, "remove-owner po=%p", po);
+ PMCDBG1(OWN,ORM,1, "remove-owner po=%p", po);
/* Remove descriptor from the owner hash table */
LIST_REMOVE(po, po_next);
/* release all owned PMC descriptors */
LIST_FOREACH_SAFE(pm, &po->po_pmcs, pm_next, tmp) {
- PMCDBG(OWN,ORM,2, "pmc=%p", pm);
+ PMCDBG1(OWN,ORM,2, "pmc=%p", pm);
KASSERT(pm->pm_owner == po,
("[pmc,%d] owner %p != po %p", __LINE__, pm->pm_owner, po));
@@ -775,7 +775,7 @@ static void
pmc_maybe_remove_owner(struct pmc_owner *po)
{
- PMCDBG(OWN,OMR,1, "maybe-remove-owner po=%p", po);
+ PMCDBG1(OWN,OMR,1, "maybe-remove-owner po=%p", po);
/*
* Remove owner record if
@@ -813,10 +813,10 @@ pmc_link_target_process(struct pmc *pm, struct pmc_process *pp)
ri = PMC_TO_ROWINDEX(pm);
- PMCDBG(PRC,TLK,1, "link-target pmc=%p ri=%d pmc-process=%p",
+ PMCDBG3(PRC,TLK,1, "link-target pmc=%p ri=%d pmc-process=%p",
pm, ri, pp);
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
LIST_FOREACH(pt, &pm->pm_targets, pt_next)
if (pt->pt_process == pp)
KASSERT(0, ("[pmc,%d] pp %p already in pmc %p targets",
@@ -866,7 +866,7 @@ pmc_unlink_target_process(struct pmc *pm, struct pmc_process *pp)
ri = PMC_TO_ROWINDEX(pm);
- PMCDBG(PRC,TUL,1, "unlink-target pmc=%p ri=%d pmc-process=%p",
+ PMCDBG3(PRC,TUL,1, "unlink-target pmc=%p ri=%d pmc-process=%p",
pm, ri, pp);
KASSERT(pp->pp_pmcs[ri].pp_pmc == pm,
@@ -902,7 +902,7 @@ pmc_unlink_target_process(struct pmc *pm, struct pmc_process *pp)
kern_psignal(p, SIGIO);
PROC_UNLOCK(p);
- PMCDBG(PRC,SIG,2, "signalling proc=%p signal=%d", p,
+ PMCDBG2(PRC,SIG,2, "signalling proc=%p signal=%d", p,
SIGIO);
}
}
@@ -975,7 +975,7 @@ pmc_attach_one_process(struct proc *p, struct pmc *pm)
sx_assert(&pmc_sx, SX_XLOCKED);
- PMCDBG(PRC,ATT,2, "attach-one pm=%p ri=%d proc=%p (%d, %s)", pm,
+ PMCDBG5(PRC,ATT,2, "attach-one pm=%p ri=%d proc=%p (%d, %s)", pm,
PMC_TO_ROWINDEX(pm), p, p->p_pid, p->p_comm);
/*
@@ -1040,7 +1040,7 @@ pmc_attach_process(struct proc *p, struct pmc *pm)
sx_assert(&pmc_sx, SX_XLOCKED);
- PMCDBG(PRC,ATT,1, "attach pm=%p ri=%d proc=%p (%d, %s)", pm,
+ PMCDBG5(PRC,ATT,1, "attach pm=%p ri=%d proc=%p (%d, %s)", pm,
PMC_TO_ROWINDEX(pm), p, p->p_pid, p->p_comm);
@@ -1107,7 +1107,7 @@ pmc_detach_one_process(struct proc *p, struct pmc *pm, int flags)
ri = PMC_TO_ROWINDEX(pm);
- PMCDBG(PRC,ATT,2, "detach-one pm=%p ri=%d proc=%p (%d, %s) flags=0x%x",
+ PMCDBG6(PRC,ATT,2, "detach-one pm=%p ri=%d proc=%p (%d, %s) flags=0x%x",
pm, ri, p, p->p_pid, p->p_comm, flags);
if ((pp = pmc_find_process_descriptor(p, 0)) == NULL)
@@ -1157,7 +1157,7 @@ pmc_detach_process(struct proc *p, struct pmc *pm)
sx_assert(&pmc_sx, SX_XLOCKED);
- PMCDBG(PRC,ATT,1, "detach pm=%p ri=%d proc=%p (%d, %s)", pm,
+ PMCDBG5(PRC,ATT,1, "detach pm=%p ri=%d proc=%p (%d, %s)", pm,
PMC_TO_ROWINDEX(pm), p, p->p_pid, p->p_comm);
if ((pm->pm_flags & PMC_F_DESCENDANTS) == 0)
@@ -1228,7 +1228,7 @@ pmc_process_csw_in(struct thread *td)
cpu = PCPU_GET(cpuid); /* td->td_oncpu is invalid */
- PMCDBG(CSW,SWI,1, "cpu=%d proc=%p (%d, %s) pp=%p", cpu, p,
+ PMCDBG5(CSW,SWI,1, "cpu=%d proc=%p (%d, %s) pp=%p", cpu, p,
p->p_pid, p->p_comm, pp);
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
@@ -1295,7 +1295,7 @@ pmc_process_csw_in(struct thread *td)
mtx_pool_unlock_spin(pmc_mtxpool, pm);
}
- PMCDBG(CSW,SWI,1,"cpu=%d ri=%d new=%jd", cpu, ri, newvalue);
+ PMCDBG3(CSW,SWI,1,"cpu=%d ri=%d new=%jd", cpu, ri, newvalue);
pcd->pcd_write_pmc(cpu, adjri, newvalue);
pcd->pcd_start_pmc(cpu, adjri);
@@ -1356,7 +1356,7 @@ pmc_process_csw_out(struct thread *td)
cpu = PCPU_GET(cpuid); /* td->td_oncpu is invalid */
- PMCDBG(CSW,SWO,1, "cpu=%d proc=%p (%d, %s) pp=%p", cpu, p,
+ PMCDBG5(CSW,SWO,1, "cpu=%d proc=%p (%d, %s) pp=%p", cpu, p,
p->p_pid, p->p_comm, pp);
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
@@ -1418,7 +1418,7 @@ pmc_process_csw_out(struct thread *td)
tmp = newvalue - PMC_PCPU_SAVED(cpu,ri);
- PMCDBG(CSW,SWO,1,"cpu=%d ri=%d tmp=%jd", cpu, ri,
+ PMCDBG3(CSW,SWO,1,"cpu=%d ri=%d tmp=%jd", cpu, ri,
tmp);
if (mode == PMC_MODE_TS) {
@@ -1435,7 +1435,7 @@ pmc_process_csw_out(struct thread *td)
tmp += pm->pm_sc.pm_reloadcount;
mtx_pool_lock_spin(pmc_mtxpool, pm);
pp->pp_pmcs[ri].pp_pmcval -= tmp;
- if ((int64_t) pp->pp_pmcs[ri].pp_pmcval < 0)
+ if ((int64_t) pp->pp_pmcs[ri].pp_pmcval <= 0)
pp->pp_pmcs[ri].pp_pmcval +=
pm->pm_sc.pm_reloadcount;
mtx_pool_unlock_spin(pmc_mtxpool, pm);
@@ -1575,7 +1575,7 @@ pmc_log_kernel_mappings(struct pmc *pm)
*/
kmbase = linker_hwpmc_list_objects();
for (km = kmbase; km->pm_file != NULL; km++) {
- PMCDBG(LOG,REG,1,"%s %p", (char *) km->pm_file,
+ PMCDBG2(LOG,REG,1,"%s %p", (char *) km->pm_file,
(void *) km->pm_address);
pmclog_process_map_in(po, (pid_t) -1, km->pm_address,
km->pm_file);
@@ -1616,7 +1616,7 @@ pmc_log_process_mappings(struct pmc_owner *po, struct proc *p)
for (entry = map->header.next; entry != &map->header; entry = entry->next) {
if (entry == NULL) {
- PMCDBG(LOG,OPS,2, "hwpmc: vm_map entry unexpectedly "
+ PMCDBG2(LOG,OPS,2, "hwpmc: vm_map entry unexpectedly "
"NULL! pid=%d vm_map=%p\n", p->p_pid, map);
break;
}
@@ -1649,7 +1649,7 @@ pmc_log_process_mappings(struct pmc_owner *po, struct proc *p)
* At this point lobj is the base vm_object and it is locked.
*/
if (lobj == NULL) {
- PMCDBG(LOG,OPS,2, "hwpmc: lobj unexpectedly NULL! pid=%d "
+ PMCDBG3(LOG,OPS,2, "hwpmc: lobj unexpectedly NULL! pid=%d "
"vm_map=%p vm_obj=%p\n", p->p_pid, map, obj);
VM_OBJECT_RUNLOCK(obj);
continue;
@@ -1784,7 +1784,7 @@ pmc_log_all_process_mappings(struct pmc_owner *po)
*/
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
const char *pmc_hooknames[] = {
/* these strings correspond to PMC_FN_* in <sys/pmckern.h> */
"",
@@ -1806,7 +1806,7 @@ static int
pmc_hook_handler(struct thread *td, int function, void *arg)
{
- PMCDBG(MOD,PMH,1, "hook td=%p func=%d \"%s\" arg=%p", td, function,
+ PMCDBG4(MOD,PMH,1, "hook td=%p func=%d \"%s\" arg=%p", td, function,
pmc_hooknames[function], arg);
switch (function)
@@ -1889,7 +1889,7 @@ pmc_hook_handler(struct thread *td, int function, void *arg)
free(freepath, M_TEMP);
- PMCDBG(PRC,EXC,1, "exec proc=%p (%d, %s) cred-changed=%d",
+ PMCDBG4(PRC,EXC,1, "exec proc=%p (%d, %s) cred-changed=%d",
p, p->p_pid, p->p_comm, pk->pm_credentialschanged);
if (pk->pm_credentialschanged == 0) /* no change */
@@ -2002,7 +2002,7 @@ pmc_hook_handler(struct thread *td, int function, void *arg)
break;
default:
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
KASSERT(0, ("[pmc,%d] unknown hook %d\n", __LINE__, function));
#endif
break;
@@ -2034,7 +2034,7 @@ pmc_allocate_owner_descriptor(struct proc *p)
TAILQ_INIT(&po->po_logbuffers);
mtx_init(&po->po_mtx, "pmc-owner-mtx", "pmc-per-proc", MTX_SPIN);
- PMCDBG(OWN,ALL,1, "allocate-owner proc=%p (%d, %s) pmc-owner=%p",
+ PMCDBG4(OWN,ALL,1, "allocate-owner proc=%p (%d, %s) pmc-owner=%p",
p, p->p_pid, p->p_comm, po);
return po;
@@ -2044,7 +2044,7 @@ static void
pmc_destroy_owner_descriptor(struct pmc_owner *po)
{
- PMCDBG(OWN,REL,1, "destroy-owner po=%p proc=%p (%d, %s)",
+ PMCDBG4(OWN,REL,1, "destroy-owner po=%p proc=%p (%d, %s)",
po, po->po_owner, po->po_owner->p_pid, po->po_owner->p_comm);
mtx_destroy(&po->po_mtx);
@@ -2135,7 +2135,7 @@ pmc_find_owner_descriptor(struct proc *p)
if (po->po_owner == p)
break;
- PMCDBG(OWN,FND,1, "find-owner proc=%p (%d, %s) hindex=0x%x -> "
+ PMCDBG5(OWN,FND,1, "find-owner proc=%p (%d, %s) hindex=0x%x -> "
"pmc-owner=%p", p, p->p_pid, p->p_comm, hindex, po);
return po;
@@ -2155,7 +2155,7 @@ pmc_allocate_pmc_descriptor(void)
pmc = malloc(sizeof(struct pmc), M_PMC, M_WAITOK|M_ZERO);
- PMCDBG(PMC,ALL,1, "allocate-pmc -> pmc=%p", pmc);
+ PMCDBG1(PMC,ALL,1, "allocate-pmc -> pmc=%p", pmc);
return pmc;
}
@@ -2185,7 +2185,7 @@ pmc_destroy_pmc_descriptor(struct pmc *pm)
static void
pmc_wait_for_pmc_idle(struct pmc *pm)
{
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
volatile int maxloop;
maxloop = 100 * pmc_cpu_max();
@@ -2195,7 +2195,7 @@ pmc_wait_for_pmc_idle(struct pmc *pm)
* comes down to zero.
*/
while (atomic_load_acq_32(&pm->pm_runcount) > 0) {
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
maxloop--;
KASSERT(maxloop > 0,
("[pmc,%d] (ri%d, rc%d) waiting too long for "
@@ -2238,7 +2238,7 @@ pmc_release_pmc_descriptor(struct pmc *pm)
pcd = pmc_ri_to_classdep(md, ri, &adjri);
mode = PMC_TO_MODE(pm);
- PMCDBG(PMC,REL,1, "release-pmc pmc=%p ri=%d mode=%d", pm, ri,
+ PMCDBG3(PMC,REL,1, "release-pmc pmc=%p ri=%d mode=%d", pm, ri,
mode);
/*
@@ -2266,14 +2266,14 @@ pmc_release_pmc_descriptor(struct pmc *pm)
KASSERT(phw->phw_pmc == pm,
("[pmc, %d] pmc ptr ri(%d) hw(%p) pm(%p)",
__LINE__, ri, phw->phw_pmc, pm));
- PMCDBG(PMC,REL,2, "stopping cpu=%d ri=%d", cpu, ri);
+ PMCDBG2(PMC,REL,2, "stopping cpu=%d ri=%d", cpu, ri);
critical_enter();
pcd->pcd_stop_pmc(cpu, adjri);
critical_exit();
}
- PMCDBG(PMC,REL,2, "decfg cpu=%d ri=%d", cpu, ri);
+ PMCDBG2(PMC,REL,2, "decfg cpu=%d ri=%d", cpu, ri);
critical_enter();
pcd->pcd_config_pmc(cpu, adjri, NULL);
@@ -2329,7 +2329,7 @@ pmc_release_pmc_descriptor(struct pmc *pm)
pp = ptgt->pt_process;
pmc_unlink_target_process(pm, pp); /* frees 'ptgt' */
- PMCDBG(PMC,REL,3, "pp->refcnt=%d", pp->pp_refcnt);
+ PMCDBG1(PMC,REL,3, "pp->refcnt=%d", pp->pp_refcnt);
/*
* If the target process record shows that no
@@ -2395,7 +2395,7 @@ pmc_register_owner(struct proc *p, struct pmc *pmc)
if (po->po_flags & PMC_PO_OWNS_LOGFILE)
pmclog_process_pmcallocate(pmc);
- PMCDBG(PMC,REG,1, "register-owner pmc-owner=%p pmc=%p",
+ PMCDBG2(PMC,REG,1, "register-owner pmc-owner=%p pmc=%p",
po, pmc);
return 0;
@@ -2433,7 +2433,7 @@ pmc_can_allocate_rowindex(struct proc *p, unsigned int ri, int cpu)
struct pmc_owner *po;
struct pmc_process *pp;
- PMCDBG(PMC,ALR,1, "can-allocate-rowindex proc=%p (%d, %s) ri=%d "
+ PMCDBG5(PMC,ALR,1, "can-allocate-rowindex proc=%p (%d, %s) ri=%d "
"cpu=%d", p, p->p_pid, p->p_comm, ri, cpu);
/*
@@ -2463,7 +2463,7 @@ pmc_can_allocate_rowindex(struct proc *p, unsigned int ri, int cpu)
if (pp->pp_pmcs[ri].pp_pmc)
return EEXIST;
- PMCDBG(PMC,ALR,2, "can-allocate-rowindex proc=%p (%d, %s) ri=%d ok",
+ PMCDBG4(PMC,ALR,2, "can-allocate-rowindex proc=%p (%d, %s) ri=%d ok",
p, p->p_pid, p->p_comm, ri);
return 0;
@@ -2481,7 +2481,7 @@ pmc_can_allocate_row(int ri, enum pmc_mode mode)
sx_assert(&pmc_sx, SX_XLOCKED);
- PMCDBG(PMC,ALR,1, "can-allocate-row ri=%d mode=%d", ri, mode);
+ PMCDBG2(PMC,ALR,1, "can-allocate-row ri=%d mode=%d", ri, mode);
if (PMC_IS_SYSTEM_MODE(mode))
disp = PMC_DISP_STANDALONE;
@@ -2508,7 +2508,7 @@ pmc_can_allocate_row(int ri, enum pmc_mode mode)
* All OK
*/
- PMCDBG(PMC,ALR,2, "can-allocate-row ri=%d mode=%d ok", ri, mode);
+ PMCDBG2(PMC,ALR,2, "can-allocate-row ri=%d mode=%d ok", ri, mode);
return 0;
@@ -2541,7 +2541,7 @@ pmc_find_pmc(pmc_id_t pmcid, struct pmc **pmc)
struct pmc *pm;
struct pmc_owner *po;
- PMCDBG(PMC,FND,1, "find-pmc id=%d", pmcid);
+ PMCDBG1(PMC,FND,1, "find-pmc id=%d", pmcid);
if ((po = pmc_find_owner_descriptor(curthread->td_proc)) == NULL)
return ESRCH;
@@ -2549,7 +2549,7 @@ pmc_find_pmc(pmc_id_t pmcid, struct pmc **pmc)
if ((pm = pmc_find_pmc_descriptor_in_process(po, pmcid)) == NULL)
return EINVAL;
- PMCDBG(PMC,FND,2, "find-pmc id=%d -> pmc=%p", pmcid, pm);
+ PMCDBG2(PMC,FND,2, "find-pmc id=%d -> pmc=%p", pmcid, pm);
*pmc = pm;
return 0;
@@ -2577,7 +2577,7 @@ pmc_start(struct pmc *pm)
error = 0;
- PMCDBG(PMC,OPS,1, "start pmc=%p mode=%d ri=%d", pm, mode, ri);
+ PMCDBG3(PMC,OPS,1, "start pmc=%p mode=%d ri=%d", pm, mode, ri);
po = pm->pm_owner;
@@ -2633,7 +2633,7 @@ pmc_start(struct pmc *pm)
if (po->po_sscount == 0) {
LIST_INSERT_HEAD(&pmc_ss_owners, po, po_ssnext);
atomic_add_rel_int(&pmc_ss_count, 1);
- PMCDBG(PMC,OPS,1, "po=%p in global list", po);
+ PMCDBG1(PMC,OPS,1, "po=%p in global list", po);
}
po->po_sscount++;
@@ -2696,7 +2696,7 @@ pmc_stop(struct pmc *pm)
KASSERT(pm != NULL, ("[pmc,%d] null pmc", __LINE__));
- PMCDBG(PMC,OPS,1, "stop pmc=%p mode=%d ri=%d", pm,
+ PMCDBG3(PMC,OPS,1, "stop pmc=%p mode=%d ri=%d", pm,
PMC_TO_MODE(pm), PMC_TO_ROWINDEX(pm));
pm->pm_state = PMC_STATE_STOPPED;
@@ -2751,7 +2751,7 @@ pmc_stop(struct pmc *pm)
if (po->po_sscount == 0) {
atomic_subtract_rel_int(&pmc_ss_count, 1);
LIST_REMOVE(po, po_ssnext);
- PMCDBG(PMC,OPS,2,"po=%p removed from global list", po);
+ PMCDBG1(PMC,OPS,2,"po=%p removed from global list", po);
}
}
@@ -2759,7 +2759,7 @@ pmc_stop(struct pmc *pm)
}
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
static const char *pmc_op_to_name[] = {
#undef __PMC_OP
#define __PMC_OP(N, D) #N ,
@@ -2804,7 +2804,7 @@ pmc_syscall_handler(struct thread *td, void *syscall_args)
op = c->pmop_code;
arg = c->pmop_data;
- PMCDBG(MOD,PMS,1, "syscall op=%d \"%s\" arg=%p", op,
+ PMCDBG3(MOD,PMS,1, "syscall op=%d \"%s\" arg=%p", op,
pmc_op_to_name[op], arg);
error = 0;
@@ -3317,7 +3317,7 @@ pmc_syscall_handler(struct thread *td, void *syscall_args)
break;
}
- PMCDBG(PMC,ALL,2, "event=%d caps=0x%x mode=%d cpu=%d",
+ PMCDBG4(PMC,ALL,2, "event=%d caps=0x%x mode=%d cpu=%d",
pa.pm_ev, caps, mode, cpu);
pmc = pmc_allocate_pmc_descriptor();
@@ -3379,7 +3379,7 @@ pmc_syscall_handler(struct thread *td, void *syscall_args)
/* Fill in the correct value in the ID field */
pmc->pm_id = PMC_ID_MAKE_ID(cpu,mode,pa.pm_class,n);
- PMCDBG(PMC,ALL,2, "ev=%d class=%d mode=%d n=%d -> pmcid=%x",
+ PMCDBG5(PMC,ALL,2, "ev=%d class=%d mode=%d n=%d -> pmcid=%x",
pmc->pm_event, pa.pm_class, mode, n, pmc->pm_id);
/* Process mode PMCs with logging enabled need log files */
@@ -3702,7 +3702,7 @@ pmc_syscall_handler(struct thread *td, void *syscall_args)
break;
ri = 0;
- PMCDBG(PMC,OPS,1, "rw id=%d flags=0x%x", prw.pm_pmcid,
+ PMCDBG2(PMC,OPS,1, "rw id=%d flags=0x%x", prw.pm_pmcid,
prw.pm_flags);
/* must have at least one flag set */
@@ -3798,12 +3798,12 @@ pmc_syscall_handler(struct thread *td, void *syscall_args)
pprw = (struct pmc_op_pmcrw *) arg;
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
if (prw.pm_flags & PMC_F_NEWVALUE)
- PMCDBG(PMC,OPS,2, "rw id=%d new %jx -> old %jx",
+ PMCDBG3(PMC,OPS,2, "rw id=%d new %jx -> old %jx",
ri, prw.pm_value, oldvalue);
else if (prw.pm_flags & PMC_F_OLDVALUE)
- PMCDBG(PMC,OPS,2, "rw id=%d -> old %jx", ri, oldvalue);
+ PMCDBG2(PMC,OPS,2, "rw id=%d -> old %jx", ri, oldvalue);
#endif
/* return old value if requested */
@@ -4046,7 +4046,7 @@ pmc_process_interrupt(int cpu, int ring, struct pmc *pm, struct trapframe *tf,
if (ps->ps_nsamples) { /* in use, reader hasn't caught up */
pm->pm_stalled = 1;
atomic_add_int(&pmc_stats.pm_intr_bufferfull, 1);
- PMCDBG(SAM,INT,1,"(spc) cpu=%d pm=%p tf=%p um=%d wr=%d rd=%d",
+ PMCDBG6(SAM,INT,1,"(spc) cpu=%d pm=%p tf=%p um=%d wr=%d rd=%d",
cpu, pm, (void *) tf, inuserspace,
(int) (psb->ps_write - psb->ps_samples),
(int) (psb->ps_read - psb->ps_samples));
@@ -4056,7 +4056,7 @@ pmc_process_interrupt(int cpu, int ring, struct pmc *pm, struct trapframe *tf,
/* Fill in entry. */
- PMCDBG(SAM,INT,1,"cpu=%d pm=%p tf=%p um=%d wr=%d rd=%d", cpu, pm,
+ PMCDBG6(SAM,INT,1,"cpu=%d pm=%p tf=%p um=%d wr=%d rd=%d", cpu, pm,
(void *) tf, inuserspace,
(int) (psb->ps_write - psb->ps_samples),
(int) (psb->ps_read - psb->ps_samples));
@@ -4239,7 +4239,7 @@ pmc_process_samples(int cpu, int ring)
break;
}
- PMCDBG(SAM,OPS,1,"cpu=%d pm=%p n=%d fl=%x wr=%d rd=%d", cpu,
+ PMCDBG6(SAM,OPS,1,"cpu=%d pm=%p n=%d fl=%x wr=%d rd=%d", cpu,
pm, ps->ps_nsamples, ps->ps_flags,
(int) (psb->ps_write - psb->ps_samples),
(int) (psb->ps_read - psb->ps_samples));
@@ -4355,7 +4355,7 @@ pmc_process_exit(void *arg __unused, struct proc *p)
return;
PMC_GET_SX_XLOCK();
- PMCDBG(PRC,EXT,1,"process-exit proc=%p (%d, %s)", p, p->p_pid,
+ PMCDBG3(PRC,EXT,1,"process-exit proc=%p (%d, %s)", p, p->p_pid,
p->p_comm);
/*
@@ -4370,7 +4370,7 @@ pmc_process_exit(void *arg __unused, struct proc *p)
* entry from our target process hash table, using
* PMC_FLAG_REMOVE.
*/
- PMCDBG(PRC,EXT,1, "process-exit proc=%p (%d, %s)", p, p->p_pid,
+ PMCDBG3(PRC,EXT,1, "process-exit proc=%p (%d, %s)", p, p->p_pid,
p->p_comm);
critical_enter(); /* no preemption */
@@ -4380,7 +4380,7 @@ pmc_process_exit(void *arg __unused, struct proc *p)
if ((pp = pmc_find_process_descriptor(p,
PMC_FLAG_REMOVE)) != NULL) {
- PMCDBG(PRC,EXT,2,
+ PMCDBG2(PRC,EXT,2,
"process-exit proc=%p pmc-process=%p", p, pp);
/*
@@ -4403,13 +4403,13 @@ pmc_process_exit(void *arg __unused, struct proc *p)
(void) (*pcd->pcd_get_config)(cpu, adjri, &pm);
- PMCDBG(PRC,EXT,2, "ri=%d pm=%p", ri, pm);
+ PMCDBG2(PRC,EXT,2, "ri=%d pm=%p", ri, pm);
if (pm == NULL ||
!PMC_IS_VIRTUAL_MODE(PMC_TO_MODE(pm)))
continue;
- PMCDBG(PRC,EXT,2, "ppmcs[%d]=%p pm=%p "
+ PMCDBG4(PRC,EXT,2, "ppmcs[%d]=%p pm=%p "
"state=%d", ri, pp->pp_pmcs[ri].pp_pmc,
pm, pm->pm_state);
@@ -4525,7 +4525,7 @@ pmc_process_fork(void *arg __unused, struct proc *p1, struct proc *newproc,
return;
PMC_GET_SX_XLOCK();
- PMCDBG(PMC,FRK,1, "process-fork proc=%p (%d, %s) -> %p", p1,
+ PMCDBG4(PMC,FRK,1, "process-fork proc=%p (%d, %s) -> %p", p1,
p1->p_pid, p1->p_comm, newproc);
/*
@@ -4625,12 +4625,20 @@ pmc_kld_unload(void *arg __unused, const char *filename __unused,
/*
* initialization
*/
+static const char *
+pmc_name_of_pmcclass(enum pmc_class class)
+{
-static const char *pmc_name_of_pmcclass[] = {
+ switch (class) {
#undef __PMC_CLASS
-#define __PMC_CLASS(N) #N ,
- __PMC_CLASSES()
-};
+#define __PMC_CLASS(S,V,D) \
+ case PMC_CLASS_##S: \
+ return #S;
+ __PMC_CLASSES();
+ default:
+ return ("<unknown>");
+ }
+}
/*
* Base class initializer: allocate structure and set default classes.
@@ -4712,7 +4720,7 @@ pmc_initialize(void)
md = NULL;
error = 0;
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
/* parse debug flags first */
if (TUNABLE_STR_FETCH(PMC_SYSCTL_NAME_PREFIX "debugflags",
pmc_debugstr, sizeof(pmc_debugstr)))
@@ -4720,7 +4728,7 @@ pmc_initialize(void)
pmc_debugstr+strlen(pmc_debugstr));
#endif
- PMCDBG(MOD,INI,0, "PMC Initialize (version %x)", PMC_VERSION);
+ PMCDBG1(MOD,INI,0, "PMC Initialize (version %x)", PMC_VERSION);
/* check kernel version */
if (pmc_kernel_version != PMC_VERSION) {
@@ -4881,7 +4889,7 @@ pmc_initialize(void)
pmc_mtxpool = mtx_pool_create("pmc-leaf", pmc_mtxpool_size,
MTX_SPIN);
- PMCDBG(MOD,INI,1, "pmc_ownerhash=%p, mask=0x%lx "
+ PMCDBG4(MOD,INI,1, "pmc_ownerhash=%p, mask=0x%lx "
"targethash=%p mask=0x%lx", pmc_ownerhash, pmc_ownerhashmask,
pmc_processhash, pmc_processhashmask);
@@ -4909,7 +4917,7 @@ pmc_initialize(void)
for (n = 0; n < (int) md->pmd_nclass; n++) {
pcd = &md->pmd_classdep[n];
printf(" %s/%d/%d/0x%b",
- pmc_name_of_pmcclass[pcd->pcd_class],
+ pmc_name_of_pmcclass(pcd->pcd_class),
pcd->pcd_num,
pcd->pcd_width,
pcd->pcd_caps,
@@ -4933,11 +4941,11 @@ pmc_cleanup(void)
struct pmc_ownerhash *ph;
struct pmc_owner *po, *tmp;
struct pmc_binding pb;
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
struct pmc_processhash *prh;
#endif
- PMCDBG(MOD,INI,0, "%s", "cleanup");
+ PMCDBG0(MOD,INI,0, "cleanup");
/* switch off sampling */
CPU_ZERO(&pmc_cpumask);
@@ -4966,7 +4974,7 @@ pmc_cleanup(void)
pmc_remove_owner(po);
/* send SIGBUS to owner processes */
- PMCDBG(MOD,INI,2, "cleanup signal proc=%p "
+ PMCDBG3(MOD,INI,2, "cleanup signal proc=%p "
"(%d, %s)", po->po_owner,
po->po_owner->p_pid,
po->po_owner->p_comm);
@@ -4985,15 +4993,15 @@ pmc_cleanup(void)
mtx_destroy(&pmc_processhash_mtx);
if (pmc_processhash) {
-#ifdef DEBUG
+#ifdef HWPMC_DEBUG
struct pmc_process *pp;
- PMCDBG(MOD,INI,3, "%s", "destroy process hash");
+ PMCDBG0(MOD,INI,3, "destroy process hash");
for (prh = pmc_processhash;
prh <= &pmc_processhash[pmc_processhashmask];
prh++)
LIST_FOREACH(pp, prh, pp_next)
- PMCDBG(MOD,INI,3, "pid=%d", pp->pp_proc->p_pid);
+ PMCDBG1(MOD,INI,3, "pid=%d", pp->pp_proc->p_pid);
#endif
hashdestroy(pmc_processhash, M_PMC, pmc_processhashmask);
@@ -5001,7 +5009,7 @@ pmc_cleanup(void)
}
if (pmc_ownerhash) {
- PMCDBG(MOD,INI,3, "%s", "destroy owner hash");
+ PMCDBG0(MOD,INI,3, "destroy owner hash");
hashdestroy(pmc_ownerhash, M_PMC, pmc_ownerhashmask);
pmc_ownerhash = NULL;
}
@@ -5014,11 +5022,11 @@ pmc_cleanup(void)
/* do processor and pmc-class dependent cleanup */
maxcpu = pmc_cpu_max();
- PMCDBG(MOD,INI,3, "%s", "md cleanup");
+ PMCDBG0(MOD,INI,3, "md cleanup");
if (md) {
pmc_save_cpu_binding(&pb);
for (cpu = 0; cpu < maxcpu; cpu++) {
- PMCDBG(MOD,INI,1,"pmc-cleanup cpu=%d pcs=%p",
+ PMCDBG2(MOD,INI,1,"pmc-cleanup cpu=%d pcs=%p",
cpu, pmc_pcpu[cpu]);
if (!pmc_cpu_is_active(cpu) || pmc_pcpu[cpu] == NULL)
continue;
@@ -5094,7 +5102,7 @@ load (struct module *module __unused, int cmd, void *arg __unused)
error = pmc_initialize();
if (error != 0)
break;
- PMCDBG(MOD,INI,1, "syscall=%d maxcpu=%d",
+ PMCDBG2(MOD,INI,1, "syscall=%d maxcpu=%d",
pmc_syscall_num, pmc_cpu_max());
break;
@@ -5102,7 +5110,7 @@ load (struct module *module __unused, int cmd, void *arg __unused)
case MOD_UNLOAD :
case MOD_SHUTDOWN:
pmc_cleanup();
- PMCDBG(MOD,INI,1, "%s", "unloaded");
+ PMCDBG0(MOD,INI,1, "unloaded");
break;
default :
diff --git a/sys/dev/hwpmc/hwpmc_mpc7xxx.c b/sys/dev/hwpmc/hwpmc_mpc7xxx.c
index eaa440e..296bd37 100644
--- a/sys/dev/hwpmc/hwpmc_mpc7xxx.c
+++ b/sys/dev/hwpmc/hwpmc_mpc7xxx.c
@@ -384,7 +384,7 @@ mpc7xxx_read_pmc(int cpu, int ri, pmc_value_t *v)
ri));
tmp = mpc7xxx_pmcn_read(ri);
- PMCDBG(MDP,REA,2,"ppc-read id=%d -> %jd", ri, tmp);
+ PMCDBG2(MDP,REA,2,"ppc-read id=%d -> %jd", ri, tmp);
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
*v = POWERPC_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp);
else
@@ -408,7 +408,7 @@ mpc7xxx_write_pmc(int cpu, int ri, pmc_value_t v)
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
v = POWERPC_RELOAD_COUNT_TO_PERFCTR_VALUE(v);
- PMCDBG(MDP,WRI,1,"powerpc-write cpu=%d ri=%d v=%jx", cpu, ri, v);
+ PMCDBG3(MDP,WRI,1,"powerpc-write cpu=%d ri=%d v=%jx", cpu, ri, v);
mpc7xxx_pmcn_write(ri, v);
@@ -420,7 +420,7 @@ mpc7xxx_config_pmc(int cpu, int ri, struct pmc *pm)
{
struct pmc_hw *phw;
- PMCDBG(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
+ PMCDBG3(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[powerpc,%d] illegal CPU value %d", __LINE__, cpu));
@@ -559,7 +559,7 @@ mpc7xxx_pcpu_init(struct pmc_mdep *md, int cpu)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[powerpc,%d] wrong cpu number %d", __LINE__, cpu));
- PMCDBG(MDP,INI,1,"powerpc-init cpu=%d", cpu);
+ PMCDBG1(MDP,INI,1,"powerpc-init cpu=%d", cpu);
powerpc_pcpu[cpu] = pac = malloc(sizeof(struct powerpc_cpu), M_PMC,
M_WAITOK|M_ZERO);
@@ -638,7 +638,7 @@ mpc7xxx_allocate_pmc(int cpu, int ri, struct pmc *pm,
pm->pm_md.pm_powerpc.pm_powerpc_evsel = config;
- PMCDBG(MDP,ALL,2,"powerpc-allocate ri=%d -> config=0x%x", ri, config);
+ PMCDBG2(MDP,ALL,2,"powerpc-allocate ri=%d -> config=0x%x", ri, config);
return 0;
}
@@ -671,7 +671,7 @@ mpc7xxx_intr(int cpu, struct trapframe *tf)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[powerpc,%d] out of range CPU %d", __LINE__, cpu));
- PMCDBG(MDP,INT,1, "cpu=%d tf=%p um=%d", cpu, (void *) tf,
+ PMCDBG3(MDP,INT,1, "cpu=%d tf=%p um=%d", cpu, (void *) tf,
TRAPF_USERMODE(tf));
retval = 0;
diff --git a/sys/dev/hwpmc/hwpmc_octeon.c b/sys/dev/hwpmc/hwpmc_octeon.c
index 824a7b0..b614573 100644
--- a/sys/dev/hwpmc/hwpmc_octeon.c
+++ b/sys/dev/hwpmc/hwpmc_octeon.c
@@ -189,7 +189,8 @@ mips_get_perfctl(int cpu, int ri, uint32_t event, uint32_t caps)
if (caps & PMC_CAP_INTERRUPT)
control.s.ie = 1;
- PMCDBG(MDP,ALL,2,"mips-allocate ri=%d -> config=0x%x", ri, control.u32);
+ PMCDBG2(MDP,ALL,2,"mips-allocate ri=%d -> config=0x%x", ri,
+ control.u32);
return (control.u32);
}
diff --git a/sys/dev/hwpmc/hwpmc_piv.c b/sys/dev/hwpmc/hwpmc_piv.c
index ff47cb8..872ad89 100644
--- a/sys/dev/hwpmc/hwpmc_piv.c
+++ b/sys/dev/hwpmc/hwpmc_piv.c
@@ -563,7 +563,7 @@ p4_pcpu_init(struct pmc_mdep *md, int cpu)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[p4,%d] insane cpu number %d", __LINE__, cpu));
- PMCDBG(MDP,INI,0, "p4-init cpu=%d is-primary=%d", cpu,
+ PMCDBG2(MDP,INI,0, "p4-init cpu=%d is-primary=%d", cpu,
pmc_cpu_is_primary(cpu) != 0);
first_ri = md->pmd_classdep[PMC_MDEP_CLASS_INDEX_P4].pcd_ri;
@@ -590,7 +590,7 @@ p4_pcpu_init(struct pmc_mdep *md, int cpu)
KASSERT(plc != pc, ("[p4,%d] per-cpu config error", __LINE__));
- PMCDBG(MDP,INI,1, "p4-init cpu=%d phycpu=%d pc=%p", cpu,
+ PMCDBG3(MDP,INI,1, "p4-init cpu=%d phycpu=%d pc=%p", cpu,
phycpu, pc);
KASSERT(pc, ("[p4,%d] Null Per-Cpu state cpu=%d phycpu=%d",
__LINE__, cpu, phycpu));
@@ -642,7 +642,7 @@ p4_pcpu_fini(struct pmc_mdep *md, int cpu)
struct p4_cpu *p4c;
struct pmc_cpu *pc;
- PMCDBG(MDP,INI,0, "p4-cleanup cpu=%d", cpu);
+ PMCDBG1(MDP,INI,0, "p4-cleanup cpu=%d", cpu);
pc = pmc_pcpu[cpu];
first_ri = md->pmd_classdep[PMC_MDEP_CLASS_INDEX_P4].pcd_ri;
@@ -702,7 +702,7 @@ p4_read_pmc(int cpu, int ri, pmc_value_t *v)
mode = PMC_TO_MODE(pm);
- PMCDBG(MDP,REA,1, "p4-read cpu=%d ri=%d mode=%d", cpu, ri, mode);
+ PMCDBG3(MDP,REA,1, "p4-read cpu=%d ri=%d mode=%d", cpu, ri, mode);
KASSERT(pd->pm_descr.pd_class == PMC_CLASS_P4,
("[p4,%d] unknown PMC class %d", __LINE__, pd->pm_descr.pd_class));
@@ -723,7 +723,7 @@ p4_read_pmc(int cpu, int ri, pmc_value_t *v)
else
*v = tmp;
- PMCDBG(MDP,REA,2, "p4-read -> %jx", *v);
+ PMCDBG1(MDP,REA,2, "p4-read -> %jx", *v);
return (0);
}
@@ -757,7 +757,7 @@ p4_write_pmc(int cpu, int ri, pmc_value_t v)
mode = PMC_TO_MODE(pm);
- PMCDBG(MDP,WRI,1, "p4-write cpu=%d ri=%d mode=%d v=%jx", cpu, ri,
+ PMCDBG4(MDP,WRI,1, "p4-write cpu=%d ri=%d mode=%d v=%jx", cpu, ri,
mode, v);
/*
@@ -800,7 +800,7 @@ p4_config_pmc(int cpu, int ri, struct pmc *pm)
KASSERT(ri >= 0 && ri < P4_NPMCS,
("[p4,%d] illegal row-index %d", __LINE__, ri));
- PMCDBG(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
+ PMCDBG3(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
pc = p4_pcpu[P4_TO_HTT_PRIMARY(cpu)];
phw = &pc->pc_p4pmcs[ri];
@@ -930,7 +930,7 @@ p4_allocate_pmc(int cpu, int ri, struct pmc *pm,
pd = &p4_pmcdesc[ri];
- PMCDBG(MDP,ALL,1, "p4-allocate ri=%d class=%d pmccaps=0x%x "
+ PMCDBG4(MDP,ALL,1, "p4-allocate ri=%d class=%d pmccaps=0x%x "
"reqcaps=0x%x", ri, pd->pm_descr.pd_class, pd->pm_descr.pd_caps,
pm->pm_caps);
@@ -965,7 +965,7 @@ p4_allocate_pmc(int cpu, int ri, struct pmc *pm,
if ((pevent = p4_find_event(pm->pm_event)) == NULL)
return (ESRCH);
- PMCDBG(MDP,ALL,2, "pevent={ev=%d,escrsel=0x%x,cccrsel=0x%x,isti=%d}",
+ PMCDBG4(MDP,ALL,2, "pevent={ev=%d,escrsel=0x%x,cccrsel=0x%x,isti=%d}",
pevent->pm_event, pevent->pm_escr_eventselect,
pevent->pm_cccr_select, pevent->pm_is_ti_event);
@@ -1105,7 +1105,7 @@ p4_allocate_pmc(int cpu, int ri, struct pmc *pm,
pm->pm_md.pm_p4.pm_p4_cccrvalue = cccrvalue;
pm->pm_md.pm_p4.pm_p4_escrvalue = escrvalue;
- PMCDBG(MDP,ALL,2, "p4-allocate cccrsel=0x%x cccrval=0x%x "
+ PMCDBG5(MDP,ALL,2, "p4-allocate cccrsel=0x%x cccrval=0x%x "
"escr=%d escrmsr=0x%x escrval=0x%x", pevent->pm_cccr_select,
cccrvalue, escr, pm->pm_md.pm_p4.pm_p4_escrmsr, escrvalue);
@@ -1127,7 +1127,7 @@ p4_release_pmc(int cpu, int ri, struct pmc *pm)
escr = pm->pm_md.pm_p4.pm_p4_escr;
- PMCDBG(MDP,REL,1, "p4-release cpu=%d ri=%d escr=%d", cpu, ri, escr);
+ PMCDBG3(MDP,REL,1, "p4-release cpu=%d ri=%d escr=%d", cpu, ri, escr);
if (PMC_IS_SYSTEM_MODE(PMC_TO_MODE(pm))) {
pc = p4_pcpu[P4_TO_HTT_PRIMARY(cpu)];
@@ -1171,7 +1171,7 @@ p4_start_pmc(int cpu, int ri)
KASSERT(pm != NULL,
("[p4,%d] starting cpu%d,pmc%d with null pmc", __LINE__, cpu, ri));
- PMCDBG(MDP,STA,1, "p4-start cpu=%d ri=%d", cpu, ri);
+ PMCDBG2(MDP,STA,1, "p4-start cpu=%d ri=%d", cpu, ri);
KASSERT(pd->pm_descr.pd_class == PMC_CLASS_P4,
("[p4,%d] wrong PMC class %d", __LINE__,
@@ -1283,9 +1283,10 @@ p4_start_pmc(int cpu, int ri)
mtx_unlock_spin(&pc->pc_mtx);
- PMCDBG(MDP,STA,2,"p4-start cpu=%d rc=%d ri=%d escr=%d "
- "escrmsr=0x%x escrvalue=0x%x cccr_config=0x%x v=%jx", cpu, rc,
- ri, pm->pm_md.pm_p4.pm_p4_escr, escrmsr, escrvalue,
+ PMCDBG6(MDP,STA,2,"p4-start cpu=%d rc=%d ri=%d escr=%d "
+ "escrmsr=0x%x escrvalue=0x%x", cpu, rc,
+ ri, pm->pm_md.pm_p4.pm_p4_escr, escrmsr, escrvalue);
+ PMCDBG2(MDP,STA,2,"cccr_config=0x%x v=%jx",
cccrvalue, P4_PCPU_HW_VALUE(pc,ri,cpu));
return (0);
@@ -1317,7 +1318,7 @@ p4_stop_pmc(int cpu, int ri)
KASSERT(pm != NULL,
("[p4,%d] null pmc for cpu%d, ri%d", __LINE__, cpu, ri));
- PMCDBG(MDP,STO,1, "p4-stop cpu=%d ri=%d", cpu, ri);
+ PMCDBG2(MDP,STO,1, "p4-stop cpu=%d ri=%d", cpu, ri);
if (PMC_IS_SYSTEM_MODE(PMC_TO_MODE(pm))) {
wrmsr(pd->pm_cccr_msr,
@@ -1385,9 +1386,9 @@ p4_stop_pmc(int cpu, int ri)
mtx_unlock_spin(&pc->pc_mtx);
- PMCDBG(MDP,STO,2, "p4-stop cpu=%d rc=%d ri=%d escrmsr=0x%x "
- "escrval=0x%x cccrval=0x%x v=%jx", cpu, rc, ri, escrmsr,
- escrvalue, cccrvalue, tmp);
+ PMCDBG5(MDP,STO,2, "p4-stop cpu=%d rc=%d ri=%d escrmsr=0x%x "
+ "escrval=0x%x", cpu, rc, ri, escrmsr, escrvalue);
+ PMCDBG2(MDP,STO,2, "cccrval=0x%x v=%jx", cccrvalue, tmp);
if (tmp < P4_PCPU_HW_VALUE(pc,ri,cpu)) /* 40 bit counter overflow */
tmp += (P4_PERFCTR_MASK + 1) - P4_PCPU_HW_VALUE(pc,ri,cpu);
@@ -1422,7 +1423,7 @@ p4_intr(int cpu, struct trapframe *tf)
struct pmc *pm;
pmc_value_t v;
- PMCDBG(MDP,INT, 1, "cpu=%d tf=0x%p um=%d", cpu, (void *) tf,
+ PMCDBG3(MDP,INT, 1, "cpu=%d tf=0x%p um=%d", cpu, (void *) tf,
TRAPF_USERMODE(tf));
pc = p4_pcpu[P4_TO_HTT_PRIMARY(cpu)];
@@ -1492,7 +1493,7 @@ p4_intr(int cpu, struct trapframe *tf)
v = rdmsr(P4_PERFCTR_MSR_FIRST + ri);
- PMCDBG(MDP,INT, 2, "ri=%d v=%jx", ri, v);
+ PMCDBG2(MDP,INT, 2, "ri=%d v=%jx", ri, v);
/* Stop the counter, and reset the overflow bit */
cccrval &= ~(P4_CCCR_OVF | P4_CCCR_ENABLE);
@@ -1568,7 +1569,7 @@ p4_describe(int cpu, int ri, struct pmc_info *pi,
KASSERT(ri >= 0 && ri < P4_NPMCS,
("[p4,%d] row-index %d out of range", __LINE__, ri));
- PMCDBG(MDP,OPS,1,"p4-describe cpu=%d ri=%d", cpu, ri);
+ PMCDBG2(MDP,OPS,1,"p4-describe cpu=%d ri=%d", cpu, ri);
if (P4_CPU_IS_HTT_SECONDARY(cpu))
return (EINVAL);
@@ -1604,7 +1605,7 @@ p4_get_msr(int ri, uint32_t *msr)
*msr = p4_pmcdesc[ri].pm_pmc_msr - P4_PERFCTR_MSR_FIRST;
- PMCDBG(MDP,OPS, 1, "ri=%d getmsr=0x%x", ri, *msr);
+ PMCDBG2(MDP,OPS, 1, "ri=%d getmsr=0x%x", ri, *msr);
return 0;
}
@@ -1620,7 +1621,7 @@ pmc_p4_initialize(struct pmc_mdep *md, int ncpus)
KASSERT(cpu_vendor_id == CPU_VENDOR_INTEL,
("[p4,%d] Initializing non-intel processor", __LINE__));
- PMCDBG(MDP,INI,1, "%s", "p4-initialize");
+ PMCDBG0(MDP,INI,1, "p4-initialize");
/* Allocate space for pointers to per-cpu descriptors. */
p4_pcpu = malloc(sizeof(*p4_pcpu) * ncpus, M_PMC, M_ZERO | M_WAITOK);
diff --git a/sys/dev/hwpmc/hwpmc_ppc970.c b/sys/dev/hwpmc/hwpmc_ppc970.c
index f477be3..1a263f3 100644
--- a/sys/dev/hwpmc/hwpmc_ppc970.c
+++ b/sys/dev/hwpmc/hwpmc_ppc970.c
@@ -342,7 +342,7 @@ ppc970_config_pmc(int cpu, int ri, struct pmc *pm)
{
struct pmc_hw *phw;
- PMCDBG(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
+ PMCDBG3(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[powerpc,%d] illegal CPU value %d", __LINE__, cpu));
@@ -445,7 +445,7 @@ ppc970_read_pmc(int cpu, int ri, pmc_value_t *v)
ri));
tmp = ppc970_pmcn_read(ri);
- PMCDBG(MDP,REA,2,"ppc-read id=%d -> %jd", ri, tmp);
+ PMCDBG2(MDP,REA,2,"ppc-read id=%d -> %jd", ri, tmp);
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
*v = POWERPC_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp);
else
@@ -469,7 +469,7 @@ ppc970_write_pmc(int cpu, int ri, pmc_value_t v)
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
v = POWERPC_RELOAD_COUNT_TO_PERFCTR_VALUE(v);
- PMCDBG(MDP,WRI,1,"powerpc-write cpu=%d ri=%d v=%jx", cpu, ri, v);
+ PMCDBG3(MDP,WRI,1,"powerpc-write cpu=%d ri=%d v=%jx", cpu, ri, v);
ppc970_pmcn_write(ri, v);
@@ -487,7 +487,7 @@ ppc970_intr(int cpu, struct trapframe *tf)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[powerpc,%d] out of range CPU %d", __LINE__, cpu));
- PMCDBG(MDP,INT,1, "cpu=%d tf=%p um=%d", cpu, (void *) tf,
+ PMCDBG3(MDP,INT,1, "cpu=%d tf=%p um=%d", cpu, (void *) tf,
TRAPF_USERMODE(tf));
retval = 0;
@@ -546,7 +546,7 @@ ppc970_pcpu_init(struct pmc_mdep *md, int cpu)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[powerpc,%d] wrong cpu number %d", __LINE__, cpu));
- PMCDBG(MDP,INI,1,"powerpc-init cpu=%d", cpu);
+ PMCDBG1(MDP,INI,1,"powerpc-init cpu=%d", cpu);
powerpc_pcpu[cpu] = pac = malloc(sizeof(struct powerpc_cpu), M_PMC,
M_WAITOK|M_ZERO);
@@ -632,7 +632,7 @@ ppc970_allocate_pmc(int cpu, int ri, struct pmc *pm,
pm->pm_md.pm_powerpc.pm_powerpc_evsel = config;
- PMCDBG(MDP,ALL,2,"powerpc-allocate ri=%d -> config=0x%x", ri, config);
+ PMCDBG2(MDP,ALL,2,"powerpc-allocate ri=%d -> config=0x%x", ri, config);
return 0;
}
diff --git a/sys/dev/hwpmc/hwpmc_ppro.c b/sys/dev/hwpmc/hwpmc_ppro.c
index e99bb30..9d983fa 100644
--- a/sys/dev/hwpmc/hwpmc_ppro.c
+++ b/sys/dev/hwpmc/hwpmc_ppro.c
@@ -339,7 +339,7 @@ p6_pcpu_init(struct pmc_mdep *md, int cpu)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[p6,%d] bad cpu %d", __LINE__, cpu));
- PMCDBG(MDP,INI,0,"p6-init cpu=%d", cpu);
+ PMCDBG1(MDP,INI,0,"p6-init cpu=%d", cpu);
p6c = malloc(sizeof (struct p6_cpu), M_PMC, M_WAITOK|M_ZERO);
pc = pmc_pcpu[cpu];
@@ -371,7 +371,7 @@ p6_pcpu_fini(struct pmc_mdep *md, int cpu)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[p6,%d] bad cpu %d", __LINE__, cpu));
- PMCDBG(MDP,INI,0,"p6-cleanup cpu=%d", cpu);
+ PMCDBG1(MDP,INI,0,"p6-cleanup cpu=%d", cpu);
p6c = p6_pcpu[cpu];
p6_pcpu[cpu] = NULL;
@@ -412,7 +412,7 @@ p6_read_pmc(int cpu, int ri, pmc_value_t *v)
else
*v = tmp;
- PMCDBG(MDP,REA,1, "p6-read cpu=%d ri=%d msr=0x%x -> v=%jx", cpu, ri,
+ PMCDBG4(MDP,REA,1, "p6-read cpu=%d ri=%d msr=0x%x -> v=%jx", cpu, ri,
pd->pm_pmc_msr, *v);
return (0);
@@ -435,7 +435,7 @@ p6_write_pmc(int cpu, int ri, pmc_value_t v)
KASSERT(pm,
("[p6,%d] cpu %d ri %d pmc not configured", __LINE__, cpu, ri));
- PMCDBG(MDP,WRI,1, "p6-write cpu=%d ri=%d msr=0x%x v=%jx", cpu, ri,
+ PMCDBG4(MDP,WRI,1, "p6-write cpu=%d ri=%d msr=0x%x v=%jx", cpu, ri,
pd->pm_pmc_msr, v);
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
@@ -455,7 +455,7 @@ p6_config_pmc(int cpu, int ri, struct pmc *pm)
KASSERT(ri >= 0 && ri < P6_NPMCS,
("[p6,%d] illegal row-index %d", __LINE__, ri));
- PMCDBG(MDP,CFG,1, "p6-config cpu=%d ri=%d pm=%p", cpu, ri, pm);
+ PMCDBG3(MDP,CFG,1, "p6-config cpu=%d ri=%d pm=%p", cpu, ri, pm);
KASSERT(p6_pcpu[cpu] != NULL, ("[p6,%d] null per-cpu %d", __LINE__,
cpu));
@@ -508,7 +508,7 @@ p6_allocate_pmc(int cpu, int ri, struct pmc *pm,
pd = &p6_pmcdesc[ri];
- PMCDBG(MDP,ALL,1, "p6-allocate ri=%d class=%d pmccaps=0x%x "
+ PMCDBG4(MDP,ALL,1, "p6-allocate ri=%d class=%d pmccaps=0x%x "
"reqcaps=0x%x", ri, pd->pm_descr.pd_class, pd->pm_descr.pd_caps,
pm->pm_caps);
@@ -579,7 +579,7 @@ p6_allocate_pmc(int cpu, int ri, struct pmc *pm,
pm->pm_md.pm_ppro.pm_ppro_evsel = config;
- PMCDBG(MDP,ALL,2, "p6-allocate config=0x%x", config);
+ PMCDBG1(MDP,ALL,2, "p6-allocate config=0x%x", config);
return (0);
}
@@ -589,7 +589,7 @@ p6_release_pmc(int cpu, int ri, struct pmc *pm)
{
(void) pm;
- PMCDBG(MDP,REL,1, "p6-release cpu=%d ri=%d pm=%p", cpu, ri, pm);
+ PMCDBG3(MDP,REL,1, "p6-release cpu=%d ri=%d pm=%p", cpu, ri, pm);
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[p6,%d] illegal CPU value %d", __LINE__, cpu));
@@ -623,11 +623,11 @@ p6_start_pmc(int cpu, int ri)
("[p6,%d] starting cpu%d,ri%d with no pmc configured",
__LINE__, cpu, ri));
- PMCDBG(MDP,STA,1, "p6-start cpu=%d ri=%d", cpu, ri);
+ PMCDBG2(MDP,STA,1, "p6-start cpu=%d ri=%d", cpu, ri);
config = pm->pm_md.pm_ppro.pm_ppro_evsel;
- PMCDBG(MDP,STA,2, "p6-start/2 cpu=%d ri=%d evselmsr=0x%x config=0x%x",
+ PMCDBG4(MDP,STA,2, "p6-start/2 cpu=%d ri=%d evselmsr=0x%x config=0x%x",
cpu, ri, pd->pm_evsel_msr, config);
P6_MARK_STARTED(pc, ri);
@@ -658,14 +658,14 @@ p6_stop_pmc(int cpu, int ri)
("[p6,%d] cpu%d ri%d no configured PMC to stop", __LINE__,
cpu, ri));
- PMCDBG(MDP,STO,1, "p6-stop cpu=%d ri=%d", cpu, ri);
+ PMCDBG2(MDP,STO,1, "p6-stop cpu=%d ri=%d", cpu, ri);
wrmsr(pd->pm_evsel_msr, 0); /* stop hw */
P6_MARK_STOPPED(pc, ri); /* update software state */
P6_SYNC_CTR_STATE(pc); /* restart CTR1 if need be */
- PMCDBG(MDP,STO,2, "p6-stop/2 cpu=%d ri=%d", cpu, ri);
+ PMCDBG2(MDP,STO,2, "p6-stop/2 cpu=%d ri=%d", cpu, ri);
return (0);
}
@@ -788,7 +788,7 @@ pmc_p6_initialize(struct pmc_mdep *md, int ncpus)
KASSERT(cpu_vendor_id == CPU_VENDOR_INTEL,
("[p6,%d] Initializing non-intel processor", __LINE__));
- PMCDBG(MDP,INI,1, "%s", "p6-initialize");
+ PMCDBG0(MDP,INI,1, "p6-initialize");
/* Allocate space for pointers to per-cpu descriptors. */
p6_pcpu = malloc(sizeof(struct p6_cpu **) * ncpus, M_PMC,
diff --git a/sys/dev/hwpmc/hwpmc_soft.c b/sys/dev/hwpmc/hwpmc_soft.c
index 7a585eb..fe143ad 100644
--- a/sys/dev/hwpmc/hwpmc_soft.c
+++ b/sys/dev/hwpmc/hwpmc_soft.c
@@ -136,7 +136,7 @@ soft_config_pmc(int cpu, int ri, struct pmc *pm)
{
struct pmc_hw *phw;
- PMCDBG(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
+ PMCDBG3(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[soft,%d] illegal CPU value %d", __LINE__, cpu));
@@ -276,7 +276,7 @@ soft_read_pmc(int cpu, int ri, pmc_value_t *v)
KASSERT(pm != NULL,
("[soft,%d] no owner for PHW [cpu%d,pmc%d]", __LINE__, cpu, ri));
- PMCDBG(MDP,REA,1,"soft-read id=%d", ri);
+ PMCDBG1(MDP,REA,1,"soft-read id=%d", ri);
*v = soft_pcpu[cpu]->soft_values[ri];
@@ -300,7 +300,7 @@ soft_write_pmc(int cpu, int ri, pmc_value_t v)
KASSERT(pm,
("[soft,%d] cpu %d ri %d pmc not configured", __LINE__, cpu, ri));
- PMCDBG(MDP,WRI,1, "soft-write cpu=%d ri=%d v=%jx", cpu, ri, v);
+ PMCDBG3(MDP,WRI,1, "soft-write cpu=%d ri=%d v=%jx", cpu, ri, v);
soft_pcpu[cpu]->soft_values[ri] = v;
diff --git a/sys/dev/hwpmc/hwpmc_tsc.c b/sys/dev/hwpmc/hwpmc_tsc.c
index 237b7a1..5eb6907 100644
--- a/sys/dev/hwpmc/hwpmc_tsc.c
+++ b/sys/dev/hwpmc/hwpmc_tsc.c
@@ -99,7 +99,7 @@ tsc_config_pmc(int cpu, int ri, struct pmc *pm)
{
struct pmc_hw *phw;
- PMCDBG(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
+ PMCDBG3(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[tsc,%d] illegal CPU value %d", __LINE__, cpu));
@@ -253,7 +253,7 @@ tsc_read_pmc(int cpu, int ri, pmc_value_t *v)
KASSERT(mode == PMC_MODE_SC,
("[tsc,%d] illegal pmc mode %d", __LINE__, mode));
- PMCDBG(MDP,REA,1,"tsc-read id=%d", ri);
+ PMCDBG1(MDP,REA,1,"tsc-read id=%d", ri);
*v = rdtsc();
diff --git a/sys/dev/hwpmc/hwpmc_uncore.c b/sys/dev/hwpmc/hwpmc_uncore.c
index 6a30eb0..2b24b33e 100644
--- a/sys/dev/hwpmc/hwpmc_uncore.c
+++ b/sys/dev/hwpmc/hwpmc_uncore.c
@@ -101,7 +101,7 @@ uncore_pcpu_init(struct pmc_mdep *md, int cpu)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[ucf,%d] insane cpu number %d", __LINE__, cpu));
- PMCDBG(MDP,INI,1,"uncore-init cpu=%d", cpu);
+ PMCDBG1(MDP,INI,1,"uncore-init cpu=%d", cpu);
uncore_ri = md->pmd_classdep[PMC_MDEP_CLASS_INDEX_UCP].pcd_ri;
npmc = md->pmd_classdep[PMC_MDEP_CLASS_INDEX_UCP].pcd_num;
@@ -137,7 +137,7 @@ uncore_pcpu_fini(struct pmc_mdep *md, int cpu)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[uncore,%d] insane cpu number (%d)", __LINE__, cpu));
- PMCDBG(MDP,INI,1,"uncore-pcpu-fini cpu=%d", cpu);
+ PMCDBG1(MDP,INI,1,"uncore-pcpu-fini cpu=%d", cpu);
if ((cc = uncore_pcpu[cpu]) == NULL)
return (0);
@@ -193,7 +193,7 @@ ucf_allocate_pmc(int cpu, int ri, struct pmc *pm,
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[uncore,%d] illegal CPU %d", __LINE__, cpu));
- PMCDBG(MDP,ALL,1, "ucf-allocate ri=%d reqcaps=0x%x", ri, pm->pm_caps);
+ PMCDBG2(MDP,ALL,1, "ucf-allocate ri=%d reqcaps=0x%x", ri, pm->pm_caps);
if (ri < 0 || ri > uncore_ucf_npmc)
return (EINVAL);
@@ -212,7 +212,7 @@ ucf_allocate_pmc(int cpu, int ri, struct pmc *pm,
pm->pm_md.pm_ucf.pm_ucf_ctrl = (flags << (ri * 4));
- PMCDBG(MDP,ALL,2, "ucf-allocate config=0x%jx",
+ PMCDBG1(MDP,ALL,2, "ucf-allocate config=0x%jx",
(uintmax_t) pm->pm_md.pm_ucf.pm_ucf_ctrl);
return (0);
@@ -227,7 +227,7 @@ ucf_config_pmc(int cpu, int ri, struct pmc *pm)
KASSERT(ri >= 0 && ri < uncore_ucf_npmc,
("[uncore,%d] illegal row-index %d", __LINE__, ri));
- PMCDBG(MDP,CFG,1, "ucf-config cpu=%d ri=%d pm=%p", cpu, ri, pm);
+ PMCDBG3(MDP,CFG,1, "ucf-config cpu=%d ri=%d pm=%p", cpu, ri, pm);
KASSERT(uncore_pcpu[cpu] != NULL, ("[uncore,%d] null per-cpu %d", __LINE__,
cpu));
@@ -296,7 +296,7 @@ ucf_read_pmc(int cpu, int ri, pmc_value_t *v)
else
*v = tmp;
- PMCDBG(MDP,REA,1, "ucf-read cpu=%d ri=%d -> v=%jx", cpu, ri, *v);
+ PMCDBG3(MDP,REA,1, "ucf-read cpu=%d ri=%d -> v=%jx", cpu, ri, *v);
return (0);
}
@@ -304,7 +304,7 @@ ucf_read_pmc(int cpu, int ri, pmc_value_t *v)
static int
ucf_release_pmc(int cpu, int ri, struct pmc *pmc)
{
- PMCDBG(MDP,REL,1, "ucf-release cpu=%d ri=%d pm=%p", cpu, ri, pmc);
+ PMCDBG3(MDP,REL,1, "ucf-release cpu=%d ri=%d pm=%p", cpu, ri, pmc);
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[uncore,%d] illegal CPU value %d", __LINE__, cpu));
@@ -328,7 +328,7 @@ ucf_start_pmc(int cpu, int ri)
KASSERT(ri >= 0 && ri < uncore_ucf_npmc,
("[uncore,%d] illegal row-index %d", __LINE__, ri));
- PMCDBG(MDP,STA,1,"ucf-start cpu=%d ri=%d", cpu, ri);
+ PMCDBG2(MDP,STA,1,"ucf-start cpu=%d ri=%d", cpu, ri);
ucfc = uncore_pcpu[cpu];
pm = ucfc->pc_uncorepmcs[ri + uncore_ucf_ri].phw_pmc;
@@ -343,7 +343,7 @@ ucf_start_pmc(int cpu, int ri)
wrmsr(UC_GLOBAL_CTRL, ucfc->pc_globalctrl);
} while (ucfc->pc_resync != 0);
- PMCDBG(MDP,STA,1,"ucfctrl=%x(%x) globalctrl=%jx(%jx)",
+ PMCDBG4(MDP,STA,1,"ucfctrl=%x(%x) globalctrl=%jx(%jx)",
ucfc->pc_ucfctrl, (uint32_t) rdmsr(UCF_CTRL),
ucfc->pc_globalctrl, rdmsr(UC_GLOBAL_CTRL));
@@ -356,7 +356,7 @@ ucf_stop_pmc(int cpu, int ri)
uint32_t fc;
struct uncore_cpu *ucfc;
- PMCDBG(MDP,STO,1,"ucf-stop cpu=%d ri=%d", cpu, ri);
+ PMCDBG2(MDP,STO,1,"ucf-stop cpu=%d ri=%d", cpu, ri);
ucfc = uncore_pcpu[cpu];
@@ -369,7 +369,7 @@ ucf_stop_pmc(int cpu, int ri)
ucfc->pc_ucfctrl &= ~fc;
- PMCDBG(MDP,STO,1,"ucf-stop ucfctrl=%x", ucfc->pc_ucfctrl);
+ PMCDBG1(MDP,STO,1,"ucf-stop ucfctrl=%x", ucfc->pc_ucfctrl);
wrmsr(UCF_CTRL, ucfc->pc_ucfctrl);
do {
@@ -378,7 +378,7 @@ ucf_stop_pmc(int cpu, int ri)
wrmsr(UC_GLOBAL_CTRL, ucfc->pc_globalctrl);
} while (ucfc->pc_resync != 0);
- PMCDBG(MDP,STO,1,"ucfctrl=%x(%x) globalctrl=%jx(%jx)",
+ PMCDBG4(MDP,STO,1,"ucfctrl=%x(%x) globalctrl=%jx(%jx)",
ucfc->pc_ucfctrl, (uint32_t) rdmsr(UCF_CTRL),
ucfc->pc_globalctrl, rdmsr(UC_GLOBAL_CTRL));
@@ -409,7 +409,7 @@ ucf_write_pmc(int cpu, int ri, pmc_value_t v)
wrmsr(UCF_CTR0 + ri, v);
wrmsr(UCF_CTRL, cc->pc_ucfctrl);
- PMCDBG(MDP,WRI,1, "ucf-write cpu=%d ri=%d v=%jx ucfctrl=%jx ",
+ PMCDBG4(MDP,WRI,1, "ucf-write cpu=%d ri=%d v=%jx ucfctrl=%jx ",
cpu, ri, v, (uintmax_t) rdmsr(UCF_CTRL));
return (0);
@@ -423,7 +423,7 @@ ucf_initialize(struct pmc_mdep *md, int maxcpu, int npmc, int pmcwidth)
KASSERT(md != NULL, ("[ucf,%d] md is NULL", __LINE__));
- PMCDBG(MDP,INI,1, "%s", "ucf-initialize");
+ PMCDBG0(MDP,INI,1, "ucf-initialize");
pcd = &md->pmd_classdep[PMC_MDEP_CLASS_INDEX_UCF];
@@ -933,7 +933,7 @@ ucp_config_pmc(int cpu, int ri, struct pmc *pm)
KASSERT(ri >= 0 && ri < uncore_ucp_npmc,
("[uncore,%d] illegal row-index %d", __LINE__, ri));
- PMCDBG(MDP,CFG,1, "ucp-config cpu=%d ri=%d pm=%p", cpu, ri, pm);
+ PMCDBG3(MDP,CFG,1, "ucp-config cpu=%d ri=%d pm=%p", cpu, ri, pm);
KASSERT(uncore_pcpu[cpu] != NULL, ("[uncore,%d] null per-cpu %d", __LINE__,
cpu));
@@ -1001,7 +1001,7 @@ ucp_read_pmc(int cpu, int ri, pmc_value_t *v)
else
*v = tmp;
- PMCDBG(MDP,REA,1, "ucp-read cpu=%d ri=%d msr=0x%x -> v=%jx", cpu, ri,
+ PMCDBG4(MDP,REA,1, "ucp-read cpu=%d ri=%d msr=0x%x -> v=%jx", cpu, ri,
ri, *v);
return (0);
@@ -1012,7 +1012,7 @@ ucp_release_pmc(int cpu, int ri, struct pmc *pm)
{
(void) pm;
- PMCDBG(MDP,REL,1, "ucp-release cpu=%d ri=%d pm=%p", cpu, ri,
+ PMCDBG3(MDP,REL,1, "ucp-release cpu=%d ri=%d pm=%p", cpu, ri,
pm);
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
@@ -1045,11 +1045,11 @@ ucp_start_pmc(int cpu, int ri)
("[uncore,%d] starting cpu%d,ri%d with no pmc configured",
__LINE__, cpu, ri));
- PMCDBG(MDP,STA,1, "ucp-start cpu=%d ri=%d", cpu, ri);
+ PMCDBG2(MDP,STA,1, "ucp-start cpu=%d ri=%d", cpu, ri);
evsel = pm->pm_md.pm_ucp.pm_ucp_evsel;
- PMCDBG(MDP,STA,2,
+ PMCDBG4(MDP,STA,2,
"ucp-start/2 cpu=%d ri=%d evselmsr=0x%x evsel=0x%x",
cpu, ri, SELECTSEL(uncore_cputype) + ri, evsel);
@@ -1104,7 +1104,7 @@ ucp_stop_pmc(int cpu, int ri)
("[uncore,%d] cpu%d ri%d no configured PMC to stop", __LINE__,
cpu, ri));
- PMCDBG(MDP,STO,1, "ucp-stop cpu=%d ri=%d", cpu, ri);
+ PMCDBG2(MDP,STO,1, "ucp-stop cpu=%d ri=%d", cpu, ri);
/* stop hw. */
wrmsr(SELECTSEL(uncore_cputype) + ri, 0);
@@ -1136,7 +1136,7 @@ ucp_write_pmc(int cpu, int ri, pmc_value_t v)
("[uncore,%d] cpu%d ri%d no configured PMC to stop", __LINE__,
cpu, ri));
- PMCDBG(MDP,WRI,1, "ucp-write cpu=%d ri=%d msr=0x%x v=%jx", cpu, ri,
+ PMCDBG4(MDP,WRI,1, "ucp-write cpu=%d ri=%d msr=0x%x v=%jx", cpu, ri,
UCP_PMC0 + ri, v);
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
@@ -1160,7 +1160,7 @@ ucp_initialize(struct pmc_mdep *md, int maxcpu, int npmc, int pmcwidth)
KASSERT(md != NULL, ("[ucp,%d] md is NULL", __LINE__));
- PMCDBG(MDP,INI,1, "%s", "ucp-initialize");
+ PMCDBG0(MDP,INI,1, "ucp-initialize");
pcd = &md->pmd_classdep[PMC_MDEP_CLASS_INDEX_UCP];
@@ -1213,7 +1213,7 @@ pmc_uncore_initialize(struct pmc_mdep *md, int maxcpu)
ucf_initialize(md, maxcpu, uncore_ucf_npmc, uncore_ucf_width);
uncore_pmcmask |= ((1ULL << uncore_ucf_npmc) - 1) << SELECTOFF(uncore_cputype);
- PMCDBG(MDP,INI,1,"uncore-init pmcmask=0x%jx ucfri=%d", uncore_pmcmask,
+ PMCDBG2(MDP,INI,1,"uncore-init pmcmask=0x%jx ucfri=%d", uncore_pmcmask,
uncore_ucf_ri);
uncore_pcpu = malloc(sizeof(*uncore_pcpu) * maxcpu, M_PMC,
@@ -1225,7 +1225,7 @@ pmc_uncore_initialize(struct pmc_mdep *md, int maxcpu)
void
pmc_uncore_finalize(struct pmc_mdep *md)
{
- PMCDBG(MDP,INI,1, "%s", "uncore-finalize");
+ PMCDBG0(MDP,INI,1, "uncore-finalize");
free(uncore_pcpu, M_PMC);
uncore_pcpu = NULL;
diff --git a/sys/dev/hwpmc/hwpmc_xscale.c b/sys/dev/hwpmc/hwpmc_xscale.c
index 9b73337..e5df8d0 100644
--- a/sys/dev/hwpmc/hwpmc_xscale.c
+++ b/sys/dev/hwpmc/hwpmc_xscale.c
@@ -277,7 +277,7 @@ xscale_allocate_pmc(int cpu, int ri, struct pmc *pm,
return EINVAL;
pm->pm_md.pm_xscale.pm_xscale_evsel = config;
- PMCDBG(MDP,ALL,2,"xscale-allocate ri=%d -> config=0x%x", ri, config);
+ PMCDBG2(MDP,ALL,2,"xscale-allocate ri=%d -> config=0x%x", ri, config);
return 0;
}
@@ -296,7 +296,7 @@ xscale_read_pmc(int cpu, int ri, pmc_value_t *v)
pm = xscale_pcpu[cpu]->pc_xscalepmcs[ri].phw_pmc;
tmp = xscale_pmcn_read(ri);
- PMCDBG(MDP,REA,2,"xscale-read id=%d -> %jd", ri, tmp);
+ PMCDBG2(MDP,REA,2,"xscale-read id=%d -> %jd", ri, tmp);
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
*v = XSCALE_PERFCTR_VALUE_TO_RELOAD_COUNT(tmp);
else
@@ -320,7 +320,7 @@ xscale_write_pmc(int cpu, int ri, pmc_value_t v)
if (PMC_IS_SAMPLING_MODE(PMC_TO_MODE(pm)))
v = XSCALE_RELOAD_COUNT_TO_PERFCTR_VALUE(v);
- PMCDBG(MDP,WRI,1,"xscale-write cpu=%d ri=%d v=%jx", cpu, ri, v);
+ PMCDBG3(MDP,WRI,1,"xscale-write cpu=%d ri=%d v=%jx", cpu, ri, v);
xscale_pmcn_write(ri, v);
@@ -332,7 +332,7 @@ xscale_config_pmc(int cpu, int ri, struct pmc *pm)
{
struct pmc_hw *phw;
- PMCDBG(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
+ PMCDBG3(MDP,CFG,1, "cpu=%d ri=%d pm=%p", cpu, ri, pm);
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[xscale,%d] illegal CPU value %d", __LINE__, cpu));
@@ -568,7 +568,7 @@ xscale_pcpu_init(struct pmc_mdep *md, int cpu)
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),
("[xscale,%d] wrong cpu number %d", __LINE__, cpu));
- PMCDBG(MDP,INI,1,"xscale-init cpu=%d", cpu);
+ PMCDBG1(MDP,INI,1,"xscale-init cpu=%d", cpu);
xscale_pcpu[cpu] = pac = malloc(sizeof(struct xscale_cpu), M_PMC,
M_WAITOK|M_ZERO);
@@ -628,7 +628,7 @@ pmc_xscale_initialize()
printf("%s: unknown XScale core generation\n", __func__);
return (NULL);
}
- PMCDBG(MDP,INI,1,"xscale-init npmcs=%d", xscale_npmcs);
+ PMCDBG1(MDP,INI,1,"xscale-init npmcs=%d", xscale_npmcs);
/*
* Allocate space for pointers to PMC HW descriptors and for
diff --git a/sys/dev/hwpmc/pmc_events.h b/sys/dev/hwpmc/pmc_events.h
index 7f878cb..467367f 100644
--- a/sys/dev/hwpmc/pmc_events.h
+++ b/sys/dev/hwpmc/pmc_events.h
@@ -4803,6 +4803,369 @@ __PMC_EV_ALIAS("IMPC_C0H_TRK_REQUEST.ALL", UCP_EVENT_84H_01H)
#define PMC_EV_ARMV7_LAST PMC_EV_ARMV7_CPU_CYCLES
/*
+ * ARMv8 Events
+ */
+
+#define __PMC_EV_ARMV8() \
+ __PMC_EV(ARMV8, EVENT_00H) \
+ __PMC_EV(ARMV8, EVENT_01H) \
+ __PMC_EV(ARMV8, EVENT_02H) \
+ __PMC_EV(ARMV8, EVENT_03H) \
+ __PMC_EV(ARMV8, EVENT_04H) \
+ __PMC_EV(ARMV8, EVENT_05H) \
+ __PMC_EV(ARMV8, EVENT_06H) \
+ __PMC_EV(ARMV8, EVENT_07H) \
+ __PMC_EV(ARMV8, EVENT_08H) \
+ __PMC_EV(ARMV8, EVENT_09H) \
+ __PMC_EV(ARMV8, EVENT_0AH) \
+ __PMC_EV(ARMV8, EVENT_0BH) \
+ __PMC_EV(ARMV8, EVENT_0CH) \
+ __PMC_EV(ARMV8, EVENT_0DH) \
+ __PMC_EV(ARMV8, EVENT_0EH) \
+ __PMC_EV(ARMV8, EVENT_0FH) \
+ __PMC_EV(ARMV8, EVENT_10H) \
+ __PMC_EV(ARMV8, EVENT_11H) \
+ __PMC_EV(ARMV8, EVENT_12H) \
+ __PMC_EV(ARMV8, EVENT_13H) \
+ __PMC_EV(ARMV8, EVENT_14H) \
+ __PMC_EV(ARMV8, EVENT_15H) \
+ __PMC_EV(ARMV8, EVENT_16H) \
+ __PMC_EV(ARMV8, EVENT_17H) \
+ __PMC_EV(ARMV8, EVENT_18H) \
+ __PMC_EV(ARMV8, EVENT_19H) \
+ __PMC_EV(ARMV8, EVENT_1AH) \
+ __PMC_EV(ARMV8, EVENT_1BH) \
+ __PMC_EV(ARMV8, EVENT_1CH) \
+ __PMC_EV(ARMV8, EVENT_1DH) \
+ __PMC_EV(ARMV8, EVENT_1EH) \
+ __PMC_EV(ARMV8, EVENT_1FH) \
+ __PMC_EV(ARMV8, EVENT_20H) \
+ __PMC_EV(ARMV8, EVENT_21H) \
+ __PMC_EV(ARMV8, EVENT_22H) \
+ __PMC_EV(ARMV8, EVENT_23H) \
+ __PMC_EV(ARMV8, EVENT_24H) \
+ __PMC_EV(ARMV8, EVENT_25H) \
+ __PMC_EV(ARMV8, EVENT_26H) \
+ __PMC_EV(ARMV8, EVENT_27H) \
+ __PMC_EV(ARMV8, EVENT_28H) \
+ __PMC_EV(ARMV8, EVENT_29H) \
+ __PMC_EV(ARMV8, EVENT_2AH) \
+ __PMC_EV(ARMV8, EVENT_2BH) \
+ __PMC_EV(ARMV8, EVENT_2CH) \
+ __PMC_EV(ARMV8, EVENT_2DH) \
+ __PMC_EV(ARMV8, EVENT_2EH) \
+ __PMC_EV(ARMV8, EVENT_2FH) \
+ __PMC_EV(ARMV8, EVENT_30H) \
+ __PMC_EV(ARMV8, EVENT_31H) \
+ __PMC_EV(ARMV8, EVENT_32H) \
+ __PMC_EV(ARMV8, EVENT_33H) \
+ __PMC_EV(ARMV8, EVENT_34H) \
+ __PMC_EV(ARMV8, EVENT_35H) \
+ __PMC_EV(ARMV8, EVENT_36H) \
+ __PMC_EV(ARMV8, EVENT_37H) \
+ __PMC_EV(ARMV8, EVENT_38H) \
+ __PMC_EV(ARMV8, EVENT_39H) \
+ __PMC_EV(ARMV8, EVENT_3AH) \
+ __PMC_EV(ARMV8, EVENT_3BH) \
+ __PMC_EV(ARMV8, EVENT_3CH) \
+ __PMC_EV(ARMV8, EVENT_3DH) \
+ __PMC_EV(ARMV8, EVENT_3EH) \
+ __PMC_EV(ARMV8, EVENT_3FH) \
+ __PMC_EV(ARMV8, EVENT_40H) \
+ __PMC_EV(ARMV8, EVENT_41H) \
+ __PMC_EV(ARMV8, EVENT_42H) \
+ __PMC_EV(ARMV8, EVENT_43H) \
+ __PMC_EV(ARMV8, EVENT_44H) \
+ __PMC_EV(ARMV8, EVENT_45H) \
+ __PMC_EV(ARMV8, EVENT_46H) \
+ __PMC_EV(ARMV8, EVENT_47H) \
+ __PMC_EV(ARMV8, EVENT_48H) \
+ __PMC_EV(ARMV8, EVENT_49H) \
+ __PMC_EV(ARMV8, EVENT_4AH) \
+ __PMC_EV(ARMV8, EVENT_4BH) \
+ __PMC_EV(ARMV8, EVENT_4CH) \
+ __PMC_EV(ARMV8, EVENT_4DH) \
+ __PMC_EV(ARMV8, EVENT_4EH) \
+ __PMC_EV(ARMV8, EVENT_4FH) \
+ __PMC_EV(ARMV8, EVENT_50H) \
+ __PMC_EV(ARMV8, EVENT_51H) \
+ __PMC_EV(ARMV8, EVENT_52H) \
+ __PMC_EV(ARMV8, EVENT_53H) \
+ __PMC_EV(ARMV8, EVENT_54H) \
+ __PMC_EV(ARMV8, EVENT_55H) \
+ __PMC_EV(ARMV8, EVENT_56H) \
+ __PMC_EV(ARMV8, EVENT_57H) \
+ __PMC_EV(ARMV8, EVENT_58H) \
+ __PMC_EV(ARMV8, EVENT_59H) \
+ __PMC_EV(ARMV8, EVENT_5AH) \
+ __PMC_EV(ARMV8, EVENT_5BH) \
+ __PMC_EV(ARMV8, EVENT_5CH) \
+ __PMC_EV(ARMV8, EVENT_5DH) \
+ __PMC_EV(ARMV8, EVENT_5EH) \
+ __PMC_EV(ARMV8, EVENT_5FH) \
+ __PMC_EV(ARMV8, EVENT_60H) \
+ __PMC_EV(ARMV8, EVENT_61H) \
+ __PMC_EV(ARMV8, EVENT_62H) \
+ __PMC_EV(ARMV8, EVENT_63H) \
+ __PMC_EV(ARMV8, EVENT_64H) \
+ __PMC_EV(ARMV8, EVENT_65H) \
+ __PMC_EV(ARMV8, EVENT_66H) \
+ __PMC_EV(ARMV8, EVENT_67H) \
+ __PMC_EV(ARMV8, EVENT_68H) \
+ __PMC_EV(ARMV8, EVENT_69H) \
+ __PMC_EV(ARMV8, EVENT_6AH) \
+ __PMC_EV(ARMV8, EVENT_6BH) \
+ __PMC_EV(ARMV8, EVENT_6CH) \
+ __PMC_EV(ARMV8, EVENT_6DH) \
+ __PMC_EV(ARMV8, EVENT_6EH) \
+ __PMC_EV(ARMV8, EVENT_6FH) \
+ __PMC_EV(ARMV8, EVENT_70H) \
+ __PMC_EV(ARMV8, EVENT_71H) \
+ __PMC_EV(ARMV8, EVENT_72H) \
+ __PMC_EV(ARMV8, EVENT_73H) \
+ __PMC_EV(ARMV8, EVENT_74H) \
+ __PMC_EV(ARMV8, EVENT_75H) \
+ __PMC_EV(ARMV8, EVENT_76H) \
+ __PMC_EV(ARMV8, EVENT_77H) \
+ __PMC_EV(ARMV8, EVENT_78H) \
+ __PMC_EV(ARMV8, EVENT_79H) \
+ __PMC_EV(ARMV8, EVENT_7AH) \
+ __PMC_EV(ARMV8, EVENT_7BH) \
+ __PMC_EV(ARMV8, EVENT_7CH) \
+ __PMC_EV(ARMV8, EVENT_7DH) \
+ __PMC_EV(ARMV8, EVENT_7EH) \
+ __PMC_EV(ARMV8, EVENT_7FH) \
+ __PMC_EV(ARMV8, EVENT_80H) \
+ __PMC_EV(ARMV8, EVENT_81H) \
+ __PMC_EV(ARMV8, EVENT_82H) \
+ __PMC_EV(ARMV8, EVENT_83H) \
+ __PMC_EV(ARMV8, EVENT_84H) \
+ __PMC_EV(ARMV8, EVENT_85H) \
+ __PMC_EV(ARMV8, EVENT_86H) \
+ __PMC_EV(ARMV8, EVENT_87H) \
+ __PMC_EV(ARMV8, EVENT_88H) \
+ __PMC_EV(ARMV8, EVENT_89H) \
+ __PMC_EV(ARMV8, EVENT_8AH) \
+ __PMC_EV(ARMV8, EVENT_8BH) \
+ __PMC_EV(ARMV8, EVENT_8CH) \
+ __PMC_EV(ARMV8, EVENT_8DH) \
+ __PMC_EV(ARMV8, EVENT_8EH) \
+ __PMC_EV(ARMV8, EVENT_8FH) \
+ __PMC_EV(ARMV8, EVENT_90H) \
+ __PMC_EV(ARMV8, EVENT_91H) \
+ __PMC_EV(ARMV8, EVENT_92H) \
+ __PMC_EV(ARMV8, EVENT_93H) \
+ __PMC_EV(ARMV8, EVENT_94H) \
+ __PMC_EV(ARMV8, EVENT_95H) \
+ __PMC_EV(ARMV8, EVENT_96H) \
+ __PMC_EV(ARMV8, EVENT_97H) \
+ __PMC_EV(ARMV8, EVENT_98H) \
+ __PMC_EV(ARMV8, EVENT_99H) \
+ __PMC_EV(ARMV8, EVENT_9AH) \
+ __PMC_EV(ARMV8, EVENT_9BH) \
+ __PMC_EV(ARMV8, EVENT_9CH) \
+ __PMC_EV(ARMV8, EVENT_9DH) \
+ __PMC_EV(ARMV8, EVENT_9EH) \
+ __PMC_EV(ARMV8, EVENT_9FH) \
+ __PMC_EV(ARMV8, EVENT_A0H) \
+ __PMC_EV(ARMV8, EVENT_A1H) \
+ __PMC_EV(ARMV8, EVENT_A2H) \
+ __PMC_EV(ARMV8, EVENT_A3H) \
+ __PMC_EV(ARMV8, EVENT_A4H) \
+ __PMC_EV(ARMV8, EVENT_A5H) \
+ __PMC_EV(ARMV8, EVENT_A6H) \
+ __PMC_EV(ARMV8, EVENT_A7H) \
+ __PMC_EV(ARMV8, EVENT_A8H) \
+ __PMC_EV(ARMV8, EVENT_A9H) \
+ __PMC_EV(ARMV8, EVENT_AAH) \
+ __PMC_EV(ARMV8, EVENT_ABH) \
+ __PMC_EV(ARMV8, EVENT_ACH) \
+ __PMC_EV(ARMV8, EVENT_ADH) \
+ __PMC_EV(ARMV8, EVENT_AEH) \
+ __PMC_EV(ARMV8, EVENT_AFH) \
+ __PMC_EV(ARMV8, EVENT_B0H) \
+ __PMC_EV(ARMV8, EVENT_B1H) \
+ __PMC_EV(ARMV8, EVENT_B2H) \
+ __PMC_EV(ARMV8, EVENT_B3H) \
+ __PMC_EV(ARMV8, EVENT_B4H) \
+ __PMC_EV(ARMV8, EVENT_B5H) \
+ __PMC_EV(ARMV8, EVENT_B6H) \
+ __PMC_EV(ARMV8, EVENT_B7H) \
+ __PMC_EV(ARMV8, EVENT_B8H) \
+ __PMC_EV(ARMV8, EVENT_B9H) \
+ __PMC_EV(ARMV8, EVENT_BAH) \
+ __PMC_EV(ARMV8, EVENT_BBH) \
+ __PMC_EV(ARMV8, EVENT_BCH) \
+ __PMC_EV(ARMV8, EVENT_BDH) \
+ __PMC_EV(ARMV8, EVENT_BEH) \
+ __PMC_EV(ARMV8, EVENT_BFH) \
+ __PMC_EV(ARMV8, EVENT_C0H) \
+ __PMC_EV(ARMV8, EVENT_C1H) \
+ __PMC_EV(ARMV8, EVENT_C2H) \
+ __PMC_EV(ARMV8, EVENT_C3H) \
+ __PMC_EV(ARMV8, EVENT_C4H) \
+ __PMC_EV(ARMV8, EVENT_C5H) \
+ __PMC_EV(ARMV8, EVENT_C6H) \
+ __PMC_EV(ARMV8, EVENT_C7H) \
+ __PMC_EV(ARMV8, EVENT_C8H) \
+ __PMC_EV(ARMV8, EVENT_C9H) \
+ __PMC_EV(ARMV8, EVENT_CAH) \
+ __PMC_EV(ARMV8, EVENT_CBH) \
+ __PMC_EV(ARMV8, EVENT_CCH) \
+ __PMC_EV(ARMV8, EVENT_CDH) \
+ __PMC_EV(ARMV8, EVENT_CEH) \
+ __PMC_EV(ARMV8, EVENT_CFH) \
+ __PMC_EV(ARMV8, EVENT_D0H) \
+ __PMC_EV(ARMV8, EVENT_D1H) \
+ __PMC_EV(ARMV8, EVENT_D2H) \
+ __PMC_EV(ARMV8, EVENT_D3H) \
+ __PMC_EV(ARMV8, EVENT_D4H) \
+ __PMC_EV(ARMV8, EVENT_D5H) \
+ __PMC_EV(ARMV8, EVENT_D6H) \
+ __PMC_EV(ARMV8, EVENT_D7H) \
+ __PMC_EV(ARMV8, EVENT_D8H) \
+ __PMC_EV(ARMV8, EVENT_D9H) \
+ __PMC_EV(ARMV8, EVENT_DAH) \
+ __PMC_EV(ARMV8, EVENT_DBH) \
+ __PMC_EV(ARMV8, EVENT_DCH) \
+ __PMC_EV(ARMV8, EVENT_DDH) \
+ __PMC_EV(ARMV8, EVENT_DEH) \
+ __PMC_EV(ARMV8, EVENT_DFH) \
+ __PMC_EV(ARMV8, EVENT_E0H) \
+ __PMC_EV(ARMV8, EVENT_E1H) \
+ __PMC_EV(ARMV8, EVENT_E2H) \
+ __PMC_EV(ARMV8, EVENT_E3H) \
+ __PMC_EV(ARMV8, EVENT_E4H) \
+ __PMC_EV(ARMV8, EVENT_E5H) \
+ __PMC_EV(ARMV8, EVENT_E6H) \
+ __PMC_EV(ARMV8, EVENT_E7H) \
+ __PMC_EV(ARMV8, EVENT_E8H) \
+ __PMC_EV(ARMV8, EVENT_E9H) \
+ __PMC_EV(ARMV8, EVENT_EAH) \
+ __PMC_EV(ARMV8, EVENT_EBH) \
+ __PMC_EV(ARMV8, EVENT_ECH) \
+ __PMC_EV(ARMV8, EVENT_EDH) \
+ __PMC_EV(ARMV8, EVENT_EEH) \
+ __PMC_EV(ARMV8, EVENT_EFH) \
+ __PMC_EV(ARMV8, EVENT_F0H) \
+ __PMC_EV(ARMV8, EVENT_F1H) \
+ __PMC_EV(ARMV8, EVENT_F2H) \
+ __PMC_EV(ARMV8, EVENT_F3H) \
+ __PMC_EV(ARMV8, EVENT_F4H) \
+ __PMC_EV(ARMV8, EVENT_F5H) \
+ __PMC_EV(ARMV8, EVENT_F6H) \
+ __PMC_EV(ARMV8, EVENT_F7H) \
+ __PMC_EV(ARMV8, EVENT_F8H) \
+ __PMC_EV(ARMV8, EVENT_F9H) \
+ __PMC_EV(ARMV8, EVENT_FAH) \
+ __PMC_EV(ARMV8, EVENT_FBH) \
+ __PMC_EV(ARMV8, EVENT_FCH) \
+ __PMC_EV(ARMV8, EVENT_FDH) \
+ __PMC_EV(ARMV8, EVENT_FEH) \
+ __PMC_EV(ARMV8, EVENT_FFH)
+
+#define PMC_EV_ARMV8_FIRST PMC_EV_ARMV8_EVENT_00H
+#define PMC_EV_ARMV8_LAST PMC_EV_ARMV8_EVENT_FFH
+
+#define __PMC_EV_ALIAS_ARMV8_COMMON() \
+ __PMC_EV_ALIAS("SW_INCR", ARMV8_EVENT_00H) \
+ __PMC_EV_ALIAS("L1I_CACHE_REFILL", ARMV8_EVENT_01H) \
+ __PMC_EV_ALIAS("L1I_TLB_REFILL", ARMV8_EVENT_02H) \
+ __PMC_EV_ALIAS("L1D_CACHE_REFILL", ARMV8_EVENT_03H) \
+ __PMC_EV_ALIAS("L1D_CACHE", ARMV8_EVENT_04H) \
+ __PMC_EV_ALIAS("L1D_TLB_REFILL", ARMV8_EVENT_05H) \
+ __PMC_EV_ALIAS("INST_RETIRED", ARMV8_EVENT_08H) \
+ __PMC_EV_ALIAS("EXC_TAKEN", ARMV8_EVENT_09H) \
+ __PMC_EV_ALIAS("EXC_RETURN", ARMV8_EVENT_0AH) \
+ __PMC_EV_ALIAS("CID_WRITE_RETIRED", ARMV8_EVENT_0BH) \
+ __PMC_EV_ALIAS("BR_MIS_PRED", ARMV8_EVENT_10H) \
+ __PMC_EV_ALIAS("CPU_CYCLES", ARMV8_EVENT_11H) \
+ __PMC_EV_ALIAS("BR_PRED", ARMV8_EVENT_12H) \
+ __PMC_EV_ALIAS("MEM_ACCESS", ARMV8_EVENT_13H) \
+ __PMC_EV_ALIAS("L1I_CACHE", ARMV8_EVENT_14H) \
+ __PMC_EV_ALIAS("L1D_CACHE_WB", ARMV8_EVENT_15H) \
+ __PMC_EV_ALIAS("L2D_CACHE", ARMV8_EVENT_16H) \
+ __PMC_EV_ALIAS("L2D_CACHE_REFILL", ARMV8_EVENT_17H) \
+ __PMC_EV_ALIAS("L2D_CACHE_WB", ARMV8_EVENT_18H) \
+ __PMC_EV_ALIAS("BUS_ACCESS", ARMV8_EVENT_19H) \
+ __PMC_EV_ALIAS("MEMORY_ERROR", ARMV8_EVENT_1AH) \
+ __PMC_EV_ALIAS("BUS_CYCLES", ARMV8_EVENT_1DH) \
+ __PMC_EV_ALIAS("CHAIN", ARMV8_EVENT_1EH) \
+ __PMC_EV_ALIAS("BUS_ACCESS_LD", ARMV8_EVENT_60H) \
+ __PMC_EV_ALIAS("BUS_ACCESS_ST", ARMV8_EVENT_61H) \
+ __PMC_EV_ALIAS("BR_INDIRECT_SPEC", ARMV8_EVENT_7AH) \
+ __PMC_EV_ALIAS("EXC_IRQ", ARMV8_EVENT_86H) \
+ __PMC_EV_ALIAS("EXC_FIQ", ARMV8_EVENT_87H)
+
+#define __PMC_EV_ALIAS_ARMV8_CORTEX_A53() \
+ __PMC_EV_ALIAS_ARMV8_COMMON() \
+ __PMC_EV_ALIAS("LD_RETIRED", ARMV8_EVENT_06H) \
+ __PMC_EV_ALIAS("ST_RETIRED", ARMV8_EVENT_07H) \
+ __PMC_EV_ALIAS("PC_WRITE_RETIRED", ARMV8_EVENT_0CH) \
+ __PMC_EV_ALIAS("BR_IMMED_RETIRED", ARMV8_EVENT_0DH) \
+ __PMC_EV_ALIAS("BR_RETURN_RETIRED", ARMV8_EVENT_0EH) \
+ __PMC_EV_ALIAS("UNALIGNED_LDST_RETIRED",ARMV8_EVENT_0FH)
+
+#define __PMC_EV_ALIAS_ARMV8_CORTEX_A57() \
+ __PMC_EV_ALIAS_ARMV8_COMMON() \
+ __PMC_EV_ALIAS("INST_SPEC", ARMV8_EVENT_1BH) \
+ __PMC_EV_ALIAS("TTBR_WRITE_RETIRED", ARMV8_EVENT_1CH) \
+ __PMC_EV_ALIAS("L1D_CACHE_LD", ARMV8_EVENT_40H) \
+ __PMC_EV_ALIAS("L1D_CACHE_ST", ARMV8_EVENT_41H) \
+ __PMC_EV_ALIAS("L1D_CACHE_REFILL_LD", ARMV8_EVENT_42H) \
+ __PMC_EV_ALIAS("L1D_CACHE_REFILL_ST", ARMV8_EVENT_43H) \
+ __PMC_EV_ALIAS("L1D_CACHE_WB_VICTIM", ARMV8_EVENT_46H) \
+ __PMC_EV_ALIAS("L1D_CACHE_WB_CLEAN", ARMV8_EVENT_47H) \
+ __PMC_EV_ALIAS("L1D_CACHE_INVAL", ARMV8_EVENT_48H) \
+ __PMC_EV_ALIAS("L1D_TLB_REFILL_LD", ARMV8_EVENT_4CH) \
+ __PMC_EV_ALIAS("L1D_TLB_REFILL_ST", ARMV8_EVENT_4DH) \
+ __PMC_EV_ALIAS("L2D_CACHE_LD", ARMV8_EVENT_50H) \
+ __PMC_EV_ALIAS("L2D_CACHE_ST", ARMV8_EVENT_51H) \
+ __PMC_EV_ALIAS("L2D_CACHE_REFILL_LD", ARMV8_EVENT_52H) \
+ __PMC_EV_ALIAS("L2D_CACHE_REFILL_ST", ARMV8_EVENT_53H) \
+ __PMC_EV_ALIAS("L2D_CACHE_WB_VICTIM", ARMV8_EVENT_56H) \
+ __PMC_EV_ALIAS("L2D_CACHE_WB_CLEAN", ARMV8_EVENT_57H) \
+ __PMC_EV_ALIAS("L2D_CACHE_INVAL", ARMV8_EVENT_58H) \
+ __PMC_EV_ALIAS("BUS_ACCESS_SHARED", ARMV8_EVENT_62H) \
+ __PMC_EV_ALIAS("BUS_ACCESS_NOT_SHARED", ARMV8_EVENT_63H) \
+ __PMC_EV_ALIAS("BUS_ACCESS_NORMAL", ARMV8_EVENT_64H) \
+ __PMC_EV_ALIAS("BUS_ACCESS_PERIPH", ARMV8_EVENT_65H) \
+ __PMC_EV_ALIAS("MEM_ACCESS_LD", ARMV8_EVENT_66H) \
+ __PMC_EV_ALIAS("MEM_ACCESS_ST", ARMV8_EVENT_67H) \
+ __PMC_EV_ALIAS("UNALIGNED_LD_SPEC", ARMV8_EVENT_68H) \
+ __PMC_EV_ALIAS("UNALIGNED_ST_SPEC", ARMV8_EVENT_69H) \
+ __PMC_EV_ALIAS("UNALIGNED_LDST_SPEC", ARMV8_EVENT_6AH) \
+ __PMC_EV_ALIAS("LDREX_SPEC", ARMV8_EVENT_6CH) \
+ __PMC_EV_ALIAS("STREX_PASS_SPEC", ARMV8_EVENT_6DH) \
+ __PMC_EV_ALIAS("STREX_FAIL_SPEC", ARMV8_EVENT_6EH) \
+ __PMC_EV_ALIAS("LD_SPEC", ARMV8_EVENT_70H) \
+ __PMC_EV_ALIAS("ST_SPEC", ARMV8_EVENT_71H) \
+ __PMC_EV_ALIAS("LDST_SPEC", ARMV8_EVENT_72H) \
+ __PMC_EV_ALIAS("DP_SPEC", ARMV8_EVENT_73H) \
+ __PMC_EV_ALIAS("ASE_SPEC", ARMV8_EVENT_74H) \
+ __PMC_EV_ALIAS("VFP_SPEC", ARMV8_EVENT_75H) \
+ __PMC_EV_ALIAS("PC_WRITE_SPEC", ARMV8_EVENT_76H) \
+ __PMC_EV_ALIAS("CRYPTO_SPEC", ARMV8_EVENT_77H) \
+ __PMC_EV_ALIAS("BR_IMMED_SPEC", ARMV8_EVENT_78H) \
+ __PMC_EV_ALIAS("BR_RETURN_SPEC", ARMV8_EVENT_79H) \
+ __PMC_EV_ALIAS("ISB_SPEC", ARMV8_EVENT_7CH) \
+ __PMC_EV_ALIAS("DSB_SPEC", ARMV8_EVENT_7DH) \
+ __PMC_EV_ALIAS("DMB_SPEC", ARMV8_EVENT_7EH) \
+ __PMC_EV_ALIAS("EXC_UNDEF", ARMV8_EVENT_81H) \
+ __PMC_EV_ALIAS("EXC_SVC", ARMV8_EVENT_82H) \
+ __PMC_EV_ALIAS("EXC_PABORT", ARMV8_EVENT_83H) \
+ __PMC_EV_ALIAS("EXC_DABORT", ARMV8_EVENT_84H) \
+ __PMC_EV_ALIAS("EXC_SMC", ARMV8_EVENT_88H) \
+ __PMC_EV_ALIAS("EXC_HVC", ARMV8_EVENT_8AH) \
+ __PMC_EV_ALIAS("EXC_TRAP_PABORT", ARMV8_EVENT_8BH) \
+ __PMC_EV_ALIAS("EXC_TRAP_DABORT", ARMV8_EVENT_8CH) \
+ __PMC_EV_ALIAS("EXC_TRAP_OTHER", ARMV8_EVENT_8DH) \
+ __PMC_EV_ALIAS("EXC_TRAP_IRQ", ARMV8_EVENT_8EH) \
+ __PMC_EV_ALIAS("EXC_TRAP_FIQ", ARMV8_EVENT_8FH) \
+ __PMC_EV_ALIAS("RC_LD_SPEC", ARMV8_EVENT_90H) \
+ __PMC_EV_ALIAS("RC_ST_SPEC", ARMV8_EVENT_91H)
+
+/*
* MIPS Events from "Programming the MIPS32 24K Core Family",
* Document Number: MD00355 Revision 04.63 December 19, 2008
* These events are kept in the order found in Table 7.4.
@@ -5566,6 +5929,7 @@ __PMC_EV_ALIAS("IMPC_C0H_TRK_REQUEST.ALL", UCP_EVENT_84H_01H)
* 0x13100 0x00FF IBM PPC970 events
* 0x13300 0x00FF Freescale e500 events
* 0x14000 0x0100 ARMv7 events
+ * 0x14100 0x0100 ARMv8 events
* 0x20000 0x1000 Software events
*/
#define __PMC_EVENTS() \
@@ -5605,6 +5969,8 @@ __PMC_EV_ALIAS("IMPC_C0H_TRK_REQUEST.ALL", UCP_EVENT_84H_01H)
__PMC_EV_E500() \
__PMC_EV_BLOCK(ARMV7, 0x14000) \
__PMC_EV_ARMV7() \
+ __PMC_EV_BLOCK(ARMV8, 0x14100) \
+ __PMC_EV_ARMV8()
#define PMC_EVENT_FIRST PMC_EV_TSC_TSC
#define PMC_EVENT_LAST PMC_EV_SOFT_LAST
diff --git a/sys/dev/hyperv/include/hyperv.h b/sys/dev/hyperv/include/hyperv.h
index 8a45d89..5360b7c 100644
--- a/sys/dev/hyperv/include/hyperv.h
+++ b/sys/dev/hyperv/include/hyperv.h
@@ -46,6 +46,7 @@
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/sema.h>
+#include <sys/smp.h>
#include <sys/mutex.h>
#include <sys/bus.h>
#include <vm/vm.h>
@@ -63,11 +64,22 @@ typedef uint8_t hv_bool_uint8_t;
#define HV_ERROR_MACHINE_LOCKED 0x800704F7
/*
- * A revision number of vmbus that is used for ensuring both ends on a
- * partition are using compatible versions.
+ * VMBUS version is 32 bit, upper 16 bit for major_number and lower
+ * 16 bit for minor_number.
+ *
+ * 0.13 -- Windows Server 2008
+ * 1.1 -- Windows 7
+ * 2.4 -- Windows 8
+ * 3.0 -- Windows 8.1
*/
+#define HV_VMBUS_VERSION_WS2008 ((0 << 16) | (13))
+#define HV_VMBUS_VERSION_WIN7 ((1 << 16) | (1))
+#define HV_VMBUS_VERSION_WIN8 ((2 << 16) | (4))
+#define HV_VMBUS_VERSION_WIN8_1 ((3 << 16) | (0))
+
+#define HV_VMBUS_VERSION_INVALID -1
-#define HV_VMBUS_REVISION_NUMBER 13
+#define HV_VMBUS_VERSION_CURRENT HV_VMBUS_VERSION_WIN8_1
/*
* Make maximum size of pipe payload of 16K
@@ -112,6 +124,18 @@ typedef struct hv_guid {
unsigned char data[16];
} __packed hv_guid;
+#define HV_NIC_GUID \
+ .data = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46, \
+ 0x91, 0x3F, 0xF2, 0xD2, 0xF9, 0x65, 0xED, 0x0E}
+
+#define HV_IDE_GUID \
+ .data = {0x32, 0x26, 0x41, 0x32, 0xcb, 0x86, 0xa2, 0x44, \
+ 0x9b, 0x5c, 0x50, 0xd1, 0x41, 0x73, 0x54, 0xf5}
+
+#define HV_SCSI_GUID \
+ .data = {0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d, \
+ 0xb6, 0x05, 0x72, 0xe2, 0xff, 0xb1, 0xdc, 0x7f}
+
/*
* At the center of the Channel Management library is
* the Channel Offer. This struct contains the
@@ -147,7 +171,11 @@ typedef struct hv_vmbus_channel_offer {
} __packed pipe;
} u;
- uint32_t padding;
+ /*
+ * Sub_channel_index, newly added in Win8.
+ */
+ uint16_t sub_channel_index;
+ uint16_t padding;
} __packed hv_vmbus_channel_offer;
@@ -344,7 +372,25 @@ typedef struct {
hv_vmbus_channel_offer offer;
uint32_t child_rel_id;
uint8_t monitor_id;
- hv_bool_uint8_t monitor_allocated;
+ /*
+ * This field has been split into a bit field on Win7
+ * and higher.
+ */
+ uint8_t monitor_allocated:1;
+ uint8_t reserved:7;
+ /*
+ * Following fields were added in win7 and higher.
+ * Make sure to check the version before accessing these fields.
+ *
+ * If "is_dedicated_interrupt" is set, we must not set the
+ * associated bit in the channel bitmap while sending the
+ * interrupt to the host.
+ *
+ * connection_id is used in signaling the host.
+ */
+ uint16_t is_dedicated_interrupt:1;
+ uint16_t reserved1:15;
+ uint32_t connection_id;
} __packed hv_vmbus_channel_offer_channel;
/*
@@ -394,9 +440,11 @@ typedef struct
hv_gpadl_handle ring_buffer_gpadl_handle;
/*
- * GPADL for the channel's server context save area.
+ * Before win8, all incoming channel interrupts are only
+ * delivered on cpu 0. Setting this value to 0 would
+ * preserve the earlier behavior.
*/
- hv_gpadl_handle server_context_area_gpadl_handle;
+ uint32_t target_vcpu;
/*
* The upstream ring buffer begins at offset zero in the memory described
@@ -646,14 +694,42 @@ typedef struct {
} hv_vmbus_ring_buffer_info;
typedef void (*hv_vmbus_pfn_channel_callback)(void *context);
+typedef void (*hv_vmbus_sc_creation_callback)(void *context);
typedef enum {
HV_CHANNEL_OFFER_STATE,
HV_CHANNEL_OPENING_STATE,
HV_CHANNEL_OPEN_STATE,
+ HV_CHANNEL_OPENED_STATE,
HV_CHANNEL_CLOSING_NONDESTRUCTIVE_STATE,
} hv_vmbus_channel_state;
+/*
+ * Connection identifier type
+ */
+typedef union {
+ uint32_t as_uint32_t;
+ struct {
+ uint32_t id:24;
+ uint32_t reserved:8;
+ } u;
+
+} __packed hv_vmbus_connection_id;
+
+/*
+ * Definition of the hv_vmbus_signal_event hypercall input structure
+ */
+typedef struct {
+ hv_vmbus_connection_id connection_id;
+ uint16_t flag_number;
+ uint16_t rsvd_z;
+} __packed hv_vmbus_input_signal_event;
+
+typedef struct {
+ uint64_t align8;
+ hv_vmbus_input_signal_event event;
+} __packed hv_vmbus_input_signal_event_buffer;
+
typedef struct hv_vmbus_channel {
TAILQ_ENTRY(hv_vmbus_channel) list_entry;
struct hv_device* device;
@@ -688,8 +764,82 @@ typedef struct hv_vmbus_channel {
hv_vmbus_pfn_channel_callback on_channel_callback;
void* channel_callback_context;
+ /*
+ * If batched_reading is set to "true", mask the interrupt
+ * and read until the channel is empty.
+ * If batched_reading is set to "false", the channel is not
+ * going to perform batched reading.
+ *
+ * Batched reading is enabled by default; specific
+ * drivers that don't want this behavior can turn it off.
+ */
+ boolean_t batched_reading;
+
+ boolean_t is_dedicated_interrupt;
+
+ /*
+ * Used as an input param for HV_CALL_SIGNAL_EVENT hypercall.
+ */
+ hv_vmbus_input_signal_event_buffer signal_event_buffer;
+ /*
+ * 8-bytes aligned of the buffer above
+ */
+ hv_vmbus_input_signal_event *signal_event_param;
+
+ /*
+ * From Win8, this field specifies the target virtual process
+ * on which to deliver the interupt from the host to guest.
+ * Before Win8, all channel interrupts would only be
+ * delivered on cpu 0. Setting this value to 0 would preserve
+ * the earlier behavior.
+ */
+ uint32_t target_vcpu;
+ /* The corresponding CPUID in the guest */
+ uint32_t target_cpu;
+
+ /*
+ * Support for multi-channels.
+ * The initial offer is considered the primary channel and this
+ * offer message will indicate if the host supports multi-channels.
+ * The guest is free to ask for multi-channels to be offerred and can
+ * open these multi-channels as a normal "primary" channel. However,
+ * all multi-channels will have the same type and instance guids as the
+ * primary channel. Requests sent on a given channel will result in a
+ * response on the same channel.
+ */
+
+ /*
+ * Multi-channel creation callback. This callback will be called in
+ * process context when a Multi-channel offer is received from the host.
+ * The guest can open the Multi-channel in the context of this callback.
+ */
+ hv_vmbus_sc_creation_callback sc_creation_callback;
+
+ struct mtx sc_lock;
+
+ /*
+ * Link list of all the multi-channels if this is a primary channel
+ */
+ TAILQ_HEAD(, hv_vmbus_channel) sc_list_anchor;
+ TAILQ_ENTRY(hv_vmbus_channel) sc_list_entry;
+
+ /*
+ * The primary channel this sub-channle belongs to.
+ * This will be NULL for the primary channel.
+ */
+ struct hv_vmbus_channel *primary_channel;
+ /*
+ * Support per channel state for use by vmbus drivers.
+ */
+ void *per_channel_state;
} hv_vmbus_channel;
+static inline void
+hv_set_channel_read_state(hv_vmbus_channel* channel, boolean_t state)
+{
+ channel->batched_reading = state;
+}
+
typedef struct hv_device {
hv_guid class_id;
hv_guid device_id;
@@ -760,6 +910,8 @@ int hv_vmbus_channel_teardown_gpdal(
hv_vmbus_channel* channel,
uint32_t gpadl_handle);
+struct hv_vmbus_channel* vmbus_select_outgoing_channel(struct hv_vmbus_channel *promary);
+
/*
* Work abstraction defines
*/
@@ -819,6 +971,7 @@ typedef struct hv_vmbus_service {
extern uint8_t* receive_buffer[];
extern hv_vmbus_service service_table[];
+extern uint32_t hv_vmbus_protocal_version;
void hv_kvp_callback(void *context);
int hv_kvp_init(hv_vmbus_service *serv);
diff --git a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
index d00d279..27a94ef 100644
--- a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
+++ b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/condvar.h>
+#include <sys/time.h>
#include <sys/systm.h>
#include <sys/sockio.h>
#include <sys/mbuf.h>
@@ -53,8 +54,12 @@ __FBSDID("$FreeBSD$");
#include <sys/callout.h>
#include <vm/vm.h>
#include <vm/pmap.h>
+#include <vm/uma.h>
#include <sys/lock.h>
#include <sys/sema.h>
+#include <sys/sglist.h>
+#include <machine/bus.h>
+#include <sys/bus_dma.h>
#include <cam/cam.h>
#include <cam/cam_ccb.h>
@@ -66,7 +71,6 @@ __FBSDID("$FreeBSD$");
#include <cam/scsi/scsi_all.h>
#include <cam/scsi/scsi_message.h>
-
#include <dev/hyperv/include/hyperv.h>
#include "hv_vstorage.h"
@@ -77,8 +81,31 @@ __FBSDID("$FreeBSD$");
#define BLKVSC_MAX_IO_REQUESTS STORVSC_MAX_IO_REQUESTS
#define STORVSC_MAX_TARGETS (2)
+#define STORVSC_WIN7_MAJOR 4
+#define STORVSC_WIN7_MINOR 2
+
+#define STORVSC_WIN8_MAJOR 5
+#define STORVSC_WIN8_MINOR 1
+
+#define VSTOR_PKT_SIZE (sizeof(struct vstor_packet) - vmscsi_size_delta)
+
+#define HV_ALIGN(x, a) roundup2(x, a)
+
struct storvsc_softc;
+struct hv_sgl_node {
+ LIST_ENTRY(hv_sgl_node) link;
+ struct sglist *sgl_data;
+};
+
+struct hv_sgl_page_pool{
+ LIST_HEAD(, hv_sgl_node) in_use_sgl_list;
+ LIST_HEAD(, hv_sgl_node) free_sgl_list;
+ boolean_t is_init;
+} g_hv_sgl_page_pool;
+
+#define STORVSC_MAX_SG_PAGE_CNT STORVSC_MAX_IO_REQUESTS * HV_MAX_MULTIPAGE_BUFFER_COUNT
+
enum storvsc_request_type {
WRITE_TYPE,
READ_TYPE,
@@ -96,20 +123,24 @@ struct hv_storvsc_request {
struct storvsc_softc *softc;
struct callout callout;
struct sema synch_sema; /*Synchronize the request/response if needed */
+ struct sglist *bounce_sgl;
+ unsigned int bounce_sgl_count;
+ uint64_t not_aligned_seg_bits;
};
struct storvsc_softc {
struct hv_device *hs_dev;
- LIST_HEAD(, hv_storvsc_request) hs_free_list;
- struct mtx hs_lock;
- struct storvsc_driver_props *hs_drv_props;
- int hs_unit;
- uint32_t hs_frozen;
- struct cam_sim *hs_sim;
- struct cam_path *hs_path;
+ LIST_HEAD(, hv_storvsc_request) hs_free_list;
+ struct mtx hs_lock;
+ struct storvsc_driver_props *hs_drv_props;
+ int hs_unit;
+ uint32_t hs_frozen;
+ struct cam_sim *hs_sim;
+ struct cam_path *hs_path;
uint32_t hs_num_out_reqs;
boolean_t hs_destroy;
boolean_t hs_drain_notify;
+ boolean_t hs_open_multi_channel;
struct sema hs_drain_sema;
struct hv_storvsc_request hs_init_req;
struct hv_storvsc_request hs_reset_req;
@@ -124,7 +155,7 @@ struct storvsc_softc {
* The first can be tested by "sg_senddiag -vv /dev/daX",
* and the second and third can be done by
* "sg_wr_mode -v -p 08 -c 0,1a -m 0,ff /dev/daX".
- */
+ */
#define HVS_TIMEOUT_TEST 0
/*
@@ -138,7 +169,7 @@ struct storvsc_driver_props {
char *drv_name;
char *drv_desc;
uint8_t drv_max_luns_per_target;
- uint8_t drv_max_ios_per_target;
+ uint8_t drv_max_ios_per_target;
uint32_t drv_ringbuffer_size;
};
@@ -150,6 +181,8 @@ enum hv_storage_type {
#define HS_MAX_ADAPTERS 10
+#define HV_STORAGE_SUPPORTS_MULTI_CHANNEL 0x1
+
/* {ba6163d9-04a1-4d29-b605-72e2ffb1dc7f} */
static const hv_guid gStorVscDeviceType={
.data = {0xd9, 0x63, 0x61, 0xba, 0xa1, 0x04, 0x29, 0x4d,
@@ -171,21 +204,48 @@ static struct storvsc_driver_props g_drv_props_table[] = {
STORVSC_RINGBUFFER_SIZE}
};
+/*
+ * Sense buffer size changed in win8; have a run-time
+ * variable to track the size we should use.
+ */
+static int sense_buffer_size;
+
+/*
+ * The size of the vmscsi_request has changed in win8. The
+ * additional size is for the newly added elements in the
+ * structure. These elements are valid only when we are talking
+ * to a win8 host.
+ * Track the correct size we need to apply.
+ */
+static int vmscsi_size_delta;
+
+static int storvsc_current_major;
+static int storvsc_current_minor;
+
/* static functions */
static int storvsc_probe(device_t dev);
static int storvsc_attach(device_t dev);
static int storvsc_detach(device_t dev);
static void storvsc_poll(struct cam_sim * sim);
static void storvsc_action(struct cam_sim * sim, union ccb * ccb);
-static void create_storvsc_request(union ccb *ccb, struct hv_storvsc_request *reqp);
+static int create_storvsc_request(union ccb *ccb, struct hv_storvsc_request *reqp);
static void storvsc_free_request(struct storvsc_softc *sc, struct hv_storvsc_request *reqp);
static enum hv_storage_type storvsc_get_storage_type(device_t dev);
+static void hv_storvsc_rescan_target(struct storvsc_softc *sc);
static void hv_storvsc_on_channel_callback(void *context);
static void hv_storvsc_on_iocompletion( struct storvsc_softc *sc,
struct vstor_packet *vstor_packet,
struct hv_storvsc_request *request);
static int hv_storvsc_connect_vsp(struct hv_device *device);
static void storvsc_io_done(struct hv_storvsc_request *reqp);
+static void storvsc_copy_sgl_to_bounce_buf(struct sglist *bounce_sgl,
+ bus_dma_segment_t *orig_sgl,
+ unsigned int orig_sgl_count,
+ uint64_t seg_bits);
+void storvsc_copy_from_bounce_buf_to_sgl(bus_dma_segment_t *dest_sgl,
+ unsigned int dest_sgl_count,
+ struct sglist* src_sgl,
+ uint64_t seg_bits);
static device_method_t storvsc_methods[] = {
/* Device interface */
@@ -207,7 +267,7 @@ MODULE_DEPEND(storvsc, vmbus, 1, 1, 1);
/**
- * The host is capable of sending messages to us that are
+ * The host is capable of sending messages to us that are
* completely unsolicited. So, we need to address the race
* condition where we may be in the process of unloading the
* driver when the host may send us an unsolicited message.
@@ -223,7 +283,7 @@ MODULE_DEPEND(storvsc, vmbus, 1, 1, 1);
* destroyed.
*
* 3. Once the device is marked as being destroyed, we only
- * permit incoming traffic to properly account for
+ * permit incoming traffic to properly account for
* packets already sent out.
*/
static inline struct storvsc_softc *
@@ -260,6 +320,113 @@ get_stor_device(struct hv_device *device,
}
/**
+ * @brief Callback handler, will be invoked when receive mutil-channel offer
+ *
+ * @param context new multi-channel
+ */
+static void
+storvsc_handle_sc_creation(void *context)
+{
+ hv_vmbus_channel *new_channel;
+ struct hv_device *device;
+ struct storvsc_softc *sc;
+ struct vmstor_chan_props props;
+ int ret = 0;
+
+ new_channel = (hv_vmbus_channel *)context;
+ device = new_channel->primary_channel->device;
+ sc = get_stor_device(device, TRUE);
+ if (sc == NULL)
+ return;
+
+ if (FALSE == sc->hs_open_multi_channel)
+ return;
+
+ memset(&props, 0, sizeof(props));
+
+ ret = hv_vmbus_channel_open(new_channel,
+ sc->hs_drv_props->drv_ringbuffer_size,
+ sc->hs_drv_props->drv_ringbuffer_size,
+ (void *)&props,
+ sizeof(struct vmstor_chan_props),
+ hv_storvsc_on_channel_callback,
+ new_channel);
+
+ return;
+}
+
+/**
+ * @brief Send multi-channel creation request to host
+ *
+ * @param device a Hyper-V device pointer
+ * @param max_chans the max channels supported by vmbus
+ */
+static void
+storvsc_send_multichannel_request(struct hv_device *dev, int max_chans)
+{
+ struct storvsc_softc *sc;
+ struct hv_storvsc_request *request;
+ struct vstor_packet *vstor_packet;
+ int request_channels_cnt = 0;
+ int ret;
+
+ /* get multichannels count that need to create */
+ request_channels_cnt = MIN(max_chans, mp_ncpus);
+
+ sc = get_stor_device(dev, TRUE);
+ if (sc == NULL) {
+ printf("Storvsc_error: get sc failed while send mutilchannel "
+ "request\n");
+ return;
+ }
+
+ request = &sc->hs_init_req;
+
+ /* Establish a handler for multi-channel */
+ dev->channel->sc_creation_callback = storvsc_handle_sc_creation;
+
+ /* request the host to create multi-channel */
+ memset(request, 0, sizeof(struct hv_storvsc_request));
+
+ sema_init(&request->synch_sema, 0, ("stor_synch_sema"));
+
+ vstor_packet = &request->vstor_packet;
+
+ vstor_packet->operation = VSTOR_OPERATION_CREATE_MULTI_CHANNELS;
+ vstor_packet->flags = REQUEST_COMPLETION_FLAG;
+ vstor_packet->u.multi_channels_cnt = request_channels_cnt;
+
+ ret = hv_vmbus_channel_send_packet(
+ dev->channel,
+ vstor_packet,
+ VSTOR_PKT_SIZE,
+ (uint64_t)(uintptr_t)request,
+ HV_VMBUS_PACKET_TYPE_DATA_IN_BAND,
+ HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
+
+ /* wait for 5 seconds */
+ ret = sema_timedwait(&request->synch_sema, 5 * hz);
+ if (ret != 0) {
+ printf("Storvsc_error: create multi-channel timeout, %d\n",
+ ret);
+ return;
+ }
+
+ if (vstor_packet->operation != VSTOR_OPERATION_COMPLETEIO ||
+ vstor_packet->status != 0) {
+ printf("Storvsc_error: create multi-channel invalid operation "
+ "(%d) or statue (%u)\n",
+ vstor_packet->operation, vstor_packet->status);
+ return;
+ }
+
+ sc->hs_open_multi_channel = TRUE;
+
+ if (bootverbose)
+ printf("Storvsc create multi-channel success!\n");
+}
+
+/**
* @brief initialize channel connection to parent partition
*
* @param dev a Hyper-V device pointer
@@ -272,11 +439,15 @@ hv_storvsc_channel_init(struct hv_device *dev)
struct hv_storvsc_request *request;
struct vstor_packet *vstor_packet;
struct storvsc_softc *sc;
+ uint16_t max_chans = 0;
+ boolean_t support_multichannel = FALSE;
+
+ max_chans = 0;
+ support_multichannel = FALSE;
sc = get_stor_device(dev, TRUE);
- if (sc == NULL) {
- return ENODEV;
- }
+ if (sc == NULL)
+ return (ENODEV);
request = &sc->hs_init_req;
memset(request, 0, sizeof(struct hv_storvsc_request));
@@ -295,20 +466,18 @@ hv_storvsc_channel_init(struct hv_device *dev)
ret = hv_vmbus_channel_send_packet(
dev->channel,
vstor_packet,
- sizeof(struct vstor_packet),
+ VSTOR_PKT_SIZE,
(uint64_t)(uintptr_t)request,
HV_VMBUS_PACKET_TYPE_DATA_IN_BAND,
HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
- if (ret != 0) {
+ if (ret != 0)
goto cleanup;
- }
-
- ret = sema_timedwait(&request->synch_sema, 500); /* KYS 5 seconds */
- if (ret != 0) {
+ /* wait 5 seconds */
+ ret = sema_timedwait(&request->synch_sema, 5 * hz);
+ if (ret != 0)
goto cleanup;
- }
if (vstor_packet->operation != VSTOR_OPERATION_COMPLETEIO ||
vstor_packet->status != 0) {
@@ -321,7 +490,8 @@ hv_storvsc_channel_init(struct hv_device *dev)
vstor_packet->operation = VSTOR_OPERATION_QUERYPROTOCOLVERSION;
vstor_packet->flags = REQUEST_COMPLETION_FLAG;
- vstor_packet->u.version.major_minor = VMSTOR_PROTOCOL_VERSION_CURRENT;
+ vstor_packet->u.version.major_minor =
+ VMSTOR_PROTOCOL_VERSION(storvsc_current_major, storvsc_current_minor);
/* revision is only significant for Windows guests */
vstor_packet->u.version.revision = 0;
@@ -329,26 +499,24 @@ hv_storvsc_channel_init(struct hv_device *dev)
ret = hv_vmbus_channel_send_packet(
dev->channel,
vstor_packet,
- sizeof(struct vstor_packet),
+ VSTOR_PKT_SIZE,
(uint64_t)(uintptr_t)request,
HV_VMBUS_PACKET_TYPE_DATA_IN_BAND,
HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
- if (ret != 0) {
+ if (ret != 0)
goto cleanup;
- }
- ret = sema_timedwait(&request->synch_sema, 500); /* KYS 5 seconds */
+ /* wait 5 seconds */
+ ret = sema_timedwait(&request->synch_sema, 5 * hz);
- if (ret) {
+ if (ret)
goto cleanup;
- }
/* TODO: Check returned version */
if (vstor_packet->operation != VSTOR_OPERATION_COMPLETEIO ||
- vstor_packet->status != 0) {
+ vstor_packet->status != 0)
goto cleanup;
- }
/**
* Query channel properties
@@ -360,27 +528,35 @@ hv_storvsc_channel_init(struct hv_device *dev)
ret = hv_vmbus_channel_send_packet(
dev->channel,
vstor_packet,
- sizeof(struct vstor_packet),
+ VSTOR_PKT_SIZE,
(uint64_t)(uintptr_t)request,
HV_VMBUS_PACKET_TYPE_DATA_IN_BAND,
HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
- if ( ret != 0) {
+ if ( ret != 0)
goto cleanup;
- }
- ret = sema_timedwait(&request->synch_sema, 500); /* KYS 5 seconds */
+ /* wait 5 seconds */
+ ret = sema_timedwait(&request->synch_sema, 5 * hz);
- if (ret != 0) {
+ if (ret != 0)
goto cleanup;
- }
/* TODO: Check returned version */
if (vstor_packet->operation != VSTOR_OPERATION_COMPLETEIO ||
- vstor_packet->status != 0) {
+ vstor_packet->status != 0) {
goto cleanup;
}
+ /* multi-channels feature is supported by WIN8 and above version */
+ max_chans = vstor_packet->u.chan_props.max_channel_cnt;
+ if ((hv_vmbus_protocal_version != HV_VMBUS_VERSION_WIN7) &&
+ (hv_vmbus_protocal_version != HV_VMBUS_VERSION_WS2008) &&
+ (vstor_packet->u.chan_props.flags &
+ HV_STORAGE_SUPPORTS_MULTI_CHANNEL)) {
+ support_multichannel = TRUE;
+ }
+
memset(vstor_packet, 0, sizeof(struct vstor_packet));
vstor_packet->operation = VSTOR_OPERATION_ENDINITIALIZATION;
vstor_packet->flags = REQUEST_COMPLETION_FLAG;
@@ -388,7 +564,7 @@ hv_storvsc_channel_init(struct hv_device *dev)
ret = hv_vmbus_channel_send_packet(
dev->channel,
vstor_packet,
- sizeof(struct vstor_packet),
+ VSTOR_PKT_SIZE,
(uint64_t)(uintptr_t)request,
HV_VMBUS_PACKET_TYPE_DATA_IN_BAND,
HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
@@ -397,16 +573,22 @@ hv_storvsc_channel_init(struct hv_device *dev)
goto cleanup;
}
- ret = sema_timedwait(&request->synch_sema, 500); /* KYS 5 seconds */
+ /* wait 5 seconds */
+ ret = sema_timedwait(&request->synch_sema, 5 * hz);
- if (ret != 0) {
+ if (ret != 0)
goto cleanup;
- }
if (vstor_packet->operation != VSTOR_OPERATION_COMPLETEIO ||
- vstor_packet->status != 0) {
+ vstor_packet->status != 0)
goto cleanup;
- }
+
+ /*
+ * If multi-channel is supported, send multichannel create
+ * request to host.
+ */
+ if (support_multichannel)
+ storvsc_send_multichannel_request(dev, max_chans);
cleanup:
sema_destroy(&request->synch_sema);
@@ -443,8 +625,7 @@ hv_storvsc_connect_vsp(struct hv_device *dev)
(void *)&props,
sizeof(struct vmstor_chan_props),
hv_storvsc_on_channel_callback,
- dev);
-
+ dev->channel);
if (ret != 0) {
return ret;
@@ -481,7 +662,7 @@ hv_storvsc_host_reset(struct hv_device *dev)
ret = hv_vmbus_channel_send_packet(dev->channel,
vstor_packet,
- sizeof(struct vstor_packet),
+ VSTOR_PKT_SIZE,
(uint64_t)(uintptr_t)&sc->hs_reset_req,
HV_VMBUS_PACKET_TYPE_DATA_IN_BAND,
HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
@@ -490,7 +671,7 @@ hv_storvsc_host_reset(struct hv_device *dev)
goto cleanup;
}
- ret = sema_timedwait(&request->synch_sema, 500); /* KYS 5 seconds */
+ ret = sema_timedwait(&request->synch_sema, 5 * hz); /* KYS 5 seconds */
if (ret) {
goto cleanup;
@@ -498,7 +679,7 @@ hv_storvsc_host_reset(struct hv_device *dev)
/*
- * At this point, all outstanding requests in the adapter
+ * At this point, all outstanding requests in the adapter
* should have been flushed out and return to us
*/
@@ -521,6 +702,7 @@ hv_storvsc_io_request(struct hv_device *device,
{
struct storvsc_softc *sc;
struct vstor_packet *vstor_packet = &request->vstor_packet;
+ struct hv_vmbus_channel* outgoing_channel = NULL;
int ret = 0;
sc = get_stor_device(device, TRUE);
@@ -531,29 +713,30 @@ hv_storvsc_io_request(struct hv_device *device,
vstor_packet->flags |= REQUEST_COMPLETION_FLAG;
- vstor_packet->u.vm_srb.length = sizeof(struct vmscsi_req);
+ vstor_packet->u.vm_srb.length = VSTOR_PKT_SIZE;
- vstor_packet->u.vm_srb.sense_info_len = SENSE_BUFFER_SIZE;
+ vstor_packet->u.vm_srb.sense_info_len = sense_buffer_size;
vstor_packet->u.vm_srb.transfer_len = request->data_buf.length;
vstor_packet->operation = VSTOR_OPERATION_EXECUTESRB;
+ outgoing_channel = vmbus_select_outgoing_channel(device->channel);
mtx_unlock(&request->softc->hs_lock);
if (request->data_buf.length) {
ret = hv_vmbus_channel_send_packet_multipagebuffer(
- device->channel,
+ outgoing_channel,
&request->data_buf,
- vstor_packet,
- sizeof(struct vstor_packet),
+ vstor_packet,
+ VSTOR_PKT_SIZE,
(uint64_t)(uintptr_t)request);
} else {
ret = hv_vmbus_channel_send_packet(
- device->channel,
+ outgoing_channel,
vstor_packet,
- sizeof(struct vstor_packet),
+ VSTOR_PKT_SIZE,
(uint64_t)(uintptr_t)request,
HV_VMBUS_PACKET_TYPE_DATA_IN_BAND,
HV_VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED);
@@ -607,10 +790,46 @@ hv_storvsc_on_iocompletion(struct storvsc_softc *sc,
}
static void
+hv_storvsc_rescan_target(struct storvsc_softc *sc)
+{
+ path_id_t pathid;
+ target_id_t targetid;
+ union ccb *ccb;
+
+ pathid = cam_sim_path(sc->hs_sim);
+ targetid = CAM_TARGET_WILDCARD;
+
+ /*
+ * Allocate a CCB and schedule a rescan.
+ */
+ ccb = xpt_alloc_ccb_nowait();
+ if (ccb == NULL) {
+ printf("unable to alloc CCB for rescan\n");
+ return;
+ }
+
+ if (xpt_create_path(&ccb->ccb_h.path, NULL, pathid, targetid,
+ CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
+ printf("unable to create path for rescan, pathid: %d,"
+ "targetid: %d\n", pathid, targetid);
+ xpt_free_ccb(ccb);
+ return;
+ }
+
+ if (targetid == CAM_TARGET_WILDCARD)
+ ccb->ccb_h.func_code = XPT_SCAN_BUS;
+ else
+ ccb->ccb_h.func_code = XPT_SCAN_TGT;
+
+ xpt_rescan(ccb);
+}
+
+static void
hv_storvsc_on_channel_callback(void *context)
{
int ret = 0;
- struct hv_device *device = (struct hv_device *)context;
+ hv_vmbus_channel *channel = (hv_vmbus_channel *)context;
+ struct hv_device *device = NULL;
struct storvsc_softc *sc;
uint32_t bytes_recvd;
uint64_t request_id;
@@ -618,47 +837,63 @@ hv_storvsc_on_channel_callback(void *context)
struct hv_storvsc_request *request;
struct vstor_packet *vstor_packet;
+ if (channel->primary_channel != NULL){
+ device = channel->primary_channel->device;
+ } else {
+ device = channel->device;
+ }
+
+ KASSERT(device, ("device is NULL"));
+
sc = get_stor_device(device, FALSE);
if (sc == NULL) {
+ printf("Storvsc_error: get stor device failed.\n");
return;
}
- KASSERT(device, ("device"));
-
ret = hv_vmbus_channel_recv_packet(
- device->channel,
+ channel,
packet,
- roundup2(sizeof(struct vstor_packet), 8),
+ roundup2(VSTOR_PKT_SIZE, 8),
&bytes_recvd,
&request_id);
while ((ret == 0) && (bytes_recvd > 0)) {
request = (struct hv_storvsc_request *)(uintptr_t)request_id;
- KASSERT(request, ("request"));
if ((request == &sc->hs_init_req) ||
(request == &sc->hs_reset_req)) {
memcpy(&request->vstor_packet, packet,
sizeof(struct vstor_packet));
- sema_post(&request->synch_sema);
+ sema_post(&request->synch_sema);
} else {
vstor_packet = (struct vstor_packet *)packet;
switch(vstor_packet->operation) {
case VSTOR_OPERATION_COMPLETEIO:
+ if (request == NULL)
+ panic("VMBUS: storvsc received a "
+ "packet with NULL request id in "
+ "COMPLETEIO operation.");
+
hv_storvsc_on_iocompletion(sc,
vstor_packet, request);
break;
case VSTOR_OPERATION_REMOVEDEVICE:
+ printf("VMBUS: storvsc operation %d not "
+ "implemented.\n", vstor_packet->operation);
/* TODO: implement */
break;
+ case VSTOR_OPERATION_ENUMERATE_BUS:
+ hv_storvsc_rescan_target(sc);
+ break;
default:
break;
}
}
ret = hv_vmbus_channel_recv_packet(
- device->channel,
+ channel,
packet,
- roundup2(sizeof(struct vstor_packet), 8),
+ roundup2(VSTOR_PKT_SIZE, 8),
&bytes_recvd,
&request_id);
}
@@ -680,7 +915,20 @@ storvsc_probe(device_t dev)
{
int ata_disk_enable = 0;
int ret = ENXIO;
-
+
+ if (hv_vmbus_protocal_version == HV_VMBUS_VERSION_WS2008 ||
+ hv_vmbus_protocal_version == HV_VMBUS_VERSION_WIN7) {
+ sense_buffer_size = PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE;
+ vmscsi_size_delta = sizeof(struct vmscsi_win8_extension);
+ storvsc_current_major = STORVSC_WIN7_MAJOR;
+ storvsc_current_minor = STORVSC_WIN7_MINOR;
+ } else {
+ sense_buffer_size = POST_WIN7_STORVSC_SENSE_BUFFER_SIZE;
+ vmscsi_size_delta = 0;
+ storvsc_current_major = STORVSC_WIN8_MAJOR;
+ storvsc_current_minor = STORVSC_WIN8_MINOR;
+ }
+
switch (storvsc_get_storage_type(dev)) {
case DRIVER_BLKVSC:
if(bootverbose)
@@ -721,9 +969,11 @@ storvsc_attach(device_t dev)
enum hv_storage_type stor_type;
struct storvsc_softc *sc;
struct cam_devq *devq;
- int ret, i;
+ int ret, i, j;
struct hv_storvsc_request *reqp;
struct root_hold_token *root_mount_token = NULL;
+ struct hv_sgl_node *sgl_node = NULL;
+ void *tmp_buff = NULL;
/*
* We need to serialize storvsc attach calls.
@@ -764,8 +1014,41 @@ storvsc_attach(device_t dev)
LIST_INSERT_HEAD(&sc->hs_free_list, reqp, link);
}
+ /* create sg-list page pool */
+ if (FALSE == g_hv_sgl_page_pool.is_init) {
+ g_hv_sgl_page_pool.is_init = TRUE;
+ LIST_INIT(&g_hv_sgl_page_pool.in_use_sgl_list);
+ LIST_INIT(&g_hv_sgl_page_pool.free_sgl_list);
+
+ /*
+ * Pre-create SG list, each SG list with
+ * HV_MAX_MULTIPAGE_BUFFER_COUNT segments, each
+ * segment has one page buffer
+ */
+ for (i = 0; i < STORVSC_MAX_IO_REQUESTS; i++) {
+ sgl_node = malloc(sizeof(struct hv_sgl_node),
+ M_DEVBUF, M_WAITOK|M_ZERO);
+
+ sgl_node->sgl_data =
+ sglist_alloc(HV_MAX_MULTIPAGE_BUFFER_COUNT,
+ M_WAITOK|M_ZERO);
+
+ for (j = 0; j < HV_MAX_MULTIPAGE_BUFFER_COUNT; j++) {
+ tmp_buff = malloc(PAGE_SIZE,
+ M_DEVBUF, M_WAITOK|M_ZERO);
+
+ sgl_node->sgl_data->sg_segs[j].ss_paddr =
+ (vm_paddr_t)tmp_buff;
+ }
+
+ LIST_INSERT_HEAD(&g_hv_sgl_page_pool.free_sgl_list,
+ sgl_node, link);
+ }
+ }
+
sc->hs_destroy = FALSE;
sc->hs_drain_notify = FALSE;
+ sc->hs_open_multi_channel = FALSE;
sema_init(&sc->hs_drain_sema, 0, "Store Drain Sema");
ret = hv_storvsc_connect_vsp(hv_dev);
@@ -834,6 +1117,20 @@ cleanup:
LIST_REMOVE(reqp, link);
free(reqp, M_DEVBUF);
}
+
+ while (!LIST_EMPTY(&g_hv_sgl_page_pool.free_sgl_list)) {
+ sgl_node = LIST_FIRST(&g_hv_sgl_page_pool.free_sgl_list);
+ LIST_REMOVE(sgl_node, link);
+ for (j = 0; j < HV_MAX_MULTIPAGE_BUFFER_COUNT; j++) {
+ if (NULL !=
+ (void*)sgl_node->sgl_data->sg_segs[j].ss_paddr) {
+ free((void*)sgl_node->sgl_data->sg_segs[j].ss_paddr, M_DEVBUF);
+ }
+ }
+ sglist_free(sgl_node->sgl_data);
+ free(sgl_node, M_DEVBUF);
+ }
+
return (ret);
}
@@ -853,6 +1150,8 @@ storvsc_detach(device_t dev)
struct storvsc_softc *sc = device_get_softc(dev);
struct hv_storvsc_request *reqp = NULL;
struct hv_device *hv_device = vmbus_get_devctx(dev);
+ struct hv_sgl_node *sgl_node = NULL;
+ int j = 0;
mtx_lock(&hv_device->channel->inbound_lock);
sc->hs_destroy = TRUE;
@@ -884,6 +1183,20 @@ storvsc_detach(device_t dev)
free(reqp, M_DEVBUF);
}
mtx_unlock(&sc->hs_lock);
+
+ while (!LIST_EMPTY(&g_hv_sgl_page_pool.free_sgl_list)) {
+ sgl_node = LIST_FIRST(&g_hv_sgl_page_pool.free_sgl_list);
+ LIST_REMOVE(sgl_node, link);
+ for (j = 0; j < HV_MAX_MULTIPAGE_BUFFER_COUNT; j++){
+ if (NULL !=
+ (void*)sgl_node->sgl_data->sg_segs[j].ss_paddr) {
+ free((void*)sgl_node->sgl_data->sg_segs[j].ss_paddr, M_DEVBUF);
+ }
+ }
+ sglist_free(sgl_node->sgl_data);
+ free(sgl_node, M_DEVBUF);
+ }
+
return (0);
}
@@ -939,7 +1252,7 @@ storvsc_timeout_test(struct hv_storvsc_request *reqp,
ticks, __func__, (ret == 0)?
"IO return detected" :
"IO return not detected");
- /*
+ /*
* Now both the timer handler and io done are running
* simultaneously. We want to confirm the io done always
* finishes after the timer handler exits. So reqp used by
@@ -1023,7 +1336,7 @@ storvsc_poll(struct cam_sim *sim)
mtx_assert(&sc->hs_lock, MA_OWNED);
mtx_unlock(&sc->hs_lock);
- hv_storvsc_on_channel_callback(sc->hs_dev);
+ hv_storvsc_on_channel_callback(sc->hs_dev->channel);
mtx_lock(&sc->hs_lock);
}
@@ -1151,12 +1464,16 @@ storvsc_action(struct cam_sim *sim, union ccb *ccb)
bzero(reqp, sizeof(struct hv_storvsc_request));
reqp->softc = sc;
-
- ccb->ccb_h.status |= CAM_SIM_QUEUED;
- create_storvsc_request(ccb, reqp);
+
+ ccb->ccb_h.status |= CAM_SIM_QUEUED;
+ if ((res = create_storvsc_request(ccb, reqp)) != 0) {
+ ccb->ccb_h.status = CAM_REQ_INVALID;
+ xpt_done(ccb);
+ return;
+ }
if (ccb->ccb_h.timeout != CAM_TIME_INFINITY) {
- callout_init(&reqp->callout, CALLOUT_MPSAFE);
+ callout_init(&reqp->callout, 1);
callout_reset_sbt(&reqp->callout,
SBT_1MS * ccb->ccb_h.timeout, 0,
storvsc_timeout, reqp, 0);
@@ -1194,6 +1511,212 @@ storvsc_action(struct cam_sim *sim, union ccb *ccb)
}
/**
+ * @brief destroy bounce buffer
+ *
+ * This function is responsible for destroy a Scatter/Gather list
+ * that create by storvsc_create_bounce_buffer()
+ *
+ * @param sgl- the Scatter/Gather need be destroy
+ * @param sg_count- page count of the SG list.
+ *
+ */
+static void
+storvsc_destroy_bounce_buffer(struct sglist *sgl)
+{
+ struct hv_sgl_node *sgl_node = NULL;
+
+ sgl_node = LIST_FIRST(&g_hv_sgl_page_pool.in_use_sgl_list);
+ LIST_REMOVE(sgl_node, link);
+ if (NULL == sgl_node) {
+ printf("storvsc error: not enough in use sgl\n");
+ return;
+ }
+ sgl_node->sgl_data = sgl;
+ LIST_INSERT_HEAD(&g_hv_sgl_page_pool.free_sgl_list, sgl_node, link);
+}
+
+/**
+ * @brief create bounce buffer
+ *
+ * This function is responsible for create a Scatter/Gather list,
+ * which hold several pages that can be aligned with page size.
+ *
+ * @param seg_count- SG-list segments count
+ * @param write - if WRITE_TYPE, set SG list page used size to 0,
+ * otherwise set used size to page size.
+ *
+ * return NULL if create failed
+ */
+static struct sglist *
+storvsc_create_bounce_buffer(uint16_t seg_count, int write)
+{
+ int i = 0;
+ struct sglist *bounce_sgl = NULL;
+ unsigned int buf_len = ((write == WRITE_TYPE) ? 0 : PAGE_SIZE);
+ struct hv_sgl_node *sgl_node = NULL;
+
+ /* get struct sglist from free_sgl_list */
+ sgl_node = LIST_FIRST(&g_hv_sgl_page_pool.free_sgl_list);
+ LIST_REMOVE(sgl_node, link);
+ if (NULL == sgl_node) {
+ printf("storvsc error: not enough free sgl\n");
+ return NULL;
+ }
+ bounce_sgl = sgl_node->sgl_data;
+ LIST_INSERT_HEAD(&g_hv_sgl_page_pool.in_use_sgl_list, sgl_node, link);
+
+ bounce_sgl->sg_maxseg = seg_count;
+
+ if (write == WRITE_TYPE)
+ bounce_sgl->sg_nseg = 0;
+ else
+ bounce_sgl->sg_nseg = seg_count;
+
+ for (i = 0; i < seg_count; i++)
+ bounce_sgl->sg_segs[i].ss_len = buf_len;
+
+ return bounce_sgl;
+}
+
+/**
+ * @brief copy data from SG list to bounce buffer
+ *
+ * This function is responsible for copy data from one SG list's segments
+ * to another SG list which used as bounce buffer.
+ *
+ * @param bounce_sgl - the destination SG list
+ * @param orig_sgl - the segment of the source SG list.
+ * @param orig_sgl_count - the count of segments.
+ * @param orig_sgl_count - indicate which segment need bounce buffer,
+ * set 1 means need.
+ *
+ */
+static void
+storvsc_copy_sgl_to_bounce_buf(struct sglist *bounce_sgl,
+ bus_dma_segment_t *orig_sgl,
+ unsigned int orig_sgl_count,
+ uint64_t seg_bits)
+{
+ int src_sgl_idx = 0;
+
+ for (src_sgl_idx = 0; src_sgl_idx < orig_sgl_count; src_sgl_idx++) {
+ if (seg_bits & (1 << src_sgl_idx)) {
+ memcpy((void*)bounce_sgl->sg_segs[src_sgl_idx].ss_paddr,
+ (void*)orig_sgl[src_sgl_idx].ds_addr,
+ orig_sgl[src_sgl_idx].ds_len);
+
+ bounce_sgl->sg_segs[src_sgl_idx].ss_len =
+ orig_sgl[src_sgl_idx].ds_len;
+ }
+ }
+}
+
+/**
+ * @brief copy data from SG list which used as bounce to another SG list
+ *
+ * This function is responsible for copy data from one SG list with bounce
+ * buffer to another SG list's segments.
+ *
+ * @param dest_sgl - the destination SG list's segments
+ * @param dest_sgl_count - the count of destination SG list's segment.
+ * @param src_sgl - the source SG list.
+ * @param seg_bits - indicate which segment used bounce buffer of src SG-list.
+ *
+ */
+void
+storvsc_copy_from_bounce_buf_to_sgl(bus_dma_segment_t *dest_sgl,
+ unsigned int dest_sgl_count,
+ struct sglist* src_sgl,
+ uint64_t seg_bits)
+{
+ int sgl_idx = 0;
+
+ for (sgl_idx = 0; sgl_idx < dest_sgl_count; sgl_idx++) {
+ if (seg_bits & (1 << sgl_idx)) {
+ memcpy((void*)(dest_sgl[sgl_idx].ds_addr),
+ (void*)(src_sgl->sg_segs[sgl_idx].ss_paddr),
+ src_sgl->sg_segs[sgl_idx].ss_len);
+ }
+ }
+}
+
+/**
+ * @brief check SG list with bounce buffer or not
+ *
+ * This function is responsible for check if need bounce buffer for SG list.
+ *
+ * @param sgl - the SG list's segments
+ * @param sg_count - the count of SG list's segment.
+ * @param bits - segmengs number that need bounce buffer
+ *
+ * return -1 if SG list needless bounce buffer
+ */
+static int
+storvsc_check_bounce_buffer_sgl(bus_dma_segment_t *sgl,
+ unsigned int sg_count,
+ uint64_t *bits)
+{
+ int i = 0;
+ int offset = 0;
+ uint64_t phys_addr = 0;
+ uint64_t tmp_bits = 0;
+ boolean_t found_hole = FALSE;
+ boolean_t pre_aligned = TRUE;
+
+ if (sg_count < 2){
+ return -1;
+ }
+
+ *bits = 0;
+
+ phys_addr = vtophys(sgl[0].ds_addr);
+ offset = phys_addr - trunc_page(phys_addr);
+
+ if (offset != 0) {
+ pre_aligned = FALSE;
+ tmp_bits |= 1;
+ }
+
+ for (i = 1; i < sg_count; i++) {
+ phys_addr = vtophys(sgl[i].ds_addr);
+ offset = phys_addr - trunc_page(phys_addr);
+
+ if (offset == 0) {
+ if (FALSE == pre_aligned){
+ /*
+ * This segment is aligned, if the previous
+ * one is not aligned, find a hole
+ */
+ found_hole = TRUE;
+ }
+ pre_aligned = TRUE;
+ } else {
+ tmp_bits |= 1 << i;
+ if (!pre_aligned) {
+ if (phys_addr != vtophys(sgl[i-1].ds_addr +
+ sgl[i-1].ds_len)) {
+ /*
+ * Check whether connect to previous
+ * segment,if not, find the hole
+ */
+ found_hole = TRUE;
+ }
+ } else {
+ found_hole = TRUE;
+ }
+ pre_aligned = FALSE;
+ }
+ }
+
+ if (!found_hole) {
+ return (-1);
+ } else {
+ *bits = tmp_bits;
+ return 0;
+ }
+}
+
+/**
* @brief Fill in a request structure based on a CAM control block
*
* Fills in a request structure based on the contents of a CAM control
@@ -1203,7 +1726,7 @@ storvsc_action(struct cam_sim *sim, union ccb *ccb)
* @param ccb pointer to a CAM contorl block
* @param reqp pointer to a request structure
*/
-static void
+static int
create_storvsc_request(union ccb *ccb, struct hv_storvsc_request *reqp)
{
struct ccb_scsiio *csio = &ccb->csio;
@@ -1211,6 +1734,7 @@ create_storvsc_request(union ccb *ccb, struct hv_storvsc_request *reqp)
uint32_t bytes_to_copy = 0;
uint32_t pfn_num = 0;
uint32_t pfn;
+ uint64_t not_aligned_seg_bits = 0;
/* refer to struct vmscsi_req for meanings of these two fields */
reqp->vstor_packet.u.vm_srb.port =
@@ -1231,48 +1755,172 @@ create_storvsc_request(union ccb *ccb, struct hv_storvsc_request *reqp)
}
switch (ccb->ccb_h.flags & CAM_DIR_MASK) {
- case CAM_DIR_OUT:
- reqp->vstor_packet.u.vm_srb.data_in = WRITE_TYPE;
- break;
- case CAM_DIR_IN:
- reqp->vstor_packet.u.vm_srb.data_in = READ_TYPE;
- break;
- case CAM_DIR_NONE:
- reqp->vstor_packet.u.vm_srb.data_in = UNKNOWN_TYPE;
- break;
- default:
- reqp->vstor_packet.u.vm_srb.data_in = UNKNOWN_TYPE;
- break;
+ case CAM_DIR_OUT:
+ reqp->vstor_packet.u.vm_srb.data_in = WRITE_TYPE;
+ break;
+ case CAM_DIR_IN:
+ reqp->vstor_packet.u.vm_srb.data_in = READ_TYPE;
+ break;
+ case CAM_DIR_NONE:
+ reqp->vstor_packet.u.vm_srb.data_in = UNKNOWN_TYPE;
+ break;
+ default:
+ reqp->vstor_packet.u.vm_srb.data_in = UNKNOWN_TYPE;
+ break;
}
reqp->sense_data = &csio->sense_data;
reqp->sense_info_len = csio->sense_len;
reqp->ccb = ccb;
- /*
- KASSERT((ccb->ccb_h.flags & CAM_SCATTER_VALID) == 0,
- ("ccb is scatter gather valid\n"));
- */
- if (csio->dxfer_len != 0) {
- reqp->data_buf.length = csio->dxfer_len;
+
+ if (0 == csio->dxfer_len) {
+ return (0);
+ }
+
+ reqp->data_buf.length = csio->dxfer_len;
+
+ switch (ccb->ccb_h.flags & CAM_DATA_MASK) {
+ case CAM_DATA_VADDR:
+ {
bytes_to_copy = csio->dxfer_len;
phys_addr = vtophys(csio->data_ptr);
- reqp->data_buf.offset = phys_addr - trunc_page(phys_addr);
+ reqp->data_buf.offset = phys_addr & PAGE_MASK;
+
+ while (bytes_to_copy != 0) {
+ int bytes, page_offset;
+ phys_addr =
+ vtophys(&csio->data_ptr[reqp->data_buf.length -
+ bytes_to_copy]);
+ pfn = phys_addr >> PAGE_SHIFT;
+ reqp->data_buf.pfn_array[pfn_num] = pfn;
+ page_offset = phys_addr & PAGE_MASK;
+
+ bytes = min(PAGE_SIZE - page_offset, bytes_to_copy);
+
+ bytes_to_copy -= bytes;
+ pfn_num++;
+ }
+ break;
}
- while (bytes_to_copy != 0) {
- int bytes, page_offset;
- phys_addr = vtophys(&csio->data_ptr[reqp->data_buf.length -
- bytes_to_copy]);
- pfn = phys_addr >> PAGE_SHIFT;
- reqp->data_buf.pfn_array[pfn_num] = pfn;
- page_offset = phys_addr - trunc_page(phys_addr);
+ case CAM_DATA_SG:
+ {
+ int i = 0;
+ int offset = 0;
+ int ret;
- bytes = min(PAGE_SIZE - page_offset, bytes_to_copy);
+ bus_dma_segment_t *storvsc_sglist =
+ (bus_dma_segment_t *)ccb->csio.data_ptr;
+ u_int16_t storvsc_sg_count = ccb->csio.sglist_cnt;
- bytes_to_copy -= bytes;
- pfn_num++;
+ printf("Storvsc: get SG I/O operation, %d\n",
+ reqp->vstor_packet.u.vm_srb.data_in);
+
+ if (storvsc_sg_count > HV_MAX_MULTIPAGE_BUFFER_COUNT){
+ printf("Storvsc: %d segments is too much, "
+ "only support %d segments\n",
+ storvsc_sg_count, HV_MAX_MULTIPAGE_BUFFER_COUNT);
+ return (EINVAL);
+ }
+
+ /*
+ * We create our own bounce buffer function currently. Idealy
+ * we should use BUS_DMA(9) framework. But with current BUS_DMA
+ * code there is no callback API to check the page alignment of
+ * middle segments before busdma can decide if a bounce buffer
+ * is needed for particular segment. There is callback,
+ * "bus_dma_filter_t *filter", but the parrameters are not
+ * sufficient for storvsc driver.
+ * TODO:
+ * Add page alignment check in BUS_DMA(9) callback. Once
+ * this is complete, switch the following code to use
+ * BUS_DMA(9) for storvsc bounce buffer support.
+ */
+ /* check if we need to create bounce buffer */
+ ret = storvsc_check_bounce_buffer_sgl(storvsc_sglist,
+ storvsc_sg_count, &not_aligned_seg_bits);
+ if (ret != -1) {
+ reqp->bounce_sgl =
+ storvsc_create_bounce_buffer(storvsc_sg_count,
+ reqp->vstor_packet.u.vm_srb.data_in);
+ if (NULL == reqp->bounce_sgl) {
+ printf("Storvsc_error: "
+ "create bounce buffer failed.\n");
+ return (ENOMEM);
+ }
+
+ reqp->bounce_sgl_count = storvsc_sg_count;
+ reqp->not_aligned_seg_bits = not_aligned_seg_bits;
+
+ /*
+ * if it is write, we need copy the original data
+ *to bounce buffer
+ */
+ if (WRITE_TYPE == reqp->vstor_packet.u.vm_srb.data_in) {
+ storvsc_copy_sgl_to_bounce_buf(
+ reqp->bounce_sgl,
+ storvsc_sglist,
+ storvsc_sg_count,
+ reqp->not_aligned_seg_bits);
+ }
+
+ /* transfer virtual address to physical frame number */
+ if (reqp->not_aligned_seg_bits & 0x1){
+ phys_addr =
+ vtophys(reqp->bounce_sgl->sg_segs[0].ss_paddr);
+ }else{
+ phys_addr =
+ vtophys(storvsc_sglist[0].ds_addr);
+ }
+ reqp->data_buf.offset = phys_addr & PAGE_MASK;
+
+ pfn = phys_addr >> PAGE_SHIFT;
+ reqp->data_buf.pfn_array[0] = pfn;
+
+ for (i = 1; i < storvsc_sg_count; i++) {
+ if (reqp->not_aligned_seg_bits & (1 << i)) {
+ phys_addr =
+ vtophys(reqp->bounce_sgl->sg_segs[i].ss_paddr);
+ } else {
+ phys_addr =
+ vtophys(storvsc_sglist[i].ds_addr);
+ }
+
+ pfn = phys_addr >> PAGE_SHIFT;
+ reqp->data_buf.pfn_array[i] = pfn;
+ }
+ } else {
+ phys_addr = vtophys(storvsc_sglist[0].ds_addr);
+
+ reqp->data_buf.offset = phys_addr & PAGE_MASK;
+
+ for (i = 0; i < storvsc_sg_count; i++) {
+ phys_addr = vtophys(storvsc_sglist[i].ds_addr);
+ pfn = phys_addr >> PAGE_SHIFT;
+ reqp->data_buf.pfn_array[i] = pfn;
+ }
+
+ /* check the last segment cross boundary or not */
+ offset = phys_addr & PAGE_MASK;
+ if (offset) {
+ phys_addr =
+ vtophys(storvsc_sglist[i-1].ds_addr +
+ PAGE_SIZE - offset);
+ pfn = phys_addr >> PAGE_SHIFT;
+ reqp->data_buf.pfn_array[i] = pfn;
+ }
+
+ reqp->bounce_sgl_count = 0;
+ }
+ break;
}
+ default:
+ printf("Unknow flags: %d\n", ccb->ccb_h.flags);
+ return(EINVAL);
+ }
+
+ return(0);
}
/**
@@ -1291,7 +1939,29 @@ storvsc_io_done(struct hv_storvsc_request *reqp)
struct ccb_scsiio *csio = &ccb->csio;
struct storvsc_softc *sc = reqp->softc;
struct vmscsi_req *vm_srb = &reqp->vstor_packet.u.vm_srb;
-
+ bus_dma_segment_t *ori_sglist = NULL;
+ int ori_sg_count = 0;
+
+ /* destroy bounce buffer if it is used */
+ if (reqp->bounce_sgl_count) {
+ ori_sglist = (bus_dma_segment_t *)ccb->csio.data_ptr;
+ ori_sg_count = ccb->csio.sglist_cnt;
+
+ /*
+ * If it is READ operation, we should copy back the data
+ * to original SG list.
+ */
+ if (READ_TYPE == reqp->vstor_packet.u.vm_srb.data_in) {
+ storvsc_copy_from_bounce_buf_to_sgl(ori_sglist,
+ ori_sg_count,
+ reqp->bounce_sgl,
+ reqp->not_aligned_seg_bits);
+ }
+
+ storvsc_destroy_bounce_buffer(reqp->bounce_sgl);
+ reqp->bounce_sgl_count = 0;
+ }
+
if (reqp->retries > 0) {
mtx_lock(&sc->hs_lock);
#if HVS_TIMEOUT_TEST
@@ -1309,7 +1979,7 @@ storvsc_io_done(struct hv_storvsc_request *reqp)
mtx_unlock(&sc->hs_lock);
}
- /*
+ /*
* callout_drain() will wait for the timer handler to finish
* if it is running. So we don't need any lock to synchronize
* between this routine and the timer handler.
diff --git a/sys/dev/hyperv/storvsc/hv_vstorage.h b/sys/dev/hyperv/storvsc/hv_vstorage.h
index 2632676..026189c 100644
--- a/sys/dev/hyperv/storvsc/hv_vstorage.h
+++ b/sys/dev/hyperv/storvsc/hv_vstorage.h
@@ -51,9 +51,11 @@
* V1 Beta 0.1
* V1 RC < 2008/1/31 1.0
* V1 RC > 2008/1/31 2.0
+ * Win7: 4.2
+ * Win8: 5.1
*/
-#define VMSTOR_PROTOCOL_VERSION_CURRENT VMSTOR_PROTOCOL_VERSION(2, 0)
+#define VMSTOR_PROTOCOL_VERSION_CURRENT VMSTOR_PROTOCOL_VERSION(5, 1)
/**
* Packet structure ops describing virtual storage requests.
@@ -69,7 +71,10 @@ enum vstor_packet_ops {
VSTOR_OPERATION_ENDINITIALIZATION = 8,
VSTOR_OPERATION_QUERYPROTOCOLVERSION = 9,
VSTOR_OPERATION_QUERYPROPERTIES = 10,
- VSTOR_OPERATION_MAXIMUM = 10
+ VSTOR_OPERATION_ENUMERATE_BUS = 11,
+ VSTOR_OPERATION_FCHBA_DATA = 12,
+ VSTOR_OPERATION_CREATE_MULTI_CHANNELS = 13,
+ VSTOR_OPERATION_MAXIMUM = 13
};
@@ -80,9 +85,25 @@ enum vstor_packet_ops {
*/
#define CDB16GENERIC_LENGTH 0x10
-#define SENSE_BUFFER_SIZE 0x12
+#define SENSE_BUFFER_SIZE 0x14
#define MAX_DATA_BUFFER_LENGTH_WITH_PADDING 0x14
+#define POST_WIN7_STORVSC_SENSE_BUFFER_SIZE 0x14
+#define PRE_WIN8_STORVSC_SENSE_BUFFER_SIZE 0x12
+
+
+struct vmscsi_win8_extension {
+ /*
+ * The following were added in Windows 8
+ */
+ uint16_t reserve;
+ uint8_t queue_tag;
+ uint8_t queue_action;
+ uint32_t srb_flags;
+ uint32_t time_out_value;
+ uint32_t queue_sort_ey;
+} __packed;
+
struct vmscsi_req {
uint16_t length;
uint8_t srb_status;
@@ -111,6 +132,11 @@ struct vmscsi_req {
uint8_t reserved_array[MAX_DATA_BUFFER_LENGTH_WITH_PADDING];
} u;
+ /*
+ * The following was added in win8.
+ */
+ struct vmscsi_win8_extension win8_extension;
+
} __packed;
/**
@@ -123,10 +149,12 @@ struct vmstor_chan_props {
uint8_t path_id;
uint8_t target_id;
+ uint16_t max_channel_cnt;
+
/**
* Note: port number is only really known on the client side
*/
- uint32_t port;
+ uint16_t port;
uint32_t flags;
uint32_t max_transfer_bytes;
@@ -193,6 +221,11 @@ struct vstor_packet {
* Used during version negotiations.
*/
struct vmstor_proto_ver version;
+
+ /**
+ * Number of multichannels to create
+ */
+ uint16_t multi_channels_cnt;
} u;
} __packed;
diff --git a/sys/dev/hyperv/utilities/hv_kvp.c b/sys/dev/hyperv/utilities/hv_kvp.c
index 848d364..4598510 100644
--- a/sys/dev/hyperv/utilities/hv_kvp.c
+++ b/sys/dev/hyperv/utilities/hv_kvp.c
@@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
#include <sys/_null.h>
#include <sys/signal.h>
#include <sys/syslog.h>
+#include <sys/systm.h>
#include <sys/mutex.h>
#include <net/if_arp.h>
@@ -232,7 +233,7 @@ hv_kvp_negotiate_version(struct hv_vmbus_icmsg_hdr *icmsghdrp,
*/
if ((icframe_vercnt >= 2) && (negop->icversion_data[1].major == 3)) {
icframe_vercnt = 3;
- if (icmsg_vercnt >= 2)
+ if (icmsg_vercnt > 2)
icmsg_vercnt = 4;
else
icmsg_vercnt = 3;
@@ -734,8 +735,8 @@ hv_kvp_process_request(void *context)
recvlen = 0;
ret = hv_vmbus_channel_recv_packet(channel, kvp_buf, 2 * PAGE_SIZE,
&recvlen, &requestid);
- hv_kvp_log_info("%s: read: context %p, pending_cnt %ju ret =%d, recvlen=%d\n",
- __func__, context, pending_cnt, ret, recvlen);
+ hv_kvp_log_info("%s: read: context %p, pending_cnt %llu ret =%d, recvlen=%d\n",
+ __func__, context, (unsigned long long)pending_cnt, ret, recvlen);
}
}
@@ -813,9 +814,9 @@ static void
hv_kvp_dev_destroy(void)
{
- if (daemon_task != NULL) {
+ if (daemon_task != NULL) {
PROC_LOCK(daemon_task);
- kern_psignal(daemon_task, SIGKILL);
+ kern_psignal(daemon_task, SIGKILL);
PROC_UNLOCK(daemon_task);
}
diff --git a/sys/dev/hyperv/utilities/hv_util.c b/sys/dev/hyperv/utilities/hv_util.c
index 3e545cf..dc4b1e2 100644
--- a/sys/dev/hyperv/utilities/hv_util.c
+++ b/sys/dev/hyperv/utilities/hv_util.c
@@ -408,6 +408,15 @@ hv_util_attach(device_t dev)
}
}
+ /*
+ * These services are not performance critical and do not need
+ * batched reading. Furthermore, some services such as KVP can
+ * only handle one message from the host at a time.
+ * Turn off batched reading for all util drivers before we open the
+ * channel.
+ */
+ hv_set_channel_read_state(hv_dev->channel, FALSE);
+
ret = hv_vmbus_channel_open(hv_dev->channel, 4 * PAGE_SIZE,
4 * PAGE_SIZE, NULL, 0,
service->callback, hv_dev->channel);
diff --git a/sys/dev/hyperv/vmbus/hv_channel.c b/sys/dev/hyperv/vmbus/hv_channel.c
index 103260a..94137fb 100644
--- a/sys/dev/hyperv/vmbus/hv_channel.c
+++ b/sys/dev/hyperv/vmbus/hv_channel.c
@@ -75,7 +75,7 @@ vmbus_channel_set_event(hv_vmbus_channel *channel)
(uint32_t *)&monitor_page->
trigger_group[channel->monitor_group].u.pending);
} else {
- hv_vmbus_set_event(channel->offer_msg.child_rel_id);
+ hv_vmbus_set_event(channel);
}
}
@@ -99,6 +99,18 @@ hv_vmbus_channel_open(
hv_vmbus_channel_open_channel* open_msg;
hv_vmbus_channel_msg_info* open_info;
+ mtx_lock(&new_channel->sc_lock);
+ if (new_channel->state == HV_CHANNEL_OPEN_STATE) {
+ new_channel->state = HV_CHANNEL_OPENING_STATE;
+ } else {
+ mtx_unlock(&new_channel->sc_lock);
+ if(bootverbose)
+ printf("VMBUS: Trying to open channel <%p> which in "
+ "%d state.\n", new_channel, new_channel->state);
+ return (EINVAL);
+ }
+ mtx_unlock(&new_channel->sc_lock);
+
new_channel->on_channel_callback = pfn_on_channel_callback;
new_channel->channel_callback_context = context;
@@ -162,7 +174,7 @@ hv_vmbus_channel_open(
new_channel->ring_buffer_gpadl_handle;
open_msg->downstream_ring_buffer_page_offset = send_ring_buffer_size
>> PAGE_SHIFT;
- open_msg->server_context_area_gpadl_handle = 0;
+ open_msg->target_vcpu = new_channel->target_vcpu;
if (user_data_len)
memcpy(open_msg->user_data, user_data, user_data_len);
@@ -182,10 +194,14 @@ hv_vmbus_channel_open(
ret = sema_timedwait(&open_info->wait_sema, 500); /* KYS 5 seconds */
- if (ret)
+ if (ret) {
+ if(bootverbose)
+ printf("VMBUS: channel <%p> open timeout.\n", new_channel);
goto cleanup;
+ }
if (open_info->response.open_result.status == 0) {
+ new_channel->state = HV_CHANNEL_OPENED_STATE;
if(bootverbose)
printf("VMBUS: channel <%p> open success.\n", new_channel);
} else {
@@ -497,16 +513,20 @@ cleanup:
return (ret);
}
-/**
- * @brief Close the specified channel
- */
-void
-hv_vmbus_channel_close(hv_vmbus_channel *channel)
+static void
+hv_vmbus_channel_close_internal(hv_vmbus_channel *channel)
{
int ret = 0;
hv_vmbus_channel_close_channel* msg;
hv_vmbus_channel_msg_info* info;
+ channel->state = HV_CHANNEL_OPEN_STATE;
+ channel->sc_creation_callback = NULL;
+
+ /*
+ * Grab the lock to prevent race condition when a packet received
+ * and unloading driver is in the process.
+ */
mtx_lock(&channel->inbound_lock);
channel->on_channel_callback = NULL;
mtx_unlock(&channel->inbound_lock);
@@ -545,23 +565,37 @@ hv_vmbus_channel_close(hv_vmbus_channel *channel)
M_DEVBUF);
free(info, M_DEVBUF);
+}
+
+/**
+ * @brief Close the specified channel
+ */
+void
+hv_vmbus_channel_close(hv_vmbus_channel *channel)
+{
+ hv_vmbus_channel* sub_channel;
+
+ if (channel->primary_channel != NULL) {
+ /*
+ * We only close multi-channels when the primary is
+ * closed.
+ */
+ return;
+ }
/*
- * If we are closing the channel during an error path in
- * opening the channel, don't free the channel
- * since the caller will free the channel
+ * Close all multi-channels first.
*/
- if (channel->state == HV_CHANNEL_OPEN_STATE) {
- mtx_lock_spin(&hv_vmbus_g_connection.channel_lock);
- TAILQ_REMOVE(
- &hv_vmbus_g_connection.channel_anchor,
- channel,
- list_entry);
- mtx_unlock_spin(&hv_vmbus_g_connection.channel_lock);
-
- hv_vmbus_free_vmbus_channel(channel);
+ TAILQ_FOREACH(sub_channel, &channel->sc_list_anchor,
+ sc_list_entry) {
+ if (sub_channel->state != HV_CHANNEL_OPENED_STATE)
+ continue;
+ hv_vmbus_channel_close_internal(sub_channel);
}
-
+ /*
+ * Then close the primary channel.
+ */
+ hv_vmbus_channel_close_internal(channel);
}
/**
@@ -581,6 +615,7 @@ hv_vmbus_channel_send_packet(
uint32_t packet_len;
uint64_t aligned_data;
uint32_t packet_len_aligned;
+ boolean_t need_sig;
hv_vmbus_sg_buffer_list buffer_list[3];
packet_len = sizeof(hv_vm_packet_descriptor) + buffer_len;
@@ -604,12 +639,11 @@ hv_vmbus_channel_send_packet(
buffer_list[2].data = &aligned_data;
buffer_list[2].length = packet_len_aligned - packet_len;
- ret = hv_ring_buffer_write(&channel->outbound, buffer_list, 3);
+ ret = hv_ring_buffer_write(&channel->outbound, buffer_list, 3,
+ &need_sig);
/* TODO: We should determine if this is optional */
- if (ret == 0
- && !hv_vmbus_get_ring_buffer_interrupt_mask(
- &channel->outbound)) {
+ if (ret == 0 && need_sig) {
vmbus_channel_set_event(channel);
}
@@ -632,6 +666,7 @@ hv_vmbus_channel_send_packet_pagebuffer(
int ret = 0;
int i = 0;
+ boolean_t need_sig;
uint32_t packet_len;
uint32_t packetLen_aligned;
hv_vmbus_sg_buffer_list buffer_list[3];
@@ -675,11 +710,11 @@ hv_vmbus_channel_send_packet_pagebuffer(
buffer_list[2].data = &alignedData;
buffer_list[2].length = packetLen_aligned - packet_len;
- ret = hv_ring_buffer_write(&channel->outbound, buffer_list, 3);
+ ret = hv_ring_buffer_write(&channel->outbound, buffer_list, 3,
+ &need_sig);
/* TODO: We should determine if this is optional */
- if (ret == 0 &&
- !hv_vmbus_get_ring_buffer_interrupt_mask(&channel->outbound)) {
+ if (ret == 0 && need_sig) {
vmbus_channel_set_event(channel);
}
@@ -700,6 +735,7 @@ hv_vmbus_channel_send_packet_multipagebuffer(
int ret = 0;
uint32_t desc_size;
+ boolean_t need_sig;
uint32_t packet_len;
uint32_t packet_len_aligned;
uint32_t pfn_count;
@@ -750,11 +786,11 @@ hv_vmbus_channel_send_packet_multipagebuffer(
buffer_list[2].data = &aligned_data;
buffer_list[2].length = packet_len_aligned - packet_len;
- ret = hv_ring_buffer_write(&channel->outbound, buffer_list, 3);
+ ret = hv_ring_buffer_write(&channel->outbound, buffer_list, 3,
+ &need_sig);
/* TODO: We should determine if this is optional */
- if (ret == 0 &&
- !hv_vmbus_get_ring_buffer_interrupt_mask(&channel->outbound)) {
+ if (ret == 0 && need_sig) {
vmbus_channel_set_event(channel);
}
diff --git a/sys/dev/hyperv/vmbus/hv_channel_mgmt.c b/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
index 011e305..783f6bc 100644
--- a/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
+++ b/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
@@ -50,6 +50,8 @@ static void vmbus_channel_on_gpadl_torndown(hv_vmbus_channel_msg_header* hdr);
static void vmbus_channel_on_offers_delivered(hv_vmbus_channel_msg_header* hdr);
static void vmbus_channel_on_version_response(hv_vmbus_channel_msg_header* hdr);
static void vmbus_channel_process_offer(void *context);
+struct hv_vmbus_channel*
+ vmbus_select_outgoing_channel(struct hv_vmbus_channel *promary);
/**
* Channel message dispatch table
@@ -233,6 +235,9 @@ hv_vmbus_allocate_channel(void)
return (NULL);
mtx_init(&channel->inbound_lock, "channel inbound", NULL, MTX_DEF);
+ mtx_init(&channel->sc_lock, "vmbus multi channel", NULL, MTX_DEF);
+
+ TAILQ_INIT(&channel->sc_list_anchor);
channel->control_work_queue = hv_work_queue_create("control");
@@ -262,6 +267,7 @@ ReleaseVmbusChannel(void *context)
void
hv_vmbus_free_vmbus_channel(hv_vmbus_channel* channel)
{
+ mtx_destroy(&channel->sc_lock);
mtx_destroy(&channel->inbound_lock);
/*
* We have to release the channel's workqueue/thread in
@@ -279,10 +285,10 @@ hv_vmbus_free_vmbus_channel(hv_vmbus_channel* channel)
static void
vmbus_channel_process_offer(void *context)
{
- int ret;
hv_vmbus_channel* new_channel;
boolean_t f_new;
hv_vmbus_channel* channel;
+ int ret;
new_channel = (hv_vmbus_channel*) context;
f_new = TRUE;
@@ -291,38 +297,76 @@ vmbus_channel_process_offer(void *context)
/*
* Make sure this is a new offer
*/
- mtx_lock_spin(&hv_vmbus_g_connection.channel_lock);
+ mtx_lock(&hv_vmbus_g_connection.channel_lock);
TAILQ_FOREACH(channel, &hv_vmbus_g_connection.channel_anchor,
list_entry)
{
- if (!memcmp(
- &channel->offer_msg.offer.interface_type,
- &new_channel->offer_msg.offer.interface_type,
- sizeof(hv_guid))
- && !memcmp(
- &channel->offer_msg.offer.interface_instance,
+ if (memcmp(&channel->offer_msg.offer.interface_type,
+ &new_channel->offer_msg.offer.interface_type,
+ sizeof(hv_guid)) == 0 &&
+ memcmp(&channel->offer_msg.offer.interface_instance,
&new_channel->offer_msg.offer.interface_instance,
- sizeof(hv_guid))) {
- f_new = FALSE;
- break;
- }
+ sizeof(hv_guid)) == 0) {
+ f_new = FALSE;
+ break;
+ }
}
if (f_new) {
- /* Insert at tail */
- TAILQ_INSERT_TAIL(
- &hv_vmbus_g_connection.channel_anchor,
- new_channel,
- list_entry);
+ /* Insert at tail */
+ TAILQ_INSERT_TAIL(
+ &hv_vmbus_g_connection.channel_anchor,
+ new_channel,
+ list_entry);
}
- mtx_unlock_spin(&hv_vmbus_g_connection.channel_lock);
+ mtx_unlock(&hv_vmbus_g_connection.channel_lock);
+
+ /*XXX add new channel to percpu_list */
if (!f_new) {
+ /*
+ * Check if this is a sub channel.
+ */
+ if (new_channel->offer_msg.offer.sub_channel_index != 0) {
+ /*
+ * It is a sub channel offer, process it.
+ */
+ new_channel->primary_channel = channel;
+ mtx_lock(&channel->sc_lock);
+ TAILQ_INSERT_TAIL(
+ &channel->sc_list_anchor,
+ new_channel,
+ sc_list_entry);
+ mtx_unlock(&channel->sc_lock);
+
+ /* Insert new channel into channel_anchor. */
+ printf("Storvsc get multi-channel offer, rel=%u.\n",
+ new_channel->offer_msg.child_rel_id);
+ mtx_lock(&hv_vmbus_g_connection.channel_lock);
+ TAILQ_INSERT_TAIL(&hv_vmbus_g_connection.channel_anchor,
+ new_channel, list_entry);
+ mtx_unlock(&hv_vmbus_g_connection.channel_lock);
+
+ if(bootverbose)
+ printf("VMBUS: new multi-channel offer <%p>.\n",
+ new_channel);
+
+ /*XXX add it to percpu_list */
+
+ new_channel->state = HV_CHANNEL_OPEN_STATE;
+ if (channel->sc_creation_callback != NULL) {
+ channel->sc_creation_callback(new_channel);
+ }
+ return;
+ }
+
hv_vmbus_free_vmbus_channel(new_channel);
return;
}
+ new_channel->state = HV_CHANNEL_OPEN_STATE;
+
/*
* Start the process of binding this offer to the driver
* (We need to set the device field before calling
@@ -333,35 +377,86 @@ vmbus_channel_process_offer(void *context)
new_channel->offer_msg.offer.interface_instance, new_channel);
/*
- * TODO - the HV_CHANNEL_OPEN_STATE flag should not be set below
- * but in the "open" channel request. The ret != 0 logic below
- * doesn't take into account that a channel
- * may have been opened successfully
- */
-
- /*
* Add the new device to the bus. This will kick off device-driver
* binding which eventually invokes the device driver's AddDevice()
* method.
*/
ret = hv_vmbus_child_device_register(new_channel->device);
if (ret != 0) {
- mtx_lock_spin(&hv_vmbus_g_connection.channel_lock);
- TAILQ_REMOVE(
- &hv_vmbus_g_connection.channel_anchor,
- new_channel,
- list_entry);
- mtx_unlock_spin(&hv_vmbus_g_connection.channel_lock);
- hv_vmbus_free_vmbus_channel(new_channel);
- } else {
- /*
- * This state is used to indicate a successful open
- * so that when we do close the channel normally,
- * we can clean up properly
- */
- new_channel->state = HV_CHANNEL_OPEN_STATE;
+ mtx_lock(&hv_vmbus_g_connection.channel_lock);
+ TAILQ_REMOVE(
+ &hv_vmbus_g_connection.channel_anchor,
+ new_channel,
+ list_entry);
+ mtx_unlock(&hv_vmbus_g_connection.channel_lock);
+ hv_vmbus_free_vmbus_channel(new_channel);
+ }
+}
+
+/**
+ * Array of device guids that are performance critical. We try to distribute
+ * the interrupt load for these devices across all online cpus.
+ */
+static const hv_guid high_perf_devices[] = {
+ {HV_NIC_GUID, },
+ {HV_IDE_GUID, },
+ {HV_SCSI_GUID, },
+};
+
+enum {
+ PERF_CHN_NIC = 0,
+ PERF_CHN_IDE,
+ PERF_CHN_SCSI,
+ MAX_PERF_CHN,
+};
+/*
+ * We use this static number to distribute the channel interrupt load.
+ */
+static uint32_t next_vcpu;
+
+/**
+ * Starting with Win8, we can statically distribute the incoming
+ * channel interrupt load by binding a channel to VCPU. We
+ * implement here a simple round robin scheme for distributing
+ * the interrupt load.
+ * We will bind channels that are not performance critical to cpu 0 and
+ * performance critical channels (IDE, SCSI and Network) will be uniformly
+ * distributed across all available CPUs.
+ */
+static void
+vmbus_channel_select_cpu(hv_vmbus_channel *channel, hv_guid *guid)
+{
+ uint32_t current_cpu;
+ int i;
+ boolean_t is_perf_channel = FALSE;
+
+ for (i = PERF_CHN_NIC; i < MAX_PERF_CHN; i++) {
+ if (memcmp(guid->data, high_perf_devices[i].data,
+ sizeof(hv_guid)) == 0) {
+ is_perf_channel = TRUE;
+ break;
+ }
+ }
+
+ if ((hv_vmbus_protocal_version == HV_VMBUS_VERSION_WS2008) ||
+ (hv_vmbus_protocal_version == HV_VMBUS_VERSION_WIN7) ||
+ (!is_perf_channel)) {
+ /* Host's view of guest cpu */
+ channel->target_vcpu = 0;
+ /* Guest's own view of cpu */
+ channel->target_cpu = 0;
+ return;
}
+ /* mp_ncpus should have the number cpus currently online */
+ current_cpu = (++next_vcpu % mp_ncpus);
+ channel->target_cpu = current_cpu;
+ channel->target_vcpu =
+ hv_vmbus_g_context.hv_vcpu_index[current_cpu];
+ if (bootverbose)
+ printf("VMBUS: Total online cpus %d, assign perf channel %d "
+ "to vcpu %d, cpu %d\n", mp_ncpus, i, channel->target_vcpu,
+ current_cpu);
}
/**
@@ -391,6 +486,38 @@ vmbus_channel_on_offer(hv_vmbus_channel_msg_header* hdr)
if (new_channel == NULL)
return;
+ /*
+ * By default we setup state to enable batched
+ * reading. A specific service can choose to
+ * disable this prior to opening the channel.
+ */
+ new_channel->batched_reading = TRUE;
+
+ new_channel->signal_event_param =
+ (hv_vmbus_input_signal_event *)
+ (HV_ALIGN_UP((unsigned long)
+ &new_channel->signal_event_buffer,
+ HV_HYPERCALL_PARAM_ALIGN));
+
+ new_channel->signal_event_param->connection_id.as_uint32_t = 0;
+ new_channel->signal_event_param->connection_id.u.id =
+ HV_VMBUS_EVENT_CONNECTION_ID;
+ new_channel->signal_event_param->flag_number = 0;
+ new_channel->signal_event_param->rsvd_z = 0;
+
+ if (hv_vmbus_protocal_version != HV_VMBUS_VERSION_WS2008) {
+ new_channel->is_dedicated_interrupt =
+ (offer->is_dedicated_interrupt != 0);
+ new_channel->signal_event_param->connection_id.u.id =
+ offer->connection_id;
+ }
+
+ /*
+ * Bind the channel to a chosen cpu.
+ */
+ vmbus_channel_select_cpu(new_channel,
+ &offer->offer.interface_type);
+
memcpy(&new_channel->offer_msg, offer,
sizeof(hv_vmbus_channel_offer_channel));
new_channel->monitor_group = (uint8_t) offer->monitor_id / 32;
@@ -666,7 +793,7 @@ hv_vmbus_release_unattached_channels(void)
{
hv_vmbus_channel *channel;
- mtx_lock_spin(&hv_vmbus_g_connection.channel_lock);
+ mtx_lock(&hv_vmbus_g_connection.channel_lock);
while (!TAILQ_EMPTY(&hv_vmbus_g_connection.channel_anchor)) {
channel = TAILQ_FIRST(&hv_vmbus_g_connection.channel_anchor);
@@ -676,5 +803,61 @@ hv_vmbus_release_unattached_channels(void)
hv_vmbus_child_device_unregister(channel->device);
hv_vmbus_free_vmbus_channel(channel);
}
- mtx_unlock_spin(&hv_vmbus_g_connection.channel_lock);
+ mtx_unlock(&hv_vmbus_g_connection.channel_lock);
+}
+
+/**
+ * @brief Select the best outgoing channel
+ *
+ * The channel whose vcpu binding is closest to the currect vcpu will
+ * be selected.
+ * If no multi-channel, always select primary channel
+ *
+ * @param primary - primary channel
+ */
+struct hv_vmbus_channel *
+vmbus_select_outgoing_channel(struct hv_vmbus_channel *primary)
+{
+ hv_vmbus_channel *new_channel = NULL;
+ hv_vmbus_channel *outgoing_channel = primary;
+ int old_cpu_distance = 0;
+ int new_cpu_distance = 0;
+ int cur_vcpu = 0;
+ int smp_pro_id = PCPU_GET(cpuid);
+
+ if (TAILQ_EMPTY(&primary->sc_list_anchor)) {
+ return outgoing_channel;
+ }
+
+ if (smp_pro_id >= MAXCPU) {
+ return outgoing_channel;
+ }
+
+ cur_vcpu = hv_vmbus_g_context.hv_vcpu_index[smp_pro_id];
+
+ TAILQ_FOREACH(new_channel, &primary->sc_list_anchor, sc_list_entry) {
+ if (new_channel->state != HV_CHANNEL_OPENED_STATE){
+ continue;
+ }
+
+ if (new_channel->target_vcpu == cur_vcpu){
+ return new_channel;
+ }
+
+ old_cpu_distance = ((outgoing_channel->target_vcpu > cur_vcpu) ?
+ (outgoing_channel->target_vcpu - cur_vcpu) :
+ (cur_vcpu - outgoing_channel->target_vcpu));
+
+ new_cpu_distance = ((new_channel->target_vcpu > cur_vcpu) ?
+ (new_channel->target_vcpu - cur_vcpu) :
+ (cur_vcpu - new_channel->target_vcpu));
+
+ if (old_cpu_distance < new_cpu_distance) {
+ continue;
+ }
+
+ outgoing_channel = new_channel;
+ }
+
+ return(outgoing_channel);
}
diff --git a/sys/dev/hyperv/vmbus/hv_connection.c b/sys/dev/hyperv/vmbus/hv_connection.c
index c8e0b48..0300828 100644
--- a/sys/dev/hyperv/vmbus/hv_connection.c
+++ b/sys/dev/hyperv/vmbus/hv_connection.c
@@ -45,14 +45,113 @@ hv_vmbus_connection hv_vmbus_g_connection =
{ .connect_state = HV_DISCONNECTED,
.next_gpadl_handle = 0xE1E10, };
+uint32_t hv_vmbus_protocal_version = HV_VMBUS_VERSION_WS2008;
+
+static uint32_t
+hv_vmbus_get_next_version(uint32_t current_ver)
+{
+ switch (current_ver) {
+ case (HV_VMBUS_VERSION_WIN7):
+ return(HV_VMBUS_VERSION_WS2008);
+
+ case (HV_VMBUS_VERSION_WIN8):
+ return(HV_VMBUS_VERSION_WIN7);
+
+ case (HV_VMBUS_VERSION_WIN8_1):
+ return(HV_VMBUS_VERSION_WIN8);
+
+ case (HV_VMBUS_VERSION_WS2008):
+ default:
+ return(HV_VMBUS_VERSION_INVALID);
+ }
+}
+
+/**
+ * Negotiate the highest supported hypervisor version.
+ */
+static int
+hv_vmbus_negotiate_version(hv_vmbus_channel_msg_info *msg_info,
+ uint32_t version)
+{
+ int ret = 0;
+ hv_vmbus_channel_initiate_contact *msg;
+
+ sema_init(&msg_info->wait_sema, 0, "Msg Info Sema");
+ msg = (hv_vmbus_channel_initiate_contact*) msg_info->msg;
+
+ msg->header.message_type = HV_CHANNEL_MESSAGE_INITIATED_CONTACT;
+ msg->vmbus_version_requested = version;
+
+ msg->interrupt_page = hv_get_phys_addr(
+ hv_vmbus_g_connection.interrupt_page);
+
+ msg->monitor_page_1 = hv_get_phys_addr(
+ hv_vmbus_g_connection.monitor_pages);
+
+ msg->monitor_page_2 =
+ hv_get_phys_addr(
+ ((uint8_t *) hv_vmbus_g_connection.monitor_pages
+ + PAGE_SIZE));
+
+ /**
+ * Add to list before we send the request since we may receive the
+ * response before returning from this routine
+ */
+ mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
+
+ TAILQ_INSERT_TAIL(
+ &hv_vmbus_g_connection.channel_msg_anchor,
+ msg_info,
+ msg_list_entry);
+
+ mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
+
+ ret = hv_vmbus_post_message(
+ msg,
+ sizeof(hv_vmbus_channel_initiate_contact));
+
+ if (ret != 0) {
+ mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
+ TAILQ_REMOVE(
+ &hv_vmbus_g_connection.channel_msg_anchor,
+ msg_info,
+ msg_list_entry);
+ mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
+ return (ret);
+ }
+
+ /**
+ * Wait for the connection response
+ */
+ ret = sema_timedwait(&msg_info->wait_sema, 500); /* KYS 5 seconds */
+
+ mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
+ TAILQ_REMOVE(
+ &hv_vmbus_g_connection.channel_msg_anchor,
+ msg_info,
+ msg_list_entry);
+ mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
+
+ /**
+ * Check if successful
+ */
+ if (msg_info->response.version_response.version_supported) {
+ hv_vmbus_g_connection.connect_state = HV_CONNECTED;
+ } else {
+ ret = ECONNREFUSED;
+ }
+
+ return (ret);
+}
+
/**
* Send a connect request on the partition service connection
*/
int
hv_vmbus_connect(void) {
int ret = 0;
+ uint32_t version;
hv_vmbus_channel_msg_info* msg_info = NULL;
- hv_vmbus_channel_initiate_contact* msg;
/**
* Make sure we are not connecting or connected
@@ -74,7 +173,7 @@ hv_vmbus_connect(void) {
TAILQ_INIT(&hv_vmbus_g_connection.channel_anchor);
mtx_init(&hv_vmbus_g_connection.channel_lock, "vmbus channel",
- NULL, MTX_SPIN);
+ NULL, MTX_DEF);
/**
* Setup the vmbus event connection for channel interrupt abstraction
@@ -130,71 +229,30 @@ hv_vmbus_connect(void) {
goto cleanup;
}
- sema_init(&msg_info->wait_sema, 0, "Msg Info Sema");
- msg = (hv_vmbus_channel_initiate_contact*) msg_info->msg;
-
- msg->header.message_type = HV_CHANNEL_MESSAGE_INITIATED_CONTACT;
- msg->vmbus_version_requested = HV_VMBUS_REVISION_NUMBER;
-
- msg->interrupt_page = hv_get_phys_addr(
- hv_vmbus_g_connection.interrupt_page);
-
- msg->monitor_page_1 = hv_get_phys_addr(
- hv_vmbus_g_connection.monitor_pages);
-
- msg->monitor_page_2 =
- hv_get_phys_addr(
- ((uint8_t *) hv_vmbus_g_connection.monitor_pages
- + PAGE_SIZE));
-
- /**
- * Add to list before we send the request since we may receive the
- * response before returning from this routine
+ /*
+ * Find the highest vmbus version number we can support.
*/
- mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
-
- TAILQ_INSERT_TAIL(
- &hv_vmbus_g_connection.channel_msg_anchor,
- msg_info,
- msg_list_entry);
-
- mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
-
- ret = hv_vmbus_post_message(
- msg,
- sizeof(hv_vmbus_channel_initiate_contact));
-
- if (ret != 0) {
- mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
- TAILQ_REMOVE(
- &hv_vmbus_g_connection.channel_msg_anchor,
- msg_info,
- msg_list_entry);
- mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
- goto cleanup;
- }
+ version = HV_VMBUS_VERSION_CURRENT;
+
+ do {
+ ret = hv_vmbus_negotiate_version(msg_info, version);
+ if (ret == EWOULDBLOCK) {
+ /*
+ * We timed out.
+ */
+ goto cleanup;
+ }
- /**
- * Wait for the connection response
- */
- ret = sema_timedwait(&msg_info->wait_sema, 500); /* KYS 5 seconds */
+ if (hv_vmbus_g_connection.connect_state == HV_CONNECTED)
+ break;
- mtx_lock_spin(&hv_vmbus_g_connection.channel_msg_lock);
- TAILQ_REMOVE(
- &hv_vmbus_g_connection.channel_msg_anchor,
- msg_info,
- msg_list_entry);
- mtx_unlock_spin(&hv_vmbus_g_connection.channel_msg_lock);
+ version = hv_vmbus_get_next_version(version);
+ } while (version != HV_VMBUS_VERSION_INVALID);
- /**
- * Check if successful
- */
- if (msg_info->response.version_response.version_supported) {
- hv_vmbus_g_connection.connect_state = HV_CONNECTED;
- } else {
- ret = ECONNREFUSED;
- goto cleanup;
- }
+ hv_vmbus_protocal_version = version;
+ if (bootverbose)
+ printf("VMBUS: Portocal Version: %d.%d\n",
+ version >> 16, version & 0xFFFF);
sema_destroy(&msg_info->wait_sema);
free(msg_info, M_DEVBUF);
@@ -286,7 +344,7 @@ hv_vmbus_get_channel_from_rel_id(uint32_t rel_id) {
* and channels are accessed without the need to take this lock or search
* the list.
*/
- mtx_lock_spin(&hv_vmbus_g_connection.channel_lock);
+ mtx_lock(&hv_vmbus_g_connection.channel_lock);
TAILQ_FOREACH(channel,
&hv_vmbus_g_connection.channel_anchor, list_entry) {
@@ -295,7 +353,7 @@ hv_vmbus_get_channel_from_rel_id(uint32_t rel_id) {
break;
}
}
- mtx_unlock_spin(&hv_vmbus_g_connection.channel_lock);
+ mtx_unlock(&hv_vmbus_g_connection.channel_lock);
return (foundChannel);
}
@@ -306,7 +364,10 @@ hv_vmbus_get_channel_from_rel_id(uint32_t rel_id) {
static void
VmbusProcessChannelEvent(uint32_t relid)
{
+ void* arg;
+ uint32_t bytes_to_read;
hv_vmbus_channel* channel;
+ boolean_t is_batched_reading;
/**
* Find the channel based on this relid and invokes
@@ -327,31 +388,98 @@ VmbusProcessChannelEvent(uint32_t relid)
* callback to NULL. This closes the window.
*/
- mtx_lock(&channel->inbound_lock);
+ /*
+ * Disable the lock due to newly added WITNESS check in r277723.
+ * Will seek other way to avoid race condition.
+ * -- whu
+ */
+ // mtx_lock(&channel->inbound_lock);
if (channel->on_channel_callback != NULL) {
- channel->on_channel_callback(channel->channel_callback_context);
+ arg = channel->channel_callback_context;
+ is_batched_reading = channel->batched_reading;
+ /*
+ * Optimize host to guest signaling by ensuring:
+ * 1. While reading the channel, we disable interrupts from
+ * host.
+ * 2. Ensure that we process all posted messages from the host
+ * before returning from this callback.
+ * 3. Once we return, enable signaling from the host. Once this
+ * state is set we check to see if additional packets are
+ * available to read. In this case we repeat the process.
+ */
+ do {
+ if (is_batched_reading)
+ hv_ring_buffer_read_begin(&channel->inbound);
+
+ channel->on_channel_callback(arg);
+
+ if (is_batched_reading)
+ bytes_to_read =
+ hv_ring_buffer_read_end(&channel->inbound);
+ else
+ bytes_to_read = 0;
+ } while (is_batched_reading && (bytes_to_read != 0));
}
- mtx_unlock(&channel->inbound_lock);
+ // mtx_unlock(&channel->inbound_lock);
}
+#ifdef HV_DEBUG_INTR
+extern uint32_t hv_intr_count;
+extern uint32_t hv_vmbus_swintr_event_cpu[MAXCPU];
+extern uint32_t hv_vmbus_intr_cpu[MAXCPU];
+#endif
+
/**
* Handler for events
*/
void
hv_vmbus_on_events(void *arg)
{
- int dword;
int bit;
+ int cpu;
+ int dword;
+ void *page_addr;
+ uint32_t* recv_interrupt_page = NULL;
int rel_id;
- int maxdword = HV_MAX_NUM_CHANNELS_SUPPORTED >> 5;
+ int maxdword;
+ hv_vmbus_synic_event_flags *event;
/* int maxdword = PAGE_SIZE >> 3; */
- /*
- * receive size is 1/2 page and divide that by 4 bytes
- */
-
- uint32_t* recv_interrupt_page =
- hv_vmbus_g_connection.recv_interrupt_page;
+ cpu = (int)(long)arg;
+ KASSERT(cpu <= mp_maxid, ("VMBUS: hv_vmbus_on_events: "
+ "cpu out of range!"));
+
+#ifdef HV_DEBUG_INTR
+ int i;
+ hv_vmbus_swintr_event_cpu[cpu]++;
+ if (hv_intr_count % 10000 == 0) {
+ printf("VMBUS: Total interrupt %d\n", hv_intr_count);
+ for (i = 0; i < mp_ncpus; i++)
+ printf("VMBUS: hw cpu[%d]: %d, event sw intr cpu[%d]: %d\n",
+ i, hv_vmbus_intr_cpu[i], i, hv_vmbus_swintr_event_cpu[i]);
+ }
+#endif
+
+ if ((hv_vmbus_protocal_version == HV_VMBUS_VERSION_WS2008) ||
+ (hv_vmbus_protocal_version == HV_VMBUS_VERSION_WIN7)) {
+ maxdword = HV_MAX_NUM_CHANNELS_SUPPORTED >> 5;
+ /*
+ * receive size is 1/2 page and divide that by 4 bytes
+ */
+ recv_interrupt_page =
+ hv_vmbus_g_connection.recv_interrupt_page;
+ } else {
+ /*
+ * On Host with Win8 or above, the event page can be
+ * checked directly to get the id of the channel
+ * that has the pending interrupt.
+ */
+ maxdword = HV_EVENT_FLAGS_DWORD_COUNT;
+ page_addr = hv_vmbus_g_context.syn_ic_event_page[cpu];
+ event = (hv_vmbus_synic_event_flags *)
+ page_addr + HV_VMBUS_MESSAGE_SINT;
+ recv_interrupt_page = event->flags32;
+ }
/*
* Check events
@@ -416,16 +544,16 @@ int hv_vmbus_post_message(void *buffer, size_t bufferLen) {
* Send an event notification to the parent
*/
int
-hv_vmbus_set_event(uint32_t child_rel_id) {
+hv_vmbus_set_event(hv_vmbus_channel *channel) {
int ret = 0;
+ uint32_t child_rel_id = channel->offer_msg.child_rel_id;
/* Each uint32_t represents 32 channels */
synch_set_bit(child_rel_id & 31,
(((uint32_t *)hv_vmbus_g_connection.send_interrupt_page
+ (child_rel_id >> 5))));
- ret = hv_vmbus_signal_event();
+ ret = hv_vmbus_signal_event(channel->signal_event_param);
return (ret);
}
-
diff --git a/sys/dev/hyperv/vmbus/hv_hv.c b/sys/dev/hyperv/vmbus/hv_hv.c
index 80a1f42..84e2a5e 100644
--- a/sys/dev/hyperv/vmbus/hv_hv.c
+++ b/sys/dev/hyperv/vmbus/hv_hv.c
@@ -67,8 +67,6 @@ static inline void do_cpuid_inline(unsigned int op, unsigned int *eax,
hv_vmbus_context hv_vmbus_g_context = {
.syn_ic_initialized = FALSE,
.hypercall_page = NULL,
- .signal_event_param = NULL,
- .signal_event_buffer = NULL,
};
static struct timecounter hv_timecounter = {
@@ -256,28 +254,6 @@ hv_vmbus_init(void)
hv_vmbus_g_context.hypercall_page = virt_addr;
- /*
- * Setup the global signal event param for the signal event hypercall
- */
- hv_vmbus_g_context.signal_event_buffer =
- malloc(sizeof(hv_vmbus_input_signal_event_buffer), M_DEVBUF,
- M_ZERO | M_NOWAIT);
- KASSERT(hv_vmbus_g_context.signal_event_buffer != NULL,
- ("Error VMBUS: Failed to allocate signal_event_buffer\n"));
- if (hv_vmbus_g_context.signal_event_buffer == NULL)
- goto cleanup;
-
- hv_vmbus_g_context.signal_event_param =
- (hv_vmbus_input_signal_event*)
- (HV_ALIGN_UP((unsigned long)
- hv_vmbus_g_context.signal_event_buffer,
- HV_HYPERCALL_PARAM_ALIGN));
- hv_vmbus_g_context.signal_event_param->connection_id.as_uint32_t = 0;
- hv_vmbus_g_context.signal_event_param->connection_id.u.id =
- HV_VMBUS_EVENT_CONNECTION_ID;
- hv_vmbus_g_context.signal_event_param->flag_number = 0;
- hv_vmbus_g_context.signal_event_param->rsvd_z = 0;
-
tc_init(&hv_timecounter); /* register virtual timecount */
return (0);
@@ -303,12 +279,6 @@ hv_vmbus_cleanup(void)
{
hv_vmbus_x64_msr_hypercall_contents hypercall_msr;
- if (hv_vmbus_g_context.signal_event_buffer != NULL) {
- free(hv_vmbus_g_context.signal_event_buffer, M_DEVBUF);
- hv_vmbus_g_context.signal_event_buffer = NULL;
- hv_vmbus_g_context.signal_event_param = NULL;
- }
-
if (hv_vmbus_g_context.guest_id == HV_FREEBSD_GUEST_ID) {
if (hv_vmbus_g_context.hypercall_page != NULL) {
hypercall_msr.as_uint64_t = 0;
@@ -370,13 +340,13 @@ hv_vmbus_post_msg_via_msg_ipc(
* event IPC. (This involves a hypercall.)
*/
hv_vmbus_status
-hv_vmbus_signal_event()
+hv_vmbus_signal_event(void *con_id)
{
hv_vmbus_status status;
status = hv_vmbus_do_hypercall(
HV_CALL_SIGNAL_EVENT,
- hv_vmbus_g_context.signal_event_param,
+ con_id,
0) & 0xFFFF;
return (status);
@@ -390,6 +360,7 @@ hv_vmbus_synic_init(void *arg)
{
int cpu;
+ uint64_t hv_vcpu_index;
hv_vmbus_synic_simp simp;
hv_vmbus_synic_siefp siefp;
hv_vmbus_synic_scontrol sctrl;
@@ -403,23 +374,14 @@ hv_vmbus_synic_init(void *arg)
return;
/*
- * KYS: Looks like we can only initialize on cpu0; don't we support
- * SMP guests?
- *
- * TODO: Need to add SMP support for FreeBSD V9
- */
-
- if (cpu != 0)
- return;
-
- /*
* TODO: Check the version
*/
version = rdmsr(HV_X64_MSR_SVERSION);
-
- hv_vmbus_g_context.syn_ic_msg_page[cpu] = setup_args->page_buffers[0];
- hv_vmbus_g_context.syn_ic_event_page[cpu] = setup_args->page_buffers[1];
+ hv_vmbus_g_context.syn_ic_msg_page[cpu] =
+ setup_args->page_buffers[2 * cpu];
+ hv_vmbus_g_context.syn_ic_event_page[cpu] =
+ setup_args->page_buffers[2 * cpu + 1];
/*
* Setup the Synic's message page
@@ -443,9 +405,10 @@ hv_vmbus_synic_init(void *arg)
wrmsr(HV_X64_MSR_SIEFP, siefp.as_uint64_t);
/*HV_SHARED_SINT_IDT_VECTOR + 0x20; */
+ shared_sint.as_uint64_t = 0;
shared_sint.u.vector = setup_args->vector;
shared_sint.u.masked = FALSE;
- shared_sint.u.auto_eoi = FALSE;
+ shared_sint.u.auto_eoi = TRUE;
wrmsr(HV_X64_MSR_SINT0 + HV_VMBUS_MESSAGE_SINT,
shared_sint.as_uint64_t);
@@ -458,6 +421,13 @@ hv_vmbus_synic_init(void *arg)
hv_vmbus_g_context.syn_ic_initialized = TRUE;
+ /*
+ * Set up the cpuid mapping from Hyper-V to FreeBSD.
+ * The array is indexed using FreeBSD cpuid.
+ */
+ hv_vcpu_index = rdmsr(HV_X64_MSR_VP_INDEX);
+ hv_vmbus_g_context.hv_vcpu_index[cpu] = (uint32_t)hv_vcpu_index;
+
return;
}
@@ -469,14 +439,10 @@ void hv_vmbus_synic_cleanup(void *arg)
hv_vmbus_synic_sint shared_sint;
hv_vmbus_synic_simp simp;
hv_vmbus_synic_siefp siefp;
- int cpu = PCPU_GET(cpuid);
if (!hv_vmbus_g_context.syn_ic_initialized)
return;
- if (cpu != 0)
- return; /* TODO: XXXKYS: SMP? */
-
shared_sint.as_uint64_t = rdmsr(
HV_X64_MSR_SINT0 + HV_VMBUS_MESSAGE_SINT);
diff --git a/sys/dev/hyperv/vmbus/hv_ring_buffer.c b/sys/dev/hyperv/vmbus/hv_ring_buffer.c
index f7c1965..5e4f52a 100644
--- a/sys/dev/hyperv/vmbus/hv_ring_buffer.c
+++ b/sys/dev/hyperv/vmbus/hv_ring_buffer.c
@@ -144,6 +144,69 @@ get_ring_buffer_indices(hv_vmbus_ring_buffer_info* ring_info)
return (uint64_t) ring_info->ring_buffer->write_index << 32;
}
+void
+hv_ring_buffer_read_begin(
+ hv_vmbus_ring_buffer_info* ring_info)
+{
+ ring_info->ring_buffer->interrupt_mask = 1;
+ mb();
+}
+
+uint32_t
+hv_ring_buffer_read_end(
+ hv_vmbus_ring_buffer_info* ring_info)
+{
+ uint32_t read, write;
+
+ ring_info->ring_buffer->interrupt_mask = 0;
+ mb();
+
+ /*
+ * Now check to see if the ring buffer is still empty.
+ * If it is not, we raced and we need to process new
+ * incoming messages.
+ */
+ get_ring_buffer_avail_bytes(ring_info, &read, &write);
+
+ return (read);
+}
+
+/*
+ * When we write to the ring buffer, check if the host needs to
+ * be signaled. Here is the details of this protocol:
+ *
+ * 1. The host guarantees that while it is draining the
+ * ring buffer, it will set the interrupt_mask to
+ * indicate it does not need to be interrupted when
+ * new data is placed.
+ *
+ * 2. The host guarantees that it will completely drain
+ * the ring buffer before exiting the read loop. Further,
+ * once the ring buffer is empty, it will clear the
+ * interrupt_mask and re-check to see if new data has
+ * arrived.
+ */
+static boolean_t
+hv_ring_buffer_needsig_on_write(
+ uint32_t old_write_location,
+ hv_vmbus_ring_buffer_info* rbi)
+{
+ mb();
+ if (rbi->ring_buffer->interrupt_mask)
+ return (FALSE);
+
+ /* Read memory barrier */
+ rmb();
+ /*
+ * This is the only case we need to signal when the
+ * ring transitions from being empty to non-empty.
+ */
+ if (old_write_location == rbi->ring_buffer->read_index)
+ return (TRUE);
+
+ return (FALSE);
+}
+
static uint32_t copy_to_ring_buffer(
hv_vmbus_ring_buffer_info* ring_info,
uint32_t start_write_offset,
@@ -204,11 +267,13 @@ int
hv_ring_buffer_write(
hv_vmbus_ring_buffer_info* out_ring_info,
hv_vmbus_sg_buffer_list sg_buffers[],
- uint32_t sg_buffer_count)
+ uint32_t sg_buffer_count,
+ boolean_t *need_sig)
{
int i = 0;
uint32_t byte_avail_to_write;
uint32_t byte_avail_to_read;
+ uint32_t old_write_location;
uint32_t total_bytes_to_write = 0;
volatile uint32_t next_write_location;
@@ -242,6 +307,8 @@ hv_ring_buffer_write(
*/
next_write_location = get_next_write_location(out_ring_info);
+ old_write_location = next_write_location;
+
for (i = 0; i < sg_buffer_count; i++) {
next_write_location = copy_to_ring_buffer(out_ring_info,
next_write_location, (char *) sg_buffers[i].data,
@@ -258,9 +325,9 @@ hv_ring_buffer_write(
(char *) &prev_indices, sizeof(uint64_t));
/*
- * Make sure we flush all writes before updating the writeIndex
+ * Full memory barrier before upding the write index.
*/
- wmb();
+ mb();
/*
* Now, update the write location
@@ -269,6 +336,9 @@ hv_ring_buffer_write(
mtx_unlock_spin(&out_ring_info->ring_lock);
+ *need_sig = hv_ring_buffer_needsig_on_write(old_write_location,
+ out_ring_info);
+
return (0);
}
diff --git a/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c b/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
index ca28fd5..f9432c8 100644
--- a/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
+++ b/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
@@ -53,22 +53,17 @@ __FBSDID("$FreeBSD$");
#include <machine/stdarg.h>
#include <machine/intr_machdep.h>
+#include <machine/md_var.h>
+#include <machine/segments.h>
#include <sys/pcpu.h>
+#include <x86/apicvar.h>
#include "hv_vmbus_priv.h"
#define VMBUS_IRQ 0x5
-static struct intr_event *hv_msg_intr_event;
-static struct intr_event *hv_event_intr_event;
-static void *msg_swintr;
-static void *event_swintr;
static device_t vmbus_devp;
-static void *vmbus_cookiep;
-static int vmbus_rid;
-struct resource *intr_res;
-static int vmbus_irq = VMBUS_IRQ;
static int vmbus_inited;
static hv_setup_args setup_args; /* only CPU 0 supported at this time */
@@ -77,14 +72,17 @@ static hv_setup_args setup_args; /* only CPU 0 supported at this time */
* the hypervisor.
*/
static void
-vmbus_msg_swintr(void *dummy)
+vmbus_msg_swintr(void *arg)
{
int cpu;
void* page_addr;
hv_vmbus_message* msg;
hv_vmbus_message* copied;
- cpu = PCPU_GET(cpuid);
+ cpu = (int)(long)arg;
+ KASSERT(cpu <= mp_maxid, ("VMBUS: vmbus_msg_swintr: "
+ "cpu out of range!"));
+
page_addr = hv_vmbus_g_context.syn_ic_msg_page[cpu];
msg = (hv_vmbus_message*) page_addr + HV_VMBUS_MESSAGE_SINT;
@@ -130,17 +128,8 @@ vmbus_msg_swintr(void *dummy)
*
* The purpose of this routine is to determine the type of VMBUS protocol
* message to process - an event or a channel message.
- * As this is an interrupt filter routine, the function runs in a very
- * restricted envinronment. From the manpage for bus_setup_intr(9)
- *
- * In this restricted environment, care must be taken to account for all
- * races. A careful analysis of races should be done as well. It is gener-
- * ally cheaper to take an extra interrupt, for example, than to protect
- * variables with spinlocks. Read, modify, write cycles of hardware regis-
- * ters need to be carefully analyzed if other threads are accessing the
- * same registers.
*/
-static int
+static inline int
hv_vmbus_isr(void *unused)
{
int cpu;
@@ -149,8 +138,6 @@ hv_vmbus_isr(void *unused)
void* page_addr;
cpu = PCPU_GET(cpuid);
- /* (Temporary limit) */
- KASSERT(cpu == 0, ("hv_vmbus_isr: Interrupt on CPU other than zero"));
/*
* The Windows team has advised that we check for events
@@ -162,9 +149,21 @@ hv_vmbus_isr(void *unused)
event = (hv_vmbus_synic_event_flags*)
page_addr + HV_VMBUS_MESSAGE_SINT;
- /* Since we are a child, we only need to check bit 0 */
- if (synch_test_and_clear_bit(0, &event->flags32[0])) {
- swi_sched(event_swintr, 0);
+ if ((hv_vmbus_protocal_version == HV_VMBUS_VERSION_WS2008) ||
+ (hv_vmbus_protocal_version == HV_VMBUS_VERSION_WIN7)) {
+ /* Since we are a child, we only need to check bit 0 */
+ if (synch_test_and_clear_bit(0, &event->flags32[0])) {
+ swi_sched(hv_vmbus_g_context.event_swintr[cpu], 0);
+ }
+ } else {
+ /*
+ * On host with Win8 or above, we can directly look at
+ * the event page. If bit n is set, we have an interrupt
+ * on the channel with id n.
+ * Directly schedule the event software interrupt on
+ * current cpu.
+ */
+ swi_sched(hv_vmbus_g_context.event_swintr[cpu], 0);
}
/* Check if there are actual msgs to be process */
@@ -172,12 +171,47 @@ hv_vmbus_isr(void *unused)
msg = (hv_vmbus_message*) page_addr + HV_VMBUS_MESSAGE_SINT;
if (msg->header.message_type != HV_MESSAGE_TYPE_NONE) {
- swi_sched(msg_swintr, 0);
+ swi_sched(hv_vmbus_g_context.msg_swintr[cpu], 0);
}
return FILTER_HANDLED;
}
+#ifdef HV_DEBUG_INTR
+uint32_t hv_intr_count = 0;
+#endif
+uint32_t hv_vmbus_swintr_event_cpu[MAXCPU];
+uint32_t hv_vmbus_intr_cpu[MAXCPU];
+
+void
+hv_vector_handler(struct trapframe *trap_frame)
+{
+#ifdef HV_DEBUG_INTR
+ int cpu;
+#endif
+
+ /*
+ * Disable preemption.
+ */
+ critical_enter();
+
+#ifdef HV_DEBUG_INTR
+ /*
+ * Do a little interrupt counting.
+ */
+ cpu = PCPU_GET(cpuid);
+ hv_vmbus_intr_cpu[cpu]++;
+ hv_intr_count++;
+#endif
+
+ hv_vmbus_isr(NULL);
+
+ /*
+ * Enable preemption.
+ */
+ critical_exit();
+}
+
static int
vmbus_read_ivar(
device_t dev,
@@ -316,6 +350,81 @@ vmbus_probe(device_t dev) {
return (BUS_PROBE_NOWILDCARD);
}
+#ifdef HYPERV
+extern inthand_t IDTVEC(rsvd), IDTVEC(hv_vmbus_callback);
+
+/**
+ * @brief Find a free IDT slot and setup the interrupt handler.
+ */
+static int
+vmbus_vector_alloc(void)
+{
+ int vector;
+ uintptr_t func;
+ struct gate_descriptor *ip;
+
+ /*
+ * Search backwards form the highest IDT vector available for use
+ * as vmbus channel callback vector. We install 'hv_vmbus_callback'
+ * handler at that vector and use it to interrupt vcpus.
+ */
+ vector = APIC_SPURIOUS_INT;
+ while (--vector >= APIC_IPI_INTS) {
+ ip = &idt[vector];
+ func = ((long)ip->gd_hioffset << 16 | ip->gd_looffset);
+ if (func == (uintptr_t)&IDTVEC(rsvd)) {
+#ifdef __i386__
+ setidt(vector , IDTVEC(hv_vmbus_callback), SDT_SYS386IGT,
+ SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
+#else
+ setidt(vector , IDTVEC(hv_vmbus_callback), SDT_SYSIGT,
+ SEL_KPL, 0);
+#endif
+
+ return (vector);
+ }
+ }
+ return (0);
+}
+
+/**
+ * @brief Restore the IDT slot to rsvd.
+ */
+static void
+vmbus_vector_free(int vector)
+{
+ uintptr_t func;
+ struct gate_descriptor *ip;
+
+ if (vector == 0)
+ return;
+
+ KASSERT(vector >= APIC_IPI_INTS && vector < APIC_SPURIOUS_INT,
+ ("invalid vector %d", vector));
+
+ ip = &idt[vector];
+ func = ((long)ip->gd_hioffset << 16 | ip->gd_looffset);
+ KASSERT(func == (uintptr_t)&IDTVEC(hv_vmbus_callback),
+ ("invalid vector %d", vector));
+
+ setidt(vector, IDTVEC(rsvd), SDT_SYSIGT, SEL_KPL, 0);
+}
+
+#else /* HYPERV */
+
+static int
+vmbus_vector_alloc(void)
+{
+ return(0);
+}
+
+static void
+vmbus_vector_free(int vector)
+{
+}
+
+#endif /* HYPERV */
+
/**
* @brief Main vmbus driver initialization routine.
*
@@ -331,22 +440,7 @@ vmbus_probe(device_t dev) {
static int
vmbus_bus_init(void)
{
- struct ioapic_intsrc {
- struct intsrc io_intsrc;
- u_int io_irq;
- u_int io_intpin:8;
- u_int io_vector:8;
- u_int io_cpu:8;
- u_int io_activehi:1;
- u_int io_edgetrigger:1;
- u_int io_masked:1;
- int io_bus:4;
- uint32_t io_lowreg;
- };
- int i, ret;
- unsigned int vector = 0;
- struct intsrc *isrc;
- struct ioapic_intsrc *intpin;
+ int i, j, n, ret;
if (vmbus_inited)
return (0);
@@ -361,80 +455,100 @@ vmbus_bus_init(void)
return (ret);
}
- ret = swi_add(&hv_msg_intr_event, "hv_msg", vmbus_msg_swintr,
- NULL, SWI_CLOCK, 0, &msg_swintr);
-
- if (ret)
- goto cleanup;
-
/*
- * Message SW interrupt handler checks a per-CPU page and
- * thus the thread needs to be bound to CPU-0 - which is where
- * all interrupts are processed.
+ * Find a free IDT slot for vmbus callback.
*/
- ret = intr_event_bind(hv_msg_intr_event, 0);
-
- if (ret)
- goto cleanup1;
+ hv_vmbus_g_context.hv_cb_vector = vmbus_vector_alloc();
- ret = swi_add(&hv_event_intr_event, "hv_event", hv_vmbus_on_events,
- NULL, SWI_CLOCK, 0, &event_swintr);
-
- if (ret)
- goto cleanup1;
+ if (hv_vmbus_g_context.hv_cb_vector == 0) {
+ if(bootverbose)
+ printf("Error VMBUS: Cannot find free IDT slot for "
+ "vmbus callback!\n");
+ goto cleanup;
+ }
- intr_res = bus_alloc_resource(vmbus_devp,
- SYS_RES_IRQ, &vmbus_rid, vmbus_irq, vmbus_irq, 1, RF_ACTIVE);
+ if(bootverbose)
+ printf("VMBUS: vmbus callback vector %d\n",
+ hv_vmbus_g_context.hv_cb_vector);
- if (intr_res == NULL) {
- ret = ENOMEM; /* XXXKYS: Need a better errno */
- goto cleanup2;
+ /*
+ * Notify the hypervisor of our vector.
+ */
+ setup_args.vector = hv_vmbus_g_context.hv_cb_vector;
+
+ CPU_FOREACH(j) {
+ hv_vmbus_intr_cpu[j] = 0;
+ hv_vmbus_swintr_event_cpu[j] = 0;
+ hv_vmbus_g_context.hv_event_intr_event[j] = NULL;
+ hv_vmbus_g_context.hv_msg_intr_event[j] = NULL;
+ hv_vmbus_g_context.event_swintr[j] = NULL;
+ hv_vmbus_g_context.msg_swintr[j] = NULL;
+
+ for (i = 0; i < 2; i++)
+ setup_args.page_buffers[2 * j + i] = NULL;
}
/*
- * Setup interrupt filter handler
+ * Per cpu setup.
*/
- ret = bus_setup_intr(vmbus_devp, intr_res,
- INTR_TYPE_NET | INTR_MPSAFE, hv_vmbus_isr, NULL,
- NULL, &vmbus_cookiep);
-
- if (ret != 0)
- goto cleanup3;
-
- ret = bus_bind_intr(vmbus_devp, intr_res, 0);
- if (ret != 0)
- goto cleanup4;
-
- isrc = intr_lookup_source(vmbus_irq);
- if ((isrc == NULL) || (isrc->is_event == NULL)) {
- ret = EINVAL;
- goto cleanup4;
- }
+ CPU_FOREACH(j) {
+ /*
+ * Setup software interrupt thread and handler for msg handling.
+ */
+ ret = swi_add(&hv_vmbus_g_context.hv_msg_intr_event[j],
+ "hv_msg", vmbus_msg_swintr, (void *)(long)j, SWI_CLOCK, 0,
+ &hv_vmbus_g_context.msg_swintr[j]);
+ if (ret) {
+ if(bootverbose)
+ printf("VMBUS: failed to setup msg swi for "
+ "cpu %d\n", j);
+ goto cleanup1;
+ }
- /* vector = isrc->is_event->ie_vector; */
- intpin = (struct ioapic_intsrc *)isrc;
- vector = intpin->io_vector;
+ /*
+ * Bind the swi thread to the cpu.
+ */
+ ret = intr_event_bind(hv_vmbus_g_context.hv_msg_intr_event[j],
+ j);
+ if (ret) {
+ if(bootverbose)
+ printf("VMBUS: failed to bind msg swi thread "
+ "to cpu %d\n", j);
+ goto cleanup1;
+ }
- if(bootverbose)
- printf("VMBUS: irq 0x%x vector 0x%x\n", vmbus_irq, vector);
+ /*
+ * Setup software interrupt thread and handler for
+ * event handling.
+ */
+ ret = swi_add(&hv_vmbus_g_context.hv_event_intr_event[j],
+ "hv_event", hv_vmbus_on_events, (void *)(long)j,
+ SWI_CLOCK, 0, &hv_vmbus_g_context.event_swintr[j]);
+ if (ret) {
+ if(bootverbose)
+ printf("VMBUS: failed to setup event swi for "
+ "cpu %d\n", j);
+ goto cleanup1;
+ }
- /**
- * Notify the hypervisor of our irq.
- */
- setup_args.vector = vector;
- for(i = 0; i < 2; i++) {
- setup_args.page_buffers[i] =
+ /*
+ * Prepare the per cpu msg and event pages to be called on each cpu.
+ */
+ for(i = 0; i < 2; i++) {
+ setup_args.page_buffers[2 * j + i] =
malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT | M_ZERO);
- if (setup_args.page_buffers[i] == NULL) {
- KASSERT(setup_args.page_buffers[i] != NULL,
+ if (setup_args.page_buffers[2 * j + i] == NULL) {
+ KASSERT(setup_args.page_buffers[2 * j + i] != NULL,
("Error VMBUS: malloc failed!"));
- if (i > 0)
- free(setup_args.page_buffers[0], M_DEVBUF);
- goto cleanup4;
+ goto cleanup1;
+ }
}
}
- /* only CPU #0 supported at this time */
+ if (bootverbose)
+ printf("VMBUS: Calling smp_rendezvous, smp_started = %d\n",
+ smp_started);
+
smp_rendezvous(NULL, hv_vmbus_synic_init, NULL, &setup_args);
/*
@@ -443,26 +557,32 @@ vmbus_bus_init(void)
ret = hv_vmbus_connect();
if (ret != 0)
- goto cleanup4;
+ goto cleanup1;
hv_vmbus_request_channel_offers();
return (ret);
- cleanup4:
-
+ cleanup1:
/*
- * remove swi, bus and intr resource
+ * Free pages alloc'ed
*/
- bus_teardown_intr(vmbus_devp, intr_res, vmbus_cookiep);
+ for (n = 0; n < 2 * MAXCPU; n++)
+ if (setup_args.page_buffers[n] != NULL)
+ free(setup_args.page_buffers[n], M_DEVBUF);
- cleanup3:
- bus_release_resource(vmbus_devp, SYS_RES_IRQ, vmbus_rid, intr_res);
-
- cleanup2:
- swi_remove(event_swintr);
+ /*
+ * remove swi and vmbus callback vector;
+ */
+ CPU_FOREACH(j) {
+ if (hv_vmbus_g_context.msg_swintr[j] != NULL)
+ swi_remove(hv_vmbus_g_context.msg_swintr[j]);
+ if (hv_vmbus_g_context.event_swintr[j] != NULL)
+ swi_remove(hv_vmbus_g_context.event_swintr[j]);
+ hv_vmbus_g_context.hv_msg_intr_event[j] = NULL;
+ hv_vmbus_g_context.hv_event_intr_event[j] = NULL;
+ }
- cleanup1:
- swi_remove(msg_swintr);
+ vmbus_vector_free(hv_vmbus_g_context.hv_cb_vector);
cleanup:
hv_vmbus_cleanup();
@@ -515,20 +635,24 @@ vmbus_bus_exit(void)
smp_rendezvous(NULL, hv_vmbus_synic_cleanup, NULL, NULL);
- for(i = 0; i < 2; i++) {
+ for(i = 0; i < 2 * MAXCPU; i++) {
if (setup_args.page_buffers[i] != 0)
free(setup_args.page_buffers[i], M_DEVBUF);
}
hv_vmbus_cleanup();
- /* remove swi, bus and intr resource */
- bus_teardown_intr(vmbus_devp, intr_res, vmbus_cookiep);
-
- bus_release_resource(vmbus_devp, SYS_RES_IRQ, vmbus_rid, intr_res);
+ /* remove swi */
+ CPU_FOREACH(i) {
+ if (hv_vmbus_g_context.msg_swintr[i] != NULL)
+ swi_remove(hv_vmbus_g_context.msg_swintr[i]);
+ if (hv_vmbus_g_context.event_swintr[i] != NULL)
+ swi_remove(hv_vmbus_g_context.event_swintr[i]);
+ hv_vmbus_g_context.hv_msg_intr_event[i] = NULL;
+ hv_vmbus_g_context.hv_event_intr_event[i] = NULL;
+ }
- swi_remove(msg_swintr);
- swi_remove(event_swintr);
+ vmbus_vector_free(hv_vmbus_g_context.hv_cb_vector);
return;
}
@@ -603,6 +727,6 @@ devclass_t vmbus_devclass;
DRIVER_MODULE(vmbus, nexus, vmbus_driver, vmbus_devclass, vmbus_modevent, 0);
MODULE_VERSION(vmbus,1);
-/* TODO: We want to be earlier than SI_SUB_VFS */
-SYSINIT(vmb_init, SI_SUB_VFS, SI_ORDER_MIDDLE, vmbus_init, NULL);
+/* We want to be started after SMP is initialized */
+SYSINIT(vmb_init, SI_SUB_SMP + 1, SI_ORDER_FIRST, vmbus_init, NULL);
diff --git a/sys/dev/hyperv/vmbus/hv_vmbus_priv.h b/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
index 6bc875d..faa6dec 100644
--- a/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
+++ b/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
@@ -181,49 +181,30 @@ enum {
#define HV_HYPERCALL_PARAM_ALIGN sizeof(uint64_t)
-/*
- * Connection identifier type
- */
-typedef union {
- uint32_t as_uint32_t;
- struct {
- uint32_t id:24;
- uint32_t reserved:8;
- } u;
-
-} __packed hv_vmbus_connection_id;
-
-/*
- * Definition of the hv_vmbus_signal_event hypercall input structure
- */
-typedef struct {
- hv_vmbus_connection_id connection_id;
- uint16_t flag_number;
- uint16_t rsvd_z;
-} __packed hv_vmbus_input_signal_event;
-
-typedef struct {
- uint64_t align8;
- hv_vmbus_input_signal_event event;
-} __packed hv_vmbus_input_signal_event_buffer;
-
typedef struct {
uint64_t guest_id;
void* hypercall_page;
hv_bool_uint8_t syn_ic_initialized;
+
+ hv_vmbus_handle syn_ic_msg_page[MAXCPU];
+ hv_vmbus_handle syn_ic_event_page[MAXCPU];
/*
- * This is used as an input param to HV_CALL_SIGNAL_EVENT hypercall.
- * The input param is immutable in our usage and
- * must be dynamic mem (vs stack or global).
+ * For FreeBSD cpuid to Hyper-V vcpuid mapping.
*/
- hv_vmbus_input_signal_event_buffer *signal_event_buffer;
+ uint32_t hv_vcpu_index[MAXCPU];
/*
- * 8-bytes aligned of the buffer above
+ * Each cpu has its own software interrupt handler for channel
+ * event and msg handling.
*/
- hv_vmbus_input_signal_event *signal_event_param;
-
- hv_vmbus_handle syn_ic_msg_page[MAXCPU];
- hv_vmbus_handle syn_ic_event_page[MAXCPU];
+ struct intr_event *hv_event_intr_event[MAXCPU];
+ struct intr_event *hv_msg_intr_event[MAXCPU];
+ void *event_swintr[MAXCPU];
+ void *msg_swintr[MAXCPU];
+ /*
+ * Host use this vector to intrrupt guest for vmbus channel
+ * event and msg.
+ */
+ unsigned int hv_cb_vector;
} hv_vmbus_context;
/*
@@ -368,7 +349,8 @@ typedef struct {
TAILQ_HEAD(, hv_vmbus_channel_msg_info) channel_msg_anchor;
struct mtx channel_msg_lock;
/**
- * List of channels
+ * List of primary channels. Sub channels will be linked
+ * under their primary channel.
*/
TAILQ_HEAD(, hv_vmbus_channel) channel_anchor;
struct mtx channel_lock;
@@ -560,6 +542,8 @@ typedef union {
uint32_t flags32[HV_EVENT_FLAGS_DWORD_COUNT];
} hv_vmbus_synic_event_flags;
+/* MSR used to provide vcpu index */
+#define HV_X64_MSR_VP_INDEX (0x40000002)
/*
* Define synthetic interrupt controller model specific registers
@@ -618,7 +602,8 @@ void hv_ring_buffer_cleanup(
int hv_ring_buffer_write(
hv_vmbus_ring_buffer_info *ring_info,
hv_vmbus_sg_buffer_list sg_buffers[],
- uint32_t sg_buff_count);
+ uint32_t sg_buff_count,
+ boolean_t *need_sig);
int hv_ring_buffer_peek(
hv_vmbus_ring_buffer_info *ring_info,
@@ -638,6 +623,12 @@ void hv_vmbus_dump_ring_info(
hv_vmbus_ring_buffer_info *ring_info,
char *prefix);
+void hv_ring_buffer_read_begin(
+ hv_vmbus_ring_buffer_info *ring_info);
+
+uint32_t hv_ring_buffer_read_end(
+ hv_vmbus_ring_buffer_info *ring_info);
+
hv_vmbus_channel* hv_vmbus_allocate_channel(void);
void hv_vmbus_free_vmbus_channel(hv_vmbus_channel *channel);
void hv_vmbus_on_channel_message(void *context);
@@ -652,7 +643,7 @@ uint16_t hv_vmbus_post_msg_via_msg_ipc(
void *payload,
size_t payload_size);
-uint16_t hv_vmbus_signal_event(void);
+uint16_t hv_vmbus_signal_event(void *con_id);
void hv_vmbus_synic_init(void *irq_arg);
void hv_vmbus_synic_cleanup(void *arg);
int hv_vmbus_query_hypervisor_presence(void);
@@ -674,7 +665,7 @@ hv_vmbus_channel* hv_vmbus_get_channel_from_rel_id(uint32_t rel_id);
int hv_vmbus_connect(void);
int hv_vmbus_disconnect(void);
int hv_vmbus_post_message(void *buffer, size_t buf_size);
-int hv_vmbus_set_event(uint32_t child_rel_id);
+int hv_vmbus_set_event(hv_vmbus_channel *channel);
void hv_vmbus_on_events(void *);
@@ -718,7 +709,7 @@ static inline uint64_t hv_generate_guest_id(
typedef struct {
unsigned int vector;
- void *page_buffers[2];
+ void *page_buffers[2 * MAXCPU];
} hv_setup_args;
#endif /* __HYPERV_PRIV_H__ */
diff --git a/sys/dev/if_ndis/if_ndis.c b/sys/dev/if_ndis/if_ndis.c
index 8f23527..7ac1dea 100644
--- a/sys/dev/if_ndis/if_ndis.c
+++ b/sys/dev/if_ndis/if_ndis.c
@@ -558,7 +558,7 @@ ndis_attach(dev)
InitializeListHead(&sc->ndis_shlist);
InitializeListHead(&sc->ndisusb_tasklist);
InitializeListHead(&sc->ndisusb_xferdonelist);
- callout_init(&sc->ndis_stat_callout, CALLOUT_MPSAFE);
+ callout_init(&sc->ndis_stat_callout, 1);
if (sc->ndis_iftype == PCMCIABus) {
error = ndis_alloc_amem(sc);
@@ -734,7 +734,7 @@ ndis_attach(dev)
uint32_t arg;
int r;
- callout_init(&sc->ndis_scan_callout, CALLOUT_MPSAFE);
+ callout_init(&sc->ndis_scan_callout, 1);
ifp->if_ioctl = ndis_ioctl_80211;
ic->ic_ifp = ifp;
@@ -3316,7 +3316,7 @@ done:
DPRINTF(("scan: bssid %s chan %dMHz (%d/%d) rssi %d\n",
ether_sprintf(wb->nwbx_macaddr), freq, sp.bchan, chanflag,
rssi));
- ieee80211_add_scan(vap, &sp, &wh, 0, rssi, noise);
+ ieee80211_add_scan(vap, ic->ic_curchan, &sp, &wh, 0, rssi, noise);
wb = (ndis_wlan_bssid_ex *)((char *)wb + wb->nwbx_len);
}
free(bl, M_DEVBUF);
diff --git a/sys/dev/iicbus/iicbus.c b/sys/dev/iicbus/iicbus.c
index dc56760..71098ed 100644
--- a/sys/dev/iicbus/iicbus.c
+++ b/sys/dev/iicbus/iicbus.c
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mutex.h>
+#include <sys/rman.h>
#include <sys/sysctl.h>
#include <sys/bus.h>
@@ -147,6 +148,7 @@ iicbus_print_child(device_t dev, device_t child)
retval += bus_print_child_header(dev, child);
if (devi->addr != 0)
retval += printf(" at addr %#x", devi->addr);
+ resource_list_print_type(&devi->rl, "irq", SYS_RES_IRQ, "%ld");
retval += bus_print_child_footer(dev, child);
return (retval);
@@ -157,9 +159,7 @@ iicbus_probe_nomatch(device_t bus, device_t child)
{
struct iicbus_ivar *devi = IICBUS_IVAR(child);
- device_printf(bus, "<unknown card>");
- printf(" at addr %#x\n", devi->addr);
- return;
+ device_printf(bus, "<unknown card> at addr %#x\n", devi->addr);
}
static int
@@ -209,6 +209,7 @@ iicbus_add_child(device_t dev, u_int order, const char *name, int unit)
device_delete_child(dev, child);
return (0);
}
+ resource_list_init(&devi->rl);
device_set_ivars(child, devi);
return (child);
}
@@ -217,11 +218,26 @@ static void
iicbus_hinted_child(device_t bus, const char *dname, int dunit)
{
device_t child;
+ int irq;
struct iicbus_ivar *devi;
child = BUS_ADD_CHILD(bus, 0, dname, dunit);
devi = IICBUS_IVAR(child);
resource_int_value(dname, dunit, "addr", &devi->addr);
+ if (resource_int_value(dname, dunit, "irq", &irq) == 0) {
+ if (bus_set_resource(child, SYS_RES_IRQ, 0, irq, 1) != 0)
+ device_printf(bus,
+ "warning: bus_set_resource() failed\n");
+ }
+}
+
+static struct resource_list *
+iicbus_get_resource_list(device_t bus __unused, device_t child)
+{
+ struct iicbus_ivar *devi;
+
+ devi = IICBUS_IVAR(child);
+ return (&devi->rl);
}
int
@@ -291,14 +307,24 @@ iicbus_get_frequency(device_t dev, u_char speed)
}
static device_method_t iicbus_methods[] = {
- /* device interface */
- DEVMETHOD(device_probe, iicbus_probe),
- DEVMETHOD(device_attach, iicbus_attach),
- DEVMETHOD(device_detach, iicbus_detach),
-
- /* bus interface */
- DEVMETHOD(bus_add_child, iicbus_add_child),
- DEVMETHOD(bus_print_child, iicbus_print_child),
+ /* device interface */
+ DEVMETHOD(device_probe, iicbus_probe),
+ DEVMETHOD(device_attach, iicbus_attach),
+ DEVMETHOD(device_detach, iicbus_detach),
+
+ /* bus interface */
+ DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
+ DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
+ DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
+ DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
+ DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource),
+ DEVMETHOD(bus_alloc_resource, bus_generic_rl_alloc_resource),
+ DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
+ DEVMETHOD(bus_release_resource, bus_generic_rl_release_resource),
+ DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource),
+ DEVMETHOD(bus_get_resource_list, iicbus_get_resource_list),
+ DEVMETHOD(bus_add_child, iicbus_add_child),
+ DEVMETHOD(bus_print_child, iicbus_print_child),
DEVMETHOD(bus_probe_nomatch, iicbus_probe_nomatch),
DEVMETHOD(bus_read_ivar, iicbus_read_ivar),
DEVMETHOD(bus_child_pnpinfo_str, iicbus_child_pnpinfo_str),
@@ -322,4 +348,3 @@ devclass_t iicbus_devclass;
MODULE_VERSION(iicbus, IICBUS_MODVER);
DRIVER_MODULE(iicbus, iichb, iicbus_driver, iicbus_devclass, 0, 0);
-
diff --git a/sys/dev/iicbus/iicbus.h b/sys/dev/iicbus/iicbus.h
index b5905ad..1085319 100644
--- a/sys/dev/iicbus/iicbus.h
+++ b/sys/dev/iicbus/iicbus.h
@@ -50,6 +50,7 @@ struct iicbus_softc
struct iicbus_ivar
{
uint32_t addr;
+ struct resource_list rl;
bool nostop;
};
diff --git a/sys/dev/isci/isci_io_request.c b/sys/dev/isci/isci_io_request.c
index 4151900..e6b68fd 100644
--- a/sys/dev/isci/isci_io_request.c
+++ b/sys/dev/isci/isci_io_request.c
@@ -680,7 +680,7 @@ isci_request_construct(struct ISCI_REQUEST *request,
request->dma_tag = io_buffer_dma_tag;
request->physical_address = physical_address;
bus_dmamap_create(request->dma_tag, 0, &request->dma_map);
- callout_init(&request->timer, CALLOUT_MPSAFE);
+ callout_init(&request->timer, 1);
}
static void
diff --git a/sys/dev/iscsi/icl_soft.c b/sys/dev/iscsi/icl_soft.c
index e31b213..c006c05 100644
--- a/sys/dev/iscsi/icl_soft.c
+++ b/sys/dev/iscsi/icl_soft.c
@@ -773,10 +773,6 @@ icl_receive_thread(void *arg)
ic = arg;
so = ic->ic_socket;
- ICL_CONN_LOCK(ic);
- ic->ic_receive_running = true;
- ICL_CONN_UNLOCK(ic);
-
for (;;) {
if (ic->ic_disconnecting) {
//ICL_DEBUG("terminating");
@@ -998,8 +994,6 @@ icl_send_thread(void *arg)
STAILQ_INIT(&queue);
ICL_CONN_LOCK(ic);
- ic->ic_send_running = true;
-
for (;;) {
for (;;) {
/*
@@ -1275,35 +1269,45 @@ icl_conn_start(struct icl_conn *ic)
}
/*
+ * Register socket upcall, to get notified about incoming PDUs
+ * and free space to send outgoing ones.
+ */
+ SOCKBUF_LOCK(&ic->ic_socket->so_snd);
+ soupcall_set(ic->ic_socket, SO_SND, icl_soupcall_send, ic);
+ SOCKBUF_UNLOCK(&ic->ic_socket->so_snd);
+ SOCKBUF_LOCK(&ic->ic_socket->so_rcv);
+ soupcall_set(ic->ic_socket, SO_RCV, icl_soupcall_receive, ic);
+ SOCKBUF_UNLOCK(&ic->ic_socket->so_rcv);
+
+ /*
* Start threads.
*/
+ ICL_CONN_LOCK(ic);
+ ic->ic_send_running = ic->ic_receive_running = true;
+ ICL_CONN_UNLOCK(ic);
error = kthread_add(icl_send_thread, ic, NULL, NULL, 0, 0, "%stx",
ic->ic_name);
if (error != 0) {
ICL_WARN("kthread_add(9) failed with error %d", error);
+ ICL_CONN_LOCK(ic);
+ ic->ic_send_running = ic->ic_receive_running = false;
+ cv_signal(&ic->ic_send_cv);
+ ICL_CONN_UNLOCK(ic);
icl_soft_conn_close(ic);
return (error);
}
-
error = kthread_add(icl_receive_thread, ic, NULL, NULL, 0, 0, "%srx",
ic->ic_name);
if (error != 0) {
ICL_WARN("kthread_add(9) failed with error %d", error);
+ ICL_CONN_LOCK(ic);
+ ic->ic_receive_running = false;
+ cv_signal(&ic->ic_send_cv);
+ ICL_CONN_UNLOCK(ic);
icl_soft_conn_close(ic);
return (error);
}
- /*
- * Register socket upcall, to get notified about incoming PDUs
- * and free space to send outgoing ones.
- */
- SOCKBUF_LOCK(&ic->ic_socket->so_snd);
- soupcall_set(ic->ic_socket, SO_SND, icl_soupcall_send, ic);
- SOCKBUF_UNLOCK(&ic->ic_socket->so_snd);
- SOCKBUF_LOCK(&ic->ic_socket->so_rcv);
- soupcall_set(ic->ic_socket, SO_RCV, icl_soupcall_receive, ic);
- SOCKBUF_UNLOCK(&ic->ic_socket->so_rcv);
-
return (0);
}
@@ -1357,46 +1361,42 @@ void
icl_soft_conn_close(struct icl_conn *ic)
{
struct icl_pdu *pdu;
+ struct socket *so;
- ICL_CONN_LOCK_ASSERT_NOT(ic);
-
- ICL_CONN_LOCK(ic);
- if (ic->ic_socket == NULL) {
- ICL_CONN_UNLOCK(ic);
- return;
- }
-
- /*
- * Deregister socket upcalls.
- */
- ICL_CONN_UNLOCK(ic);
- SOCKBUF_LOCK(&ic->ic_socket->so_snd);
- if (ic->ic_socket->so_snd.sb_upcall != NULL)
- soupcall_clear(ic->ic_socket, SO_SND);
- SOCKBUF_UNLOCK(&ic->ic_socket->so_snd);
- SOCKBUF_LOCK(&ic->ic_socket->so_rcv);
- if (ic->ic_socket->so_rcv.sb_upcall != NULL)
- soupcall_clear(ic->ic_socket, SO_RCV);
- SOCKBUF_UNLOCK(&ic->ic_socket->so_rcv);
ICL_CONN_LOCK(ic);
- ic->ic_disconnecting = true;
-
/*
* Wake up the threads, so they can properly terminate.
*/
+ ic->ic_disconnecting = true;
while (ic->ic_receive_running || ic->ic_send_running) {
- //ICL_DEBUG("waiting for send/receive threads to terminate");
cv_signal(&ic->ic_receive_cv);
cv_signal(&ic->ic_send_cv);
cv_wait(&ic->ic_send_cv, ic->ic_lock);
}
- //ICL_DEBUG("send/receive threads terminated");
+ /* Some other thread could close the connection same time. */
+ so = ic->ic_socket;
+ if (so == NULL) {
+ ICL_CONN_UNLOCK(ic);
+ return;
+ }
+ ic->ic_socket = NULL;
+
+ /*
+ * Deregister socket upcalls.
+ */
ICL_CONN_UNLOCK(ic);
- soclose(ic->ic_socket);
+ SOCKBUF_LOCK(&so->so_snd);
+ if (so->so_snd.sb_upcall != NULL)
+ soupcall_clear(so, SO_SND);
+ SOCKBUF_UNLOCK(&so->so_snd);
+ SOCKBUF_LOCK(&so->so_rcv);
+ if (so->so_rcv.sb_upcall != NULL)
+ soupcall_clear(so, SO_RCV);
+ SOCKBUF_UNLOCK(&so->so_rcv);
+ soclose(so);
ICL_CONN_LOCK(ic);
- ic->ic_socket = NULL;
if (ic->ic_receive_pdu != NULL) {
//ICL_DEBUG("freeing partially received PDU");
diff --git a/sys/dev/iwn/if_iwn.c b/sys/dev/iwn/if_iwn.c
index 3733509..ab98204 100644
--- a/sys/dev/iwn/if_iwn.c
+++ b/sys/dev/iwn/if_iwn.c
@@ -1875,7 +1875,7 @@ iwn_alloc_rx_ring(struct iwn_softc *sc, struct iwn_rx_ring *ring)
&paddr, BUS_DMA_NOWAIT);
if (error != 0 && error != EFBIG) {
device_printf(sc->sc_dev,
- "%s: can't not map mbuf, error %d\n", __func__,
+ "%s: can't map mbuf, error %d\n", __func__,
error);
goto fail;
}
@@ -2036,6 +2036,10 @@ iwn_reset_tx_ring(struct iwn_softc *sc, struct iwn_tx_ring *ring)
m_freem(data->m);
data->m = NULL;
}
+ if (data->ni != NULL) {
+ ieee80211_free_node(data->ni);
+ data->ni = NULL;
+ }
}
/* Clear TX descriptors. */
memset(ring->desc, 0, ring->desc_dma.size);
@@ -2969,7 +2973,7 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
return;
}
/* Discard frames that are too short. */
- if (len < sizeof (*wh)) {
+ if (len < sizeof (struct ieee80211_frame_ack)) {
DPRINTF(sc, IWN_DEBUG_RECV, "%s: frame too short: %d\n",
__func__, len);
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
@@ -3021,7 +3025,10 @@ iwn_rx_done(struct iwn_softc *sc, struct iwn_rx_desc *desc,
/* Grab a reference to the source node. */
wh = mtod(m, struct ieee80211_frame *);
- ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh);
+ if (len >= sizeof(struct ieee80211_frame_min))
+ ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh);
+ else
+ ni = NULL;
nf = (ni != NULL && ni->ni_vap->iv_state == IEEE80211_S_RUN &&
(ic->ic_flags & IEEE80211_F_SCAN) == 0) ? sc->noise : -95;
@@ -4047,8 +4054,10 @@ iwn_intr(void *arg)
r2 = 0; /* Unused. */
} else {
r1 = IWN_READ(sc, IWN_INT);
- if (r1 == 0xffffffff || (r1 & 0xfffffff0) == 0xa5a5a5a0)
+ if (r1 == 0xffffffff || (r1 & 0xfffffff0) == 0xa5a5a5a0) {
+ IWN_UNLOCK(sc);
return; /* Hardware gone! */
+ }
r2 = IWN_READ(sc, IWN_FH_INT);
}
@@ -4519,7 +4528,7 @@ iwn_tx_data(struct iwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
return error;
}
/* Too many DMA segments, linearize mbuf. */
- m1 = m_collapse(m, M_NOWAIT, IWN_MAX_SCATTER);
+ m1 = m_collapse(m, M_NOWAIT, IWN_MAX_SCATTER - 1);
if (m1 == NULL) {
device_printf(sc->sc_dev,
"%s: could not defrag mbuf\n", __func__);
@@ -4725,7 +4734,7 @@ iwn_tx_data_raw(struct iwn_softc *sc, struct mbuf *m,
return error;
}
/* Too many DMA segments, linearize mbuf. */
- m1 = m_collapse(m, M_NOWAIT, IWN_MAX_SCATTER);
+ m1 = m_collapse(m, M_NOWAIT, IWN_MAX_SCATTER - 1);
if (m1 == NULL) {
device_printf(sc->sc_dev,
"%s: could not defrag mbuf\n", __func__);
@@ -4825,8 +4834,8 @@ iwn_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
/* NB: m is reclaimed on tx failure */
ieee80211_free_node(ni);
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
- }
- sc->sc_tx_timer = 5;
+ } else
+ sc->sc_tx_timer = 5;
IWN_UNLOCK(sc);
@@ -4872,9 +4881,8 @@ iwn_start_locked(struct ifnet *ifp)
if (iwn_tx_data(sc, m, ni) != 0) {
ieee80211_free_node(ni);
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
- continue;
- }
- sc->sc_tx_timer = 5;
+ } else
+ sc->sc_tx_timer = 5;
}
DPRINTF(sc, IWN_DEBUG_XMIT, "%s: done\n", __func__);
@@ -4950,7 +4958,6 @@ iwn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
IWN_LOCK(sc);
memset(&sc->last_stat, 0, sizeof(struct iwn_stats));
IWN_UNLOCK(sc);
- error = 0;
break;
default:
error = EINVAL;
@@ -6818,16 +6825,10 @@ iwn_scan(struct iwn_softc *sc, struct ieee80211vap *vap,
chan->active = htole16(dwell_active);
chan->passive = htole16(dwell_passive);
- if (IEEE80211_IS_CHAN_5GHZ(c) &&
- !(c->ic_flags & IEEE80211_CHAN_PASSIVE)) {
- chan->rf_gain = 0x3b;
- } else if (IEEE80211_IS_CHAN_5GHZ(c)) {
+ if (IEEE80211_IS_CHAN_5GHZ(c))
chan->rf_gain = 0x3b;
- } else if (!(c->ic_flags & IEEE80211_CHAN_PASSIVE)) {
- chan->rf_gain = 0x28;
- } else {
+ else
chan->rf_gain = 0x28;
- }
DPRINTF(sc, IWN_DEBUG_STATE,
"%s: chan %u flags 0x%x rf_gain 0x%x "
@@ -8809,7 +8810,6 @@ iwn_hw_reset(void *arg0, int pending)
}
#ifdef IWN_DEBUG
#define IWN_DESC(x) case x: return #x
-#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
/*
* Translate CSR code to string
@@ -8880,7 +8880,7 @@ iwn_debug_register(struct iwn_softc *sc)
DPRINTF(sc, IWN_DEBUG_REGISTER,
"CSR values: (2nd byte of IWN_INT_COALESCING is IWN_INT_PERIODIC)%s",
"\n");
- for (i = 0; i < COUNTOF(csr_tbl); i++){
+ for (i = 0; i < nitems(csr_tbl); i++){
DPRINTF(sc, IWN_DEBUG_REGISTER," %10s: 0x%08x ",
iwn_get_csr_string(csr_tbl[i]), IWN_READ(sc, csr_tbl[i]));
if ((i+1) % 3 == 0)
diff --git a/sys/dev/ixgbe/if_ix.c b/sys/dev/ixgbe/if_ix.c
index 48ff9d1..b9bba31 100644
--- a/sys/dev/ixgbe/if_ix.c
+++ b/sys/dev/ixgbe/if_ix.c
@@ -54,7 +54,7 @@ int ixgbe_display_debug_stats = 0;
/*********************************************************************
* Driver version
*********************************************************************/
-char ixgbe_driver_version[] = "2.7.4";
+char ixgbe_driver_version[] = "2.8.3";
/*********************************************************************
* PCI Device ID Table
@@ -117,6 +117,8 @@ static int ixgbe_probe(device_t);
static int ixgbe_attach(device_t);
static int ixgbe_detach(device_t);
static int ixgbe_shutdown(device_t);
+static int ixgbe_suspend(device_t);
+static int ixgbe_resume(device_t);
static int ixgbe_ioctl(struct ifnet *, u_long, caddr_t);
static void ixgbe_init(void *);
static void ixgbe_init_locked(struct adapter *);
@@ -136,7 +138,12 @@ static int ixgbe_setup_msix(struct adapter *);
static void ixgbe_free_pci_resources(struct adapter *);
static void ixgbe_local_timer(void *);
static int ixgbe_setup_interface(device_t, struct adapter *);
+static void ixgbe_config_dmac(struct adapter *);
+static void ixgbe_config_delay_values(struct adapter *);
static void ixgbe_config_link(struct adapter *);
+static void ixgbe_check_eee_support(struct adapter *);
+static void ixgbe_check_wol_support(struct adapter *);
+static int ixgbe_setup_low_power_mode(struct adapter *);
static void ixgbe_rearm_queues(struct adapter *, u64);
static void ixgbe_initialize_transmit_units(struct adapter *);
@@ -150,9 +157,6 @@ static void ixgbe_update_stats_counters(struct adapter *);
static void ixgbe_set_promisc(struct adapter *);
static void ixgbe_set_multi(struct adapter *);
static void ixgbe_update_link_status(struct adapter *);
-static int ixgbe_set_flowcntl(SYSCTL_HANDLER_ARGS);
-static int ixgbe_set_advertise(SYSCTL_HANDLER_ARGS);
-static int ixgbe_set_thermal_test(SYSCTL_HANDLER_ARGS);
static void ixgbe_set_ivar(struct adapter *, u8, u8, s8);
static void ixgbe_configure_ivars(struct adapter *);
static u8 * ixgbe_mc_array_itr(struct ixgbe_hw *, u8 **, u32 *);
@@ -161,7 +165,22 @@ static void ixgbe_setup_vlan_hw_support(struct adapter *);
static void ixgbe_register_vlan(void *, struct ifnet *, u16);
static void ixgbe_unregister_vlan(void *, struct ifnet *, u16);
-static void ixgbe_add_hw_stats(struct adapter *adapter);
+static void ixgbe_add_device_sysctls(struct adapter *);
+static void ixgbe_add_hw_stats(struct adapter *);
+
+/* Sysctl handlers */
+static int ixgbe_set_flowcntl(SYSCTL_HANDLER_ARGS);
+static int ixgbe_set_advertise(SYSCTL_HANDLER_ARGS);
+static int ixgbe_sysctl_thermal_test(SYSCTL_HANDLER_ARGS);
+static int ixgbe_sysctl_dmac(SYSCTL_HANDLER_ARGS);
+static int ixgbe_sysctl_phy_temp(SYSCTL_HANDLER_ARGS);
+static int ixgbe_sysctl_phy_overtemp_occurred(SYSCTL_HANDLER_ARGS);
+static int ixgbe_sysctl_wol_enable(SYSCTL_HANDLER_ARGS);
+static int ixgbe_sysctl_wufc(SYSCTL_HANDLER_ARGS);
+static int ixgbe_sysctl_eee_enable(SYSCTL_HANDLER_ARGS);
+static int ixgbe_sysctl_eee_negotiated(SYSCTL_HANDLER_ARGS);
+static int ixgbe_sysctl_eee_rx_lpi_status(SYSCTL_HANDLER_ARGS);
+static int ixgbe_sysctl_eee_tx_lpi_status(SYSCTL_HANDLER_ARGS);
/* Support for pluggable optic modules */
static bool ixgbe_sfp_probe(struct adapter *);
@@ -179,15 +198,12 @@ static void ixgbe_handle_que(void *, int);
static void ixgbe_handle_link(void *, int);
static void ixgbe_handle_msf(void *, int);
static void ixgbe_handle_mod(void *, int);
+static void ixgbe_handle_phy(void *, int);
#ifdef IXGBE_FDIR
static void ixgbe_reinit_fdir(void *, int);
#endif
-
-/* Missing shared code prototype */
-extern void ixgbe_stop_mac_link_on_d3_82599(struct ixgbe_hw *hw);
-
/*********************************************************************
* FreeBSD Device Interface Entry Points
*********************************************************************/
@@ -198,6 +214,8 @@ static device_method_t ix_methods[] = {
DEVMETHOD(device_attach, ixgbe_attach),
DEVMETHOD(device_detach, ixgbe_detach),
DEVMETHOD(device_shutdown, ixgbe_shutdown),
+ DEVMETHOD(device_suspend, ixgbe_suspend),
+ DEVMETHOD(device_resume, ixgbe_resume),
DEVMETHOD_END
};
@@ -404,32 +422,6 @@ ixgbe_attach(device_t dev)
/* Core Lock Init*/
IXGBE_CORE_LOCK_INIT(adapter, device_get_nameunit(dev));
- /* SYSCTL APIs */
- SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
- SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
- OID_AUTO, "fc", CTLTYPE_INT | CTLFLAG_RW,
- adapter, 0, ixgbe_set_flowcntl, "I", IXGBE_SYSCTL_DESC_SET_FC);
-
- SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
- SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
- OID_AUTO, "enable_aim", CTLFLAG_RW,
- &ixgbe_enable_aim, 1, "Interrupt Moderation");
-
- /*
- ** Allow a kind of speed control by forcing the autoneg
- ** advertised speed list to only a certain value, this
- ** supports 1G on 82599 devices, and 100Mb on x540.
- */
- SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
- SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
- OID_AUTO, "advertise_speed", CTLTYPE_INT | CTLFLAG_RW,
- adapter, 0, ixgbe_set_advertise, "I", IXGBE_SYSCTL_DESC_ADV_SPEED);
-
- SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
- SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
- OID_AUTO, "ts", CTLTYPE_INT | CTLFLAG_RW, adapter,
- 0, ixgbe_set_thermal_test, "I", "Thermal Test");
-
/* Set up the timer callout */
callout_init_mtx(&adapter->timer, &adapter->core_mtx, 0);
@@ -559,22 +551,26 @@ ixgbe_attach(device_t dev)
adapter->vlan_detach = EVENTHANDLER_REGISTER(vlan_unconfig,
ixgbe_unregister_vlan, adapter, EVENTHANDLER_PRI_FIRST);
- /*
- ** Check PCIE slot type/speed/width
- */
+ /* Check PCIE slot type/speed/width */
ixgbe_get_slot_info(hw);
/* Set an initial default flow control value */
adapter->fc = ixgbe_fc_full;
+ /* Check for certain supported features */
+ ixgbe_check_wol_support(adapter);
+ ixgbe_check_eee_support(adapter);
+
+ /* Add sysctls */
+ ixgbe_add_device_sysctls(adapter);
+ ixgbe_add_hw_stats(adapter);
+
/* let hardware know driver is loaded */
ctrl_ext = IXGBE_READ_REG(hw, IXGBE_CTRL_EXT);
ctrl_ext |= IXGBE_CTRL_EXT_DRV_LOAD;
IXGBE_WRITE_REG(hw, IXGBE_CTRL_EXT, ctrl_ext);
- ixgbe_add_hw_stats(adapter);
-
#ifdef DEV_NETMAP
ixgbe_netmap_attach(adapter);
#endif /* DEV_NETMAP */
@@ -618,8 +614,9 @@ ixgbe_detach(device_t dev)
return (EBUSY);
}
+ /* Stop the adapter */
IXGBE_CORE_LOCK(adapter);
- ixgbe_stop(adapter);
+ ixgbe_setup_low_power_mode(adapter);
IXGBE_CORE_UNLOCK(adapter);
for (int i = 0; i < adapter->num_queues; i++, que++, txr++) {
@@ -637,6 +634,7 @@ ixgbe_detach(device_t dev)
taskqueue_drain(adapter->tq, &adapter->link_task);
taskqueue_drain(adapter->tq, &adapter->mod_task);
taskqueue_drain(adapter->tq, &adapter->msf_task);
+ taskqueue_drain(adapter->tq, &adapter->phy_task);
#ifdef IXGBE_FDIR
taskqueue_drain(adapter->tq, &adapter->fdir_task);
#endif
@@ -681,9 +679,77 @@ static int
ixgbe_shutdown(device_t dev)
{
struct adapter *adapter = device_get_softc(dev);
+ int error = 0;
+
+ INIT_DEBUGOUT("ixgbe_shutdown: begin");
+
IXGBE_CORE_LOCK(adapter);
- ixgbe_stop(adapter);
+ error = ixgbe_setup_low_power_mode(adapter);
+ IXGBE_CORE_UNLOCK(adapter);
+
+ return (error);
+}
+
+/**
+ * Methods for going from:
+ * D0 -> D3: ixgbe_suspend
+ * D3 -> D0: ixgbe_resume
+ */
+static int
+ixgbe_suspend(device_t dev)
+{
+ struct adapter *adapter = device_get_softc(dev);
+ int error = 0;
+
+ INIT_DEBUGOUT("ixgbe_suspend: begin");
+
+ IXGBE_CORE_LOCK(adapter);
+
+ error = ixgbe_setup_low_power_mode(adapter);
+
+ /* Save state and power down */
+ pci_save_state(dev);
+ pci_set_powerstate(dev, PCI_POWERSTATE_D3);
+
+ IXGBE_CORE_UNLOCK(adapter);
+
+ return (error);
+}
+
+static int
+ixgbe_resume(device_t dev)
+{
+ struct adapter *adapter = device_get_softc(dev);
+ struct ifnet *ifp = adapter->ifp;
+ struct ixgbe_hw *hw = &adapter->hw;
+ u32 wus;
+
+ INIT_DEBUGOUT("ixgbe_resume: begin");
+
+ IXGBE_CORE_LOCK(adapter);
+
+ pci_set_powerstate(dev, PCI_POWERSTATE_D0);
+ pci_restore_state(dev);
+
+ /* Read & clear WUS register */
+ wus = IXGBE_READ_REG(hw, IXGBE_WUS);
+ if (wus)
+ device_printf(dev, "Woken up by (WUS): %#010x\n",
+ IXGBE_READ_REG(hw, IXGBE_WUS));
+ IXGBE_WRITE_REG(hw, IXGBE_WUS, 0xffffffff);
+ /* And clear WUFC until next low-power transition */
+ IXGBE_WRITE_REG(hw, IXGBE_WUFC, 0);
+
+ /*
+ * Required after D3->D0 transition;
+ * will re-advertise all previous advertised speeds
+ */
+ if (ifp->if_flags & IFF_UP)
+ ixgbe_init_locked(adapter);
+
IXGBE_CORE_UNLOCK(adapter);
+
+ INIT_DEBUGOUT("ixgbe_resume: end");
return (0);
}
@@ -736,13 +802,13 @@ ixgbe_ioctl(struct ifnet * ifp, u_long command, caddr_t data)
break;
case SIOCSIFMTU:
IOCTL_DEBUGOUT("ioctl: SIOCSIFMTU (Set Interface MTU)");
- if (ifr->ifr_mtu > IXGBE_MAX_FRAME_SIZE - ETHER_HDR_LEN) {
+ if (ifr->ifr_mtu > IXGBE_MAX_MTU) {
error = EINVAL;
} else {
IXGBE_CORE_LOCK(adapter);
ifp->if_mtu = ifr->ifr_mtu;
adapter->max_frame_size =
- ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+ ifp->if_mtu + IXGBE_MTU_HDR;
ixgbe_init_locked(adapter);
IXGBE_CORE_UNLOCK(adapter);
}
@@ -891,7 +957,7 @@ ixgbe_init_locked(struct adapter *adapter)
/* Prepare transmit descriptors and buffers */
if (ixgbe_setup_transmit_structures(adapter)) {
- device_printf(dev,"Could not setup transmit structures\n");
+ device_printf(dev, "Could not setup transmit structures\n");
ixgbe_stop(adapter);
return;
}
@@ -917,7 +983,7 @@ ixgbe_init_locked(struct adapter *adapter)
/* Prepare receive descriptors and buffers */
if (ixgbe_setup_receive_structures(adapter)) {
- device_printf(dev,"Could not setup receive structures\n");
+ device_printf(dev, "Could not setup receive structures\n");
ixgbe_stop(adapter);
return;
}
@@ -932,11 +998,16 @@ ixgbe_init_locked(struct adapter *adapter)
/* Add for Module detection */
if (hw->mac.type == ixgbe_mac_82599EB)
- gpie |= IXGBE_SDP2_GPIEN_BY_MAC(hw);
+ gpie |= IXGBE_SDP2_GPIEN;
- /* Thermal Failure Detection */
- if (hw->mac.type == ixgbe_mac_X540)
- gpie |= IXGBE_SDP0_GPIEN_BY_MAC(hw);
+ /*
+ * Thermal Failure Detection (X540)
+ * Link Detection (X552)
+ */
+ if (hw->mac.type == ixgbe_mac_X540 ||
+ hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP ||
+ hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T)
+ gpie |= IXGBE_SDP0_GPIEN_X540;
if (adapter->msix > 1) {
/* Enable Enhanced MSIX mode */
@@ -948,6 +1019,7 @@ ixgbe_init_locked(struct adapter *adapter)
/* Set MTU size */
if (ifp->if_mtu > ETHERMTU) {
+ /* aka IXGBE_MAXFRS on 82599 and newer */
mhadd = IXGBE_READ_REG(hw, IXGBE_MHADD);
mhadd &= ~IXGBE_MHADD_MFS_MASK;
mhadd |= adapter->max_frame_size << IXGBE_MHADD_MFS_SHIFT;
@@ -955,7 +1027,6 @@ ixgbe_init_locked(struct adapter *adapter)
}
/* Now enable all the queues */
-
for (int i = 0; i < adapter->num_queues; i++) {
txdctl = IXGBE_READ_REG(hw, IXGBE_TXDCTL(i));
txdctl |= IXGBE_TXDCTL_ENABLE;
@@ -1072,55 +1143,25 @@ ixgbe_init_locked(struct adapter *adapter)
/* Set moderation on the Link interrupt */
IXGBE_WRITE_REG(hw, IXGBE_EITR(adapter->vector), IXGBE_LINK_ITR);
+ /* Configure Energy Efficient Ethernet for supported devices */
+ if (adapter->eee_support)
+ ixgbe_setup_eee(hw, adapter->eee_enabled);
+
/* Config/Enable Link */
ixgbe_config_link(adapter);
/* Hardware Packet Buffer & Flow Control setup */
- {
- u32 rxpb, frame, size, tmp;
-
- frame = adapter->max_frame_size;
+ ixgbe_config_delay_values(adapter);
- /* Calculate High Water */
- switch (hw->mac.type) {
- case ixgbe_mac_X540:
- case ixgbe_mac_X550:
- case ixgbe_mac_X550EM_a:
- case ixgbe_mac_X550EM_x:
- tmp = IXGBE_DV_X540(frame, frame);
- break;
- default:
- tmp = IXGBE_DV(frame, frame);
- break;
- }
- size = IXGBE_BT2KB(tmp);
- rxpb = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(0)) >> 10;
- hw->fc.high_water[0] = rxpb - size;
-
- /* Now calculate Low Water */
- switch (hw->mac.type) {
- case ixgbe_mac_X540:
- case ixgbe_mac_X550:
- case ixgbe_mac_X550EM_a:
- case ixgbe_mac_X550EM_x:
- tmp = IXGBE_LOW_DV_X540(frame);
- break;
- default:
- tmp = IXGBE_LOW_DV(frame);
- break;
- }
- hw->fc.low_water[0] = IXGBE_BT2KB(tmp);
-
- hw->fc.requested_mode = adapter->fc;
- hw->fc.pause_time = IXGBE_FC_PAUSE;
- hw->fc.send_xon = TRUE;
- }
/* Initialize the FC settings */
ixgbe_start_hw(hw);
/* Set up VLAN support and filter */
ixgbe_setup_vlan_hw_support(adapter);
+ /* Setup DMA Coalescing */
+ ixgbe_config_dmac(adapter);
+
/* And now turn on interrupts */
ixgbe_enable_intr(adapter);
@@ -1141,6 +1182,46 @@ ixgbe_init(void *arg)
return;
}
+static void
+ixgbe_config_delay_values(struct adapter *adapter)
+{
+ struct ixgbe_hw *hw = &adapter->hw;
+ u32 rxpb, frame, size, tmp;
+
+ frame = adapter->max_frame_size;
+
+ /* Calculate High Water */
+ switch (hw->mac.type) {
+ case ixgbe_mac_X540:
+ case ixgbe_mac_X550:
+ case ixgbe_mac_X550EM_x:
+ tmp = IXGBE_DV_X540(frame, frame);
+ break;
+ default:
+ tmp = IXGBE_DV(frame, frame);
+ break;
+ }
+ size = IXGBE_BT2KB(tmp);
+ rxpb = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(0)) >> 10;
+ hw->fc.high_water[0] = rxpb - size;
+
+ /* Now calculate Low Water */
+ switch (hw->mac.type) {
+ case ixgbe_mac_X540:
+ case ixgbe_mac_X550:
+ case ixgbe_mac_X550EM_x:
+ tmp = IXGBE_LOW_DV_X540(frame);
+ break;
+ default:
+ tmp = IXGBE_LOW_DV(frame);
+ break;
+ }
+ hw->fc.low_water[0] = IXGBE_BT2KB(tmp);
+
+ hw->fc.requested_mode = adapter->fc;
+ hw->fc.pause_time = IXGBE_FC_PAUSE;
+ hw->fc.send_xon = TRUE;
+}
/*
**
@@ -1195,9 +1276,10 @@ ixgbe_handle_que(void *context, int pending)
struct adapter *adapter = que->adapter;
struct tx_ring *txr = que->txr;
struct ifnet *ifp = adapter->ifp;
+ bool more;
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
- ixgbe_rxeof(que);
+ more = ixgbe_rxeof(que);
IXGBE_TX_LOCK(txr);
ixgbe_txeof(txr);
#ifndef IXGBE_LEGACY_TX
@@ -1270,6 +1352,11 @@ ixgbe_legacy_irq(void *arg)
if (reg_eicr & IXGBE_EICR_LSC)
taskqueue_enqueue(adapter->tq, &adapter->link_task);
+ /* External PHY interrupt */
+ if (hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T &&
+ (reg_eicr & IXGBE_EICR_GPI_SDP0_X540))
+ taskqueue_enqueue(adapter->tq, &adapter->phy_task);
+
if (more)
taskqueue_enqueue(que->tq, &que->que_task);
else
@@ -1378,9 +1465,9 @@ ixgbe_msix_link(void *arg)
{
struct adapter *adapter = arg;
struct ixgbe_hw *hw = &adapter->hw;
- u32 reg_eicr;
+ u32 reg_eicr, mod_mask;
- ++adapter->vector_irq;
+ ++adapter->link_irq;
/* First get the cause */
reg_eicr = IXGBE_READ_REG(hw, IXGBE_EICS);
@@ -1408,42 +1495,46 @@ ixgbe_msix_link(void *arg)
device_printf(adapter->dev, "\nCRITICAL: ECC ERROR!! "
"Please Reboot!!\n");
IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_ECC);
- } else
+ }
- if (ixgbe_is_sfp(hw)) {
- if (reg_eicr & IXGBE_EICR_GPI_SDP1) {
- IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1_BY_MAC(hw));
- taskqueue_enqueue(adapter->tq, &adapter->msf_task);
- } else if (reg_eicr & IXGBE_EICR_GPI_SDP2) {
- IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP2_BY_MAC(hw));
- taskqueue_enqueue(adapter->tq, &adapter->mod_task);
- }
+ /* Check for over temp condition */
+ if (reg_eicr & IXGBE_EICR_TS) {
+ device_printf(adapter->dev, "\nCRITICAL: OVER TEMP!! "
+ "PHY IS SHUT DOWN!!\n");
+ device_printf(adapter->dev, "System shutdown required!\n");
+ IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_TS);
}
- }
+ }
+
+ /* Pluggable optics-related interrupt */
+ if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
+ mod_mask = IXGBE_EICR_GPI_SDP0_X540;
+ else
+ mod_mask = IXGBE_EICR_GPI_SDP2_BY_MAC(hw);
+
+ if (ixgbe_is_sfp(hw)) {
+ if (reg_eicr & IXGBE_EICR_GPI_SDP1_BY_MAC(hw)) {
+ IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1_BY_MAC(hw));
+ taskqueue_enqueue(adapter->tq, &adapter->msf_task);
+ } else if (reg_eicr & mod_mask) {
+ IXGBE_WRITE_REG(hw, IXGBE_EICR, mod_mask);
+ taskqueue_enqueue(adapter->tq, &adapter->mod_task);
+ }
+ }
/* Check for fan failure */
if ((hw->device_id == IXGBE_DEV_ID_82598AT) &&
- (reg_eicr & IXGBE_EICR_GPI_SDP1_BY_MAC(hw))) {
+ (reg_eicr & IXGBE_EICR_GPI_SDP1)) {
+ IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1);
device_printf(adapter->dev, "\nCRITICAL: FAN FAILURE!! "
"REPLACE IMMEDIATELY!!\n");
- IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP1_BY_MAC(hw));
}
- /* Check for over temp condition */
- switch (hw->mac.type) {
- case ixgbe_mac_X540:
- case ixgbe_mac_X550:
- case ixgbe_mac_X550EM_a:
- if (reg_eicr & IXGBE_EICR_TS) {
- device_printf(adapter->dev, "\nCRITICAL: OVER TEMP!! "
- "PHY IS SHUT DOWN!!\n");
- device_printf(adapter->dev, "System shutdown required\n");
- IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_TS);
- }
- break;
- default:
- /* Other MACs have no thermal sensor interrupt */
- break;
+ /* External PHY interrupt */
+ if (hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T &&
+ (reg_eicr & IXGBE_EICR_GPI_SDP0_X540)) {
+ IXGBE_WRITE_REG(hw, IXGBE_EICR, IXGBE_EICR_GPI_SDP0_X540);
+ taskqueue_enqueue(adapter->tq, &adapter->phy_task);
}
IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, IXGBE_EIMS_OTHER);
@@ -1542,20 +1633,26 @@ ixgbe_media_status(struct ifnet * ifp, struct ifmediareq * ifmr)
if (layer & IXGBE_PHYSICAL_LAYER_10GBASE_KR)
switch (adapter->link_speed) {
case IXGBE_LINK_SPEED_10GB_FULL:
- ifmr->ifm_active |= IFM_10_T | IFM_FDX;
+ ifmr->ifm_active |= IFM_10G_SR | IFM_FDX;
+ break;
+ case IXGBE_LINK_SPEED_2_5GB_FULL:
+ ifmr->ifm_active |= IFM_2500_SX | IFM_FDX;
break;
case IXGBE_LINK_SPEED_1GB_FULL:
- ifmr->ifm_active |= IFM_10_5 | IFM_FDX;
+ ifmr->ifm_active |= IFM_1000_CX | IFM_FDX;
break;
}
- if (layer & IXGBE_PHYSICAL_LAYER_10GBASE_KX4
+ else if (layer & IXGBE_PHYSICAL_LAYER_10GBASE_KX4
|| layer & IXGBE_PHYSICAL_LAYER_1000BASE_KX)
switch (adapter->link_speed) {
case IXGBE_LINK_SPEED_10GB_FULL:
- ifmr->ifm_active |= IFM_10_2 | IFM_FDX;
+ ifmr->ifm_active |= IFM_10G_CX4 | IFM_FDX;
+ break;
+ case IXGBE_LINK_SPEED_2_5GB_FULL:
+ ifmr->ifm_active |= IFM_2500_SX | IFM_FDX;
break;
case IXGBE_LINK_SPEED_1GB_FULL:
- ifmr->ifm_active |= IFM_10_5 | IFM_FDX;
+ ifmr->ifm_active |= IFM_1000_CX | IFM_FDX;
break;
}
@@ -1564,10 +1661,12 @@ ixgbe_media_status(struct ifnet * ifp, struct ifmediareq * ifmr)
ifmr->ifm_active |= IFM_UNKNOWN;
#if __FreeBSD_version >= 900025
- /* Flow control setting */
- if (adapter->fc == ixgbe_fc_rx_pause || adapter->fc == ixgbe_fc_full)
+ /* Display current flow control setting used on link */
+ if (hw->fc.current_mode == ixgbe_fc_rx_pause ||
+ hw->fc.current_mode == ixgbe_fc_full)
ifmr->ifm_active |= IFM_ETH_RXPAUSE;
- if (adapter->fc == ixgbe_fc_tx_pause || adapter->fc == ixgbe_fc_full)
+ if (hw->fc.current_mode == ixgbe_fc_tx_pause ||
+ hw->fc.current_mode == ixgbe_fc_full)
ifmr->ifm_active |= IFM_ETH_TXPAUSE;
#endif
@@ -1597,21 +1696,22 @@ ixgbe_media_change(struct ifnet * ifp)
if (IFM_TYPE(ifm->ifm_media) != IFM_ETHER)
return (EINVAL);
+ if (hw->phy.media_type == ixgbe_media_type_backplane)
+ return (EPERM);
+
/*
** We don't actually need to check against the supported
** media types of the adapter; ifmedia will take care of
** that for us.
- ** NOTE: this relies on falling thru the switch
- ** to get all the values set, it can be confusing.
*/
switch (IFM_SUBTYPE(ifm->ifm_media)) {
case IFM_AUTO:
case IFM_10G_T:
speed |= IXGBE_LINK_SPEED_100_FULL;
case IFM_10G_LRM:
- case IFM_10G_SR: /* KR, too */
+ case IFM_10G_SR: /* KR, too */
case IFM_10G_LR:
- case IFM_10G_CX4: /* KX4 for now */
+ case IFM_10G_CX4: /* KX4 */
speed |= IXGBE_LINK_SPEED_1GB_FULL;
case IFM_10G_TWINAX:
speed |= IXGBE_LINK_SPEED_10GB_FULL;
@@ -1620,7 +1720,7 @@ ixgbe_media_change(struct ifnet * ifp)
speed |= IXGBE_LINK_SPEED_100_FULL;
case IFM_1000_LX:
case IFM_1000_SX:
- case IFM_1000_CX: /* KX until there's real support */
+ case IFM_1000_CX: /* KX */
speed |= IXGBE_LINK_SPEED_1GB_FULL;
break;
case IFM_100_TX:
@@ -1640,7 +1740,7 @@ ixgbe_media_change(struct ifnet * ifp)
return (0);
invalid:
- device_printf(adapter->dev, "Invalid media type\n");
+ device_printf(adapter->dev, "Invalid media type!\n");
return (EINVAL);
}
@@ -1865,7 +1965,6 @@ ixgbe_update_link_status(struct adapter *adapter)
struct ifnet *ifp = adapter->ifp;
device_t dev = adapter->dev;
-
if (adapter->link_up){
if (adapter->link_active == FALSE) {
if (bootverbose)
@@ -1875,6 +1974,8 @@ ixgbe_update_link_status(struct adapter *adapter)
adapter->link_active = TRUE;
/* Update any Flow Control changes */
ixgbe_fc_enable(&adapter->hw);
+ /* Update DMA coalescing config */
+ ixgbe_config_dmac(adapter);
if_link_state_change(ifp, LINK_STATE_UP);
}
} else { /* Link down */
@@ -1961,7 +2062,7 @@ ixgbe_identify_hardware(struct adapter *adapter)
/* We need this here to set the num_segs below */
ixgbe_set_mac_type(hw);
- /* Pick up the 82599 and VF settings */
+ /* Pick up the 82599 settings */
if (hw->mac.type != ixgbe_mac_82598EB) {
hw->phy.smart_speed = ixgbe_smart_speed;
adapter->num_segs = IXGBE_82599_SCATTER;
@@ -2071,6 +2172,7 @@ ixgbe_allocate_legacy(struct adapter *adapter)
TASK_INIT(&adapter->link_task, 0, ixgbe_handle_link, adapter);
TASK_INIT(&adapter->mod_task, 0, ixgbe_handle_mod, adapter);
TASK_INIT(&adapter->msf_task, 0, ixgbe_handle_msf, adapter);
+ TASK_INIT(&adapter->phy_task, 0, ixgbe_handle_phy, adapter);
#ifdef IXGBE_FDIR
TASK_INIT(&adapter->fdir_task, 0, ixgbe_reinit_fdir, adapter);
#endif
@@ -2136,8 +2238,6 @@ ixgbe_allocate_msix(struct adapter *adapter)
}
#endif
-
-
for (int i = 0; i < adapter->num_queues; i++, vector++, que++, txr++) {
rid = vector + 1;
que->res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
@@ -2187,14 +2287,11 @@ ixgbe_allocate_msix(struct adapter *adapter)
"Bound RSS bucket %d to CPU %d\n",
i, cpu_id);
#else
-#if 0 // This is too noisy
- device_printf(dev,
- "Bound queue %d to cpu %d\n",
- i, cpu_id);
-#endif
+ if (bootverbose)
+ device_printf(dev,
+ "Bound queue %d to cpu %d\n",
+ i, cpu_id);
#endif
-
-
#ifndef IXGBE_LEGACY_TX
TASK_INIT(&txr->txq_task, 0, ixgbe_deferred_mq_start, txr);
#endif
@@ -2240,6 +2337,7 @@ ixgbe_allocate_msix(struct adapter *adapter)
TASK_INIT(&adapter->link_task, 0, ixgbe_handle_link, adapter);
TASK_INIT(&adapter->mod_task, 0, ixgbe_handle_mod, adapter);
TASK_INIT(&adapter->msf_task, 0, ixgbe_handle_msf, adapter);
+ TASK_INIT(&adapter->phy_task, 0, ixgbe_handle_phy, adapter);
#ifdef IXGBE_FDIR
TASK_INIT(&adapter->fdir_task, 0, ixgbe_reinit_fdir, adapter);
#endif
@@ -2465,6 +2563,12 @@ ixgbe_setup_interface(device_t dev, struct adapter *adapter)
#if __FreeBSD_version >= 1100036
if_setgetcounterfn(ifp, ixgbe_get_counter);
#endif
+#if __FreeBSD_version >= 1100045
+ /* TSO parameters */
+ ifp->if_hw_tsomax = 65518;
+ ifp->if_hw_tsomaxsegcount = IXGBE_82599_SCATTER;
+ ifp->if_hw_tsomaxsegsize = 2048;
+#endif
#ifndef IXGBE_LEGACY_TX
ifp->if_transmit = ixgbe_mq_start;
ifp->if_qflush = ixgbe_qflush;
@@ -2548,10 +2652,6 @@ ixgbe_add_media_types(struct adapter *adapter)
ifmedia_add(&adapter->media, IFM_ETHER | IFM_10G_CX4, 0, NULL);
if (layer & IXGBE_PHYSICAL_LAYER_1000BASE_SX)
ifmedia_add(&adapter->media, IFM_ETHER | IFM_1000_SX, 0, NULL);
-#if 0
- if (layer & IXGBE_PHYSICAL_LAYER_1000BASE_LX)
- ifmedia_add(&adapter->media, IFM_ETHER | IFM_1000_LX, 0, NULL);
-#endif
/*
** Other (no matching FreeBSD media type):
@@ -2560,25 +2660,24 @@ ixgbe_add_media_types(struct adapter *adapter)
*/
if (layer & IXGBE_PHYSICAL_LAYER_10GBASE_KR) {
device_printf(dev, "Media supported: 10GbaseKR\n");
- device_printf(dev, "10GbaseKR mapped to 10baseT\n");
- ifmedia_add(&adapter->media, IFM_ETHER | IFM_10_T, 0, NULL);
+ device_printf(dev, "10GbaseKR mapped to 10GbaseSR\n");
+ ifmedia_add(&adapter->media, IFM_ETHER | IFM_10G_SR, 0, NULL);
}
if (layer & IXGBE_PHYSICAL_LAYER_10GBASE_KX4) {
device_printf(dev, "Media supported: 10GbaseKX4\n");
- device_printf(dev, "10GbaseKX4 mapped to 10base2\n");
- ifmedia_add(&adapter->media, IFM_ETHER | IFM_10_2, 0, NULL);
+ device_printf(dev, "10GbaseKX4 mapped to 10GbaseCX4\n");
+ ifmedia_add(&adapter->media, IFM_ETHER | IFM_10G_CX4, 0, NULL);
}
if (layer & IXGBE_PHYSICAL_LAYER_1000BASE_KX) {
device_printf(dev, "Media supported: 1000baseKX\n");
- device_printf(dev, "1000baseKX mapped to 10base5\n");
- ifmedia_add(&adapter->media, IFM_ETHER | IFM_10_5, 0, NULL);
+ device_printf(dev, "1000baseKX mapped to 1000baseCX\n");
+ ifmedia_add(&adapter->media, IFM_ETHER | IFM_1000_CX, 0, NULL);
}
if (layer & IXGBE_PHYSICAL_LAYER_1000BASE_BX) {
/* Someday, someone will care about you... */
device_printf(dev, "Media supported: 1000baseBX\n");
}
- /* Very old */
if (hw->device_id == IXGBE_DEV_ID_82598AT) {
ifmedia_add(&adapter->media,
IFM_ETHER | IFM_1000_T | IFM_FDX, 0, NULL);
@@ -2706,7 +2805,8 @@ ixgbe_initialise_rss_mapping(struct adapter *adapter)
{
struct ixgbe_hw *hw = &adapter->hw;
uint32_t reta;
- int i, j, queue_id;
+ int i, j, queue_id, table_size;
+ int index_mult;
uint32_t rss_key[10];
uint32_t mrqc;
#ifdef RSS
@@ -2724,8 +2824,23 @@ ixgbe_initialise_rss_mapping(struct adapter *adapter)
arc4rand(&rss_key, sizeof(rss_key), 0);
#endif
+ /* Set multiplier for RETA setup and table size based on MAC */
+ index_mult = 0x1;
+ table_size = 128;
+ switch (adapter->hw.mac.type) {
+ case ixgbe_mac_82598EB:
+ index_mult = 0x11;
+ break;
+ case ixgbe_mac_X550:
+ case ixgbe_mac_X550EM_x:
+ table_size = 512;
+ break;
+ default:
+ break;
+ }
+
/* Set up the redirection table */
- for (i = 0, j = 0; i < 128; i++, j++) {
+ for (i = 0, j = 0; i < table_size; i++, j++) {
if (j == adapter->num_queues) j = 0;
#ifdef RSS
/*
@@ -2736,7 +2851,7 @@ ixgbe_initialise_rss_mapping(struct adapter *adapter)
queue_id = rss_get_indirection_to_bucket(i);
queue_id = queue_id % adapter->num_queues;
#else
- queue_id = (j * 0x11);
+ queue_id = (j * index_mult);
#endif
/*
* The low 8 bits are for hash value (n+0);
@@ -2745,7 +2860,10 @@ ixgbe_initialise_rss_mapping(struct adapter *adapter)
reta = reta >> 8;
reta = reta | ( ((uint32_t) queue_id) << 24);
if ((i & 3) == 3) {
- IXGBE_WRITE_REG(hw, IXGBE_RETA(i >> 2), reta);
+ if (i < 128)
+ IXGBE_WRITE_REG(hw, IXGBE_RETA(i >> 2), reta);
+ else
+ IXGBE_WRITE_REG(hw, IXGBE_ERETA((i >> 2) - 32), reta);
reta = 0;
}
}
@@ -2834,8 +2952,10 @@ ixgbe_initialize_receive_units(struct adapter *adapter)
/* Enable broadcasts */
fctrl = IXGBE_READ_REG(hw, IXGBE_FCTRL);
fctrl |= IXGBE_FCTRL_BAM;
- fctrl |= IXGBE_FCTRL_DPF;
- fctrl |= IXGBE_FCTRL_PMCF;
+ if (adapter->hw.mac.type == ixgbe_mac_82598EB) {
+ fctrl |= IXGBE_FCTRL_DPF;
+ fctrl |= IXGBE_FCTRL_PMCF;
+ }
IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl);
/* Set for Jumbo Frames? */
@@ -3045,30 +3165,37 @@ ixgbe_enable_intr(struct adapter *adapter)
mask = (IXGBE_EIMS_ENABLE_MASK & ~IXGBE_EIMS_RTX_QUEUE);
/* Enable Fan Failure detection */
if (hw->device_id == IXGBE_DEV_ID_82598AT)
- mask |= IXGBE_EIMS_GPI_SDP1_BY_MAC(hw);
+ mask |= IXGBE_EIMS_GPI_SDP1;
switch (adapter->hw.mac.type) {
case ixgbe_mac_82599EB:
mask |= IXGBE_EIMS_ECC;
/* Temperature sensor on some adapters */
- mask |= IXGBE_EIMS_GPI_SDP0_BY_MAC(hw);
+ mask |= IXGBE_EIMS_GPI_SDP0;
/* SFP+ (RX_LOS_N & MOD_ABS_N) */
- mask |= IXGBE_EIMS_GPI_SDP1_BY_MAC(hw);
- mask |= IXGBE_EIMS_GPI_SDP2_BY_MAC(hw);
+ mask |= IXGBE_EIMS_GPI_SDP1;
+ mask |= IXGBE_EIMS_GPI_SDP2;
#ifdef IXGBE_FDIR
mask |= IXGBE_EIMS_FLOW_DIR;
#endif
break;
case ixgbe_mac_X540:
- case ixgbe_mac_X550:
- case ixgbe_mac_X550EM_a:
- case ixgbe_mac_X550EM_x:
/* Detect if Thermal Sensor is enabled */
fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM);
if (fwsm & IXGBE_FWSM_TS_ENABLED)
mask |= IXGBE_EIMS_TS;
- /* XXX: Which SFP mode line does this look at? */
- if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
+ mask |= IXGBE_EIMS_ECC;
+#ifdef IXGBE_FDIR
+ mask |= IXGBE_EIMS_FLOW_DIR;
+#endif
+ break;
+ case ixgbe_mac_X550:
+ case ixgbe_mac_X550EM_x:
+ /* MAC thermal sensor is automatically enabled */
+ mask |= IXGBE_EIMS_TS;
+ /* Some devices use SDP0 for important information */
+ if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP ||
+ hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T)
mask |= IXGBE_EIMS_GPI_SDP0_BY_MAC(hw);
mask |= IXGBE_EIMS_ECC;
#ifdef IXGBE_FDIR
@@ -3081,7 +3208,7 @@ ixgbe_enable_intr(struct adapter *adapter)
IXGBE_WRITE_REG(hw, IXGBE_EIMS, mask);
- /* With RSS we use auto clear */
+ /* With MSI-X we use auto clear */
if (adapter->msix_mem) {
mask = IXGBE_EIMS_ENABLE_MASK;
/* Don't autoclear Link */
@@ -3135,10 +3262,12 @@ ixgbe_get_slot_info(struct ixgbe_hw *hw)
if (hw->device_id != IXGBE_DEV_ID_82599_SFP_SF_QP) {
ixgbe_get_bus_info(hw);
/* These devices don't use PCI-E */
- if (hw->mac.type == ixgbe_mac_X550EM_x
- || hw->mac.type == ixgbe_mac_X550EM_a)
+ switch (hw->mac.type) {
+ case ixgbe_mac_X550EM_x:
return;
- goto display;
+ default:
+ goto display;
+ }
}
/*
@@ -3260,7 +3389,6 @@ ixgbe_set_ivar(struct adapter *adapter, u8 entry, u8 vector, s8 type)
case ixgbe_mac_82599EB:
case ixgbe_mac_X540:
case ixgbe_mac_X550:
- case ixgbe_mac_X550EM_a:
case ixgbe_mac_X550EM_x:
if (type == -1) { /* MISC IVAR */
index = (entry & 1) * 8;
@@ -3289,8 +3417,14 @@ ixgbe_configure_ivars(struct adapter *adapter)
if (ixgbe_max_interrupt_rate > 0)
newitr = (4000000 / ixgbe_max_interrupt_rate) & 0x0FF8;
- else
+ else {
+ /*
+ ** Disable DMA coalescing if interrupt moderation is
+ ** disabled.
+ */
+ adapter->dmac = 0;
newitr = 0;
+ }
for (int i = 0; i < adapter->num_queues; i++, que++) {
/* First the RX queue entry */
@@ -3350,7 +3484,7 @@ ixgbe_handle_link(void *context, int pending)
ixgbe_check_link(&adapter->hw,
&adapter->link_speed, &adapter->link_up, 0);
- ixgbe_update_link_status(adapter);
+ ixgbe_update_link_status(adapter);
}
/*
@@ -3410,6 +3544,28 @@ ixgbe_handle_msf(void *context, int pending)
return;
}
+/*
+** Tasklet for handling interrupts from an external PHY
+*/
+static void
+ixgbe_handle_phy(void *context, int pending)
+{
+ struct adapter *adapter = context;
+ struct ixgbe_hw *hw = &adapter->hw;
+ int error;
+
+ error = hw->phy.ops.handle_lasi(hw);
+ if (error == IXGBE_ERR_OVERTEMP)
+ device_printf(adapter->dev,
+ "CRITICAL: EXTERNAL PHY OVER TEMP!! "
+ " PHY will downshift to lower power state!\n");
+ else if (error)
+ device_printf(adapter->dev,
+ "Error handling LASI interrupt: %d\n",
+ error);
+ return;
+}
+
#ifdef IXGBE_FDIR
/*
** Tasklet for reinitializing the Flow Director filter table
@@ -3432,6 +3588,127 @@ ixgbe_reinit_fdir(void *context, int pending)
}
#endif
+/*********************************************************************
+ *
+ * Configure DMA Coalescing
+ *
+ **********************************************************************/
+static void
+ixgbe_config_dmac(struct adapter *adapter)
+{
+ struct ixgbe_hw *hw = &adapter->hw;
+ struct ixgbe_dmac_config *dcfg = &hw->mac.dmac_config;
+
+ if (hw->mac.type < ixgbe_mac_X550 ||
+ !hw->mac.ops.dmac_config)
+ return;
+
+ if (dcfg->watchdog_timer ^ adapter->dmac ||
+ dcfg->link_speed ^ adapter->link_speed) {
+ dcfg->watchdog_timer = adapter->dmac;
+ dcfg->fcoe_en = false;
+ dcfg->link_speed = adapter->link_speed;
+ dcfg->num_tcs = 1;
+
+ INIT_DEBUGOUT2("dmac settings: watchdog %d, link speed %d\n",
+ dcfg->watchdog_timer, dcfg->link_speed);
+
+ hw->mac.ops.dmac_config(hw);
+ }
+}
+
+/*
+ * Checks whether the adapter supports Energy Efficient Ethernet
+ * or not, based on device ID.
+ */
+static void
+ixgbe_check_eee_support(struct adapter *adapter)
+{
+ struct ixgbe_hw *hw = &adapter->hw;
+
+ adapter->eee_support = adapter->eee_enabled =
+ (hw->device_id == IXGBE_DEV_ID_X550T ||
+ hw->device_id == IXGBE_DEV_ID_X550EM_X_KR);
+}
+
+/*
+ * Checks whether the adapter's ports are capable of
+ * Wake On LAN by reading the adapter's NVM.
+ *
+ * Sets each port's hw->wol_enabled value depending
+ * on the value read here.
+ */
+static void
+ixgbe_check_wol_support(struct adapter *adapter)
+{
+ struct ixgbe_hw *hw = &adapter->hw;
+ u16 dev_caps = 0;
+
+ /* Find out WoL support for port */
+ adapter->wol_support = hw->wol_enabled = 0;
+ ixgbe_get_device_caps(hw, &dev_caps);
+ if ((dev_caps & IXGBE_DEVICE_CAPS_WOL_PORT0_1) ||
+ ((dev_caps & IXGBE_DEVICE_CAPS_WOL_PORT0) &&
+ hw->bus.func == 0))
+ adapter->wol_support = hw->wol_enabled = 1;
+
+ /* Save initial wake up filter configuration */
+ adapter->wufc = IXGBE_READ_REG(hw, IXGBE_WUFC);
+
+ return;
+}
+
+/*
+ * Prepare the adapter/port for LPLU and/or WoL
+ */
+static int
+ixgbe_setup_low_power_mode(struct adapter *adapter)
+{
+ struct ixgbe_hw *hw = &adapter->hw;
+ device_t dev = adapter->dev;
+ s32 error = 0;
+
+ mtx_assert(&adapter->core_mtx, MA_OWNED);
+
+ /* Limit power management flow to X550EM baseT */
+ if (hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T
+ && hw->phy.ops.enter_lplu) {
+ /* Turn off support for APM wakeup. (Using ACPI instead) */
+ IXGBE_WRITE_REG(hw, IXGBE_GRC,
+ IXGBE_READ_REG(hw, IXGBE_GRC) & ~(u32)2);
+
+ /*
+ * Clear Wake Up Status register to prevent any previous wakeup
+ * events from waking us up immediately after we suspend.
+ */
+ IXGBE_WRITE_REG(hw, IXGBE_WUS, 0xffffffff);
+
+ /*
+ * Program the Wakeup Filter Control register with user filter
+ * settings
+ */
+ IXGBE_WRITE_REG(hw, IXGBE_WUFC, adapter->wufc);
+
+ /* Enable wakeups and power management in Wakeup Control */
+ IXGBE_WRITE_REG(hw, IXGBE_WUC,
+ IXGBE_WUC_WKEN | IXGBE_WUC_PME_EN);
+
+ /* X550EM baseT adapters need a special LPLU flow */
+ hw->phy.reset_disable = true;
+ ixgbe_stop(adapter);
+ error = hw->phy.ops.enter_lplu(hw);
+ if (error)
+ device_printf(dev,
+ "Error entering LPLU: %d\n", error);
+ hw->phy.reset_disable = false;
+ } else {
+ /* Just stop for other adapters */
+ ixgbe_stop(adapter);
+ }
+
+ return error;
+}
+
/**********************************************************************
*
* Update the board statistics counters.
@@ -3449,42 +3726,6 @@ ixgbe_update_stats_counters(struct adapter *adapter)
adapter->stats.pf.errbc += IXGBE_READ_REG(hw, IXGBE_ERRBC);
adapter->stats.pf.mspdc += IXGBE_READ_REG(hw, IXGBE_MSPDC);
- /*
- ** Note: these are for the 8 possible traffic classes,
- ** which in current implementation is unused,
- ** therefore only 0 should read real data.
- */
- for (int i = 0; i < 8; i++) {
- u32 mp;
- mp = IXGBE_READ_REG(hw, IXGBE_MPC(i));
- /* missed_rx tallies misses for the gprc workaround */
- missed_rx += mp;
- /* global total per queue */
- adapter->stats.pf.mpc[i] += mp;
- /* total for stats display */
- total_missed_rx += adapter->stats.pf.mpc[i];
- if (hw->mac.type == ixgbe_mac_82598EB) {
- adapter->stats.pf.rnbc[i] +=
- IXGBE_READ_REG(hw, IXGBE_RNBC(i));
- adapter->stats.pf.qbtc[i] +=
- IXGBE_READ_REG(hw, IXGBE_QBTC(i));
- adapter->stats.pf.qbrc[i] +=
- IXGBE_READ_REG(hw, IXGBE_QBRC(i));
- adapter->stats.pf.pxonrxc[i] +=
- IXGBE_READ_REG(hw, IXGBE_PXONRXC(i));
- } else
- adapter->stats.pf.pxonrxc[i] +=
- IXGBE_READ_REG(hw, IXGBE_PXONRXCNT(i));
- adapter->stats.pf.pxontxc[i] +=
- IXGBE_READ_REG(hw, IXGBE_PXONTXC(i));
- adapter->stats.pf.pxofftxc[i] +=
- IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i));
- if (hw->mac.type != ixgbe_mac_X550EM_x)
- adapter->stats.pf.pxoffrxc[i] +=
- IXGBE_READ_REG(hw, IXGBE_PXOFFRXC(i));
- adapter->stats.pf.pxon2offc[i] +=
- IXGBE_READ_REG(hw, IXGBE_PXON2OFFCNT(i));
- }
for (int i = 0; i < 16; i++) {
adapter->stats.pf.qprc[i] += IXGBE_READ_REG(hw, IXGBE_QPRC(i));
adapter->stats.pf.qptc[i] += IXGBE_READ_REG(hw, IXGBE_QPTC(i));
@@ -3592,6 +3833,8 @@ static uint64_t
ixgbe_get_counter(struct ifnet *ifp, ift_counter cnt)
{
struct adapter *adapter;
+ struct tx_ring *txr;
+ uint64_t rv;
adapter = if_getsoftc(ifp);
@@ -3612,6 +3855,12 @@ ixgbe_get_counter(struct ifnet *ifp, ift_counter cnt)
return (0);
case IFCOUNTER_IQDROPS:
return (adapter->iqdrops);
+ case IFCOUNTER_OQDROPS:
+ rv = 0;
+ txr = adapter->tx_rings;
+ for (int i = 0; i < adapter->num_queues; i++, txr++)
+ rv += txr->br->br_drops;
+ return (rv);
case IFCOUNTER_IERRORS:
return (adapter->ierrors);
default:
@@ -3720,6 +3969,108 @@ ixgbe_sysctl_interrupt_rate_handler(SYSCTL_HANDLER_ARGS)
return 0;
}
+static void
+ixgbe_add_device_sysctls(struct adapter *adapter)
+{
+ device_t dev = adapter->dev;
+ struct ixgbe_hw *hw = &adapter->hw;
+ struct sysctl_oid_list *child;
+ struct sysctl_ctx_list *ctx;
+
+ ctx = device_get_sysctl_ctx(dev);
+ child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev));
+
+ /* Sysctls for all devices */
+ SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "fc",
+ CTLTYPE_INT | CTLFLAG_RW, adapter, 0,
+ ixgbe_set_flowcntl, "I", IXGBE_SYSCTL_DESC_SET_FC);
+
+ SYSCTL_ADD_INT(ctx, child, OID_AUTO, "enable_aim",
+ CTLFLAG_RW,
+ &ixgbe_enable_aim, 1, "Interrupt Moderation");
+
+ SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "advertise_speed",
+ CTLTYPE_INT | CTLFLAG_RW, adapter, 0,
+ ixgbe_set_advertise, "I", IXGBE_SYSCTL_DESC_ADV_SPEED);
+
+ SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "thermal_test",
+ CTLTYPE_INT | CTLFLAG_RW, adapter, 0,
+ ixgbe_sysctl_thermal_test, "I", "Thermal Test");
+
+ /* for X550 devices */
+ if (hw->mac.type >= ixgbe_mac_X550)
+ SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "dmac",
+ CTLTYPE_INT | CTLFLAG_RW, adapter, 0,
+ ixgbe_sysctl_dmac, "I", "DMA Coalesce");
+
+ /* for X550T and X550EM backplane devices */
+ if (hw->device_id == IXGBE_DEV_ID_X550T ||
+ hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+ struct sysctl_oid *eee_node;
+ struct sysctl_oid_list *eee_list;
+
+ eee_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "eee",
+ CTLFLAG_RD, NULL,
+ "Energy Efficient Ethernet sysctls");
+ eee_list = SYSCTL_CHILDREN(eee_node);
+
+ SYSCTL_ADD_PROC(ctx, eee_list, OID_AUTO, "enable",
+ CTLTYPE_INT | CTLFLAG_RW, adapter, 0,
+ ixgbe_sysctl_eee_enable, "I",
+ "Enable or Disable EEE");
+
+ SYSCTL_ADD_PROC(ctx, eee_list, OID_AUTO, "negotiated",
+ CTLTYPE_INT | CTLFLAG_RD, adapter, 0,
+ ixgbe_sysctl_eee_negotiated, "I",
+ "EEE negotiated on link");
+
+ SYSCTL_ADD_PROC(ctx, eee_list, OID_AUTO, "tx_lpi_status",
+ CTLTYPE_INT | CTLFLAG_RD, adapter, 0,
+ ixgbe_sysctl_eee_tx_lpi_status, "I",
+ "Whether or not TX link is in LPI state");
+
+ SYSCTL_ADD_PROC(ctx, eee_list, OID_AUTO, "rx_lpi_status",
+ CTLTYPE_INT | CTLFLAG_RD, adapter, 0,
+ ixgbe_sysctl_eee_rx_lpi_status, "I",
+ "Whether or not RX link is in LPI state");
+ }
+
+ /* for certain 10GBaseT devices */
+ if (hw->device_id == IXGBE_DEV_ID_X550T ||
+ hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T) {
+ SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "wol_enable",
+ CTLTYPE_INT | CTLFLAG_RW, adapter, 0,
+ ixgbe_sysctl_wol_enable, "I",
+ "Enable/Disable Wake on LAN");
+
+ SYSCTL_ADD_PROC(ctx, child, OID_AUTO, "wufc",
+ CTLTYPE_INT | CTLFLAG_RW, adapter, 0,
+ ixgbe_sysctl_wufc, "I",
+ "Enable/Disable Wake Up Filters");
+ }
+
+ /* for X550EM 10GBaseT devices */
+ if (hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T) {
+ struct sysctl_oid *phy_node;
+ struct sysctl_oid_list *phy_list;
+
+ phy_node = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "phy",
+ CTLFLAG_RD, NULL,
+ "External PHY sysctls");
+ phy_list = SYSCTL_CHILDREN(phy_node);
+
+ SYSCTL_ADD_PROC(ctx, phy_list, OID_AUTO, "temp",
+ CTLTYPE_INT | CTLFLAG_RD, adapter, 0,
+ ixgbe_sysctl_phy_temp, "I",
+ "Current External PHY Temperature (Celsius)");
+
+ SYSCTL_ADD_PROC(ctx, phy_list, OID_AUTO, "overtemp_occurred",
+ CTLTYPE_INT | CTLFLAG_RD, adapter, 0,
+ ixgbe_sysctl_phy_overtemp_occurred, "I",
+ "External PHY High Temperature Event Occurred");
+ }
+}
+
/*
* Add sysctl variables, one per statistic, to the system.
*/
@@ -3753,7 +4104,7 @@ ixgbe_add_hw_stats(struct adapter *adapter)
CTLFLAG_RD, &adapter->watchdog_events,
"Watchdog timeouts");
SYSCTL_ADD_ULONG(ctx, child, OID_AUTO, "link_irq",
- CTLFLAG_RD, &adapter->vector_irq,
+ CTLFLAG_RD, &adapter->link_irq,
"Link MSIX IRQ Handled");
for (int i = 0; i < adapter->num_queues; i++, txr++) {
@@ -3790,6 +4141,9 @@ ixgbe_add_hw_stats(struct adapter *adapter)
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "tx_packets",
CTLFLAG_RD, &txr->total_packets,
"Queue Packets Transmitted");
+ SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "br_drops",
+ CTLFLAG_RD, &txr->br->br_drops,
+ "Packets dropped in buf_ring");
}
for (int i = 0; i < adapter->num_queues; i++, rxr++) {
@@ -4082,20 +4436,77 @@ ixgbe_set_advertise(SYSCTL_HANDLER_ARGS)
}
/*
-** Thermal Shutdown Trigger
-** - cause a Thermal Overtemp IRQ
-** - this now requires firmware enabling
-*/
+ * The following two sysctls are for X550 BaseT devices;
+ * they deal with the external PHY used in them.
+ */
static int
-ixgbe_set_thermal_test(SYSCTL_HANDLER_ARGS)
+ixgbe_sysctl_phy_temp(SYSCTL_HANDLER_ARGS)
{
- int error, fire = 0;
struct adapter *adapter = (struct adapter *) arg1;
struct ixgbe_hw *hw = &adapter->hw;
+ u16 reg;
+ if (hw->device_id != IXGBE_DEV_ID_X550EM_X_10G_T) {
+ device_printf(adapter->dev,
+ "Device has no supported external thermal sensor.\n");
+ return (ENODEV);
+ }
- if (hw->mac.type < ixgbe_mac_X540)
- return (0);
+ if (hw->phy.ops.read_reg(hw, IXGBE_PHY_CURRENT_TEMP,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+ &reg)) {
+ device_printf(adapter->dev,
+ "Error reading from PHY's current temperature register\n");
+ return (EAGAIN);
+ }
+
+ /* Shift temp for output */
+ reg = reg >> 8;
+
+ return (sysctl_handle_int(oidp, NULL, reg, req));
+}
+
+/*
+ * Reports whether the current PHY temperature is over
+ * the overtemp threshold.
+ * - This is reported directly from the PHY
+ */
+static int
+ixgbe_sysctl_phy_overtemp_occurred(SYSCTL_HANDLER_ARGS)
+{
+ struct adapter *adapter = (struct adapter *) arg1;
+ struct ixgbe_hw *hw = &adapter->hw;
+ u16 reg;
+
+ if (hw->device_id != IXGBE_DEV_ID_X550EM_X_10G_T) {
+ device_printf(adapter->dev,
+ "Device has no supported external thermal sensor.\n");
+ return (ENODEV);
+ }
+
+ if (hw->phy.ops.read_reg(hw, IXGBE_PHY_OVERTEMP_STATUS,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+ &reg)) {
+ device_printf(adapter->dev,
+ "Error reading from PHY's temperature status register\n");
+ return (EAGAIN);
+ }
+
+ /* Get occurrence bit */
+ reg = !!(reg & 0x4000);
+ return (sysctl_handle_int(oidp, 0, reg, req));
+}
+
+/*
+** Thermal Shutdown Trigger (internal MAC)
+** - Set this to 1 to cause an overtemp event to occur
+*/
+static int
+ixgbe_sysctl_thermal_test(SYSCTL_HANDLER_ARGS)
+{
+ struct adapter *adapter = (struct adapter *) arg1;
+ struct ixgbe_hw *hw = &adapter->hw;
+ int error, fire = 0;
error = sysctl_handle_int(oidp, &fire, 0, req);
if ((error) || (req->newptr == NULL))
@@ -4111,6 +4522,223 @@ ixgbe_set_thermal_test(SYSCTL_HANDLER_ARGS)
}
/*
+** Manage DMA Coalescing.
+** Control values:
+** 0/1 - off / on (use default value of 1000)
+**
+** Legal timer values are:
+** 50,100,250,500,1000,2000,5000,10000
+**
+** Turning off interrupt moderation will also turn this off.
+*/
+static int
+ixgbe_sysctl_dmac(SYSCTL_HANDLER_ARGS)
+{
+ struct adapter *adapter = (struct adapter *) arg1;
+ struct ixgbe_hw *hw = &adapter->hw;
+ struct ifnet *ifp = adapter->ifp;
+ int error;
+ u16 oldval;
+
+ oldval = adapter->dmac;
+ error = sysctl_handle_int(oidp, &adapter->dmac, 0, req);
+ if ((error) || (req->newptr == NULL))
+ return (error);
+
+ switch (hw->mac.type) {
+ case ixgbe_mac_X550:
+ case ixgbe_mac_X550EM_x:
+ break;
+ default:
+ device_printf(adapter->dev,
+ "DMA Coalescing is only supported on X550 devices\n");
+ return (ENODEV);
+ }
+
+ switch (adapter->dmac) {
+ case 0:
+ /* Disabled */
+ break;
+ case 1: /* Enable and use default */
+ adapter->dmac = 1000;
+ break;
+ case 50:
+ case 100:
+ case 250:
+ case 500:
+ case 1000:
+ case 2000:
+ case 5000:
+ case 10000:
+ /* Legal values - allow */
+ break;
+ default:
+ /* Do nothing, illegal value */
+ adapter->dmac = oldval;
+ return (EINVAL);
+ }
+
+ /* Re-initialize hardware if it's already running */
+ if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+ ixgbe_init(adapter);
+
+ return (0);
+}
+
+/*
+ * Sysctl to enable/disable the WoL capability, if supported by the adapter.
+ * Values:
+ * 0 - disabled
+ * 1 - enabled
+ */
+static int
+ixgbe_sysctl_wol_enable(SYSCTL_HANDLER_ARGS)
+{
+ struct adapter *adapter = (struct adapter *) arg1;
+ struct ixgbe_hw *hw = &adapter->hw;
+ int new_wol_enabled;
+ int error = 0;
+
+ new_wol_enabled = hw->wol_enabled;
+ error = sysctl_handle_int(oidp, &new_wol_enabled, 0, req);
+ if ((error) || (req->newptr == NULL))
+ return (error);
+ if (new_wol_enabled == hw->wol_enabled)
+ return (0);
+
+ if (new_wol_enabled > 0 && !adapter->wol_support)
+ return (ENODEV);
+ else
+ hw->wol_enabled = !!(new_wol_enabled);
+
+ return (0);
+}
+
+/*
+ * Sysctl to enable/disable the Energy Efficient Ethernet capability,
+ * if supported by the adapter.
+ * Values:
+ * 0 - disabled
+ * 1 - enabled
+ */
+static int
+ixgbe_sysctl_eee_enable(SYSCTL_HANDLER_ARGS)
+{
+ struct adapter *adapter = (struct adapter *) arg1;
+ struct ifnet *ifp = adapter->ifp;
+ int new_eee_enabled, error = 0;
+
+ new_eee_enabled = adapter->eee_enabled;
+ error = sysctl_handle_int(oidp, &new_eee_enabled, 0, req);
+ if ((error) || (req->newptr == NULL))
+ return (error);
+ if (new_eee_enabled == adapter->eee_enabled)
+ return (0);
+
+ if (new_eee_enabled > 0 && !adapter->eee_support)
+ return (ENODEV);
+ else
+ adapter->eee_enabled = !!(new_eee_enabled);
+
+ /* Re-initialize hardware if it's already running */
+ if (ifp->if_drv_flags & IFF_DRV_RUNNING)
+ ixgbe_init(adapter);
+
+ return (0);
+}
+
+/*
+ * Read-only sysctl indicating whether EEE support was negotiated
+ * on the link.
+ */
+static int
+ixgbe_sysctl_eee_negotiated(SYSCTL_HANDLER_ARGS)
+{
+ struct adapter *adapter = (struct adapter *) arg1;
+ struct ixgbe_hw *hw = &adapter->hw;
+ bool status;
+
+ status = !!(IXGBE_READ_REG(hw, IXGBE_EEE_STAT) & IXGBE_EEE_STAT_NEG);
+
+ return (sysctl_handle_int(oidp, 0, status, req));
+}
+
+/*
+ * Read-only sysctl indicating whether RX Link is in LPI state.
+ */
+static int
+ixgbe_sysctl_eee_rx_lpi_status(SYSCTL_HANDLER_ARGS)
+{
+ struct adapter *adapter = (struct adapter *) arg1;
+ struct ixgbe_hw *hw = &adapter->hw;
+ bool status;
+
+ status = !!(IXGBE_READ_REG(hw, IXGBE_EEE_STAT) &
+ IXGBE_EEE_RX_LPI_STATUS);
+
+ return (sysctl_handle_int(oidp, 0, status, req));
+}
+
+/*
+ * Read-only sysctl indicating whether TX Link is in LPI state.
+ */
+static int
+ixgbe_sysctl_eee_tx_lpi_status(SYSCTL_HANDLER_ARGS)
+{
+ struct adapter *adapter = (struct adapter *) arg1;
+ struct ixgbe_hw *hw = &adapter->hw;
+ bool status;
+
+ status = !!(IXGBE_READ_REG(hw, IXGBE_EEE_STAT) &
+ IXGBE_EEE_TX_LPI_STATUS);
+
+ return (sysctl_handle_int(oidp, 0, status, req));
+}
+
+/*
+ * Sysctl to enable/disable the types of packets that the
+ * adapter will wake up on upon receipt.
+ * WUFC - Wake Up Filter Control
+ * Flags:
+ * 0x1 - Link Status Change
+ * 0x2 - Magic Packet
+ * 0x4 - Direct Exact
+ * 0x8 - Directed Multicast
+ * 0x10 - Broadcast
+ * 0x20 - ARP/IPv4 Request Packet
+ * 0x40 - Direct IPv4 Packet
+ * 0x80 - Direct IPv6 Packet
+ *
+ * Setting another flag will cause the sysctl to return an
+ * error.
+ */
+static int
+ixgbe_sysctl_wufc(SYSCTL_HANDLER_ARGS)
+{
+ struct adapter *adapter = (struct adapter *) arg1;
+ int error = 0;
+ u32 new_wufc;
+
+ new_wufc = adapter->wufc;
+
+ error = sysctl_handle_int(oidp, &new_wufc, 0, req);
+ if ((error) || (req->newptr == NULL))
+ return (error);
+ if (new_wufc == adapter->wufc)
+ return (0);
+
+ if (new_wufc & 0xffffff00)
+ return (EINVAL);
+ else {
+ new_wufc &= 0xff;
+ new_wufc |= (0xffffff & adapter->wufc);
+ adapter->wufc = new_wufc;
+ }
+
+ return (0);
+}
+
+/*
** Enable the hardware to drop packets when the buffer is
** full. This is useful when multiqueue,so that no single
** queue being full stalls the entire RX engine. We only
@@ -4154,6 +4782,7 @@ ixgbe_rearm_queues(struct adapter *adapter, u64 queues)
case ixgbe_mac_82599EB:
case ixgbe_mac_X540:
case ixgbe_mac_X550:
+ case ixgbe_mac_X550EM_x:
mask = (queues & 0xFFFFFFFF);
IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(0), mask);
mask = (queues >> 32);
diff --git a/sys/dev/ixgbe/if_ixv.c b/sys/dev/ixgbe/if_ixv.c
index 672077b..a550a85 100644
--- a/sys/dev/ixgbe/if_ixv.c
+++ b/sys/dev/ixgbe/if_ixv.c
@@ -60,7 +60,6 @@ static ixgbe_vendor_info_t ixv_vendor_info_array[] =
{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_82599_VF, 0, 0, 0},
{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X540_VF, 0, 0, 0},
{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550_VF, 0, 0, 0},
- {IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_A_VF, 0, 0, 0},
{IXGBE_INTEL_VENDOR_ID, IXGBE_DEV_ID_X550EM_X_VF, 0, 0, 0},
/* required last entry */
{0, 0, 0, 0, 0}
@@ -882,7 +881,7 @@ ixv_msix_mbx(void *arg)
struct ixgbe_hw *hw = &adapter->hw;
u32 reg;
- ++adapter->vector_irq;
+ ++adapter->link_irq;
/* First get the cause */
reg = IXGBE_READ_REG(hw, IXGBE_VTEICS);
@@ -2034,8 +2033,8 @@ ixv_add_stats_sysctls(struct adapter *adapter)
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "tx_packets",
CTLFLAG_RD, &(txr->total_packets),
"TX Packets");
- SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "tx_bytes",
- CTLFLAG_RD, &(txr->tx_bytes),
+ SYSCTL_ADD_UINT(ctx, queue_list, OID_AUTO, "tx_bytes",
+ CTLFLAG_RD, &(txr->bytes), 0,
"TX Bytes");
SYSCTL_ADD_UQUAD(ctx, queue_list, OID_AUTO, "tx_no_desc",
CTLFLAG_RD, &(txr->no_desc_avail),
@@ -2083,7 +2082,7 @@ ixv_print_debug_info(struct adapter *adapter)
}
device_printf(dev,"MBX IRQ Handled: %lu\n",
- (long)adapter->vector_irq);
+ (long)adapter->link_irq);
return;
}
diff --git a/sys/dev/ixgbe/ix_txrx.c b/sys/dev/ixgbe/ix_txrx.c
index 6c9c84a..bfe1607 100644
--- a/sys/dev/ixgbe/ix_txrx.c
+++ b/sys/dev/ixgbe/ix_txrx.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -210,7 +210,11 @@ ixgbe_mq_start(struct ifnet *ifp, struct mbuf *m)
* If everything is setup correctly, it should be the
* same bucket that the current CPU we're on is.
*/
+#if __FreeBSD_version < 1100054
+ if (m->m_flags & M_FLOWID) {
+#else
if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) {
+#endif
#ifdef RSS
if (rss_hash2bucket(m->m_pkthdr.flowid,
M_HASHTYPE_GET(m), &bucket_id) == 0)
@@ -276,7 +280,12 @@ ixgbe_mq_start_locked(struct ifnet *ifp, struct tx_ring *txr)
enqueued++;
#if 0 // this is VF-only
#if __FreeBSD_version >= 1100036
- if (next->m_flags & M_MCAST)
+ /*
+ * Since we're looking at the tx ring, we can check
+ * to see if we're a VF by examing our tail register
+ * address.
+ */
+ if (txr->tail < IXGBE_TDT(0) && next->m_flags & M_MCAST)
if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1);
#endif
#endif
@@ -312,8 +321,8 @@ ixgbe_deferred_mq_start(void *arg, int pending)
}
/*
-** Flush all ring buffers
-*/
+ * Flush all ring buffers
+ */
void
ixgbe_qflush(struct ifnet *ifp)
{
@@ -387,6 +396,10 @@ retry:
/* Try it again? - one try */
if (remap == TRUE) {
remap = FALSE;
+ /*
+ * XXX: m_defrag will choke on
+ * non-MCLBYTES-sized clusters
+ */
m = m_defrag(*m_headp, M_NOWAIT);
if (m == NULL) {
adapter->mbuf_defrag_failed++;
@@ -418,9 +431,9 @@ retry:
m_head = *m_headp;
/*
- ** Set up the appropriate offload context
- ** this will consume the first descriptor
- */
+ * Set up the appropriate offload context
+ * this will consume the first descriptor
+ */
error = ixgbe_tx_ctx_setup(txr, m_head, &cmd_type_len, &olinfo_status);
if (__predict_false(error)) {
if (error == ENOBUFS)
@@ -439,7 +452,6 @@ retry:
}
#endif
- olinfo_status |= IXGBE_ADVTXD_CC;
i = txr->next_avail_desc;
for (j = 0; j < nsegs; j++) {
bus_size_t seglen;
@@ -466,11 +478,11 @@ retry:
txbuf->m_head = m_head;
/*
- ** Here we swap the map so the last descriptor,
- ** which gets the completion interrupt has the
- ** real map, and the first descriptor gets the
- ** unused map from this descriptor.
- */
+ * Here we swap the map so the last descriptor,
+ * which gets the completion interrupt has the
+ * real map, and the first descriptor gets the
+ * unused map from this descriptor.
+ */
txr->tx_buffers[first].map = txbuf->map;
txbuf->map = map;
bus_dmamap_sync(txr->txtag, map, BUS_DMASYNC_PREWRITE);
@@ -493,7 +505,6 @@ retry:
txr->busy = 1;
return (0);
-
}
@@ -732,6 +743,7 @@ static int
ixgbe_tx_ctx_setup(struct tx_ring *txr, struct mbuf *mp,
u32 *cmd_type_len, u32 *olinfo_status)
{
+ struct adapter *adapter = txr->adapter;
struct ixgbe_adv_tx_context_desc *TXD;
struct ether_vlan_header *eh;
struct ip *ip;
@@ -766,6 +778,8 @@ ixgbe_tx_ctx_setup(struct tx_ring *txr, struct mbuf *mp,
vtag = htole16(mp->m_pkthdr.ether_vtag);
vlan_macip_lens |= (vtag << IXGBE_ADVTXD_VLAN_SHIFT);
}
+ else if (!IXGBE_IS_X550VF(adapter) && (offload == FALSE))
+ return (0);
/*
* Determine where frame payload starts.
@@ -1727,9 +1741,6 @@ ixgbe_rx_discard(struct rx_ring *rxr, int i)
* the mbufs in the descriptor and sends data which has been
* dma'ed into host memory to upper layer.
*
- * We loop at most count times if count is > 0, or until done if
- * count < 0.
- *
* Return TRUE for more work, FALSE for all clean.
*********************************************************************/
bool
@@ -1792,10 +1803,9 @@ ixgbe_rxeof(struct ix_queue *que)
/* Make sure bad packets are discarded */
if (eop && (staterr & IXGBE_RXDADV_ERR_FRAME_ERR_MASK) != 0) {
-#if 0 // VF-only
#if __FreeBSD_version >= 1100036
- if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
-#endif
+ if (IXGBE_IS_VF(adapter))
+ if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
#endif
rxr->rx_discarded++;
ixgbe_rx_discard(rxr, i);
@@ -1906,6 +1916,9 @@ ixgbe_rxeof(struct ix_queue *que)
#ifdef RSS
sendmp->m_pkthdr.flowid =
le32toh(cur->wb.lower.hi_dword.rss);
+#if __FreeBSD_version < 1100054
+ sendmp->m_flags |= M_FLOWID;
+#endif
switch (pkt_info & IXGBE_RXDADV_RSSTYPE_MASK) {
case IXGBE_RXDADV_RSSTYPE_IPV4_TCP:
M_HASHTYPE_SET(sendmp, M_HASHTYPE_RSS_TCP_IPV4);
@@ -1939,7 +1952,11 @@ ixgbe_rxeof(struct ix_queue *que)
}
#else /* RSS */
sendmp->m_pkthdr.flowid = que->msix;
+#if __FreeBSD_version >= 1100054
M_HASHTYPE_SET(sendmp, M_HASHTYPE_OPAQUE);
+#else
+ sendmp->m_flags |= M_FLOWID;
+#endif
#endif /* RSS */
#endif /* FreeBSD_version */
}
diff --git a/sys/dev/ixgbe/ixgbe.h b/sys/dev/ixgbe/ixgbe.h
index 813ee4f..44e7c3c 100644
--- a/sys/dev/ixgbe/ixgbe.h
+++ b/sys/dev/ixgbe/ixgbe.h
@@ -90,8 +90,11 @@
#include <sys/pcpu.h>
#include <sys/smp.h>
#include <machine/smp.h>
+#include <sys/sbuf.h>
#include "ixgbe_api.h"
+#include "ixgbe_common.h"
+#include "ixgbe_phy.h"
#include "ixgbe_vf.h"
/* Tunables */
@@ -146,7 +149,11 @@
#define IXGBE_TX_CLEANUP_THRESHOLD (adapter->num_tx_desc / 8)
#define IXGBE_TX_OP_THRESHOLD (adapter->num_tx_desc / 32)
-#define IXGBE_MAX_FRAME_SIZE 0x3F00
+/* These defines are used in MTU calculations */
+#define IXGBE_MAX_FRAME_SIZE 9728
+#define IXGBE_MTU_HDR (ETHER_HDR_LEN + ETHER_CRC_LEN + \
+ ETHER_VLAN_ENCAP_LEN)
+#define IXGBE_MAX_MTU (IXGBE_MAX_FRAME_SIZE - IXGBE_MTU_HDR)
/* Flow control constants */
#define IXGBE_FC_PAUSE 0xFFFF
@@ -227,6 +234,17 @@
#define IXGBE_BULK_LATENCY 1200
#define IXGBE_LINK_ITR 2000
+/* MAC type macros */
+#define IXGBE_IS_X550VF(_adapter) \
+ ((_adapter->hw.mac.type == ixgbe_mac_X550_vf) || \
+ (_adapter->hw.mac.type == ixgbe_mac_X550EM_x_vf))
+
+#define IXGBE_IS_VF(_adapter) \
+ (IXGBE_IS_X550VF(_adapter) || \
+ (_adapter->hw.mac.type == ixgbe_mac_X540_vf) || \
+ (_adapter->hw.mac.type == ixgbe_mac_82599_vf))
+
+
/*
*****************************************************************************
* vendor_info_array
@@ -323,8 +341,8 @@ struct tx_ring {
u32 bytes; /* used for AIM */
u32 packets;
/* Soft Stats */
- u64 tx_bytes;
unsigned long tso_tx;
+ unsigned long no_tx_map_avail;
unsigned long no_tx_dma_setup;
u64 no_desc_avail;
u64 total_packets;
@@ -419,6 +437,13 @@ struct adapter {
u32 link_speed;
bool link_up;
u32 vector;
+ u16 dmac;
+ bool eee_support;
+ bool eee_enabled;
+
+ /* Power management-related */
+ bool wol_support;
+ u32 wufc;
/* Mbuf cluster size */
u32 rx_mbuf_sz;
@@ -432,6 +457,7 @@ struct adapter {
int fdir_reinit;
struct task fdir_task;
#endif
+ struct task phy_task; /* PHY intr tasklet */
struct taskqueue *tq;
/*
@@ -467,7 +493,7 @@ struct adapter {
unsigned long mbuf_header_failed;
unsigned long mbuf_packet_failed;
unsigned long watchdog_events;
- unsigned long vector_irq;
+ unsigned long link_irq;
union {
struct ixgbe_hw_stats pf;
struct ixgbevf_hw_stats vf;
@@ -540,12 +566,17 @@ struct adapter {
#define IXGBE_SET_IQDROPS(sc, count) (sc)->ifp->if_iqdrops = (count)
#endif
+/* External PHY register addresses */
+#define IXGBE_PHY_CURRENT_TEMP 0xC820
+#define IXGBE_PHY_OVERTEMP_STATUS 0xC830
+
/* Sysctl help messages; displayed with sysctl -d */
#define IXGBE_SYSCTL_DESC_ADV_SPEED \
"\nControl advertised link speed using these flags:\n" \
"\t0x1 - advertise 100M\n" \
"\t0x2 - advertise 1G\n" \
- "\t0x4 - advertise 10G"
+ "\t0x4 - advertise 10G\n\n" \
+ "\t100M is only supported on certain 10GBaseT adapters.\n"
#define IXGBE_SYSCTL_DESC_SET_FC \
"\nSet flow control mode using these values:\n" \
diff --git a/sys/dev/ixgbe/ixgbe_82598.c b/sys/dev/ixgbe/ixgbe_82598.c
index d9b8985..46e64c5 100644
--- a/sys/dev/ixgbe/ixgbe_82598.c
+++ b/sys/dev/ixgbe/ixgbe_82598.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -260,6 +260,8 @@ s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw)
DEBUGFUNC("ixgbe_start_hw_82598");
ret_val = ixgbe_start_hw_generic(hw);
+ if (ret_val)
+ return ret_val;
/* Disable relaxed ordering */
for (i = 0; ((i < hw->mac.max_tx_queues) &&
@@ -278,8 +280,7 @@ s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw)
}
/* set the completion timeout for interface */
- if (ret_val == IXGBE_SUCCESS)
- ixgbe_set_pcie_completion_timeout(hw);
+ ixgbe_set_pcie_completion_timeout(hw);
return ret_val;
}
diff --git a/sys/dev/ixgbe/ixgbe_82598.h b/sys/dev/ixgbe/ixgbe_82598.h
index 621be41..d2241c7 100644
--- a/sys/dev/ixgbe/ixgbe_82598.h
+++ b/sys/dev/ixgbe/ixgbe_82598.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/sys/dev/ixgbe/ixgbe_82599.c b/sys/dev/ixgbe/ixgbe_82599.c
index d49d851..b38620f 100644
--- a/sys/dev/ixgbe/ixgbe_82599.c
+++ b/sys/dev/ixgbe/ixgbe_82599.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -421,6 +421,8 @@ s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,
/* Check if 1G SFP module. */
if (hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
+ hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
+ hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1) {
*speed = IXGBE_LINK_SPEED_1GB_FULL;
@@ -1803,7 +1805,6 @@ s32 ixgbe_fdir_set_input_mask_82599(struct ixgbe_hw *hw,
switch (hw->mac.type) {
case ixgbe_mac_X550:
case ixgbe_mac_X550EM_x:
- case ixgbe_mac_X550EM_a:
IXGBE_WRITE_REG(hw, IXGBE_FDIRSCTPM, ~fdirtcpm);
break;
default:
@@ -2465,7 +2466,6 @@ reset_pipeline_out:
return ret_val;
}
-
/**
* ixgbe_read_i2c_byte_82599 - Reads 8 bit word over I2C
* @hw: pointer to hardware structure
diff --git a/sys/dev/ixgbe/ixgbe_82599.h b/sys/dev/ixgbe/ixgbe_82599.h
index 8c973ac..bcfb043 100644
--- a/sys/dev/ixgbe/ixgbe_82599.h
+++ b/sys/dev/ixgbe/ixgbe_82599.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/sys/dev/ixgbe/ixgbe_api.c b/sys/dev/ixgbe/ixgbe_api.c
index 2535664..9784e3c 100644
--- a/sys/dev/ixgbe/ixgbe_api.c
+++ b/sys/dev/ixgbe/ixgbe_api.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -35,6 +35,22 @@
#include "ixgbe_api.h"
#include "ixgbe_common.h"
+static const u32 ixgbe_mvals_base[IXGBE_MVALS_IDX_LIMIT] = {
+ IXGBE_MVALS_INIT()
+};
+
+static const u32 ixgbe_mvals_X540[IXGBE_MVALS_IDX_LIMIT] = {
+ IXGBE_MVALS_INIT(_X540)
+};
+
+static const u32 ixgbe_mvals_X550[IXGBE_MVALS_IDX_LIMIT] = {
+ IXGBE_MVALS_INIT(_X550)
+};
+
+static const u32 ixgbe_mvals_X550EM_x[IXGBE_MVALS_IDX_LIMIT] = {
+ IXGBE_MVALS_INIT(_X550EM_x)
+};
+
/**
* ixgbe_dcb_get_rtrup2tc - read rtrup2tc reg
* @hw: pointer to hardware structure
@@ -81,20 +97,16 @@ s32 ixgbe_init_shared_code(struct ixgbe_hw *hw)
case ixgbe_mac_X540:
status = ixgbe_init_ops_X540(hw);
break;
-#if 0 //JFV temporary disable
case ixgbe_mac_X550:
status = ixgbe_init_ops_X550(hw);
break;
case ixgbe_mac_X550EM_x:
- case ixgbe_mac_X550EM_a:
status = ixgbe_init_ops_X550EM(hw);
break;
-#endif
case ixgbe_mac_82599_vf:
case ixgbe_mac_X540_vf:
case ixgbe_mac_X550_vf:
case ixgbe_mac_X550EM_x_vf:
- case ixgbe_mac_X550EM_a_vf:
status = ixgbe_init_ops_vf(hw);
break;
default:
@@ -124,6 +136,8 @@ s32 ixgbe_set_mac_type(struct ixgbe_hw *hw)
return IXGBE_ERR_DEVICE_NOT_SUPPORTED;
}
+ hw->mvals = ixgbe_mvals_base;
+
switch (hw->device_id) {
case IXGBE_DEV_ID_82598:
case IXGBE_DEV_ID_82598_BX:
@@ -164,14 +178,17 @@ s32 ixgbe_set_mac_type(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X540_VF:
case IXGBE_DEV_ID_X540_VF_HV:
hw->mac.type = ixgbe_mac_X540_vf;
+ hw->mvals = ixgbe_mvals_X540;
break;
case IXGBE_DEV_ID_X540T:
case IXGBE_DEV_ID_X540T1:
case IXGBE_DEV_ID_X540_BYPASS:
hw->mac.type = ixgbe_mac_X540;
+ hw->mvals = ixgbe_mvals_X540;
break;
case IXGBE_DEV_ID_X550T:
hw->mac.type = ixgbe_mac_X550;
+ hw->mvals = ixgbe_mvals_X550;
break;
case IXGBE_DEV_ID_X550EM_X_KX4:
case IXGBE_DEV_ID_X550EM_X_KR:
@@ -179,21 +196,17 @@ s32 ixgbe_set_mac_type(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550EM_X_1G_T:
case IXGBE_DEV_ID_X550EM_X_SFP:
hw->mac.type = ixgbe_mac_X550EM_x;
- break;
- case IXGBE_DEV_ID_X550EM_A_KR:
- hw->mac.type = ixgbe_mac_X550EM_a;
+ hw->mvals = ixgbe_mvals_X550EM_x;
break;
case IXGBE_DEV_ID_X550_VF:
case IXGBE_DEV_ID_X550_VF_HV:
hw->mac.type = ixgbe_mac_X550_vf;
+ hw->mvals = ixgbe_mvals_X550;
break;
case IXGBE_DEV_ID_X550EM_X_VF:
case IXGBE_DEV_ID_X550EM_X_VF_HV:
hw->mac.type = ixgbe_mac_X550EM_x_vf;
- break;
- case IXGBE_DEV_ID_X550EM_A_VF:
- case IXGBE_DEV_ID_X550EM_A_VF_HV:
- hw->mac.type = ixgbe_mac_X550EM_a_vf;
+ hw->mvals = ixgbe_mvals_X550EM_x;
break;
default:
ret_val = IXGBE_ERR_DEVICE_NOT_SUPPORTED;
@@ -1283,6 +1296,23 @@ s32 ixgbe_enter_lplu(struct ixgbe_hw *hw)
}
/**
+ * ixgbe_handle_lasi - Handle external Base T PHY interrupt
+ * @hw: pointer to hardware structure
+ *
+ * Handle external Base T PHY interrupt. If high temperature
+ * failure alarm then return error, else if link status change
+ * then setup internal/external PHY link
+ *
+ * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
+ * failure alarm, else return PHY access status.
+ */
+s32 ixgbe_handle_lasi(struct ixgbe_hw *hw)
+{
+ return ixgbe_call_func(hw, hw->phy.ops.handle_lasi, (hw),
+ IXGBE_NOT_IMPLEMENTED);
+}
+
+/**
* ixgbe_read_analog_reg8 - Reads 8 bit analog register
* @hw: pointer to hardware structure
* @reg: analog register to read
@@ -1340,6 +1370,23 @@ s32 ixgbe_read_i2c_byte(struct ixgbe_hw *hw, u8 byte_offset, u8 dev_addr,
}
/**
+ * ixgbe_read_i2c_byte_unlocked - Reads 8 bit word via I2C from device address
+ * @hw: pointer to hardware structure
+ * @byte_offset: byte offset to read
+ * @dev_addr: I2C bus address to read from
+ * @data: value read
+ *
+ * Performs byte read operation to SFP module's EEPROM over I2C interface.
+ **/
+s32 ixgbe_read_i2c_byte_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
+ u8 dev_addr, u8 *data)
+{
+ return ixgbe_call_func(hw, hw->phy.ops.read_i2c_byte_unlocked,
+ (hw, byte_offset, dev_addr, data),
+ IXGBE_NOT_IMPLEMENTED);
+}
+
+/**
* ixgbe_read_i2c_combined - Perform I2C read combined operation
* @hw: pointer to the hardware structure
* @addr: I2C bus address to read from
@@ -1355,6 +1402,23 @@ s32 ixgbe_read_i2c_combined(struct ixgbe_hw *hw, u8 addr, u16 reg, u16 *val)
}
/**
+ * ixgbe_read_i2c_combined_unlocked - Perform I2C read combined operation
+ * @hw: pointer to the hardware structure
+ * @addr: I2C bus address to read from
+ * @reg: I2C device register to read from
+ * @val: pointer to location to receive read value
+ *
+ * Returns an error code on error.
+ **/
+s32 ixgbe_read_i2c_combined_unlocked(struct ixgbe_hw *hw, u8 addr, u16 reg,
+ u16 *val)
+{
+ return ixgbe_call_func(hw, hw->phy.ops.read_i2c_combined_unlocked,
+ (hw, addr, reg, val),
+ IXGBE_NOT_IMPLEMENTED);
+}
+
+/**
* ixgbe_write_i2c_byte - Writes 8 bit word over I2C
* @hw: pointer to hardware structure
* @byte_offset: byte offset to write
@@ -1372,6 +1436,24 @@ s32 ixgbe_write_i2c_byte(struct ixgbe_hw *hw, u8 byte_offset, u8 dev_addr,
}
/**
+ * ixgbe_write_i2c_byte_unlocked - Writes 8 bit word over I2C
+ * @hw: pointer to hardware structure
+ * @byte_offset: byte offset to write
+ * @dev_addr: I2C bus address to write to
+ * @data: value to write
+ *
+ * Performs byte write operation to SFP module's EEPROM over I2C interface
+ * at a specified device address.
+ **/
+s32 ixgbe_write_i2c_byte_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
+ u8 dev_addr, u8 data)
+{
+ return ixgbe_call_func(hw, hw->phy.ops.write_i2c_byte_unlocked,
+ (hw, byte_offset, dev_addr, data),
+ IXGBE_NOT_IMPLEMENTED);
+}
+
+/**
* ixgbe_write_i2c_combined - Perform I2C write combined operation
* @hw: pointer to the hardware structure
* @addr: I2C bus address to write to
@@ -1387,6 +1469,22 @@ s32 ixgbe_write_i2c_combined(struct ixgbe_hw *hw, u8 addr, u16 reg, u16 val)
}
/**
+ * ixgbe_write_i2c_combined_unlocked - Perform I2C write combined operation
+ * @hw: pointer to the hardware structure
+ * @addr: I2C bus address to write to
+ * @reg: I2C device register to write to
+ * @val: value to write
+ *
+ * Returns an error code on error.
+ **/
+s32 ixgbe_write_i2c_combined_unlocked(struct ixgbe_hw *hw, u8 addr, u16 reg,
+ u16 val)
+{
+ return ixgbe_call_func(hw, hw->phy.ops.write_i2c_combined_unlocked,
+ (hw, addr, reg, val), IXGBE_NOT_IMPLEMENTED);
+}
+
+/**
* ixgbe_write_i2c_eeprom - Writes 8 bit EEPROM word over I2C interface
* @hw: pointer to hardware structure
* @byte_offset: EEPROM byte offset to write
diff --git a/sys/dev/ixgbe/ixgbe_api.h b/sys/dev/ixgbe/ixgbe_api.h
index 650ae67..8c2c4a8 100644
--- a/sys/dev/ixgbe/ixgbe_api.h
+++ b/sys/dev/ixgbe/ixgbe_api.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -173,10 +173,18 @@ u32 ixgbe_atr_compute_sig_hash_82599(union ixgbe_atr_hash_dword input,
bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw);
s32 ixgbe_read_i2c_byte(struct ixgbe_hw *hw, u8 byte_offset, u8 dev_addr,
u8 *data);
+s32 ixgbe_read_i2c_byte_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
+ u8 dev_addr, u8 *data);
s32 ixgbe_read_i2c_combined(struct ixgbe_hw *hw, u8 addr, u16 reg, u16 *val);
+s32 ixgbe_read_i2c_combined_unlocked(struct ixgbe_hw *hw, u8 addr, u16 reg,
+ u16 *val);
s32 ixgbe_write_i2c_byte(struct ixgbe_hw *hw, u8 byte_offset, u8 dev_addr,
u8 data);
+s32 ixgbe_write_i2c_byte_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
+ u8 dev_addr, u8 data);
s32 ixgbe_write_i2c_combined(struct ixgbe_hw *hw, u8 addr, u16 reg, u16 val);
+s32 ixgbe_write_i2c_combined_unlocked(struct ixgbe_hw *hw, u8 addr, u16 reg,
+ u16 val);
s32 ixgbe_write_i2c_eeprom(struct ixgbe_hw *hw, u8 byte_offset, u8 eeprom_data);
s32 ixgbe_get_san_mac_addr(struct ixgbe_hw *hw, u8 *san_mac_addr);
s32 ixgbe_set_san_mac_addr(struct ixgbe_hw *hw, u8 *san_mac_addr);
@@ -203,6 +211,7 @@ void ixgbe_enable_mdd(struct ixgbe_hw *hw);
void ixgbe_mdd_event(struct ixgbe_hw *hw, u32 *vf_bitmap);
void ixgbe_restore_mdd_vf(struct ixgbe_hw *hw, u32 vf);
s32 ixgbe_enter_lplu(struct ixgbe_hw *hw);
+s32 ixgbe_handle_lasi(struct ixgbe_hw *hw);
void ixgbe_set_rate_select_speed(struct ixgbe_hw *hw, ixgbe_link_speed speed);
void ixgbe_disable_rx(struct ixgbe_hw *hw);
void ixgbe_enable_rx(struct ixgbe_hw *hw);
diff --git a/sys/dev/ixgbe/ixgbe_common.c b/sys/dev/ixgbe/ixgbe_common.c
index 57fe1b5..f0a0776 100644
--- a/sys/dev/ixgbe/ixgbe_common.c
+++ b/sys/dev/ixgbe/ixgbe_common.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -188,6 +188,7 @@ bool ixgbe_device_supports_autoneg_fc(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X540T1:
case IXGBE_DEV_ID_X540_BYPASS:
case IXGBE_DEV_ID_X550T:
+ case IXGBE_DEV_ID_X550EM_X_10G_T:
supported = TRUE;
break;
default:
@@ -1090,7 +1091,7 @@ s32 ixgbe_stop_adapter_generic(struct ixgbe_hw *hw)
msec_delay(2);
/*
- * Prevent the PCI-E bus from from hanging by disabling PCI-E master
+ * Prevent the PCI-E bus from hanging by disabling PCI-E master
* access and verify no pending requests
*/
return ixgbe_disable_pcie_master(hw);
@@ -3573,7 +3574,6 @@ u16 ixgbe_get_pcie_msix_count_generic(struct ixgbe_hw *hw)
case ixgbe_mac_X540:
case ixgbe_mac_X550:
case ixgbe_mac_X550EM_x:
- case ixgbe_mac_X550EM_a:
pcie_offset = IXGBE_PCIE_MSIX_82599_CAPS;
max_msix_count = IXGBE_MAX_MSIX_VECTORS_82599;
break;
diff --git a/sys/dev/ixgbe/ixgbe_common.h b/sys/dev/ixgbe/ixgbe_common.h
index 94c7f97..e685f5b 100644
--- a/sys/dev/ixgbe/ixgbe_common.h
+++ b/sys/dev/ixgbe/ixgbe_common.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/sys/dev/ixgbe/ixgbe_dcb.c b/sys/dev/ixgbe/ixgbe_dcb.c
index 6f848e7..3659d17 100644
--- a/sys/dev/ixgbe/ixgbe_dcb.c
+++ b/sys/dev/ixgbe/ixgbe_dcb.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -396,7 +396,6 @@ s32 ixgbe_dcb_get_tc_stats(struct ixgbe_hw *hw, struct ixgbe_hw_stats *stats,
case ixgbe_mac_X540:
case ixgbe_mac_X550:
case ixgbe_mac_X550EM_x:
- case ixgbe_mac_X550EM_a:
#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
ret = ixgbe_dcb_get_tc_stats_82599(hw, stats, tc_count);
break;
@@ -427,7 +426,6 @@ s32 ixgbe_dcb_get_pfc_stats(struct ixgbe_hw *hw, struct ixgbe_hw_stats *stats,
case ixgbe_mac_X540:
case ixgbe_mac_X550:
case ixgbe_mac_X550EM_x:
- case ixgbe_mac_X550EM_a:
#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
ret = ixgbe_dcb_get_pfc_stats_82599(hw, stats, tc_count);
break;
@@ -469,7 +467,6 @@ s32 ixgbe_dcb_config_rx_arbiter_cee(struct ixgbe_hw *hw,
case ixgbe_mac_X540:
case ixgbe_mac_X550:
case ixgbe_mac_X550EM_x:
- case ixgbe_mac_X550EM_a:
#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
ret = ixgbe_dcb_config_rx_arbiter_82599(hw, refill, max, bwgid,
tsa, map);
@@ -511,7 +508,6 @@ s32 ixgbe_dcb_config_tx_desc_arbiter_cee(struct ixgbe_hw *hw,
case ixgbe_mac_X540:
case ixgbe_mac_X550:
case ixgbe_mac_X550EM_x:
- case ixgbe_mac_X550EM_a:
#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
ret = ixgbe_dcb_config_tx_desc_arbiter_82599(hw, refill, max,
bwgid, tsa);
@@ -555,7 +551,6 @@ s32 ixgbe_dcb_config_tx_data_arbiter_cee(struct ixgbe_hw *hw,
case ixgbe_mac_X540:
case ixgbe_mac_X550:
case ixgbe_mac_X550EM_x:
- case ixgbe_mac_X550EM_a:
#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
ret = ixgbe_dcb_config_tx_data_arbiter_82599(hw, refill, max,
bwgid, tsa,
@@ -593,7 +588,6 @@ s32 ixgbe_dcb_config_pfc_cee(struct ixgbe_hw *hw,
case ixgbe_mac_X540:
case ixgbe_mac_X550:
case ixgbe_mac_X550EM_x:
- case ixgbe_mac_X550EM_a:
#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
ret = ixgbe_dcb_config_pfc_82599(hw, pfc_en, map);
break;
@@ -622,7 +616,6 @@ s32 ixgbe_dcb_config_tc_stats(struct ixgbe_hw *hw)
case ixgbe_mac_X540:
case ixgbe_mac_X550:
case ixgbe_mac_X550EM_x:
- case ixgbe_mac_X550EM_a:
#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
ret = ixgbe_dcb_config_tc_stats_82599(hw, NULL);
break;
@@ -670,7 +663,6 @@ s32 ixgbe_dcb_hw_config_cee(struct ixgbe_hw *hw,
case ixgbe_mac_X540:
case ixgbe_mac_X550:
case ixgbe_mac_X550EM_x:
- case ixgbe_mac_X550EM_a:
#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
ixgbe_dcb_config_82599(hw, dcb_config);
ret = ixgbe_dcb_hw_config_82599(hw, dcb_config->link_speed,
@@ -705,7 +697,6 @@ s32 ixgbe_dcb_config_pfc(struct ixgbe_hw *hw, u8 pfc_en, u8 *map)
case ixgbe_mac_X540:
case ixgbe_mac_X550:
case ixgbe_mac_X550EM_x:
- case ixgbe_mac_X550EM_a:
#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
ret = ixgbe_dcb_config_pfc_82599(hw, pfc_en, map);
break;
@@ -731,7 +722,6 @@ s32 ixgbe_dcb_hw_config(struct ixgbe_hw *hw, u16 *refill, u16 *max,
case ixgbe_mac_X540:
case ixgbe_mac_X550:
case ixgbe_mac_X550EM_x:
- case ixgbe_mac_X550EM_a:
#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT)
ixgbe_dcb_config_rx_arbiter_82599(hw, refill, max, bwg_id,
tsa, map);
diff --git a/sys/dev/ixgbe/ixgbe_dcb.h b/sys/dev/ixgbe/ixgbe_dcb.h
index 878bbf8..871b784 100644
--- a/sys/dev/ixgbe/ixgbe_dcb.h
+++ b/sys/dev/ixgbe/ixgbe_dcb.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/sys/dev/ixgbe/ixgbe_dcb_82598.c b/sys/dev/ixgbe/ixgbe_dcb_82598.c
index a5a090d..fb946c9 100644
--- a/sys/dev/ixgbe/ixgbe_dcb_82598.c
+++ b/sys/dev/ixgbe/ixgbe_dcb_82598.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/sys/dev/ixgbe/ixgbe_dcb_82598.h b/sys/dev/ixgbe/ixgbe_dcb_82598.h
index 47f19f6..35974f7 100644
--- a/sys/dev/ixgbe/ixgbe_dcb_82598.h
+++ b/sys/dev/ixgbe/ixgbe_dcb_82598.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/sys/dev/ixgbe/ixgbe_dcb_82599.c b/sys/dev/ixgbe/ixgbe_dcb_82599.c
index 0232d3c..4443411 100644
--- a/sys/dev/ixgbe/ixgbe_dcb_82599.c
+++ b/sys/dev/ixgbe/ixgbe_dcb_82599.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/sys/dev/ixgbe/ixgbe_dcb_82599.h b/sys/dev/ixgbe/ixgbe_dcb_82599.h
index 7702dc9..bab7628 100644
--- a/sys/dev/ixgbe/ixgbe_dcb_82599.h
+++ b/sys/dev/ixgbe/ixgbe_dcb_82599.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/sys/dev/ixgbe/ixgbe_mbx.c b/sys/dev/ixgbe/ixgbe_mbx.c
index 067bba0..d8ba55a 100644
--- a/sys/dev/ixgbe/ixgbe_mbx.c
+++ b/sys/dev/ixgbe/ixgbe_mbx.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -607,7 +607,6 @@ static s32 ixgbe_check_for_rst_pf(struct ixgbe_hw *hw, u16 vf_number)
break;
case ixgbe_mac_X550:
case ixgbe_mac_X550EM_x:
- case ixgbe_mac_X550EM_a:
case ixgbe_mac_X540:
vflre = IXGBE_READ_REG(hw, IXGBE_VFLREC(reg_offset));
break;
@@ -745,7 +744,6 @@ void ixgbe_init_mbx_params_pf(struct ixgbe_hw *hw)
if (hw->mac.type != ixgbe_mac_82599EB &&
hw->mac.type != ixgbe_mac_X550 &&
hw->mac.type != ixgbe_mac_X550EM_x &&
- hw->mac.type != ixgbe_mac_X550EM_a &&
hw->mac.type != ixgbe_mac_X540)
return;
diff --git a/sys/dev/ixgbe/ixgbe_mbx.h b/sys/dev/ixgbe/ixgbe_mbx.h
index 2cffb8a..ea75cbe 100644
--- a/sys/dev/ixgbe/ixgbe_mbx.h
+++ b/sys/dev/ixgbe/ixgbe_mbx.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/sys/dev/ixgbe/ixgbe_osdep.h b/sys/dev/ixgbe/ixgbe_osdep.h
index ebb55f4..95f6ed5c 100644
--- a/sys/dev/ixgbe/ixgbe_osdep.h
+++ b/sys/dev/ixgbe/ixgbe_osdep.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2013, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -108,13 +108,14 @@
#define UNREFERENCED_3PARAMETER(_p, _q, _r)
#define UNREFERENCED_4PARAMETER(_p, _q, _r, _s)
-
#define IXGBE_NTOHL(_i) ntohl(_i)
#define IXGBE_NTOHS(_i) ntohs(_i)
/* XXX these need to be revisited */
-#define IXGBE_CPU_TO_LE32 le32toh
-#define IXGBE_LE32_TO_CPUS le32dec
+#define IXGBE_CPU_TO_LE32 htole32
+#define IXGBE_LE32_TO_CPUS(x)
+#define IXGBE_CPU_TO_BE16 htobe16
+#define IXGBE_CPU_TO_BE32 htobe32
typedef uint8_t u8;
typedef int8_t s8;
diff --git a/sys/dev/ixgbe/ixgbe_phy.c b/sys/dev/ixgbe/ixgbe_phy.c
index 5ac719c..88206c7 100644
--- a/sys/dev/ixgbe/ixgbe_phy.c
+++ b/sys/dev/ixgbe/ixgbe_phy.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -101,16 +101,17 @@ static u8 ixgbe_ones_comp_byte_add(u8 add1, u8 add2)
}
/**
- * ixgbe_read_i2c_combined_generic - Perform I2C read combined operation
+ * ixgbe_read_i2c_combined_generic_int - Perform I2C read combined operation
* @hw: pointer to the hardware structure
* @addr: I2C bus address to read from
* @reg: I2C device register to read from
* @val: pointer to location to receive read value
+ * @lock: TRUE if to take and release semaphore
*
* Returns an error code on error.
*/
-static s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
- u16 reg, u16 *val)
+static s32 ixgbe_read_i2c_combined_generic_int(struct ixgbe_hw *hw, u8 addr,
+ u16 reg, u16 *val, bool lock)
{
u32 swfw_mask = hw->phy.phy_semaphore_mask;
int max_retry = 10;
@@ -121,11 +122,13 @@ static s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
u8 reg_high;
u8 csum;
+ if (hw->mac.type >= ixgbe_mac_X550)
+ max_retry = 3;
reg_high = ((reg >> 7) & 0xFE) | 1; /* Indicate read combined */
csum = ixgbe_ones_comp_byte_add(reg_high, reg & 0xFF);
csum = ~csum;
do {
- if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
+ if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
return IXGBE_ERR_SWFW_SYNC;
ixgbe_i2c_start(hw);
/* Device Address and write indication */
@@ -158,13 +161,15 @@ static s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
if (ixgbe_clock_out_i2c_bit(hw, FALSE))
goto fail;
ixgbe_i2c_stop(hw);
- hw->mac.ops.release_swfw_sync(hw, swfw_mask);
+ if (lock)
+ hw->mac.ops.release_swfw_sync(hw, swfw_mask);
*val = (high_bits << 8) | low_bits;
return 0;
fail:
ixgbe_i2c_bus_clear(hw);
- hw->mac.ops.release_swfw_sync(hw, swfw_mask);
+ if (lock)
+ hw->mac.ops.release_swfw_sync(hw, swfw_mask);
retry++;
if (retry < max_retry)
DEBUGOUT("I2C byte read combined error - Retrying.\n");
@@ -176,17 +181,50 @@ fail:
}
/**
- * ixgbe_write_i2c_combined_generic - Perform I2C write combined operation
+ * ixgbe_read_i2c_combined_generic - Perform I2C read combined operation
+ * @hw: pointer to the hardware structure
+ * @addr: I2C bus address to read from
+ * @reg: I2C device register to read from
+ * @val: pointer to location to receive read value
+ *
+ * Returns an error code on error.
+ **/
+static s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
+ u16 reg, u16 *val)
+{
+ return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, TRUE);
+}
+
+/**
+ * ixgbe_read_i2c_combined_generic_unlocked - Do I2C read combined operation
+ * @hw: pointer to the hardware structure
+ * @addr: I2C bus address to read from
+ * @reg: I2C device register to read from
+ * @val: pointer to location to receive read value
+ *
+ * Returns an error code on error.
+ **/
+static s32
+ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw *hw, u8 addr,
+ u16 reg, u16 *val)
+{
+ return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, FALSE);
+}
+
+/**
+ * ixgbe_write_i2c_combined_generic_int - Perform I2C write combined operation
* @hw: pointer to the hardware structure
* @addr: I2C bus address to write to
* @reg: I2C device register to write to
* @val: value to write
+ * @lock: TRUE if to take and release semaphore
*
* Returns an error code on error.
*/
-static s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
- u8 addr, u16 reg, u16 val)
+static s32 ixgbe_write_i2c_combined_generic_int(struct ixgbe_hw *hw, u8 addr,
+ u16 reg, u16 val, bool lock)
{
+ u32 swfw_mask = hw->phy.phy_semaphore_mask;
int max_retry = 1;
int retry = 0;
u8 reg_high;
@@ -198,6 +236,8 @@ static s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
csum = ixgbe_ones_comp_byte_add(csum, val & 0xFF);
csum = ~csum;
do {
+ if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
+ return IXGBE_ERR_SWFW_SYNC;
ixgbe_i2c_start(hw);
/* Device Address and write indication */
if (ixgbe_out_i2c_byte_ack(hw, addr))
@@ -218,10 +258,14 @@ static s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
if (ixgbe_out_i2c_byte_ack(hw, csum))
goto fail;
ixgbe_i2c_stop(hw);
+ if (lock)
+ hw->mac.ops.release_swfw_sync(hw, swfw_mask);
return 0;
fail:
ixgbe_i2c_bus_clear(hw);
+ if (lock)
+ hw->mac.ops.release_swfw_sync(hw, swfw_mask);
retry++;
if (retry < max_retry)
DEBUGOUT("I2C byte write combined error - Retrying.\n");
@@ -233,6 +277,37 @@ fail:
}
/**
+ * ixgbe_write_i2c_combined_generic - Perform I2C write combined operation
+ * @hw: pointer to the hardware structure
+ * @addr: I2C bus address to write to
+ * @reg: I2C device register to write to
+ * @val: value to write
+ *
+ * Returns an error code on error.
+ **/
+static s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
+ u8 addr, u16 reg, u16 val)
+{
+ return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, TRUE);
+}
+
+/**
+ * ixgbe_write_i2c_combined_generic_unlocked - Do I2C write combined operation
+ * @hw: pointer to the hardware structure
+ * @addr: I2C bus address to write to
+ * @reg: I2C device register to write to
+ * @val: value to write
+ *
+ * Returns an error code on error.
+ **/
+static s32
+ixgbe_write_i2c_combined_generic_unlocked(struct ixgbe_hw *hw,
+ u8 addr, u16 reg, u16 val)
+{
+ return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, FALSE);
+}
+
+/**
* ixgbe_init_phy_ops_generic - Inits PHY function ptrs
* @hw: pointer to the hardware structure
*
@@ -265,6 +340,13 @@ s32 ixgbe_init_phy_ops_generic(struct ixgbe_hw *hw)
phy->sfp_type = ixgbe_sfp_type_unknown;
phy->ops.read_i2c_combined = ixgbe_read_i2c_combined_generic;
phy->ops.write_i2c_combined = ixgbe_write_i2c_combined_generic;
+ phy->ops.read_i2c_combined_unlocked =
+ ixgbe_read_i2c_combined_generic_unlocked;
+ phy->ops.write_i2c_combined_unlocked =
+ ixgbe_write_i2c_combined_generic_unlocked;
+ phy->ops.read_i2c_byte_unlocked = ixgbe_read_i2c_byte_generic_unlocked;
+ phy->ops.write_i2c_byte_unlocked =
+ ixgbe_write_i2c_byte_generic_unlocked;
phy->ops.check_overtemp = ixgbe_tn_check_overtemp;
return IXGBE_SUCCESS;
}
@@ -1363,6 +1445,13 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
else
hw->phy.sfp_type =
ixgbe_sfp_type_1g_sx_core1;
+ } else if (comp_codes_1g & IXGBE_SFF_1GBASELX_CAPABLE) {
+ if (hw->bus.lan_id == 0)
+ hw->phy.sfp_type =
+ ixgbe_sfp_type_1g_lx_core0;
+ else
+ hw->phy.sfp_type =
+ ixgbe_sfp_type_1g_lx_core1;
} else {
hw->phy.sfp_type = ixgbe_sfp_type_unknown;
}
@@ -1450,6 +1539,8 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
if (comp_codes_10g == 0 &&
!(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
+ hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
+ hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
hw->phy.type = ixgbe_phy_sfp_unsupported;
@@ -1467,6 +1558,8 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)
if (!(enforce_sfp & IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP) &&
!(hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
+ hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
+ hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1)) {
/* Make sure we're a supported PHY type */
@@ -1600,6 +1693,9 @@ s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw)
goto out;
}
+ /* LAN ID is needed for I2C access */
+ hw->mac.ops.set_lan_id(hw);
+
status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_IDENTIFIER,
&identifier);
@@ -1614,9 +1710,6 @@ s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw)
hw->phy.id = identifier;
- /* LAN ID is needed for sfp_type determination */
- hw->mac.ops.set_lan_id(hw);
-
status = hw->phy.ops.read_i2c_eeprom(hw, IXGBE_SFF_QSFP_10GBE_COMP,
&comp_codes_10g);
@@ -1804,10 +1897,12 @@ s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw,
* SR modules
*/
if (sfp_type == ixgbe_sfp_type_da_act_lmt_core0 ||
+ sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
sfp_type == ixgbe_sfp_type_1g_cu_core0 ||
sfp_type == ixgbe_sfp_type_1g_sx_core0)
sfp_type = ixgbe_sfp_type_srlr_core0;
else if (sfp_type == ixgbe_sfp_type_da_act_lmt_core1 ||
+ sfp_type == ixgbe_sfp_type_1g_lx_core1 ||
sfp_type == ixgbe_sfp_type_1g_cu_core1 ||
sfp_type == ixgbe_sfp_type_1g_sx_core1)
sfp_type = ixgbe_sfp_type_srlr_core1;
@@ -1932,16 +2027,17 @@ static bool ixgbe_is_sfp_probe(struct ixgbe_hw *hw, u8 offset, u8 addr)
}
/**
- * ixgbe_read_i2c_byte_generic - Reads 8 bit word over I2C
+ * ixgbe_read_i2c_byte_generic_int - Reads 8 bit word over I2C
* @hw: pointer to hardware structure
* @byte_offset: byte offset to read
* @data: value read
+ * @lock: TRUE if to take and release semaphore
*
* Performs byte read operation to SFP module's EEPROM over I2C interface at
* a specified device address.
**/
-s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
- u8 dev_addr, u8 *data)
+static s32 ixgbe_read_i2c_byte_generic_int(struct ixgbe_hw *hw, u8 byte_offset,
+ u8 dev_addr, u8 *data, bool lock)
{
s32 status;
u32 max_retry = 10;
@@ -1952,11 +2048,13 @@ s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
DEBUGFUNC("ixgbe_read_i2c_byte_generic");
+ if (hw->mac.type >= ixgbe_mac_X550)
+ max_retry = 3;
if (ixgbe_is_sfp_probe(hw, byte_offset, dev_addr))
max_retry = IXGBE_SFP_DETECT_RETRIES;
do {
- if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
+ if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask))
return IXGBE_ERR_SWFW_SYNC;
ixgbe_i2c_start(hw);
@@ -1998,13 +2096,16 @@ s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
goto fail;
ixgbe_i2c_stop(hw);
- hw->mac.ops.release_swfw_sync(hw, swfw_mask);
+ if (lock)
+ hw->mac.ops.release_swfw_sync(hw, swfw_mask);
return IXGBE_SUCCESS;
fail:
ixgbe_i2c_bus_clear(hw);
- hw->mac.ops.release_swfw_sync(hw, swfw_mask);
- msec_delay(100);
+ if (lock) {
+ hw->mac.ops.release_swfw_sync(hw, swfw_mask);
+ msec_delay(100);
+ }
retry++;
if (retry < max_retry)
DEBUGOUT("I2C byte read error - Retrying.\n");
@@ -2017,28 +2118,60 @@ fail:
}
/**
- * ixgbe_write_i2c_byte_generic - Writes 8 bit word over I2C
+ * ixgbe_read_i2c_byte_generic - Reads 8 bit word over I2C
+ * @hw: pointer to hardware structure
+ * @byte_offset: byte offset to read
+ * @data: value read
+ *
+ * Performs byte read operation to SFP module's EEPROM over I2C interface at
+ * a specified device address.
+ **/
+s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
+ u8 dev_addr, u8 *data)
+{
+ return ixgbe_read_i2c_byte_generic_int(hw, byte_offset, dev_addr,
+ data, TRUE);
+}
+
+/**
+ * ixgbe_read_i2c_byte_generic_unlocked - Reads 8 bit word over I2C
+ * @hw: pointer to hardware structure
+ * @byte_offset: byte offset to read
+ * @data: value read
+ *
+ * Performs byte read operation to SFP module's EEPROM over I2C interface at
+ * a specified device address.
+ **/
+s32 ixgbe_read_i2c_byte_generic_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
+ u8 dev_addr, u8 *data)
+{
+ return ixgbe_read_i2c_byte_generic_int(hw, byte_offset, dev_addr,
+ data, FALSE);
+}
+
+/**
+ * ixgbe_write_i2c_byte_generic_int - Writes 8 bit word over I2C
* @hw: pointer to hardware structure
* @byte_offset: byte offset to write
* @data: value to write
+ * @lock: TRUE if to take and release semaphore
*
* Performs byte write operation to SFP module's EEPROM over I2C interface at
* a specified device address.
**/
-s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
- u8 dev_addr, u8 data)
+static s32 ixgbe_write_i2c_byte_generic_int(struct ixgbe_hw *hw, u8 byte_offset,
+ u8 dev_addr, u8 data, bool lock)
{
- s32 status = IXGBE_SUCCESS;
+ s32 status;
u32 max_retry = 1;
u32 retry = 0;
u32 swfw_mask = hw->phy.phy_semaphore_mask;
DEBUGFUNC("ixgbe_write_i2c_byte_generic");
- if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) != IXGBE_SUCCESS) {
- status = IXGBE_ERR_SWFW_SYNC;
- goto write_byte_out;
- }
+ if (lock && hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) !=
+ IXGBE_SUCCESS)
+ return IXGBE_ERR_SWFW_SYNC;
do {
ixgbe_i2c_start(hw);
@@ -2068,7 +2201,8 @@ s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
goto fail;
ixgbe_i2c_stop(hw);
- hw->mac.ops.release_swfw_sync(hw, swfw_mask);
+ if (lock)
+ hw->mac.ops.release_swfw_sync(hw, swfw_mask);
return IXGBE_SUCCESS;
fail:
@@ -2080,13 +2214,45 @@ fail:
DEBUGOUT("I2C byte write error.\n");
} while (retry < max_retry);
- hw->mac.ops.release_swfw_sync(hw, swfw_mask);
+ if (lock)
+ hw->mac.ops.release_swfw_sync(hw, swfw_mask);
-write_byte_out:
return status;
}
/**
+ * ixgbe_write_i2c_byte_generic - Writes 8 bit word over I2C
+ * @hw: pointer to hardware structure
+ * @byte_offset: byte offset to write
+ * @data: value to write
+ *
+ * Performs byte write operation to SFP module's EEPROM over I2C interface at
+ * a specified device address.
+ **/
+s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
+ u8 dev_addr, u8 data)
+{
+ return ixgbe_write_i2c_byte_generic_int(hw, byte_offset, dev_addr,
+ data, TRUE);
+}
+
+/**
+ * ixgbe_write_i2c_byte_generic_unlocked - Writes 8 bit word over I2C
+ * @hw: pointer to hardware structure
+ * @byte_offset: byte offset to write
+ * @data: value to write
+ *
+ * Performs byte write operation to SFP module's EEPROM over I2C interface at
+ * a specified device address.
+ **/
+s32 ixgbe_write_i2c_byte_generic_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
+ u8 dev_addr, u8 data)
+{
+ return ixgbe_write_i2c_byte_generic_int(hw, byte_offset, dev_addr,
+ data, FALSE);
+}
+
+/**
* ixgbe_i2c_start - Sets I2C start condition
* @hw: pointer to hardware structure
*
diff --git a/sys/dev/ixgbe/ixgbe_phy.h b/sys/dev/ixgbe/ixgbe_phy.h
index 021d5f0..fad31bd 100644
--- a/sys/dev/ixgbe/ixgbe_phy.h
+++ b/sys/dev/ixgbe/ixgbe_phy.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -89,9 +89,24 @@
#define IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS 0x3
#define IXGBE_CS4227 0xBE /* CS4227 address */
-#define IXGBE_CS4227_SPARE24_LSB 0x12B0 /* Reg to program EDC */
+#define IXGBE_CS4227_GLOBAL_ID_LSB 0
+#define IXGBE_CS4227_SCRATCH 2
+#define IXGBE_CS4227_GLOBAL_ID_VALUE 0x03E5
+#define IXGBE_CS4227_SCRATCH_VALUE 0x5aa5
+#define IXGBE_CS4227_RETRIES 5
+#define IXGBE_CS4227_LINE_SPARE22_MSB 0x12AD /* Reg to program speed */
+#define IXGBE_CS4227_LINE_SPARE24_LSB 0x12B0 /* Reg to program EDC */
+#define IXGBE_CS4227_HOST_SPARE22_MSB 0x1AAD /* Reg to program speed */
+#define IXGBE_CS4227_HOST_SPARE24_LSB 0x1AB0 /* Reg to program EDC */
#define IXGBE_CS4227_EDC_MODE_CX1 0x0002
#define IXGBE_CS4227_EDC_MODE_SR 0x0004
+#define IXGBE_CS4227_RESET_HOLD 500 /* microseconds */
+#define IXGBE_CS4227_RESET_DELAY 500 /* milliseconds */
+#define IXGBE_CS4227_CHECK_DELAY 30 /* milliseconds */
+#define IXGBE_PE 0xE0 /* Port expander address */
+#define IXGBE_PE_OUTPUT 1 /* Output register offset */
+#define IXGBE_PE_CONFIG 3 /* Config register offset */
+#define IXGBE_PE_BIT1 (1 << 1)
/* Flow control defines */
#define IXGBE_TAF_SYM_PAUSE 0x400
@@ -175,8 +190,12 @@ s32 ixgbe_get_sfp_init_sequence_offsets(struct ixgbe_hw *hw,
s32 ixgbe_tn_check_overtemp(struct ixgbe_hw *hw);
s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
u8 dev_addr, u8 *data);
+s32 ixgbe_read_i2c_byte_generic_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
+ u8 dev_addr, u8 *data);
s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,
u8 dev_addr, u8 data);
+s32 ixgbe_write_i2c_byte_generic_unlocked(struct ixgbe_hw *hw, u8 byte_offset,
+ u8 dev_addr, u8 data);
s32 ixgbe_read_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
u8 *eeprom_data);
s32 ixgbe_write_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,
diff --git a/sys/dev/ixgbe/ixgbe_type.h b/sys/dev/ixgbe/ixgbe_type.h
index 24ba046..2a53952 100644
--- a/sys/dev/ixgbe/ixgbe_type.h
+++ b/sys/dev/ixgbe/ixgbe_type.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -111,6 +111,7 @@
#define IXGBE_SUBDEV_ID_82599_LOM_SNAP6 0x2159
#define IXGBE_SUBDEV_ID_82599_SFP_1OCP 0x000D
#define IXGBE_SUBDEV_ID_82599_SFP_2OCP 0x0008
+#define IXGBE_SUBDEV_ID_82599_SFP_LOM 0x06EE
#define IXGBE_DEV_ID_82599_BACKPLANE_FCOE 0x152A
#define IXGBE_DEV_ID_82599_SFP_FCOE 0x1529
#define IXGBE_DEV_ID_82599_SFP_EM 0x1507
@@ -130,8 +131,6 @@
#define IXGBE_DEV_ID_X540_BYPASS 0x155C
#define IXGBE_DEV_ID_X540T1 0x1560
#define IXGBE_DEV_ID_X550T 0x1563
-/* Placeholder value, pending official value. */
-#define IXGBE_DEV_ID_X550EM_A_KR 0xABCD
#define IXGBE_DEV_ID_X550EM_X_KX4 0x15AA
#define IXGBE_DEV_ID_X550EM_X_KR 0x15AB
#define IXGBE_DEV_ID_X550EM_X_SFP 0x15AC
@@ -139,11 +138,13 @@
#define IXGBE_DEV_ID_X550EM_X_1G_T 0x15AE
#define IXGBE_DEV_ID_X550_VF_HV 0x1564
#define IXGBE_DEV_ID_X550_VF 0x1565
-#define IXGBE_DEV_ID_X550EM_A_VF 0x15B3
-#define IXGBE_DEV_ID_X550EM_A_VF_HV 0x15B4
#define IXGBE_DEV_ID_X550EM_X_VF 0x15A8
#define IXGBE_DEV_ID_X550EM_X_VF_HV 0x15A9
+#define IXGBE_CAT(r,m) IXGBE_##r##m
+
+#define IXGBE_BY_MAC(_hw, r) ((_hw)->mvals[IXGBE_CAT(r, _IDX)])
+
/* General Registers */
#define IXGBE_CTRL 0x00000
#define IXGBE_STATUS 0x00008
@@ -151,9 +152,11 @@
#define IXGBE_ESDP 0x00020
#define IXGBE_EODSDP 0x00028
#define IXGBE_I2CCTL_82599 0x00028
+#define IXGBE_I2CCTL IXGBE_I2CCTL_82599
+#define IXGBE_I2CCTL_X540 IXGBE_I2CCTL_82599
#define IXGBE_I2CCTL_X550 0x15F5C
-#define IXGBE_I2CCTL_BY_MAC(_hw) ((((_hw)->mac.type >= ixgbe_mac_X550) ? \
- IXGBE_I2CCTL_X550 : IXGBE_I2CCTL_82599))
+#define IXGBE_I2CCTL_X550EM_x IXGBE_I2CCTL_X550
+#define IXGBE_I2CCTL_BY_MAC(_hw) IXGBE_BY_MAC((_hw), I2CCTL)
#define IXGBE_PHY_GPIO 0x00028
#define IXGBE_MAC_GPIO 0x00030
#define IXGBE_PHYINT_STATUS0 0x00100
@@ -166,18 +169,40 @@
#define IXGBE_EXVET 0x05078
/* NVM Registers */
-#define IXGBE_EEC 0x10010
-#define IXGBE_EERD 0x10014
-#define IXGBE_EEWR 0x10018
-#define IXGBE_FLA 0x1001C
+#define IXGBE_EEC 0x10010
+#define IXGBE_EEC_X540 IXGBE_EEC
+#define IXGBE_EEC_X550 IXGBE_EEC
+#define IXGBE_EEC_X550EM_x IXGBE_EEC
+#define IXGBE_EEC_BY_MAC(_hw) IXGBE_EEC
+
+#define IXGBE_EERD 0x10014
+#define IXGBE_EEWR 0x10018
+
+#define IXGBE_FLA 0x1001C
+#define IXGBE_FLA_X540 IXGBE_FLA
+#define IXGBE_FLA_X550 IXGBE_FLA
+#define IXGBE_FLA_X550EM_x IXGBE_FLA
+#define IXGBE_FLA_BY_MAC(_hw) IXGBE_FLA
+
#define IXGBE_EEMNGCTL 0x10110
#define IXGBE_EEMNGDATA 0x10114
#define IXGBE_FLMNGCTL 0x10118
#define IXGBE_FLMNGDATA 0x1011C
#define IXGBE_FLMNGCNT 0x10120
#define IXGBE_FLOP 0x1013C
-#define IXGBE_GRC 0x10200
-#define IXGBE_SRAMREL 0x10210
+
+#define IXGBE_GRC 0x10200
+#define IXGBE_GRC_X540 IXGBE_GRC
+#define IXGBE_GRC_X550 IXGBE_GRC
+#define IXGBE_GRC_X550EM_x IXGBE_GRC
+#define IXGBE_GRC_BY_MAC(_hw) IXGBE_GRC
+
+#define IXGBE_SRAMREL 0x10210
+#define IXGBE_SRAMREL_X540 IXGBE_SRAMREL
+#define IXGBE_SRAMREL_X550 IXGBE_SRAMREL
+#define IXGBE_SRAMREL_X550EM_x IXGBE_SRAMREL
+#define IXGBE_SRAMREL_BY_MAC(_hw) IXGBE_SRAMREL
+
#define IXGBE_PHYDBG 0x10218
/* General Receive Control */
@@ -188,20 +213,48 @@
#define IXGBE_VPDDIAG1 0x10208
/* I2CCTL Bit Masks */
-#define IXGBE_I2C_CLK_IN_BY_MAC(_hw)(((_hw)->mac.type) >= ixgbe_mac_X550 ? \
- 0x00004000 : 0x00000001)
-#define IXGBE_I2C_CLK_OUT_BY_MAC(_hw)(((_hw)->mac.type) >= ixgbe_mac_X550 ? \
- 0x00000200 : 0x00000002)
-#define IXGBE_I2C_DATA_IN_BY_MAC(_hw)(((_hw)->mac.type) >= ixgbe_mac_X550 ? \
- 0x00001000 : 0x00000004)
-#define IXGBE_I2C_DATA_OUT_BY_MAC(_hw)(((_hw)->mac.type) >= ixgbe_mac_X550 ? \
- 0x00000400 : 0x00000008)
-#define IXGBE_I2C_BB_EN_BY_MAC(hw) ((hw)->mac.type >= ixgbe_mac_X550 ? \
- 0x00000100 : 0)
-#define IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw) ((hw)->mac.type >= ixgbe_mac_X550 ? \
- 0x00000800 : 0)
-#define IXGBE_I2C_CLK_OE_N_EN_BY_MAC(hw) ((hw)->mac.type >= ixgbe_mac_X550 ? \
- 0x00002000 : 0)
+#define IXGBE_I2C_CLK_IN 0x00000001
+#define IXGBE_I2C_CLK_IN_X540 IXGBE_I2C_CLK_IN
+#define IXGBE_I2C_CLK_IN_X550 0x00004000
+#define IXGBE_I2C_CLK_IN_X550EM_x IXGBE_I2C_CLK_IN_X550
+#define IXGBE_I2C_CLK_IN_BY_MAC(_hw) IXGBE_BY_MAC((_hw), I2C_CLK_IN)
+
+#define IXGBE_I2C_CLK_OUT 0x00000002
+#define IXGBE_I2C_CLK_OUT_X540 IXGBE_I2C_CLK_OUT
+#define IXGBE_I2C_CLK_OUT_X550 0x00000200
+#define IXGBE_I2C_CLK_OUT_X550EM_x IXGBE_I2C_CLK_OUT_X550
+#define IXGBE_I2C_CLK_OUT_BY_MAC(_hw) IXGBE_BY_MAC((_hw), I2C_CLK_OUT)
+
+#define IXGBE_I2C_DATA_IN 0x00000004
+#define IXGBE_I2C_DATA_IN_X540 IXGBE_I2C_DATA_IN
+#define IXGBE_I2C_DATA_IN_X550 0x00001000
+#define IXGBE_I2C_DATA_IN_X550EM_x IXGBE_I2C_DATA_IN_X550
+#define IXGBE_I2C_DATA_IN_BY_MAC(_hw) IXGBE_BY_MAC((_hw), I2C_DATA_IN)
+
+#define IXGBE_I2C_DATA_OUT 0x00000008
+#define IXGBE_I2C_DATA_OUT_X540 IXGBE_I2C_DATA_OUT
+#define IXGBE_I2C_DATA_OUT_X550 0x00000400
+#define IXGBE_I2C_DATA_OUT_X550EM_x IXGBE_I2C_DATA_OUT_X550
+#define IXGBE_I2C_DATA_OUT_BY_MAC(_hw) IXGBE_BY_MAC((_hw), I2C_DATA_OUT)
+
+#define IXGBE_I2C_DATA_OE_N_EN 0
+#define IXGBE_I2C_DATA_OE_N_EN_X540 IXGBE_I2C_DATA_OE_N_EN
+#define IXGBE_I2C_DATA_OE_N_EN_X550 0x00000800
+#define IXGBE_I2C_DATA_OE_N_EN_X550EM_x IXGBE_I2C_DATA_OE_N_EN_X550
+#define IXGBE_I2C_DATA_OE_N_EN_BY_MAC(_hw) IXGBE_BY_MAC((_hw), I2C_DATA_OE_N_EN)
+
+#define IXGBE_I2C_BB_EN 0
+#define IXGBE_I2C_BB_EN_X540 IXGBE_I2C_BB_EN
+#define IXGBE_I2C_BB_EN_X550 0x00000100
+#define IXGBE_I2C_BB_EN_X550EM_x IXGBE_I2C_BB_EN_X550
+
+#define IXGBE_I2C_BB_EN_BY_MAC(_hw) IXGBE_BY_MAC((_hw), I2C_BB_EN)
+
+#define IXGBE_I2C_CLK_OE_N_EN 0
+#define IXGBE_I2C_CLK_OE_N_EN_X540 IXGBE_I2C_CLK_OE_N_EN
+#define IXGBE_I2C_CLK_OE_N_EN_X550 0x00002000
+#define IXGBE_I2C_CLK_OE_N_EN_X550EM_x IXGBE_I2C_CLK_OE_N_EN_X550
+#define IXGBE_I2C_CLK_OE_N_EN_BY_MAC(_hw) IXGBE_BY_MAC((_hw), I2C_CLK_OE_N_EN)
#define IXGBE_I2C_CLOCK_STRETCHING_TIMEOUT 500
@@ -612,6 +665,7 @@ struct ixgbe_dmac_config {
#define IXGBE_EEER 0x043A0 /* EEE register */
#define IXGBE_EEE_STAT 0x04398 /* EEE Status */
#define IXGBE_EEE_SU 0x04380 /* EEE Set up */
+#define IXGBE_EEE_SU_TEEE_DLY_SHIFT 26
#define IXGBE_TLPIC 0x041F4 /* EEE Tx LPI count */
#define IXGBE_RLPIC 0x041F8 /* EEE Rx LPI count */
@@ -989,14 +1043,34 @@ struct ixgbe_dmac_config {
#define IXGBE_GSCN_2 0x11028
#define IXGBE_GSCN_3 0x1102C
#define IXGBE_FACTPS 0x10150
+#define IXGBE_FACTPS_X540 IXGBE_FACTPS
+#define IXGBE_FACTPS_X550 IXGBE_FACTPS
+#define IXGBE_FACTPS_X550EM_x IXGBE_FACTPS
+#define IXGBE_FACTPS_BY_MAC(_hw) IXGBE_FACTPS
+
#define IXGBE_PCIEANACTL 0x11040
#define IXGBE_SWSM 0x10140
+#define IXGBE_SWSM_X540 IXGBE_SWSM
+#define IXGBE_SWSM_X550 IXGBE_SWSM
+#define IXGBE_SWSM_X550EM_x IXGBE_SWSM
+#define IXGBE_SWSM_BY_MAC(_hw) IXGBE_SWSM
+
#define IXGBE_FWSM 0x10148
+#define IXGBE_FWSM_X540 IXGBE_FWSM
+#define IXGBE_FWSM_X550 IXGBE_FWSM
+#define IXGBE_FWSM_X550EM_x IXGBE_FWSM
+#define IXGBE_FWSM_BY_MAC(_hw) IXGBE_FWSM
+
+#define IXGBE_SWFW_SYNC IXGBE_GSSR
+#define IXGBE_SWFW_SYNC_X540 IXGBE_SWFW_SYNC
+#define IXGBE_SWFW_SYNC_X550 IXGBE_SWFW_SYNC
+#define IXGBE_SWFW_SYNC_X550EM_x IXGBE_SWFW_SYNC
+#define IXGBE_SWFW_SYNC_BY_MAC(_hw) IXGBE_SWFW_SYNC
+
#define IXGBE_GSSR 0x10160
#define IXGBE_MREVID 0x11064
#define IXGBE_DCA_ID 0x11070
#define IXGBE_DCA_CTRL 0x11074
-#define IXGBE_SWFW_SYNC IXGBE_GSSR
/* PCI-E registers 82599-Specific */
#define IXGBE_GCR_EXT 0x11050
@@ -1008,14 +1082,18 @@ struct ixgbe_dmac_config {
#define IXGBE_PHYDAT_82599 0x11044
#define IXGBE_PHYCTL_82599 0x11048
#define IXGBE_PBACLR_82599 0x11068
-#define IXGBE_CIAA_82599 0x11088
-#define IXGBE_CIAD_82599 0x1108C
+#define IXGBE_CIAA 0x11088
+#define IXGBE_CIAD 0x1108C
+#define IXGBE_CIAA_82599 IXGBE_CIAA
+#define IXGBE_CIAD_82599 IXGBE_CIAD
+#define IXGBE_CIAA_X540 IXGBE_CIAA
+#define IXGBE_CIAD_X540 IXGBE_CIAD
#define IXGBE_CIAA_X550 0x11508
#define IXGBE_CIAD_X550 0x11510
-#define IXGBE_CIAA_BY_MAC(_hw) ((((_hw)->mac.type >= ixgbe_mac_X550) ? \
- IXGBE_CIAA_X550 : IXGBE_CIAA_82599))
-#define IXGBE_CIAD_BY_MAC(_hw) ((((_hw)->mac.type >= ixgbe_mac_X550) ? \
- IXGBE_CIAD_X550 : IXGBE_CIAD_82599))
+#define IXGBE_CIAA_X550EM_x IXGBE_CIAA_X550
+#define IXGBE_CIAD_X550EM_x IXGBE_CIAD_X550
+#define IXGBE_CIAA_BY_MAC(_hw) IXGBE_BY_MAC((_hw), CIAA)
+#define IXGBE_CIAD_BY_MAC(_hw) IXGBE_BY_MAC((_hw), CIAD)
#define IXGBE_PICAUSE 0x110B0
#define IXGBE_PIENA 0x110B8
#define IXGBE_CDQ_MBR_82599 0x110B4
@@ -1365,6 +1443,8 @@ struct ixgbe_dmac_config {
#define IXGBE_MDIO_AUTO_NEG_STATUS 0x1 /* AUTO_NEG Status Reg */
#define IXGBE_MDIO_AUTO_NEG_VENDOR_STAT 0xC800 /* AUTO_NEG Vendor Status Reg */
#define IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM 0xCC00 /* AUTO_NEG Vendor TX Reg */
+#define IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2 0xCC01 /* AUTO_NEG Vendor Tx Reg */
+#define IXGBE_MDIO_AUTO_NEG_VEN_LSC 0x1 /* AUTO_NEG Vendor Tx LSC */
#define IXGBE_MDIO_AUTO_NEG_ADVT 0x10 /* AUTO_NEG Advt Reg */
#define IXGBE_MDIO_AUTO_NEG_LP 0x13 /* AUTO_NEG LP Status Reg */
#define IXGBE_MDIO_AUTO_NEG_EEE_ADVT 0x3C /* AUTO_NEG EEE Advt Reg */
@@ -1393,11 +1473,24 @@ struct ixgbe_dmac_config {
#define IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK 0x3 /* PHY Reset Complete Mask */
#define IXGBE_MDIO_GLOBAL_RES_PR_10 0xC479 /* Global Resv Provisioning 10 Reg */
#define IXGBE_MDIO_POWER_UP_STALL 0x8000 /* Power Up Stall */
-
+#define IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK 0xFF00 /* int std mask */
+#define IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG 0xFC00 /* chip std int flag */
+#define IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK 0xFF01 /* int chip-wide mask */
+#define IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG 0xFC01 /* int chip-wide mask */
+#define IXGBE_MDIO_GLOBAL_ALARM_1 0xCC00 /* Global alarm 1 */
+#define IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL 0x4000 /* high temp failure */
+#define IXGBE_MDIO_GLOBAL_INT_MASK 0xD400 /* Global int mask */
+#define IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN 0x1000 /* autoneg vendor alarm int enable */
+#define IXGBE_MDIO_GLOBAL_ALARM_1_INT 0x4 /* int in Global alarm 1 */
+#define IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN 0x1 /* vendor alarm int enable */
+#define IXGBE_MDIO_GLOBAL_STD_ALM2_INT 0x200 /* vendor alarm2 int mask */
+#define IXGBE_MDIO_GLOBAL_INT_HI_TEMP_EN 0x4000 /* int high temp enable */
#define IXGBE_MDIO_PMA_PMD_CONTROL_ADDR 0x0000 /* PMA/PMD Control Reg */
#define IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR 0xC30A /* PHY_XS SDA/SCL Addr Reg */
#define IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA 0xC30B /* PHY_XS SDA/SCL Data Reg */
#define IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT 0xC30C /* PHY_XS SDA/SCL Status Reg */
+#define IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK 0xD401 /* PHY TX Vendor LASI */
+#define IXGBE_MDIO_PMA_TX_VEN_LASI_INT_EN 0x1 /* PHY TX Vendor LASI enable */
#define IXGBE_MDIO_PMD_STD_TX_DISABLE_CNTR 0x9 /* Standard Transmit Dis Reg */
#define IXGBE_MDIO_PMD_GLOBAL_TX_DISABLE 0x0001 /* PMD Global Transmit Dis */
@@ -1479,12 +1572,16 @@ struct ixgbe_dmac_config {
#define IXGBE_SDP0_GPIEN_X540 0x00000002 /* SDP0 on X540 and X550 */
#define IXGBE_SDP1_GPIEN_X540 0x00000004 /* SDP1 on X540 and X550 */
#define IXGBE_SDP2_GPIEN_X540 0x00000008 /* SDP2 on X540 and X550 */
-#define IXGBE_SDP0_GPIEN_BY_MAC(_hw) ((_hw)->mac.type >= ixgbe_mac_X540 ? \
- IXGBE_SDP0_GPIEN_X540 : IXGBE_SDP0_GPIEN)
-#define IXGBE_SDP1_GPIEN_BY_MAC(_hw) ((_hw)->mac.type >= ixgbe_mac_X540 ? \
- IXGBE_SDP1_GPIEN_X540 : IXGBE_SDP1_GPIEN)
-#define IXGBE_SDP2_GPIEN_BY_MAC(_hw) ((_hw)->mac.type >= ixgbe_mac_X540 ? \
- IXGBE_SDP2_GPIEN_X540 : IXGBE_SDP2_GPIEN)
+#define IXGBE_SDP0_GPIEN_X550 IXGBE_SDP0_GPIEN_X540
+#define IXGBE_SDP1_GPIEN_X550 IXGBE_SDP1_GPIEN_X540
+#define IXGBE_SDP2_GPIEN_X550 IXGBE_SDP2_GPIEN_X540
+#define IXGBE_SDP0_GPIEN_X550EM_x IXGBE_SDP0_GPIEN_X540
+#define IXGBE_SDP1_GPIEN_X550EM_x IXGBE_SDP1_GPIEN_X540
+#define IXGBE_SDP2_GPIEN_X550EM_x IXGBE_SDP2_GPIEN_X540
+#define IXGBE_SDP0_GPIEN_BY_MAC(_hw) IXGBE_BY_MAC((_hw), SDP0_GPIEN)
+#define IXGBE_SDP1_GPIEN_BY_MAC(_hw) IXGBE_BY_MAC((_hw), SDP1_GPIEN)
+#define IXGBE_SDP2_GPIEN_BY_MAC(_hw) IXGBE_BY_MAC((_hw), SDP2_GPIEN)
+
#define IXGBE_GPIE_MSIX_MODE 0x00000010 /* MSI-X mode */
#define IXGBE_GPIE_OCD 0x00000020 /* Other Clear Disable */
#define IXGBE_GPIE_EIMEN 0x00000040 /* Immediate Interrupt Enable */
@@ -1665,15 +1762,16 @@ enum {
#define IXGBE_EICR_GPI_SDP0_X540 0x02000000 /* Gen Purpose Interrupt on SDP0 */
#define IXGBE_EICR_GPI_SDP1_X540 0x04000000 /* Gen Purpose Interrupt on SDP1 */
#define IXGBE_EICR_GPI_SDP2_X540 0x08000000 /* Gen Purpose Interrupt on SDP2 */
-#define IXGBE_EICR_GPI_SDP0_BY_MAC(_hw) ((_hw)->mac.type >= ixgbe_mac_X540 ? \
- IXGBE_EICR_GPI_SDP0_X540 : \
- IXGBE_EICR_GPI_SDP0)
-#define IXGBE_EICR_GPI_SDP1_BY_MAC(_hw) ((_hw)->mac.type >= ixgbe_mac_X540 ? \
- IXGBE_EICR_GPI_SDP1_X540 : \
- IXGBE_EICR_GPI_SDP1)
-#define IXGBE_EICR_GPI_SDP2_BY_MAC(_hw) ((_hw)->mac.type >= ixgbe_mac_X540 ? \
- IXGBE_EICR_GPI_SDP2_X540 : \
- IXGBE_EICR_GPI_SDP2)
+#define IXGBE_EICR_GPI_SDP0_X550 IXGBE_EICR_GPI_SDP0_X540
+#define IXGBE_EICR_GPI_SDP1_X550 IXGBE_EICR_GPI_SDP1_X540
+#define IXGBE_EICR_GPI_SDP2_X550 IXGBE_EICR_GPI_SDP2_X540
+#define IXGBE_EICR_GPI_SDP0_X550EM_x IXGBE_EICR_GPI_SDP0_X540
+#define IXGBE_EICR_GPI_SDP1_X550EM_x IXGBE_EICR_GPI_SDP1_X540
+#define IXGBE_EICR_GPI_SDP2_X550EM_x IXGBE_EICR_GPI_SDP2_X540
+#define IXGBE_EICR_GPI_SDP0_BY_MAC(_hw) IXGBE_BY_MAC((_hw), EICR_GPI_SDP0)
+#define IXGBE_EICR_GPI_SDP1_BY_MAC(_hw) IXGBE_BY_MAC((_hw), EICR_GPI_SDP1)
+#define IXGBE_EICR_GPI_SDP2_BY_MAC(_hw) IXGBE_BY_MAC((_hw), EICR_GPI_SDP2)
+
#define IXGBE_EICR_PBUR 0x10000000 /* Packet Buffer Handler Error */
#define IXGBE_EICR_DHER 0x20000000 /* Descriptor Handler Error */
#define IXGBE_EICR_TCP_TIMER 0x40000000 /* TCP Timer */
@@ -1901,6 +1999,9 @@ enum {
#define IXGBE_LED_IVRT(_i) IXGBE_LED_OFFSET(IXGBE_LED_IVRT_BASE, _i)
#define IXGBE_LED_BLINK(_i) IXGBE_LED_OFFSET(IXGBE_LED_BLINK_BASE, _i)
#define IXGBE_LED_MODE_MASK(_i) IXGBE_LED_OFFSET(IXGBE_LED_MODE_MASK_BASE, _i)
+#define IXGBE_X557_LED_MANUAL_SET_MASK (1 << 8)
+#define IXGBE_X557_MAX_LED_INDEX 3
+#define IXGBE_X557_LED_PROVISIONING 0xC430
/* LED modes */
#define IXGBE_LED_LINK_UP 0x0
@@ -2784,6 +2885,7 @@ enum ixgbe_fdir_pballoc_type {
#define IXGBE_HI_FLASH_ERASE_TIMEOUT 1000 /* Process Erase command limit */
#define IXGBE_HI_FLASH_UPDATE_TIMEOUT 5000 /* Process Update command limit */
#define IXGBE_HI_FLASH_APPLY_TIMEOUT 0 /* Process Apply command limit */
+#define IXGBE_HI_PHY_MGMT_REQ_TIMEOUT 2000 /* Wait up to 2 seconds */
/* CEM Support */
#define FW_CEM_HDR_LEN 0x4
@@ -2804,6 +2906,7 @@ enum ixgbe_fdir_pballoc_type {
#define FW_MAX_READ_BUFFER_SIZE 1024
#define FW_DISABLE_RXEN_CMD 0xDE
#define FW_DISABLE_RXEN_LEN 0x1
+#define FW_PHY_MGMT_REQ_CMD 0x20
/* Host Interface Command Structures */
struct ixgbe_hic_hdr {
@@ -3200,6 +3303,36 @@ union ixgbe_atr_hash_dword {
};
+#define IXGBE_MVALS_INIT(m) \
+ IXGBE_CAT(EEC, m), \
+ IXGBE_CAT(FLA, m), \
+ IXGBE_CAT(GRC, m), \
+ IXGBE_CAT(SRAMREL, m), \
+ IXGBE_CAT(FACTPS, m), \
+ IXGBE_CAT(SWSM, m), \
+ IXGBE_CAT(FWSM, m), \
+ IXGBE_CAT(SDP0_GPIEN, m), \
+ IXGBE_CAT(SDP1_GPIEN, m), \
+ IXGBE_CAT(SDP2_GPIEN, m), \
+ IXGBE_CAT(EICR_GPI_SDP0, m), \
+ IXGBE_CAT(EICR_GPI_SDP1, m), \
+ IXGBE_CAT(EICR_GPI_SDP2, m), \
+ IXGBE_CAT(CIAA, m), \
+ IXGBE_CAT(CIAD, m), \
+ IXGBE_CAT(I2C_CLK_IN, m), \
+ IXGBE_CAT(I2C_CLK_OUT, m), \
+ IXGBE_CAT(I2C_DATA_IN, m), \
+ IXGBE_CAT(I2C_DATA_OUT, m), \
+ IXGBE_CAT(I2C_DATA_OE_N_EN, m), \
+ IXGBE_CAT(I2C_BB_EN, m), \
+ IXGBE_CAT(I2C_CLK_OE_N_EN, m), \
+ IXGBE_CAT(I2CCTL, m)
+
+enum ixgbe_mvals {
+ IXGBE_MVALS_INIT(_IDX),
+ IXGBE_MVALS_IDX_LIMIT
+};
+
/*
* Unavailable: The FCoE Boot Option ROM is not present in the flash.
* Disabled: Present; boot order is not set for any targets on the port.
@@ -3225,17 +3358,10 @@ enum ixgbe_mac_type {
ixgbe_mac_82599_vf,
ixgbe_mac_X540,
ixgbe_mac_X540_vf,
- /*
- * X550EM MAC type decoder:
- * ixgbe_mac_X550EM_x: "x" = Xeon
- * ixgbe_mac_X550EM_a: "a" = Atom
- */
ixgbe_mac_X550,
ixgbe_mac_X550EM_x,
- ixgbe_mac_X550EM_a,
ixgbe_mac_X550_vf,
ixgbe_mac_X550EM_x_vf,
- ixgbe_mac_X550EM_a_vf,
ixgbe_num_macs
};
@@ -3294,6 +3420,8 @@ enum ixgbe_sfp_type {
ixgbe_sfp_type_1g_cu_core1 = 10,
ixgbe_sfp_type_1g_sx_core0 = 11,
ixgbe_sfp_type_1g_sx_core1 = 12,
+ ixgbe_sfp_type_1g_lx_core0 = 13,
+ ixgbe_sfp_type_1g_lx_core1 = 14,
ixgbe_sfp_type_not_present = 0xFFFE,
ixgbe_sfp_type_unknown = 0xFFFF
};
@@ -3611,6 +3739,15 @@ struct ixgbe_phy_operations {
s32 (*check_overtemp)(struct ixgbe_hw *);
s32 (*set_phy_power)(struct ixgbe_hw *, bool on);
s32 (*enter_lplu)(struct ixgbe_hw *);
+ s32 (*handle_lasi)(struct ixgbe_hw *hw);
+ s32 (*read_i2c_combined_unlocked)(struct ixgbe_hw *, u8 addr, u16 reg,
+ u16 *value);
+ s32 (*write_i2c_combined_unlocked)(struct ixgbe_hw *, u8 addr, u16 reg,
+ u16 value);
+ s32 (*read_i2c_byte_unlocked)(struct ixgbe_hw *, u8 offset, u8 addr,
+ u8 *value);
+ s32 (*write_i2c_byte_unlocked)(struct ixgbe_hw *, u8 offset, u8 addr,
+ u8 value);
};
struct ixgbe_eeprom_info {
@@ -3674,6 +3811,7 @@ struct ixgbe_phy_info {
bool multispeed_fiber;
bool reset_if_overtemp;
bool qsfp_shared_i2c_bus;
+ u32 nw_mng_if_sel;
};
#include "ixgbe_mbx.h"
@@ -3717,6 +3855,7 @@ struct ixgbe_hw {
struct ixgbe_eeprom_info eeprom;
struct ixgbe_bus_info bus;
struct ixgbe_mbx_info mbx;
+ const u32 *mvals;
u16 device_id;
u16 vendor_id;
u16 subsystem_device_id;
@@ -3775,6 +3914,10 @@ struct ixgbe_hw {
#define IXGBE_NOT_IMPLEMENTED 0x7FFFFFFF
+#define IXGBE_FUSES0_GROUP(_i) (0x11158 + ((_i) * 4))
+#define IXGBE_FUSES0_300MHZ (1 << 5)
+#define IXGBE_FUSES0_REV1 (1 << 6)
+
#define IXGBE_KRM_PORT_CAR_GEN_CTRL(P) ((P == 0) ? (0x4010) : (0x8010))
#define IXGBE_KRM_LINK_CTRL_1(P) ((P == 0) ? (0x420C) : (0x820C))
#define IXGBE_KRM_AN_CNTL_1(P) ((P == 0) ? (0x422C) : (0x822C))
@@ -3842,8 +3985,10 @@ struct ixgbe_hw {
#define IXGBE_SB_IOSF_CTRL_BUSY_SHIFT 31
#define IXGBE_SB_IOSF_CTRL_BUSY (1 << IXGBE_SB_IOSF_CTRL_BUSY_SHIFT)
#define IXGBE_SB_IOSF_TARGET_KR_PHY 0
-#define IXGBE_SB_IOSF_TARGET_KX4_UNIPHY 1
-#define IXGBE_SB_IOSF_TARGET_KX4_PCS0 2
-#define IXGBE_SB_IOSF_TARGET_KX4_PCS1 3
+#define IXGBE_SB_IOSF_TARGET_KX4_PHY 1
+#define IXGBE_SB_IOSF_TARGET_KX4_PCS 2
+
+#define IXGBE_NW_MNG_IF_SEL 0x00011178
+#define IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE (1 << 24)
#endif /* _IXGBE_TYPE_H_ */
diff --git a/sys/dev/ixgbe/ixgbe_vf.c b/sys/dev/ixgbe/ixgbe_vf.c
index 964514c..c010cf4 100644
--- a/sys/dev/ixgbe/ixgbe_vf.c
+++ b/sys/dev/ixgbe/ixgbe_vf.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -669,4 +669,3 @@ int ixgbevf_get_queues(struct ixgbe_hw *hw, unsigned int *num_tcs,
UNREFERENCED_3PARAMETER(hw, num_tcs, default_tc);
return IXGBE_SUCCESS;
}
-
diff --git a/sys/dev/ixgbe/ixgbe_vf.h b/sys/dev/ixgbe/ixgbe_vf.h
index 8f4d46e..edc8013 100644
--- a/sys/dev/ixgbe/ixgbe_vf.h
+++ b/sys/dev/ixgbe/ixgbe_vf.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/sys/dev/ixgbe/ixgbe_x540.c b/sys/dev/ixgbe/ixgbe_x540.c
index 93c6ca4..ddf0674 100644
--- a/sys/dev/ixgbe/ixgbe_x540.c
+++ b/sys/dev/ixgbe/ixgbe_x540.c
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -932,14 +932,14 @@ static void ixgbe_release_swfw_sync_semaphore(struct ixgbe_hw *hw)
/* Release both semaphores by writing 0 to the bits REGSMP and SMBI */
- swsm = IXGBE_READ_REG(hw, IXGBE_SWSM);
- swsm &= ~IXGBE_SWSM_SMBI;
- IXGBE_WRITE_REG(hw, IXGBE_SWSM, swsm);
-
swsm = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC);
swsm &= ~IXGBE_SWFW_REGSMP;
IXGBE_WRITE_REG(hw, IXGBE_SWFW_SYNC, swsm);
+ swsm = IXGBE_READ_REG(hw, IXGBE_SWSM);
+ swsm &= ~IXGBE_SWSM_SMBI;
+ IXGBE_WRITE_REG(hw, IXGBE_SWSM, swsm);
+
IXGBE_WRITE_FLUSH(hw);
}
@@ -1011,5 +1011,3 @@ s32 ixgbe_blink_led_stop_X540(struct ixgbe_hw *hw, u32 index)
return IXGBE_SUCCESS;
}
-
-
diff --git a/sys/dev/ixgbe/ixgbe_x540.h b/sys/dev/ixgbe/ixgbe_x540.h
index 12da827..efd0d41 100644
--- a/sys/dev/ixgbe/ixgbe_x540.h
+++ b/sys/dev/ixgbe/ixgbe_x540.h
@@ -1,6 +1,6 @@
/******************************************************************************
- Copyright (c) 2001-2014, Intel Corporation
+ Copyright (c) 2001-2015, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/sys/dev/ixgbe/ixgbe_x550.c b/sys/dev/ixgbe/ixgbe_x550.c
new file mode 100644
index 0000000..65daa17
--- /dev/null
+++ b/sys/dev/ixgbe/ixgbe_x550.c
@@ -0,0 +1,3191 @@
+/******************************************************************************
+
+ Copyright (c) 2001-2015, Intel Corporation
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce 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 Intel Corporation nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+******************************************************************************/
+/*$FreeBSD$*/
+
+#include "ixgbe_x550.h"
+#include "ixgbe_x540.h"
+#include "ixgbe_type.h"
+#include "ixgbe_api.h"
+#include "ixgbe_common.h"
+#include "ixgbe_phy.h"
+
+static s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed);
+
+/**
+ * ixgbe_init_ops_X550 - Inits func ptrs and MAC type
+ * @hw: pointer to hardware structure
+ *
+ * Initialize the function pointers and assign the MAC type for X550.
+ * Does not touch the hardware.
+ **/
+s32 ixgbe_init_ops_X550(struct ixgbe_hw *hw)
+{
+ struct ixgbe_mac_info *mac = &hw->mac;
+ struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
+ s32 ret_val;
+
+ DEBUGFUNC("ixgbe_init_ops_X550");
+
+ ret_val = ixgbe_init_ops_X540(hw);
+ mac->ops.dmac_config = ixgbe_dmac_config_X550;
+ mac->ops.dmac_config_tcs = ixgbe_dmac_config_tcs_X550;
+ mac->ops.dmac_update_tcs = ixgbe_dmac_update_tcs_X550;
+ mac->ops.setup_eee = ixgbe_setup_eee_X550;
+ mac->ops.set_source_address_pruning =
+ ixgbe_set_source_address_pruning_X550;
+ mac->ops.set_ethertype_anti_spoofing =
+ ixgbe_set_ethertype_anti_spoofing_X550;
+
+ mac->ops.get_rtrup2tc = ixgbe_dcb_get_rtrup2tc_generic;
+ eeprom->ops.init_params = ixgbe_init_eeprom_params_X550;
+ eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
+ eeprom->ops.read = ixgbe_read_ee_hostif_X550;
+ eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
+ eeprom->ops.write = ixgbe_write_ee_hostif_X550;
+ eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
+ eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
+ eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
+
+ mac->ops.disable_mdd = ixgbe_disable_mdd_X550;
+ mac->ops.enable_mdd = ixgbe_enable_mdd_X550;
+ mac->ops.mdd_event = ixgbe_mdd_event_X550;
+ mac->ops.restore_mdd_vf = ixgbe_restore_mdd_vf_X550;
+ mac->ops.disable_rx = ixgbe_disable_rx_x550;
+ if (hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T) {
+ hw->mac.ops.led_on = ixgbe_led_on_t_X550em;
+ hw->mac.ops.led_off = ixgbe_led_off_t_X550em;
+ }
+ return ret_val;
+}
+
+/**
+ * ixgbe_read_cs4227 - Read CS4227 register
+ * @hw: pointer to hardware structure
+ * @reg: register number to write
+ * @value: pointer to receive value read
+ *
+ * Returns status code
+ **/
+static s32 ixgbe_read_cs4227(struct ixgbe_hw *hw, u16 reg, u16 *value)
+{
+ return ixgbe_read_i2c_combined_unlocked(hw, IXGBE_CS4227, reg, value);
+}
+
+/**
+ * ixgbe_write_cs4227 - Write CS4227 register
+ * @hw: pointer to hardware structure
+ * @reg: register number to write
+ * @value: value to write to register
+ *
+ * Returns status code
+ **/
+static s32 ixgbe_write_cs4227(struct ixgbe_hw *hw, u16 reg, u16 value)
+{
+ return ixgbe_write_i2c_combined_unlocked(hw, IXGBE_CS4227, reg, value);
+}
+
+/**
+ * ixgbe_get_cs4227_status - Return CS4227 status
+ * @hw: pointer to hardware structure
+ *
+ * Returns error if CS4227 not successfully initialized
+ **/
+static s32 ixgbe_get_cs4227_status(struct ixgbe_hw *hw)
+{
+ s32 status;
+ u16 value = 0;
+ u16 reg_slice, reg_val;
+ u8 retry;
+
+ for (retry = 0; retry < IXGBE_CS4227_RETRIES; ++retry) {
+ status = ixgbe_read_cs4227(hw, IXGBE_CS4227_GLOBAL_ID_LSB,
+ &value);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ if (value == IXGBE_CS4227_GLOBAL_ID_VALUE)
+ break;
+ msec_delay(IXGBE_CS4227_CHECK_DELAY);
+ }
+ if (value != IXGBE_CS4227_GLOBAL_ID_VALUE)
+ return IXGBE_ERR_PHY;
+
+ status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* If this is the first time after power-on, check the ucode.
+ * Otherwise, this will disrupt link on all ports. Because we
+ * can only do this the first time, we must check all ports,
+ * not just our own.
+ */
+ if (value != IXGBE_CS4227_SCRATCH_VALUE) {
+ reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB;
+ reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
+ status = ixgbe_write_cs4227(hw, reg_slice,
+ reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB;
+ reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
+ status = ixgbe_write_cs4227(hw, reg_slice,
+ reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (1 << 12);
+ reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
+ status = ixgbe_write_cs4227(hw, reg_slice,
+ reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (1 << 12);
+ reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
+ status = ixgbe_write_cs4227(hw, reg_slice,
+ reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ msec_delay(10);
+ }
+
+ /* Verify that the ucode is operational on all ports. */
+ reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB;
+ reg_val = 0xFFFF;
+ status = ixgbe_read_cs4227(hw, reg_slice, &reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ if (reg_val != 0)
+ return IXGBE_ERR_PHY;
+
+ reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB;
+ reg_val = 0xFFFF;
+ status = ixgbe_read_cs4227(hw, reg_slice, &reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ if (reg_val != 0)
+ return IXGBE_ERR_PHY;
+
+ reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (1 << 12);
+ reg_val = 0xFFFF;
+ status = ixgbe_read_cs4227(hw, reg_slice, &reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ if (reg_val != 0)
+ return IXGBE_ERR_PHY;
+
+ reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (1 << 12);
+ reg_val = 0xFFFF;
+ status = ixgbe_read_cs4227(hw, reg_slice, &reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ if (reg_val != 0)
+ return IXGBE_ERR_PHY;
+
+ /* Set scratch for next time. */
+ status = ixgbe_write_cs4227(hw, IXGBE_CS4227_SCRATCH,
+ IXGBE_CS4227_SCRATCH_VALUE);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ status = ixgbe_read_cs4227(hw, IXGBE_CS4227_SCRATCH, &value);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ if (value != IXGBE_CS4227_SCRATCH_VALUE)
+ return IXGBE_ERR_PHY;
+
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_read_pe - Read register from port expander
+ * @hw: pointer to hardware structure
+ * @reg: register number to read
+ * @value: pointer to receive read value
+ *
+ * Returns status code
+ **/
+static s32 ixgbe_read_pe(struct ixgbe_hw *hw, u8 reg, u8 *value)
+{
+ s32 status;
+
+ status = ixgbe_read_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
+ if (status != IXGBE_SUCCESS)
+ ERROR_REPORT2(IXGBE_ERROR_CAUTION,
+ "port expander access failed with %d\n", status);
+ return status;
+}
+
+/**
+ * ixgbe_write_pe - Write register to port expander
+ * @hw: pointer to hardware structure
+ * @reg: register number to write
+ * @value: value to write
+ *
+ * Returns status code
+ **/
+static s32 ixgbe_write_pe(struct ixgbe_hw *hw, u8 reg, u8 value)
+{
+ s32 status;
+
+ status = ixgbe_write_i2c_byte_unlocked(hw, reg, IXGBE_PE, value);
+ if (status != IXGBE_SUCCESS)
+ ERROR_REPORT2(IXGBE_ERROR_CAUTION,
+ "port expander access failed with %d\n", status);
+ return status;
+}
+
+/**
+ * ixgbe_reset_cs4227 - Reset CS4227 using port expander
+ * @hw: pointer to hardware structure
+ *
+ * Returns error code
+ **/
+static s32 ixgbe_reset_cs4227(struct ixgbe_hw *hw)
+{
+ s32 status;
+ u8 reg;
+
+ status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, &reg);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ reg |= IXGBE_PE_BIT1;
+ status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ status = ixgbe_read_pe(hw, IXGBE_PE_CONFIG, &reg);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ reg &= ~IXGBE_PE_BIT1;
+ status = ixgbe_write_pe(hw, IXGBE_PE_CONFIG, reg);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, &reg);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ reg &= ~IXGBE_PE_BIT1;
+ status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ usec_delay(IXGBE_CS4227_RESET_HOLD);
+
+ status = ixgbe_read_pe(hw, IXGBE_PE_OUTPUT, &reg);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ reg |= IXGBE_PE_BIT1;
+ status = ixgbe_write_pe(hw, IXGBE_PE_OUTPUT, reg);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ msec_delay(IXGBE_CS4227_RESET_DELAY);
+
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_check_cs4227 - Check CS4227 and reset as needed
+ * @hw: pointer to hardware structure
+ **/
+static void ixgbe_check_cs4227(struct ixgbe_hw *hw)
+{
+ u32 swfw_mask = hw->phy.phy_semaphore_mask;
+ s32 status;
+ u8 retry;
+
+ for (retry = 0; retry < IXGBE_CS4227_RETRIES; retry++) {
+ status = hw->mac.ops.acquire_swfw_sync(hw, swfw_mask);
+ if (status != IXGBE_SUCCESS) {
+ ERROR_REPORT2(IXGBE_ERROR_CAUTION,
+ "semaphore failed with %d\n", status);
+ return;
+ }
+ status = ixgbe_get_cs4227_status(hw);
+ if (status == IXGBE_SUCCESS) {
+ hw->mac.ops.release_swfw_sync(hw, swfw_mask);
+ msec_delay(hw->eeprom.semaphore_delay);
+ return;
+ }
+ ixgbe_reset_cs4227(hw);
+ hw->mac.ops.release_swfw_sync(hw, swfw_mask);
+ msec_delay(hw->eeprom.semaphore_delay);
+ }
+ ERROR_REPORT2(IXGBE_ERROR_CAUTION,
+ "Unable to initialize CS4227, err=%d\n", status);
+}
+
+/**
+ * ixgbe_setup_mux_ctl - Setup ESDP register for I2C mux control
+ * @hw: pointer to hardware structure
+ **/
+static void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
+{
+ u32 esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
+
+ if (hw->bus.lan_id) {
+ esdp &= ~(IXGBE_ESDP_SDP1_NATIVE | IXGBE_ESDP_SDP1);
+ esdp |= IXGBE_ESDP_SDP1_DIR;
+ }
+ esdp &= ~(IXGBE_ESDP_SDP0_NATIVE | IXGBE_ESDP_SDP0_DIR);
+ IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
+ IXGBE_WRITE_FLUSH(hw);
+}
+
+/**
+ * ixgbe_identify_phy_x550em - Get PHY type based on device id
+ * @hw: pointer to hardware structure
+ *
+ * Returns error code
+ */
+static s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
+{
+ switch (hw->device_id) {
+ case IXGBE_DEV_ID_X550EM_X_SFP:
+ /* set up for CS4227 usage */
+ hw->phy.phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
+ ixgbe_setup_mux_ctl(hw);
+ ixgbe_check_cs4227(hw);
+
+ return ixgbe_identify_module_generic(hw);
+ break;
+ case IXGBE_DEV_ID_X550EM_X_KX4:
+ hw->phy.type = ixgbe_phy_x550em_kx4;
+ break;
+ case IXGBE_DEV_ID_X550EM_X_KR:
+ hw->phy.type = ixgbe_phy_x550em_kr;
+ break;
+ case IXGBE_DEV_ID_X550EM_X_1G_T:
+ case IXGBE_DEV_ID_X550EM_X_10G_T:
+ return ixgbe_identify_phy_generic(hw);
+ default:
+ break;
+ }
+ return IXGBE_SUCCESS;
+}
+
+static s32 ixgbe_read_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
+ u32 device_type, u16 *phy_data)
+{
+ UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, *phy_data);
+ return IXGBE_NOT_IMPLEMENTED;
+}
+
+static s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, u32 reg_addr,
+ u32 device_type, u16 phy_data)
+{
+ UNREFERENCED_4PARAMETER(*hw, reg_addr, device_type, phy_data);
+ return IXGBE_NOT_IMPLEMENTED;
+}
+
+/**
+* ixgbe_init_ops_X550EM - Inits func ptrs and MAC type
+* @hw: pointer to hardware structure
+*
+* Initialize the function pointers and for MAC type X550EM.
+* Does not touch the hardware.
+**/
+s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
+{
+ struct ixgbe_mac_info *mac = &hw->mac;
+ struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
+ struct ixgbe_phy_info *phy = &hw->phy;
+ s32 ret_val;
+
+ DEBUGFUNC("ixgbe_init_ops_X550EM");
+
+ /* Similar to X550 so start there. */
+ ret_val = ixgbe_init_ops_X550(hw);
+
+ /* Since this function eventually calls
+ * ixgbe_init_ops_540 by design, we are setting
+ * the pointers to NULL explicitly here to overwrite
+ * the values being set in the x540 function.
+ */
+
+ /* FCOE not supported in x550EM */
+ mac->ops.get_san_mac_addr = NULL;
+ mac->ops.set_san_mac_addr = NULL;
+ mac->ops.get_wwn_prefix = NULL;
+ mac->ops.get_fcoe_boot_status = NULL;
+
+ /* IPsec not supported in x550EM */
+ mac->ops.disable_sec_rx_path = NULL;
+ mac->ops.enable_sec_rx_path = NULL;
+
+ /* AUTOC register is not present in x550EM. */
+ mac->ops.prot_autoc_read = NULL;
+ mac->ops.prot_autoc_write = NULL;
+
+ /* X550EM bus type is internal*/
+ hw->bus.type = ixgbe_bus_type_internal;
+ mac->ops.get_bus_info = ixgbe_get_bus_info_X550em;
+
+ mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
+ mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
+ mac->ops.get_media_type = ixgbe_get_media_type_X550em;
+ mac->ops.setup_sfp = ixgbe_setup_sfp_modules_X550em;
+ mac->ops.get_link_capabilities = ixgbe_get_link_capabilities_X550em;
+ mac->ops.reset_hw = ixgbe_reset_hw_X550em;
+ mac->ops.get_supported_physical_layer =
+ ixgbe_get_supported_physical_layer_X550em;
+
+ if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper)
+ mac->ops.setup_fc = ixgbe_setup_fc_generic;
+ else
+ mac->ops.setup_fc = ixgbe_setup_fc_X550em;
+
+ mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550em;
+ mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550em;
+
+ if (hw->device_id != IXGBE_DEV_ID_X550EM_X_KR)
+ mac->ops.setup_eee = NULL;
+
+ /* PHY */
+ phy->ops.init = ixgbe_init_phy_ops_X550em;
+ phy->ops.identify = ixgbe_identify_phy_x550em;
+ if (mac->ops.get_media_type(hw) != ixgbe_media_type_copper)
+ phy->ops.set_phy_power = NULL;
+
+
+ /* EEPROM */
+ eeprom->ops.init_params = ixgbe_init_eeprom_params_X540;
+ eeprom->ops.read = ixgbe_read_ee_hostif_X550;
+ eeprom->ops.read_buffer = ixgbe_read_ee_hostif_buffer_X550;
+ eeprom->ops.write = ixgbe_write_ee_hostif_X550;
+ eeprom->ops.write_buffer = ixgbe_write_ee_hostif_buffer_X550;
+ eeprom->ops.update_checksum = ixgbe_update_eeprom_checksum_X550;
+ eeprom->ops.validate_checksum = ixgbe_validate_eeprom_checksum_X550;
+ eeprom->ops.calc_checksum = ixgbe_calc_eeprom_checksum_X550;
+
+ return ret_val;
+}
+
+/**
+ * ixgbe_dmac_config_X550
+ * @hw: pointer to hardware structure
+ *
+ * Configure DMA coalescing. If enabling dmac, dmac is activated.
+ * When disabling dmac, dmac enable dmac bit is cleared.
+ **/
+s32 ixgbe_dmac_config_X550(struct ixgbe_hw *hw)
+{
+ u32 reg, high_pri_tc;
+
+ DEBUGFUNC("ixgbe_dmac_config_X550");
+
+ /* Disable DMA coalescing before configuring */
+ reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
+ reg &= ~IXGBE_DMACR_DMAC_EN;
+ IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
+
+ /* Disable DMA Coalescing if the watchdog timer is 0 */
+ if (!hw->mac.dmac_config.watchdog_timer)
+ goto out;
+
+ ixgbe_dmac_config_tcs_X550(hw);
+
+ /* Configure DMA Coalescing Control Register */
+ reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
+
+ /* Set the watchdog timer in units of 40.96 usec */
+ reg &= ~IXGBE_DMACR_DMACWT_MASK;
+ reg |= (hw->mac.dmac_config.watchdog_timer * 100) / 4096;
+
+ reg &= ~IXGBE_DMACR_HIGH_PRI_TC_MASK;
+ /* If fcoe is enabled, set high priority traffic class */
+ if (hw->mac.dmac_config.fcoe_en) {
+ high_pri_tc = 1 << hw->mac.dmac_config.fcoe_tc;
+ reg |= ((high_pri_tc << IXGBE_DMACR_HIGH_PRI_TC_SHIFT) &
+ IXGBE_DMACR_HIGH_PRI_TC_MASK);
+ }
+ reg |= IXGBE_DMACR_EN_MNG_IND;
+
+ /* Enable DMA coalescing after configuration */
+ reg |= IXGBE_DMACR_DMAC_EN;
+ IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
+
+out:
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_dmac_config_tcs_X550
+ * @hw: pointer to hardware structure
+ *
+ * Configure DMA coalescing threshold per TC. The dmac enable bit must
+ * be cleared before configuring.
+ **/
+s32 ixgbe_dmac_config_tcs_X550(struct ixgbe_hw *hw)
+{
+ u32 tc, reg, pb_headroom, rx_pb_size, maxframe_size_kb;
+
+ DEBUGFUNC("ixgbe_dmac_config_tcs_X550");
+
+ /* Configure DMA coalescing enabled */
+ switch (hw->mac.dmac_config.link_speed) {
+ case IXGBE_LINK_SPEED_100_FULL:
+ pb_headroom = IXGBE_DMACRXT_100M;
+ break;
+ case IXGBE_LINK_SPEED_1GB_FULL:
+ pb_headroom = IXGBE_DMACRXT_1G;
+ break;
+ default:
+ pb_headroom = IXGBE_DMACRXT_10G;
+ break;
+ }
+
+ maxframe_size_kb = ((IXGBE_READ_REG(hw, IXGBE_MAXFRS) >>
+ IXGBE_MHADD_MFS_SHIFT) / 1024);
+
+ /* Set the per Rx packet buffer receive threshold */
+ for (tc = 0; tc < IXGBE_DCB_MAX_TRAFFIC_CLASS; tc++) {
+ reg = IXGBE_READ_REG(hw, IXGBE_DMCTH(tc));
+ reg &= ~IXGBE_DMCTH_DMACRXT_MASK;
+
+ if (tc < hw->mac.dmac_config.num_tcs) {
+ /* Get Rx PB size */
+ rx_pb_size = IXGBE_READ_REG(hw, IXGBE_RXPBSIZE(tc));
+ rx_pb_size = (rx_pb_size & IXGBE_RXPBSIZE_MASK) >>
+ IXGBE_RXPBSIZE_SHIFT;
+
+ /* Calculate receive buffer threshold in kilobytes */
+ if (rx_pb_size > pb_headroom)
+ rx_pb_size = rx_pb_size - pb_headroom;
+ else
+ rx_pb_size = 0;
+
+ /* Minimum of MFS shall be set for DMCTH */
+ reg |= (rx_pb_size > maxframe_size_kb) ?
+ rx_pb_size : maxframe_size_kb;
+ }
+ IXGBE_WRITE_REG(hw, IXGBE_DMCTH(tc), reg);
+ }
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_dmac_update_tcs_X550
+ * @hw: pointer to hardware structure
+ *
+ * Disables dmac, updates per TC settings, and then enables dmac.
+ **/
+s32 ixgbe_dmac_update_tcs_X550(struct ixgbe_hw *hw)
+{
+ u32 reg;
+
+ DEBUGFUNC("ixgbe_dmac_update_tcs_X550");
+
+ /* Disable DMA coalescing before configuring */
+ reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
+ reg &= ~IXGBE_DMACR_DMAC_EN;
+ IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
+
+ ixgbe_dmac_config_tcs_X550(hw);
+
+ /* Enable DMA coalescing after configuration */
+ reg = IXGBE_READ_REG(hw, IXGBE_DMACR);
+ reg |= IXGBE_DMACR_DMAC_EN;
+ IXGBE_WRITE_REG(hw, IXGBE_DMACR, reg);
+
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_init_eeprom_params_X550 - Initialize EEPROM params
+ * @hw: pointer to hardware structure
+ *
+ * Initializes the EEPROM parameters ixgbe_eeprom_info within the
+ * ixgbe_hw struct in order to set up EEPROM access.
+ **/
+s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
+{
+ struct ixgbe_eeprom_info *eeprom = &hw->eeprom;
+ u32 eec;
+ u16 eeprom_size;
+
+ DEBUGFUNC("ixgbe_init_eeprom_params_X550");
+
+ if (eeprom->type == ixgbe_eeprom_uninitialized) {
+ eeprom->semaphore_delay = 10;
+ eeprom->type = ixgbe_flash;
+
+ eec = IXGBE_READ_REG(hw, IXGBE_EEC);
+ eeprom_size = (u16)((eec & IXGBE_EEC_SIZE) >>
+ IXGBE_EEC_SIZE_SHIFT);
+ eeprom->word_size = 1 << (eeprom_size +
+ IXGBE_EEPROM_WORD_SIZE_SHIFT);
+
+ DEBUGOUT2("Eeprom params: type = %d, size = %d\n",
+ eeprom->type, eeprom->word_size);
+ }
+
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_setup_eee_X550 - Enable/disable EEE support
+ * @hw: pointer to the HW structure
+ * @enable_eee: boolean flag to enable EEE
+ *
+ * Enable/disable EEE based on enable_eee flag.
+ * Auto-negotiation must be started after BASE-T EEE bits in PHY register 7.3C
+ * are modified.
+ *
+ **/
+s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool enable_eee)
+{
+ u32 eeer;
+ u16 autoneg_eee_reg;
+ u32 link_reg;
+ s32 status;
+ u32 fuse;
+
+ DEBUGFUNC("ixgbe_setup_eee_X550");
+
+ eeer = IXGBE_READ_REG(hw, IXGBE_EEER);
+ /* Enable or disable EEE per flag */
+ if (enable_eee) {
+ eeer |= (IXGBE_EEER_TX_LPI_EN | IXGBE_EEER_RX_LPI_EN);
+
+ if (hw->device_id == IXGBE_DEV_ID_X550T) {
+ /* Advertise EEE capability */
+ hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_eee_reg);
+
+ autoneg_eee_reg |= (IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
+ IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
+ IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
+
+ hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_eee_reg);
+ } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+ /* Not supported on first revision. */
+ fuse = IXGBE_READ_REG(hw, IXGBE_FUSES0_GROUP(0));
+ if (!(fuse & IXGBE_FUSES0_REV1))
+ return IXGBE_SUCCESS;
+
+ status = ixgbe_read_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, &link_reg);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
+ IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX;
+
+ /* Don't advertise FEC capability when EEE enabled. */
+ link_reg &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
+
+ status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ }
+ } else {
+ eeer &= ~(IXGBE_EEER_TX_LPI_EN | IXGBE_EEER_RX_LPI_EN);
+
+ if (hw->device_id == IXGBE_DEV_ID_X550T) {
+ /* Disable advertised EEE capability */
+ hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &autoneg_eee_reg);
+
+ autoneg_eee_reg &= ~(IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
+ IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
+ IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
+
+ hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE, autoneg_eee_reg);
+ } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+ status = ixgbe_read_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, &link_reg);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ link_reg &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
+ IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX);
+
+ /* Advertise FEC capability when EEE is disabled. */
+ link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
+
+ status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ }
+ }
+ IXGBE_WRITE_REG(hw, IXGBE_EEER, eeer);
+
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_set_source_address_pruning_X550 - Enable/Disbale source address pruning
+ * @hw: pointer to hardware structure
+ * @enable: enable or disable source address pruning
+ * @pool: Rx pool to set source address pruning for
+ **/
+void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw, bool enable,
+ unsigned int pool)
+{
+ u64 pfflp;
+
+ /* max rx pool is 63 */
+ if (pool > 63)
+ return;
+
+ pfflp = (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPL);
+ pfflp |= (u64)IXGBE_READ_REG(hw, IXGBE_PFFLPH) << 32;
+
+ if (enable)
+ pfflp |= (1ULL << pool);
+ else
+ pfflp &= ~(1ULL << pool);
+
+ IXGBE_WRITE_REG(hw, IXGBE_PFFLPL, (u32)pfflp);
+ IXGBE_WRITE_REG(hw, IXGBE_PFFLPH, (u32)(pfflp >> 32));
+}
+
+/**
+ * ixgbe_set_ethertype_anti_spoofing_X550 - Enable/Disable Ethertype anti-spoofing
+ * @hw: pointer to hardware structure
+ * @enable: enable or disable switch for Ethertype anti-spoofing
+ * @vf: Virtual Function pool - VF Pool to set for Ethertype anti-spoofing
+ *
+ **/
+void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
+ bool enable, int vf)
+{
+ int vf_target_reg = vf >> 3;
+ int vf_target_shift = vf % 8 + IXGBE_SPOOF_ETHERTYPEAS_SHIFT;
+ u32 pfvfspoof;
+
+ DEBUGFUNC("ixgbe_set_ethertype_anti_spoofing_X550");
+
+ pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
+ if (enable)
+ pfvfspoof |= (1 << vf_target_shift);
+ else
+ pfvfspoof &= ~(1 << vf_target_shift);
+
+ IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
+}
+
+/**
+ * ixgbe_iosf_wait - Wait for IOSF command completion
+ * @hw: pointer to hardware structure
+ * @ctrl: pointer to location to receive final IOSF control value
+ *
+ * Returns failing status on timeout
+ *
+ * Note: ctrl can be NULL if the IOSF control register value is not needed
+ **/
+static s32 ixgbe_iosf_wait(struct ixgbe_hw *hw, u32 *ctrl)
+{
+ u32 i, command;
+
+ /* Check every 10 usec to see if the address cycle completed.
+ * The SB IOSF BUSY bit will clear when the operation is
+ * complete
+ */
+ for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
+ command = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL);
+ if ((command & IXGBE_SB_IOSF_CTRL_BUSY) == 0)
+ break;
+ usec_delay(10);
+ }
+ if (ctrl)
+ *ctrl = command;
+ if (i == IXGBE_MDIO_COMMAND_TIMEOUT) {
+ ERROR_REPORT1(IXGBE_ERROR_POLLING, "Wait timed out\n");
+ return IXGBE_ERR_PHY;
+ }
+
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_write_iosf_sb_reg_x550 - Writes a value to specified register of the IOSF
+ * device
+ * @hw: pointer to hardware structure
+ * @reg_addr: 32 bit PHY register to write
+ * @device_type: 3 bit device type
+ * @data: Data to write to the register
+ **/
+s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
+ u32 device_type, u32 data)
+{
+ u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
+ u32 command, error;
+ s32 ret;
+
+ ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
+ if (ret != IXGBE_SUCCESS)
+ return ret;
+
+ ret = ixgbe_iosf_wait(hw, NULL);
+ if (ret != IXGBE_SUCCESS)
+ goto out;
+
+ command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
+ (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
+
+ /* Write IOSF control register */
+ IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
+
+ /* Write IOSF data register */
+ IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA, data);
+
+ ret = ixgbe_iosf_wait(hw, &command);
+
+ if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
+ error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
+ IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
+ ERROR_REPORT2(IXGBE_ERROR_POLLING,
+ "Failed to write, error %x\n", error);
+ ret = IXGBE_ERR_PHY;
+ }
+
+out:
+ ixgbe_release_swfw_semaphore(hw, gssr);
+ return ret;
+}
+
+/**
+ * ixgbe_read_iosf_sb_reg_x550 - Writes a value to specified register of the IOSF
+ * device
+ * @hw: pointer to hardware structure
+ * @reg_addr: 32 bit PHY register to write
+ * @device_type: 3 bit device type
+ * @phy_data: Pointer to read data from the register
+ **/
+s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
+ u32 device_type, u32 *data)
+{
+ u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM;
+ u32 command, error;
+ s32 ret;
+
+ ret = ixgbe_acquire_swfw_semaphore(hw, gssr);
+ if (ret != IXGBE_SUCCESS)
+ return ret;
+
+ ret = ixgbe_iosf_wait(hw, NULL);
+ if (ret != IXGBE_SUCCESS)
+ goto out;
+
+ command = ((reg_addr << IXGBE_SB_IOSF_CTRL_ADDR_SHIFT) |
+ (device_type << IXGBE_SB_IOSF_CTRL_TARGET_SELECT_SHIFT));
+
+ /* Write IOSF control register */
+ IXGBE_WRITE_REG(hw, IXGBE_SB_IOSF_INDIRECT_CTRL, command);
+
+ ret = ixgbe_iosf_wait(hw, &command);
+
+ if ((command & IXGBE_SB_IOSF_CTRL_RESP_STAT_MASK) != 0) {
+ error = (command & IXGBE_SB_IOSF_CTRL_CMPL_ERR_MASK) >>
+ IXGBE_SB_IOSF_CTRL_CMPL_ERR_SHIFT;
+ ERROR_REPORT2(IXGBE_ERROR_POLLING,
+ "Failed to read, error %x\n", error);
+ ret = IXGBE_ERR_PHY;
+ }
+
+ if (ret == IXGBE_SUCCESS)
+ *data = IXGBE_READ_REG(hw, IXGBE_SB_IOSF_INDIRECT_DATA);
+
+out:
+ ixgbe_release_swfw_semaphore(hw, gssr);
+ return ret;
+}
+
+/**
+ * ixgbe_disable_mdd_X550
+ * @hw: pointer to hardware structure
+ *
+ * Disable malicious driver detection
+ **/
+void ixgbe_disable_mdd_X550(struct ixgbe_hw *hw)
+{
+ u32 reg;
+
+ DEBUGFUNC("ixgbe_disable_mdd_X550");
+
+ /* Disable MDD for TX DMA and interrupt */
+ reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
+ reg &= ~(IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
+ IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
+
+ /* Disable MDD for RX and interrupt */
+ reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
+ reg &= ~(IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
+ IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
+}
+
+/**
+ * ixgbe_enable_mdd_X550
+ * @hw: pointer to hardware structure
+ *
+ * Enable malicious driver detection
+ **/
+void ixgbe_enable_mdd_X550(struct ixgbe_hw *hw)
+{
+ u32 reg;
+
+ DEBUGFUNC("ixgbe_enable_mdd_X550");
+
+ /* Enable MDD for TX DMA and interrupt */
+ reg = IXGBE_READ_REG(hw, IXGBE_DMATXCTL);
+ reg |= (IXGBE_DMATXCTL_MDP_EN | IXGBE_DMATXCTL_MBINTEN);
+ IXGBE_WRITE_REG(hw, IXGBE_DMATXCTL, reg);
+
+ /* Enable MDD for RX and interrupt */
+ reg = IXGBE_READ_REG(hw, IXGBE_RDRXCTL);
+ reg |= (IXGBE_RDRXCTL_MDP_EN | IXGBE_RDRXCTL_MBINTEN);
+ IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, reg);
+}
+
+/**
+ * ixgbe_restore_mdd_vf_X550
+ * @hw: pointer to hardware structure
+ * @vf: vf index
+ *
+ * Restore VF that was disabled during malicious driver detection event
+ **/
+void ixgbe_restore_mdd_vf_X550(struct ixgbe_hw *hw, u32 vf)
+{
+ u32 idx, reg, num_qs, start_q, bitmask;
+
+ DEBUGFUNC("ixgbe_restore_mdd_vf_X550");
+
+ /* Map VF to queues */
+ reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
+ switch (reg & IXGBE_MRQC_MRQE_MASK) {
+ case IXGBE_MRQC_VMDQRT8TCEN:
+ num_qs = 8; /* 16 VFs / pools */
+ bitmask = 0x000000FF;
+ break;
+ case IXGBE_MRQC_VMDQRSS32EN:
+ case IXGBE_MRQC_VMDQRT4TCEN:
+ num_qs = 4; /* 32 VFs / pools */
+ bitmask = 0x0000000F;
+ break;
+ default: /* 64 VFs / pools */
+ num_qs = 2;
+ bitmask = 0x00000003;
+ break;
+ }
+ start_q = vf * num_qs;
+
+ /* Release vf's queues by clearing WQBR_TX and WQBR_RX (RW1C) */
+ idx = start_q / 32;
+ reg = 0;
+ reg |= (bitmask << (start_q % 32));
+ IXGBE_WRITE_REG(hw, IXGBE_WQBR_TX(idx), reg);
+ IXGBE_WRITE_REG(hw, IXGBE_WQBR_RX(idx), reg);
+}
+
+/**
+ * ixgbe_mdd_event_X550
+ * @hw: pointer to hardware structure
+ * @vf_bitmap: vf bitmap of malicious vfs
+ *
+ * Handle malicious driver detection event.
+ **/
+void ixgbe_mdd_event_X550(struct ixgbe_hw *hw, u32 *vf_bitmap)
+{
+ u32 wqbr;
+ u32 i, j, reg, q, shift, vf, idx;
+
+ DEBUGFUNC("ixgbe_mdd_event_X550");
+
+ /* figure out pool size for mapping to vf's */
+ reg = IXGBE_READ_REG(hw, IXGBE_MRQC);
+ switch (reg & IXGBE_MRQC_MRQE_MASK) {
+ case IXGBE_MRQC_VMDQRT8TCEN:
+ shift = 3; /* 16 VFs / pools */
+ break;
+ case IXGBE_MRQC_VMDQRSS32EN:
+ case IXGBE_MRQC_VMDQRT4TCEN:
+ shift = 2; /* 32 VFs / pools */
+ break;
+ default:
+ shift = 1; /* 64 VFs / pools */
+ break;
+ }
+
+ /* Read WQBR_TX and WQBR_RX and check for malicious queues */
+ for (i = 0; i < 4; i++) {
+ wqbr = IXGBE_READ_REG(hw, IXGBE_WQBR_TX(i));
+ wqbr |= IXGBE_READ_REG(hw, IXGBE_WQBR_RX(i));
+
+ if (!wqbr)
+ continue;
+
+ /* Get malicious queue */
+ for (j = 0; j < 32 && wqbr; j++) {
+
+ if (!(wqbr & (1 << j)))
+ continue;
+
+ /* Get queue from bitmask */
+ q = j + (i * 32);
+
+ /* Map queue to vf */
+ vf = (q >> shift);
+
+ /* Set vf bit in vf_bitmap */
+ idx = vf / 32;
+ vf_bitmap[idx] |= (1 << (vf % 32));
+ wqbr &= ~(1 << j);
+ }
+ }
+}
+
+/**
+ * ixgbe_get_media_type_X550em - Get media type
+ * @hw: pointer to hardware structure
+ *
+ * Returns the media type (fiber, copper, backplane)
+ */
+enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
+{
+ enum ixgbe_media_type media_type;
+
+ DEBUGFUNC("ixgbe_get_media_type_X550em");
+
+ /* Detect if there is a copper PHY attached. */
+ switch (hw->device_id) {
+ case IXGBE_DEV_ID_X550EM_X_KR:
+ case IXGBE_DEV_ID_X550EM_X_KX4:
+ media_type = ixgbe_media_type_backplane;
+ break;
+ case IXGBE_DEV_ID_X550EM_X_SFP:
+ media_type = ixgbe_media_type_fiber;
+ break;
+ case IXGBE_DEV_ID_X550EM_X_1G_T:
+ case IXGBE_DEV_ID_X550EM_X_10G_T:
+ media_type = ixgbe_media_type_copper;
+ break;
+ default:
+ media_type = ixgbe_media_type_unknown;
+ break;
+ }
+ return media_type;
+}
+
+/**
+ * ixgbe_supported_sfp_modules_X550em - Check if SFP module type is supported
+ * @hw: pointer to hardware structure
+ * @linear: TRUE if SFP module is linear
+ */
+static s32 ixgbe_supported_sfp_modules_X550em(struct ixgbe_hw *hw, bool *linear)
+{
+ DEBUGFUNC("ixgbe_supported_sfp_modules_X550em");
+
+ switch (hw->phy.sfp_type) {
+ case ixgbe_sfp_type_not_present:
+ return IXGBE_ERR_SFP_NOT_PRESENT;
+ case ixgbe_sfp_type_da_cu_core0:
+ case ixgbe_sfp_type_da_cu_core1:
+ *linear = TRUE;
+ break;
+ case ixgbe_sfp_type_srlr_core0:
+ case ixgbe_sfp_type_srlr_core1:
+ case ixgbe_sfp_type_da_act_lmt_core0:
+ case ixgbe_sfp_type_da_act_lmt_core1:
+ case ixgbe_sfp_type_1g_sx_core0:
+ case ixgbe_sfp_type_1g_sx_core1:
+ case ixgbe_sfp_type_1g_lx_core0:
+ case ixgbe_sfp_type_1g_lx_core1:
+ *linear = FALSE;
+ break;
+ case ixgbe_sfp_type_unknown:
+ case ixgbe_sfp_type_1g_cu_core0:
+ case ixgbe_sfp_type_1g_cu_core1:
+ default:
+ return IXGBE_ERR_SFP_NOT_SUPPORTED;
+ }
+
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_identify_sfp_module_X550em - Identifies SFP modules
+ * @hw: pointer to hardware structure
+ *
+ * Searches for and identifies the SFP module and assigns appropriate PHY type.
+ **/
+s32 ixgbe_identify_sfp_module_X550em(struct ixgbe_hw *hw)
+{
+ s32 status;
+ bool linear;
+
+ DEBUGFUNC("ixgbe_identify_sfp_module_X550em");
+
+ status = ixgbe_identify_module_generic(hw);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* Check if SFP module is supported */
+ status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
+
+ return status;
+}
+
+/**
+ * ixgbe_setup_sfp_modules_X550em - Setup MAC link ops
+ * @hw: pointer to hardware structure
+ */
+s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
+{
+ s32 status;
+ bool linear;
+
+ DEBUGFUNC("ixgbe_setup_sfp_modules_X550em");
+
+ /* Check if SFP module is supported */
+ status = ixgbe_supported_sfp_modules_X550em(hw, &linear);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ ixgbe_init_mac_link_ops_X550em(hw);
+ hw->phy.ops.reset = NULL;
+
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_init_mac_link_ops_X550em - init mac link function pointers
+ * @hw: pointer to hardware structure
+ */
+void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
+{
+ struct ixgbe_mac_info *mac = &hw->mac;
+
+ DEBUGFUNC("ixgbe_init_mac_link_ops_X550em");
+
+ switch (hw->mac.ops.get_media_type(hw)) {
+ case ixgbe_media_type_fiber:
+ /* CS4227 does not support autoneg, so disable the laser control
+ * functions for SFP+ fiber
+ */
+ mac->ops.disable_tx_laser = NULL;
+ mac->ops.enable_tx_laser = NULL;
+ mac->ops.flap_tx_laser = NULL;
+ mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
+ mac->ops.setup_mac_link = ixgbe_setup_mac_link_sfp_x550em;
+ mac->ops.set_rate_select_speed =
+ ixgbe_set_soft_rate_select_speed;
+ break;
+ case ixgbe_media_type_copper:
+ mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
+ mac->ops.check_link = ixgbe_check_link_t_X550em;
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+ * ixgbe_get_link_capabilities_x550em - Determines link capabilities
+ * @hw: pointer to hardware structure
+ * @speed: pointer to link speed
+ * @autoneg: TRUE when autoneg or autotry is enabled
+ */
+s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
+ ixgbe_link_speed *speed,
+ bool *autoneg)
+{
+ DEBUGFUNC("ixgbe_get_link_capabilities_X550em");
+
+ /* SFP */
+ if (hw->phy.media_type == ixgbe_media_type_fiber) {
+
+ /* CS4227 SFP must not enable auto-negotiation */
+ *autoneg = FALSE;
+
+ /* Check if 1G SFP module. */
+ if (hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||
+ hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1
+ || hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core0 ||
+ hw->phy.sfp_type == ixgbe_sfp_type_1g_lx_core1) {
+ *speed = IXGBE_LINK_SPEED_1GB_FULL;
+ return IXGBE_SUCCESS;
+ }
+
+ /* Link capabilities are based on SFP */
+ if (hw->phy.multispeed_fiber)
+ *speed = IXGBE_LINK_SPEED_10GB_FULL |
+ IXGBE_LINK_SPEED_1GB_FULL;
+ else
+ *speed = IXGBE_LINK_SPEED_10GB_FULL;
+ } else {
+ *speed = IXGBE_LINK_SPEED_10GB_FULL |
+ IXGBE_LINK_SPEED_1GB_FULL;
+ *autoneg = TRUE;
+ }
+
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_get_lasi_ext_t_x550em - Determime external Base T PHY interrupt cause
+ * @hw: pointer to hardware structure
+ * @lsc: pointer to boolean flag which indicates whether external Base T
+ * PHY interrupt is lsc
+ *
+ * Determime if external Base T PHY interrupt cause is high temperature
+ * failure alarm or link status change.
+ *
+ * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
+ * failure alarm, else return PHY access status.
+ */
+static s32 ixgbe_get_lasi_ext_t_x550em(struct ixgbe_hw *hw, bool *lsc)
+{
+ u32 status;
+ u16 reg;
+
+ *lsc = FALSE;
+
+ /* Vendor alarm triggered */
+ status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+ &reg);
+
+ if (status != IXGBE_SUCCESS ||
+ !(reg & IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN))
+ return status;
+
+ /* Vendor Auto-Neg alarm triggered or Global alarm 1 triggered */
+ status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_FLAG,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+ &reg);
+
+ if (status != IXGBE_SUCCESS ||
+ !(reg & (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
+ IXGBE_MDIO_GLOBAL_ALARM_1_INT)))
+ return status;
+
+ /* High temperature failure alarm triggered */
+ status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_ALARM_1,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+ &reg);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* If high temperature failure, then return over temp error and exit */
+ if (reg & IXGBE_MDIO_GLOBAL_ALM_1_HI_TMP_FAIL) {
+ /* power down the PHY in case the PHY FW didn't already */
+ ixgbe_set_copper_phy_power(hw, FALSE);
+ return IXGBE_ERR_OVERTEMP;
+ }
+
+ /* Vendor alarm 2 triggered */
+ status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_CHIP_STD_INT_FLAG,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &reg);
+
+ if (status != IXGBE_SUCCESS ||
+ !(reg & IXGBE_MDIO_GLOBAL_STD_ALM2_INT))
+ return status;
+
+ /* link connect/disconnect event occurred */
+ status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM2,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &reg);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* Indicate LSC */
+ if (reg & IXGBE_MDIO_AUTO_NEG_VEN_LSC)
+ *lsc = TRUE;
+
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_enable_lasi_ext_t_x550em - Enable external Base T PHY interrupts
+ * @hw: pointer to hardware structure
+ *
+ * Enable link status change and temperature failure alarm for the external
+ * Base T PHY
+ *
+ * Returns PHY access status
+ */
+static s32 ixgbe_enable_lasi_ext_t_x550em(struct ixgbe_hw *hw)
+{
+ u32 status;
+ u16 reg;
+ bool lsc;
+
+ /* Clear interrupt flags */
+ status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
+
+ /* Enable link status change alarm */
+ status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE, &reg);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ reg |= IXGBE_MDIO_PMA_TX_VEN_LASI_INT_EN;
+
+ status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_PMA_TX_VEN_LASI_INT_MASK,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE, reg);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* Enables high temperature failure alarm */
+ status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+ &reg);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ reg |= IXGBE_MDIO_GLOBAL_INT_HI_TEMP_EN;
+
+ status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_MASK,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+ reg);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* Enable vendor Auto-Neg alarm and Global Interrupt Mask 1 alarm */
+ status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+ &reg);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ reg |= (IXGBE_MDIO_GLOBAL_AN_VEN_ALM_INT_EN |
+ IXGBE_MDIO_GLOBAL_ALARM_1_INT);
+
+ status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_VEN_MASK,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+ reg);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* Enable chip-wide vendor alarm */
+ status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+ &reg);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ reg |= IXGBE_MDIO_GLOBAL_VEN_ALM_INT_EN;
+
+ status = hw->phy.ops.write_reg(hw, IXGBE_MDIO_GLOBAL_INT_CHIP_STD_MASK,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+ reg);
+
+ return status;
+}
+
+/**
+ * ixgbe_setup_kr_speed_x550em - Configure the KR PHY for link speed.
+ * @hw: pointer to hardware structure
+ * @speed: link speed
+ *
+ * Configures the integrated KR PHY.
+ **/
+static s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw *hw,
+ ixgbe_link_speed speed)
+{
+ s32 status;
+ u32 reg_val;
+
+ status = ixgbe_read_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
+ if (status)
+ return status;
+
+ reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
+ reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_FEC_REQ |
+ IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC);
+ reg_val &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR |
+ IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX);
+
+ /* Advertise 10G support. */
+ if (speed & IXGBE_LINK_SPEED_10GB_FULL)
+ reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR;
+
+ /* Advertise 1G support. */
+ if (speed & IXGBE_LINK_SPEED_1GB_FULL)
+ reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX;
+
+ /* Restart auto-negotiation. */
+ reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
+ status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+
+ return status;
+}
+
+/**
+ * ixgbe_init_phy_ops_X550em - PHY/SFP specific init
+ * @hw: pointer to hardware structure
+ *
+ * Initialize any function pointers that were not able to be
+ * set during init_shared_code because the PHY/SFP type was
+ * not known. Perform the SFP init if necessary.
+ */
+s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
+{
+ struct ixgbe_phy_info *phy = &hw->phy;
+ ixgbe_link_speed speed;
+ s32 ret_val;
+
+ DEBUGFUNC("ixgbe_init_phy_ops_X550em");
+
+ hw->mac.ops.set_lan_id(hw);
+
+ if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
+ phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
+ ixgbe_setup_mux_ctl(hw);
+
+ /* Save NW management interface connected on board. This is used
+ * to determine internal PHY mode.
+ */
+ phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
+
+ /* If internal PHY mode is KR, then initialize KR link */
+ if (phy->nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE) {
+ speed = IXGBE_LINK_SPEED_10GB_FULL |
+ IXGBE_LINK_SPEED_1GB_FULL;
+ ret_val = ixgbe_setup_kr_speed_x550em(hw, speed);
+ }
+
+ phy->ops.identify_sfp = ixgbe_identify_sfp_module_X550em;
+ }
+
+ /* Identify the PHY or SFP module */
+ ret_val = phy->ops.identify(hw);
+ if (ret_val == IXGBE_ERR_SFP_NOT_SUPPORTED)
+ return ret_val;
+
+ /* Setup function pointers based on detected hardware */
+ ixgbe_init_mac_link_ops_X550em(hw);
+ if (phy->sfp_type != ixgbe_sfp_type_unknown)
+ phy->ops.reset = NULL;
+
+ /* Set functions pointers based on phy type */
+ switch (hw->phy.type) {
+ case ixgbe_phy_x550em_kx4:
+ phy->ops.setup_link = ixgbe_setup_kx4_x550em;
+ phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
+ phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
+ break;
+ case ixgbe_phy_x550em_kr:
+ phy->ops.setup_link = ixgbe_setup_kr_x550em;
+ phy->ops.read_reg = ixgbe_read_phy_reg_x550em;
+ phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
+ break;
+ case ixgbe_phy_x550em_ext_t:
+ /* Save NW management interface connected on board. This is used
+ * to determine internal PHY mode
+ */
+ phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
+
+ /* If internal link mode is XFI, then setup iXFI internal link,
+ * else setup KR now.
+ */
+ if (!(phy->nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
+ phy->ops.setup_internal_link =
+ ixgbe_setup_internal_phy_t_x550em;
+ } else {
+ speed = IXGBE_LINK_SPEED_10GB_FULL |
+ IXGBE_LINK_SPEED_1GB_FULL;
+ ret_val = ixgbe_setup_kr_speed_x550em(hw, speed);
+ }
+
+ phy->ops.enter_lplu = ixgbe_enter_lplu_t_x550em;
+ phy->ops.handle_lasi = ixgbe_handle_lasi_ext_t_x550em;
+ phy->ops.reset = ixgbe_reset_phy_t_X550em;
+ break;
+ default:
+ break;
+ }
+ return ret_val;
+}
+
+/**
+ * ixgbe_reset_hw_X550em - Perform hardware reset
+ * @hw: pointer to hardware structure
+ *
+ * Resets the hardware by resetting the transmit and receive units, masks
+ * and clears all interrupts, perform a PHY reset, and perform a link (MAC)
+ * reset.
+ */
+s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw)
+{
+ ixgbe_link_speed link_speed;
+ s32 status;
+ u32 ctrl = 0;
+ u32 i;
+ u32 hlreg0;
+ bool link_up = FALSE;
+
+ DEBUGFUNC("ixgbe_reset_hw_X550em");
+
+ /* Call adapter stop to disable Tx/Rx and clear interrupts */
+ status = hw->mac.ops.stop_adapter(hw);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* flush pending Tx transactions */
+ ixgbe_clear_tx_pending(hw);
+
+ /* PHY ops must be identified and initialized prior to reset */
+
+ /* Identify PHY and related function pointers */
+ status = hw->phy.ops.init(hw);
+
+ if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
+ return status;
+
+ /* start the external PHY */
+ if (hw->phy.type == ixgbe_phy_x550em_ext_t) {
+ status = ixgbe_init_ext_t_x550em(hw);
+ if (status)
+ return status;
+ }
+
+ /* Setup SFP module if there is one present. */
+ if (hw->phy.sfp_setup_needed) {
+ status = hw->mac.ops.setup_sfp(hw);
+ hw->phy.sfp_setup_needed = FALSE;
+ }
+
+ if (status == IXGBE_ERR_SFP_NOT_SUPPORTED)
+ return status;
+
+ /* Reset PHY */
+ if (!hw->phy.reset_disable && hw->phy.ops.reset)
+ hw->phy.ops.reset(hw);
+
+mac_reset_top:
+ /* Issue global reset to the MAC. Needs to be SW reset if link is up.
+ * If link reset is used when link is up, it might reset the PHY when
+ * mng is using it. If link is down or the flag to force full link
+ * reset is set, then perform link reset.
+ */
+ ctrl = IXGBE_CTRL_LNK_RST;
+ if (!hw->force_full_reset) {
+ hw->mac.ops.check_link(hw, &link_speed, &link_up, FALSE);
+ if (link_up)
+ ctrl = IXGBE_CTRL_RST;
+ }
+
+ ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
+ IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
+ IXGBE_WRITE_FLUSH(hw);
+
+ /* Poll for reset bit to self-clear meaning reset is complete */
+ for (i = 0; i < 10; i++) {
+ usec_delay(1);
+ ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
+ if (!(ctrl & IXGBE_CTRL_RST_MASK))
+ break;
+ }
+
+ if (ctrl & IXGBE_CTRL_RST_MASK) {
+ status = IXGBE_ERR_RESET_FAILED;
+ DEBUGOUT("Reset polling failed to complete.\n");
+ }
+
+ msec_delay(50);
+
+ /* Double resets are required for recovery from certain error
+ * conditions. Between resets, it is necessary to stall to
+ * allow time for any pending HW events to complete.
+ */
+ if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
+ hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
+ goto mac_reset_top;
+ }
+
+ /* Store the permanent mac address */
+ hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
+
+ /* Store MAC address from RAR0, clear receive address registers, and
+ * clear the multicast table. Also reset num_rar_entries to 128,
+ * since we modify this value when programming the SAN MAC address.
+ */
+ hw->mac.num_rar_entries = 128;
+ hw->mac.ops.init_rx_addrs(hw);
+
+ if (hw->device_id == IXGBE_DEV_ID_X550EM_X_10G_T) {
+ /* Config MDIO clock speed. */
+ hlreg0 = IXGBE_READ_REG(hw, IXGBE_HLREG0);
+ hlreg0 &= ~IXGBE_HLREG0_MDCSPD;
+ IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0);
+ }
+
+ if (hw->device_id == IXGBE_DEV_ID_X550EM_X_SFP)
+ ixgbe_setup_mux_ctl(hw);
+
+ return status;
+}
+
+/**
+ * ixgbe_init_ext_t_x550em - Start (unstall) the external Base T PHY.
+ * @hw: pointer to hardware structure
+ */
+s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
+{
+ u32 status;
+ u16 reg;
+
+ status = hw->phy.ops.read_reg(hw,
+ IXGBE_MDIO_TX_VENDOR_ALARMS_3,
+ IXGBE_MDIO_PMA_PMD_DEV_TYPE,
+ &reg);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* If PHY FW reset completed bit is set then this is the first
+ * SW instance after a power on so the PHY FW must be un-stalled.
+ */
+ if (reg & IXGBE_MDIO_TX_VENDOR_ALARMS_3_RST_MASK) {
+ status = hw->phy.ops.read_reg(hw,
+ IXGBE_MDIO_GLOBAL_RES_PR_10,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+ &reg);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ reg &= ~IXGBE_MDIO_POWER_UP_STALL;
+
+ status = hw->phy.ops.write_reg(hw,
+ IXGBE_MDIO_GLOBAL_RES_PR_10,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE,
+ reg);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+ }
+
+ return status;
+}
+
+/**
+ * ixgbe_setup_kr_x550em - Configure the KR PHY.
+ * @hw: pointer to hardware structure
+ *
+ * Configures the integrated KR PHY.
+ **/
+s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
+{
+ return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
+}
+
+/**
+ * ixgbe_setup_kx4_x550em - Configure the KX4 PHY.
+ * @hw: pointer to hardware structure
+ *
+ * Configures the integrated KX4 PHY.
+ **/
+s32 ixgbe_setup_kx4_x550em(struct ixgbe_hw *hw)
+{
+ s32 status;
+ u32 reg_val;
+
+ status = ixgbe_read_iosf_sb_reg_x550(hw, IXGBE_KX4_LINK_CNTL_1,
+ IXGBE_SB_IOSF_TARGET_KX4_PCS, &reg_val);
+ if (status)
+ return status;
+
+ reg_val &= ~(IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4 |
+ IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX);
+
+ reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_ENABLE;
+
+ /* Advertise 10G support. */
+ if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_10GB_FULL)
+ reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX4;
+
+ /* Advertise 1G support. */
+ if (hw->phy.autoneg_advertised & IXGBE_LINK_SPEED_1GB_FULL)
+ reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_CAP_KX;
+
+ /* Restart auto-negotiation. */
+ reg_val |= IXGBE_KX4_LINK_CNTL_1_TETH_AN_RESTART;
+ status = ixgbe_write_iosf_sb_reg_x550(hw, IXGBE_KX4_LINK_CNTL_1,
+ IXGBE_SB_IOSF_TARGET_KX4_PCS, reg_val);
+
+ return status;
+}
+
+/**
+ * ixgbe_setup_mac_link_sfp_x550em - Setup internal/external the PHY for SFP
+ * @hw: pointer to hardware structure
+ *
+ * Configure the external PHY and the integrated KR PHY for SFP support.
+ **/
+s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
+ ixgbe_link_speed speed,
+ bool autoneg_wait_to_complete)
+{
+ s32 ret_val;
+ u16 reg_slice, reg_val;
+ bool setup_linear = FALSE;
+ UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
+
+ /* Check if SFP module is supported and linear */
+ ret_val = ixgbe_supported_sfp_modules_X550em(hw, &setup_linear);
+
+ /* If no SFP module present, then return success. Return success since
+ * there is no reason to configure CS4227 and SFP not present error is
+ * not excepted in the setup MAC link flow.
+ */
+ if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
+ return IXGBE_SUCCESS;
+
+ if (ret_val != IXGBE_SUCCESS)
+ return ret_val;
+
+ /* Configure CS4227 for LINE connection rate then type. */
+ reg_slice = IXGBE_CS4227_LINE_SPARE22_MSB + (hw->bus.lan_id << 12);
+ reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ? 0 : 0x8000;
+ ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
+ reg_val);
+
+ reg_slice = IXGBE_CS4227_LINE_SPARE24_LSB + (hw->bus.lan_id << 12);
+ if (setup_linear)
+ reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
+ else
+ reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
+ ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
+ reg_val);
+
+ /* Configure CS4227 for HOST connection rate then type. */
+ reg_slice = IXGBE_CS4227_HOST_SPARE22_MSB + (hw->bus.lan_id << 12);
+ reg_val = (speed & IXGBE_LINK_SPEED_10GB_FULL) ? 0 : 0x8000;
+ ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
+ reg_val);
+
+ reg_slice = IXGBE_CS4227_HOST_SPARE24_LSB + (hw->bus.lan_id << 12);
+ if (setup_linear)
+ reg_val = (IXGBE_CS4227_EDC_MODE_CX1 << 1) | 0x1;
+ else
+ reg_val = (IXGBE_CS4227_EDC_MODE_SR << 1) | 0x1;
+ ret_val = ixgbe_write_i2c_combined(hw, IXGBE_CS4227, reg_slice,
+ reg_val);
+
+ /* If internal link mode is XFI, then setup XFI internal link. */
+ if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE))
+ ret_val = ixgbe_setup_ixfi_x550em(hw, &speed);
+
+ return ret_val;
+}
+
+/**
+ * ixgbe_setup_ixfi_x550em - Configure the KR PHY for iXFI mode.
+ * @hw: pointer to hardware structure
+ * @speed: the link speed to force
+ *
+ * Configures the integrated KR PHY to use iXFI mode. Used to connect an
+ * internal and external PHY at a specific speed, without autonegotiation.
+ **/
+static s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed)
+{
+ s32 status;
+ u32 reg_val;
+
+ /* Disable AN and force speed to 10G Serial. */
+ status = ixgbe_read_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
+ reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
+
+ /* Select forced link speed for internal PHY. */
+ switch (*speed) {
+ case IXGBE_LINK_SPEED_10GB_FULL:
+ reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
+ break;
+ case IXGBE_LINK_SPEED_1GB_FULL:
+ reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G;
+ break;
+ default:
+ /* Other link speeds are not supported by internal KR PHY. */
+ return IXGBE_ERR_LINK_SETUP;
+ }
+
+ status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* Disable training protocol FSM. */
+ status = ixgbe_read_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_CONV_WO_PROTOCOL;
+ status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* Disable Flex from training TXFFE. */
+ status = ixgbe_read_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
+ reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
+ reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
+ status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_DSP_TXFFE_STATE_4(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ status = ixgbe_read_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_C0_EN;
+ reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN;
+ reg_val &= ~IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN;
+ status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_DSP_TXFFE_STATE_5(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* Enable override for coefficients. */
+ status = ixgbe_read_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_OVRRD_EN;
+ reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CZERO_EN;
+ reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CPLUS1_OVRRD_EN;
+ reg_val |= IXGBE_KRM_TX_COEFF_CTRL_1_CMINUS1_OVRRD_EN;
+ status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_TX_COEFF_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* Toggle port SW reset by AN reset. */
+ status = ixgbe_read_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
+ status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+
+ return status;
+}
+
+/**
+ * ixgbe_ext_phy_t_x550em_get_link - Get ext phy link status
+ * @hw: address of hardware structure
+ * @link_up: address of boolean to indicate link status
+ *
+ * Returns error code if unable to get link status.
+ */
+static s32 ixgbe_ext_phy_t_x550em_get_link(struct ixgbe_hw *hw, bool *link_up)
+{
+ u32 ret;
+ u16 autoneg_status;
+
+ *link_up = FALSE;
+
+ /* read this twice back to back to indicate current status */
+ ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+ &autoneg_status);
+ if (ret != IXGBE_SUCCESS)
+ return ret;
+
+ ret = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+ &autoneg_status);
+ if (ret != IXGBE_SUCCESS)
+ return ret;
+
+ *link_up = !!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS);
+
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_setup_internal_phy_t_x550em - Configure KR PHY to X557 link
+ * @hw: point to hardware structure
+ *
+ * Configures the link between the integrated KR PHY and the external X557 PHY
+ * The driver will call this function when it gets a link status change
+ * interrupt from the X557 PHY. This function configures the link speed
+ * between the PHYs to match the link speed of the BASE-T link.
+ *
+ * A return of a non-zero value indicates an error, and the base driver should
+ * not report link up.
+ */
+s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw)
+{
+ ixgbe_link_speed force_speed;
+ bool link_up;
+ u32 status;
+ u16 speed;
+
+ if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
+ return IXGBE_ERR_CONFIG;
+
+ /* If link is not up, then there is no setup necessary so return */
+ status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ if (!link_up)
+ return IXGBE_SUCCESS;
+
+ status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+ &speed);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* If link is not still up, then no setup is necessary so return */
+ status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ if (!link_up)
+ return IXGBE_SUCCESS;
+
+ /* clear everything but the speed and duplex bits */
+ speed &= IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_MASK;
+
+ switch (speed) {
+ case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB_FULL:
+ force_speed = IXGBE_LINK_SPEED_10GB_FULL;
+ break;
+ case IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB_FULL:
+ force_speed = IXGBE_LINK_SPEED_1GB_FULL;
+ break;
+ default:
+ /* Internal PHY does not support anything else */
+ return IXGBE_ERR_INVALID_LINK_SETTINGS;
+ }
+
+ return ixgbe_setup_ixfi_x550em(hw, &force_speed);
+}
+
+/**
+ * ixgbe_setup_phy_loopback_x550em - Configure the KR PHY for loopback.
+ * @hw: pointer to hardware structure
+ *
+ * Configures the integrated KR PHY to use internal loopback mode.
+ **/
+s32 ixgbe_setup_phy_loopback_x550em(struct ixgbe_hw *hw)
+{
+ s32 status;
+ u32 reg_val;
+
+ /* Disable AN and force speed to 10G Serial. */
+ status = ixgbe_read_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
+ reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
+ reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G;
+ status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* Set near-end loopback clocks. */
+ status = ixgbe_read_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_32B;
+ reg_val |= IXGBE_KRM_PORT_CAR_GEN_CTRL_NELB_KRPCS;
+ status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_PORT_CAR_GEN_CTRL(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* Set loopback enable. */
+ status = ixgbe_read_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ reg_val |= IXGBE_KRM_PMD_DFX_BURNIN_TX_RX_KR_LB_MASK;
+ status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_PMD_DFX_BURNIN(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* Training bypass. */
+ status = ixgbe_read_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
+ if (status != IXGBE_SUCCESS)
+ return status;
+ reg_val |= IXGBE_KRM_RX_TRN_LINKUP_CTRL_PROTOCOL_BYPASS;
+ status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_RX_TRN_LINKUP_CTRL(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+
+ return status;
+}
+
+/**
+ * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
+ * assuming that the semaphore is already obtained.
+ * @hw: pointer to hardware structure
+ * @offset: offset of word in the EEPROM to read
+ * @data: word read from the EEPROM
+ *
+ * Reads a 16 bit word from the EEPROM using the hostif.
+ **/
+s32 ixgbe_read_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
+ u16 *data)
+{
+ s32 status;
+ struct ixgbe_hic_read_shadow_ram buffer;
+
+ DEBUGFUNC("ixgbe_read_ee_hostif_data_X550");
+ buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
+ buffer.hdr.req.buf_lenh = 0;
+ buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
+ buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
+
+ /* convert offset from words to bytes */
+ buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
+ /* one word */
+ buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
+
+ status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
+ sizeof(buffer),
+ IXGBE_HI_COMMAND_TIMEOUT, FALSE);
+
+ if (status)
+ return status;
+
+ *data = (u16)IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG,
+ FW_NVM_DATA_OFFSET);
+
+ return 0;
+}
+
+/**
+ * ixgbe_read_ee_hostif_X550 - Read EEPROM word using a host interface command
+ * @hw: pointer to hardware structure
+ * @offset: offset of word in the EEPROM to read
+ * @data: word read from the EEPROM
+ *
+ * Reads a 16 bit word from the EEPROM using the hostif.
+ **/
+s32 ixgbe_read_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
+ u16 *data)
+{
+ s32 status = IXGBE_SUCCESS;
+
+ DEBUGFUNC("ixgbe_read_ee_hostif_X550");
+
+ if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
+ IXGBE_SUCCESS) {
+ status = ixgbe_read_ee_hostif_data_X550(hw, offset, data);
+ hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
+ } else {
+ status = IXGBE_ERR_SWFW_SYNC;
+ }
+
+ return status;
+}
+
+/**
+ * ixgbe_read_ee_hostif_buffer_X550- Read EEPROM word(s) using hostif
+ * @hw: pointer to hardware structure
+ * @offset: offset of word in the EEPROM to read
+ * @words: number of words
+ * @data: word(s) read from the EEPROM
+ *
+ * Reads a 16 bit word(s) from the EEPROM using the hostif.
+ **/
+s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
+ u16 offset, u16 words, u16 *data)
+{
+ struct ixgbe_hic_read_shadow_ram buffer;
+ u32 current_word = 0;
+ u16 words_to_read;
+ s32 status;
+ u32 i;
+
+ DEBUGFUNC("ixgbe_read_ee_hostif_buffer_X550");
+
+ /* Take semaphore for the entire operation. */
+ status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
+ if (status) {
+ DEBUGOUT("EEPROM read buffer - semaphore failed\n");
+ return status;
+ }
+ while (words) {
+ if (words > FW_MAX_READ_BUFFER_SIZE / 2)
+ words_to_read = FW_MAX_READ_BUFFER_SIZE / 2;
+ else
+ words_to_read = words;
+
+ buffer.hdr.req.cmd = FW_READ_SHADOW_RAM_CMD;
+ buffer.hdr.req.buf_lenh = 0;
+ buffer.hdr.req.buf_lenl = FW_READ_SHADOW_RAM_LEN;
+ buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
+
+ /* convert offset from words to bytes */
+ buffer.address = IXGBE_CPU_TO_BE32((offset + current_word) * 2);
+ buffer.length = IXGBE_CPU_TO_BE16(words_to_read * 2);
+
+ status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
+ sizeof(buffer),
+ IXGBE_HI_COMMAND_TIMEOUT,
+ FALSE);
+
+ if (status) {
+ DEBUGOUT("Host interface command failed\n");
+ goto out;
+ }
+
+ for (i = 0; i < words_to_read; i++) {
+ u32 reg = IXGBE_FLEX_MNG + (FW_NVM_DATA_OFFSET << 2) +
+ 2 * i;
+ u32 value = IXGBE_READ_REG(hw, reg);
+
+ data[current_word] = (u16)(value & 0xffff);
+ current_word++;
+ i++;
+ if (i < words_to_read) {
+ value >>= 16;
+ data[current_word] = (u16)(value & 0xffff);
+ current_word++;
+ }
+ }
+ words -= words_to_read;
+ }
+
+out:
+ hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
+ return status;
+}
+
+/**
+ * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
+ * @hw: pointer to hardware structure
+ * @offset: offset of word in the EEPROM to write
+ * @data: word write to the EEPROM
+ *
+ * Write a 16 bit word to the EEPROM using the hostif.
+ **/
+s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
+ u16 data)
+{
+ s32 status;
+ struct ixgbe_hic_write_shadow_ram buffer;
+
+ DEBUGFUNC("ixgbe_write_ee_hostif_data_X550");
+
+ buffer.hdr.req.cmd = FW_WRITE_SHADOW_RAM_CMD;
+ buffer.hdr.req.buf_lenh = 0;
+ buffer.hdr.req.buf_lenl = FW_WRITE_SHADOW_RAM_LEN;
+ buffer.hdr.req.checksum = FW_DEFAULT_CHECKSUM;
+
+ /* one word */
+ buffer.length = IXGBE_CPU_TO_BE16(sizeof(u16));
+ buffer.data = data;
+ buffer.address = IXGBE_CPU_TO_BE32(offset * 2);
+
+ status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
+ sizeof(buffer),
+ IXGBE_HI_COMMAND_TIMEOUT, FALSE);
+
+ return status;
+}
+
+/**
+ * ixgbe_write_ee_hostif_X550 - Write EEPROM word using hostif
+ * @hw: pointer to hardware structure
+ * @offset: offset of word in the EEPROM to write
+ * @data: word write to the EEPROM
+ *
+ * Write a 16 bit word to the EEPROM using the hostif.
+ **/
+s32 ixgbe_write_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
+ u16 data)
+{
+ s32 status = IXGBE_SUCCESS;
+
+ DEBUGFUNC("ixgbe_write_ee_hostif_X550");
+
+ if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM) ==
+ IXGBE_SUCCESS) {
+ status = ixgbe_write_ee_hostif_data_X550(hw, offset, data);
+ hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
+ } else {
+ DEBUGOUT("write ee hostif failed to get semaphore");
+ status = IXGBE_ERR_SWFW_SYNC;
+ }
+
+ return status;
+}
+
+/**
+ * ixgbe_write_ee_hostif_buffer_X550 - Write EEPROM word(s) using hostif
+ * @hw: pointer to hardware structure
+ * @offset: offset of word in the EEPROM to write
+ * @words: number of words
+ * @data: word(s) write to the EEPROM
+ *
+ * Write a 16 bit word(s) to the EEPROM using the hostif.
+ **/
+s32 ixgbe_write_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
+ u16 offset, u16 words, u16 *data)
+{
+ s32 status = IXGBE_SUCCESS;
+ u32 i = 0;
+
+ DEBUGFUNC("ixgbe_write_ee_hostif_buffer_X550");
+
+ /* Take semaphore for the entire operation. */
+ status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
+ if (status != IXGBE_SUCCESS) {
+ DEBUGOUT("EEPROM write buffer - semaphore failed\n");
+ goto out;
+ }
+
+ for (i = 0; i < words; i++) {
+ status = ixgbe_write_ee_hostif_data_X550(hw, offset + i,
+ data[i]);
+
+ if (status != IXGBE_SUCCESS) {
+ DEBUGOUT("Eeprom buffered write failed\n");
+ break;
+ }
+ }
+
+ hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_EEP_SM);
+out:
+
+ return status;
+}
+
+/**
+ * ixgbe_checksum_ptr_x550 - Checksum one pointer region
+ * @hw: pointer to hardware structure
+ * @ptr: pointer offset in eeprom
+ * @size: size of section pointed by ptr, if 0 first word will be used as size
+ * @csum: address of checksum to update
+ *
+ * Returns error status for any failure
+ */
+static s32 ixgbe_checksum_ptr_x550(struct ixgbe_hw *hw, u16 ptr,
+ u16 size, u16 *csum, u16 *buffer,
+ u32 buffer_size)
+{
+ u16 buf[256];
+ s32 status;
+ u16 length, bufsz, i, start;
+ u16 *local_buffer;
+
+ bufsz = sizeof(buf) / sizeof(buf[0]);
+
+ /* Read a chunk at the pointer location */
+ if (!buffer) {
+ status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr, bufsz, buf);
+ if (status) {
+ DEBUGOUT("Failed to read EEPROM image\n");
+ return status;
+ }
+ local_buffer = buf;
+ } else {
+ if (buffer_size < ptr)
+ return IXGBE_ERR_PARAM;
+ local_buffer = &buffer[ptr];
+ }
+
+ if (size) {
+ start = 0;
+ length = size;
+ } else {
+ start = 1;
+ length = local_buffer[0];
+
+ /* Skip pointer section if length is invalid. */
+ if (length == 0xFFFF || length == 0 ||
+ (ptr + length) >= hw->eeprom.word_size)
+ return IXGBE_SUCCESS;
+ }
+
+ if (buffer && ((u32)start + (u32)length > buffer_size))
+ return IXGBE_ERR_PARAM;
+
+ for (i = start; length; i++, length--) {
+ if (i == bufsz && !buffer) {
+ ptr += bufsz;
+ i = 0;
+ if (length < bufsz)
+ bufsz = length;
+
+ /* Read a chunk at the pointer location */
+ status = ixgbe_read_ee_hostif_buffer_X550(hw, ptr,
+ bufsz, buf);
+ if (status) {
+ DEBUGOUT("Failed to read EEPROM image\n");
+ return status;
+ }
+ }
+ *csum += local_buffer[i];
+ }
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_calc_checksum_X550 - Calculates and returns the checksum
+ * @hw: pointer to hardware structure
+ * @buffer: pointer to buffer containing calculated checksum
+ * @buffer_size: size of buffer
+ *
+ * Returns a negative error code on error, or the 16-bit checksum
+ **/
+s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer, u32 buffer_size)
+{
+ u16 eeprom_ptrs[IXGBE_EEPROM_LAST_WORD + 1];
+ u16 *local_buffer;
+ s32 status;
+ u16 checksum = 0;
+ u16 pointer, i, size;
+
+ DEBUGFUNC("ixgbe_calc_eeprom_checksum_X550");
+
+ hw->eeprom.ops.init_params(hw);
+
+ if (!buffer) {
+ /* Read pointer area */
+ status = ixgbe_read_ee_hostif_buffer_X550(hw, 0,
+ IXGBE_EEPROM_LAST_WORD + 1,
+ eeprom_ptrs);
+ if (status) {
+ DEBUGOUT("Failed to read EEPROM image\n");
+ return status;
+ }
+ local_buffer = eeprom_ptrs;
+ } else {
+ if (buffer_size < IXGBE_EEPROM_LAST_WORD)
+ return IXGBE_ERR_PARAM;
+ local_buffer = buffer;
+ }
+
+ /*
+ * For X550 hardware include 0x0-0x41 in the checksum, skip the
+ * checksum word itself
+ */
+ for (i = 0; i <= IXGBE_EEPROM_LAST_WORD; i++)
+ if (i != IXGBE_EEPROM_CHECKSUM)
+ checksum += local_buffer[i];
+
+ /*
+ * Include all data from pointers 0x3, 0x6-0xE. This excludes the
+ * FW, PHY module, and PCIe Expansion/Option ROM pointers.
+ */
+ for (i = IXGBE_PCIE_ANALOG_PTR_X550; i < IXGBE_FW_PTR; i++) {
+ if (i == IXGBE_PHY_PTR || i == IXGBE_OPTION_ROM_PTR)
+ continue;
+
+ pointer = local_buffer[i];
+
+ /* Skip pointer section if the pointer is invalid. */
+ if (pointer == 0xFFFF || pointer == 0 ||
+ pointer >= hw->eeprom.word_size)
+ continue;
+
+ switch (i) {
+ case IXGBE_PCIE_GENERAL_PTR:
+ size = IXGBE_IXGBE_PCIE_GENERAL_SIZE;
+ break;
+ case IXGBE_PCIE_CONFIG0_PTR:
+ case IXGBE_PCIE_CONFIG1_PTR:
+ size = IXGBE_PCIE_CONFIG_SIZE;
+ break;
+ default:
+ size = 0;
+ break;
+ }
+
+ status = ixgbe_checksum_ptr_x550(hw, pointer, size, &checksum,
+ buffer, buffer_size);
+ if (status)
+ return status;
+ }
+
+ checksum = (u16)IXGBE_EEPROM_SUM - checksum;
+
+ return (s32)checksum;
+}
+
+/**
+ * ixgbe_calc_eeprom_checksum_X550 - Calculates and returns the checksum
+ * @hw: pointer to hardware structure
+ *
+ * Returns a negative error code on error, or the 16-bit checksum
+ **/
+s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw)
+{
+ return ixgbe_calc_checksum_X550(hw, NULL, 0);
+}
+
+/**
+ * ixgbe_validate_eeprom_checksum_X550 - Validate EEPROM checksum
+ * @hw: pointer to hardware structure
+ * @checksum_val: calculated checksum
+ *
+ * Performs checksum calculation and validates the EEPROM checksum. If the
+ * caller does not need checksum_val, the value can be NULL.
+ **/
+s32 ixgbe_validate_eeprom_checksum_X550(struct ixgbe_hw *hw, u16 *checksum_val)
+{
+ s32 status;
+ u16 checksum;
+ u16 read_checksum = 0;
+
+ DEBUGFUNC("ixgbe_validate_eeprom_checksum_X550");
+
+ /* Read the first word from the EEPROM. If this times out or fails, do
+ * not continue or we could be in for a very long wait while every
+ * EEPROM read fails
+ */
+ status = hw->eeprom.ops.read(hw, 0, &checksum);
+ if (status) {
+ DEBUGOUT("EEPROM read failed\n");
+ return status;
+ }
+
+ status = hw->eeprom.ops.calc_checksum(hw);
+ if (status < 0)
+ return status;
+
+ checksum = (u16)(status & 0xffff);
+
+ status = ixgbe_read_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
+ &read_checksum);
+ if (status)
+ return status;
+
+ /* Verify read checksum from EEPROM is the same as
+ * calculated checksum
+ */
+ if (read_checksum != checksum) {
+ status = IXGBE_ERR_EEPROM_CHECKSUM;
+ ERROR_REPORT1(IXGBE_ERROR_INVALID_STATE,
+ "Invalid EEPROM checksum");
+ }
+
+ /* If the user cares, return the calculated checksum */
+ if (checksum_val)
+ *checksum_val = checksum;
+
+ return status;
+}
+
+/**
+ * ixgbe_update_eeprom_checksum_X550 - Updates the EEPROM checksum and flash
+ * @hw: pointer to hardware structure
+ *
+ * After writing EEPROM to shadow RAM using EEWR register, software calculates
+ * checksum and updates the EEPROM and instructs the hardware to update
+ * the flash.
+ **/
+s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw)
+{
+ s32 status;
+ u16 checksum = 0;
+
+ DEBUGFUNC("ixgbe_update_eeprom_checksum_X550");
+
+ /* Read the first word from the EEPROM. If this times out or fails, do
+ * not continue or we could be in for a very long wait while every
+ * EEPROM read fails
+ */
+ status = ixgbe_read_ee_hostif_X550(hw, 0, &checksum);
+ if (status) {
+ DEBUGOUT("EEPROM read failed\n");
+ return status;
+ }
+
+ status = ixgbe_calc_eeprom_checksum_X550(hw);
+ if (status < 0)
+ return status;
+
+ checksum = (u16)(status & 0xffff);
+
+ status = ixgbe_write_ee_hostif_X550(hw, IXGBE_EEPROM_CHECKSUM,
+ checksum);
+ if (status)
+ return status;
+
+ status = ixgbe_update_flash_X550(hw);
+
+ return status;
+}
+
+/**
+ * ixgbe_update_flash_X550 - Instruct HW to copy EEPROM to Flash device
+ * @hw: pointer to hardware structure
+ *
+ * Issue a shadow RAM dump to FW to copy EEPROM from shadow RAM to the flash.
+ **/
+s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw)
+{
+ s32 status = IXGBE_SUCCESS;
+ union ixgbe_hic_hdr2 buffer;
+
+ DEBUGFUNC("ixgbe_update_flash_X550");
+
+ buffer.req.cmd = FW_SHADOW_RAM_DUMP_CMD;
+ buffer.req.buf_lenh = 0;
+ buffer.req.buf_lenl = FW_SHADOW_RAM_DUMP_LEN;
+ buffer.req.checksum = FW_DEFAULT_CHECKSUM;
+
+ status = ixgbe_host_interface_command(hw, (u32 *)&buffer,
+ sizeof(buffer),
+ IXGBE_HI_COMMAND_TIMEOUT, FALSE);
+
+ return status;
+}
+
+/**
+ * ixgbe_get_supported_physical_layer_X550em - Returns physical layer type
+ * @hw: pointer to hardware structure
+ *
+ * Determines physical layer capabilities of the current configuration.
+ **/
+u32 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw)
+{
+ u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
+ u16 ext_ability = 0;
+
+ DEBUGFUNC("ixgbe_get_supported_physical_layer_X550em");
+
+ hw->phy.ops.identify(hw);
+
+ switch (hw->phy.type) {
+ case ixgbe_phy_x550em_kr:
+ physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KR |
+ IXGBE_PHYSICAL_LAYER_1000BASE_KX;
+ break;
+ case ixgbe_phy_x550em_kx4:
+ physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4 |
+ IXGBE_PHYSICAL_LAYER_1000BASE_KX;
+ break;
+ case ixgbe_phy_x550em_ext_t:
+ hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_EXT_ABILITY,
+ IXGBE_MDIO_PMA_PMD_DEV_TYPE,
+ &ext_ability);
+ if (ext_ability & IXGBE_MDIO_PHY_10GBASET_ABILITY)
+ physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
+ if (ext_ability & IXGBE_MDIO_PHY_1000BASET_ABILITY)
+ physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
+ break;
+ default:
+ break;
+ }
+
+ if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber)
+ physical_layer = ixgbe_get_supported_phy_sfp_layer_generic(hw);
+
+ return physical_layer;
+}
+
+/**
+ * ixgbe_get_bus_info_x550em - Set PCI bus info
+ * @hw: pointer to hardware structure
+ *
+ * Sets bus link width and speed to unknown because X550em is
+ * not a PCI device.
+ **/
+s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw)
+{
+
+ DEBUGFUNC("ixgbe_get_bus_info_x550em");
+
+ hw->bus.width = ixgbe_bus_width_unknown;
+ hw->bus.speed = ixgbe_bus_speed_unknown;
+
+ hw->mac.ops.set_lan_id(hw);
+
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_disable_rx_x550 - Disable RX unit
+ *
+ * Enables the Rx DMA unit for x550
+ **/
+void ixgbe_disable_rx_x550(struct ixgbe_hw *hw)
+{
+ u32 rxctrl, pfdtxgswc;
+ s32 status;
+ struct ixgbe_hic_disable_rxen fw_cmd;
+
+ DEBUGFUNC("ixgbe_enable_rx_dma_x550");
+
+ rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
+ if (rxctrl & IXGBE_RXCTRL_RXEN) {
+ pfdtxgswc = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
+ if (pfdtxgswc & IXGBE_PFDTXGSWC_VT_LBEN) {
+ pfdtxgswc &= ~IXGBE_PFDTXGSWC_VT_LBEN;
+ IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, pfdtxgswc);
+ hw->mac.set_lben = TRUE;
+ } else {
+ hw->mac.set_lben = FALSE;
+ }
+
+ fw_cmd.hdr.cmd = FW_DISABLE_RXEN_CMD;
+ fw_cmd.hdr.buf_len = FW_DISABLE_RXEN_LEN;
+ fw_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
+ fw_cmd.port_number = (u8)hw->bus.lan_id;
+
+ status = ixgbe_host_interface_command(hw, (u32 *)&fw_cmd,
+ sizeof(struct ixgbe_hic_disable_rxen),
+ IXGBE_HI_COMMAND_TIMEOUT, TRUE);
+
+ /* If we fail - disable RX using register write */
+ if (status) {
+ rxctrl = IXGBE_READ_REG(hw, IXGBE_RXCTRL);
+ if (rxctrl & IXGBE_RXCTRL_RXEN) {
+ rxctrl &= ~IXGBE_RXCTRL_RXEN;
+ IXGBE_WRITE_REG(hw, IXGBE_RXCTRL, rxctrl);
+ }
+ }
+ }
+}
+
+/**
+ * ixgbe_enter_lplu_x550em - Transition to low power states
+ * @hw: pointer to hardware structure
+ *
+ * Configures Low Power Link Up on transition to low power states
+ * (from D0 to non-D0). Link is required to enter LPLU so avoid resetting the
+ * X557 PHY immediately prior to entering LPLU.
+ **/
+s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw)
+{
+ u16 an_10g_cntl_reg, autoneg_reg, speed;
+ s32 status;
+ ixgbe_link_speed lcd_speed;
+ u32 save_autoneg;
+ bool link_up;
+
+ /* If blocked by MNG FW, then don't restart AN */
+ if (ixgbe_check_reset_blocked(hw))
+ return IXGBE_SUCCESS;
+
+ status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ status = ixgbe_read_eeprom(hw, NVM_INIT_CTRL_3, &hw->eeprom.ctrl_word_3);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* If link is down, LPLU disabled in NVM, WoL disabled, or manageability
+ * disabled, then force link down by entering low power mode.
+ */
+ if (!link_up || !(hw->eeprom.ctrl_word_3 & NVM_INIT_CTRL_3_LPLU) ||
+ !(hw->wol_enabled || ixgbe_mng_present(hw)))
+ return ixgbe_set_copper_phy_power(hw, FALSE);
+
+ /* Determine LCD */
+ status = ixgbe_get_lcd_t_x550em(hw, &lcd_speed);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* If no valid LCD link speed, then force link down and exit. */
+ if (lcd_speed == IXGBE_LINK_SPEED_UNKNOWN)
+ return ixgbe_set_copper_phy_power(hw, FALSE);
+
+ status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_STAT,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+ &speed);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* If no link now, speed is invalid so take link down */
+ status = ixgbe_ext_phy_t_x550em_get_link(hw, &link_up);
+ if (status != IXGBE_SUCCESS)
+ return ixgbe_set_copper_phy_power(hw, FALSE);
+
+ /* clear everything but the speed bits */
+ speed &= IXGBE_MDIO_AUTO_NEG_VEN_STAT_SPEED_MASK;
+
+ /* If current speed is already LCD, then exit. */
+ if (((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_1GB) &&
+ (lcd_speed == IXGBE_LINK_SPEED_1GB_FULL)) ||
+ ((speed == IXGBE_MDIO_AUTO_NEG_VENDOR_STATUS_10GB) &&
+ (lcd_speed == IXGBE_LINK_SPEED_10GB_FULL)))
+ return status;
+
+ /* Clear AN completed indication */
+ status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_VENDOR_TX_ALARM,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+ &autoneg_reg);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ status = hw->phy.ops.read_reg(hw, IXGBE_MII_10GBASE_T_AUTONEG_CTRL_REG,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+ &an_10g_cntl_reg);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ status = hw->phy.ops.read_reg(hw,
+ IXGBE_MII_AUTONEG_VENDOR_PROVISION_1_REG,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+ &autoneg_reg);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ save_autoneg = hw->phy.autoneg_advertised;
+
+ /* Setup link at least common link speed */
+ status = hw->mac.ops.setup_link(hw, lcd_speed, FALSE);
+
+ /* restore autoneg from before setting lplu speed */
+ hw->phy.autoneg_advertised = save_autoneg;
+
+ return status;
+}
+
+/**
+ * ixgbe_get_lcd_x550em - Determine lowest common denominator
+ * @hw: pointer to hardware structure
+ * @lcd_speed: pointer to lowest common link speed
+ *
+ * Determine lowest common link speed with link partner.
+ **/
+s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *lcd_speed)
+{
+ u16 an_lp_status;
+ s32 status;
+ u16 word = hw->eeprom.ctrl_word_3;
+
+ *lcd_speed = IXGBE_LINK_SPEED_UNKNOWN;
+
+ status = hw->phy.ops.read_reg(hw, IXGBE_AUTO_NEG_LP_STATUS,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+ &an_lp_status);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* If link partner advertised 1G, return 1G */
+ if (an_lp_status & IXGBE_AUTO_NEG_LP_1000BASE_CAP) {
+ *lcd_speed = IXGBE_LINK_SPEED_1GB_FULL;
+ return status;
+ }
+
+ /* If 10G disabled for LPLU via NVM D10GMP, then return no valid LCD */
+ if ((hw->bus.lan_id && (word & NVM_INIT_CTRL_3_D10GMP_PORT1)) ||
+ (word & NVM_INIT_CTRL_3_D10GMP_PORT0))
+ return status;
+
+ /* Link partner not capable of lower speeds, return 10G */
+ *lcd_speed = IXGBE_LINK_SPEED_10GB_FULL;
+ return status;
+}
+
+/**
+ * ixgbe_setup_fc_X550em - Set up flow control
+ * @hw: pointer to hardware structure
+ *
+ * Called at init time to set up flow control.
+ **/
+s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
+{
+ s32 ret_val = IXGBE_SUCCESS;
+ u32 pause, asm_dir, reg_val;
+
+ DEBUGFUNC("ixgbe_setup_fc_X550em");
+
+ /* Validate the requested mode */
+ if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
+ ERROR_REPORT1(IXGBE_ERROR_UNSUPPORTED,
+ "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
+ ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
+ goto out;
+ }
+
+ /* 10gig parts do not have a word in the EEPROM to determine the
+ * default flow control setting, so we explicitly set it to full.
+ */
+ if (hw->fc.requested_mode == ixgbe_fc_default)
+ hw->fc.requested_mode = ixgbe_fc_full;
+
+ /* Determine PAUSE and ASM_DIR bits. */
+ switch (hw->fc.requested_mode) {
+ case ixgbe_fc_none:
+ pause = 0;
+ asm_dir = 0;
+ break;
+ case ixgbe_fc_tx_pause:
+ pause = 0;
+ asm_dir = 1;
+ break;
+ case ixgbe_fc_rx_pause:
+ /* Rx Flow control is enabled and Tx Flow control is
+ * disabled by software override. Since there really
+ * isn't a way to advertise that we are capable of RX
+ * Pause ONLY, we will advertise that we support both
+ * symmetric and asymmetric Rx PAUSE, as such we fall
+ * through to the fc_full statement. Later, we will
+ * disable the adapter's ability to send PAUSE frames.
+ */
+ case ixgbe_fc_full:
+ pause = 1;
+ asm_dir = 1;
+ break;
+ default:
+ ERROR_REPORT1(IXGBE_ERROR_ARGUMENT,
+ "Flow control param set incorrectly\n");
+ ret_val = IXGBE_ERR_CONFIG;
+ goto out;
+ }
+
+ if (hw->phy.media_type == ixgbe_media_type_backplane) {
+ ret_val = ixgbe_read_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, &reg_val);
+ if (ret_val != IXGBE_SUCCESS)
+ goto out;
+ reg_val &= ~(IXGBE_KRM_AN_CNTL_1_SYM_PAUSE |
+ IXGBE_KRM_AN_CNTL_1_ASM_PAUSE);
+ if (pause)
+ reg_val |= IXGBE_KRM_AN_CNTL_1_SYM_PAUSE;
+ if (asm_dir)
+ reg_val |= IXGBE_KRM_AN_CNTL_1_ASM_PAUSE;
+ ret_val = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+
+ /* Not all devices fully support AN. */
+ if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR)
+ hw->fc.disable_fc_autoneg = TRUE;
+ }
+
+out:
+ return ret_val;
+}
+
+/**
+ * ixgbe_set_mux - Set mux for port 1 access with CS4227
+ * @hw: pointer to hardware structure
+ * @state: set mux if 1, clear if 0
+ */
+static void ixgbe_set_mux(struct ixgbe_hw *hw, u8 state)
+{
+ u32 esdp;
+
+ if (!hw->bus.lan_id)
+ return;
+ esdp = IXGBE_READ_REG(hw, IXGBE_ESDP);
+ if (state)
+ esdp |= IXGBE_ESDP_SDP1;
+ else
+ esdp &= ~IXGBE_ESDP_SDP1;
+ IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp);
+ IXGBE_WRITE_FLUSH(hw);
+}
+
+/**
+ * ixgbe_acquire_swfw_sync_X550em - Acquire SWFW semaphore
+ * @hw: pointer to hardware structure
+ * @mask: Mask to specify which semaphore to acquire
+ *
+ * Acquires the SWFW semaphore and sets the I2C MUX
+ **/
+s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
+{
+ s32 status;
+
+ DEBUGFUNC("ixgbe_acquire_swfw_sync_X550em");
+
+ status = ixgbe_acquire_swfw_sync_X540(hw, mask);
+ if (status)
+ return status;
+
+ if (mask & IXGBE_GSSR_I2C_MASK)
+ ixgbe_set_mux(hw, 1);
+
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_release_swfw_sync_X550em - Release SWFW semaphore
+ * @hw: pointer to hardware structure
+ * @mask: Mask to specify which semaphore to release
+ *
+ * Releases the SWFW semaphore and sets the I2C MUX
+ **/
+void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
+{
+ DEBUGFUNC("ixgbe_release_swfw_sync_X550em");
+
+ if (mask & IXGBE_GSSR_I2C_MASK)
+ ixgbe_set_mux(hw, 0);
+
+ ixgbe_release_swfw_sync_X540(hw, mask);
+}
+
+/**
+ * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
+ * @hw: pointer to hardware structure
+ *
+ * Handle external Base T PHY interrupt. If high temperature
+ * failure alarm then return error, else if link status change
+ * then setup internal/external PHY link
+ *
+ * Return IXGBE_ERR_OVERTEMP if interrupt is high temperature
+ * failure alarm, else return PHY access status.
+ */
+s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw)
+{
+ bool lsc;
+ u32 status;
+
+ status = ixgbe_get_lasi_ext_t_x550em(hw, &lsc);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ if (lsc)
+ return ixgbe_setup_internal_phy(hw);
+
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_setup_mac_link_t_X550em - Sets the auto advertised link speed
+ * @hw: pointer to hardware structure
+ * @speed: new link speed
+ * @autoneg_wait_to_complete: TRUE when waiting for completion is needed
+ *
+ * Setup internal/external PHY link speed based on link speed, then set
+ * external PHY auto advertised link speed.
+ *
+ * Returns error status for any failure
+ **/
+s32 ixgbe_setup_mac_link_t_X550em(struct ixgbe_hw *hw,
+ ixgbe_link_speed speed,
+ bool autoneg_wait_to_complete)
+{
+ s32 status;
+ ixgbe_link_speed force_speed;
+
+ DEBUGFUNC("ixgbe_setup_mac_link_t_X550em");
+
+ /* Setup internal/external PHY link speed to iXFI (10G), unless
+ * only 1G is auto advertised then setup KX link.
+ */
+ if (speed & IXGBE_LINK_SPEED_10GB_FULL)
+ force_speed = IXGBE_LINK_SPEED_10GB_FULL;
+ else
+ force_speed = IXGBE_LINK_SPEED_1GB_FULL;
+
+ /* If internal link mode is XFI, then setup XFI internal link. */
+ if (!(hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE)) {
+ status = ixgbe_setup_ixfi_x550em(hw, &force_speed);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+ }
+
+ return hw->phy.ops.setup_link_speed(hw, speed, autoneg_wait_to_complete);
+}
+
+/**
+ * ixgbe_check_link_t_X550em - Determine link and speed status
+ * @hw: pointer to hardware structure
+ * @speed: pointer to link speed
+ * @link_up: TRUE when link is up
+ * @link_up_wait_to_complete: bool used to wait for link up or not
+ *
+ * Check that both the MAC and X557 external PHY have link.
+ **/
+s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
+ bool *link_up, bool link_up_wait_to_complete)
+{
+ u32 status;
+ u16 autoneg_status;
+
+ if (hw->mac.ops.get_media_type(hw) != ixgbe_media_type_copper)
+ return IXGBE_ERR_CONFIG;
+
+ status = ixgbe_check_mac_link_generic(hw, speed, link_up,
+ link_up_wait_to_complete);
+
+ /* If check link fails or MAC link is not up, then return */
+ if (status != IXGBE_SUCCESS || !(*link_up))
+ return status;
+
+ /* MAC link is up, so check external PHY link.
+ * Read this twice back to back to indicate current status.
+ */
+ status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+ &autoneg_status);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_STATUS,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+ &autoneg_status);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* If external PHY link is not up, then indicate link not up */
+ if (!(autoneg_status & IXGBE_MDIO_AUTO_NEG_LINK_STATUS))
+ *link_up = FALSE;
+
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_reset_phy_t_X550em - Performs X557 PHY reset and enables LASI
+ * @hw: pointer to hardware structure
+ **/
+s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw)
+{
+ s32 status;
+
+ status = ixgbe_reset_phy_generic(hw);
+
+ if (status != IXGBE_SUCCESS)
+ return status;
+
+ /* Configure Link Status Alarm and Temperature Threshold interrupts */
+ return ixgbe_enable_lasi_ext_t_x550em(hw);
+}
+
+/**
+ * ixgbe_led_on_t_X550em - Turns on the software controllable LEDs.
+ * @hw: pointer to hardware structure
+ * @led_idx: led number to turn on
+ **/
+s32 ixgbe_led_on_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
+{
+ u16 phy_data;
+
+ DEBUGFUNC("ixgbe_led_on_t_X550em");
+
+ if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
+ return IXGBE_ERR_PARAM;
+
+ /* To turn on the LED, set mode to ON. */
+ ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
+ phy_data |= IXGBE_X557_LED_MANUAL_SET_MASK;
+ ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
+
+ return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_led_off_t_X550em - Turns off the software controllable LEDs.
+ * @hw: pointer to hardware structure
+ * @led_idx: led number to turn off
+ **/
+s32 ixgbe_led_off_t_X550em(struct ixgbe_hw *hw, u32 led_idx)
+{
+ u16 phy_data;
+
+ DEBUGFUNC("ixgbe_led_off_t_X550em");
+
+ if (led_idx >= IXGBE_X557_MAX_LED_INDEX)
+ return IXGBE_ERR_PARAM;
+
+ /* To turn on the LED, set mode to ON. */
+ ixgbe_read_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, &phy_data);
+ phy_data &= ~IXGBE_X557_LED_MANUAL_SET_MASK;
+ ixgbe_write_phy_reg(hw, IXGBE_X557_LED_PROVISIONING + led_idx,
+ IXGBE_MDIO_VENDOR_SPECIFIC_1_DEV_TYPE, phy_data);
+
+ return IXGBE_SUCCESS;
+}
+
diff --git a/sys/dev/ixgbe/ixgbe_x550.h b/sys/dev/ixgbe/ixgbe_x550.h
new file mode 100644
index 0000000..8a544ec
--- /dev/null
+++ b/sys/dev/ixgbe/ixgbe_x550.h
@@ -0,0 +1,109 @@
+/******************************************************************************
+
+ Copyright (c) 2001-2015, Intel Corporation
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce 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 Intel Corporation nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED 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 OWNER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 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 _IXGBE_X550_H_
+#define _IXGBE_X550_H_
+
+#include "ixgbe_type.h"
+
+s32 ixgbe_dmac_config_X550(struct ixgbe_hw *hw);
+s32 ixgbe_dmac_config_tcs_X550(struct ixgbe_hw *hw);
+s32 ixgbe_dmac_update_tcs_X550(struct ixgbe_hw *hw);
+
+s32 ixgbe_get_bus_info_X550em(struct ixgbe_hw *hw);
+s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw);
+s32 ixgbe_update_eeprom_checksum_X550(struct ixgbe_hw *hw);
+s32 ixgbe_calc_eeprom_checksum_X550(struct ixgbe_hw *hw);
+s32 ixgbe_calc_checksum_X550(struct ixgbe_hw *hw, u16 *buffer, u32 buffer_size);
+s32 ixgbe_validate_eeprom_checksum_X550(struct ixgbe_hw *hw, u16 *checksum_val);
+s32 ixgbe_update_flash_X550(struct ixgbe_hw *hw);
+s32 ixgbe_write_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
+ u16 offset, u16 words, u16 *data);
+s32 ixgbe_write_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
+ u16 data);
+s32 ixgbe_read_ee_hostif_buffer_X550(struct ixgbe_hw *hw,
+ u16 offset, u16 words, u16 *data);
+s32 ixgbe_read_ee_hostif_X550(struct ixgbe_hw *hw, u16 offset,
+u16 *data);
+s32 ixgbe_read_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
+ u16 *data);
+s32 ixgbe_write_ee_hostif_data_X550(struct ixgbe_hw *hw, u16 offset,
+ u16 data);
+s32 ixgbe_set_eee_X550(struct ixgbe_hw *hw, bool enable_eee);
+s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool enable_eee);
+void ixgbe_set_source_address_pruning_X550(struct ixgbe_hw *hw, bool enable,
+ unsigned int pool);
+void ixgbe_set_ethertype_anti_spoofing_X550(struct ixgbe_hw *hw,
+ bool enable, int vf);
+s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
+ u32 device_type, u32 data);
+s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr,
+ u32 device_type, u32 *data);
+void ixgbe_disable_mdd_X550(struct ixgbe_hw *hw);
+void ixgbe_enable_mdd_X550(struct ixgbe_hw *hw);
+void ixgbe_mdd_event_X550(struct ixgbe_hw *hw, u32 *vf_bitmap);
+void ixgbe_restore_mdd_vf_X550(struct ixgbe_hw *hw, u32 vf);
+enum ixgbe_media_type ixgbe_get_media_type_X550em(struct ixgbe_hw *hw);
+s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw);
+s32 ixgbe_get_link_capabilities_X550em(struct ixgbe_hw *hw,
+ ixgbe_link_speed *speed, bool *autoneg);
+void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw);
+s32 ixgbe_reset_hw_X550em(struct ixgbe_hw *hw);
+s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw);
+s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw);
+s32 ixgbe_setup_kx4_x550em(struct ixgbe_hw *hw);
+s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw);
+s32 ixgbe_setup_internal_phy_t_x550em(struct ixgbe_hw *hw);
+s32 ixgbe_setup_phy_loopback_x550em(struct ixgbe_hw *hw);
+u32 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw);
+void ixgbe_disable_rx_x550(struct ixgbe_hw *hw);
+s32 ixgbe_get_lcd_t_x550em(struct ixgbe_hw *hw, ixgbe_link_speed *lcd_speed);
+s32 ixgbe_enter_lplu_t_x550em(struct ixgbe_hw *hw);
+s32 ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask);
+void ixgbe_release_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask);
+s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw);
+s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
+ ixgbe_link_speed speed,
+ bool autoneg_wait_to_complete);
+s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw);
+s32 ixgbe_setup_mac_link_t_X550em(struct ixgbe_hw *hw,
+ ixgbe_link_speed speed,
+ bool autoneg_wait_to_complete);
+s32 ixgbe_check_link_t_X550em(struct ixgbe_hw *hw, ixgbe_link_speed *speed,
+ bool *link_up, bool link_up_wait_to_complete);
+s32 ixgbe_reset_phy_t_X550em(struct ixgbe_hw *hw);
+s32 ixgbe_identify_sfp_module_X550em(struct ixgbe_hw *hw);
+s32 ixgbe_led_on_t_X550em(struct ixgbe_hw *hw, u32 led_idx);
+s32 ixgbe_led_off_t_X550em(struct ixgbe_hw *hw, u32 led_idx);
+#endif /* _IXGBE_X550_H_ */
diff --git a/sys/dev/ixl/i40e_adminq.c b/sys/dev/ixl/i40e_adminq.c
index d769c45..d769c45 100755..100644
--- a/sys/dev/ixl/i40e_adminq.c
+++ b/sys/dev/ixl/i40e_adminq.c
diff --git a/sys/dev/ixl/i40e_adminq.h b/sys/dev/ixl/i40e_adminq.h
index 9db4c9d..9db4c9d 100755..100644
--- a/sys/dev/ixl/i40e_adminq.h
+++ b/sys/dev/ixl/i40e_adminq.h
diff --git a/sys/dev/ixl/i40e_adminq_cmd.h b/sys/dev/ixl/i40e_adminq_cmd.h
index 0d52883..0d52883 100755..100644
--- a/sys/dev/ixl/i40e_adminq_cmd.h
+++ b/sys/dev/ixl/i40e_adminq_cmd.h
diff --git a/sys/dev/ixl/i40e_alloc.h b/sys/dev/ixl/i40e_alloc.h
index dc6fadd..dc6fadd 100755..100644
--- a/sys/dev/ixl/i40e_alloc.h
+++ b/sys/dev/ixl/i40e_alloc.h
diff --git a/sys/dev/ixl/i40e_common.c b/sys/dev/ixl/i40e_common.c
index 777ecef..777ecef 100755..100644
--- a/sys/dev/ixl/i40e_common.c
+++ b/sys/dev/ixl/i40e_common.c
diff --git a/sys/dev/ixl/i40e_hmc.c b/sys/dev/ixl/i40e_hmc.c
index 81cb2ae..81cb2ae 100755..100644
--- a/sys/dev/ixl/i40e_hmc.c
+++ b/sys/dev/ixl/i40e_hmc.c
diff --git a/sys/dev/ixl/i40e_hmc.h b/sys/dev/ixl/i40e_hmc.h
index cba325f..cba325f 100755..100644
--- a/sys/dev/ixl/i40e_hmc.h
+++ b/sys/dev/ixl/i40e_hmc.h
diff --git a/sys/dev/ixl/i40e_lan_hmc.c b/sys/dev/ixl/i40e_lan_hmc.c
index 0866ad1..0866ad1 100755..100644
--- a/sys/dev/ixl/i40e_lan_hmc.c
+++ b/sys/dev/ixl/i40e_lan_hmc.c
diff --git a/sys/dev/ixl/i40e_lan_hmc.h b/sys/dev/ixl/i40e_lan_hmc.h
index 8b73570..8b73570 100755..100644
--- a/sys/dev/ixl/i40e_lan_hmc.h
+++ b/sys/dev/ixl/i40e_lan_hmc.h
diff --git a/sys/dev/ixl/i40e_nvm.c b/sys/dev/ixl/i40e_nvm.c
index 35001a5..35001a5 100755..100644
--- a/sys/dev/ixl/i40e_nvm.c
+++ b/sys/dev/ixl/i40e_nvm.c
diff --git a/sys/dev/ixl/i40e_osdep.c b/sys/dev/ixl/i40e_osdep.c
index b29db64..b29db64 100755..100644
--- a/sys/dev/ixl/i40e_osdep.c
+++ b/sys/dev/ixl/i40e_osdep.c
diff --git a/sys/dev/ixl/i40e_osdep.h b/sys/dev/ixl/i40e_osdep.h
index 83e8922..83e8922 100755..100644
--- a/sys/dev/ixl/i40e_osdep.h
+++ b/sys/dev/ixl/i40e_osdep.h
diff --git a/sys/dev/ixl/i40e_prototype.h b/sys/dev/ixl/i40e_prototype.h
index d49b52d..d49b52d 100755..100644
--- a/sys/dev/ixl/i40e_prototype.h
+++ b/sys/dev/ixl/i40e_prototype.h
diff --git a/sys/dev/ixl/i40e_register.h b/sys/dev/ixl/i40e_register.h
index a8e47b3..a8e47b3 100755..100644
--- a/sys/dev/ixl/i40e_register.h
+++ b/sys/dev/ixl/i40e_register.h
diff --git a/sys/dev/ixl/i40e_status.h b/sys/dev/ixl/i40e_status.h
index 24d5e6b..24d5e6b 100755..100644
--- a/sys/dev/ixl/i40e_status.h
+++ b/sys/dev/ixl/i40e_status.h
diff --git a/sys/dev/ixl/i40e_type.h b/sys/dev/ixl/i40e_type.h
index 1de747d..1de747d 100755..100644
--- a/sys/dev/ixl/i40e_type.h
+++ b/sys/dev/ixl/i40e_type.h
diff --git a/sys/dev/ixl/i40e_virtchnl.h b/sys/dev/ixl/i40e_virtchnl.h
index 5a5e8f3..5a5e8f3 100755..100644
--- a/sys/dev/ixl/i40e_virtchnl.h
+++ b/sys/dev/ixl/i40e_virtchnl.h
diff --git a/sys/dev/ixl/if_ixl.c b/sys/dev/ixl/if_ixl.c
index de4ee24..de4ee24 100755..100644
--- a/sys/dev/ixl/if_ixl.c
+++ b/sys/dev/ixl/if_ixl.c
diff --git a/sys/dev/ixl/if_ixlv.c b/sys/dev/ixl/if_ixlv.c
index a9ee127..fe4c63f 100644
--- a/sys/dev/ixl/if_ixlv.c
+++ b/sys/dev/ixl/if_ixlv.c
@@ -1693,7 +1693,6 @@ ixlv_setup_queues(struct ixlv_sc *sc)
return (0);
fail:
- free(vsi->queues, M_DEVBUF);
for (int i = 0; i < vsi->num_queues; i++) {
que = &vsi->queues[i];
rxr = &que->rxr;
@@ -1703,6 +1702,7 @@ fail:
if (txr->base)
i40e_free_dma_mem(&sc->hw, &txr->dma);
}
+ free(vsi->queues, M_DEVBUF);
early:
return (error);
diff --git a/sys/dev/ixl/ixl.h b/sys/dev/ixl/ixl.h
index df8f04f..1ddfbca3 100644
--- a/sys/dev/ixl/ixl.h
+++ b/sys/dev/ixl/ixl.h
@@ -324,7 +324,7 @@
#define IXL_SET_IMCASTS(vsi, count) (vsi)->imcasts = (count)
#define IXL_SET_OMCASTS(vsi, count) (vsi)->omcasts = (count)
#define IXL_SET_IQDROPS(vsi, count) (vsi)->iqdrops = (count)
-#define IXL_SET_OQDROPS(vsi, count) (vsi)->iqdrops = (count)
+#define IXL_SET_OQDROPS(vsi, count) (vsi)->oqdrops = (count)
#define IXL_SET_NOPROTO(vsi, count) (vsi)->noproto = (count)
#else
#define IXL_SET_IPACKETS(vsi, count) (vsi)->ifp->if_ipackets = (count)
diff --git a/sys/dev/ixl/ixl_txrx.c b/sys/dev/ixl/ixl_txrx.c
index 43a1949..43a1949 100755..100644
--- a/sys/dev/ixl/ixl_txrx.c
+++ b/sys/dev/ixl/ixl_txrx.c
diff --git a/sys/dev/mfi/mfi.c b/sys/dev/mfi/mfi.c
index 5ec813e..a2d604c 100644
--- a/sys/dev/mfi/mfi.c
+++ b/sys/dev/mfi/mfi.c
@@ -780,7 +780,7 @@ mfi_attach(struct mfi_softc *sc)
bus_generic_attach(sc->mfi_dev);
/* Start the timeout watchdog */
- callout_init(&sc->mfi_watchdog_callout, CALLOUT_MPSAFE);
+ callout_init(&sc->mfi_watchdog_callout, 1);
callout_reset(&sc->mfi_watchdog_callout, mfi_cmd_timeout * hz,
mfi_timeout, sc);
diff --git a/sys/dev/mmc/mmc.c b/sys/dev/mmc/mmc.c
index d623870..a61da44 100644
--- a/sys/dev/mmc/mmc.c
+++ b/sys/dev/mmc/mmc.c
@@ -1379,6 +1379,20 @@ mmc_discover_cards(struct mmc_softc *sc)
ivar->hs_tran_speed = SD_MAX_HS;
}
}
+
+ /*
+ * We reselect the card here. Some cards become
+ * unselected and timeout with the above two commands,
+ * although the state tables / diagrams in the standard
+ * suggest they go back to the transfer state. The only
+ * thing we use from the sd_status is the erase sector
+ * size, but it is still nice to get that right. It is
+ * normally harmless for cards not misbehaving. The
+ * Atmel bridge will complain about this command timing
+ * out. Others seem to handle it correctly, so it may
+ * be a combination of card and controller.
+ */
+ mmc_select_card(sc, ivar->rca);
mmc_app_sd_status(sc, ivar->rca, ivar->raw_sd_status);
mmc_app_decode_sd_status(ivar->raw_sd_status,
&ivar->sd_status);
@@ -1797,6 +1811,7 @@ static driver_t mmc_driver = {
};
static devclass_t mmc_devclass;
+DRIVER_MODULE(mmc, a10_mmc, mmc_driver, mmc_devclass, NULL, NULL);
DRIVER_MODULE(mmc, aml8726_mmc, mmc_driver, mmc_devclass, NULL, NULL);
DRIVER_MODULE(mmc, aml8726_sdxc, mmc_driver, mmc_devclass, NULL, NULL);
DRIVER_MODULE(mmc, at91_mci, mmc_driver, mmc_devclass, NULL, NULL);
@@ -1807,4 +1822,3 @@ DRIVER_MODULE(mmc, sdhci_pci, mmc_driver, mmc_devclass, NULL, NULL);
DRIVER_MODULE(mmc, sdhci_ti, mmc_driver, mmc_devclass, NULL, NULL);
DRIVER_MODULE(mmc, ti_mmchs, mmc_driver, mmc_devclass, NULL, NULL);
DRIVER_MODULE(mmc, dwmmc, mmc_driver, mmc_devclass, NULL, NULL);
-
diff --git a/sys/dev/mrsas/mrsas.c b/sys/dev/mrsas/mrsas.c
index 1fa94f1..6f63c6e 100644
--- a/sys/dev/mrsas/mrsas.c
+++ b/sys/dev/mrsas/mrsas.c
@@ -1,6 +1,7 @@
/*
+ * Copyright (c) 2015, AVAGO Tech. All rights reserved. Author: Marian Choy
* Copyright (c) 2014, LSI Corp. All rights reserved. Author: Marian Choy
- * Support: freebsdraid@lsi.com
+ * Support: freebsdraid@avagotech.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -31,7 +32,7 @@
* those of the authors and should not be interpreted as representing
* official policies,either expressed or implied, of the FreeBSD Project.
*
- * Send feedback to: <megaraidfbsd@lsi.com> Mail to: LSI Corporation, 1621
+ * Send feedback to: <megaraidfbsd@avagotech.com> Mail to: AVAGO TECHNOLOGIES 1621
* Barber Lane, Milpitas, CA 95035 ATTN: MegaRaid FreeBSD
*
*/
@@ -81,16 +82,19 @@ static int mrsas_init_fw(struct mrsas_softc *sc);
static int mrsas_setup_raidmap(struct mrsas_softc *sc);
static int mrsas_complete_cmd(struct mrsas_softc *sc, u_int32_t MSIxIndex);
static int mrsas_clear_intr(struct mrsas_softc *sc);
-static int
-mrsas_get_ctrl_info(struct mrsas_softc *sc,
- struct mrsas_ctrl_info *ctrl_info);
-static int
+static int mrsas_get_ctrl_info(struct mrsas_softc *sc);
+static void mrsas_update_ext_vd_details(struct mrsas_softc *sc);
+static int
mrsas_issue_blocked_abort_cmd(struct mrsas_softc *sc,
struct mrsas_mfi_cmd *cmd_to_abort);
+static struct mrsas_softc *
+mrsas_get_softc_instance(struct cdev *dev,
+ u_long cmd, caddr_t arg);
u_int32_t mrsas_read_reg(struct mrsas_softc *sc, int offset);
-u_int8_t
+u_int8_t
mrsas_build_mptmfi_passthru(struct mrsas_softc *sc,
struct mrsas_mfi_cmd *mfi_cmd);
+void mrsas_complete_outstanding_ioctls(struct mrsas_softc *sc);
int mrsas_transition_to_ready(struct mrsas_softc *sc, int ocr);
int mrsas_init_adapter(struct mrsas_softc *sc);
int mrsas_alloc_mpt_cmds(struct mrsas_softc *sc);
@@ -102,10 +106,10 @@ int mrsas_issue_dcmd(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd);
int mrsas_issue_polled(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd);
int mrsas_reset_ctrl(struct mrsas_softc *sc);
int mrsas_wait_for_outstanding(struct mrsas_softc *sc);
-int
+int
mrsas_issue_blocked_cmd(struct mrsas_softc *sc,
struct mrsas_mfi_cmd *cmd);
-int
+int
mrsas_alloc_tmp_dcmd(struct mrsas_softc *sc, struct mrsas_tmp_dcmd *tcmd,
int size);
void mrsas_release_mfi_cmd(struct mrsas_mfi_cmd *cmd);
@@ -122,17 +126,17 @@ void mrsas_teardown_intr(struct mrsas_softc *sc);
void mrsas_addr_cb(void *arg, bus_dma_segment_t *segs, int nsegs, int error);
void mrsas_kill_hba(struct mrsas_softc *sc);
void mrsas_aen_handler(struct mrsas_softc *sc);
-void
+void
mrsas_write_reg(struct mrsas_softc *sc, int offset,
u_int32_t value);
-void
+void
mrsas_fire_cmd(struct mrsas_softc *sc, u_int32_t req_desc_lo,
u_int32_t req_desc_hi);
void mrsas_free_ctlr_info_cmd(struct mrsas_softc *sc);
-void
+void
mrsas_complete_mptmfi_passthru(struct mrsas_softc *sc,
struct mrsas_mfi_cmd *cmd, u_int8_t status);
-void
+void
mrsas_map_mpt_cmd_status(struct mrsas_mpt_cmd *cmd, u_int8_t status,
u_int8_t extStatus);
struct mrsas_mfi_cmd *mrsas_get_mfi_cmd(struct mrsas_softc *sc);
@@ -175,9 +179,9 @@ typedef struct mrsas_ident {
} MRSAS_CTLR_ID;
MRSAS_CTLR_ID device_table[] = {
- {0x1000, MRSAS_TBOLT, 0xffff, 0xffff, "LSI Thunderbolt SAS Controller"},
- {0x1000, MRSAS_INVADER, 0xffff, 0xffff, "LSI Invader SAS Controller"},
- {0x1000, MRSAS_FURY, 0xffff, 0xffff, "LSI Fury SAS Controller"},
+ {0x1000, MRSAS_TBOLT, 0xffff, 0xffff, "AVAGO Thunderbolt SAS Controller"},
+ {0x1000, MRSAS_INVADER, 0xffff, 0xffff, "AVAGO Invader SAS Controller"},
+ {0x1000, MRSAS_FURY, 0xffff, 0xffff, "AVAGO Fury SAS Controller"},
{0, 0, 0, 0, NULL}
};
@@ -272,6 +276,7 @@ mrsas_disable_intr(struct mrsas_softc *sc)
u_int32_t mask = 0xFFFFFFFF;
u_int32_t status;
+ sc->mask_interrupts = 1;
mrsas_write_reg(sc, offsetof(mrsas_reg_set, outbound_intr_mask), mask);
/* Dummy read to force pci flush */
status = mrsas_read_reg(sc, offsetof(mrsas_reg_set, outbound_intr_mask));
@@ -283,6 +288,7 @@ mrsas_enable_intr(struct mrsas_softc *sc)
u_int32_t mask = MFI_FUSION_ENABLE_INTERRUPT_MASK;
u_int32_t status;
+ sc->mask_interrupts = 0;
mrsas_write_reg(sc, offsetof(mrsas_reg_set, outbound_intr_status), ~0);
status = mrsas_read_reg(sc, offsetof(mrsas_reg_set, outbound_intr_status));
@@ -352,7 +358,7 @@ mrsas_probe(device_t dev)
if ((id = mrsas_find_ident(dev)) != NULL) {
if (first_ctrl) {
- printf("LSI MegaRAID SAS FreeBSD mrsas driver version: %s\n",
+ printf("AVAGO MegaRAID SAS FreeBSD mrsas driver version: %s\n",
MRSAS_VERSION);
first_ctrl = 0;
}
@@ -460,6 +466,11 @@ mrsas_get_tunables(struct mrsas_softc *sc)
*/
TUNABLE_INT_FETCH("hw.mrsas.debug_level", &sc->mrsas_debug);
+ /*
+ * Grab the global variables.
+ */
+ TUNABLE_INT_FETCH("hw.mrsas.lb_pending_cmds", &sc->lb_pending_cmds);
+
/* Grab the unit-instance variables */
snprintf(tmpstr, sizeof(tmpstr), "dev.mrsas.%d.debug_level",
device_get_unit(sc->mrsas_dev));
@@ -1163,6 +1174,12 @@ mrsas_free_mem(struct mrsas_softc *sc)
*/
if (sc->mrsas_parent_tag != NULL)
bus_dma_tag_destroy(sc->mrsas_parent_tag);
+
+ /*
+ * Free ctrl_info memory
+ */
+ if (sc->ctrl_info != NULL)
+ free(sc->ctrl_info, M_MRSAS);
}
/*
@@ -1231,6 +1248,43 @@ mrsas_resume(device_t dev)
return (0);
}
+/**
+ * mrsas_get_softc_instance: Find softc instance based on cmd type
+ *
+ * This function will return softc instance based on cmd type.
+ * In some case, application fire ioctl on required management instance and
+ * do not provide host_no. Use cdev->si_drv1 to get softc instance for those
+ * case, else get the softc instance from host_no provided by application in
+ * user data.
+ */
+
+static struct mrsas_softc *
+mrsas_get_softc_instance(struct cdev *dev, u_long cmd, caddr_t arg)
+{
+ struct mrsas_softc *sc = NULL;
+ struct mrsas_iocpacket *user_ioc = (struct mrsas_iocpacket *)arg;
+
+ if (cmd == MRSAS_IOC_GET_PCI_INFO) {
+ sc = dev->si_drv1;
+ } else {
+ /*
+ * get the Host number & the softc from data sent by the
+ * Application
+ */
+ sc = mrsas_mgmt_info.sc_ptr[user_ioc->host_no];
+ if ((user_ioc->host_no >= mrsas_mgmt_info.max_index) || (sc == NULL)) {
+ if (sc == NULL)
+ mrsas_dprint(sc, MRSAS_FAULT,
+ "There is no Controller number %d .\n", user_ioc->host_no);
+ else
+ mrsas_dprint(sc, MRSAS_FAULT,
+ "Invalid Controller number %d .\n", user_ioc->host_no);
+ }
+ }
+
+ return sc;
+}
+
/*
* mrsas_ioctl: IOCtl commands entry point.
*
@@ -1243,19 +1297,12 @@ mrsas_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag,
{
struct mrsas_softc *sc;
int ret = 0, i = 0;
+ MRSAS_DRV_PCI_INFORMATION *pciDrvInfo;
- struct mrsas_iocpacket *user_ioc = (struct mrsas_iocpacket *)arg;
-
- /* get the Host number & the softc from data sent by the Application */
- sc = mrsas_mgmt_info.sc_ptr[user_ioc->host_no];
-
- if ((mrsas_mgmt_info.max_index == user_ioc->host_no) || (sc == NULL)) {
- printf("Please check the controller number\n");
- if (sc == NULL)
- printf("There is NO such Host no. %d\n", user_ioc->host_no);
-
+ sc = mrsas_get_softc_instance(dev, cmd, arg);
+ if (!sc)
return ENOENT;
- }
+
if (sc->remove_in_progress) {
mrsas_dprint(sc, MRSAS_INFO,
"Driver remove or shutdown called.\n");
@@ -1299,6 +1346,22 @@ do_ioctl:
case MRSAS_IOC_SCAN_BUS:
ret = mrsas_bus_scan(sc);
break;
+
+ case MRSAS_IOC_GET_PCI_INFO:
+ pciDrvInfo = (MRSAS_DRV_PCI_INFORMATION *) arg;
+ memset(pciDrvInfo, 0, sizeof(MRSAS_DRV_PCI_INFORMATION));
+ pciDrvInfo->busNumber = pci_get_bus(sc->mrsas_dev);
+ pciDrvInfo->deviceNumber = pci_get_slot(sc->mrsas_dev);
+ pciDrvInfo->functionNumber = pci_get_function(sc->mrsas_dev);
+ pciDrvInfo->domainID = pci_get_domain(sc->mrsas_dev);
+ mrsas_dprint(sc, MRSAS_INFO, "pci bus no: %d,"
+ "pci device no: %d, pci function no: %d,"
+ "pci domain ID: %d\n",
+ pciDrvInfo->busNumber, pciDrvInfo->deviceNumber,
+ pciDrvInfo->functionNumber, pciDrvInfo->domainID);
+ ret = 0;
+ break;
+
default:
mrsas_dprint(sc, MRSAS_TRACE, "IOCTL command 0x%lx is not handled\n", cmd);
ret = ENOENT;
@@ -1328,8 +1391,10 @@ mrsas_poll(struct cdev *dev, int poll_events, struct thread *td)
}
if (revents == 0) {
if (poll_events & (POLLIN | POLLRDNORM)) {
+ mtx_lock(&sc->aen_lock);
sc->mrsas_poll_waiting = 1;
selrecord(td, &sc->mrsas_select);
+ mtx_unlock(&sc->aen_lock);
}
}
return revents;
@@ -1387,6 +1452,9 @@ mrsas_isr(void *arg)
struct mrsas_softc *sc = irq_context->sc;
int status = 0;
+ if (sc->mask_interrupts)
+ return;
+
if (!sc->msix_vectors) {
status = mrsas_clear_intr(sc);
if (!status)
@@ -1424,7 +1492,7 @@ mrsas_complete_cmd(struct mrsas_softc *sc, u_int32_t MSIxIndex)
MRSAS_RAID_SCSI_IO_REQUEST *scsi_io_req;
struct mrsas_mpt_cmd *cmd_mpt;
struct mrsas_mfi_cmd *cmd_mfi;
- u_int8_t arm, reply_descript_type;
+ u_int8_t reply_descript_type;
u_int16_t smid, num_completed;
u_int8_t status, extStatus;
union desc_value desc_val;
@@ -1462,8 +1530,7 @@ mrsas_complete_cmd(struct mrsas_softc *sc, u_int32_t MSIxIndex)
device_id = cmd_mpt->ccb_ptr->ccb_h.target_id;
lbinfo = &sc->load_balance_info[device_id];
if (cmd_mpt->load_balance == MRSAS_LOAD_BALANCE_FLAG) {
- arm = lbinfo->raid1DevHandle[0] == scsi_io_req->DevHandle ? 0 : 1;
- mrsas_atomic_dec(&lbinfo->scsi_pending_cmds[arm]);
+ mrsas_atomic_dec(&lbinfo->scsi_pending_cmds[cmd_mpt->pd_r1_lb]);
cmd_mpt->load_balance &= ~MRSAS_LOAD_BALANCE_FLAG;
}
/* Fall thru and complete IO */
@@ -1608,8 +1675,8 @@ mrsas_map_mpt_cmd_status(struct mrsas_mpt_cmd *cmd, u_int8_t status, u_int8_t ex
static int
mrsas_alloc_mem(struct mrsas_softc *sc)
{
- u_int32_t verbuf_size, io_req_size, reply_desc_size, sense_size, chain_frame_size,
- evt_detail_size, count;
+ u_int32_t verbuf_size, io_req_size, reply_desc_size, sense_size,
+ chain_frame_size, evt_detail_size, count;
/*
* Allocate parent DMA tag
@@ -1861,34 +1928,6 @@ mrsas_setup_raidmap(struct mrsas_softc *sc)
{
int i;
- sc->drv_supported_vd_count =
- MRSAS_MAX_LD_CHANNELS * MRSAS_MAX_DEV_PER_CHANNEL;
- sc->drv_supported_pd_count =
- MRSAS_MAX_PD_CHANNELS * MRSAS_MAX_DEV_PER_CHANNEL;
-
- if (sc->max256vdSupport) {
- sc->fw_supported_vd_count = MAX_LOGICAL_DRIVES_EXT;
- sc->fw_supported_pd_count = MAX_PHYSICAL_DEVICES;
- } else {
- sc->fw_supported_vd_count = MAX_LOGICAL_DRIVES;
- sc->fw_supported_pd_count = MAX_PHYSICAL_DEVICES;
- }
-
-#if VD_EXT_DEBUG
- device_printf(sc->mrsas_dev, "FW supports: max256vdSupport = %s\n",
- sc->max256vdSupport ? "YES" : "NO");
- device_printf(sc->mrsas_dev, "FW supports %dVDs %dPDs\n"
- "DRIVER supports %dVDs %dPDs \n",
- sc->fw_supported_vd_count, sc->fw_supported_pd_count,
- sc->drv_supported_vd_count, sc->drv_supported_pd_count);
-#endif
-
- sc->old_map_sz = sizeof(MR_FW_RAID_MAP) +
- (sizeof(MR_LD_SPAN_MAP) * (sc->fw_supported_vd_count - 1));
- sc->new_map_sz = sizeof(MR_FW_RAID_MAP_EXT);
- sc->drv_map_sz = sizeof(MR_DRV_RAID_MAP) +
- (sizeof(MR_LD_SPAN_MAP) * (sc->drv_supported_vd_count - 1));
-
for (i = 0; i < 2; i++) {
sc->ld_drv_map[i] =
(void *)malloc(sc->drv_map_sz, M_MRSAS, M_NOWAIT);
@@ -1903,14 +1942,6 @@ mrsas_setup_raidmap(struct mrsas_softc *sc)
}
}
- sc->max_map_sz = max(sc->old_map_sz, sc->new_map_sz);
-
- if (sc->max256vdSupport)
- sc->current_map_sz = sc->new_map_sz;
- else
- sc->current_map_sz = sc->old_map_sz;
-
-
for (int i = 0; i < 2; i++) {
if (bus_dma_tag_create(sc->mrsas_parent_tag,
4, 0,
@@ -1970,7 +2001,7 @@ ABORT:
* get_pdlist, get_ld_list and max_sectors are currently not being used, it
* is left here as placeholder.
*/
-static int
+static int
mrsas_init_fw(struct mrsas_softc *sc)
{
@@ -1978,7 +2009,6 @@ mrsas_init_fw(struct mrsas_softc *sc)
u_int32_t max_sectors_1;
u_int32_t max_sectors_2;
u_int32_t tmp_sectors;
- struct mrsas_ctrl_info *ctrl_info;
u_int32_t scratch_pad_2;
int msix_enable = 0;
int fw_msix_count = 0;
@@ -2040,23 +2070,25 @@ mrsas_init_fw(struct mrsas_softc *sc)
device_printf(sc->mrsas_dev, "Allocate MFI cmd failed.\n");
return (1);
}
+ sc->ctrl_info = malloc(sizeof(struct mrsas_ctrl_info), M_MRSAS, M_NOWAIT);
+ if (!sc->ctrl_info) {
+ device_printf(sc->mrsas_dev, "Malloc for ctrl_info failed.\n");
+ return (1);
+ }
/*
* Get the controller info from FW, so that the MAX VD support
* availability can be decided.
*/
- ctrl_info = malloc(sizeof(struct mrsas_ctrl_info), M_MRSAS, M_NOWAIT);
- if (!ctrl_info)
- device_printf(sc->mrsas_dev, "Malloc for ctrl_info failed.\n");
-
- if (mrsas_get_ctrl_info(sc, ctrl_info)) {
+ if (mrsas_get_ctrl_info(sc)) {
device_printf(sc->mrsas_dev, "Unable to get FW ctrl_info.\n");
+ return (1);
}
- sc->max256vdSupport =
- (u_int8_t)ctrl_info->adapterOperations3.supportMaxExtLDs;
+ sc->secure_jbod_support =
+ (u_int8_t)sc->ctrl_info->adapterOperations3.supportSecurityonJBOD;
+
+ if (sc->secure_jbod_support)
+ device_printf(sc->mrsas_dev, "FW supports SED \n");
- if (ctrl_info->max_lds > 64) {
- sc->max256vdSupport = 1;
- }
if (mrsas_setup_raidmap(sc) != SUCCESS) {
device_printf(sc->mrsas_dev, "Set up RAID map failed.\n");
return (1);
@@ -2080,9 +2112,9 @@ mrsas_init_fw(struct mrsas_softc *sc)
* calculate max_sectors_1. So the number ended up as zero always.
*/
tmp_sectors = 0;
- max_sectors_1 = (1 << ctrl_info->stripe_sz_ops.min) *
- ctrl_info->max_strips_per_io;
- max_sectors_2 = ctrl_info->max_request_size;
+ max_sectors_1 = (1 << sc->ctrl_info->stripe_sz_ops.min) *
+ sc->ctrl_info->max_strips_per_io;
+ max_sectors_2 = sc->ctrl_info->max_request_size;
tmp_sectors = min(max_sectors_1, max_sectors_2);
sc->max_sectors_per_req = sc->max_num_sge * MRSAS_PAGE_SIZE / 512;
@@ -2090,9 +2122,9 @@ mrsas_init_fw(struct mrsas_softc *sc)
sc->max_sectors_per_req = tmp_sectors;
sc->disableOnlineCtrlReset =
- ctrl_info->properties.OnOffProperties.disableOnlineCtrlReset;
+ sc->ctrl_info->properties.OnOffProperties.disableOnlineCtrlReset;
sc->UnevenSpanSupport =
- ctrl_info->adapterOperations2.supportUnevenSpans;
+ sc->ctrl_info->adapterOperations2.supportUnevenSpans;
if (sc->UnevenSpanSupport) {
device_printf(sc->mrsas_dev, "FW supports: UnevenSpanSupport=%x\n\n",
sc->UnevenSpanSupport);
@@ -2102,9 +2134,6 @@ mrsas_init_fw(struct mrsas_softc *sc)
else
sc->fast_path_io = 0;
}
- if (ctrl_info)
- free(ctrl_info, M_MRSAS);
-
return (0);
}
@@ -2136,7 +2165,7 @@ mrsas_init_adapter(struct mrsas_softc *sc)
max_cmd = sc->max_fw_cmds;
/* Determine allocation size of command frames */
- sc->reply_q_depth = ((max_cmd + 1 + 15) / 16 * 16);
+ sc->reply_q_depth = ((max_cmd + 1 + 15) / 16 * 16) * 2;
sc->request_alloc_sz = sizeof(MRSAS_REQUEST_DESCRIPTOR_UNION) * max_cmd;
sc->reply_alloc_sz = sizeof(MPI2_REPLY_DESCRIPTORS_UNION) * (sc->reply_q_depth);
sc->io_frames_alloc_sz = MRSAS_MPI2_RAID_DEFAULT_IO_FRAME_SIZE + (MRSAS_MPI2_RAID_DEFAULT_IO_FRAME_SIZE * (max_cmd + 1));
@@ -2281,7 +2310,9 @@ mrsas_ioc_init(struct mrsas_softc *sc)
init_frame->driver_ver_lo = (bus_addr_t)sc->verbuf_phys_addr;
init_frame->driver_ver_hi = 0;
}
+ init_frame->driver_operations.mfi_capabilities.support_ndrive_r1_lb = 1;
init_frame->driver_operations.mfi_capabilities.support_max_255lds = 1;
+ init_frame->driver_operations.mfi_capabilities.security_protocol_cmds_fw = 1;
phys_addr = (bus_addr_t)sc->ioc_init_phys_mem + 1024;
init_frame->queue_info_new_phys_addr_lo = phys_addr;
init_frame->data_xfer_len = sizeof(Mpi2IOCInitRequest_t);
@@ -2423,7 +2454,7 @@ mrsas_alloc_mpt_cmds(struct mrsas_softc *sc)
* This functions fires the command to Firmware by writing to the
* inbound_low_queue_port and inbound_high_queue_port.
*/
-void
+void
mrsas_fire_cmd(struct mrsas_softc *sc, u_int32_t req_desc_lo,
u_int32_t req_desc_hi)
{
@@ -2703,7 +2734,6 @@ mrsas_reset_ctrl(struct mrsas_softc *sc)
/* Reset not supported, kill adapter */
mrsas_dprint(sc, MRSAS_OCR, "Reset not supported, killing adapter.\n");
mrsas_kill_hba(sc);
- sc->adprecovery = MRSAS_HW_CRITICAL_ERROR;
retval = FAIL;
goto out;
}
@@ -2788,10 +2818,6 @@ mrsas_reset_ctrl(struct mrsas_softc *sc)
mrsas_dprint(sc, MRSAS_OCR, "mrsas_ioc_init() failed!\n");
continue;
}
- mrsas_clear_bit(MRSAS_FUSION_IN_RESET, &sc->reset_flags);
- mrsas_enable_intr(sc);
- sc->adprecovery = MRSAS_HBA_OPERATIONAL;
-
/* Re-fire management commands */
for (j = 0; j < sc->max_fw_cmds; j++) {
mpt_cmd = sc->mpt_cmd_list[j];
@@ -2821,9 +2847,18 @@ mrsas_reset_ctrl(struct mrsas_softc *sc)
memset(sc->load_balance_info, 0,
sizeof(LD_LOAD_BALANCE_INFO) * MAX_LOGICAL_DRIVES_EXT);
+ if (mrsas_get_ctrl_info(sc)) {
+ mrsas_kill_hba(sc);
+ retval = FAIL;
+ goto out;
+ }
if (!mrsas_get_map_info(sc))
mrsas_sync_map_info(sc);
+ mrsas_clear_bit(MRSAS_FUSION_IN_RESET, &sc->reset_flags);
+ mrsas_enable_intr(sc);
+ sc->adprecovery = MRSAS_HBA_OPERATIONAL;
+
/* Adapter reset completed successfully */
device_printf(sc->mrsas_dev, "Reset successful\n");
retval = SUCCESS;
@@ -2854,11 +2889,43 @@ out:
void
mrsas_kill_hba(struct mrsas_softc *sc)
{
+ sc->adprecovery = MRSAS_HW_CRITICAL_ERROR;
+ pause("mrsas_kill_hba", 1000);
mrsas_dprint(sc, MRSAS_OCR, "%s\n", __func__);
mrsas_write_reg(sc, offsetof(mrsas_reg_set, doorbell),
MFI_STOP_ADP);
/* Flush */
mrsas_read_reg(sc, offsetof(mrsas_reg_set, doorbell));
+ mrsas_complete_outstanding_ioctls(sc);
+}
+
+/**
+ * mrsas_complete_outstanding_ioctls Complete pending IOCTLS after kill_hba
+ * input: Controller softc
+ *
+ * Returns void
+ */
+void
+mrsas_complete_outstanding_ioctls(struct mrsas_softc *sc)
+{
+ int i;
+ struct mrsas_mpt_cmd *cmd_mpt;
+ struct mrsas_mfi_cmd *cmd_mfi;
+ u_int32_t count, MSIxIndex;
+
+ count = sc->msix_vectors > 0 ? sc->msix_vectors : 1;
+ for (i = 0; i < sc->max_fw_cmds; i++) {
+ cmd_mpt = sc->mpt_cmd_list[i];
+
+ if (cmd_mpt->sync_cmd_idx != (u_int32_t)MRSAS_ULONG_MAX) {
+ cmd_mfi = sc->mfi_cmd_list[cmd_mpt->sync_cmd_idx];
+ if (cmd_mfi->sync_cmd && cmd_mfi->frame->hdr.cmd != MFI_CMD_ABORT) {
+ for (MSIxIndex = 0; MSIxIndex < count; MSIxIndex++)
+ mrsas_complete_mptmfi_passthru(sc, cmd_mfi,
+ cmd_mpt->io_request->RaidContext.status);
+ }
+ }
+ }
}
/*
@@ -2945,8 +3012,7 @@ mrsas_release_mfi_cmd(struct mrsas_mfi_cmd *cmd)
* supported by the FW.
*/
static int
-mrsas_get_ctrl_info(struct mrsas_softc *sc,
- struct mrsas_ctrl_info *ctrl_info)
+mrsas_get_ctrl_info(struct mrsas_softc *sc)
{
int retcode = 0;
struct mrsas_mfi_cmd *cmd;
@@ -2979,16 +3045,60 @@ mrsas_get_ctrl_info(struct mrsas_softc *sc,
dcmd->sgl.sge32[0].length = sizeof(struct mrsas_ctrl_info);
if (!mrsas_issue_polled(sc, cmd))
- memcpy(ctrl_info, sc->ctlr_info_mem, sizeof(struct mrsas_ctrl_info));
+ memcpy(sc->ctrl_info, sc->ctlr_info_mem, sizeof(struct mrsas_ctrl_info));
else
retcode = 1;
+ mrsas_update_ext_vd_details(sc);
+
mrsas_free_ctlr_info_cmd(sc);
mrsas_release_mfi_cmd(cmd);
return (retcode);
}
/*
+ * mrsas_update_ext_vd_details : Update details w.r.t Extended VD
+ * input:
+ * sc - Controller's softc
+*/
+static void
+mrsas_update_ext_vd_details(struct mrsas_softc *sc)
+{
+ sc->max256vdSupport =
+ sc->ctrl_info->adapterOperations3.supportMaxExtLDs;
+ /* Below is additional check to address future FW enhancement */
+ if (sc->ctrl_info->max_lds > 64)
+ sc->max256vdSupport = 1;
+
+ sc->drv_supported_vd_count = MRSAS_MAX_LD_CHANNELS
+ * MRSAS_MAX_DEV_PER_CHANNEL;
+ sc->drv_supported_pd_count = MRSAS_MAX_PD_CHANNELS
+ * MRSAS_MAX_DEV_PER_CHANNEL;
+ if (sc->max256vdSupport) {
+ sc->fw_supported_vd_count = MAX_LOGICAL_DRIVES_EXT;
+ sc->fw_supported_pd_count = MAX_PHYSICAL_DEVICES;
+ } else {
+ sc->fw_supported_vd_count = MAX_LOGICAL_DRIVES;
+ sc->fw_supported_pd_count = MAX_PHYSICAL_DEVICES;
+ }
+
+ sc->old_map_sz = sizeof(MR_FW_RAID_MAP) +
+ (sizeof(MR_LD_SPAN_MAP) *
+ (sc->fw_supported_vd_count - 1));
+ sc->new_map_sz = sizeof(MR_FW_RAID_MAP_EXT);
+ sc->drv_map_sz = sizeof(MR_DRV_RAID_MAP) +
+ (sizeof(MR_LD_SPAN_MAP) *
+ (sc->drv_supported_vd_count - 1));
+
+ sc->max_map_sz = max(sc->old_map_sz, sc->new_map_sz);
+
+ if (sc->max256vdSupport)
+ sc->current_map_sz = sc->new_map_sz;
+ else
+ sc->current_map_sz = sc->old_map_sz;
+}
+
+/*
* mrsas_alloc_ctlr_info_cmd: Allocates memory for controller info command
* input: Adapter soft state
*
@@ -3763,7 +3873,7 @@ mrsas_get_ld_list(struct mrsas_softc *sc)
* memory is initialized to all zeros upon successful loading of the dma
* mapped memory.
*/
-int
+int
mrsas_alloc_tmp_dcmd(struct mrsas_softc *sc,
struct mrsas_tmp_dcmd *tcmd, int size)
{
@@ -3996,10 +4106,12 @@ mrsas_complete_aen(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd)
*/
if ((!cmd->abort_aen) && (sc->remove_in_progress == 0)) {
sc->mrsas_aen_triggered = 1;
+ mtx_lock(&sc->aen_lock);
if (sc->mrsas_poll_waiting) {
sc->mrsas_poll_waiting = 0;
selwakeup(&sc->mrsas_select);
}
+ mtx_unlock(&sc->aen_lock);
} else
cmd->abort_aen = 0;
diff --git a/sys/dev/mrsas/mrsas.h b/sys/dev/mrsas/mrsas.h
index 37b6e95..1cfe89e 100644
--- a/sys/dev/mrsas/mrsas.h
+++ b/sys/dev/mrsas/mrsas.h
@@ -1,6 +1,7 @@
/*
+ * Copyright (c) 2015, AVAGO Tech. All rights reserved. Authors: Marian Choy
* Copyright (c) 2014, LSI Corp. All rights reserved. Authors: Marian Choy
- * Support: freebsdraid@lsi.com
+ * Support: freebsdraid@avagotech.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -31,7 +32,7 @@
* those of the authors and should not be interpreted as representing
* official policies,either expressed or implied, of the FreeBSD Project.
*
- * Send feedback to: <megaraidfbsd@lsi.com> Mail to: LSI Corporation, 1621
+ * Send feedback to: <megaraidfbsd@avagotech.com> Mail to: AVAGO TECHNOLOGIES, 1621
* Barber Lane, Milpitas, CA 95035 ATTN: MegaRaid FreeBSD
*
*/
@@ -101,7 +102,7 @@ __FBSDID("$FreeBSD$");
*/
#define BYTE_ALIGNMENT 1
#define MRSAS_MAX_NAME_LENGTH 32
-#define MRSAS_VERSION "06.705.10.02-fbsd"
+#define MRSAS_VERSION "06.707.04.03-fbsd"
#define MRSAS_ULONG_MAX 0xFFFFFFFFFFFFFFFF
#define MRSAS_DEFAULT_TIMEOUT 0x14 /* Temporarily set */
#define DONE 0
@@ -813,9 +814,8 @@ typedef struct _MR_DRV_RAID_MAP_ALL {
typedef struct _LD_LOAD_BALANCE_INFO {
u_int8_t loadBalanceFlag;
u_int8_t reserved1;
- u_int16_t raid1DevHandle[2];
- mrsas_atomic_t scsi_pending_cmds[2];
- u_int64_t last_accessed_block[2];
+ mrsas_atomic_t scsi_pending_cmds[MAX_PHYSICAL_DEVICES];
+ u_int64_t last_accessed_block[MAX_PHYSICAL_DEVICES];
} LD_LOAD_BALANCE_INFO, *PLD_LOAD_BALANCE_INFO;
/* SPAN_SET is info caclulated from span info from Raid map per ld */
@@ -858,6 +858,9 @@ struct IO_REQUEST_INFO {
u_int8_t start_span;
u_int8_t reserved;
u_int64_t start_row;
+ /* span[7:5], arm[4:0] */
+ u_int8_t span_arm;
+ u_int8_t pd_after_lb;
};
typedef struct _MR_LD_TARGET_SYNC {
@@ -1315,6 +1318,13 @@ typedef enum _REGION_TYPE {
#define MRSAS_REQ_STATE_TRAN 2
#define MRSAS_REQ_STATE_COMPLETE 3
+typedef enum _MR_SCSI_CMD_TYPE {
+ READ_WRITE_LDIO = 0,
+ NON_READ_WRITE_LDIO = 1,
+ READ_WRITE_SYSPDIO = 2,
+ NON_READ_WRITE_SYSPDIO = 3,
+} MR_SCSI_CMD_TYPE;
+
enum mrsas_req_flags {
MRSAS_DIR_UNKNOWN = 0x1,
MRSAS_DIR_IN = 0x2,
@@ -1350,6 +1360,7 @@ struct mrsas_mpt_cmd {
u_int32_t sync_cmd_idx;
u_int32_t index;
u_int8_t flags;
+ u_int8_t pd_r1_lb;
u_int8_t load_balance;
bus_size_t length;
u_int32_t error_code;
@@ -1897,9 +1908,26 @@ struct mrsas_ctrl_info {
char reserved6[4]; /* 0x7E4 RESERVED FOR IOV */
struct { /* 0x7E8 */
- u_int32_t resrved:5;
+ u_int32_t supportPersonalityChange:2;
+ u_int32_t supportThermalPollInterval:1;
+ u_int32_t supportDisableImmediateIO:1;
+ u_int32_t supportT10RebuildAssist:1;
u_int32_t supportMaxExtLDs:1;
- u_int32_t reserved1:26;
+ u_int32_t supportCrashDump:1;
+ u_int32_t supportSwZone:1;
+ u_int32_t supportDebugQueue:1;
+ u_int32_t supportNVCacheErase:1;
+ u_int32_t supportForceTo512e:1;
+ u_int32_t supportHOQRebuild:1;
+ u_int32_t supportAllowedOpsforDrvRemoval:1;
+ u_int32_t supportDrvActivityLEDSetting:1;
+ u_int32_t supportNVDRAM:1;
+ u_int32_t supportForceFlash:1;
+ u_int32_t supportDisableSESMonitoring:1;
+ u_int32_t supportCacheBypassModes:1;
+ u_int32_t supportSecurityonJBOD:1;
+ u_int32_t discardCacheDuringLDDelete:1;
+ u_int32_t reserved:12;
} adapterOperations3;
u_int8_t pad[0x800 - 0x7EC]; /* 0x7EC */
@@ -1970,7 +1998,10 @@ typedef union _MFI_CAPABILITIES {
u_int32_t support_additional_msix:1;
u_int32_t support_fastpath_wb:1;
u_int32_t support_max_255lds:1;
- u_int32_t reserved:28;
+ u_int32_t support_ndrive_r1_lb:1;
+ u_int32_t support_core_affinity:1;
+ u_int32_t security_protocol_cmds_fw:1;
+ u_int32_t reserved:25;
} mfi_capabilities;
u_int32_t reg;
} MFI_CAPABILITIES;
@@ -2413,6 +2444,167 @@ struct mrsas_mgmt_info {
int max_index;
};
+#define PCI_TYPE0_ADDRESSES 6
+#define PCI_TYPE1_ADDRESSES 2
+#define PCI_TYPE2_ADDRESSES 5
+
+typedef struct _MRSAS_DRV_PCI_COMMON_HEADER {
+ u_int16_t vendorID;
+ //(ro)
+ u_int16_t deviceID;
+ //(ro)
+ u_int16_t command;
+ //Device control
+ u_int16_t status;
+ u_int8_t revisionID;
+ //(ro)
+ u_int8_t progIf;
+ //(ro)
+ u_int8_t subClass;
+ //(ro)
+ u_int8_t baseClass;
+ //(ro)
+ u_int8_t cacheLineSize;
+ //(ro +)
+ u_int8_t latencyTimer;
+ //(ro +)
+ u_int8_t headerType;
+ //(ro)
+ u_int8_t bist;
+ //Built in self test
+
+ union {
+ struct _MRSAS_DRV_PCI_HEADER_TYPE_0 {
+ u_int32_t baseAddresses[PCI_TYPE0_ADDRESSES];
+ u_int32_t cis;
+ u_int16_t subVendorID;
+ u_int16_t subSystemID;
+ u_int32_t romBaseAddress;
+ u_int8_t capabilitiesPtr;
+ u_int8_t reserved1[3];
+ u_int32_t reserved2;
+ u_int8_t interruptLine;
+ u_int8_t interruptPin;
+ //(ro)
+ u_int8_t minimumGrant;
+ //(ro)
+ u_int8_t maximumLatency;
+ //(ro)
+ } type0;
+
+ /*
+ * PCI to PCI Bridge
+ */
+
+ struct _MRSAS_DRV_PCI_HEADER_TYPE_1 {
+ u_int32_t baseAddresses[PCI_TYPE1_ADDRESSES];
+ u_int8_t primaryBus;
+ u_int8_t secondaryBus;
+ u_int8_t subordinateBus;
+ u_int8_t secondaryLatency;
+ u_int8_t ioBase;
+ u_int8_t ioLimit;
+ u_int16_t secondaryStatus;
+ u_int16_t memoryBase;
+ u_int16_t memoryLimit;
+ u_int16_t prefetchBase;
+ u_int16_t prefetchLimit;
+ u_int32_t prefetchBaseUpper32;
+ u_int32_t prefetchLimitUpper32;
+ u_int16_t ioBaseUpper16;
+ u_int16_t ioLimitUpper16;
+ u_int8_t capabilitiesPtr;
+ u_int8_t reserved1[3];
+ u_int32_t romBaseAddress;
+ u_int8_t interruptLine;
+ u_int8_t interruptPin;
+ u_int16_t bridgeControl;
+ } type1;
+
+ /*
+ * PCI to CARDBUS Bridge
+ */
+
+ struct _MRSAS_DRV_PCI_HEADER_TYPE_2 {
+ u_int32_t socketRegistersBaseAddress;
+ u_int8_t capabilitiesPtr;
+ u_int8_t reserved;
+ u_int16_t secondaryStatus;
+ u_int8_t primaryBus;
+ u_int8_t secondaryBus;
+ u_int8_t subordinateBus;
+ u_int8_t secondaryLatency;
+ struct {
+ u_int32_t base;
+ u_int32_t limit;
+ } range [PCI_TYPE2_ADDRESSES - 1];
+ u_int8_t interruptLine;
+ u_int8_t interruptPin;
+ u_int16_t bridgeControl;
+ } type2;
+ } u;
+
+} MRSAS_DRV_PCI_COMMON_HEADER, *PMRSAS_DRV_PCI_COMMON_HEADER;
+
+#define MRSAS_DRV_PCI_COMMON_HEADER_SIZE sizeof(MRSAS_DRV_PCI_COMMON_HEADER) //64 bytes
+
+typedef struct _MRSAS_DRV_PCI_LINK_CAPABILITY {
+ union {
+ struct {
+ u_int32_t linkSpeed:4;
+ u_int32_t linkWidth:6;
+ u_int32_t aspmSupport:2;
+ u_int32_t losExitLatency:3;
+ u_int32_t l1ExitLatency:3;
+ u_int32_t rsvdp:6;
+ u_int32_t portNumber:8;
+ } bits;
+
+ u_int32_t asUlong;
+ } u;
+} MRSAS_DRV_PCI_LINK_CAPABILITY, *PMRSAS_DRV_PCI_LINK_CAPABILITY;
+
+#define MRSAS_DRV_PCI_LINK_CAPABILITY_SIZE sizeof(MRSAS_DRV_PCI_LINK_CAPABILITY)
+
+typedef struct _MRSAS_DRV_PCI_LINK_STATUS_CAPABILITY {
+ union {
+ struct {
+ u_int16_t linkSpeed:4;
+ u_int16_t negotiatedLinkWidth:6;
+ u_int16_t linkTrainingError:1;
+ u_int16_t linkTraning:1;
+ u_int16_t slotClockConfig:1;
+ u_int16_t rsvdZ:3;
+ } bits;
+
+ u_int16_t asUshort;
+ } u;
+ u_int16_t reserved;
+} MRSAS_DRV_PCI_LINK_STATUS_CAPABILITY, *PMRSAS_DRV_PCI_LINK_STATUS_CAPABILITY;
+
+#define MRSAS_DRV_PCI_LINK_STATUS_CAPABILITY_SIZE sizeof(MRSAS_DRV_PCI_LINK_STATUS_CAPABILITY)
+
+
+typedef struct _MRSAS_DRV_PCI_CAPABILITIES {
+ MRSAS_DRV_PCI_LINK_CAPABILITY linkCapability;
+ MRSAS_DRV_PCI_LINK_STATUS_CAPABILITY linkStatusCapability;
+} MRSAS_DRV_PCI_CAPABILITIES, *PMRSAS_DRV_PCI_CAPABILITIES;
+
+#define MRSAS_DRV_PCI_CAPABILITIES_SIZE sizeof(MRSAS_DRV_PCI_CAPABILITIES)
+
+/* PCI information */
+typedef struct _MRSAS_DRV_PCI_INFORMATION {
+ u_int32_t busNumber;
+ u_int8_t deviceNumber;
+ u_int8_t functionNumber;
+ u_int8_t interruptVector;
+ u_int8_t reserved1;
+ MRSAS_DRV_PCI_COMMON_HEADER pciHeaderInfo;
+ MRSAS_DRV_PCI_CAPABILITIES capability;
+ u_int32_t domainID;
+ u_int8_t reserved2[28];
+} MRSAS_DRV_PCI_INFORMATION, *PMRSAS_DRV_PCI_INFORMATION;
+
/*******************************************************************
* per-instance data
********************************************************************/
@@ -2476,6 +2668,7 @@ struct mrsas_softc {
int msix_vectors;
int msix_enable;
uint32_t msix_reg_offset[16];
+ uint8_t mask_interrupts;
struct mrsas_mpt_cmd **mpt_cmd_list;
struct mrsas_mfi_cmd **mfi_cmd_list;
TAILQ_HEAD(, mrsas_mpt_cmd) mrsas_mpt_cmd_list_head;
@@ -2519,6 +2712,7 @@ struct mrsas_softc {
bus_dmamap_t evt_detail_dmamap;
struct mrsas_evt_detail *evt_detail_mem;
bus_addr_t evt_detail_phys_addr;
+ struct mrsas_ctrl_info *ctrl_info;
bus_dma_tag_t ctlr_info_tag;
bus_dmamap_t ctlr_info_dmamap;
void *ctlr_info_mem;
@@ -2546,9 +2740,11 @@ struct mrsas_softc {
struct task ev_task;
u_int32_t CurLdCount;
u_int64_t reset_flags;
+ int lb_pending_cmds;
LD_LOAD_BALANCE_INFO load_balance_info[MAX_LOGICAL_DRIVES_EXT];
LD_SPAN_INFO log_to_span[MAX_LOGICAL_DRIVES_EXT];
+ u_int8_t secure_jbod_support;
u_int8_t max256vdSupport;
u_int16_t fw_supported_vd_count;
u_int16_t fw_supported_pd_count;
diff --git a/sys/dev/mrsas/mrsas_cam.c b/sys/dev/mrsas/mrsas_cam.c
index 80ddc39..08f9002 100644
--- a/sys/dev/mrsas/mrsas_cam.c
+++ b/sys/dev/mrsas/mrsas_cam.c
@@ -1,6 +1,7 @@
/*
+ * Copyright (c) 2015, AVAGO Tech. All rights reserved. Author: Marian Choy
* Copyright (c) 2014, LSI Corp. All rights reserved. Author: Marian Choy
- * Support: freebsdraid@lsi.com
+ * Support: freebsdraid@avagotech.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -57,17 +58,19 @@ __FBSDID("$FreeBSD$");
* Function prototypes
*/
int mrsas_cam_attach(struct mrsas_softc *sc);
-int mrsas_ldio_inq(struct cam_sim *sim, union ccb *ccb);
+int mrsas_find_io_type(struct cam_sim *sim, union ccb *ccb);
int mrsas_bus_scan(struct mrsas_softc *sc);
int mrsas_bus_scan_sim(struct mrsas_softc *sc, struct cam_sim *sim);
-int mrsas_map_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd);
int
+mrsas_map_request(struct mrsas_softc *sc,
+ struct mrsas_mpt_cmd *cmd, union ccb *ccb);
+int
mrsas_build_ldio(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
union ccb *ccb);
-int
+int
mrsas_build_dcdb(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
union ccb *ccb, struct cam_sim *sim);
-int
+int
mrsas_setup_io(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
union ccb *ccb, u_int32_t device_id,
MRSAS_RAID_SCSI_IO_REQUEST * io_request);
@@ -77,10 +80,10 @@ void mrsas_cam_detach(struct mrsas_softc *sc);
void mrsas_release_mpt_cmd(struct mrsas_mpt_cmd *cmd);
void mrsas_unmap_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd);
void mrsas_cmd_done(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd);
-void
+void
mrsas_fire_cmd(struct mrsas_softc *sc, u_int32_t req_desc_lo,
u_int32_t req_desc_hi);
-void
+void
mrsas_set_pd_lba(MRSAS_RAID_SCSI_IO_REQUEST * io_request,
u_int8_t cdb_len, struct IO_REQUEST_INFO *io_info, union ccb *ccb,
MR_DRV_RAID_MAP_ALL * local_map_ptr, u_int32_t ref_tag,
@@ -89,10 +92,10 @@ static void mrsas_freeze_simq(struct mrsas_mpt_cmd *cmd, struct cam_sim *sim);
static void mrsas_cam_poll(struct cam_sim *sim);
static void mrsas_action(struct cam_sim *sim, union ccb *ccb);
static void mrsas_scsiio_timeout(void *data);
-static void
+static void
mrsas_data_load_cb(void *arg, bus_dma_segment_t *segs,
int nseg, int error);
-static int32_t
+static int32_t
mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
union ccb *ccb);
struct mrsas_mpt_cmd *mrsas_get_mpt_cmd(struct mrsas_softc *sc);
@@ -112,9 +115,9 @@ MR_BuildRaidContext(struct mrsas_softc *sc,
extern u_int16_t
MR_LdSpanArrayGet(u_int32_t ld, u_int32_t span,
MR_DRV_RAID_MAP_ALL * map);
-extern u_int16_t
-mrsas_get_updated_dev_handle(PLD_LOAD_BALANCE_INFO lbInfo,
- struct IO_REQUEST_INFO *io_info);
+extern u_int16_t
+mrsas_get_updated_dev_handle(struct mrsas_softc *sc,
+ PLD_LOAD_BALANCE_INFO lbInfo, struct IO_REQUEST_INFO *io_info);
extern u_int8_t
megasas_get_best_arm(PLD_LOAD_BALANCE_INFO lbInfo, u_int8_t arm,
u_int64_t block, u_int32_t count);
@@ -315,7 +318,11 @@ mrsas_action(struct cam_sim *sim, union ccb *ccb)
ccb->cpi.version_num = 1;
ccb->cpi.hba_inquiry = 0;
ccb->cpi.target_sprt = 0;
+#if (__FreeBSD_version >= 902001)
+ ccb->cpi.hba_misc = PIM_UNMAPPED;
+#else
ccb->cpi.hba_misc = 0;
+#endif
ccb->cpi.hba_eng_cnt = 0;
ccb->cpi.max_lun = MRSAS_SCSI_MAX_LUNS;
ccb->cpi.unit_number = cam_sim_unit(sim);
@@ -323,7 +330,7 @@ mrsas_action(struct cam_sim *sim, union ccb *ccb)
ccb->cpi.initiator_id = MRSAS_SCSI_INITIATOR_ID;
ccb->cpi.base_transfer_speed = 150000;
strncpy(ccb->cpi.sim_vid, "FreeBSD", SIM_IDLEN);
- strncpy(ccb->cpi.hba_vid, "LSI", HBA_IDLEN);
+ strncpy(ccb->cpi.hba_vid, "AVAGO", HBA_IDLEN);
strncpy(ccb->cpi.dev_name, cam_sim_name(sim), DEV_IDLEN);
ccb->cpi.transport = XPORT_SPI;
ccb->cpi.transport_version = 2;
@@ -378,8 +385,13 @@ mrsas_scsiio_timeout(void *data)
* on OCR enable/disable property of Controller from ocr_thread
* context.
*/
+#if (__FreeBSD_version >= 1000510)
callout_reset_sbt(&cmd->cm_callout, SBT_1S * 600, 0,
- mrsas_scsiio_timeout, cmd, 0);
+ mrsas_scsiio_timeout, cmd, 0);
+#else
+ callout_reset(&cmd->cm_callout, (600000 * hz) / 1000,
+ mrsas_scsiio_timeout, cmd);
+#endif
sc->do_timedout_reset = 1;
if (sc->ocr_thread_active)
wakeup(&sc->ocr_chan);
@@ -425,8 +437,8 @@ mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
} else
cmd->flags = MRSAS_DIR_NONE; /* no data */
- /* For FreeBSD 10.0 and higher */
-#if (__FreeBSD_version >= 1000000)
+/* For FreeBSD 9.2 and higher */
+#if (__FreeBSD_version >= 902001)
/*
* XXX We don't yet support physical addresses here.
*/
@@ -455,6 +467,11 @@ mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
if (cmd->length)
cmd->data = csio->data_ptr;
break;
+ case CAM_DATA_BIO:
+ cmd->length = csio->dxfer_len;
+ if (cmd->length)
+ cmd->data = csio->data_ptr;
+ break;
default:
ccb->ccb_h.status = CAM_REQ_INVALID;
goto done;
@@ -499,7 +516,9 @@ mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
bcopy(csio->cdb_io.cdb_bytes, cmd->io_request->CDB.CDB32, csio->cdb_len);
mtx_lock(&sc->raidmap_lock);
- if (mrsas_ldio_inq(sim, ccb)) {
+ /* Check for IO type READ-WRITE targeted for Logical Volume */
+ if (mrsas_find_io_type(sim, ccb) == READ_WRITE_LDIO) {
+ /* Build READ-WRITE IO for Logical Volume */
if (mrsas_build_ldio(sc, cmd, ccb)) {
device_printf(sc->mrsas_dev, "Build LDIO failed.\n");
mtx_unlock(&sc->raidmap_lock);
@@ -530,8 +549,13 @@ mrsas_startio(struct mrsas_softc *sc, struct cam_sim *sim,
/*
* Start timer for IO timeout. Default timeout value is 90 second.
*/
- callout_reset_sbt(&cmd->cm_callout, SBT_1MS * sc->mrsas_io_timeout, 0,
+#if (__FreeBSD_version >= 1000510)
+ callout_reset_sbt(&cmd->cm_callout, SBT_1S * 600, 0,
mrsas_scsiio_timeout, cmd, 0);
+#else
+ callout_reset(&cmd->cm_callout, (600000 * hz) / 1000,
+ mrsas_scsiio_timeout, cmd);
+#endif
mrsas_atomic_inc(&sc->fw_outstanding);
if (mrsas_atomic_read(&sc->fw_outstanding) > sc->io_cmds_highwater)
@@ -546,20 +570,17 @@ done:
}
/*
- * mrsas_ldio_inq: Determines if IO is read/write or inquiry
+ * mrsas_find_io_type: Determines if IO is read/write or inquiry
* input: pointer to CAM Control Block
*
* This function determines if the IO is read/write or inquiry. It returns a 1
* if the IO is read/write and 0 if it is inquiry.
*/
-int
-mrsas_ldio_inq(struct cam_sim *sim, union ccb *ccb)
+int
+mrsas_find_io_type(struct cam_sim *sim, union ccb *ccb)
{
struct ccb_scsiio *csio = &(ccb->csio);
- if (cam_sim_bus(sim) == 1)
- return (0);
-
switch (csio->cdb_io.cdb_bytes[0]) {
case READ_10:
case WRITE_10:
@@ -569,9 +590,11 @@ mrsas_ldio_inq(struct cam_sim *sim, union ccb *ccb)
case WRITE_6:
case READ_16:
case WRITE_16:
- return 1;
+ return (cam_sim_bus(sim) ?
+ READ_WRITE_SYSPDIO : READ_WRITE_LDIO);
default:
- return 0;
+ return (cam_sim_bus(sim) ?
+ NON_READ_WRITE_SYSPDIO : NON_READ_WRITE_LDIO);
}
}
@@ -677,7 +700,7 @@ mrsas_build_ldio(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
io_request->DataLength = cmd->length;
- if (mrsas_map_request(sc, cmd) == SUCCESS) {
+ if (mrsas_map_request(sc, cmd, ccb) == SUCCESS) {
if (cmd->sge_count > MRSAS_MAX_SGL) {
device_printf(sc->mrsas_dev, "Error: sge_count (0x%x) exceeds"
"max (0x%x) allowed\n", cmd->sge_count, sc->max_num_sge);
@@ -824,9 +847,10 @@ mrsas_setup_io(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
if ((sc->load_balance_info[device_id].loadBalanceFlag) &&
(io_info.isRead)) {
io_info.devHandle =
- mrsas_get_updated_dev_handle(&sc->load_balance_info[device_id],
- &io_info);
+ mrsas_get_updated_dev_handle(sc,
+ &sc->load_balance_info[device_id], &io_info);
cmd->load_balance = MRSAS_LOAD_BALANCE_FLAG;
+ cmd->pd_r1_lb = io_info.pd_after_lb;
} else
cmd->load_balance = 0;
cmd->request_desc->SCSIIO.DevHandle = io_info.devHandle;
@@ -876,30 +900,49 @@ mrsas_build_dcdb(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
device_id = ccb_h->target_id;
map_ptr = sc->ld_drv_map[(sc->map_id & 1)];
- /* Check if this is for system PD */
+ /*
+ * Check if this is RW for system PD or
+ * it's a NON RW for sys PD and there is NO secure jbod FW support
+ */
if (cam_sim_bus(sim) == 1 &&
sc->pd_list[device_id].driveState == MR_PD_STATE_SYSTEM) {
- io_request->Function = 0;
- io_request->DevHandle = map_ptr->raidMap.devHndlInfo[device_id].
- curDevHdl;
- io_request->RaidContext.timeoutValue = map_ptr->raidMap.fpPdIoTimeoutSec;
- io_request->RaidContext.regLockFlags = 0;
- io_request->RaidContext.regLockRowLBA = 0;
- io_request->RaidContext.regLockLength = 0;
- io_request->RaidContext.RAIDFlags = MR_RAID_FLAGS_IO_SUB_TYPE_SYSTEM_PD
- << MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT;
- if ((sc->device_id == MRSAS_INVADER) || (sc->device_id == MRSAS_FURY))
- io_request->IoFlags |= MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH;
- cmd->request_desc->SCSIIO.RequestFlags =
- (MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY <<
- MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
- cmd->request_desc->SCSIIO.DevHandle =
+ io_request->DevHandle =
map_ptr->raidMap.devHndlInfo[device_id].curDevHdl;
+ io_request->RaidContext.RAIDFlags =
+ MR_RAID_FLAGS_IO_SUB_TYPE_SYSTEM_PD <<
+ MR_RAID_CTX_RAID_FLAGS_IO_SUB_TYPE_SHIFT;
+ cmd->request_desc->SCSIIO.DevHandle = io_request->DevHandle;
cmd->request_desc->SCSIIO.MSIxIndex =
sc->msix_vectors ? smp_processor_id() % sc->msix_vectors : 0;
+ if (sc->secure_jbod_support && (mrsas_find_io_type(sim, ccb) == NON_READ_WRITE_SYSPDIO)) {
+ /* system pd firmware path */
+ io_request->Function = MRSAS_MPI2_FUNCTION_LD_IO_REQUEST;
+ cmd->request_desc->SCSIIO.RequestFlags =
+ (MPI2_REQ_DESCRIPT_FLAGS_SCSI_IO << MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
+ } else {
+ /* system pd fast path */
+ io_request->Function = MPI2_FUNCTION_SCSI_IO_REQUEST;
+ io_request->RaidContext.timeoutValue = map_ptr->raidMap.fpPdIoTimeoutSec;
+ io_request->RaidContext.regLockFlags = 0;
+ io_request->RaidContext.regLockRowLBA = 0;
+ io_request->RaidContext.regLockLength = 0;
+
+ cmd->request_desc->SCSIIO.RequestFlags =
+ (MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY <<
+ MRSAS_REQ_DESCRIPT_FLAGS_TYPE_SHIFT);
+
+ /*
+ * NOTE - For system pd RW cmds only IoFlags will be FAST_PATH
+ * Because the NON RW cmds will now go via FW Queue
+ * and not the Exception queue
+ */
+ if ((sc->device_id == MRSAS_INVADER) || (sc->device_id == MRSAS_FURY))
+ io_request->IoFlags |= MPI25_SAS_DEVICE0_FLAGS_ENABLED_FAST_PATH;
+ }
} else {
+ /* FW path for SysPD or LD Non-RW (SCSI management commands) */
io_request->Function = MRSAS_MPI2_FUNCTION_LD_IO_REQUEST;
io_request->DevHandle = device_id;
cmd->request_desc->SCSIIO.RequestFlags =
@@ -911,7 +954,7 @@ mrsas_build_dcdb(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
io_request->LUN[1] = ccb_h->target_lun & 0xF;
io_request->DataLength = cmd->length;
- if (mrsas_map_request(sc, cmd) == SUCCESS) {
+ if (mrsas_map_request(sc, cmd, ccb) == SUCCESS) {
if (cmd->sge_count > sc->max_num_sge) {
device_printf(sc->mrsas_dev, "Error: sge_count (0x%x) exceeds"
"max (0x%x) allowed\n", cmd->sge_count, sc->max_num_sge);
@@ -934,20 +977,25 @@ mrsas_build_dcdb(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd,
* is built in the callback. If the bus dmamap load is not successful,
* cmd->error_code will contain the error code and a 1 is returned.
*/
-int
-mrsas_map_request(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd)
+int
+mrsas_map_request(struct mrsas_softc *sc,
+ struct mrsas_mpt_cmd *cmd, union ccb *ccb)
{
u_int32_t retcode = 0;
struct cam_sim *sim;
- int flag = BUS_DMA_NOWAIT;
sim = xpt_path_sim(cmd->ccb_ptr->ccb_h.path);
if (cmd->data != NULL) {
- mtx_lock(&sc->io_lock);
/* Map data buffer into bus space */
+ mtx_lock(&sc->io_lock);
+#if (__FreeBSD_version >= 902001)
+ retcode = bus_dmamap_load_ccb(sc->data_tag, cmd->data_dmamap, ccb,
+ mrsas_data_load_cb, cmd, 0);
+#else
retcode = bus_dmamap_load(sc->data_tag, cmd->data_dmamap, cmd->data,
- cmd->length, mrsas_data_load_cb, cmd, flag);
+ cmd->length, mrsas_data_load_cb, cmd, BUS_DMA_NOWAIT);
+#endif
mtx_unlock(&sc->io_lock);
if (retcode)
device_printf(sc->mrsas_dev, "bus_dmamap_load(): retcode = %d\n", retcode);
diff --git a/sys/dev/mrsas/mrsas_fp.c b/sys/dev/mrsas/mrsas_fp.c
index cd0d57f..7ae5662 100644
--- a/sys/dev/mrsas/mrsas_fp.c
+++ b/sys/dev/mrsas/mrsas_fp.c
@@ -1,6 +1,7 @@
/*
+ * Copyright (c) 2015, AVAGO Tech. All rights reserved. Author: Marian Choy
* Copyright (c) 2014, LSI Corp. All rights reserved. Author: Marian Choy
- * Support: freebsdraid@lsi.com
+ * Support: freebsdraid@avagotech.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -31,7 +32,7 @@
* those of the authors and should not be interpreted as representing
* official policies,either expressed or implied, of the FreeBSD Project.
*
- * Send feedback to: <megaraidfbsd@lsi.com> Mail to: LSI Corporation, 1621
+ * Send feedback to: <megaraidfbsd@avagotech.com> Mail to: AVAGO TECHNOLOGIES, 1621
* Barber Lane, Milpitas, CA 95035 ATTN: MegaRaid FreeBSD
*
*/
@@ -55,13 +56,13 @@ __FBSDID("$FreeBSD$");
*/
u_int8_t MR_ValidateMapInfo(struct mrsas_softc *sc);
u_int8_t
-mrsas_get_best_arm(PLD_LOAD_BALANCE_INFO lbInfo, u_int8_t arm,
- u_int64_t block, u_int32_t count);
-u_int8_t
+mrsas_get_best_arm_pd(struct mrsas_softc *sc,
+ PLD_LOAD_BALANCE_INFO lbInfo, struct IO_REQUEST_INFO *io_info);
+u_int8_t
MR_BuildRaidContext(struct mrsas_softc *sc,
struct IO_REQUEST_INFO *io_info,
RAID_CONTEXT * pRAID_Context, MR_DRV_RAID_MAP_ALL * map);
-u_int8_t
+u_int8_t
MR_GetPhyParams(struct mrsas_softc *sc, u_int32_t ld,
u_int64_t stripRow, u_int16_t stripRef, struct IO_REQUEST_INFO *io_info,
RAID_CONTEXT * pRAID_Context,
@@ -70,32 +71,32 @@ u_int16_t MR_TargetIdToLdGet(u_int32_t ldTgtId, MR_DRV_RAID_MAP_ALL * map);
u_int32_t MR_LdBlockSizeGet(u_int32_t ldTgtId, MR_DRV_RAID_MAP_ALL * map);
u_int16_t MR_GetLDTgtId(u_int32_t ld, MR_DRV_RAID_MAP_ALL * map);
u_int16_t
-mrsas_get_updated_dev_handle(PLD_LOAD_BALANCE_INFO lbInfo,
- struct IO_REQUEST_INFO *io_info);
+mrsas_get_updated_dev_handle(struct mrsas_softc *sc,
+ PLD_LOAD_BALANCE_INFO lbInfo, struct IO_REQUEST_INFO *io_info);
u_int32_t mega_mod64(u_int64_t dividend, u_int32_t divisor);
-u_int32_t
+u_int32_t
MR_GetSpanBlock(u_int32_t ld, u_int64_t row, u_int64_t *span_blk,
MR_DRV_RAID_MAP_ALL * map, int *div_error);
u_int64_t mega_div64_32(u_int64_t dividend, u_int32_t divisor);
void
-mrsas_update_load_balance_params(MR_DRV_RAID_MAP_ALL * map,
- PLD_LOAD_BALANCE_INFO lbInfo);
-void
+mrsas_update_load_balance_params(struct mrsas_softc *sc,
+ MR_DRV_RAID_MAP_ALL * map, PLD_LOAD_BALANCE_INFO lbInfo);
+void
mrsas_set_pd_lba(MRSAS_RAID_SCSI_IO_REQUEST * io_request,
u_int8_t cdb_len, struct IO_REQUEST_INFO *io_info, union ccb *ccb,
MR_DRV_RAID_MAP_ALL * local_map_ptr, u_int32_t ref_tag,
u_int32_t ld_block_size);
-static u_int16_t
+static u_int16_t
MR_LdSpanArrayGet(u_int32_t ld, u_int32_t span,
MR_DRV_RAID_MAP_ALL * map);
static u_int16_t MR_PdDevHandleGet(u_int32_t pd, MR_DRV_RAID_MAP_ALL * map);
-static u_int16_t
+static u_int16_t
MR_ArPdGet(u_int32_t ar, u_int32_t arm,
MR_DRV_RAID_MAP_ALL * map);
static MR_LD_SPAN *
MR_LdSpanPtrGet(u_int32_t ld, u_int32_t span,
MR_DRV_RAID_MAP_ALL * map);
-static u_int8_t
+static u_int8_t
MR_LdDataArmGet(u_int32_t ld, u_int32_t armIdx,
MR_DRV_RAID_MAP_ALL * map);
static MR_SPAN_BLOCK_INFO *
@@ -146,6 +147,8 @@ typedef u_int32_t REGION_LEN;
#define FALSE 0
#define TRUE 1
+#define LB_PENDING_CMDS_DEFAULT 4
+
/*
* Related Macros
@@ -376,10 +379,9 @@ MR_ValidateMapInfo(struct mrsas_softc *sc)
return 1;
}
if (sc->UnevenSpanSupport) {
- printf("Updating span set\n\n");
mr_update_span_set(drv_map, ldSpanInfo);
}
- mrsas_update_load_balance_params(drv_map, sc->load_balance_info);
+ mrsas_update_load_balance_params(sc, drv_map, sc->load_balance_info);
return 0;
}
@@ -566,12 +568,12 @@ get_row_from_strip(struct mrsas_softc *sc,
else
break;
}
- mrsas_dprint(sc, MRSAS_PRL11, "LSI Debug : Strip 0x%llx, span_set_Strip 0x%llx, span_set_Row 0x%llx "
+ mrsas_dprint(sc, MRSAS_PRL11, "AVAGO Debug : Strip 0x%llx, span_set_Strip 0x%llx, span_set_Row 0x%llx "
"data width 0x%llx span offset 0x%llx\n", (unsigned long long)strip,
(unsigned long long)span_set_Strip,
(unsigned long long)span_set_Row,
(unsigned long long)span_set->span_row_data_width, (unsigned long long)span_offset);
- mrsas_dprint(sc, MRSAS_PRL11, "LSI Debug : For strip 0x%llx row is 0x%llx\n", (unsigned long long)strip,
+ mrsas_dprint(sc, MRSAS_PRL11, "AVAGO Debug : For strip 0x%llx row is 0x%llx\n", (unsigned long long)strip,
(unsigned long long)span_set->data_row_start +
(unsigned long long)span_set_Row + (span_offset - 1));
return (span_set->data_row_start + span_set_Row + (span_offset - 1));
@@ -631,7 +633,7 @@ get_strip_from_row(struct mrsas_softc *sc,
}
}
}
- mrsas_dprint(sc, MRSAS_PRL11, "LSI Debug - get_strip_from_row: returns invalid "
+ mrsas_dprint(sc, MRSAS_PRL11, "AVAGO Debug - get_strip_from_row: returns invalid "
"strip for ld=%x, row=%lx\n", ld, (long unsigned int)row);
return -1;
}
@@ -679,13 +681,13 @@ get_arm_from_strip(struct mrsas_softc *sc,
else
break;
}
- mrsas_dprint(sc, MRSAS_PRL11, "LSI PRL11: get_arm_from_strip: "
+ mrsas_dprint(sc, MRSAS_PRL11, "AVAGO PRL11: get_arm_from_strip: "
"for ld=0x%x strip=0x%lx arm is 0x%x\n", ld,
(long unsigned int)strip, (strip_offset - span_offset));
return (strip_offset - span_offset);
}
- mrsas_dprint(sc, MRSAS_PRL11, "LSI Debug: - get_arm_from_strip: returns invalid arm"
+ mrsas_dprint(sc, MRSAS_PRL11, "AVAGO Debug: - get_arm_from_strip: returns invalid arm"
" for ld=%x strip=%lx\n", ld, (long unsigned int)strip);
return -1;
@@ -723,9 +725,11 @@ get_arm(struct mrsas_softc *sc, u_int32_t ld, u_int8_t span, u_int64_t stripe,
* This routine calculates the arm, span and block for the specified stripe and
* reference in stripe using spanset
*
- * Inputs : Logical drive number
- * stripRow: Stripe number
- * stripRef: Reference in stripe
+ * Inputs :
+ * sc - HBA instance
+ * ld - Logical drive number
+ * stripRow: Stripe number
+ * stripRef: Reference in stripe
*
* Outputs : span - Span number block - Absolute Block
* number in the physical disk
@@ -785,6 +789,7 @@ mr_spanset_get_phy_params(struct mrsas_softc *sc, u_int32_t ld, u_int64_t stripR
*pdBlock += stripRef + MR_LdSpanPtrGet(ld, span, map)->startBlk;
pRAID_Context->spanArm = (span << RAID_CTX_SPANARM_SPAN_SHIFT) | physArm;
+ io_info->span_arm = pRAID_Context->spanArm;
return retval;
}
@@ -831,7 +836,7 @@ MR_BuildRaidContext(struct mrsas_softc *sc, struct IO_REQUEST_INFO *io_info,
else if (sc->UnevenSpanSupport) {
io_info->IoforUnevenSpan = 1;
} else {
- mrsas_dprint(sc, MRSAS_PRL11, "LSI Debug: raid->rowDataSize is 0, but has SPAN[0] rowDataSize = 0x%0x,"
+ mrsas_dprint(sc, MRSAS_PRL11, "AVAGO Debug: raid->rowDataSize is 0, but has SPAN[0] rowDataSize = 0x%0x,"
" but there is _NO_ UnevenSpanSupport\n",
MR_LdSpanPtrGet(ld, 0, map)->spanRowDataSize);
return FALSE;
@@ -858,13 +863,13 @@ MR_BuildRaidContext(struct mrsas_softc *sc, struct IO_REQUEST_INFO *io_info,
startlba_span = (u_int8_t)mr_spanset_get_span_block(sc, ld, start_row,
pdBlock, map, &error_code);
if (error_code == 1) {
- mrsas_dprint(sc, MRSAS_PRL11, "LSI Debug: return from %s %d. Send IO w/o region lock.\n",
+ mrsas_dprint(sc, MRSAS_PRL11, "AVAGO Debug: return from %s %d. Send IO w/o region lock.\n",
__func__, __LINE__);
return FALSE;
}
}
if (startlba_span == SPAN_INVALID) {
- mrsas_dprint(sc, MRSAS_PRL11, "LSI Debug: return from %s %d for row 0x%llx,"
+ mrsas_dprint(sc, MRSAS_PRL11, "AVAGO Debug: return from %s %d for row 0x%llx,"
"start strip %llx endSrip %llx\n", __func__,
__LINE__, (unsigned long long)start_row,
(unsigned long long)start_strip,
@@ -873,12 +878,12 @@ MR_BuildRaidContext(struct mrsas_softc *sc, struct IO_REQUEST_INFO *io_info,
}
io_info->start_span = startlba_span;
io_info->start_row = start_row;
- mrsas_dprint(sc, MRSAS_PRL11, "LSI Debug: Check Span number from %s %d for row 0x%llx, "
+ mrsas_dprint(sc, MRSAS_PRL11, "AVAGO Debug: Check Span number from %s %d for row 0x%llx, "
" start strip 0x%llx endSrip 0x%llx span 0x%x\n",
__func__, __LINE__, (unsigned long long)start_row,
(unsigned long long)start_strip,
(unsigned long long)endStrip, startlba_span);
- mrsas_dprint(sc, MRSAS_PRL11, "LSI Debug : 1. start_row 0x%llx endRow 0x%llx Start span 0x%x\n",
+ mrsas_dprint(sc, MRSAS_PRL11, "AVAGO Debug : 1. start_row 0x%llx endRow 0x%llx Start span 0x%x\n",
(unsigned long long)start_row, (unsigned long long)endRow, startlba_span);
} else {
start_row = mega_div64_32(start_strip, raid->rowDataSize);
@@ -1042,7 +1047,7 @@ mr_update_span_set(MR_DRV_RAID_MAP_ALL * map, PLD_SPAN_INFO ldSpanInfo)
span_row_width +=
MR_LdSpanPtrGet(ld, count, map)->spanRowDataSize;
#if SPAN_DEBUG
- printf("LSI Debug span %x rowDataSize %x\n", count,
+ printf("AVAGO Debug span %x rowDataSize %x\n", count,
MR_LdSpanPtrGet(ld, count, map)->spanRowDataSize);
#endif
}
@@ -1097,46 +1102,38 @@ mr_update_span_set(MR_DRV_RAID_MAP_ALL * map, PLD_SPAN_INFO ldSpanInfo)
/*
* mrsas_update_load_balance_params: Update load balance parmas
- * Inputs: map pointer
- * Load balance info
+ * Inputs:
+ * sc - driver softc instance
+ * drv_map - driver RAID map
+ * lbInfo - Load balance info
*
* This function updates the load balance parameters for the LD config of a two
* drive optimal RAID-1.
*/
-void
-mrsas_update_load_balance_params(MR_DRV_RAID_MAP_ALL * map,
- PLD_LOAD_BALANCE_INFO lbInfo)
+void
+mrsas_update_load_balance_params(struct mrsas_softc *sc,
+ MR_DRV_RAID_MAP_ALL * drv_map, PLD_LOAD_BALANCE_INFO lbInfo)
{
int ldCount;
u_int16_t ld;
- u_int32_t pd, arRef;
MR_LD_RAID *raid;
- for (ldCount = 0; ldCount < MAX_LOGICAL_DRIVES; ldCount++) {
- ld = MR_TargetIdToLdGet(ldCount, map);
- if (ld >= MAX_LOGICAL_DRIVES) {
+ if (sc->lb_pending_cmds > 128 || sc->lb_pending_cmds < 1)
+ sc->lb_pending_cmds = LB_PENDING_CMDS_DEFAULT;
+
+ for (ldCount = 0; ldCount < MAX_LOGICAL_DRIVES_EXT; ldCount++) {
+ ld = MR_TargetIdToLdGet(ldCount, drv_map);
+ if (ld >= MAX_LOGICAL_DRIVES_EXT) {
lbInfo[ldCount].loadBalanceFlag = 0;
continue;
}
- raid = MR_LdRaidGet(ld, map);
-
- /* Two drive Optimal RAID 1 */
- if ((raid->level == 1) && (raid->rowSize == 2) &&
- (raid->spanDepth == 1)
- && raid->ldState == MR_LD_STATE_OPTIMAL) {
- lbInfo[ldCount].loadBalanceFlag = 1;
-
- /* Get the array on which this span is present */
- arRef = MR_LdSpanArrayGet(ld, 0, map);
-
- /* Get the PD */
- pd = MR_ArPdGet(arRef, 0, map);
- /* Get dev handle from PD */
- lbInfo[ldCount].raid1DevHandle[0] = MR_PdDevHandleGet(pd, map);
- pd = MR_ArPdGet(arRef, 1, map);
- lbInfo[ldCount].raid1DevHandle[1] = MR_PdDevHandleGet(pd, map);
- } else
+ raid = MR_LdRaidGet(ld, drv_map);
+ if ((raid->level != 1) ||
+ (raid->ldState != MR_LD_STATE_OPTIMAL)) {
lbInfo[ldCount].loadBalanceFlag = 0;
+ continue;
+ }
+ lbInfo[ldCount].loadBalanceFlag = 1;
}
}
@@ -1152,7 +1149,7 @@ mrsas_update_load_balance_params(MR_DRV_RAID_MAP_ALL * map,
*
* Used to set the PD logical block address in CDB for FP IOs.
*/
-void
+void
mrsas_set_pd_lba(MRSAS_RAID_SCSI_IO_REQUEST * io_request, u_int8_t cdb_len,
struct IO_REQUEST_INFO *io_info, union ccb *ccb,
MR_DRV_RAID_MAP_ALL * local_map_ptr, u_int32_t ref_tag,
@@ -1299,6 +1296,7 @@ mrsas_set_pd_lba(MRSAS_RAID_SCSI_IO_REQUEST * io_request, u_int8_t cdb_len,
}
/* Fall through normal case, just load LBA here */
u_int8_t val = cdb[1] & 0xE0;
+
switch (cdb_len) {
case 6:
cdb[3] = (u_int8_t)(start_blk & 0xff);
@@ -1332,57 +1330,94 @@ mrsas_set_pd_lba(MRSAS_RAID_SCSI_IO_REQUEST * io_request, u_int8_t cdb_len,
}
/*
- * mrsas_get_best_arm: Determine the best spindle arm
- * Inputs: Load balance info
+ * mrsas_get_best_arm_pd: Determine the best spindle arm
+ * Inputs:
+ * sc - HBA instance
+ * lbInfo - Load balance info
+ * io_info - IO request info
*
* This function determines and returns the best arm by looking at the
* parameters of the last PD access.
*/
-u_int8_t
-mrsas_get_best_arm(PLD_LOAD_BALANCE_INFO lbInfo, u_int8_t arm,
- u_int64_t block, u_int32_t count)
+u_int8_t
+mrsas_get_best_arm_pd(struct mrsas_softc *sc,
+ PLD_LOAD_BALANCE_INFO lbInfo, struct IO_REQUEST_INFO *io_info)
{
- u_int16_t pend0, pend1;
+ MR_LD_RAID *raid;
+ MR_DRV_RAID_MAP_ALL *drv_map;
+ u_int16_t pend0, pend1, ld;
u_int64_t diff0, diff1;
- u_int8_t bestArm;
+ u_int8_t bestArm, pd0, pd1, span, arm;
+ u_int32_t arRef, span_row_size;
+
+ u_int64_t block = io_info->ldStartBlock;
+ u_int32_t count = io_info->numBlocks;
+
+ span = ((io_info->span_arm & RAID_CTX_SPANARM_SPAN_MASK)
+ >> RAID_CTX_SPANARM_SPAN_SHIFT);
+ arm = (io_info->span_arm & RAID_CTX_SPANARM_ARM_MASK);
+
+ drv_map = sc->ld_drv_map[(sc->map_id & 1)];
+ ld = MR_TargetIdToLdGet(io_info->ldTgtId, drv_map);
+ raid = MR_LdRaidGet(ld, drv_map);
+ span_row_size = sc->UnevenSpanSupport ?
+ SPAN_ROW_SIZE(drv_map, ld, span) : raid->rowSize;
+
+ arRef = MR_LdSpanArrayGet(ld, span, drv_map);
+ pd0 = MR_ArPdGet(arRef, arm, drv_map);
+ pd1 = MR_ArPdGet(arRef, (arm + 1) >= span_row_size ?
+ (arm + 1 - span_row_size) : arm + 1, drv_map);
/* get the pending cmds for the data and mirror arms */
- pend0 = mrsas_atomic_read(&lbInfo->scsi_pending_cmds[0]);
- pend1 = mrsas_atomic_read(&lbInfo->scsi_pending_cmds[1]);
+ pend0 = mrsas_atomic_read(&lbInfo->scsi_pending_cmds[pd0]);
+ pend1 = mrsas_atomic_read(&lbInfo->scsi_pending_cmds[pd1]);
/* Determine the disk whose head is nearer to the req. block */
- diff0 = ABS_DIFF(block, lbInfo->last_accessed_block[0]);
- diff1 = ABS_DIFF(block, lbInfo->last_accessed_block[1]);
- bestArm = (diff0 <= diff1 ? 0 : 1);
+ diff0 = ABS_DIFF(block, lbInfo->last_accessed_block[pd0]);
+ diff1 = ABS_DIFF(block, lbInfo->last_accessed_block[pd1]);
+ bestArm = (diff0 <= diff1 ? arm : arm ^ 1);
- if ((bestArm == arm && pend0 > pend1 + 16) || (bestArm != arm && pend1 > pend0 + 16))
+ if ((bestArm == arm && pend0 > pend1 + sc->lb_pending_cmds) ||
+ (bestArm != arm && pend1 > pend0 + sc->lb_pending_cmds))
bestArm ^= 1;
/* Update the last accessed block on the correct pd */
- lbInfo->last_accessed_block[bestArm] = block + count - 1;
+ lbInfo->last_accessed_block[bestArm == arm ? pd0 : pd1] = block + count - 1;
+ io_info->span_arm = (span << RAID_CTX_SPANARM_SPAN_SHIFT) | bestArm;
+ io_info->pd_after_lb = (bestArm == arm) ? pd0 : pd1;
+#if SPAN_DEBUG
+ if (arm != bestArm)
+ printf("AVAGO Debug R1 Load balance occur - span 0x%x arm 0x%x bestArm 0x%x "
+ "io_info->span_arm 0x%x\n",
+ span, arm, bestArm, io_info->span_arm);
+#endif
- return bestArm;
+ return io_info->pd_after_lb;
}
/*
* mrsas_get_updated_dev_handle: Get the update dev handle
- * Inputs: Load balance info io_info pointer
+ * Inputs:
+ * sc - Adapter instance soft state
+ * lbInfo - Load balance info
+ * io_info - io_info pointer
*
* This function determines and returns the updated dev handle.
*/
-u_int16_t
-mrsas_get_updated_dev_handle(PLD_LOAD_BALANCE_INFO lbInfo,
- struct IO_REQUEST_INFO *io_info)
+u_int16_t
+mrsas_get_updated_dev_handle(struct mrsas_softc *sc,
+ PLD_LOAD_BALANCE_INFO lbInfo, struct IO_REQUEST_INFO *io_info)
{
- u_int8_t arm, old_arm;
+ u_int8_t arm_pd;
u_int16_t devHandle;
+ MR_DRV_RAID_MAP_ALL *drv_map;
- old_arm = lbInfo->raid1DevHandle[0] == io_info->devHandle ? 0 : 1;
+ drv_map = sc->ld_drv_map[(sc->map_id & 1)];
/* get best new arm */
- arm = mrsas_get_best_arm(lbInfo, old_arm, io_info->ldStartBlock, io_info->numBlocks);
- devHandle = lbInfo->raid1DevHandle[arm];
- mrsas_atomic_inc(&lbInfo->scsi_pending_cmds[arm]);
+ arm_pd = mrsas_get_best_arm_pd(sc, lbInfo, io_info);
+ devHandle = MR_PdDevHandleGet(arm_pd, drv_map);
+ mrsas_atomic_inc(&lbInfo->scsi_pending_cmds[arm_pd]);
return devHandle;
}
@@ -1471,6 +1506,7 @@ MR_GetPhyParams(struct mrsas_softc *sc, u_int32_t ld,
*pdBlock += stripRef + MR_LdSpanPtrGet(ld, span, map)->startBlk;
pRAID_Context->spanArm = (span << RAID_CTX_SPANARM_SPAN_SHIFT) | physArm;
+ io_info->span_arm = pRAID_Context->spanArm;
return retval;
}
diff --git a/sys/dev/mrsas/mrsas_ioctl.c b/sys/dev/mrsas/mrsas_ioctl.c
index 8e2aead..3c4dbf9 100644
--- a/sys/dev/mrsas/mrsas_ioctl.c
+++ b/sys/dev/mrsas/mrsas_ioctl.c
@@ -1,6 +1,7 @@
/*
+ * Copyright (c) 2015, AVAGO Tech. All rights reserved. Author: Marian Choy
* Copyright (c) 2014, LSI Corp. All rights reserved. Author: Marian Choy
- * Support: freebsdraid@lsi.com
+ * Support: freebsdraid@avagotech.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -31,7 +32,7 @@
* those of the authors and should not be interpreted as representing
* official policies,either expressed or implied, of the FreeBSD Project.
*
- * Send feedback to: <megaraidfbsd@lsi.com> Mail to: LSI Corporation, 1621
+ * Send feedback to: <megaraidfbsd@avagotech.com> Mail to: AVAGO TECHNOLOGIES, 1621
* Barber Lane, Milpitas, CA 95035 ATTN: MegaRaid FreeBSD
*
*/
@@ -238,7 +239,7 @@ mrsas_passthru(struct mrsas_softc *sc, void *arg, u_long ioctlCmd)
}
sense_ptr =
(unsigned long *)((unsigned long)cmd->frame + user_ioc->sense_off);
- sense_ptr = ioctl_sense_mem;
+ *sense_ptr = ioctl_sense_phys_addr;
}
/*
* Set the sync_cmd flag so that the ISR knows not to complete this
@@ -296,13 +297,14 @@ out:
/*
* Release sense buffer
*/
- if (ioctl_sense_phys_addr)
- bus_dmamap_unload(ioctl_sense_tag, ioctl_sense_dmamap);
- if (ioctl_sense_mem != NULL)
- bus_dmamem_free(ioctl_sense_tag, ioctl_sense_mem, ioctl_sense_dmamap);
- if (ioctl_sense_tag != NULL)
- bus_dma_tag_destroy(ioctl_sense_tag);
-
+ if (user_ioc->sense_len) {
+ if (ioctl_sense_phys_addr)
+ bus_dmamap_unload(ioctl_sense_tag, ioctl_sense_dmamap);
+ if (ioctl_sense_mem != NULL)
+ bus_dmamem_free(ioctl_sense_tag, ioctl_sense_mem, ioctl_sense_dmamap);
+ if (ioctl_sense_tag != NULL)
+ bus_dma_tag_destroy(ioctl_sense_tag);
+ }
/*
* Release data buffers
*/
diff --git a/sys/dev/mrsas/mrsas_ioctl.h b/sys/dev/mrsas/mrsas_ioctl.h
index bf05a7d..c43fc6d 100644
--- a/sys/dev/mrsas/mrsas_ioctl.h
+++ b/sys/dev/mrsas/mrsas_ioctl.h
@@ -1,6 +1,7 @@
/*
+ * Copyright (c) 2015, AVAGO Tech. All rights reserved. Author: Marian Choy
* Copyright (c) 2014, LSI Corp. All rights reserved. Author: Marian Choy
- * Support: freebsdraid@lsi.com
+ * Support: freebsdraid@avagotech.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -31,7 +32,7 @@
* those of the authors and should not be interpreted as representing
* official policies,either expressed or implied, of the FreeBSD Project.
*
- * Send feedback to: <megaraidfbsd@lsi.com> Mail to: LSI Corporation, 1621
+ * Send feedback to: <megaraidfbsd@avagotech.com> Mail to: AVAGO TECHNOLOGIES, 1621
* Barber Lane, Milpitas, CA 95035 ATTN: MegaRaid FreeBSD
*
*/
@@ -64,6 +65,7 @@ __FBSDID("$FreeBSD$");
* into a somewhat unique, 32-bit value.
*/
+#define MRSAS_IOC_GET_PCI_INFO _IOR('M', 7, MRSAS_DRV_PCI_INFORMATION)
#define MRSAS_IOC_FIRMWARE_PASS_THROUGH64 _IOWR('M', 1, struct mrsas_iocpacket)
#ifdef COMPAT_FREEBSD32
#define MRSAS_IOC_FIRMWARE_PASS_THROUGH32 _IOWR('M', 1, struct mrsas_iocpacket32)
diff --git a/sys/dev/mrsas/mrsas_linux.c b/sys/dev/mrsas/mrsas_linux.c
index 8a3db0b..15f38c5 100644
--- a/sys/dev/mrsas/mrsas_linux.c
+++ b/sys/dev/mrsas/mrsas_linux.c
@@ -1,6 +1,7 @@
/*
+ * Copyright (c) 2015, AVAGO Tech. All rights reserved. Author: Kashyap Desai,
* Copyright (c) 2014, LSI Corp. All rights reserved. Author: Kashyap Desai,
- * Sibananda Sahu Support: freebsdraid@lsi.com
+ * Sibananda Sahu Support: freebsdraid@avagotech.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -31,7 +32,7 @@
* those of the authors and should not be interpreted as representing
* official policies,either expressed or implied, of the FreeBSD Project.
*
- * Send feedback to: <megaraidfbsd@lsi.com> Mail to: LSI Corporation, 1621
+ * Send feedback to: <megaraidfbsd@avagotech.com> Mail to: AVAGO TECHNOLOGIES, 1621
* Barber Lane, Milpitas, CA 95035 ATTN: MegaRaid FreeBSD
*
*/
diff --git a/sys/dev/mwl/if_mwl.c b/sys/dev/mwl/if_mwl.c
index 89a39c0..5997dbc 100644
--- a/sys/dev/mwl/if_mwl.c
+++ b/sys/dev/mwl/if_mwl.c
@@ -363,7 +363,7 @@ mwl_attach(uint16_t devid, struct mwl_softc *sc)
if (error != 0) /* NB: mwl_setupdma prints msg */
goto bad1;
- callout_init(&sc->sc_timer, CALLOUT_MPSAFE);
+ callout_init(&sc->sc_timer, 1);
callout_init_mtx(&sc->sc_watchdog, &sc->sc_mtx, 0);
sc->sc_tq = taskqueue_create("mwl_taskq", M_NOWAIT,
diff --git a/sys/dev/nand/nandsim_chip.c b/sys/dev/nand/nandsim_chip.c
index f04ad80..3241e1a 100644
--- a/sys/dev/nand/nandsim_chip.c
+++ b/sys/dev/nand/nandsim_chip.c
@@ -94,7 +94,7 @@ nandsim_chip_init(struct nandsim_softc* sc, uint8_t chip_num,
return (NULL);
mtx_init(&chip->ns_lock, "nandsim lock", NULL, MTX_DEF);
- callout_init(&chip->ns_callout, CALLOUT_MPSAFE);
+ callout_init(&chip->ns_callout, 1);
STAILQ_INIT(&chip->nandsim_events);
chip->chip_num = chip_num;
diff --git a/sys/dev/nand/nfc_rb.c b/sys/dev/nand/nfc_rb.c
new file mode 100644
index 0000000..64f888a
--- /dev/null
+++ b/sys/dev/nand/nfc_rb.c
@@ -0,0 +1,275 @@
+/*-
+ * Copyright (C) 2015 Justin Hibbits
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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.
+ */
+
+/* RouterBoard 600/800 NAND controller driver. */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/malloc.h>
+#include <sys/rman.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/time.h>
+
+#include <machine/bus.h>
+
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include <dev/nand/nand.h>
+#include <dev/nand/nandbus.h>
+#include "nfc_if.h"
+#include "gpio_if.h"
+
+#define RB_NAND_DATA (0x00)
+
+struct rb_nand_softc {
+ struct nand_softc nand_dev;
+ struct resource *sc_mem;
+ int rid;
+ device_t sc_gpio;
+ uint32_t sc_rdy_pin;
+ uint32_t sc_nce_pin;
+ uint32_t sc_cle_pin;
+ uint32_t sc_ale_pin;
+};
+
+static int rb_nand_attach(device_t);
+static int rb_nand_probe(device_t);
+static int rb_nand_send_command(device_t, uint8_t);
+static int rb_nand_send_address(device_t, uint8_t);
+static uint8_t rb_nand_read_byte(device_t);
+static void rb_nand_read_buf(device_t, void *, uint32_t);
+static void rb_nand_write_buf(device_t, void *, uint32_t);
+static int rb_nand_select_cs(device_t, uint8_t);
+static int rb_nand_read_rnb(device_t);
+
+static device_method_t rb_nand_methods[] = {
+ DEVMETHOD(device_probe, rb_nand_probe),
+ DEVMETHOD(device_attach, rb_nand_attach),
+
+ DEVMETHOD(nfc_send_command, rb_nand_send_command),
+ DEVMETHOD(nfc_send_address, rb_nand_send_address),
+ DEVMETHOD(nfc_read_byte, rb_nand_read_byte),
+ DEVMETHOD(nfc_read_buf, rb_nand_read_buf),
+ DEVMETHOD(nfc_write_buf, rb_nand_write_buf),
+ DEVMETHOD(nfc_select_cs, rb_nand_select_cs),
+ DEVMETHOD(nfc_read_rnb, rb_nand_read_rnb),
+
+ { 0, 0 },
+};
+
+static driver_t rb_nand_driver = {
+ "nand",
+ rb_nand_methods,
+ sizeof(struct rb_nand_softc),
+};
+
+static devclass_t rb_nand_devclass;
+DRIVER_MODULE(rb_nand, ofwbus, rb_nand_driver, rb_nand_devclass, 0, 0);
+
+#if 0
+static const struct nand_ecc_data rb_ecc = {
+ .eccsize = 6,
+ .eccmode = NAND_ECC_SOFT,
+ .eccbytes = 6,
+ .eccpositions = { 8, 9, 10, 13, 14, 15 },
+};
+#endif
+
+static int
+rb_nand_probe(device_t dev)
+{
+ const char *device_type;
+
+ device_type = ofw_bus_get_type(dev);
+
+ if (!device_type || strcmp(device_type, "rb,nand"))
+ return (ENXIO);
+
+ device_set_desc(dev, "RouterBoard 333/600/800 NAND controller");
+ return (BUS_PROBE_DEFAULT);
+}
+
+static int
+rb_nand_attach(device_t dev)
+{
+ struct rb_nand_softc *sc;
+ phandle_t node;
+ uint32_t ale[2],cle[2],nce[2],rdy[2];
+ int err;
+
+ sc = device_get_softc(dev);
+ node = ofw_bus_get_node(dev);
+
+ if (OF_getprop(node, "ale", ale, sizeof(ale)) <= 0) {
+ return (ENXIO);
+ }
+ if (OF_getprop(node, "cle", cle, sizeof(cle)) <= 0) {
+ return (ENXIO);
+ }
+ if (OF_getprop(node, "nce", nce, sizeof(nce)) <= 0) {
+ return (ENXIO);
+ }
+ if (OF_getprop(node, "rdy", rdy, sizeof(rdy)) <= 0) {
+ return (ENXIO);
+ }
+
+ if (ale[0] != cle[0] || ale[0] != nce[0] || ale[0] != rdy[0]) {
+ device_printf(dev, "GPIO handles for signals must match.\n");
+ return (ENXIO);
+ }
+ sc->sc_ale_pin = ale[1];
+ sc->sc_cle_pin = cle[1];
+ sc->sc_nce_pin = nce[1];
+ sc->sc_rdy_pin = rdy[1];
+
+ sc->sc_gpio = OF_device_from_xref(ale[0]);
+ if (sc->sc_gpio == NULL) {
+ device_printf(dev, "No GPIO resource found!\n");
+ return (ENXIO);
+ }
+
+ sc->sc_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->rid,
+ RF_ACTIVE);
+ if (sc->sc_mem == NULL) {
+ device_printf(dev, "could not allocate resources!\n");
+ return (ENXIO);
+ }
+
+ nand_init(&sc->nand_dev, dev, NAND_ECC_SOFT, 0, 0, NULL, NULL);
+
+ err = nandbus_create(dev);
+
+ return (err);
+}
+
+static int
+rb_nand_send_command(device_t dev, uint8_t command)
+{
+ struct rb_nand_softc *sc;
+
+ nand_debug(NDBG_DRV,"rb_nand: send command %x", command);
+
+ sc = device_get_softc(dev);
+ GPIO_PIN_SET(sc->sc_gpio, sc->sc_cle_pin, 1);
+ GPIO_PIN_SET(sc->sc_gpio, sc->sc_ale_pin, 0);
+ GPIO_PIN_SET(sc->sc_gpio, sc->sc_nce_pin, 0);
+ bus_write_1(sc->sc_mem, RB_NAND_DATA, command);
+ GPIO_PIN_SET(sc->sc_gpio, sc->sc_cle_pin, 0);
+ return (0);
+}
+
+static int
+rb_nand_send_address(device_t dev, uint8_t addr)
+{
+ struct rb_nand_softc *sc;
+
+ nand_debug(NDBG_DRV,"rb_nand: send address %x", addr);
+
+ sc = device_get_softc(dev);
+ GPIO_PIN_SET(sc->sc_gpio, sc->sc_cle_pin, 0);
+ GPIO_PIN_SET(sc->sc_gpio, sc->sc_ale_pin, 1);
+ GPIO_PIN_SET(sc->sc_gpio, sc->sc_nce_pin, 0);
+ bus_write_1(sc->sc_mem, RB_NAND_DATA, addr);
+ GPIO_PIN_SET(sc->sc_gpio, sc->sc_ale_pin, 0);
+ return (0);
+}
+
+static uint8_t
+rb_nand_read_byte(device_t dev)
+{
+ struct rb_nand_softc *sc;
+ uint8_t data;
+
+ sc = device_get_softc(dev);
+ data = bus_read_1(sc->sc_mem, RB_NAND_DATA);
+
+ nand_debug(NDBG_DRV,"rb_nand: read %x", data);
+
+ return (data);
+}
+
+static void
+rb_nand_read_buf(device_t dev, void* buf, uint32_t len)
+{
+ struct rb_nand_softc *sc;
+
+ sc = device_get_softc(dev);
+
+ bus_read_region_1(sc->sc_mem, RB_NAND_DATA, buf, len);
+}
+
+static void
+rb_nand_write_buf(device_t dev, void* buf, uint32_t len)
+{
+ struct rb_nand_softc *sc;
+ int i;
+ uint8_t *b = (uint8_t*)buf;
+
+ sc = device_get_softc(dev);
+
+ for (i = 0; i < len; i++) {
+#ifdef NAND_DEBUG
+ if (!(i % 16))
+ printf("%s", i == 0 ? "rb_nand:\n" : "\n");
+ printf(" %x", b[i]);
+ if (i == len - 1)
+ printf("\n");
+#endif
+ bus_write_1(sc->sc_mem, RB_NAND_DATA, b[i]);
+ }
+}
+
+static int
+rb_nand_select_cs(device_t dev, uint8_t cs)
+{
+
+ if (cs > 0)
+ return (ENODEV);
+
+ return (0);
+}
+
+static int
+rb_nand_read_rnb(device_t dev)
+{
+ struct rb_nand_softc *sc;
+ uint32_t rdy_bit;
+
+ sc = device_get_softc(dev);
+ GPIO_PIN_GET(sc->sc_gpio, sc->sc_rdy_pin, &rdy_bit);
+
+ return (rdy_bit); /* ready */
+}
diff --git a/sys/dev/netmap/netmap_mem2.c b/sys/dev/netmap/netmap_mem2.c
index fa891ec..c823376 100644
--- a/sys/dev/netmap/netmap_mem2.c
+++ b/sys/dev/netmap/netmap_mem2.c
@@ -130,9 +130,9 @@ struct netmap_mem_d {
/* the three allocators */
struct netmap_obj_pool pools[NETMAP_POOLS_NR];
- netmap_mem_config_t config;
- netmap_mem_finalize_t finalize;
- netmap_mem_deref_t deref;
+ netmap_mem_config_t config; /* called with NMA_LOCK held */
+ netmap_mem_finalize_t finalize; /* called with NMA_LOCK held */
+ netmap_mem_deref_t deref; /* called with NMA_LOCK held */
nm_memid_t nm_id; /* allocator identifier */
int nm_grp; /* iommu groupd id */
@@ -751,6 +751,12 @@ netmap_reset_obj_allocator(struct netmap_obj_pool *p)
u_int i;
size_t sz = p->_clustsize;
+ /*
+ * Free each cluster allocated in
+ * netmap_finalize_obj_allocator(). The cluster start
+ * addresses are stored at multiples of p->_clusterentries
+ * in the lut.
+ */
for (i = 0; i < p->objtotal; i += p->_clustentries) {
if (p->lut[i].vaddr)
contigfree(p->lut[i].vaddr, sz, M_NETMAP);
@@ -929,6 +935,7 @@ netmap_finalize_obj_allocator(struct netmap_obj_pool *p)
if (i % p->_clustentries == 0 && p->lut[i].vaddr)
contigfree(p->lut[i].vaddr,
n, M_NETMAP);
+ p->lut[i].vaddr = NULL;
}
out:
p->objtotal = i;
@@ -936,6 +943,17 @@ netmap_finalize_obj_allocator(struct netmap_obj_pool *p)
p->numclusters = (i + p->_clustentries - 1) / p->_clustentries;
break;
}
+ /*
+ * Set bitmap and lut state for all buffers in the current
+ * cluster.
+ *
+ * [i, lim) is the set of buffer indexes that cover the
+ * current cluster.
+ *
+ * 'clust' is really the address of the current buffer in
+ * the current cluster as we index through it with a stride
+ * of p->_objsize.
+ */
for (; i < lim; i++, clust += p->_objsize) {
p->bitmap[ (i>>5) ] |= ( 1 << (i & 31) );
p->lut[i].vaddr = clust;
@@ -1092,10 +1110,8 @@ static int
netmap_mem_private_finalize(struct netmap_mem_d *nmd)
{
int err;
- NMA_LOCK(nmd);
nmd->refcount++;
err = netmap_mem_finalize_all(nmd);
- NMA_UNLOCK(nmd);
return err;
}
@@ -1103,10 +1119,8 @@ netmap_mem_private_finalize(struct netmap_mem_d *nmd)
static void
netmap_mem_private_deref(struct netmap_mem_d *nmd)
{
- NMA_LOCK(nmd);
if (--nmd->refcount <= 0)
netmap_mem_reset_all(nmd);
- NMA_UNLOCK(nmd);
}
@@ -1242,10 +1256,7 @@ static int
netmap_mem_global_finalize(struct netmap_mem_d *nmd)
{
int err;
-
- NMA_LOCK(nmd);
-
-
+
/* update configuration if changed */
if (netmap_mem_global_config(nmd))
goto out;
@@ -1268,8 +1279,6 @@ out:
nmd->refcount--;
err = nmd->lasterr;
- NMA_UNLOCK(nmd);
-
return err;
}
@@ -1518,7 +1527,6 @@ netmap_mem_if_delete(struct netmap_adapter *na, struct netmap_if *nifp)
static void
netmap_mem_global_deref(struct netmap_mem_d *nmd)
{
- NMA_LOCK(nmd);
nmd->refcount--;
if (!nmd->refcount)
@@ -1526,7 +1534,6 @@ netmap_mem_global_deref(struct netmap_mem_d *nmd)
if (netmap_verbose)
D("refcount = %d", nmd->refcount);
- NMA_UNLOCK(nmd);
}
int
@@ -1535,7 +1542,9 @@ netmap_mem_finalize(struct netmap_mem_d *nmd, struct netmap_adapter *na)
if (nm_mem_assign_group(nmd, na->pdev) < 0) {
return ENOMEM;
} else {
+ NMA_LOCK(nmd);
nmd->finalize(nmd);
+ NMA_UNLOCK(nmd);
}
if (!nmd->lasterr && na->pdev)
@@ -1549,6 +1558,48 @@ netmap_mem_deref(struct netmap_mem_d *nmd, struct netmap_adapter *na)
{
NMA_LOCK(nmd);
netmap_mem_unmap(&nmd->pools[NETMAP_BUF_POOL], na);
+ if (nmd->refcount == 1) {
+ u_int i;
+
+ /*
+ * Reset the allocator when it falls out of use so that any
+ * pool resources leaked by unclean application exits are
+ * reclaimed.
+ */
+ for (i = 0; i < NETMAP_POOLS_NR; i++) {
+ struct netmap_obj_pool *p;
+ u_int j;
+
+ p = &nmd->pools[i];
+ p->objfree = p->objtotal;
+ /*
+ * Reproduce the net effect of the M_ZERO malloc()
+ * and marking of free entries in the bitmap that
+ * occur in finalize_obj_allocator()
+ */
+ memset(p->bitmap,
+ '\0',
+ sizeof(uint32_t) * ((p->objtotal + 31) / 32));
+
+ /*
+ * Set all the bits in the bitmap that have
+ * corresponding buffers to 1 to indicate they are
+ * free.
+ */
+ for (j = 0; j < p->objtotal; j++) {
+ if (p->lut[j].vaddr != NULL) {
+ p->bitmap[ (j>>5) ] |= ( 1 << (j & 31) );
+ }
+ }
+ }
+
+ /*
+ * Per netmap_mem_finalize_all(),
+ * buffers 0 and 1 are reserved
+ */
+ nmd->pools[NETMAP_BUF_POOL].objfree -= 2;
+ nmd->pools[NETMAP_BUF_POOL].bitmap[0] = ~3;
+ }
+ nmd->deref(nmd);
NMA_UNLOCK(nmd);
- return nmd->deref(nmd);
}
diff --git a/sys/dev/ntb/if_ntb/if_ntb.c b/sys/dev/ntb/if_ntb/if_ntb.c
index e86ed53..84716d9 100644
--- a/sys/dev/ntb/if_ntb/if_ntb.c
+++ b/sys/dev/ntb/if_ntb/if_ntb.c
@@ -555,8 +555,8 @@ ntb_transport_init_queue(struct ntb_netdev *nt, unsigned int qp_num)
qp->tx_index = 0;
callout_init(&qp->link_work, 0);
- callout_init(&qp->queue_full, CALLOUT_MPSAFE);
- callout_init(&qp->rx_full, CALLOUT_MPSAFE);
+ callout_init(&qp->queue_full, 1);
+ callout_init(&qp->rx_full, 1);
mtx_init(&qp->ntb_rx_pend_q_lock, "ntb rx pend q", NULL, MTX_SPIN);
mtx_init(&qp->ntb_rx_free_q_lock, "ntb rx free q", NULL, MTX_SPIN);
diff --git a/sys/dev/ntb/ntb_hw/ntb_hw.c b/sys/dev/ntb/ntb_hw/ntb_hw.c
index 019f2a7..731dfaf 100644
--- a/sys/dev/ntb/ntb_hw/ntb_hw.c
+++ b/sys/dev/ntb/ntb_hw/ntb_hw.c
@@ -266,8 +266,8 @@ ntb_attach(device_t device)
ntb->features = p->features;
/* Heartbeat timer for NTB_SOC since there is no link interrupt */
- callout_init(&ntb->heartbeat_timer, CALLOUT_MPSAFE);
- callout_init(&ntb->lr_timer, CALLOUT_MPSAFE);
+ callout_init(&ntb->heartbeat_timer, 1);
+ callout_init(&ntb->lr_timer, 1);
DETACH_ON_ERROR(ntb_map_pci_bars(ntb));
DETACH_ON_ERROR(ntb_initialize_hw(ntb));
diff --git a/sys/dev/nxge/if_nxge.c b/sys/dev/nxge/if_nxge.c
index 9fa2cfe..90871ae 100644
--- a/sys/dev/nxge/if_nxge.c
+++ b/sys/dev/nxge/if_nxge.c
@@ -1744,7 +1744,7 @@ xge_device_init(xge_lldev_t *lldev, xge_hal_channel_reopen_e option)
return;
/* Initializing timer */
- callout_init(&lldev->timer, CALLOUT_MPSAFE);
+ callout_init(&lldev->timer, 1);
xge_trace(XGE_TRACE, "Set MTU size");
status = xge_hal_device_mtu_set(hldev, ifnetp->if_mtu);
diff --git a/sys/dev/oce/oce_if.c b/sys/dev/oce/oce_if.c
index 062181b..826cd3c 100644
--- a/sys/dev/oce/oce_if.c
+++ b/sys/dev/oce/oce_if.c
@@ -341,7 +341,7 @@ oce_attach(device_t dev)
oce_add_sysctls(sc);
- callout_init(&sc->timer, CALLOUT_MPSAFE);
+ callout_init(&sc->timer, 1);
rc = callout_reset(&sc->timer, 2 * hz, oce_local_timer, sc);
if (rc)
goto stats_free;
diff --git a/sys/dev/ofw/ofw_bus_subr.c b/sys/dev/ofw/ofw_bus_subr.c
index 6756398..5063930 100644
--- a/sys/dev/ofw/ofw_bus_subr.c
+++ b/sys/dev/ofw/ofw_bus_subr.c
@@ -176,12 +176,37 @@ ofw_bus_status_okay(device_t dev)
return (0);
}
+static int
+ofw_bus_node_is_compatible(const char *compat, int len, const char *onecompat)
+{
+ int onelen, l, ret;
+
+ onelen = strlen(onecompat);
+
+ ret = 0;
+ while (len > 0) {
+ if (strlen(compat) == onelen &&
+ strncasecmp(compat, onecompat, onelen) == 0) {
+ /* Found it. */
+ ret = 1;
+ break;
+ }
+
+ /* Slide to the next sub-string. */
+ l = strlen(compat) + 1;
+ compat += l;
+ len -= l;
+ }
+
+ return (ret);
+}
+
int
ofw_bus_is_compatible(device_t dev, const char *onecompat)
{
phandle_t node;
const char *compat;
- int len, onelen, l;
+ int len;
if ((compat = ofw_bus_get_compat(dev)) == NULL)
return (0);
@@ -193,20 +218,7 @@ ofw_bus_is_compatible(device_t dev, const char *onecompat)
if ((len = OF_getproplen(node, "compatible")) <= 0)
return (0);
- onelen = strlen(onecompat);
-
- while (len > 0) {
- if (strlen(compat) == onelen &&
- strncasecmp(compat, onecompat, onelen) == 0)
- /* Found it. */
- return (1);
-
- /* Slide to the next sub-string. */
- l = strlen(compat) + 1;
- compat += l;
- len -= l;
- }
- return (0);
+ return (ofw_bus_node_is_compatible(compat, len, onecompat));
}
int
@@ -418,7 +430,8 @@ ofw_bus_reg_to_rl(device_t dev, phandle_t node, pcell_t acells, pcell_t scells,
}
int
-ofw_bus_intr_to_rl(device_t dev, phandle_t node, struct resource_list *rl)
+ofw_bus_intr_to_rl(device_t dev, phandle_t node,
+ struct resource_list *rl, int *rlen)
{
phandle_t iparent;
uint32_t icells, *intr;
@@ -483,7 +496,36 @@ ofw_bus_intr_to_rl(device_t dev, phandle_t node, struct resource_list *rl)
irqnum = ofw_bus_map_intr(dev, iparent, icells, &intr[i]);
resource_list_add(rl, SYS_RES_IRQ, rid++, irqnum, irqnum, 1);
}
+ if (rlen != NULL)
+ *rlen = rid;
free(intr, M_OFWPROP);
return (err);
}
+phandle_t
+ofw_bus_find_compatible(phandle_t node, const char *onecompat)
+{
+ phandle_t child, ret;
+ void *compat;
+ int len;
+
+ /*
+ * Traverse all children of 'start' node, and find first with
+ * matching 'compatible' property.
+ */
+ for (child = OF_child(node); child != 0; child = OF_peer(child)) {
+ len = OF_getprop_alloc(child, "compatible", 1, &compat);
+ if (len >= 0) {
+ ret = ofw_bus_node_is_compatible(compat, len,
+ onecompat);
+ free(compat, M_OFWPROP);
+ if (ret != 0)
+ return (child);
+ }
+
+ ret = ofw_bus_find_compatible(child, onecompat);
+ if (ret != 0)
+ return (ret);
+ }
+ return (0);
+}
diff --git a/sys/dev/ofw/ofw_bus_subr.h b/sys/dev/ofw/ofw_bus_subr.h
index 53a609b..be35711 100644
--- a/sys/dev/ofw/ofw_bus_subr.h
+++ b/sys/dev/ofw/ofw_bus_subr.h
@@ -75,7 +75,7 @@ int ofw_bus_search_intrmap(void *, int, void *, int, void *, int, void *,
/* Routines for parsing device-tree data into resource lists. */
int ofw_bus_reg_to_rl(device_t, phandle_t, pcell_t, pcell_t,
struct resource_list *);
-int ofw_bus_intr_to_rl(device_t, phandle_t, struct resource_list *);
+int ofw_bus_intr_to_rl(device_t, phandle_t, struct resource_list *, int *);
/* Helper to get device status property */
const char *ofw_bus_get_status(device_t dev);
@@ -101,4 +101,7 @@ const struct ofw_compat_data *
/* Helper routine for checking existence of a prop */
int ofw_bus_has_prop(device_t, const char *);
+/* Helper to search for a child with a given compat prop */
+phandle_t ofw_bus_find_compatible(phandle_t, const char *);
+
#endif /* !_DEV_OFW_OFW_BUS_SUBR_H_ */
diff --git a/sys/dev/ofw/ofw_iicbus.c b/sys/dev/ofw/ofw_iicbus.c
index f6d1be5..e6816c1 100644
--- a/sys/dev/ofw/ofw_iicbus.c
+++ b/sys/dev/ofw/ofw_iicbus.c
@@ -72,7 +72,7 @@ static device_method_t ofw_iicbus_methods[] = {
};
struct ofw_iicbus_devinfo {
- struct iicbus_ivar opd_dinfo;
+ struct iicbus_ivar opd_dinfo; /* Must be the first. */
struct ofw_bus_devinfo opd_obdinfo;
};
@@ -153,7 +153,11 @@ ofw_iicbus_attach(device_t dev)
free(dinfo, M_DEVBUF);
continue;
}
+
childdev = device_add_child(dev, NULL, -1);
+ resource_list_init(&dinfo->opd_dinfo.rl);
+ ofw_bus_intr_to_rl(childdev, child,
+ &dinfo->opd_dinfo.rl, NULL);
device_set_ivars(childdev, dinfo);
}
diff --git a/sys/dev/ofw/ofwbus.c b/sys/dev/ofw/ofwbus.c
index 6a81b6e..670abff 100644
--- a/sys/dev/ofw/ofwbus.c
+++ b/sys/dev/ofw/ofwbus.c
@@ -69,7 +69,9 @@ struct ofwbus_softc {
struct rman sc_mem_rman;
};
+#ifndef __aarch64__
static device_identify_t ofwbus_identify;
+#endif
static device_probe_t ofwbus_probe;
static device_attach_t ofwbus_attach;
static bus_alloc_resource_t ofwbus_alloc_resource;
@@ -78,7 +80,9 @@ static bus_release_resource_t ofwbus_release_resource;
static device_method_t ofwbus_methods[] = {
/* Device interface */
+#ifndef __aarch64__
DEVMETHOD(device_identify, ofwbus_identify),
+#endif
DEVMETHOD(device_probe, ofwbus_probe),
DEVMETHOD(device_attach, ofwbus_attach),
@@ -97,6 +101,7 @@ EARLY_DRIVER_MODULE(ofwbus, nexus, ofwbus_driver, ofwbus_devclass, 0, 0,
BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE);
MODULE_VERSION(ofwbus, 1);
+#ifndef __aarch64__
static void
ofwbus_identify(driver_t *driver, device_t parent)
{
@@ -108,11 +113,17 @@ ofwbus_identify(driver_t *driver, device_t parent)
if (device_find_child(parent, "ofwbus", -1) == NULL)
BUS_ADD_CHILD(parent, 0, "ofwbus", -1);
}
+#endif
static int
ofwbus_probe(device_t dev)
{
+#ifdef __aarch64__
+ if (OF_peer(0) == 0)
+ return (ENXIO);
+#endif
+
device_set_desc(dev, "Open Firmware Device Tree");
return (BUS_PROBE_NOWILDCARD);
}
diff --git a/sys/dev/patm/if_patm_attach.c b/sys/dev/patm/if_patm_attach.c
index f4b8c4e..ed48bda 100644
--- a/sys/dev/patm/if_patm_attach.c
+++ b/sys/dev/patm/if_patm_attach.c
@@ -208,7 +208,7 @@ patm_attach(device_t dev)
mtx_init(&sc->tst_lock, "tst lock", NULL, MTX_DEF);
cv_init(&sc->vcc_cv, "vcc_close");
- callout_init(&sc->tst_callout, CALLOUT_MPSAFE);
+ callout_init(&sc->tst_callout, 1);
sysctl_ctx_init(&sc->sysctl_ctx);
diff --git a/sys/dev/pccbb/pccbb_pci.c b/sys/dev/pccbb/pccbb_pci.c
index 7dca418..a82afa2 100644
--- a/sys/dev/pccbb/pccbb_pci.c
+++ b/sys/dev/pccbb/pccbb_pci.c
@@ -502,10 +502,26 @@ cbb_chipinit(struct cbb_softc *sc)
* properly initialized.
*
* The TI125X parts have a different register.
+ *
+ * Note: Only the lower two nibbles matter. When set
+ * to 0, the MFUNC{0,1} pins are GPIO, which isn't
+ * going to work out too well because we specifically
+ * program these parts to parallel interrupt signalling
+ * elsewhere. We preserve the upper bits of this
+ * register since changing them have subtle side effects
+ * for different variants of the card and are
+ * extremely difficult to exaustively test.
+ *
+ * Also, the TI 1510/1520 changed the default for the MFUNC
+ * register from 0x0 to 0x1000 to enable IRQSER by default.
+ * We want to be careful to avoid overriding that, and the
+ * below test will do that. Should this check prove to be
+ * too permissive, we should just check against 0 and 0x1000
+ * and not touch it otherwise.
*/
mux = pci_read_config(sc->dev, CBBR_MFUNC, 4);
sysctrl = pci_read_config(sc->dev, CBBR_SYSCTRL, 4);
- if (mux == 0) {
+ if ((mux & (CBBM_MFUNC_PIN0 | CBBM_MFUNC_PIN1)) == 0) {
mux = (mux & ~CBBM_MFUNC_PIN0) |
CBBM_MFUNC_PIN0_INTA;
if ((sysctrl & CBBM_SYSCTRL_INTRTIE) == 0)
@@ -518,7 +534,8 @@ cbb_chipinit(struct cbb_softc *sc)
/*
* Disable zoom video. Some machines initialize this
* improperly and exerpience has shown that this helps
- * prevent strange behavior.
+ * prevent strange behavior. We don't support zoom
+ * video anyway, so no harm can come from this.
*/
pci_write_config(sc->dev, CBBR_MMCTRL, 0, 4);
break;
diff --git a/sys/dev/pci/pci_iov.c b/sys/dev/pci/pci_iov.c
index e256a5d..4672e55 100644
--- a/sys/dev/pci/pci_iov.c
+++ b/sys/dev/pci/pci_iov.c
@@ -386,7 +386,7 @@ pci_iov_parse_config(struct pcicfg_iov *iov, struct pci_iov_arg *arg,
if (error != 0)
goto out;
- config = nvlist_unpack(packed_config, arg->len);
+ config = nvlist_unpack(packed_config, arg->len, NV_FLAG_IGNORE_CASE);
if (config == NULL) {
error = EINVAL;
goto out;
diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c
index 789a918..585ee86 100644
--- a/sys/dev/pci/pci_pci.c
+++ b/sys/dev/pci/pci_pci.c
@@ -442,16 +442,7 @@ pcib_probe_windows(struct pcib_softc *sc)
dev = sc->dev;
if (pci_clear_pcib) {
- pci_write_config(dev, PCIR_IOBASEL_1, 0xff, 1);
- pci_write_config(dev, PCIR_IOBASEH_1, 0xffff, 2);
- pci_write_config(dev, PCIR_IOLIMITL_1, 0, 1);
- pci_write_config(dev, PCIR_IOLIMITH_1, 0, 2);
- pci_write_config(dev, PCIR_MEMBASE_1, 0xffff, 2);
- pci_write_config(dev, PCIR_MEMLIMIT_1, 0, 2);
- pci_write_config(dev, PCIR_PMBASEL_1, 0xffff, 2);
- pci_write_config(dev, PCIR_PMBASEH_1, 0xffffffff, 4);
- pci_write_config(dev, PCIR_PMLIMITL_1, 0, 2);
- pci_write_config(dev, PCIR_PMLIMITH_1, 0, 4);
+ pcib_bridge_init(dev);
}
/* Determine if the I/O port window is implemented. */
@@ -1115,6 +1106,21 @@ pcib_resume(device_t dev)
return (bus_generic_resume(dev));
}
+void
+pcib_bridge_init(device_t dev)
+{
+ pci_write_config(dev, PCIR_IOBASEL_1, 0xff, 1);
+ pci_write_config(dev, PCIR_IOBASEH_1, 0xffff, 2);
+ pci_write_config(dev, PCIR_IOLIMITL_1, 0, 1);
+ pci_write_config(dev, PCIR_IOLIMITH_1, 0, 2);
+ pci_write_config(dev, PCIR_MEMBASE_1, 0xffff, 2);
+ pci_write_config(dev, PCIR_MEMLIMIT_1, 0, 2);
+ pci_write_config(dev, PCIR_PMBASEL_1, 0xffff, 2);
+ pci_write_config(dev, PCIR_PMBASEH_1, 0xffffffff, 4);
+ pci_write_config(dev, PCIR_PMLIMITL_1, 0, 2);
+ pci_write_config(dev, PCIR_PMLIMITH_1, 0, 4);
+}
+
int
pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
{
diff --git a/sys/dev/pci/pcib_private.h b/sys/dev/pci/pcib_private.h
index 20cb014..bba4ce2 100644
--- a/sys/dev/pci/pcib_private.h
+++ b/sys/dev/pci/pcib_private.h
@@ -145,6 +145,7 @@ void pcib_setup_secbus(device_t dev, struct pcib_secbus *bus,
#endif
int pcib_attach(device_t dev);
void pcib_attach_common(device_t dev);
+void pcib_bridge_init(device_t dev);
#ifdef NEW_PCIB
const char *pcib_child_name(device_t child);
#endif
diff --git a/sys/dev/qlxgb/qla_os.c b/sys/dev/qlxgb/qla_os.c
index 54619cb..da1e34f 100644
--- a/sys/dev/qlxgb/qla_os.c
+++ b/sys/dev/qlxgb/qla_os.c
@@ -378,7 +378,7 @@ qla_pci_attach(device_t dev)
ha->flags.qla_watchdog_active = 1;
ha->flags.qla_watchdog_pause = 1;
- callout_init(&ha->tx_callout, TRUE);
+ callout_init(&ha->tx_callout, 1);
/* create ioctl device interface */
if (qla_make_cdev(ha)) {
diff --git a/sys/dev/qlxgbe/ql_os.c b/sys/dev/qlxgbe/ql_os.c
index 04fbf71..8b7023c 100644
--- a/sys/dev/qlxgbe/ql_os.c
+++ b/sys/dev/qlxgbe/ql_os.c
@@ -419,7 +419,7 @@ qla_pci_attach(device_t dev)
taskqueue_start_threads(&ha->tx_tq, 1, PI_NET, "%s txq",
device_get_nameunit(ha->pci_dev));
- callout_init(&ha->tx_callout, TRUE);
+ callout_init(&ha->tx_callout, 1);
ha->flags.qla_callout_init = 1;
/* create ioctl device interface */
diff --git a/sys/dev/qlxge/qls_os.c b/sys/dev/qlxge/qls_os.c
index 1617d24..878a0e6 100644
--- a/sys/dev/qlxge/qls_os.c
+++ b/sys/dev/qlxge/qls_os.c
@@ -453,7 +453,7 @@ qls_pci_attach(device_t dev)
taskqueue_start_threads(&ha->tx_tq, 1, PI_NET, "%s txq",
device_get_nameunit(ha->pci_dev));
- callout_init(&ha->tx_callout, TRUE);
+ callout_init(&ha->tx_callout, 1);
ha->flags.qla_callout_init = 1;
/* create ioctl device interface */
diff --git a/sys/dev/rndtest/rndtest.c b/sys/dev/rndtest/rndtest.c
index e4fd3b0..871d0b7 100644
--- a/sys/dev/rndtest/rndtest.c
+++ b/sys/dev/rndtest/rndtest.c
@@ -98,7 +98,7 @@ rndtest_attach(device_t dev)
#if __FreeBSD_version < 500000
callout_init(&rsp->rs_to);
#else
- callout_init(&rsp->rs_to, CALLOUT_MPSAFE);
+ callout_init(&rsp->rs_to, 1);
#endif
} else
device_printf(dev, "rndtest_init: no memory for state block\n");
diff --git a/sys/dev/safe/safe.c b/sys/dev/safe/safe.c
index 9b91ed0..2df1f51 100644
--- a/sys/dev/safe/safe.c
+++ b/sys/dev/safe/safe.c
@@ -425,7 +425,7 @@ safe_attach(device_t dev)
#endif
safe_rng_init(sc);
- callout_init(&sc->sc_rngto, CALLOUT_MPSAFE);
+ callout_init(&sc->sc_rngto, 1);
callout_reset(&sc->sc_rngto, hz*safe_rnginterval, safe_rng, sc);
}
#endif /* SAFE_NO_RNG */
diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c
index b9af721..b1fae29 100644
--- a/sys/dev/sdhci/sdhci.c
+++ b/sys/dev/sdhci/sdhci.c
@@ -615,10 +615,16 @@ sdhci_init_slot(device_t dev, struct sdhci_slot *slot, int num)
(slot->opt & SDHCI_HAVE_DMA) ? "DMA" : "PIO");
sdhci_dumpregs(slot);
}
-
+
+ slot->timeout = 10;
+ SYSCTL_ADD_INT(device_get_sysctl_ctx(slot->bus),
+ SYSCTL_CHILDREN(device_get_sysctl_tree(slot->bus)), OID_AUTO,
+ "timeout", CTLFLAG_RW, &slot->timeout, 0,
+ "Maximum timeout for SDHCI transfers (in secs)");
TASK_INIT(&slot->card_task, 0, sdhci_card_task, slot);
callout_init(&slot->card_callout, 1);
callout_init_mtx(&slot->timeout_callout, &slot->mtx, 0);
+
return (0);
}
@@ -872,7 +878,8 @@ sdhci_start_command(struct sdhci_slot *slot, struct mmc_command *cmd)
/* Start command. */
WR2(slot, SDHCI_COMMAND_FLAGS, (cmd->opcode << 8) | (flags & 0xff));
/* Start timeout callout. */
- callout_reset(&slot->timeout_callout, 2*hz, sdhci_timeout, slot);
+ callout_reset(&slot->timeout_callout, slot->timeout * hz,
+ sdhci_timeout, slot);
}
static void
diff --git a/sys/dev/sdhci/sdhci.h b/sys/dev/sdhci/sdhci.h
index b7d1960..3c27d0c 100644
--- a/sys/dev/sdhci/sdhci.h
+++ b/sys/dev/sdhci/sdhci.h
@@ -271,6 +271,7 @@ struct sdhci_slot {
#define SDHCI_HAVE_DMA 1
#define SDHCI_PLATFORM_TRANSFER 2
u_char version;
+ int timeout; /* Transfer timeout */
uint32_t max_clk; /* Max possible freq */
uint32_t timeout_clk; /* Timeout freq */
bus_dma_tag_t dmatag;
diff --git a/sys/dev/sfxge/sfxge.c b/sys/dev/sfxge/sfxge.c
index fc01d1d..150df72 100644
--- a/sys/dev/sfxge/sfxge.c
+++ b/sys/dev/sfxge/sfxge.c
@@ -59,12 +59,14 @@ __FBSDID("$FreeBSD$");
#include "sfxge_rx.h"
#include "sfxge_version.h"
-#define SFXGE_CAP (IFCAP_VLAN_MTU | \
- IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM | IFCAP_TSO | \
- IFCAP_JUMBO_MTU | IFCAP_LRO | \
+#define SFXGE_CAP (IFCAP_VLAN_MTU | IFCAP_VLAN_HWCSUM | \
+ IFCAP_RXCSUM | IFCAP_TXCSUM | \
+ IFCAP_RXCSUM_IPV6 | IFCAP_TXCSUM_IPV6 | \
+ IFCAP_TSO4 | IFCAP_TSO6 | \
+ IFCAP_JUMBO_MTU | \
IFCAP_VLAN_HWTSO | IFCAP_LINKSTATE | IFCAP_HWSTATS)
#define SFXGE_CAP_ENABLE SFXGE_CAP
-#define SFXGE_CAP_FIXED (IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_VLAN_HWCSUM | \
+#define SFXGE_CAP_FIXED (IFCAP_VLAN_MTU | \
IFCAP_JUMBO_MTU | IFCAP_LINKSTATE | IFCAP_HWSTATS)
MALLOC_DEFINE(M_SFXGE, "sfxge", "Solarflare 10GigE driver");
@@ -87,7 +89,6 @@ SYSCTL_INT(_hw_sfxge, OID_AUTO, tx_ring, CTLFLAG_RDTUN,
&sfxge_tx_ring_entries, 0,
"Maximum number of descriptors in a transmit ring");
-
static void
sfxge_reset(void *arg, int npending);
@@ -257,32 +258,81 @@ sfxge_if_ioctl(struct ifnet *ifp, unsigned long command, caddr_t data)
sfxge_mac_filter_set(sc);
break;
case SIOCSIFCAP:
+ {
+ int reqcap = ifr->ifr_reqcap;
+ int capchg_mask;
+
SFXGE_ADAPTER_LOCK(sc);
+ /* Capabilities to be changed in accordance with request */
+ capchg_mask = ifp->if_capenable ^ reqcap;
+
/*
* The networking core already rejects attempts to
* enable capabilities we don't have. We still have
* to reject attempts to disable capabilities that we
* can't (yet) disable.
*/
- if (~ifr->ifr_reqcap & SFXGE_CAP_FIXED) {
+ KASSERT((reqcap & ~ifp->if_capabilities) == 0,
+ ("Unsupported capabilities %x requested %x vs %x",
+ reqcap & ~ifp->if_capabilities,
+ reqcap , ifp->if_capabilities));
+ if (capchg_mask & SFXGE_CAP_FIXED) {
error = EINVAL;
SFXGE_ADAPTER_UNLOCK(sc);
break;
}
- ifp->if_capenable = ifr->ifr_reqcap;
- if (ifp->if_capenable & IFCAP_TXCSUM)
+ /* Check request before any changes */
+ if ((capchg_mask & IFCAP_TSO4) &&
+ (reqcap & (IFCAP_TSO4 | IFCAP_TXCSUM)) == IFCAP_TSO4) {
+ error = EAGAIN;
+ SFXGE_ADAPTER_UNLOCK(sc);
+ if_printf(ifp, "enable txcsum before tso4\n");
+ break;
+ }
+ if ((capchg_mask & IFCAP_TSO6) &&
+ (reqcap & (IFCAP_TSO6 | IFCAP_TXCSUM_IPV6)) == IFCAP_TSO6) {
+ error = EAGAIN;
+ SFXGE_ADAPTER_UNLOCK(sc);
+ if_printf(ifp, "enable txcsum6 before tso6\n");
+ break;
+ }
+
+ if (reqcap & IFCAP_TXCSUM) {
ifp->if_hwassist |= (CSUM_IP | CSUM_TCP | CSUM_UDP);
- else
+ } else {
ifp->if_hwassist &= ~(CSUM_IP | CSUM_TCP | CSUM_UDP);
- if (ifp->if_capenable & IFCAP_TSO)
- ifp->if_hwassist |= CSUM_TSO;
- else
- ifp->if_hwassist &= ~CSUM_TSO;
+ if (reqcap & IFCAP_TSO4) {
+ reqcap &= ~IFCAP_TSO4;
+ if_printf(ifp,
+ "tso4 disabled due to -txcsum\n");
+ }
+ }
+ if (reqcap & IFCAP_TXCSUM_IPV6) {
+ ifp->if_hwassist |= (CSUM_TCP_IPV6 | CSUM_UDP_IPV6);
+ } else {
+ ifp->if_hwassist &= ~(CSUM_TCP_IPV6 | CSUM_UDP_IPV6);
+ if (reqcap & IFCAP_TSO6) {
+ reqcap &= ~IFCAP_TSO6;
+ if_printf(ifp,
+ "tso6 disabled due to -txcsum6\n");
+ }
+ }
+
+ /*
+ * The kernel takes both IFCAP_TSOx and CSUM_TSO into
+ * account before using TSO. So, we do not touch
+ * checksum flags when IFCAP_TSOx is modified.
+ * Note that CSUM_TSO is (CSUM_IP_TSO|CSUM_IP6_TSO),
+ * but both bits are set in IPv4 and IPv6 mbufs.
+ */
+
+ ifp->if_capenable = reqcap;
SFXGE_ADAPTER_UNLOCK(sc);
break;
+ }
case SIOCSIFMEDIA:
case SIOCGIFMEDIA:
error = ifmedia_ioctl(ifp, ifr, &sc->media, command);
@@ -326,7 +376,14 @@ sfxge_ifnet_init(struct ifnet *ifp, struct sfxge_softc *sc)
ifp->if_capabilities = SFXGE_CAP;
ifp->if_capenable = SFXGE_CAP_ENABLE;
- ifp->if_hwassist = CSUM_TCP | CSUM_UDP | CSUM_IP | CSUM_TSO;
+
+#ifdef SFXGE_LRO
+ ifp->if_capabilities |= IFCAP_LRO;
+ ifp->if_capenable |= IFCAP_LRO;
+#endif
+
+ ifp->if_hwassist = CSUM_TCP | CSUM_UDP | CSUM_IP | CSUM_TSO |
+ CSUM_TCP_IPV6 | CSUM_UDP_IPV6;
ether_ifattach(ifp, encp->enc_mac_addr);
diff --git a/sys/dev/sfxge/sfxge_port.c b/sys/dev/sfxge/sfxge_port.c
index ccedd4f..baddb8d 100644
--- a/sys/dev/sfxge/sfxge_port.c
+++ b/sys/dev/sfxge/sfxge_port.c
@@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$");
#include "sfxge.h"
+static int sfxge_phy_cap_mask(struct sfxge_softc *, int, uint32_t *);
+
static int
sfxge_mac_stat_update(struct sfxge_softc *sc)
{
@@ -443,6 +445,7 @@ sfxge_port_start(struct sfxge_softc *sc)
efx_nic_t *enp;
size_t pdu;
int rc;
+ uint32_t phy_cap_mask;
port = &sc->port;
enp = sc->enp;
@@ -483,10 +486,13 @@ sfxge_port_start(struct sfxge_softc *sc)
if ((rc = efx_mac_drain(enp, B_FALSE)) != 0)
goto fail3;
- if ((rc = efx_phy_adv_cap_set(sc->enp, sc->media.ifm_cur->ifm_data))
- != 0)
+ if ((rc = sfxge_phy_cap_mask(sc, sc->media.ifm_cur->ifm_media,
+ &phy_cap_mask)) != 0)
goto fail4;
+ if ((rc = efx_phy_adv_cap_set(sc->enp, phy_cap_mask)) != 0)
+ goto fail5;
+
port->init_state = SFXGE_PORT_STARTED;
/* Single poll in case there were missing initial events */
@@ -495,6 +501,7 @@ sfxge_port_start(struct sfxge_softc *sc)
return (0);
+fail5:
fail4:
(void)efx_mac_drain(enp, B_TRUE);
fail3:
@@ -686,7 +693,7 @@ fail:
return (rc);
}
-static int sfxge_link_mode[EFX_PHY_MEDIA_NTYPES][EFX_LINK_NMODES] = {
+static const int sfxge_link_mode[EFX_PHY_MEDIA_NTYPES][EFX_LINK_NMODES] = {
[EFX_PHY_MEDIA_CX4] = {
[EFX_LINK_10000FDX] = IFM_ETHER | IFM_FDX | IFM_10G_CX4,
},
@@ -738,12 +745,95 @@ sfxge_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
SFXGE_ADAPTER_UNLOCK(sc);
}
+static efx_phy_cap_type_t
+sfxge_link_mode_to_phy_cap(efx_link_mode_t mode)
+{
+ switch (mode) {
+ case EFX_LINK_10HDX:
+ return (EFX_PHY_CAP_10HDX);
+ case EFX_LINK_10FDX:
+ return (EFX_PHY_CAP_10FDX);
+ case EFX_LINK_100HDX:
+ return (EFX_PHY_CAP_100HDX);
+ case EFX_LINK_100FDX:
+ return (EFX_PHY_CAP_100FDX);
+ case EFX_LINK_1000HDX:
+ return (EFX_PHY_CAP_1000HDX);
+ case EFX_LINK_1000FDX:
+ return (EFX_PHY_CAP_1000FDX);
+ case EFX_LINK_10000FDX:
+ return (EFX_PHY_CAP_10000FDX);
+ default:
+ EFSYS_ASSERT(B_FALSE);
+ return (EFX_PHY_CAP_INVALID);
+ }
+}
+
+static int
+sfxge_phy_cap_mask(struct sfxge_softc *sc, int ifmedia, uint32_t *phy_cap_mask)
+{
+ efx_phy_media_type_t medium_type;
+ boolean_t mode_found = B_FALSE;
+ uint32_t cap_mask, mode_cap_mask;
+ efx_link_mode_t mode;
+ efx_phy_cap_type_t phy_cap;
+
+ efx_phy_media_type_get(sc->enp, &medium_type);
+ if (medium_type >= nitems(sfxge_link_mode)) {
+ if_printf(sc->ifnet, "unexpected media type %d\n", medium_type);
+ return (EINVAL);
+ }
+
+ efx_phy_adv_cap_get(sc->enp, EFX_PHY_CAP_PERM, &cap_mask);
+
+ for (mode = EFX_LINK_10HDX; mode < EFX_LINK_NMODES; mode++) {
+ if (ifmedia == sfxge_link_mode[medium_type][mode]) {
+ mode_found = B_TRUE;
+ break;
+ }
+ }
+
+ if (!mode_found) {
+ /*
+ * If media is not in the table, it must be IFM_AUTO.
+ */
+ KASSERT((cap_mask & (1 << EFX_PHY_CAP_AN)) &&
+ ifmedia == (IFM_ETHER | IFM_AUTO),
+ ("%s: no mode for media %d", __func__, ifmedia));
+ *phy_cap_mask = (cap_mask & ~(1 << EFX_PHY_CAP_ASYM));
+ return (0);
+ }
+
+ phy_cap = sfxge_link_mode_to_phy_cap(mode);
+ if (phy_cap == EFX_PHY_CAP_INVALID) {
+ if_printf(sc->ifnet,
+ "cannot map link mode %d to phy capability\n",
+ mode);
+ return (EINVAL);
+ }
+
+ mode_cap_mask = (1 << phy_cap);
+ mode_cap_mask |= cap_mask & (1 << EFX_PHY_CAP_AN);
+#ifdef SFXGE_HAVE_PAUSE_MEDIAOPTS
+ if (ifmedia & IFM_ETH_RXPAUSE)
+ mode_cap_mask |= cap_mask & (1 << EFX_PHY_CAP_PAUSE);
+ if (!(ifmedia & IFM_ETH_TXPAUSE))
+ mode_cap_mask |= cap_mask & (1 << EFX_PHY_CAP_ASYM);
+#else
+ mode_cap_mask |= cap_mask & (1 << EFX_PHY_CAP_PAUSE);
+#endif
+
+ *phy_cap_mask = mode_cap_mask;
+ return (0);
+}
+
static int
sfxge_media_change(struct ifnet *ifp)
{
struct sfxge_softc *sc;
struct ifmedia_entry *ifm;
int rc;
+ uint32_t phy_cap_mask;
sc = ifp->if_softc;
ifm = sc->media.ifm_cur;
@@ -759,7 +849,10 @@ sfxge_media_change(struct ifnet *ifp)
if (rc != 0)
goto out;
- rc = efx_phy_adv_cap_set(sc->enp, ifm->ifm_data);
+ if ((rc = sfxge_phy_cap_mask(sc, ifm->ifm_media, &phy_cap_mask)) != 0)
+ goto out;
+
+ rc = efx_phy_adv_cap_set(sc->enp, phy_cap_mask);
out:
SFXGE_ADAPTER_UNLOCK(sc);
@@ -771,6 +864,7 @@ int sfxge_port_ifmedia_init(struct sfxge_softc *sc)
efx_phy_media_type_t medium_type;
uint32_t cap_mask, mode_cap_mask;
efx_link_mode_t mode;
+ efx_phy_cap_type_t phy_cap;
int mode_ifm, best_mode_ifm = 0;
int rc;
@@ -801,41 +895,30 @@ int sfxge_port_ifmedia_init(struct sfxge_softc *sc)
efx_phy_media_type_get(sc->enp, &medium_type);
efx_phy_adv_cap_get(sc->enp, EFX_PHY_CAP_PERM, &cap_mask);
- EFX_STATIC_ASSERT(EFX_LINK_10HDX == EFX_PHY_CAP_10HDX + 1);
- EFX_STATIC_ASSERT(EFX_LINK_10FDX == EFX_PHY_CAP_10FDX + 1);
- EFX_STATIC_ASSERT(EFX_LINK_100HDX == EFX_PHY_CAP_100HDX + 1);
- EFX_STATIC_ASSERT(EFX_LINK_100FDX == EFX_PHY_CAP_100FDX + 1);
- EFX_STATIC_ASSERT(EFX_LINK_1000HDX == EFX_PHY_CAP_1000HDX + 1);
- EFX_STATIC_ASSERT(EFX_LINK_1000FDX == EFX_PHY_CAP_1000FDX + 1);
- EFX_STATIC_ASSERT(EFX_LINK_10000FDX == EFX_PHY_CAP_10000FDX + 1);
+ for (mode = EFX_LINK_10HDX; mode < EFX_LINK_NMODES; mode++) {
+ phy_cap = sfxge_link_mode_to_phy_cap(mode);
+ if (phy_cap == EFX_PHY_CAP_INVALID)
+ continue;
- for (mode = EFX_LINK_10HDX; mode <= EFX_LINK_10000FDX; mode++) {
- mode_cap_mask = 1 << (mode - 1);
+ mode_cap_mask = (1 << phy_cap);
mode_ifm = sfxge_link_mode[medium_type][mode];
if ((cap_mask & mode_cap_mask) && mode_ifm) {
- mode_cap_mask |= cap_mask & (1 << EFX_PHY_CAP_AN);
-
-#ifdef SFXGE_HAVE_PAUSE_MEDIAOPTS
/* No flow-control */
- ifmedia_add(&sc->media, mode_ifm, mode_cap_mask, NULL);
+ ifmedia_add(&sc->media, mode_ifm, 0, NULL);
+#ifdef SFXGE_HAVE_PAUSE_MEDIAOPTS
/* Respond-only. If using AN, we implicitly
* offer symmetric as well, but that doesn't
* mean we *have* to generate pause frames.
*/
- mode_cap_mask |= cap_mask & ((1 << EFX_PHY_CAP_PAUSE) |
- (1 << EFX_PHY_CAP_ASYM));
mode_ifm |= IFM_ETH_RXPAUSE;
- ifmedia_add(&sc->media, mode_ifm, mode_cap_mask, NULL);
+ ifmedia_add(&sc->media, mode_ifm, 0, NULL);
/* Symmetric */
- mode_cap_mask &= ~(1 << EFX_PHY_CAP_ASYM);
mode_ifm |= IFM_ETH_TXPAUSE;
-#else /* !SFXGE_HAVE_PAUSE_MEDIAOPTS */
- mode_cap_mask |= cap_mask & (1 << EFX_PHY_CAP_PAUSE);
+ ifmedia_add(&sc->media, mode_ifm, 0, NULL);
#endif
- ifmedia_add(&sc->media, mode_ifm, mode_cap_mask, NULL);
/* Link modes are numbered in order of speed,
* so assume the last one available is the best.
@@ -847,8 +930,7 @@ int sfxge_port_ifmedia_init(struct sfxge_softc *sc)
if (cap_mask & (1 << EFX_PHY_CAP_AN)) {
/* Add autoselect mode. */
mode_ifm = IFM_ETHER | IFM_AUTO;
- ifmedia_add(&sc->media, mode_ifm,
- cap_mask & ~(1 << EFX_PHY_CAP_ASYM), NULL);
+ ifmedia_add(&sc->media, mode_ifm, 0, NULL);
best_mode_ifm = mode_ifm;
}
diff --git a/sys/dev/sfxge/sfxge_rx.c b/sys/dev/sfxge/sfxge_rx.c
index 9216ac9..2535e87 100644
--- a/sys/dev/sfxge/sfxge_rx.c
+++ b/sys/dev/sfxge/sfxge_rx.c
@@ -322,23 +322,24 @@ static void
sfxge_rx_deliver(struct sfxge_softc *sc, struct sfxge_rx_sw_desc *rx_desc)
{
struct mbuf *m = rx_desc->mbuf;
+ int flags = rx_desc->flags;
int csum_flags;
/* Convert checksum flags */
- csum_flags = (rx_desc->flags & EFX_CKSUM_IPV4) ?
+ csum_flags = (flags & EFX_CKSUM_IPV4) ?
(CSUM_IP_CHECKED | CSUM_IP_VALID) : 0;
- if (rx_desc->flags & EFX_CKSUM_TCPUDP)
+ if (flags & EFX_CKSUM_TCPUDP)
csum_flags |= CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
- if (rx_desc->flags & (EFX_PKT_IPV4 | EFX_PKT_IPV6)) {
+ if (flags & (EFX_PKT_IPV4 | EFX_PKT_IPV6)) {
m->m_pkthdr.flowid = EFX_RX_HASH_VALUE(EFX_RX_HASHALG_TOEPLITZ,
mtod(m, uint8_t *));
/* The hash covers a 4-tuple for TCP only */
M_HASHTYPE_SET(m,
- (rx_desc->flags & EFX_PKT_IPV4) ?
- ((rx_desc->flags & EFX_PKT_TCP) ?
+ (flags & EFX_PKT_IPV4) ?
+ ((flags & EFX_PKT_TCP) ?
M_HASHTYPE_RSS_TCP_IPV4 : M_HASHTYPE_RSS_IPV4) :
- ((rx_desc->flags & EFX_PKT_TCP) ?
+ ((flags & EFX_PKT_TCP) ?
M_HASHTYPE_RSS_TCP_IPV6 : M_HASHTYPE_RSS_IPV6));
}
m->m_data += sc->rx_prefix_size;
@@ -687,15 +688,18 @@ sfxge_lro(struct sfxge_rxq *rxq, struct sfxge_rx_sw_desc *rx_buf)
*/
if (l3_proto == htons(ETHERTYPE_IP)) {
struct ip *iph = nh;
- if ((iph->ip_p - IPPROTO_TCP) |
- (iph->ip_hl - (sizeof(*iph) >> 2u)) |
+
+ KASSERT(iph->ip_p == IPPROTO_TCP,
+ ("IPv4 protocol is not TCP, but packet marker is set"));
+ if ((iph->ip_hl - (sizeof(*iph) >> 2u)) |
(iph->ip_off & htons(IP_MF | IP_OFFMASK)))
goto deliver_now;
th = (struct tcphdr *)(iph + 1);
} else if (l3_proto == htons(ETHERTYPE_IPV6)) {
struct ip6_hdr *iph = nh;
- if (iph->ip6_nxt != IPPROTO_TCP)
- goto deliver_now;
+
+ KASSERT(iph->ip6_nxt == IPPROTO_TCP,
+ ("IPv6 next header is not TCP, but packet marker is set"));
l2_id |= SFXGE_LRO_L2_ID_IPV6;
th = (struct tcphdr *)(iph + 1);
} else {
@@ -791,7 +795,8 @@ void
sfxge_rx_qcomplete(struct sfxge_rxq *rxq, boolean_t eop)
{
struct sfxge_softc *sc = rxq->sc;
- int lro_enabled = sc->ifnet->if_capenable & IFCAP_LRO;
+ int if_capenable = sc->ifnet->if_capenable;
+ int lro_enabled = if_capenable & IFCAP_LRO;
unsigned int index;
struct sfxge_evq *evq;
unsigned int completed;
@@ -821,26 +826,44 @@ sfxge_rx_qcomplete(struct sfxge_rxq *rxq, boolean_t eop)
prefetch_read_many(mtod(m, caddr_t));
- /* Check for loopback packets */
- if (!(rx_desc->flags & EFX_PKT_IPV4) &&
- !(rx_desc->flags & EFX_PKT_IPV6)) {
- struct ether_header *etherhp;
+ switch (rx_desc->flags & (EFX_PKT_IPV4 | EFX_PKT_IPV6)) {
+ case EFX_PKT_IPV4:
+ if (~if_capenable & IFCAP_RXCSUM)
+ rx_desc->flags &=
+ ~(EFX_CKSUM_IPV4 | EFX_CKSUM_TCPUDP);
+ break;
+ case EFX_PKT_IPV6:
+ if (~if_capenable & IFCAP_RXCSUM_IPV6)
+ rx_desc->flags &= ~EFX_CKSUM_TCPUDP;
+ break;
+ case 0:
+ /* Check for loopback packets */
+ {
+ struct ether_header *etherhp;
- /*LINTED*/
- etherhp = mtod(m, struct ether_header *);
+ /*LINTED*/
+ etherhp = mtod(m, struct ether_header *);
- if (etherhp->ether_type ==
- htons(SFXGE_ETHERTYPE_LOOPBACK)) {
- EFSYS_PROBE(loopback);
+ if (etherhp->ether_type ==
+ htons(SFXGE_ETHERTYPE_LOOPBACK)) {
+ EFSYS_PROBE(loopback);
- rxq->loopback++;
- goto discard;
+ rxq->loopback++;
+ goto discard;
+ }
}
+ break;
+ default:
+ KASSERT(B_FALSE,
+ ("Rx descriptor with both IPv4 and IPv6 flags"));
+ goto discard;
}
/* Pass packet up the stack or into LRO (pipelined) */
if (prev != NULL) {
- if (lro_enabled)
+ if (lro_enabled &&
+ ((prev->flags & (EFX_PKT_TCP | EFX_CKSUM_TCPUDP)) ==
+ (EFX_PKT_TCP | EFX_CKSUM_TCPUDP)))
sfxge_lro(rxq, prev);
else
sfxge_rx_deliver(sc, prev);
@@ -859,7 +882,9 @@ discard:
/* Pass last packet up the stack or into LRO */
if (prev != NULL) {
- if (lro_enabled)
+ if (lro_enabled &&
+ ((prev->flags & (EFX_PKT_TCP | EFX_CKSUM_TCPUDP)) ==
+ (EFX_PKT_TCP | EFX_CKSUM_TCPUDP)))
sfxge_lro(rxq, prev);
else
sfxge_rx_deliver(sc, prev);
@@ -1192,7 +1217,7 @@ sfxge_rx_qinit(struct sfxge_softc *sc, unsigned int index)
M_SFXGE, M_WAITOK | M_ZERO);
sfxge_lro_init(rxq);
- callout_init(&rxq->refill_callout, B_TRUE);
+ callout_init(&rxq->refill_callout, 1);
rxq->init_state = SFXGE_RXQ_INITIALIZED;
diff --git a/sys/dev/sfxge/sfxge_tx.c b/sys/dev/sfxge/sfxge_tx.c
index d00f9eb..524b09d 100644
--- a/sys/dev/sfxge/sfxge_tx.c
+++ b/sys/dev/sfxge/sfxge_tx.c
@@ -521,18 +521,10 @@ sfxge_tx_qdpl_service(struct sfxge_txq *txq)
}
/*
- * Put a packet on the deferred packet list.
- *
- * If we are called with the txq lock held, we put the packet on the "get
- * list", otherwise we atomically push it on the "put list". The swizzle
- * function takes care of ordering.
- *
- * The length of the put list is bounded by SFXGE_TX_MAX_DEFERRED. We
- * overload the csum_data field in the mbuf to keep track of this length
- * because there is no cheap alternative to avoid races.
+ * Put a packet on the deferred packet get-list.
*/
static int
-sfxge_tx_qdpl_put(struct sfxge_txq *txq, struct mbuf *mbuf, int locked)
+sfxge_tx_qdpl_put_locked(struct sfxge_txq *txq, struct mbuf *mbuf)
{
struct sfxge_tx_dpl *stdp;
@@ -540,52 +532,66 @@ sfxge_tx_qdpl_put(struct sfxge_txq *txq, struct mbuf *mbuf, int locked)
KASSERT(mbuf->m_nextpkt == NULL, ("mbuf->m_nextpkt != NULL"));
- if (locked) {
- SFXGE_TXQ_LOCK_ASSERT_OWNED(txq);
-
- sfxge_tx_qdpl_swizzle(txq);
+ SFXGE_TXQ_LOCK_ASSERT_OWNED(txq);
- if (stdp->std_get_count >= stdp->std_get_max) {
- txq->get_overflow++;
+ if (stdp->std_get_count >= stdp->std_get_max) {
+ txq->get_overflow++;
+ return (ENOBUFS);
+ }
+ if (sfxge_is_mbuf_non_tcp(mbuf)) {
+ if (stdp->std_get_non_tcp_count >=
+ stdp->std_get_non_tcp_max) {
+ txq->get_non_tcp_overflow++;
return (ENOBUFS);
}
- if (sfxge_is_mbuf_non_tcp(mbuf)) {
- if (stdp->std_get_non_tcp_count >=
- stdp->std_get_non_tcp_max) {
- txq->get_non_tcp_overflow++;
- return (ENOBUFS);
- }
- stdp->std_get_non_tcp_count++;
- }
-
- *(stdp->std_getp) = mbuf;
- stdp->std_getp = &mbuf->m_nextpkt;
- stdp->std_get_count++;
- } else {
- volatile uintptr_t *putp;
- uintptr_t old;
- uintptr_t new;
- unsigned old_len;
-
- putp = &stdp->std_put;
- new = (uintptr_t)mbuf;
-
- do {
- old = *putp;
- if (old != 0) {
- struct mbuf *mp = (struct mbuf *)old;
- old_len = mp->m_pkthdr.csum_data;
- } else
- old_len = 0;
- if (old_len >= stdp->std_put_max) {
- atomic_add_long(&txq->put_overflow, 1);
- return (ENOBUFS);
- }
- mbuf->m_pkthdr.csum_data = old_len + 1;
- mbuf->m_nextpkt = (void *)old;
- } while (atomic_cmpset_ptr(putp, old, new) == 0);
+ stdp->std_get_non_tcp_count++;
}
+ *(stdp->std_getp) = mbuf;
+ stdp->std_getp = &mbuf->m_nextpkt;
+ stdp->std_get_count++;
+
+ return (0);
+}
+
+/*
+ * Put a packet on the deferred packet put-list.
+ *
+ * We overload the csum_data field in the mbuf to keep track of this length
+ * because there is no cheap alternative to avoid races.
+ */
+static int
+sfxge_tx_qdpl_put_unlocked(struct sfxge_txq *txq, struct mbuf *mbuf)
+{
+ struct sfxge_tx_dpl *stdp;
+ volatile uintptr_t *putp;
+ uintptr_t old;
+ uintptr_t new;
+ unsigned old_len;
+
+ KASSERT(mbuf->m_nextpkt == NULL, ("mbuf->m_nextpkt != NULL"));
+
+ SFXGE_TXQ_LOCK_ASSERT_NOTOWNED(txq);
+
+ stdp = &txq->dpl;
+ putp = &stdp->std_put;
+ new = (uintptr_t)mbuf;
+
+ do {
+ old = *putp;
+ if (old != 0) {
+ struct mbuf *mp = (struct mbuf *)old;
+ old_len = mp->m_pkthdr.csum_data;
+ } else
+ old_len = 0;
+ if (old_len >= stdp->std_put_max) {
+ atomic_add_long(&txq->put_overflow, 1);
+ return (ENOBUFS);
+ }
+ mbuf->m_pkthdr.csum_data = old_len + 1;
+ mbuf->m_nextpkt = (void *)old;
+ } while (atomic_cmpset_ptr(putp, old, new) == 0);
+
return (0);
}
@@ -596,13 +602,11 @@ sfxge_tx_qdpl_put(struct sfxge_txq *txq, struct mbuf *mbuf, int locked)
int
sfxge_tx_packet_add(struct sfxge_txq *txq, struct mbuf *m)
{
- int locked;
int rc;
if (!SFXGE_LINK_UP(txq->sc)) {
- rc = ENETDOWN;
atomic_add_long(&txq->netdown_drops, 1);
- goto fail;
+ return (ENETDOWN);
}
/*
@@ -610,35 +614,33 @@ sfxge_tx_packet_add(struct sfxge_txq *txq, struct mbuf *m)
* the packet will be appended to the "get list" of the deferred
* packet list. Otherwise, it will be pushed on the "put list".
*/
- locked = SFXGE_TXQ_TRYLOCK(txq);
-
- if (sfxge_tx_qdpl_put(txq, m, locked) != 0) {
- if (locked)
- SFXGE_TXQ_UNLOCK(txq);
- rc = ENOBUFS;
- goto fail;
- }
+ if (SFXGE_TXQ_TRYLOCK(txq)) {
+ /* First swizzle put-list to get-list to keep order */
+ sfxge_tx_qdpl_swizzle(txq);
- /*
- * Try to grab the lock again.
- *
- * If we are able to get the lock, we need to process the deferred
- * packet list. If we are not able to get the lock, another thread
- * is processing the list.
- */
- if (!locked)
- locked = SFXGE_TXQ_TRYLOCK(txq);
+ rc = sfxge_tx_qdpl_put_locked(txq, m);
- if (locked) {
/* Try to service the list. */
sfxge_tx_qdpl_service(txq);
/* Lock has been dropped. */
+ } else {
+ rc = sfxge_tx_qdpl_put_unlocked(txq, m);
+
+ /*
+ * Try to grab the lock again.
+ *
+ * If we are able to get the lock, we need to process
+ * the deferred packet list. If we are not able to get
+ * the lock, another thread is processing the list.
+ */
+ if ((rc == 0) && SFXGE_TXQ_TRYLOCK(txq)) {
+ sfxge_tx_qdpl_service(txq);
+ /* Lock has been dropped. */
+ }
}
- return (0);
+ SFXGE_TXQ_LOCK_ASSERT_NOTOWNED(txq);
-fail:
- m_freem(m);
return (rc);
}
@@ -699,7 +701,8 @@ sfxge_if_transmit(struct ifnet *ifp, struct mbuf *m)
("interface not up"));
/* Pick the desired transmit queue. */
- if (m->m_pkthdr.csum_flags & (CSUM_DELAY_DATA | CSUM_TSO)) {
+ if (m->m_pkthdr.csum_flags &
+ (CSUM_DELAY_DATA | CSUM_TCP_IPV6 | CSUM_UDP_IPV6 | CSUM_TSO)) {
int index = 0;
/* check if flowid is set */
@@ -716,6 +719,8 @@ sfxge_if_transmit(struct ifnet *ifp, struct mbuf *m)
}
rc = sfxge_tx_packet_add(txq, m);
+ if (rc != 0)
+ m_freem(m);
return (rc);
}
@@ -860,8 +865,14 @@ static void tso_start(struct sfxge_tso_state *tso, struct mbuf *mbuf)
tso->seqnum = ntohl(th->th_seq);
/* These flags must not be duplicated */
- KASSERT(!(th->th_flags & (TH_URG | TH_SYN | TH_RST)),
- ("incompatible TCP flag on TSO packet"));
+ /*
+ * RST should not be duplicated as well, but FreeBSD kernel
+ * generates TSO packets with RST flag. So, do not assert
+ * its absence.
+ */
+ KASSERT(!(th->th_flags & (TH_URG | TH_SYN)),
+ ("incompatible TCP flag 0x%x on TSO packet",
+ th->th_flags & (TH_URG | TH_SYN)));
tso->out_len = mbuf->m_pkthdr.len - tso->header_len;
}
diff --git a/sys/dev/sfxge/sfxge_tx.h b/sys/dev/sfxge/sfxge_tx.h
index a2848e0..724ee22 100644
--- a/sys/dev/sfxge/sfxge_tx.h
+++ b/sys/dev/sfxge/sfxge_tx.h
@@ -148,6 +148,8 @@ enum sfxge_txq_type {
mtx_unlock(&(_txq)->lock)
#define SFXGE_TXQ_LOCK_ASSERT_OWNED(_txq) \
mtx_assert(&(_txq)->lock, MA_OWNED)
+#define SFXGE_TXQ_LOCK_ASSERT_NOTOWNED(_txq) \
+ mtx_assert(&(_txq)->lock, MA_NOTOWNED)
struct sfxge_txq {
diff --git a/sys/dev/sound/midi/mpu401.c b/sys/dev/sound/midi/mpu401.c
index 3e061a7..5ce6648 100644
--- a/sys/dev/sound/midi/mpu401.c
+++ b/sys/dev/sound/midi/mpu401.c
@@ -185,7 +185,7 @@ mpu401_init(kobj_class_t cls, void *cookie, driver_intr_t softintr,
kobj_init((kobj_t)m, cls);
- callout_init(&m->timer, CALLOUT_MPSAFE);
+ callout_init(&m->timer, 1);
m->si = softintr;
m->cookie = cookie;
diff --git a/sys/dev/sound/pci/atiixp.c b/sys/dev/sound/pci/atiixp.c
index 9b8c55e..8df67aa 100644
--- a/sys/dev/sound/pci/atiixp.c
+++ b/sys/dev/sound/pci/atiixp.c
@@ -1194,7 +1194,7 @@ atiixp_pci_attach(device_t dev)
sc->lock = snd_mtxcreate(device_get_nameunit(dev), "snd_atiixp softc");
sc->dev = dev;
- callout_init(&sc->poll_timer, CALLOUT_MPSAFE);
+ callout_init(&sc->poll_timer, 1);
sc->poll_ticks = 1;
if (resource_int_value(device_get_name(sc->dev),
diff --git a/sys/dev/sound/pci/es137x.c b/sys/dev/sound/pci/es137x.c
index 42d0450..0dd88a8 100644
--- a/sys/dev/sound/pci/es137x.c
+++ b/sys/dev/sound/pci/es137x.c
@@ -1741,7 +1741,7 @@ es_pci_attach(device_t dev)
es->st = rman_get_bustag(es->reg);
es->sh = rman_get_bushandle(es->reg);
- callout_init(&es->poll_timer, CALLOUT_MPSAFE);
+ callout_init(&es->poll_timer, 1);
es->poll_ticks = 1;
if (resource_int_value(device_get_name(dev),
diff --git a/sys/dev/sound/pci/hda/hdaa.c b/sys/dev/sound/pci/hda/hdaa.c
index 0d2ae47..a1b9f7c 100644
--- a/sys/dev/sound/pci/hda/hdaa.c
+++ b/sys/dev/sound/pci/hda/hdaa.c
@@ -3203,7 +3203,7 @@ hdaa_audio_as_parse(struct hdaa_devinfo *devinfo)
/* Scan associations skipping as=0. */
cnt = 0;
- for (j = 1; j < 16; j++) {
+ for (j = 1; j < 16 && cnt < max; j++) {
first = 16;
hpredir = 0;
for (i = devinfo->startnode; i < devinfo->endnode; i++) {
@@ -6592,7 +6592,7 @@ hdaa_attach(device_t dev)
devinfo->newquirks = -1;
devinfo->newgpio = -1;
devinfo->newgpo = -1;
- callout_init(&devinfo->poll_jack, CALLOUT_MPSAFE);
+ callout_init(&devinfo->poll_jack, 1);
devinfo->poll_ival = hz;
hdaa_lock(devinfo);
diff --git a/sys/dev/sound/pci/hda/hdac.c b/sys/dev/sound/pci/hda/hdac.c
index 1e173c6..b0f250c 100644
--- a/sys/dev/sound/pci/hda/hdac.c
+++ b/sys/dev/sound/pci/hda/hdac.c
@@ -1110,7 +1110,7 @@ hdac_attach(device_t dev)
sc->lock = snd_mtxcreate(device_get_nameunit(dev), "HDA driver mutex");
sc->dev = dev;
TASK_INIT(&sc->unsolq_task, 0, hdac_unsolq_task, sc);
- callout_init(&sc->poll_callout, CALLOUT_MPSAFE);
+ callout_init(&sc->poll_callout, 1);
for (i = 0; i < HDAC_CODEC_MAX; i++)
sc->codecs[i].dev = NULL;
if (devid >= 0) {
diff --git a/sys/dev/sound/pci/via8233.c b/sys/dev/sound/pci/via8233.c
index 171278c..0694cef 100644
--- a/sys/dev/sound/pci/via8233.c
+++ b/sys/dev/sound/pci/via8233.c
@@ -1175,7 +1175,7 @@ via_attach(device_t dev)
"snd_via8233 softc");
via->dev = dev;
- callout_init(&via->poll_timer, CALLOUT_MPSAFE);
+ callout_init(&via->poll_timer, 1);
via->poll_ticks = 1;
if (resource_int_value(device_get_name(dev),
diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c
index fbf49f6..83ec6c1 100644
--- a/sys/dev/sound/pcm/channel.c
+++ b/sys/dev/sound/pcm/channel.c
@@ -1020,32 +1020,17 @@ static const struct {
{ NULL, NULL, NULL, 0 }
};
-static const struct {
- char *name, *alias1, *alias2;
- int matrix_id;
-} matrix_id_tab[] = {
- { "1.0", "1", "mono", SND_CHN_MATRIX_1_0 },
- { "2.0", "2", "stereo", SND_CHN_MATRIX_2_0 },
- { "2.1", NULL, NULL, SND_CHN_MATRIX_2_1 },
- { "3.0", "3", NULL, SND_CHN_MATRIX_3_0 },
- { "3.1", NULL, NULL, SND_CHN_MATRIX_3_1 },
- { "4.0", "4", "quad", SND_CHN_MATRIX_4_0 },
- { "4.1", NULL, NULL, SND_CHN_MATRIX_4_1 },
- { "5.0", "5", NULL, SND_CHN_MATRIX_5_0 },
- { "5.1", "6", NULL, SND_CHN_MATRIX_5_1 },
- { "6.0", NULL, NULL, SND_CHN_MATRIX_6_0 },
- { "6.1", "7", NULL, SND_CHN_MATRIX_6_1 },
- { "7.0", NULL, NULL, SND_CHN_MATRIX_7_0 },
- { "7.1", "8", NULL, SND_CHN_MATRIX_7_1 },
- { NULL, NULL, NULL, SND_CHN_MATRIX_UNKNOWN }
-};
-
uint32_t
snd_str2afmt(const char *req)
{
- uint32_t i, afmt;
- int matrix_id;
- char b1[8], b2[8];
+ int ext;
+ int ch;
+ int i;
+ char b1[8];
+ char b2[8];
+
+ memset(b1, 0, sizeof(b1));
+ memset(b2, 0, sizeof(b2));
i = sscanf(req, "%5[^:]:%6s", b1, b2);
@@ -1059,88 +1044,78 @@ snd_str2afmt(const char *req)
} else
return (0);
- afmt = 0;
- matrix_id = SND_CHN_MATRIX_UNKNOWN;
-
- for (i = 0; afmt == 0 && afmt_tab[i].name != NULL; i++) {
- if (strcasecmp(afmt_tab[i].name, b1) == 0 ||
- (afmt_tab[i].alias1 != NULL &&
- strcasecmp(afmt_tab[i].alias1, b1) == 0) ||
- (afmt_tab[i].alias2 != NULL &&
- strcasecmp(afmt_tab[i].alias2, b1) == 0)) {
- afmt = afmt_tab[i].afmt;
- strlcpy(b1, afmt_tab[i].name, sizeof(b1));
- }
- }
-
- if (afmt == 0)
+ i = sscanf(b2, "%d.%d", &ch, &ext);
+
+ if (i == 0) {
+ if (strcasecmp(b2, "mono") == 0) {
+ ch = 1;
+ ext = 0;
+ } else if (strcasecmp(b2, "stereo") == 0) {
+ ch = 2;
+ ext = 0;
+ } else if (strcasecmp(b2, "quad") == 0) {
+ ch = 4;
+ ext = 0;
+ } else
+ return (0);
+ } else if (i == 1) {
+ if (ch < 1 || ch > AFMT_CHANNEL_MAX)
+ return (0);
+ ext = 0;
+ } else if (i == 2) {
+ if (ext < 0 || ext > AFMT_EXTCHANNEL_MAX)
+ return (0);
+ if (ch < 1 || (ch + ext) > AFMT_CHANNEL_MAX)
+ return (0);
+ } else
return (0);
- for (i = 0; matrix_id == SND_CHN_MATRIX_UNKNOWN &&
- matrix_id_tab[i].name != NULL; i++) {
- if (strcmp(matrix_id_tab[i].name, b2) == 0 ||
- (matrix_id_tab[i].alias1 != NULL &&
- strcmp(matrix_id_tab[i].alias1, b2) == 0) ||
- (matrix_id_tab[i].alias2 != NULL &&
- strcasecmp(matrix_id_tab[i].alias2, b2) == 0)) {
- matrix_id = matrix_id_tab[i].matrix_id;
- strlcpy(b2, matrix_id_tab[i].name, sizeof(b2));
+ for (i = 0; afmt_tab[i].name != NULL; i++) {
+ if (strcasecmp(afmt_tab[i].name, b1) != 0) {
+ if (afmt_tab[i].alias1 == NULL)
+ continue;
+ if (strcasecmp(afmt_tab[i].alias1, b1) != 0) {
+ if (afmt_tab[i].alias2 == NULL)
+ continue;
+ if (strcasecmp(afmt_tab[i].alias2, b1) != 0)
+ continue;
+ }
}
+ /* found a match */
+ return (SND_FORMAT(afmt_tab[i].afmt, ch + ext, ext));
}
-
- if (matrix_id == SND_CHN_MATRIX_UNKNOWN)
- return (0);
-
-#ifndef _KERNEL
- printf("Parse OK: '%s' -> '%s:%s' %d\n", req, b1, b2,
- (int)(b2[0]) - '0' + (int)(b2[2]) - '0');
-#endif
-
- return (SND_FORMAT(afmt, b2[0] - '0' + b2[2] - '0', b2[2] - '0'));
+ /* not a valid format */
+ return (0);
}
uint32_t
snd_afmt2str(uint32_t afmt, char *buf, size_t len)
{
- uint32_t i, enc, ch, ext;
- char tmp[AFMTSTR_LEN];
+ uint32_t enc;
+ uint32_t ext;
+ uint32_t ch;
+ int i;
if (buf == NULL || len < AFMTSTR_LEN)
return (0);
-
- bzero(tmp, sizeof(tmp));
+ memset(buf, 0, len);
enc = AFMT_ENCODING(afmt);
ch = AFMT_CHANNEL(afmt);
ext = AFMT_EXTCHANNEL(afmt);
-
- for (i = 0; afmt_tab[i].name != NULL; i++) {
- if (enc == afmt_tab[i].afmt) {
- strlcpy(tmp, afmt_tab[i].name, sizeof(tmp));
- strlcat(tmp, ":", sizeof(tmp));
- break;
- }
- }
-
- if (strlen(tmp) == 0)
+ /* check there is at least one channel */
+ if (ch <= ext)
return (0);
-
- for (i = 0; matrix_id_tab[i].name != NULL; i++) {
- if (ch == (matrix_id_tab[i].name[0] - '0' +
- matrix_id_tab[i].name[2] - '0') &&
- ext == (matrix_id_tab[i].name[2] - '0')) {
- strlcat(tmp, matrix_id_tab[i].name, sizeof(tmp));
- break;
- }
+ for (i = 0; afmt_tab[i].name != NULL; i++) {
+ if (enc != afmt_tab[i].afmt)
+ continue;
+ /* found a match */
+ snprintf(buf, len, "%s:%d.%d",
+ afmt_tab[i].name, ch - ext, ext);
+ return (SND_FORMAT(enc, ch, ext));
}
-
- if (strlen(tmp) == 0)
- return (0);
-
- strlcpy(buf, tmp, len);
-
- return (snd_str2afmt(buf));
+ return (0);
}
int
diff --git a/sys/dev/sound/pcm/channel.h b/sys/dev/sound/pcm/channel.h
index 6601b54..45f43b5 100644
--- a/sys/dev/sound/pcm/channel.h
+++ b/sys/dev/sound/pcm/channel.h
@@ -162,6 +162,7 @@ struct pcm_channel {
} channels;
struct pcmchan_matrix matrix;
+ struct pcmchan_matrix matrix_scratch;
int volume[SND_VOL_C_MAX][SND_CHN_T_VOL_MAX];
diff --git a/sys/dev/sound/pcm/feeder_chain.c b/sys/dev/sound/pcm/feeder_chain.c
index a647269..308d5f2 100644
--- a/sys/dev/sound/pcm/feeder_chain.c
+++ b/sys/dev/sound/pcm/feeder_chain.c
@@ -561,6 +561,20 @@ feeder_build_mixer(struct pcm_channel *c, struct feeder_chain_desc *cdesc)
((c)->mode == FEEDER_CHAIN_LEAN && \
!((c)->current.afmt & (AFMT_S16_NE | AFMT_S32_NE)))))
+static void
+feeder_default_matrix(struct pcmchan_matrix *m, uint32_t fmt, int id)
+{
+ int x;
+
+ memset(m, 0, sizeof(*m));
+
+ m->id = id;
+ m->channels = AFMT_CHANNEL(fmt);
+ m->ext = AFMT_EXTCHANNEL(fmt);
+ for (x = 0; x != SND_CHN_T_MAX; x++)
+ m->offset[x] = -1;
+}
+
int
feeder_chain(struct pcm_channel *c)
{
@@ -641,10 +655,10 @@ feeder_chain(struct pcm_channel *c)
*/
hwmatrix = CHANNEL_GETMATRIX(c->methods, c->devinfo, hwfmt);
if (hwmatrix == NULL) {
- device_printf(c->dev,
- "%s(): failed to acquire hw matrix [0x%08x]\n",
- __func__, hwfmt);
- return (ENODEV);
+ /* setup a default matrix */
+ hwmatrix = &c->matrix_scratch;
+ feeder_default_matrix(hwmatrix, hwfmt,
+ SND_CHN_MATRIX_UNKNOWN);
}
/* ..... and rebuild hwfmt. */
hwfmt = SND_FORMAT(hwfmt, hwmatrix->channels, hwmatrix->ext);
@@ -656,13 +670,14 @@ feeder_chain(struct pcm_channel *c)
softmatrix->ext != AFMT_EXTCHANNEL(softfmt)) {
softmatrix = feeder_matrix_format_map(softfmt);
if (softmatrix == NULL) {
- device_printf(c->dev,
- "%s(): failed to acquire soft matrix [0x%08x]\n",
- __func__, softfmt);
- return (ENODEV);
+ /* setup a default matrix */
+ softmatrix = &c->matrix;
+ feeder_default_matrix(softmatrix, softfmt,
+ SND_CHN_MATRIX_PCMCHANNEL);
+ } else {
+ c->matrix = *softmatrix;
+ c->matrix.id = SND_CHN_MATRIX_PCMCHANNEL;
}
- c->matrix = *softmatrix;
- c->matrix.id = SND_CHN_MATRIX_PCMCHANNEL;
}
softfmt = SND_FORMAT(softfmt, softmatrix->channels, softmatrix->ext);
if (softfmt != c->format)
diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h
index 3565ca5..32e0343 100644
--- a/sys/dev/sound/pcm/sound.h
+++ b/sys/dev/sound/pcm/sound.h
@@ -213,10 +213,12 @@ struct snd_mixer;
* ~(0xb00ff7ff)
*/
#define AFMT_ENCODING_MASK 0xf00fffff
-#define AFMT_CHANNEL_MASK 0x01f00000
+#define AFMT_CHANNEL_MASK 0x07f00000
#define AFMT_CHANNEL_SHIFT 20
-#define AFMT_EXTCHANNEL_MASK 0x0e000000
-#define AFMT_EXTCHANNEL_SHIFT 25
+#define AFMT_CHANNEL_MAX 0x7f
+#define AFMT_EXTCHANNEL_MASK 0x08000000
+#define AFMT_EXTCHANNEL_SHIFT 27
+#define AFMT_EXTCHANNEL_MAX 1
#define AFMT_ENCODING(v) ((v) & AFMT_ENCODING_MASK)
diff --git a/sys/dev/sound/usb/uaudio.c b/sys/dev/sound/usb/uaudio.c
index 8822bf0..063d8ce 100644
--- a/sys/dev/sound/usb/uaudio.c
+++ b/sys/dev/sound/usb/uaudio.c
@@ -115,6 +115,8 @@ SYSCTL_INT(_hw_usb_uaudio, OID_AUTO, default_channels, CTLFLAG_RWTUN,
#define UAUDIO_NFRAMES 64 /* must be factor of 8 due HS-USB */
#define UAUDIO_NCHANBUFS 2 /* number of outstanding request */
#define UAUDIO_RECURSE_LIMIT 255 /* rounds */
+#define UAUDIO_CHANNELS_MAX MIN(64, AFMT_CHANNEL_MAX)
+#define UAUDIO_MATRIX_MAX 8 /* channels */
#define MAKE_WORD(h,l) (((h) << 8) | (l))
#define BIT_TEST(bm,bno) (((bm)[(bno) / 8] >> (7 - ((bno) % 8))) & 1)
@@ -346,6 +348,7 @@ struct uaudio_softc {
uint8_t sc_uq_au_no_xu:1;
uint8_t sc_uq_bad_adc:1;
uint8_t sc_uq_au_vendor_class:1;
+ uint8_t sc_pcm_bitperfect:1;
};
struct uaudio_terminal_node {
@@ -1062,6 +1065,10 @@ uaudio_attach_sub(device_t dev, kobj_class_t mixer_class, kobj_class_t chan_clas
*/
uaudio_pcm_setflags(dev, SD_F_SOFTPCMVOL);
}
+ if (sc->sc_pcm_bitperfect) {
+ DPRINTF("device needs bitperfect by default\n");
+ uaudio_pcm_setflags(dev, SD_F_BITPERFECT);
+ }
if (mixer_init(dev, mixer_class, sc))
goto detach;
sc->sc_mixer_init = 1;
@@ -1568,6 +1575,19 @@ uaudio_chan_fill_info_sub(struct uaudio_softc *sc, struct usb_device *udev,
asf1d.v1 = NULL;
ed1 = NULL;
sed.v1 = NULL;
+
+ /*
+ * There can only be one USB audio instance
+ * per USB device. Grab all USB audio
+ * interfaces on this USB device so that we
+ * don't attach USB audio twice:
+ */
+ if (alt_index == 0 && curidx != sc->sc_mixer_iface_index &&
+ (id->bInterfaceClass == UICLASS_AUDIO || audio_if != 0 ||
+ midi_if != 0)) {
+ usbd_set_parent_iface(sc->sc_udev, curidx,
+ sc->sc_mixer_iface_index);
+ }
}
if (audio_if == 0) {
@@ -1803,9 +1823,6 @@ uaudio_chan_fill_info_sub(struct uaudio_softc *sc, struct usb_device *udev,
chan_alt->iface_index = curidx;
chan_alt->iface_alt_index = alt_index;
- usbd_set_parent_iface(sc->sc_udev, curidx,
- sc->sc_mixer_iface_index);
-
if (ep_dir == UE_DIR_IN)
chan_alt->usb_cfg = uaudio_cfg_record;
else
@@ -1826,19 +1843,21 @@ uaudio_chan_fill_info_sub(struct uaudio_softc *sc, struct usb_device *udev,
format = chan_alt->p_fmt->freebsd_fmt;
+ /* get default SND_FORMAT() */
+ format = SND_FORMAT(format, chan_alt->channels, 0);
+
switch (chan_alt->channels) {
- case 2:
- /* stereo */
- format = SND_FORMAT(format, 2, 0);
- break;
+ uint32_t temp_fmt;
case 1:
- /* mono */
- format = SND_FORMAT(format, 1, 0);
+ case 2:
+ /* mono and stereo */
break;
default:
/* surround and more */
- format = feeder_matrix_default_format(
- SND_FORMAT(format, chan_alt->channels, 0));
+ temp_fmt = feeder_matrix_default_format(format);
+ /* if multichannel, then format can be zero */
+ if (temp_fmt != 0)
+ format = temp_fmt;
break;
}
@@ -1865,6 +1884,10 @@ uaudio_chan_fill_info_sub(struct uaudio_softc *sc, struct usb_device *udev,
chan->pcm_cap.fmtlist = chan->pcm_format;
chan->pcm_cap.fmtlist[0] = format;
+ /* check if device needs bitperfect */
+ if (chan_alt->channels > UAUDIO_MATRIX_MAX)
+ sc->sc_pcm_bitperfect = 1;
+
if (rate < chan->pcm_cap.minspeed || chan->pcm_cap.minspeed == 0)
chan->pcm_cap.minspeed = rate;
if (rate > chan->pcm_cap.maxspeed || chan->pcm_cap.maxspeed == 0)
@@ -1939,15 +1962,15 @@ uaudio_chan_fill_info(struct uaudio_softc *sc, struct usb_device *udev)
channels = 4;
break;
default:
- channels = 16;
+ channels = UAUDIO_CHANNELS_MAX;
break;
}
- } else if (channels > 16) {
- channels = 16;
- }
- if (sbuf_new(&sc->sc_sndstat, NULL, 4096, SBUF_AUTOEXTEND)) {
+ } else if (channels > UAUDIO_CHANNELS_MAX)
+ channels = UAUDIO_CHANNELS_MAX;
+
+ if (sbuf_new(&sc->sc_sndstat, NULL, 4096, SBUF_AUTOEXTEND))
sc->sc_sndstat_valid = 1;
- }
+
/* try to search for a valid config */
for (x = channels; x; x--) {
diff --git a/sys/dev/twa/tw_osl_freebsd.c b/sys/dev/twa/tw_osl_freebsd.c
index 8b56267..dbd249a 100644
--- a/sys/dev/twa/tw_osl_freebsd.c
+++ b/sys/dev/twa/tw_osl_freebsd.c
@@ -423,8 +423,8 @@ twa_attach(device_t dev)
}
sc->watchdog_index = 0;
- callout_init(&(sc->watchdog_callout[0]), CALLOUT_MPSAFE);
- callout_init(&(sc->watchdog_callout[1]), CALLOUT_MPSAFE);
+ callout_init(&(sc->watchdog_callout[0]), 1);
+ callout_init(&(sc->watchdog_callout[1]), 1);
callout_reset(&(sc->watchdog_callout[0]), 5*hz, twa_watchdog, &sc->ctlr_handle);
return(0);
diff --git a/sys/dev/tws/tws.c b/sys/dev/tws/tws.c
index 9c70db3..4c3529e 100644
--- a/sys/dev/tws/tws.c
+++ b/sys/dev/tws/tws.c
@@ -198,7 +198,7 @@ tws_attach(device_t dev)
mtx_init( &sc->sim_lock, "tws_sim_lock", NULL, MTX_DEF);
mtx_init( &sc->gen_lock, "tws_gen_lock", NULL, MTX_DEF);
mtx_init( &sc->io_lock, "tws_io_lock", NULL, MTX_DEF | MTX_RECURSE);
- callout_init(&sc->stats_timer, CALLOUT_MPSAFE);
+ callout_init(&sc->stats_timer, 1);
if ( tws_init_trace_q(sc) == FAILURE )
printf("trace init failure\n");
@@ -719,7 +719,7 @@ tws_init_reqs(struct tws_softc *sc, u_int32_t dma_mem_size)
sc->reqs[i].cmd_pkt->hdr.header_desc.size_header = 128;
- callout_init(&sc->reqs[i].timeout, CALLOUT_MPSAFE);
+ callout_init(&sc->reqs[i].timeout, 1);
sc->reqs[i].state = TWS_REQ_STATE_FREE;
if ( i >= TWS_RESERVED_REQS )
tws_q_insert_tail(sc, &sc->reqs[i], TWS_FREE_Q);
diff --git a/sys/dev/uart/uart_dev_ti8250.c b/sys/dev/uart/uart_dev_ti8250.c
index 373dc74..e82dbb7 100644
--- a/sys/dev/uart/uart_dev_ti8250.c
+++ b/sys/dev/uart/uart_dev_ti8250.c
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
#include <arm/ti/ti_prcm.h>
+#include <arm/ti/ti_hwmods.h>
#include <dev/fdt/fdt_common.h>
#include <dev/ofw/ofw_bus.h>
@@ -71,29 +72,15 @@ static int
ti8250_bus_probe(struct uart_softc *sc)
{
int status;
- int devid;
clk_ident_t clkid;
- pcell_t prop;
- phandle_t node;
-
- /*
- * Get the device id from FDT. If it's not there we can't turn on the
- * right clocks, so bail, unless we're doing unit 0. We assume that's
- * the serial console, whose clock isn't controllable anyway, and we
- * sure don't want to break the console because of a config error.
- */
- node = ofw_bus_get_node(sc->sc_dev);
- if ((OF_getprop(node, "uart-device-id", &prop, sizeof(prop))) <= 0) {
- device_printf(sc->sc_dev,
- "missing uart-device-id attribute in FDT\n");
- if (device_get_unit(sc->sc_dev) != 0)
- return (ENXIO);
- devid = 0;
- } else
- devid = fdt32_to_cpu(prop);
/* Enable clocks for this device. We can't continue if that fails. */
- clkid = UART0_CLK + devid;
+ clkid = ti_hwmods_get_clock(sc->sc_dev);
+ if (clkid == INVALID_CLK_IDENT) {
+ device_printf(sc->sc_dev,
+ "failed to get clock based on hwmods\n");
+ clkid = UART1_CLK + device_get_unit(sc->sc_dev);
+ }
if ((status = ti_prcm_clk_enable(clkid)) != 0)
return (status);
@@ -138,10 +125,12 @@ static struct uart_class uart_ti8250_class = {
.uc_ops = &uart_ns8250_ops,
.uc_range = 0x88,
.uc_rclk = 48000000,
- .uc_rshift = 0
+ .uc_rshift = 2
};
static struct ofw_compat_data compat_data[] = {
{"ti,ns16550", (uintptr_t)&uart_ti8250_class},
+ {"ti,omap3-uart", (uintptr_t)&uart_ti8250_class},
+ {"ti,omap4-uart", (uintptr_t)&uart_ti8250_class},
{NULL, (uintptr_t)NULL},
};
UART_FDT_CLASS_AND_DEVICE(compat_data);
diff --git a/sys/dev/ubsec/ubsec.c b/sys/dev/ubsec/ubsec.c
index a79886c..27bb591 100644
--- a/sys/dev/ubsec/ubsec.c
+++ b/sys/dev/ubsec/ubsec.c
@@ -456,7 +456,7 @@ ubsec_attach(device_t dev)
sc->sc_rnghz = hz / 100;
else
sc->sc_rnghz = 1;
- callout_init(&sc->sc_rngto, CALLOUT_MPSAFE);
+ callout_init(&sc->sc_rngto, 1);
callout_reset(&sc->sc_rngto, sc->sc_rnghz, ubsec_rng, sc);
skip_rng:
;
diff --git a/sys/dev/usb/controller/dwc_otg.c b/sys/dev/usb/controller/dwc_otg.c
index 37b5333..50ead5c 100644
--- a/sys/dev/usb/controller/dwc_otg.c
+++ b/sys/dev/usb/controller/dwc_otg.c
@@ -297,32 +297,29 @@ dwc_otg_init_fifo(struct dwc_otg_softc *sc, uint8_t mode)
if (x < sc->sc_dev_in_ep_max) {
uint32_t limit;
- limit = (x == 1) ? DWC_OTG_MAX_TXN :
- (DWC_OTG_MAX_TXN / 2);
-
- if (fifo_size >= limit) {
- DWC_OTG_WRITE_4(sc, DOTG_DIEPTXF(x),
- ((limit / 4) << 16) |
- (tx_start / 4));
- tx_start += limit;
- fifo_size -= limit;
- pf->usb.max_in_frame_size = 0x200;
- pf->usb.support_in = 1;
- pf->max_buffer = limit;
+ limit = (x == 1) ? MIN(DWC_OTG_TX_MAX_FIFO_SIZE,
+ DWC_OTG_MAX_TXN) : MIN(DWC_OTG_MAX_TXN / 2,
+ DWC_OTG_TX_MAX_FIFO_SIZE);
- } else if (fifo_size >= 0x80) {
- DWC_OTG_WRITE_4(sc, DOTG_DIEPTXF(x),
- ((0x80 / 4) << 16) | (tx_start / 4));
- tx_start += 0x80;
- fifo_size -= 0x80;
- pf->usb.max_in_frame_size = 0x40;
+ /* see if there is enough FIFO space */
+ if (limit <= fifo_size) {
+ pf->max_buffer = limit;
pf->usb.support_in = 1;
-
} else {
- pf->usb.is_simplex = 1;
- DWC_OTG_WRITE_4(sc, DOTG_DIEPTXF(x),
- (0x0 << 16) | (tx_start / 4));
+ limit = MIN(DWC_OTG_TX_MAX_FIFO_SIZE, 0x40);
+ if (limit <= fifo_size) {
+ pf->usb.support_in = 1;
+ } else {
+ pf->usb.is_simplex = 1;
+ limit = 0;
+ }
}
+ /* set FIFO size */
+ DWC_OTG_WRITE_4(sc, DOTG_DIEPTXF(x),
+ ((limit / 4) << 16) | (tx_start / 4));
+ tx_start += limit;
+ fifo_size -= limit;
+ pf->usb.max_in_frame_size = limit;
} else {
pf->usb.is_simplex = 1;
}
@@ -1560,6 +1557,22 @@ dwc_otg_data_rx(struct dwc_otg_softc *sc, struct dwc_otg_td *td)
/* release FIFO */
dwc_otg_common_rx_ack(sc);
+ temp = sc->sc_out_ctl[td->ep_no];
+
+ /* check for isochronous mode */
+ if ((temp & DIEPCTL_EPTYPE_MASK) ==
+ (DIEPCTL_EPTYPE_ISOC << DIEPCTL_EPTYPE_SHIFT)) {
+ /* toggle odd or even frame bit */
+ if (temp & DIEPCTL_SETD1PID) {
+ temp &= ~DIEPCTL_SETD1PID;
+ temp |= DIEPCTL_SETD0PID;
+ } else {
+ temp &= ~DIEPCTL_SETD0PID;
+ temp |= DIEPCTL_SETD1PID;
+ }
+ sc->sc_out_ctl[td->ep_no] = temp;
+ }
+
/* check if we are complete */
if ((td->remainder == 0) || got_short) {
if (td->short_pkt) {
@@ -2135,10 +2148,23 @@ repeat:
temp = sc->sc_in_ctl[td->ep_no];
+ /* check for isochronous mode */
+ if ((temp & DIEPCTL_EPTYPE_MASK) ==
+ (DIEPCTL_EPTYPE_ISOC << DIEPCTL_EPTYPE_SHIFT)) {
+ /* toggle odd or even frame bit */
+ if (temp & DIEPCTL_SETD1PID) {
+ temp &= ~DIEPCTL_SETD1PID;
+ temp |= DIEPCTL_SETD0PID;
+ } else {
+ temp &= ~DIEPCTL_SETD0PID;
+ temp |= DIEPCTL_SETD1PID;
+ }
+ sc->sc_in_ctl[td->ep_no] = temp;
+ }
+
/* must enable before writing data to FIFO */
DWC_OTG_WRITE_4(sc, DOTG_DIEPCTL(td->ep_no), temp |
- DIEPCTL_EPENA |
- DIEPCTL_CNAK);
+ DIEPCTL_EPENA | DIEPCTL_CNAK);
td->tx_bytes = count;
diff --git a/sys/dev/usb/controller/dwc_otg.h b/sys/dev/usb/controller/dwc_otg.h
index 1fa1bbf..52b3b91 100644
--- a/sys/dev/usb/controller/dwc_otg.h
+++ b/sys/dev/usb/controller/dwc_otg.h
@@ -38,6 +38,9 @@
#define DWC_OTG_SLOT_IDLE_MAX 3
#define DWC_OTG_SLOT_IDLE_MIN 2
#define DWC_OTG_NAK_MAX 8 /* 1 ms */
+#ifndef DWC_OTG_TX_MAX_FIFO_SIZE
+#define DWC_OTG_TX_MAX_FIFO_SIZE DWC_OTG_MAX_TXN
+#endif
#define DWC_OTG_READ_4(sc, reg) \
bus_space_read_4((sc)->sc_io_tag, (sc)->sc_io_hdl, reg)
diff --git a/sys/dev/usb/quirk/usb_quirk.c b/sys/dev/usb/quirk/usb_quirk.c
index e0c5db7..3cfaef0 100644
--- a/sys/dev/usb/quirk/usb_quirk.c
+++ b/sys/dev/usb/quirk/usb_quirk.c
@@ -523,6 +523,9 @@ static struct usb_quirk_entry usb_quirks[USB_DEV_QUIRKS_MAX] = {
USB_QUIRK(FEIYA, DUMMY, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE, UQ_MATCH_VENDOR_ONLY),
USB_QUIRK(REALTEK, DUMMY, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE, UQ_MATCH_VENDOR_ONLY),
USB_QUIRK(INITIO, DUMMY, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE, UQ_MATCH_VENDOR_ONLY),
+
+ /* DYMO LabelManager Pnp */
+ USB_QUIRK(DYMO, LABELMANAGERPNP, 0x0000, 0xffff, UQ_MSC_DYMO_EJECT),
};
#undef USB_QUIRK_VP
#undef USB_QUIRK
@@ -592,6 +595,7 @@ static const char *usb_quirk_str[USB_QUIRK_MAX] = {
[UQ_BAD_MIDI] = "UQ_BAD_MIDI",
[UQ_AU_VENDOR_CLASS] = "UQ_AU_VENDOR_CLASS",
[UQ_SINGLE_CMD_MIDI] = "UQ_SINGLE_CMD_MIDI",
+ [UQ_MSC_DYMO_EJECT] = "UQ_MSC_DYMO_EJECT",
};
/*------------------------------------------------------------------------*
diff --git a/sys/dev/usb/quirk/usb_quirk.h b/sys/dev/usb/quirk/usb_quirk.h
index c2e9501..7010916 100644
--- a/sys/dev/usb/quirk/usb_quirk.h
+++ b/sys/dev/usb/quirk/usb_quirk.h
@@ -108,6 +108,7 @@ enum {
UQ_BAD_MIDI, /* device claims MIDI class, but isn't */
UQ_AU_VENDOR_CLASS, /* audio device uses vendor and not audio class */
UQ_SINGLE_CMD_MIDI, /* at most one command per USB packet */
+ UQ_MSC_DYMO_EJECT, /* ejects Dymo MSC device */
USB_QUIRK_MAX
};
diff --git a/sys/dev/usb/serial/u3g.c b/sys/dev/usb/serial/u3g.c
index cd4cc1e..88b8961 100644
--- a/sys/dev/usb/serial/u3g.c
+++ b/sys/dev/usb/serial/u3g.c
@@ -522,6 +522,7 @@ static const STRUCT_USB_HOST_ID u3g_devs[] = {
U3G_DEV(SIERRA, MC5727, 0),
U3G_DEV(SIERRA, MC5727_2, 0),
U3G_DEV(SIERRA, MC5728, 0),
+ U3G_DEV(SIERRA, MC7354, 0),
U3G_DEV(SIERRA, MC8700, 0),
U3G_DEV(SIERRA, MC8755, 0),
U3G_DEV(SIERRA, MC8755_2, 0),
diff --git a/sys/dev/usb/serial/uftdi.c b/sys/dev/usb/serial/uftdi.c
index 0159520..c0dc79f 100644
--- a/sys/dev/usb/serial/uftdi.c
+++ b/sys/dev/usb/serial/uftdi.c
@@ -497,6 +497,7 @@ static const STRUCT_USB_HOST_ID uftdi_devs[] = {
UFTDI_DEV(FTDI, SCS_DEVICE_5, 0),
UFTDI_DEV(FTDI, SCS_DEVICE_6, 0),
UFTDI_DEV(FTDI, SCS_DEVICE_7, 0),
+ UFTDI_DEV(FTDI, SCX8_USB_PHOENIX, 0),
UFTDI_DEV(FTDI, SDMUSBQSS, 0),
UFTDI_DEV(FTDI, SEMC_DSS20, 0),
UFTDI_DEV(FTDI, SERIAL_2232C, UFTDI_JTAG_CHECK_STRING),
diff --git a/sys/dev/usb/serial/usb_serial.c b/sys/dev/usb/serial/usb_serial.c
index ae4ed3a..46d08b5 100644
--- a/sys/dev/usb/serial/usb_serial.c
+++ b/sys/dev/usb/serial/usb_serial.c
@@ -415,8 +415,9 @@ ucom_attach_tty(struct ucom_super_softc *ssc, struct ucom_softc *sc)
sc->sc_tty = tp;
sc->sc_pps.ppscap = PPS_CAPTUREBOTH;
- sc->sc_pps.mtx = sc->sc_mtx;
- pps_init(&sc->sc_pps);
+ sc->sc_pps.driver_abi = PPS_ABI_VERSION;
+ sc->sc_pps.driver_mtx = sc->sc_mtx;
+ pps_init_abi(&sc->sc_pps);
DPRINTF("ttycreate: %s\n", buf);
diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c
index b3b46b3..5ffc07f 100644
--- a/sys/dev/usb/usb_device.c
+++ b/sys/dev/usb/usb_device.c
@@ -1343,6 +1343,12 @@ usb_probe_and_attach(struct usb_device *udev, uint8_t iface_index)
*/
if (iface_index == USB_IFACE_INDEX_ANY) {
+ if (usb_test_quirk(&uaa, UQ_MSC_DYMO_EJECT) != 0 &&
+ usb_dymo_eject(udev, 0) == 0) {
+ /* success, mark the udev as disappearing */
+ uaa.dev_state = UAA_DEV_EJECTING;
+ }
+
EVENTHANDLER_INVOKE(usb_dev_configured, udev, &uaa);
if (uaa.dev_state != UAA_DEV_READY) {
diff --git a/sys/dev/usb/usb_msctest.c b/sys/dev/usb/usb_msctest.c
index c77afd0..b99fd29 100644
--- a/sys/dev/usb/usb_msctest.c
+++ b/sys/dev/usb/usb_msctest.c
@@ -181,6 +181,7 @@ static usb_callback_t bbb_data_rd_cs_callback;
static usb_callback_t bbb_data_write_callback;
static usb_callback_t bbb_data_wr_cs_callback;
static usb_callback_t bbb_status_callback;
+static usb_callback_t bbb_raw_write_callback;
static void bbb_done(struct bbb_transfer *, int);
static void bbb_transfer_start(struct bbb_transfer *, uint8_t);
@@ -188,7 +189,7 @@ static void bbb_data_clear_stall_callback(struct usb_xfer *, uint8_t,
uint8_t);
static int bbb_command_start(struct bbb_transfer *, uint8_t, uint8_t,
void *, size_t, void *, size_t, usb_timeout_t);
-static struct bbb_transfer *bbb_attach(struct usb_device *, uint8_t);
+static struct bbb_transfer *bbb_attach(struct usb_device *, uint8_t, uint8_t);
static void bbb_detach(struct bbb_transfer *);
static const struct usb_config bbb_config[ST_MAX] = {
@@ -251,6 +252,19 @@ static const struct usb_config bbb_config[ST_MAX] = {
},
};
+static const struct usb_config bbb_raw_config[1] = {
+
+ [0] = {
+ .type = UE_BULK_INTR,
+ .endpoint = UE_ADDR_ANY,
+ .direction = UE_DIR_OUT,
+ .bufsize = SCSI_MAX_LEN,
+ .flags = {.ext_buffer = 1,.proxy_buffer = 1,},
+ .callback = &bbb_raw_write_callback,
+ .timeout = 1 * USB_MS_HZ, /* 1 second */
+ },
+};
+
static void
bbb_done(struct bbb_transfer *sc, int error)
{
@@ -471,6 +485,47 @@ bbb_status_callback(struct usb_xfer *xfer, usb_error_t error)
}
}
+static void
+bbb_raw_write_callback(struct usb_xfer *xfer, usb_error_t error)
+{
+ struct bbb_transfer *sc = usbd_xfer_softc(xfer);
+ usb_frlength_t max_bulk = usbd_xfer_max_len(xfer);
+ int actlen, sumlen;
+
+ usbd_xfer_status(xfer, &actlen, &sumlen, NULL, NULL);
+
+ switch (USB_GET_STATE(xfer)) {
+ case USB_ST_TRANSFERRED:
+ sc->data_rem -= actlen;
+ sc->data_ptr += actlen;
+ sc->actlen += actlen;
+
+ if (actlen < sumlen) {
+ /* short transfer */
+ sc->data_rem = 0;
+ }
+ case USB_ST_SETUP:
+ DPRINTF("max_bulk=%d, data_rem=%d\n",
+ max_bulk, sc->data_rem);
+
+ if (sc->data_rem == 0) {
+ bbb_done(sc, 0);
+ break;
+ }
+ if (max_bulk > sc->data_rem) {
+ max_bulk = sc->data_rem;
+ }
+ usbd_xfer_set_timeout(xfer, sc->data_timeout);
+ usbd_xfer_set_frame_data(xfer, 0, sc->data_ptr, max_bulk);
+ usbd_transfer_submit(xfer);
+ break;
+
+ default: /* Error */
+ bbb_done(sc, error);
+ break;
+ }
+}
+
/*------------------------------------------------------------------------*
* bbb_command_start - execute a SCSI command synchronously
*
@@ -506,13 +561,45 @@ bbb_command_start(struct bbb_transfer *sc, uint8_t dir, uint8_t lun,
return (sc->error);
}
+/*------------------------------------------------------------------------*
+ * bbb_raw_write - write a raw BULK message synchronously
+ *
+ * Return values
+ * 0: Success
+ * Else: Failure
+ *------------------------------------------------------------------------*/
+static int
+bbb_raw_write(struct bbb_transfer *sc, const void *data_ptr, size_t data_len,
+ usb_timeout_t data_timeout)
+{
+ sc->data_ptr = __DECONST(void *, data_ptr);
+ sc->data_len = data_len;
+ sc->data_rem = data_len;
+ sc->data_timeout = (data_timeout + USB_MS_HZ);
+ sc->actlen = 0;
+ sc->error = 0;
+
+ DPRINTFN(1, "BULK DATA = %*D\n", (int)data_len,
+ (const char *)data_ptr, ":");
+
+ mtx_lock(&sc->mtx);
+ usbd_transfer_start(sc->xfer[0]);
+ while (usbd_transfer_pending(sc->xfer[0]))
+ cv_wait(&sc->cv, &sc->mtx);
+ mtx_unlock(&sc->mtx);
+ return (sc->error);
+}
+
static struct bbb_transfer *
-bbb_attach(struct usb_device *udev, uint8_t iface_index)
+bbb_attach(struct usb_device *udev, uint8_t iface_index,
+ uint8_t bInterfaceClass)
{
struct usb_interface *iface;
struct usb_interface_descriptor *id;
+ const struct usb_config *pconfig;
struct bbb_transfer *sc;
usb_error_t err;
+ int nconfig;
#if USB_HAVE_MSCTEST_DETACH
uint8_t do_unlock;
@@ -535,22 +622,39 @@ bbb_attach(struct usb_device *udev, uint8_t iface_index)
return (NULL);
id = iface->idesc;
- if (id == NULL || id->bInterfaceClass != UICLASS_MASS)
+ if (id == NULL || id->bInterfaceClass != bInterfaceClass)
return (NULL);
- switch (id->bInterfaceSubClass) {
- case UISUBCLASS_SCSI:
- case UISUBCLASS_UFI:
- case UISUBCLASS_SFF8020I:
- case UISUBCLASS_SFF8070I:
+ switch (id->bInterfaceClass) {
+ case UICLASS_MASS:
+ switch (id->bInterfaceSubClass) {
+ case UISUBCLASS_SCSI:
+ case UISUBCLASS_UFI:
+ case UISUBCLASS_SFF8020I:
+ case UISUBCLASS_SFF8070I:
+ break;
+ default:
+ return (NULL);
+ }
+ switch (id->bInterfaceProtocol) {
+ case UIPROTO_MASS_BBB_OLD:
+ case UIPROTO_MASS_BBB:
+ break;
+ default:
+ return (NULL);
+ }
+ pconfig = bbb_config;
+ nconfig = ST_MAX;
break;
- default:
- return (NULL);
- }
-
- switch (id->bInterfaceProtocol) {
- case UIPROTO_MASS_BBB_OLD:
- case UIPROTO_MASS_BBB:
+ case UICLASS_HID:
+ switch (id->bInterfaceSubClass) {
+ case 0:
+ break;
+ default:
+ return (NULL);
+ }
+ pconfig = bbb_raw_config;
+ nconfig = 1;
break;
default:
return (NULL);
@@ -560,22 +664,27 @@ bbb_attach(struct usb_device *udev, uint8_t iface_index)
mtx_init(&sc->mtx, "USB autoinstall", NULL, MTX_DEF);
cv_init(&sc->cv, "WBBB");
- err = usbd_transfer_setup(udev, &iface_index, sc->xfer, bbb_config,
- ST_MAX, sc, &sc->mtx);
+ err = usbd_transfer_setup(udev, &iface_index, sc->xfer, pconfig,
+ nconfig, sc, &sc->mtx);
if (err) {
bbb_detach(sc);
return (NULL);
}
- /* store pointer to DMA buffers */
- sc->buffer = usbd_xfer_get_frame_buffer(
- sc->xfer[ST_DATA_RD], 0);
- sc->buffer_size =
- usbd_xfer_max_len(sc->xfer[ST_DATA_RD]);
- sc->cbw = usbd_xfer_get_frame_buffer(
- sc->xfer[ST_COMMAND], 0);
- sc->csw = usbd_xfer_get_frame_buffer(
- sc->xfer[ST_STATUS], 0);
-
+ switch (id->bInterfaceClass) {
+ case UICLASS_MASS:
+ /* store pointer to DMA buffers */
+ sc->buffer = usbd_xfer_get_frame_buffer(
+ sc->xfer[ST_DATA_RD], 0);
+ sc->buffer_size =
+ usbd_xfer_max_len(sc->xfer[ST_DATA_RD]);
+ sc->cbw = usbd_xfer_get_frame_buffer(
+ sc->xfer[ST_COMMAND], 0);
+ sc->csw = usbd_xfer_get_frame_buffer(
+ sc->xfer[ST_STATUS], 0);
+ break;
+ default:
+ break;
+ }
return (sc);
}
@@ -604,7 +713,7 @@ usb_iface_is_cdrom(struct usb_device *udev, uint8_t iface_index)
uint8_t sid_type;
int err;
- sc = bbb_attach(udev, iface_index);
+ sc = bbb_attach(udev, iface_index, UICLASS_MASS);
if (sc == NULL)
return (0);
@@ -660,7 +769,7 @@ usb_msc_auto_quirk(struct usb_device *udev, uint8_t iface_index)
uint8_t sid_type;
int err;
- sc = bbb_attach(udev, iface_index);
+ sc = bbb_attach(udev, iface_index, UICLASS_MASS);
if (sc == NULL)
return (0);
@@ -829,7 +938,7 @@ usb_msc_eject(struct usb_device *udev, uint8_t iface_index, int method)
struct bbb_transfer *sc;
usb_error_t err;
- sc = bbb_attach(udev, iface_index);
+ sc = bbb_attach(udev, iface_index, UICLASS_MASS);
if (sc == NULL)
return (USB_ERR_INVAL);
@@ -890,6 +999,21 @@ usb_msc_eject(struct usb_device *udev, uint8_t iface_index, int method)
}
usb_error_t
+usb_dymo_eject(struct usb_device *udev, uint8_t iface_index)
+{
+ static const uint8_t data[3] = { 0x1b, 0x5a, 0x01 };
+ struct bbb_transfer *sc;
+ usb_error_t err;
+
+ sc = bbb_attach(udev, iface_index, UICLASS_HID);
+ if (sc == NULL)
+ return (USB_ERR_INVAL);
+ err = bbb_raw_write(sc, data, sizeof(data), USB_MS_HZ);
+ bbb_detach(sc);
+ return (err);
+}
+
+usb_error_t
usb_msc_read_10(struct usb_device *udev, uint8_t iface_index,
uint32_t lba, uint32_t blocks, void *buffer)
{
@@ -908,7 +1032,7 @@ usb_msc_read_10(struct usb_device *udev, uint8_t iface_index,
cmd[8] = blocks;
cmd[9] = 0;
- sc = bbb_attach(udev, iface_index);
+ sc = bbb_attach(udev, iface_index, UICLASS_MASS);
if (sc == NULL)
return (USB_ERR_INVAL);
@@ -939,7 +1063,7 @@ usb_msc_write_10(struct usb_device *udev, uint8_t iface_index,
cmd[8] = blocks;
cmd[9] = 0;
- sc = bbb_attach(udev, iface_index);
+ sc = bbb_attach(udev, iface_index, UICLASS_MASS);
if (sc == NULL)
return (USB_ERR_INVAL);
@@ -958,7 +1082,7 @@ usb_msc_read_capacity(struct usb_device *udev, uint8_t iface_index,
struct bbb_transfer *sc;
usb_error_t err;
- sc = bbb_attach(udev, iface_index);
+ sc = bbb_attach(udev, iface_index, UICLASS_MASS);
if (sc == NULL)
return (USB_ERR_INVAL);
diff --git a/sys/dev/usb/usb_msctest.h b/sys/dev/usb/usb_msctest.h
index dcc3cf7..d3f26c2 100644
--- a/sys/dev/usb/usb_msctest.h
+++ b/sys/dev/usb/usb_msctest.h
@@ -52,5 +52,7 @@ usb_error_t usb_msc_write_10(struct usb_device *udev,
usb_error_t usb_msc_read_capacity(struct usb_device *udev,
uint8_t iface_index, uint32_t *lba_last,
uint32_t *block_size);
+usb_error_t usb_dymo_eject(struct usb_device *udev,
+ uint8_t iface_index);
#endif /* _USB_MSCTEST_H_ */
diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs
index 4a10610..f8ba5b5 100644
--- a/sys/dev/usb/usbdevs
+++ b/sys/dev/usb/usbdevs
@@ -452,6 +452,7 @@ vendor GLOBESPAN 0x0915 Globespan
vendor CONCORDCAMERA 0x0919 Concord Camera
vendor GARMIN 0x091e Garmin International
vendor GOHUBS 0x0921 GoHubs
+vendor DYMO 0x0922 DYMO
vendor XEROX 0x0924 Xerox
vendor BIOMETRIC 0x0929 American Biometric Company
vendor TOSHIBA 0x0930 Toshiba
@@ -1694,6 +1695,9 @@ product DRESDENELEKTRONIK WIRELESSHANDHELDTERMINAL 0x0004 Wireless Handheld Ter
product DRESDENELEKTRONIK DE_RFNODE 0x001c deRFnode
product DRESDENELEKTRONIK LEVELSHIFTERSTICKLOWCOST 0x0022 Levelshifter Stick Low Cost
+/* DYMO */
+product DYMO LABELMANAGERPNP 0x1001 DYMO LabelManager PnP
+
/* Dynastream Innovations */
product DYNASTREAM ANTDEVBOARD 0x1003 ANT dev board
product DYNASTREAM ANT2USB 0x1004 ANT2USB
@@ -1872,6 +1876,7 @@ product FREECOM HDD 0xfc05 Classic SL Hard Drive
product FSC E5400 0x1009 PrismGT USB 2.0 WLAN
/* Future Technology Devices products */
+product FTDI SCX8_USB_PHOENIX 0x5259 SCx8 USB Phoenix interface
product FTDI SERIAL_8U100AX 0x8372 8U100AX Serial
product FTDI SERIAL_8U232AM 0x6001 8U232AM Serial
product FTDI SERIAL_8U232AM4 0x6004 8U232AM Serial
@@ -3755,6 +3760,7 @@ product REALTEK RTL8188CU_1 0x817a RTL8188CU
product REALTEK RTL8188CU_2 0x817b RTL8188CU
product REALTEK RTL8187 0x8187 RTL8187 Wireless Adapter
product REALTEK RTL8187B_0 0x8189 RTL8187B Wireless Adapter
+product REALTEK RTL8188CU_3 0x8191 RTL8188CU
product REALTEK RTL8196EU 0x8196 RTL8196EU
product REALTEK RTL8187B_1 0x8197 RTL8187B Wireless Adapter
product REALTEK RTL8187B_2 0x8198 RTL8187B Wireless Adapter
@@ -4028,6 +4034,7 @@ product SIERRA C22 0x6891 C22
product SIERRA E6892 0x6892 E6892
product SIERRA E6893 0x6893 E6893
product SIERRA MC8700 0x68A3 MC8700
+product SIERRA MC7354 0x6820 MC7354
product SIERRA AIRCARD875 0x6820 Aircard 875 HSDPA
product SIERRA AC313U 0x68aa Sierra Wireless AirCard 313U
product SIERRA TRUINSTALL 0x0fff Aircard Tru Installer
diff --git a/sys/dev/usb/video/udl.c b/sys/dev/usb/video/udl.c
index 69e2429..0d7c504 100644
--- a/sys/dev/usb/video/udl.c
+++ b/sys/dev/usb/video/udl.c
@@ -203,12 +203,14 @@ udl_buffer_alloc(uint32_t size)
}
mtx_unlock(&udl_buffer_mtx);
if (buf != NULL) {
+ uint8_t *ptr = ((uint8_t *)buf) - size;
/* wipe and recycle buffer */
- memset(buf, 0, size);
- return (buf);
+ memset(ptr, 0, size);
+ /* return buffer pointer */
+ return (ptr);
}
/* allocate new buffer */
- return (malloc(size, M_USB_DL, M_WAITOK | M_ZERO));
+ return (malloc(size + sizeof(*buf), M_USB_DL, M_WAITOK | M_ZERO));
}
static void
@@ -216,9 +218,11 @@ udl_buffer_free(void *_buf, uint32_t size)
{
struct udl_buffer *buf;
- buf = (struct udl_buffer *)_buf;
- if (buf == NULL)
+ /* check for NULL pointer */
+ if (_buf == NULL)
return;
+ /* compute pointer to recycle list */
+ buf = (struct udl_buffer *)(((uint8_t *)_buf) + size);
/*
* Memory mapped buffers should never be freed.
diff --git a/sys/dev/usb/wlan/if_urtwn.c b/sys/dev/usb/wlan/if_urtwn.c
index ba2779d..331f782 100644
--- a/sys/dev/usb/wlan/if_urtwn.c
+++ b/sys/dev/usb/wlan/if_urtwn.c
@@ -137,6 +137,7 @@ static const STRUCT_USB_HOST_ID urtwn_devs[] = {
URTWN_DEV(REALTEK, RTL8188CU_0),
URTWN_DEV(REALTEK, RTL8188CU_1),
URTWN_DEV(REALTEK, RTL8188CU_2),
+ URTWN_DEV(REALTEK, RTL8188CU_3),
URTWN_DEV(REALTEK, RTL8188CU_COMBO),
URTWN_DEV(REALTEK, RTL8188CUS),
URTWN_DEV(REALTEK, RTL8188RU_1),
@@ -145,7 +146,6 @@ static const STRUCT_USB_HOST_ID urtwn_devs[] = {
URTWN_DEV(REALTEK, RTL8191CU),
URTWN_DEV(REALTEK, RTL8192CE),
URTWN_DEV(REALTEK, RTL8192CU),
- URTWN_DEV(REALTEK, RTL8188CU_0),
URTWN_DEV(SITECOMEU, RTL8188CU_1),
URTWN_DEV(SITECOMEU, RTL8188CU_2),
URTWN_DEV(SITECOMEU, RTL8192CU),
@@ -1195,7 +1195,7 @@ urtwn_efuse_read(struct urtwn_softc *sc)
uint8_t *rom = (uint8_t *)&sc->rom;
uint16_t addr = 0;
uint32_t reg;
- uint8_t off, msk, vol;
+ uint8_t off, msk;
int i;
urtwn_efuse_switch_power(sc);
@@ -1228,18 +1228,15 @@ urtwn_efuse_read(struct urtwn_softc *sc)
printf("\n");
}
#endif
- /* Disable LDO 2.5V. */
- vol = urtwn_read_1(sc, R92C_EFUSE_TEST + 3);
- urtwn_write_1(sc, R92C_EFUSE_TEST + 3, vol & ~(0x80));
-
+ urtwn_write_1(sc, R92C_EFUSE_ACCESS, R92C_EFUSE_ACCESS_OFF);
}
+
static void
urtwn_efuse_switch_power(struct urtwn_softc *sc)
{
uint32_t reg;
- if (sc->chip & URTWN_CHIP_88E)
- urtwn_write_1(sc, R92C_EFUSE_ACCESS, R92C_EFUSE_ACCESS_ON);
+ urtwn_write_1(sc, R92C_EFUSE_ACCESS, R92C_EFUSE_ACCESS_ON);
reg = urtwn_read_2(sc, R92C_SYS_ISO_CTRL);
if (!(reg & R92C_SYS_ISO_CTRL_PWC_EV12V)) {
@@ -1257,16 +1254,6 @@ urtwn_efuse_switch_power(struct urtwn_softc *sc)
urtwn_write_2(sc, R92C_SYS_CLKR,
reg | R92C_SYS_CLKR_LOADER_EN | R92C_SYS_CLKR_ANA8M);
}
-
- if (!(sc->chip & URTWN_CHIP_88E)) {
- uint8_t vol;
-
- /* Enable LDO 2.5V. */
- vol = urtwn_read_1(sc, R92C_EFUSE_TEST + 3);
- vol &= 0x0f;
- vol |= 0x30;
- urtwn_write_1(sc, R92C_EFUSE_TEST + 3, (vol | 0x80));
- }
}
static int
@@ -1905,10 +1892,7 @@ urtwn_tx_start(struct urtwn_softc *sc, struct ieee80211_node *ni,
txd->txdw4 |= htole32(SM(R92C_TXDW4_RTSRATE, 8));
txd->txdw5 |= htole32(0x0001ff00);
/* Send data at OFDM54. */
- if (sc->chip & URTWN_CHIP_88E)
- txd->txdw5 |= htole32(0x13 & 0x3f);
- else
- txd->txdw5 |= htole32(SM(R92C_TXDW5_DATARATE, 11));
+ txd->txdw5 |= htole32(SM(R92C_TXDW5_DATARATE, 11));
} else {
txd->txdw1 |= htole32(
SM(R92C_TXDW1_MACID, 0) |
@@ -2578,7 +2562,6 @@ urtwn_r88e_dma_init(struct urtwn_softc *sc)
return (EIO);
/* Set number of pages for normal priority queue. */
- urtwn_write_2(sc, R92C_RQPN_NPQ, 0);
urtwn_write_2(sc, R92C_RQPN_NPQ, 0x000d);
urtwn_write_4(sc, R92C_RQPN, 0x808e000d);
@@ -3365,6 +3348,7 @@ urtwn_init_locked(void *arg)
urtwn_rxfilter_init(sc);
+ /* Set response rate. */
reg = urtwn_read_4(sc, R92C_RRSR);
reg = RW(reg, R92C_RRSR_RATE_BITMAP, R92C_RRSR_RATE_CCK_ONLY_1M);
urtwn_write_4(sc, R92C_RRSR, reg);
@@ -3397,16 +3381,17 @@ urtwn_init_locked(void *arg)
urtwn_write_1(sc, R92C_TRXDMA_CTRL,
urtwn_read_1(sc, R92C_TRXDMA_CTRL) |
R92C_TRXDMA_CTRL_RXDMA_AGG_EN);
- urtwn_write_1(sc, R92C_USB_SPECIAL_OPTION,
- urtwn_read_1(sc, R92C_USB_SPECIAL_OPTION) |
- R92C_USB_SPECIAL_OPTION_AGG_EN);
urtwn_write_1(sc, R92C_RXDMA_AGG_PG_TH, 48);
if (sc->chip & URTWN_CHIP_88E)
urtwn_write_1(sc, R92C_RXDMA_AGG_PG_TH + 1, 4);
- else
+ else {
urtwn_write_1(sc, R92C_USB_DMA_AGG_TO, 4);
- urtwn_write_1(sc, R92C_USB_AGG_TH, 8);
- urtwn_write_1(sc, R92C_USB_AGG_TO, 6);
+ urtwn_write_1(sc, R92C_USB_SPECIAL_OPTION,
+ urtwn_read_1(sc, R92C_USB_SPECIAL_OPTION) |
+ R92C_USB_SPECIAL_OPTION_AGG_EN);
+ urtwn_write_1(sc, R92C_USB_AGG_TH, 8);
+ urtwn_write_1(sc, R92C_USB_AGG_TO, 6);
+ }
/* Initialize beacon parameters. */
urtwn_write_2(sc, R92C_BCN_CTRL, 0x1010);
diff --git a/sys/dev/usb/wlan/if_urtwnreg.h b/sys/dev/usb/wlan/if_urtwnreg.h
index 4eef029..2bbec7a 100644
--- a/sys/dev/usb/wlan/if_urtwnreg.h
+++ b/sys/dev/usb/wlan/if_urtwnreg.h
@@ -177,13 +177,13 @@
#define R92C_RD_NAV_NXT 0x544
#define R92C_NAV_PROT_LEN 0x546
#define R92C_BCN_CTRL 0x550
-#define R92C_USTIME_TSF 0x551
#define R92C_MBID_NUM 0x552
#define R92C_DUAL_TSF_RST 0x553
#define R92C_BCN_INTERVAL 0x554
#define R92C_DRVERLYINT 0x558
#define R92C_BCNDMATIM 0x559
#define R92C_ATIMWND 0x55a
+#define R92C_USTIME_TSF 0x55c
#define R92C_BCN_MAX_ERR 0x55d
#define R92C_RXTSF_OFFSET_CCK 0x55e
#define R92C_RXTSF_OFFSET_OFDM 0x55f
diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c
index 39fc28d..704a3d9 100644
--- a/sys/dev/virtio/network/if_vtnet.c
+++ b/sys/dev/virtio/network/if_vtnet.c
@@ -2745,6 +2745,11 @@ vtnet_drain_rxtx_queues(struct vtnet_softc *sc)
struct vtnet_txq *txq;
int i;
+#ifdef DEV_NETMAP
+ if (nm_native_on(NA(sc->vtnet_ifp)))
+ return;
+#endif /* DEV_NETMAP */
+
for (i = 0; i < sc->vtnet_act_vq_pairs; i++) {
rxq = &sc->vtnet_rxqs[i];
vtnet_rxq_free_mbufs(rxq);
diff --git a/sys/dev/virtio/random/virtio_random.c b/sys/dev/virtio/random/virtio_random.c
index bd1f0df..caa4288 100644
--- a/sys/dev/virtio/random/virtio_random.c
+++ b/sys/dev/virtio/random/virtio_random.c
@@ -129,7 +129,7 @@ vtrnd_attach(device_t dev)
sc = device_get_softc(dev);
sc->vtrnd_dev = dev;
- callout_init(&sc->vtrnd_callout, CALLOUT_MPSAFE);
+ callout_init(&sc->vtrnd_callout, 1);
virtio_set_feature_desc(dev, vtrnd_feature_desc);
vtrnd_negotiate_features(sc);
diff --git a/sys/dev/vt/hw/fb/vt_fb.c b/sys/dev/vt/hw/fb/vt_fb.c
index 40f56fc..b2babd1 100644
--- a/sys/dev/vt/hw/fb/vt_fb.c
+++ b/sys/dev/vt/hw/fb/vt_fb.c
@@ -264,46 +264,40 @@ vt_fb_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw,
{
struct fb_info *info;
uint32_t fgc, bgc, cc, o;
- int c, l, bpp, bpl;
- u_long line;
- uint8_t b, m;
- const uint8_t *ch;
+ int bpp, bpl, xi, yi;
+ int bit, byte;
info = vd->vd_softc;
bpp = FBTYPE_GET_BYTESPP(info);
fgc = info->fb_cmap[fg];
bgc = info->fb_cmap[bg];
- b = m = 0;
- bpl = (width + 7) >> 3; /* Bytes per source line. */
+ bpl = (width + 7) / 8; /* Bytes per source line. */
if (info->fb_flags & FB_FLAG_NOWRITE)
return;
KASSERT((info->fb_vbase != 0), ("Unmapped framebuffer"));
- line = (info->fb_stride * y) + (x * bpp);
- for (l = 0;
- l < height && y + l < vw->vw_draw_area.tr_end.tp_row;
- l++) {
- ch = pattern;
- for (c = 0;
- c < width && x + c < vw->vw_draw_area.tr_end.tp_col;
- c++) {
- if (c % 8 == 0)
- b = *ch++;
- else
- b <<= 1;
- if (mask != NULL) {
- if (c % 8 == 0)
- m = *mask++;
- else
- m <<= 1;
- /* Skip pixel write, if mask has no bit set. */
- if ((m & 0x80) == 0)
- continue;
- }
- o = line + (c * bpp);
- cc = b & 0x80 ? fgc : bgc;
+ /* Bound by right and bottom edges. */
+ if (y + height > vw->vw_draw_area.tr_end.tp_row) {
+ if (y >= vw->vw_draw_area.tr_end.tp_row)
+ return;
+ height = vw->vw_draw_area.tr_end.tp_row - y;
+ }
+ if (x + width > vw->vw_draw_area.tr_end.tp_col) {
+ if (x >= vw->vw_draw_area.tr_end.tp_col)
+ return;
+ width = vw->vw_draw_area.tr_end.tp_col - x;
+ }
+ for (yi = 0; yi < height; yi++) {
+ for (xi = 0; xi < width; xi++) {
+ byte = yi * bpl + xi / 8;
+ bit = 0x80 >> (xi % 8);
+ /* Skip pixel write, if mask bit not set. */
+ if (mask != NULL && (mask[byte] & bit) == 0)
+ continue;
+ o = (y + yi) * info->fb_stride + (x + xi) * bpp;
+ cc = pattern[byte] & bit ? fgc : bgc;
switch(bpp) {
case 1:
@@ -326,8 +320,6 @@ vt_fb_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw,
break;
}
}
- line += info->fb_stride;
- pattern += bpl;
}
}
diff --git a/sys/dev/vt/hw/vga/vt_vga.c b/sys/dev/vt/hw/vga/vt_vga.c
index e939fdd..689692e 100644
--- a/sys/dev/vt/hw/vga/vt_vga.c
+++ b/sys/dev/vt/hw/vga/vt_vga.c
@@ -1035,11 +1035,12 @@ vga_initialize_graphics(struct vt_device *vd)
REG_WRITE1(sc, VGA_GC_DATA, 0xff);
}
-static void
+static int
vga_initialize(struct vt_device *vd, int textmode)
{
struct vga_softc *sc = vd->vd_softc;
uint8_t x;
+ int timeout;
/* Make sure the VGA adapter is not in monochrome emulation mode. */
x = REG_READ1(sc, VGA_GEN_MISC_OUTPUT_R);
@@ -1060,10 +1061,16 @@ vga_initialize(struct vt_device *vd, int textmode)
* code therefore also removes that guarantee and appropriate measures
* need to be taken.
*/
+ timeout = 10000;
do {
+ DELAY(10);
x = REG_READ1(sc, VGA_GEN_INPUT_STAT_1);
x &= VGA_GEN_IS1_VR | VGA_GEN_IS1_DE;
- } while (x != (VGA_GEN_IS1_VR | VGA_GEN_IS1_DE));
+ } while (x != (VGA_GEN_IS1_VR | VGA_GEN_IS1_DE) && --timeout != 0);
+ if (timeout == 0) {
+ printf("Timeout initializing vt_vga\n");
+ return (ENXIO);
+ }
/* Now, disable the sync. signals. */
REG_WRITE1(sc, VGA_CRTC_ADDRESS, VGA_CRTC_MODE_CONTROL);
@@ -1194,6 +1201,8 @@ vga_initialize(struct vt_device *vd, int textmode)
*/
sc->vga_curfg = sc->vga_curbg = 0xff;
}
+
+ return (0);
}
static int
@@ -1235,7 +1244,8 @@ vga_init(struct vt_device *vd)
vd->vd_width = VT_VGA_WIDTH;
vd->vd_height = VT_VGA_HEIGHT;
}
- vga_initialize(vd, textmode);
+ if (vga_initialize(vd, textmode) != 0)
+ return (CN_DEAD);
sc->vga_enabled = true;
return (CN_INTERNAL);
diff --git a/sys/dev/vt/vt.h b/sys/dev/vt/vt.h
index 85c0345..bdfcf46 100644
--- a/sys/dev/vt/vt.h
+++ b/sys/dev/vt/vt.h
@@ -83,9 +83,8 @@
#define ISSIGVALID(sig) ((sig) > 0 && (sig) < NSIG)
#define VT_SYSCTL_INT(_name, _default, _descr) \
-static int vt_##_name = _default; \
-SYSCTL_INT(_kern_vt, OID_AUTO, _name, CTLFLAG_RWTUN, &vt_##_name, _default,\
- _descr);
+static int vt_##_name = (_default); \
+SYSCTL_INT(_kern_vt, OID_AUTO, _name, CTLFLAG_RWTUN, &vt_##_name, 0, _descr)
struct vt_driver;
diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c
index a637055..ecd5267 100644
--- a/sys/dev/vt/vt_core.c
+++ b/sys/dev/vt/vt_core.c
@@ -451,12 +451,35 @@ vt_proc_window_switch(struct vt_window *vw)
struct vt_device *vd;
int ret;
+ /* Prevent switching to NULL */
+ if (vw == NULL) {
+ DPRINTF(30, "%s: Cannot switch: vw is NULL.", __func__);
+ return (EINVAL);
+ }
vd = vw->vw_device;
curvw = vd->vd_curwindow;
+ /* Check if virtual terminal is locked */
if (curvw->vw_flags & VWF_VTYLOCK)
return (EBUSY);
+ /* Check if switch already in progress */
+ if (curvw->vw_flags & VWF_SWWAIT_REL) {
+ /* Check if switching to same window */
+ if (curvw->vw_switch_to == vw) {
+ DPRINTF(30, "%s: Switch in progress to same vw.", __func__);
+ return (0); /* success */
+ }
+ DPRINTF(30, "%s: Switch in progress to different vw.", __func__);
+ return (EBUSY);
+ }
+
+ /* Avoid switching to already selected window */
+ if (vw == curvw) {
+ DPRINTF(30, "%s: Cannot switch: vw == curvw.", __func__);
+ return (0); /* success */
+ }
+
/* Ask current process permission to switch away. */
if (curvw->vw_smode.mode == VT_PROCESS) {
DPRINTF(30, "%s: VT_PROCESS ", __func__);
@@ -664,8 +687,7 @@ vt_scrollmode_kbdevent(struct vt_window *vw, int c, int console)
if (console == 0) {
if (c >= F_SCR && c <= MIN(L_SCR, F_SCR + VT_MAXWINDOWS - 1)) {
vw = vd->vd_windows[c - F_SCR];
- if (vw != NULL)
- vt_proc_window_switch(vw);
+ vt_proc_window_switch(vw);
return;
}
VT_LOCK(vd);
@@ -750,8 +772,7 @@ vt_processkey(keyboard_t *kbd, struct vt_device *vd, int c)
if (c >= F_SCR && c <= MIN(L_SCR, F_SCR + VT_MAXWINDOWS - 1)) {
vw = vd->vd_windows[c - F_SCR];
- if (vw != NULL)
- vt_proc_window_switch(vw);
+ vt_proc_window_switch(vw);
return (0);
}
@@ -760,15 +781,13 @@ vt_processkey(keyboard_t *kbd, struct vt_device *vd, int c)
/* Switch to next VT. */
c = (vw->vw_number + 1) % VT_MAXWINDOWS;
vw = vd->vd_windows[c];
- if (vw != NULL)
- vt_proc_window_switch(vw);
+ vt_proc_window_switch(vw);
return (0);
case PREV:
/* Switch to previous VT. */
- c = (vw->vw_number - 1) % VT_MAXWINDOWS;
+ c = (vw->vw_number + VT_MAXWINDOWS - 1) % VT_MAXWINDOWS;
vw = vd->vd_windows[c];
- if (vw != NULL)
- vt_proc_window_switch(vw);
+ vt_proc_window_switch(vw);
return (0);
case SLK: {
vt_save_kbd_state(vw, kbd);
@@ -2774,8 +2793,7 @@ vt_resume(struct vt_device *vd)
if (vt_suspendswitch == 0)
return;
- /* Switch back to saved window */
- if (vd->vd_savedwindow != NULL)
- vt_proc_window_switch(vd->vd_savedwindow);
+ /* Switch back to saved window, if any */
+ vt_proc_window_switch(vd->vd_savedwindow);
vd->vd_savedwindow = NULL;
}
diff --git a/sys/dev/watchdog/watchdog.c b/sys/dev/watchdog/watchdog.c
index 5c9c6a1..9d87327 100644
--- a/sys/dev/watchdog/watchdog.c
+++ b/sys/dev/watchdog/watchdog.c
@@ -389,8 +389,8 @@ watchdog_modevent(module_t mod __unused, int type, void *data __unused)
{
switch(type) {
case MOD_LOAD:
- callout_init(&wd_pretimeo_handle, true);
- callout_init(&wd_softtimeo_handle, true);
+ callout_init(&wd_pretimeo_handle, 1);
+ callout_init(&wd_softtimeo_handle, 1);
wd_dev = make_dev(&wd_cdevsw, 0,
UID_ROOT, GID_WHEEL, 0600, _PATH_WATCHDOG);
return 0;
diff --git a/sys/dev/wpi/if_wpi.c b/sys/dev/wpi/if_wpi.c
index 9579c61..7b438c7 100644
--- a/sys/dev/wpi/if_wpi.c
+++ b/sys/dev/wpi/if_wpi.c
@@ -152,11 +152,14 @@ static int wpi_alloc_fwmem(struct wpi_softc *);
static void wpi_free_fwmem(struct wpi_softc *);
static int wpi_alloc_rx_ring(struct wpi_softc *);
static void wpi_update_rx_ring(struct wpi_softc *);
+static void wpi_update_rx_ring_ps(struct wpi_softc *);
static void wpi_reset_rx_ring(struct wpi_softc *);
static void wpi_free_rx_ring(struct wpi_softc *);
static int wpi_alloc_tx_ring(struct wpi_softc *, struct wpi_tx_ring *,
int);
static void wpi_update_tx_ring(struct wpi_softc *, struct wpi_tx_ring *);
+static void wpi_update_tx_ring_ps(struct wpi_softc *,
+ struct wpi_tx_ring *);
static void wpi_reset_tx_ring(struct wpi_softc *, struct wpi_tx_ring *);
static void wpi_free_tx_ring(struct wpi_softc *, struct wpi_tx_ring *);
static int wpi_read_eeprom(struct wpi_softc *,
@@ -171,9 +174,13 @@ static int wpi_setregdomain(struct ieee80211com *,
struct ieee80211_channel[]);
static int wpi_read_eeprom_group(struct wpi_softc *, int);
static int wpi_add_node_entry_adhoc(struct wpi_softc *);
-static void wpi_node_free(struct ieee80211_node *);
static struct ieee80211_node *wpi_node_alloc(struct ieee80211vap *,
const uint8_t mac[IEEE80211_ADDR_LEN]);
+static void wpi_node_free(struct ieee80211_node *);
+static void wpi_recv_mgmt(struct ieee80211_node *, struct mbuf *, int, int,
+ int);
+static void wpi_restore_node(void *, struct ieee80211_node *);
+static void wpi_restore_node_table(struct wpi_softc *, struct wpi_vap *);
static int wpi_newstate(struct ieee80211vap *, enum ieee80211_state, int);
static void wpi_calib_timeout(void *);
static void wpi_rx_done(struct wpi_softc *, struct wpi_rx_desc *,
@@ -228,6 +235,7 @@ static uint16_t wpi_get_active_dwell_time(struct wpi_softc *,
static uint16_t wpi_limit_dwell(struct wpi_softc *, uint16_t);
static uint16_t wpi_get_passive_dwell_time(struct wpi_softc *,
struct ieee80211_channel *);
+static uint32_t wpi_get_scan_pause_time(uint32_t, uint16_t);
static int wpi_scan(struct wpi_softc *, struct ieee80211_channel *);
static int wpi_auth(struct wpi_softc *, struct ieee80211vap *);
static int wpi_config_beacon(struct wpi_vap *);
@@ -516,11 +524,13 @@ wpi_attach(device_t dev)
ic->ic_scan_start = wpi_scan_start;
ic->ic_scan_end = wpi_scan_end;
ic->ic_set_channel = wpi_set_channel;
- sc->sc_scan_curchan = ic->ic_scan_curchan;
ic->ic_scan_curchan = wpi_scan_curchan;
ic->ic_scan_mindwell = wpi_scan_mindwell;
ic->ic_setregdomain = wpi_setregdomain;
+ sc->sc_update_rx_ring = wpi_update_rx_ring;
+ sc->sc_update_tx_ring = wpi_update_tx_ring;
+
wpi_radiotap_attach(sc);
callout_init_mtx(&sc->calib_to, &sc->rxon_mtx, 0);
@@ -609,7 +619,12 @@ wpi_init_beacon(struct wpi_vap *wvp)
cmd->ofdm_mask = 0xff;
cmd->cck_mask = 0x0f;
cmd->lifetime = htole32(WPI_LIFETIME_INFINITE);
- cmd->flags = htole32(WPI_TX_AUTO_SEQ | WPI_TX_INSERT_TSTAMP);
+
+ /*
+ * XXX WPI_TX_AUTO_SEQ seems to be ignored - workaround this issue
+ * XXX by using WPI_TX_NEED_ACK instead (with some side effects).
+ */
+ cmd->flags = htole32(WPI_TX_NEED_ACK | WPI_TX_INSERT_TSTAMP);
bcn->code = WPI_CMD_SET_BEACON;
bcn->ac = WPI_CMD_QUEUE_NUM;
@@ -643,6 +658,8 @@ wpi_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
/* Override with driver methods. */
vap->iv_key_set = wpi_key_set;
vap->iv_key_delete = wpi_key_delete;
+ wvp->wv_recv_mgmt = vap->iv_recv_mgmt;
+ vap->iv_recv_mgmt = wpi_recv_mgmt;
wvp->wv_newstate = vap->iv_newstate;
vap->iv_newstate = wpi_newstate;
vap->iv_update_beacon = wpi_update_beacon;
@@ -689,8 +706,6 @@ wpi_detach(device_t dev)
if (ifp != NULL) {
ic = ifp->if_l2com;
- ieee80211_draintask(ic, &sc->sc_reinittask);
- ieee80211_draintask(ic, &sc->sc_radiooff_task);
ieee80211_draintask(ic, &sc->sc_radioon_task);
ieee80211_draintask(ic, &sc->sc_start_task);
@@ -1086,6 +1101,12 @@ fail: wpi_free_rx_ring(sc);
static void
wpi_update_rx_ring(struct wpi_softc *sc)
{
+ WPI_WRITE(sc, WPI_FH_RX_WPTR, sc->rxq.cur & ~7);
+}
+
+static void
+wpi_update_rx_ring_ps(struct wpi_softc *sc)
+{
struct wpi_rx_ring *ring = &sc->rxq;
if (ring->update != 0) {
@@ -1093,14 +1114,15 @@ wpi_update_rx_ring(struct wpi_softc *sc)
return;
}
- if (WPI_READ(sc, WPI_UCODE_GP1) & WPI_UCODE_GP1_MAC_SLEEP) {
+ WPI_SETBITS(sc, WPI_GP_CNTRL, WPI_GP_CNTRL_MAC_ACCESS_REQ);
+ if (WPI_READ(sc, WPI_GP_CNTRL) & WPI_GP_CNTRL_SLEEP) {
DPRINTF(sc, WPI_DEBUG_PWRSAVE, "%s: wakeup request\n",
__func__);
-
- WPI_SETBITS(sc, WPI_GP_CNTRL, WPI_GP_CNTRL_MAC_ACCESS_REQ);
ring->update = 1;
- } else
- WPI_WRITE(sc, WPI_FH_RX_WPTR, ring->cur & ~7);
+ } else {
+ wpi_update_rx_ring(sc);
+ WPI_CLRBITS(sc, WPI_GP_CNTRL, WPI_GP_CNTRL_MAC_ACCESS_REQ);
+ }
}
static void
@@ -1244,19 +1266,27 @@ fail: wpi_free_tx_ring(sc, ring);
static void
wpi_update_tx_ring(struct wpi_softc *sc, struct wpi_tx_ring *ring)
{
+ WPI_WRITE(sc, WPI_HBUS_TARG_WRPTR, ring->qid << 8 | ring->cur);
+}
+
+static void
+wpi_update_tx_ring_ps(struct wpi_softc *sc, struct wpi_tx_ring *ring)
+{
+
if (ring->update != 0) {
/* Wait for INT_WAKEUP event. */
return;
}
- if (WPI_READ(sc, WPI_UCODE_GP1) & WPI_UCODE_GP1_MAC_SLEEP) {
+ WPI_SETBITS(sc, WPI_GP_CNTRL, WPI_GP_CNTRL_MAC_ACCESS_REQ);
+ if (WPI_READ(sc, WPI_GP_CNTRL) & WPI_GP_CNTRL_SLEEP) {
DPRINTF(sc, WPI_DEBUG_PWRSAVE, "%s (%d): requesting wakeup\n",
__func__, ring->qid);
-
- WPI_SETBITS(sc, WPI_GP_CNTRL, WPI_GP_CNTRL_MAC_ACCESS_REQ);
ring->update = 1;
- } else
- WPI_WRITE(sc, WPI_HBUS_TARG_WRPTR, ring->qid << 8 | ring->cur);
+ } else {
+ wpi_update_tx_ring(sc, ring);
+ WPI_CLRBITS(sc, WPI_GP_CNTRL, WPI_GP_CNTRL_MAC_ACCESS_REQ);
+ }
}
static void
@@ -1276,6 +1306,10 @@ wpi_reset_tx_ring(struct wpi_softc *sc, struct wpi_tx_ring *ring)
m_freem(data->m);
data->m = NULL;
}
+ if (data->ni != NULL) {
+ ieee80211_free_node(data->ni);
+ data->ni = NULL;
+ }
}
/* Clear TX descriptors. */
memset(ring->desc, 0, ring->desc_dma.size);
@@ -1651,6 +1685,72 @@ wpi_node_free(struct ieee80211_node *ni)
sc->sc_node_free(ni);
}
+static __inline int
+wpi_check_bss_filter(struct wpi_softc *sc)
+{
+ return (sc->rxon.filter & htole32(WPI_FILTER_BSS)) != 0;
+}
+
+static void
+wpi_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m, int subtype, int rssi,
+ int nf)
+{
+ struct ieee80211vap *vap = ni->ni_vap;
+ struct wpi_softc *sc = vap->iv_ic->ic_ifp->if_softc;
+ struct wpi_vap *wvp = WPI_VAP(vap);
+ uint64_t ni_tstamp, rx_tstamp;
+
+ wvp->wv_recv_mgmt(ni, m, subtype, rssi, nf);
+
+ if (vap->iv_opmode == IEEE80211_M_IBSS &&
+ vap->iv_state == IEEE80211_S_RUN &&
+ (subtype == IEEE80211_FC0_SUBTYPE_BEACON ||
+ subtype == IEEE80211_FC0_SUBTYPE_PROBE_RESP)) {
+ ni_tstamp = le64toh(ni->ni_tstamp.tsf);
+ rx_tstamp = le64toh(sc->rx_tstamp);
+
+ if (ni_tstamp >= rx_tstamp) {
+ DPRINTF(sc, WPI_DEBUG_STATE,
+ "ibss merge, tsf %ju tstamp %ju\n",
+ (uintmax_t)rx_tstamp, (uintmax_t)ni_tstamp);
+ (void) ieee80211_ibss_merge(ni);
+ }
+ }
+}
+
+static void
+wpi_restore_node(void *arg, struct ieee80211_node *ni)
+{
+ struct wpi_softc *sc = arg;
+ struct wpi_node *wn = WPI_NODE(ni);
+ int error;
+
+ WPI_NT_LOCK(sc);
+ if (wn->id != WPI_ID_UNDEFINED) {
+ wn->id = WPI_ID_UNDEFINED;
+ if ((error = wpi_add_ibss_node(sc, ni)) != 0) {
+ device_printf(sc->sc_dev,
+ "%s: could not add IBSS node, error %d\n",
+ __func__, error);
+ }
+ }
+ WPI_NT_UNLOCK(sc);
+}
+
+static void
+wpi_restore_node_table(struct wpi_softc *sc, struct wpi_vap *wvp)
+{
+ struct ieee80211com *ic = sc->sc_ifp->if_l2com;
+
+ /* Set group keys once. */
+ WPI_NT_LOCK(sc);
+ wvp->wv_gtk = 0;
+ WPI_NT_UNLOCK(sc);
+
+ ieee80211_iterate_nodes(&ic->ic_sta, wpi_restore_node, sc);
+ ieee80211_crypto_reload_keys(ic);
+}
+
/**
* Called by net80211 when ever there is a change to 80211 state machine
*/
@@ -1669,20 +1769,21 @@ wpi_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
ieee80211_state_name[vap->iv_state],
ieee80211_state_name[nstate]);
- if (vap->iv_state == IEEE80211_S_RUN && nstate != IEEE80211_S_RUN) {
+ if (vap->iv_state == IEEE80211_S_RUN && nstate < IEEE80211_S_RUN) {
if ((error = wpi_set_pslevel(sc, 0, 0, 1)) != 0) {
device_printf(sc->sc_dev,
"%s: could not set power saving level\n",
__func__);
return error;
}
+
+ wpi_set_led(sc, WPI_LED_LINK, 1, 0);
}
switch (nstate) {
case IEEE80211_S_SCAN:
WPI_RXON_LOCK(sc);
- if ((sc->rxon.filter & htole32(WPI_FILTER_BSS)) &&
- vap->iv_opmode != IEEE80211_M_STA) {
+ if (wpi_check_bss_filter(sc) != 0) {
sc->rxon.filter &= ~htole32(WPI_FILTER_BSS);
if ((error = wpi_send_rxon(sc, 0, 1)) != 0) {
device_printf(sc->sc_dev,
@@ -1698,6 +1799,11 @@ wpi_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
/* FALLTHROUGH */
case IEEE80211_S_AUTH:
/*
+ * NB: do not optimize AUTH -> AUTH state transmission -
+ * this will break powersave with non-QoS AP!
+ */
+
+ /*
* The node must be registered in the firmware before auth.
* Also the associd must be cleared on RUN -> ASSOC
* transitions.
@@ -1711,13 +1817,36 @@ wpi_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
case IEEE80211_S_RUN:
/*
- * RUN -> RUN transition; Just restart the timers.
+ * RUN -> RUN transition:
+ * STA mode: Just restart the timers.
+ * IBSS mode: Process IBSS merge.
*/
if (vap->iv_state == IEEE80211_S_RUN) {
- WPI_RXON_LOCK(sc);
- wpi_calib_timeout(sc);
- WPI_RXON_UNLOCK(sc);
- break;
+ if (vap->iv_opmode != IEEE80211_M_IBSS) {
+ WPI_RXON_LOCK(sc);
+ wpi_calib_timeout(sc);
+ WPI_RXON_UNLOCK(sc);
+ break;
+ } else {
+ /*
+ * Drop the BSS_FILTER bit
+ * (there is no another way to change bssid).
+ */
+ WPI_RXON_LOCK(sc);
+ sc->rxon.filter &= ~htole32(WPI_FILTER_BSS);
+ if ((error = wpi_send_rxon(sc, 0, 1)) != 0) {
+ device_printf(sc->sc_dev,
+ "%s: could not send RXON\n",
+ __func__);
+ }
+ WPI_RXON_UNLOCK(sc);
+
+ /* Restore all what was lost. */
+ wpi_restore_node_table(sc, wvp);
+
+ /* XXX set conditionally? */
+ wpi_updateedca(ic);
+ }
}
/*
@@ -1749,7 +1878,7 @@ wpi_calib_timeout(void *arg)
{
struct wpi_softc *sc = arg;
- if (!(sc->rxon.filter & htole32(WPI_FILTER_BSS)))
+ if (wpi_check_bss_filter(sc) == 0)
return;
wpi_power_calibration(sc);
@@ -1843,7 +1972,7 @@ wpi_rx_done(struct wpi_softc *sc, struct wpi_rx_desc *desc,
goto fail1;
}
/* Discard frames that are too short. */
- if (len < sizeof (*wh)) {
+ if (len < sizeof (struct ieee80211_frame_ack)) {
DPRINTF(sc, WPI_DEBUG_RECV, "%s: frame too short: %d\n",
__func__, len);
goto fail1;
@@ -1904,7 +2033,12 @@ wpi_rx_done(struct wpi_softc *sc, struct wpi_rx_desc *desc,
m->m_flags |= M_WEP;
}
- ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh);
+ if (len >= sizeof(struct ieee80211_frame_min))
+ ni = ieee80211_find_rxnode(ic, (struct ieee80211_frame_min *)wh);
+ else
+ ni = NULL;
+
+ sc->rx_tstamp = tail->tstamp;
if (ieee80211_radiotap_active(ic)) {
struct wpi_rx_radiotap_header *tap = &sc->sc_rxtap;
@@ -1957,7 +2091,7 @@ wpi_tx_done(struct wpi_softc *sc, struct wpi_rx_desc *desc)
struct ieee80211vap *vap;
struct ieee80211com *ic;
uint32_t status = le32toh(stat->status);
- int ackfailcnt = stat->ackfailcnt / 2; /* wpi_mrr_setup() */
+ int ackfailcnt = stat->ackfailcnt / WPI_NTRIES_DEFAULT;
KASSERT(data->ni != NULL, ("no node"));
KASSERT(data->m != NULL, ("no mbuf"));
@@ -1966,7 +2100,7 @@ wpi_tx_done(struct wpi_softc *sc, struct wpi_rx_desc *desc)
DPRINTF(sc, WPI_DEBUG_XMIT, "%s: "
"qid %d idx %d retries %d btkillcnt %d rate %x duration %d "
- "status %x\n", __func__, desc->qid, desc->idx, ackfailcnt,
+ "status %x\n", __func__, desc->qid, desc->idx, stat->ackfailcnt,
stat->btkillcnt, stat->rate, le32toh(stat->duration), status);
/* Unmap and free mbuf. */
@@ -1980,7 +2114,7 @@ wpi_tx_done(struct wpi_softc *sc, struct wpi_rx_desc *desc)
/*
* Update rate control statistics for the node.
*/
- if ((status & 0xff) != 1) {
+ if (status & WPI_TX_STATUS_FAIL) {
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
ieee80211_ratectl_tx_complete(vap, ni,
IEEE80211_RATECTL_TX_FAILURE, &ackfailcnt, NULL);
@@ -1990,7 +2124,7 @@ wpi_tx_done(struct wpi_softc *sc, struct wpi_rx_desc *desc)
IEEE80211_RATECTL_TX_SUCCESS, &ackfailcnt, NULL);
}
- ieee80211_tx_complete(ni, m, (status & 0xff) != 1);
+ ieee80211_tx_complete(ni, m, (status & WPI_TX_STATUS_FAIL) != 0);
WPI_TXQ_STATE_LOCK(sc);
ring->queued -= 1;
@@ -2048,6 +2182,18 @@ wpi_cmd_done(struct wpi_softc *sc, struct wpi_rx_desc *desc)
}
wakeup(&ring->cmd[desc->idx]);
+
+ if (desc->type == WPI_CMD_SET_POWER_MODE) {
+ WPI_TXQ_LOCK(sc);
+ if (sc->sc_flags & WPI_PS_PATH) {
+ sc->sc_update_rx_ring = wpi_update_rx_ring_ps;
+ sc->sc_update_tx_ring = wpi_update_tx_ring_ps;
+ } else {
+ sc->sc_update_rx_ring = wpi_update_rx_ring;
+ sc->sc_update_tx_ring = wpi_update_tx_ring;
+ }
+ WPI_TXQ_UNLOCK(sc);
+ }
}
static void
@@ -2061,7 +2207,7 @@ wpi_notif_intr(struct wpi_softc *sc)
bus_dmamap_sync(sc->shared_dma.tag, sc->shared_dma.map,
BUS_DMASYNC_POSTREAD);
- hw = le32toh(sc->shared->next);
+ hw = le32toh(sc->shared->next) & 0xfff;
hw = (hw == 0) ? WPI_RX_RING_COUNT - 1 : hw - 1;
while (sc->rxq.cur != hw) {
@@ -2110,23 +2256,57 @@ wpi_notif_intr(struct wpi_softc *sc)
{
struct wpi_beacon_missed *miss =
(struct wpi_beacon_missed *)(desc + 1);
- uint32_t misses;
+ uint32_t expected, misses, received, threshold;
bus_dmamap_sync(sc->rxq.data_dmat, data->map,
BUS_DMASYNC_POSTREAD);
+
misses = le32toh(miss->consecutive);
+ expected = le32toh(miss->expected);
+ received = le32toh(miss->received);
+ threshold = MAX(2, vap->iv_bmissthreshold);
+
+ DPRINTF(sc, WPI_DEBUG_BMISS,
+ "%s: beacons missed %u(%u) (received %u/%u)\n",
+ __func__, misses, le32toh(miss->total), received,
+ expected);
+
+ if (misses >= threshold ||
+ (received == 0 && expected >= threshold)) {
+ WPI_RXON_LOCK(sc);
+ if (callout_pending(&sc->scan_timeout)) {
+ wpi_cmd(sc, WPI_CMD_SCAN_ABORT, NULL,
+ 0, 1);
+ }
+ WPI_RXON_UNLOCK(sc);
+ if (vap->iv_state == IEEE80211_S_RUN &&
+ (ic->ic_flags & IEEE80211_F_SCAN) == 0)
+ ieee80211_beacon_miss(ic);
+ }
- DPRINTF(sc, WPI_DEBUG_STATE,
- "%s: beacons missed %d/%d\n", __func__, misses,
- le32toh(miss->total));
+ break;
+ }
+#ifdef WPI_DEBUG
+ case WPI_BEACON_SENT:
+ {
+ struct wpi_tx_stat *stat =
+ (struct wpi_tx_stat *)(desc + 1);
+ uint64_t *tsf = (uint64_t *)(stat + 1);
+ uint32_t *mode = (uint32_t *)(tsf + 1);
+
+ bus_dmamap_sync(sc->rxq.data_dmat, data->map,
+ BUS_DMASYNC_POSTREAD);
- if (vap->iv_state == IEEE80211_S_RUN &&
- (ic->ic_flags & IEEE80211_F_SCAN) == 0 &&
- misses >= vap->iv_bmissthreshold)
- ieee80211_beacon_miss(ic);
+ DPRINTF(sc, WPI_DEBUG_BEACON,
+ "beacon sent: rts %u, ack %u, btkill %u, rate %u, "
+ "duration %u, status %x, tsf %ju, mode %x\n",
+ stat->rtsfailcnt, stat->ackfailcnt,
+ stat->btkillcnt, stat->rate, le32toh(stat->duration),
+ le32toh(stat->status), *tsf, *mode);
break;
}
+#endif
case WPI_UC_READY:
{
struct wpi_ucode_info *uc =
@@ -2163,46 +2343,53 @@ wpi_notif_intr(struct wpi_softc *sc)
WPI_NT_LOCK(sc);
wpi_clear_node_table(sc);
WPI_NT_UNLOCK(sc);
- ieee80211_runtask(ic, &sc->sc_radiooff_task);
+ taskqueue_enqueue(sc->sc_tq,
+ &sc->sc_radiooff_task);
return;
}
break;
}
+#ifdef WPI_DEBUG
case WPI_START_SCAN:
{
bus_dmamap_sync(sc->rxq.data_dmat, data->map,
BUS_DMASYNC_POSTREAD);
-#ifdef WPI_DEBUG
+
struct wpi_start_scan *scan =
(struct wpi_start_scan *)(desc + 1);
DPRINTF(sc, WPI_DEBUG_SCAN,
"%s: scanning channel %d status %x\n",
__func__, scan->chan, le32toh(scan->status));
-#endif
+
break;
}
+#endif
case WPI_STOP_SCAN:
{
bus_dmamap_sync(sc->rxq.data_dmat, data->map,
BUS_DMASYNC_POSTREAD);
-#ifdef WPI_DEBUG
+
struct wpi_stop_scan *scan =
(struct wpi_stop_scan *)(desc + 1);
+
DPRINTF(sc, WPI_DEBUG_SCAN,
"scan finished nchan=%d status=%d chan=%d\n",
scan->nchan, scan->status, scan->chan);
-#endif
+
WPI_RXON_LOCK(sc);
callout_stop(&sc->scan_timeout);
WPI_RXON_UNLOCK(sc);
- ieee80211_scan_next(vap);
+ if (scan->status == WPI_SCAN_ABORTED)
+ ieee80211_cancel_scan(vap);
+ else
+ ieee80211_scan_next(vap);
break;
}
}
if (sc->rxq.cur % 8 == 0) {
/* Tell the firmware what we have processed. */
- wpi_update_rx_ring(sc);
+ sc->sc_update_rx_ring(sc);
}
}
}
@@ -2233,9 +2420,8 @@ wpi_wakeup_intr(struct wpi_softc *sc)
wpi_update_tx_ring(sc, ring);
}
}
- WPI_TXQ_UNLOCK(sc);
-
WPI_CLRBITS(sc, WPI_GP_CNTRL, WPI_GP_CNTRL_MAC_ACCESS_REQ);
+ WPI_TXQ_UNLOCK(sc);
}
/*
@@ -2245,8 +2431,7 @@ wpi_wakeup_intr(struct wpi_softc *sc)
static void
wpi_debug_registers(struct wpi_softc *sc)
{
-#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
- int i;
+ size_t i;
static const uint32_t csr_tbl[] = {
WPI_HW_IF_CONFIG,
WPI_INT,
@@ -2273,7 +2458,7 @@ wpi_debug_registers(struct wpi_softc *sc)
DPRINTF(sc, WPI_DEBUG_REGISTER,"%s","\n");
- for (i = 0; i < COUNTOF(csr_tbl); i++) {
+ for (i = 0; i < nitems(csr_tbl); i++) {
DPRINTF(sc, WPI_DEBUG_REGISTER, " %-18s: 0x%08x ",
wpi_get_csr_string(csr_tbl[i]), WPI_READ(sc, csr_tbl[i]));
@@ -2283,7 +2468,7 @@ wpi_debug_registers(struct wpi_softc *sc)
DPRINTF(sc, WPI_DEBUG_REGISTER, "\n\n");
if (wpi_nic_lock(sc) == 0) {
- for (i = 0; i < COUNTOF(prph_tbl); i++) {
+ for (i = 0; i < nitems(prph_tbl); i++) {
DPRINTF(sc, WPI_DEBUG_REGISTER, " %-18s: 0x%08x ",
wpi_get_prph_string(prph_tbl[i]),
wpi_prph_read(sc, prph_tbl[i]));
@@ -2297,7 +2482,6 @@ wpi_debug_registers(struct wpi_softc *sc)
DPRINTF(sc, WPI_DEBUG_REGISTER,
"Cannot access internal registers.\n");
}
-#undef COUNTOF
}
#endif
@@ -2311,8 +2495,6 @@ wpi_fatal_intr(struct wpi_softc *sc)
{
struct wpi_fw_dump dump;
uint32_t i, offset, count;
- const uint32_t size_errmsg =
- (sizeof (wpi_fw_errmsg) / sizeof ((wpi_fw_errmsg)[0]));
/* Check that the error log address is valid. */
if (sc->errptr < WPI_FW_DATA_BASE ||
@@ -2342,7 +2524,7 @@ wpi_fatal_intr(struct wpi_softc *sc)
sizeof (dump) / sizeof (uint32_t));
printf(" error type = \"%s\" (0x%08X)\n",
- (dump.desc < size_errmsg) ?
+ (dump.desc < nitems(wpi_fw_errmsg)) ?
wpi_fw_errmsg[dump.desc] : "UNKNOWN",
dump.desc);
printf(" error data = 0x%08X\n",
@@ -2539,7 +2721,7 @@ wpi_cmd2(struct wpi_softc *sc, struct wpi_buf *buf)
/* Kick TX ring. */
ring->cur = (ring->cur + 1) % WPI_TX_RING_COUNT;
- wpi_update_tx_ring(sc, ring);
+ sc->sc_update_tx_ring(sc, ring);
if (ring->qid < WPI_CMD_QUEUE_NUM) {
/* Mark TX ring as full if we reach a certain threshold. */
@@ -2597,7 +2779,7 @@ wpi_tx_data(struct wpi_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
/* Select EDCA Access Category and TX ring for this frame. */
if (IEEE80211_QOS_HAS_SEQ(wh)) {
- qos = ((const struct ieee80211_qosframe *)wh)->i_qos[0];
+ qos = ((const struct ieee80211_qosframe *)wh)->i_qos[0];
tid = qos & IEEE80211_QOS_TID;
} else {
qos = 0;
@@ -2658,6 +2840,8 @@ wpi_tx_data(struct wpi_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
flags |= WPI_TX_NEED_ACK;
}
+ if (!IEEE80211_QOS_HAS_SEQ(wh))
+ flags |= WPI_TX_AUTO_SEQ;
if (wh->i_fc[1] & IEEE80211_FC1_MORE_FRAG)
flags |= WPI_TX_MORE_FRAG; /* Cannot happen yet. */
@@ -2705,9 +2889,6 @@ wpi_tx_data(struct wpi_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
tx->id = wn->id;
}
- if (type != IEEE80211_FC0_TYPE_MGT)
- tx->data_ntries = tp->maxretry;
-
if (k != NULL && !swcrypt) {
switch (k->wk_cipher->ic_cipher) {
case IEEE80211_CIPHER_AES_CCM:
@@ -2729,6 +2910,7 @@ wpi_tx_data(struct wpi_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
tx->ofdm_mask = 0xff;
tx->cck_mask = 0x0f;
tx->rts_ntries = 7;
+ tx->data_ntries = tp->maxretry;
tx_data.ni = ni;
tx_data.m = m;
@@ -2764,6 +2946,8 @@ wpi_tx_data_raw(struct wpi_softc *sc, struct mbuf *m,
rate = params->ibp_rate0;
flags = 0;
+ if (!IEEE80211_QOS_HAS_SEQ(wh))
+ flags |= WPI_TX_AUTO_SEQ;
if ((params->ibp_flags & IEEE80211_BPF_NOACK) == 0)
flags |= WPI_TX_NEED_ACK;
if (params->ibp_flags & IEEE80211_BPF_RTS)
@@ -3089,7 +3273,7 @@ wpi_cmd(struct wpi_softc *sc, int code, const void *buf, size_t size,
/* Kick command ring. */
ring->cur = (ring->cur + 1) % WPI_TX_RING_COUNT;
- wpi_update_tx_ring(sc, ring);
+ sc->sc_update_tx_ring(sc, ring);
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END, __func__);
@@ -3125,8 +3309,8 @@ wpi_mrr_setup(struct wpi_softc *sc)
/* Fallback to the immediate lower CCK rate (if any.) */
mrr.rates[i].next =
(i == WPI_RIDX_CCK1) ? WPI_RIDX_CCK1 : i - 1;
- /* Try one time at this rate before falling back to "next". */
- mrr.rates[i].ntries = 1;
+ /* Try twice at this rate before falling back to "next". */
+ mrr.rates[i].ntries = WPI_NTRIES_DEFAULT;
}
/* OFDM rates (not used with 802.11b). */
for (i = WPI_RIDX_OFDM6; i <= WPI_RIDX_OFDM54; i++) {
@@ -3138,8 +3322,8 @@ wpi_mrr_setup(struct wpi_softc *sc)
((ic->ic_curmode == IEEE80211_MODE_11A) ?
WPI_RIDX_OFDM6 : WPI_RIDX_CCK2) :
i - 1;
- /* Try one time at this rate before falling back to "next". */
- mrr.rates[i].ntries = 1;
+ /* Try twice at this rate before falling back to "next". */
+ mrr.rates[i].ntries = WPI_NTRIES_DEFAULT;
}
/* Setup MRR for control frames. */
mrr.which = htole32(WPI_MRR_CTL);
@@ -3590,8 +3774,13 @@ wpi_set_pslevel(struct wpi_softc *sc, uint8_t dtim, int level, int async)
pmgt = &wpi_pmgt[1][level];
memset(&cmd, 0, sizeof cmd);
- if (level != 0) /* not CAM */
+ WPI_TXQ_LOCK(sc);
+ if (level != 0) { /* not CAM */
cmd.flags |= htole16(WPI_PS_ALLOW_SLEEP);
+ sc->sc_flags |= WPI_PS_PATH;
+ } else
+ sc->sc_flags &= ~WPI_PS_PATH;
+ WPI_TXQ_UNLOCK(sc);
/* Retrieve PCIe Active State Power Management (ASPM). */
reg = pci_read_config(sc->sc_dev, sc->sc_cap_off + 0x10, 1);
if (!(reg & 0x1)) /* L0s Entry disabled. */
@@ -3644,7 +3833,7 @@ wpi_send_rxon(struct wpi_softc *sc, int assoc, int async)
if (async)
WPI_RXON_LOCK_ASSERT(sc);
- if (assoc && (sc->rxon.filter & htole32(WPI_FILTER_BSS))) {
+ if (assoc && wpi_check_bss_filter(sc) != 0) {
struct wpi_assoc rxon_assoc;
rxon_assoc.flags = sc->rxon.flags;
@@ -3710,7 +3899,7 @@ wpi_config(struct wpi_softc *sc)
struct ifnet *ifp = sc->sc_ifp;
struct ieee80211com *ic = ifp->if_l2com;
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
- uint32_t flags;
+ struct ieee80211_channel *c = ic->ic_curchan;
int error;
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__);
@@ -3734,9 +3923,9 @@ wpi_config(struct wpi_softc *sc)
IEEE80211_ADDR_COPY(sc->rxon.myaddr, vap->iv_myaddr);
/* Set default channel. */
- sc->rxon.chan = ieee80211_chan2ieee(ic, ic->ic_curchan);
+ sc->rxon.chan = ieee80211_chan2ieee(ic, c);
sc->rxon.flags = htole32(WPI_RXON_TSF | WPI_RXON_CTS_TO_SELF);
- if (IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan))
+ if (IEEE80211_IS_CHAN_2GHZ(c))
sc->rxon.flags |= htole32(WPI_RXON_AUTO | WPI_RXON_24GHZ);
sc->rxon.filter = WPI_FILTER_MULTICAST;
@@ -3754,7 +3943,6 @@ wpi_config(struct wpi_softc *sc)
sc->rxon.filter |= WPI_FILTER_ASSOC | WPI_FILTER_PROMISC;
break;
case IEEE80211_M_AHDEMO:
- /* XXX workaround for passive channels selection */
sc->rxon.mode = WPI_MODE_HOSTAP;
break;
case IEEE80211_M_MONITOR:
@@ -3770,6 +3958,14 @@ wpi_config(struct wpi_softc *sc)
sc->rxon.cck_mask = 0x0f; /* not yet negotiated */
sc->rxon.ofdm_mask = 0xff; /* not yet negotiated */
+ /* XXX Current configuration may be unusable. */
+ if (IEEE80211_IS_CHAN_NOADHOC(c) && sc->rxon.mode == WPI_MODE_IBSS) {
+ device_printf(sc->sc_dev,
+ "%s: invalid channel (%d) selected for IBSS mode\n",
+ __func__, ieee80211_chan2ieee(ic, c));
+ return EINVAL;
+ }
+
if ((error = wpi_send_rxon(sc, 0, 0)) != 0) {
device_printf(sc->sc_dev, "%s: could not send RXON\n",
__func__);
@@ -3783,15 +3979,6 @@ wpi_config(struct wpi_softc *sc)
return error;
}
- /* Disable beacon notifications (unused). */
- flags = WPI_STATISTICS_BEACON_DISABLE;
- error = wpi_cmd(sc, WPI_CMD_GET_STATISTICS, &flags, sizeof flags, 1);
- if (error != 0) {
- device_printf(sc->sc_dev,
- "could not disable beacon statistics, error %d\n", error);
- return error;
- }
-
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END, __func__);
return 0;
@@ -3813,7 +4000,7 @@ wpi_get_active_dwell_time(struct wpi_softc *sc,
}
/*
- * Limit the total dwell time to 85% of the beacon interval.
+ * Limit the total dwell time.
*
* Returns the dwell time in milliseconds.
*/
@@ -3838,11 +4025,11 @@ wpi_limit_dwell(struct wpi_softc *sc, uint16_t dwell_time)
if (bintval > 0) {
DPRINTF(sc, WPI_DEBUG_SCAN, "%s: bintval=%d\n", __func__,
bintval);
- return (MIN(WPI_PASSIVE_DWELL_BASE, ((bintval * 85) / 100)));
+ return (MIN(dwell_time, bintval - WPI_CHANNEL_TUNE_TIME * 2));
}
/* No association context? Default. */
- return (WPI_PASSIVE_DWELL_BASE);
+ return dwell_time;
}
static uint16_t
@@ -3859,6 +4046,18 @@ wpi_get_passive_dwell_time(struct wpi_softc *sc, struct ieee80211_channel *c)
return (wpi_limit_dwell(sc, passive));
}
+static uint32_t
+wpi_get_scan_pause_time(uint32_t time, uint16_t bintval)
+{
+ uint32_t mod = (time % bintval) * IEEE80211_DUR_TU;
+ uint32_t nbeacons = time / bintval;
+
+ if (mod > WPI_PAUSE_MAX_TIME)
+ mod = WPI_PAUSE_MAX_TIME;
+
+ return WPI_PAUSE_SCAN(nbeacons, mod);
+}
+
/*
* Send a scan request to the firmware.
*/
@@ -3877,7 +4076,7 @@ wpi_scan(struct wpi_softc *sc, struct ieee80211_channel *c)
struct ieee80211_rateset *rs;
uint16_t dwell_active, dwell_passive;
uint8_t *buf, *frm;
- int buflen, error, i, nssid;
+ int bgscan, bintval, buflen, error, i, nssid;
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__);
@@ -3888,10 +4087,16 @@ wpi_scan(struct wpi_softc *sc, struct ieee80211_channel *c)
if (callout_pending(&sc->scan_timeout)) {
device_printf(sc->sc_dev, "%s: called whilst scanning!\n",
__func__);
+ error = EAGAIN;
+ goto fail;
+ }
- DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_END_ERR, __func__);
-
- return (EAGAIN);
+ bgscan = wpi_check_bss_filter(sc);
+ bintval = vap->iv_bss->ni_intval;
+ if (bgscan != 0 &&
+ bintval < WPI_QUIET_TIME_DEFAULT + WPI_CHANNEL_TUNE_TIME * 2) {
+ error = EOPNOTSUPP;
+ goto fail;
}
buf = malloc(WPI_SCAN_MAXSZ, M_DEVBUF, M_NOWAIT | M_ZERO);
@@ -3908,15 +4113,19 @@ wpi_scan(struct wpi_softc *sc, struct ieee80211_channel *c)
* Move to the next channel if no packets are received within 10 msecs
* after sending the probe request.
*/
- hdr->quiet_time = htole16(10); /* timeout in milliseconds */
- hdr->quiet_threshold = htole16(1); /* min # of packets */
- /*
- * Max needs to be greater than active and passive and quiet!
- * It's also in microseconds!
- */
- hdr->max_svc = htole32(250 * IEEE80211_DUR_TU);
- hdr->pause_svc = htole32((4 << 24) |
- (100 * IEEE80211_DUR_TU)); /* Hardcode for now */
+ hdr->quiet_time = htole16(WPI_QUIET_TIME_DEFAULT);
+ hdr->quiet_threshold = htole16(1);
+
+ if (bgscan != 0) {
+ /*
+ * Max needs to be greater than active and passive and quiet!
+ * It's also in microseconds!
+ */
+ hdr->max_svc = htole32(250 * IEEE80211_DUR_TU);
+ hdr->pause_svc = htole32(wpi_get_scan_pause_time(100,
+ bintval));
+ }
+
hdr->filter = htole32(WPI_FILTER_MULTICAST | WPI_FILTER_BEACON);
tx = (struct wpi_cmd_data *)(hdr + 1);
@@ -3998,8 +4207,8 @@ wpi_scan(struct wpi_softc *sc, struct ieee80211_channel *c)
dwell_passive = wpi_get_passive_dwell_time(sc, c);
/* Make sure they're valid. */
- if (dwell_passive <= dwell_active)
- dwell_passive = dwell_active + 1;
+ if (dwell_active > dwell_passive)
+ dwell_active = dwell_passive;
chan->active = htole16(dwell_active);
chan->passive = htole16(dwell_passive);
@@ -4015,6 +4224,20 @@ wpi_scan(struct wpi_softc *sc, struct ieee80211_channel *c)
chan->chan, IEEE80211_IS_CHAN_PASSIVE(c));
hdr->nchan++;
+
+ if (hdr->nchan == 1 && sc->rxon.chan == chan->chan) {
+ /* XXX Force probe request transmission. */
+ memcpy(chan + 1, chan, sizeof (struct wpi_scan_chan));
+
+ chan++;
+
+ /* Reduce unnecessary delay. */
+ chan->flags = 0;
+ chan->passive = chan->active = hdr->quiet_time;
+
+ hdr->nchan++;
+ }
+
chan++;
buflen = (uint8_t *)chan - buf;
@@ -4044,6 +4267,7 @@ wpi_auth(struct wpi_softc *sc, struct ieee80211vap *vap)
{
struct ieee80211com *ic = vap->iv_ic;
struct ieee80211_node *ni = vap->iv_bss;
+ struct ieee80211_channel *c = ni->ni_chan;
int error;
WPI_RXON_LOCK(sc);
@@ -4054,18 +4278,18 @@ wpi_auth(struct wpi_softc *sc, struct ieee80211vap *vap)
sc->rxon.associd = 0;
sc->rxon.filter &= ~htole32(WPI_FILTER_BSS);
IEEE80211_ADDR_COPY(sc->rxon.bssid, ni->ni_bssid);
- sc->rxon.chan = ieee80211_chan2ieee(ic, ni->ni_chan);
+ sc->rxon.chan = ieee80211_chan2ieee(ic, c);
sc->rxon.flags = htole32(WPI_RXON_TSF | WPI_RXON_CTS_TO_SELF);
- if (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan))
+ if (IEEE80211_IS_CHAN_2GHZ(c))
sc->rxon.flags |= htole32(WPI_RXON_AUTO | WPI_RXON_24GHZ);
if (ic->ic_flags & IEEE80211_F_SHSLOT)
sc->rxon.flags |= htole32(WPI_RXON_SHSLOT);
if (ic->ic_flags & IEEE80211_F_SHPREAMBLE)
sc->rxon.flags |= htole32(WPI_RXON_SHPREAMBLE);
- if (IEEE80211_IS_CHAN_A(ni->ni_chan)) {
+ if (IEEE80211_IS_CHAN_A(c)) {
sc->rxon.cck_mask = 0;
sc->rxon.ofdm_mask = 0x15;
- } else if (IEEE80211_IS_CHAN_B(ni->ni_chan)) {
+ } else if (IEEE80211_IS_CHAN_B(c)) {
sc->rxon.cck_mask = 0x03;
sc->rxon.ofdm_mask = 0;
} else {
@@ -4243,6 +4467,7 @@ wpi_run(struct wpi_softc *sc, struct ieee80211vap *vap)
{
struct ieee80211com *ic = vap->iv_ic;
struct ieee80211_node *ni = vap->iv_bss;
+ struct ieee80211_channel *c = ni->ni_chan;
int error;
DPRINTF(sc, WPI_DEBUG_TRACE, TRACE_STR_BEGIN, __func__);
@@ -4254,7 +4479,7 @@ wpi_run(struct wpi_softc *sc, struct ieee80211vap *vap)
}
/* XXX kernel panic workaround */
- if (ni->ni_chan == IEEE80211_CHAN_ANYC) {
+ if (c == IEEE80211_CHAN_ANYC) {
device_printf(sc->sc_dev, "%s: incomplete configuration\n",
__func__);
return EINVAL;
@@ -4270,20 +4495,18 @@ wpi_run(struct wpi_softc *sc, struct ieee80211vap *vap)
WPI_RXON_LOCK(sc);
IEEE80211_ADDR_COPY(sc->rxon.bssid, ni->ni_bssid);
sc->rxon.associd = htole16(IEEE80211_NODE_AID(ni));
- sc->rxon.chan = ieee80211_chan2ieee(ic, ni->ni_chan);
+ sc->rxon.chan = ieee80211_chan2ieee(ic, c);
sc->rxon.flags = htole32(WPI_RXON_TSF | WPI_RXON_CTS_TO_SELF);
- if (IEEE80211_IS_CHAN_2GHZ(ni->ni_chan))
+ if (IEEE80211_IS_CHAN_2GHZ(c))
sc->rxon.flags |= htole32(WPI_RXON_AUTO | WPI_RXON_24GHZ);
- /* Short preamble and slot time are negotiated when associating. */
- sc->rxon.flags &= ~htole32(WPI_RXON_SHPREAMBLE | WPI_RXON_SHSLOT);
if (ic->ic_flags & IEEE80211_F_SHSLOT)
sc->rxon.flags |= htole32(WPI_RXON_SHSLOT);
if (ic->ic_flags & IEEE80211_F_SHPREAMBLE)
sc->rxon.flags |= htole32(WPI_RXON_SHPREAMBLE);
- if (IEEE80211_IS_CHAN_A(ni->ni_chan)) {
+ if (IEEE80211_IS_CHAN_A(c)) {
sc->rxon.cck_mask = 0;
sc->rxon.ofdm_mask = 0x15;
- } else if (IEEE80211_IS_CHAN_B(ni->ni_chan)) {
+ } else if (IEEE80211_IS_CHAN_B(c)) {
sc->rxon.cck_mask = 0x03;
sc->rxon.ofdm_mask = 0;
} else {
@@ -4619,7 +4842,7 @@ wpi_post_alive(struct wpi_softc *sc)
/* NB: Runtime firmware must be up and running. */
if (!(wpi_prph_read(sc, WPI_APMG_RFKILL) & 1)) {
- device_printf(sc->sc_dev,
+ device_printf(sc->sc_dev,
"RF switch: radio disabled (%s)\n", __func__);
wpi_nic_unlock(sc);
return EPERM; /* :-) */
@@ -4943,7 +5166,7 @@ wpi_apm_stop_master(struct wpi_softc *sc)
/* Stop busmaster DMA activity. */
WPI_SETBITS(sc, WPI_RESET, WPI_RESET_STOP_MASTER);
-
+
if ((WPI_READ(sc, WPI_GP_CNTRL) & WPI_GP_CNTRL_PS_MASK) ==
WPI_GP_CNTRL_MAC_PS)
return; /* Already asleep. */
@@ -5395,16 +5618,10 @@ wpi_scan_curchan(struct ieee80211_scan_state *ss, unsigned long maxdwell)
int error;
WPI_RXON_LOCK(sc);
- if (sc->rxon.chan != ieee80211_chan2ieee(ic, ic->ic_curchan)) {
- error = wpi_scan(sc, ic->ic_curchan);
- WPI_RXON_UNLOCK(sc);
- if (error != 0)
- ieee80211_cancel_scan(vap);
- } else {
- WPI_RXON_UNLOCK(sc);
- /* Send probe request when associated. */
- sc->sc_scan_curchan(ss, maxdwell);
- }
+ error = wpi_scan(sc, ic->ic_curchan);
+ WPI_RXON_UNLOCK(sc);
+ if (error != 0)
+ ieee80211_cancel_scan(vap);
}
/**
diff --git a/sys/dev/wpi/if_wpi_debug.h b/sys/dev/wpi/if_wpi_debug.h
index 245bf59..6b78ace 100644
--- a/sys/dev/wpi/if_wpi_debug.h
+++ b/sys/dev/wpi/if_wpi_debug.h
@@ -43,6 +43,7 @@ enum {
WPI_DEBUG_KEY = 0x00020000, /* node key management */
WPI_DEBUG_EDCA = 0x00040000, /* WME info */
WPI_DEBUG_REGISTER = 0x00080000, /* print chipset register */
+ WPI_DEBUG_BMISS = 0x00100000, /* print number of missed beacons */
WPI_DEBUG_ANY = 0xffffffff
};
@@ -85,12 +86,12 @@ static const char *wpi_cmd_str(int cmd)
WPI_DESC(WPI_CMD_SET_LED);
WPI_DESC(WPI_CMD_SET_POWER_MODE);
WPI_DESC(WPI_CMD_SCAN);
+ WPI_DESC(WPI_CMD_SCAN_ABORT);
WPI_DESC(WPI_CMD_SET_BEACON);
WPI_DESC(WPI_CMD_TXPOWER);
WPI_DESC(WPI_CMD_BT_COEX);
default:
- KASSERT(1, ("Unknown Command: %d\n", cmd));
return "UNKNOWN CMD";
}
}
@@ -98,7 +99,7 @@ static const char *wpi_cmd_str(int cmd)
/*
* Translate CSR code to string
*/
-static const char *wpi_get_csr_string(int csr)
+static const char *wpi_get_csr_string(size_t csr)
{
switch (csr) {
WPI_DESC(WPI_HW_IF_CONFIG);
@@ -117,12 +118,12 @@ static const char *wpi_get_csr_string(int csr)
WPI_DESC(WPI_ANA_PLL);
WPI_DESC(WPI_DBG_HPET_MEM);
default:
- KASSERT(1, ("Unknown CSR: %d\n", csr));
+ KASSERT(0, ("Unknown CSR: %d\n", csr));
return "UNKNOWN CSR";
}
}
-static const char *wpi_get_prph_string(int prph)
+static const char *wpi_get_prph_string(size_t prph)
{
switch (prph) {
WPI_DESC(WPI_APMG_CLK_CTRL);
@@ -130,7 +131,7 @@ static const char *wpi_get_prph_string(int prph)
WPI_DESC(WPI_APMG_PCI_STT);
WPI_DESC(WPI_APMG_RFKILL);
default:
- KASSERT(1, ("Unknown register: %d\n", prph));
+ KASSERT(0, ("Unknown register: %d\n", prph));
return "UNKNOWN PRPH";
}
}
diff --git a/sys/dev/wpi/if_wpireg.h b/sys/dev/wpi/if_wpireg.h
index 7e60049..b0aa35c 100644
--- a/sys/dev/wpi/if_wpireg.h
+++ b/sys/dev/wpi/if_wpireg.h
@@ -256,6 +256,26 @@ struct wpi_tx_stat {
uint8_t rate;
uint32_t duration;
uint32_t status;
+#define WPI_TX_STATUS_SUCCESS 0x01
+#define WPI_TX_STATUS_DIRECT_DONE 0x02
+#define WPI_TX_STATUS_FAIL 0x80
+#define WPI_TX_STATUS_FAIL_SHORT_LIMIT 0x82
+#define WPI_TX_STATUS_FAIL_LONG_LIMIT 0x83
+#define WPI_TX_STATUS_FAIL_FIFO_UNDERRUN 0x84
+#define WPI_TX_STATUS_FAIL_MGMNT_ABORT 0x85
+#define WPI_TX_STATUS_FAIL_NEXT_FRAG 0x86
+#define WPI_TX_STATUS_FAIL_LIFE_EXPIRE 0x87
+#define WPI_TX_STATUS_FAIL_NODE_PS 0x88
+#define WPI_TX_STATUS_FAIL_ABORTED 0x89
+#define WPI_TX_STATUS_FAIL_BT_RETRY 0x8a
+#define WPI_TX_STATUS_FAIL_NODE_INVALID 0x8b
+#define WPI_TX_STATUS_FAIL_FRAG_DROPPED 0x8c
+#define WPI_TX_STATUS_FAIL_TID_DISABLE 0x8d
+#define WPI_TX_STATUS_FAIL_FRAME_FLUSHED 0x8e
+#define WPI_TX_STATUS_FAIL_INSUFFICIENT_CF_POLL 0x8f
+#define WPI_TX_STATUS_FAIL_TX_LOCKED 0x90
+#define WPI_TX_STATUS_FAIL_NO_BEACON_ON_RADAR 0x91
+
} __packed;
struct wpi_rx_desc {
@@ -332,6 +352,7 @@ struct wpi_tx_cmd {
#define WPI_CMD_SET_LED 72
#define WPI_CMD_SET_POWER_MODE 119
#define WPI_CMD_SCAN 128
+#define WPI_CMD_SCAN_ABORT 129
#define WPI_CMD_SET_BEACON 145
#define WPI_CMD_TXPOWER 151
#define WPI_CMD_BT_COEX 155
@@ -547,6 +568,8 @@ struct wpi_mrr_setup {
uint8_t plcp;
uint8_t flags;
uint8_t ntries;
+#define WPI_NTRIES_DEFAULT 2
+
uint8_t next;
} __packed rates[WPI_RIDX_MAX + 1];
} __packed;
@@ -589,12 +612,17 @@ struct wpi_scan_hdr {
uint16_t len;
uint8_t reserved1;
uint8_t nchan;
- uint16_t quiet_time;
- uint16_t quiet_threshold;
+ uint16_t quiet_time; /* timeout in milliseconds */
+#define WPI_QUIET_TIME_DEFAULT 10
+
+ uint16_t quiet_threshold; /* min # of packets */
uint16_t crc_threshold;
uint16_t reserved2;
uint32_t max_svc; /* background scans */
uint32_t pause_svc; /* background scans */
+#define WPI_PAUSE_MAX_TIME ((1 << 20) - 1)
+#define WPI_PAUSE_SCAN(nbeacons, time) ((nbeacons << 24) | time)
+
uint32_t flags;
uint32_t filter;
@@ -630,6 +658,7 @@ struct wpi_scan_chan {
#define WPI_PASSIVE_DWELL_TIME_2GHZ ( 20)
#define WPI_PASSIVE_DWELL_TIME_5GHZ ( 10)
#define WPI_PASSIVE_DWELL_BASE (100)
+#define WPI_CHANNEL_TUNE_TIME ( 6)
/* Structure for command WPI_CMD_TXPOWER. */
struct wpi_cmd_txpower {
@@ -697,6 +726,9 @@ struct wpi_start_scan {
struct wpi_stop_scan {
uint8_t nchan;
uint8_t status;
+#define WPI_SCAN_COMPLETED 1
+#define WPI_SCAN_ABORTED 2
+
uint8_t reserved;
uint8_t chan;
uint64_t tsf;
diff --git a/sys/dev/wpi/if_wpivar.h b/sys/dev/wpi/if_wpivar.h
index 7c74825..7a65b72 100644
--- a/sys/dev/wpi/if_wpivar.h
+++ b/sys/dev/wpi/if_wpivar.h
@@ -121,17 +121,19 @@ struct wpi_buf {
};
struct wpi_vap {
- struct ieee80211vap wv_vap;
+ struct ieee80211vap wv_vap;
- struct wpi_buf wv_bcbuf;
- struct ieee80211_beacon_offsets wv_boff;
- struct mtx wv_mtx;
+ struct wpi_buf wv_bcbuf;
+ struct ieee80211_beacon_offsets wv_boff;
+ struct mtx wv_mtx;
- uint32_t wv_gtk;
-#define WPI_VAP_KEY(kid) (1 << kid)
+ uint32_t wv_gtk;
+#define WPI_VAP_KEY(kid) (1 << kid)
- int (*wv_newstate)(struct ieee80211vap *,
- enum ieee80211_state, int);
+ int (*wv_newstate)(struct ieee80211vap *,
+ enum ieee80211_state, int);
+ void (*wv_recv_mgmt)(struct ieee80211_node *,
+ struct mbuf *, int, int, int);
};
#define WPI_VAP(vap) ((struct wpi_vap *)(vap))
@@ -164,6 +166,9 @@ struct wpi_softc {
struct ifnet *sc_ifp;
int sc_debug;
+ int sc_flags;
+#define WPI_PS_PATH (1 << 0)
+
struct mtx sc_mtx;
struct mtx tx_mtx;
@@ -177,6 +182,7 @@ struct wpi_softc {
uint32_t txq_active;
struct wpi_rx_ring rxq;
+ uint64_t rx_tstamp;
/* TX Thermal Callibration. */
struct callout calib_to;
@@ -210,8 +216,9 @@ struct wpi_softc {
struct mtx nt_mtx;
void (*sc_node_free)(struct ieee80211_node *);
- void (*sc_scan_curchan)(struct ieee80211_scan_state *,
- unsigned long);
+ void (*sc_update_rx_ring)(struct wpi_softc *);
+ void (*sc_update_tx_ring)(struct wpi_softc *,
+ struct wpi_tx_ring *);
struct wpi_rx_radiotap_header sc_rxtap;
struct wpi_tx_radiotap_header sc_txtap;
diff --git a/sys/dev/xen/balloon/balloon.c b/sys/dev/xen/balloon/balloon.c
index e113e2c..a6036d8 100644
--- a/sys/dev/xen/balloon/balloon.c
+++ b/sys/dev/xen/balloon/balloon.c
@@ -118,11 +118,6 @@ current_target(void)
static unsigned long
minimum_target(void)
{
-#ifdef XENHVM
-#define max_pfn realmem
-#else
-#define max_pfn HYPERVISOR_shared_info->arch.max_pfn
-#endif
unsigned long min_pages, curr_pages = current_target();
#define MB2PAGES(mb) ((mb) << (20 - PAGE_SHIFT))
@@ -139,16 +134,15 @@ minimum_target(void)
* 32768 1320
* 131072 4392
*/
- if (max_pfn < MB2PAGES(128))
- min_pages = MB2PAGES(8) + (max_pfn >> 1);
- else if (max_pfn < MB2PAGES(512))
- min_pages = MB2PAGES(40) + (max_pfn >> 2);
- else if (max_pfn < MB2PAGES(2048))
- min_pages = MB2PAGES(104) + (max_pfn >> 3);
+ if (realmem < MB2PAGES(128))
+ min_pages = MB2PAGES(8) + (realmem >> 1);
+ else if (realmem < MB2PAGES(512))
+ min_pages = MB2PAGES(40) + (realmem >> 2);
+ else if (realmem < MB2PAGES(2048))
+ min_pages = MB2PAGES(104) + (realmem >> 3);
else
- min_pages = MB2PAGES(296) + (max_pfn >> 5);
+ min_pages = MB2PAGES(296) + (realmem >> 5);
#undef MB2PAGES
-#undef max_pfn
/* Don't enforce growth */
return (min(min_pages, curr_pages));
@@ -204,12 +198,9 @@ increase_reservation(unsigned long nr_pages)
bs.balloon_low--;
pfn = (VM_PAGE_TO_PHYS(page) >> PAGE_SHIFT);
- KASSERT((xen_feature(XENFEAT_auto_translated_physmap) ||
- !phys_to_machine_mapping_valid(pfn)),
+ KASSERT(xen_feature(XENFEAT_auto_translated_physmap),
("auto translated physmap but mapping is valid"));
- set_phys_to_machine(pfn, frame_list[i]);
-
vm_page_free(page);
}
@@ -258,9 +249,8 @@ decrease_reservation(unsigned long nr_pages)
}
pfn = (VM_PAGE_TO_PHYS(page) >> PAGE_SHIFT);
- frame_list[i] = PFNTOMFN(pfn);
+ frame_list[i] = pfn;
- set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
TAILQ_INSERT_HEAD(&ballooned_pages, page, plinks.q);
bs.balloon_low++;
}
@@ -393,21 +383,11 @@ static int
xenballoon_attach(device_t dev)
{
int err;
-#ifndef XENHVM
- vm_page_t page;
- unsigned long pfn;
-
-#define max_pfn HYPERVISOR_shared_info->arch.max_pfn
-#endif
mtx_init(&balloon_mutex, "balloon_mutex", NULL, MTX_DEF);
-#ifndef XENHVM
- bs.current_pages = min(xen_start_info->nr_pages, max_pfn);
-#else
bs.current_pages = xen_pv_domain() ?
HYPERVISOR_start_info->nr_pages : realmem;
-#endif
bs.target_pages = bs.current_pages;
bs.balloon_low = 0;
bs.balloon_high = 0;
@@ -416,16 +396,6 @@ xenballoon_attach(device_t dev)
kproc_create(balloon_process, NULL, NULL, 0, 0, "balloon");
-#ifndef XENHVM
- /* Initialise the balloon with excess memory space. */
- for (pfn = xen_start_info->nr_pages; pfn < max_pfn; pfn++) {
- page = PHYS_TO_VM_PAGE(pfn << PAGE_SHIFT);
- TAILQ_INSERT_HEAD(&ballooned_pages, page, plinks.q);
- bs.balloon_low++;
- }
-#undef max_pfn
-#endif
-
target_watch.callback = watch_target;
err = xs_register_watch(&target_watch);
diff --git a/sys/dev/xen/blkback/blkback.c b/sys/dev/xen/blkback/blkback.c
index 1273961..d352242 100644
--- a/sys/dev/xen/blkback/blkback.c
+++ b/sys/dev/xen/blkback/blkback.c
@@ -742,7 +742,6 @@ struct xbb_softc {
/** Mutex protecting per-instance data. */
struct mtx lock;
-#ifdef XENHVM
/**
* Resource representing allocated physical address space
* associated with our per-instance kva region.
@@ -751,7 +750,6 @@ struct xbb_softc {
/** Resource id for allocated physical address space. */
int pseudo_phys_res_id;
-#endif
/**
* I/O statistics from BlockBack dispatch down. These are
@@ -2818,16 +2816,11 @@ static void
xbb_free_communication_mem(struct xbb_softc *xbb)
{
if (xbb->kva != 0) {
-#ifndef XENHVM
- kva_free(xbb->kva, xbb->kva_size);
-#else
if (xbb->pseudo_phys_res != NULL) {
- bus_release_resource(xbb->dev, SYS_RES_MEMORY,
- xbb->pseudo_phys_res_id,
- xbb->pseudo_phys_res);
+ xenmem_free(xbb->dev, xbb->pseudo_phys_res_id,
+ xbb->pseudo_phys_res);
xbb->pseudo_phys_res = NULL;
}
-#endif
}
xbb->kva = 0;
xbb->gnt_base_addr = 0;
@@ -3055,12 +3048,6 @@ xbb_alloc_communication_mem(struct xbb_softc *xbb)
DPRINTF("%s: kva_size = %d, reqlist_kva_size = %d\n",
device_get_nameunit(xbb->dev), xbb->kva_size,
xbb->reqlist_kva_size);
-#ifndef XENHVM
- xbb->kva = kva_alloc(xbb->kva_size);
- if (xbb->kva == 0)
- return (ENOMEM);
- xbb->gnt_base_addr = xbb->kva;
-#else /* XENHVM */
/*
* Reserve a range of pseudo physical memory that we can map
* into kva. These pages will only be backed by machine
@@ -3068,17 +3055,14 @@ xbb_alloc_communication_mem(struct xbb_softc *xbb)
* via grant table operations.
*/
xbb->pseudo_phys_res_id = 0;
- xbb->pseudo_phys_res = bus_alloc_resource(xbb->dev, SYS_RES_MEMORY,
- &xbb->pseudo_phys_res_id,
- 0, ~0, xbb->kva_size,
- RF_ACTIVE);
+ xbb->pseudo_phys_res = xenmem_alloc(xbb->dev, &xbb->pseudo_phys_res_id,
+ xbb->kva_size);
if (xbb->pseudo_phys_res == NULL) {
xbb->kva = 0;
return (ENOMEM);
}
xbb->kva = (vm_offset_t)rman_get_virtual(xbb->pseudo_phys_res);
xbb->gnt_base_addr = rman_get_start(xbb->pseudo_phys_res);
-#endif /* XENHVM */
DPRINTF("%s: kva: %#jx, gnt_base_addr: %#jx\n",
device_get_nameunit(xbb->dev), (uintmax_t)xbb->kva,
diff --git a/sys/dev/xen/control/control.c b/sys/dev/xen/control/control.c
index 665a5ac..2a0d459 100644
--- a/sys/dev/xen/control/control.c
+++ b/sys/dev/xen/control/control.c
@@ -138,9 +138,7 @@ __FBSDID("$FreeBSD$");
#include <xen/gnttab.h>
#include <xen/xen_intr.h>
-#ifdef XENHVM
#include <xen/hvm.h>
-#endif
#include <xen/interface/event_channel.h>
#include <xen/interface/grant_table.h>
@@ -192,133 +190,6 @@ xctrl_reboot()
shutdown_nice(0);
}
-#ifndef XENHVM
-extern void xencons_suspend(void);
-extern void xencons_resume(void);
-
-/* Full PV mode suspension. */
-static void
-xctrl_suspend()
-{
- int i, j, k, fpp, suspend_cancelled;
- unsigned long max_pfn, start_info_mfn;
-
- EVENTHANDLER_INVOKE(power_suspend);
-
-#ifdef SMP
- struct thread *td;
- cpuset_t map;
- u_int cpuid;
-
- /*
- * Bind us to CPU 0 and stop any other VCPUs.
- */
- td = curthread;
- thread_lock(td);
- sched_bind(td, 0);
- thread_unlock(td);
- cpuid = PCPU_GET(cpuid);
- KASSERT(cpuid == 0, ("xen_suspend: not running on cpu 0"));
-
- map = all_cpus;
- CPU_CLR(cpuid, &map);
- CPU_NAND(&map, &stopped_cpus);
- if (!CPU_EMPTY(&map))
- stop_cpus(map);
-#endif
-
- /*
- * Be sure to hold Giant across DEVICE_SUSPEND/RESUME since non-MPSAFE
- * drivers need this.
- */
- mtx_lock(&Giant);
- if (DEVICE_SUSPEND(root_bus) != 0) {
- mtx_unlock(&Giant);
- printf("%s: device_suspend failed\n", __func__);
-#ifdef SMP
- if (!CPU_EMPTY(&map))
- restart_cpus(map);
-#endif
- return;
- }
- mtx_unlock(&Giant);
-
- local_irq_disable();
-
- xencons_suspend();
- gnttab_suspend();
- intr_suspend();
-
- max_pfn = HYPERVISOR_shared_info->arch.max_pfn;
-
- void *shared_info = HYPERVISOR_shared_info;
- HYPERVISOR_shared_info = NULL;
- pmap_kremove((vm_offset_t) shared_info);
- PT_UPDATES_FLUSH();
-
- xen_start_info->store_mfn = MFNTOPFN(xen_start_info->store_mfn);
- xen_start_info->console.domU.mfn = MFNTOPFN(xen_start_info->console.domU.mfn);
-
- /*
- * We'll stop somewhere inside this hypercall. When it returns,
- * we'll start resuming after the restore.
- */
- start_info_mfn = VTOMFN(xen_start_info);
- pmap_suspend();
- suspend_cancelled = HYPERVISOR_suspend(start_info_mfn);
- pmap_resume();
-
- pmap_kenter_ma((vm_offset_t) shared_info, xen_start_info->shared_info);
- HYPERVISOR_shared_info = shared_info;
-
- HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
- VTOMFN(xen_pfn_to_mfn_frame_list_list);
-
- fpp = PAGE_SIZE/sizeof(unsigned long);
- for (i = 0, j = 0, k = -1; i < max_pfn; i += fpp, j++) {
- if ((j % fpp) == 0) {
- k++;
- xen_pfn_to_mfn_frame_list_list[k] =
- VTOMFN(xen_pfn_to_mfn_frame_list[k]);
- j = 0;
- }
- xen_pfn_to_mfn_frame_list[k][j] =
- VTOMFN(&xen_phys_machine[i]);
- }
- HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
-
- gnttab_resume(NULL);
- intr_resume(suspend_cancelled != 0);
- local_irq_enable();
- xencons_resume();
-
-#ifdef CONFIG_SMP
- for_each_cpu(i)
- vcpu_prepare(i);
-
-#endif
-
- /*
- * Only resume xenbus /after/ we've prepared our VCPUs; otherwise
- * the VCPU hotplug callback can race with our vcpu_prepare
- */
- mtx_lock(&Giant);
- DEVICE_RESUME(root_bus);
- mtx_unlock(&Giant);
-
-#ifdef SMP
- thread_lock(curthread);
- sched_unbind(curthread);
- thread_unlock(curthread);
- if (!CPU_EMPTY(&map))
- restart_cpus(map);
-#endif
- EVENTHANDLER_INVOKE(power_resume);
-}
-
-#else
-
-/* HVM mode suspension. */
static void
xctrl_suspend()
{
@@ -417,7 +288,6 @@ xctrl_suspend()
printf("System resumed after suspension\n");
}
-#endif
static void
xctrl_crash()
diff --git a/sys/dev/xen/grant_table/grant_table.c b/sys/dev/xen/grant_table/grant_table.c
index 2511657..728d64d 100644
--- a/sys/dev/xen/grant_table/grant_table.c
+++ b/sys/dev/xen/grant_table/grant_table.c
@@ -53,7 +53,6 @@ static int gnttab_free_count;
static grant_ref_t gnttab_free_head;
static struct mtx gnttab_list_lock;
-#ifdef XENHVM
/*
* Resource representing allocated physical address space
* for the grant table metainfo
@@ -62,7 +61,6 @@ static struct resource *gnttab_pseudo_phys_res;
/* Resource id for allocated physical address space. */
static int gnttab_pseudo_phys_res_id;
-#endif
static grant_entry_t *shared;
@@ -510,72 +508,6 @@ unmap_pte_fn(pte_t *pte, struct page *pmd_page,
}
#endif
-#ifndef XENHVM
-
-static int
-gnttab_map(unsigned int start_idx, unsigned int end_idx)
-{
- struct gnttab_setup_table setup;
- u_long *frames;
-
- unsigned int nr_gframes = end_idx + 1;
- int i, rc;
-
- frames = malloc(nr_gframes * sizeof(unsigned long), M_DEVBUF, M_NOWAIT);
- if (!frames)
- return (ENOMEM);
-
- setup.dom = DOMID_SELF;
- setup.nr_frames = nr_gframes;
- set_xen_guest_handle(setup.frame_list, frames);
-
- rc = HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
- if (rc == -ENOSYS) {
- free(frames, M_DEVBUF);
- return (ENOSYS);
- }
- KASSERT(!(rc || setup.status),
- ("unexpected result from grant_table_op"));
-
- if (shared == NULL) {
- vm_offset_t area;
-
- area = kva_alloc(PAGE_SIZE * max_nr_grant_frames());
- KASSERT(area, ("can't allocate VM space for grant table"));
- shared = (grant_entry_t *)area;
- }
-
- for (i = 0; i < nr_gframes; i++)
- PT_SET_MA(((caddr_t)shared) + i*PAGE_SIZE,
- ((vm_paddr_t)frames[i]) << PAGE_SHIFT | PG_RW | PG_V);
-
- free(frames, M_DEVBUF);
-
- return (0);
-}
-
-int
-gnttab_resume(device_t dev)
-{
-
- if (max_nr_grant_frames() < nr_grant_frames)
- return (ENOSYS);
- return (gnttab_map(0, nr_grant_frames - 1));
-}
-
-int
-gnttab_suspend(void)
-{
- int i;
-
- for (i = 0; i < nr_grant_frames; i++)
- pmap_kremove((vm_offset_t) shared + i * PAGE_SIZE);
-
- return (0);
-}
-
-#else /* XENHVM */
-
static vm_paddr_t resume_frames;
static int
@@ -627,9 +559,8 @@ gnttab_resume(device_t dev)
KASSERT(dev != NULL,
("No resume frames and no device provided"));
- gnttab_pseudo_phys_res = bus_alloc_resource(dev,
- SYS_RES_MEMORY, &gnttab_pseudo_phys_res_id, 0, ~0,
- PAGE_SIZE * max_nr_gframes, RF_ACTIVE);
+ gnttab_pseudo_phys_res = xenmem_alloc(dev,
+ &gnttab_pseudo_phys_res_id, PAGE_SIZE * max_nr_gframes);
if (gnttab_pseudo_phys_res == NULL)
panic("Unable to reserve physical memory for gnttab");
resume_frames = rman_get_start(gnttab_pseudo_phys_res);
@@ -638,8 +569,6 @@ gnttab_resume(device_t dev)
return (gnttab_map(0, nr_gframes - 1));
}
-#endif
-
static int
gnttab_expand(unsigned int req_entries)
{
diff --git a/sys/dev/xen/netback/netback.c b/sys/dev/xen/netback/netback.c
index 63337ad..2233084 100644
--- a/sys/dev/xen/netback/netback.c
+++ b/sys/dev/xen/netback/netback.c
@@ -473,7 +473,6 @@ struct xnb_softc {
*/
gnttab_copy_table tx_gnttab;
-#ifdef XENHVM
/**
* Resource representing allocated physical address space
* associated with our per-instance kva region.
@@ -482,7 +481,6 @@ struct xnb_softc {
/** Resource id for allocated physical address space. */
int pseudo_phys_res_id;
-#endif
/** Ring mapping and interrupt configuration data. */
struct xnb_ring_config ring_configs[XNB_NUM_RING_TYPES];
@@ -626,16 +624,11 @@ static void
xnb_free_communication_mem(struct xnb_softc *xnb)
{
if (xnb->kva != 0) {
-#ifndef XENHVM
- kva_free(xnb->kva, xnb->kva_size);
-#else
if (xnb->pseudo_phys_res != NULL) {
- bus_release_resource(xnb->dev, SYS_RES_MEMORY,
- xnb->pseudo_phys_res_id,
+ xenmem_free(xnb->dev, xnb->pseudo_phys_res_id,
xnb->pseudo_phys_res);
xnb->pseudo_phys_res = NULL;
}
-#endif /* XENHVM */
}
xnb->kva = 0;
xnb->gnt_base_addr = 0;
@@ -816,12 +809,7 @@ xnb_alloc_communication_mem(struct xnb_softc *xnb)
for (i=0; i < XNB_NUM_RING_TYPES; i++) {
xnb->kva_size += xnb->ring_configs[i].ring_pages * PAGE_SIZE;
}
-#ifndef XENHVM
- xnb->kva = kva_alloc(xnb->kva_size);
- if (xnb->kva == 0)
- return (ENOMEM);
- xnb->gnt_base_addr = xnb->kva;
-#else /* defined XENHVM */
+
/*
* Reserve a range of pseudo physical memory that we can map
* into kva. These pages will only be backed by machine
@@ -830,17 +818,14 @@ xnb_alloc_communication_mem(struct xnb_softc *xnb)
* into this space.
*/
xnb->pseudo_phys_res_id = 0;
- xnb->pseudo_phys_res = bus_alloc_resource(xnb->dev, SYS_RES_MEMORY,
- &xnb->pseudo_phys_res_id,
- 0, ~0, xnb->kva_size,
- RF_ACTIVE);
+ xnb->pseudo_phys_res = xenmem_alloc(xnb->dev, &xnb->pseudo_phys_res_id,
+ xnb->kva_size);
if (xnb->pseudo_phys_res == NULL) {
xnb->kva = 0;
return (ENOMEM);
}
xnb->kva = (vm_offset_t)rman_get_virtual(xnb->pseudo_phys_res);
xnb->gnt_base_addr = rman_get_start(xnb->pseudo_phys_res);
-#endif /* !defined XENHVM */
return (0);
}
diff --git a/sys/dev/xen/netfront/netfront.c b/sys/dev/xen/netfront/netfront.c
index 27900ba..317a339 100644
--- a/sys/dev/xen/netfront/netfront.c
+++ b/sys/dev/xen/netfront/netfront.c
@@ -682,7 +682,6 @@ netfront_backend_changed(device_t dev, XenbusState newstate)
switch (newstate) {
case XenbusStateInitialising:
case XenbusStateInitialised:
- case XenbusStateConnected:
case XenbusStateUnknown:
case XenbusStateClosed:
case XenbusStateReconfigured:
@@ -694,13 +693,15 @@ netfront_backend_changed(device_t dev, XenbusState newstate)
if (network_connect(sc) != 0)
break;
xenbus_set_state(dev, XenbusStateConnected);
-#ifdef INET
- netfront_send_fake_arp(dev, sc);
-#endif
break;
case XenbusStateClosing:
xenbus_set_state(dev, XenbusStateClosed);
break;
+ case XenbusStateConnected:
+#ifdef INET
+ netfront_send_fake_arp(dev, sc);
+#endif
+ break;
}
}
@@ -879,12 +880,11 @@ refill:
if (sc->copying_receiver == 0) {
gnttab_grant_foreign_transfer_ref(ref,
otherend_id, pfn);
- sc->rx_pfn_array[nr_flips] = PFNTOMFN(pfn);
+ sc->rx_pfn_array[nr_flips] = pfn;
if (!xen_feature(XENFEAT_auto_translated_physmap)) {
/* Remove this page before passing
* back to Xen.
*/
- set_phys_to_machine(pfn, INVALID_P2M_ENTRY);
MULTI_update_va_mapping(&sc->rx_mcl[i],
vaddr, 0, 0);
}
@@ -892,7 +892,7 @@ refill:
} else {
gnttab_grant_foreign_access_ref(ref,
otherend_id,
- PFNTOMFN(pfn), 0);
+ pfn, 0);
}
req->id = id;
req->gref = ref;
@@ -907,7 +907,6 @@ refill:
* We may have allocated buffers which have entries outstanding
* in the page * update queue -- make sure we flush those first!
*/
- PT_UPDATES_FLUSH();
if (nr_flips != 0) {
#ifdef notyet
/* Tell the ballon driver what is going on. */
@@ -1361,8 +1360,6 @@ xennet_get_responses(struct netfront_info *np,
mmu->ptr = ((vm_paddr_t)mfn << PAGE_SHIFT) |
MMU_MACHPHYS_UPDATE;
mmu->val = pfn;
-
- set_phys_to_machine(pfn, mfn);
}
pages_flipped++;
} else {
@@ -1927,7 +1924,7 @@ network_connect(struct netfront_info *np)
} else {
gnttab_grant_foreign_access_ref(ref,
xenbus_get_otherend_id(np->xbdev),
- PFNTOMFN(pfn), 0);
+ pfn, 0);
}
req->gref = ref;
req->id = requeue_idx;
@@ -2095,7 +2092,7 @@ create_netdev(device_t dev)
ifp->if_hw_tsomaxsegsize = PAGE_SIZE;
ether_ifattach(ifp, np->mac);
- callout_init(&np->xn_stat_ch, CALLOUT_MPSAFE);
+ callout_init(&np->xn_stat_ch, 1);
netfront_carrier_off(np);
return (0);
diff --git a/sys/dev/xen/privcmd/privcmd.c b/sys/dev/xen/privcmd/privcmd.c
index 761fb03..0bf9585 100644
--- a/sys/dev/xen/privcmd/privcmd.c
+++ b/sys/dev/xen/privcmd/privcmd.c
@@ -141,11 +141,8 @@ retry:
free(map->errs, M_PRIVCMD);
}
- vm_phys_fictitious_unreg_range(map->phys_base_addr,
- map->phys_base_addr + map->size * PAGE_SIZE);
-
- error = bus_release_resource(privcmd_dev, SYS_RES_MEMORY,
- map->pseudo_phys_res_id, map->pseudo_phys_res);
+ error = xenmem_free(privcmd_dev, map->pseudo_phys_res_id,
+ map->pseudo_phys_res);
KASSERT(error == 0, ("Unable to release memory resource: %d", error));
free(map, M_PRIVCMD);
@@ -196,36 +193,25 @@ privcmd_mmap_single(struct cdev *cdev, vm_ooffset_t *offset, vm_size_t size,
vm_object_t *object, int nprot)
{
struct privcmd_map *map;
- int error;
map = malloc(sizeof(*map), M_PRIVCMD, M_WAITOK | M_ZERO);
map->size = OFF_TO_IDX(size);
map->pseudo_phys_res_id = 0;
- map->pseudo_phys_res = bus_alloc_resource(privcmd_dev, SYS_RES_MEMORY,
- &map->pseudo_phys_res_id, 0, ~0, size, RF_ACTIVE);
+ map->pseudo_phys_res = xenmem_alloc(privcmd_dev,
+ &map->pseudo_phys_res_id, size);
if (map->pseudo_phys_res == NULL) {
free(map, M_PRIVCMD);
return (ENOMEM);
}
map->phys_base_addr = rman_get_start(map->pseudo_phys_res);
-
- error = vm_phys_fictitious_reg_range(map->phys_base_addr,
- map->phys_base_addr + size, VM_MEMATTR_DEFAULT);
- if (error) {
- bus_release_resource(privcmd_dev, SYS_RES_MEMORY,
- map->pseudo_phys_res_id, map->pseudo_phys_res);
- free(map, M_PRIVCMD);
- return (error);
- }
-
map->mem = cdev_pager_allocate(map, OBJT_MGTDEVICE, &privcmd_pg_ops,
size, nprot, *offset, NULL);
if (map->mem == NULL) {
- bus_release_resource(privcmd_dev, SYS_RES_MEMORY,
- map->pseudo_phys_res_id, map->pseudo_phys_res);
+ xenmem_free(privcmd_dev, map->pseudo_phys_res_id,
+ map->pseudo_phys_res);
free(map, M_PRIVCMD);
return (ENOMEM);
}
diff --git a/sys/fs/nfs/nfs_commonport.c b/sys/fs/nfs/nfs_commonport.c
index eea146a..bc5d9de 100644
--- a/sys/fs/nfs/nfs_commonport.c
+++ b/sys/fs/nfs/nfs_commonport.c
@@ -589,7 +589,7 @@ nfscommon_modevent(module_t mod, int type, void *data)
mtx_init(&nfs_req_mutex, "nfs_req_mutex", NULL, MTX_DEF);
mtx_init(&nfsrv_nfsuserdsock.nr_mtx, "nfsuserd", NULL,
MTX_DEF);
- callout_init(&newnfsd_callout, CALLOUT_MPSAFE);
+ callout_init(&newnfsd_callout, 1);
newnfs_init();
nfsd_call_nfscommon = nfssvc_nfscommon;
loaded = 1;
diff --git a/sys/fs/nfsclient/nfs_clbio.c b/sys/fs/nfsclient/nfs_clbio.c
index ea42537..e8de4a5 100644
--- a/sys/fs/nfsclient/nfs_clbio.c
+++ b/sys/fs/nfsclient/nfs_clbio.c
@@ -864,7 +864,7 @@ ncl_write(struct vop_write_args *ap)
struct nfsmount *nmp = VFSTONFS(vp->v_mount);
daddr_t lbn;
int bcount, noncontig_write, obcount;
- int bp_cached, n, on, error = 0, error1;
+ int bp_cached, n, on, error = 0, error1, wouldcommit;
size_t orig_resid, local_resid;
off_t orig_size, tmp_off;
@@ -908,7 +908,6 @@ ncl_write(struct vop_write_args *ap)
if (ioflag & IO_NDELAY)
return (EAGAIN);
#endif
-flush_and_restart:
np->n_attrstamp = 0;
KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp);
error = ncl_vinvalbuf(vp, V_SAVE, td, 1);
@@ -965,27 +964,14 @@ flush_and_restart:
* IO_UNIT -- we just make all writes atomic anyway, as there's
* no point optimizing for something that really won't ever happen.
*/
+ wouldcommit = 0;
if (!(ioflag & IO_SYNC)) {
int nflag;
mtx_lock(&np->n_mtx);
nflag = np->n_flag;
mtx_unlock(&np->n_mtx);
- int needrestart = 0;
- if (nmp->nm_wcommitsize < uio->uio_resid) {
- /*
- * If this request could not possibly be completed
- * without exceeding the maximum outstanding write
- * commit size, see if we can convert it into a
- * synchronous write operation.
- */
- if (ioflag & IO_NDELAY)
- return (EAGAIN);
- ioflag |= IO_SYNC;
- if (nflag & NMODIFIED)
- needrestart = 1;
- } else if (nflag & NMODIFIED) {
- int wouldcommit = 0;
+ if (nflag & NMODIFIED) {
BO_LOCK(&vp->v_bufobj);
if (vp->v_bufobj.bo_dirty.bv_cnt != 0) {
TAILQ_FOREACH(bp, &vp->v_bufobj.bo_dirty.bv_hd,
@@ -995,27 +981,22 @@ flush_and_restart:
}
}
BO_UNLOCK(&vp->v_bufobj);
- /*
- * Since we're not operating synchronously and
- * bypassing the buffer cache, we are in a commit
- * and holding all of these buffers whether
- * transmitted or not. If not limited, this
- * will lead to the buffer cache deadlocking,
- * as no one else can flush our uncommitted buffers.
- */
- wouldcommit += uio->uio_resid;
- /*
- * If we would initially exceed the maximum
- * outstanding write commit size, flush and restart.
- */
- if (wouldcommit > nmp->nm_wcommitsize)
- needrestart = 1;
}
- if (needrestart)
- goto flush_and_restart;
}
do {
+ if (!(ioflag & IO_SYNC)) {
+ wouldcommit += biosize;
+ if (wouldcommit > nmp->nm_wcommitsize) {
+ np->n_attrstamp = 0;
+ KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp);
+ error = ncl_vinvalbuf(vp, V_SAVE, td, 1);
+ if (error)
+ return (error);
+ wouldcommit = biosize;
+ }
+ }
+
NFSINCRGLOBAL(newnfsstats.biocache_writes);
lbn = uio->uio_offset / biosize;
on = uio->uio_offset - (lbn * biosize);
diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c
index 7968353..55eb983 100644
--- a/sys/fs/nfsclient/nfs_clrpcops.c
+++ b/sys/fs/nfsclient/nfs_clrpcops.c
@@ -3072,25 +3072,6 @@ nfsrpc_readdir(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
*eofp = eof;
}
- /*
- * Add extra empty records to any remaining DIRBLKSIZ chunks.
- */
- while (uio_uio_resid(uiop) > 0 && ((size_t)(uio_uio_resid(uiop))) != tresid) {
- dp = (struct dirent *) CAST_DOWN(caddr_t, uio_iov_base(uiop));
- dp->d_type = DT_UNKNOWN;
- dp->d_fileno = 0;
- dp->d_namlen = 0;
- dp->d_name[0] = '\0';
- tl = (u_int32_t *)&dp->d_name[4];
- *tl++ = cookie.lval[0];
- *tl = cookie.lval[1];
- dp->d_reclen = DIRBLKSIZ;
- uio_iov_base_add(uiop, DIRBLKSIZ);
- uio_iov_len_add(uiop, -(DIRBLKSIZ));
- uio_uio_resid_add(uiop, -(DIRBLKSIZ));
- uiop->uio_offset += DIRBLKSIZ;
- }
-
nfsmout:
if (nd->nd_mrep != NULL)
mbuf_freem(nd->nd_mrep);
@@ -3565,25 +3546,6 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep,
*eofp = eof;
}
- /*
- * Add extra empty records to any remaining DIRBLKSIZ chunks.
- */
- while (uio_uio_resid(uiop) > 0 && uio_uio_resid(uiop) != tresid) {
- dp = (struct dirent *)uio_iov_base(uiop);
- dp->d_type = DT_UNKNOWN;
- dp->d_fileno = 0;
- dp->d_namlen = 0;
- dp->d_name[0] = '\0';
- tl = (u_int32_t *)&dp->d_name[4];
- *tl++ = cookie.lval[0];
- *tl = cookie.lval[1];
- dp->d_reclen = DIRBLKSIZ;
- uio_iov_base_add(uiop, DIRBLKSIZ);
- uio_iov_len_add(uiop, -(DIRBLKSIZ));
- uio_uio_resid_add(uiop, -(DIRBLKSIZ));
- uiop->uio_offset += DIRBLKSIZ;
- }
-
nfsmout:
if (nd->nd_mrep != NULL)
mbuf_freem(nd->nd_mrep);
diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c
index 513abf4..6aee675 100644
--- a/sys/fs/nfsclient/nfs_clvnops.c
+++ b/sys/fs/nfsclient/nfs_clvnops.c
@@ -2210,7 +2210,7 @@ nfs_readdir(struct vop_readdir_args *ap)
struct vnode *vp = ap->a_vp;
struct nfsnode *np = VTONFS(vp);
struct uio *uio = ap->a_uio;
- ssize_t tresid;
+ ssize_t tresid, left;
int error = 0;
struct vattr vattr;
@@ -2239,6 +2239,17 @@ nfs_readdir(struct vop_readdir_args *ap)
}
/*
+ * NFS always guarantees that directory entries don't straddle
+ * DIRBLKSIZ boundaries. As such, we need to limit the size
+ * to an exact multiple of DIRBLKSIZ, to avoid copying a partial
+ * directory entry.
+ */
+ left = uio->uio_resid % DIRBLKSIZ;
+ if (left == uio->uio_resid)
+ return (EINVAL);
+ uio->uio_resid -= left;
+
+ /*
* Call ncl_bioread() to do the real work.
*/
tresid = uio->uio_resid;
@@ -2249,6 +2260,9 @@ nfs_readdir(struct vop_readdir_args *ap)
if (ap->a_eofflag != NULL)
*ap->a_eofflag = 1;
}
+
+ /* Add the partial DIRBLKSIZ (left) back in. */
+ uio->uio_resid += left;
return (error);
}
diff --git a/sys/fs/procfs/procfs_ctl.c b/sys/fs/procfs/procfs_ctl.c
index dc267f6..1437644 100644
--- a/sys/fs/procfs/procfs_ctl.c
+++ b/sys/fs/procfs/procfs_ctl.c
@@ -143,8 +143,8 @@ procfs_control(struct thread *td, struct proc *p, int op)
p->p_flag |= P_TRACED;
faultin(p);
p->p_xstat = 0; /* XXX ? */
+ p->p_oppid = p->p_pptr->p_pid;
if (p->p_pptr != td->td_proc) {
- p->p_oppid = p->p_pptr->p_pid;
proc_reparent(p, td->td_proc);
}
kern_psignal(p, SIGSTOP);
diff --git a/sys/gdb/gdb_cons.c b/sys/gdb/gdb_cons.c
index 47f453f..6bf2f9b 100644
--- a/sys/gdb/gdb_cons.c
+++ b/sys/gdb/gdb_cons.c
@@ -76,7 +76,7 @@ gdb_cninit(struct consdev *cp)
/* setup tx buffer and callout */
if (c->npending == -1) {
c->npending = 0;
- callout_init(&c->flush, CALLOUT_MPSAFE);
+ callout_init(&c->flush, 1);
cp->cn_arg = c;
}
}
diff --git a/sys/geom/gate/g_gate.c b/sys/geom/gate/g_gate.c
index ae0d7b0..3453eef 100644
--- a/sys/geom/gate/g_gate.c
+++ b/sys/geom/gate/g_gate.c
@@ -486,7 +486,7 @@ g_gate_create(struct g_gate_ctl_create *ggio)
if (sc->sc_queue_size > G_GATE_MAX_QUEUE_SIZE)
sc->sc_queue_size = G_GATE_MAX_QUEUE_SIZE;
sc->sc_timeout = ggio->gctl_timeout;
- callout_init(&sc->sc_callout, CALLOUT_MPSAFE);
+ callout_init(&sc->sc_callout, 1);
mtx_lock(&g_gate_units_lock);
sc->sc_unit = g_gate_getunit(ggio->gctl_unit, &error);
diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c
index 9cc324c..f0eb103 100644
--- a/sys/geom/journal/g_journal.c
+++ b/sys/geom/journal/g_journal.c
@@ -2314,7 +2314,7 @@ g_journal_create(struct g_class *mp, struct g_provider *pp,
sc->sc_rootmount = root_mount_hold("GJOURNAL");
GJ_DEBUG(1, "root_mount_hold %p", sc->sc_rootmount);
- callout_init(&sc->sc_callout, CALLOUT_MPSAFE);
+ callout_init(&sc->sc_callout, 1);
if (md->md_type != GJ_TYPE_COMPLETE) {
/*
* Journal and data are on separate providers.
diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c
index 1912271..cb2e41b 100644
--- a/sys/geom/mirror/g_mirror.c
+++ b/sys/geom/mirror/g_mirror.c
@@ -2935,7 +2935,7 @@ g_mirror_create(struct g_class *mp, const struct g_mirror_metadata *md)
LIST_INIT(&sc->sc_disks);
TAILQ_INIT(&sc->sc_events);
mtx_init(&sc->sc_events_mtx, "gmirror:events", NULL, MTX_DEF);
- callout_init(&sc->sc_callout, CALLOUT_MPSAFE);
+ callout_init(&sc->sc_callout, 1);
mtx_init(&sc->sc_done_mtx, "gmirror:done", NULL, MTX_DEF);
sc->sc_state = G_MIRROR_DEVICE_STATE_STARTING;
gp->softc = sc;
diff --git a/sys/geom/part/g_part_mbr.c b/sys/geom/part/g_part_mbr.c
index 5073398..c340106 100644
--- a/sys/geom/part/g_part_mbr.c
+++ b/sys/geom/part/g_part_mbr.c
@@ -138,6 +138,9 @@ static struct g_part_mbr_alias {
{ DOSPTYP_PPCBOOT, G_PART_ALIAS_PREP_BOOT },
{ DOSPTYP_VMFS, G_PART_ALIAS_VMFS },
{ DOSPTYP_VMKDIAG, G_PART_ALIAS_VMKDIAG },
+ { DOSPTYP_APPLE_UFS, G_PART_ALIAS_APPLE_UFS },
+ { DOSPTYP_APPLE_BOOT, G_PART_ALIAS_APPLE_BOOT },
+ { DOSPTYP_HFS, G_PART_ALIAS_APPLE_HFS },
};
static int
diff --git a/sys/geom/raid3/g_raid3.c b/sys/geom/raid3/g_raid3.c
index f935f78..132ef84 100644
--- a/sys/geom/raid3/g_raid3.c
+++ b/sys/geom/raid3/g_raid3.c
@@ -3156,7 +3156,7 @@ g_raid3_create(struct g_class *mp, const struct g_raid3_metadata *md)
bioq_init(&sc->sc_sync_delayed);
TAILQ_INIT(&sc->sc_events);
mtx_init(&sc->sc_events_mtx, "graid3:events", NULL, MTX_DEF);
- callout_init(&sc->sc_callout, CALLOUT_MPSAFE);
+ callout_init(&sc->sc_callout, 1);
sc->sc_state = G_RAID3_DEVICE_STATE_STARTING;
gp->softc = sc;
sc->sc_geom = gp;
diff --git a/sys/geom/sched/gs_rr.c b/sys/geom/sched/gs_rr.c
index b9d5d1b..7742ef6 100644
--- a/sys/geom/sched/gs_rr.c
+++ b/sys/geom/sched/gs_rr.c
@@ -602,7 +602,7 @@ g_rr_init(struct g_geom *geom)
sc = malloc(sizeof *sc, M_GEOM_SCHED, M_NOWAIT | M_ZERO);
sc->sc_geom = geom;
TAILQ_INIT(&sc->sc_rr_tailq);
- callout_init(&sc->sc_wait, CALLOUT_MPSAFE);
+ callout_init(&sc->sc_wait, 1);
LIST_INSERT_HEAD(&me.sc_head, sc, sc_next);
me.units++;
diff --git a/sys/geom/uncompress/g_uncompress.c b/sys/geom/uncompress/g_uncompress.c
index 8c2d5cb..62a677d 100644
--- a/sys/geom/uncompress/g_uncompress.c
+++ b/sys/geom/uncompress/g_uncompress.c
@@ -464,7 +464,8 @@ g_uncompress_taste(struct g_class *mp, struct g_provider *pp, int flags)
struct g_provider *pp2;
struct g_consumer *cp;
struct g_geom *gp;
- uint32_t i, total_offsets, type;
+ uint64_t *offsets;
+ uint32_t i, r, total, total_offsets, type;
uint8_t *buf;
int error;
@@ -499,8 +500,8 @@ g_uncompress_taste(struct g_class *mp, struct g_provider *pp, int flags)
*/
DPRINTF(("%s: media sectorsize %u, mediasize %jd\n",
gp->name, pp->sectorsize, (intmax_t)pp->mediasize));
- i = roundup(sizeof(struct cloop_header), pp->sectorsize);
- buf = g_read_data(cp, 0, i, NULL);
+ total = roundup(sizeof(struct cloop_header), pp->sectorsize);
+ buf = g_read_data(cp, 0, total, NULL);
if (buf == NULL)
goto err;
header = (struct cloop_header *) buf;
@@ -557,20 +558,29 @@ g_uncompress_taste(struct g_class *mp, struct g_provider *pp, int flags)
gp->name, sc->nblocks);
goto err;
}
- free(buf, M_GEOM);
+ g_free(buf);
- i = roundup((sizeof(struct cloop_header) +
- total_offsets * sizeof(uint64_t)), pp->sectorsize);
- buf = g_read_data(cp, 0, i, NULL);
- if (buf == NULL)
- goto err;
sc->offsets = malloc(total_offsets * sizeof(uint64_t),
- M_GEOM_UNCOMPRESS, M_WAITOK);
- for (i = 0; i <= total_offsets; i++) {
- sc->offsets[i] = be64toh(((uint64_t *)
- (buf+sizeof(struct cloop_header)))[i]);
+ M_GEOM_UNCOMPRESS, M_WAITOK | M_ZERO);
+ total = roundup((sizeof(struct cloop_header) +
+ total_offsets * sizeof(uint64_t)), pp->sectorsize);
+#define RSZ ((total - r) > MAXPHYS ? MAXPHYS: (total - r))
+ for (r = 0, i = 0; r < total; r += MAXPHYS) {
+ buf = g_read_data(cp, r, RSZ, &error);
+ if (buf == NULL) {
+ free(sc->offsets, M_GEOM_UNCOMPRESS);
+ goto err;
+ }
+ offsets = (uint64_t *)buf;
+ if (r == 0)
+ offsets +=
+ sizeof(struct cloop_header) / sizeof(uint64_t);
+ for (; i < total_offsets && offsets < (uint64_t *)(buf + RSZ);
+ i++, offsets++)
+ sc->offsets[i] = be64toh(*offsets);
+ g_free(buf);
}
- free(buf, M_GEOM);
+#undef RSZ
buf = NULL;
DPRINTF(("%s: done reading offsets\n", gp->name));
mtx_init(&sc->last_mtx, "geom_uncompress cache", NULL, MTX_DEF);
@@ -619,7 +629,7 @@ err:
g_topology_lock();
g_access(cp, -1, 0, 0);
if (buf != NULL)
- free(buf, M_GEOM);
+ g_free(buf);
if (gp->softc != NULL) {
g_uncompress_softc_free(gp->softc, NULL);
gp->softc = NULL;
diff --git a/sys/i386/acpica/acpi_machdep.c b/sys/i386/acpica/acpi_machdep.c
index 049354b..4c79691 100644
--- a/sys/i386/acpica/acpi_machdep.c
+++ b/sys/i386/acpica/acpi_machdep.c
@@ -106,13 +106,6 @@ acpi_machdep_quirks(int *quirks)
return (0);
}
-void
-acpi_cpu_c1()
-{
-
- __asm __volatile("sti; hlt");
-}
-
/*
* Support for mapping ACPI tables during early boot. This abuses the
* crashdump map because the kernel cannot allocate KVA in
diff --git a/sys/i386/conf/DEFAULTS b/sys/i386/conf/DEFAULTS
index 78d807c..d5bdb1d 100644
--- a/sys/i386/conf/DEFAULTS
+++ b/sys/i386/conf/DEFAULTS
@@ -26,7 +26,6 @@ options GEOM_PART_EBR_COMPAT
options GEOM_PART_MBR
# enable support for native hardware
-options NATIVE
device atpic
options NEW_PCIB
diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC
index 086844a..d1d2a2f 100644
--- a/sys/i386/conf/GENERIC
+++ b/sys/i386/conf/GENERIC
@@ -73,6 +73,9 @@ options MAC # TrustedBSD MAC Framework
options KDTRACE_HOOKS # Kernel DTrace hooks
options DDB_CTF # Kernel ELF linker loads CTF data
options INCLUDE_CONFIG_FILE # Include this file in kernel
+options RACCT # Resource accounting framework
+options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default
+options RCTL # Resource limits
# Debugging support. Always need this:
options KDB # Enable kernel debugger support.
@@ -174,6 +177,10 @@ device mrsas # LSI/Avago MegaRAID SAS/SATA, 6Gb/s and 12Gb/s
device pst # Promise Supertrak SX6000
device twe # 3ware ATA RAID
+# NVM Express (NVMe) support
+device nvme # base NVMe driver
+device nvd # expose NVMe namespace as disks, depends on nvme
+
# atkbdc0 controls both the keyboard and the PS/2 mouse
device atkbdc # AT keyboard controller
device atkbd # AT keyboard
@@ -358,7 +365,9 @@ device virtio_blk # VirtIO Block device
device virtio_scsi # VirtIO SCSI device
device virtio_balloon # VirtIO Memory Balloon device
-# HyperV drivers
+# HyperV drivers and enchancement support
+# NOTE: HYPERV depends on hyperv. They must be added or removed together.
+options HYPERV # Hyper-V kernel infrastructure
device hyperv # HyperV drivers
# Xen HVM Guest Optimizations
diff --git a/sys/i386/conf/XEN b/sys/i386/conf/XEN
deleted file mode 100644
index dd83670..0000000
--- a/sys/i386/conf/XEN
+++ /dev/null
@@ -1,96 +0,0 @@
-#
-# XEN -- Kernel configuration for i386 XEN DomU
-#
-# $FreeBSD$
-
-cpu I686_CPU
-ident XEN
-
-makeoptions DEBUG=-g # Build kernel with gdb(1) debug symbols
-
-# The following drivers don't build with PAE or XEN enabled.
-makeoptions WITHOUT_MODULES="ctl dpt drm drm2 hptmv ida"
-
-# The following drivers don't work with PAE enabled.
-makeoptions WITHOUT_MODULES+="ncr pst"
-
-options SCHED_ULE # ULE scheduler
-options PREEMPTION # Enable kernel thread preemption
-
-options INET # InterNETworking
-options INET6 # IPv6 communications protocols
-options SCTP # Stream Control Transmission Protocol
-options FFS # Berkeley Fast Filesystem
-options SOFTUPDATES # Enable FFS soft updates support
-options UFS_ACL # Support for access control lists
-options UFS_DIRHASH # Improve performance on big directories
-options UFS_GJOURNAL # Enable gjournal-based UFS journaling
-options NFSCL # Network Filesystem Client
-options NFSD # Network Filesystem Server
-options NFSLOCKD # Network Lock Manager
-options NFS_ROOT # NFS usable as /, requires NFSCL
-options MSDOSFS # MSDOS Filesystem
-options CD9660 # ISO 9660 Filesystem
-options PROCFS # Process filesystem (requires PSEUDOFS)
-options PSEUDOFS # Pseudo-filesystem framework
-options GEOM_PART_GPT # GUID Partition Tables.
-options GEOM_LABEL # Provides labelization
-options COMPAT_FREEBSD4 # Compatible with FreeBSD4
-options COMPAT_FREEBSD5 # Compatible with FreeBSD5
-options COMPAT_FREEBSD6 # Compatible with FreeBSD6
-options COMPAT_FREEBSD7 # Compatible with FreeBSD7
-options COMPAT_FREEBSD9 # Compatible with FreeBSD9
-options COMPAT_FREEBSD10 # Compatible with FreeBSD10
-options KTRACE # ktrace(1) support
-options STACK # stack(9) support
-options SYSVSHM # SYSV-style shared memory
-options SYSVMSG # SYSV-style message queues
-options SYSVSEM # SYSV-style semaphores
-options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
-options KBD_INSTALL_CDEV # install a CDEV entry in /dev
-options AUDIT # Security event auditing
-
-# Debugging for use in -current
-options KDB # Enable kernel debugger support.
-options DDB # Support DDB.
-options GDB # Support remote GDB.
-options DEADLKRES # Enable the deadlock resolver
-options INVARIANTS # Enable calls of extra sanity checking
-options INVARIANT_SUPPORT # Extra sanity checks of internal structures, required by INVARIANTS
-options WITNESS # Enable checks to detect deadlocks and cycles
-options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
-
-options PAE
-nooption NATIVE
-option XEN
-nodevice atpic
-nodevice isa
-options MCLSHIFT=12
-
-# To make an SMP kernel, the next two lines are needed
-options SMP # Symmetric MultiProcessor Kernel
-device apic # I/O APIC
-
-#device atkbdc # AT keyboard controller
-#device atkbd # AT keyboard
-device psm # PS/2 mouse
-device pci
-
-#device kbdmux # keyboard multiplexer
-
-# Pseudo devices.
-device loop # Network loopback
-device random # Entropy device
-device ether # Ethernet support
-device tun # Packet tunnel.
-device md # Memory "disks"
-device gif # IPv6 and IPv4 tunneling
-
-# Wireless cards
-options IEEE80211_SUPPORT_MESH
-options AH_SUPPORT_AR5416
-
-# The `bpf' device enables the Berkeley Packet Filter.
-# Be aware of the administrative consequences of enabling this!
-# Note that 'bpf' is required for DHCP.
-device bpf # Berkeley packet filter
diff --git a/sys/i386/i386/apic_vector.s b/sys/i386/i386/apic_vector.s
index 316bc7a..18b3c5d 100644
--- a/sys/i386/i386/apic_vector.s
+++ b/sys/i386/i386/apic_vector.s
@@ -181,6 +181,25 @@ IDTVEC(xen_intr_upcall)
jmp doreti
#endif
+#ifdef HYPERV
+/*
+ * This is the Hyper-V vmbus channel direct callback interrupt.
+ * Only used when it is running on Hyper-V.
+ */
+ .text
+ SUPERALIGN_TEXT
+IDTVEC(hv_vmbus_callback)
+ PUSH_FRAME
+ SET_KERNEL_SREGS
+ cld
+ FAKE_MCOUNT(TF_EIP(%esp))
+ pushl %esp
+ call hv_vector_handler
+ add $4, %esp
+ MEXITCOUNT
+ jmp doreti
+#endif
+
#ifdef SMP
/*
* Global address space TLB shootdown.
@@ -247,7 +266,6 @@ IDTVEC(invlcache)
/*
* Handler for IPIs sent via the per-cpu IPI bitmap.
*/
-#ifndef XEN
.text
SUPERALIGN_TEXT
IDTVEC(ipi_intr_bitmap_handler)
@@ -262,7 +280,7 @@ IDTVEC(ipi_intr_bitmap_handler)
call ipi_bitmap_handler
MEXITCOUNT
jmp doreti
-#endif
+
/*
* Executed by a CPU when it receives an IPI_STOP from another CPU.
*/
@@ -282,7 +300,6 @@ IDTVEC(cpustop)
/*
* Executed by a CPU when it receives an IPI_SUSPEND from another CPU.
*/
-#ifndef XEN
.text
SUPERALIGN_TEXT
IDTVEC(cpususpend)
@@ -295,7 +312,6 @@ IDTVEC(cpususpend)
POP_FRAME
jmp doreti_iret
-#endif
/*
* Executed by a CPU when it receives a RENDEZVOUS IPI from another CPU.
diff --git a/sys/i386/i386/db_disasm.c b/sys/i386/i386/db_disasm.c
index 901cff1..4f771dc 100644
--- a/sys/i386/i386/db_disasm.c
+++ b/sys/i386/i386/db_disasm.c
@@ -1148,9 +1148,7 @@ db_disasm_esc(loc, inst, short_addr, size, seg)
* next instruction.
*/
db_addr_t
-db_disasm(loc, altfmt)
- db_addr_t loc;
- boolean_t altfmt;
+db_disasm(db_addr_t loc, bool altfmt)
{
int inst;
int size;
diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c
index 97e2e97..7a00740 100644
--- a/sys/i386/i386/genassym.c
+++ b/sys/i386/i386/genassym.c
@@ -238,11 +238,6 @@ ASSYM(BUS_SPACE_HANDLE_BASE, offsetof(struct bus_space_handle, bsh_base));
ASSYM(BUS_SPACE_HANDLE_IAT, offsetof(struct bus_space_handle, bsh_iat));
#endif
-#ifdef XEN
-ASSYM(PC_CR3, offsetof(struct pcpu, pc_cr3));
-ASSYM(XEN_HYPERVISOR_VIRT_START, HYPERVISOR_VIRT_START);
-#endif
-
#ifdef HWPMC_HOOKS
ASSYM(PMC_FN_USER_CALLCHAIN, PMC_FN_USER_CALLCHAIN);
#endif
diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c
index 72f7685..a5867c4 100644
--- a/sys/i386/i386/machdep.c
+++ b/sys/i386/i386/machdep.c
@@ -160,24 +160,6 @@ int arch_i386_is_xbox = 0;
uint32_t arch_i386_xbox_memsize = 0;
#endif
-#ifdef XEN
-/* XEN includes */
-#include <xen/xen-os.h>
-#include <xen/hypervisor.h>
-#include <machine/xen/xenvar.h>
-#include <machine/xen/xenfunc.h>
-#include <xen/xen_intr.h>
-
-void Xhypervisor_callback(void);
-void failsafe_callback(void);
-
-extern trap_info_t trap_table[];
-struct proc_ldt default_proc_ldt;
-extern int init_first;
-int running_xen = 1;
-extern unsigned long physfree;
-#endif /* XEN */
-
/* Sanity check for __curthread() */
CTASSERT(offsetof(struct pcpu, pc_curthread) == 0);
@@ -356,9 +338,7 @@ cpu_startup(dummy)
*/
bufinit();
vm_pager_bufferinit();
-#ifndef XEN
cpu_setregs();
-#endif
}
/*
@@ -1291,13 +1271,8 @@ SYSCTL_STRING(_machdep, OID_AUTO, bootmethod, CTLFLAG_RD, bootmethod, 0,
int _default_ldt;
-#ifdef XEN
-union descriptor *gdt;
-union descriptor *ldt;
-#else
union descriptor gdt[NGDT * MAXCPU]; /* global descriptor table */
union descriptor ldt[NLDT]; /* local descriptor table */
-#endif
static struct gate_descriptor idt0[NIDT];
struct gate_descriptor *idt = &idt0[0]; /* interrupt descriptor table */
struct region_descriptor r_gdt, r_idt; /* table descriptors */
@@ -1397,7 +1372,6 @@ struct soft_segment_descriptor gdt_segs[] = {
.ssd_xx = 0, .ssd_xx1 = 0,
.ssd_def32 = 1,
.ssd_gran = 1 },
-#ifndef XEN
/* GPROC0_SEL 9 Proc 0 Tss Descriptor */
{
.ssd_base = 0x0,
@@ -1489,7 +1463,6 @@ struct soft_segment_descriptor gdt_segs[] = {
.ssd_xx = 0, .ssd_xx1 = 0,
.ssd_def32 = 0,
.ssd_gran = 0 },
-#endif /* !XEN */
};
static struct soft_segment_descriptor ldt_segs[] = {
@@ -1641,7 +1614,7 @@ sdtossd(sd, ssd)
ssd->ssd_gran = sd->sd_gran;
}
-#if !defined(PC98) && !defined(XEN)
+#if !defined(PC98)
static int
add_physmap_entry(uint64_t base, uint64_t length, vm_paddr_t *physmap,
int *physmap_idxp)
@@ -1748,9 +1721,8 @@ add_smap_entries(struct bios_smap *smapbase, vm_paddr_t *physmap,
if (!add_smap_entry(smap, physmap, physmap_idxp))
break;
}
-#endif /* !PC98 && !XEN */
+#endif /* !PC98 */
-#ifndef XEN
static void
basemem_setup(void)
{
@@ -1798,7 +1770,6 @@ basemem_setup(void)
for (i = basemem / 4; i < 160; i++)
pte[i] = (i << PAGE_SHIFT) | PG_V | PG_RW | PG_U;
}
-#endif /* !XEN */
/*
* Populate the (physmap) array with base/bound pairs describing the
@@ -2074,8 +2045,6 @@ do_next:
for (off = 0; off < round_page(msgbufsize); off += PAGE_SIZE)
pmap_kenter((vm_offset_t)msgbufp + off, phys_avail[pa_indx] +
off);
-
- PT_UPDATES_FLUSH();
}
#else /* PC98 */
static void
@@ -2086,7 +2055,6 @@ getmemsize(int first)
vm_paddr_t physmap[PHYSMAP_SIZE];
pt_entry_t *pte;
quad_t dcons_addr, dcons_size, physmem_tunable;
-#ifndef XEN
int hasbrokenint12, i, res;
u_int extmem;
struct vm86frame vmf;
@@ -2094,17 +2062,8 @@ getmemsize(int first)
vm_paddr_t pa;
struct bios_smap *smap, *smapbase;
caddr_t kmdp;
-#endif
has_smap = 0;
-#if defined(XEN)
- Maxmem = xen_start_info->nr_pages - init_first;
- physmem = Maxmem;
- basemem = 0;
- physmap[0] = init_first << PAGE_SHIFT;
- physmap[1] = ptoa(Maxmem) - round_page(msgbufsize);
- physmap_idx = 0;
-#else
#ifdef XBOX
if (arch_i386_is_xbox) {
/*
@@ -2247,7 +2206,6 @@ have_smap:
physmap[physmap_idx + 1] = physmap[physmap_idx] + extmem * 1024;
physmap_done:
-#endif
/*
* Now, physmap contains a map of physical memory.
*/
@@ -2321,7 +2279,6 @@ physmap_done:
getenv_quad("dcons.size", &dcons_size) == 0)
dcons_addr = 0;
-#ifndef XEN
/*
* physmap is in bytes, so when converting to page boundaries,
* round up the start address and round down the end address.
@@ -2442,13 +2399,6 @@ do_next:
}
*pte = 0;
invltlb();
-#else
- phys_avail[0] = physfree;
- phys_avail[1] = xen_start_info->nr_pages*PAGE_SIZE;
- dump_avail[0] = 0;
- dump_avail[1] = xen_start_info->nr_pages*PAGE_SIZE;
-
-#endif
/*
* XXX
@@ -2472,272 +2422,9 @@ do_next:
for (off = 0; off < round_page(msgbufsize); off += PAGE_SIZE)
pmap_kenter((vm_offset_t)msgbufp + off, phys_avail[pa_indx] +
off);
-
- PT_UPDATES_FLUSH();
}
#endif /* PC98 */
-#ifdef XEN
-#define MTOPSIZE (1<<(14 + PAGE_SHIFT))
-
-register_t
-init386(first)
- int first;
-{
- unsigned long gdtmachpfn;
- int error, gsel_tss, metadata_missing, x, pa;
- struct pcpu *pc;
-#ifdef CPU_ENABLE_SSE
- struct xstate_hdr *xhdr;
-#endif
- struct callback_register event = {
- .type = CALLBACKTYPE_event,
- .address = {GSEL(GCODE_SEL, SEL_KPL), (unsigned long)Xhypervisor_callback },
- };
- struct callback_register failsafe = {
- .type = CALLBACKTYPE_failsafe,
- .address = {GSEL(GCODE_SEL, SEL_KPL), (unsigned long)failsafe_callback },
- };
-
- thread0.td_kstack = proc0kstack;
- thread0.td_kstack_pages = KSTACK_PAGES;
-
- /*
- * This may be done better later if it gets more high level
- * components in it. If so just link td->td_proc here.
- */
- proc_linkup0(&proc0, &thread0);
-
- metadata_missing = 0;
- if (xen_start_info->mod_start) {
- preload_metadata = (caddr_t)xen_start_info->mod_start;
- preload_bootstrap_relocate(KERNBASE);
- } else {
- metadata_missing = 1;
- }
- if (envmode == 1)
- kern_envp = static_env;
- else if ((caddr_t)xen_start_info->cmd_line)
- kern_envp = xen_setbootenv((caddr_t)xen_start_info->cmd_line);
-
- boothowto |= xen_boothowto(kern_envp);
-
- /* Init basic tunables, hz etc */
- init_param1();
-
- /*
- * XEN occupies a portion of the upper virtual address space
- * At its base it manages an array mapping machine page frames
- * to physical page frames - hence we need to be able to
- * access 4GB - (64MB - 4MB + 64k)
- */
- gdt_segs[GPRIV_SEL].ssd_limit = atop(HYPERVISOR_VIRT_START + MTOPSIZE);
- gdt_segs[GUFS_SEL].ssd_limit = atop(HYPERVISOR_VIRT_START + MTOPSIZE);
- gdt_segs[GUGS_SEL].ssd_limit = atop(HYPERVISOR_VIRT_START + MTOPSIZE);
- gdt_segs[GCODE_SEL].ssd_limit = atop(HYPERVISOR_VIRT_START + MTOPSIZE);
- gdt_segs[GDATA_SEL].ssd_limit = atop(HYPERVISOR_VIRT_START + MTOPSIZE);
- gdt_segs[GUCODE_SEL].ssd_limit = atop(HYPERVISOR_VIRT_START + MTOPSIZE);
- gdt_segs[GUDATA_SEL].ssd_limit = atop(HYPERVISOR_VIRT_START + MTOPSIZE);
- gdt_segs[GBIOSLOWMEM_SEL].ssd_limit = atop(HYPERVISOR_VIRT_START + MTOPSIZE);
-
- pc = &__pcpu[0];
- gdt_segs[GPRIV_SEL].ssd_base = (int) pc;
- gdt_segs[GPROC0_SEL].ssd_base = (int) &pc->pc_common_tss;
-
- PT_SET_MA(gdt, xpmap_ptom(VTOP(gdt)) | PG_V | PG_RW);
- bzero(gdt, PAGE_SIZE);
- for (x = 0; x < NGDT; x++)
- ssdtosd(&gdt_segs[x], &gdt[x].sd);
-
- mtx_init(&dt_lock, "descriptor tables", NULL, MTX_SPIN);
-
- gdtmachpfn = vtomach(gdt) >> PAGE_SHIFT;
- PT_SET_MA(gdt, xpmap_ptom(VTOP(gdt)) | PG_V);
- PANIC_IF(HYPERVISOR_set_gdt(&gdtmachpfn, 512) != 0);
- lgdt(&r_gdt);
- gdtset = 1;
-
- if ((error = HYPERVISOR_set_trap_table(trap_table)) != 0) {
- panic("set_trap_table failed - error %d\n", error);
- }
-
- error = HYPERVISOR_callback_op(CALLBACKOP_register, &event);
- if (error == 0)
- error = HYPERVISOR_callback_op(CALLBACKOP_register, &failsafe);
-#if CONFIG_XEN_COMPAT <= 0x030002
- if (error == -ENOXENSYS)
- HYPERVISOR_set_callbacks(GSEL(GCODE_SEL, SEL_KPL),
- (unsigned long)Xhypervisor_callback,
- GSEL(GCODE_SEL, SEL_KPL), (unsigned long)failsafe_callback);
-#endif
- pcpu_init(pc, 0, sizeof(struct pcpu));
- for (pa = first; pa < first + DPCPU_SIZE; pa += PAGE_SIZE)
- pmap_kenter(pa + KERNBASE, pa);
- dpcpu_init((void *)(first + KERNBASE), 0);
- first += DPCPU_SIZE;
- physfree += DPCPU_SIZE;
- init_first += DPCPU_SIZE / PAGE_SIZE;
-
- PCPU_SET(prvspace, pc);
- PCPU_SET(curthread, &thread0);
-
- /*
- * Initialize mutexes.
- *
- * icu_lock: in order to allow an interrupt to occur in a critical
- * section, to set pcpu->ipending (etc...) properly, we
- * must be able to get the icu lock, so it can't be
- * under witness.
- */
- mutex_init();
- mtx_init(&icu_lock, "icu", NULL, MTX_SPIN | MTX_NOWITNESS | MTX_NOPROFILE);
-
- /* make ldt memory segments */
- PT_SET_MA(ldt, xpmap_ptom(VTOP(ldt)) | PG_V | PG_RW);
- bzero(ldt, PAGE_SIZE);
- ldt_segs[LUCODE_SEL].ssd_limit = atop(0 - 1);
- ldt_segs[LUDATA_SEL].ssd_limit = atop(0 - 1);
- for (x = 0; x < sizeof ldt_segs / sizeof ldt_segs[0]; x++)
- ssdtosd(&ldt_segs[x], &ldt[x].sd);
-
- default_proc_ldt.ldt_base = (caddr_t)ldt;
- default_proc_ldt.ldt_len = 6;
- _default_ldt = (int)&default_proc_ldt;
- PCPU_SET(currentldt, _default_ldt);
- PT_SET_MA(ldt, *vtopte((unsigned long)ldt) & ~PG_RW);
- xen_set_ldt((unsigned long) ldt, (sizeof ldt_segs / sizeof ldt_segs[0]));
-
-#if defined(XEN_PRIVILEGED)
- /*
- * Initialize the i8254 before the console so that console
- * initialization can use DELAY().
- */
- i8254_init();
-#endif
-
- /*
- * Initialize the console before we print anything out.
- */
- cninit();
-
- if (metadata_missing)
- printf("WARNING: loader(8) metadata is missing!\n");
-
-#ifdef DEV_ISA
-#ifdef DEV_ATPIC
- elcr_probe();
- atpic_startup();
-#else
- /* Reset and mask the atpics and leave them shut down. */
- atpic_reset();
-
- /*
- * Point the ICU spurious interrupt vectors at the APIC spurious
- * interrupt handler.
- */
- setidt(IDT_IO_INTS + 7, IDTVEC(spuriousint), SDT_SYS386IGT, SEL_KPL,
- GSEL(GCODE_SEL, SEL_KPL));
- setidt(IDT_IO_INTS + 15, IDTVEC(spuriousint), SDT_SYS386IGT, SEL_KPL,
- GSEL(GCODE_SEL, SEL_KPL));
-#endif
-#endif
-
-#ifdef DDB
- db_fetch_ksymtab(bootinfo.bi_symtab, bootinfo.bi_esymtab);
-#endif
-
- kdb_init();
-
-#ifdef KDB
- if (boothowto & RB_KDB)
- kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger");
-#endif
-
- finishidentcpu(); /* Final stage of CPU initialization */
- setidt(IDT_UD, &IDTVEC(ill), SDT_SYS386TGT, SEL_KPL,
- GSEL(GCODE_SEL, SEL_KPL));
- setidt(IDT_GP, &IDTVEC(prot), SDT_SYS386TGT, SEL_KPL,
- GSEL(GCODE_SEL, SEL_KPL));
- initializecpu(); /* Initialize CPU registers */
- initializecpucache();
-
- /* pointer to selector slot for %fs/%gs */
- PCPU_SET(fsgs_gdt, &gdt[GUFS_SEL].sd);
-
- 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);
-#if defined(PAE) || defined(PAE_TABLES)
- dblfault_tss.tss_cr3 = (int)IdlePDPT;
-#else
- dblfault_tss.tss_cr3 = (int)IdlePTD;
-#endif
- 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);
- init_param2(physmem);
-
- /* now running on new page tables, configured,and u/iom is accessible */
-
- msgbufinit(msgbufp, msgbufsize);
-#ifdef DEV_NPX
- npxinit(true);
-#endif
- /*
- * Set up thread0 pcb after npxinit calculated pcb + fpu save
- * area size. Zero out the extended state header in fpu save
- * area.
- */
- thread0.td_pcb = get_pcb_td(&thread0);
- bzero(get_pcb_user_save_td(&thread0), cpu_max_ext_state_size);
-#ifdef CPU_ENABLE_SSE
- if (use_xsave) {
- xhdr = (struct xstate_hdr *)(get_pcb_user_save_td(&thread0) +
- 1);
- xhdr->xstate_bv = xsave_mask;
- }
-#endif
- PCPU_SET(curpcb, thread0.td_pcb);
- /* make an initial tss so cpu can get interrupt stack on syscall! */
- /* Note: -16 is so we can grow the trapframe if we came from vm86 */
- PCPU_SET(common_tss.tss_esp0, (vm_offset_t)thread0.td_pcb - 16);
- PCPU_SET(common_tss.tss_ss0, GSEL(GDATA_SEL, SEL_KPL));
- gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
- HYPERVISOR_stack_switch(GSEL(GDATA_SEL, SEL_KPL),
- PCPU_GET(common_tss.tss_esp0));
-
- /* transfer to user mode */
-
- _ucodesel = GSEL(GUCODE_SEL, SEL_UPL);
- _udatasel = GSEL(GUDATA_SEL, SEL_UPL);
-
- /* setup proc 0's pcb */
- thread0.td_pcb->pcb_flags = 0;
-#if defined(PAE) || defined(PAE_TABLES)
- thread0.td_pcb->pcb_cr3 = (int)IdlePDPT;
-#else
- thread0.td_pcb->pcb_cr3 = (int)IdlePTD;
-#endif
- thread0.td_pcb->pcb_ext = 0;
- thread0.td_frame = &proc0_tf;
- thread0.td_pcb->pcb_fsd = PCPU_GET(fsgs_gdt)[0];
- thread0.td_pcb->pcb_gsd = PCPU_GET(fsgs_gdt)[1];
-
- cpu_probe_amdc1e();
-
- /* Location of kernel stack for locore */
- return ((register_t)thread0.td_pcb);
-}
-
-#else
register_t
init386(first)
int first;
@@ -3061,7 +2748,6 @@ init386(first)
/* Location of kernel stack for locore */
return ((register_t)thread0.td_pcb);
}
-#endif
void
cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t size)
diff --git a/sys/i386/i386/minidump_machdep.c b/sys/i386/i386/minidump_machdep.c
index a7d2a69..8f78abc 100644
--- a/sys/i386/i386/minidump_machdep.c
+++ b/sys/i386/i386/minidump_machdep.c
@@ -68,10 +68,6 @@ static void *dump_va;
static uint64_t counter, progress;
CTASSERT(sizeof(*vm_page_dump) == 4);
-#ifndef XEN
-#define xpmap_mtop(x) (x)
-#define xpmap_ptom(x) (x)
-#endif
static int
@@ -205,7 +201,7 @@ minidumpsys(struct dumperinfo *di)
j = va >> PDRSHIFT;
if ((pd[j] & (PG_PS | PG_V)) == (PG_PS | PG_V)) {
/* This is an entire 2M page. */
- pa = xpmap_mtop(pd[j] & PG_PS_FRAME);
+ pa = pd[j] & PG_PS_FRAME;
for (k = 0; k < NPTEPG; k++) {
if (is_dumpable(pa))
dump_add_page(pa);
@@ -215,10 +211,10 @@ minidumpsys(struct dumperinfo *di)
}
if ((pd[j] & PG_V) == PG_V) {
/* set bit for each valid page in this 2MB block */
- pt = pmap_kenter_temporary(xpmap_mtop(pd[j] & PG_FRAME), 0);
+ pt = pmap_kenter_temporary(pd[j] & PG_FRAME, 0);
for (k = 0; k < NPTEPG; k++) {
if ((pt[k] & PG_V) == PG_V) {
- pa = xpmap_mtop(pt[k] & PG_FRAME);
+ pa = pt[k] & PG_FRAME;
if (is_dumpable(pa))
dump_add_page(pa);
}
@@ -318,24 +314,8 @@ minidumpsys(struct dumperinfo *di)
continue;
}
if ((pd[j] & PG_V) == PG_V) {
- pa = xpmap_mtop(pd[j] & PG_FRAME);
-#ifndef XEN
+ pa = pd[j] & PG_FRAME;
error = blk_write(di, 0, pa, PAGE_SIZE);
-#else
- pt = pmap_kenter_temporary(pa, 0);
- memcpy(fakept, pt, PAGE_SIZE);
- for (i = 0; i < NPTEPG; i++)
- fakept[i] = xpmap_mtop(fakept[i]);
- error = blk_write(di, (char *)&fakept, 0, PAGE_SIZE);
- if (error)
- goto fail;
- /* flush, in case we reuse fakept in the same block */
- error = blk_flush(di);
- if (error)
- goto fail;
- bzero(fakept, sizeof(fakept));
-#endif
-
if (error)
goto fail;
} else {
diff --git a/sys/i386/i386/mp_watchdog.c b/sys/i386/i386/mp_watchdog.c
index b03d261..f6b853a 100644
--- a/sys/i386/i386/mp_watchdog.c
+++ b/sys/i386/i386/mp_watchdog.c
@@ -85,7 +85,7 @@ static void
watchdog_init(void *arg)
{
- callout_init(&watchdog_callout, CALLOUT_MPSAFE);
+ callout_init(&watchdog_callout, 1);
if (watchdog_cpu != -1)
watchdog_change(watchdog_cpu);
}
diff --git a/sys/i386/i386/support.s b/sys/i386/i386/support.s
index 0a08012..78d76ef 100644
--- a/sys/i386/i386/support.s
+++ b/sys/i386/i386/support.s
@@ -695,11 +695,9 @@ END(bcmp)
*/
/* void lgdt(struct region_descriptor *rdp); */
ENTRY(lgdt)
-#ifndef XEN
/* reload the descriptor table */
movl 4(%esp),%eax
lgdt (%eax)
-#endif
/* flush the prefetch q */
jmp 1f
diff --git a/sys/i386/i386/swtch.s b/sys/i386/i386/swtch.s
index 26bfd3b..6bedb48 100644
--- a/sys/i386/i386/swtch.s
+++ b/sys/i386/i386/swtch.s
@@ -88,7 +88,7 @@ ENTRY(cpu_throw)
movl 8(%esp),%ecx /* New thread */
movl TD_PCB(%ecx),%edx
movl PCB_CR3(%edx),%eax
- LOAD_CR3(%eax)
+ movl %eax,%cr3
/* set bit in new pm_active */
movl TD_PROC(%ecx),%eax
movl P_VMSPACE(%eax), %ebx
@@ -174,10 +174,10 @@ ENTRY(cpu_switch)
/* switch address space */
movl PCB_CR3(%edx),%eax
- READ_CR3(%ebx) /* The same address space? */
+ movl %cr3,%ebx /* The same address space? */
cmpl %ebx,%eax
je sw0
- LOAD_CR3(%eax) /* new address space */
+ movl %eax,%cr3 /* new address space */
movl %esi,%eax
movl PCPU(CPUID),%esi
SETOP %eax,TD_LOCK(%edi) /* Switchout td_lock */
@@ -204,18 +204,6 @@ sw0:
SETOP %esi,TD_LOCK(%edi) /* Switchout td_lock */
sw1:
BLOCK_SPIN(%ecx)
-#ifdef XEN
- pushl %eax
- pushl %ecx
- pushl %edx
- call xen_handle_thread_switch
- popl %edx
- popl %ecx
- popl %eax
- /*
- * XXX set IOPL
- */
-#else
/*
* At this point, we've switched address spaces and are ready
* to load up the rest of the next context.
@@ -264,7 +252,7 @@ sw1:
movl 12(%esi), %ebx
movl %eax, 8(%edi)
movl %ebx, 12(%edi)
-#endif
+
/* Restore context. */
movl PCB_EBX(%edx),%ebx
movl PCB_ESP(%edx),%esp
@@ -290,7 +278,7 @@ sw1:
movl _default_ldt,%eax
cmpl PCPU(CURRENTLDT),%eax
je 2f
- LLDT(_default_ldt)
+ lldt _default_ldt
movl %eax,PCPU(CURRENTLDT)
jmp 2f
1:
diff --git a/sys/i386/i386/sys_machdep.c b/sys/i386/i386/sys_machdep.c
index 9518862..9044d19 100644
--- a/sys/i386/i386/sys_machdep.c
+++ b/sys/i386/i386/sys_machdep.c
@@ -59,20 +59,6 @@ __FBSDID("$FreeBSD$");
#include <security/audit/audit.h>
-#ifdef XEN
-#include <machine/xen/xenfunc.h>
-
-void i386_reset_ldt(struct proc_ldt *pldt);
-
-void
-i386_reset_ldt(struct proc_ldt *pldt)
-{
- xen_set_ldt((vm_offset_t)pldt->ldt_base, pldt->ldt_len);
-}
-#else
-#define i386_reset_ldt(x)
-#endif
-
#include <vm/vm_kern.h> /* for kernel_map */
#define MAX_LD 8192
@@ -211,12 +197,7 @@ sysarch(td, uap)
*/
sd.sd_lobase = base & 0xffffff;
sd.sd_hibase = (base >> 24) & 0xff;
-#ifdef XEN
- /* need to do nosegneg like Linux */
- sd.sd_lolimit = (HYPERVISOR_VIRT_START >> 12) & 0xffff;
-#else
sd.sd_lolimit = 0xffff; /* 4GB limit, wraps around */
-#endif
sd.sd_hilimit = 0xf;
sd.sd_type = SDT_MEMRWA;
sd.sd_dpl = SEL_UPL;
@@ -226,12 +207,7 @@ sysarch(td, uap)
sd.sd_gran = 1;
critical_enter();
td->td_pcb->pcb_fsd = sd;
-#ifdef XEN
- HYPERVISOR_update_descriptor(vtomach(&PCPU_GET(fsgs_gdt)[0]),
- *(uint64_t *)&sd);
-#else
PCPU_GET(fsgs_gdt)[0] = sd;
-#endif
critical_exit();
td->td_frame->tf_fs = GSEL(GUFS_SEL, SEL_UPL);
}
@@ -252,12 +228,7 @@ sysarch(td, uap)
sd.sd_lobase = base & 0xffffff;
sd.sd_hibase = (base >> 24) & 0xff;
-#ifdef XEN
- /* need to do nosegneg like Linux */
- sd.sd_lolimit = (HYPERVISOR_VIRT_START >> 12) & 0xffff;
-#else
sd.sd_lolimit = 0xffff; /* 4GB limit, wraps around */
-#endif
sd.sd_hilimit = 0xf;
sd.sd_type = SDT_MEMRWA;
sd.sd_dpl = SEL_UPL;
@@ -267,12 +238,7 @@ sysarch(td, uap)
sd.sd_gran = 1;
critical_enter();
td->td_pcb->pcb_gsd = sd;
-#ifdef XEN
- HYPERVISOR_update_descriptor(vtomach(&PCPU_GET(fsgs_gdt)[1]),
- *(uint64_t *)&sd);
-#else
PCPU_GET(fsgs_gdt)[1] = sd;
-#endif
critical_exit();
load_gs(GSEL(GUGS_SEL, SEL_UPL));
}
@@ -434,10 +400,6 @@ set_user_ldt(struct mdproc *mdp)
}
pldt = mdp->md_ldt;
-#ifdef XEN
- i386_reset_ldt(pldt);
- PCPU_SET(currentldt, (int)pldt);
-#else
#ifdef SMP
gdt[PCPU_GET(cpuid) * NGDT + GUSERLDT_SEL].sd = pldt->ldt_sd;
#else
@@ -445,7 +407,6 @@ set_user_ldt(struct mdproc *mdp)
#endif
lldt(GSEL(GUSERLDT_SEL, SEL_KPL));
PCPU_SET(currentldt, GSEL(GUSERLDT_SEL, SEL_KPL));
-#endif /* XEN */
if (dtlocked)
mtx_unlock_spin(&dt_lock);
}
@@ -464,43 +425,6 @@ set_user_ldt_rv(struct vmspace *vmsp)
}
#endif
-#ifdef XEN
-
-/*
- * dt_lock must be held. Returns with dt_lock held.
- */
-struct proc_ldt *
-user_ldt_alloc(struct mdproc *mdp, int len)
-{
- struct proc_ldt *pldt, *new_ldt;
-
- mtx_assert(&dt_lock, MA_OWNED);
- mtx_unlock_spin(&dt_lock);
- new_ldt = malloc(sizeof(struct proc_ldt),
- M_SUBPROC, M_WAITOK);
-
- new_ldt->ldt_len = len = NEW_MAX_LD(len);
- new_ldt->ldt_base = (caddr_t)kmem_malloc(kernel_arena,
- round_page(len * sizeof(union descriptor)), M_WAITOK);
- new_ldt->ldt_refcnt = 1;
- new_ldt->ldt_active = 0;
-
- mtx_lock_spin(&dt_lock);
- if ((pldt = mdp->md_ldt)) {
- if (len > pldt->ldt_len)
- len = pldt->ldt_len;
- bcopy(pldt->ldt_base, new_ldt->ldt_base,
- len * sizeof(union descriptor));
- } else {
- bcopy(ldt, new_ldt->ldt_base, PAGE_SIZE);
- }
- mtx_unlock_spin(&dt_lock); /* XXX kill once pmap locking fixed. */
- pmap_map_readonly(kernel_pmap, (vm_offset_t)new_ldt->ldt_base,
- new_ldt->ldt_len*sizeof(union descriptor));
- mtx_lock_spin(&dt_lock); /* XXX kill once pmap locking fixed. */
- return (new_ldt);
-}
-#else
/*
* dt_lock must be held. Returns with dt_lock held.
*/
@@ -535,7 +459,6 @@ user_ldt_alloc(struct mdproc *mdp, int len)
return (new_ldt);
}
-#endif /* !XEN */
/*
* Must be called with dt_lock held. Returns with dt_lock unheld.
@@ -553,13 +476,8 @@ user_ldt_free(struct thread *td)
}
if (td == curthread) {
-#ifdef XEN
- i386_reset_ldt(&default_proc_ldt);
- PCPU_SET(currentldt, (int)&default_proc_ldt);
-#else
lldt(_default_ldt);
PCPU_SET(currentldt, _default_ldt);
-#endif
}
mdp->md_ldt = NULL;
@@ -785,27 +703,7 @@ again:
td->td_retval[0] = uap->start;
return (error);
}
-#ifdef XEN
-static int
-i386_set_ldt_data(struct thread *td, int start, int num,
- union descriptor *descs)
-{
- struct mdproc *mdp = &td->td_proc->p_md;
- struct proc_ldt *pldt = mdp->md_ldt;
- mtx_assert(&dt_lock, MA_OWNED);
-
- while (num) {
- xen_update_descriptor(
- &((union descriptor *)(pldt->ldt_base))[start],
- descs);
- num--;
- start++;
- descs++;
- }
- return (0);
-}
-#else
static int
i386_set_ldt_data(struct thread *td, int start, int num,
union descriptor *descs)
@@ -821,7 +719,6 @@ i386_set_ldt_data(struct thread *td, int start, int num,
num * sizeof(union descriptor));
return (0);
}
-#endif /* !XEN */
static int
i386_ldt_grow(struct thread *td, int len)
diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c
index 5fd4a16..5671dc9 100644
--- a/sys/i386/i386/vm_machdep.c
+++ b/sys/i386/i386/vm_machdep.c
@@ -89,9 +89,6 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_map.h>
#include <vm/vm_param.h>
-#ifdef XEN
-#include <xen/hypervisor.h>
-#endif
#ifdef PC98
#include <pc98/cbus/cbus.h>
#else
@@ -304,10 +301,8 @@ cpu_fork(td1, p2, td2, flags)
/* Setup to release spin count in fork_exit(). */
td2->td_md.md_spinlock_count = 1;
- /*
- * XXX XEN need to check on PSL_USER is handled
- */
td2->td_md.md_saved_flags = PSL_KERNEL | PSL_I;
+
/*
* Now, cpu_switch() can schedule the new process.
* pcb_esp is loaded pointing to the cpu_switch() stack frame
@@ -698,12 +693,6 @@ cpu_reset_real()
#endif
disable_intr();
-#ifdef XEN
- if (smp_processor_id() == 0)
- HYPERVISOR_shutdown(SHUTDOWN_reboot);
- else
- HYPERVISOR_shutdown(SHUTDOWN_poweroff);
-#endif
#ifdef CPU_ELAN
if (elan_mmcr != NULL)
elan_mmcr->RESCFG = 1;
@@ -797,13 +786,8 @@ sf_buf_map(struct sf_buf *sf, int flags)
*/
ptep = vtopte(sf->kva);
opte = *ptep;
-#ifdef XEN
- PT_SET_MA(sf->kva, xpmap_ptom(VM_PAGE_TO_PHYS(sf->m)) | pgeflag
- | PG_RW | PG_V | pmap_cache_bits(sf->m->md.pat_mode, 0));
-#else
*ptep = VM_PAGE_TO_PHYS(sf->m) | pgeflag | PG_RW | PG_V |
pmap_cache_bits(sf->m->md.pat_mode, 0);
-#endif
/*
* Avoid unnecessary TLB invalidations: If the sf_buf's old
@@ -854,15 +838,8 @@ sf_buf_shootdown(struct sf_buf *sf, int flags)
int
sf_buf_unmap(struct sf_buf *sf)
{
-#ifdef XEN
- /*
- * Xen doesn't like having dangling R/W mappings
- */
- pmap_qremove(sf->kva, 1);
- return (1);
-#else
+
return (0);
-#endif
}
static void
diff --git a/sys/i386/ibcs2/ibcs2_misc.c b/sys/i386/ibcs2/ibcs2_misc.c
index d81cfee..2c2cae4 100644
--- a/sys/i386/ibcs2/ibcs2_misc.c
+++ b/sys/i386/ibcs2/ibcs2_misc.c
@@ -200,15 +200,22 @@ ibcs2_execv(td, uap)
struct ibcs2_execv_args *uap;
{
struct image_args eargs;
+ struct vmspace *oldvmspace;
char *path;
int error;
CHECKALTEXIST(td, uap->path, &path);
+ error = pre_execve(td, &oldvmspace);
+ if (error != 0) {
+ free(path, M_TEMP);
+ return (error);
+ }
error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, uap->argp, NULL);
free(path, M_TEMP);
if (error == 0)
error = kern_execve(td, &eargs, NULL);
+ post_execve(td, error, oldvmspace);
return (error);
}
@@ -218,16 +225,23 @@ ibcs2_execve(td, uap)
struct ibcs2_execve_args *uap;
{
struct image_args eargs;
+ struct vmspace *oldvmspace;
char *path;
int error;
CHECKALTEXIST(td, uap->path, &path);
+ error = pre_execve(td, &oldvmspace);
+ if (error != 0) {
+ free(path, M_TEMP);
+ return (error);
+ }
error = exec_copyin_args(&eargs, path, UIO_SYSSPACE, uap->argp,
uap->envp);
free(path, M_TEMP);
if (error == 0)
error = kern_execve(td, &eargs, NULL);
+ post_execve(td, error, oldvmspace);
return (error);
}
diff --git a/sys/i386/include/asmacros.h b/sys/i386/include/asmacros.h
index c1c3f64..716915c 100644
--- a/sys/i386/include/asmacros.h
+++ b/sys/i386/include/asmacros.h
@@ -176,37 +176,6 @@
movl $KPSEL, %eax ; /* reload with per-CPU data segment */ \
movl %eax, %fs
-#ifdef XEN
-#define LOAD_CR3(reg) \
- movl reg,PCPU(CR3); \
- pushl %ecx ; \
- pushl %edx ; \
- pushl %esi ; \
- pushl reg ; \
- call xen_load_cr3 ; \
- addl $4,%esp ; \
- popl %esi ; \
- popl %edx ; \
- popl %ecx ; \
-
-#define READ_CR3(reg) movl PCPU(CR3),reg;
-#define LLDT(arg) \
- pushl %edx ; \
- pushl %eax ; \
- xorl %eax,%eax ; \
- movl %eax,%gs ; \
- call i386_reset_ldt ; \
- popl %eax ; \
- popl %edx
-#define CLI call ni_cli
-#else
-#define LOAD_CR3(reg) movl reg,%cr3;
-#define READ_CR3(reg) movl %cr3,reg;
-#define LLDT(arg) lldt arg;
-#define CLI cli
-#endif /* !XEN */
-
-
#endif /* LOCORE */
#ifdef __STDC__
diff --git a/sys/i386/include/cpufunc.h b/sys/i386/include/cpufunc.h
index f80a898..3bc25d4 100644
--- a/sys/i386/include/cpufunc.h
+++ b/sys/i386/include/cpufunc.h
@@ -42,17 +42,6 @@
#error this file needs sys/cdefs.h as a prerequisite
#endif
-#ifdef XEN
-extern void xen_cli(void);
-extern void xen_sti(void);
-extern u_int xen_rcr2(void);
-extern void xen_load_cr3(u_int data);
-extern void xen_tlb_flush(void);
-extern void xen_invlpg(u_int addr);
-extern void write_eflags(u_int eflags);
-extern u_int read_eflags(void);
-#endif
-
struct region_descriptor;
#define readb(va) (*(volatile uint8_t *) (va))
@@ -106,11 +95,8 @@ clts(void)
static __inline void
disable_intr(void)
{
-#ifdef XEN
- xen_cli();
-#else
+
__asm __volatile("cli" : : : "memory");
-#endif
}
static __inline void
@@ -132,11 +118,8 @@ cpuid_count(u_int ax, u_int cx, u_int *p)
static __inline void
enable_intr(void)
{
-#ifdef XEN
- xen_sti();
-#else
+
__asm __volatile("sti");
-#endif
}
static __inline void
@@ -325,11 +308,7 @@ ia32_pause(void)
}
static __inline u_int
-#ifdef XEN
-_read_eflags(void)
-#else
read_eflags(void)
-#endif
{
u_int ef;
@@ -389,11 +368,7 @@ wbinvd(void)
}
static __inline void
-#ifdef XEN
-_write_eflags(u_int ef)
-#else
write_eflags(u_int ef)
-#endif
{
__asm __volatile("pushl %0; popfl" : : "r" (ef));
}
@@ -425,9 +400,6 @@ rcr2(void)
{
u_int data;
-#ifdef XEN
- return (xen_rcr2());
-#endif
__asm __volatile("movl %%cr2,%0" : "=r" (data));
return (data);
}
@@ -435,11 +407,8 @@ rcr2(void)
static __inline void
load_cr3(u_int data)
{
-#ifdef XEN
- xen_load_cr3(data);
-#else
+
__asm __volatile("movl %0,%%cr3" : : "r" (data) : "memory");
-#endif
}
static __inline u_int
@@ -491,11 +460,8 @@ load_xcr(u_int reg, uint64_t val)
static __inline void
invltlb(void)
{
-#ifdef XEN
- xen_tlb_flush();
-#else
+
load_cr3(rcr3());
-#endif
}
/*
@@ -506,11 +472,7 @@ static __inline void
invlpg(u_int addr)
{
-#ifdef XEN
- xen_invlpg(addr);
-#else
__asm __volatile("invlpg %0" : : "m" (*(char *)addr) : "memory");
-#endif
}
static __inline u_short
diff --git a/sys/i386/include/intr_machdep.h b/sys/i386/include/intr_machdep.h
index 082b649..96ac06a 100644
--- a/sys/i386/include/intr_machdep.h
+++ b/sys/i386/include/intr_machdep.h
@@ -58,13 +58,7 @@
(FIRST_MSI_INT + NUM_MSI_INTS)
#define LAST_EVTCHN_INT \
(FIRST_EVTCHN_INT + NUM_EVTCHN_INTS - 1)
-#elif defined(XEN)
-#include <xen/xen-os.h>
-#define NUM_EVTCHN_INTS NR_EVENT_CHANNELS
-#define FIRST_EVTCHN_INT 0
-#define LAST_EVTCHN_INT \
- (FIRST_EVTCHN_INT + NUM_EVTCHN_INTS - 1)
-#else /* !XEN && !XENHVM */
+#else /* !XENHVM */
#define NUM_EVTCHN_INTS 0
#endif
#define NUM_IO_INTS (FIRST_MSI_INT + NUM_MSI_INTS + NUM_EVTCHN_INTS)
diff --git a/sys/i386/include/md_var.h b/sys/i386/include/md_var.h
index bffdd57..b5bd35e 100644
--- a/sys/i386/include/md_var.h
+++ b/sys/i386/include/md_var.h
@@ -97,6 +97,7 @@ struct dumperinfo;
void *alloc_fpusave(int flags);
void bcopyb(const void *from, void *to, size_t len);
void busdma_swi(void);
+bool cpu_mwait_usable(void);
void cpu_probe_amdc1e(void);
void cpu_setregs(void);
void cpu_switch_load_gs(void) __asm(__STRING(cpu_switch_load_gs));
diff --git a/sys/i386/include/pcpu.h b/sys/i386/include/pcpu.h
index dc29b6d..231f80f 100644
--- a/sys/i386/include/pcpu.h
+++ b/sys/i386/include/pcpu.h
@@ -44,34 +44,6 @@
* other processors"
*/
-#if defined(XEN)
-
-/* These are peridically updated in shared_info, and then copied here. */
-struct shadow_time_info {
- uint64_t tsc_timestamp; /* TSC at last update of time vals. */
- uint64_t system_timestamp; /* Time, in nanosecs, since boot. */
- uint32_t tsc_to_nsec_mul;
- uint32_t tsc_to_usec_mul;
- int tsc_shift;
- uint32_t version;
-};
-
-#define PCPU_XEN_FIELDS \
- ; \
- u_int pc_cr3; /* track cr3 for R1/R3*/ \
- vm_paddr_t *pc_pdir_shadow; \
- uint64_t pc_processed_system_time; \
- struct shadow_time_info pc_shadow_time; \
- char __pad[185]
-
-#else /* !XEN */
-
-#define PCPU_XEN_FIELDS \
- ; \
- char __pad[233]
-
-#endif
-
#define PCPU_MD_FIELDS \
char pc_monitorbuf[128] __aligned(128); /* cache line */ \
struct pcpu *pc_prvspace; /* Self-reference */ \
@@ -85,8 +57,8 @@ struct shadow_time_info {
u_int pc_apic_id; \
int pc_private_tss; /* Flag indicating private tss*/\
u_int pc_cmci_mask; /* MCx banks for CMCI */ \
- u_int pc_vcpu_id /* Xen vCPU ID */ \
- PCPU_XEN_FIELDS
+ u_int pc_vcpu_id; /* Xen vCPU ID */ \
+ char __pad[233]
#ifdef _KERNEL
diff --git a/sys/i386/include/pmap.h b/sys/i386/include/pmap.h
index 0d8057f..76822b1 100644
--- a/sys/i386/include/pmap.h
+++ b/sys/i386/include/pmap.h
@@ -219,76 +219,6 @@ extern pd_entry_t *IdlePTD; /* physical address of "Idle" state directory */
*/
#define vtophys(va) pmap_kextract((vm_offset_t)(va))
-#if defined(XEN)
-#include <sys/param.h>
-
-#include <xen/xen-os.h>
-
-#include <machine/xen/xenvar.h>
-#include <machine/xen/xenpmap.h>
-
-extern pt_entry_t pg_nx;
-
-#define PG_KERNEL (PG_V | PG_A | PG_RW | PG_M)
-
-#define MACH_TO_VM_PAGE(ma) PHYS_TO_VM_PAGE(xpmap_mtop((ma)))
-#define VM_PAGE_TO_MACH(m) xpmap_ptom(VM_PAGE_TO_PHYS((m)))
-
-#define VTOM(va) xpmap_ptom(VTOP(va))
-
-static __inline vm_paddr_t
-pmap_kextract_ma(vm_offset_t va)
-{
- vm_paddr_t ma;
- if ((ma = PTD[va >> PDRSHIFT]) & PG_PS) {
- ma = (ma & ~(NBPDR - 1)) | (va & (NBPDR - 1));
- } else {
- ma = (*vtopte(va) & PG_FRAME) | (va & PAGE_MASK);
- }
- return ma;
-}
-
-static __inline vm_paddr_t
-pmap_kextract(vm_offset_t va)
-{
- return xpmap_mtop(pmap_kextract_ma(va));
-}
-#define vtomach(va) pmap_kextract_ma(((vm_offset_t) (va)))
-
-vm_paddr_t pmap_extract_ma(struct pmap *pmap, vm_offset_t va);
-
-void pmap_kenter_ma(vm_offset_t va, vm_paddr_t pa);
-void pmap_map_readonly(struct pmap *pmap, vm_offset_t va, int len);
-void pmap_map_readwrite(struct pmap *pmap, vm_offset_t va, int len);
-
-static __inline pt_entry_t
-pte_load_store(pt_entry_t *ptep, pt_entry_t v)
-{
- pt_entry_t r;
-
- r = *ptep;
- PT_SET_VA(ptep, v, TRUE);
- return (r);
-}
-
-static __inline pt_entry_t
-pte_load_store_ma(pt_entry_t *ptep, pt_entry_t v)
-{
- pt_entry_t r;
-
- r = *ptep;
- PT_SET_VA_MA(ptep, v, TRUE);
- return (r);
-}
-
-#define pte_load_clear(ptep) pte_load_store((ptep), (pt_entry_t)0ULL)
-
-#define pte_store(ptep, pte) pte_load_store((ptep), (pt_entry_t)pte)
-#define pte_store_ma(ptep, pte) pte_load_store_ma((ptep), (pt_entry_t)pte)
-#define pde_store_ma(ptep, pte) pte_load_store_ma((ptep), (pt_entry_t)pte)
-
-#elif !defined(XEN)
-
/*
* KPTmap is a linear mapping of the kernel page table. It differs from the
* recursive mapping in two ways: (1) it only provides access to kernel page
@@ -328,13 +258,8 @@ pmap_kextract(vm_offset_t va)
}
return (pa);
}
-#endif
-
-#if !defined(XEN)
-#define PT_UPDATES_FLUSH()
-#endif
-#if (defined(PAE) || defined(PAE_TABLES)) && !defined(XEN)
+#if (defined(PAE) || defined(PAE_TABLES))
#define pde_cmpset(pdep, old, new) atomic_cmpset_64_i586(pdep, old, new)
#define pte_load_store(ptep, pte) atomic_swap_64_i586(ptep, pte)
@@ -343,7 +268,7 @@ pmap_kextract(vm_offset_t va)
extern pt_entry_t pg_nx;
-#elif !defined(PAE) && !defined(PAE_TABLES) && !defined(XEN)
+#else /* !(PAE || PAE_TABLES) */
#define pde_cmpset(pdep, old, new) atomic_cmpset_int(pdep, old, new)
#define pte_load_store(ptep, pte) atomic_swap_int(ptep, pte)
@@ -352,7 +277,7 @@ extern pt_entry_t pg_nx;
*(u_int *)(ptep) = (u_int)(pte); \
} while (0)
-#endif /* PAE */
+#endif /* !(PAE || PAE_TABLES) */
#define pte_clear(ptep) pte_store(ptep, 0)
diff --git a/sys/i386/include/segments.h b/sys/i386/include/segments.h
index d67f2e0..635dffc 100644
--- a/sys/i386/include/segments.h
+++ b/sys/i386/include/segments.h
@@ -82,14 +82,8 @@ struct region_descriptor {
#ifdef _KERNEL
extern int _default_ldt;
-#ifdef XEN
-extern struct proc_ldt default_proc_ldt;
-extern union descriptor *gdt;
-extern union descriptor *ldt;
-#else
extern union descriptor gdt[];
extern union descriptor ldt[NLDT];
-#endif
extern struct soft_segment_descriptor gdt_segs[];
extern struct gate_descriptor *idt;
extern struct region_descriptor r_gdt, r_idt;
diff --git a/sys/i386/include/smp.h b/sys/i386/include/smp.h
index 71f3121..71c830e 100644
--- a/sys/i386/include/smp.h
+++ b/sys/i386/include/smp.h
@@ -90,9 +90,7 @@ inthand_t
void assign_cpu_ids(void);
void cpu_add(u_int apic_id, char boot_cpu);
void cpustop_handler(void);
-#ifndef XEN
void cpususpend_handler(void);
-#endif
void init_secondary_tail(void);
void invltlb_handler(void);
void invlpg_handler(void);
@@ -101,9 +99,7 @@ void invlcache_handler(void);
void init_secondary(void);
void ipi_startup(int apic_id, int vector);
void ipi_all_but_self(u_int ipi);
-#ifndef XEN
void ipi_bitmap_handler(struct trapframe frame);
-#endif
void ipi_cpu(int cpu, u_int ipi);
int ipi_nmi_handler(void);
void ipi_selected(cpuset_t cpus, u_int ipi);
@@ -121,9 +117,6 @@ void mem_range_AP_init(void);
void topo_probe(void);
void ipi_send_cpu(int cpu, u_int ipi);
-#ifdef XEN
-void ipi_to_irq_init(void);
-#endif
#endif /* !LOCORE */
#endif /* SMP */
diff --git a/sys/i386/include/vmparam.h b/sys/i386/include/vmparam.h
index 7775669..cb23b05 100644
--- a/sys/i386/include/vmparam.h
+++ b/sys/i386/include/vmparam.h
@@ -135,11 +135,7 @@
* Kernel physical load address.
*/
#ifndef KERNLOAD
-#if defined(XEN) && !defined(XEN_PRIVILEGED_GUEST)
-#define KERNLOAD 0
-#else
#define KERNLOAD (1 << PDRSHIFT)
-#endif
#endif /* !defined(KERNLOAD) */
/*
@@ -149,11 +145,7 @@
* messy at times, but hey, we'll do anything to save a page :-)
*/
-#ifdef XEN
-#define VM_MAX_KERNEL_ADDRESS HYPERVISOR_VIRT_START
-#else
#define VM_MAX_KERNEL_ADDRESS VADDR(KPTDI+NKPDE-1, NPTEPG-1)
-#endif
#define VM_MIN_KERNEL_ADDRESS VADDR(PTDPTDI, PTDPTDI)
diff --git a/sys/i386/include/xen/features.h b/sys/i386/include/xen/features.h
deleted file mode 100644
index fb4f680..0000000
--- a/sys/i386/include/xen/features.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/******************************************************************************
- * features.h
- *
- * Query the features reported by Xen.
- *
- * Copyright (c) 2006, Ian Campbell
- *
- * $FreeBSD$
- */
-
-#ifndef __ASM_XEN_FEATURES_H__
-#define __ASM_XEN_FEATURES_H__
-
-#include <xen/interface/version.h>
-
-extern void setup_xen_features(void);
-
-extern uint8_t xen_features[XENFEAT_NR_SUBMAPS * 32];
-
-#define xen_feature(flag) (xen_features[flag])
-
-#endif /* __ASM_XEN_FEATURES_H__ */
diff --git a/sys/i386/include/xen/hypercall.h b/sys/i386/include/xen/hypercall.h
index c7e2a00..1c4d529 100644
--- a/sys/i386/include/xen/hypercall.h
+++ b/sys/i386/include/xen/hypercall.h
@@ -246,14 +246,8 @@ HYPERVISOR_memory_op(
return _hypercall2(int, memory_op, cmd, arg);
}
-#if defined(XEN)
-int HYPERVISOR_multicall(multicall_entry_t *, int);
-static inline int
-_HYPERVISOR_multicall(
-#else /* XENHVM */
static inline int
HYPERVISOR_multicall(
-#endif
void *call_list, int nr_calls)
{
return _hypercall2(int, multicall, call_list, nr_calls);
diff --git a/sys/i386/include/xen/xen-os.h b/sys/i386/include/xen/xen-os.h
index 3d1ef04..9b9b63f 100644
--- a/sys/i386/include/xen/xen-os.h
+++ b/sys/i386/include/xen/xen-os.h
@@ -44,105 +44,6 @@ static inline void rep_nop(void)
}
#define cpu_relax() rep_nop()
-#ifndef XENHVM
-
-#ifdef SMP
-extern int gdtset;
-
-#include <sys/time.h> /* XXX for pcpu.h */
-#include <sys/pcpu.h> /* XXX for PCPU_GET */
-static inline int
-smp_processor_id(void)
-{
- if (__predict_true(gdtset))
- return PCPU_GET(cpuid);
- return 0;
-}
-
-#else
-#define smp_processor_id() 0
-#endif
-
-#ifndef PANIC_IF
-#define PANIC_IF(exp) if (__predict_false(exp)) {printf("panic - %s: %s:%d\n",#exp, __FILE__, __LINE__); panic("%s: %s:%d", #exp, __FILE__, __LINE__);}
-#endif
-
-/*
- * Crude memory allocator for memory allocation early in boot.
- */
-void *bootmem_alloc(unsigned int size);
-void bootmem_free(void *ptr, unsigned int size);
-
-/*
- * STI/CLI equivalents. These basically set and clear the virtual
- * event_enable flag in the shared_info structure. Note that when
- * the enable bit is set, there may be pending events to be handled.
- * We may therefore call into do_hypervisor_callback() directly.
- */
-
-#define __cli() \
-do { \
- vcpu_info_t *_vcpu; \
- _vcpu = &HYPERVISOR_shared_info->vcpu_info[smp_processor_id()]; \
- _vcpu->evtchn_upcall_mask = 1; \
- barrier(); \
-} while (0)
-
-#define __sti() \
-do { \
- vcpu_info_t *_vcpu; \
- barrier(); \
- _vcpu = &HYPERVISOR_shared_info->vcpu_info[smp_processor_id()]; \
- _vcpu->evtchn_upcall_mask = 0; \
- barrier(); /* unmask then check (avoid races) */ \
- if (__predict_false(_vcpu->evtchn_upcall_pending)) \
- force_evtchn_callback(); \
-} while (0)
-
-#define __restore_flags(x) \
-do { \
- vcpu_info_t *_vcpu; \
- barrier(); \
- _vcpu = &HYPERVISOR_shared_info->vcpu_info[smp_processor_id()]; \
- if ((_vcpu->evtchn_upcall_mask = (x)) == 0) { \
- barrier(); /* unmask then check (avoid races) */ \
- if (__predict_false(_vcpu->evtchn_upcall_pending)) \
- force_evtchn_callback(); \
- } \
-} while (0)
-
-/*
- * Add critical_{enter, exit}?
- *
- */
-#define __save_and_cli(x) \
-do { \
- vcpu_info_t *_vcpu; \
- _vcpu = &HYPERVISOR_shared_info->vcpu_info[smp_processor_id()]; \
- (x) = _vcpu->evtchn_upcall_mask; \
- _vcpu->evtchn_upcall_mask = 1; \
- barrier(); \
-} while (0)
-
-
-#define cli() __cli()
-#define sti() __sti()
-#define save_flags(x) __save_flags(x)
-#define restore_flags(x) __restore_flags(x)
-#define save_and_cli(x) __save_and_cli(x)
-
-#define local_irq_save(x) __save_and_cli(x)
-#define local_irq_restore(x) __restore_flags(x)
-#define local_irq_disable() __cli()
-#define local_irq_enable() __sti()
-
-#define mtx_lock_irqsave(lock, x) {local_irq_save((x)); mtx_lock_spin((lock));}
-#define mtx_unlock_irqrestore(lock, x) {mtx_unlock_spin((lock)); local_irq_restore((x)); }
-#define spin_lock_irqsave mtx_lock_irqsave
-#define spin_unlock_irqrestore mtx_unlock_irqrestore
-
-#endif /* !XENHVM */
-
/* This is a barrier for the compiler only, NOT the processor! */
#define barrier() __asm__ __volatile__("": : :"memory")
diff --git a/sys/i386/include/xen/xenfunc.h b/sys/i386/include/xen/xenfunc.h
index f02ee12..f48b1f1 100644
--- a/sys/i386/include/xen/xenfunc.h
+++ b/sys/i386/include/xen/xenfunc.h
@@ -34,7 +34,6 @@
#include <vm/pmap.h>
-#include <machine/xen/xenpmap.h>
#include <machine/segments.h>
#include <sys/pcpu.h>
diff --git a/sys/i386/include/xen/xenpmap.h b/sys/i386/include/xen/xenpmap.h
deleted file mode 100644
index 8287e72..0000000
--- a/sys/i386/include/xen/xenpmap.h
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- *
- * Copyright (c) 2004 Christian Limpach.
- * Copyright (c) 2004,2005 Kip Macy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Christian Limpach.
- * 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 _XEN_XENPMAP_H_
-#define _XEN_XENPMAP_H_
-
-#if defined(XEN)
-void _xen_queue_pt_update(vm_paddr_t, vm_paddr_t, char *, int);
-void xen_pt_switch(vm_paddr_t);
-void xen_set_ldt(vm_paddr_t, unsigned long);
-void xen_pgdpt_pin(vm_paddr_t);
-void xen_pgd_pin(vm_paddr_t);
-void xen_pgd_unpin(vm_paddr_t);
-void xen_pt_pin(vm_paddr_t);
-void xen_pt_unpin(vm_paddr_t);
-void xen_flush_queue(void);
-void pmap_ref(pt_entry_t *pte, vm_paddr_t ma);
-void pmap_suspend(void);
-void pmap_resume(void);
-void xen_check_queue(void);
-
-#ifdef INVARIANTS
-#define xen_queue_pt_update(a, b) _xen_queue_pt_update((a), (b), __FILE__, __LINE__)
-#else
-#define xen_queue_pt_update(a, b) _xen_queue_pt_update((a), (b), NULL, 0)
-#endif
-
-
-#include <sys/param.h>
-#include <sys/pcpu.h>
-
-#ifdef PMAP_DEBUG
-#define PMAP_REF pmap_ref
-#define PMAP_DEC_REF_PAGE pmap_dec_ref_page
-#define PMAP_MARK_PRIV pmap_mark_privileged
-#define PMAP_MARK_UNPRIV pmap_mark_unprivileged
-#else
-#define PMAP_MARK_PRIV(a)
-#define PMAP_MARK_UNPRIV(a)
-#define PMAP_REF(a, b)
-#define PMAP_DEC_REF_PAGE(a)
-#endif
-
-#define ALWAYS_SYNC 0
-
-#ifdef PT_DEBUG
-#define PT_LOG() printk("WP PT_SET %s:%d\n", __FILE__, __LINE__)
-#else
-#define PT_LOG()
-#endif
-
-#define INVALID_P2M_ENTRY (~0UL)
-
-#define pmap_valid_entry(E) ((E) & PG_V) /* is PDE or PTE valid? */
-
-#define SH_PD_SET_VA 1
-#define SH_PD_SET_VA_MA 2
-#define SH_PD_SET_VA_CLEAR 3
-
-struct pmap;
-void pd_set(struct pmap *pmap, int ptepindex, vm_paddr_t val, int type);
-#ifdef notyet
-static vm_paddr_t
-vptetomachpte(vm_paddr_t *pte)
-{
- vm_offset_t offset, ppte;
- vm_paddr_t pgoffset, retval, *pdir_shadow_ptr;
- int pgindex;
-
- ppte = (vm_offset_t)pte;
- pgoffset = (ppte & PAGE_MASK);
- offset = ppte - (vm_offset_t)PTmap;
- pgindex = ppte >> PDRSHIFT;
-
- pdir_shadow_ptr = (vm_paddr_t *)PCPU_GET(pdir_shadow);
- retval = (pdir_shadow_ptr[pgindex] & ~PAGE_MASK) + pgoffset;
- return (retval);
-}
-#endif
-#define PT_GET(_ptp) \
- (pmap_valid_entry(*(_ptp)) ? xpmap_mtop(*(_ptp)) : (0))
-
-#ifdef WRITABLE_PAGETABLES
-
-#define PT_SET_VA(_ptp,_npte,sync) do { \
- PMAP_REF((_ptp), xpmap_ptom(_npte)); \
- PT_LOG(); \
- *(_ptp) = xpmap_ptom((_npte)); \
-} while (/*CONSTCOND*/0)
-#define PT_SET_VA_MA(_ptp,_npte,sync) do { \
- PMAP_REF((_ptp), (_npte)); \
- PT_LOG(); \
- *(_ptp) = (_npte); \
-} while (/*CONSTCOND*/0)
-#define PT_CLEAR_VA(_ptp, sync) do { \
- PMAP_REF((pt_entry_t *)(_ptp), 0); \
- PT_LOG(); \
- *(_ptp) = 0; \
-} while (/*CONSTCOND*/0)
-
-#define PD_SET_VA(_pmap, _ptp, _npte, sync) do { \
- PMAP_REF((_ptp), xpmap_ptom(_npte)); \
- pd_set((_pmap),(_ptp),(_npte), SH_PD_SET_VA); \
- if (sync || ALWAYS_SYNC) xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-#define PD_SET_VA_MA(_pmap, _ptp, _npte, sync) do { \
- PMAP_REF((_ptp), (_npte)); \
- pd_set((_pmap),(_ptp),(_npte), SH_PD_SET_VA_MA); \
- if (sync || ALWAYS_SYNC) xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-#define PD_CLEAR_VA(_pmap, _ptp, sync) do { \
- PMAP_REF((pt_entry_t *)(_ptp), 0); \
- pd_set((_pmap),(_ptp), 0, SH_PD_SET_VA_CLEAR); \
- if (sync || ALWAYS_SYNC) xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-
-#else /* !WRITABLE_PAGETABLES */
-
-#define PT_SET_VA(_ptp,_npte,sync) do { \
- PMAP_REF((_ptp), xpmap_ptom(_npte)); \
- xen_queue_pt_update(vtomach(_ptp), \
- xpmap_ptom(_npte)); \
- if (sync || ALWAYS_SYNC) xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-#define PT_SET_VA_MA(_ptp,_npte,sync) do { \
- PMAP_REF((_ptp), (_npte)); \
- xen_queue_pt_update(vtomach(_ptp), _npte); \
- if (sync || ALWAYS_SYNC) xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-#define PT_CLEAR_VA(_ptp, sync) do { \
- PMAP_REF((pt_entry_t *)(_ptp), 0); \
- xen_queue_pt_update(vtomach(_ptp), 0); \
- if (sync || ALWAYS_SYNC) \
- xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-
-#define PD_SET_VA(_pmap, _ptepindex,_npte,sync) do { \
- PMAP_REF((_ptp), xpmap_ptom(_npte)); \
- pd_set((_pmap),(_ptepindex),(_npte), SH_PD_SET_VA); \
- if (sync || ALWAYS_SYNC) xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-#define PD_SET_VA_MA(_pmap, _ptepindex,_npte,sync) do { \
- PMAP_REF((_ptp), (_npte)); \
- pd_set((_pmap),(_ptepindex),(_npte), SH_PD_SET_VA_MA); \
- if (sync || ALWAYS_SYNC) xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-#define PD_CLEAR_VA(_pmap, _ptepindex, sync) do { \
- PMAP_REF((pt_entry_t *)(_ptp), 0); \
- pd_set((_pmap),(_ptepindex), 0, SH_PD_SET_VA_CLEAR); \
- if (sync || ALWAYS_SYNC) xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-
-#endif
-
-#define PT_SET_MA(_va, _ma) \
-do { \
- PANIC_IF(HYPERVISOR_update_va_mapping(((unsigned long)(_va)),\
- (_ma), \
- UVMF_INVLPG| UVMF_ALL) < 0); \
-} while (/*CONSTCOND*/0)
-
-#define PT_UPDATES_FLUSH() do { \
- xen_flush_queue(); \
-} while (/*CONSTCOND*/0)
-
-static __inline vm_paddr_t
-xpmap_mtop(vm_paddr_t mpa)
-{
- vm_paddr_t tmp = (mpa & PG_FRAME);
-
- return machtophys(tmp) | (mpa & ~PG_FRAME);
-}
-
-static __inline vm_paddr_t
-xpmap_ptom(vm_paddr_t ppa)
-{
- vm_paddr_t tmp = (ppa & PG_FRAME);
-
- return phystomach(tmp) | (ppa & ~PG_FRAME);
-}
-
-static __inline void
-set_phys_to_machine(unsigned long pfn, unsigned long mfn)
-{
-#ifdef notyet
- PANIC_IF(max_mapnr && pfn >= max_mapnr);
-#endif
- if (xen_feature(XENFEAT_auto_translated_physmap)) {
-#ifdef notyet
- PANIC_IF((pfn != mfn && mfn != INVALID_P2M_ENTRY));
-#endif
- return;
- }
- xen_phys_machine[pfn] = mfn;
-}
-
-static __inline int
-phys_to_machine_mapping_valid(unsigned long pfn)
-{
- return xen_phys_machine[pfn] != INVALID_P2M_ENTRY;
-}
-
-#endif /* !XEN */
-
-#endif /* _XEN_XENPMAP_H_ */
diff --git a/sys/i386/include/xen/xenstored.h b/sys/i386/include/xen/xenstored.h
deleted file mode 100644
index e584fa5..0000000
--- a/sys/i386/include/xen/xenstored.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Simple prototyle Xen Store Daemon providing simple tree-like database.
- * Copyright (C) 2005 Rusty Russell IBM Corporation
- *
- * This file may be distributed separately from the Linux kernel, or
- * incorporated into other software packages, subject to the following license:
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this source file (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy, modify,
- * merge, publish, distribute, 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
- * AUTHORS OR 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.
- */
-
-#ifndef _XENSTORED_H
-#define _XENSTORED_H
-
-enum xsd_sockmsg_type
-{
- XS_DEBUG,
- XS_SHUTDOWN,
- XS_DIRECTORY,
- XS_READ,
- XS_GET_PERMS,
- XS_WATCH,
- XS_WATCH_ACK,
- XS_UNWATCH,
- XS_TRANSACTION_START,
- XS_TRANSACTION_END,
- XS_OP_READ_ONLY = XS_TRANSACTION_END,
- XS_INTRODUCE,
- XS_RELEASE,
- XS_GETDOMAINPATH,
- XS_WRITE,
- XS_MKDIR,
- XS_RM,
- XS_SET_PERMS,
- XS_WATCH_EVENT,
- XS_ERROR,
-};
-
-#define XS_WRITE_NONE "NONE"
-#define XS_WRITE_CREATE "CREATE"
-#define XS_WRITE_CREATE_EXCL "CREATE|EXCL"
-
-/* We hand errors as strings, for portability. */
-struct xsd_errors
-{
- int errnum;
- const char *errstring;
-};
-#define XSD_ERROR(x) { x, #x }
-static struct xsd_errors xsd_errors[] __attribute__((unused)) = {
- XSD_ERROR(EINVAL),
- XSD_ERROR(EACCES),
- XSD_ERROR(EEXIST),
- XSD_ERROR(EISDIR),
- XSD_ERROR(ENOENT),
- XSD_ERROR(ENOMEM),
- XSD_ERROR(ENOSPC),
- XSD_ERROR(EIO),
- XSD_ERROR(ENOTEMPTY),
- XSD_ERROR(ENOSYS),
- XSD_ERROR(EROFS),
- XSD_ERROR(EBUSY),
- XSD_ERROR(ETIMEDOUT),
- XSD_ERROR(EISCONN),
-};
-struct xsd_sockmsg
-{
- uint32_t type;
- uint32_t len; /* Length of data following this. */
-
- /* Generally followed by nul-terminated string(s). */
-};
-
-#endif /* _XENSTORED_H */
diff --git a/sys/i386/include/xen/xenvar.h b/sys/i386/include/xen/xenvar.h
index 5694607..484c279 100644
--- a/sys/i386/include/xen/xenvar.h
+++ b/sys/i386/include/xen/xenvar.h
@@ -29,91 +29,8 @@
#ifndef XENVAR_H_
#define XENVAR_H_
-#include <machine/xen/features.h>
-
-#if defined(XEN)
-
-#define XBOOTUP 0x1
-#define XPMAP 0x2
-extern int xendebug_flags;
-#ifndef NOXENDEBUG
-/* Print directly to the Xen console during debugging. */
-#define XENPRINTF xc_printf
-#else
-#define XENPRINTF printf
-#endif
-
-extern xen_pfn_t *xen_phys_machine;
-extern xen_pfn_t *xen_pfn_to_mfn_frame_list[16];
-extern xen_pfn_t *xen_pfn_to_mfn_frame_list_list;
-
-#if 0
-#define TRACE_ENTER XENPRINTF("(file=%s, line=%d) entered %s\n", __FILE__, __LINE__, __FUNCTION__)
-#define TRACE_EXIT XENPRINTF("(file=%s, line=%d) exiting %s\n", __FILE__, __LINE__, __FUNCTION__)
-#define TRACE_DEBUG(argflags, _f, _a...) \
-if (xendebug_flags & argflags) XENPRINTF("(file=%s, line=%d) " _f "\n", __FILE__, __LINE__, ## _a);
-#else
-#define TRACE_ENTER
-#define TRACE_EXIT
-#define TRACE_DEBUG(argflags, _f, _a...)
-#endif
-
-extern xen_pfn_t *xen_machine_phys;
-/* Xen starts physical pages after the 4MB ISA hole -
- * FreeBSD doesn't
- */
-
-
-#undef ADD_ISA_HOLE /* XXX */
-
-#ifdef ADD_ISA_HOLE
-#define ISA_INDEX_OFFSET 1024
-#define ISA_PDR_OFFSET 1
-#else
-#define ISA_INDEX_OFFSET 0
-#define ISA_PDR_OFFSET 0
-#endif
-
-
-#define PFNTOMFN(i) (xen_phys_machine[(i)])
-#define MFNTOPFN(i) ((vm_paddr_t)xen_machine_phys[(i)])
-
-#define VTOP(x) ((((uintptr_t)(x))) - KERNBASE)
-#define PTOV(x) (((uintptr_t)(x)) + KERNBASE)
-
-#define VTOPFN(x) (VTOP(x) >> PAGE_SHIFT)
-#define PFNTOV(x) PTOV((vm_paddr_t)(x) << PAGE_SHIFT)
-
-#define VTOMFN(va) (vtomach(va) >> PAGE_SHIFT)
-#define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
-
-#define phystomach(pa) (((vm_paddr_t)(PFNTOMFN((pa) >> PAGE_SHIFT))) << PAGE_SHIFT)
-#define machtophys(ma) (((vm_paddr_t)(MFNTOPFN((ma) >> PAGE_SHIFT))) << PAGE_SHIFT)
-
-
-void xpq_init(void);
-
-#define BITS_PER_LONG 32
-#define NR_CPUS XEN_LEGACY_MAX_VCPUS
-
-#define BITS_TO_LONGS(bits) \
- (((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
-#define DECLARE_BITMAP(name,bits) \
- unsigned long name[BITS_TO_LONGS(bits)]
-
-int xen_create_contiguous_region(vm_page_t pages, int npages);
-
-void xen_destroy_contiguous_region(void * addr, int npages);
-
-#elif defined(XENHVM)
+#include <xen/features.h>
#define vtomach(va) pmap_kextract((vm_offset_t) (va))
-#define PFNTOMFN(pa) (pa)
-#define MFNTOPFN(ma) (ma)
-
-#define set_phys_to_machine(pfn, mfn) ((void)0)
-#define phys_to_machine_mapping_valid(pfn) (TRUE)
-
-#endif /* !XEN && !XENHVM */
#endif
diff --git a/sys/i386/isa/npx.c b/sys/i386/isa/npx.c
index b0ea4e7..a7113e2 100644
--- a/sys/i386/isa/npx.c
+++ b/sys/i386/isa/npx.c
@@ -69,10 +69,6 @@ __FBSDID("$FreeBSD$");
#include <machine/ucontext.h>
#include <machine/intr_machdep.h>
-#ifdef XEN
-#include <xen/xen-os.h>
-#include <xen/hypervisor.h>
-#endif
#ifdef DEV_ISA
#include <isa/isavar.h>
@@ -157,13 +153,8 @@ void xsaveopt(char *addr, uint64_t mask);
#endif /* __GNUCLIKE_ASM && !lint */
-#ifdef XEN
-#define start_emulating() (HYPERVISOR_fpu_taskswitch(1))
-#define stop_emulating() (HYPERVISOR_fpu_taskswitch(0))
-#else
#define start_emulating() load_cr0(rcr0() | CR0_TS)
#define stop_emulating() clts()
-#endif
#ifdef CPU_ENABLE_SSE
#define GET_FPU_CW(thread) \
diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c
index d9c28d9..effc32a 100644
--- a/sys/i386/linux/linux_machdep.c
+++ b/sys/i386/linux/linux_machdep.c
@@ -126,9 +126,10 @@ bsd_to_linux_sigaltstack(int bsa)
int
linux_execve(struct thread *td, struct linux_execve_args *args)
{
- int error;
- char *newpath;
struct image_args eargs;
+ struct vmspace *oldvmspace;
+ char *newpath;
+ int error;
LCONVPATHEXIST(td, args->path, &newpath);
@@ -137,12 +138,17 @@ linux_execve(struct thread *td, struct linux_execve_args *args)
printf(ARGS(execve, "%s"), newpath);
#endif
+ error = pre_execve(td, &oldvmspace);
+ if (error != 0) {
+ free(newpath, M_TEMP);
+ return (error);
+ }
error = exec_copyin_args(&eargs, newpath, UIO_SYSSPACE,
args->argp, args->envp);
free(newpath, M_TEMP);
if (error == 0)
error = kern_execve(td, &eargs, NULL);
- if (error == 0)
+ if (error == 0) {
/* linux process can exec fbsd one, dont attempt
* to create emuldata for such process using
* linux_proc_init, this leads to a panic on KASSERT
@@ -150,6 +156,8 @@ linux_execve(struct thread *td, struct linux_execve_args *args)
*/
if (SV_PROC_ABI(td->td_proc) == SV_ABI_LINUX)
error = linux_proc_init(td, 0, 0);
+ }
+ post_execve(td, error, oldvmspace);
return (error);
}
diff --git a/sys/i386/pci/pci_cfgreg.c b/sys/i386/pci/pci_cfgreg.c
index 5d57e89..2716a7a 100644
--- a/sys/i386/pci/pci_cfgreg.c
+++ b/sys/i386/pci/pci_cfgreg.c
@@ -93,9 +93,7 @@ static uint32_t pci_docfgregread(int bus, int slot, int func, int reg,
int bytes);
static int pcireg_cfgread(int bus, int slot, int func, int reg, int bytes);
static void pcireg_cfgwrite(int bus, int slot, int func, int reg, int data, int bytes);
-#ifndef XEN
static int pcireg_cfgopen(void);
-#endif
static int pciereg_cfgread(int bus, unsigned slot, unsigned func,
unsigned reg, unsigned bytes);
static void pciereg_cfgwrite(int bus, unsigned slot, unsigned func,
@@ -116,7 +114,6 @@ pci_i386_map_intline(int line)
return (line);
}
-#ifndef XEN
static u_int16_t
pcibios_get_version(void)
{
@@ -137,7 +134,6 @@ pcibios_get_version(void)
}
return (args.ebx & 0xffff);
}
-#endif
/*
* Initialise access to PCI configuration space
@@ -145,9 +141,6 @@ pcibios_get_version(void)
int
pci_cfgregopen(void)
{
-#ifdef XEN
- return (0);
-#else
static int opened = 0;
uint64_t pciebar;
u_int16_t vid, did;
@@ -202,7 +195,6 @@ pci_cfgregopen(void)
}
return(1);
-#endif
}
static uint32_t
@@ -390,7 +382,6 @@ pcireg_cfgwrite(int bus, int slot, int func, int reg, int data, int bytes)
mtx_unlock_spin(&pcicfg_mtx);
}
-#ifndef XEN
/* check whether the configuration mechanism has been correctly identified */
static int
pci_cfgcheck(int maxdev)
@@ -607,7 +598,6 @@ pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus)
return (1);
}
-#endif /* !XEN */
#define PCIE_PADDR(base, reg, bus, slot, func) \
((base) + \
diff --git a/sys/i386/pci/pci_pir.c b/sys/i386/pci/pci_pir.c
index 0d64cab..6aeaae3 100644
--- a/sys/i386/pci/pci_pir.c
+++ b/sys/i386/pci/pci_pir.c
@@ -137,9 +137,6 @@ pci_pir_open(void)
int i;
uint8_t ck, *cv;
-#ifdef XEN
- return;
-#else
/* Don't try if we've already found a table. */
if (pci_route_table != NULL)
return;
@@ -150,7 +147,7 @@ pci_pir_open(void)
sigaddr = bios_sigsearch(0, "_PIR", 4, 16, 0);
if (sigaddr == 0)
return;
-#endif
+
/* If we found something, check the checksum and length. */
/* XXX - Use pmap_mapdev()? */
pt = (struct PIR_table *)(uintptr_t)BIOS_PADDRTOVADDR(sigaddr);
@@ -481,11 +478,7 @@ pci_pir_biosroute(int bus, int device, int func, int pin, int irq)
args.eax = PCIBIOS_ROUTE_INTERRUPT;
args.ebx = (bus << 8) | (device << 3) | func;
args.ecx = (irq << 8) | (0xa + pin);
-#ifdef XEN
- return (0);
-#else
return (bios32(&args, PCIbios.ventry, GSEL(GCODE_SEL, SEL_KPL)));
-#endif
}
diff --git a/sys/i386/xen/clock.c b/sys/i386/xen/clock.c
deleted file mode 100644
index ffb436e..0000000
--- a/sys/i386/xen/clock.c
+++ /dev/null
@@ -1,570 +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
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/* #define DELAYDEBUG */
-/*
- * Routines to handle clock hardware.
- */
-
-#include "opt_ddb.h"
-#include "opt_clock.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/clock.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/proc.h>
-#include <sys/time.h>
-#include <sys/timeet.h>
-#include <sys/timetc.h>
-#include <sys/kernel.h>
-#include <sys/limits.h>
-#include <sys/sysctl.h>
-#include <sys/cons.h>
-#include <sys/power.h>
-
-#include <machine/clock.h>
-#include <machine/cputypes.h>
-#include <machine/frame.h>
-#include <machine/intr_machdep.h>
-#include <machine/md_var.h>
-#include <machine/psl.h>
-#include <machine/pvclock.h>
-#if defined(SMP)
-#include <machine/smp.h>
-#endif
-#include <machine/specialreg.h>
-#include <machine/timerreg.h>
-
-#include <x86/isa/icu.h>
-#include <isa/isareg.h>
-#include <isa/rtc.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <machine/pmap.h>
-#include <xen/hypervisor.h>
-#include <xen/xen-os.h>
-#include <machine/xen/xenfunc.h>
-#include <xen/interface/vcpu.h>
-#include <machine/cpu.h>
-#include <xen/xen_intr.h>
-
-/*
- * 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) (!((y) % 4))
-#define DAYSPERYEAR (28+30*4+31*7)
-
-#ifndef TIMER_FREQ
-#define TIMER_FREQ 1193182
-#endif
-
-#ifdef CYC2NS_SCALE_FACTOR
-#undef CYC2NS_SCALE_FACTOR
-#endif
-#define CYC2NS_SCALE_FACTOR 10
-
-/* Values for timerX_state: */
-#define RELEASED 0
-#define RELEASE_PENDING 1
-#define ACQUIRED 2
-#define ACQUIRE_PENDING 3
-
-struct mtx clock_lock;
-#define RTC_LOCK_INIT \
- mtx_init(&clock_lock, "clk", NULL, MTX_SPIN | MTX_NOPROFILE)
-#define RTC_LOCK mtx_lock_spin(&clock_lock)
-#define RTC_UNLOCK mtx_unlock_spin(&clock_lock)
-#define NS_PER_TICK (1000000000ULL/hz)
-
-int adjkerntz; /* local offset from UTC in seconds */
-int clkintr_pending;
-int pscnt = 1;
-int psdiv = 1;
-int wall_cmos_clock;
-u_int timer_freq = TIMER_FREQ;
-static u_long cyc2ns_scale;
-static uint64_t processed_system_time; /* stime (ns) at last processing. */
-
-#define do_div(n,base) ({ \
- unsigned long __upper, __low, __high, __mod, __base; \
- __base = (base); \
- __asm("":"=a" (__low), "=d" (__high):"A" (n)); \
- __upper = __high; \
- if (__high) { \
- __upper = __high % (__base); \
- __high = __high / (__base); \
- } \
- __asm("divl %2":"=a" (__low), "=d" (__mod):"rm" (__base), "0" (__low), "1" (__upper)); \
- __asm("":"=A" (n):"a" (__low),"d" (__high)); \
- __mod; \
-})
-
-
-/* convert from cycles(64bits) => nanoseconds (64bits)
- * basic equation:
- * ns = cycles / (freq / ns_per_sec)
- * ns = cycles * (ns_per_sec / freq)
- * ns = cycles * (10^9 / (cpu_mhz * 10^6))
- * ns = cycles * (10^3 / cpu_mhz)
- *
- * Then we use scaling math (suggested by george@mvista.com) to get:
- * ns = cycles * (10^3 * SC / cpu_mhz) / SC
- * ns = cycles * cyc2ns_scale / SC
- *
- * And since SC is a constant power of two, we can convert the div
- * into a shift.
- * -johnstul@us.ibm.com "math is hard, lets go shopping!"
- */
-static inline void set_cyc2ns_scale(unsigned long cpu_mhz)
-{
- cyc2ns_scale = (1000 << CYC2NS_SCALE_FACTOR)/cpu_mhz;
-}
-
-static inline unsigned long long cycles_2_ns(unsigned long long cyc)
-{
- return ((cyc * cyc2ns_scale) >> CYC2NS_SCALE_FACTOR);
-}
-
-static uint32_t
-getit(void)
-{
- return (pvclock_get_last_cycles());
-}
-
-
-/*
- * XXX: timer needs more SMP work.
- */
-void
-i8254_init(void)
-{
-
- RTC_LOCK_INIT;
-}
-
-/*
- * 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
-i8254_delay(int n)
-{
- int delta, ticks_left;
- uint32_t tick, prev_tick;
-#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
- /*
- * 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).
- *
- * However, if ddb is active then use a fake counter since reading
- * the i8254 counter involves acquiring a lock. ddb must not go
- * locking for many reasons, but it calls here for at least atkbd
- * input.
- */
- 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 = tick - prev_tick;
- prev_tick = tick;
- if (delta < 0) {
- /*
- * Guard against timer0_max_count being wrong.
- * This shouldn't happen in normal operation,
- * but it may happen if set_timer_freq() is
- * traced.
- */
- /* delta += timer0_max_count; ??? */
- 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
-}
-
-void
-startrtclock()
-{
- uint64_t __cpu_khz;
- uint32_t cpu_khz;
- struct vcpu_time_info *info;
-
- __cpu_khz = 1000000ULL << 32;
- info = &HYPERVISOR_shared_info->vcpu_info[0].time;
-
- (void)do_div(__cpu_khz, info->tsc_to_system_mul);
- if ( info->tsc_shift < 0 )
- cpu_khz = __cpu_khz << -info->tsc_shift;
- else
- cpu_khz = __cpu_khz >> info->tsc_shift;
-
- printf("Xen reported: %u.%03u MHz processor.\n",
- cpu_khz / 1000, cpu_khz % 1000);
-
- /* (10^6 * 2^32) / cpu_hz = (10^3 * 2^32) / cpu_khz =
- (2^32 * 1 / (clocks/us)) */
-
- set_cyc2ns_scale(cpu_khz/1000);
- tsc_freq = cpu_khz * 1000;
-}
-
-/*
- * RTC support routines
- */
-
-
-static __inline int
-readrtc(int port)
-{
- return(bcd2bin(rtcin(port)));
-}
-
-
-#ifdef XEN_PRIVILEGED_GUEST
-
-/*
- * Initialize the time of day register, based on the time base which is, e.g.
- * from a filesystem.
- */
-static void
-domu_inittodr(time_t base)
-{
- unsigned long sec;
- int s, y;
- struct timespec ts;
-
- update_wallclock();
- add_uptime_to_wallclock();
-
- RTC_LOCK;
-
- if (base) {
- ts.tv_sec = base;
- ts.tv_nsec = 0;
- tc_setclock(&ts);
- }
-
- sec += tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-
- y = time_second - shadow_tv.tv_sec;
- if (y <= -2 || y >= 2) {
- /* badly off, adjust it */
- tc_setclock(&shadow_tv);
- }
- RTC_UNLOCK;
-}
-
-/*
- * Write system time back to RTC.
- */
-static void
-domu_resettodr(void)
-{
- unsigned long tm;
- int s;
- dom0_op_t op;
- struct shadow_time_info *shadow;
- struct pcpu *pc;
-
- pc = pcpu_find(smp_processor_id());
- shadow = &pc->pc_shadow_time;
- if (xen_disable_rtc_set)
- return;
-
- s = splclock();
- tm = time_second;
- splx(s);
-
- tm -= tz_minuteswest * 60 + (wall_cmos_clock ? adjkerntz : 0);
-
- if ((xen_start_info->flags & SIF_INITDOMAIN) &&
- !independent_wallclock)
- {
- op.cmd = DOM0_SETTIME;
- op.u.settime.secs = tm;
- op.u.settime.nsecs = 0;
- op.u.settime.system_time = shadow->system_timestamp;
- HYPERVISOR_dom0_op(&op);
- update_wallclock();
- add_uptime_to_wallclock();
- } else if (independent_wallclock) {
- /* notyet */
- ;
- }
-}
-
-/*
- * 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 year, month;
- int y, m, s;
- struct timespec ts;
-
- if (!(xen_start_info->flags & SIF_INITDOMAIN)) {
- domu_inittodr(base);
- return;
- }
-
- if (base) {
- s = splclock();
- ts.tv_sec = base;
- ts.tv_nsec = 0;
- tc_setclock(&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;
- 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_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;
- tc_setclock(&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 (!(xen_start_info->flags & SIF_INITDOMAIN)) {
- domu_resettodr();
- return;
- }
-
- if (xen_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_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 + 1); /* 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, RTCSB_24HR);
- rtcin(RTC_INTR);
-}
-#endif
-
-/*
- * Start clocks running.
- */
-void
-cpu_initclocks(void)
-{
- cpu_initclocks_bsp();
-}
-
-/* Return system time offset by ticks */
-uint64_t
-get_system_time(int ticks)
-{
- return (processed_system_time + (ticks * NS_PER_TICK));
-}
-
-int
-timer_spkr_acquire(void)
-{
-
- return (0);
-}
-
-int
-timer_spkr_release(void)
-{
-
- return (0);
-}
-
-void
-timer_spkr_setfreq(int freq)
-{
-
-}
-
diff --git a/sys/i386/xen/exception.s b/sys/i386/xen/exception.s
deleted file mode 100644
index 95f1c0e..0000000
--- a/sys/i386/xen/exception.s
+++ /dev/null
@@ -1,494 +0,0 @@
-/*-
- * Copyright (c) 1989, 1990 William F. Jolitz.
- * 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.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE 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_apic.h"
-#include "opt_npx.h"
-
-#include <machine/asmacros.h>
-#include <machine/psl.h>
-#include <machine/trap.h>
-
-#include "assym.s"
-
-#define SEL_RPL_MASK 0x0002
-#define __HYPERVISOR_iret 23
-
-/* Offsets into shared_info_t. */
-
-#define evtchn_upcall_pending /* 0 */
-#define evtchn_upcall_mask 1
-
-#define sizeof_vcpu_shift 6
-
-
-#ifdef SMP
-#define GET_VCPU_INFO(reg) movl PCPU(CPUID),reg ; \
- shl $sizeof_vcpu_shift,reg ; \
- addl HYPERVISOR_shared_info,reg
-#else
-#define GET_VCPU_INFO(reg) movl HYPERVISOR_shared_info,reg
-#endif
-
-#define __DISABLE_INTERRUPTS(reg) movb $1,evtchn_upcall_mask(reg)
-#define __ENABLE_INTERRUPTS(reg) movb $0,evtchn_upcall_mask(reg)
-#define DISABLE_INTERRUPTS(reg) GET_VCPU_INFO(reg) ; \
- __DISABLE_INTERRUPTS(reg)
-#define ENABLE_INTERRUPTS(reg) GET_VCPU_INFO(reg) ; \
- __ENABLE_INTERRUPTS(reg)
-#define __TEST_PENDING(reg) testb $0xFF,evtchn_upcall_pending(reg)
-
-#define POPA \
- popl %edi; \
- popl %esi; \
- popl %ebp; \
- popl %ebx; \
- popl %ebx; \
- popl %edx; \
- popl %ecx; \
- popl %eax;
-
- .text
-
-/*****************************************************************************/
-/* Trap handling */
-/*****************************************************************************/
-/*
- * Trap and fault vector routines.
- *
- * Most traps are 'trap gates', SDT_SYS386TGT. A trap gate pushes state on
- * the stack that mostly looks like an interrupt, but does not disable
- * interrupts. A few of the traps we are use are interrupt gates,
- * SDT_SYS386IGT, which are nearly the same thing except interrupts are
- * disabled on entry.
- *
- * The cpu will push a certain amount of state onto the kernel stack for
- * the current process. The amount of state depends on the type of trap
- * and whether the trap crossed rings or not. See i386/include/frame.h.
- * At the very least the current EFLAGS (status register, which includes
- * the interrupt disable state prior to the trap), the code segment register,
- * and the return instruction pointer are pushed by the cpu. The cpu
- * will also push an 'error' code for certain traps. We push a dummy
- * error code for those traps where the cpu doesn't in order to maintain
- * a consistent frame. We also push a contrived 'trap number'.
- *
- * The cpu does not push the general registers, we must do that, and we
- * must restore them prior to calling 'iret'. The cpu adjusts the %cs and
- * %ss segment registers, but does not mess with %ds, %es, or %fs. Thus we
- * must load them with appropriate values for supervisor mode operation.
- */
-
-MCOUNT_LABEL(user)
-MCOUNT_LABEL(btrap)
-
-#define TRAP(a) pushl $(a) ; jmp alltraps
-
-IDTVEC(div)
- pushl $0; TRAP(T_DIVIDE)
-IDTVEC(dbg)
- pushl $0; TRAP(T_TRCTRAP)
-IDTVEC(nmi)
- pushl $0; TRAP(T_NMI)
-IDTVEC(bpt)
- pushl $0; TRAP(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)
- pushl $0; TRAP(T_ARITHTRAP)
-IDTVEC(align)
- TRAP(T_ALIGNFLT)
-IDTVEC(xmm)
- pushl $0; TRAP(T_XMMFLT)
-
-IDTVEC(hypervisor_callback)
- pushl $0;
- pushl $0;
- pushal
- pushl %ds
- pushl %es
- pushl %fs
-upcall_with_regs_pushed:
- SET_KERNEL_SREGS
- FAKE_MCOUNT(TF_EIP(%esp))
-call_evtchn_upcall:
- movl TF_EIP(%esp),%eax
- cmpl $scrit,%eax
- jb 10f
- cmpl $ecrit,%eax
- jb critical_region_fixup
-
-10: pushl %esp
- call xen_intr_handle_upcall
- addl $4,%esp
-
- /*
- * Return via doreti to handle ASTs.
- */
- MEXITCOUNT
- jmp doreti
-
-
-hypervisor_callback_pending:
- DISABLE_INTERRUPTS(%esi) /* cli */
- jmp 10b
- /*
- * alltraps entry point. Interrupts are enabled if this was a trap
- * gate (TGT), else disabled if this was an interrupt gate (IGT).
- * Note that int0x80_syscall is a trap gate. Only page faults
- * use an interrupt gate.
- */
- SUPERALIGN_TEXT
- .globl alltraps
- .type alltraps,@function
-alltraps:
- pushal
- pushl %ds
- pushl %es
- pushl %fs
-
-alltraps_with_regs_pushed:
- SET_KERNEL_SREGS
- FAKE_MCOUNT(TF_EIP(%esp))
-
-calltrap:
- push %esp
- call trap
- add $4, %esp
-
- /*
- * Return via doreti to handle ASTs.
- */
- MEXITCOUNT
- jmp doreti
-
-/*
- * SYSCALL CALL GATE (old entry point for a.out binaries)
- *
- * 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.
- */
- SUPERALIGN_TEXT
-IDTVEC(lcall_syscall)
- pushfl /* save eflags */
- popl 8(%esp) /* shuffle into tf_eflags */
- pushl $7 /* sizeof "lcall 7,0" */
- subl $4,%esp /* skip over tf_trapno */
- pushal
- pushl %ds
- pushl %es
- pushl %fs
- SET_KERNEL_SREGS
- FAKE_MCOUNT(TF_EIP(%esp))
- pushl %esp
- call syscall
- add $4, %esp
- MEXITCOUNT
- jmp doreti
-
-/*
- * Call gate entry for FreeBSD ELF and Linux/NetBSD syscall (int 0x80)
- *
- * Even though the name says 'int0x80', this is actually a TGT (trap gate)
- * rather then an IGT (interrupt gate). Thus interrupts are enabled on
- * entry just as they are for a normal syscall.
- */
- SUPERALIGN_TEXT
-IDTVEC(int0x80_syscall)
- pushl $2 /* sizeof "int 0x80" */
- pushl $0xBEEF /* for debug */
- pushal
- pushl %ds
- pushl %es
- pushl %fs
- SET_KERNEL_SREGS
- FAKE_MCOUNT(TF_EIP(%esp))
- pushl %esp
- call syscall
- add $4, %esp
- MEXITCOUNT
- jmp doreti
-
-ENTRY(fork_trampoline)
- pushl %esp /* trapframe pointer */
- pushl %ebx /* arg1 */
- pushl %esi /* function */
- call fork_exit
- addl $12,%esp
- /* cut from syscall */
-
- /*
- * Return via doreti to handle ASTs.
- */
- MEXITCOUNT
- jmp doreti
-
-
-/*
- * To efficiently implement classification of trap and interrupt handlers
- * for profiling, there must be only trap handlers between the labels btrap
- * and bintr, and only interrupt handlers between the labels bintr and
- * eintr. This is implemented (partly) by including files that contain
- * some of the handlers. Before including the files, set up a normal asm
- * environment so that the included files doen't need to know that they are
- * included.
- */
-
- .data
- .p2align 4
- .text
- SUPERALIGN_TEXT
-MCOUNT_LABEL(bintr)
-
-#ifdef DEV_APIC
- .data
- .p2align 4
- .text
- SUPERALIGN_TEXT
-
-#include <i386/i386/apic_vector.s>
-#endif
-
- .data
- .p2align 4
- .text
- SUPERALIGN_TEXT
-#include <i386/i386/vm86bios.s>
-
- .text
-MCOUNT_LABEL(eintr)
-
-/*
- * void doreti(struct trapframe)
- *
- * Handle return from interrupts, traps and syscalls.
- */
- .text
- SUPERALIGN_TEXT
- .type doreti,@function
-doreti:
- FAKE_MCOUNT($bintr) /* init "from" bintr -> doreti */
-doreti_next:
-#ifdef notyet
- /*
- * Check if ASTs can be handled now. PSL_VM must be checked first
- * since segment registers only have an RPL in non-VM86 mode.
- */
- testl $PSL_VM,TF_EFLAGS(%esp) /* are we in vm86 mode? */
- jz doreti_notvm86
- movl PCPU(CURPCB),%ecx
- testl $PCB_VM86CALL,PCB_FLAGS(%ecx) /* are we in a vm86 call? */
- jz doreti_ast /* can handle ASTS now if not */
- jmp doreti_exit
-
-doreti_notvm86:
-#endif
- testb $SEL_RPL_MASK,TF_CS(%esp) /* are we returning to user mode? */
- jz doreti_exit /* can't handle ASTs now if not */
-
-doreti_ast:
- /*
- * Check for ASTs atomically with returning. Disabling CPU
- * interrupts provides sufficient locking even in the SMP case,
- * since we will be informed of any new ASTs by an IPI.
- */
- DISABLE_INTERRUPTS(%esi) /* cli */
- movl PCPU(CURTHREAD),%eax
- testl $TDF_ASTPENDING | TDF_NEEDRESCHED,TD_FLAGS(%eax)
- je doreti_exit
- ENABLE_INTERRUPTS(%esi) /* sti */
- pushl %esp /* pass a pointer to the trapframe */
- call ast
- add $4,%esp
- jmp doreti_ast
-
- /*
- * doreti_exit: pop registers, iret.
- *
- * The segment register pop is a special case, since it may
- * fault if (for example) a sigreturn specifies bad segment
- * registers. The fault is handled in trap.c.
- */
-doreti_exit:
- ENABLE_INTERRUPTS(%esi) # reenable event callbacks (sti)
-
- .globl scrit
-scrit:
- __TEST_PENDING(%esi)
- jnz hypervisor_callback_pending /* More to go */
-
- MEXITCOUNT
-
- .globl doreti_popl_fs
-doreti_popl_fs:
- popl %fs
- .globl doreti_popl_es
-doreti_popl_es:
- popl %es
- .globl doreti_popl_ds
-doreti_popl_ds:
- popl %ds
-
- /*
- * This is important: as nothing is atomic over here (we can get
- * interrupted any time), we use the critical_region_fixup() in
- * order to figure out where out stack is. Therefore, do NOT use
- * 'popal' here without fixing up the table!
- */
- POPA
- addl $8,%esp
- .globl doreti_iret
-doreti_iret:
- jmp hypercall_page + (__HYPERVISOR_iret * 32)
- .globl ecrit
-ecrit:
- /*
- * doreti_iret_fault and friends. Alternative return code for
- * the case where we get a fault in the doreti_exit code
- * above. trap() (i386/i386/trap.c) catches this specific
- * case, sends the process a signal and continues in the
- * corresponding place in the code below.
- */
- ALIGN_TEXT
- .globl doreti_iret_fault
-doreti_iret_fault:
- subl $8,%esp
- pushal
- pushl %ds
- .globl doreti_popl_ds_fault
-doreti_popl_ds_fault:
- pushl %es
- .globl doreti_popl_es_fault
-doreti_popl_es_fault:
- pushl %fs
- .globl doreti_popl_fs_fault
-doreti_popl_fs_fault:
- movl $0,TF_ERR(%esp) /* XXX should be the error code */
- movl $T_PROTFLT,TF_TRAPNO(%esp)
- jmp alltraps_with_regs_pushed
-
- /*
-# [How we do the fixup]. We want to merge the current stack frame with the
-# just-interrupted frame. How we do this depends on where in the critical
-# region the interrupted handler was executing, and so how many saved
-# registers are in each frame. We do this quickly using the lookup table
-# 'critical_fixup_table'. For each byte offset in the critical region, it
-# provides the number of bytes which have already been popped from the
-# interrupted stack frame.
-*/
-
-.globl critical_region_fixup
-critical_region_fixup:
- addl $critical_fixup_table-scrit,%eax
- movzbl (%eax),%eax # %eax contains num bytes popped
- movl %esp,%esi
- add %eax,%esi # %esi points at end of src region
- movl %esp,%edi
- add $0x40,%edi # %edi points at end of dst region
- movl %eax,%ecx
- shr $2,%ecx # convert bytes to words
- je 16f # skip loop if nothing to copy
-15: subl $4,%esi # pre-decrementing copy loop
- subl $4,%edi
- movl (%esi),%eax
- movl %eax,(%edi)
- loop 15b
-16: movl %edi,%esp # final %edi is top of merged stack
- jmp hypervisor_callback_pending
-
-
-critical_fixup_table:
-.byte 0x0,0x0,0x0 #testb $0x1,(%esi)
-.byte 0x0,0x0,0x0,0x0,0x0,0x0 #jne ea
-.byte 0x0,0x0 #pop %fs
-.byte 0x04 #pop %es
-.byte 0x08 #pop %ds
-.byte 0x0c #pop %edi
-.byte 0x10 #pop %esi
-.byte 0x14 #pop %ebp
-.byte 0x18 #pop %ebx
-.byte 0x1c #pop %ebx
-.byte 0x20 #pop %edx
-.byte 0x24 #pop %ecx
-.byte 0x28 #pop %eax
-.byte 0x2c,0x2c,0x2c #add $0x8,%esp
-#if 0
- .byte 0x34 #iret
-#endif
-.byte 0x34,0x34,0x34,0x34,0x34 #HYPERVISOR_iret
-
-
-/* # Hypervisor uses this for application faults while it executes.*/
-ENTRY(failsafe_callback)
- pushal
- call xen_failsafe_handler
-/*# call install_safe_pf_handler */
- movl 28(%esp),%ebx
-1: movl %ebx,%ds
- movl 32(%esp),%ebx
-2: movl %ebx,%es
- movl 36(%esp),%ebx
-3: movl %ebx,%fs
- movl 40(%esp),%ebx
-4: movl %ebx,%gs
-/*# call install_normal_pf_handler */
- popal
- addl $12,%esp
- iret
-
-
diff --git a/sys/i386/xen/locore.s b/sys/i386/xen/locore.s
deleted file mode 100644
index 7e67684..0000000
--- a/sys/i386/xen/locore.s
+++ /dev/null
@@ -1,360 +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.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (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_compat.h"
-#include "opt_nfsroot.h"
-#include "opt_pmap.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>
-
-#define __ASSEMBLY__
-#include <xen/interface/elfnote.h>
-
-/* The defines below have been lifted out of <machine/xen-public/arch-x86_32.h> */
-#define FLAT_RING1_CS 0xe019 /* GDT index 259 */
-#define FLAT_RING1_DS 0xe021 /* GDT index 260 */
-#define KERNEL_CS FLAT_RING1_CS
-#define KERNEL_DS FLAT_RING1_DS
-
-#include "assym.s"
-
-.section __xen_guest
- .ascii "LOADER=generic,GUEST_OS=freebsd,GUEST_VER=7.0,XEN_VER=xen-3.0,BSD_SYMTAB,VIRT_BASE=0xc0000000"
- .byte 0
-
- ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz, "FreeBSD")
- ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz, "HEAD")
- ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz, "xen-3.0")
- ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE, .long, KERNBASE)
- ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET, .long, KERNBASE)
- ELFNOTE(Xen, XEN_ELFNOTE_ENTRY, .long, btext)
- ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .long, hypercall_page)
- ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW, .long, XEN_HYPERVISOR_VIRT_START)
-#if 0
- ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz, "writable_page_tables|writable_descriptor_tables|auto_translated_physmap|pae_pgdir_above_4gb|supervisor_mode_kernel")
-#endif
- ELFNOTE(Xen, XEN_ELFNOTE_FEATURES, .asciz, "writable_page_tables|supervisor_mode_kernel|writable_descriptor_tables")
-
-#ifdef PAE
- ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz, "yes")
- ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .long, PG_V, PG_V)
-#else
- ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE, .asciz, "no")
- ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID, .long, PG_V, PG_V)
-#endif
- ELFNOTE(Xen, XEN_ELFNOTE_LOADER, .asciz, "generic")
- ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long, 1)
-
-
-
-/*
- * 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)
-
-/*
- * Compiled KERNBASE location and the kernel load address
- */
- .globl kernbase
- .set kernbase,KERNBASE
- .globl kernload
- .set kernload,KERNLOAD
-
-/*
- * Globals
- */
- .data
- ALIGN_DATA /* just to be sure */
-
- .space 0x2000 /* space for tmpstk - temporary stack */
-tmpstk:
-
- .globl bootinfo
-bootinfo: .space BOOTINFO_SIZE /* bootinfo that we can handle */
-
- .globl KERNend
-KERNend: .long 0 /* phys addr end of kernel (just after bss) */
- .globl physfree
-physfree: .long 0 /* phys addr of next free page */
-
- .globl IdlePTD
-IdlePTD: .long 0 /* phys addr of kernel PTD */
-
-#ifdef PAE
- .globl IdlePDPT
-IdlePDPT: .long 0 /* phys addr of kernel PDPT */
-#endif
-
-#ifdef SMP
- .globl KPTphys
-#endif
-KPTphys: .long 0 /* phys addr of kernel page tables */
- .globl gdtset
-gdtset: .long 0 /* GDT is valid */
-
- .globl proc0kstack
-proc0kstack: .long 0 /* address of proc 0 kstack space */
-p0kpa: .long 0 /* phys addr of proc0's STACK */
-
-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 PC98
- .globl pc98_system_parameter
-pc98_system_parameter:
- .space 0x240
-#endif
-
- .globl avail_space
-avail_space: .long 0
-
-/**********************************************************************
- *
- * Some handy macros
- *
- */
-
-/*
- * We're already in protected mode, so no remapping is needed.
- */
-#define R(foo) (foo)
-
-#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 $PTESHIFT,%ebx ; \
- addl base,%ebx ; \
- orl $PG_V,%eax ; \
- orl prot,%eax ; \
-1: movl %eax,(%ebx) ; \
- addl $PAGE_SIZE,%eax ; /* increment physical address */ \
- addl $PTESIZE,%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)
-
-/* Temporary stack */
-.space 8192
-tmpstack:
- .long tmpstack, KERNEL_DS
-
- .text
-
-.p2align 12, 0x90
-
-#define HYPERCALL_PAGE_OFFSET 0x1000
-.org HYPERCALL_PAGE_OFFSET
-ENTRY(hypercall_page)
- .cfi_startproc
- .skip 0x1000
- .cfi_endproc
-
-/**********************************************************************
- *
- * This is where the bootblocks start us, set the ball rolling...
- *
- */
-NON_GPROF_ENTRY(btext)
- /* At the end of our stack, we shall have free space - so store it */
- movl %esp,%ebx
- movl %ebx,R(avail_space)
-
- lss tmpstack,%esp
-
- pushl %esi
- call initvalues
- popl %esi
-
- /* Store the CPUID information */
- xorl %eax,%eax
- cpuid # 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
- cpuid # cpuid 1
- movl %eax,R(cpu_id) # store cpu_id
- movl %ebx,R(cpu_procinfo) # store cpu_procinfo
- movl %edx,R(cpu_feature) # store cpu_feature
- movl %ecx,R(cpu_feature2) # store cpu_feature2
- rorl $8,%eax # extract family type
- andl $15,%eax
- cmpl $5,%eax
- movl $CPU_686,R(cpu)
-
- movl proc0kstack,%eax
- leal (KSTACK_PAGES*PAGE_SIZE-PCB_SIZE)(%eax),%esp
- xorl %ebp,%ebp /* mark end of frames */
-#ifdef PAE
- movl IdlePDPT,%esi
-#else
- movl IdlePTD,%esi
-#endif
- movl %esi,(KSTACK_PAGES*PAGE_SIZE-PCB_SIZE+PCB_CR3)(%eax)
- pushl physfree
- call init386
- addl $4, %esp
- call mi_startup
- /* NOTREACHED */
- int $3
-
-/*
- * Signal trampoline, copied to top of user stack
- */
-NON_GPROF_ENTRY(sigcode)
- calll *SIGF_HANDLER(%esp)
- leal SIGF_UC(%esp),%eax /* get ucontext */
- pushl %eax
- testl $PSL_VM,UC_EFLAGS(%eax)
- jne 1f
- mov UC_GS(%eax), %gs /* restore %gs */
-1:
- movl $SYS_sigreturn,%eax
- pushl %eax /* junk to fake return addr. */
- int $0x80 /* enter kernel with args */
- /* on stack */
-1:
- jmp 1b
-
-#ifdef COMPAT_FREEBSD4
- ALIGN_TEXT
-freebsd4_sigcode:
- calll *SIGF_HANDLER(%esp)
- leal SIGF_UC4(%esp),%eax /* get ucontext */
- pushl %eax
- testl $PSL_VM,UC4_EFLAGS(%eax)
- jne 1f
- mov UC4_GS(%eax),%gs /* restore %gs */
-1:
- movl $344,%eax /* 4.x SYS_sigreturn */
- pushl %eax /* junk to fake return addr. */
- int $0x80 /* enter kernel with args */
- /* on stack */
-1:
- jmp 1b
-#endif
-
-#ifdef COMPAT_43
- 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 $103,%eax /* 3.x SYS_sigreturn */
- pushl %eax /* junk to fake return addr. */
- int $0x80 /* enter kernel with args */
-0: jmp 0b
-#endif /* COMPAT_43 */
-
- ALIGN_TEXT
-esigcode:
-
- .data
- .globl szsigcode
-szsigcode:
- .long esigcode-sigcode
-#ifdef COMPAT_FREEBSD4
- .globl szfreebsd4_sigcode
-szfreebsd4_sigcode:
- .long esigcode-freebsd4_sigcode
-#endif
-#ifdef COMPAT_43
- .globl szosigcode
-szosigcode:
- .long esigcode-osigcode
-#endif
diff --git a/sys/i386/xen/mp_machdep.c b/sys/i386/xen/mp_machdep.c
deleted file mode 100644
index 6556d25..0000000
--- a/sys/i386/xen/mp_machdep.c
+++ /dev/null
@@ -1,1292 +0,0 @@
-/*-
- * Copyright (c) 1996, by Steve Passe
- * Copyright (c) 2008, by Kip Macy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "opt_apic.h"
-#include "opt_cpu.h"
-#include "opt_kstack_pages.h"
-#include "opt_mp_watchdog.h"
-#include "opt_pmap.h"
-#include "opt_sched.h"
-#include "opt_smp.h"
-
-#if !defined(lint)
-#if !defined(SMP)
-#error How did you get here?
-#endif
-
-#ifndef DEV_APIC
-#error The apic device is required for SMP, add "device apic" to your config file.
-#endif
-#if defined(CPU_DISABLE_CMPXCHG) && !defined(COMPILING_LINT)
-#error SMP not supported with CPU_DISABLE_CMPXCHG
-#endif
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/cons.h> /* cngetc() */
-#include <sys/cpuset.h>
-#ifdef GPROF
-#include <sys/gmon.h>
-#endif
-#include <sys/kernel.h>
-#include <sys/ktr.h>
-#include <sys/lock.h>
-#include <sys/malloc.h>
-#include <sys/memrange.h>
-#include <sys/mutex.h>
-#include <sys/pcpu.h>
-#include <sys/proc.h>
-#include <sys/rwlock.h>
-#include <sys/sched.h>
-#include <sys/smp.h>
-#include <sys/sysctl.h>
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#include <vm/vm_kern.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_page.h>
-
-#include <x86/apicreg.h>
-#include <machine/md_var.h>
-#include <machine/mp_watchdog.h>
-#include <machine/pcb.h>
-#include <machine/psl.h>
-#include <machine/smp.h>
-#include <machine/specialreg.h>
-#include <machine/pcpu.h>
-
-#include <xen/xen-os.h>
-#include <xen/evtchn.h>
-#include <xen/xen_intr.h>
-#include <xen/hypervisor.h>
-#include <xen/interface/vcpu.h>
-
-/*---------------------------- Extern Declarations ---------------------------*/
-extern struct pcpu __pcpu[];
-
-extern void Xhypervisor_callback(void);
-extern void failsafe_callback(void);
-
-/*--------------------------- Forward Declarations ---------------------------*/
-static driver_filter_t smp_reschedule_interrupt;
-static driver_filter_t smp_call_function_interrupt;
-static int start_all_aps(void);
-static int start_ap(int apic_id);
-static void release_aps(void *dummy);
-
-/*---------------------------------- Macros ----------------------------------*/
-#define IPI_TO_IDX(ipi) ((ipi) - APIC_IPI_INTS)
-
-/*-------------------------------- Local Types -------------------------------*/
-typedef void call_data_func_t(uintptr_t , uintptr_t);
-
-struct xen_ipi_handler
-{
- driver_filter_t *filter;
- const char *description;
-};
-
-enum {
- RESCHEDULE_VECTOR,
- CALL_FUNCTION_VECTOR,
-};
-
-/*-------------------------------- Global Data -------------------------------*/
-static u_int hyperthreading_cpus;
-static cpuset_t hyperthreading_cpus_mask;
-
-int mp_naps; /* # of Applications processors */
-int boot_cpu_id = -1; /* designated BSP */
-
-int bootAP;
-static union descriptor *bootAPgdt;
-
-/* Free these after use */
-void *bootstacks[MAXCPU];
-
-struct pcb stoppcbs[MAXCPU];
-
-/* Variables needed for SMP tlb shootdown. */
-vm_offset_t smp_tlb_addr1;
-vm_offset_t smp_tlb_addr2;
-volatile int smp_tlb_wait;
-
-static u_int logical_cpus;
-static volatile cpuset_t ipi_nmi_pending;
-
-/* used to hold the AP's until we are ready to release them */
-struct mtx ap_boot_mtx;
-
-/* Set to 1 once we're ready to let the APs out of the pen. */
-volatile int aps_ready = 0;
-
-/*
- * Store data from cpu_add() until later in the boot when we actually setup
- * the APs.
- */
-struct cpu_info cpu_info[MAX_APIC_ID + 1];
-int cpu_apic_ids[MAXCPU];
-int apic_cpuids[MAX_APIC_ID + 1];
-
-/* Holds pending bitmap based IPIs per CPU */
-volatile u_int cpu_ipi_pending[MAXCPU];
-
-int cpu_logical;
-int cpu_cores;
-
-static const struct xen_ipi_handler xen_ipis[] =
-{
- [RESCHEDULE_VECTOR] = { smp_reschedule_interrupt, "resched" },
- [CALL_FUNCTION_VECTOR] = { smp_call_function_interrupt,"callfunc" }
-};
-
-/*------------------------------- Per-CPU Data -------------------------------*/
-DPCPU_DEFINE(xen_intr_handle_t, ipi_handle[nitems(xen_ipis)]);
-DPCPU_DEFINE(struct vcpu_info *, vcpu_info);
-
-/*------------------------------ Implementation ------------------------------*/
-struct cpu_group *
-cpu_topo(void)
-{
- if (cpu_cores == 0)
- cpu_cores = 1;
- if (cpu_logical == 0)
- cpu_logical = 1;
- if (mp_ncpus % (cpu_cores * cpu_logical) != 0) {
- printf("WARNING: Non-uniform processors.\n");
- printf("WARNING: Using suboptimal topology.\n");
- return (smp_topo_none());
- }
- /*
- * No multi-core or hyper-threaded.
- */
- if (cpu_logical * cpu_cores == 1)
- return (smp_topo_none());
- /*
- * Only HTT no multi-core.
- */
- if (cpu_logical > 1 && cpu_cores == 1)
- return (smp_topo_1level(CG_SHARE_L1, cpu_logical, CG_FLAG_HTT));
- /*
- * Only multi-core no HTT.
- */
- if (cpu_cores > 1 && cpu_logical == 1)
- return (smp_topo_1level(CG_SHARE_NONE, cpu_cores, 0));
- /*
- * Both HTT and multi-core.
- */
- return (smp_topo_2level(CG_SHARE_NONE, cpu_cores,
- CG_SHARE_L1, cpu_logical, CG_FLAG_HTT));
-}
-
-/*
- * Calculate usable address in base memory for AP trampoline code.
- */
-u_int
-mp_bootaddress(u_int basemem)
-{
-
- return (basemem);
-}
-
-void
-cpu_add(u_int apic_id, char boot_cpu)
-{
-
- if (apic_id > MAX_APIC_ID) {
- panic("SMP: APIC ID %d too high", apic_id);
- return;
- }
- KASSERT(cpu_info[apic_id].cpu_present == 0, ("CPU %d added twice",
- apic_id));
- cpu_info[apic_id].cpu_present = 1;
- if (boot_cpu) {
- KASSERT(boot_cpu_id == -1,
- ("CPU %d claims to be BSP, but CPU %d already is", apic_id,
- boot_cpu_id));
- boot_cpu_id = apic_id;
- cpu_info[apic_id].cpu_bsp = 1;
- }
- if (mp_ncpus < MAXCPU)
- mp_ncpus++;
- if (bootverbose)
- printf("SMP: Added CPU %d (%s)\n", apic_id, boot_cpu ? "BSP" :
- "AP");
-}
-
-void
-cpu_mp_setmaxid(void)
-{
-
- mp_maxid = MAXCPU - 1;
-}
-
-int
-cpu_mp_probe(void)
-{
-
- /*
- * Always record BSP in CPU map so that the mbuf init code works
- * correctly.
- */
- CPU_SETOF(0, &all_cpus);
- if (mp_ncpus == 0) {
- /*
- * No CPUs were found, so this must be a UP system. Setup
- * the variables to represent a system with a single CPU
- * with an id of 0.
- */
- mp_ncpus = 1;
- return (0);
- }
-
- /* At least one CPU was found. */
- if (mp_ncpus == 1) {
- /*
- * One CPU was found, so this must be a UP system with
- * an I/O APIC.
- */
- return (0);
- }
-
- /* At least two CPUs were found. */
- return (1);
-}
-
-/*
- * Initialize the IPI handlers and start up the AP's.
- */
-void
-cpu_mp_start(void)
-{
- int i;
-
- /* Initialize the logical ID to APIC ID table. */
- for (i = 0; i < MAXCPU; i++) {
- cpu_apic_ids[i] = -1;
- cpu_ipi_pending[i] = 0;
- }
-
- /* Set boot_cpu_id if needed. */
- if (boot_cpu_id == -1) {
- boot_cpu_id = PCPU_GET(apic_id);
- cpu_info[boot_cpu_id].cpu_bsp = 1;
- } else
- KASSERT(boot_cpu_id == PCPU_GET(apic_id),
- ("BSP's APIC ID doesn't match boot_cpu_id"));
- cpu_apic_ids[0] = boot_cpu_id;
- apic_cpuids[boot_cpu_id] = 0;
-
- assign_cpu_ids();
-
- /* Start each Application Processor */
- start_all_aps();
-
- /* Setup the initial logical CPUs info. */
- logical_cpus = 0;
- CPU_ZERO(&logical_cpus_mask);
- if (cpu_feature & CPUID_HTT)
- logical_cpus = (cpu_procinfo & CPUID_HTT_CORES) >> 16;
-
- set_interrupt_apic_ids();
-}
-
-
-static void
-iv_rendezvous(uintptr_t a, uintptr_t b)
-{
- smp_rendezvous_action();
-}
-
-static void
-iv_invltlb(uintptr_t a, uintptr_t b)
-{
- xen_tlb_flush();
-}
-
-static void
-iv_invlpg(uintptr_t a, uintptr_t b)
-{
- xen_invlpg(a);
-}
-
-static void
-iv_invlrng(uintptr_t a, uintptr_t b)
-{
- vm_offset_t start = (vm_offset_t)a;
- vm_offset_t end = (vm_offset_t)b;
-
- while (start < end) {
- xen_invlpg(start);
- start += PAGE_SIZE;
- }
-}
-
-
-static void
-iv_invlcache(uintptr_t a, uintptr_t b)
-{
-
- wbinvd();
- atomic_add_int(&smp_tlb_wait, 1);
-}
-
-/*
- * These start from "IPI offset" APIC_IPI_INTS
- */
-static call_data_func_t *ipi_vectors[5] =
-{
- iv_rendezvous,
- iv_invltlb,
- iv_invlpg,
- iv_invlrng,
- iv_invlcache,
-};
-
-/*
- * Reschedule call back. Nothing to do,
- * all the work is done automatically when
- * we return from the interrupt.
- */
-static int
-smp_reschedule_interrupt(void *unused)
-{
- int cpu = PCPU_GET(cpuid);
- u_int ipi_bitmap;
-
- ipi_bitmap = atomic_readandclear_int(&cpu_ipi_pending[cpu]);
-
- if (ipi_bitmap & (1 << IPI_PREEMPT)) {
-#ifdef COUNT_IPIS
- (*ipi_preempt_counts[cpu])++;
-#endif
- sched_preempt(curthread);
- }
-
- if (ipi_bitmap & (1 << IPI_AST)) {
-#ifdef COUNT_IPIS
- (*ipi_ast_counts[cpu])++;
-#endif
- /* Nothing to do for AST */
- }
- return (FILTER_HANDLED);
-}
-
-struct _call_data {
- uint16_t func_id;
- uint16_t wait;
- uintptr_t arg1;
- uintptr_t arg2;
- atomic_t started;
- atomic_t finished;
-};
-
-static struct _call_data *call_data;
-
-static int
-smp_call_function_interrupt(void *unused)
-{
- call_data_func_t *func;
- uintptr_t arg1 = call_data->arg1;
- uintptr_t arg2 = call_data->arg2;
- int wait = call_data->wait;
- atomic_t *started = &call_data->started;
- atomic_t *finished = &call_data->finished;
-
- /* We only handle function IPIs, not bitmap IPIs */
- if (call_data->func_id < APIC_IPI_INTS ||
- call_data->func_id > IPI_BITMAP_VECTOR)
- panic("invalid function id %u", call_data->func_id);
-
- func = ipi_vectors[IPI_TO_IDX(call_data->func_id)];
- /*
- * Notify initiating CPU that I've grabbed the data and am
- * about to execute the function
- */
- mb();
- atomic_inc(started);
- /*
- * At this point the info structure may be out of scope unless wait==1
- */
- (*func)(arg1, arg2);
-
- if (wait) {
- mb();
- atomic_inc(finished);
- }
- atomic_add_int(&smp_tlb_wait, 1);
- return (FILTER_HANDLED);
-}
-
-/*
- * Print various information about the SMP system hardware and setup.
- */
-void
-cpu_mp_announce(void)
-{
- int i, x;
-
- /* List CPUs */
- printf(" cpu0 (BSP): APIC ID: %2d\n", boot_cpu_id);
- for (i = 1, x = 0; x <= MAX_APIC_ID; x++) {
- if (!cpu_info[x].cpu_present || cpu_info[x].cpu_bsp)
- continue;
- if (cpu_info[x].cpu_disabled)
- printf(" cpu (AP): APIC ID: %2d (disabled)\n", x);
- else {
- KASSERT(i < mp_ncpus,
- ("mp_ncpus and actual cpus are out of whack"));
- printf(" cpu%d (AP): APIC ID: %2d\n", i++, x);
- }
- }
-}
-
-static int
-xen_smp_cpu_init(unsigned int cpu)
-{
- xen_intr_handle_t *ipi_handle;
- const struct xen_ipi_handler *ipi;
- int idx, rc;
-
- ipi_handle = DPCPU_ID_GET(cpu, ipi_handle);
- for (ipi = xen_ipis, idx = 0; idx < nitems(xen_ipis); ipi++, idx++) {
-
- /*
- * The PCPU variable pc_device is not initialized on i386 PV,
- * so we have to use the root_bus device in order to setup
- * the IPIs.
- */
- rc = xen_intr_alloc_and_bind_ipi(root_bus, cpu,
- ipi->filter, INTR_TYPE_TTY, &ipi_handle[idx]);
- if (rc != 0) {
- printf("Unable to allocate a XEN IPI port. "
- "Error %d\n", rc);
- break;
- }
- xen_intr_describe(ipi_handle[idx], "%s", ipi->description);
- }
-
- for (;idx < nitems(xen_ipis); idx++)
- ipi_handle[idx] = NULL;
-
- if (rc == 0)
- return (0);
-
- /* Either all are successfully mapped, or none at all. */
- for (idx = 0; idx < nitems(xen_ipis); idx++) {
- if (ipi_handle[idx] == NULL)
- continue;
-
- xen_intr_unbind(ipi_handle[idx]);
- ipi_handle[idx] = NULL;
- }
-
- return (rc);
-}
-
-static void
-xen_smp_intr_init_cpus(void *unused)
-{
- int i;
-
- for (i = 0; i < mp_ncpus; i++)
- xen_smp_cpu_init(i);
-}
-
-static void
-xen_smp_intr_setup_cpus(void *unused)
-{
- int i;
-
- for (i = 0; i < mp_ncpus; i++)
- DPCPU_ID_SET(i, vcpu_info,
- &HYPERVISOR_shared_info->vcpu_info[i]);
-}
-
-#define MTOPSIZE (1<<(14 + PAGE_SHIFT))
-
-/*
- * AP CPU's call this to initialize themselves.
- */
-void
-init_secondary(void)
-{
- vm_offset_t addr;
- u_int cpuid;
- int gsel_tss;
-
-
- /* bootAP is set in start_ap() to our ID. */
- PCPU_SET(currentldt, _default_ldt);
- gsel_tss = GSEL(GPROC0_SEL, SEL_KPL);
-#if 0
- gdt[bootAP * NGDT + GPROC0_SEL].sd.sd_type = SDT_SYS386TSS;
-#endif
- PCPU_SET(common_tss.tss_esp0, 0); /* not used until after switch */
- PCPU_SET(common_tss.tss_ss0, GSEL(GDATA_SEL, SEL_KPL));
- PCPU_SET(common_tss.tss_ioopt, (sizeof (struct i386tss)) << 16);
-#if 0
- PCPU_SET(tss_gdt, &gdt[bootAP * NGDT + GPROC0_SEL].sd);
-
- PCPU_SET(common_tssd, *PCPU_GET(tss_gdt));
-#endif
- PCPU_SET(fsgs_gdt, &gdt[GUFS_SEL].sd);
-
- /*
- * Set to a known state:
- * Set by mpboot.s: CR0_PG, CR0_PE
- * Set by cpu_setregs: CR0_NE, CR0_MP, CR0_TS, CR0_WP, CR0_AM
- */
- /*
- * signal our startup to the BSP.
- */
- mp_naps++;
-
- /* Spin until the BSP releases the AP's. */
- while (!aps_ready)
- ia32_pause();
-
- /* BSP may have changed PTD while we were waiting */
- invltlb();
- for (addr = 0; addr < NKPT * NBPDR - 1; addr += PAGE_SIZE)
- invlpg(addr);
-
-#if 0
- /* set up SSE/NX */
- initializecpu();
-#endif
-
- /* set up FPU state on the AP */
- npxinit(false);
-#if 0
- /* A quick check from sanity claus */
- if (PCPU_GET(apic_id) != lapic_id()) {
- printf("SMP: cpuid = %d\n", PCPU_GET(cpuid));
- printf("SMP: actual apic_id = %d\n", lapic_id());
- printf("SMP: correct apic_id = %d\n", PCPU_GET(apic_id));
- panic("cpuid mismatch! boom!!");
- }
-#endif
-
- /* Initialize curthread. */
- KASSERT(PCPU_GET(idlethread) != NULL, ("no idle thread"));
- PCPU_SET(curthread, PCPU_GET(idlethread));
-
- mtx_lock_spin(&ap_boot_mtx);
-#if 0
-
- /* Init local apic for irq's */
- lapic_setup(1);
-#endif
- smp_cpus++;
-
- cpuid = PCPU_GET(cpuid);
- CTR1(KTR_SMP, "SMP: AP CPU #%d Launched", cpuid);
- printf("SMP: AP CPU #%d Launched!\n", cpuid);
-
- /* Determine if we are a logical CPU. */
- if (logical_cpus > 1 && PCPU_GET(apic_id) % logical_cpus != 0)
- CPU_SET(cpuid, &logical_cpus_mask);
-
- /* Determine if we are a hyperthread. */
- if (hyperthreading_cpus > 1 &&
- PCPU_GET(apic_id) % hyperthreading_cpus != 0)
- CPU_SET(cpuid, &hyperthreading_cpus_mask);
-#if 0
- if (bootverbose)
- lapic_dump("AP");
-#endif
- if (smp_cpus == mp_ncpus) {
- /* enable IPI's, tlb shootdown, freezes etc */
- atomic_store_rel_int(&smp_started, 1);
- }
-
- mtx_unlock_spin(&ap_boot_mtx);
-
- /* wait until all the AP's are up */
- while (smp_started == 0)
- ia32_pause();
-
- PCPU_SET(curthread, PCPU_GET(idlethread));
-
- /* Start per-CPU event timers. */
- cpu_initclocks_ap();
-
- /* enter the scheduler */
- sched_throw(NULL);
-
- panic("scheduler returned us to %s", __func__);
- /* NOTREACHED */
-}
-
-/*******************************************************************
- * local functions and data
- */
-
-/*
- * We tell the I/O APIC code about all the CPUs we want to receive
- * interrupts. If we don't want certain CPUs to receive IRQs we
- * can simply not tell the I/O APIC code about them in this function.
- * We also do not tell it about the BSP since it tells itself about
- * the BSP internally to work with UP kernels and on UP machines.
- */
-void
-set_interrupt_apic_ids(void)
-{
- u_int i, apic_id;
-
- for (i = 0; i < MAXCPU; i++) {
- apic_id = cpu_apic_ids[i];
- if (apic_id == -1)
- continue;
- if (cpu_info[apic_id].cpu_bsp)
- continue;
- if (cpu_info[apic_id].cpu_disabled)
- continue;
-
- /* Don't let hyperthreads service interrupts. */
- if (hyperthreading_cpus > 1 &&
- apic_id % hyperthreading_cpus != 0)
- continue;
-
- intr_add_cpu(i);
- }
-}
-
-/*
- * Assign logical CPU IDs to local APICs.
- */
-void
-assign_cpu_ids(void)
-{
- u_int i;
-
- /* Check for explicitly disabled CPUs. */
- for (i = 0; i <= MAX_APIC_ID; i++) {
- if (!cpu_info[i].cpu_present || cpu_info[i].cpu_bsp)
- continue;
-
- /* Don't use this CPU if it has been disabled by a tunable. */
- if (resource_disabled("lapic", i)) {
- cpu_info[i].cpu_disabled = 1;
- continue;
- }
- }
-
- /*
- * Assign CPU IDs to local APIC IDs and disable any CPUs
- * beyond MAXCPU. CPU 0 has already been assigned to the BSP,
- * so we only have to assign IDs for APs.
- */
- mp_ncpus = 1;
- for (i = 0; i <= MAX_APIC_ID; i++) {
- if (!cpu_info[i].cpu_present || cpu_info[i].cpu_bsp ||
- cpu_info[i].cpu_disabled)
- continue;
-
- if (mp_ncpus < MAXCPU) {
- cpu_apic_ids[mp_ncpus] = i;
- apic_cpuids[i] = mp_ncpus;
- mp_ncpus++;
- } else
- cpu_info[i].cpu_disabled = 1;
- }
- KASSERT(mp_maxid >= mp_ncpus - 1,
- ("%s: counters out of sync: max %d, count %d", __func__, mp_maxid,
- mp_ncpus));
-}
-
-/*
- * start each AP in our list
- */
-/* Lowest 1MB is already mapped: don't touch*/
-#define TMPMAP_START 1
-int
-start_all_aps(void)
-{
- int x,apic_id, cpu;
- struct pcpu *pc;
-
- mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN);
-
- /* set up temporary P==V mapping for AP boot */
- /* XXX this is a hack, we should boot the AP on its own stack/PTD */
-
- /* start each AP */
- for (cpu = 1; cpu < mp_ncpus; cpu++) {
- apic_id = cpu_apic_ids[cpu];
-
-
- bootAP = cpu;
- bootAPgdt = gdt + (512*cpu);
-
- /* Get per-cpu data */
- pc = &__pcpu[bootAP];
- pcpu_init(pc, bootAP, sizeof(struct pcpu));
- dpcpu_init((void *)kmem_malloc(kernel_arena, DPCPU_SIZE,
- M_WAITOK | M_ZERO), bootAP);
- pc->pc_apic_id = cpu_apic_ids[bootAP];
- pc->pc_vcpu_id = cpu_apic_ids[bootAP];
- pc->pc_prvspace = pc;
- pc->pc_curthread = 0;
-
- gdt_segs[GPRIV_SEL].ssd_base = (int) pc;
- gdt_segs[GPROC0_SEL].ssd_base = (int) &pc->pc_common_tss;
-
- PT_SET_MA(bootAPgdt, VTOM(bootAPgdt) | PG_V | PG_RW);
- bzero(bootAPgdt, PAGE_SIZE);
- for (x = 0; x < NGDT; x++)
- ssdtosd(&gdt_segs[x], &bootAPgdt[x].sd);
- PT_SET_MA(bootAPgdt, vtomach(bootAPgdt) | PG_V);
-#ifdef notyet
-
- if (HYPERVISOR_vcpu_op(VCPUOP_get_physid, cpu, &cpu_id) == 0) {
- apicid = xen_vcpu_physid_to_x86_apicid(cpu_id.phys_id);
- acpiid = xen_vcpu_physid_to_x86_acpiid(cpu_id.phys_id);
-#ifdef CONFIG_ACPI
- if (acpiid != 0xff)
- x86_acpiid_to_apicid[acpiid] = apicid;
-#endif
- }
-#endif
-
- /* attempt to start the Application Processor */
- if (!start_ap(cpu)) {
- printf("AP #%d (PHY# %d) failed!\n", cpu, apic_id);
- /* better panic as the AP may be running loose */
- printf("panic y/n? [y] ");
- if (cngetc() != 'n')
- panic("bye-bye");
- }
-
- CPU_SET(cpu, &all_cpus); /* record AP in CPU map */
- }
-
-
- pmap_invalidate_range(kernel_pmap, 0, NKPT * NBPDR - 1);
-
- /* number of APs actually started */
- return (mp_naps);
-}
-
-extern uint8_t *pcpu_boot_stack;
-extern trap_info_t trap_table[];
-
-static void
-smp_trap_init(trap_info_t *trap_ctxt)
-{
- const trap_info_t *t = trap_table;
-
- for (t = trap_table; t->address; t++) {
- trap_ctxt[t->vector].flags = t->flags;
- trap_ctxt[t->vector].cs = t->cs;
- trap_ctxt[t->vector].address = t->address;
- }
-}
-
-extern struct rwlock pvh_global_lock;
-extern int nkpt;
-static void
-cpu_initialize_context(unsigned int cpu)
-{
- /* vcpu_guest_context_t is too large to allocate on the stack.
- * Hence we allocate statically and protect it with a lock */
- vm_page_t m[NPGPTD + 2];
- static vcpu_guest_context_t ctxt;
- vm_offset_t boot_stack;
- vm_offset_t newPTD;
- vm_paddr_t ma[NPGPTD];
- int i;
-
- /*
- * Page 0,[0-3] PTD
- * Page 1, [4] boot stack
- * Page [5] PDPT
- *
- */
- for (i = 0; i < NPGPTD + 2; i++) {
- m[i] = vm_page_alloc(NULL, 0,
- VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED |
- VM_ALLOC_ZERO);
-
- pmap_zero_page(m[i]);
-
- }
- boot_stack = kva_alloc(PAGE_SIZE);
- newPTD = kva_alloc(NPGPTD * PAGE_SIZE);
- ma[0] = VM_PAGE_TO_MACH(m[0])|PG_V;
-
-#ifdef PAE
- pmap_kenter(boot_stack, VM_PAGE_TO_PHYS(m[NPGPTD + 1]));
- for (i = 0; i < NPGPTD; i++) {
- ((vm_paddr_t *)boot_stack)[i] =
- ma[i] = VM_PAGE_TO_MACH(m[i])|PG_V;
- }
-#endif
-
- /*
- * Copy cpu0 IdlePTD to new IdlePTD - copying only
- * kernel mappings
- */
- pmap_qenter(newPTD, m, 4);
-
- memcpy((uint8_t *)newPTD + KPTDI*sizeof(vm_paddr_t),
- (uint8_t *)PTOV(IdlePTD) + KPTDI*sizeof(vm_paddr_t),
- nkpt*sizeof(vm_paddr_t));
-
- pmap_qremove(newPTD, 4);
- kva_free(newPTD, 4 * PAGE_SIZE);
- /*
- * map actual idle stack to boot_stack
- */
- pmap_kenter(boot_stack, VM_PAGE_TO_PHYS(m[NPGPTD]));
-
-
- xen_pgdpt_pin(VM_PAGE_TO_MACH(m[NPGPTD + 1]));
- rw_wlock(&pvh_global_lock);
- for (i = 0; i < 4; i++) {
- int pdir = (PTDPTDI + i) / NPDEPG;
- int curoffset = (PTDPTDI + i) % NPDEPG;
-
- xen_queue_pt_update((vm_paddr_t)
- ((ma[pdir] & ~PG_V) + (curoffset*sizeof(vm_paddr_t))),
- ma[i]);
- }
- PT_UPDATES_FLUSH();
- rw_wunlock(&pvh_global_lock);
-
- memset(&ctxt, 0, sizeof(ctxt));
- ctxt.flags = VGCF_IN_KERNEL;
- ctxt.user_regs.ds = GSEL(GDATA_SEL, SEL_KPL);
- ctxt.user_regs.es = GSEL(GDATA_SEL, SEL_KPL);
- ctxt.user_regs.fs = GSEL(GPRIV_SEL, SEL_KPL);
- ctxt.user_regs.gs = GSEL(GDATA_SEL, SEL_KPL);
- ctxt.user_regs.cs = GSEL(GCODE_SEL, SEL_KPL);
- ctxt.user_regs.ss = GSEL(GDATA_SEL, SEL_KPL);
- ctxt.user_regs.eip = (unsigned long)init_secondary;
- ctxt.user_regs.eflags = PSL_KERNEL | 0x1000; /* IOPL_RING1 */
-
- memset(&ctxt.fpu_ctxt, 0, sizeof(ctxt.fpu_ctxt));
-
- smp_trap_init(ctxt.trap_ctxt);
-
- ctxt.ldt_ents = 0;
- ctxt.gdt_frames[0] =
- (uint32_t)((uint64_t)vtomach(bootAPgdt) >> PAGE_SHIFT);
- ctxt.gdt_ents = 512;
-
-#ifdef __i386__
- ctxt.user_regs.esp = boot_stack + PAGE_SIZE;
-
- ctxt.kernel_ss = GSEL(GDATA_SEL, SEL_KPL);
- ctxt.kernel_sp = boot_stack + PAGE_SIZE;
-
- ctxt.event_callback_cs = GSEL(GCODE_SEL, SEL_KPL);
- ctxt.event_callback_eip = (unsigned long)Xhypervisor_callback;
- ctxt.failsafe_callback_cs = GSEL(GCODE_SEL, SEL_KPL);
- ctxt.failsafe_callback_eip = (unsigned long)failsafe_callback;
-
- ctxt.ctrlreg[3] = VM_PAGE_TO_MACH(m[NPGPTD + 1]);
-#else /* __x86_64__ */
- ctxt.user_regs.esp = idle->thread.rsp0 - sizeof(struct pt_regs);
- ctxt.kernel_ss = GSEL(GDATA_SEL, SEL_KPL);
- ctxt.kernel_sp = idle->thread.rsp0;
-
- ctxt.event_callback_eip = (unsigned long)hypervisor_callback;
- ctxt.failsafe_callback_eip = (unsigned long)failsafe_callback;
- ctxt.syscall_callback_eip = (unsigned long)system_call;
-
- ctxt.ctrlreg[3] = xen_pfn_to_cr3(virt_to_mfn(init_level4_pgt));
-
- ctxt.gs_base_kernel = (unsigned long)(cpu_pda(cpu));
-#endif
-
- printf("gdtpfn=%lx pdptpfn=%lx\n",
- ctxt.gdt_frames[0],
- ctxt.ctrlreg[3] >> PAGE_SHIFT);
-
- PANIC_IF(HYPERVISOR_vcpu_op(VCPUOP_initialise, cpu, &ctxt));
- DELAY(3000);
- PANIC_IF(HYPERVISOR_vcpu_op(VCPUOP_up, cpu, NULL));
-}
-
-/*
- * 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 isn't pretty,
- * but it seems to work.
- */
-
-int cpus;
-static int
-start_ap(int apic_id)
-{
- int ms;
-
- /* used as a watchpoint to signal AP startup */
- cpus = mp_naps;
-
- cpu_initialize_context(apic_id);
-
- /* Wait up to 5 seconds for it to start. */
- for (ms = 0; ms < 5000; ms++) {
- if (mp_naps > cpus)
- return (1); /* return SUCCESS */
- DELAY(1000);
- }
- return (0); /* return FAILURE */
-}
-
-static void
-ipi_pcpu(int cpu, u_int ipi)
-{
- KASSERT((ipi <= nitems(xen_ipis)), ("invalid IPI"));
- xen_intr_signal(DPCPU_ID_GET(cpu, ipi_handle[ipi]));
-}
-
-/*
- * send an IPI to a specific CPU.
- */
-void
-ipi_send_cpu(int cpu, u_int ipi)
-{
- u_int bitmap, old_pending, new_pending;
-
- if (IPI_IS_BITMAPED(ipi)) {
- bitmap = 1 << ipi;
- ipi = IPI_BITMAP_VECTOR;
- do {
- old_pending = cpu_ipi_pending[cpu];
- new_pending = old_pending | bitmap;
- } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu],
- old_pending, new_pending));
- if (!old_pending)
- ipi_pcpu(cpu, RESCHEDULE_VECTOR);
- } else {
- KASSERT(call_data != NULL, ("call_data not set"));
- ipi_pcpu(cpu, CALL_FUNCTION_VECTOR);
- }
-}
-
-/*
- * Flush the TLB on all other CPU's
- */
-static void
-smp_tlb_shootdown(u_int vector, vm_offset_t addr1, vm_offset_t addr2)
-{
- u_int ncpu;
- struct _call_data data;
-
- ncpu = mp_ncpus - 1; /* does not shootdown self */
- if (ncpu < 1)
- return; /* no other cpus */
- if (!(read_eflags() & PSL_I))
- panic("%s: interrupts disabled", __func__);
- mtx_lock_spin(&smp_ipi_mtx);
- KASSERT(call_data == NULL, ("call_data isn't null?!"));
- call_data = &data;
- call_data->func_id = vector;
- call_data->arg1 = addr1;
- call_data->arg2 = addr2;
- atomic_store_rel_int(&smp_tlb_wait, 0);
- ipi_all_but_self(vector);
- while (smp_tlb_wait < ncpu)
- ia32_pause();
- call_data = NULL;
- mtx_unlock_spin(&smp_ipi_mtx);
-}
-
-static void
-smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector, vm_offset_t addr1,
- vm_offset_t addr2)
-{
- int cpu, ncpu, othercpus;
- struct _call_data data;
-
- othercpus = mp_ncpus - 1;
- if (CPU_ISFULLSET(&mask)) {
- if (othercpus < 1)
- return;
- } else {
- CPU_CLR(PCPU_GET(cpuid), &mask);
- if (CPU_EMPTY(&mask))
- return;
- }
- if (!(read_eflags() & PSL_I))
- panic("%s: interrupts disabled", __func__);
- mtx_lock_spin(&smp_ipi_mtx);
- KASSERT(call_data == NULL, ("call_data isn't null?!"));
- call_data = &data;
- call_data->func_id = vector;
- call_data->arg1 = addr1;
- call_data->arg2 = addr2;
- atomic_store_rel_int(&smp_tlb_wait, 0);
- if (CPU_ISFULLSET(&mask)) {
- ncpu = othercpus;
- ipi_all_but_self(vector);
- } else {
- ncpu = 0;
- while ((cpu = CPU_FFS(&mask)) != 0) {
- cpu--;
- CPU_CLR(cpu, &mask);
- CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu,
- vector);
- ipi_send_cpu(cpu, vector);
- ncpu++;
- }
- }
- while (smp_tlb_wait < ncpu)
- ia32_pause();
- call_data = NULL;
- mtx_unlock_spin(&smp_ipi_mtx);
-}
-
-void
-smp_cache_flush(void)
-{
-
- if (smp_started)
- smp_tlb_shootdown(IPI_INVLCACHE, 0, 0);
-}
-
-void
-smp_invltlb(void)
-{
-
- if (smp_started) {
- smp_tlb_shootdown(IPI_INVLTLB, 0, 0);
- }
-}
-
-void
-smp_invlpg(vm_offset_t addr)
-{
-
- if (smp_started) {
- smp_tlb_shootdown(IPI_INVLPG, addr, 0);
- }
-}
-
-void
-smp_invlpg_range(vm_offset_t addr1, vm_offset_t addr2)
-{
-
- if (smp_started) {
- smp_tlb_shootdown(IPI_INVLRNG, addr1, addr2);
- }
-}
-
-void
-smp_masked_invltlb(cpuset_t mask)
-{
-
- if (smp_started) {
- smp_targeted_tlb_shootdown(mask, IPI_INVLTLB, 0, 0);
- }
-}
-
-void
-smp_masked_invlpg(cpuset_t mask, vm_offset_t addr)
-{
-
- if (smp_started) {
- smp_targeted_tlb_shootdown(mask, IPI_INVLPG, addr, 0);
- }
-}
-
-void
-smp_masked_invlpg_range(cpuset_t mask, vm_offset_t addr1, vm_offset_t addr2)
-{
-
- if (smp_started) {
- smp_targeted_tlb_shootdown(mask, IPI_INVLRNG, addr1, addr2);
- }
-}
-
-/*
- * send an IPI to a set of cpus.
- */
-void
-ipi_selected(cpuset_t cpus, u_int ipi)
-{
- int cpu;
-
- /*
- * IPI_STOP_HARD maps to a NMI and the trap handler needs a bit
- * of help in order to understand what is the source.
- * Set the mask of receiving CPUs for this purpose.
- */
- if (ipi == IPI_STOP_HARD)
- CPU_OR_ATOMIC(&ipi_nmi_pending, &cpus);
-
- while ((cpu = CPU_FFS(&cpus)) != 0) {
- cpu--;
- CPU_CLR(cpu, &cpus);
- CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi);
- ipi_send_cpu(cpu, ipi);
- }
-}
-
-/*
- * send an IPI to a specific CPU.
- */
-void
-ipi_cpu(int cpu, u_int ipi)
-{
-
- /*
- * IPI_STOP_HARD maps to a NMI and the trap handler needs a bit
- * of help in order to understand what is the source.
- * Set the mask of receiving CPUs for this purpose.
- */
- if (ipi == IPI_STOP_HARD)
- CPU_SET_ATOMIC(cpu, &ipi_nmi_pending);
-
- CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi);
- ipi_send_cpu(cpu, ipi);
-}
-
-/*
- * send an IPI to all CPUs EXCEPT myself
- */
-void
-ipi_all_but_self(u_int ipi)
-{
- cpuset_t other_cpus;
-
- /*
- * IPI_STOP_HARD maps to a NMI and the trap handler needs a bit
- * of help in order to understand what is the source.
- * Set the mask of receiving CPUs for this purpose.
- */
- other_cpus = all_cpus;
- CPU_CLR(PCPU_GET(cpuid), &other_cpus);
- if (ipi == IPI_STOP_HARD)
- CPU_OR_ATOMIC(&ipi_nmi_pending, &other_cpus);
-
- CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi);
- ipi_selected(other_cpus, ipi);
-}
-
-int
-ipi_nmi_handler()
-{
- u_int cpuid;
-
- /*
- * As long as there is not a simple way to know about a NMI's
- * source, if the bitmask for the current CPU is present in
- * the global pending bitword an IPI_STOP_HARD has been issued
- * and should be handled.
- */
- cpuid = PCPU_GET(cpuid);
- if (!CPU_ISSET(cpuid, &ipi_nmi_pending))
- return (1);
-
- CPU_CLR_ATOMIC(cpuid, &ipi_nmi_pending);
- cpustop_handler();
- return (0);
-}
-
-/*
- * Handle an IPI_STOP by saving our current context and spinning until we
- * are resumed.
- */
-void
-cpustop_handler(void)
-{
- int cpu;
-
- cpu = PCPU_GET(cpuid);
-
- savectx(&stoppcbs[cpu]);
-
- /* Indicate that we are stopped */
- CPU_SET_ATOMIC(cpu, &stopped_cpus);
-
- /* Wait for restart */
- while (!CPU_ISSET(cpu, &started_cpus))
- ia32_pause();
-
- CPU_CLR_ATOMIC(cpu, &started_cpus);
- CPU_CLR_ATOMIC(cpu, &stopped_cpus);
-
- if (cpu == 0 && cpustop_restartfunc != NULL) {
- cpustop_restartfunc();
- cpustop_restartfunc = NULL;
- }
-}
-
-/*
- * Handlers for TLB related IPIs
- *
- * On i386 Xen PV this are no-ops since this port doesn't support SMP.
- */
-void
-invltlb_handler(void)
-{
-}
-
-void
-invlpg_handler(void)
-{
-}
-
-void
-invlrng_handler(void)
-{
-}
-
-void
-invlcache_handler(void)
-{
-}
-
-/*
- * 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.
- */
-static void
-release_aps(void *dummy __unused)
-{
-
- if (mp_ncpus == 1)
- return;
- atomic_store_rel_int(&aps_ready, 1);
- while (smp_started == 0)
- ia32_pause();
-}
-SYSINIT(start_aps, SI_SUB_SMP, SI_ORDER_FIRST, release_aps, NULL);
-SYSINIT(start_ipis, SI_SUB_SMP, SI_ORDER_ANY, xen_smp_intr_init_cpus, NULL);
-SYSINIT(start_cpu, SI_SUB_INTR, SI_ORDER_ANY, xen_smp_intr_setup_cpus, NULL);
diff --git a/sys/i386/xen/mptable.c b/sys/i386/xen/mptable.c
deleted file mode 100644
index 81d7c1b..0000000
--- a/sys/i386/xen/mptable.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/*-
- * Copyright (c) 2003 John Baldwin <jhb@FreeBSD.org>
- * 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/bus.h>
-#include <sys/kernel.h>
-
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-
-#include <machine/frame.h>
-#include <machine/intr_machdep.h>
-#include <x86/apicvar.h>
-
-#include <xen/hypervisor.h>
-#include <xen/xen-os.h>
-#include <machine/smp.h>
-#include <xen/interface/vcpu.h>
-
-
-static int mptable_probe(void);
-static int mptable_probe_cpus(void);
-static void mptable_register(void *dummy);
-static int mptable_setup_local(void);
-static int mptable_setup_io(void);
-
-static struct apic_enumerator mptable_enumerator = {
- "MPTable",
- mptable_probe,
- mptable_probe_cpus,
- mptable_setup_local,
- mptable_setup_io
-};
-
-static int
-mptable_probe(void)
-{
-
- return (-100);
-}
-
-static int
-mptable_probe_cpus(void)
-{
- int i, rc;
-
- for (i = 0; i < MAXCPU; i++) {
- rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL);
- if (rc >= 0)
- cpu_add(i, (i == 0));
- }
-
- return (0);
-}
-
-/*
- * Initialize the local APIC on the BSP.
- */
-static int
-mptable_setup_local(void)
-{
-
- PCPU_SET(apic_id, 0);
- PCPU_SET(vcpu_id, 0);
- return (0);
-}
-
-static int
-mptable_setup_io(void)
-{
-
- return (0);
-}
-
-static void
-mptable_register(void *dummy __unused)
-{
-
- apic_register_enumerator(&mptable_enumerator);
-}
-SYSINIT(mptable_register, SI_SUB_TUNABLES - 1, SI_ORDER_FIRST, mptable_register,
- NULL);
diff --git a/sys/i386/xen/pmap.c b/sys/i386/xen/pmap.c
deleted file mode 100644
index 757fc36..0000000
--- a/sys/i386/xen/pmap.c
+++ /dev/null
@@ -1,4420 +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.
- * Copyright (c) 2005 Alan L. Cox <alc@cs.rice.edu>
- * 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
- */
-/*-
- * Copyright (c) 2003 Networks Associates Technology, Inc.
- * All rights reserved.
- *
- * This software was developed for the FreeBSD Project by Jake Burkholder,
- * Safeport Network Services, and Network Associates Laboratories, the
- * Security Research Division of Network Associates, Inc. under
- * DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA
- * CHATS research program.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * Manages physical address maps.
- *
- * 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_cpu.h"
-#include "opt_pmap.h"
-#include "opt_smp.h"
-#include "opt_xbox.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/ktr.h>
-#include <sys/lock.h>
-#include <sys/malloc.h>
-#include <sys/mman.h>
-#include <sys/msgbuf.h>
-#include <sys/mutex.h>
-#include <sys/proc.h>
-#include <sys/rwlock.h>
-#include <sys/sf_buf.h>
-#include <sys/sx.h>
-#include <sys/vmmeter.h>
-#include <sys/sched.h>
-#include <sys/sysctl.h>
-#ifdef SMP
-#include <sys/smp.h>
-#else
-#include <sys/cpuset.h>
-#endif
-
-#include <vm/vm.h>
-#include <vm/vm_param.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/uma.h>
-
-#include <machine/cpu.h>
-#include <machine/cputypes.h>
-#include <machine/md_var.h>
-#include <machine/pcb.h>
-#include <machine/specialreg.h>
-#ifdef SMP
-#include <machine/smp.h>
-#endif
-
-#ifdef XBOX
-#include <machine/xbox.h>
-#endif
-
-#include <xen/interface/xen.h>
-#include <xen/hypervisor.h>
-#include <machine/xen/hypercall.h>
-#include <machine/xen/xenvar.h>
-#include <machine/xen/xenfunc.h>
-
-#if !defined(CPU_DISABLE_SSE) && defined(I686_CPU)
-#define CPU_ENABLE_SSE
-#endif
-
-#ifndef PMAP_SHPGPERPROC
-#define PMAP_SHPGPERPROC 200
-#endif
-
-#define DIAGNOSTIC
-
-#if !defined(DIAGNOSTIC)
-#ifdef __GNUC_GNU_INLINE__
-#define PMAP_INLINE __attribute__((__gnu_inline__)) inline
-#else
-#define PMAP_INLINE extern inline
-#endif
-#else
-#define PMAP_INLINE
-#endif
-
-#ifdef PV_STATS
-#define PV_STAT(x) do { x ; } while (0)
-#else
-#define PV_STAT(x) do { } while (0)
-#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_prot(pte, v) ((*(int *)pte &= ~PG_PROT), (*(int *)pte |= (v)))
-
-#define HAMFISTED_LOCKING
-#ifdef HAMFISTED_LOCKING
-static struct mtx createdelete_lock;
-#endif
-
-struct pmap kernel_pmap_store;
-LIST_HEAD(pmaplist, pmap);
-static struct pmaplist allpmaps;
-static struct mtx allpmaps_lock;
-
-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) */
-int pgeflag = 0; /* PG_G or-in */
-int pseflag = 0; /* PG_PS or-in */
-
-int nkpt;
-vm_offset_t kernel_vm_end;
-extern u_int32_t KERNend;
-
-#ifdef PAE
-pt_entry_t pg_nx;
-#endif
-
-static SYSCTL_NODE(_vm, OID_AUTO, pmap, CTLFLAG_RD, 0, "VM/pmap parameters");
-
-static int pat_works; /* Is page attribute table sane? */
-
-/*
- * This lock is defined as static in other pmap implementations. It cannot,
- * however, be defined as static here, because it is (ab)used to serialize
- * queued page table changes in other sources files.
- */
-struct rwlock pvh_global_lock;
-
-/*
- * Data for the pv entry allocation mechanism
- */
-static TAILQ_HEAD(pch, pv_chunk) pv_chunks = TAILQ_HEAD_INITIALIZER(pv_chunks);
-static int pv_entry_count = 0, pv_entry_max = 0, pv_entry_high_water = 0;
-static int shpgperproc = PMAP_SHPGPERPROC;
-
-struct pv_chunk *pv_chunkbase; /* KVA block for pv_chunks */
-int pv_maxchunks; /* How many chunks we have KVA for */
-vm_offset_t pv_vafree; /* freelist stored in the PTE */
-
-/*
- * All those kernel PT submaps that BSD is so fond of
- */
-struct sysmaps {
- struct mtx lock;
- pt_entry_t *CMAP1;
- pt_entry_t *CMAP2;
- caddr_t CADDR1;
- caddr_t CADDR2;
-};
-static struct sysmaps sysmaps_pcpu[MAXCPU];
-pt_entry_t *CMAP3;
-caddr_t ptvmmap = 0;
-caddr_t CADDR3;
-struct msgbuf *msgbufp = 0;
-
-/*
- * Crashdump maps.
- */
-static caddr_t crashdumpmap;
-
-static pt_entry_t *PMAP1 = 0, *PMAP2;
-static pt_entry_t *PADDR1 = 0, *PADDR2;
-#ifdef SMP
-static int PMAP1cpu;
-static int PMAP1changedcpu;
-SYSCTL_INT(_debug, OID_AUTO, PMAP1changedcpu, CTLFLAG_RD,
- &PMAP1changedcpu, 0,
- "Number of times pmap_pte_quick changed CPU with same PMAP1");
-#endif
-static int PMAP1changed;
-SYSCTL_INT(_debug, OID_AUTO, PMAP1changed, CTLFLAG_RD,
- &PMAP1changed, 0,
- "Number of times pmap_pte_quick changed PMAP1");
-static int PMAP1unchanged;
-SYSCTL_INT(_debug, OID_AUTO, PMAP1unchanged, CTLFLAG_RD,
- &PMAP1unchanged, 0,
- "Number of times pmap_pte_quick didn't change PMAP1");
-static struct mtx PMAP2mutex;
-
-static void free_pv_chunk(struct pv_chunk *pc);
-static void free_pv_entry(pmap_t pmap, pv_entry_t pv);
-static pv_entry_t get_pv_entry(pmap_t pmap, boolean_t try);
-static void pmap_pvh_free(struct md_page *pvh, pmap_t pmap, vm_offset_t va);
-static pv_entry_t pmap_pvh_remove(struct md_page *pvh, pmap_t pmap,
- vm_offset_t va);
-
-static vm_page_t pmap_enter_quick_locked(multicall_entry_t **mcl, int *count, pmap_t pmap, vm_offset_t va,
- vm_page_t m, vm_prot_t prot, vm_page_t mpte);
-static void pmap_flush_page(vm_page_t m);
-static void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mode);
-static int pmap_remove_pte(pmap_t pmap, pt_entry_t *ptq, vm_offset_t sva,
- vm_page_t *free);
-static void pmap_remove_page(struct pmap *pmap, vm_offset_t va,
- vm_page_t *free);
-static void pmap_remove_entry(struct pmap *pmap, vm_page_t m,
- vm_offset_t va);
-static boolean_t pmap_try_insert_pv_entry(pmap_t pmap, vm_offset_t va,
- vm_page_t m);
-
-static vm_page_t pmap_allocpte(pmap_t pmap, vm_offset_t va, u_int flags);
-
-static vm_page_t _pmap_allocpte(pmap_t pmap, u_int ptepindex, u_int flags);
-static void _pmap_unwire_ptp(pmap_t pmap, vm_page_t m, vm_page_t *free);
-static pt_entry_t *pmap_pte_quick(pmap_t pmap, vm_offset_t va);
-static void pmap_pte_release(pt_entry_t *pte);
-static int pmap_unuse_pt(pmap_t, vm_offset_t, vm_page_t *);
-static boolean_t pmap_is_prefaultable_locked(pmap_t pmap, vm_offset_t addr);
-
-static __inline void pagezero(void *page);
-
-CTASSERT(1 << PDESHIFT == sizeof(pd_entry_t));
-CTASSERT(1 << PTESHIFT == sizeof(pt_entry_t));
-
-/*
- * If you get an error here, then you set KVA_PAGES wrong! See the
- * description of KVA_PAGES in sys/i386/include/pmap.h. It must be
- * multiple of 4 for a normal kernel, or a multiple of 8 for a PAE.
- */
-CTASSERT(KERNBASE % (1 << 24) == 0);
-
-void
-pd_set(struct pmap *pmap, int ptepindex, vm_paddr_t val, int type)
-{
- vm_paddr_t pdir_ma = vtomach(&pmap->pm_pdir[ptepindex]);
-
- switch (type) {
- case SH_PD_SET_VA:
-#if 0
- xen_queue_pt_update(shadow_pdir_ma,
- xpmap_ptom(val & ~(PG_RW)));
-#endif
- xen_queue_pt_update(pdir_ma,
- xpmap_ptom(val));
- break;
- case SH_PD_SET_VA_MA:
-#if 0
- xen_queue_pt_update(shadow_pdir_ma,
- val & ~(PG_RW));
-#endif
- xen_queue_pt_update(pdir_ma, val);
- break;
- case SH_PD_SET_VA_CLEAR:
-#if 0
- xen_queue_pt_update(shadow_pdir_ma, 0);
-#endif
- xen_queue_pt_update(pdir_ma, 0);
- break;
- }
-}
-
-/*
- * 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(vm_paddr_t firstaddr)
-{
- vm_offset_t va;
- pt_entry_t *pte, *unused;
- struct sysmaps *sysmaps;
- int i;
-
- /*
- * Initialize the first available kernel virtual address. However,
- * using "firstaddr" may waste a few pages of the kernel virtual
- * address space, because locore may not have mapped every physical
- * page that it allocated. Preferably, locore would provide a first
- * unused virtual address in addition to "firstaddr".
- */
- virtual_avail = (vm_offset_t) KERNBASE + firstaddr;
-
- virtual_end = VM_MAX_KERNEL_ADDRESS;
-
- /*
- * Initialize the kernel pmap (which is statically allocated).
- */
- PMAP_LOCK_INIT(kernel_pmap);
- kernel_pmap->pm_pdir = (pd_entry_t *) (KERNBASE + (u_int)IdlePTD);
-#ifdef PAE
- kernel_pmap->pm_pdpt = (pdpt_entry_t *) (KERNBASE + (u_int)IdlePDPT);
-#endif
- CPU_FILL(&kernel_pmap->pm_active); /* don't allow deactivation */
- TAILQ_INIT(&kernel_pmap->pm_pvchunk);
-
- /*
- * Initialize the global pv list lock.
- */
- rw_init_flags(&pvh_global_lock, "pmap pv global", RW_RECURSE);
-
- LIST_INIT(&allpmaps);
- mtx_init(&allpmaps_lock, "allpmaps", NULL, MTX_SPIN);
- mtx_lock_spin(&allpmaps_lock);
- LIST_INSERT_HEAD(&allpmaps, kernel_pmap, pm_list);
- mtx_unlock_spin(&allpmaps_lock);
- if (nkpt == 0)
- 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 = vtopte(va);
-
- /*
- * CMAP1/CMAP2 are used for zeroing and copying pages.
- * CMAP3 is used for the idle process page zeroing.
- */
- for (i = 0; i < MAXCPU; i++) {
- sysmaps = &sysmaps_pcpu[i];
- mtx_init(&sysmaps->lock, "SYSMAPS", NULL, MTX_DEF);
- SYSMAP(caddr_t, sysmaps->CMAP1, sysmaps->CADDR1, 1)
- SYSMAP(caddr_t, sysmaps->CMAP2, sysmaps->CADDR2, 1)
- PT_SET_MA(sysmaps->CADDR1, 0);
- PT_SET_MA(sysmaps->CADDR2, 0);
- }
- SYSMAP(caddr_t, CMAP3, CADDR3, 1)
- PT_SET_MA(CADDR3, 0);
-
- /*
- * Crashdump maps.
- */
- SYSMAP(caddr_t, unused, crashdumpmap, MAXDUMPPGS)
-
- /*
- * ptvmmap is used for reading arbitrary physical pages via /dev/mem.
- */
- SYSMAP(caddr_t, unused, ptvmmap, 1)
-
- /*
- * msgbufp is used to map the system message buffer.
- */
- SYSMAP(struct msgbuf *, unused, msgbufp, atop(round_page(msgbufsize)))
-
- /*
- * PADDR1 and PADDR2 are used by pmap_pte_quick() and pmap_pte(),
- * respectively.
- */
- SYSMAP(pt_entry_t *, PMAP1, PADDR1, 1)
- SYSMAP(pt_entry_t *, PMAP2, PADDR2, 1)
-
- mtx_init(&PMAP2mutex, "PMAP2", NULL, MTX_DEF);
-
- virtual_avail = va;
-
- /*
- * Leave in place an identity mapping (virt == phys) for the low 1 MB
- * physical memory region that is used by the ACPI wakeup code. This
- * mapping must not have PG_G set.
- */
-#ifndef XEN
- /*
- * leave here deliberately to show that this is not supported
- */
-#ifdef XBOX
- /* FIXME: This is gross, but needed for the XBOX. Since we are in such
- * an early stadium, we cannot yet neatly map video memory ... :-(
- * Better fixes are very welcome! */
- if (!arch_i386_is_xbox)
-#endif
- for (i = 1; i < NKPT; i++)
- PTD[i] = 0;
-
- /* Initialize the PAT MSR if present. */
- pmap_init_pat();
-
- /* Turn on PG_G on kernel page(s) */
- pmap_set_pg();
-#endif
-
-#ifdef HAMFISTED_LOCKING
- mtx_init(&createdelete_lock, "pmap create/delete", NULL, MTX_DEF);
-#endif
-}
-
-/*
- * Setup the PAT MSR.
- */
-void
-pmap_init_pat(void)
-{
- uint64_t pat_msr;
-
- /* Bail if this CPU doesn't implement PAT. */
- if (!(cpu_feature & CPUID_PAT))
- return;
-
- if (cpu_vendor_id != CPU_VENDOR_INTEL ||
- (CPUID_TO_FAMILY(cpu_id) == 6 && CPUID_TO_MODEL(cpu_id) >= 0xe)) {
- /*
- * Leave the indices 0-3 at the default of WB, WT, UC, and UC-.
- * Program 4 and 5 as WP and WC.
- * Leave 6 and 7 as UC and UC-.
- */
- pat_msr = rdmsr(MSR_PAT);
- pat_msr &= ~(PAT_MASK(4) | PAT_MASK(5));
- pat_msr |= PAT_VALUE(4, PAT_WRITE_PROTECTED) |
- PAT_VALUE(5, PAT_WRITE_COMBINING);
- pat_works = 1;
- } else {
- /*
- * Due to some Intel errata, we can only safely use the lower 4
- * PAT entries. Thus, just replace PAT Index 2 with WC instead
- * of UC-.
- *
- * Intel Pentium III Processor Specification Update
- * Errata E.27 (Upper Four PAT Entries Not Usable With Mode B
- * or Mode C Paging)
- *
- * Intel Pentium IV Processor Specification Update
- * Errata N46 (PAT Index MSB May Be Calculated Incorrectly)
- */
- pat_msr = rdmsr(MSR_PAT);
- pat_msr &= ~PAT_MASK(2);
- pat_msr |= PAT_VALUE(2, PAT_WRITE_COMBINING);
- pat_works = 0;
- }
- wrmsr(MSR_PAT, pat_msr);
-}
-
-/*
- * Initialize a vm_page's machine-dependent fields.
- */
-void
-pmap_page_init(vm_page_t m)
-{
-
- TAILQ_INIT(&m->md.pv_list);
- m->md.pat_mode = PAT_WRITE_BACK;
-}
-
-/*
- * ABuse the pte nodes for unmapped kva to thread a kva freelist through.
- * Requirements:
- * - Must deal with pages in order to ensure that none of the PG_* bits
- * are ever set, PG_V in particular.
- * - Assumes we can write to ptes without pte_store() atomic ops, even
- * on PAE systems. This should be ok.
- * - Assumes nothing will ever test these addresses for 0 to indicate
- * no mapping instead of correctly checking PG_V.
- * - Assumes a vm_offset_t will fit in a pte (true for i386).
- * Because PG_V is never set, there can be no mappings to invalidate.
- */
-static int ptelist_count = 0;
-static vm_offset_t
-pmap_ptelist_alloc(vm_offset_t *head)
-{
- vm_offset_t va;
- vm_offset_t *phead = (vm_offset_t *)*head;
-
- if (ptelist_count == 0) {
- printf("out of memory!!!!!!\n");
- return (0); /* Out of memory */
- }
- ptelist_count--;
- va = phead[ptelist_count];
- return (va);
-}
-
-static void
-pmap_ptelist_free(vm_offset_t *head, vm_offset_t va)
-{
- vm_offset_t *phead = (vm_offset_t *)*head;
-
- phead[ptelist_count++] = va;
-}
-
-static void
-pmap_ptelist_init(vm_offset_t *head, void *base, int npages)
-{
- int i, nstackpages;
- vm_offset_t va;
- vm_page_t m;
-
- nstackpages = (npages + PAGE_SIZE/sizeof(vm_offset_t) - 1)/ (PAGE_SIZE/sizeof(vm_offset_t));
- for (i = 0; i < nstackpages; i++) {
- va = (vm_offset_t)base + i * PAGE_SIZE;
- m = vm_page_alloc(NULL, i,
- VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED |
- VM_ALLOC_ZERO);
- pmap_qenter(va, &m, 1);
- }
-
- *head = (vm_offset_t)base;
- for (i = npages - 1; i >= nstackpages; i--) {
- va = (vm_offset_t)base + i * PAGE_SIZE;
- pmap_ptelist_free(head, va);
- }
-}
-
-
-/*
- * Initialize the pmap module.
- * Called by vm_init, to initialize any structures that the pmap
- * system needs to map virtual memory.
- */
-void
-pmap_init(void)
-{
-
- /*
- * 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.
- */
- TUNABLE_INT_FETCH("vm.pmap.shpgperproc", &shpgperproc);
- pv_entry_max = shpgperproc * maxproc + vm_cnt.v_page_count;
- TUNABLE_INT_FETCH("vm.pmap.pv_entries", &pv_entry_max);
- pv_entry_max = roundup(pv_entry_max, _NPCPV);
- pv_entry_high_water = 9 * (pv_entry_max / 10);
-
- pv_maxchunks = MAX(pv_entry_max / _NPCPV, maxproc);
- pv_chunkbase = (struct pv_chunk *)kva_alloc(PAGE_SIZE * pv_maxchunks);
- if (pv_chunkbase == NULL)
- panic("pmap_init: not enough kvm for pv chunks");
- pmap_ptelist_init(&pv_vafree, pv_chunkbase, pv_maxchunks);
-}
-
-
-SYSCTL_INT(_vm_pmap, OID_AUTO, pv_entry_max, CTLFLAG_RD, &pv_entry_max, 0,
- "Max number of PV entries");
-SYSCTL_INT(_vm_pmap, OID_AUTO, shpgperproc, CTLFLAG_RD, &shpgperproc, 0,
- "Page share factor per proc");
-
-static SYSCTL_NODE(_vm_pmap, OID_AUTO, pde, CTLFLAG_RD, 0,
- "2/4MB page mapping counters");
-
-static u_long pmap_pde_mappings;
-SYSCTL_ULONG(_vm_pmap_pde, OID_AUTO, mappings, CTLFLAG_RD,
- &pmap_pde_mappings, 0, "2/4MB page mappings");
-
-/***************************************************
- * Low level helper routines.....
- ***************************************************/
-
-/*
- * Determine the appropriate bits to set in a PTE or PDE for a specified
- * caching mode.
- */
-int
-pmap_cache_bits(int mode, boolean_t is_pde)
-{
- int pat_flag, pat_index, cache_bits;
-
- /* The PAT bit is different for PTE's and PDE's. */
- pat_flag = is_pde ? PG_PDE_PAT : PG_PTE_PAT;
-
- /* If we don't support PAT, map extended modes to older ones. */
- if (!(cpu_feature & CPUID_PAT)) {
- switch (mode) {
- case PAT_UNCACHEABLE:
- case PAT_WRITE_THROUGH:
- case PAT_WRITE_BACK:
- break;
- case PAT_UNCACHED:
- case PAT_WRITE_COMBINING:
- case PAT_WRITE_PROTECTED:
- mode = PAT_UNCACHEABLE;
- break;
- }
- }
-
- /* Map the caching mode to a PAT index. */
- if (pat_works) {
- switch (mode) {
- case PAT_UNCACHEABLE:
- pat_index = 3;
- break;
- case PAT_WRITE_THROUGH:
- pat_index = 1;
- break;
- case PAT_WRITE_BACK:
- pat_index = 0;
- break;
- case PAT_UNCACHED:
- pat_index = 2;
- break;
- case PAT_WRITE_COMBINING:
- pat_index = 5;
- break;
- case PAT_WRITE_PROTECTED:
- pat_index = 4;
- break;
- default:
- panic("Unknown caching mode %d\n", mode);
- }
- } else {
- switch (mode) {
- case PAT_UNCACHED:
- case PAT_UNCACHEABLE:
- case PAT_WRITE_PROTECTED:
- pat_index = 3;
- break;
- case PAT_WRITE_THROUGH:
- pat_index = 1;
- break;
- case PAT_WRITE_BACK:
- pat_index = 0;
- break;
- case PAT_WRITE_COMBINING:
- pat_index = 2;
- break;
- default:
- panic("Unknown caching mode %d\n", mode);
- }
- }
-
- /* Map the 3-bit index value into the PAT, PCD, and PWT bits. */
- cache_bits = 0;
- if (pat_index & 0x4)
- cache_bits |= pat_flag;
- if (pat_index & 0x2)
- cache_bits |= PG_NC_PCD;
- if (pat_index & 0x1)
- cache_bits |= PG_NC_PWT;
- return (cache_bits);
-}
-#ifdef SMP
-/*
- * For SMP, these functions have to use the IPI mechanism for coherence.
- *
- * N.B.: Before calling any of the following TLB invalidation functions,
- * the calling processor must ensure that all stores updating a non-
- * kernel page table are globally performed. Otherwise, another
- * processor could cache an old, pre-update entry without being
- * invalidated. This can happen one of two ways: (1) The pmap becomes
- * active on another processor after its pm_active field is checked by
- * one of the following functions but before a store updating the page
- * table is globally performed. (2) The pmap becomes active on another
- * processor before its pm_active field is checked but due to
- * speculative loads one of the following functions stills reads the
- * pmap as inactive on the other processor.
- *
- * The kernel page table is exempt because its pm_active field is
- * immutable. The kernel page table is always active on every
- * processor.
- */
-void
-pmap_invalidate_page(pmap_t pmap, vm_offset_t va)
-{
- cpuset_t other_cpus;
- u_int cpuid;
-
- CTR2(KTR_PMAP, "pmap_invalidate_page: pmap=%p va=0x%x",
- pmap, va);
-
- sched_pin();
- if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) {
- invlpg(va);
- smp_invlpg(va);
- } else {
- cpuid = PCPU_GET(cpuid);
- other_cpus = all_cpus;
- CPU_CLR(cpuid, &other_cpus);
- if (CPU_ISSET(cpuid, &pmap->pm_active))
- invlpg(va);
- CPU_AND(&other_cpus, &pmap->pm_active);
- if (!CPU_EMPTY(&other_cpus))
- smp_masked_invlpg(other_cpus, va);
- }
- sched_unpin();
- PT_UPDATES_FLUSH();
-}
-
-void
-pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
-{
- cpuset_t other_cpus;
- vm_offset_t addr;
- u_int cpuid;
-
- CTR3(KTR_PMAP, "pmap_invalidate_page: pmap=%p eva=0x%x sva=0x%x",
- pmap, sva, eva);
-
- sched_pin();
- if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) {
- for (addr = sva; addr < eva; addr += PAGE_SIZE)
- invlpg(addr);
- smp_invlpg_range(sva, eva);
- } else {
- cpuid = PCPU_GET(cpuid);
- other_cpus = all_cpus;
- CPU_CLR(cpuid, &other_cpus);
- if (CPU_ISSET(cpuid, &pmap->pm_active))
- for (addr = sva; addr < eva; addr += PAGE_SIZE)
- invlpg(addr);
- CPU_AND(&other_cpus, &pmap->pm_active);
- if (!CPU_EMPTY(&other_cpus))
- smp_masked_invlpg_range(other_cpus, sva, eva);
- }
- sched_unpin();
- PT_UPDATES_FLUSH();
-}
-
-void
-pmap_invalidate_all(pmap_t pmap)
-{
- cpuset_t other_cpus;
- u_int cpuid;
-
- CTR1(KTR_PMAP, "pmap_invalidate_page: pmap=%p", pmap);
-
- sched_pin();
- if (pmap == kernel_pmap || !CPU_CMP(&pmap->pm_active, &all_cpus)) {
- invltlb();
- smp_invltlb();
- } else {
- cpuid = PCPU_GET(cpuid);
- other_cpus = all_cpus;
- CPU_CLR(cpuid, &other_cpus);
- if (CPU_ISSET(cpuid, &pmap->pm_active))
- invltlb();
- CPU_AND(&other_cpus, &pmap->pm_active);
- if (!CPU_EMPTY(&other_cpus))
- smp_masked_invltlb(other_cpus);
- }
- sched_unpin();
-}
-
-void
-pmap_invalidate_cache(void)
-{
-
- sched_pin();
- wbinvd();
- smp_cache_flush();
- sched_unpin();
-}
-#else /* !SMP */
-/*
- * Normal, non-SMP, 486+ invalidation functions.
- * We inline these within pmap.c for speed.
- */
-PMAP_INLINE void
-pmap_invalidate_page(pmap_t pmap, vm_offset_t va)
-{
- CTR2(KTR_PMAP, "pmap_invalidate_page: pmap=%p va=0x%x",
- pmap, va);
-
- if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active))
- invlpg(va);
- PT_UPDATES_FLUSH();
-}
-
-PMAP_INLINE void
-pmap_invalidate_range(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
-{
- vm_offset_t addr;
-
- if (eva - sva > PAGE_SIZE)
- CTR3(KTR_PMAP, "pmap_invalidate_range: pmap=%p sva=0x%x eva=0x%x",
- pmap, sva, eva);
-
- if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active))
- for (addr = sva; addr < eva; addr += PAGE_SIZE)
- invlpg(addr);
- PT_UPDATES_FLUSH();
-}
-
-PMAP_INLINE void
-pmap_invalidate_all(pmap_t pmap)
-{
-
- CTR1(KTR_PMAP, "pmap_invalidate_all: pmap=%p", pmap);
-
- if (pmap == kernel_pmap || !CPU_EMPTY(&pmap->pm_active))
- invltlb();
-}
-
-PMAP_INLINE void
-pmap_invalidate_cache(void)
-{
-
- wbinvd();
-}
-#endif /* !SMP */
-
-#define PMAP_CLFLUSH_THRESHOLD (2 * 1024 * 1024)
-
-void
-pmap_invalidate_cache_range(vm_offset_t sva, vm_offset_t eva, boolean_t force)
-{
-
- if (force) {
- sva &= ~(vm_offset_t)cpu_clflush_line_size;
- } else {
- KASSERT((sva & PAGE_MASK) == 0,
- ("pmap_invalidate_cache_range: sva not page-aligned"));
- KASSERT((eva & PAGE_MASK) == 0,
- ("pmap_invalidate_cache_range: eva not page-aligned"));
- }
-
- if ((cpu_feature & CPUID_SS) != 0 && !force)
- ; /* If "Self Snoop" is supported, do nothing. */
- else if ((cpu_feature & CPUID_CLFSH) != 0 &&
- eva - sva < PMAP_CLFLUSH_THRESHOLD) {
-
- /*
- * Otherwise, do per-cache line flush. Use the mfence
- * instruction to insure that previous stores are
- * included in the write-back. The processor
- * propagates flush to other processors in the cache
- * coherence domain.
- */
- mfence();
- for (; sva < eva; sva += cpu_clflush_line_size)
- clflush(sva);
- mfence();
- } else {
-
- /*
- * No targeted cache flush methods are supported by CPU,
- * or the supplied range is bigger than 2MB.
- * Globally invalidate cache.
- */
- pmap_invalidate_cache();
- }
-}
-
-void
-pmap_invalidate_cache_pages(vm_page_t *pages, int count)
-{
- int i;
-
- if (count >= PMAP_CLFLUSH_THRESHOLD / PAGE_SIZE ||
- (cpu_feature & CPUID_CLFSH) == 0) {
- pmap_invalidate_cache();
- } else {
- for (i = 0; i < count; i++)
- pmap_flush_page(pages[i]);
- }
-}
-
-/*
- * Are we current address space or kernel? N.B. We return FALSE when
- * a pmap's page table is in use because a kernel thread is borrowing
- * it. The borrowed page table can change spontaneously, making any
- * dependence on its continued use subject to a race condition.
- */
-static __inline int
-pmap_is_current(pmap_t pmap)
-{
-
- return (pmap == kernel_pmap ||
- (pmap == vmspace_pmap(curthread->td_proc->p_vmspace) &&
- (pmap->pm_pdir[PTDPTDI] & PG_FRAME) == (PTDpde[0] & PG_FRAME)));
-}
-
-/*
- * If the given pmap is not the current or kernel pmap, the returned pte must
- * be released by passing it to pmap_pte_release().
- */
-pt_entry_t *
-pmap_pte(pmap_t pmap, vm_offset_t va)
-{
- pd_entry_t newpf;
- pd_entry_t *pde;
-
- pde = pmap_pde(pmap, va);
- if (*pde & PG_PS)
- return (pde);
- if (*pde != 0) {
- /* are we current address space or kernel? */
- if (pmap_is_current(pmap))
- return (vtopte(va));
- mtx_lock(&PMAP2mutex);
- newpf = *pde & PG_FRAME;
- if ((*PMAP2 & PG_FRAME) != newpf) {
- PT_SET_MA(PADDR2, newpf | PG_V | PG_A | PG_M);
- CTR3(KTR_PMAP, "pmap_pte: pmap=%p va=0x%x newpte=0x%08x",
- pmap, va, (*PMAP2 & 0xffffffff));
- }
- return (PADDR2 + (i386_btop(va) & (NPTEPG - 1)));
- }
- return (NULL);
-}
-
-/*
- * Releases a pte that was obtained from pmap_pte(). Be prepared for the pte
- * being NULL.
- */
-static __inline void
-pmap_pte_release(pt_entry_t *pte)
-{
-
- if ((pt_entry_t *)((vm_offset_t)pte & ~PAGE_MASK) == PADDR2) {
- CTR1(KTR_PMAP, "pmap_pte_release: pte=0x%jx",
- *PMAP2);
- rw_wlock(&pvh_global_lock);
- PT_SET_VA(PMAP2, 0, TRUE);
- rw_wunlock(&pvh_global_lock);
- mtx_unlock(&PMAP2mutex);
- }
-}
-
-static __inline void
-invlcaddr(void *caddr)
-{
-
- invlpg((u_int)caddr);
- PT_UPDATES_FLUSH();
-}
-
-/*
- * 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.
- *
- * If the given pmap is not the current pmap, pvh_global_lock
- * must be held and curthread pinned to a CPU.
- */
-static pt_entry_t *
-pmap_pte_quick(pmap_t pmap, vm_offset_t va)
-{
- pd_entry_t newpf;
- pd_entry_t *pde;
-
- pde = pmap_pde(pmap, va);
- if (*pde & PG_PS)
- return (pde);
- if (*pde != 0) {
- /* are we current address space or kernel? */
- if (pmap_is_current(pmap))
- return (vtopte(va));
- rw_assert(&pvh_global_lock, RA_WLOCKED);
- KASSERT(curthread->td_pinned > 0, ("curthread not pinned"));
- newpf = *pde & PG_FRAME;
- if ((*PMAP1 & PG_FRAME) != newpf) {
- PT_SET_MA(PADDR1, newpf | PG_V | PG_A | PG_M);
- CTR3(KTR_PMAP, "pmap_pte_quick: pmap=%p va=0x%x newpte=0x%08x",
- pmap, va, (u_long)*PMAP1);
-
-#ifdef SMP
- PMAP1cpu = PCPU_GET(cpuid);
-#endif
- PMAP1changed++;
- } else
-#ifdef SMP
- if (PMAP1cpu != PCPU_GET(cpuid)) {
- PMAP1cpu = PCPU_GET(cpuid);
- invlcaddr(PADDR1);
- PMAP1changedcpu++;
- } else
-#endif
- PMAP1unchanged++;
- return (PADDR1 + (i386_btop(va) & (NPTEPG - 1)));
- }
- return (0);
-}
-
-/*
- * Routine: pmap_extract
- * Function:
- * Extract the physical page address associated
- * with the given map/virtual_address pair.
- */
-vm_paddr_t
-pmap_extract(pmap_t pmap, vm_offset_t va)
-{
- vm_paddr_t rtval;
- pt_entry_t *pte;
- pd_entry_t pde;
- pt_entry_t pteval;
-
- rtval = 0;
- PMAP_LOCK(pmap);
- pde = pmap->pm_pdir[va >> PDRSHIFT];
- if (pde != 0) {
- if ((pde & PG_PS) != 0) {
- rtval = xpmap_mtop(pde & PG_PS_FRAME) | (va & PDRMASK);
- PMAP_UNLOCK(pmap);
- return rtval;
- }
- pte = pmap_pte(pmap, va);
- pteval = *pte ? xpmap_mtop(*pte) : 0;
- rtval = (pteval & PG_FRAME) | (va & PAGE_MASK);
- pmap_pte_release(pte);
- }
- PMAP_UNLOCK(pmap);
- return (rtval);
-}
-
-/*
- * Routine: pmap_extract_ma
- * Function:
- * Like pmap_extract, but returns machine address
- */
-vm_paddr_t
-pmap_extract_ma(pmap_t pmap, vm_offset_t va)
-{
- vm_paddr_t rtval;
- pt_entry_t *pte;
- pd_entry_t pde;
-
- rtval = 0;
- PMAP_LOCK(pmap);
- pde = pmap->pm_pdir[va >> PDRSHIFT];
- if (pde != 0) {
- if ((pde & PG_PS) != 0) {
- rtval = (pde & ~PDRMASK) | (va & PDRMASK);
- PMAP_UNLOCK(pmap);
- return rtval;
- }
- pte = pmap_pte(pmap, va);
- rtval = (*pte & PG_FRAME) | (va & PAGE_MASK);
- pmap_pte_release(pte);
- }
- PMAP_UNLOCK(pmap);
- return (rtval);
-}
-
-/*
- * Routine: pmap_extract_and_hold
- * Function:
- * Atomically extract and hold the physical page
- * with the given pmap and virtual address pair
- * if that mapping permits the given protection.
- */
-vm_page_t
-pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot)
-{
- pd_entry_t pde;
- pt_entry_t pte, *ptep;
- vm_page_t m;
- vm_paddr_t pa;
-
- pa = 0;
- m = NULL;
- PMAP_LOCK(pmap);
-retry:
- pde = PT_GET(pmap_pde(pmap, va));
- if (pde != 0) {
- if (pde & PG_PS) {
- if ((pde & PG_RW) || (prot & VM_PROT_WRITE) == 0) {
- if (vm_page_pa_tryrelock(pmap, (pde &
- PG_PS_FRAME) | (va & PDRMASK), &pa))
- goto retry;
- m = PHYS_TO_VM_PAGE((pde & PG_PS_FRAME) |
- (va & PDRMASK));
- vm_page_hold(m);
- }
- } else {
- ptep = pmap_pte(pmap, va);
- pte = PT_GET(ptep);
- pmap_pte_release(ptep);
- if (pte != 0 &&
- ((pte & PG_RW) || (prot & VM_PROT_WRITE) == 0)) {
- if (vm_page_pa_tryrelock(pmap, pte & PG_FRAME,
- &pa))
- goto retry;
- m = PHYS_TO_VM_PAGE(pte & PG_FRAME);
- vm_page_hold(m);
- }
- }
- }
- PA_UNLOCK_COND(pa);
- PMAP_UNLOCK(pmap);
- return (m);
-}
-
-/***************************************************
- * Low level mapping routines.....
- ***************************************************/
-
-/*
- * Add a wired page to the kva.
- * Note: not SMP coherent.
- *
- * This function may be used before pmap_bootstrap() is called.
- */
-void
-pmap_kenter(vm_offset_t va, vm_paddr_t pa)
-{
-
- PT_SET_MA(va, xpmap_ptom(pa)| PG_RW | PG_V | pgeflag);
-}
-
-void
-pmap_kenter_ma(vm_offset_t va, vm_paddr_t ma)
-{
- pt_entry_t *pte;
-
- pte = vtopte(va);
- pte_store_ma(pte, ma | PG_RW | PG_V | pgeflag);
-}
-
-static __inline void
-pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mode)
-{
-
- PT_SET_MA(va, pa | PG_RW | PG_V | pgeflag | pmap_cache_bits(mode, 0));
-}
-
-/*
- * Remove a page from the kernel pagetables.
- * Note: not SMP coherent.
- *
- * This function may be used before pmap_bootstrap() is called.
- */
-PMAP_INLINE void
-pmap_kremove(vm_offset_t va)
-{
- pt_entry_t *pte;
-
- pte = vtopte(va);
- PT_CLEAR_VA(pte, FALSE);
-}
-
-/*
- * Used to map a range of physical addresses into kernel
- * virtual address space.
- *
- * The value passed in '*virt' is a suggested virtual address for
- * the mapping. Architectures which can support a direct-mapped
- * physical to virtual region can return the appropriate address
- * within that region, leaving '*virt' unchanged. Other
- * architectures should map the pages starting at '*virt' and
- * update '*virt' with the first usable address after the mapped
- * region.
- */
-vm_offset_t
-pmap_map(vm_offset_t *virt, vm_paddr_t start, vm_paddr_t end, int prot)
-{
- vm_offset_t va, sva;
-
- va = sva = *virt;
- CTR4(KTR_PMAP, "pmap_map: va=0x%x start=0x%jx end=0x%jx prot=0x%x",
- va, start, end, prot);
- while (start < end) {
- pmap_kenter(va, start);
- va += PAGE_SIZE;
- start += PAGE_SIZE;
- }
- pmap_invalidate_range(kernel_pmap, sva, va);
- *virt = va;
- return (sva);
-}
-
-
-/*
- * 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.
- * Note: SMP coherent. Uses a ranged shootdown IPI.
- */
-void
-pmap_qenter(vm_offset_t sva, vm_page_t *ma, int count)
-{
- pt_entry_t *endpte, *pte;
- vm_paddr_t pa;
- vm_offset_t va = sva;
- int mclcount = 0;
- multicall_entry_t mcl[16];
- multicall_entry_t *mclp = mcl;
- int error;
-
- CTR2(KTR_PMAP, "pmap_qenter:sva=0x%x count=%d", va, count);
- pte = vtopte(sva);
- endpte = pte + count;
- while (pte < endpte) {
- pa = VM_PAGE_TO_MACH(*ma) | pgeflag | PG_RW | PG_V | PG_M | PG_A;
-
- mclp->op = __HYPERVISOR_update_va_mapping;
- mclp->args[0] = va;
- mclp->args[1] = (uint32_t)(pa & 0xffffffff);
- mclp->args[2] = (uint32_t)(pa >> 32);
- mclp->args[3] = (*pte & PG_V) ? UVMF_INVLPG|UVMF_ALL : 0;
-
- va += PAGE_SIZE;
- pte++;
- ma++;
- mclp++;
- mclcount++;
- if (mclcount == 16) {
- error = HYPERVISOR_multicall(mcl, mclcount);
- mclp = mcl;
- mclcount = 0;
- KASSERT(error == 0, ("bad multicall %d", error));
- }
- }
- if (mclcount) {
- error = HYPERVISOR_multicall(mcl, mclcount);
- KASSERT(error == 0, ("bad multicall %d", error));
- }
-
-#ifdef INVARIANTS
- for (pte = vtopte(sva), mclcount = 0; mclcount < count; mclcount++, pte++)
- KASSERT(*pte, ("pte not set for va=0x%x", sva + mclcount*PAGE_SIZE));
-#endif
-}
-
-/*
- * This routine tears out page mappings from the
- * kernel -- it is meant only for temporary mappings.
- * Note: SMP coherent. Uses a ranged shootdown IPI.
- */
-void
-pmap_qremove(vm_offset_t sva, int count)
-{
- vm_offset_t va;
-
- CTR2(KTR_PMAP, "pmap_qremove: sva=0x%x count=%d", sva, count);
- va = sva;
- rw_wlock(&pvh_global_lock);
- critical_enter();
- while (count-- > 0) {
- pmap_kremove(va);
- va += PAGE_SIZE;
- }
- PT_UPDATES_FLUSH();
- pmap_invalidate_range(kernel_pmap, sva, va);
- critical_exit();
- rw_wunlock(&pvh_global_lock);
-}
-
-/***************************************************
- * Page table page management routines.....
- ***************************************************/
-static __inline void
-pmap_free_zero_pages(vm_page_t free)
-{
- vm_page_t m;
-
- while (free != NULL) {
- m = free;
- free = (void *)m->object;
- m->object = NULL;
- vm_page_free_zero(m);
- }
-}
-
-/*
- * Decrements a page table page's wire count, which is used to record the
- * number of valid page table entries within the page. If the wire count
- * drops to zero, then the page table page is unmapped. Returns TRUE if the
- * page table page was unmapped and FALSE otherwise.
- */
-static inline boolean_t
-pmap_unwire_ptp(pmap_t pmap, vm_page_t m, vm_page_t *free)
-{
-
- --m->wire_count;
- if (m->wire_count == 0) {
- _pmap_unwire_ptp(pmap, m, free);
- return (TRUE);
- } else
- return (FALSE);
-}
-
-static void
-_pmap_unwire_ptp(pmap_t pmap, vm_page_t m, vm_page_t *free)
-{
- vm_offset_t pteva;
-
- PT_UPDATES_FLUSH();
- /*
- * unmap the page table page
- */
- xen_pt_unpin(pmap->pm_pdir[m->pindex]);
- /*
- * page *might* contain residual mapping :-/
- */
- PD_CLEAR_VA(pmap, m->pindex, TRUE);
- pmap_zero_page(m);
- --pmap->pm_stats.resident_count;
-
- /*
- * This is a release store so that the ordinary store unmapping
- * the page table page is globally performed before TLB shoot-
- * down is begun.
- */
- atomic_subtract_rel_int(&vm_cnt.v_wire_count, 1);
-
- /*
- * Do an invltlb to make the invalidated mapping
- * take effect immediately.
- */
- pteva = VM_MAXUSER_ADDRESS + i386_ptob(m->pindex);
- pmap_invalidate_page(pmap, pteva);
-
- /*
- * Put page on a list so that it is released after
- * *ALL* TLB shootdown is done
- */
- m->object = (void *)*free;
- *free = m;
-}
-
-/*
- * 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_t pmap, vm_offset_t va, vm_page_t *free)
-{
- pd_entry_t ptepde;
- vm_page_t mpte;
-
- if (va >= VM_MAXUSER_ADDRESS)
- return (0);
- ptepde = PT_GET(pmap_pde(pmap, va));
- mpte = PHYS_TO_VM_PAGE(ptepde & PG_FRAME);
- return (pmap_unwire_ptp(pmap, mpte, free));
-}
-
-/*
- * Initialize the pmap for the swapper process.
- */
-void
-pmap_pinit0(pmap_t pmap)
-{
-
- PMAP_LOCK_INIT(pmap);
- /*
- * Since the page table directory is shared with the kernel pmap,
- * which is already included in the list "allpmaps", this pmap does
- * not need to be inserted into that list.
- */
- pmap->pm_pdir = (pd_entry_t *)(KERNBASE + (vm_offset_t)IdlePTD);
-#ifdef PAE
- pmap->pm_pdpt = (pdpt_entry_t *)(KERNBASE + (vm_offset_t)IdlePDPT);
-#endif
- CPU_ZERO(&pmap->pm_active);
- PCPU_SET(curpmap, pmap);
- TAILQ_INIT(&pmap->pm_pvchunk);
- bzero(&pmap->pm_stats, sizeof pmap->pm_stats);
-}
-
-/*
- * Initialize a preallocated and zeroed pmap structure,
- * such as one in a vmspace structure.
- */
-int
-pmap_pinit(pmap_t pmap)
-{
- vm_page_t m, ptdpg[NPGPTD + 1];
- int npgptd = NPGPTD + 1;
- int i;
-
-#ifdef HAMFISTED_LOCKING
- mtx_lock(&createdelete_lock);
-#endif
-
- /*
- * 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 *)kva_alloc(NBPTD);
- if (pmap->pm_pdir == NULL) {
-#ifdef HAMFISTED_LOCKING
- mtx_unlock(&createdelete_lock);
-#endif
- return (0);
- }
-#ifdef PAE
- pmap->pm_pdpt = (pd_entry_t *)kva_alloc(1);
-#endif
- }
-
- /*
- * allocate the page directory page(s)
- */
- for (i = 0; i < npgptd;) {
- m = vm_page_alloc(NULL, 0, VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ |
- VM_ALLOC_WIRED | VM_ALLOC_ZERO);
- if (m == NULL)
- VM_WAIT;
- else {
- ptdpg[i++] = m;
- }
- }
-
- pmap_qenter((vm_offset_t)pmap->pm_pdir, ptdpg, NPGPTD);
-
- for (i = 0; i < NPGPTD; i++)
- if ((ptdpg[i]->flags & PG_ZERO) == 0)
- pagezero(pmap->pm_pdir + (i * NPDEPG));
-
- mtx_lock_spin(&allpmaps_lock);
- LIST_INSERT_HEAD(&allpmaps, pmap, pm_list);
- /* Copy the kernel page table directory entries. */
- bcopy(PTD + KPTDI, pmap->pm_pdir + KPTDI, nkpt * sizeof(pd_entry_t));
- mtx_unlock_spin(&allpmaps_lock);
-
-#ifdef PAE
- pmap_qenter((vm_offset_t)pmap->pm_pdpt, &ptdpg[NPGPTD], 1);
- if ((ptdpg[NPGPTD]->flags & PG_ZERO) == 0)
- bzero(pmap->pm_pdpt, PAGE_SIZE);
- for (i = 0; i < NPGPTD; i++) {
- vm_paddr_t ma;
-
- ma = VM_PAGE_TO_MACH(ptdpg[i]);
- pmap->pm_pdpt[i] = ma | PG_V;
-
- }
-#endif
- for (i = 0; i < NPGPTD; i++) {
- pt_entry_t *pd;
- vm_paddr_t ma;
-
- ma = VM_PAGE_TO_MACH(ptdpg[i]);
- pd = pmap->pm_pdir + (i * NPDEPG);
- PT_SET_MA(pd, *vtopte((vm_offset_t)pd) & ~(PG_M|PG_A|PG_U|PG_RW));
-#if 0
- xen_pgd_pin(ma);
-#endif
- }
-
-#ifdef PAE
- PT_SET_MA(pmap->pm_pdpt, *vtopte((vm_offset_t)pmap->pm_pdpt) & ~PG_RW);
-#endif
- rw_wlock(&pvh_global_lock);
- xen_flush_queue();
- xen_pgdpt_pin(VM_PAGE_TO_MACH(ptdpg[NPGPTD]));
- for (i = 0; i < NPGPTD; i++) {
- vm_paddr_t ma = VM_PAGE_TO_MACH(ptdpg[i]);
- PT_SET_VA_MA(&pmap->pm_pdir[PTDPTDI + i], ma | PG_V | PG_A, FALSE);
- }
- xen_flush_queue();
- rw_wunlock(&pvh_global_lock);
- CPU_ZERO(&pmap->pm_active);
- TAILQ_INIT(&pmap->pm_pvchunk);
- bzero(&pmap->pm_stats, sizeof pmap->pm_stats);
-
-#ifdef HAMFISTED_LOCKING
- mtx_unlock(&createdelete_lock);
-#endif
- return (1);
-}
-
-/*
- * this routine is called if the page table page is not
- * mapped correctly.
- */
-static vm_page_t
-_pmap_allocpte(pmap_t pmap, u_int ptepindex, u_int flags)
-{
- vm_paddr_t ptema;
- vm_page_t m;
-
- /*
- * Allocate a page table page.
- */
- if ((m = vm_page_alloc(NULL, ptepindex, VM_ALLOC_NOOBJ |
- VM_ALLOC_WIRED | VM_ALLOC_ZERO)) == NULL) {
- if ((flags & PMAP_ENTER_NOSLEEP) == 0) {
- PMAP_UNLOCK(pmap);
- rw_wunlock(&pvh_global_lock);
- VM_WAIT;
- rw_wlock(&pvh_global_lock);
- PMAP_LOCK(pmap);
- }
-
- /*
- * Indicate the need to retry. While waiting, the page table
- * page may have been allocated.
- */
- return (NULL);
- }
- if ((m->flags & PG_ZERO) == 0)
- pmap_zero_page(m);
-
- /*
- * Map the pagetable page into the process address space, if
- * it isn't already there.
- */
-
- pmap->pm_stats.resident_count++;
-
- ptema = VM_PAGE_TO_MACH(m);
- xen_pt_pin(ptema);
- PT_SET_VA_MA(&pmap->pm_pdir[ptepindex],
- (ptema | PG_U | PG_RW | PG_V | PG_A | PG_M), TRUE);
-
- KASSERT(pmap->pm_pdir[ptepindex],
- ("_pmap_allocpte: ptepindex=%d did not get mapped", ptepindex));
- return (m);
-}
-
-static vm_page_t
-pmap_allocpte(pmap_t pmap, vm_offset_t va, u_int flags)
-{
- u_int ptepindex;
- pd_entry_t ptema;
- vm_page_t m;
-
- /*
- * Calculate pagetable page index
- */
- ptepindex = va >> PDRSHIFT;
-retry:
- /*
- * Get the page directory entry
- */
- ptema = pmap->pm_pdir[ptepindex];
-
- /*
- * This supports switching from a 4MB page to a
- * normal 4K page.
- */
- if (ptema & PG_PS) {
- /*
- * XXX
- */
- pmap->pm_pdir[ptepindex] = 0;
- ptema = 0;
- pmap->pm_stats.resident_count -= NBPDR / PAGE_SIZE;
- pmap_invalidate_all(kernel_pmap);
- }
-
- /*
- * If the page table page is mapped, we just increment the
- * hold count, and activate it.
- */
- if (ptema & PG_V) {
- m = PHYS_TO_VM_PAGE(xpmap_mtop(ptema) & PG_FRAME);
- m->wire_count++;
- } else {
- /*
- * Here if the pte page isn't mapped, or if it has
- * been deallocated.
- */
- CTR3(KTR_PMAP, "pmap_allocpte: pmap=%p va=0x%08x flags=0x%x",
- pmap, va, flags);
- m = _pmap_allocpte(pmap, ptepindex, flags);
- if (m == NULL && (flags & PMAP_ENTER_NOSLEEP) == 0)
- goto retry;
-
- KASSERT(pmap->pm_pdir[ptepindex], ("ptepindex=%d did not get mapped", ptepindex));
- }
- return (m);
-}
-
-
-/***************************************************
-* 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_t pmap)
-{
- vm_page_t m, ptdpg[2*NPGPTD+1];
- vm_paddr_t ma;
- int i;
-#ifdef PAE
- int npgptd = NPGPTD + 1;
-#else
- int npgptd = NPGPTD;
-#endif
-
- KASSERT(pmap->pm_stats.resident_count == 0,
- ("pmap_release: pmap resident count %ld != 0",
- pmap->pm_stats.resident_count));
- PT_UPDATES_FLUSH();
-
-#ifdef HAMFISTED_LOCKING
- mtx_lock(&createdelete_lock);
-#endif
-
- KASSERT(CPU_EMPTY(&pmap->pm_active),
- ("releasing active pmap %p", pmap));
- mtx_lock_spin(&allpmaps_lock);
- LIST_REMOVE(pmap, pm_list);
- mtx_unlock_spin(&allpmaps_lock);
-
- for (i = 0; i < NPGPTD; i++)
- ptdpg[i] = PHYS_TO_VM_PAGE(vtophys(pmap->pm_pdir + (i*NPDEPG)) & PG_FRAME);
- pmap_qremove((vm_offset_t)pmap->pm_pdir, NPGPTD);
-#ifdef PAE
- ptdpg[NPGPTD] = PHYS_TO_VM_PAGE(vtophys(pmap->pm_pdpt));
-#endif
-
- for (i = 0; i < npgptd; i++) {
- m = ptdpg[i];
- ma = VM_PAGE_TO_MACH(m);
- /* unpinning L1 and L2 treated the same */
-#if 0
- xen_pgd_unpin(ma);
-#else
- if (i == NPGPTD)
- xen_pgd_unpin(ma);
-#endif
-#ifdef PAE
- if (i < NPGPTD)
- KASSERT(VM_PAGE_TO_MACH(m) == (pmap->pm_pdpt[i] & PG_FRAME),
- ("pmap_release: got wrong ptd page"));
-#endif
- m->wire_count--;
- atomic_subtract_int(&vm_cnt.v_wire_count, 1);
- vm_page_free(m);
- }
-#ifdef PAE
- pmap_qremove((vm_offset_t)pmap->pm_pdpt, 1);
-#endif
-
-#ifdef HAMFISTED_LOCKING
- mtx_unlock(&createdelete_lock);
-#endif
-}
-
-static int
-kvm_size(SYSCTL_HANDLER_ARGS)
-{
- unsigned long ksize = VM_MAX_KERNEL_ADDRESS - KERNBASE;
-
- return (sysctl_handle_long(oidp, &ksize, 0, req));
-}
-SYSCTL_PROC(_vm, OID_AUTO, kvm_size, CTLTYPE_LONG|CTLFLAG_RD,
- 0, 0, kvm_size, "IU", "Size of KVM");
-
-static int
-kvm_free(SYSCTL_HANDLER_ARGS)
-{
- unsigned long kfree = VM_MAX_KERNEL_ADDRESS - kernel_vm_end;
-
- return (sysctl_handle_long(oidp, &kfree, 0, req));
-}
-SYSCTL_PROC(_vm, OID_AUTO, kvm_free, CTLTYPE_LONG|CTLFLAG_RD,
- 0, 0, kvm_free, "IU", "Amount of KVM free");
-
-/*
- * grow the number of kernel page table entries, if needed
- */
-void
-pmap_growkernel(vm_offset_t addr)
-{
- struct pmap *pmap;
- vm_paddr_t ptppaddr;
- vm_page_t nkpg;
- pd_entry_t newpdir;
-
- mtx_assert(&kernel_map->system_mtx, MA_OWNED);
- 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++;
- if (kernel_vm_end - 1 >= kernel_map->max_offset) {
- kernel_vm_end = kernel_map->max_offset;
- break;
- }
- }
- }
- addr = roundup2(addr, NBPDR);
- if (addr - 1 >= kernel_map->max_offset)
- addr = kernel_map->max_offset;
- while (kernel_vm_end < addr) {
- if (pdir_pde(PTD, kernel_vm_end)) {
- kernel_vm_end = (kernel_vm_end + NBPDR) & ~PDRMASK;
- if (kernel_vm_end - 1 >= kernel_map->max_offset) {
- kernel_vm_end = kernel_map->max_offset;
- break;
- }
- continue;
- }
-
- nkpg = vm_page_alloc(NULL, kernel_vm_end >> PDRSHIFT,
- VM_ALLOC_INTERRUPT | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED |
- VM_ALLOC_ZERO);
- if (nkpg == NULL)
- panic("pmap_growkernel: no memory to grow kernel");
-
- nkpt++;
-
- if ((nkpg->flags & PG_ZERO) == 0)
- pmap_zero_page(nkpg);
- ptppaddr = VM_PAGE_TO_PHYS(nkpg);
- newpdir = (pd_entry_t) (ptppaddr | PG_V | PG_RW | PG_A | PG_M);
- rw_wlock(&pvh_global_lock);
- PD_SET_VA(kernel_pmap, (kernel_vm_end >> PDRSHIFT), newpdir, TRUE);
- mtx_lock_spin(&allpmaps_lock);
- LIST_FOREACH(pmap, &allpmaps, pm_list)
- PD_SET_VA(pmap, (kernel_vm_end >> PDRSHIFT), newpdir, TRUE);
-
- mtx_unlock_spin(&allpmaps_lock);
- rw_wunlock(&pvh_global_lock);
-
- kernel_vm_end = (kernel_vm_end + NBPDR) & ~PDRMASK;
- if (kernel_vm_end - 1 >= kernel_map->max_offset) {
- kernel_vm_end = kernel_map->max_offset;
- break;
- }
- }
-}
-
-
-/***************************************************
- * page management routines.
- ***************************************************/
-
-CTASSERT(sizeof(struct pv_chunk) == PAGE_SIZE);
-CTASSERT(_NPCM == 11);
-CTASSERT(_NPCPV == 336);
-
-static __inline struct pv_chunk *
-pv_to_chunk(pv_entry_t pv)
-{
-
- return ((struct pv_chunk *)((uintptr_t)pv & ~(uintptr_t)PAGE_MASK));
-}
-
-#define PV_PMAP(pv) (pv_to_chunk(pv)->pc_pmap)
-
-#define PC_FREE0_9 0xfffffffful /* Free values for index 0 through 9 */
-#define PC_FREE10 0x0000fffful /* Free values for index 10 */
-
-static const uint32_t pc_freemask[_NPCM] = {
- PC_FREE0_9, PC_FREE0_9, PC_FREE0_9,
- PC_FREE0_9, PC_FREE0_9, PC_FREE0_9,
- PC_FREE0_9, PC_FREE0_9, PC_FREE0_9,
- PC_FREE0_9, PC_FREE10
-};
-
-SYSCTL_INT(_vm_pmap, OID_AUTO, pv_entry_count, CTLFLAG_RD, &pv_entry_count, 0,
- "Current number of pv entries");
-
-#ifdef PV_STATS
-static int pc_chunk_count, pc_chunk_allocs, pc_chunk_frees, pc_chunk_tryfail;
-
-SYSCTL_INT(_vm_pmap, OID_AUTO, pc_chunk_count, CTLFLAG_RD, &pc_chunk_count, 0,
- "Current number of pv entry chunks");
-SYSCTL_INT(_vm_pmap, OID_AUTO, pc_chunk_allocs, CTLFLAG_RD, &pc_chunk_allocs, 0,
- "Current number of pv entry chunks allocated");
-SYSCTL_INT(_vm_pmap, OID_AUTO, pc_chunk_frees, CTLFLAG_RD, &pc_chunk_frees, 0,
- "Current number of pv entry chunks frees");
-SYSCTL_INT(_vm_pmap, OID_AUTO, pc_chunk_tryfail, CTLFLAG_RD, &pc_chunk_tryfail, 0,
- "Number of times tried to get a chunk page but failed.");
-
-static long pv_entry_frees, pv_entry_allocs;
-static int pv_entry_spare;
-
-SYSCTL_LONG(_vm_pmap, OID_AUTO, pv_entry_frees, CTLFLAG_RD, &pv_entry_frees, 0,
- "Current number of pv entry frees");
-SYSCTL_LONG(_vm_pmap, OID_AUTO, pv_entry_allocs, CTLFLAG_RD, &pv_entry_allocs, 0,
- "Current number of pv entry allocs");
-SYSCTL_INT(_vm_pmap, OID_AUTO, pv_entry_spare, CTLFLAG_RD, &pv_entry_spare, 0,
- "Current number of spare pv entries");
-#endif
-
-/*
- * We are in a serious low memory condition. Resort to
- * drastic measures to free some pages so we can allocate
- * another pv entry chunk.
- */
-static vm_page_t
-pmap_pv_reclaim(pmap_t locked_pmap)
-{
- struct pch newtail;
- struct pv_chunk *pc;
- pmap_t pmap;
- pt_entry_t *pte, tpte;
- pv_entry_t pv;
- vm_offset_t va;
- vm_page_t free, m, m_pc;
- uint32_t inuse;
- int bit, field, freed;
-
- PMAP_LOCK_ASSERT(locked_pmap, MA_OWNED);
- pmap = NULL;
- free = m_pc = NULL;
- TAILQ_INIT(&newtail);
- while ((pc = TAILQ_FIRST(&pv_chunks)) != NULL && (pv_vafree == 0 ||
- free == NULL)) {
- TAILQ_REMOVE(&pv_chunks, pc, pc_lru);
- if (pmap != pc->pc_pmap) {
- if (pmap != NULL) {
- pmap_invalidate_all(pmap);
- if (pmap != locked_pmap)
- PMAP_UNLOCK(pmap);
- }
- pmap = pc->pc_pmap;
- /* Avoid deadlock and lock recursion. */
- if (pmap > locked_pmap)
- PMAP_LOCK(pmap);
- else if (pmap != locked_pmap && !PMAP_TRYLOCK(pmap)) {
- pmap = NULL;
- TAILQ_INSERT_TAIL(&newtail, pc, pc_lru);
- continue;
- }
- }
-
- /*
- * Destroy every non-wired, 4 KB page mapping in the chunk.
- */
- freed = 0;
- for (field = 0; field < _NPCM; field++) {
- for (inuse = ~pc->pc_map[field] & pc_freemask[field];
- inuse != 0; inuse &= ~(1UL << bit)) {
- bit = bsfl(inuse);
- pv = &pc->pc_pventry[field * 32 + bit];
- va = pv->pv_va;
- pte = pmap_pte(pmap, va);
- tpte = *pte;
- if ((tpte & PG_W) == 0)
- tpte = pte_load_clear(pte);
- pmap_pte_release(pte);
- if ((tpte & PG_W) != 0)
- continue;
- KASSERT(tpte != 0,
- ("pmap_pv_reclaim: pmap %p va %x zero pte",
- pmap, va));
- if ((tpte & PG_G) != 0)
- pmap_invalidate_page(pmap, va);
- m = PHYS_TO_VM_PAGE(tpte & PG_FRAME);
- if ((tpte & (PG_M | PG_RW)) == (PG_M | PG_RW))
- vm_page_dirty(m);
- if ((tpte & PG_A) != 0)
- vm_page_aflag_set(m, PGA_REFERENCED);
- TAILQ_REMOVE(&m->md.pv_list, pv, pv_next);
- if (TAILQ_EMPTY(&m->md.pv_list))
- vm_page_aflag_clear(m, PGA_WRITEABLE);
- pc->pc_map[field] |= 1UL << bit;
- pmap_unuse_pt(pmap, va, &free);
- freed++;
- }
- }
- if (freed == 0) {
- TAILQ_INSERT_TAIL(&newtail, pc, pc_lru);
- continue;
- }
- /* Every freed mapping is for a 4 KB page. */
- pmap->pm_stats.resident_count -= freed;
- PV_STAT(pv_entry_frees += freed);
- PV_STAT(pv_entry_spare += freed);
- pv_entry_count -= freed;
- TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list);
- for (field = 0; field < _NPCM; field++)
- if (pc->pc_map[field] != pc_freemask[field]) {
- TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc,
- pc_list);
- TAILQ_INSERT_TAIL(&newtail, pc, pc_lru);
-
- /*
- * One freed pv entry in locked_pmap is
- * sufficient.
- */
- if (pmap == locked_pmap)
- goto out;
- break;
- }
- if (field == _NPCM) {
- PV_STAT(pv_entry_spare -= _NPCPV);
- PV_STAT(pc_chunk_count--);
- PV_STAT(pc_chunk_frees++);
- /* Entire chunk is free; return it. */
- m_pc = PHYS_TO_VM_PAGE(pmap_kextract((vm_offset_t)pc));
- pmap_qremove((vm_offset_t)pc, 1);
- pmap_ptelist_free(&pv_vafree, (vm_offset_t)pc);
- break;
- }
- }
-out:
- TAILQ_CONCAT(&pv_chunks, &newtail, pc_lru);
- if (pmap != NULL) {
- pmap_invalidate_all(pmap);
- if (pmap != locked_pmap)
- PMAP_UNLOCK(pmap);
- }
- if (m_pc == NULL && pv_vafree != 0 && free != NULL) {
- m_pc = free;
- free = (void *)m_pc->object;
- /* Recycle a freed page table page. */
- m_pc->wire_count = 1;
- atomic_add_int(&vm_cnt.v_wire_count, 1);
- }
- pmap_free_zero_pages(free);
- return (m_pc);
-}
-
-/*
- * free the pv_entry back to the free list
- */
-static void
-free_pv_entry(pmap_t pmap, pv_entry_t pv)
-{
- struct pv_chunk *pc;
- int idx, field, bit;
-
- rw_assert(&pvh_global_lock, RA_WLOCKED);
- PMAP_LOCK_ASSERT(pmap, MA_OWNED);
- PV_STAT(pv_entry_frees++);
- PV_STAT(pv_entry_spare++);
- pv_entry_count--;
- pc = pv_to_chunk(pv);
- idx = pv - &pc->pc_pventry[0];
- field = idx / 32;
- bit = idx % 32;
- pc->pc_map[field] |= 1ul << bit;
- for (idx = 0; idx < _NPCM; idx++)
- if (pc->pc_map[idx] != pc_freemask[idx]) {
- /*
- * 98% of the time, pc is already at the head of the
- * list. If it isn't already, move it to the head.
- */
- if (__predict_false(TAILQ_FIRST(&pmap->pm_pvchunk) !=
- pc)) {
- TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list);
- TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc,
- pc_list);
- }
- return;
- }
- TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list);
- free_pv_chunk(pc);
-}
-
-static void
-free_pv_chunk(struct pv_chunk *pc)
-{
- vm_page_t m;
-
- TAILQ_REMOVE(&pv_chunks, pc, pc_lru);
- PV_STAT(pv_entry_spare -= _NPCPV);
- PV_STAT(pc_chunk_count--);
- PV_STAT(pc_chunk_frees++);
- /* entire chunk is free, return it */
- m = PHYS_TO_VM_PAGE(pmap_kextract((vm_offset_t)pc));
- pmap_qremove((vm_offset_t)pc, 1);
- vm_page_unwire(m, PQ_INACTIVE);
- vm_page_free(m);
- pmap_ptelist_free(&pv_vafree, (vm_offset_t)pc);
-}
-
-/*
- * get a new pv_entry, allocating a block from the system
- * when needed.
- */
-static pv_entry_t
-get_pv_entry(pmap_t pmap, boolean_t try)
-{
- static const struct timeval printinterval = { 60, 0 };
- static struct timeval lastprint;
- int bit, field;
- pv_entry_t pv;
- struct pv_chunk *pc;
- vm_page_t m;
-
- PMAP_LOCK_ASSERT(pmap, MA_OWNED);
- rw_assert(&pvh_global_lock, RA_WLOCKED);
- PV_STAT(pv_entry_allocs++);
- pv_entry_count++;
- if (pv_entry_count > pv_entry_high_water)
- if (ratecheck(&lastprint, &printinterval))
- printf("Approaching the limit on PV entries, consider "
- "increasing either the vm.pmap.shpgperproc or the "
- "vm.pmap.pv_entry_max tunable.\n");
-retry:
- pc = TAILQ_FIRST(&pmap->pm_pvchunk);
- if (pc != NULL) {
- for (field = 0; field < _NPCM; field++) {
- if (pc->pc_map[field]) {
- bit = bsfl(pc->pc_map[field]);
- break;
- }
- }
- if (field < _NPCM) {
- pv = &pc->pc_pventry[field * 32 + bit];
- pc->pc_map[field] &= ~(1ul << bit);
- /* If this was the last item, move it to tail */
- for (field = 0; field < _NPCM; field++)
- if (pc->pc_map[field] != 0) {
- PV_STAT(pv_entry_spare--);
- return (pv); /* not full, return */
- }
- TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list);
- TAILQ_INSERT_TAIL(&pmap->pm_pvchunk, pc, pc_list);
- PV_STAT(pv_entry_spare--);
- return (pv);
- }
- }
- /*
- * Access to the ptelist "pv_vafree" is synchronized by the page
- * queues lock. If "pv_vafree" is currently non-empty, it will
- * remain non-empty until pmap_ptelist_alloc() completes.
- */
- if (pv_vafree == 0 || (m = vm_page_alloc(NULL, 0, VM_ALLOC_NORMAL |
- VM_ALLOC_NOOBJ | VM_ALLOC_WIRED)) == NULL) {
- if (try) {
- pv_entry_count--;
- PV_STAT(pc_chunk_tryfail++);
- return (NULL);
- }
- m = pmap_pv_reclaim(pmap);
- if (m == NULL)
- goto retry;
- }
- PV_STAT(pc_chunk_count++);
- PV_STAT(pc_chunk_allocs++);
- pc = (struct pv_chunk *)pmap_ptelist_alloc(&pv_vafree);
- pmap_qenter((vm_offset_t)pc, &m, 1);
- if ((m->flags & PG_ZERO) == 0)
- pagezero(pc);
- pc->pc_pmap = pmap;
- pc->pc_map[0] = pc_freemask[0] & ~1ul; /* preallocated bit 0 */
- for (field = 1; field < _NPCM; field++)
- pc->pc_map[field] = pc_freemask[field];
- TAILQ_INSERT_TAIL(&pv_chunks, pc, pc_lru);
- pv = &pc->pc_pventry[0];
- TAILQ_INSERT_HEAD(&pmap->pm_pvchunk, pc, pc_list);
- PV_STAT(pv_entry_spare += _NPCPV - 1);
- return (pv);
-}
-
-static __inline pv_entry_t
-pmap_pvh_remove(struct md_page *pvh, pmap_t pmap, vm_offset_t va)
-{
- pv_entry_t pv;
-
- rw_assert(&pvh_global_lock, RA_WLOCKED);
- TAILQ_FOREACH(pv, &pvh->pv_list, pv_next) {
- if (pmap == PV_PMAP(pv) && va == pv->pv_va) {
- TAILQ_REMOVE(&pvh->pv_list, pv, pv_next);
- break;
- }
- }
- return (pv);
-}
-
-static void
-pmap_pvh_free(struct md_page *pvh, pmap_t pmap, vm_offset_t va)
-{
- pv_entry_t pv;
-
- pv = pmap_pvh_remove(pvh, pmap, va);
- KASSERT(pv != NULL, ("pmap_pvh_free: pv not found"));
- free_pv_entry(pmap, pv);
-}
-
-static void
-pmap_remove_entry(pmap_t pmap, vm_page_t m, vm_offset_t va)
-{
-
- rw_assert(&pvh_global_lock, RA_WLOCKED);
- pmap_pvh_free(&m->md, pmap, va);
- if (TAILQ_EMPTY(&m->md.pv_list))
- vm_page_aflag_clear(m, PGA_WRITEABLE);
-}
-
-/*
- * Conditionally create a pv entry.
- */
-static boolean_t
-pmap_try_insert_pv_entry(pmap_t pmap, vm_offset_t va, vm_page_t m)
-{
- pv_entry_t pv;
-
- PMAP_LOCK_ASSERT(pmap, MA_OWNED);
- rw_assert(&pvh_global_lock, RA_WLOCKED);
- if (pv_entry_count < pv_entry_high_water &&
- (pv = get_pv_entry(pmap, TRUE)) != NULL) {
- pv->pv_va = va;
- TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_next);
- return (TRUE);
- } else
- return (FALSE);
-}
-
-/*
- * pmap_remove_pte: do the things to unmap a page in a process
- */
-static int
-pmap_remove_pte(pmap_t pmap, pt_entry_t *ptq, vm_offset_t va, vm_page_t *free)
-{
- pt_entry_t oldpte;
- vm_page_t m;
-
- CTR3(KTR_PMAP, "pmap_remove_pte: pmap=%p *ptq=0x%x va=0x%x",
- pmap, (u_long)*ptq, va);
-
- rw_assert(&pvh_global_lock, RA_WLOCKED);
- PMAP_LOCK_ASSERT(pmap, MA_OWNED);
- oldpte = *ptq;
- PT_SET_VA_MA(ptq, 0, TRUE);
- KASSERT(oldpte != 0,
- ("pmap_remove_pte: pmap %p va %x zero pte", pmap, va));
- 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)
- pmap_invalidate_page(kernel_pmap, va);
- pmap->pm_stats.resident_count -= 1;
- if (oldpte & PG_MANAGED) {
- m = PHYS_TO_VM_PAGE(xpmap_mtop(oldpte) & PG_FRAME);
- if ((oldpte & (PG_M | PG_RW)) == (PG_M | PG_RW))
- vm_page_dirty(m);
- if (oldpte & PG_A)
- vm_page_aflag_set(m, PGA_REFERENCED);
- pmap_remove_entry(pmap, m, va);
- }
- return (pmap_unuse_pt(pmap, va, free));
-}
-
-/*
- * Remove a single page from a process address space
- */
-static void
-pmap_remove_page(pmap_t pmap, vm_offset_t va, vm_page_t *free)
-{
- pt_entry_t *pte;
-
- CTR2(KTR_PMAP, "pmap_remove_page: pmap=%p va=0x%x",
- pmap, va);
-
- rw_assert(&pvh_global_lock, RA_WLOCKED);
- KASSERT(curthread->td_pinned > 0, ("curthread not pinned"));
- PMAP_LOCK_ASSERT(pmap, MA_OWNED);
- if ((pte = pmap_pte_quick(pmap, va)) == NULL || (*pte & PG_V) == 0)
- return;
- pmap_remove_pte(pmap, pte, va, free);
- pmap_invalidate_page(pmap, va);
- if (*PMAP1)
- PT_SET_MA(PADDR1, 0);
-
-}
-
-/*
- * 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_t pmap, vm_offset_t sva, vm_offset_t eva)
-{
- vm_offset_t pdnxt;
- pd_entry_t ptpaddr;
- pt_entry_t *pte;
- vm_page_t free = NULL;
- int anyvalid;
-
- CTR3(KTR_PMAP, "pmap_remove: pmap=%p sva=0x%x eva=0x%x",
- pmap, sva, eva);
-
- /*
- * Perform an unsynchronized read. This is, however, safe.
- */
- if (pmap->pm_stats.resident_count == 0)
- return;
-
- anyvalid = 0;
-
- rw_wlock(&pvh_global_lock);
- sched_pin();
- PMAP_LOCK(pmap);
-
- /*
- * special handling of removing one page. a very
- * common operation and easy to short circuit some
- * code.
- */
- if ((sva + PAGE_SIZE == eva) &&
- ((pmap->pm_pdir[(sva >> PDRSHIFT)] & PG_PS) == 0)) {
- pmap_remove_page(pmap, sva, &free);
- goto out;
- }
-
- for (; sva < eva; sva = pdnxt) {
- u_int pdirindex;
-
- /*
- * Calculate index for next page table.
- */
- pdnxt = (sva + NBPDR) & ~PDRMASK;
- if (pdnxt < sva)
- pdnxt = eva;
- if (pmap->pm_stats.resident_count == 0)
- break;
-
- pdirindex = sva >> PDRSHIFT;
- ptpaddr = pmap->pm_pdir[pdirindex];
-
- /*
- * Weed out invalid mappings. Note: we assume that the page
- * directory table is always allocated, and in kernel virtual.
- */
- if (ptpaddr == 0)
- continue;
-
- /*
- * Check for large page.
- */
- if ((ptpaddr & PG_PS) != 0) {
- PD_CLEAR_VA(pmap, pdirindex, TRUE);
- pmap->pm_stats.resident_count -= NBPDR / PAGE_SIZE;
- anyvalid = 1;
- 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 > eva)
- pdnxt = eva;
-
- for (pte = pmap_pte_quick(pmap, sva); sva != pdnxt; pte++,
- sva += PAGE_SIZE) {
- if ((*pte & PG_V) == 0)
- continue;
-
- /*
- * The TLB entry for a PG_G mapping is invalidated
- * by pmap_remove_pte().
- */
- if ((*pte & PG_G) == 0)
- anyvalid = 1;
- if (pmap_remove_pte(pmap, pte, sva, &free))
- break;
- }
- }
- PT_UPDATES_FLUSH();
- if (*PMAP1)
- PT_SET_VA_MA(PMAP1, 0, TRUE);
-out:
- if (anyvalid)
- pmap_invalidate_all(pmap);
- sched_unpin();
- rw_wunlock(&pvh_global_lock);
- PMAP_UNLOCK(pmap);
- pmap_free_zero_pages(free);
-}
-
-/*
- * 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...)
- */
-
-void
-pmap_remove_all(vm_page_t m)
-{
- pv_entry_t pv;
- pmap_t pmap;
- pt_entry_t *pte, tpte;
- vm_page_t free;
-
- KASSERT((m->oflags & VPO_UNMANAGED) == 0,
- ("pmap_remove_all: page %p is not managed", m));
- free = NULL;
- rw_wlock(&pvh_global_lock);
- sched_pin();
- while ((pv = TAILQ_FIRST(&m->md.pv_list)) != NULL) {
- pmap = PV_PMAP(pv);
- PMAP_LOCK(pmap);
- pmap->pm_stats.resident_count--;
- pte = pmap_pte_quick(pmap, pv->pv_va);
- tpte = *pte;
- PT_SET_VA_MA(pte, 0, TRUE);
- KASSERT(tpte != 0, ("pmap_remove_all: pmap %p va %x zero pte",
- pmap, pv->pv_va));
- if (tpte & PG_W)
- pmap->pm_stats.wired_count--;
- if (tpte & PG_A)
- vm_page_aflag_set(m, PGA_REFERENCED);
-
- /*
- * Update the vm_page_t clean and reference bits.
- */
- if ((tpte & (PG_M | PG_RW)) == (PG_M | PG_RW))
- vm_page_dirty(m);
- pmap_unuse_pt(pmap, pv->pv_va, &free);
- pmap_invalidate_page(pmap, pv->pv_va);
- TAILQ_REMOVE(&m->md.pv_list, pv, pv_next);
- free_pv_entry(pmap, pv);
- PMAP_UNLOCK(pmap);
- }
- vm_page_aflag_clear(m, PGA_WRITEABLE);
- PT_UPDATES_FLUSH();
- if (*PMAP1)
- PT_SET_MA(PADDR1, 0);
- sched_unpin();
- rw_wunlock(&pvh_global_lock);
- pmap_free_zero_pages(free);
-}
-
-/*
- * 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)
-{
- vm_offset_t pdnxt;
- pd_entry_t ptpaddr;
- pt_entry_t *pte;
- int anychanged;
-
- CTR4(KTR_PMAP, "pmap_protect: pmap=%p sva=0x%x eva=0x%x prot=0x%x",
- pmap, sva, eva, prot);
-
- if ((prot & VM_PROT_READ) == VM_PROT_NONE) {
- pmap_remove(pmap, sva, eva);
- return;
- }
-
-#ifdef PAE
- if ((prot & (VM_PROT_WRITE|VM_PROT_EXECUTE)) ==
- (VM_PROT_WRITE|VM_PROT_EXECUTE))
- return;
-#else
- if (prot & VM_PROT_WRITE)
- return;
-#endif
-
- anychanged = 0;
-
- rw_wlock(&pvh_global_lock);
- sched_pin();
- PMAP_LOCK(pmap);
- for (; sva < eva; sva = pdnxt) {
- pt_entry_t obits, pbits;
- u_int pdirindex;
-
- pdnxt = (sva + NBPDR) & ~PDRMASK;
- if (pdnxt < sva)
- pdnxt = eva;
-
- pdirindex = sva >> PDRSHIFT;
- ptpaddr = pmap->pm_pdir[pdirindex];
-
- /*
- * Weed out invalid mappings. Note: we assume that the page
- * directory table is always allocated, and in kernel virtual.
- */
- if (ptpaddr == 0)
- continue;
-
- /*
- * Check for large page.
- */
- if ((ptpaddr & PG_PS) != 0) {
- if ((prot & VM_PROT_WRITE) == 0)
- pmap->pm_pdir[pdirindex] &= ~(PG_M|PG_RW);
-#ifdef PAE
- if ((prot & VM_PROT_EXECUTE) == 0)
- pmap->pm_pdir[pdirindex] |= pg_nx;
-#endif
- anychanged = 1;
- continue;
- }
-
- if (pdnxt > eva)
- pdnxt = eva;
-
- for (pte = pmap_pte_quick(pmap, sva); sva != pdnxt; pte++,
- sva += PAGE_SIZE) {
- vm_page_t m;
-
-retry:
- /*
- * Regardless of whether a pte is 32 or 64 bits in
- * size, PG_RW, PG_A, and PG_M are among the least
- * significant 32 bits.
- */
- obits = pbits = *pte;
- if ((pbits & PG_V) == 0)
- continue;
-
- if ((prot & VM_PROT_WRITE) == 0) {
- if ((pbits & (PG_MANAGED | PG_M | PG_RW)) ==
- (PG_MANAGED | PG_M | PG_RW)) {
- m = PHYS_TO_VM_PAGE(xpmap_mtop(pbits) &
- PG_FRAME);
- vm_page_dirty(m);
- }
- pbits &= ~(PG_RW | PG_M);
- }
-#ifdef PAE
- if ((prot & VM_PROT_EXECUTE) == 0)
- pbits |= pg_nx;
-#endif
-
- if (pbits != obits) {
- obits = *pte;
- PT_SET_VA_MA(pte, pbits, TRUE);
- if (*pte != pbits)
- goto retry;
- if (obits & PG_G)
- pmap_invalidate_page(pmap, sva);
- else
- anychanged = 1;
- }
- }
- }
- PT_UPDATES_FLUSH();
- if (*PMAP1)
- PT_SET_VA_MA(PMAP1, 0, TRUE);
- if (anychanged)
- pmap_invalidate_all(pmap);
- sched_unpin();
- rw_wunlock(&pvh_global_lock);
- PMAP_UNLOCK(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.
- */
-int
-pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot,
- u_int flags, int8_t psind __unused)
-{
- pd_entry_t *pde;
- pt_entry_t *pte;
- pt_entry_t newpte, origpte;
- pv_entry_t pv;
- vm_paddr_t opa, pa;
- vm_page_t mpte, om;
- boolean_t invlva, wired;
-
- CTR5(KTR_PMAP,
- "pmap_enter: pmap=%08p va=0x%08x ma=0x%08x prot=0x%x flags=0x%x",
- pmap, va, VM_PAGE_TO_MACH(m), prot, flags);
- va = trunc_page(va);
- KASSERT(va <= VM_MAX_KERNEL_ADDRESS, ("pmap_enter: toobig"));
- KASSERT(va < UPT_MIN_ADDRESS || va >= UPT_MAX_ADDRESS,
- ("pmap_enter: invalid to pmap_enter page table pages (va: 0x%x)",
- va));
- if ((m->oflags & VPO_UNMANAGED) == 0 && !vm_page_xbusied(m))
- VM_OBJECT_ASSERT_LOCKED(m->object);
-
- mpte = NULL;
- wired = (flags & PMAP_ENTER_WIRED) != 0;
-
- rw_wlock(&pvh_global_lock);
- PMAP_LOCK(pmap);
- sched_pin();
-
- /*
- * In the case that a page table page is not
- * resident, we are creating it here.
- */
- if (va < VM_MAXUSER_ADDRESS) {
- mpte = pmap_allocpte(pmap, va, flags);
- if (mpte == NULL) {
- KASSERT((flags & PMAP_ENTER_NOSLEEP) != 0,
- ("pmap_allocpte failed with sleep allowed"));
- sched_unpin();
- rw_wunlock(&pvh_global_lock);
- PMAP_UNLOCK(pmap);
- return (KERN_RESOURCE_SHORTAGE);
- }
- }
-
- pde = pmap_pde(pmap, va);
- if ((*pde & PG_PS) != 0)
- panic("pmap_enter: attempted pmap_enter on 4MB page");
- pte = pmap_pte_quick(pmap, va);
-
- /*
- * Page Directory table entry not valid, we need a new PT page
- */
- if (pte == NULL) {
- panic("pmap_enter: invalid page directory pdir=%#jx, va=%#x",
- (uintmax_t)pmap->pm_pdir[va >> PDRSHIFT], va);
- }
-
- pa = VM_PAGE_TO_PHYS(m);
- om = NULL;
- opa = origpte = 0;
-
-#if 0
- KASSERT((*pte & PG_V) || (*pte == 0), ("address set but not valid pte=%p *pte=0x%016jx",
- pte, *pte));
-#endif
- origpte = *pte;
- if (origpte)
- origpte = xpmap_mtop(origpte);
- opa = origpte & PG_FRAME;
-
- /*
- * 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--;
-
- /*
- * Remove extra pte reference
- */
- if (mpte)
- mpte->wire_count--;
-
- if (origpte & PG_MANAGED) {
- om = m;
- pa |= PG_MANAGED;
- }
- goto validate;
- }
-
- pv = NULL;
-
- /*
- * Mapping has changed, invalidate old range and fall through to
- * handle validating new mapping.
- */
- if (opa) {
- if (origpte & PG_W)
- pmap->pm_stats.wired_count--;
- if (origpte & PG_MANAGED) {
- om = PHYS_TO_VM_PAGE(opa);
- pv = pmap_pvh_remove(&om->md, pmap, va);
- } else if (va < VM_MAXUSER_ADDRESS)
- printf("va=0x%x is unmanaged :-( \n", va);
-
- if (mpte != NULL) {
- mpte->wire_count--;
- KASSERT(mpte->wire_count > 0,
- ("pmap_enter: missing reference to page table page,"
- " va: 0x%x", va));
- }
- } else
- pmap->pm_stats.resident_count++;
-
- /*
- * Enter on the PV list if part of our managed memory.
- */
- if ((m->oflags & VPO_UNMANAGED) == 0) {
- KASSERT(va < kmi.clean_sva || va >= kmi.clean_eva,
- ("pmap_enter: managed mapping within the clean submap"));
- if (pv == NULL)
- pv = get_pv_entry(pmap, FALSE);
- pv->pv_va = va;
- TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_next);
- pa |= PG_MANAGED;
- } else if (pv != NULL)
- free_pv_entry(pmap, pv);
-
- /*
- * Increment counters
- */
- if (wired)
- pmap->pm_stats.wired_count++;
-
-validate:
- /*
- * Now validate mapping with desired protection/wiring.
- */
- newpte = (pt_entry_t)(pa | PG_V);
- if ((prot & VM_PROT_WRITE) != 0) {
- newpte |= PG_RW;
- if ((newpte & PG_MANAGED) != 0)
- vm_page_aflag_set(m, PGA_WRITEABLE);
- }
-#ifdef PAE
- if ((prot & VM_PROT_EXECUTE) == 0)
- newpte |= pg_nx;
-#endif
- if (wired)
- newpte |= PG_W;
- if (va < VM_MAXUSER_ADDRESS)
- newpte |= PG_U;
- if (pmap == kernel_pmap)
- newpte |= pgeflag;
-
- critical_enter();
- /*
- * if the mapping or permission bits are different, we need
- * to update the pte.
- */
- if ((origpte & ~(PG_M|PG_A)) != newpte) {
- if (origpte) {
- invlva = FALSE;
- origpte = *pte;
- PT_SET_VA(pte, newpte | PG_A, FALSE);
- if (origpte & PG_A) {
- if (origpte & PG_MANAGED)
- vm_page_aflag_set(om, PGA_REFERENCED);
- if (opa != VM_PAGE_TO_PHYS(m))
- invlva = TRUE;
-#ifdef PAE
- if ((origpte & PG_NX) == 0 &&
- (newpte & PG_NX) != 0)
- invlva = TRUE;
-#endif
- }
- if ((origpte & (PG_M | PG_RW)) == (PG_M | PG_RW)) {
- if ((origpte & PG_MANAGED) != 0)
- vm_page_dirty(om);
- if ((prot & VM_PROT_WRITE) == 0)
- invlva = TRUE;
- }
- if ((origpte & PG_MANAGED) != 0 &&
- TAILQ_EMPTY(&om->md.pv_list))
- vm_page_aflag_clear(om, PGA_WRITEABLE);
- if (invlva)
- pmap_invalidate_page(pmap, va);
- } else{
- PT_SET_VA(pte, newpte | PG_A, FALSE);
- }
-
- }
- PT_UPDATES_FLUSH();
- critical_exit();
- if (*PMAP1)
- PT_SET_VA_MA(PMAP1, 0, TRUE);
- sched_unpin();
- rw_wunlock(&pvh_global_lock);
- PMAP_UNLOCK(pmap);
- return (KERN_SUCCESS);
-}
-
-/*
- * Maps a sequence of resident pages belonging to the same object.
- * The sequence begins with the given page m_start. This page is
- * mapped at the given virtual address start. Each subsequent page is
- * mapped at a virtual address that is offset from start by the same
- * amount as the page is offset from m_start within the object. The
- * last page in the sequence is the page with the largest offset from
- * m_start that can be mapped at a virtual address less than the given
- * virtual address end. Not every virtual page between start and end
- * is mapped; only those for which a resident page exists with the
- * corresponding offset from m_start are mapped.
- */
-void
-pmap_enter_object(pmap_t pmap, vm_offset_t start, vm_offset_t end,
- vm_page_t m_start, vm_prot_t prot)
-{
- vm_page_t m, mpte;
- vm_pindex_t diff, psize;
- multicall_entry_t mcl[16];
- multicall_entry_t *mclp = mcl;
- int error, count = 0;
-
- VM_OBJECT_ASSERT_LOCKED(m_start->object);
-
- psize = atop(end - start);
- mpte = NULL;
- m = m_start;
- rw_wlock(&pvh_global_lock);
- PMAP_LOCK(pmap);
- while (m != NULL && (diff = m->pindex - m_start->pindex) < psize) {
- mpte = pmap_enter_quick_locked(&mclp, &count, pmap, start + ptoa(diff), m,
- prot, mpte);
- m = TAILQ_NEXT(m, listq);
- if (count == 16) {
- error = HYPERVISOR_multicall(mcl, count);
- KASSERT(error == 0, ("bad multicall %d", error));
- mclp = mcl;
- count = 0;
- }
- }
- if (count) {
- error = HYPERVISOR_multicall(mcl, count);
- KASSERT(error == 0, ("bad multicall %d", error));
- }
- rw_wunlock(&pvh_global_lock);
- PMAP_UNLOCK(pmap);
-}
-
-/*
- * this code makes some *MAJOR* assumptions:
- * 1. Current pmap & pmap exists.
- * 2. Not wired.
- * 3. Read access.
- * 4. No page table pages.
- * but is *MUCH* faster than pmap_enter...
- */
-
-void
-pmap_enter_quick(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot)
-{
- multicall_entry_t mcl, *mclp;
- int count = 0;
- mclp = &mcl;
-
- CTR4(KTR_PMAP, "pmap_enter_quick: pmap=%p va=0x%x m=%p prot=0x%x",
- pmap, va, m, prot);
-
- rw_wlock(&pvh_global_lock);
- PMAP_LOCK(pmap);
- (void)pmap_enter_quick_locked(&mclp, &count, pmap, va, m, prot, NULL);
- if (count)
- HYPERVISOR_multicall(&mcl, count);
- rw_wunlock(&pvh_global_lock);
- PMAP_UNLOCK(pmap);
-}
-
-#ifdef notyet
-void
-pmap_enter_quick_range(pmap_t pmap, vm_offset_t *addrs, vm_page_t *pages, vm_prot_t *prots, int count)
-{
- int i, error, index = 0;
- multicall_entry_t mcl[16];
- multicall_entry_t *mclp = mcl;
-
- PMAP_LOCK(pmap);
- for (i = 0; i < count; i++, addrs++, pages++, prots++) {
- if (!pmap_is_prefaultable_locked(pmap, *addrs))
- continue;
-
- (void) pmap_enter_quick_locked(&mclp, &index, pmap, *addrs, *pages, *prots, NULL);
- if (index == 16) {
- error = HYPERVISOR_multicall(mcl, index);
- mclp = mcl;
- index = 0;
- KASSERT(error == 0, ("bad multicall %d", error));
- }
- }
- if (index) {
- error = HYPERVISOR_multicall(mcl, index);
- KASSERT(error == 0, ("bad multicall %d", error));
- }
-
- PMAP_UNLOCK(pmap);
-}
-#endif
-
-static vm_page_t
-pmap_enter_quick_locked(multicall_entry_t **mclpp, int *count, pmap_t pmap, vm_offset_t va, vm_page_t m,
- vm_prot_t prot, vm_page_t mpte)
-{
- pt_entry_t *pte;
- vm_paddr_t pa;
- vm_page_t free;
- multicall_entry_t *mcl = *mclpp;
-
- KASSERT(va < kmi.clean_sva || va >= kmi.clean_eva ||
- (m->oflags & VPO_UNMANAGED) != 0,
- ("pmap_enter_quick_locked: managed mapping within the clean submap"));
- rw_assert(&pvh_global_lock, RA_WLOCKED);
- PMAP_LOCK_ASSERT(pmap, MA_OWNED);
-
- /*
- * In the case that a page table page is not
- * resident, we are creating it here.
- */
- if (va < VM_MAXUSER_ADDRESS) {
- u_int ptepindex;
- pd_entry_t ptema;
-
- /*
- * Calculate pagetable page index
- */
- ptepindex = va >> PDRSHIFT;
- if (mpte && (mpte->pindex == ptepindex)) {
- mpte->wire_count++;
- } else {
- /*
- * Get the page directory entry
- */
- ptema = pmap->pm_pdir[ptepindex];
-
- /*
- * If the page table page is mapped, we just increment
- * the hold count, and activate it.
- */
- if (ptema & PG_V) {
- if (ptema & PG_PS)
- panic("pmap_enter_quick: unexpected mapping into 4MB page");
- mpte = PHYS_TO_VM_PAGE(xpmap_mtop(ptema) & PG_FRAME);
- mpte->wire_count++;
- } else {
- mpte = _pmap_allocpte(pmap, ptepindex,
- PMAP_ENTER_NOSLEEP);
- if (mpte == NULL)
- return (mpte);
- }
- }
- } 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.
- */
- KASSERT(pmap_is_current(pmap), ("entering pages in non-current pmap"));
- pte = vtopte(va);
- if (*pte & PG_V) {
- if (mpte != NULL) {
- mpte->wire_count--;
- mpte = NULL;
- }
- return (mpte);
- }
-
- /*
- * Enter on the PV list if part of our managed memory.
- */
- if ((m->oflags & VPO_UNMANAGED) == 0 &&
- !pmap_try_insert_pv_entry(pmap, va, m)) {
- if (mpte != NULL) {
- free = NULL;
- if (pmap_unwire_ptp(pmap, mpte, &free)) {
- pmap_invalidate_page(pmap, va);
- pmap_free_zero_pages(free);
- }
-
- mpte = NULL;
- }
- return (mpte);
- }
-
- /*
- * Increment counters
- */
- pmap->pm_stats.resident_count++;
-
- pa = VM_PAGE_TO_PHYS(m);
-#ifdef PAE
- if ((prot & VM_PROT_EXECUTE) == 0)
- pa |= pg_nx;
-#endif
-
-#if 0
- /*
- * Now validate mapping with RO protection
- */
- if ((m->oflags & VPO_UNMANAGED) != 0)
- pte_store(pte, pa | PG_V | PG_U);
- else
- pte_store(pte, pa | PG_V | PG_U | PG_MANAGED);
-#else
- /*
- * Now validate mapping with RO protection
- */
- if ((m->oflags & VPO_UNMANAGED) != 0)
- pa = xpmap_ptom(pa | PG_V | PG_U);
- else
- pa = xpmap_ptom(pa | PG_V | PG_U | PG_MANAGED);
-
- mcl->op = __HYPERVISOR_update_va_mapping;
- mcl->args[0] = va;
- mcl->args[1] = (uint32_t)(pa & 0xffffffff);
- mcl->args[2] = (uint32_t)(pa >> 32);
- mcl->args[3] = 0;
- *mclpp = mcl + 1;
- *count = *count + 1;
-#endif
- return (mpte);
-}
-
-/*
- * Make a temporary mapping for a physical address. This is only intended
- * to be used for panic dumps.
- */
-void *
-pmap_kenter_temporary(vm_paddr_t pa, int i)
-{
- vm_offset_t va;
- vm_paddr_t ma = xpmap_ptom(pa);
-
- va = (vm_offset_t)crashdumpmap + (i * PAGE_SIZE);
- PT_SET_MA(va, (ma & ~PAGE_MASK) | PG_V | pgeflag);
- invlpg(va);
- return ((void *)crashdumpmap);
-}
-
-/*
- * This code maps large physical mmap regions into the
- * processor address space. Note that some shortcuts
- * are taken, but the code works.
- */
-void
-pmap_object_init_pt(pmap_t pmap, vm_offset_t addr, vm_object_t object,
- vm_pindex_t pindex, vm_size_t size)
-{
- pd_entry_t *pde;
- vm_paddr_t pa, ptepa;
- vm_page_t p;
- int pat_mode;
-
- VM_OBJECT_ASSERT_WLOCKED(object);
- KASSERT(object->type == OBJT_DEVICE || object->type == OBJT_SG,
- ("pmap_object_init_pt: non-device object"));
- if (pseflag &&
- (addr & (NBPDR - 1)) == 0 && (size & (NBPDR - 1)) == 0) {
- if (!vm_object_populate(object, pindex, pindex + atop(size)))
- return;
- p = vm_page_lookup(object, pindex);
- KASSERT(p->valid == VM_PAGE_BITS_ALL,
- ("pmap_object_init_pt: invalid page %p", p));
- pat_mode = p->md.pat_mode;
-
- /*
- * Abort the mapping if the first page is not physically
- * aligned to a 2/4MB page boundary.
- */
- ptepa = VM_PAGE_TO_PHYS(p);
- if (ptepa & (NBPDR - 1))
- return;
-
- /*
- * Skip the first page. Abort the mapping if the rest of
- * the pages are not physically contiguous or have differing
- * memory attributes.
- */
- p = TAILQ_NEXT(p, listq);
- for (pa = ptepa + PAGE_SIZE; pa < ptepa + size;
- pa += PAGE_SIZE) {
- KASSERT(p->valid == VM_PAGE_BITS_ALL,
- ("pmap_object_init_pt: invalid page %p", p));
- if (pa != VM_PAGE_TO_PHYS(p) ||
- pat_mode != p->md.pat_mode)
- return;
- p = TAILQ_NEXT(p, listq);
- }
-
- /*
- * Map using 2/4MB pages. Since "ptepa" is 2/4M aligned and
- * "size" is a multiple of 2/4M, adding the PAT setting to
- * "pa" will not affect the termination of this loop.
- */
- PMAP_LOCK(pmap);
- for (pa = ptepa | pmap_cache_bits(pat_mode, 1); pa < ptepa +
- size; pa += NBPDR) {
- pde = pmap_pde(pmap, addr);
- if (*pde == 0) {
- pde_store(pde, pa | PG_PS | PG_M | PG_A |
- PG_U | PG_RW | PG_V);
- pmap->pm_stats.resident_count += NBPDR /
- PAGE_SIZE;
- pmap_pde_mappings++;
- }
- /* Else continue on if the PDE is already valid. */
- addr += NBPDR;
- }
- PMAP_UNLOCK(pmap);
- }
-}
-
-/*
- * Clear the wired attribute from the mappings for the specified range of
- * addresses in the given pmap. Every valid mapping within that range
- * must have the wired attribute set. In contrast, invalid mappings
- * cannot have the wired attribute set, so they are ignored.
- *
- * The wired attribute of the page table entry is not a hardware feature,
- * so there is no need to invalidate any TLB entries.
- */
-void
-pmap_unwire(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
-{
- vm_offset_t pdnxt;
- pd_entry_t *pde;
- pt_entry_t *pte;
-
- CTR3(KTR_PMAP, "pmap_unwire: pmap=%p sva=0x%x eva=0x%x", pmap, sva,
- eva);
- rw_wlock(&pvh_global_lock);
- sched_pin();
- PMAP_LOCK(pmap);
- for (; sva < eva; sva = pdnxt) {
- pdnxt = (sva + NBPDR) & ~PDRMASK;
- if (pdnxt < sva)
- pdnxt = eva;
- pde = pmap_pde(pmap, sva);
- if ((*pde & PG_V) == 0)
- continue;
- if ((*pde & PG_PS) != 0)
- panic("pmap_unwire: unexpected PG_PS in pde %#jx",
- (uintmax_t)*pde);
- if (pdnxt > eva)
- pdnxt = eva;
- for (pte = pmap_pte_quick(pmap, sva); sva != pdnxt; pte++,
- sva += PAGE_SIZE) {
- if ((*pte & PG_V) == 0)
- continue;
- if ((*pte & PG_W) == 0)
- panic("pmap_unwire: pte %#jx is missing PG_W",
- (uintmax_t)*pte);
- PT_SET_VA_MA(pte, *pte & ~PG_W, FALSE);
- pmap->pm_stats.wired_count--;
- }
- }
- if (*PMAP1)
- PT_CLEAR_VA(PMAP1, FALSE);
- PT_UPDATES_FLUSH();
- sched_unpin();
- rw_wunlock(&pvh_global_lock);
- PMAP_UNLOCK(pmap);
-}
-
-
-/*
- * 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(pmap_t dst_pmap, pmap_t src_pmap, vm_offset_t dst_addr, vm_size_t len,
- vm_offset_t src_addr)
-{
- vm_page_t free;
- vm_offset_t addr;
- vm_offset_t end_addr = src_addr + len;
- vm_offset_t pdnxt;
-
- if (dst_addr != src_addr)
- return;
-
- if (!pmap_is_current(src_pmap)) {
- CTR2(KTR_PMAP,
- "pmap_copy, skipping: pdir[PTDPTDI]=0x%jx PTDpde[0]=0x%jx",
- (src_pmap->pm_pdir[PTDPTDI] & PG_FRAME), (PTDpde[0] & PG_FRAME));
-
- return;
- }
- CTR5(KTR_PMAP, "pmap_copy: dst_pmap=%p src_pmap=%p dst_addr=0x%x len=%d src_addr=0x%x",
- dst_pmap, src_pmap, dst_addr, len, src_addr);
-
-#ifdef HAMFISTED_LOCKING
- mtx_lock(&createdelete_lock);
-#endif
-
- rw_wlock(&pvh_global_lock);
- if (dst_pmap < src_pmap) {
- PMAP_LOCK(dst_pmap);
- PMAP_LOCK(src_pmap);
- } else {
- PMAP_LOCK(src_pmap);
- PMAP_LOCK(dst_pmap);
- }
- sched_pin();
- for (addr = src_addr; addr < end_addr; addr = pdnxt) {
- pt_entry_t *src_pte, *dst_pte;
- vm_page_t dstmpte, srcmpte;
- pd_entry_t srcptepaddr;
- u_int ptepindex;
-
- KASSERT(addr < UPT_MIN_ADDRESS,
- ("pmap_copy: invalid to pmap_copy page tables"));
-
- pdnxt = (addr + NBPDR) & ~PDRMASK;
- if (pdnxt < addr)
- pdnxt = end_addr;
- ptepindex = addr >> PDRSHIFT;
-
- srcptepaddr = PT_GET(&src_pmap->pm_pdir[ptepindex]);
- if (srcptepaddr == 0)
- continue;
-
- if (srcptepaddr & PG_PS) {
- if (dst_pmap->pm_pdir[ptepindex] == 0) {
- PD_SET_VA(dst_pmap, ptepindex, srcptepaddr & ~PG_W, TRUE);
- dst_pmap->pm_stats.resident_count +=
- NBPDR / PAGE_SIZE;
- }
- continue;
- }
-
- srcmpte = PHYS_TO_VM_PAGE(srcptepaddr & PG_FRAME);
- KASSERT(srcmpte->wire_count > 0,
- ("pmap_copy: source page table page is unused"));
-
- if (pdnxt > end_addr)
- pdnxt = end_addr;
-
- src_pte = vtopte(addr);
- while (addr < pdnxt) {
- pt_entry_t ptetemp;
- ptetemp = *src_pte;
- /*
- * we only virtual copy managed pages
- */
- if ((ptetemp & PG_MANAGED) != 0) {
- dstmpte = pmap_allocpte(dst_pmap, addr,
- PMAP_ENTER_NOSLEEP);
- if (dstmpte == NULL)
- goto out;
- dst_pte = pmap_pte_quick(dst_pmap, addr);
- if (*dst_pte == 0 &&
- pmap_try_insert_pv_entry(dst_pmap, addr,
- PHYS_TO_VM_PAGE(xpmap_mtop(ptetemp) & PG_FRAME))) {
- /*
- * Clear the wired, modified, and
- * accessed (referenced) bits
- * during the copy.
- */
- KASSERT(ptetemp != 0, ("src_pte not set"));
- PT_SET_VA_MA(dst_pte, ptetemp & ~(PG_W | PG_M | PG_A), TRUE /* XXX debug */);
- KASSERT(*dst_pte == (ptetemp & ~(PG_W | PG_M | PG_A)),
- ("no pmap copy expected: 0x%jx saw: 0x%jx",
- ptetemp & ~(PG_W | PG_M | PG_A), *dst_pte));
- dst_pmap->pm_stats.resident_count++;
- } else {
- free = NULL;
- if (pmap_unwire_ptp(dst_pmap, dstmpte,
- &free)) {
- pmap_invalidate_page(dst_pmap,
- addr);
- pmap_free_zero_pages(free);
- }
- goto out;
- }
- if (dstmpte->wire_count >= srcmpte->wire_count)
- break;
- }
- addr += PAGE_SIZE;
- src_pte++;
- }
- }
-out:
- PT_UPDATES_FLUSH();
- sched_unpin();
- rw_wunlock(&pvh_global_lock);
- PMAP_UNLOCK(src_pmap);
- PMAP_UNLOCK(dst_pmap);
-
-#ifdef HAMFISTED_LOCKING
- mtx_unlock(&createdelete_lock);
-#endif
-}
-
-static __inline void
-pagezero(void *page)
-{
-#if defined(I686_CPU)
- if (cpu_class == CPUCLASS_686) {
-#if defined(CPU_ENABLE_SSE)
- if (cpu_feature & CPUID_SSE2)
- sse2_pagezero(page);
- else
-#endif
- i686_pagezero(page);
- } else
-#endif
- bzero(page, PAGE_SIZE);
-}
-
-/*
- * 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(vm_page_t m)
-{
- struct sysmaps *sysmaps;
-
- sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)];
- mtx_lock(&sysmaps->lock);
- if (*sysmaps->CMAP2)
- panic("pmap_zero_page: CMAP2 busy");
- sched_pin();
- PT_SET_MA(sysmaps->CADDR2, PG_V | PG_RW | VM_PAGE_TO_MACH(m) | PG_A | PG_M);
- pagezero(sysmaps->CADDR2);
- PT_SET_MA(sysmaps->CADDR2, 0);
- sched_unpin();
- mtx_unlock(&sysmaps->lock);
-}
-
-/*
- * 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(vm_page_t m, int off, int size)
-{
- struct sysmaps *sysmaps;
-
- sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)];
- mtx_lock(&sysmaps->lock);
- if (*sysmaps->CMAP2)
- panic("pmap_zero_page_area: CMAP2 busy");
- sched_pin();
- PT_SET_MA(sysmaps->CADDR2, PG_V | PG_RW | VM_PAGE_TO_MACH(m) | PG_A | PG_M);
-
- if (off == 0 && size == PAGE_SIZE)
- pagezero(sysmaps->CADDR2);
- else
- bzero((char *)sysmaps->CADDR2 + off, size);
- PT_SET_MA(sysmaps->CADDR2, 0);
- sched_unpin();
- mtx_unlock(&sysmaps->lock);
-}
-
-/*
- * pmap_zero_page_idle zeros the specified hardware page by mapping
- * the page into KVM and using bzero to clear its contents. This
- * is intended to be called from the vm_pagezero process only and
- * outside of Giant.
- */
-void
-pmap_zero_page_idle(vm_page_t m)
-{
-
- if (*CMAP3)
- panic("pmap_zero_page_idle: CMAP3 busy");
- sched_pin();
- PT_SET_MA(CADDR3, PG_V | PG_RW | VM_PAGE_TO_MACH(m) | PG_A | PG_M);
- pagezero(CADDR3);
- PT_SET_MA(CADDR3, 0);
- sched_unpin();
-}
-
-/*
- * 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(vm_page_t src, vm_page_t dst)
-{
- struct sysmaps *sysmaps;
-
- sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)];
- mtx_lock(&sysmaps->lock);
- if (*sysmaps->CMAP1)
- panic("pmap_copy_page: CMAP1 busy");
- if (*sysmaps->CMAP2)
- panic("pmap_copy_page: CMAP2 busy");
- sched_pin();
- PT_SET_MA(sysmaps->CADDR1, PG_V | VM_PAGE_TO_MACH(src) | PG_A);
- PT_SET_MA(sysmaps->CADDR2, PG_V | PG_RW | VM_PAGE_TO_MACH(dst) | PG_A | PG_M);
- bcopy(sysmaps->CADDR1, sysmaps->CADDR2, PAGE_SIZE);
- PT_SET_MA(sysmaps->CADDR1, 0);
- PT_SET_MA(sysmaps->CADDR2, 0);
- sched_unpin();
- mtx_unlock(&sysmaps->lock);
-}
-
-int unmapped_buf_allowed = 1;
-
-void
-pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
- vm_offset_t b_offset, int xfersize)
-{
- struct sysmaps *sysmaps;
- vm_page_t a_pg, b_pg;
- char *a_cp, *b_cp;
- vm_offset_t a_pg_offset, b_pg_offset;
- int cnt;
-
- sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)];
- mtx_lock(&sysmaps->lock);
- if (*sysmaps->CMAP1 != 0)
- panic("pmap_copy_pages: CMAP1 busy");
- if (*sysmaps->CMAP2 != 0)
- panic("pmap_copy_pages: CMAP2 busy");
- sched_pin();
- while (xfersize > 0) {
- a_pg = ma[a_offset >> PAGE_SHIFT];
- a_pg_offset = a_offset & PAGE_MASK;
- cnt = min(xfersize, PAGE_SIZE - a_pg_offset);
- b_pg = mb[b_offset >> PAGE_SHIFT];
- b_pg_offset = b_offset & PAGE_MASK;
- cnt = min(cnt, PAGE_SIZE - b_pg_offset);
- PT_SET_MA(sysmaps->CADDR1, PG_V | VM_PAGE_TO_MACH(a_pg) | PG_A);
- PT_SET_MA(sysmaps->CADDR2, PG_V | PG_RW |
- VM_PAGE_TO_MACH(b_pg) | PG_A | PG_M);
- a_cp = sysmaps->CADDR1 + a_pg_offset;
- b_cp = sysmaps->CADDR2 + b_pg_offset;
- bcopy(a_cp, b_cp, cnt);
- a_offset += cnt;
- b_offset += cnt;
- xfersize -= cnt;
- }
- PT_SET_MA(sysmaps->CADDR1, 0);
- PT_SET_MA(sysmaps->CADDR2, 0);
- sched_unpin();
- mtx_unlock(&sysmaps->lock);
-}
-
-/*
- * Returns true if the pmap's pv is one of the first
- * 16 pvs linked to from this page. This count may
- * be changed upwards or downwards in the future; it
- * is only necessary that true be returned for a small
- * subset of pmaps for proper page aging.
- */
-boolean_t
-pmap_page_exists_quick(pmap_t pmap, vm_page_t m)
-{
- pv_entry_t pv;
- int loops = 0;
- boolean_t rv;
-
- KASSERT((m->oflags & VPO_UNMANAGED) == 0,
- ("pmap_page_exists_quick: page %p is not managed", m));
- rv = FALSE;
- rw_wlock(&pvh_global_lock);
- TAILQ_FOREACH(pv, &m->md.pv_list, pv_next) {
- if (PV_PMAP(pv) == pmap) {
- rv = TRUE;
- break;
- }
- loops++;
- if (loops >= 16)
- break;
- }
- rw_wunlock(&pvh_global_lock);
- return (rv);
-}
-
-/*
- * pmap_page_wired_mappings:
- *
- * Return the number of managed mappings to the given physical page
- * that are wired.
- */
-int
-pmap_page_wired_mappings(vm_page_t m)
-{
- pv_entry_t pv;
- pt_entry_t *pte;
- pmap_t pmap;
- int count;
-
- count = 0;
- if ((m->oflags & VPO_UNMANAGED) != 0)
- return (count);
- rw_wlock(&pvh_global_lock);
- sched_pin();
- TAILQ_FOREACH(pv, &m->md.pv_list, pv_next) {
- pmap = PV_PMAP(pv);
- PMAP_LOCK(pmap);
- pte = pmap_pte_quick(pmap, pv->pv_va);
- if ((*pte & PG_W) != 0)
- count++;
- PMAP_UNLOCK(pmap);
- }
- sched_unpin();
- rw_wunlock(&pvh_global_lock);
- return (count);
-}
-
-/*
- * Returns TRUE if the given page is mapped. Otherwise, returns FALSE.
- */
-boolean_t
-pmap_page_is_mapped(vm_page_t m)
-{
-
- if ((m->oflags & VPO_UNMANAGED) != 0)
- return (FALSE);
- return (!TAILQ_EMPTY(&m->md.pv_list));
-}
-
-/*
- * 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_t pmap)
-{
- pt_entry_t *pte, tpte;
- vm_page_t m, free = NULL;
- pv_entry_t pv;
- struct pv_chunk *pc, *npc;
- int field, idx;
- int32_t bit;
- uint32_t inuse, bitmask;
- int allfree;
-
- CTR1(KTR_PMAP, "pmap_remove_pages: pmap=%p", pmap);
-
- if (pmap != vmspace_pmap(curthread->td_proc->p_vmspace)) {
- printf("warning: pmap_remove_pages called with non-current pmap\n");
- return;
- }
- rw_wlock(&pvh_global_lock);
- KASSERT(pmap_is_current(pmap), ("removing pages from non-current pmap"));
- PMAP_LOCK(pmap);
- sched_pin();
- TAILQ_FOREACH_SAFE(pc, &pmap->pm_pvchunk, pc_list, npc) {
- KASSERT(pc->pc_pmap == pmap, ("Wrong pmap %p %p", pmap,
- pc->pc_pmap));
- allfree = 1;
- for (field = 0; field < _NPCM; field++) {
- inuse = ~pc->pc_map[field] & pc_freemask[field];
- while (inuse != 0) {
- bit = bsfl(inuse);
- bitmask = 1UL << bit;
- idx = field * 32 + bit;
- pv = &pc->pc_pventry[idx];
- inuse &= ~bitmask;
-
- pte = vtopte(pv->pv_va);
- tpte = *pte ? xpmap_mtop(*pte) : 0;
-
- if (tpte == 0) {
- printf(
- "TPTE at %p IS ZERO @ VA %08x\n",
- pte, pv->pv_va);
- panic("bad pte");
- }
-
-/*
- * We cannot remove wired pages from a process' mapping at this time
- */
- if (tpte & PG_W) {
- allfree = 0;
- continue;
- }
-
- m = PHYS_TO_VM_PAGE(tpte & PG_FRAME);
- KASSERT(m->phys_addr == (tpte & PG_FRAME),
- ("vm_page_t %p phys_addr mismatch %016jx %016jx",
- m, (uintmax_t)m->phys_addr,
- (uintmax_t)tpte));
-
- KASSERT(m < &vm_page_array[vm_page_array_size],
- ("pmap_remove_pages: bad tpte %#jx",
- (uintmax_t)tpte));
-
-
- PT_CLEAR_VA(pte, FALSE);
-
- /*
- * Update the vm_page_t clean/reference bits.
- */
- if (tpte & PG_M)
- vm_page_dirty(m);
-
- TAILQ_REMOVE(&m->md.pv_list, pv, pv_next);
- if (TAILQ_EMPTY(&m->md.pv_list))
- vm_page_aflag_clear(m, PGA_WRITEABLE);
-
- pmap_unuse_pt(pmap, pv->pv_va, &free);
-
- /* Mark free */
- PV_STAT(pv_entry_frees++);
- PV_STAT(pv_entry_spare++);
- pv_entry_count--;
- pc->pc_map[field] |= bitmask;
- pmap->pm_stats.resident_count--;
- }
- }
- PT_UPDATES_FLUSH();
- if (allfree) {
- TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list);
- free_pv_chunk(pc);
- }
- }
- PT_UPDATES_FLUSH();
- if (*PMAP1)
- PT_SET_MA(PADDR1, 0);
-
- sched_unpin();
- pmap_invalidate_all(pmap);
- rw_wunlock(&pvh_global_lock);
- PMAP_UNLOCK(pmap);
- pmap_free_zero_pages(free);
-}
-
-/*
- * pmap_is_modified:
- *
- * Return whether or not the specified physical page was modified
- * in any physical maps.
- */
-boolean_t
-pmap_is_modified(vm_page_t m)
-{
- pv_entry_t pv;
- pt_entry_t *pte;
- pmap_t pmap;
- boolean_t rv;
-
- KASSERT((m->oflags & VPO_UNMANAGED) == 0,
- ("pmap_is_modified: page %p is not managed", m));
- rv = FALSE;
-
- /*
- * If the page is not exclusive busied, then PGA_WRITEABLE cannot be
- * concurrently set while the object is locked. Thus, if PGA_WRITEABLE
- * is clear, no PTEs can have PG_M set.
- */
- VM_OBJECT_ASSERT_WLOCKED(m->object);
- if (!vm_page_xbusied(m) && (m->aflags & PGA_WRITEABLE) == 0)
- return (rv);
- rw_wlock(&pvh_global_lock);
- sched_pin();
- TAILQ_FOREACH(pv, &m->md.pv_list, pv_next) {
- pmap = PV_PMAP(pv);
- PMAP_LOCK(pmap);
- pte = pmap_pte_quick(pmap, pv->pv_va);
- rv = (*pte & PG_M) != 0;
- PMAP_UNLOCK(pmap);
- if (rv)
- break;
- }
- if (*PMAP1)
- PT_SET_MA(PADDR1, 0);
- sched_unpin();
- rw_wunlock(&pvh_global_lock);
- return (rv);
-}
-
-/*
- * pmap_is_prefaultable:
- *
- * Return whether or not the specified virtual address is elgible
- * for prefault.
- */
-static boolean_t
-pmap_is_prefaultable_locked(pmap_t pmap, vm_offset_t addr)
-{
- pt_entry_t *pte;
- boolean_t rv = FALSE;
-
- return (rv);
-
- if (pmap_is_current(pmap) && *pmap_pde(pmap, addr)) {
- pte = vtopte(addr);
- rv = (*pte == 0);
- }
- return (rv);
-}
-
-boolean_t
-pmap_is_prefaultable(pmap_t pmap, vm_offset_t addr)
-{
- boolean_t rv;
-
- PMAP_LOCK(pmap);
- rv = pmap_is_prefaultable_locked(pmap, addr);
- PMAP_UNLOCK(pmap);
- return (rv);
-}
-
-boolean_t
-pmap_is_referenced(vm_page_t m)
-{
- pv_entry_t pv;
- pt_entry_t *pte;
- pmap_t pmap;
- boolean_t rv;
-
- KASSERT((m->oflags & VPO_UNMANAGED) == 0,
- ("pmap_is_referenced: page %p is not managed", m));
- rv = FALSE;
- rw_wlock(&pvh_global_lock);
- sched_pin();
- TAILQ_FOREACH(pv, &m->md.pv_list, pv_next) {
- pmap = PV_PMAP(pv);
- PMAP_LOCK(pmap);
- pte = pmap_pte_quick(pmap, pv->pv_va);
- rv = (*pte & (PG_A | PG_V)) == (PG_A | PG_V);
- PMAP_UNLOCK(pmap);
- if (rv)
- break;
- }
- if (*PMAP1)
- PT_SET_MA(PADDR1, 0);
- sched_unpin();
- rw_wunlock(&pvh_global_lock);
- return (rv);
-}
-
-void
-pmap_map_readonly(pmap_t pmap, vm_offset_t va, int len)
-{
- int i, npages = round_page(len) >> PAGE_SHIFT;
- for (i = 0; i < npages; i++) {
- pt_entry_t *pte;
- pte = pmap_pte(pmap, (vm_offset_t)(va + i*PAGE_SIZE));
- rw_wlock(&pvh_global_lock);
- pte_store(pte, xpmap_mtop(*pte & ~(PG_RW|PG_M)));
- rw_wunlock(&pvh_global_lock);
- PMAP_MARK_PRIV(xpmap_mtop(*pte));
- pmap_pte_release(pte);
- }
-}
-
-void
-pmap_map_readwrite(pmap_t pmap, vm_offset_t va, int len)
-{
- int i, npages = round_page(len) >> PAGE_SHIFT;
- for (i = 0; i < npages; i++) {
- pt_entry_t *pte;
- pte = pmap_pte(pmap, (vm_offset_t)(va + i*PAGE_SIZE));
- PMAP_MARK_UNPRIV(xpmap_mtop(*pte));
- rw_wlock(&pvh_global_lock);
- pte_store(pte, xpmap_mtop(*pte) | (PG_RW|PG_M));
- rw_wunlock(&pvh_global_lock);
- pmap_pte_release(pte);
- }
-}
-
-/*
- * Clear the write and modified bits in each of the given page's mappings.
- */
-void
-pmap_remove_write(vm_page_t m)
-{
- pv_entry_t pv;
- pmap_t pmap;
- pt_entry_t oldpte, *pte;
-
- KASSERT((m->oflags & VPO_UNMANAGED) == 0,
- ("pmap_remove_write: page %p is not managed", m));
-
- /*
- * If the page is not exclusive busied, then PGA_WRITEABLE cannot be
- * set by another thread while the object is locked. Thus,
- * if PGA_WRITEABLE is clear, no page table entries need updating.
- */
- VM_OBJECT_ASSERT_WLOCKED(m->object);
- if (!vm_page_xbusied(m) && (m->aflags & PGA_WRITEABLE) == 0)
- return;
- rw_wlock(&pvh_global_lock);
- sched_pin();
- TAILQ_FOREACH(pv, &m->md.pv_list, pv_next) {
- pmap = PV_PMAP(pv);
- PMAP_LOCK(pmap);
- pte = pmap_pte_quick(pmap, pv->pv_va);
-retry:
- oldpte = *pte;
- if ((oldpte & PG_RW) != 0) {
- vm_paddr_t newpte = oldpte & ~(PG_RW | PG_M);
-
- /*
- * Regardless of whether a pte is 32 or 64 bits
- * in size, PG_RW and PG_M are among the least
- * significant 32 bits.
- */
- PT_SET_VA_MA(pte, newpte, TRUE);
- if (*pte != newpte)
- goto retry;
-
- if ((oldpte & PG_M) != 0)
- vm_page_dirty(m);
- pmap_invalidate_page(pmap, pv->pv_va);
- }
- PMAP_UNLOCK(pmap);
- }
- vm_page_aflag_clear(m, PGA_WRITEABLE);
- PT_UPDATES_FLUSH();
- if (*PMAP1)
- PT_SET_MA(PADDR1, 0);
- sched_unpin();
- rw_wunlock(&pvh_global_lock);
-}
-
-/*
- * pmap_ts_referenced:
- *
- * Return a count of reference bits for a page, clearing those bits.
- * It is not necessary for every reference bit to be cleared, but it
- * is necessary that 0 only be returned when there are truly no
- * reference bits set.
- *
- * XXX: The exact number of bits to check and clear is a matter that
- * should be tested and standardized at some point in the future for
- * optimal aging of shared pages.
- */
-int
-pmap_ts_referenced(vm_page_t m)
-{
- pv_entry_t pv, pvf, pvn;
- pmap_t pmap;
- pt_entry_t *pte;
- int rtval = 0;
-
- KASSERT((m->oflags & VPO_UNMANAGED) == 0,
- ("pmap_ts_referenced: page %p is not managed", m));
- rw_wlock(&pvh_global_lock);
- sched_pin();
- if ((pv = TAILQ_FIRST(&m->md.pv_list)) != NULL) {
- pvf = pv;
- do {
- pvn = TAILQ_NEXT(pv, pv_next);
- TAILQ_REMOVE(&m->md.pv_list, pv, pv_next);
- TAILQ_INSERT_TAIL(&m->md.pv_list, pv, pv_next);
- pmap = PV_PMAP(pv);
- PMAP_LOCK(pmap);
- pte = pmap_pte_quick(pmap, pv->pv_va);
- if ((*pte & PG_A) != 0) {
- PT_SET_VA_MA(pte, *pte & ~PG_A, FALSE);
- pmap_invalidate_page(pmap, pv->pv_va);
- rtval++;
- if (rtval > 4)
- pvn = NULL;
- }
- PMAP_UNLOCK(pmap);
- } while ((pv = pvn) != NULL && pv != pvf);
- }
- PT_UPDATES_FLUSH();
- if (*PMAP1)
- PT_SET_MA(PADDR1, 0);
- sched_unpin();
- rw_wunlock(&pvh_global_lock);
- return (rtval);
-}
-
-/*
- * Apply the given advice to the specified range of addresses within the
- * given pmap. Depending on the advice, clear the referenced and/or
- * modified flags in each mapping and set the mapped page's dirty field.
- */
-void
-pmap_advise(pmap_t pmap, vm_offset_t sva, vm_offset_t eva, int advice)
-{
- pd_entry_t oldpde;
- pt_entry_t *pte;
- vm_offset_t pdnxt;
- vm_page_t m;
- boolean_t anychanged;
-
- if (advice != MADV_DONTNEED && advice != MADV_FREE)
- return;
- anychanged = FALSE;
- rw_wlock(&pvh_global_lock);
- sched_pin();
- PMAP_LOCK(pmap);
- for (; sva < eva; sva = pdnxt) {
- pdnxt = (sva + NBPDR) & ~PDRMASK;
- if (pdnxt < sva)
- pdnxt = eva;
- oldpde = pmap->pm_pdir[sva >> PDRSHIFT];
- if ((oldpde & (PG_PS | PG_V)) != PG_V)
- continue;
- if (pdnxt > eva)
- pdnxt = eva;
- for (pte = pmap_pte_quick(pmap, sva); sva != pdnxt; pte++,
- sva += PAGE_SIZE) {
- if ((*pte & (PG_MANAGED | PG_V)) != (PG_MANAGED |
- PG_V))
- continue;
- else if ((*pte & (PG_M | PG_RW)) == (PG_M | PG_RW)) {
- if (advice == MADV_DONTNEED) {
- /*
- * Future calls to pmap_is_modified()
- * can be avoided by making the page
- * dirty now.
- */
- m = PHYS_TO_VM_PAGE(xpmap_mtop(*pte) &
- PG_FRAME);
- vm_page_dirty(m);
- }
- PT_SET_VA_MA(pte, *pte & ~(PG_M | PG_A), TRUE);
- } else if ((*pte & PG_A) != 0)
- PT_SET_VA_MA(pte, *pte & ~PG_A, TRUE);
- else
- continue;
- if ((*pte & PG_G) != 0)
- pmap_invalidate_page(pmap, sva);
- else
- anychanged = TRUE;
- }
- }
- PT_UPDATES_FLUSH();
- if (*PMAP1)
- PT_SET_VA_MA(PMAP1, 0, TRUE);
- if (anychanged)
- pmap_invalidate_all(pmap);
- sched_unpin();
- rw_wunlock(&pvh_global_lock);
- PMAP_UNLOCK(pmap);
-}
-
-/*
- * Clear the modify bits on the specified physical page.
- */
-void
-pmap_clear_modify(vm_page_t m)
-{
- pv_entry_t pv;
- pmap_t pmap;
- pt_entry_t *pte;
-
- KASSERT((m->oflags & VPO_UNMANAGED) == 0,
- ("pmap_clear_modify: page %p is not managed", m));
- VM_OBJECT_ASSERT_WLOCKED(m->object);
- KASSERT(!vm_page_xbusied(m),
- ("pmap_clear_modify: page %p is exclusive busied", m));
-
- /*
- * If the page is not PGA_WRITEABLE, then no PTEs can have PG_M set.
- * If the object containing the page is locked and the page is not
- * exclusive busied, then PGA_WRITEABLE cannot be concurrently set.
- */
- if ((m->aflags & PGA_WRITEABLE) == 0)
- return;
- rw_wlock(&pvh_global_lock);
- sched_pin();
- TAILQ_FOREACH(pv, &m->md.pv_list, pv_next) {
- pmap = PV_PMAP(pv);
- PMAP_LOCK(pmap);
- pte = pmap_pte_quick(pmap, pv->pv_va);
- if ((*pte & (PG_M | PG_RW)) == (PG_M | PG_RW)) {
- /*
- * Regardless of whether a pte is 32 or 64 bits
- * in size, PG_M is among the least significant
- * 32 bits.
- */
- PT_SET_VA_MA(pte, *pte & ~PG_M, FALSE);
- pmap_invalidate_page(pmap, pv->pv_va);
- }
- PMAP_UNLOCK(pmap);
- }
- sched_unpin();
- rw_wunlock(&pvh_global_lock);
-}
-
-/*
- * Miscellaneous support routines follow
- */
-
-/*
- * 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_attr(vm_paddr_t pa, vm_size_t size, int mode)
-{
- vm_offset_t va, offset;
- vm_size_t tmpsize;
-
- offset = pa & PAGE_MASK;
- size = round_page(offset + size);
- pa = pa & PG_FRAME;
-
- if (pa < KERNLOAD && pa + size <= KERNLOAD)
- va = KERNBASE + pa;
- else
- va = kva_alloc(size);
- if (!va)
- panic("pmap_mapdev: Couldn't alloc kernel virtual memory");
-
- for (tmpsize = 0; tmpsize < size; tmpsize += PAGE_SIZE)
- pmap_kenter_attr(va + tmpsize, pa + tmpsize, mode);
- pmap_invalidate_range(kernel_pmap, va, va + tmpsize);
- pmap_invalidate_cache_range(va, va + size, FALSE);
- return ((void *)(va + offset));
-}
-
-void *
-pmap_mapdev(vm_paddr_t pa, vm_size_t size)
-{
-
- return (pmap_mapdev_attr(pa, size, PAT_UNCACHEABLE));
-}
-
-void *
-pmap_mapbios(vm_paddr_t pa, vm_size_t size)
-{
-
- return (pmap_mapdev_attr(pa, size, PAT_WRITE_BACK));
-}
-
-void
-pmap_unmapdev(vm_offset_t va, vm_size_t size)
-{
- vm_offset_t base, offset;
-
- if (va >= KERNBASE && va + size <= KERNBASE + KERNLOAD)
- return;
- base = trunc_page(va);
- offset = va & PAGE_MASK;
- size = round_page(offset + size);
- kva_free(base, size);
-}
-
-/*
- * Sets the memory attribute for the specified page.
- */
-void
-pmap_page_set_memattr(vm_page_t m, vm_memattr_t ma)
-{
-
- m->md.pat_mode = ma;
- if ((m->flags & PG_FICTITIOUS) != 0)
- return;
-
- /*
- * If "m" is a normal page, flush it from the cache.
- * See pmap_invalidate_cache_range().
- *
- * First, try to find an existing mapping of the page by sf
- * buffer. sf_buf_invalidate_cache() modifies mapping and
- * flushes the cache.
- */
- if (sf_buf_invalidate_cache(m))
- return;
-
- /*
- * If page is not mapped by sf buffer, but CPU does not
- * support self snoop, map the page transient and do
- * invalidation. In the worst case, whole cache is flushed by
- * pmap_invalidate_cache_range().
- */
- if ((cpu_feature & CPUID_SS) == 0)
- pmap_flush_page(m);
-}
-
-static void
-pmap_flush_page(vm_page_t m)
-{
- struct sysmaps *sysmaps;
- vm_offset_t sva, eva;
-
- if ((cpu_feature & CPUID_CLFSH) != 0) {
- sysmaps = &sysmaps_pcpu[PCPU_GET(cpuid)];
- mtx_lock(&sysmaps->lock);
- if (*sysmaps->CMAP2)
- panic("pmap_flush_page: CMAP2 busy");
- sched_pin();
- PT_SET_MA(sysmaps->CADDR2, PG_V | PG_RW |
- VM_PAGE_TO_MACH(m) | PG_A | PG_M |
- pmap_cache_bits(m->md.pat_mode, 0));
- invlcaddr(sysmaps->CADDR2);
- sva = (vm_offset_t)sysmaps->CADDR2;
- eva = sva + PAGE_SIZE;
-
- /*
- * Use mfence despite the ordering implied by
- * mtx_{un,}lock() because clflush is not guaranteed
- * to be ordered by any other instruction.
- */
- mfence();
- for (; sva < eva; sva += cpu_clflush_line_size)
- clflush(sva);
- mfence();
- PT_SET_MA(sysmaps->CADDR2, 0);
- sched_unpin();
- mtx_unlock(&sysmaps->lock);
- } else
- pmap_invalidate_cache();
-}
-
-/*
- * Changes the specified virtual address range's memory type to that given by
- * the parameter "mode". The specified virtual address range must be
- * completely contained within either the kernel map.
- *
- * Returns zero if the change completed successfully, and either EINVAL or
- * ENOMEM if the change failed. Specifically, EINVAL is returned if some part
- * of the virtual address range was not mapped, and ENOMEM is returned if
- * there was insufficient memory available to complete the change.
- */
-int
-pmap_change_attr(vm_offset_t va, vm_size_t size, int mode)
-{
- vm_offset_t base, offset, tmpva;
- pt_entry_t *pte;
- u_int opte, npte;
- pd_entry_t *pde;
- boolean_t changed;
-
- base = trunc_page(va);
- offset = va & PAGE_MASK;
- size = round_page(offset + size);
-
- /* Only supported on kernel virtual addresses. */
- if (base <= VM_MAXUSER_ADDRESS)
- return (EINVAL);
-
- /* 4MB pages and pages that aren't mapped aren't supported. */
- for (tmpva = base; tmpva < (base + size); tmpva += PAGE_SIZE) {
- pde = pmap_pde(kernel_pmap, tmpva);
- if (*pde & PG_PS)
- return (EINVAL);
- if ((*pde & PG_V) == 0)
- return (EINVAL);
- pte = vtopte(va);
- if ((*pte & PG_V) == 0)
- return (EINVAL);
- }
-
- changed = FALSE;
-
- /*
- * Ok, all the pages exist and are 4k, so run through them updating
- * their cache mode.
- */
- for (tmpva = base; size > 0; ) {
- pte = vtopte(tmpva);
-
- /*
- * The cache mode bits are all in the low 32-bits of the
- * PTE, so we can just spin on updating the low 32-bits.
- */
- do {
- opte = *(u_int *)pte;
- npte = opte & ~(PG_PTE_PAT | PG_NC_PCD | PG_NC_PWT);
- npte |= pmap_cache_bits(mode, 0);
- PT_SET_VA_MA(pte, npte, TRUE);
- } while (npte != opte && (*pte != npte));
- if (npte != opte)
- changed = TRUE;
- tmpva += PAGE_SIZE;
- size -= PAGE_SIZE;
- }
-
- /*
- * Flush CPU caches to make sure any data isn't cached that
- * shouldn't be, etc.
- */
- if (changed) {
- pmap_invalidate_range(kernel_pmap, base, tmpva);
- pmap_invalidate_cache_range(base, tmpva, FALSE);
- }
- return (0);
-}
-
-/*
- * perform the pmap work for mincore
- */
-int
-pmap_mincore(pmap_t pmap, vm_offset_t addr, vm_paddr_t *locked_pa)
-{
- pt_entry_t *ptep, pte;
- vm_paddr_t pa;
- int val;
-
- PMAP_LOCK(pmap);
-retry:
- ptep = pmap_pte(pmap, addr);
- pte = (ptep != NULL) ? PT_GET(ptep) : 0;
- pmap_pte_release(ptep);
- val = 0;
- if ((pte & PG_V) != 0) {
- val |= MINCORE_INCORE;
- if ((pte & (PG_M | PG_RW)) == (PG_M | PG_RW))
- val |= MINCORE_MODIFIED | MINCORE_MODIFIED_OTHER;
- if ((pte & PG_A) != 0)
- val |= MINCORE_REFERENCED | MINCORE_REFERENCED_OTHER;
- }
- if ((val & (MINCORE_MODIFIED_OTHER | MINCORE_REFERENCED_OTHER)) !=
- (MINCORE_MODIFIED_OTHER | MINCORE_REFERENCED_OTHER) &&
- (pte & (PG_MANAGED | PG_V)) == (PG_MANAGED | PG_V)) {
- pa = pte & PG_FRAME;
- /* Ensure that "PHYS_TO_VM_PAGE(pa)->object" doesn't change. */
- if (vm_page_pa_tryrelock(pmap, pa, locked_pa))
- goto retry;
- } else
- PA_UNLOCK_COND(*locked_pa);
- PMAP_UNLOCK(pmap);
- return (val);
-}
-
-void
-pmap_activate(struct thread *td)
-{
- pmap_t pmap, oldpmap;
- u_int cpuid;
- u_int32_t cr3;
-
- critical_enter();
- pmap = vmspace_pmap(td->td_proc->p_vmspace);
- oldpmap = PCPU_GET(curpmap);
- cpuid = PCPU_GET(cpuid);
-#if defined(SMP)
- CPU_CLR_ATOMIC(cpuid, &oldpmap->pm_active);
- CPU_SET_ATOMIC(cpuid, &pmap->pm_active);
-#else
- CPU_CLR(cpuid, &oldpmap->pm_active);
- CPU_SET(cpuid, &pmap->pm_active);
-#endif
-#ifdef PAE
- cr3 = vtophys(pmap->pm_pdpt);
-#else
- cr3 = vtophys(pmap->pm_pdir);
-#endif
- /*
- * pmap_activate is for the current thread on the current cpu
- */
- td->td_pcb->pcb_cr3 = cr3;
- PT_UPDATES_FLUSH();
- load_cr3(cr3);
- PCPU_SET(curpmap, pmap);
- critical_exit();
-}
-
-void
-pmap_sync_icache(pmap_t pm, vm_offset_t va, vm_size_t sz)
-{
-}
-
-/*
- * Increase the starting virtual address of the given mapping if a
- * different alignment might result in more superpage mappings.
- */
-void
-pmap_align_superpage(vm_object_t object, vm_ooffset_t offset,
- vm_offset_t *addr, vm_size_t size)
-{
- vm_offset_t superpage_offset;
-
- if (size < NBPDR)
- return;
- if (object != NULL && (object->flags & OBJ_COLORED) != 0)
- offset += ptoa(object->pg_color);
- superpage_offset = offset & PDRMASK;
- if (size - ((NBPDR - superpage_offset) & PDRMASK) < NBPDR ||
- (*addr & PDRMASK) == superpage_offset)
- return;
- if ((*addr & PDRMASK) < superpage_offset)
- *addr = (*addr & ~PDRMASK) + superpage_offset;
- else
- *addr = ((*addr + PDRMASK) & ~PDRMASK) + superpage_offset;
-}
-
-void
-pmap_suspend()
-{
- pmap_t pmap;
- int i, pdir, offset;
- vm_paddr_t pdirma;
- mmu_update_t mu[4];
-
- /*
- * We need to remove the recursive mapping structure from all
- * our pmaps so that Xen doesn't get confused when it restores
- * the page tables. The recursive map lives at page directory
- * index PTDPTDI. We assume that the suspend code has stopped
- * the other vcpus (if any).
- */
- LIST_FOREACH(pmap, &allpmaps, pm_list) {
- for (i = 0; i < 4; i++) {
- /*
- * Figure out which page directory (L2) page
- * contains this bit of the recursive map and
- * the offset within that page of the map
- * entry
- */
- pdir = (PTDPTDI + i) / NPDEPG;
- offset = (PTDPTDI + i) % NPDEPG;
- pdirma = pmap->pm_pdpt[pdir] & PG_FRAME;
- mu[i].ptr = pdirma + offset * sizeof(pd_entry_t);
- mu[i].val = 0;
- }
- HYPERVISOR_mmu_update(mu, 4, NULL, DOMID_SELF);
- }
-}
-
-void
-pmap_resume()
-{
- pmap_t pmap;
- int i, pdir, offset;
- vm_paddr_t pdirma;
- mmu_update_t mu[4];
-
- /*
- * Restore the recursive map that we removed on suspend.
- */
- LIST_FOREACH(pmap, &allpmaps, pm_list) {
- for (i = 0; i < 4; i++) {
- /*
- * Figure out which page directory (L2) page
- * contains this bit of the recursive map and
- * the offset within that page of the map
- * entry
- */
- pdir = (PTDPTDI + i) / NPDEPG;
- offset = (PTDPTDI + i) % NPDEPG;
- pdirma = pmap->pm_pdpt[pdir] & PG_FRAME;
- mu[i].ptr = pdirma + offset * sizeof(pd_entry_t);
- mu[i].val = (pmap->pm_pdpt[i] & PG_FRAME) | PG_V;
- }
- HYPERVISOR_mmu_update(mu, 4, NULL, DOMID_SELF);
- }
-}
-
-#if defined(PMAP_DEBUG)
-pmap_pid_dump(int pid)
-{
- pmap_t pmap;
- struct proc *p;
- int npte = 0;
- int index;
-
- sx_slock(&allproc_lock);
- FOREACH_PROC_IN_SYSTEM(p) {
- 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 < NPDEPTD; i++) {
- pd_entry_t *pde;
- pt_entry_t *pte;
- vm_offset_t base = i << PDRSHIFT;
-
- pde = &pmap->pm_pdir[i];
- if (pde && pmap_pde_v(pde)) {
- for (j = 0; j < NPTEPG; j++) {
- vm_offset_t va = base + (j << PAGE_SHIFT);
- if (va >= (vm_offset_t) VM_MIN_KERNEL_ADDRESS) {
- if (index) {
- index = 0;
- printf("\n");
- }
- sx_sunlock(&allproc_lock);
- return (npte);
- }
- pte = pmap_pte(pmap, va);
- if (pte && pmap_pte_v(pte)) {
- pt_entry_t pa;
- vm_page_t m;
- pa = PT_GET(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(" ");
- }
- }
- }
- }
- }
- }
- }
- sx_sunlock(&allproc_lock);
- return (npte);
-}
-#endif
-
-#if defined(DEBUG)
-
-static void pads(pmap_t pm);
-void pmap_pvdump(vm_paddr_t pa);
-
-/* print address space of pmap*/
-static void
-pads(pmap_t pm)
-{
- int i, j;
- vm_paddr_t va;
- pt_entry_t *ptep;
-
- if (pm == kernel_pmap)
- return;
- for (i = 0; i < NPDEPTD; i++)
- if (pm->pm_pdir[i])
- for (j = 0; j < NPTEPG; 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(pm, va);
- if (pmap_pte_v(ptep))
- printf("%x:%x ", va, *ptep);
- };
-
-}
-
-void
-pmap_pvdump(vm_paddr_t pa)
-{
- pv_entry_t pv;
- pmap_t pmap;
- vm_page_t m;
-
- printf("pa %x", pa);
- m = PHYS_TO_VM_PAGE(pa);
- TAILQ_FOREACH(pv, &m->md.pv_list, pv_next) {
- pmap = PV_PMAP(pv);
- printf(" -> pmap %p, va %x", (void *)pmap, pv->pv_va);
- pads(pmap);
- }
- printf(" ");
-}
-#endif
diff --git a/sys/i386/xen/xen_machdep.c b/sys/i386/xen/xen_machdep.c
deleted file mode 100644
index dbaa7ad..0000000
--- a/sys/i386/xen/xen_machdep.c
+++ /dev/null
@@ -1,1236 +0,0 @@
-/*
- *
- * Copyright (c) 2004 Christian Limpach.
- * Copyright (c) 2004-2006,2008 Kip Macy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Christian Limpach.
- * 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/bus.h>
-#include <sys/ktr.h>
-#include <sys/lock.h>
-#include <sys/mount.h>
-#include <sys/malloc.h>
-#include <sys/mutex.h>
-#include <sys/kernel.h>
-#include <sys/proc.h>
-#include <sys/reboot.h>
-#include <sys/rwlock.h>
-#include <sys/sysproto.h>
-#include <sys/boot.h>
-
-#include <xen/xen-os.h>
-
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <machine/segments.h>
-#include <machine/pcb.h>
-#include <machine/stdarg.h>
-#include <machine/vmparam.h>
-#include <machine/cpu.h>
-#include <machine/intr_machdep.h>
-#include <machine/md_var.h>
-#include <machine/asmacros.h>
-
-
-
-#include <xen/hypervisor.h>
-#include <xen/xenstore/xenstorevar.h>
-#include <machine/xen/xenvar.h>
-#include <machine/xen/xenfunc.h>
-#include <machine/xen/xenpmap.h>
-#include <machine/xen/xenfunc.h>
-#include <xen/interface/memory.h>
-#include <machine/xen/features.h>
-#ifdef SMP
-#include <machine/privatespace.h>
-#endif
-
-
-#include <vm/vm_page.h>
-
-
-#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(xmm), IDTVEC(lcall_syscall), IDTVEC(int0x80_syscall);
-
-
-int xendebug_flags;
-start_info_t *xen_start_info;
-start_info_t *HYPERVISOR_start_info;
-shared_info_t *HYPERVISOR_shared_info;
-xen_pfn_t *xen_machine_phys = machine_to_phys_mapping;
-xen_pfn_t *xen_phys_machine;
-xen_pfn_t *xen_pfn_to_mfn_frame_list[16];
-xen_pfn_t *xen_pfn_to_mfn_frame_list_list;
-int preemptable, init_first;
-extern unsigned int avail_space;
-int xen_vector_callback_enabled = 0;
-enum xen_domain_type xen_domain_type = XEN_PV_DOMAIN;
-
-void ni_cli(void);
-void ni_sti(void);
-
-
-void
-ni_cli(void)
-{
- CTR0(KTR_SPARE2, "ni_cli disabling interrupts");
- __asm__("pushl %edx;"
- "pushl %eax;"
- );
- __cli();
- __asm__("popl %eax;"
- "popl %edx;"
- );
-}
-
-
-void
-ni_sti(void)
-{
- __asm__("pushl %edx;"
- "pushl %esi;"
- "pushl %eax;"
- );
- __sti();
- __asm__("popl %eax;"
- "popl %esi;"
- "popl %edx;"
- );
-}
-
-void
-force_evtchn_callback(void)
-{
- (void)HYPERVISOR_xen_version(0, NULL);
-}
-
-/*
- * Modify the cmd_line by converting ',' to NULLs so that it is in a format
- * suitable for the static env vars.
- */
-char *
-xen_setbootenv(char *cmd_line)
-{
- char *cmd_line_next;
-
- /* Skip leading spaces */
- for (; *cmd_line == ' '; cmd_line++);
-
- xc_printf("xen_setbootenv(): cmd_line='%s'\n", cmd_line);
-
- for (cmd_line_next = cmd_line; strsep(&cmd_line_next, ",") != NULL;);
- return cmd_line;
-}
-
-int
-xen_boothowto(char *envp)
-{
- int i, howto = 0;
-
- /* get equivalents from the environment */
- for (i = 0; howto_names[i].ev != NULL; i++)
- if (kern_getenv(howto_names[i].ev) != NULL)
- howto |= howto_names[i].mask;
- return howto;
-}
-
-
-#define XPQUEUE_SIZE 128
-
-struct mmu_log {
- char *file;
- int line;
-};
-
-#ifdef SMP
-/* per-cpu queues and indices */
-#ifdef INVARIANTS
-static struct mmu_log xpq_queue_log[XEN_LEGACY_MAX_VCPUS][XPQUEUE_SIZE];
-#endif
-
-static int xpq_idx[XEN_LEGACY_MAX_VCPUS];
-static mmu_update_t xpq_queue[XEN_LEGACY_MAX_VCPUS][XPQUEUE_SIZE];
-
-#define XPQ_QUEUE_LOG xpq_queue_log[vcpu]
-#define XPQ_QUEUE xpq_queue[vcpu]
-#define XPQ_IDX xpq_idx[vcpu]
-#define SET_VCPU() int vcpu = smp_processor_id()
-#else
-
-static mmu_update_t xpq_queue[XPQUEUE_SIZE];
-#ifdef INVARIANTS
-static struct mmu_log xpq_queue_log[XPQUEUE_SIZE];
-#endif
-static int xpq_idx = 0;
-
-#define XPQ_QUEUE_LOG xpq_queue_log
-#define XPQ_QUEUE xpq_queue
-#define XPQ_IDX xpq_idx
-#define SET_VCPU()
-#endif /* !SMP */
-
-#define XPQ_IDX_INC atomic_add_int(&XPQ_IDX, 1);
-
-#if 0
-static void
-xen_dump_queue(void)
-{
- int _xpq_idx = XPQ_IDX;
- int i;
-
- if (_xpq_idx <= 1)
- return;
-
- xc_printf("xen_dump_queue(): %u entries\n", _xpq_idx);
- for (i = 0; i < _xpq_idx; i++) {
- xc_printf(" val: %llx ptr: %llx\n", XPQ_QUEUE[i].val,
- XPQ_QUEUE[i].ptr);
- }
-}
-#endif
-
-
-static __inline void
-_xen_flush_queue(void)
-{
- SET_VCPU();
- int _xpq_idx = XPQ_IDX;
- int error, i;
-
-#ifdef INVARIANTS
- if (__predict_true(gdtset))
- CRITICAL_ASSERT(curthread);
-#endif
-
- XPQ_IDX = 0;
- /* Make sure index is cleared first to avoid double updates. */
- error = HYPERVISOR_mmu_update((mmu_update_t *)&XPQ_QUEUE,
- _xpq_idx, NULL, DOMID_SELF);
-
-#if 0
- if (__predict_true(gdtset))
- for (i = _xpq_idx; i > 0;) {
- if (i >= 3) {
- CTR6(KTR_PMAP, "mmu:val: %lx ptr: %lx val: %lx "
- "ptr: %lx val: %lx ptr: %lx",
- (XPQ_QUEUE[i-1].val & 0xffffffff),
- (XPQ_QUEUE[i-1].ptr & 0xffffffff),
- (XPQ_QUEUE[i-2].val & 0xffffffff),
- (XPQ_QUEUE[i-2].ptr & 0xffffffff),
- (XPQ_QUEUE[i-3].val & 0xffffffff),
- (XPQ_QUEUE[i-3].ptr & 0xffffffff));
- i -= 3;
- } else if (i == 2) {
- CTR4(KTR_PMAP, "mmu: val: %lx ptr: %lx val: %lx ptr: %lx",
- (XPQ_QUEUE[i-1].val & 0xffffffff),
- (XPQ_QUEUE[i-1].ptr & 0xffffffff),
- (XPQ_QUEUE[i-2].val & 0xffffffff),
- (XPQ_QUEUE[i-2].ptr & 0xffffffff));
- i = 0;
- } else {
- CTR2(KTR_PMAP, "mmu: val: %lx ptr: %lx",
- (XPQ_QUEUE[i-1].val & 0xffffffff),
- (XPQ_QUEUE[i-1].ptr & 0xffffffff));
- i = 0;
- }
- }
-#endif
- if (__predict_false(error < 0)) {
- for (i = 0; i < _xpq_idx; i++)
- printf("val: %llx ptr: %llx\n",
- XPQ_QUEUE[i].val, XPQ_QUEUE[i].ptr);
- panic("Failed to execute MMU updates: %d", error);
- }
-
-}
-
-void
-xen_flush_queue(void)
-{
- SET_VCPU();
-
- if (__predict_true(gdtset))
- critical_enter();
- if (XPQ_IDX != 0) _xen_flush_queue();
- if (__predict_true(gdtset))
- critical_exit();
-}
-
-static __inline void
-xen_increment_idx(void)
-{
- SET_VCPU();
-
- XPQ_IDX++;
- if (__predict_false(XPQ_IDX == XPQUEUE_SIZE))
- xen_flush_queue();
-}
-
-void
-xen_check_queue(void)
-{
-#ifdef INVARIANTS
- SET_VCPU();
-
- KASSERT(XPQ_IDX == 0, ("pending operations XPQ_IDX=%d", XPQ_IDX));
-#endif
-}
-
-void
-xen_invlpg(vm_offset_t va)
-{
- struct mmuext_op op;
- op.cmd = MMUEXT_INVLPG_ALL;
- op.arg1.linear_addr = va & ~PAGE_MASK;
- PANIC_IF(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
-}
-
-void
-xen_load_cr3(u_int val)
-{
- struct mmuext_op op;
-#ifdef INVARIANTS
- SET_VCPU();
-
- KASSERT(XPQ_IDX == 0, ("pending operations XPQ_IDX=%d", XPQ_IDX));
-#endif
- op.cmd = MMUEXT_NEW_BASEPTR;
- op.arg1.mfn = xpmap_ptom(val) >> PAGE_SHIFT;
- PANIC_IF(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
-}
-
-#ifdef KTR
-static __inline u_int
-rebp(void)
-{
- u_int data;
-
- __asm __volatile("movl 4(%%ebp),%0" : "=r" (data));
- return (data);
-}
-#endif
-
-u_int
-read_eflags(void)
-{
- vcpu_info_t *_vcpu;
- u_int eflags;
-
- eflags = _read_eflags();
- _vcpu = &HYPERVISOR_shared_info->vcpu_info[smp_processor_id()];
- if (_vcpu->evtchn_upcall_mask)
- eflags &= ~PSL_I;
-
- return (eflags);
-}
-
-void
-write_eflags(u_int eflags)
-{
- u_int intr;
-
- CTR2(KTR_SPARE2, "%x xen_restore_flags eflags %x", rebp(), eflags);
- intr = ((eflags & PSL_I) == 0);
- __restore_flags(intr);
- _write_eflags(eflags);
-}
-
-void
-xen_cli(void)
-{
- CTR1(KTR_SPARE2, "%x xen_cli disabling interrupts", rebp());
- __cli();
-}
-
-void
-xen_sti(void)
-{
- CTR1(KTR_SPARE2, "%x xen_sti enabling interrupts", rebp());
- __sti();
-}
-
-u_int
-xen_rcr2(void)
-{
-
- return (HYPERVISOR_shared_info->vcpu_info[curcpu].arch.cr2);
-}
-
-void
-_xen_machphys_update(vm_paddr_t mfn, vm_paddr_t pfn, char *file, int line)
-{
- SET_VCPU();
-
- if (__predict_true(gdtset))
- critical_enter();
- XPQ_QUEUE[XPQ_IDX].ptr = (mfn << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
- XPQ_QUEUE[XPQ_IDX].val = pfn;
-#ifdef INVARIANTS
- XPQ_QUEUE_LOG[XPQ_IDX].file = file;
- XPQ_QUEUE_LOG[XPQ_IDX].line = line;
-#endif
- xen_increment_idx();
- if (__predict_true(gdtset))
- critical_exit();
-}
-
-extern struct rwlock pvh_global_lock;
-
-void
-_xen_queue_pt_update(vm_paddr_t ptr, vm_paddr_t val, char *file, int line)
-{
- SET_VCPU();
-
- if (__predict_true(gdtset))
- rw_assert(&pvh_global_lock, RA_WLOCKED);
-
- KASSERT((ptr & 7) == 0, ("misaligned update"));
-
- if (__predict_true(gdtset))
- critical_enter();
-
- XPQ_QUEUE[XPQ_IDX].ptr = ((uint64_t)ptr) | MMU_NORMAL_PT_UPDATE;
- XPQ_QUEUE[XPQ_IDX].val = (uint64_t)val;
-#ifdef INVARIANTS
- XPQ_QUEUE_LOG[XPQ_IDX].file = file;
- XPQ_QUEUE_LOG[XPQ_IDX].line = line;
-#endif
- xen_increment_idx();
- if (__predict_true(gdtset))
- critical_exit();
-}
-
-void
-xen_pgdpt_pin(vm_paddr_t ma)
-{
- struct mmuext_op op;
- op.cmd = MMUEXT_PIN_L3_TABLE;
- op.arg1.mfn = ma >> PAGE_SHIFT;
- xen_flush_queue();
- PANIC_IF(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
-}
-
-void
-xen_pgd_pin(vm_paddr_t ma)
-{
- struct mmuext_op op;
- op.cmd = MMUEXT_PIN_L2_TABLE;
- op.arg1.mfn = ma >> PAGE_SHIFT;
- xen_flush_queue();
- PANIC_IF(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
-}
-
-void
-xen_pgd_unpin(vm_paddr_t ma)
-{
- struct mmuext_op op;
- op.cmd = MMUEXT_UNPIN_TABLE;
- op.arg1.mfn = ma >> PAGE_SHIFT;
- xen_flush_queue();
- PANIC_IF(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
-}
-
-void
-xen_pt_pin(vm_paddr_t ma)
-{
- struct mmuext_op op;
- op.cmd = MMUEXT_PIN_L1_TABLE;
- op.arg1.mfn = ma >> PAGE_SHIFT;
- xen_flush_queue();
- PANIC_IF(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
-}
-
-void
-xen_pt_unpin(vm_paddr_t ma)
-{
- struct mmuext_op op;
- op.cmd = MMUEXT_UNPIN_TABLE;
- op.arg1.mfn = ma >> PAGE_SHIFT;
- xen_flush_queue();
- PANIC_IF(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
-}
-
-void
-xen_set_ldt(vm_paddr_t ptr, unsigned long len)
-{
- struct mmuext_op op;
- op.cmd = MMUEXT_SET_LDT;
- op.arg1.linear_addr = ptr;
- op.arg2.nr_ents = len;
- xen_flush_queue();
- PANIC_IF(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
-}
-
-void xen_tlb_flush(void)
-{
- struct mmuext_op op;
- op.cmd = MMUEXT_TLB_FLUSH_LOCAL;
- xen_flush_queue();
- PANIC_IF(HYPERVISOR_mmuext_op(&op, 1, NULL, DOMID_SELF) < 0);
-}
-
-void
-xen_update_descriptor(union descriptor *table, union descriptor *entry)
-{
- vm_paddr_t pa;
- pt_entry_t *ptp;
-
- ptp = vtopte((vm_offset_t)table);
- pa = (*ptp & PG_FRAME) | ((vm_offset_t)table & PAGE_MASK);
- if (HYPERVISOR_update_descriptor(pa, *(uint64_t *)entry))
- panic("HYPERVISOR_update_descriptor failed\n");
-}
-
-
-#if 0
-/*
- * Bitmap is indexed by page number. If bit is set, the page is part of a
- * xen_create_contiguous_region() area of memory.
- */
-unsigned long *contiguous_bitmap;
-
-static void
-contiguous_bitmap_set(unsigned long first_page, unsigned long nr_pages)
-{
- unsigned long start_off, end_off, curr_idx, end_idx;
-
- curr_idx = first_page / BITS_PER_LONG;
- start_off = first_page & (BITS_PER_LONG-1);
- end_idx = (first_page + nr_pages) / BITS_PER_LONG;
- end_off = (first_page + nr_pages) & (BITS_PER_LONG-1);
-
- if (curr_idx == end_idx) {
- contiguous_bitmap[curr_idx] |=
- ((1UL<<end_off)-1) & -(1UL<<start_off);
- } else {
- contiguous_bitmap[curr_idx] |= -(1UL<<start_off);
- while ( ++curr_idx < end_idx )
- contiguous_bitmap[curr_idx] = ~0UL;
- contiguous_bitmap[curr_idx] |= (1UL<<end_off)-1;
- }
-}
-
-static void
-contiguous_bitmap_clear(unsigned long first_page, unsigned long nr_pages)
-{
- unsigned long start_off, end_off, curr_idx, end_idx;
-
- curr_idx = first_page / BITS_PER_LONG;
- start_off = first_page & (BITS_PER_LONG-1);
- end_idx = (first_page + nr_pages) / BITS_PER_LONG;
- end_off = (first_page + nr_pages) & (BITS_PER_LONG-1);
-
- if (curr_idx == end_idx) {
- contiguous_bitmap[curr_idx] &=
- -(1UL<<end_off) | ((1UL<<start_off)-1);
- } else {
- contiguous_bitmap[curr_idx] &= (1UL<<start_off)-1;
- while ( ++curr_idx != end_idx )
- contiguous_bitmap[curr_idx] = 0;
- contiguous_bitmap[curr_idx] &= -(1UL<<end_off);
- }
-}
-#endif
-
-/* Ensure multi-page extents are contiguous in machine memory. */
-int
-xen_create_contiguous_region(vm_page_t pages, int npages)
-{
- unsigned long mfn, i, flags;
- int order;
- struct xen_memory_reservation reservation = {
- .nr_extents = 1,
- .extent_order = 0,
- .domid = DOMID_SELF
- };
- set_xen_guest_handle(reservation.extent_start, &mfn);
-
- balloon_lock(flags);
-
- /* can currently only handle power of two allocation */
- PANIC_IF(ffs(npages) != fls(npages));
-
- /* 0. determine order */
- order = (ffs(npages) == fls(npages)) ? fls(npages) - 1 : fls(npages);
-
- /* 1. give away machine pages. */
- for (i = 0; i < (1 << order); i++) {
- int pfn;
- pfn = VM_PAGE_TO_PHYS(&pages[i]) >> PAGE_SHIFT;
- mfn = PFNTOMFN(pfn);
- PFNTOMFN(pfn) = INVALID_P2M_ENTRY;
- PANIC_IF(HYPERVISOR_memory_op(XENMEM_decrease_reservation, &reservation) != 1);
- }
-
-
- /* 2. Get a new contiguous memory extent. */
- reservation.extent_order = order;
- /* xenlinux hardcodes this because of aacraid - maybe set to 0 if we're not
- * running with a broxen driver XXXEN
- */
- reservation.address_bits = 31;
- if (HYPERVISOR_memory_op(XENMEM_increase_reservation, &reservation) != 1)
- goto fail;
-
- /* 3. Map the new extent in place of old pages. */
- for (i = 0; i < (1 << order); i++) {
- int pfn;
- pfn = VM_PAGE_TO_PHYS(&pages[i]) >> PAGE_SHIFT;
- xen_machphys_update(mfn+i, pfn);
- PFNTOMFN(pfn) = mfn+i;
- }
-
- xen_tlb_flush();
-
-#if 0
- contiguous_bitmap_set(VM_PAGE_TO_PHYS(&pages[0]) >> PAGE_SHIFT, 1UL << order);
-#endif
-
- balloon_unlock(flags);
-
- return 0;
-
- fail:
- reservation.extent_order = 0;
- reservation.address_bits = 0;
-
- for (i = 0; i < (1 << order); i++) {
- int pfn;
- pfn = VM_PAGE_TO_PHYS(&pages[i]) >> PAGE_SHIFT;
- PANIC_IF(HYPERVISOR_memory_op(
- XENMEM_increase_reservation, &reservation) != 1);
- xen_machphys_update(mfn, pfn);
- PFNTOMFN(pfn) = mfn;
- }
-
- xen_tlb_flush();
-
- balloon_unlock(flags);
-
- return ENOMEM;
-}
-
-void
-xen_destroy_contiguous_region(void *addr, int npages)
-{
- unsigned long mfn, i, flags, order, pfn0;
- struct xen_memory_reservation reservation = {
- .nr_extents = 1,
- .extent_order = 0,
- .domid = DOMID_SELF
- };
- set_xen_guest_handle(reservation.extent_start, &mfn);
-
- pfn0 = vtophys(addr) >> PAGE_SHIFT;
-#if 0
- scrub_pages(vstart, 1 << order);
-#endif
- /* can currently only handle power of two allocation */
- PANIC_IF(ffs(npages) != fls(npages));
-
- /* 0. determine order */
- order = (ffs(npages) == fls(npages)) ? fls(npages) - 1 : fls(npages);
-
- balloon_lock(flags);
-
-#if 0
- contiguous_bitmap_clear(vtophys(addr) >> PAGE_SHIFT, 1UL << order);
-#endif
-
- /* 1. Zap current PTEs, giving away the underlying pages. */
- for (i = 0; i < (1 << order); i++) {
- int pfn;
- uint64_t new_val = 0;
- pfn = vtomach((char *)addr + i*PAGE_SIZE) >> PAGE_SHIFT;
-
- PANIC_IF(HYPERVISOR_update_va_mapping((vm_offset_t)((char *)addr + (i * PAGE_SIZE)), new_val, 0));
- PFNTOMFN(pfn) = INVALID_P2M_ENTRY;
- PANIC_IF(HYPERVISOR_memory_op(
- XENMEM_decrease_reservation, &reservation) != 1);
- }
-
- /* 2. Map new pages in place of old pages. */
- for (i = 0; i < (1 << order); i++) {
- int pfn;
- uint64_t new_val;
- pfn = pfn0 + i;
- PANIC_IF(HYPERVISOR_memory_op(XENMEM_increase_reservation, &reservation) != 1);
-
- new_val = mfn << PAGE_SHIFT;
- PANIC_IF(HYPERVISOR_update_va_mapping((vm_offset_t)addr + (i * PAGE_SIZE),
- new_val, PG_KERNEL));
- xen_machphys_update(mfn, pfn);
- PFNTOMFN(pfn) = mfn;
- }
-
- xen_tlb_flush();
-
- balloon_unlock(flags);
-}
-
-extern vm_offset_t proc0kstack;
-extern int vm86paddr, vm86phystk;
-char *bootmem_start, *bootmem_current, *bootmem_end;
-
-pteinfo_t *pteinfo_list;
-void initvalues(start_info_t *startinfo);
-
-void *
-bootmem_alloc(unsigned int size)
-{
- char *retptr;
-
- retptr = bootmem_current;
- PANIC_IF(retptr + size > bootmem_end);
- bootmem_current += size;
-
- return retptr;
-}
-
-void
-bootmem_free(void *ptr, unsigned int size)
-{
- char *tptr;
-
- tptr = ptr;
- PANIC_IF(tptr != bootmem_current - size ||
- bootmem_current - size < bootmem_start);
-
- bootmem_current -= size;
-}
-
-#if 0
-static vm_paddr_t
-xpmap_mtop2(vm_paddr_t mpa)
-{
- return ((machine_to_phys_mapping[mpa >> PAGE_SHIFT] << PAGE_SHIFT)
- ) | (mpa & ~PG_FRAME);
-}
-
-static pd_entry_t
-xpmap_get_bootpde(vm_paddr_t va)
-{
-
- return ((pd_entry_t *)xen_start_info->pt_base)[va >> 22];
-}
-
-static pd_entry_t
-xpmap_get_vbootpde(vm_paddr_t va)
-{
- pd_entry_t pde;
-
- pde = xpmap_get_bootpde(va);
- if ((pde & PG_V) == 0)
- return (pde & ~PG_FRAME);
- return (pde & ~PG_FRAME) |
- (xpmap_mtop2(pde & PG_FRAME) + KERNBASE);
-}
-
-static pt_entry_t 8*
-xpmap_get_bootptep(vm_paddr_t va)
-{
- pd_entry_t pde;
-
- pde = xpmap_get_vbootpde(va);
- if ((pde & PG_V) == 0)
- return (void *)-1;
-#define PT_MASK 0x003ff000 /* page table address bits */
- return &(((pt_entry_t *)(pde & PG_FRAME))[(va & PT_MASK) >> PAGE_SHIFT]);
-}
-
-static pt_entry_t
-xpmap_get_bootpte(vm_paddr_t va)
-{
-
- return xpmap_get_bootptep(va)[0];
-}
-#endif
-
-
-#ifdef ADD_ISA_HOLE
-static void
-shift_phys_machine(unsigned long *phys_machine, int nr_pages)
-{
-
- unsigned long *tmp_page, *current_page, *next_page;
- int i;
-
- tmp_page = bootmem_alloc(PAGE_SIZE);
- current_page = phys_machine + nr_pages - (PAGE_SIZE/sizeof(unsigned long));
- next_page = current_page - (PAGE_SIZE/sizeof(unsigned long));
- bcopy(phys_machine, tmp_page, PAGE_SIZE);
-
- while (current_page > phys_machine) {
- /* save next page */
- bcopy(next_page, tmp_page, PAGE_SIZE);
- /* shift down page */
- bcopy(current_page, next_page, PAGE_SIZE);
- /* finish swap */
- bcopy(tmp_page, current_page, PAGE_SIZE);
-
- current_page -= (PAGE_SIZE/sizeof(unsigned long));
- next_page -= (PAGE_SIZE/sizeof(unsigned long));
- }
- bootmem_free(tmp_page, PAGE_SIZE);
-
- for (i = 0; i < nr_pages; i++) {
- xen_machphys_update(phys_machine[i], i);
- }
- memset(phys_machine, INVALID_P2M_ENTRY, PAGE_SIZE);
-
-}
-#endif /* ADD_ISA_HOLE */
-
-/*
- * Build a directory of the pages that make up our Physical to Machine
- * mapping table. The Xen suspend/restore code uses this to find our
- * mapping table.
- */
-static void
-init_frame_list_list(void *arg)
-{
- unsigned long nr_pages = xen_start_info->nr_pages;
-#define FPP (PAGE_SIZE/sizeof(xen_pfn_t))
- int i, j, k;
-
- xen_pfn_to_mfn_frame_list_list = malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK);
- for (i = 0, j = 0, k = -1; i < nr_pages;
- i += FPP, j++) {
- if ((j & (FPP - 1)) == 0) {
- k++;
- xen_pfn_to_mfn_frame_list[k] =
- malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK);
- xen_pfn_to_mfn_frame_list_list[k] =
- VTOMFN(xen_pfn_to_mfn_frame_list[k]);
- j = 0;
- }
- xen_pfn_to_mfn_frame_list[k][j] =
- VTOMFN(&xen_phys_machine[i]);
- }
-
- HYPERVISOR_shared_info->arch.max_pfn = nr_pages;
- HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list
- = VTOMFN(xen_pfn_to_mfn_frame_list_list);
-}
-SYSINIT(init_fll, SI_SUB_DEVFS, SI_ORDER_ANY, init_frame_list_list, NULL);
-
-extern unsigned long physfree;
-
-int pdir, curoffset;
-extern int nkpt;
-
-extern uint32_t kernbase;
-
-void
-initvalues(start_info_t *startinfo)
-{
- vm_offset_t cur_space, cur_space_pt;
- struct physdev_set_iopl set_iopl;
-
- int l3_pages, l2_pages, l1_pages, offset;
- vm_paddr_t console_page_ma, xen_store_ma;
- vm_offset_t tmpva;
- vm_paddr_t shinfo;
-#ifdef PAE
- vm_paddr_t IdlePDPTma, IdlePDPTnewma;
- vm_paddr_t IdlePTDnewma[4];
- pd_entry_t *IdlePDPTnew, *IdlePTDnew;
- vm_paddr_t IdlePTDma[4];
-#else
- vm_paddr_t IdlePTDma[1];
-#endif
- unsigned long i;
- int ncpus = MAXCPU;
-
- nkpt = min(
- min(
- max((startinfo->nr_pages >> NPGPTD_SHIFT), nkpt),
- NPGPTD*NPDEPG - KPTDI),
- (HYPERVISOR_VIRT_START - KERNBASE) >> PDRSHIFT);
-
- HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments);
-#ifdef notyet
- /*
- * need to install handler
- */
- HYPERVISOR_vm_assist(VMASST_CMD_enable, VMASST_TYPE_4gb_segments_notify);
-#endif
- xen_start_info = startinfo;
- HYPERVISOR_start_info = startinfo;
- xen_phys_machine = (xen_pfn_t *)startinfo->mfn_list;
-
- IdlePTD = (pd_entry_t *)((uint8_t *)startinfo->pt_base + PAGE_SIZE);
- l1_pages = 0;
-
-#ifdef PAE
- l3_pages = 1;
- l2_pages = 0;
- IdlePDPT = (pd_entry_t *)startinfo->pt_base;
- IdlePDPTma = VTOM(startinfo->pt_base);
- for (i = (KERNBASE >> 30);
- (i < 4) && (IdlePDPT[i] != 0); i++)
- l2_pages++;
- /*
- * Note that only one page directory has been allocated at this point.
- * Thus, if KERNBASE
- */
- for (i = 0; i < l2_pages; i++)
- IdlePTDma[i] = VTOM(IdlePTD + i*PAGE_SIZE);
-
- l2_pages = (l2_pages == 0) ? 1 : l2_pages;
-#else
- l3_pages = 0;
- l2_pages = 1;
-#endif
- for (i = (((KERNBASE>>18) & PAGE_MASK)>>PAGE_SHIFT);
- (i<l2_pages*NPDEPG) && (i<(VM_MAX_KERNEL_ADDRESS>>PDRSHIFT)); i++) {
-
- if (IdlePTD[i] == 0)
- break;
- l1_pages++;
- }
-
- /* number of pages allocated after the pts + 1*/;
- cur_space = xen_start_info->pt_base +
- (l3_pages + l2_pages + l1_pages + 1)*PAGE_SIZE;
-
- xc_printf("initvalues(): wooh - availmem=%x,%x\n", avail_space,
- cur_space);
-
- xc_printf("KERNBASE=%x,pt_base=%lx, VTOPFN(base)=%x, nr_pt_frames=%lx\n",
- KERNBASE,xen_start_info->pt_base, VTOPFN(xen_start_info->pt_base),
- xen_start_info->nr_pt_frames);
- xendebug_flags = 0; /* 0xffffffff; */
-
-#ifdef ADD_ISA_HOLE
- shift_phys_machine(xen_phys_machine, xen_start_info->nr_pages);
-#endif
- XENPRINTF("IdlePTD %p\n", IdlePTD);
- XENPRINTF("nr_pages: %ld shared_info: 0x%lx flags: 0x%x pt_base: 0x%lx "
- "mod_start: 0x%lx mod_len: 0x%lx\n",
- xen_start_info->nr_pages, xen_start_info->shared_info,
- xen_start_info->flags, xen_start_info->pt_base,
- xen_start_info->mod_start, xen_start_info->mod_len);
-
-#ifdef PAE
- IdlePDPTnew = (pd_entry_t *)cur_space; cur_space += PAGE_SIZE;
- bzero(IdlePDPTnew, PAGE_SIZE);
-
- IdlePDPTnewma = VTOM(IdlePDPTnew);
- IdlePTDnew = (pd_entry_t *)cur_space; cur_space += 4*PAGE_SIZE;
- bzero(IdlePTDnew, 4*PAGE_SIZE);
-
- for (i = 0; i < 4; i++)
- IdlePTDnewma[i] = VTOM((uint8_t *)IdlePTDnew + i*PAGE_SIZE);
- /*
- * L3
- *
- * Copy the 4 machine addresses of the new PTDs in to the PDPT
- *
- */
- for (i = 0; i < 4; i++)
- IdlePDPTnew[i] = IdlePTDnewma[i] | PG_V;
-
- __asm__("nop;");
- /*
- *
- * re-map the new PDPT read-only
- */
- PT_SET_MA(IdlePDPTnew, IdlePDPTnewma | PG_V);
- /*
- *
- * Unpin the current PDPT
- */
- xen_pt_unpin(IdlePDPTma);
-
-#endif /* PAE */
-
- /* Map proc0's KSTACK */
- proc0kstack = cur_space; cur_space += (KSTACK_PAGES * PAGE_SIZE);
- xc_printf("proc0kstack=%u\n", proc0kstack);
-
- /* vm86/bios stack */
- cur_space += PAGE_SIZE;
-
- /* Map space for the vm86 region */
- vm86paddr = (vm_offset_t)cur_space;
- cur_space += (PAGE_SIZE * 3);
-
- /* allocate 4 pages for bootmem allocator */
- bootmem_start = bootmem_current = (char *)cur_space;
- cur_space += (4 * PAGE_SIZE);
- bootmem_end = (char *)cur_space;
-
- /* allocate pages for gdt */
- gdt = (union descriptor *)cur_space;
- cur_space += PAGE_SIZE*ncpus;
-
- /* allocate page for ldt */
- ldt = (union descriptor *)cur_space; cur_space += PAGE_SIZE;
- cur_space += PAGE_SIZE;
-
- /* unmap remaining pages from initial chunk
- *
- */
- for (tmpva = cur_space; tmpva < (((uint32_t)&kernbase) + (l1_pages<<PDRSHIFT));
- tmpva += PAGE_SIZE) {
- bzero((char *)tmpva, PAGE_SIZE);
- PT_SET_MA(tmpva, (vm_paddr_t)0);
- }
-
- PT_UPDATES_FLUSH();
-
- memcpy(((uint8_t *)IdlePTDnew) + ((unsigned int)(KERNBASE >> 18)),
- ((uint8_t *)IdlePTD) + ((KERNBASE >> 18) & PAGE_MASK),
- l1_pages*sizeof(pt_entry_t));
-
- for (i = 0; i < 4; i++) {
- PT_SET_MA((uint8_t *)IdlePTDnew + i*PAGE_SIZE,
- IdlePTDnewma[i] | PG_V);
- }
- xen_load_cr3(VTOP(IdlePDPTnew));
- xen_pgdpt_pin(VTOM(IdlePDPTnew));
-
- /* allocate remainder of nkpt pages */
- cur_space_pt = cur_space;
- for (offset = (KERNBASE >> PDRSHIFT), i = l1_pages; i < nkpt;
- i++, cur_space += PAGE_SIZE) {
- pdir = (offset + i) / NPDEPG;
- curoffset = ((offset + i) % NPDEPG);
- if (((offset + i) << PDRSHIFT) == VM_MAX_KERNEL_ADDRESS)
- break;
-
- /*
- * make sure that all the initial page table pages
- * have been zeroed
- */
- PT_SET_MA(cur_space, VTOM(cur_space) | PG_V | PG_RW);
- bzero((char *)cur_space, PAGE_SIZE);
- PT_SET_MA(cur_space, (vm_paddr_t)0);
- xen_pt_pin(VTOM(cur_space));
- xen_queue_pt_update((vm_paddr_t)(IdlePTDnewma[pdir] +
- curoffset*sizeof(vm_paddr_t)),
- VTOM(cur_space) | PG_KERNEL);
- PT_UPDATES_FLUSH();
- }
-
- for (i = 0; i < 4; i++) {
- pdir = (PTDPTDI + i) / NPDEPG;
- curoffset = (PTDPTDI + i) % NPDEPG;
-
- xen_queue_pt_update((vm_paddr_t)(IdlePTDnewma[pdir] +
- curoffset*sizeof(vm_paddr_t)),
- IdlePTDnewma[i] | PG_V);
- }
-
- PT_UPDATES_FLUSH();
-
- IdlePTD = IdlePTDnew;
- IdlePDPT = IdlePDPTnew;
- IdlePDPTma = IdlePDPTnewma;
-
- HYPERVISOR_shared_info = (shared_info_t *)cur_space;
- cur_space += PAGE_SIZE;
-
- xen_store = (struct xenstore_domain_interface *)cur_space;
- cur_space += PAGE_SIZE;
-
- console_page = (char *)cur_space;
- cur_space += PAGE_SIZE;
-
- /*
- * shared_info is an unsigned long so this will randomly break if
- * it is allocated above 4GB - I guess people are used to that
- * sort of thing with Xen ... sigh
- */
- shinfo = xen_start_info->shared_info;
- PT_SET_MA(HYPERVISOR_shared_info, shinfo | PG_KERNEL);
-
- xc_printf("#4\n");
-
- xen_store_ma = (((vm_paddr_t)xen_start_info->store_mfn) << PAGE_SHIFT);
- PT_SET_MA(xen_store, xen_store_ma | PG_KERNEL);
- console_page_ma = (((vm_paddr_t)xen_start_info->console.domU.mfn) << PAGE_SHIFT);
- PT_SET_MA(console_page, console_page_ma | PG_KERNEL);
-
- xc_printf("#5\n");
-
- set_iopl.iopl = 1;
- PANIC_IF(HYPERVISOR_physdev_op(PHYSDEVOP_SET_IOPL, &set_iopl));
- xc_printf("#6\n");
-#if 0
- /* add page table for KERNBASE */
- xen_queue_pt_update(IdlePTDma + KPTDI*sizeof(vm_paddr_t),
- VTOM(cur_space) | PG_KERNEL);
- xen_flush_queue();
-#ifdef PAE
- xen_queue_pt_update(pdir_shadow_ma[3] + KPTDI*sizeof(vm_paddr_t),
- VTOM(cur_space) | PG_V | PG_A);
-#else
- xen_queue_pt_update(pdir_shadow_ma + KPTDI*sizeof(vm_paddr_t),
- VTOM(cur_space) | PG_V | PG_A);
-#endif
- xen_flush_queue();
- cur_space += PAGE_SIZE;
- xc_printf("#6\n");
-#endif /* 0 */
-#ifdef notyet
- if (xen_start_info->flags & SIF_INITDOMAIN) {
- /* Map first megabyte */
- for (i = 0; i < (256 << PAGE_SHIFT); i += PAGE_SIZE)
- PT_SET_MA(KERNBASE + i, i | PG_KERNEL | PG_NC_PCD);
- xen_flush_queue();
- }
-#endif
- /*
- * re-map kernel text read-only
- *
- */
- for (i = (((vm_offset_t)&btext) & ~PAGE_MASK);
- i < (((vm_offset_t)&etext) & ~PAGE_MASK); i += PAGE_SIZE)
- PT_SET_MA(i, VTOM(i) | PG_V | PG_A);
-
- xc_printf("#7\n");
- physfree = VTOP(cur_space);
- init_first = physfree >> PAGE_SHIFT;
- IdlePTD = (pd_entry_t *)VTOP(IdlePTD);
- IdlePDPT = (pd_entry_t *)VTOP(IdlePDPT);
- setup_xen_features();
- xc_printf("#8, proc0kstack=%u\n", proc0kstack);
-}
-
-
-trap_info_t trap_table[] = {
- { 0, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(div)},
- { 1, 0|4, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(dbg)},
- { 3, 3|4, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(bpt)},
- { 4, 3, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(ofl)},
- /* This is UPL on Linux and KPL on BSD */
- { 5, 3, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(bnd)},
- { 6, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(ill)},
- { 7, 0|4, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(dna)},
- /*
- * { 8, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(XXX)},
- * no handler for double fault
- */
- { 9, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(fpusegm)},
- {10, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(tss)},
- {11, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(missing)},
- {12, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(stk)},
- {13, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(prot)},
- {14, 0|4, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(page)},
- {15, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(rsvd)},
- {16, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(fpu)},
- {17, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(align)},
- {18, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(mchk)},
- {19, 0, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(xmm)},
- {0x80, 3, GSEL(GCODE_SEL, SEL_KPL), (unsigned long) &IDTVEC(int0x80_syscall)},
- { 0, 0, 0, 0 }
-};
-
-/* Perform a multicall and check that individual calls succeeded. */
-int
-HYPERVISOR_multicall(struct multicall_entry * call_list, int nr_calls)
-{
- int ret = 0;
- int i;
-
- /* Perform the multicall. */
- PANIC_IF(_HYPERVISOR_multicall(call_list, nr_calls));
-
- /* Check the results of individual hypercalls. */
- for (i = 0; i < nr_calls; i++)
- if (__predict_false(call_list[i].result < 0))
- ret++;
- if (__predict_false(ret > 0))
- panic("%d multicall(s) failed: cpu %d\n",
- ret, smp_processor_id());
-
- /* If we didn't panic already, everything succeeded. */
- return (0);
-}
-
-/********** CODE WORTH KEEPING ABOVE HERE *****************/
-
-void xen_failsafe_handler(void);
-
-void
-xen_failsafe_handler(void)
-{
-
- panic("xen_failsafe_handler called!\n");
-}
-
-void xen_handle_thread_switch(struct pcb *pcb);
-
-/* This is called by cpu_switch() when switching threads. */
-/* The pcb arg refers to the process control block of the */
-/* next thread which is to run */
-void
-xen_handle_thread_switch(struct pcb *pcb)
-{
- uint32_t *a = (uint32_t *)&PCPU_GET(fsgs_gdt)[0];
- uint32_t *b = (uint32_t *)&pcb->pcb_fsd;
- multicall_entry_t mcl[3];
- int i = 0;
-
- /* Notify Xen of task switch */
- mcl[i].op = __HYPERVISOR_stack_switch;
- mcl[i].args[0] = GSEL(GDATA_SEL, SEL_KPL);
- mcl[i++].args[1] = (unsigned long)pcb;
-
- /* Check for update of fsd */
- if (*a != *b || *(a+1) != *(b+1)) {
- mcl[i].op = __HYPERVISOR_update_descriptor;
- *(uint64_t *)&mcl[i].args[0] = vtomach((vm_offset_t)a);
- *(uint64_t *)&mcl[i++].args[2] = *(uint64_t *)b;
- }
-
- a += 2;
- b += 2;
-
- /* Check for update of gsd */
- if (*a != *b || *(a+1) != *(b+1)) {
- mcl[i].op = __HYPERVISOR_update_descriptor;
- *(uint64_t *)&mcl[i].args[0] = vtomach((vm_offset_t)a);
- *(uint64_t *)&mcl[i++].args[2] = *(uint64_t *)b;
- }
-
- (void)HYPERVISOR_multicall(mcl, i);
-}
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index 39e4df3..a98a15d 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -972,6 +972,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp)
elf_auxargs->base = addr;
elf_auxargs->flags = 0;
elf_auxargs->entry = entry;
+ elf_auxargs->hdr_eflags = hdr->e_flags;
imgp->auxargs = elf_auxargs;
imgp->interpreted = 0;
@@ -1002,6 +1003,9 @@ __elfN(freebsd_fixup)(register_t **stack_base, struct image_params *imgp)
AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
AUXARGS_ENTRY(pos, AT_BASE, args->base);
+#ifdef AT_EHDRFLAGS
+ AUXARGS_ENTRY(pos, AT_EHDRFLAGS, args->hdr_eflags);
+#endif
if (imgp->execpathp != 0)
AUXARGS_ENTRY(pos, AT_EXECPATH, imgp->execpathp);
AUXARGS_ENTRY(pos, AT_OSRELDATE,
@@ -1238,12 +1242,14 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags)
coresize = round_page(hdrsize + notesz) + seginfo.size;
#ifdef RACCT
- PROC_LOCK(td->td_proc);
- error = racct_add(td->td_proc, RACCT_CORE, coresize);
- PROC_UNLOCK(td->td_proc);
- if (error != 0) {
- error = EFAULT;
- goto done;
+ if (racct_enable) {
+ PROC_LOCK(td->td_proc);
+ error = racct_add(td->td_proc, RACCT_CORE, coresize);
+ PROC_UNLOCK(td->td_proc);
+ if (error != 0) {
+ error = EFAULT;
+ goto done;
+ }
}
#endif
if (coresize >= limit) {
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index b77b788..c263356 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -506,7 +506,7 @@ proc0_init(void *dummy __unused)
callout_init_mtx(&p->p_itcallout, &p->p_mtx, 0);
callout_init_mtx(&p->p_limco, &p->p_mtx, 0);
- callout_init(&td->td_slpcallout, CALLOUT_MPSAFE);
+ callout_init(&td->td_slpcallout, 1);
/* Create credentials. */
newcred = crget();
@@ -561,9 +561,9 @@ proc0_init(void *dummy __unused)
p->p_stats = pstats_alloc();
/* Allocate a prototype map so we have something to fork. */
- pmap_pinit0(vmspace_pmap(&vmspace0));
p->p_vmspace = &vmspace0;
vmspace0.vm_refcnt = 1;
+ pmap_pinit0(vmspace_pmap(&vmspace0));
/*
* proc0 is not expected to enter usermode, so there is no special
diff --git a/sys/kern/kern_cons.c b/sys/kern/kern_cons.c
index 75f8b9c..d219c81 100644
--- a/sys/kern/kern_cons.c
+++ b/sys/kern/kern_cons.c
@@ -654,7 +654,7 @@ static void
sysbeep_init(void *unused)
{
- callout_init(&beeping_timer, CALLOUT_MPSAFE);
+ callout_init(&beeping_timer, 1);
}
SYSINIT(sysbeep, SI_SUB_SOFTINTR, SI_ORDER_ANY, sysbeep_init, NULL);
#else
diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c
index 47845ef..71481fe 100644
--- a/sys/kern/kern_cpuset.c
+++ b/sys/kern/kern_cpuset.c
@@ -113,7 +113,7 @@ static struct unrhdr *cpuset_unr;
static struct cpuset *cpuset_zero, *cpuset_default;
/* Return the size of cpuset_t at the kernel level */
-SYSCTL_INT(_kern_sched, OID_AUTO, cpusetsize, CTLFLAG_RD,
+SYSCTL_INT(_kern_sched, OID_AUTO, cpusetsize, CTLFLAG_RD | CTLFLAG_CAPRD,
SYSCTL_NULL_INT_PTR, sizeof(cpuset_t), "sizeof(cpuset_t)");
cpuset_t *cpuset_root;
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index f3f27bf..7848396 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -617,7 +617,6 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
if (foffset < 0 ||
(flp->l_start > 0 &&
foffset > OFF_MAX - flp->l_start)) {
- FILEDESC_SUNLOCK(fdp);
error = EOVERFLOW;
fdrop(fp, td);
break;
@@ -731,7 +730,6 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
foffset > OFF_MAX - flp->l_start) ||
(flp->l_start < 0 &&
foffset < OFF_MIN - flp->l_start)) {
- FILEDESC_SUNLOCK(fdp);
error = EOVERFLOW;
fdrop(fp, td);
break;
@@ -857,13 +855,15 @@ do_dup(struct thread *td, int flags, int old, int new)
* the limit on the size of the file descriptor table.
*/
#ifdef RACCT
- PROC_LOCK(p);
- error = racct_set(p, RACCT_NOFILE, new + 1);
- PROC_UNLOCK(p);
- if (error != 0) {
- FILEDESC_XUNLOCK(fdp);
- fdrop(fp, td);
- return (EMFILE);
+ if (racct_enable) {
+ PROC_LOCK(p);
+ error = racct_set(p, RACCT_NOFILE, new + 1);
+ PROC_UNLOCK(p);
+ if (error != 0) {
+ FILEDESC_XUNLOCK(fdp);
+ fdrop(fp, td);
+ return (EMFILE);
+ }
}
#endif
fdgrowtable_exp(fdp, new + 1);
@@ -1631,11 +1631,13 @@ fdalloc(struct thread *td, int minfd, int *result)
if (fd >= fdp->fd_nfiles) {
allocfd = min(fd * 2, maxfd);
#ifdef RACCT
- PROC_LOCK(p);
- error = racct_set(p, RACCT_NOFILE, allocfd);
- PROC_UNLOCK(p);
- if (error != 0)
- return (EMFILE);
+ if (racct_enable) {
+ PROC_LOCK(p);
+ error = racct_set(p, RACCT_NOFILE, allocfd);
+ PROC_UNLOCK(p);
+ if (error != 0)
+ return (EMFILE);
+ }
#endif
/*
* fd is already equal to first free descriptor >= minfd, so
@@ -2042,9 +2044,11 @@ fdescfree(struct thread *td)
MPASS(fdp != NULL);
#ifdef RACCT
- PROC_LOCK(td->td_proc);
- racct_set(td->td_proc, RACCT_NOFILE, 0);
- PROC_UNLOCK(td->td_proc);
+ if (racct_enable) {
+ PROC_LOCK(td->td_proc);
+ racct_set(td->td_proc, RACCT_NOFILE, 0);
+ PROC_UNLOCK(td->td_proc);
+ }
#endif
if (td->td_proc->p_fdtol != NULL)
diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index e01f12c..b6d8a79 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -615,7 +615,7 @@ filt_timerattach(struct knote *kn)
kn->kn_status &= ~KN_DETACHED; /* knlist_add clears it */
kn->kn_ptr.p_nexttime = malloc(sizeof(sbintime_t), M_KQUEUE, M_WAITOK);
calloutp = malloc(sizeof(*calloutp), M_KQUEUE, M_WAITOK);
- callout_init(calloutp, CALLOUT_MPSAFE);
+ callout_init(calloutp, 1);
kn->kn_hook = calloutp;
*kn->kn_ptr.p_nexttime = to + sbinuptime();
callout_reset_sbt_on(calloutp, *kn->kn_ptr.p_nexttime, 0,
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 9d893f8..8668f0d 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -193,21 +193,20 @@ struct execve_args {
#endif
int
-sys_execve(td, uap)
- struct thread *td;
- struct execve_args /* {
- char *fname;
- char **argv;
- char **envv;
- } */ *uap;
+sys_execve(struct thread *td, struct execve_args *uap)
{
- int error;
struct image_args args;
+ struct vmspace *oldvmspace;
+ int error;
+ error = pre_execve(td, &oldvmspace);
+ if (error != 0)
+ return (error);
error = exec_copyin_args(&args, uap->fname, UIO_USERSPACE,
uap->argv, uap->envv);
if (error == 0)
error = kern_execve(td, &args, NULL);
+ post_execve(td, error, oldvmspace);
return (error);
}
@@ -221,15 +220,20 @@ struct fexecve_args {
int
sys_fexecve(struct thread *td, struct fexecve_args *uap)
{
- int error;
struct image_args args;
+ struct vmspace *oldvmspace;
+ int error;
+ error = pre_execve(td, &oldvmspace);
+ if (error != 0)
+ return (error);
error = exec_copyin_args(&args, NULL, UIO_SYSSPACE,
uap->argv, uap->envv);
if (error == 0) {
args.fd = uap->fd;
error = kern_execve(td, &args, NULL);
}
+ post_execve(td, error, oldvmspace);
return (error);
}
@@ -243,65 +247,56 @@ struct __mac_execve_args {
#endif
int
-sys___mac_execve(td, uap)
- struct thread *td;
- struct __mac_execve_args /* {
- char *fname;
- char **argv;
- char **envv;
- struct mac *mac_p;
- } */ *uap;
+sys___mac_execve(struct thread *td, struct __mac_execve_args *uap)
{
#ifdef MAC
- int error;
struct image_args args;
+ struct vmspace *oldvmspace;
+ int error;
+ error = pre_execve(td, &oldvmspace);
+ if (error != 0)
+ return (error);
error = exec_copyin_args(&args, uap->fname, UIO_USERSPACE,
uap->argv, uap->envv);
if (error == 0)
error = kern_execve(td, &args, uap->mac_p);
+ post_execve(td, error, oldvmspace);
return (error);
#else
return (ENOSYS);
#endif
}
-/*
- * XXX: kern_execve has the astonishing property of not always returning to
- * the caller. If sufficiently bad things happen during the call to
- * do_execve(), it can end up calling exit1(); as a result, callers must
- * avoid doing anything which they might need to undo (e.g., allocating
- * memory).
- */
int
-kern_execve(td, args, mac_p)
- struct thread *td;
- struct image_args *args;
- struct mac *mac_p;
+pre_execve(struct thread *td, struct vmspace **oldvmspace)
{
- struct proc *p = td->td_proc;
- struct vmspace *oldvmspace;
+ struct proc *p;
int error;
- AUDIT_ARG_ARGV(args->begin_argv, args->argc,
- args->begin_envv - args->begin_argv);
- AUDIT_ARG_ENVV(args->begin_envv, args->envc,
- args->endp - args->begin_envv);
- if (p->p_flag & P_HADTHREADS) {
+ KASSERT(td == curthread, ("non-current thread %p", td));
+ error = 0;
+ p = td->td_proc;
+ if ((p->p_flag & P_HADTHREADS) != 0) {
PROC_LOCK(p);
- if (thread_single(p, SINGLE_BOUNDARY)) {
- PROC_UNLOCK(p);
- exec_free_args(args);
- return (ERESTART); /* Try again later. */
- }
+ if (thread_single(p, SINGLE_BOUNDARY) != 0)
+ error = ERESTART;
PROC_UNLOCK(p);
}
+ KASSERT(error != 0 || (td->td_pflags & TDP_EXECVMSPC) == 0,
+ ("nested execve"));
+ *oldvmspace = p->p_vmspace;
+ return (error);
+}
- KASSERT((td->td_pflags & TDP_EXECVMSPC) == 0, ("nested execve"));
- oldvmspace = td->td_proc->p_vmspace;
- error = do_execve(td, args, mac_p);
+void
+post_execve(struct thread *td, int error, struct vmspace *oldvmspace)
+{
+ struct proc *p;
- if (p->p_flag & P_HADTHREADS) {
+ KASSERT(td == curthread, ("non-current thread %p", td));
+ p = td->td_proc;
+ if ((p->p_flag & P_HADTHREADS) != 0) {
PROC_LOCK(p);
/*
* If success, we upgrade to SINGLE_EXIT state to
@@ -314,13 +309,29 @@ kern_execve(td, args, mac_p)
PROC_UNLOCK(p);
}
if ((td->td_pflags & TDP_EXECVMSPC) != 0) {
- KASSERT(td->td_proc->p_vmspace != oldvmspace,
+ KASSERT(p->p_vmspace != oldvmspace,
("oldvmspace still used"));
vmspace_free(oldvmspace);
td->td_pflags &= ~TDP_EXECVMSPC;
}
+}
- return (error);
+/*
+ * XXX: kern_execve has the astonishing property of not always returning to
+ * the caller. If sufficiently bad things happen during the call to
+ * do_execve(), it can end up calling exit1(); as a result, callers must
+ * avoid doing anything which they might need to undo (e.g., allocating
+ * memory).
+ */
+int
+kern_execve(struct thread *td, struct image_args *args, struct mac *mac_p)
+{
+
+ AUDIT_ARG_ARGV(args->begin_argv, args->argc,
+ args->begin_envv - args->begin_argv);
+ AUDIT_ARG_ENVV(args->begin_envv, args->envc,
+ args->endp - args->begin_envv);
+ return (do_execve(td, args, mac_p));
}
/*
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 4d23fc0..e760bc8 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -847,13 +847,13 @@ proc_reap(struct thread *td, struct proc *p, int *status, int options)
PROC_LOCK(q);
sigqueue_take(p->p_ksi);
PROC_UNLOCK(q);
- PROC_UNLOCK(p);
/*
* If we got the child via a ptrace 'attach', we need to give it back
* to the old parent.
*/
- if (p->p_oppid != 0) {
+ if (p->p_oppid != 0 && p->p_oppid != p->p_pptr->p_pid) {
+ PROC_UNLOCK(p);
t = proc_realparent(p);
PROC_LOCK(t);
PROC_LOCK(p);
@@ -867,6 +867,8 @@ proc_reap(struct thread *td, struct proc *p, int *status, int options)
sx_xunlock(&proctree_lock);
return;
}
+ p->p_oppid = 0;
+ PROC_UNLOCK(p);
/*
* Remove other references to this process to ensure we have an
@@ -907,9 +909,11 @@ proc_reap(struct thread *td, struct proc *p, int *status, int options)
* Destroy resource accounting information associated with the process.
*/
#ifdef RACCT
- PROC_LOCK(p);
- racct_sub(p, RACCT_NPROC, 1);
- PROC_UNLOCK(p);
+ if (racct_enable) {
+ PROC_LOCK(p);
+ racct_sub(p, RACCT_NPROC, 1);
+ PROC_UNLOCK(p);
+ }
#endif
racct_proc_exit(p);
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index c3dd792..2c7fe2e 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -943,7 +943,8 @@ fail:
#endif
racct_proc_exit(newproc);
fail1:
- crfree(proc_set_cred(newproc, NULL));
+ crfree(newproc->p_ucred);
+ newproc->p_ucred = NULL;
fail2:
if (vm2 != NULL)
vmspace_free(vm2);
diff --git a/sys/kern/kern_intr.c b/sys/kern/kern_intr.c
index 7a5d936..a84019a 100644
--- a/sys/kern/kern_intr.c
+++ b/sys/kern/kern_intr.c
@@ -1455,12 +1455,7 @@ intr_event_handle(struct intr_event *ie, struct trapframe *frame)
/* Schedule the ithread if needed. */
if (thread) {
error = intr_event_schedule_thread(ie);
-#ifndef XEN
KASSERT(error == 0, ("bad stray interrupt"));
-#else
- if (error != 0)
- log(LOG_WARNING, "bad stray interrupt");
-#endif
}
critical_exit();
td->td_intr_nesting_level--;
diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c
index 5b23129..c87c4e2 100644
--- a/sys/kern/kern_jail.c
+++ b/sys/kern/kern_jail.c
@@ -1778,7 +1778,7 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags)
mtx_unlock(&pr->pr_mtx);
#ifdef RACCT
- if (created)
+ if (racct_enable && created)
prison_racct_attach(pr);
#endif
@@ -1862,7 +1862,7 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags)
}
#ifdef RACCT
- if (!created) {
+ if (racct_enable && !created) {
if (!(flags & JAIL_ATTACH))
sx_sunlock(&allprison_lock);
prison_racct_modify(pr);
@@ -2652,7 +2652,8 @@ prison_deref(struct prison *pr, int flags)
cpuset_rel(pr->pr_cpuset);
osd_jail_exit(pr);
#ifdef RACCT
- prison_racct_detach(pr);
+ if (racct_enable)
+ prison_racct_detach(pr);
#endif
free(pr, M_PRISON);
@@ -4460,12 +4461,15 @@ SYSCTL_JAIL_PARAM(_allow_mount, tmpfs, CTLTYPE_INT | CTLFLAG_RW,
SYSCTL_JAIL_PARAM(_allow_mount, zfs, CTLTYPE_INT | CTLFLAG_RW,
"B", "Jail may mount the zfs file system");
+#ifdef RACCT
void
prison_racct_foreach(void (*callback)(struct racct *racct,
void *arg2, void *arg3), void *arg2, void *arg3)
{
struct prison_racct *prr;
+ ASSERT_RACCT_ENABLED();
+
sx_slock(&allprison_lock);
LIST_FOREACH(prr, &allprison_racct, prr_next)
(callback)(prr->prr_racct, arg2, arg3);
@@ -4477,6 +4481,7 @@ prison_racct_find_locked(const char *name)
{
struct prison_racct *prr;
+ ASSERT_RACCT_ENABLED();
sx_assert(&allprison_lock, SA_XLOCKED);
if (name[0] == '\0' || strlen(name) >= MAXHOSTNAMELEN)
@@ -4507,6 +4512,8 @@ prison_racct_find(const char *name)
{
struct prison_racct *prr;
+ ASSERT_RACCT_ENABLED();
+
sx_xlock(&allprison_lock);
prr = prison_racct_find_locked(name);
sx_xunlock(&allprison_lock);
@@ -4517,6 +4524,8 @@ void
prison_racct_hold(struct prison_racct *prr)
{
+ ASSERT_RACCT_ENABLED();
+
refcount_acquire(&prr->prr_refcount);
}
@@ -4524,6 +4533,7 @@ static void
prison_racct_free_locked(struct prison_racct *prr)
{
+ ASSERT_RACCT_ENABLED();
sx_assert(&allprison_lock, SA_XLOCKED);
if (refcount_release(&prr->prr_refcount)) {
@@ -4538,6 +4548,7 @@ prison_racct_free(struct prison_racct *prr)
{
int old;
+ ASSERT_RACCT_ENABLED();
sx_assert(&allprison_lock, SA_UNLOCKED);
old = prr->prr_refcount;
@@ -4549,12 +4560,12 @@ prison_racct_free(struct prison_racct *prr)
sx_xunlock(&allprison_lock);
}
-#ifdef RACCT
static void
prison_racct_attach(struct prison *pr)
{
struct prison_racct *prr;
+ ASSERT_RACCT_ENABLED();
sx_assert(&allprison_lock, SA_XLOCKED);
prr = prison_racct_find_locked(pr->pr_name);
@@ -4574,6 +4585,8 @@ prison_racct_modify(struct prison *pr)
struct ucred *cred;
struct prison_racct *oldprr;
+ ASSERT_RACCT_ENABLED();
+
sx_slock(&allproc_lock);
sx_xlock(&allprison_lock);
@@ -4613,6 +4626,7 @@ static void
prison_racct_detach(struct prison *pr)
{
+ ASSERT_RACCT_ENABLED();
sx_assert(&allprison_lock, SA_UNLOCKED);
if (pr->pr_prison_racct == NULL)
diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c
index 2a40593..32ded48 100644
--- a/sys/kern/kern_ktr.c
+++ b/sys/kern/kern_ktr.c
@@ -96,8 +96,8 @@ static MALLOC_DEFINE(M_KTR, "KTR", "KTR");
FEATURE(ktr, "Kernel support for KTR kernel tracing facility");
volatile int ktr_idx = 0;
-int ktr_mask = KTR_MASK;
-int ktr_compile = KTR_COMPILE;
+uint64_t ktr_mask = KTR_MASK;
+uint64_t ktr_compile = KTR_COMPILE;
int ktr_entries = KTR_BOOT_ENTRIES;
int ktr_version = KTR_VERSION;
struct ktr_entry ktr_buf_init[KTR_BOOT_ENTRIES];
@@ -109,7 +109,7 @@ static SYSCTL_NODE(_debug, OID_AUTO, ktr, CTLFLAG_RD, 0, "KTR options");
SYSCTL_INT(_debug_ktr, OID_AUTO, version, CTLFLAG_RD,
&ktr_version, 0, "Version of the KTR interface");
-SYSCTL_UINT(_debug_ktr, OID_AUTO, compile, CTLFLAG_RD,
+SYSCTL_UQUAD(_debug_ktr, OID_AUTO, compile, CTLFLAG_RD,
&ktr_compile, 0, "Bitmask of KTR event classes compiled into the kernel");
static int
@@ -162,18 +162,19 @@ SYSCTL_PROC(_debug_ktr, OID_AUTO, clear, CTLTYPE_INT|CTLFLAG_RW, 0, 0,
static int
sysctl_debug_ktr_mask(SYSCTL_HANDLER_ARGS)
{
- int mask, error;
+ uint64_t mask;
+ int error;
mask = ktr_mask;
- error = sysctl_handle_int(oidp, &mask, 0, req);
+ error = sysctl_handle_64(oidp, &mask, 0, req);
if (error || !req->newptr)
return (error);
ktr_mask = mask;
return (error);
}
-SYSCTL_PROC(_debug_ktr, OID_AUTO, mask, CTLTYPE_UINT|CTLFLAG_RWTUN, 0, 0,
- sysctl_debug_ktr_mask, "IU",
+SYSCTL_PROC(_debug_ktr, OID_AUTO, mask, CTLTYPE_U64 | CTLFLAG_RWTUN, 0, 0,
+ sysctl_debug_ktr_mask, "QU",
"Bitmask of KTR event classes for which logging is enabled");
#if KTR_ENTRIES > KTR_BOOT_ENTRIES
@@ -184,7 +185,7 @@ SYSCTL_PROC(_debug_ktr, OID_AUTO, mask, CTLTYPE_UINT|CTLFLAG_RWTUN, 0, 0,
static void
ktr_entries_initializer(void *dummy __unused)
{
- int mask;
+ uint64_t mask;
/* Temporarily disable ktr in case malloc() is being traced. */
mask = ktr_mask;
@@ -208,7 +209,8 @@ SYSINIT(ktr_entries_initializer, SI_SUB_KMEM, SI_ORDER_ANY,
static int
sysctl_debug_ktr_entries(SYSCTL_HANDLER_ARGS)
{
- int entries, error, mask;
+ uint64_t mask;
+ int entries, error;
struct ktr_entry *buf, *oldbuf;
entries = ktr_entries;
@@ -219,7 +221,7 @@ sysctl_debug_ktr_entries(SYSCTL_HANDLER_ARGS)
return (ERANGE);
/* Disable ktr temporarily. */
mask = ktr_mask;
- atomic_store_rel_int(&ktr_mask, 0);
+ ktr_mask = 0;
/* Wait for threads to go idle. */
if ((error = quiesce_all_cpus("ktrent", PCATCH)) != 0) {
ktr_mask = mask;
@@ -235,7 +237,7 @@ sysctl_debug_ktr_entries(SYSCTL_HANDLER_ARGS)
ktr_buf = buf;
ktr_entries = entries;
ktr_idx = 0;
- atomic_store_rel_int(&ktr_mask, mask);
+ ktr_mask = mask;
if (oldbuf != NULL)
free(oldbuf, M_KTR);
@@ -310,7 +312,7 @@ SYSCTL_PROC(_debug_ktr, OID_AUTO, alq_enable,
#endif
void
-ktr_tracepoint(u_int mask, const char *file, int line, const char *format,
+ktr_tracepoint(uint64_t mask, const char *file, int line, const char *format,
u_long arg1, u_long arg2, u_long arg3, u_long arg4, u_long arg5,
u_long arg6)
{
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index aef1e4e..ff5b106 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -665,13 +665,15 @@ reallocf(void *addr, unsigned long size, struct malloc_type *mtp, int flags)
}
/*
- * Wake the page daemon when we exhaust KVA. It will call the lowmem handler
- * and uma_reclaim() callbacks in a context that is safe.
+ * Wake the uma reclamation pagedaemon thread when we exhaust KVA. It
+ * will call the lowmem handler and uma_reclaim() callbacks in a
+ * context that is safe.
*/
static void
kmem_reclaim(vmem_t *vm, int flags)
{
+ uma_reclaim_wakeup();
pagedaemon_wakeup();
}
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index 505521d..6618c08 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -2822,7 +2822,7 @@ static SYSCTL_NODE(_kern_proc, KERN_PROC_PROC, proc, CTLFLAG_RD | CTLFLAG_MPSAFE
sysctl_kern_proc, "Return process table, no threads");
static SYSCTL_NODE(_kern_proc, KERN_PROC_ARGS, args,
- CTLFLAG_RW | CTLFLAG_ANYBODY | CTLFLAG_MPSAFE,
+ CTLFLAG_RW | CTLFLAG_CAPWR | CTLFLAG_ANYBODY | CTLFLAG_MPSAFE,
sysctl_kern_proc_args, "Process argument list");
static SYSCTL_NODE(_kern_proc, KERN_PROC_ENV, env, CTLFLAG_RD | CTLFLAG_MPSAFE,
diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c
index 05becea..e8ae9fe 100644
--- a/sys/kern/kern_racct.c
+++ b/sys/kern/kern_racct.c
@@ -70,8 +70,15 @@ FEATURE(racct, "Resource Accounting");
* Do not block processes that have their %cpu usage <= pcpu_threshold.
*/
static int pcpu_threshold = 1;
+#ifdef RACCT_DEFAULT_TO_DISABLED
+int racct_enable = 0;
+#else
+int racct_enable = 1;
+#endif
SYSCTL_NODE(_kern, OID_AUTO, racct, CTLFLAG_RW, 0, "Resource Accounting");
+SYSCTL_UINT(_kern_racct, OID_AUTO, enable, CTLFLAG_RDTUN, &racct_enable,
+ 0, "Enable RACCT/RCTL");
SYSCTL_UINT(_kern_racct, OID_AUTO, pcpu_threshold, CTLFLAG_RW, &pcpu_threshold,
0, "Processes with higher %cpu usage than this value can be throttled.");
@@ -313,6 +320,8 @@ racct_getpcpu(struct proc *p, u_int pcpu)
fixpt_t p_pctcpu;
struct thread *td;
+ ASSERT_RACCT_ENABLED();
+
/*
* If the process is swapped out, we count its %cpu usage as zero.
* This behaviour is consistent with the userland ps(1) tool.
@@ -377,6 +386,7 @@ racct_add_racct(struct racct *dest, const struct racct *src)
{
int i;
+ ASSERT_RACCT_ENABLED();
mtx_assert(&racct_lock, MA_OWNED);
/*
@@ -398,6 +408,7 @@ racct_sub_racct(struct racct *dest, const struct racct *src)
{
int i;
+ ASSERT_RACCT_ENABLED();
mtx_assert(&racct_lock, MA_OWNED);
/*
@@ -431,6 +442,9 @@ void
racct_create(struct racct **racctp)
{
+ if (!racct_enable)
+ return;
+
SDT_PROBE(racct, kernel, racct, create, racctp, 0, 0, 0, 0);
KASSERT(*racctp == NULL, ("racct already allocated"));
@@ -444,6 +458,8 @@ racct_destroy_locked(struct racct **racctp)
int i;
struct racct *racct;
+ ASSERT_RACCT_ENABLED();
+
SDT_PROBE(racct, kernel, racct, destroy, racctp, 0, 0, 0, 0);
mtx_assert(&racct_lock, MA_OWNED);
@@ -470,6 +486,9 @@ void
racct_destroy(struct racct **racct)
{
+ if (!racct_enable)
+ return;
+
mtx_lock(&racct_lock);
racct_destroy_locked(racct);
mtx_unlock(&racct_lock);
@@ -485,6 +504,7 @@ racct_alloc_resource(struct racct *racct, int resource,
uint64_t amount)
{
+ ASSERT_RACCT_ENABLED();
mtx_assert(&racct_lock, MA_OWNED);
KASSERT(racct != NULL, ("NULL racct"));
@@ -516,6 +536,8 @@ racct_add_locked(struct proc *p, int resource, uint64_t amount)
int error;
#endif
+ ASSERT_RACCT_ENABLED();
+
SDT_PROBE(racct, kernel, rusage, add, p, resource, amount, 0, 0);
/*
@@ -546,6 +568,9 @@ racct_add(struct proc *p, int resource, uint64_t amount)
{
int error;
+ if (!racct_enable)
+ return (0);
+
mtx_lock(&racct_lock);
error = racct_add_locked(p, resource, amount);
mtx_unlock(&racct_lock);
@@ -557,6 +582,8 @@ racct_add_cred_locked(struct ucred *cred, int resource, uint64_t amount)
{
struct prison *pr;
+ ASSERT_RACCT_ENABLED();
+
SDT_PROBE(racct, kernel, rusage, add__cred, cred, resource, amount,
0, 0);
@@ -577,6 +604,9 @@ void
racct_add_cred(struct ucred *cred, int resource, uint64_t amount)
{
+ if (!racct_enable)
+ return;
+
mtx_lock(&racct_lock);
racct_add_cred_locked(cred, resource, amount);
mtx_unlock(&racct_lock);
@@ -590,6 +620,9 @@ void
racct_add_force(struct proc *p, int resource, uint64_t amount)
{
+ if (!racct_enable)
+ return;
+
SDT_PROBE(racct, kernel, rusage, add__force, p, resource, amount, 0, 0);
/*
@@ -612,6 +645,8 @@ racct_set_locked(struct proc *p, int resource, uint64_t amount)
int error;
#endif
+ ASSERT_RACCT_ENABLED();
+
SDT_PROBE(racct, kernel, rusage, set, p, resource, amount, 0, 0);
/*
@@ -671,6 +706,9 @@ racct_set(struct proc *p, int resource, uint64_t amount)
{
int error;
+ if (!racct_enable)
+ return (0);
+
mtx_lock(&racct_lock);
error = racct_set_locked(p, resource, amount);
mtx_unlock(&racct_lock);
@@ -683,6 +721,8 @@ racct_set_force_locked(struct proc *p, int resource, uint64_t amount)
int64_t old_amount, decayed_amount;
int64_t diff_proc, diff_cred;
+ ASSERT_RACCT_ENABLED();
+
SDT_PROBE(racct, kernel, rusage, set, p, resource, amount, 0, 0);
/*
@@ -717,6 +757,10 @@ racct_set_force_locked(struct proc *p, int resource, uint64_t amount)
void
racct_set_force(struct proc *p, int resource, uint64_t amount)
{
+
+ if (!racct_enable)
+ return;
+
mtx_lock(&racct_lock);
racct_set_force_locked(p, resource, amount);
mtx_unlock(&racct_lock);
@@ -732,6 +776,9 @@ uint64_t
racct_get_limit(struct proc *p, int resource)
{
+ if (!racct_enable)
+ return (UINT64_MAX);
+
#ifdef RCTL
return (rctl_get_limit(p, resource));
#else
@@ -749,6 +796,9 @@ uint64_t
racct_get_available(struct proc *p, int resource)
{
+ if (!racct_enable)
+ return (UINT64_MAX);
+
#ifdef RCTL
return (rctl_get_available(p, resource));
#else
@@ -765,6 +815,8 @@ static int64_t
racct_pcpu_available(struct proc *p)
{
+ ASSERT_RACCT_ENABLED();
+
#ifdef RCTL
return (rctl_pcpu_available(p));
#else
@@ -779,6 +831,9 @@ void
racct_sub(struct proc *p, int resource, uint64_t amount)
{
+ if (!racct_enable)
+ return;
+
SDT_PROBE(racct, kernel, rusage, sub, p, resource, amount, 0, 0);
/*
@@ -804,6 +859,8 @@ racct_sub_cred_locked(struct ucred *cred, int resource, uint64_t amount)
{
struct prison *pr;
+ ASSERT_RACCT_ENABLED();
+
SDT_PROBE(racct, kernel, rusage, sub__cred, cred, resource, amount,
0, 0);
@@ -827,6 +884,9 @@ void
racct_sub_cred(struct ucred *cred, int resource, uint64_t amount)
{
+ if (!racct_enable)
+ return;
+
mtx_lock(&racct_lock);
racct_sub_cred_locked(cred, resource, amount);
mtx_unlock(&racct_lock);
@@ -840,6 +900,9 @@ racct_proc_fork(struct proc *parent, struct proc *child)
{
int i, error = 0;
+ if (!racct_enable)
+ return (0);
+
/*
* Create racct for the child process.
*/
@@ -896,6 +959,9 @@ racct_proc_fork_done(struct proc *child)
{
#ifdef RCTL
+ if (!racct_enable)
+ return;
+
PROC_LOCK(child);
mtx_lock(&racct_lock);
rctl_enforce(child, RACCT_NPROC, 0);
@@ -913,6 +979,9 @@ racct_proc_exit(struct proc *p)
struct timeval wallclock;
uint64_t pct_estimate, pct;
+ if (!racct_enable)
+ return;
+
PROC_LOCK(p);
/*
* We don't need to calculate rux, proc_reap() has already done this.
@@ -967,6 +1036,9 @@ racct_proc_ucred_changed(struct proc *p, struct ucred *oldcred,
struct loginclass *oldlc, *newlc;
struct prison *oldpr, *newpr, *pr;
+ if (!racct_enable)
+ return;
+
PROC_LOCK_ASSERT(p, MA_NOTOWNED);
newuip = newcred->cr_ruidinfo;
@@ -1004,6 +1076,8 @@ void
racct_move(struct racct *dest, struct racct *src)
{
+ ASSERT_RACCT_ENABLED();
+
mtx_lock(&racct_lock);
racct_add_racct(dest, src);
@@ -1020,6 +1094,7 @@ racct_proc_throttle(struct proc *p)
int cpuid;
#endif
+ ASSERT_RACCT_ENABLED();
PROC_LOCK_ASSERT(p, MA_OWNED);
/*
@@ -1065,6 +1140,9 @@ racct_proc_throttle(struct proc *p)
static void
racct_proc_wakeup(struct proc *p)
{
+
+ ASSERT_RACCT_ENABLED();
+
PROC_LOCK_ASSERT(p, MA_OWNED);
if (p->p_throttled) {
@@ -1079,6 +1157,8 @@ racct_decay_resource(struct racct *racct, void * res, void* dummy)
int resource;
int64_t r_old, r_new;
+ ASSERT_RACCT_ENABLED();
+
resource = *(int *)res;
r_old = racct->r_resources[resource];
@@ -1095,6 +1175,9 @@ racct_decay_resource(struct racct *racct, void * res, void* dummy)
static void
racct_decay(int resource)
{
+
+ ASSERT_RACCT_ENABLED();
+
ui_racct_foreach(racct_decay_resource, &resource, NULL);
loginclass_racct_foreach(racct_decay_resource, &resource, NULL);
prison_racct_foreach(racct_decay_resource, &resource, NULL);
@@ -1109,6 +1192,8 @@ racctd(void)
uint64_t runtime;
uint64_t pct, pct_estimate;
+ ASSERT_RACCT_ENABLED();
+
for (;;) {
racct_decay(RACCT_PCTCPU);
@@ -1188,11 +1273,22 @@ static struct kproc_desc racctd_kp = {
racctd,
NULL
};
-SYSINIT(racctd, SI_SUB_RACCTD, SI_ORDER_FIRST, kproc_start, &racctd_kp);
+
+static void
+racctd_init(void)
+{
+ if (!racct_enable)
+ return;
+
+ kproc_start(&racctd_kp);
+}
+SYSINIT(racctd, SI_SUB_RACCTD, SI_ORDER_FIRST, racctd_init, NULL);
static void
racct_init(void)
{
+ if (!racct_enable)
+ return;
racct_zone = uma_zcreate("racct", sizeof(struct racct),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
diff --git a/sys/kern/kern_rctl.c b/sys/kern/kern_rctl.c
index 934327a..c43b83d 100644
--- a/sys/kern/kern_rctl.c
+++ b/sys/kern/kern_rctl.c
@@ -225,6 +225,7 @@ rctl_available_resource(const struct proc *p, const struct rctl_rule *rule)
int64_t available = INT64_MAX;
struct ucred *cred = p->p_ucred;
+ ASSERT_RACCT_ENABLED();
rw_assert(&rctl_lock, RA_LOCKED);
resource = rule->rr_resource;
@@ -264,6 +265,8 @@ rctl_would_exceed(const struct proc *p, const struct rctl_rule *rule,
{
int64_t available;
+ ASSERT_RACCT_ENABLED();
+
rw_assert(&rctl_lock, RA_LOCKED);
available = rctl_available_resource(p, rule);
@@ -283,6 +286,8 @@ rctl_pcpu_available(const struct proc *p) {
struct rctl_rule_link *link;
int64_t available, minavailable, limit;
+ ASSERT_RACCT_ENABLED();
+
minavailable = INT64_MAX;
limit = 0;
@@ -334,6 +339,8 @@ rctl_enforce(struct proc *p, int resource, uint64_t amount)
static int curtime = 0;
static struct timeval lasttime;
+ ASSERT_RACCT_ENABLED();
+
rw_rlock(&rctl_lock);
/*
@@ -457,6 +464,8 @@ rctl_get_limit(struct proc *p, int resource)
struct rctl_rule_link *link;
uint64_t amount = UINT64_MAX;
+ ASSERT_RACCT_ENABLED();
+
rw_rlock(&rctl_lock);
/*
@@ -487,6 +496,8 @@ rctl_get_available(struct proc *p, int resource)
minavailable = INT64_MAX;
+ ASSERT_RACCT_ENABLED();
+
rw_rlock(&rctl_lock);
/*
@@ -521,6 +532,8 @@ static int
rctl_rule_matches(const struct rctl_rule *rule, const struct rctl_rule *filter)
{
+ ASSERT_RACCT_ENABLED();
+
if (filter->rr_subject_type != RCTL_SUBJECT_TYPE_UNDEFINED) {
if (rule->rr_subject_type != filter->rr_subject_type)
return (0);
@@ -635,6 +648,7 @@ rctl_racct_add_rule(struct racct *racct, struct rctl_rule *rule)
{
struct rctl_rule_link *link;
+ ASSERT_RACCT_ENABLED();
KASSERT(rctl_rule_fully_specified(rule), ("rule not fully specified"));
rctl_rule_acquire(rule);
@@ -652,6 +666,7 @@ rctl_racct_add_rule_locked(struct racct *racct, struct rctl_rule *rule)
{
struct rctl_rule_link *link;
+ ASSERT_RACCT_ENABLED();
KASSERT(rctl_rule_fully_specified(rule), ("rule not fully specified"));
rw_assert(&rctl_lock, RA_WLOCKED);
@@ -678,6 +693,7 @@ rctl_racct_remove_rules(struct racct *racct,
int removed = 0;
struct rctl_rule_link *link, *linktmp;
+ ASSERT_RACCT_ENABLED();
rw_assert(&rctl_lock, RA_WLOCKED);
LIST_FOREACH_SAFE(link, &racct->r_rule_links, rrl_next, linktmp) {
@@ -696,6 +712,8 @@ static void
rctl_rule_acquire_subject(struct rctl_rule *rule)
{
+ ASSERT_RACCT_ENABLED();
+
switch (rule->rr_subject_type) {
case RCTL_SUBJECT_TYPE_UNDEFINED:
case RCTL_SUBJECT_TYPE_PROCESS:
@@ -722,6 +740,8 @@ static void
rctl_rule_release_subject(struct rctl_rule *rule)
{
+ ASSERT_RACCT_ENABLED();
+
switch (rule->rr_subject_type) {
case RCTL_SUBJECT_TYPE_UNDEFINED:
case RCTL_SUBJECT_TYPE_PROCESS:
@@ -749,6 +769,8 @@ rctl_rule_alloc(int flags)
{
struct rctl_rule *rule;
+ ASSERT_RACCT_ENABLED();
+
rule = uma_zalloc(rctl_rule_zone, flags);
if (rule == NULL)
return (NULL);
@@ -771,6 +793,8 @@ rctl_rule_duplicate(const struct rctl_rule *rule, int flags)
{
struct rctl_rule *copy;
+ ASSERT_RACCT_ENABLED();
+
copy = uma_zalloc(rctl_rule_zone, flags);
if (copy == NULL)
return (NULL);
@@ -793,6 +817,7 @@ void
rctl_rule_acquire(struct rctl_rule *rule)
{
+ ASSERT_RACCT_ENABLED();
KASSERT(rule->rr_refcount > 0, ("rule->rr_refcount <= 0"));
refcount_acquire(&rule->rr_refcount);
@@ -805,6 +830,7 @@ rctl_rule_free(void *context, int pending)
rule = (struct rctl_rule *)context;
+ ASSERT_RACCT_ENABLED();
KASSERT(rule->rr_refcount == 0, ("rule->rr_refcount != 0"));
/*
@@ -819,6 +845,7 @@ void
rctl_rule_release(struct rctl_rule *rule)
{
+ ASSERT_RACCT_ENABLED();
KASSERT(rule->rr_refcount > 0, ("rule->rr_refcount <= 0"));
if (refcount_release(&rule->rr_refcount)) {
@@ -838,6 +865,8 @@ static int
rctl_rule_fully_specified(const struct rctl_rule *rule)
{
+ ASSERT_RACCT_ENABLED();
+
switch (rule->rr_subject_type) {
case RCTL_SUBJECT_TYPE_UNDEFINED:
return (0);
@@ -882,6 +911,8 @@ rctl_string_to_rule(char *rulestr, struct rctl_rule **rulep)
struct rctl_rule *rule;
id_t id;
+ ASSERT_RACCT_ENABLED();
+
rule = rctl_rule_alloc(M_WAITOK);
subjectstr = strsep(&rulestr, ":");
@@ -1008,6 +1039,7 @@ rctl_rule_add(struct rctl_rule *rule)
struct rctl_rule *rule2;
int match;
+ ASSERT_RACCT_ENABLED();
KASSERT(rctl_rule_fully_specified(rule), ("rule not fully specified"));
/*
@@ -1118,6 +1150,8 @@ rctl_rule_remove_callback(struct racct *racct, void *arg2, void *arg3)
struct rctl_rule *filter = (struct rctl_rule *)arg2;
int found = 0;
+ ASSERT_RACCT_ENABLED();
+
rw_wlock(&rctl_lock);
found += rctl_racct_remove_rules(racct, filter);
rw_wunlock(&rctl_lock);
@@ -1134,6 +1168,8 @@ rctl_rule_remove(struct rctl_rule *filter)
int found = 0;
struct proc *p;
+ ASSERT_RACCT_ENABLED();
+
if (filter->rr_subject_type == RCTL_SUBJECT_TYPE_PROCESS &&
filter->rr_subject.rs_proc != NULL) {
p = filter->rr_subject.rs_proc;
@@ -1172,6 +1208,8 @@ rctl_rule_to_sbuf(struct sbuf *sb, const struct rctl_rule *rule)
{
int64_t amount;
+ ASSERT_RACCT_ENABLED();
+
sbuf_printf(sb, "%s:", rctl_subject_type_name(rule->rr_subject_type));
switch (rule->rr_subject_type) {
@@ -1231,6 +1269,8 @@ rctl_read_inbuf(char **inputstr, const char *inbufp, size_t inbuflen)
int error;
char *str;
+ ASSERT_RACCT_ENABLED();
+
if (inbuflen <= 0)
return (EINVAL);
if (inbuflen > RCTL_MAX_INBUFLEN)
@@ -1256,6 +1296,8 @@ rctl_write_outbuf(struct sbuf *outputsbuf, char *outbufp, size_t outbuflen)
{
int error;
+ ASSERT_RACCT_ENABLED();
+
if (outputsbuf == NULL)
return (0);
@@ -1277,6 +1319,8 @@ rctl_racct_to_sbuf(struct racct *racct, int sloppy)
int64_t amount;
struct sbuf *sb;
+ ASSERT_RACCT_ENABLED();
+
sb = sbuf_new_auto();
for (i = 0; i <= RACCT_MAX; i++) {
if (sloppy == 0 && RACCT_IS_SLOPPY(i))
@@ -1302,6 +1346,9 @@ sys_rctl_get_racct(struct thread *td, struct rctl_get_racct_args *uap)
struct loginclass *lc;
struct prison_racct *prr;
+ if (!racct_enable)
+ return (ENOSYS);
+
error = priv_check(td, PRIV_RCTL_GET_RACCT);
if (error != 0)
return (error);
@@ -1372,6 +1419,8 @@ rctl_get_rules_callback(struct racct *racct, void *arg2, void *arg3)
struct rctl_rule_link *link;
struct sbuf *sb = (struct sbuf *)arg3;
+ ASSERT_RACCT_ENABLED();
+
rw_rlock(&rctl_lock);
LIST_FOREACH(link, &racct->r_rule_links, rrl_next) {
if (!rctl_rule_matches(link->rrl_rule, filter))
@@ -1393,6 +1442,9 @@ sys_rctl_get_rules(struct thread *td, struct rctl_get_rules_args *uap)
struct rctl_rule_link *link;
struct proc *p;
+ if (!racct_enable)
+ return (ENOSYS);
+
error = priv_check(td, PRIV_RCTL_GET_RULES);
if (error != 0)
return (error);
@@ -1467,6 +1519,9 @@ sys_rctl_get_limits(struct thread *td, struct rctl_get_limits_args *uap)
struct rctl_rule *filter;
struct rctl_rule_link *link;
+ if (!racct_enable)
+ return (ENOSYS);
+
error = priv_check(td, PRIV_RCTL_GET_LIMITS);
if (error != 0)
return (error);
@@ -1538,6 +1593,9 @@ sys_rctl_add_rule(struct thread *td, struct rctl_add_rule_args *uap)
struct rctl_rule *rule;
char *inputstr;
+ if (!racct_enable)
+ return (ENOSYS);
+
error = priv_check(td, PRIV_RCTL_ADD_RULE);
if (error != 0)
return (error);
@@ -1580,6 +1638,9 @@ sys_rctl_remove_rule(struct thread *td, struct rctl_remove_rule_args *uap)
struct rctl_rule *filter;
char *inputstr;
+ if (!racct_enable)
+ return (ENOSYS);
+
error = priv_check(td, PRIV_RCTL_REMOVE_RULE);
if (error != 0)
return (error);
@@ -1616,6 +1677,8 @@ rctl_proc_ucred_changed(struct proc *p, struct ucred *newcred)
struct prison_racct *newprr;
LIST_HEAD(, rctl_rule_link) newrules;
+ ASSERT_RACCT_ENABLED();
+
newuip = newcred->cr_ruidinfo;
newlc = newcred->cr_loginclass;
newprr = newcred->cr_prison->pr_prison_racct;
@@ -1756,6 +1819,7 @@ rctl_proc_fork(struct proc *parent, struct proc *child)
LIST_INIT(&child->p_racct->r_rule_links);
+ ASSERT_RACCT_ENABLED();
KASSERT(parent->p_racct != NULL, ("process without racct; p = %p", parent));
rw_wlock(&rctl_lock);
@@ -1809,6 +1873,8 @@ rctl_racct_release(struct racct *racct)
{
struct rctl_rule_link *link;
+ ASSERT_RACCT_ENABLED();
+
rw_wlock(&rctl_lock);
while (!LIST_EMPTY(&racct->r_rule_links)) {
link = LIST_FIRST(&racct->r_rule_links);
@@ -1823,6 +1889,9 @@ static void
rctl_init(void)
{
+ if (!racct_enable)
+ return;
+
rctl_rule_link_zone = uma_zcreate("rctl_rule_link",
sizeof(struct rctl_rule_link), NULL, NULL, NULL, NULL,
UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index 998ee15..4d57fd3 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -700,10 +700,8 @@ vpanic(const char *fmt, va_list ap)
}
/*
- * We set stop_scheduler here and not in the block above,
- * because we want to ensure that if panic has been called and
- * stop_scheduler_on_panic is true, then stop_scheduler will
- * always be set. Even if panic has been entered from kdb.
+ * Ensure that the scheduler is stopped while panicking, even if panic
+ * has been entered from kdb.
*/
td->td_stopsched = 1;
#endif
@@ -875,16 +873,16 @@ mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver,
{
bzero(kdh, sizeof(*kdh));
- strncpy(kdh->magic, magic, sizeof(kdh->magic));
- strncpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture));
+ strlcpy(kdh->magic, magic, sizeof(kdh->magic));
+ strlcpy(kdh->architecture, MACHINE_ARCH, sizeof(kdh->architecture));
kdh->version = htod32(KERNELDUMPVERSION);
kdh->architectureversion = htod32(archver);
kdh->dumplength = htod64(dumplen);
kdh->dumptime = htod64(time_second);
kdh->blocksize = htod32(blksz);
- strncpy(kdh->hostname, prison0.pr_hostname, sizeof(kdh->hostname));
- strncpy(kdh->versionstring, version, sizeof(kdh->versionstring));
+ strlcpy(kdh->hostname, prison0.pr_hostname, sizeof(kdh->hostname));
+ strlcpy(kdh->versionstring, version, sizeof(kdh->versionstring));
if (panicstr != NULL)
- strncpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
+ strlcpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring));
kdh->parity = kerneldump_parity(kdh);
}
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index ad10dc7..e0ee2dc 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -66,12 +66,6 @@ __FBSDID("$FreeBSD$");
#include <machine/cpu.h>
-#ifdef XEN
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#endif
-
#define KTDSTATE(td) \
(((td)->td_inhibitors & TDI_SLEEPING) != 0 ? "sleep" : \
((td)->td_inhibitors & TDI_SUSPENDED) != 0 ? "suspended" : \
@@ -475,9 +469,6 @@ mi_switch(int flags, struct thread *newtd)
"lockname:\"%s\"", td->td_lockname);
#endif
SDT_PROBE0(sched, , , preempt);
-#ifdef XEN
- PT_UPDATES_FLUSH();
-#endif
sched_switch(td, newtd, flags);
KTR_STATE1(KTR_SCHED, "thread", sched_tdname(td), "running",
"prio:%d", td->td_priority);
@@ -565,7 +556,7 @@ loadav(void *arg)
static void
synch_setup(void *dummy)
{
- callout_init(&loadav_callout, CALLOUT_MPSAFE);
+ callout_init(&loadav_callout, 1);
/* Kick off timeout driven events by calling first time. */
loadav(NULL);
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index 6264c64..9dca0e8 100644
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -1468,6 +1468,17 @@ SYSCTL_PROC(_kern_timecounter, OID_AUTO, choice, CTLTYPE_STRING | CTLFLAG_RD,
* RFC 2783 PPS-API implementation.
*/
+/*
+ * Return true if the driver is aware of the abi version extensions in the
+ * pps_state structure, and it supports at least the given abi version number.
+ */
+static inline int
+abi_aware(struct pps_state *pps, int vers)
+{
+
+ return ((pps->kcmode & KCMODE_ABIFLAG) && pps->driver_abi >= vers);
+}
+
static int
pps_fetch(struct pps_fetch_args *fapi, struct pps_state *pps)
{
@@ -1497,10 +1508,17 @@ pps_fetch(struct pps_fetch_args *fapi, struct pps_state *pps)
cseq = pps->ppsinfo.clear_sequence;
while (aseq == pps->ppsinfo.assert_sequence &&
cseq == pps->ppsinfo.clear_sequence) {
- if (pps->mtx != NULL)
- err = msleep(pps, pps->mtx, PCATCH, "ppsfch", timo);
- else
+ if (abi_aware(pps, 1) && pps->driver_mtx != NULL) {
+ if (pps->flags & PPSFLAG_MTX_SPIN) {
+ err = msleep_spin(pps, pps->driver_mtx,
+ "ppsfch", timo);
+ } else {
+ err = msleep(pps, pps->driver_mtx, PCATCH,
+ "ppsfch", timo);
+ }
+ } else {
err = tsleep(pps, PCATCH, "ppsfch", timo);
+ }
if (err == EWOULDBLOCK && fapi->timeout.tv_sec == -1) {
continue;
} else if (err != 0) {
@@ -1590,7 +1608,8 @@ pps_ioctl(u_long cmd, caddr_t data, struct pps_state *pps)
return (EINVAL);
if (kapi->edge & ~pps->ppscap)
return (EINVAL);
- pps->kcmode = kapi->edge;
+ pps->kcmode = (kapi->edge & KCMODE_EDGEMASK) |
+ (pps->kcmode & KCMODE_ABIFLAG);
return (0);
#else
return (EOPNOTSUPP);
@@ -1611,6 +1630,18 @@ pps_init(struct pps_state *pps)
#ifdef FFCLOCK
pps->ppscap |= PPS_TSCLK_MASK;
#endif
+ pps->kcmode &= ~KCMODE_ABIFLAG;
+}
+
+void
+pps_init_abi(struct pps_state *pps)
+{
+
+ pps_init(pps);
+ if (pps->driver_abi > 0) {
+ pps->kcmode |= KCMODE_ABIFLAG;
+ pps->kernel_abi = PPS_ABI_VERSION;
+ }
}
void
diff --git a/sys/kern/kern_thr.c b/sys/kern/kern_thr.c
index d5f1ce6..6911bb97 100644
--- a/sys/kern/kern_thr.c
+++ b/sys/kern/kern_thr.c
@@ -187,11 +187,13 @@ create_thread(struct thread *td, mcontext_t *ctx,
}
#ifdef RACCT
- PROC_LOCK(p);
- error = racct_add(p, RACCT_NTHR, 1);
- PROC_UNLOCK(p);
- if (error != 0)
- return (EPROCLIM);
+ if (racct_enable) {
+ PROC_LOCK(p);
+ error = racct_add(p, RACCT_NTHR, 1);
+ PROC_UNLOCK(p);
+ if (error != 0)
+ return (EPROCLIM);
+ }
#endif
/* Initialize our td */
@@ -280,9 +282,11 @@ create_thread(struct thread *td, mcontext_t *ctx,
fail:
#ifdef RACCT
- PROC_LOCK(p);
- racct_sub(p, RACCT_NTHR, 1);
- PROC_UNLOCK(p);
+ if (racct_enable) {
+ PROC_LOCK(p);
+ racct_sub(p, RACCT_NTHR, 1);
+ PROC_UNLOCK(p);
+ }
#endif
return (error);
}
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index 0a93dbd..0dd5f46 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -74,6 +74,8 @@ static struct mtx zombie_lock;
MTX_SYSINIT(zombie_lock, &zombie_lock, "zombie lock", MTX_SPIN);
static void thread_zombie(struct thread *);
+static int thread_unsuspend_one(struct thread *td, struct proc *p,
+ bool boundary);
#define TID_BUFFER_SIZE 1024
@@ -445,7 +447,7 @@ thread_exit(void)
if (p->p_numthreads == p->p_suspcount) {
thread_lock(p->p_singlethread);
wakeup_swapper = thread_unsuspend_one(
- p->p_singlethread, p);
+ p->p_singlethread, p, false);
thread_unlock(p->p_singlethread);
if (wakeup_swapper)
kick_proc0();
@@ -544,7 +546,7 @@ thread_link(struct thread *td, struct proc *p)
LIST_INIT(&td->td_lprof[0]);
LIST_INIT(&td->td_lprof[1]);
sigqueue_init(&td->td_sigqueue, p);
- callout_init(&td->td_slpcallout, CALLOUT_MPSAFE);
+ callout_init(&td->td_slpcallout, 1);
TAILQ_INSERT_TAIL(&p->p_threads, td, td_plist);
p->p_numthreads++;
}
@@ -603,19 +605,19 @@ weed_inhib(int mode, struct thread *td2, struct proc *p)
switch (mode) {
case SINGLE_EXIT:
if (TD_IS_SUSPENDED(td2))
- wakeup_swapper |= thread_unsuspend_one(td2, p);
+ wakeup_swapper |= thread_unsuspend_one(td2, p, true);
if (TD_ON_SLEEPQ(td2) && (td2->td_flags & TDF_SINTR) != 0)
wakeup_swapper |= sleepq_abort(td2, EINTR);
break;
case SINGLE_BOUNDARY:
if (TD_IS_SUSPENDED(td2) && (td2->td_flags & TDF_BOUNDARY) == 0)
- wakeup_swapper |= thread_unsuspend_one(td2, p);
+ wakeup_swapper |= thread_unsuspend_one(td2, p, false);
if (TD_ON_SLEEPQ(td2) && (td2->td_flags & TDF_SINTR) != 0)
wakeup_swapper |= sleepq_abort(td2, ERESTART);
break;
case SINGLE_NO_EXIT:
if (TD_IS_SUSPENDED(td2) && (td2->td_flags & TDF_BOUNDARY) == 0)
- wakeup_swapper |= thread_unsuspend_one(td2, p);
+ wakeup_swapper |= thread_unsuspend_one(td2, p, false);
if (TD_ON_SLEEPQ(td2) && (td2->td_flags & TDF_SINTR) != 0)
wakeup_swapper |= sleepq_abort(td2, ERESTART);
break;
@@ -630,7 +632,7 @@ weed_inhib(int mode, struct thread *td2, struct proc *p)
*/
if (TD_IS_SUSPENDED(td2) && (td2->td_flags & (TDF_BOUNDARY |
TDF_ALLPROCSUSP)) == 0)
- wakeup_swapper |= thread_unsuspend_one(td2, p);
+ wakeup_swapper |= thread_unsuspend_one(td2, p, false);
if (TD_ON_SLEEPQ(td2) && (td2->td_flags & TDF_SINTR) != 0) {
if ((td2->td_flags & TDF_SBDRY) == 0) {
thread_suspend_one(td2);
@@ -759,6 +761,29 @@ stopme:
PROC_LOCK(p);
PROC_SLOCK(p);
}
+ } else if (mode == SINGLE_BOUNDARY) {
+ /*
+ * Wait until all suspended threads are removed from
+ * the processors. The thread_suspend_check()
+ * increments p_boundary_count while it is still
+ * running, which makes it possible for the execve()
+ * to destroy vmspace while our other threads are
+ * still using the address space.
+ *
+ * We lock the thread, which is only allowed to
+ * succeed after context switch code finished using
+ * the address space.
+ */
+ FOREACH_THREAD_IN_PROC(p, td2) {
+ if (td2 == td)
+ continue;
+ thread_lock(td2);
+ KASSERT((td2->td_flags & TDF_BOUNDARY) != 0,
+ ("td %p not on boundary", td2));
+ KASSERT(TD_IS_SUSPENDED(td2),
+ ("td %p is not suspended", td2));
+ thread_unlock(td2);
+ }
}
PROC_SUNLOCK(p);
return (0);
@@ -843,12 +868,9 @@ thread_suspend_check(int return_instead)
return (ERESTART);
/*
- * Ignore suspend requests for stop signals if they
- * are deferred.
+ * Ignore suspend requests if they are deferred.
*/
- if ((P_SHOULDSTOP(p) == P_STOPPED_SIG ||
- (p->p_flag & P_TOTAL_STOP) != 0) &&
- (td->td_flags & TDF_SBDRY) != 0) {
+ if ((td->td_flags & TDF_SBDRY) != 0) {
KASSERT(return_instead,
("TDF_SBDRY set for unsafe thread_suspend_check"));
return (0);
@@ -875,8 +897,8 @@ thread_suspend_check(int return_instead)
if (P_SHOULDSTOP(p) == P_STOPPED_SINGLE) {
if (p->p_numthreads == p->p_suspcount + 1) {
thread_lock(p->p_singlethread);
- wakeup_swapper =
- thread_unsuspend_one(p->p_singlethread, p);
+ wakeup_swapper = thread_unsuspend_one(
+ p->p_singlethread, p, false);
thread_unlock(p->p_singlethread);
if (wakeup_swapper)
kick_proc0();
@@ -895,15 +917,8 @@ thread_suspend_check(int return_instead)
}
PROC_SUNLOCK(p);
mi_switch(SW_INVOL | SWT_SUSPEND, NULL);
- if (return_instead == 0)
- td->td_flags &= ~TDF_BOUNDARY;
thread_unlock(td);
PROC_LOCK(p);
- if (return_instead == 0) {
- PROC_SLOCK(p);
- p->p_boundary_count--;
- PROC_SUNLOCK(p);
- }
}
return (0);
}
@@ -952,8 +967,8 @@ thread_suspend_one(struct thread *td)
sched_sleep(td, 0);
}
-int
-thread_unsuspend_one(struct thread *td, struct proc *p)
+static int
+thread_unsuspend_one(struct thread *td, struct proc *p, bool boundary)
{
THREAD_LOCK_ASSERT(td, MA_OWNED);
@@ -963,6 +978,10 @@ thread_unsuspend_one(struct thread *td, struct proc *p)
if (td->td_proc == p) {
PROC_SLOCK_ASSERT(p, MA_OWNED);
p->p_suspcount--;
+ if (boundary && (td->td_flags & TDF_BOUNDARY) != 0) {
+ td->td_flags &= ~TDF_BOUNDARY;
+ p->p_boundary_count--;
+ }
}
return (setrunnable(td));
}
@@ -983,12 +1002,13 @@ thread_unsuspend(struct proc *p)
FOREACH_THREAD_IN_PROC(p, td) {
thread_lock(td);
if (TD_IS_SUSPENDED(td)) {
- wakeup_swapper |= thread_unsuspend_one(td, p);
+ wakeup_swapper |= thread_unsuspend_one(td, p,
+ true);
}
thread_unlock(td);
}
- } else if ((P_SHOULDSTOP(p) == P_STOPPED_SINGLE) &&
- (p->p_numthreads == p->p_suspcount)) {
+ } else if (P_SHOULDSTOP(p) == P_STOPPED_SINGLE &&
+ p->p_numthreads == p->p_suspcount) {
/*
* Stopping everything also did the job for the single
* threading request. Now we've downgraded to single-threaded,
@@ -997,7 +1017,7 @@ thread_unsuspend(struct proc *p)
if (p->p_singlethread->td_proc == p) {
thread_lock(p->p_singlethread);
wakeup_swapper = thread_unsuspend_one(
- p->p_singlethread, p);
+ p->p_singlethread, p, false);
thread_unlock(p->p_singlethread);
}
}
@@ -1021,6 +1041,12 @@ thread_single_end(struct proc *p, int mode)
KASSERT((mode == SINGLE_ALLPROC && (p->p_flag & P_TOTAL_STOP) != 0) ||
(mode != SINGLE_ALLPROC && (p->p_flag & P_TOTAL_STOP) == 0),
("mode %d does not match P_TOTAL_STOP", mode));
+ KASSERT(mode == SINGLE_ALLPROC || p->p_singlethread == curthread,
+ ("thread_single_end from other thread %p %p",
+ curthread, p->p_singlethread));
+ KASSERT(mode != SINGLE_BOUNDARY ||
+ (p->p_flag & P_SINGLE_BOUNDARY) != 0,
+ ("mis-matched SINGLE_BOUNDARY flags %x", p->p_flag));
p->p_flag &= ~(P_STOPPED_SINGLE | P_SINGLE_EXIT | P_SINGLE_BOUNDARY |
P_TOTAL_STOP);
PROC_SLOCK(p);
@@ -1036,11 +1062,14 @@ thread_single_end(struct proc *p, int mode)
FOREACH_THREAD_IN_PROC(p, td) {
thread_lock(td);
if (TD_IS_SUSPENDED(td)) {
- wakeup_swapper |= thread_unsuspend_one(td, p);
+ wakeup_swapper |= thread_unsuspend_one(td, p,
+ mode == SINGLE_BOUNDARY);
}
thread_unlock(td);
}
}
+ KASSERT(mode != SINGLE_BOUNDARY || p->p_boundary_count == 0,
+ ("inconsistent boundary count %d", p->p_boundary_count));
PROC_SUNLOCK(p);
if (wakeup_swapper)
kick_proc0();
diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c
index 3e39d55..59bd387 100644
--- a/sys/kern/sched_4bsd.c
+++ b/sys/kern/sched_4bsd.c
@@ -1585,7 +1585,7 @@ sched_pctcpu(struct thread *td)
return (ts->ts_pctcpu);
}
-#ifdef RACCT
+#ifdef RACCT
/*
* Calculates the contribution to the thread cpu usage for the latest
* (unfinished) second.
diff --git a/sys/kern/subr_dnvlist.c b/sys/kern/subr_dnvlist.c
index fe17684..9058520 100644
--- a/sys/kern/subr_dnvlist.c
+++ b/sys/kern/subr_dnvlist.c
@@ -89,89 +89,6 @@ dnvlist_get_binary(const nvlist_t *nvl, const char *name, size_t *sizep,
return (value);
}
-#ifndef _KERNEL
-#define DNVLIST_GETF(ftype, type) \
-ftype \
-dnvlist_getf_##type(const nvlist_t *nvl, ftype defval, \
- const char *namefmt, ...) \
-{ \
- va_list nameap; \
- ftype value; \
- \
- va_start(nameap, namefmt); \
- value = dnvlist_getv_##type(nvl, defval, namefmt, nameap); \
- va_end(nameap); \
- \
- return (value); \
-}
-
-DNVLIST_GETF(bool, bool)
-DNVLIST_GETF(uint64_t, number)
-DNVLIST_GETF(const char *, string)
-DNVLIST_GETF(const nvlist_t *, nvlist)
-DNVLIST_GETF(int, descriptor)
-
-#undef DNVLIST_GETF
-
-const void *
-dnvlist_getf_binary(const nvlist_t *nvl, size_t *sizep, const void *defval,
- size_t defsize, const char *namefmt, ...)
-{
- va_list nameap;
- const void *value;
-
- va_start(nameap, namefmt);
- value = dnvlist_getv_binary(nvl, sizep, defval, defsize, namefmt,
- nameap);
- va_end(nameap);
-
- return (value);
-}
-
-#define DNVLIST_GETV(ftype, type) \
-ftype \
-dnvlist_getv_##type(const nvlist_t *nvl, ftype defval, \
- const char *namefmt, va_list nameap) \
-{ \
- char *name; \
- ftype value; \
- \
- vasprintf(&name, namefmt, nameap); \
- if (name == NULL) \
- return (defval); \
- value = dnvlist_get_##type(nvl, name, defval); \
- free(name); \
- return (value); \
-}
-
-DNVLIST_GETV(bool, bool)
-DNVLIST_GETV(uint64_t, number)
-DNVLIST_GETV(const char *, string)
-DNVLIST_GETV(const nvlist_t *, nvlist)
-DNVLIST_GETV(int, descriptor)
-
-#undef DNVLIST_GETV
-
-const void *
-dnvlist_getv_binary(const nvlist_t *nvl, size_t *sizep, const void *defval,
- size_t defsize, const char *namefmt, va_list nameap)
-{
- char *name;
- const void *value;
-
- nv_vasprintf(&name, namefmt, nameap);
- if (name != NULL) {
- value = dnvlist_get_binary(nvl, name, sizep, defval, defsize);
- nv_free(name);
- } else {
- if (sizep != NULL)
- *sizep = defsize;
- value = defval;
- }
- return (value);
-}
-#endif
-
#define DNVLIST_TAKE(ftype, type) \
ftype \
dnvlist_take_##type(nvlist_t *nvl, const char *name, ftype defval) \
@@ -209,86 +126,3 @@ dnvlist_take_binary(nvlist_t *nvl, const char *name, size_t *sizep,
return (value);
}
-#ifndef _KERNEL
-#define DNVLIST_TAKEF(ftype, type) \
-ftype \
-dnvlist_takef_##type(nvlist_t *nvl, ftype defval, \
- const char *namefmt, ...) \
-{ \
- va_list nameap; \
- ftype value; \
- \
- va_start(nameap, namefmt); \
- value = dnvlist_takev_##type(nvl, defval, namefmt, nameap); \
- va_end(nameap); \
- \
- return (value); \
-}
-
-DNVLIST_TAKEF(bool, bool)
-DNVLIST_TAKEF(uint64_t, number)
-DNVLIST_TAKEF(char *, string)
-DNVLIST_TAKEF(nvlist_t *, nvlist)
-DNVLIST_TAKEF(int, descriptor)
-
-#undef DNVLIST_TAKEF
-
-void *
-dnvlist_takef_binary(nvlist_t *nvl, size_t *sizep, void *defval,
- size_t defsize, const char *namefmt, ...)
-{
- va_list nameap;
- void *value;
-
- va_start(nameap, namefmt);
- value = dnvlist_takev_binary(nvl, sizep, defval, defsize, namefmt,
- nameap);
- va_end(nameap);
-
- return (value);
-}
-
-#define DNVLIST_TAKEV(ftype, type) \
-ftype \
-dnvlist_takev_##type(nvlist_t *nvl, ftype defval, const char *namefmt, \
- va_list nameap) \
-{ \
- char *name; \
- ftype value; \
- \
- vasprintf(&name, namefmt, nameap); \
- if (name == NULL) \
- return (defval); \
- value = dnvlist_take_##type(nvl, name, defval); \
- free(name); \
- return (value); \
-}
-
-DNVLIST_TAKEV(bool, bool)
-DNVLIST_TAKEV(uint64_t, number)
-DNVLIST_TAKEV(char *, string)
-DNVLIST_TAKEV(nvlist_t *, nvlist)
-DNVLIST_TAKEV(int, descriptor)
-
-#undef DNVLIST_TAKEV
-
-void *
-dnvlist_takev_binary(nvlist_t *nvl, size_t *sizep, void *defval,
- size_t defsize, const char *namefmt, va_list nameap)
-{
- char *name;
- void *value;
-
- nv_vasprintf(&name, namefmt, nameap);
- if (name != NULL) {
- value = dnvlist_take_binary(nvl, name, sizep, defval, defsize);
- nv_free(name);
- } else {
- if (sizep != NULL)
- *sizep = defsize;
- value = defval;
- }
-
- return (value);
-}
-#endif
diff --git a/sys/kern/subr_nvlist.c b/sys/kern/subr_nvlist.c
index f352c62..de1972e 100644
--- a/sys/kern/subr_nvlist.c
+++ b/sys/kern/subr_nvlist.c
@@ -88,7 +88,7 @@ __FBSDID("$FreeBSD$");
#endif
#define NV_FLAG_PRIVATE_MASK (NV_FLAG_BIG_ENDIAN)
-#define NV_FLAG_PUBLIC_MASK (NV_FLAG_IGNORE_CASE)
+#define NV_FLAG_PUBLIC_MASK (NV_FLAG_IGNORE_CASE | NV_FLAG_NO_UNIQUE)
#define NV_FLAG_ALL_MASK (NV_FLAG_PRIVATE_MASK | NV_FLAG_PUBLIC_MASK)
#define NVLIST_MAGIC 0x6e766c /* "nvl" */
@@ -129,6 +129,8 @@ nvlist_create(int flags)
PJDLOG_ASSERT((flags & ~(NV_FLAG_PUBLIC_MASK)) == 0);
nvl = nv_malloc(sizeof(*nvl));
+ if (nvl == NULL)
+ return (NULL);
nvl->nvl_error = 0;
nvl->nvl_flags = flags;
nvl->nvl_parent = NULL;
@@ -142,12 +144,11 @@ void
nvlist_destroy(nvlist_t *nvl)
{
nvpair_t *nvp;
- int serrno;
if (nvl == NULL)
return;
- SAVE_ERRNO(serrno);
+ ERRNO_SAVE();
NVLIST_ASSERT(nvl);
@@ -158,7 +159,7 @@ nvlist_destroy(nvlist_t *nvl)
nvl->nvl_magic = 0;
nv_free(nvl);
- RESTORE_ERRNO(serrno);
+ ERRNO_RESTORE();
}
void
@@ -231,6 +232,17 @@ nvlist_empty(const nvlist_t *nvl)
return (nvlist_first_nvpair(nvl) == NULL);
}
+int
+nvlist_flags(const nvlist_t *nvl)
+{
+
+ NVLIST_ASSERT(nvl);
+ PJDLOG_ASSERT(nvl->nvl_error == 0);
+ PJDLOG_ASSERT((nvl->nvl_flags & ~(NV_FLAG_PUBLIC_MASK)) == 0);
+
+ return (nvl->nvl_flags);
+}
+
static void
nvlist_report_missing(int type, const char *name)
{
@@ -264,7 +276,7 @@ nvlist_find(const nvlist_t *nvl, int type, const char *name)
}
if (nvp == NULL)
- RESTORE_ERRNO(ENOENT);
+ ERRNO_SET(ENOENT);
return (nvp);
}
@@ -281,37 +293,6 @@ nvlist_exists_type(const nvlist_t *nvl, const char *name, int type)
return (nvlist_find(nvl, type, name) != NULL);
}
-#ifndef _KERNEL
-bool
-nvlist_existsf_type(const nvlist_t *nvl, int type, const char *namefmt, ...)
-{
- va_list nameap;
- bool ret;
-
- va_start(nameap, namefmt);
- ret = nvlist_existsv_type(nvl, type, namefmt, nameap);
- va_end(nameap);
-
- return (ret);
-}
-
-bool
-nvlist_existsv_type(const nvlist_t *nvl, int type, const char *namefmt,
- va_list nameap)
-{
- char *name;
- bool exists;
-
- nv_vasprintf(&name, namefmt, nameap);
- if (name == NULL)
- return (false);
-
- exists = nvlist_exists_type(nvl, name, type);
- nv_free(name);
- return (exists);
-}
-#endif
-
void
nvlist_free_type(nvlist_t *nvl, const char *name, int type)
{
@@ -329,30 +310,6 @@ nvlist_free_type(nvlist_t *nvl, const char *name, int type)
nvlist_report_missing(type, name);
}
-#ifndef _KERNEL
-void
-nvlist_freef_type(nvlist_t *nvl, int type, const char *namefmt, ...)
-{
- va_list nameap;
-
- va_start(nameap, namefmt);
- nvlist_freev_type(nvl, type, namefmt, nameap);
- va_end(nameap);
-}
-
-void
-nvlist_freev_type(nvlist_t *nvl, int type, const char *namefmt, va_list nameap)
-{
- char *name;
-
- nv_vasprintf(&name, namefmt, nameap);
- if (name == NULL)
- nvlist_report_missing(type, "<unknown>");
- nvlist_free_type(nvl, name, type);
- nv_free(name);
-}
-#endif
-
nvlist_t *
nvlist_clone(const nvlist_t *nvl)
{
@@ -362,7 +319,7 @@ nvlist_clone(const nvlist_t *nvl)
NVLIST_ASSERT(nvl);
if (nvl->nvl_error != 0) {
- RESTORE_ERRNO(nvl->nvl_error);
+ ERRNO_SET(nvl->nvl_error);
return (NULL);
}
@@ -533,27 +490,30 @@ out:
#ifndef _KERNEL
static int *
-nvlist_xdescriptors(const nvlist_t *nvl, int *descs, int level)
+nvlist_xdescriptors(const nvlist_t *nvl, int *descs)
{
- const nvpair_t *nvp;
+ nvpair_t *nvp;
+ const char *name;
+ int type;
NVLIST_ASSERT(nvl);
PJDLOG_ASSERT(nvl->nvl_error == 0);
- PJDLOG_ASSERT(level < 3);
- for (nvp = nvlist_first_nvpair(nvl); nvp != NULL;
- nvp = nvlist_next_nvpair(nvl, nvp)) {
- switch (nvpair_type(nvp)) {
- case NV_TYPE_DESCRIPTOR:
- *descs = nvpair_get_descriptor(nvp);
- descs++;
- break;
- case NV_TYPE_NVLIST:
- descs = nvlist_xdescriptors(nvpair_get_nvlist(nvp),
- descs, level + 1);
- break;
+ nvp = NULL;
+ do {
+ while ((name = nvlist_next(nvl, &type, (void**)&nvp)) != NULL) {
+ switch (type) {
+ case NV_TYPE_DESCRIPTOR:
+ *descs = nvpair_get_descriptor(nvp);
+ descs++;
+ break;
+ case NV_TYPE_NVLIST:
+ nvl = nvpair_get_nvlist(nvp);
+ nvp = NULL;
+ break;
+ }
}
- }
+ } while ((nvl = nvlist_get_parent(nvl, (void**)&nvp)) != NULL);
return (descs);
}
@@ -571,7 +531,7 @@ nvlist_descriptors(const nvlist_t *nvl, size_t *nitemsp)
if (fds == NULL)
return (NULL);
if (nitems > 0)
- nvlist_xdescriptors(nvl, fds, 0);
+ nvlist_xdescriptors(nvl, fds);
fds[nitems] = -1;
if (nitemsp != NULL)
*nitemsp = nitems;
@@ -579,30 +539,33 @@ nvlist_descriptors(const nvlist_t *nvl, size_t *nitemsp)
}
#endif
-static size_t
-nvlist_xndescriptors(const nvlist_t *nvl, int level)
+size_t
+nvlist_ndescriptors(const nvlist_t *nvl)
{
#ifndef _KERNEL
- const nvpair_t *nvp;
+ nvpair_t *nvp;
+ const char *name;
size_t ndescs;
+ int type;
NVLIST_ASSERT(nvl);
PJDLOG_ASSERT(nvl->nvl_error == 0);
- PJDLOG_ASSERT(level < 3);
ndescs = 0;
- for (nvp = nvlist_first_nvpair(nvl); nvp != NULL;
- nvp = nvlist_next_nvpair(nvl, nvp)) {
- switch (nvpair_type(nvp)) {
- case NV_TYPE_DESCRIPTOR:
- ndescs++;
- break;
- case NV_TYPE_NVLIST:
- ndescs += nvlist_xndescriptors(nvpair_get_nvlist(nvp),
- level + 1);
- break;
+ nvp = NULL;
+ do {
+ while ((name = nvlist_next(nvl, &type, (void**)&nvp)) != NULL) {
+ switch (type) {
+ case NV_TYPE_DESCRIPTOR:
+ ndescs++;
+ break;
+ case NV_TYPE_NVLIST:
+ nvl = nvpair_get_nvlist(nvp);
+ nvp = NULL;
+ break;
+ }
}
- }
+ } while ((nvl = nvlist_get_parent(nvl, (void**)&nvp)) != NULL);
return (ndescs);
#else
@@ -610,13 +573,6 @@ nvlist_xndescriptors(const nvlist_t *nvl, int level)
#endif
}
-size_t
-nvlist_ndescriptors(const nvlist_t *nvl)
-{
-
- return (nvlist_xndescriptors(nvl, 0));
-}
-
static unsigned char *
nvlist_pack_header(const nvlist_t *nvl, unsigned char *ptr, size_t *leftp)
{
@@ -640,7 +596,7 @@ nvlist_pack_header(const nvlist_t *nvl, unsigned char *ptr, size_t *leftp)
return (ptr);
}
-void *
+static void *
nvlist_xpack(const nvlist_t *nvl, int64_t *fdidxp, size_t *sizep)
{
unsigned char *buf, *ptr;
@@ -652,7 +608,7 @@ nvlist_xpack(const nvlist_t *nvl, int64_t *fdidxp, size_t *sizep)
NVLIST_ASSERT(nvl);
if (nvl->nvl_error != 0) {
- RESTORE_ERRNO(nvl->nvl_error);
+ ERRNO_SET(nvl->nvl_error);
return (NULL);
}
@@ -742,12 +698,12 @@ nvlist_pack(const nvlist_t *nvl, size_t *sizep)
NVLIST_ASSERT(nvl);
if (nvl->nvl_error != 0) {
- RESTORE_ERRNO(nvl->nvl_error);
+ ERRNO_SET(nvl->nvl_error);
return (NULL);
}
if (nvlist_ndescriptors(nvl) > 0) {
- RESTORE_ERRNO(EOPNOTSUPP);
+ ERRNO_SET(EOPNOTSUPP);
return (NULL);
}
@@ -759,11 +715,11 @@ nvlist_check_header(struct nvlist_header *nvlhdrp)
{
if (nvlhdrp->nvlh_magic != NVLIST_HEADER_MAGIC) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (false);
}
if ((nvlhdrp->nvlh_flags & ~NV_FLAG_ALL_MASK) != 0) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (false);
}
#if BYTE_ORDER == BIG_ENDIAN
@@ -815,12 +771,13 @@ nvlist_unpack_header(nvlist_t *nvl, const unsigned char *ptr, size_t nfds,
return (ptr);
failed:
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
-nvlist_t *
-nvlist_xunpack(const void *buf, size_t size, const int *fds, size_t nfds)
+static nvlist_t *
+nvlist_xunpack(const void *buf, size_t size, const int *fds, size_t nfds,
+ int flags)
{
const unsigned char *ptr;
nvlist_t *nvl, *retnvl, *tmpnvl;
@@ -828,6 +785,8 @@ nvlist_xunpack(const void *buf, size_t size, const int *fds, size_t nfds)
size_t left;
bool isbe;
+ PJDLOG_ASSERT((flags & ~(NV_FLAG_PUBLIC_MASK)) == 0);
+
left = size;
ptr = buf;
@@ -839,6 +798,10 @@ nvlist_xunpack(const void *buf, size_t size, const int *fds, size_t nfds)
ptr = nvlist_unpack_header(nvl, ptr, nfds, &isbe, &left);
if (ptr == NULL)
goto failed;
+ if (nvl->nvl_flags != flags) {
+ ERRNO_SET(EILSEQ);
+ goto failed;
+ }
while (left > 0) {
ptr = nvpair_unpack(isbe, ptr, &left, &nvp);
@@ -875,6 +838,7 @@ nvlist_xunpack(const void *buf, size_t size, const int *fds, size_t nfds)
if (nvl->nvl_parent == NULL)
goto failed;
nvl = nvpair_nvlist(nvl->nvl_parent);
+ nvpair_free_structure(nvp);
continue;
default:
PJDLOG_ABORT("Invalid type (%d).", nvpair_type(nvp));
@@ -895,10 +859,10 @@ failed:
}
nvlist_t *
-nvlist_unpack(const void *buf, size_t size)
+nvlist_unpack(const void *buf, size_t size, int flags)
{
- return (nvlist_xunpack(buf, size, NULL, 0));
+ return (nvlist_xunpack(buf, size, NULL, 0, flags));
}
#ifndef _KERNEL
@@ -909,10 +873,10 @@ nvlist_send(int sock, const nvlist_t *nvl)
int *fds;
void *data;
int64_t fdidx;
- int serrno, ret;
+ int ret;
if (nvlist_error(nvl) != 0) {
- errno = nvlist_error(nvl);
+ ERRNO_SET(nvlist_error(nvl));
return (-1);
}
@@ -938,21 +902,21 @@ nvlist_send(int sock, const nvlist_t *nvl)
ret = 0;
out:
- serrno = errno;
- free(fds);
- free(data);
- errno = serrno;
+ ERRNO_SAVE();
+ nv_free(fds);
+ nv_free(data);
+ ERRNO_RESTORE();
return (ret);
}
nvlist_t *
-nvlist_recv(int sock)
+nvlist_recv(int sock, int flags)
{
struct nvlist_header nvlhdr;
nvlist_t *nvl, *ret;
unsigned char *buf;
size_t nfds, size, i;
- int serrno, *fds;
+ int *fds;
if (buf_recv(sock, &nvlhdr, sizeof(nvlhdr)) == -1)
return (NULL);
@@ -963,7 +927,7 @@ nvlist_recv(int sock)
nfds = (size_t)nvlhdr.nvlh_descriptors;
size = sizeof(nvlhdr) + (size_t)nvlhdr.nvlh_size;
- buf = malloc(size);
+ buf = nv_malloc(size);
if (buf == NULL)
return (NULL);
@@ -976,32 +940,34 @@ nvlist_recv(int sock)
goto out;
if (nfds > 0) {
- fds = malloc(nfds * sizeof(fds[0]));
+ fds = nv_malloc(nfds * sizeof(fds[0]));
if (fds == NULL)
goto out;
if (fd_recv(sock, fds, nfds) == -1)
goto out;
}
- nvl = nvlist_xunpack(buf, size, fds, nfds);
+ nvl = nvlist_xunpack(buf, size, fds, nfds, flags);
if (nvl == NULL) {
+ ERRNO_SAVE();
for (i = 0; i < nfds; i++)
close(fds[i]);
+ ERRNO_RESTORE();
goto out;
}
ret = nvl;
out:
- serrno = errno;
- free(buf);
- free(fds);
- errno = serrno;
+ ERRNO_SAVE();
+ nv_free(buf);
+ nv_free(fds);
+ ERRNO_RESTORE();
return (ret);
}
nvlist_t *
-nvlist_xfer(int sock, nvlist_t *nvl)
+nvlist_xfer(int sock, nvlist_t *nvl, int flags)
{
if (nvlist_send(sock, nvl) < 0) {
@@ -1009,7 +975,7 @@ nvlist_xfer(int sock, nvlist_t *nvl)
return (NULL);
}
nvlist_destroy(nvl);
- return (nvlist_recv(sock));
+ return (nvlist_recv(sock, flags));
}
#endif
@@ -1100,86 +1066,6 @@ NVLIST_EXISTS(binary, BINARY)
#undef NVLIST_EXISTS
-#ifndef _KERNEL
-bool
-nvlist_existsf(const nvlist_t *nvl, const char *namefmt, ...)
-{
- va_list nameap;
- bool ret;
-
- va_start(nameap, namefmt);
- ret = nvlist_existsv(nvl, namefmt, nameap);
- va_end(nameap);
- return (ret);
-}
-
-#define NVLIST_EXISTSF(type) \
-bool \
-nvlist_existsf_##type(const nvlist_t *nvl, const char *namefmt, ...) \
-{ \
- va_list nameap; \
- bool ret; \
- \
- va_start(nameap, namefmt); \
- ret = nvlist_existsv_##type(nvl, namefmt, nameap); \
- va_end(nameap); \
- return (ret); \
-}
-
-NVLIST_EXISTSF(null)
-NVLIST_EXISTSF(bool)
-NVLIST_EXISTSF(number)
-NVLIST_EXISTSF(string)
-NVLIST_EXISTSF(nvlist)
-#ifndef _KERNEL
-NVLIST_EXISTSF(descriptor)
-#endif
-NVLIST_EXISTSF(binary)
-
-#undef NVLIST_EXISTSF
-
-bool
-nvlist_existsv(const nvlist_t *nvl, const char *namefmt, va_list nameap)
-{
- char *name;
- bool exists;
-
- nv_vasprintf(&name, namefmt, nameap);
- if (name == NULL)
- return (false);
-
- exists = nvlist_exists(nvl, name);
- nv_free(name);
- return (exists);
-}
-
-#define NVLIST_EXISTSV(type) \
-bool \
-nvlist_existsv_##type(const nvlist_t *nvl, const char *namefmt, \
- va_list nameap) \
-{ \
- char *name; \
- bool exists; \
- \
- vasprintf(&name, namefmt, nameap); \
- if (name == NULL) \
- return (false); \
- exists = nvlist_exists_##type(nvl, name); \
- free(name); \
- return (exists); \
-}
-
-NVLIST_EXISTSV(null)
-NVLIST_EXISTSV(bool)
-NVLIST_EXISTSV(number)
-NVLIST_EXISTSV(string)
-NVLIST_EXISTSV(nvlist)
-NVLIST_EXISTSV(descriptor)
-NVLIST_EXISTSV(binary)
-
-#undef NVLIST_EXISTSV
-#endif
-
void
nvlist_add_nvpair(nvlist_t *nvl, const nvpair_t *nvp)
{
@@ -1188,19 +1074,21 @@ nvlist_add_nvpair(nvlist_t *nvl, const nvpair_t *nvp)
NVPAIR_ASSERT(nvp);
if (nvlist_error(nvl) != 0) {
- RESTORE_ERRNO(nvlist_error(nvl));
+ ERRNO_SET(nvlist_error(nvl));
return;
}
- if (nvlist_exists(nvl, nvpair_name(nvp))) {
- nvl->nvl_error = EEXIST;
- RESTORE_ERRNO(nvlist_error(nvl));
- return;
+ if ((nvl->nvl_flags & NV_FLAG_NO_UNIQUE) == 0) {
+ if (nvlist_exists(nvl, nvpair_name(nvp))) {
+ nvl->nvl_error = EEXIST;
+ ERRNO_SET(nvlist_error(nvl));
+ return;
+ }
}
newnvp = nvpair_clone(nvp);
if (newnvp == NULL) {
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
- RESTORE_ERRNO(nvlist_error(nvl));
+ ERRNO_SET(nvlist_error(nvl));
return;
}
@@ -1208,34 +1096,6 @@ nvlist_add_nvpair(nvlist_t *nvl, const nvpair_t *nvp)
}
void
-nvlist_add_null(nvlist_t *nvl, const char *name)
-{
-
- nvlist_addf_null(nvl, "%s", name);
-}
-
-void
-nvlist_add_bool(nvlist_t *nvl, const char *name, bool value)
-{
-
- nvlist_addf_bool(nvl, value, "%s", name);
-}
-
-void
-nvlist_add_number(nvlist_t *nvl, const char *name, uint64_t value)
-{
-
- nvlist_addf_number(nvl, value, "%s", name);
-}
-
-void
-nvlist_add_string(nvlist_t *nvl, const char *name, const char *value)
-{
-
- nvlist_addf_string(nvl, value, "%s", name);
-}
-
-void
nvlist_add_stringf(nvlist_t *nvl, const char *name, const char *valuefmt, ...)
{
va_list valueap;
@@ -1252,247 +1112,88 @@ nvlist_add_stringv(nvlist_t *nvl, const char *name, const char *valuefmt,
nvpair_t *nvp;
if (nvlist_error(nvl) != 0) {
- RESTORE_ERRNO(nvlist_error(nvl));
+ ERRNO_SET(nvlist_error(nvl));
return;
}
nvp = nvpair_create_stringv(name, valuefmt, valueap);
if (nvp == NULL) {
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
- RESTORE_ERRNO(nvl->nvl_error);
- } else
+ ERRNO_SET(nvl->nvl_error);
+ } else {
nvlist_move_nvpair(nvl, nvp);
-}
-
-void
-nvlist_add_nvlist(nvlist_t *nvl, const char *name, const nvlist_t *value)
-{
-
- nvlist_addf_nvlist(nvl, value, "%s", name);
-}
-
-#ifndef _KERNEL
-void
-nvlist_add_descriptor(nvlist_t *nvl, const char *name, int value)
-{
-
- nvlist_addf_descriptor(nvl, value, "%s", name);
-}
-#endif
-
-void
-nvlist_add_binary(nvlist_t *nvl, const char *name, const void *value,
- size_t size)
-{
-
- nvlist_addf_binary(nvl, value, size, "%s", name);
-}
-
-void
-nvlist_addf_null(nvlist_t *nvl, const char *namefmt, ...)
-{
- va_list nameap;
-
- va_start(nameap, namefmt);
- nvlist_addv_null(nvl, namefmt, nameap);
- va_end(nameap);
-}
-
-void
-nvlist_addf_bool(nvlist_t *nvl, bool value, const char *namefmt, ...)
-{
- va_list nameap;
-
- va_start(nameap, namefmt);
- nvlist_addv_bool(nvl, value, namefmt, nameap);
- va_end(nameap);
-}
-
-void
-nvlist_addf_number(nvlist_t *nvl, uint64_t value, const char *namefmt, ...)
-{
- va_list nameap;
-
- va_start(nameap, namefmt);
- nvlist_addv_number(nvl, value, namefmt, nameap);
- va_end(nameap);
-}
-
-void
-nvlist_addf_string(nvlist_t *nvl, const char *value, const char *namefmt, ...)
-{
- va_list nameap;
-
- va_start(nameap, namefmt);
- nvlist_addv_string(nvl, value, namefmt, nameap);
- va_end(nameap);
-}
-
-void
-nvlist_addf_nvlist(nvlist_t *nvl, const nvlist_t *value, const char *namefmt,
- ...)
-{
- va_list nameap;
-
- va_start(nameap, namefmt);
- nvlist_addv_nvlist(nvl, value, namefmt, nameap);
- va_end(nameap);
-}
-
-#ifndef _KERNEL
-void
-nvlist_addf_descriptor(nvlist_t *nvl, int value, const char *namefmt, ...)
-{
- va_list nameap;
-
- va_start(nameap, namefmt);
- nvlist_addv_descriptor(nvl, value, namefmt, nameap);
- va_end(nameap);
-}
-#endif
-
-void
-nvlist_addf_binary(nvlist_t *nvl, const void *value, size_t size,
- const char *namefmt, ...)
-{
- va_list nameap;
-
- va_start(nameap, namefmt);
- nvlist_addv_binary(nvl, value, size, namefmt, nameap);
- va_end(nameap);
-}
-
-void
-nvlist_addv_null(nvlist_t *nvl, const char *namefmt, va_list nameap)
-{
- nvpair_t *nvp;
-
- if (nvlist_error(nvl) != 0) {
- RESTORE_ERRNO(nvlist_error(nvl));
- return;
}
-
- nvp = nvpair_createv_null(namefmt, nameap);
- if (nvp == NULL) {
- nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
- RESTORE_ERRNO(nvl->nvl_error);
- } else
- nvlist_move_nvpair(nvl, nvp);
}
void
-nvlist_addv_bool(nvlist_t *nvl, bool value, const char *namefmt, va_list nameap)
+nvlist_add_null(nvlist_t *nvl, const char *name)
{
nvpair_t *nvp;
if (nvlist_error(nvl) != 0) {
- RESTORE_ERRNO(nvlist_error(nvl));
+ ERRNO_SET(nvlist_error(nvl));
return;
}
- nvp = nvpair_createv_bool(value, namefmt, nameap);
+ nvp = nvpair_create_null(name);
if (nvp == NULL) {
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
- RESTORE_ERRNO(nvl->nvl_error);
- } else
+ ERRNO_SET(nvl->nvl_error);
+ } else {
nvlist_move_nvpair(nvl, nvp);
-}
-
-void
-nvlist_addv_number(nvlist_t *nvl, uint64_t value, const char *namefmt,
- va_list nameap)
-{
- nvpair_t *nvp;
-
- if (nvlist_error(nvl) != 0) {
- RESTORE_ERRNO(nvlist_error(nvl));
- return;
}
-
- nvp = nvpair_createv_number(value, namefmt, nameap);
- if (nvp == NULL) {
- nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
- RESTORE_ERRNO(nvl->nvl_error);
- } else
- nvlist_move_nvpair(nvl, nvp);
}
void
-nvlist_addv_string(nvlist_t *nvl, const char *value, const char *namefmt,
- va_list nameap)
+nvlist_add_binary(nvlist_t *nvl, const char *name, const void *value,
+ size_t size)
{
nvpair_t *nvp;
if (nvlist_error(nvl) != 0) {
- RESTORE_ERRNO(nvlist_error(nvl));
+ ERRNO_SET(nvlist_error(nvl));
return;
}
- nvp = nvpair_createv_string(value, namefmt, nameap);
+ nvp = nvpair_create_binary(name, value, size);
if (nvp == NULL) {
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
- RESTORE_ERRNO(nvl->nvl_error);
- } else
+ ERRNO_SET(nvl->nvl_error);
+ } else {
nvlist_move_nvpair(nvl, nvp);
-}
-
-void
-nvlist_addv_nvlist(nvlist_t *nvl, const nvlist_t *value, const char *namefmt,
- va_list nameap)
-{
- nvpair_t *nvp;
-
- if (nvlist_error(nvl) != 0) {
- RESTORE_ERRNO(nvlist_error(nvl));
- return;
}
-
- nvp = nvpair_createv_nvlist(value, namefmt, nameap);
- if (nvp == NULL) {
- nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
- RESTORE_ERRNO(nvl->nvl_error);
- } else
- nvlist_move_nvpair(nvl, nvp);
}
-#ifndef _KERNEL
-void
-nvlist_addv_descriptor(nvlist_t *nvl, int value, const char *namefmt,
- va_list nameap)
-{
- nvpair_t *nvp;
-
- if (nvlist_error(nvl) != 0) {
- errno = nvlist_error(nvl);
- return;
- }
- nvp = nvpair_createv_descriptor(value, namefmt, nameap);
- if (nvp == NULL)
- nvl->nvl_error = errno = (errno != 0 ? errno : ENOMEM);
- else
- nvlist_move_nvpair(nvl, nvp);
-}
+#define NVLIST_ADD(vtype, type) \
+void \
+nvlist_add_##type(nvlist_t *nvl, const char *name, vtype value) \
+{ \
+ nvpair_t *nvp; \
+ \
+ if (nvlist_error(nvl) != 0) { \
+ ERRNO_SET(nvlist_error(nvl)); \
+ return; \
+ } \
+ \
+ nvp = nvpair_create_##type(name, value); \
+ if (nvp == NULL) { \
+ nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM); \
+ ERRNO_SET(nvl->nvl_error); \
+ } else { \
+ nvlist_move_nvpair(nvl, nvp); \
+ } \
+}
+
+NVLIST_ADD(bool, bool)
+NVLIST_ADD(uint64_t, number)
+NVLIST_ADD(const char *, string)
+NVLIST_ADD(const nvlist_t *, nvlist)
+#ifndef _KERNEL
+NVLIST_ADD(int, descriptor);
#endif
-void
-nvlist_addv_binary(nvlist_t *nvl, const void *value, size_t size,
- const char *namefmt, va_list nameap)
-{
- nvpair_t *nvp;
-
- if (nvlist_error(nvl) != 0) {
- RESTORE_ERRNO(nvlist_error(nvl));
- return;
- }
-
- nvp = nvpair_createv_binary(value, size, namefmt, nameap);
- if (nvp == NULL) {
- nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
- RESTORE_ERRNO(nvl->nvl_error);
- } else
- nvlist_move_nvpair(nvl, nvp);
-}
+#undef NVLIST_ADD
void
nvlist_move_nvpair(nvlist_t *nvl, nvpair_t *nvp)
@@ -1503,153 +1204,102 @@ nvlist_move_nvpair(nvlist_t *nvl, nvpair_t *nvp)
if (nvlist_error(nvl) != 0) {
nvpair_free(nvp);
- RESTORE_ERRNO(nvlist_error(nvl));
+ ERRNO_SET(nvlist_error(nvl));
return;
}
- if (nvlist_exists(nvl, nvpair_name(nvp))) {
- nvpair_free(nvp);
- nvl->nvl_error = EEXIST;
- RESTORE_ERRNO(nvl->nvl_error);
- return;
+ if ((nvl->nvl_flags & NV_FLAG_NO_UNIQUE) == 0) {
+ if (nvlist_exists(nvl, nvpair_name(nvp))) {
+ nvpair_free(nvp);
+ nvl->nvl_error = EEXIST;
+ ERRNO_SET(nvl->nvl_error);
+ return;
+ }
}
nvpair_insert(&nvl->nvl_head, nvp, nvl);
}
-#define NVLIST_MOVE(vtype, type) \
-void \
-nvlist_move_##type(nvlist_t *nvl, const char *name, vtype value) \
-{ \
- \
- nvlist_movef_##type(nvl, value, "%s", name); \
-}
-
-NVLIST_MOVE(char *, string)
-NVLIST_MOVE(nvlist_t *, nvlist)
-#ifndef _KERNEL
-NVLIST_MOVE(int, descriptor)
-#endif
-
-#undef NVLIST_MOVE
-
void
-nvlist_move_binary(nvlist_t *nvl, const char *name, void *value, size_t size)
-{
-
- nvlist_movef_binary(nvl, value, size, "%s", name);
-}
-
-#define NVLIST_MOVEF(vtype, type) \
-void \
-nvlist_movef_##type(nvlist_t *nvl, vtype value, const char *namefmt, \
- ...) \
-{ \
- va_list nameap; \
- \
- va_start(nameap, namefmt); \
- nvlist_movev_##type(nvl, value, namefmt, nameap); \
- va_end(nameap); \
-}
-
-NVLIST_MOVEF(char *, string)
-NVLIST_MOVEF(nvlist_t *, nvlist)
-#ifndef _KERNEL
-NVLIST_MOVEF(int, descriptor)
-#endif
-
-#undef NVLIST_MOVEF
-
-void
-nvlist_movef_binary(nvlist_t *nvl, void *value, size_t size,
- const char *namefmt, ...)
-{
- va_list nameap;
-
- va_start(nameap, namefmt);
- nvlist_movev_binary(nvl, value, size, namefmt, nameap);
- va_end(nameap);
-}
-
-void
-nvlist_movev_string(nvlist_t *nvl, char *value, const char *namefmt,
- va_list nameap)
+nvlist_move_string(nvlist_t *nvl, const char *name, char *value)
{
nvpair_t *nvp;
if (nvlist_error(nvl) != 0) {
nv_free(value);
- RESTORE_ERRNO(nvlist_error(nvl));
+ ERRNO_SET(nvlist_error(nvl));
return;
}
- nvp = nvpair_movev_string(value, namefmt, nameap);
+ nvp = nvpair_move_string(name, value);
if (nvp == NULL) {
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
- RESTORE_ERRNO(nvl->nvl_error);
- } else
+ ERRNO_SET(nvl->nvl_error);
+ } else {
nvlist_move_nvpair(nvl, nvp);
+ }
}
void
-nvlist_movev_nvlist(nvlist_t *nvl, nvlist_t *value, const char *namefmt,
- va_list nameap)
+nvlist_move_nvlist(nvlist_t *nvl, const char *name, nvlist_t *value)
{
nvpair_t *nvp;
if (nvlist_error(nvl) != 0) {
if (value != NULL && nvlist_get_nvpair_parent(value) != NULL)
nvlist_destroy(value);
- RESTORE_ERRNO(nvlist_error(nvl));
+ ERRNO_SET(nvlist_error(nvl));
return;
}
- nvp = nvpair_movev_nvlist(value, namefmt, nameap);
+ nvp = nvpair_move_nvlist(name, value);
if (nvp == NULL) {
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
- RESTORE_ERRNO(nvl->nvl_error);
- } else
+ ERRNO_SET(nvl->nvl_error);
+ } else {
nvlist_move_nvpair(nvl, nvp);
+ }
}
#ifndef _KERNEL
void
-nvlist_movev_descriptor(nvlist_t *nvl, int value, const char *namefmt,
- va_list nameap)
+nvlist_move_descriptor(nvlist_t *nvl, const char *name, int value)
{
nvpair_t *nvp;
if (nvlist_error(nvl) != 0) {
close(value);
- errno = nvlist_error(nvl);
+ ERRNO_SET(nvlist_error(nvl));
return;
}
- nvp = nvpair_movev_descriptor(value, namefmt, nameap);
- if (nvp == NULL)
- nvl->nvl_error = errno = (errno != 0 ? errno : ENOMEM);
- else
+ nvp = nvpair_move_descriptor(name, value);
+ if (nvp == NULL) {
+ nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
+ ERRNO_SET(nvl->nvl_error);
+ } else {
nvlist_move_nvpair(nvl, nvp);
+ }
}
#endif
void
-nvlist_movev_binary(nvlist_t *nvl, void *value, size_t size,
- const char *namefmt, va_list nameap)
+nvlist_move_binary(nvlist_t *nvl, const char *name, void *value, size_t size)
{
nvpair_t *nvp;
if (nvlist_error(nvl) != 0) {
nv_free(value);
- RESTORE_ERRNO(nvlist_error(nvl));
+ ERRNO_SET(nvlist_error(nvl));
return;
}
- nvp = nvpair_movev_binary(value, size, namefmt, nameap);
+ nvp = nvpair_move_binary(name, value, size);
if (nvp == NULL) {
nvl->nvl_error = ERRNO_OR_DEFAULT(ENOMEM);
- RESTORE_ERRNO(nvl->nvl_error);
- } else
+ ERRNO_SET(nvl->nvl_error);
+ } else {
nvlist_move_nvpair(nvl, nvp);
+ }
}
const nvpair_t *
@@ -1693,84 +1343,6 @@ nvlist_get_binary(const nvlist_t *nvl, const char *name, size_t *sizep)
return (nvpair_get_binary(nvp, sizep));
}
-#define NVLIST_GETF(ftype, type) \
-ftype \
-nvlist_getf_##type(const nvlist_t *nvl, const char *namefmt, ...) \
-{ \
- va_list nameap; \
- ftype value; \
- \
- va_start(nameap, namefmt); \
- value = nvlist_getv_##type(nvl, namefmt, nameap); \
- va_end(nameap); \
- \
- return (value); \
-}
-
-#ifndef _KERNEL
-NVLIST_GETF(bool, bool)
-NVLIST_GETF(uint64_t, number)
-NVLIST_GETF(const char *, string)
-NVLIST_GETF(const nvlist_t *, nvlist)
-NVLIST_GETF(int, descriptor)
-
-#undef NVLIST_GETF
-
-const void *
-nvlist_getf_binary(const nvlist_t *nvl, size_t *sizep, const char *namefmt, ...)
-{
- va_list nameap;
- const void *value;
-
- va_start(nameap, namefmt);
- value = nvlist_getv_binary(nvl, sizep, namefmt, nameap);
- va_end(nameap);
-
- return (value);
-}
-
-#define NVLIST_GETV(ftype, type, TYPE) \
-ftype \
-nvlist_getv_##type(const nvlist_t *nvl, const char *namefmt, \
- va_list nameap) \
-{ \
- char *name; \
- ftype value; \
- \
- vasprintf(&name, namefmt, nameap); \
- if (name == NULL) \
- nvlist_report_missing(NV_TYPE_##TYPE, "<unknown>"); \
- value = nvlist_get_##type(nvl, name); \
- free(name); \
- \
- return (value); \
-}
-
-NVLIST_GETV(bool, bool, BOOL)
-NVLIST_GETV(uint64_t, number, NUMBER)
-NVLIST_GETV(const char *, string, STRING)
-NVLIST_GETV(const nvlist_t *, nvlist, NVLIST)
-NVLIST_GETV(int, descriptor, DESCRIPTOR)
-
-#undef NVLIST_GETV
-
-const void *
-nvlist_getv_binary(const nvlist_t *nvl, size_t *sizep, const char *namefmt,
- va_list nameap)
-{
- char *name;
- const void *binary;
-
- nv_vasprintf(&name, namefmt, nameap);
- if (name == NULL)
- nvlist_report_missing(NV_TYPE_BINARY, "<unknown>");
-
- binary = nvlist_get_binary(nvl, name, sizep);
- nv_free(name);
- return (binary);
-}
-#endif
-
#define NVLIST_TAKE(ftype, type, TYPE) \
ftype \
nvlist_take_##type(nvlist_t *nvl, const char *name) \
@@ -1813,82 +1385,6 @@ nvlist_take_binary(nvlist_t *nvl, const char *name, size_t *sizep)
return (value);
}
-#define NVLIST_TAKEF(ftype, type) \
-ftype \
-nvlist_takef_##type(nvlist_t *nvl, const char *namefmt, ...) \
-{ \
- va_list nameap; \
- ftype value; \
- \
- va_start(nameap, namefmt); \
- value = nvlist_takev_##type(nvl, namefmt, nameap); \
- va_end(nameap); \
- \
- return (value); \
-}
-
-#ifndef _KERNEL
-NVLIST_TAKEF(bool, bool)
-NVLIST_TAKEF(uint64_t, number)
-NVLIST_TAKEF(char *, string)
-NVLIST_TAKEF(nvlist_t *, nvlist)
-NVLIST_TAKEF(int, descriptor)
-
-#undef NVLIST_TAKEF
-
-void *
-nvlist_takef_binary(nvlist_t *nvl, size_t *sizep, const char *namefmt, ...)
-{
- va_list nameap;
- void *value;
-
- va_start(nameap, namefmt);
- value = nvlist_takev_binary(nvl, sizep, namefmt, nameap);
- va_end(nameap);
-
- return (value);
-}
-
-#define NVLIST_TAKEV(ftype, type, TYPE) \
-ftype \
-nvlist_takev_##type(nvlist_t *nvl, const char *namefmt, va_list nameap) \
-{ \
- char *name; \
- ftype value; \
- \
- vasprintf(&name, namefmt, nameap); \
- if (name == NULL) \
- nvlist_report_missing(NV_TYPE_##TYPE, "<unknown>"); \
- value = nvlist_take_##type(nvl, name); \
- free(name); \
- return (value); \
-}
-
-NVLIST_TAKEV(bool, bool, BOOL)
-NVLIST_TAKEV(uint64_t, number, NUMBER)
-NVLIST_TAKEV(char *, string, STRING)
-NVLIST_TAKEV(nvlist_t *, nvlist, NVLIST)
-NVLIST_TAKEV(int, descriptor, DESCRIPTOR)
-
-#undef NVLIST_TAKEV
-
-void *
-nvlist_takev_binary(nvlist_t *nvl, size_t *sizep, const char *namefmt,
- va_list nameap)
-{
- char *name;
- void *binary;
-
- nv_vasprintf(&name, namefmt, nameap);
- if (name == NULL)
- nvlist_report_missing(NV_TYPE_BINARY, "<unknown>");
-
- binary = nvlist_take_binary(nvl, name, sizep);
- nv_free(name);
- return (binary);
-}
-#endif
-
void
nvlist_remove_nvpair(nvlist_t *nvl, nvpair_t *nvp)
{
@@ -1927,68 +1423,6 @@ NVLIST_FREE(binary, BINARY)
#undef NVLIST_FREE
-#ifndef _KERNEL
-void
-nvlist_freef(nvlist_t *nvl, const char *namefmt, ...)
-{
- va_list nameap;
-
- va_start(nameap, namefmt);
- nvlist_freev(nvl, namefmt, nameap);
- va_end(nameap);
-}
-
-#define NVLIST_FREEF(type) \
-void \
-nvlist_freef_##type(nvlist_t *nvl, const char *namefmt, ...) \
-{ \
- va_list nameap; \
- \
- va_start(nameap, namefmt); \
- nvlist_freev_##type(nvl, namefmt, nameap); \
- va_end(nameap); \
-}
-
-NVLIST_FREEF(null)
-NVLIST_FREEF(bool)
-NVLIST_FREEF(number)
-NVLIST_FREEF(string)
-NVLIST_FREEF(nvlist)
-NVLIST_FREEF(descriptor)
-NVLIST_FREEF(binary)
-
-#undef NVLIST_FREEF
-
-void
-nvlist_freev(nvlist_t *nvl, const char *namefmt, va_list nameap)
-{
-
- nvlist_freev_type(nvl, NV_TYPE_NONE, namefmt, nameap);
-}
-
-#define NVLIST_FREEV(type, TYPE) \
-void \
-nvlist_freev_##type(nvlist_t *nvl, const char *namefmt, va_list nameap) \
-{ \
- char *name; \
- \
- vasprintf(&name, namefmt, nameap); \
- if (name == NULL) \
- nvlist_report_missing(NV_TYPE_##TYPE, "<unknown>"); \
- nvlist_free_##type(nvl, name); \
- free(name); \
-}
-
-NVLIST_FREEV(null, NULL)
-NVLIST_FREEV(bool, BOOL)
-NVLIST_FREEV(number, NUMBER)
-NVLIST_FREEV(string, STRING)
-NVLIST_FREEV(nvlist, NVLIST)
-NVLIST_FREEV(descriptor, DESCRIPTOR)
-NVLIST_FREEV(binary, BINARY)
-#undef NVLIST_FREEV
-#endif
-
void
nvlist_free_nvpair(nvlist_t *nvl, nvpair_t *nvp)
{
@@ -2000,3 +1434,4 @@ nvlist_free_nvpair(nvlist_t *nvl, nvpair_t *nvp)
nvlist_remove_nvpair(nvl, nvp);
nvpair_free(nvp);
}
+
diff --git a/sys/kern/subr_nvpair.c b/sys/kern/subr_nvpair.c
index 7b88e42..44b0ab8 100644
--- a/sys/kern/subr_nvpair.c
+++ b/sys/kern/subr_nvpair.c
@@ -143,7 +143,8 @@ nvpair_insert(struct nvl_head *head, nvpair_t *nvp, nvlist_t *nvl)
NVPAIR_ASSERT(nvp);
PJDLOG_ASSERT(nvp->nvp_list == NULL);
- PJDLOG_ASSERT(!nvlist_exists(nvl, nvpair_name(nvp)));
+ PJDLOG_ASSERT((nvlist_flags(nvl) & NV_FLAG_NO_UNIQUE) != 0 ||
+ !nvlist_exists(nvl, nvpair_name(nvp)));
TAILQ_INSERT_TAIL(head, nvp, nvp_next);
nvp->nvp_list = nvl;
@@ -468,7 +469,7 @@ nvpair_unpack_header(bool isbe, nvpair_t *nvp, const unsigned char *ptr,
return (ptr);
failed:
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
@@ -480,7 +481,7 @@ nvpair_unpack_null(bool isbe __unused, nvpair_t *nvp, const unsigned char *ptr,
PJDLOG_ASSERT(nvp->nvp_type == NV_TYPE_NULL);
if (nvp->nvp_datasize != 0) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
@@ -496,11 +497,11 @@ nvpair_unpack_bool(bool isbe __unused, nvpair_t *nvp, const unsigned char *ptr,
PJDLOG_ASSERT(nvp->nvp_type == NV_TYPE_BOOL);
if (nvp->nvp_datasize != sizeof(value)) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
if (*leftp < sizeof(value)) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
@@ -509,7 +510,7 @@ nvpair_unpack_bool(bool isbe __unused, nvpair_t *nvp, const unsigned char *ptr,
*leftp -= sizeof(value);
if (value != 0 && value != 1) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
@@ -526,11 +527,11 @@ nvpair_unpack_number(bool isbe, nvpair_t *nvp, const unsigned char *ptr,
PJDLOG_ASSERT(nvp->nvp_type == NV_TYPE_NUMBER);
if (nvp->nvp_datasize != sizeof(uint64_t)) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
if (*leftp < sizeof(uint64_t)) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
@@ -552,13 +553,13 @@ nvpair_unpack_string(bool isbe __unused, nvpair_t *nvp,
PJDLOG_ASSERT(nvp->nvp_type == NV_TYPE_STRING);
if (*leftp < nvp->nvp_datasize || nvp->nvp_datasize == 0) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
if (strnlen((const char *)ptr, nvp->nvp_datasize) !=
nvp->nvp_datasize - 1) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
@@ -581,7 +582,7 @@ nvpair_unpack_nvlist(bool isbe __unused, nvpair_t *nvp,
PJDLOG_ASSERT(nvp->nvp_type == NV_TYPE_NVLIST);
if (*leftp < nvp->nvp_datasize || nvp->nvp_datasize == 0) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
@@ -609,11 +610,11 @@ nvpair_unpack_descriptor(bool isbe, nvpair_t *nvp, const unsigned char *ptr,
PJDLOG_ASSERT(nvp->nvp_type == NV_TYPE_DESCRIPTOR);
if (nvp->nvp_datasize != sizeof(idx)) {
- errno = EINVAL;
+ ERRNO_SET(EINVAL);
return (NULL);
}
if (*leftp < sizeof(idx)) {
- errno = EINVAL;
+ ERRNO_SET(EINVAL);
return (NULL);
}
@@ -623,12 +624,12 @@ nvpair_unpack_descriptor(bool isbe, nvpair_t *nvp, const unsigned char *ptr,
idx = le64dec(ptr);
if (idx < 0) {
- errno = EINVAL;
+ ERRNO_SET(EINVAL);
return (NULL);
}
if ((size_t)idx >= nfds) {
- errno = EINVAL;
+ ERRNO_SET(EINVAL);
return (NULL);
}
@@ -650,7 +651,7 @@ nvpair_unpack_binary(bool isbe __unused, nvpair_t *nvp,
PJDLOG_ASSERT(nvp->nvp_type == NV_TYPE_BINARY);
if (*leftp < nvp->nvp_datasize || nvp->nvp_datasize == 0) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
@@ -716,66 +717,31 @@ nvpair_name(const nvpair_t *nvp)
}
static nvpair_t *
-nvpair_allocv(int type, uint64_t data, size_t datasize, const char *namefmt,
- va_list nameap)
+nvpair_allocv(const char *name, int type, uint64_t data, size_t datasize)
{
nvpair_t *nvp;
- char *name;
- int namelen;
+ size_t namelen;
PJDLOG_ASSERT(type >= NV_TYPE_FIRST && type <= NV_TYPE_LAST);
- namelen = nv_vasprintf(&name, namefmt, nameap);
- if (namelen < 0)
- return (NULL);
-
- PJDLOG_ASSERT(namelen > 0);
+ namelen = strlen(name);
if (namelen >= NV_NAME_MAX) {
- nv_free(name);
- RESTORE_ERRNO(ENAMETOOLONG);
+ ERRNO_SET(ENAMETOOLONG);
return (NULL);
}
nvp = nv_calloc(1, sizeof(*nvp) + namelen + 1);
if (nvp != NULL) {
nvp->nvp_name = (char *)(nvp + 1);
- memcpy(nvp->nvp_name, name, namelen + 1);
+ memcpy(nvp->nvp_name, name, namelen);
+ nvp->nvp_name[namelen] = '\0';
nvp->nvp_type = type;
nvp->nvp_data = data;
nvp->nvp_datasize = datasize;
nvp->nvp_magic = NVPAIR_MAGIC;
}
- nv_free(name);
return (nvp);
-};
-
-nvpair_t *
-nvpair_create_null(const char *name)
-{
-
- return (nvpair_createf_null("%s", name));
-}
-
-nvpair_t *
-nvpair_create_bool(const char *name, bool value)
-{
-
- return (nvpair_createf_bool(value, "%s", name));
-}
-
-nvpair_t *
-nvpair_create_number(const char *name, uint64_t value)
-{
-
- return (nvpair_createf_number(value, "%s", name));
-}
-
-nvpair_t *
-nvpair_create_string(const char *name, const char *value)
-{
-
- return (nvpair_createf_string(value, "%s", name));
}
nvpair_t *
@@ -808,153 +774,36 @@ nvpair_create_stringv(const char *name, const char *valuefmt, va_list valueap)
}
nvpair_t *
-nvpair_create_nvlist(const char *name, const nvlist_t *value)
-{
-
- return (nvpair_createf_nvlist(value, "%s", name));
-}
-
-#ifndef _KERNEL
-nvpair_t *
-nvpair_create_descriptor(const char *name, int value)
-{
-
- return (nvpair_createf_descriptor(value, "%s", name));
-}
-#endif
-
-nvpair_t *
-nvpair_create_binary(const char *name, const void *value, size_t size)
-{
-
- return (nvpair_createf_binary(value, size, "%s", name));
-}
-
-nvpair_t *
-nvpair_createf_null(const char *namefmt, ...)
-{
- va_list nameap;
- nvpair_t *nvp;
-
- va_start(nameap, namefmt);
- nvp = nvpair_createv_null(namefmt, nameap);
- va_end(nameap);
-
- return (nvp);
-}
-
-nvpair_t *
-nvpair_createf_bool(bool value, const char *namefmt, ...)
-{
- va_list nameap;
- nvpair_t *nvp;
-
- va_start(nameap, namefmt);
- nvp = nvpair_createv_bool(value, namefmt, nameap);
- va_end(nameap);
-
- return (nvp);
-}
-
-nvpair_t *
-nvpair_createf_number(uint64_t value, const char *namefmt, ...)
-{
- va_list nameap;
- nvpair_t *nvp;
-
- va_start(nameap, namefmt);
- nvp = nvpair_createv_number(value, namefmt, nameap);
- va_end(nameap);
-
- return (nvp);
-}
-
-nvpair_t *
-nvpair_createf_string(const char *value, const char *namefmt, ...)
-{
- va_list nameap;
- nvpair_t *nvp;
-
- va_start(nameap, namefmt);
- nvp = nvpair_createv_string(value, namefmt, nameap);
- va_end(nameap);
-
- return (nvp);
-}
-
-nvpair_t *
-nvpair_createf_nvlist(const nvlist_t *value, const char *namefmt, ...)
-{
- va_list nameap;
- nvpair_t *nvp;
-
- va_start(nameap, namefmt);
- nvp = nvpair_createv_nvlist(value, namefmt, nameap);
- va_end(nameap);
-
- return (nvp);
-}
-
-#ifndef _KERNEL
-nvpair_t *
-nvpair_createf_descriptor(int value, const char *namefmt, ...)
-{
- va_list nameap;
- nvpair_t *nvp;
-
- va_start(nameap, namefmt);
- nvp = nvpair_createv_descriptor(value, namefmt, nameap);
- va_end(nameap);
-
- return (nvp);
-}
-#endif
-
-nvpair_t *
-nvpair_createf_binary(const void *value, size_t size, const char *namefmt, ...)
-{
- va_list nameap;
- nvpair_t *nvp;
-
- va_start(nameap, namefmt);
- nvp = nvpair_createv_binary(value, size, namefmt, nameap);
- va_end(nameap);
-
- return (nvp);
-}
-
-nvpair_t *
-nvpair_createv_null(const char *namefmt, va_list nameap)
+nvpair_create_null(const char *name)
{
- return (nvpair_allocv(NV_TYPE_NULL, 0, 0, namefmt, nameap));
+ return (nvpair_allocv(name, NV_TYPE_NULL, 0, 0));
}
nvpair_t *
-nvpair_createv_bool(bool value, const char *namefmt, va_list nameap)
+nvpair_create_bool(const char *name, bool value)
{
- return (nvpair_allocv(NV_TYPE_BOOL, value ? 1 : 0, sizeof(uint8_t),
- namefmt, nameap));
+ return (nvpair_allocv(name, NV_TYPE_BOOL, value ? 1 : 0,
+ sizeof(uint8_t)));
}
nvpair_t *
-nvpair_createv_number(uint64_t value, const char *namefmt, va_list nameap)
+nvpair_create_number(const char *name, uint64_t value)
{
- return (nvpair_allocv(NV_TYPE_NUMBER, value, sizeof(value), namefmt,
- nameap));
+ return (nvpair_allocv(name, NV_TYPE_NUMBER, value, sizeof(value)));
}
nvpair_t *
-nvpair_createv_string(const char *value, const char *namefmt, va_list nameap)
+nvpair_create_string(const char *name, const char *value)
{
nvpair_t *nvp;
size_t size;
char *data;
if (value == NULL) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
@@ -963,8 +812,8 @@ nvpair_createv_string(const char *value, const char *namefmt, va_list nameap)
return (NULL);
size = strlen(value) + 1;
- nvp = nvpair_allocv(NV_TYPE_STRING, (uint64_t)(uintptr_t)data, size,
- namefmt, nameap);
+ nvp = nvpair_allocv(name, NV_TYPE_STRING, (uint64_t)(uintptr_t)data,
+ size);
if (nvp == NULL)
nv_free(data);
@@ -972,14 +821,13 @@ nvpair_createv_string(const char *value, const char *namefmt, va_list nameap)
}
nvpair_t *
-nvpair_createv_nvlist(const nvlist_t *value, const char *namefmt,
- va_list nameap)
+nvpair_create_nvlist(const char *name, const nvlist_t *value)
{
nvlist_t *nvl;
nvpair_t *nvp;
if (value == NULL) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
@@ -987,8 +835,7 @@ nvpair_createv_nvlist(const nvlist_t *value, const char *namefmt,
if (nvl == NULL)
return (NULL);
- nvp = nvpair_allocv(NV_TYPE_NVLIST, (uint64_t)(uintptr_t)nvl, 0,
- namefmt, nameap);
+ nvp = nvpair_allocv(name, NV_TYPE_NVLIST, (uint64_t)(uintptr_t)nvl, 0);
if (nvp == NULL)
nvlist_destroy(nvl);
else
@@ -999,12 +846,12 @@ nvpair_createv_nvlist(const nvlist_t *value, const char *namefmt,
#ifndef _KERNEL
nvpair_t *
-nvpair_createv_descriptor(int value, const char *namefmt, va_list nameap)
+nvpair_create_descriptor(const char *name, int value)
{
nvpair_t *nvp;
if (value < 0 || !fd_is_valid(value)) {
- errno = EBADF;
+ ERRNO_SET(EBADF);
return (NULL);
}
@@ -1012,24 +859,26 @@ nvpair_createv_descriptor(int value, const char *namefmt, va_list nameap)
if (value < 0)
return (NULL);
- nvp = nvpair_allocv(NV_TYPE_DESCRIPTOR, (uint64_t)value,
- sizeof(int64_t), namefmt, nameap);
- if (nvp == NULL)
+ nvp = nvpair_allocv(name, NV_TYPE_DESCRIPTOR, (uint64_t)value,
+ sizeof(int64_t));
+ if (nvp == NULL) {
+ ERRNO_SAVE();
close(value);
+ ERRNO_RESTORE();
+ }
return (nvp);
}
#endif
nvpair_t *
-nvpair_createv_binary(const void *value, size_t size, const char *namefmt,
- va_list nameap)
+nvpair_create_binary(const char *name, const void *value, size_t size)
{
nvpair_t *nvp;
void *data;
if (value == NULL || size == 0) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
@@ -1038,8 +887,8 @@ nvpair_createv_binary(const void *value, size_t size, const char *namefmt,
return (NULL);
memcpy(data, value, size);
- nvp = nvpair_allocv(NV_TYPE_BINARY, (uint64_t)(uintptr_t)data, size,
- namefmt, nameap);
+ nvp = nvpair_allocv(name, NV_TYPE_BINARY, (uint64_t)(uintptr_t)data,
+ size);
if (nvp == NULL)
nv_free(data);
@@ -1049,127 +898,42 @@ nvpair_createv_binary(const void *value, size_t size, const char *namefmt,
nvpair_t *
nvpair_move_string(const char *name, char *value)
{
-
- return (nvpair_movef_string(value, "%s", name));
-}
-
-nvpair_t *
-nvpair_move_nvlist(const char *name, nvlist_t *value)
-{
-
- return (nvpair_movef_nvlist(value, "%s", name));
-}
-
-#ifndef _KERNEL
-nvpair_t *
-nvpair_move_descriptor(const char *name, int value)
-{
-
- return (nvpair_movef_descriptor(value, "%s", name));
-}
-#endif
-
-nvpair_t *
-nvpair_move_binary(const char *name, void *value, size_t size)
-{
-
- return (nvpair_movef_binary(value, size, "%s", name));
-}
-
-nvpair_t *
-nvpair_movef_string(char *value, const char *namefmt, ...)
-{
- va_list nameap;
- nvpair_t *nvp;
-
- va_start(nameap, namefmt);
- nvp = nvpair_movev_string(value, namefmt, nameap);
- va_end(nameap);
-
- return (nvp);
-}
-
-nvpair_t *
-nvpair_movef_nvlist(nvlist_t *value, const char *namefmt, ...)
-{
- va_list nameap;
- nvpair_t *nvp;
-
- va_start(nameap, namefmt);
- nvp = nvpair_movev_nvlist(value, namefmt, nameap);
- va_end(nameap);
-
- return (nvp);
-}
-
-#ifndef _KERNEL
-nvpair_t *
-nvpair_movef_descriptor(int value, const char *namefmt, ...)
-{
- va_list nameap;
- nvpair_t *nvp;
-
- va_start(nameap, namefmt);
- nvp = nvpair_movev_descriptor(value, namefmt, nameap);
- va_end(nameap);
-
- return (nvp);
-}
-#endif
-
-nvpair_t *
-nvpair_movef_binary(void *value, size_t size, const char *namefmt, ...)
-{
- va_list nameap;
- nvpair_t *nvp;
-
- va_start(nameap, namefmt);
- nvp = nvpair_movev_binary(value, size, namefmt, nameap);
- va_end(nameap);
-
- return (nvp);
-}
-
-nvpair_t *
-nvpair_movev_string(char *value, const char *namefmt, va_list nameap)
-{
nvpair_t *nvp;
- int serrno;
if (value == NULL) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
- nvp = nvpair_allocv(NV_TYPE_STRING, (uint64_t)(uintptr_t)value,
- strlen(value) + 1, namefmt, nameap);
+ nvp = nvpair_allocv(name, NV_TYPE_STRING, (uint64_t)(uintptr_t)value,
+ strlen(value) + 1);
if (nvp == NULL) {
- SAVE_ERRNO(serrno);
+ ERRNO_SAVE();
nv_free(value);
- RESTORE_ERRNO(serrno);
+ ERRNO_RESTORE();
}
return (nvp);
}
nvpair_t *
-nvpair_movev_nvlist(nvlist_t *value, const char *namefmt, va_list nameap)
+nvpair_move_nvlist(const char *name, nvlist_t *value)
{
nvpair_t *nvp;
if (value == NULL || nvlist_get_nvpair_parent(value) != NULL) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
if (nvlist_error(value) != 0) {
- RESTORE_ERRNO(nvlist_error(value));
+ ERRNO_SET(nvlist_error(value));
nvlist_destroy(value);
return (NULL);
}
- nvp = nvpair_allocv(NV_TYPE_NVLIST, (uint64_t)(uintptr_t)value, 0,
- namefmt, nameap);
+ nvp = nvpair_allocv(name, NV_TYPE_NVLIST, (uint64_t)(uintptr_t)value,
+ 0);
if (nvp == NULL)
nvlist_destroy(value);
else
@@ -1180,22 +944,21 @@ nvpair_movev_nvlist(nvlist_t *value, const char *namefmt, va_list nameap)
#ifndef _KERNEL
nvpair_t *
-nvpair_movev_descriptor(int value, const char *namefmt, va_list nameap)
+nvpair_move_descriptor(const char *name, int value)
{
nvpair_t *nvp;
- int serrno;
if (value < 0 || !fd_is_valid(value)) {
- errno = EBADF;
+ ERRNO_SET(EBADF);
return (NULL);
}
- nvp = nvpair_allocv(NV_TYPE_DESCRIPTOR, (uint64_t)value,
- sizeof(int64_t), namefmt, nameap);
+ nvp = nvpair_allocv(name, NV_TYPE_DESCRIPTOR, (uint64_t)value,
+ sizeof(int64_t));
if (nvp == NULL) {
- serrno = errno;
+ ERRNO_SAVE();
close(value);
- errno = serrno;
+ ERRNO_RESTORE();
}
return (nvp);
@@ -1203,23 +966,21 @@ nvpair_movev_descriptor(int value, const char *namefmt, va_list nameap)
#endif
nvpair_t *
-nvpair_movev_binary(void *value, size_t size, const char *namefmt,
- va_list nameap)
+nvpair_move_binary(const char *name, void *value, size_t size)
{
nvpair_t *nvp;
- int serrno;
if (value == NULL || size == 0) {
- RESTORE_ERRNO(EINVAL);
+ ERRNO_SET(EINVAL);
return (NULL);
}
- nvp = nvpair_allocv(NV_TYPE_BINARY, (uint64_t)(uintptr_t)value, size,
- namefmt, nameap);
+ nvp = nvpair_allocv(name, NV_TYPE_BINARY, (uint64_t)(uintptr_t)value,
+ size);
if (nvp == NULL) {
- SAVE_ERRNO(serrno);
+ ERRNO_SAVE();
nv_free(value);
- RESTORE_ERRNO(serrno);
+ ERRNO_RESTORE();
}
return (nvp);
@@ -1348,3 +1109,4 @@ nvpair_type_string(int type)
return ("<UNKNOWN>");
}
}
+
diff --git a/sys/kern/subr_param.c b/sys/kern/subr_param.c
index f662ec2..cba656a 100644
--- a/sys/kern/subr_param.c
+++ b/sys/kern/subr_param.c
@@ -99,11 +99,7 @@ pid_t pid_max = PID_MAX;
long maxswzone; /* max swmeta KVA storage */
long maxbcache; /* max buffer cache KVA storage */
long maxpipekva; /* Limit on pipe KVA */
-#ifdef XEN
-int vm_guest = VM_GUEST_XEN;
-#else
int vm_guest = VM_GUEST_NO; /* Running as virtual machine guest? */
-#endif
u_long maxtsiz; /* max text size */
u_long dfldsiz; /* initial data size limit */
u_long maxdsiz; /* max data size */
diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c
index cfc3ed7..93f7557 100644
--- a/sys/kern/subr_trap.c
+++ b/sys/kern/subr_trap.c
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#include <sys/ktr.h>
#include <sys/pioctl.h>
#include <sys/ptrace.h>
+#include <sys/racct.h>
#include <sys/resourcevar.h>
#include <sys/sched.h>
#include <sys/signalvar.h>
@@ -79,12 +80,6 @@ __FBSDID("$FreeBSD$");
#include <net/vnet.h>
#endif
-#ifdef XEN
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#endif
-
#ifdef HWPMC_HOOKS
#include <sys/pmckern.h>
#endif
@@ -135,9 +130,6 @@ userret(struct thread *td, struct trapframe *frame)
* Let the scheduler adjust our priority etc.
*/
sched_userret(td);
-#ifdef XEN
- PT_UPDATES_FLUSH();
-#endif
/*
* Check for misbehavior.
@@ -172,11 +164,13 @@ userret(struct thread *td, struct trapframe *frame)
__func__, td, p->p_pid, td->td_name, curvnet,
(td->td_vnet_lpush != NULL) ? td->td_vnet_lpush : "N/A"));
#endif
-#ifdef RACCT
- PROC_LOCK(p);
- while (p->p_throttled == 1)
- msleep(p->p_racct, &p->p_mtx, 0, "racct", 0);
- PROC_UNLOCK(p);
+#ifdef RACCT
+ if (racct_enable) {
+ PROC_LOCK(p);
+ while (p->p_throttled == 1)
+ msleep(p->p_racct, &p->p_mtx, 0, "racct", 0);
+ PROC_UNLOCK(p);
+ }
#endif
}
diff --git a/sys/kern/subr_turnstile.c b/sys/kern/subr_turnstile.c
index 367297a..7765cbf 100644
--- a/sys/kern/subr_turnstile.c
+++ b/sys/kern/subr_turnstile.c
@@ -1151,7 +1151,7 @@ DB_SHOW_COMMAND(lockchain, db_show_lockchain)
/* Figure out which thread to start with. */
if (have_addr)
- td = db_lookup_thread(addr, TRUE);
+ td = db_lookup_thread(addr, true);
else
td = kdb_thread;
@@ -1236,7 +1236,7 @@ DB_SHOW_COMMAND(sleepchain, db_show_sleepchain)
/* Figure out which thread to start with. */
if (have_addr)
- td = db_lookup_thread(addr, TRUE);
+ td = db_lookup_thread(addr, true);
else
td = kdb_thread;
diff --git a/sys/kern/subr_vmem.c b/sys/kern/subr_vmem.c
index 80940be..4e08113 100644
--- a/sys/kern/subr_vmem.c
+++ b/sys/kern/subr_vmem.c
@@ -766,7 +766,7 @@ vmem_start_callout(void *unused)
TASK_INIT(&vmem_periodic_wk, 0, vmem_periodic, NULL);
vmem_periodic_interval = hz * 10;
- callout_init(&vmem_periodic_ch, CALLOUT_MPSAFE);
+ callout_init(&vmem_periodic_ch, 1);
callout_reset(&vmem_periodic_ch, vmem_periodic_interval,
vmem_periodic_kick, NULL);
}
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index f80026a..dc343d0 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -2440,7 +2440,7 @@ DB_SHOW_COMMAND(locks, db_witness_list)
struct thread *td;
if (have_addr)
- td = db_lookup_thread(addr, TRUE);
+ td = db_lookup_thread(addr, true);
else
td = kdb_thread;
witness_ddb_list(td);
diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c
index acc44710..59357c4 100644
--- a/sys/kern/sysv_msg.c
+++ b/sys/kern/sysv_msg.c
@@ -617,12 +617,14 @@ sys_msgget(td, uap)
goto done2;
}
#ifdef RACCT
- PROC_LOCK(td->td_proc);
- error = racct_add(td->td_proc, RACCT_NMSGQ, 1);
- PROC_UNLOCK(td->td_proc);
- if (error != 0) {
- error = ENOSPC;
- goto done2;
+ if (racct_enable) {
+ PROC_LOCK(td->td_proc);
+ error = racct_add(td->td_proc, RACCT_NMSGQ, 1);
+ PROC_UNLOCK(td->td_proc);
+ if (error != 0) {
+ error = ENOSPC;
+ goto done2;
+ }
}
#endif
DPRINTF(("msqid %d is available\n", msqid));
@@ -724,20 +726,22 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgflg, mtype)
#endif
#ifdef RACCT
- PROC_LOCK(td->td_proc);
- if (racct_add(td->td_proc, RACCT_MSGQQUEUED, 1)) {
- PROC_UNLOCK(td->td_proc);
- error = EAGAIN;
- goto done2;
- }
- saved_msgsz = msgsz;
- if (racct_add(td->td_proc, RACCT_MSGQSIZE, msgsz)) {
- racct_sub(td->td_proc, RACCT_MSGQQUEUED, 1);
+ if (racct_enable) {
+ PROC_LOCK(td->td_proc);
+ if (racct_add(td->td_proc, RACCT_MSGQQUEUED, 1)) {
+ PROC_UNLOCK(td->td_proc);
+ error = EAGAIN;
+ goto done2;
+ }
+ saved_msgsz = msgsz;
+ if (racct_add(td->td_proc, RACCT_MSGQSIZE, msgsz)) {
+ racct_sub(td->td_proc, RACCT_MSGQQUEUED, 1);
+ PROC_UNLOCK(td->td_proc);
+ error = EAGAIN;
+ goto done2;
+ }
PROC_UNLOCK(td->td_proc);
- error = EAGAIN;
- goto done2;
}
- PROC_UNLOCK(td->td_proc);
#endif
segs_needed = (msgsz + msginfo.msgssz - 1) / msginfo.msgssz;
@@ -994,7 +998,7 @@ kern_msgsnd(td, msqid, msgp, msgsz, msgflg, mtype)
td->td_retval[0] = 0;
done3:
#ifdef RACCT
- if (error != 0) {
+ if (racct_enable && error != 0) {
PROC_LOCK(td->td_proc);
racct_sub(td->td_proc, RACCT_MSGQQUEUED, 1);
racct_sub(td->td_proc, RACCT_MSGQSIZE, saved_msgsz);
diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c
index 6ff5789..d9324f4 100644
--- a/sys/kern/sysv_sem.c
+++ b/sys/kern/sysv_sem.c
@@ -915,12 +915,14 @@ sys_semget(struct thread *td, struct semget_args *uap)
goto done2;
}
#ifdef RACCT
- PROC_LOCK(td->td_proc);
- error = racct_add(td->td_proc, RACCT_NSEM, nsems);
- PROC_UNLOCK(td->td_proc);
- if (error != 0) {
- error = ENOSPC;
- goto done2;
+ if (racct_enable) {
+ PROC_LOCK(td->td_proc);
+ error = racct_add(td->td_proc, RACCT_NSEM, nsems);
+ PROC_UNLOCK(td->td_proc);
+ if (error != 0) {
+ error = ENOSPC;
+ goto done2;
+ }
}
#endif
DPRINTF(("semid %d is available\n", semid));
@@ -1009,12 +1011,15 @@ sys_semop(struct thread *td, struct semop_args *uap)
return (E2BIG);
} else {
#ifdef RACCT
- PROC_LOCK(td->td_proc);
- if (nsops > racct_get_available(td->td_proc, RACCT_NSEMOP)) {
+ if (racct_enable) {
+ PROC_LOCK(td->td_proc);
+ if (nsops >
+ racct_get_available(td->td_proc, RACCT_NSEMOP)) {
+ PROC_UNLOCK(td->td_proc);
+ return (E2BIG);
+ }
PROC_UNLOCK(td->td_proc);
- return (E2BIG);
}
- PROC_UNLOCK(td->td_proc);
#endif
sops = malloc(nsops * sizeof(*sops), M_TEMP, M_WAITOK);
diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c
index 274deda..3240a5f 100644
--- a/sys/kern/sysv_shm.c
+++ b/sys/kern/sysv_shm.c
@@ -651,17 +651,19 @@ shmget_allocate_segment(struct thread *td, struct shmget_args *uap, int mode)
("segnum %d shmalloced %d", segnum, shmalloced));
shmseg = &shmsegs[segnum];
#ifdef RACCT
- PROC_LOCK(td->td_proc);
- if (racct_add(td->td_proc, RACCT_NSHM, 1)) {
- PROC_UNLOCK(td->td_proc);
- return (ENOSPC);
- }
- if (racct_add(td->td_proc, RACCT_SHMSIZE, size)) {
- racct_sub(td->td_proc, RACCT_NSHM, 1);
+ if (racct_enable) {
+ PROC_LOCK(td->td_proc);
+ if (racct_add(td->td_proc, RACCT_NSHM, 1)) {
+ PROC_UNLOCK(td->td_proc);
+ return (ENOSPC);
+ }
+ if (racct_add(td->td_proc, RACCT_SHMSIZE, size)) {
+ racct_sub(td->td_proc, RACCT_NSHM, 1);
+ PROC_UNLOCK(td->td_proc);
+ return (ENOMEM);
+ }
PROC_UNLOCK(td->td_proc);
- return (ENOMEM);
}
- PROC_UNLOCK(td->td_proc);
#endif
/*
@@ -672,10 +674,12 @@ shmget_allocate_segment(struct thread *td, struct shmget_args *uap, int mode)
0, size, VM_PROT_DEFAULT, 0, cred);
if (shm_object == NULL) {
#ifdef RACCT
- PROC_LOCK(td->td_proc);
- racct_sub(td->td_proc, RACCT_NSHM, 1);
- racct_sub(td->td_proc, RACCT_SHMSIZE, size);
- PROC_UNLOCK(td->td_proc);
+ if (racct_enable) {
+ PROC_LOCK(td->td_proc);
+ racct_sub(td->td_proc, RACCT_NSHM, 1);
+ racct_sub(td->td_proc, RACCT_SHMSIZE, size);
+ PROC_UNLOCK(td->td_proc);
+ }
#endif
return (ENOMEM);
}
@@ -961,39 +965,39 @@ oshmctl(struct thread *td, struct oshmctl_args *uap)
if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC))
return (ENOSYS);
+ if (uap->cmd != IPC_STAT) {
+ return (freebsd7_shmctl(td,
+ (struct freebsd7_shmctl_args *)uap));
+ }
SYSVSHM_LOCK();
shmseg = shm_find_segment(uap->shmid, true);
if (shmseg == NULL) {
SYSVSHM_UNLOCK();
return (EINVAL);
}
- switch (uap->cmd) {
- case IPC_STAT:
- error = ipcperm(td, &shmseg->u.shm_perm, IPC_R);
- if (error != 0)
- break;
+ error = ipcperm(td, &shmseg->u.shm_perm, IPC_R);
+ if (error != 0) {
+ SYSVSHM_UNLOCK();
+ return (error);
+ }
#ifdef MAC
- error = mac_sysvshm_check_shmctl(td->td_ucred, shmseg,
- uap->cmd);
- if (error != 0)
- break;
-#endif
- ipcperm_new2old(&shmseg->u.shm_perm, &outbuf.shm_perm);
- outbuf.shm_segsz = shmseg->u.shm_segsz;
- outbuf.shm_cpid = shmseg->u.shm_cpid;
- outbuf.shm_lpid = shmseg->u.shm_lpid;
- outbuf.shm_nattch = shmseg->u.shm_nattch;
- outbuf.shm_atime = shmseg->u.shm_atime;
- outbuf.shm_dtime = shmseg->u.shm_dtime;
- outbuf.shm_ctime = shmseg->u.shm_ctime;
- outbuf.shm_handle = shmseg->object;
- error = copyout(&outbuf, uap->ubuf, sizeof(outbuf));
- break;
- default:
- error = freebsd7_shmctl(td, (struct freebsd7_shmctl_args *)uap);
- break;
+ error = mac_sysvshm_check_shmctl(td->td_ucred, shmseg, uap->cmd);
+ if (error != 0) {
+ SYSVSHM_UNLOCK();
+ return (error);
}
+#endif
+ ipcperm_new2old(&shmseg->u.shm_perm, &outbuf.shm_perm);
+ outbuf.shm_segsz = shmseg->u.shm_segsz;
+ outbuf.shm_cpid = shmseg->u.shm_cpid;
+ outbuf.shm_lpid = shmseg->u.shm_lpid;
+ outbuf.shm_nattch = shmseg->u.shm_nattch;
+ outbuf.shm_atime = shmseg->u.shm_atime;
+ outbuf.shm_dtime = shmseg->u.shm_dtime;
+ outbuf.shm_ctime = shmseg->u.shm_ctime;
+ outbuf.shm_handle = shmseg->object;
SYSVSHM_UNLOCK();
+ error = copyout(&outbuf, uap->ubuf, sizeof(outbuf));
return (error);
#else
return (EINVAL);
@@ -1025,9 +1029,7 @@ sys_shmsys(struct thread *td, struct shmsys_args *uap)
return (ENOSYS);
if (uap->which < 0 || uap->which >= nitems(shmcalls))
return (EINVAL);
- SYSVSHM_LOCK();
error = (*shmcalls[uap->which])(td, &uap->a2);
- SYSVSHM_UNLOCK();
return (error);
}
diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c
index 9eda77c..6dc24f9 100644
--- a/sys/kern/uipc_domain.c
+++ b/sys/kern/uipc_domain.c
@@ -248,8 +248,8 @@ domaininit(void *dummy)
if (max_linkhdr < 16) /* XXX */
max_linkhdr = 16;
- callout_init(&pffast_callout, CALLOUT_MPSAFE);
- callout_init(&pfslow_callout, CALLOUT_MPSAFE);
+ callout_init(&pffast_callout, 1);
+ callout_init(&pfslow_callout, 1);
mtx_lock(&dom_mtx);
KASSERT(domain_init_status == 0, ("domaininit called too late!"));
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index a1a7915..b77d476 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -813,6 +813,7 @@ m_dup(struct mbuf *m, int how)
}
if ((n->m_flags & M_EXT) == 0)
nsize = MHLEN;
+ n->m_flags &= ~M_RDONLY;
}
n->m_len = 0;
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 5b6abc1..5ac04ac 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -113,8 +113,8 @@ static void vfs_setdirty_locked_object(struct buf *bp);
static void vfs_vmio_release(struct buf *bp);
static int vfs_bio_clcheck(struct vnode *vp, int size,
daddr_t lblkno, daddr_t blkno);
-static int buf_flush(int);
-static int flushbufqueues(int, int);
+static int buf_flush(struct vnode *vp, int);
+static int flushbufqueues(struct vnode *, int, int);
static void buf_daemon(void);
static void bremfreel(struct buf *bp);
static __inline void bd_wakeup(void);
@@ -2097,7 +2097,7 @@ getnewbuf_bufd_help(struct vnode *vp, int gbflags, int slpflag, int slptimeo,
{
struct thread *td;
char *waitmsg;
- int cnt, error, flags, norunbuf, wait;
+ int error, fl, flags, norunbuf;
mtx_assert(&bqclean, MA_OWNED);
@@ -2119,8 +2119,6 @@ getnewbuf_bufd_help(struct vnode *vp, int gbflags, int slpflag, int slptimeo,
return;
td = curthread;
- cnt = 0;
- wait = MNT_NOWAIT;
rw_wlock(&nblock);
while ((needsbuffer & flags) != 0) {
if (vp != NULL && vp->v_type != VCHR &&
@@ -2134,20 +2132,23 @@ getnewbuf_bufd_help(struct vnode *vp, int gbflags, int slpflag, int slptimeo,
* cannot be achieved by the buf_daemon, that
* cannot lock the vnode.
*/
- if (cnt++ > 2)
- wait = MNT_WAIT;
- ASSERT_VOP_LOCKED(vp, "bufd_helper");
- error = VOP_ISLOCKED(vp) == LK_EXCLUSIVE ? 0 :
- vn_lock(vp, LK_TRYUPGRADE);
- if (error == 0) {
- /* play bufdaemon */
- norunbuf = curthread_pflags_set(TDP_BUFNEED |
- TDP_NORUNNINGBUF);
- VOP_FSYNC(vp, wait, td);
- atomic_add_long(&notbufdflushes, 1);
- curthread_pflags_restore(norunbuf);
- }
+ norunbuf = ~(TDP_BUFNEED | TDP_NORUNNINGBUF) |
+ (td->td_pflags & TDP_NORUNNINGBUF);
+
+ /*
+ * Play bufdaemon. The getnewbuf() function
+ * may be called while the thread owns lock
+ * for another dirty buffer for the same
+ * vnode, which makes it impossible to use
+ * VOP_FSYNC() there, due to the buffer lock
+ * recursion.
+ */
+ td->td_pflags |= TDP_BUFNEED | TDP_NORUNNINGBUF;
+ fl = buf_flush(vp, flushbufqtarget);
+ td->td_pflags &= norunbuf;
rw_wlock(&nblock);
+ if (fl != 0)
+ continue;
if ((needsbuffer & flags) == 0)
break;
}
@@ -2566,18 +2567,20 @@ static struct kproc_desc buf_kp = {
SYSINIT(bufdaemon, SI_SUB_KTHREAD_BUF, SI_ORDER_FIRST, kproc_start, &buf_kp);
static int
-buf_flush(int target)
+buf_flush(struct vnode *vp, int target)
{
int flushed;
- flushed = flushbufqueues(target, 0);
+ flushed = flushbufqueues(vp, target, 0);
if (flushed == 0) {
/*
* Could not find any buffers without rollback
* dependencies, so just write the first one
* in the hopes of eventually making progress.
*/
- flushed = flushbufqueues(target, 1);
+ if (vp != NULL && target > 2)
+ target /= 2;
+ flushbufqueues(vp, target, 1);
}
return (flushed);
}
@@ -2614,7 +2617,7 @@ buf_daemon()
* the I/O system.
*/
while (numdirtybuffers > lodirty) {
- if (buf_flush(numdirtybuffers - lodirty) == 0)
+ if (buf_flush(NULL, numdirtybuffers - lodirty) == 0)
break;
kern_yield(PRI_USER);
}
@@ -2669,7 +2672,7 @@ SYSCTL_INT(_vfs, OID_AUTO, flushwithdeps, CTLFLAG_RW, &flushwithdeps,
0, "Number of buffers flushed with dependecies that require rollbacks");
static int
-flushbufqueues(int target, int flushdeps)
+flushbufqueues(struct vnode *lvp, int target, int flushdeps)
{
struct buf *sentinel;
struct vnode *vp;
@@ -2679,6 +2682,7 @@ flushbufqueues(int target, int flushdeps)
int flushed;
int queue;
int error;
+ bool unlock;
flushed = 0;
queue = QUEUE_DIRTY;
@@ -2700,8 +2704,18 @@ flushbufqueues(int target, int flushdeps)
mtx_unlock(&bqdirty);
break;
}
- KASSERT(bp->b_qindex != QUEUE_SENTINEL,
- ("parallel calls to flushbufqueues() bp %p", bp));
+ /*
+ * Skip sentinels inserted by other invocations of the
+ * flushbufqueues(), taking care to not reorder them.
+ *
+ * Only flush the buffers that belong to the
+ * vnode locked by the curthread.
+ */
+ if (bp->b_qindex == QUEUE_SENTINEL || (lvp != NULL &&
+ bp->b_vp != lvp)) {
+ mtx_unlock(&bqdirty);
+ continue;
+ }
error = BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT, NULL);
mtx_unlock(&bqdirty);
if (error != 0)
@@ -2749,16 +2763,37 @@ flushbufqueues(int target, int flushdeps)
BUF_UNLOCK(bp);
continue;
}
- error = vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT);
+ if (lvp == NULL) {
+ unlock = true;
+ error = vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT);
+ } else {
+ ASSERT_VOP_LOCKED(vp, "getbuf");
+ unlock = false;
+ error = VOP_ISLOCKED(vp) == LK_EXCLUSIVE ? 0 :
+ vn_lock(vp, LK_TRYUPGRADE);
+ }
if (error == 0) {
CTR3(KTR_BUF, "flushbufqueue(%p) vp %p flags %X",
bp, bp->b_vp, bp->b_flags);
- vfs_bio_awrite(bp);
+ if (curproc == bufdaemonproc) {
+ vfs_bio_awrite(bp);
+ } else {
+ bremfree(bp);
+ bwrite(bp);
+ notbufdflushes++;
+ }
vn_finished_write(mp);
- VOP_UNLOCK(vp, 0);
+ if (unlock)
+ VOP_UNLOCK(vp, 0);
flushwithdeps += hasdeps;
flushed++;
- if (runningbufspace > hirunningspace)
+
+ /*
+ * Sleeping on runningbufspace while holding
+ * vnode lock leads to deadlock.
+ */
+ if (curproc == bufdaemonproc &&
+ runningbufspace > hirunningspace)
waitrunningbufspace();
continue;
}
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index c5c479d..d2f0df1 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -4158,13 +4158,13 @@ sys_umask(td, uap)
int newmask;
} */ *uap;
{
- register struct filedesc *fdp;
+ struct filedesc *fdp;
- FILEDESC_XLOCK(td->td_proc->p_fd);
fdp = td->td_proc->p_fd;
+ FILEDESC_XLOCK(fdp);
td->td_retval[0] = fdp->fd_cmask;
fdp->fd_cmask = uap->newmask & ALLPERMS;
- FILEDESC_XUNLOCK(td->td_proc->p_fd);
+ FILEDESC_XUNLOCK(fdp);
return (0);
}
diff --git a/sys/mips/atheros/files.ar71xx b/sys/mips/atheros/files.ar71xx
index 5356f04..712d033 100644
--- a/sys/mips/atheros/files.ar71xx
+++ b/sys/mips/atheros/files.ar71xx
@@ -30,5 +30,6 @@ mips/atheros/ar934x_chip.c standard
mips/atheros/qca955x_chip.c standard
mips/atheros/ar71xx_fixup.c optional ar71xx_ath_eeprom
mips/atheros/qca955x_apb.c optional qca955x_apb
+mips/atheros/qca955x_pci.c optional qca955x_pci pci
dev/hwpmc/hwpmc_mips24k.c optional hwpmc_mips24k
diff --git a/sys/mips/atheros/qca955x_pci.c b/sys/mips/atheros/qca955x_pci.c
new file mode 100644
index 0000000..c50ab67
--- /dev/null
+++ b/sys/mips/atheros/qca955x_pci.c
@@ -0,0 +1,606 @@
+/*-
+ * Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org>
+ * Copyright (c) 2011, Luiz Otavio O Souza.
+ * Copyright (c) 2015, Adrian Chadd <adrian@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 AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (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>
+__FBSDID("$FreeBSD$");
+
+#include "opt_ar71xx.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+
+#include <sys/bus.h>
+#include <sys/interrupt.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/rman.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+#include <vm/vm_extern.h>
+
+#include <machine/bus.h>
+#include <machine/cpu.h>
+#include <machine/intr_machdep.h>
+#include <machine/pmap.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+
+#include <dev/pci/pcib_private.h>
+#include "pcib_if.h"
+
+#include <mips/atheros/ar71xxreg.h> /* XXX aim to eliminate this! */
+#include <mips/atheros/qca955xreg.h>
+#include <mips/atheros/ar71xx_setup.h>
+#include <mips/atheros/ar71xx_pci_bus_space.h>
+
+#include <mips/atheros/ar71xx_cpudef.h>
+
+#undef AR724X_PCI_DEBUG
+//#define AR724X_PCI_DEBUG
+#ifdef AR724X_PCI_DEBUG
+#define dprintf printf
+#else
+#define dprintf(x, arg...)
+#endif
+
+/*
+ * This is a PCI controller for the QCA955x and later SoCs.
+ * It needs to be aware of >1 PCIe host endpoints.
+ *
+ * XXX TODO; it may be nice to merge this with ar724x_pci.c;
+ * they're very similar.
+ */
+struct ar71xx_pci_irq {
+ struct ar71xx_pci_softc *sc;
+ int irq;
+};
+
+struct ar71xx_pci_softc {
+ device_t sc_dev;
+
+ int sc_busno;
+ struct rman sc_mem_rman;
+ struct rman sc_irq_rman;
+
+ uint32_t sc_pci_reg_base; /* XXX until bus stuff is done */
+ uint32_t sc_pci_crp_base; /* XXX until bus stuff is done */
+ uint32_t sc_pci_ctrl_base; /* XXX until bus stuff is done */
+ uint32_t sc_pci_mem_base; /* XXX until bus stuff is done */
+ uint32_t sc_pci_membase_limit;
+
+ struct intr_event *sc_eventstab[AR71XX_PCI_NIRQS];
+ mips_intrcnt_t sc_intr_counter[AR71XX_PCI_NIRQS];
+ struct ar71xx_pci_irq sc_pci_irq[AR71XX_PCI_NIRQS];
+ struct resource *sc_irq;
+ void *sc_ih;
+};
+
+static int qca955x_pci_setup_intr(device_t, device_t, struct resource *, int,
+ driver_filter_t *, driver_intr_t *, void *, void **);
+static int qca955x_pci_teardown_intr(device_t, device_t, struct resource *,
+ void *);
+static int qca955x_pci_intr(void *);
+
+static void
+qca955x_pci_write(uint32_t reg, uint32_t offset, uint32_t data, int bytes)
+{
+ uint32_t val, mask, shift;
+
+ /* Register access is 32-bit aligned */
+ shift = (offset & 3) * 8;
+ if (bytes % 4)
+ mask = (1 << (bytes * 8)) - 1;
+ else
+ mask = 0xffffffff;
+
+ val = ATH_READ_REG(reg + (offset & ~3));
+ val &= ~(mask << shift);
+ val |= ((data & mask) << shift);
+ ATH_WRITE_REG(reg + (offset & ~3), val);
+
+ dprintf("%s: %#x/%#x addr=%#x, data=%#x(%#x), bytes=%d\n", __func__,
+ reg, reg + (offset & ~3), offset, data, val, bytes);
+}
+
+static uint32_t
+qca955x_pci_read_config(device_t dev, u_int bus, u_int slot, u_int func,
+ u_int reg, int bytes)
+{
+ struct ar71xx_pci_softc *sc = device_get_softc(dev);
+ uint32_t data, shift, mask;
+
+ /* Register access is 32-bit aligned */
+ shift = (reg & 3) * 8;
+
+ /* Create a mask based on the width, post-shift */
+ if (bytes == 2)
+ mask = 0xffff;
+ else if (bytes == 1)
+ mask = 0xff;
+ else
+ mask = 0xffffffff;
+
+ dprintf("%s: tag (%x, %x, %x) reg %d(%d)\n", __func__, bus, slot,
+ func, reg, bytes);
+
+ if ((bus == 0) && (slot == 0) && (func == 0))
+ data = ATH_READ_REG(sc->sc_pci_reg_base + (reg & ~3));
+ else
+ data = -1;
+
+ /* Get request bytes from 32-bit word */
+ data = (data >> shift) & mask;
+
+ dprintf("%s: read 0x%x\n", __func__, data);
+
+ return (data);
+}
+
+static void
+qca955x_pci_write_config(device_t dev, u_int bus, u_int slot, u_int func,
+ u_int reg, uint32_t data, int bytes)
+{
+ struct ar71xx_pci_softc *sc = device_get_softc(dev);
+
+ dprintf("%s: tag (%x, %x, %x) reg %d(%d): %x\n", __func__, bus, slot,
+ func, reg, bytes, data);
+
+ if ((bus != 0) || (slot != 0) || (func != 0))
+ return;
+
+ qca955x_pci_write(sc->sc_pci_reg_base, reg, data, bytes);
+}
+
+static void
+qca955x_pci_mask_irq(void *source)
+{
+ uint32_t reg;
+ struct ar71xx_pci_irq *pirq = source;
+ struct ar71xx_pci_softc *sc = pirq->sc;
+
+ /* XXX - Only one interrupt ? Only one device ? */
+ if (pirq->irq != AR71XX_PCI_IRQ_START)
+ return;
+
+ /* Update the interrupt mask reg */
+ reg = ATH_READ_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_INTR_MASK);
+ ATH_WRITE_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_INTR_MASK,
+ reg & ~QCA955X_PCI_INTR_DEV0);
+
+ /* Clear any pending interrupt */
+ reg = ATH_READ_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_INTR_STATUS);
+ ATH_WRITE_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_INTR_STATUS,
+ reg | QCA955X_PCI_INTR_DEV0);
+}
+
+static void
+qca955x_pci_unmask_irq(void *source)
+{
+ uint32_t reg;
+ struct ar71xx_pci_irq *pirq = source;
+ struct ar71xx_pci_softc *sc = pirq->sc;
+
+ if (pirq->irq != AR71XX_PCI_IRQ_START)
+ return;
+
+ /* Update the interrupt mask reg */
+ reg = ATH_READ_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_INTR_MASK);
+ ATH_WRITE_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_INTR_MASK,
+ reg | QCA955X_PCI_INTR_DEV0);
+}
+
+static int
+qca955x_pci_setup(device_t dev)
+{
+ struct ar71xx_pci_softc *sc = device_get_softc(dev);
+ uint32_t reg;
+
+ /* setup COMMAND register */
+ reg = PCIM_CMD_BUSMASTEREN | PCIM_CMD_MEMEN | PCIM_CMD_SERRESPEN |
+ PCIM_CMD_BACKTOBACK | PCIM_CMD_PERRESPEN | PCIM_CMD_MWRICEN;
+
+ qca955x_pci_write(sc->sc_pci_crp_base, PCIR_COMMAND, reg, 2);
+
+ /* These are the memory/prefetch base/limit parameters */
+ qca955x_pci_write(sc->sc_pci_crp_base, 0x20, sc->sc_pci_membase_limit, 4);
+ qca955x_pci_write(sc->sc_pci_crp_base, 0x24, sc->sc_pci_membase_limit, 4);
+
+ reg = ATH_READ_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_RESET);
+ if (reg != 0x7) {
+ DELAY(100000);
+ ATH_WRITE_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_RESET, 0);
+ ATH_READ_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_RESET);
+ DELAY(100);
+ ATH_WRITE_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_RESET, 4);
+ ATH_READ_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_RESET);
+ DELAY(100000);
+ }
+
+ ATH_WRITE_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_APP, 0x1ffc1);
+ /* Flush write */
+ (void) ATH_READ_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_APP);
+
+ DELAY(1000);
+
+ reg = ATH_READ_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_RESET);
+ if ((reg & QCA955X_PCI_RESET_LINK_UP) == 0) {
+ device_printf(dev, "no PCIe controller found\n");
+ return (ENXIO);
+ }
+
+ return (0);
+}
+
+static int
+qca955x_pci_probe(device_t dev)
+{
+
+ return (BUS_PROBE_NOWILDCARD);
+}
+
+static int
+qca955x_pci_attach(device_t dev)
+{
+ struct ar71xx_pci_softc *sc = device_get_softc(dev);
+ int unit = device_get_unit(dev);
+ int busno = 0;
+ int rid = 0;
+
+ /* Dirty; maybe these could all just be hints */
+ if (unit == 0) {
+ sc->sc_pci_reg_base = QCA955X_PCI_CFG_BASE0;
+ sc->sc_pci_crp_base = QCA955X_PCI_CRP_BASE0;
+ sc->sc_pci_ctrl_base = QCA955X_PCI_CTRL_BASE0;
+ sc->sc_pci_mem_base = QCA955X_PCI_MEM_BASE0;
+ /* XXX verify */
+ sc->sc_pci_membase_limit = 0x11f01000;
+ } else if (unit == 1) {
+ sc->sc_pci_reg_base = QCA955X_PCI_CFG_BASE1;
+ sc->sc_pci_crp_base = QCA955X_PCI_CRP_BASE1;
+ sc->sc_pci_ctrl_base = QCA955X_PCI_CTRL_BASE1;
+ sc->sc_pci_mem_base = QCA955X_PCI_MEM_BASE1;
+ /* XXX verify */
+ sc->sc_pci_membase_limit = 0x12f01200;
+ } else {
+ device_printf(dev, "%s: invalid unit (%d)\n", __func__, unit);
+ return (ENXIO);
+ }
+
+ sc->sc_mem_rman.rm_type = RMAN_ARRAY;
+ sc->sc_mem_rman.rm_descr = "qca955x PCI memory window";
+ if (rman_init(&sc->sc_mem_rman) != 0 ||
+ rman_manage_region(&sc->sc_mem_rman,
+ sc->sc_pci_mem_base,
+ sc->sc_pci_mem_base + QCA955X_PCI_MEM_SIZE - 1) != 0) {
+ panic("qca955x_pci_attach: failed to set up I/O rman");
+ }
+
+ sc->sc_irq_rman.rm_type = RMAN_ARRAY;
+ sc->sc_irq_rman.rm_descr = "qca955x PCI IRQs";
+ if (rman_init(&sc->sc_irq_rman) != 0 ||
+ rman_manage_region(&sc->sc_irq_rman, AR71XX_PCI_IRQ_START,
+ AR71XX_PCI_IRQ_END) != 0)
+ panic("qca955x_pci_attach: failed to set up IRQ rman");
+
+ /* Disable interrupts */
+ ATH_WRITE_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_INTR_STATUS, 0);
+ ATH_WRITE_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_INTR_MASK, 0);
+
+ /* Hook up our interrupt handler. */
+ if ((sc->sc_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
+ RF_SHAREABLE | RF_ACTIVE)) == NULL) {
+ device_printf(dev, "unable to allocate IRQ resource\n");
+ return (ENXIO);
+ }
+
+ if ((bus_setup_intr(dev, sc->sc_irq, INTR_TYPE_MISC,
+ qca955x_pci_intr, NULL, sc, &sc->sc_ih))) {
+ device_printf(dev,
+ "WARNING: unable to register interrupt handler\n");
+ return (ENXIO);
+ }
+
+ /* Reset PCIe core and PCIe PHY */
+ ar71xx_device_stop(QCA955X_RESET_PCIE);
+ ar71xx_device_stop(QCA955X_RESET_PCIE_PHY);
+ DELAY(100);
+ ar71xx_device_start(QCA955X_RESET_PCIE_PHY);
+ ar71xx_device_start(QCA955X_RESET_PCIE);
+
+ if (qca955x_pci_setup(dev))
+ return (ENXIO);
+
+ /*
+ * Write initial base address.
+ *
+ * I'm not yet sure why this is required and/or why it isn't
+ * initialised like this. The AR71xx PCI code initialises
+ * the PCI windows for each device, but neither it or the
+ * 724x PCI bridge modules explicitly initialise the BAR.
+ *
+ * So before this gets committed, have a chat with jhb@ or
+ * someone else who knows PCI well and figure out whether
+ * the initial BAR is supposed to be determined by /other/
+ * means.
+ */
+ qca955x_pci_write_config(dev, 0, 0, 0, PCIR_BAR(0),
+ sc->sc_pci_mem_base,
+ 4);
+
+ /* Fixup internal PCI bridge */
+ qca955x_pci_write_config(dev, 0, 0, 0, PCIR_COMMAND,
+ PCIM_CMD_BUSMASTEREN | PCIM_CMD_MEMEN
+ | PCIM_CMD_SERRESPEN | PCIM_CMD_BACKTOBACK
+ | PCIM_CMD_PERRESPEN | PCIM_CMD_MWRICEN, 2);
+
+ device_add_child(dev, "pci", busno);
+ return (bus_generic_attach(dev));
+}
+
+static int
+qca955x_pci_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
+{
+ struct ar71xx_pci_softc *sc = device_get_softc(dev);
+
+ switch (which) {
+ case PCIB_IVAR_DOMAIN:
+ *result = 0;
+ return (0);
+ case PCIB_IVAR_BUS:
+ *result = sc->sc_busno;
+ return (0);
+ }
+
+ return (ENOENT);
+}
+
+static int
+qca955x_pci_write_ivar(device_t dev, device_t child, int which, uintptr_t result)
+{
+ struct ar71xx_pci_softc * sc = device_get_softc(dev);
+
+ switch (which) {
+ case PCIB_IVAR_BUS:
+ sc->sc_busno = result;
+ return (0);
+ }
+
+ return (ENOENT);
+}
+
+static struct resource *
+qca955x_pci_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 ar71xx_pci_softc *sc = device_get_softc(bus);
+ struct resource *rv;
+ struct rman *rm;
+
+ switch (type) {
+ case SYS_RES_IRQ:
+ rm = &sc->sc_irq_rman;
+ break;
+ case SYS_RES_MEMORY:
+ rm = &sc->sc_mem_rman;
+ break;
+ default:
+ return (NULL);
+ }
+
+ rv = rman_reserve_resource(rm, start, end, count, flags, child);
+
+ if (rv == NULL)
+ return (NULL);
+
+ rman_set_rid(rv, *rid);
+
+ if (flags & RF_ACTIVE) {
+ if (bus_activate_resource(child, type, *rid, rv)) {
+ rman_release_resource(rv);
+ return (NULL);
+ }
+ }
+
+ return (rv);
+}
+
+static int
+qca955x_pci_activate_resource(device_t bus, device_t child, int type, int rid,
+ struct resource *r)
+{
+ int res = (BUS_ACTIVATE_RESOURCE(device_get_parent(bus),
+ child, type, rid, r));
+
+ if (!res) {
+ switch(type) {
+ case SYS_RES_MEMORY:
+ case SYS_RES_IOPORT:
+
+ rman_set_bustag(r, ar71xx_bus_space_pcimem);
+ break;
+ }
+ }
+
+ return (res);
+}
+
+static int
+qca955x_pci_setup_intr(device_t bus, device_t child, struct resource *ires,
+ int flags, driver_filter_t *filt, driver_intr_t *handler,
+ void *arg, void **cookiep)
+{
+ struct ar71xx_pci_softc *sc = device_get_softc(bus);
+ struct intr_event *event;
+ int irq, error;
+
+ irq = rman_get_start(ires);
+ if (irq > AR71XX_PCI_IRQ_END)
+ panic("%s: bad irq %d", __func__, irq);
+
+ event = sc->sc_eventstab[irq];
+ if (event == NULL) {
+ sc->sc_pci_irq[irq].sc = sc;
+ sc->sc_pci_irq[irq].irq = irq;
+ error = intr_event_create(&event, (void *)&sc->sc_pci_irq[irq],
+ 0, irq,
+ qca955x_pci_mask_irq,
+ qca955x_pci_unmask_irq,
+ NULL, NULL,
+ "pci intr%d:", irq);
+
+ if (error == 0) {
+ sc->sc_eventstab[irq] = event;
+ sc->sc_intr_counter[irq] =
+ mips_intrcnt_create(event->ie_name);
+ }
+ else
+ return error;
+ }
+
+ intr_event_add_handler(event, device_get_nameunit(child), filt,
+ handler, arg, intr_priority(flags), flags, cookiep);
+ mips_intrcnt_setname(sc->sc_intr_counter[irq], event->ie_fullname);
+
+ qca955x_pci_unmask_irq(&sc->sc_pci_irq[irq]);
+
+ return (0);
+}
+
+static int
+qca955x_pci_teardown_intr(device_t dev, device_t child, struct resource *ires,
+ void *cookie)
+{
+ struct ar71xx_pci_softc *sc = device_get_softc(dev);
+ int irq, result;
+
+ irq = rman_get_start(ires);
+ if (irq > AR71XX_PCI_IRQ_END)
+ panic("%s: bad irq %d", __func__, irq);
+
+ if (sc->sc_eventstab[irq] == NULL)
+ panic("Trying to teardown unoccupied IRQ");
+
+ qca955x_pci_mask_irq(&sc->sc_pci_irq[irq]);
+
+ result = intr_event_remove_handler(cookie);
+ if (!result)
+ sc->sc_eventstab[irq] = NULL;
+
+ return (result);
+}
+
+static int
+qca955x_pci_intr(void *arg)
+{
+ struct ar71xx_pci_softc *sc = arg;
+ struct intr_event *event;
+ uint32_t reg, irq, mask;
+
+ /* XXX TODO - may need to flush a different handler? */
+ ar71xx_device_ddr_flush_ip2();
+
+ reg = ATH_READ_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_INTR_STATUS);
+ mask = ATH_READ_REG(sc->sc_pci_ctrl_base + QCA955X_PCI_INTR_MASK);
+ /*
+ * Handle only unmasked interrupts
+ */
+ reg &= mask;
+ /*
+ * XXX TODO: handle >1 PCIe end point!
+ */
+ if (reg & QCA955X_PCI_INTR_DEV0) {
+ irq = AR71XX_PCI_IRQ_START;
+ event = sc->sc_eventstab[irq];
+ if (!event || TAILQ_EMPTY(&event->ie_handlers)) {
+ printf("Stray IRQ %d\n", irq);
+ return (FILTER_STRAY);
+ }
+
+ /* TODO: frame instead of NULL? */
+ intr_event_handle(event, NULL);
+ mips_intrcnt_inc(sc->sc_intr_counter[irq]);
+ }
+
+ return (FILTER_HANDLED);
+}
+
+static int
+qca955x_pci_maxslots(device_t dev)
+{
+
+ return (PCI_SLOTMAX);
+}
+
+static int
+qca955x_pci_route_interrupt(device_t pcib, device_t device, int pin)
+{
+
+ return (pci_get_slot(device));
+}
+
+static device_method_t qca955x_pci_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, qca955x_pci_probe),
+ DEVMETHOD(device_attach, qca955x_pci_attach),
+ DEVMETHOD(device_shutdown, bus_generic_shutdown),
+ DEVMETHOD(device_suspend, bus_generic_suspend),
+ DEVMETHOD(device_resume, bus_generic_resume),
+
+ /* Bus interface */
+ DEVMETHOD(bus_read_ivar, qca955x_pci_read_ivar),
+ DEVMETHOD(bus_write_ivar, qca955x_pci_write_ivar),
+ DEVMETHOD(bus_alloc_resource, qca955x_pci_alloc_resource),
+ DEVMETHOD(bus_release_resource, bus_generic_release_resource),
+ DEVMETHOD(bus_activate_resource, qca955x_pci_activate_resource),
+ DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
+ DEVMETHOD(bus_setup_intr, qca955x_pci_setup_intr),
+ DEVMETHOD(bus_teardown_intr, qca955x_pci_teardown_intr),
+
+ /* pcib interface */
+ DEVMETHOD(pcib_maxslots, qca955x_pci_maxslots),
+ DEVMETHOD(pcib_read_config, qca955x_pci_read_config),
+ DEVMETHOD(pcib_write_config, qca955x_pci_write_config),
+ DEVMETHOD(pcib_route_interrupt, qca955x_pci_route_interrupt),
+
+ DEVMETHOD_END
+};
+
+static driver_t qca955x_pci_driver = {
+ "pcib",
+ qca955x_pci_methods,
+ sizeof(struct ar71xx_pci_softc),
+};
+
+static devclass_t qca955x_pci_devclass;
+
+DRIVER_MODULE(qca955x_pci, nexus, qca955x_pci_driver, qca955x_pci_devclass, 0, 0);
+DRIVER_MODULE(qca955x_pci, apb, qca955x_pci_driver, qca955x_pci_devclass, 0, 0);
diff --git a/sys/mips/beri/beri_simplebus.c b/sys/mips/beri/beri_simplebus.c
index 87ad3be..54f654a 100644
--- a/sys/mips/beri/beri_simplebus.c
+++ b/sys/mips/beri/beri_simplebus.c
@@ -198,7 +198,7 @@ simplebus_attach(device_t dev)
continue;
}
- if (ofw_bus_intr_to_rl(dev, dt_child, &di->di_res)) {
+ if (ofw_bus_intr_to_rl(dev, dt_child, &di->di_res, NULL)) {
device_printf(dev, "%s: could not process "
"'interrupts' property\n", di->di_ofw.obd_name);
resource_list_free(&di->di_res);
diff --git a/sys/mips/cavium/octe/ethernet.c b/sys/mips/cavium/octe/ethernet.c
index b2a5ddf..d473d82 100644
--- a/sys/mips/cavium/octe/ethernet.c
+++ b/sys/mips/cavium/octe/ethernet.c
@@ -455,7 +455,7 @@ int cvm_oct_init_module(device_t bus)
cvmx_write_csr(CVMX_POW_WQ_INT_THRX(pow_receive_group), 0x1001);
}
- callout_init(&cvm_oct_poll_timer, CALLOUT_MPSAFE);
+ callout_init(&cvm_oct_poll_timer, 1);
callout_reset(&cvm_oct_poll_timer, hz, cvm_do_timer, NULL);
return 0;
diff --git a/sys/mips/cavium/octeon_rnd.c b/sys/mips/cavium/octeon_rnd.c
index 9419314..844de45 100644
--- a/sys/mips/cavium/octeon_rnd.c
+++ b/sys/mips/cavium/octeon_rnd.c
@@ -95,7 +95,7 @@ octeon_rnd_attach(device_t dev)
struct octeon_rnd_softc *sc;
sc = device_get_softc(dev);
- callout_init(&sc->sc_callout, CALLOUT_MPSAFE);
+ callout_init(&sc->sc_callout, 1);
callout_reset(&sc->sc_callout, hz * 5, octeon_rnd_harvest, sc);
cvmx_rng_enable();
diff --git a/sys/mips/conf/AP135 b/sys/mips/conf/AP135
index 2271948..39d2b6c 100644
--- a/sys/mips/conf/AP135
+++ b/sys/mips/conf/AP135
@@ -50,7 +50,12 @@ options GEOM_UNCOMPRESS
# Used for the static uboot partition map
device geom_map
-# yes, this board has a PCI connected atheros device
+# yes, this board has a PCIe connected atheros device
+# add ath_pci so it can at least attach things when there's a
+# ath(4) in there, rather than the 11ac chip we don't support.
+device pci
+device qca955x_pci
+
device ath_pci
options AR71XX_ATH_EEPROM
device firmware # Used by the above
@@ -58,3 +63,6 @@ options ATH_EEPROM_FIRMWARE
# Boot off of the rootfs, as defined in the geom_map setup.
options ROOTDEVNAME=\"ufs:map/rootfs.uncompress\"
+
+# Default to accept
+options IPFIREWALL_DEFAULT_TO_ACCEPT
diff --git a/sys/mips/conf/AP135.hints b/sys/mips/conf/AP135.hints
index 1778b91..3db44d0 100644
--- a/sys/mips/conf/AP135.hints
+++ b/sys/mips/conf/AP135.hints
@@ -117,11 +117,11 @@ hint.ath.0.eepromsize=16384
# to find it.
# ath1 hint - pcie slot 0
-hint.pcib.0.bus.0.0.0.ath_fixup_addr=0x1fff4000
-hint.pcib.0.bus.0.0.0.ath_fixup_size=16384
+# hint.pcib.0.bus.0.0.0.ath_fixup_addr=0x1fff4000
+# hint.pcib.0.bus.0.0.0.ath_fixup_size=16384
# ath0 - eeprom comes from here
-hint.ath.1.eeprom_firmware="pcib.0.bus.0.0.0.eeprom_firmware"
+# hint.ath.1.eeprom_firmware="pcib.0.bus.0.0.0.eeprom_firmware"
# flash layout:
#
diff --git a/sys/mips/conf/QCA955X_BASE b/sys/mips/conf/QCA955X_BASE
index 93211c1..9785f0e 100644
--- a/sys/mips/conf/QCA955X_BASE
+++ b/sys/mips/conf/QCA955X_BASE
@@ -27,7 +27,7 @@ hints "QCA955X_BASE.hints"
makeoptions DEBUG=-g #Build kernel with gdb(1) debug symbols
# makeoptions MODULES_OVERRIDE="random gpio ar71xx if_gif if_gre if_bridge bridgestp usb wlan wlan_xauth wlan_acl wlan_wep wlan_tkip wlan_ccmp wlan_rssadapt wlan_amrr ath ath_ahb hwpmc"
-makeoptions MODULES_OVERRIDE="if_vlan ipfw if_gre if_gif if_bridge bridgestp hwpmc"
+makeoptions MODULES_OVERRIDE="if_vlan ipfw if_gre if_gif if_bridge bridgestp"
options DDB
options KDB
@@ -53,10 +53,10 @@ options NBUF=128
# Limit UMTX hash size
# options UMTX_NUM_CHAINS=64
-# PMC
+# PMC - fow now there's no hwpmc module for mips74k
#options HWPMC_HOOKS
#device hwpmc
-#device hwpmc_mips24k
+#device hwpmc_mips74k
# options NFS_LEGACYRPC
# Debugging for use in -current
@@ -109,12 +109,6 @@ options USB_DEBUG
options USB_HOST_ALIGN=32 # AR71XX (MIPS in general?) requires this
device ehci
-device pci
-# XXX TODO: need to write a qca955x_pci bridge
-# .. since it now handles >1 PCIe bus and the reset
-# registers may have changed a bit.
-# device ar724x_pci
-
device scbus
device umass
device da
diff --git a/sys/mips/conf/ROUTERSTATION b/sys/mips/conf/ROUTERSTATION
index a680c26..6b46cf7 100644
--- a/sys/mips/conf/ROUTERSTATION
+++ b/sys/mips/conf/ROUTERSTATION
@@ -12,8 +12,8 @@ hints "ROUTERSTATION.hints"
# GEOM modules
device geom_redboot # to get access to the SPI flash partitions
-device geom_uzip # compressed in-memory filesystem support
-options GEOM_UZIP
+device geom_uncompress # compressed in-memory filesystem support
+options GEOM_UNCOMPRESS
# For DOS
options MSDOSFS
@@ -25,4 +25,4 @@ device etherswitch
device ukswitch
# Boot path - redboot MFS
-options ROOTDEVNAME=\"ufs:redboot/rootfs.uzip\"
+options ROOTDEVNAME=\"ufs:redboot/rootfs.uncompress\"
diff --git a/sys/mips/conf/RSPRO b/sys/mips/conf/RSPRO
index d5a5405..5936767 100644
--- a/sys/mips/conf/RSPRO
+++ b/sys/mips/conf/RSPRO
@@ -13,8 +13,8 @@ device pcf2123_rtc
# GEOM modules
device geom_redboot # to get access to the SPI flash partitions
-device geom_uzip # compressed in-memory filesystem support
-options GEOM_UZIP
+device geom_uncompress # compressed in-memory filesystem support
+options GEOM_UNCOMPRESS
# For DOS
options MSDOSFS
@@ -26,5 +26,5 @@ device etherswitch
device arswitch
# Boot off of flash
-options ROOTDEVNAME=\"ufs:redboot/rootfs.uzip\"
+options ROOTDEVNAME=\"ufs:redboot/rootfs.uncompress\"
diff --git a/sys/mips/include/intr_machdep.h b/sys/mips/include/intr_machdep.h
index 547e75a..186533c 100644
--- a/sys/mips/include/intr_machdep.h
+++ b/sys/mips/include/intr_machdep.h
@@ -70,5 +70,6 @@ mips_intrcnt_inc(mips_intrcnt_t counter)
{
if (counter)
atomic_add_long(counter, 1);
+ PCPU_INC(cnt.v_intr);
}
#endif /* !_MACHINE_INTR_MACHDEP_H_ */
diff --git a/sys/mips/mips/busdma_machdep.c b/sys/mips/mips/busdma_machdep.c
index 083e8f5..90ec399 100644
--- a/sys/mips/mips/busdma_machdep.c
+++ b/sys/mips/mips/busdma_machdep.c
@@ -1359,8 +1359,8 @@ add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr,
if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) {
/* Page offset needs to be preserved. */
- bpage->vaddr |= vaddr & PAGE_MASK;
- bpage->busaddr |= vaddr & PAGE_MASK;
+ bpage->vaddr |= addr & PAGE_MASK;
+ bpage->busaddr |= addr & PAGE_MASK;
}
bpage->datavaddr = vaddr;
bpage->dataaddr = addr;
diff --git a/sys/mips/mips/db_disasm.c b/sys/mips/mips/db_disasm.c
index c7e5223..14788ed 100644
--- a/sys/mips/mips/db_disasm.c
+++ b/sys/mips/mips/db_disasm.c
@@ -130,7 +130,7 @@ static char *c0_reg[32] = {
static int md_printins(int ins, int mdbdot);
db_addr_t
-db_disasm(db_addr_t loc, boolean_t altfmt)
+db_disasm(db_addr_t loc, bool altfmt)
{
int ins;
diff --git a/sys/mips/mips/pmap.c b/sys/mips/mips/pmap.c
index 2ca8ed5..7ab4244 100644
--- a/sys/mips/mips/pmap.c
+++ b/sys/mips/mips/pmap.c
@@ -1036,7 +1036,7 @@ pmap_grow_direct_page_cache()
{
#ifdef __mips_n64
- vm_pageout_grow_cache(3, 0, MIPS_XKPHYS_LARGEST_PHYS);
+ VM_WAIT;
#else
vm_pageout_grow_cache(3, 0, MIPS_KSEG0_LARGEST_PHYS);
#endif
@@ -3243,7 +3243,7 @@ DB_SHOW_COMMAND(ptable, ddb_pid_dump)
vm_offset_t va;
if (have_addr) {
- td = db_lookup_thread(addr, TRUE);
+ td = db_lookup_thread(addr, true);
if (td == NULL) {
db_printf("Invalid pid or tid");
return;
diff --git a/sys/mips/mips/vm_machdep.c b/sys/mips/mips/vm_machdep.c
index 26cdbff..42f3f68 100644
--- a/sys/mips/mips/vm_machdep.c
+++ b/sys/mips/mips/vm_machdep.c
@@ -571,7 +571,7 @@ DB_SHOW_COMMAND(pcb, ddb_dump_pcb)
/* Determine which thread to examine. */
if (have_addr)
- td = db_lookup_thread(addr, TRUE);
+ td = db_lookup_thread(addr, true);
else
td = curthread;
diff --git a/sys/mips/nlm/dev/net/xlpge.c b/sys/mips/nlm/dev/net/xlpge.c
index e9bb86e..aaa6379 100644
--- a/sys/mips/nlm/dev/net/xlpge.c
+++ b/sys/mips/nlm/dev/net/xlpge.c
@@ -1240,7 +1240,7 @@ nlm_xlpge_attach(device_t dev)
sc->prepad_en = sc->network_sc->prepad_en;
sc->prepad_size = sc->network_sc->prepad_size;
- callout_init(&sc->xlpge_callout, CALLOUT_MPSAFE);
+ callout_init(&sc->xlpge_callout, 1);
XLPGE_LOCK_INIT(sc, device_get_nameunit(dev));
diff --git a/sys/mips/rmi/dev/xlr/rge.c b/sys/mips/rmi/dev/xlr/rge.c
index 6fd2bc6..248dd42 100644
--- a/sys/mips/rmi/dev/xlr/rge.c
+++ b/sys/mips/rmi/dev/xlr/rge.c
@@ -1894,9 +1894,9 @@ rge_attach(device_t dev)
if (!gmac_common_init_done) {
mac_common_init();
gmac_common_init_done = 1;
- callout_init(&xlr_tx_stop_bkp, CALLOUT_MPSAFE);
+ callout_init(&xlr_tx_stop_bkp, 1);
callout_reset(&xlr_tx_stop_bkp, hz, xlr_tx_q_wakeup, NULL);
- callout_init(&rge_dbg_count, CALLOUT_MPSAFE);
+ callout_init(&rge_dbg_count, 1);
//callout_reset(&rge_dbg_count, hz, xlr_debug_count, NULL);
}
if ((ret = rmi_xlr_mac_open(sc)) == -1) {
diff --git a/sys/modules/Makefile b/sys/modules/Makefile
index 14d166f..7afc5a8 100644
--- a/sys/modules/Makefile
+++ b/sys/modules/Makefile
@@ -456,6 +456,7 @@ _txp= txp
.endif
.if ${MK_SOURCELESS_UCODE} != "no" && ${MACHINE_CPUARCH} != "arm" && \
+ ${MACHINE_ARCH:C/mips(el)?/mips/} != "mips" && \
${MACHINE_ARCH} != "powerpc"
_cxgbe= cxgbe
.endif
diff --git a/sys/modules/ix/Makefile b/sys/modules/ix/Makefile
index 5a5485d..1f30cb0 100644
--- a/sys/modules/ix/Makefile
+++ b/sys/modules/ix/Makefile
@@ -9,7 +9,7 @@ SRCS += if_ix.c ix_txrx.c
# Shared source
SRCS += ixgbe_common.c ixgbe_api.c ixgbe_phy.c ixgbe_mbx.c ixgbe_vf.c
SRCS += ixgbe_dcb.c ixgbe_dcb_82598.c ixgbe_dcb_82599.c
-SRCS += ixgbe_82599.c ixgbe_82598.c ixgbe_x540.c
+SRCS += ixgbe_82598.c ixgbe_82599.c ixgbe_x540.c ixgbe_x550.c
CFLAGS+= -I${.CURDIR}/../../dev/ixgbe -DSMP
.include <bsd.kmod.mk>
diff --git a/sys/modules/ixv/Makefile b/sys/modules/ixv/Makefile
index 20ecaf1..f8ce347 100644
--- a/sys/modules/ixv/Makefile
+++ b/sys/modules/ixv/Makefile
@@ -9,7 +9,7 @@ SRCS += if_ixv.c ix_txrx.c
# Shared source
SRCS += ixgbe_common.c ixgbe_api.c ixgbe_phy.c ixgbe_mbx.c ixgbe_vf.c
SRCS += ixgbe_dcb.c ixgbe_dcb_82598.c ixgbe_dcb_82599.c
-SRCS += ixgbe_82599.c ixgbe_82598.c ixgbe_x540.c
+SRCS += ixgbe_82598.c ixgbe_82599.c ixgbe_x540.c ixgbe_x550.c
CFLAGS+= -I${.CURDIR}/../../dev/ixgbe -DSMP
.include <bsd.kmod.mk>
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index 753854d..faa7681 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -3065,9 +3065,11 @@ bridge_state_change(struct ifnet *ifp, int state)
"discarding"
};
+ CURVNET_SET(ifp->if_vnet);
if (V_log_stp)
log(LOG_NOTICE, "%s: state changed to %s on %s\n",
sc->sc_ifp->if_xname, stpstates[state], ifp->if_xname);
+ CURVNET_RESTORE();
}
/*
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c
index cbcb50f..48a842a 100644
--- a/sys/net/if_gif.c
+++ b/sys/net/if_gif.c
@@ -920,6 +920,17 @@ gif_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
#endif
}
break;
+ case SIOCGTUNFIB:
+ ifr->ifr_fib = sc->gif_fibnum;
+ break;
+ case SIOCSTUNFIB:
+ if ((error = priv_check(curthread, PRIV_NET_GIF)) != 0)
+ break;
+ if (ifr->ifr_fib >= rt_numfibs)
+ error = EINVAL;
+ else
+ sc->gif_fibnum = ifr->ifr_fib;
+ break;
case GIFGOPTS:
options = sc->gif_options;
error = copyout(&options, ifr->ifr_data, sizeof(options));
@@ -935,7 +946,6 @@ gif_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
else
sc->gif_options = options;
break;
-
default:
error = EINVAL;
break;
diff --git a/sys/net/if_gif.h b/sys/net/if_gif.h
index c1fe83b..ed143e8 100644
--- a/sys/net/if_gif.h
+++ b/sys/net/if_gif.h
@@ -127,7 +127,9 @@ int in6_gif_attach(struct gif_softc *);
#define GIFSOPTS _IOW('i', 151, struct ifreq)
#define GIF_ACCEPT_REVETHIP 0x0001
+#define GIF_IGNORE_SOURCE 0x0002
#define GIF_SEND_REVETHIP 0x0010
-#define GIF_OPTMASK (GIF_ACCEPT_REVETHIP|GIF_SEND_REVETHIP)
+#define GIF_OPTMASK (GIF_ACCEPT_REVETHIP|GIF_SEND_REVETHIP| \
+ GIF_IGNORE_SOURCE)
#endif /* _NET_IF_GIF_H_ */
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c
index 3162c6f..c38ec3a 100644
--- a/sys/net/if_gre.c
+++ b/sys/net/if_gre.c
@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_types.h>
#include <net/netisr.h>
#include <net/vnet.h>
+#include <net/route.h>
#include <netinet/in.h>
#ifdef INET
@@ -441,6 +442,17 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
#endif
}
break;
+ case SIOCGTUNFIB:
+ ifr->ifr_fib = sc->gre_fibnum;
+ break;
+ case SIOCSTUNFIB:
+ if ((error = priv_check(curthread, PRIV_NET_GRE)) != 0)
+ break;
+ if (ifr->ifr_fib >= rt_numfibs)
+ error = EINVAL;
+ else
+ sc->gre_fibnum = ifr->ifr_fib;
+ break;
case GRESKEY:
if ((error = priv_check(curthread, PRIV_NET_GRE)) != 0)
break;
@@ -454,7 +466,8 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
}
break;
case GREGKEY:
- error = copyout(&sc->gre_key, ifr->ifr_data, sizeof(sc->gre_key));
+ error = copyout(&sc->gre_key, ifr->ifr_data,
+ sizeof(sc->gre_key));
break;
case GRESOPTS:
if ((error = priv_check(curthread, PRIV_NET_GRE)) != 0)
@@ -725,7 +738,7 @@ gre_input(struct mbuf **mp, int *offp, int proto)
m_adj(m, *offp + hlen);
m_clrprotoflags(m);
m->m_pkthdr.rcvif = ifp;
- M_SETFIB(m, sc->gre_fibnum);
+ M_SETFIB(m, ifp->if_fib);
#ifdef MAC
mac_ifnet_create_mbuf(ifp, m);
#endif
diff --git a/sys/net/if_me.c b/sys/net/if_me.c
index a00bdd2..ff79713 100644
--- a/sys/net/if_me.c
+++ b/sys/net/if_me.c
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_types.h>
#include <net/netisr.h>
#include <net/vnet.h>
+#include <net/route.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
@@ -297,6 +298,17 @@ me_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
if (error != 0)
memset(src, 0, sizeof(*src));
break;
+ case SIOCGTUNFIB:
+ ifr->ifr_fib = sc->me_fibnum;
+ break;
+ case SIOCSTUNFIB:
+ if ((error = priv_check(curthread, PRIV_NET_GRE)) != 0)
+ break;
+ if (ifr->ifr_fib >= rt_numfibs)
+ error = EINVAL;
+ else
+ sc->me_fibnum = ifr->ifr_fib;
+ break;
default:
error = EINVAL;
break;
@@ -453,7 +465,7 @@ me_input(struct mbuf **mp, int *offp, int proto)
m_clrprotoflags(m);
m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.csum_flags |= (CSUM_IP_CHECKED | CSUM_IP_VALID);
- M_SETFIB(m, sc->me_fibnum);
+ M_SETFIB(m, ifp->if_fib);
hlen = AF_INET;
BPF_MTAP2(ifp, &hlen, sizeof(hlen), m);
if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
@@ -477,7 +489,7 @@ me_check_nesting(struct ifnet *ifp, struct mbuf *m)
count = 1;
mtag = NULL;
- while ((mtag = m_tag_locate(m, MTAG_ME, 0, NULL)) != NULL) {
+ while ((mtag = m_tag_locate(m, MTAG_ME, 0, mtag)) != NULL) {
if (*(struct ifnet **)(mtag + 1) == ifp) {
log(LOG_NOTICE, "%s: loop detected\n", ifp->if_xname);
return (EIO);
diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c
index c0f8e39..6743981 100644
--- a/sys/net/if_spppsubr.c
+++ b/sys/net/if_spppsubr.c
@@ -1005,7 +1005,7 @@ sppp_attach(struct ifnet *ifp)
mtx_init(&sp->mtx, "sppp", MTX_NETWORK_LOCK, MTX_DEF | MTX_RECURSE);
/* Initialize keepalive handler. */
- callout_init(&sp->keepalive_callout, CALLOUT_MPSAFE);
+ callout_init(&sp->keepalive_callout, 1);
callout_reset(&sp->keepalive_callout, hz * 10, sppp_keepalive,
(void *)sp);
@@ -1037,7 +1037,7 @@ sppp_attach(struct ifnet *ifp)
#ifdef INET6
sp->confflags |= CONF_ENABLE_IPV6;
#endif
- callout_init(&sp->ifstart_callout, CALLOUT_MPSAFE);
+ callout_init(&sp->ifstart_callout, 1);
sp->if_start = ifp->if_start;
ifp->if_start = sppp_ifstart;
sp->pp_comp = malloc(sizeof(struct slcompress), M_TEMP, M_WAITOK);
@@ -2145,7 +2145,7 @@ sppp_lcp_init(struct sppp *sp)
sp->lcp.max_terminate = 2;
sp->lcp.max_configure = 10;
sp->lcp.max_failure = 10;
- callout_init(&sp->ch[IDX_LCP], CALLOUT_MPSAFE);
+ callout_init(&sp->ch[IDX_LCP], 1);
}
static void
@@ -2836,7 +2836,7 @@ sppp_ipcp_init(struct sppp *sp)
sp->fail_counter[IDX_IPCP] = 0;
sp->pp_seq[IDX_IPCP] = 0;
sp->pp_rseq[IDX_IPCP] = 0;
- callout_init(&sp->ch[IDX_IPCP], CALLOUT_MPSAFE);
+ callout_init(&sp->ch[IDX_IPCP], 1);
}
static void
@@ -3395,7 +3395,7 @@ sppp_ipv6cp_init(struct sppp *sp)
sp->fail_counter[IDX_IPV6CP] = 0;
sp->pp_seq[IDX_IPV6CP] = 0;
sp->pp_rseq[IDX_IPV6CP] = 0;
- callout_init(&sp->ch[IDX_IPV6CP], CALLOUT_MPSAFE);
+ callout_init(&sp->ch[IDX_IPV6CP], 1);
}
static void
@@ -4200,7 +4200,7 @@ sppp_chap_init(struct sppp *sp)
sp->fail_counter[IDX_CHAP] = 0;
sp->pp_seq[IDX_CHAP] = 0;
sp->pp_rseq[IDX_CHAP] = 0;
- callout_init(&sp->ch[IDX_CHAP], CALLOUT_MPSAFE);
+ callout_init(&sp->ch[IDX_CHAP], 1);
}
static void
@@ -4522,8 +4522,8 @@ sppp_pap_init(struct sppp *sp)
sp->fail_counter[IDX_PAP] = 0;
sp->pp_seq[IDX_PAP] = 0;
sp->pp_rseq[IDX_PAP] = 0;
- callout_init(&sp->ch[IDX_PAP], CALLOUT_MPSAFE);
- callout_init(&sp->pap_my_to_ch, CALLOUT_MPSAFE);
+ callout_init(&sp->ch[IDX_PAP], 1);
+ callout_init(&sp->pap_my_to_ch, 1);
}
static void
diff --git a/sys/net/if_types.h b/sys/net/if_types.h
index df019e0..92e101a 100644
--- a/sys/net/if_types.h
+++ b/sys/net/if_types.h
@@ -254,4 +254,20 @@ typedef enum {
IFT_PFLOG = 0xf6, /* PF packet filter logging */
IFT_PFSYNC = 0xf7, /* PF packet filter synchronization */
} ifType;
+
+/*
+ * Some (broken) software uses #ifdef IFT_TYPE to check whether
+ * an operating systems supports certain interface type. Lack of
+ * ifdef leads to a piece of functionality compiled out.
+ */
+#ifndef BURN_BRIDGES
+#define IFT_BRIDGE IFT_BRIDGE
+#define IFT_PPP IFT_PPP
+#define IFT_PROPVIRTUAL IFT_PROPVIRTUAL
+#define IFT_L2VLAN IFT_L2VLAN
+#define IFT_L3IPVLAN IFT_L3IPVLAN
+#define IFT_IEEE1394 IFT_IEEE1394
+#define IFT_INFINIBAND IFT_INFINIBAND
+#endif
+
#endif /* !_NET_IF_TYPES_H_ */
diff --git a/sys/net/sff8436.h b/sys/net/sff8436.h
index 7d705b8..97abe10 100644
--- a/sys/net/sff8436.h
+++ b/sys/net/sff8436.h
@@ -202,7 +202,9 @@ enum {
* optional features are implemented
* (if any) in the transceiver
* (see Table 42) */
- SFF_8436_CC_EXT = 222, /* Check code for the Extended ID
+ SFF_8636_BITRATE = 222, /* Nominal bit rate per channel, units
+ * of 250 Mbps */
+ SFF_8436_CC_EXT = 223, /* Check code for the Extended ID
* Fields (bytes 192-222 incl) */
SFF_8436_VENDOR_RSRVD_START = 224,
SFF_8436_VENDOR_RSRVD_END = 255,
diff --git a/sys/net/sff8472.h b/sys/net/sff8472.h
index 08b37ca..fdeb2e9 100644
--- a/sys/net/sff8472.h
+++ b/sys/net/sff8472.h
@@ -377,7 +377,7 @@ enum {
/*
* Table 3.2 Identifier values.
- * Identifier constants has taken from SFF-8024 rev 2.2 table 4.1
+ * Identifier constants has taken from SFF-8024 rev 2.9 table 4.1
* (as referenced by table 3.2 footer)
* */
enum {
@@ -400,28 +400,36 @@ enum {
SFF_8024_ID_HD8X = 0x10, /* Shielded Mini Multilane HD 8X */
SFF_8024_ID_QSFP28 = 0x11, /* QSFP28 */
SFF_8024_ID_CXP2 = 0x12, /* CXP2 (aka CXP28) */
- SFF_8024_ID_LAST = SFF_8024_ID_CXP2
+ SFF_8024_ID_CDFP = 0x13, /* CDFP (Style 1/Style 2) */
+ SFF_8024_ID_SMM4 = 0x14, /* Shielded Mini Multilate HD 4X Fanout */
+ SFF_8024_ID_SMM8 = 0x15, /* Shielded Mini Multilate HD 8X Fanout */
+ SFF_8024_ID_CDFP3 = 0x16, /* CDFP (Style3) */
+ SFF_8024_ID_LAST = SFF_8024_ID_CDFP3
};
static const char *sff_8024_id[SFF_8024_ID_LAST + 1] = {"Unknown",
"GBIC",
"SFF",
- "SFP/SFP+",
+ "SFP/SFP+/SFP28",
"XBI",
"Xenpak",
"XFP",
"XFF",
"XFP-E",
- "XPAk",
+ "XPAK",
"X2",
- "DWDM-SFP",
+ "DWDM-SFP/SFP+",
"QSFP",
"QSFP+",
"CXP",
"HD4X",
"HD8X",
"QSFP28",
- "CXP2"};
+ "CXP2",
+ "CDFP",
+ "SMM4",
+ "SMM8",
+ "CDFP3"};
/* Keep compability with old definitions */
#define SFF_8472_ID_UNKNOWN SFF_8024_ID_UNKNOWN
diff --git a/sys/net80211/ieee80211.h b/sys/net80211/ieee80211.h
index 9b005f3..8e586bd 100644
--- a/sys/net80211/ieee80211.h
+++ b/sys/net80211/ieee80211.h
@@ -169,6 +169,11 @@ struct ieee80211_qosframe_addr4 {
#define IEEE80211_FC1_PROTECTED 0x40
#define IEEE80211_FC1_ORDER 0x80
+#define IEEE80211_HAS_SEQ(type, subtype) \
+ ((type) != IEEE80211_FC0_TYPE_CTL && \
+ !((type) == IEEE80211_FC0_TYPE_DATA && \
+ ((subtype) & IEEE80211_FC0_SUBTYPE_QOS_NULL) == \
+ IEEE80211_FC0_SUBTYPE_QOS_NULL))
#define IEEE80211_SEQ_FRAG_MASK 0x000f
#define IEEE80211_SEQ_FRAG_SHIFT 0
#define IEEE80211_SEQ_SEQ_MASK 0xfff0
diff --git a/sys/net80211/ieee80211_adhoc.c b/sys/net80211/ieee80211_adhoc.c
index c1b4b51..0d761c4 100644
--- a/sys/net80211/ieee80211_adhoc.c
+++ b/sys/net80211/ieee80211_adhoc.c
@@ -229,6 +229,8 @@ adhoc_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
}
#endif
break;
+ case IEEE80211_S_RUN: /* IBSS merge */
+ break;
default:
goto invalid;
}
@@ -289,7 +291,6 @@ doprint(struct ieee80211vap *vap, int subtype)
static int
adhoc_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf)
{
-#define HAS_SEQ(type) ((type & 0x4) == 0)
struct ieee80211vap *vap = ni->ni_vap;
struct ieee80211com *ic = ni->ni_ic;
struct ifnet *ifp = vap->iv_ifp;
@@ -369,7 +370,10 @@ adhoc_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf)
/*
* Validate the bssid.
*/
- if (!IEEE80211_ADDR_EQ(bssid, vap->iv_bss->ni_bssid) &&
+ if (!(type == IEEE80211_FC0_TYPE_MGT &&
+ (subtype == IEEE80211_FC0_SUBTYPE_BEACON ||
+ subtype == IEEE80211_FC0_SUBTYPE_PROBE_RESP)) &&
+ !IEEE80211_ADDR_EQ(bssid, vap->iv_bss->ni_bssid) &&
!IEEE80211_ADDR_EQ(bssid, ifp->if_broadcastaddr)) {
/* not interested in */
IEEE80211_DISCARD_MAC(vap, IEEE80211_MSG_INPUT,
@@ -409,7 +413,8 @@ adhoc_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf)
}
IEEE80211_RSSI_LPF(ni->ni_avgrssi, rssi);
ni->ni_noise = nf;
- if (HAS_SEQ(type)) {
+ if (IEEE80211_HAS_SEQ(type, subtype) &&
+ IEEE80211_ADDR_EQ(wh->i_addr2, ni->ni_macaddr)) {
uint8_t tid = ieee80211_gettid(wh);
if (IEEE80211_QOS_HAS_SEQ(wh) &&
TID_TO_WME_AC(tid) >= WME_AC_VI)
@@ -730,7 +735,8 @@ adhoc_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0,
ieee80211_probe_curchan(vap, 1);
ic->ic_flags_ext &= ~IEEE80211_FEXT_PROBECHAN;
}
- ieee80211_add_scan(vap, &scan, wh, subtype, rssi, nf);
+ ieee80211_add_scan(vap, ic->ic_curchan, &scan, wh,
+ subtype, rssi, nf);
return;
}
if (scan.capinfo & IEEE80211_CAPINFO_IBSS) {
diff --git a/sys/net80211/ieee80211_freebsd.c b/sys/net80211/ieee80211_freebsd.c
index a292619..7a2abf8 100644
--- a/sys/net80211/ieee80211_freebsd.c
+++ b/sys/net80211/ieee80211_freebsd.c
@@ -873,14 +873,8 @@ wlan_modevent(module_t mod, int type, void *unused)
printf("wlan: <802.11 Link Layer>\n");
wlan_bpfevent = EVENTHANDLER_REGISTER(bpf_track,
bpf_track, 0, EVENTHANDLER_PRI_ANY);
- if (wlan_bpfevent == NULL)
- return ENOMEM;
wlan_ifllevent = EVENTHANDLER_REGISTER(iflladdr_event,
wlan_iflladdr, NULL, EVENTHANDLER_PRI_ANY);
- if (wlan_ifllevent == NULL) {
- EVENTHANDLER_DEREGISTER(bpf_track, wlan_bpfevent);
- return ENOMEM;
- }
#if __FreeBSD_version >= 1000020
wlan_cloner = if_clone_simple(wlanname, wlan_clone_create,
wlan_clone_destroy, 0);
diff --git a/sys/net80211/ieee80211_freebsd.h b/sys/net80211/ieee80211_freebsd.h
index 711bac3..aa21f3b 100644
--- a/sys/net80211/ieee80211_freebsd.h
+++ b/sys/net80211/ieee80211_freebsd.h
@@ -355,8 +355,8 @@ wlan_##name##_modevent(module_t mod, int type, void *unused) \
case MOD_UNLOAD: \
case MOD_QUIESCE: \
if (nrefs) { \
- printf("wlan_##name: still in use (%u dynamic refs)\n",\
- nrefs); \
+ printf("wlan_" #name ": still in use " \
+ "(%u dynamic refs)\n", nrefs); \
return EBUSY; \
} \
if (type == MOD_UNLOAD) { \
diff --git a/sys/net80211/ieee80211_hostap.c b/sys/net80211/ieee80211_hostap.c
index 32eec45..a625b4e 100644
--- a/sys/net80211/ieee80211_hostap.c
+++ b/sys/net80211/ieee80211_hostap.c
@@ -478,7 +478,6 @@ doprint(struct ieee80211vap *vap, int subtype)
static int
hostap_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf)
{
-#define HAS_SEQ(type) ((type & 0x4) == 0)
struct ieee80211vap *vap = ni->ni_vap;
struct ieee80211com *ic = ni->ni_ic;
struct ifnet *ifp = vap->iv_ifp;
@@ -571,7 +570,7 @@ hostap_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf)
IEEE80211_RSSI_LPF(ni->ni_avgrssi, rssi);
ni->ni_noise = nf;
- if (HAS_SEQ(type)) {
+ if (IEEE80211_HAS_SEQ(type, subtype)) {
uint8_t tid = ieee80211_gettid(wh);
if (IEEE80211_QOS_HAS_SEQ(wh) &&
TID_TO_WME_AC(tid) >= WME_AC_VI)
@@ -1737,7 +1736,8 @@ hostap_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0,
ieee80211_probe_curchan(vap, 1);
ic->ic_flags_ext &= ~IEEE80211_FEXT_PROBECHAN;
}
- ieee80211_add_scan(vap, &scan, wh, subtype, rssi, nf);
+ ieee80211_add_scan(vap, ic->ic_curchan, &scan, wh,
+ subtype, rssi, nf);
return;
}
/*
diff --git a/sys/net80211/ieee80211_ht.c b/sys/net80211/ieee80211_ht.c
index 5fe2e80..0700de8 100644
--- a/sys/net80211/ieee80211_ht.c
+++ b/sys/net80211/ieee80211_ht.c
@@ -1691,7 +1691,7 @@ ieee80211_setup_basic_htrates(struct ieee80211_node *ni, const uint8_t *ie)
static void
ampdu_tx_setup(struct ieee80211_tx_ampdu *tap)
{
- callout_init(&tap->txa_timer, CALLOUT_MPSAFE);
+ callout_init(&tap->txa_timer, 1);
tap->txa_flags |= IEEE80211_AGGR_SETUP;
tap->txa_lastsample = ticks;
}
@@ -2662,10 +2662,24 @@ ieee80211_add_htcap_body(uint8_t *frm, struct ieee80211_node *ni)
caps |= IEEE80211_HTCAP_CHWIDTH40;
else
caps &= ~IEEE80211_HTCAP_CHWIDTH40;
- /* use advertised setting (XXX locally constraint) */
+
+ /* Start by using the advertised settings */
rxmax = MS(ni->ni_htparam, IEEE80211_HTCAP_MAXRXAMPDU);
density = MS(ni->ni_htparam, IEEE80211_HTCAP_MPDUDENSITY);
+ /* Cap at VAP rxmax */
+ if (rxmax > vap->iv_ampdu_rxmax)
+ rxmax = vap->iv_ampdu_rxmax;
+
+ /*
+ * If the VAP ampdu density value greater, use that.
+ *
+ * (Larger density value == larger minimum gap between A-MPDU
+ * subframes.)
+ */
+ if (vap->iv_ampdu_density > density)
+ density = vap->iv_ampdu_density;
+
/*
* NB: Hardware might support HT40 on some but not all
* channels. We can't determine this earlier because only
@@ -2682,9 +2696,12 @@ ieee80211_add_htcap_body(uint8_t *frm, struct ieee80211_node *ni)
caps |= IEEE80211_HTCAP_CHWIDTH40;
else
caps &= ~IEEE80211_HTCAP_CHWIDTH40;
+
+ /* XXX TODO should it start by using advertised settings? */
rxmax = vap->iv_ampdu_rxmax;
density = vap->iv_ampdu_density;
}
+
/* adjust short GI based on channel and config */
if ((vap->iv_flags_ht & IEEE80211_FHT_SHORTGI20) == 0)
caps &= ~IEEE80211_HTCAP_SHORTGI20;
diff --git a/sys/net80211/ieee80211_hwmp.c b/sys/net80211/ieee80211_hwmp.c
index 8d57302..601b848 100644
--- a/sys/net80211/ieee80211_hwmp.c
+++ b/sys/net80211/ieee80211_hwmp.c
@@ -275,7 +275,7 @@ hwmp_vattach(struct ieee80211vap *vap)
return;
}
hs->hs_maxhops = IEEE80211_HWMP_DEFAULT_MAXHOPS;
- callout_init(&hs->hs_roottimer, CALLOUT_MPSAFE);
+ callout_init(&hs->hs_roottimer, 1);
vap->iv_hwmp = hs;
}
diff --git a/sys/net80211/ieee80211_input.h b/sys/net80211/ieee80211_input.h
index b90f46a..f3d569e 100644
--- a/sys/net80211/ieee80211_input.h
+++ b/sys/net80211/ieee80211_input.h
@@ -168,19 +168,22 @@ ieee80211_check_rxseq(struct ieee80211_node *ni, struct ieee80211_frame *wh)
{
#define SEQ_LEQ(a,b) ((int)((a)-(b)) <= 0)
#define SEQ_EQ(a,b) ((int)((a)-(b)) == 0)
-#define HAS_SEQ(type) ((type & 0x4) == 0)
#define SEQNO(a) ((a) >> IEEE80211_SEQ_SEQ_SHIFT)
#define FRAGNO(a) ((a) & IEEE80211_SEQ_FRAG_MASK)
uint16_t rxseq;
- uint8_t type;
+ uint8_t type, subtype;
uint8_t tid;
struct ieee80211_rx_ampdu *rap;
rxseq = le16toh(*(uint16_t *)wh->i_seq);
type = wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK;
+ subtype = wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK;
- /* Types with no sequence number are always treated valid */
- if (! HAS_SEQ(type))
+ /*
+ * Types with no sequence number (or QoS (+)Null frames)
+ * are always treated valid.
+ */
+ if (! IEEE80211_HAS_SEQ(type, subtype))
return 1;
tid = ieee80211_gettid(wh);
@@ -235,7 +238,6 @@ ieee80211_check_rxseq(struct ieee80211_node *ni, struct ieee80211_frame *wh)
return 1;
#undef SEQ_LEQ
#undef SEQ_EQ
-#undef HAS_SEQ
#undef SEQNO
#undef FRAGNO
}
diff --git a/sys/net80211/ieee80211_mesh.c b/sys/net80211/ieee80211_mesh.c
index de9d60b..5ffd50b 100644
--- a/sys/net80211/ieee80211_mesh.c
+++ b/sys/net80211/ieee80211_mesh.c
@@ -217,7 +217,7 @@ mesh_rt_add_locked(struct ieee80211vap *vap,
IEEE80211_ADDR_COPY(rt->rt_dest, dest);
rt->rt_priv = (void *)ALIGN(&rt[1]);
mtx_init(&rt->rt_lock, "MBSS_RT", "802.11s route entry", MTX_DEF);
- callout_init(&rt->rt_discovery, CALLOUT_MPSAFE);
+ callout_init(&rt->rt_discovery, 1);
rt->rt_updtime = ticks; /* create time */
TAILQ_INSERT_TAIL(&ms->ms_routes, rt, rt_next);
}
@@ -679,8 +679,8 @@ mesh_vattach(struct ieee80211vap *vap)
TAILQ_INIT(&ms->ms_known_gates);
TAILQ_INIT(&ms->ms_routes);
mtx_init(&ms->ms_rt_lock, "MBSS", "802.11s routing table", MTX_DEF);
- callout_init(&ms->ms_cleantimer, CALLOUT_MPSAFE);
- callout_init(&ms->ms_gatetimer, CALLOUT_MPSAFE);
+ callout_init(&ms->ms_cleantimer, 1);
+ callout_init(&ms->ms_gatetimer, 1);
ms->ms_gateseq = 0;
mesh_select_proto_metric(vap, "AIRTIME");
KASSERT(ms->ms_pmetric, ("ms_pmetric == NULL"));
@@ -1906,7 +1906,7 @@ mesh_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0, int subtype,
ieee80211_probe_curchan(vap, 1);
ic->ic_flags_ext &= ~IEEE80211_FEXT_PROBECHAN;
}
- ieee80211_add_scan(vap, &scan, wh,
+ ieee80211_add_scan(vap, ic->ic_curchan, &scan, wh,
subtype, rssi, nf);
return;
}
@@ -3384,8 +3384,8 @@ void
ieee80211_mesh_node_init(struct ieee80211vap *vap, struct ieee80211_node *ni)
{
ni->ni_flags |= IEEE80211_NODE_QOS;
- callout_init(&ni->ni_mltimer, CALLOUT_MPSAFE);
- callout_init(&ni->ni_mlhtimer, CALLOUT_MPSAFE);
+ callout_init(&ni->ni_mltimer, 1);
+ callout_init(&ni->ni_mlhtimer, 1);
}
/*
diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c
index 9fc4cd4..fbb8e93 100644
--- a/sys/net80211/ieee80211_node.c
+++ b/sys/net80211/ieee80211_node.c
@@ -93,6 +93,8 @@ static void node_getmimoinfo(const struct ieee80211_node *,
static void _ieee80211_free_node(struct ieee80211_node *);
+static void node_reclaim(struct ieee80211_node_table *nt,
+ struct ieee80211_node *ni);
static void ieee80211_node_table_init(struct ieee80211com *ic,
struct ieee80211_node_table *nt, const char *name,
int inact, int keymaxix);
@@ -112,7 +114,7 @@ ieee80211_node_attach(struct ieee80211com *ic)
"802.11 staging q");
ieee80211_node_table_init(ic, &ic->ic_sta, "station",
IEEE80211_INACT_INIT, ic->ic_max_keyix);
- callout_init(&ic->ic_inact, CALLOUT_MPSAFE);
+ callout_init(&ic->ic_inact, 1);
callout_reset(&ic->ic_inact, IEEE80211_INACT_WAIT*hz,
ieee80211_node_timeout, ic);
@@ -719,9 +721,15 @@ ieee80211_sta_join1(struct ieee80211_node *selbs)
IEEE80211_ADDR_EQ(obss->ni_macaddr, selbs->ni_macaddr));
vap->iv_bss = selbs; /* NB: caller assumed to bump refcnt */
if (obss != NULL) {
+ struct ieee80211_node_table *nt = obss->ni_table;
+
copy_bss(selbs, obss);
ieee80211_node_decref(obss); /* iv_bss reference */
- ieee80211_free_node(obss); /* station table reference */
+
+ IEEE80211_NODE_LOCK(nt);
+ node_reclaim(nt, obss); /* station table reference */
+ IEEE80211_NODE_UNLOCK(nt);
+
obss = NULL; /* NB: guard against later use */
}
@@ -871,7 +879,7 @@ ieee80211_sta_leave(struct ieee80211_node *ni)
void
ieee80211_node_deauth(struct ieee80211_node *ni, int reason)
{
- /* NB: bump the refcnt to be sure temporay nodes are not reclaimed */
+ /* NB: bump the refcnt to be sure temporary nodes are not reclaimed */
ieee80211_ref_node(ni);
if (ni->ni_associd != 0)
IEEE80211_SEND_MGMT(ni, IEEE80211_FC0_SUBTYPE_DEAUTH, reason);
@@ -1749,6 +1757,28 @@ _ieee80211_free_node(struct ieee80211_node *ni)
ni->ni_ic->ic_node_free(ni);
}
+/*
+ * Clear any entry in the unicast key mapping table.
+ */
+static int
+node_clear_keyixmap(struct ieee80211_node_table *nt, struct ieee80211_node *ni)
+{
+ ieee80211_keyix keyix;
+
+ keyix = ni->ni_ucastkey.wk_rxkeyix;
+ if (nt->nt_keyixmap != NULL && keyix < nt->nt_keyixmax &&
+ nt->nt_keyixmap[keyix] == ni) {
+ IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE,
+ "%s: %p<%s> clear key map entry %u\n",
+ __func__, ni, ether_sprintf(ni->ni_macaddr), keyix);
+ nt->nt_keyixmap[keyix] = NULL;
+ ieee80211_node_decref(ni);
+ return 1;
+ }
+
+ return 0;
+}
+
void
#ifdef IEEE80211_DEBUG_REFCNT
ieee80211_free_node_debug(struct ieee80211_node *ni, const char *func, int line)
@@ -1770,24 +1800,9 @@ ieee80211_free_node(struct ieee80211_node *ni)
* Last reference, reclaim state.
*/
_ieee80211_free_node(ni);
- } else if (ieee80211_node_refcnt(ni) == 1 &&
- nt->nt_keyixmap != NULL) {
- ieee80211_keyix keyix;
- /*
- * Check for a last reference in the key mapping table.
- */
- keyix = ni->ni_ucastkey.wk_rxkeyix;
- if (keyix < nt->nt_keyixmax &&
- nt->nt_keyixmap[keyix] == ni) {
- IEEE80211_DPRINTF(ni->ni_vap,
- IEEE80211_MSG_NODE,
- "%s: %p<%s> clear key map entry", __func__,
- ni, ether_sprintf(ni->ni_macaddr));
- nt->nt_keyixmap[keyix] = NULL;
- ieee80211_node_decref(ni); /* XXX needed? */
+ } else if (ieee80211_node_refcnt(ni) == 1)
+ if (node_clear_keyixmap(nt, ni))
_ieee80211_free_node(ni);
- }
- }
IEEE80211_NODE_UNLOCK(nt);
} else {
if (ieee80211_node_dectestref(ni))
@@ -1855,7 +1870,6 @@ ieee80211_node_delucastkey(struct ieee80211_node *ni)
static void
node_reclaim(struct ieee80211_node_table *nt, struct ieee80211_node *ni)
{
- ieee80211_keyix keyix;
IEEE80211_NODE_LOCK_ASSERT(nt);
@@ -1870,15 +1884,7 @@ node_reclaim(struct ieee80211_node_table *nt, struct ieee80211_node *ni)
* table. We cannot depend on the mapping table entry
* being cleared because the node may not be free'd.
*/
- keyix = ni->ni_ucastkey.wk_rxkeyix;
- if (nt->nt_keyixmap != NULL && keyix < nt->nt_keyixmax &&
- nt->nt_keyixmap[keyix] == ni) {
- IEEE80211_DPRINTF(ni->ni_vap, IEEE80211_MSG_NODE,
- "%s: %p<%s> clear key map entry %u\n",
- __func__, ni, ether_sprintf(ni->ni_macaddr), keyix);
- nt->nt_keyixmap[keyix] = NULL;
- ieee80211_node_decref(ni); /* NB: don't need free */
- }
+ (void)node_clear_keyixmap(nt, ni);
if (!ieee80211_node_dectestref(ni)) {
/*
* Other references are present, just remove the
diff --git a/sys/net80211/ieee80211_output.c b/sys/net80211/ieee80211_output.c
index 5647c03..2158bee 100644
--- a/sys/net80211/ieee80211_output.c
+++ b/sys/net80211/ieee80211_output.c
@@ -132,7 +132,7 @@ ieee80211_vap_pkt_send_dest(struct ieee80211vap *vap, struct mbuf *m,
{
struct ieee80211com *ic = vap->iv_ic;
struct ifnet *ifp = vap->iv_ifp;
- int error;
+ int error, len, mcast;
if ((ni->ni_flags & IEEE80211_NODE_PWR_MGT) &&
(m->m_flags & M_PWR_SAV) == 0) {
@@ -142,7 +142,8 @@ ieee80211_vap_pkt_send_dest(struct ieee80211vap *vap, struct mbuf *m,
* the frame back when the time is right.
* XXX lose WDS vap linkage?
*/
- (void) ieee80211_pwrsave(ni, m);
+ if (ieee80211_pwrsave(ni, m) != 0)
+ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
ieee80211_free_node(ni);
/*
@@ -171,6 +172,8 @@ ieee80211_vap_pkt_send_dest(struct ieee80211vap *vap, struct mbuf *m,
* interface it (might have been) received on.
*/
m->m_pkthdr.rcvif = (void *)ni;
+ mcast = (m->m_flags & (M_MCAST | M_BCAST)) ? 1: 0;
+ len = m->m_pkthdr.len;
BPF_MTAP(ifp, m); /* 802.3 tx */
@@ -236,7 +239,7 @@ ieee80211_vap_pkt_send_dest(struct ieee80211vap *vap, struct mbuf *m,
/* NB: stat+msg handled in ieee80211_encap */
IEEE80211_TX_UNLOCK(ic);
ieee80211_free_node(ni);
- /* XXX better status? */
+ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
return (ENOBUFS);
}
}
@@ -250,8 +253,11 @@ ieee80211_vap_pkt_send_dest(struct ieee80211vap *vap, struct mbuf *m,
if (error != 0) {
/* NB: IFQ_HANDOFF reclaims mbuf */
ieee80211_free_node(ni);
+ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
} else {
if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ if_inc_counter(ifp, IFCOUNTER_OMCASTS, mcast);
+ if_inc_counter(ifp, IFCOUNTER_OBYTES, len);
}
ic->ic_lastdata = ticks;
@@ -315,6 +321,7 @@ ieee80211_start_pkt(struct ieee80211vap *vap, struct mbuf *m)
eh->ether_dhost, "mcast", "%s", "on DWDS");
vap->iv_stats.is_dwds_mcast++;
m_freem(m);
+ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
/* XXX better status? */
return (ENOBUFS);
}
@@ -397,7 +404,8 @@ ieee80211_start_pkt(struct ieee80211vap *vap, struct mbuf *m)
* for transmit.
*/
ic->ic_lastdata = ticks;
- (void) ieee80211_pwrsave(ni, m);
+ if (ieee80211_pwrsave(ni, m) != 0)
+ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
ieee80211_free_node(ni);
ieee80211_new_state(vap, IEEE80211_S_RUN, 0);
return (0);
@@ -429,9 +437,9 @@ ieee80211_vap_transmit(struct ifnet *ifp, struct mbuf *m)
IEEE80211_DPRINTF(vap, IEEE80211_MSG_OUTPUT,
"%s: ignore queue, parent %s not up+running\n",
__func__, parent->if_xname);
- /* XXX stat */
m_freem(m);
- return (EINVAL);
+ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ return (ENETDOWN);
}
/*
@@ -453,7 +461,8 @@ ieee80211_vap_transmit(struct ifnet *ifp, struct mbuf *m)
IEEE80211_UNLOCK(ic);
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
m_freem(m);
- return (EINVAL);
+ if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
+ return (ENETDOWN);
}
IEEE80211_UNLOCK(ic);
}
@@ -730,7 +739,12 @@ ieee80211_send_setup(
if (tid != IEEE80211_NONQOS_TID && IEEE80211_AMPDU_RUNNING(tap))
m->m_flags |= M_AMPDU_MPDU;
else {
- seqno = ni->ni_txseqs[tid]++;
+ if (IEEE80211_HAS_SEQ(type & IEEE80211_FC0_TYPE_MASK,
+ type & IEEE80211_FC0_SUBTYPE_MASK))
+ seqno = ni->ni_txseqs[tid]++;
+ else
+ seqno = 0;
+
*(uint16_t *)&wh->i_seq[0] =
htole16(seqno << IEEE80211_SEQ_SEQ_SHIFT);
M_SEQNO_SET(m, seqno);
diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c
index 2f84769..1f09616 100644
--- a/sys/net80211/ieee80211_proto.c
+++ b/sys/net80211/ieee80211_proto.c
@@ -195,7 +195,7 @@ ieee80211_proto_vattach(struct ieee80211vap *vap)
vap->iv_fragthreshold = IEEE80211_FRAG_DEFAULT;
vap->iv_bmiss_max = IEEE80211_BMISS_MAX;
callout_init_mtx(&vap->iv_swbmiss, IEEE80211_LOCK_OBJ(ic), 0);
- callout_init(&vap->iv_mgtsend, CALLOUT_MPSAFE);
+ callout_init(&vap->iv_mgtsend, 1);
TASK_INIT(&vap->iv_nstate_task, 0, ieee80211_newstate_cb, vap);
TASK_INIT(&vap->iv_swbmiss_task, 0, beacon_swmiss, vap);
/*
diff --git a/sys/net80211/ieee80211_scan.c b/sys/net80211/ieee80211_scan.c
index f42ddc0..6c950d6 100644
--- a/sys/net80211/ieee80211_scan.c
+++ b/sys/net80211/ieee80211_scan.c
@@ -309,80 +309,6 @@ ieee80211_scan_copy_ssid(struct ieee80211vap *vap, struct ieee80211_scan_state *
* Start a scan unless one is already going.
*/
int
-ieee80211_start_scan_locked(const struct ieee80211_scanner *scan,
- struct ieee80211vap *vap, int flags, u_int duration,
- u_int mindwell, u_int maxdwell,
- u_int nssid, const struct ieee80211_scan_ssid ssids[])
-{
- struct ieee80211com *ic = vap->iv_ic;
- struct ieee80211_scan_state *ss = ic->ic_scan;
-
- IEEE80211_LOCK_ASSERT(ic);
-
- if (ic->ic_flags & IEEE80211_F_CSAPENDING) {
- IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
- "%s: scan inhibited by pending channel change\n", __func__);
- } else if ((ic->ic_flags & IEEE80211_F_SCAN) == 0) {
- IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
- "%s: %s scan, duration %u mindwell %u maxdwell %u, desired mode %s, %s%s%s%s%s%s\n"
- , __func__
- , flags & IEEE80211_SCAN_ACTIVE ? "active" : "passive"
- , duration, mindwell, maxdwell
- , ieee80211_phymode_name[vap->iv_des_mode]
- , flags & IEEE80211_SCAN_FLUSH ? "flush" : "append"
- , flags & IEEE80211_SCAN_NOPICK ? ", nopick" : ""
- , flags & IEEE80211_SCAN_NOJOIN ? ", nojoin" : ""
- , flags & IEEE80211_SCAN_NOBCAST ? ", nobcast" : ""
- , flags & IEEE80211_SCAN_PICK1ST ? ", pick1st" : ""
- , flags & IEEE80211_SCAN_ONCE ? ", once" : ""
- );
-
- ieee80211_scan_update_locked(vap, scan);
- if (ss->ss_ops != NULL) {
- if ((flags & IEEE80211_SCAN_NOSSID) == 0)
- ieee80211_scan_copy_ssid(vap, ss, nssid, ssids);
-
- /* NB: top 4 bits for internal use */
- ss->ss_flags = flags & 0xfff;
- if (ss->ss_flags & IEEE80211_SCAN_ACTIVE)
- vap->iv_stats.is_scan_active++;
- else
- vap->iv_stats.is_scan_passive++;
- if (flags & IEEE80211_SCAN_FLUSH)
- ss->ss_ops->scan_flush(ss);
- if (flags & IEEE80211_SCAN_BGSCAN)
- ic->ic_flags_ext |= IEEE80211_FEXT_BGSCAN;
-
- /* Set duration for this particular scan */
- ieee80211_swscan_set_scan_duration(vap, duration);
-
- ss->ss_next = 0;
- ss->ss_mindwell = mindwell;
- ss->ss_maxdwell = maxdwell;
- /* NB: scan_start must be before the scan runtask */
- ss->ss_ops->scan_start(ss, vap);
-#ifdef IEEE80211_DEBUG
- if (ieee80211_msg_scan(vap))
- ieee80211_scan_dump(ss);
-#endif /* IEEE80211_DEBUG */
- ic->ic_flags |= IEEE80211_F_SCAN;
-
- /* Start scan task */
- ieee80211_swscan_run_scan_task(vap);
- }
- return 1;
- } else {
- IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
- "%s: %s scan already in progress\n", __func__,
- ss->ss_flags & IEEE80211_SCAN_ACTIVE ? "active" : "passive");
- }
- return 0;
-}
-
-/*
- * Start a scan unless one is already going.
- */
-int
ieee80211_start_scan(struct ieee80211vap *vap, int flags,
u_int duration, u_int mindwell, u_int maxdwell,
u_int nssid, const struct ieee80211_scan_ssid ssids[])
@@ -636,12 +562,14 @@ ieee80211_scan_dump_probe_beacon(uint8_t subtype, int isnew,
*/
void
ieee80211_add_scan(struct ieee80211vap *vap,
+ struct ieee80211_channel *curchan,
const struct ieee80211_scanparams *sp,
const struct ieee80211_frame *wh,
int subtype, int rssi, int noise)
{
- return (ieee80211_swscan_add_scan(vap, sp, wh, subtype, rssi, noise));
+ return (ieee80211_swscan_add_scan(vap, curchan, sp, wh, subtype,
+ rssi, noise));
}
/*
diff --git a/sys/net80211/ieee80211_scan.h b/sys/net80211/ieee80211_scan.h
index 9c2575a..8b54186 100644
--- a/sys/net80211/ieee80211_scan.h
+++ b/sys/net80211/ieee80211_scan.h
@@ -148,6 +148,7 @@ struct ieee80211_channel *ieee80211_scan_pickchannel(struct ieee80211com *, int)
struct ieee80211_scanparams;
void ieee80211_add_scan(struct ieee80211vap *,
+ struct ieee80211_channel *,
const struct ieee80211_scanparams *,
const struct ieee80211_frame *,
int subtype, int rssi, int noise);
@@ -273,6 +274,7 @@ struct ieee80211_scanner {
struct ieee80211_scan_state *, int);
/* add an entry to the cache */
int (*scan_add)(struct ieee80211_scan_state *,
+ struct ieee80211_channel *,
const struct ieee80211_scanparams *,
const struct ieee80211_frame *,
int subtype, int rssi, int noise);
@@ -307,10 +309,6 @@ void ieee80211_scan_copy_ssid(struct ieee80211vap *vap,
void ieee80211_scan_dump_probe_beacon(uint8_t subtype, int isnew,
const uint8_t mac[IEEE80211_ADDR_LEN],
const struct ieee80211_scanparams *sp, int rssi);
-int ieee80211_start_scan_locked(const struct ieee80211_scanner *scan,
- struct ieee80211vap *vap, int flags, u_int duration,
- u_int mindwell, u_int maxdwell,
- u_int nssid, const struct ieee80211_scan_ssid ssids[]);
void ieee80211_scan_dump(struct ieee80211_scan_state *ss);
#endif /* _NET80211_IEEE80211_SCAN_H_ */
diff --git a/sys/net80211/ieee80211_scan_sta.c b/sys/net80211/ieee80211_scan_sta.c
index 1e87e35..1fb45b0 100644
--- a/sys/net80211/ieee80211_scan_sta.c
+++ b/sys/net80211/ieee80211_scan_sta.c
@@ -228,6 +228,7 @@ sta_flush_table(struct sta_table *st)
*/
static int
sta_add(struct ieee80211_scan_state *ss,
+ struct ieee80211_channel *curchan,
const struct ieee80211_scanparams *sp,
const struct ieee80211_frame *wh,
int subtype, int rssi, int noise)
@@ -310,15 +311,15 @@ found:
* IEEE80211_BPARSE_OFFCHAN.
*/
c = ieee80211_find_channel_byieee(ic, sp->chan,
- ic->ic_curchan->ic_flags);
+ curchan->ic_flags);
if (c != NULL) {
ise->se_chan = c;
} else if (ise->se_chan == NULL) {
/* should not happen, pick something */
- ise->se_chan = ic->ic_curchan;
+ ise->se_chan = curchan;
}
} else
- ise->se_chan = ic->ic_curchan;
+ ise->se_chan = curchan;
if (IEEE80211_IS_CHAN_HT(ise->se_chan) && sp->htcap == NULL) {
/* Demote legacy networks to a non-HT channel. */
c = ieee80211_find_channel(ic, ise->se_chan->ic_freq,
diff --git a/sys/net80211/ieee80211_scan_sw.c b/sys/net80211/ieee80211_scan_sw.c
index bce92a4..70b4673 100644
--- a/sys/net80211/ieee80211_scan_sw.c
+++ b/sys/net80211/ieee80211_scan_sw.c
@@ -211,6 +211,81 @@ ieee80211_swscan_run_scan_task(struct ieee80211vap *vap)
/*
* Start a scan unless one is already going.
+ */
+static int
+ieee80211_swscan_start_scan_locked(const struct ieee80211_scanner *scan,
+ struct ieee80211vap *vap, int flags, u_int duration,
+ u_int mindwell, u_int maxdwell,
+ u_int nssid, const struct ieee80211_scan_ssid ssids[])
+{
+ struct ieee80211com *ic = vap->iv_ic;
+ struct ieee80211_scan_state *ss = ic->ic_scan;
+
+ IEEE80211_LOCK_ASSERT(ic);
+
+ if (ic->ic_flags & IEEE80211_F_CSAPENDING) {
+ IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
+ "%s: scan inhibited by pending channel change\n", __func__);
+ } else if ((ic->ic_flags & IEEE80211_F_SCAN) == 0) {
+ IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
+ "%s: %s scan, duration %u mindwell %u maxdwell %u, desired mode %s, %s%s%s%s%s%s\n"
+ , __func__
+ , flags & IEEE80211_SCAN_ACTIVE ? "active" : "passive"
+ , duration, mindwell, maxdwell
+ , ieee80211_phymode_name[vap->iv_des_mode]
+ , flags & IEEE80211_SCAN_FLUSH ? "flush" : "append"
+ , flags & IEEE80211_SCAN_NOPICK ? ", nopick" : ""
+ , flags & IEEE80211_SCAN_NOJOIN ? ", nojoin" : ""
+ , flags & IEEE80211_SCAN_NOBCAST ? ", nobcast" : ""
+ , flags & IEEE80211_SCAN_PICK1ST ? ", pick1st" : ""
+ , flags & IEEE80211_SCAN_ONCE ? ", once" : ""
+ );
+
+ ieee80211_scan_update_locked(vap, scan);
+ if (ss->ss_ops != NULL) {
+ if ((flags & IEEE80211_SCAN_NOSSID) == 0)
+ ieee80211_scan_copy_ssid(vap, ss, nssid, ssids);
+
+ /* NB: top 4 bits for internal use */
+ ss->ss_flags = flags & 0xfff;
+ if (ss->ss_flags & IEEE80211_SCAN_ACTIVE)
+ vap->iv_stats.is_scan_active++;
+ else
+ vap->iv_stats.is_scan_passive++;
+ if (flags & IEEE80211_SCAN_FLUSH)
+ ss->ss_ops->scan_flush(ss);
+ if (flags & IEEE80211_SCAN_BGSCAN)
+ ic->ic_flags_ext |= IEEE80211_FEXT_BGSCAN;
+
+ /* Set duration for this particular scan */
+ ieee80211_swscan_set_scan_duration(vap, duration);
+
+ ss->ss_next = 0;
+ ss->ss_mindwell = mindwell;
+ ss->ss_maxdwell = maxdwell;
+ /* NB: scan_start must be before the scan runtask */
+ ss->ss_ops->scan_start(ss, vap);
+#ifdef IEEE80211_DEBUG
+ if (ieee80211_msg_scan(vap))
+ ieee80211_scan_dump(ss);
+#endif /* IEEE80211_DEBUG */
+ ic->ic_flags |= IEEE80211_F_SCAN;
+
+ /* Start scan task */
+ ieee80211_swscan_run_scan_task(vap);
+ }
+ return 1;
+ } else {
+ IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN,
+ "%s: %s scan already in progress\n", __func__,
+ ss->ss_flags & IEEE80211_SCAN_ACTIVE ? "active" : "passive");
+ }
+ return 0;
+}
+
+
+/*
+ * Start a scan unless one is already going.
*
* Called without the comlock held; grab the comlock as appropriate.
*/
@@ -226,7 +301,7 @@ ieee80211_swscan_start_scan(const struct ieee80211_scanner *scan,
IEEE80211_UNLOCK_ASSERT(ic);
IEEE80211_LOCK(ic);
- result = ieee80211_start_scan_locked(scan, vap, flags, duration,
+ result = ieee80211_swscan_start_scan_locked(scan, vap, flags, duration,
mindwell, maxdwell, nssid, ssids);
IEEE80211_UNLOCK(ic);
@@ -289,7 +364,7 @@ ieee80211_swscan_check_scan(const struct ieee80211_scanner *scan,
}
}
}
- result = ieee80211_start_scan_locked(scan, vap, flags, duration,
+ result = ieee80211_swscan_start_scan_locked(scan, vap, flags, duration,
mindwell, maxdwell, nssid, ssids);
return result;
@@ -825,6 +900,7 @@ done:
*/
void
ieee80211_swscan_add_scan(struct ieee80211vap *vap,
+ struct ieee80211_channel *curchan,
const struct ieee80211_scanparams *sp,
const struct ieee80211_frame *wh,
int subtype, int rssi, int noise)
@@ -847,7 +923,7 @@ ieee80211_swscan_add_scan(struct ieee80211vap *vap,
ieee80211_scan_dump_probe_beacon(subtype, 1, wh->i_addr2, sp, rssi);
#endif
if (ss->ss_ops != NULL &&
- ss->ss_ops->scan_add(ss, sp, wh, subtype, rssi, noise)) {
+ ss->ss_ops->scan_add(ss, curchan, sp, wh, subtype, rssi, noise)) {
/*
* If we've reached the min dwell time terminate
* the timer so we'll switch to the next channel.
diff --git a/sys/net80211/ieee80211_scan_sw.h b/sys/net80211/ieee80211_scan_sw.h
index 95fe482..7bb0cc3 100644
--- a/sys/net80211/ieee80211_scan_sw.h
+++ b/sys/net80211/ieee80211_scan_sw.h
@@ -53,6 +53,7 @@ extern void ieee80211_swscan_scan_done(struct ieee80211vap *vap);
extern void ieee80211_swscan_probe_curchan(struct ieee80211vap *vap,
int force);
extern void ieee80211_swscan_add_scan(struct ieee80211vap *vap,
+ struct ieee80211_channel *curchan,
const struct ieee80211_scanparams *sp,
const struct ieee80211_frame *wh,
int subtype, int rssi, int noise);
diff --git a/sys/net80211/ieee80211_sta.c b/sys/net80211/ieee80211_sta.c
index c3c2bc9..267ad11 100644
--- a/sys/net80211/ieee80211_sta.c
+++ b/sys/net80211/ieee80211_sta.c
@@ -527,7 +527,6 @@ doprint(struct ieee80211vap *vap, int subtype)
static int
sta_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf)
{
-#define HAS_SEQ(type) ((type & 0x4) == 0)
struct ieee80211vap *vap = ni->ni_vap;
struct ieee80211com *ic = ni->ni_ic;
struct ifnet *ifp = vap->iv_ifp;
@@ -623,7 +622,8 @@ sta_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf)
IEEE80211_RSSI_LPF(ni->ni_avgrssi, rssi);
ni->ni_noise = nf;
- if (HAS_SEQ(type) && !IEEE80211_IS_MULTICAST(wh->i_addr1)) {
+ if ( IEEE80211_HAS_SEQ(type, subtype) &&
+ !IEEE80211_IS_MULTICAST(wh->i_addr1)) {
uint8_t tid = ieee80211_gettid(wh);
if (IEEE80211_QOS_HAS_SEQ(wh) &&
TID_TO_WME_AC(tid) >= WME_AC_VI)
@@ -1484,8 +1484,8 @@ sta_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0,
* our ap.
*/
if (ic->ic_flags & IEEE80211_F_SCAN) {
- ieee80211_add_scan(vap, &scan, wh,
- subtype, rssi, nf);
+ ieee80211_add_scan(vap, ic->ic_curchan,
+ &scan, wh, subtype, rssi, nf);
} else if (contbgscan(vap)) {
ieee80211_bg_scan(vap, 0);
} else if (startbgscan(vap)) {
@@ -1529,7 +1529,8 @@ sta_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m0,
ieee80211_probe_curchan(vap, 1);
ic->ic_flags_ext &= ~IEEE80211_FEXT_PROBECHAN;
}
- ieee80211_add_scan(vap, &scan, wh, subtype, rssi, nf);
+ ieee80211_add_scan(vap, ic->ic_curchan, &scan, wh,
+ subtype, rssi, nf);
return;
}
break;
diff --git a/sys/net80211/ieee80211_wds.c b/sys/net80211/ieee80211_wds.c
index ec1bd85..fc77259 100644
--- a/sys/net80211/ieee80211_wds.c
+++ b/sys/net80211/ieee80211_wds.c
@@ -301,8 +301,12 @@ ieee80211_dwds_mcast(struct ieee80211vap *vap0, struct mbuf *m)
/* NB: IFQ_HANDOFF reclaims mbuf */
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
ieee80211_free_node(ni);
- } else
+ } else {
if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
+ if_inc_counter(ifp, IFCOUNTER_OMCASTS, 1);
+ if_inc_counter(ifp, IFCOUNTER_OBYTES,
+ m->m_pkthdr.len);
+ }
}
}
@@ -406,7 +410,6 @@ wds_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
static int
wds_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf)
{
-#define HAS_SEQ(type) ((type & 0x4) == 0)
struct ieee80211vap *vap = ni->ni_vap;
struct ieee80211com *ic = ni->ni_ic;
struct ifnet *ifp = vap->iv_ifp;
@@ -488,7 +491,7 @@ wds_input(struct ieee80211_node *ni, struct mbuf *m, int rssi, int nf)
}
IEEE80211_RSSI_LPF(ni->ni_avgrssi, rssi);
ni->ni_noise = nf;
- if (HAS_SEQ(type)) {
+ if (IEEE80211_HAS_SEQ(type, subtype)) {
uint8_t tid = ieee80211_gettid(wh);
if (IEEE80211_QOS_HAS_SEQ(wh) &&
TID_TO_WME_AC(tid) >= WME_AC_VI)
diff --git a/sys/netgraph/netflow/ng_netflow.c b/sys/netgraph/netflow/ng_netflow.c
index 7b23e61..b5a82a4 100644
--- a/sys/netgraph/netflow/ng_netflow.c
+++ b/sys/netgraph/netflow/ng_netflow.c
@@ -259,7 +259,7 @@ ng_netflow_constructor(node_p node)
priv->ifaces[i].info.conf = NG_NETFLOW_CONF_INGRESS;
/* Initialize callout handle */
- callout_init(&priv->exp_callout, CALLOUT_MPSAFE);
+ callout_init(&priv->exp_callout, 1);
/* Allocate memory and set up flow cache */
ng_netflow_cache_init(priv);
diff --git a/sys/netgraph/netgraph.h b/sys/netgraph/netgraph.h
index dc008f4..9fc8986 100644
--- a/sys/netgraph/netgraph.h
+++ b/sys/netgraph/netgraph.h
@@ -1161,7 +1161,7 @@ int ng_send_fn2(node_p node, hook_p hook, item_p pitem, ng_item_fn2 *fn,
int ng_uncallout(struct callout *c, node_p node);
int ng_callout(struct callout *c, node_p node, hook_p hook, int ticks,
ng_item_fn *fn, void * arg1, int arg2);
-#define ng_callout_init(c) callout_init(c, CALLOUT_MPSAFE)
+#define ng_callout_init(c) callout_init(c, 1)
/* Flags for netgraph functions. */
#define NG_NOFLAGS 0x00000000 /* no special options */
diff --git a/sys/netinet/in_gif.c b/sys/netinet/in_gif.c
index cd412ad..e634987 100644
--- a/sys/netinet/in_gif.c
+++ b/sys/netinet/in_gif.c
@@ -168,13 +168,19 @@ in_gif_input(struct mbuf **mp, int *offp, int proto)
static int
gif_validate4(const struct ip *ip, struct gif_softc *sc, struct ifnet *ifp)
{
+ int ret;
GIF_RLOCK_ASSERT(sc);
/* check for address match */
- if (sc->gif_iphdr->ip_src.s_addr != ip->ip_dst.s_addr ||
- sc->gif_iphdr->ip_dst.s_addr != ip->ip_src.s_addr)
+ if (sc->gif_iphdr->ip_src.s_addr != ip->ip_dst.s_addr)
return (0);
+ ret = 32;
+ if (sc->gif_iphdr->ip_dst.s_addr != ip->ip_src.s_addr) {
+ if ((sc->gif_options & GIF_IGNORE_SOURCE) == 0)
+ return (0);
+ } else
+ ret += 32;
/* martian filters on outer source - NOT done in ip_input! */
if (IN_MULTICAST(ntohl(ip->ip_src.s_addr)))
@@ -205,7 +211,7 @@ gif_validate4(const struct ip *ip, struct gif_softc *sc, struct ifnet *ifp)
}
RTFREE_LOCKED(rt);
}
- return (32 * 2);
+ return (ret);
}
/*
diff --git a/sys/netinet/in_kdtrace.c b/sys/netinet/in_kdtrace.c
index d37e3c0..edcc853 100644
--- a/sys/netinet/in_kdtrace.c
+++ b/sys/netinet/in_kdtrace.c
@@ -102,6 +102,9 @@ SDT_PROBE_DEFINE5_XLATE(tcp, , , send,
"struct tcpcb *", "tcpsinfo_t *" ,
"struct tcphdr *", "tcpinfo_t *");
+SDT_PROBE_DEFINE1_XLATE(tcp, , , siftr,
+ "struct pkt_node *", "siftrinfo_t *");
+
SDT_PROBE_DEFINE6_XLATE(tcp, , , state__change,
"void *", "void *",
"struct tcpcb *", "csinfo_t *",
diff --git a/sys/netinet/in_kdtrace.h b/sys/netinet/in_kdtrace.h
index 07b3e3a..c0511d0 100644
--- a/sys/netinet/in_kdtrace.h
+++ b/sys/netinet/in_kdtrace.h
@@ -32,6 +32,8 @@
SDT_PROBE6(ip, , , probe, arg0, arg1, arg2, arg3, arg4, arg5)
#define UDP_PROBE(probe, arg0, arg1, arg2, arg3, arg4) \
SDT_PROBE5(udp, , , probe, arg0, arg1, arg2, arg3, arg4)
+#define TCP_PROBE1(probe, arg0) \
+ SDT_PROBE1(tcp, , , probe, arg0)
#define TCP_PROBE5(probe, arg0, arg1, arg2, arg3, arg4) \
SDT_PROBE5(tcp, , , probe, arg0, arg1, arg2, arg3, arg4)
#define TCP_PROBE6(probe, arg0, arg1, arg2, arg3, arg4, arg5) \
@@ -51,6 +53,7 @@ SDT_PROBE_DECLARE(tcp, , , connect__refused);
SDT_PROBE_DECLARE(tcp, , , connect__request);
SDT_PROBE_DECLARE(tcp, , , receive);
SDT_PROBE_DECLARE(tcp, , , send);
+SDT_PROBE_DECLARE(tcp, , , siftr);
SDT_PROBE_DECLARE(tcp, , , state__change);
SDT_PROBE_DECLARE(udp, , , receive);
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index f8f2905..bc48e10 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -2249,7 +2249,7 @@ ipport_tick_init(const void *unused __unused)
{
/* Start ipport_tick. */
- callout_init(&ipport_tick_callout, CALLOUT_MPSAFE);
+ callout_init(&ipport_tick_callout, 1);
callout_reset(&ipport_tick_callout, 1, ipport_tick, NULL);
EVENTHANDLER_REGISTER(shutdown_pre_sync, ip_fini, NULL,
SHUTDOWN_PRI_DEFAULT);
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index a71e91c..ffa88ae 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -2816,9 +2816,9 @@ vnet_mroute_init(const void *unused __unused)
MALLOC(V_nexpire, u_char *, mfchashsize, M_MRTABLE, M_WAITOK|M_ZERO);
bzero(V_bw_meter_timers, sizeof(V_bw_meter_timers));
- callout_init(&V_expire_upcalls_ch, CALLOUT_MPSAFE);
- callout_init(&V_bw_upcalls_ch, CALLOUT_MPSAFE);
- callout_init(&V_bw_meter_ch, CALLOUT_MPSAFE);
+ callout_init(&V_expire_upcalls_ch, 1);
+ callout_init(&V_bw_upcalls_ch, 1);
+ callout_init(&V_bw_meter_ch, 1);
}
VNET_SYSINIT(vnet_mroute_init, SI_SUB_PSEUDO, SI_ORDER_ANY, vnet_mroute_init,
diff --git a/sys/netinet/sctp_input.c b/sys/netinet/sctp_input.c
index 4fab986..048dfd3 100644
--- a/sys/netinet/sctp_input.c
+++ b/sys/netinet/sctp_input.c
@@ -2325,12 +2325,13 @@ sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset,
sctp_is_feature_on(inp, SCTP_PCB_FLAGS_AUTOCLOSE)) {
sctp_timer_start(SCTP_TIMER_TYPE_AUTOCLOSE, inp, stcb, NULL);
}
- /* calculate the RTT */
(void)SCTP_GETTIME_TIMEVAL(&stcb->asoc.time_entered);
if ((netp) && (*netp)) {
+ /* calculate the RTT and set the encaps port */
(*netp)->RTO = sctp_calculate_rto(stcb, asoc, *netp,
&cookie->time_entered, sctp_align_unsafe_makecopy,
SCTP_RTT_FROM_NON_DATA);
+ (*netp)->port = port;
}
/* respond with a COOKIE-ACK */
sctp_send_cookie_ack(stcb);
diff --git a/sys/netinet/siftr.c b/sys/netinet/siftr.c
index 2cd58ad..6b31d7b 100644
--- a/sys/netinet/siftr.c
+++ b/sys/netinet/siftr.c
@@ -75,6 +75,7 @@ __FBSDID("$FreeBSD$");
#include <sys/pcpu.h>
#include <sys/proc.h>
#include <sys/sbuf.h>
+#include <sys/sdt.h>
#include <sys/smp.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
@@ -86,6 +87,7 @@ __FBSDID("$FreeBSD$");
#include <net/pfil.h>
#include <netinet/in.h>
+#include <netinet/in_kdtrace.h>
#include <netinet/in_pcb.h>
#include <netinet/in_systm.h>
#include <netinet/in_var.h>
@@ -811,6 +813,8 @@ siftr_siftdata(struct pkt_node *pn, struct inpcb *inp, struct tcpcb *tp,
* maximum pps throughput processing when SIFTR is loaded and enabled.
*/
microtime(&pn->tval);
+ TCP_PROBE1(siftr, &pn);
+
}
diff --git a/sys/netinet/tcp_hostcache.c b/sys/netinet/tcp_hostcache.c
index ca13f27..a492540 100644
--- a/sys/netinet/tcp_hostcache.c
+++ b/sys/netinet/tcp_hostcache.c
@@ -117,6 +117,7 @@ static VNET_DEFINE(struct callout, tcp_hc_callout);
static struct hc_metrics *tcp_hc_lookup(struct in_conninfo *);
static struct hc_metrics *tcp_hc_insert(struct in_conninfo *);
static int sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS);
+static int sysctl_tcp_hc_purgenow(SYSCTL_HANDLER_ARGS);
static void tcp_hc_purge_internal(int);
static void tcp_hc_purge(void *);
@@ -155,6 +156,9 @@ SYSCTL_PROC(_net_inet_tcp_hostcache, OID_AUTO, list,
CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_SKIP, 0, 0,
sysctl_tcp_hc_list, "A", "List of all hostcache entries");
+SYSCTL_PROC(_net_inet_tcp_hostcache, OID_AUTO, purgenow,
+ CTLTYPE_INT | CTLFLAG_RW, NULL, 0,
+ sysctl_tcp_hc_purgenow, "I", "Immediately purge all entries");
static MALLOC_DEFINE(M_HOSTCACHE, "hostcache", "TCP hostcache");
@@ -234,7 +238,7 @@ tcp_hc_init(void)
/*
* Set up periodic cache cleanup.
*/
- callout_init(&V_tcp_hc_callout, CALLOUT_MPSAFE);
+ callout_init(&V_tcp_hc_callout, 1);
callout_reset(&V_tcp_hc_callout, V_tcp_hostcache.prune * hz,
tcp_hc_purge, curvnet);
}
@@ -696,3 +700,24 @@ tcp_hc_purge(void *arg)
tcp_hc_purge, arg);
CURVNET_RESTORE();
}
+
+/*
+ * Expire and purge all entries in hostcache immediately.
+ */
+static int
+sysctl_tcp_hc_purgenow(SYSCTL_HANDLER_ARGS)
+{
+ int error, val;
+
+ val = 0;
+ error = sysctl_handle_int(oidp, &val, 0, req);
+ if (error || !req->newptr)
+ return (error);
+
+ tcp_hc_purge_internal(1);
+
+ callout_reset(&V_tcp_hc_callout, V_tcp_hostcache.prune * hz,
+ tcp_hc_purge, curvnet);
+
+ return (0);
+}
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index bd515ce..aaf227c 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1542,7 +1542,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
tcp_timer_activate(tp, TT_KEEP, TP_KEEPIDLE(tp));
/*
- * Unscale the window into a 32-bit value.
+ * Scale up the window into a 32-bit value.
* For the SYN_SENT state the scale is zero.
*/
tiwin = th->th_win << tp->snd_scale;
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index d75221c..757bcf2 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -791,11 +791,11 @@ tcp_newtcpcb(struct inpcb *inp)
V_tcp_mssdflt;
/* Set up our timeouts. */
- callout_init(&tp->t_timers->tt_rexmt, CALLOUT_MPSAFE);
- callout_init(&tp->t_timers->tt_persist, CALLOUT_MPSAFE);
- callout_init(&tp->t_timers->tt_keep, CALLOUT_MPSAFE);
- callout_init(&tp->t_timers->tt_2msl, CALLOUT_MPSAFE);
- callout_init(&tp->t_timers->tt_delack, CALLOUT_MPSAFE);
+ callout_init(&tp->t_timers->tt_rexmt, 1);
+ callout_init(&tp->t_timers->tt_persist, 1);
+ callout_init(&tp->t_timers->tt_keep, 1);
+ callout_init(&tp->t_timers->tt_2msl, 1);
+ callout_init(&tp->t_timers->tt_delack, 1);
if (V_tcp_do_rfc1323)
tp->t_flags = (TF_REQ_SCALE|TF_REQ_TSTMP);
diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c
index da48615..1ba74d8 100644
--- a/sys/netinet/tcp_timewait.c
+++ b/sys/netinet/tcp_timewait.c
@@ -251,6 +251,13 @@ tcp_twstart(struct tcpcb *tp)
}
}
+
+ /*
+ * For use only by DTrace. We do not reference the state
+ * after this point so modifying it in place is not a problem.
+ */
+ tcp_state_change(tp, TCPS_TIME_WAIT);
+
tw = uma_zalloc(V_tcptw_zone, M_NOWAIT);
if (tw == NULL) {
/*
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index be5106a..d2570c4 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -1997,18 +1997,9 @@ in6_if2idlen(struct ifnet *ifp)
{
switch (ifp->if_type) {
case IFT_ETHER: /* RFC2464 */
-#ifdef IFT_PROPVIRTUAL
case IFT_PROPVIRTUAL: /* XXX: no RFC. treat it as ether */
-#endif
-#ifdef IFT_L2VLAN
case IFT_L2VLAN: /* ditto */
-#endif
-#ifdef IFT_IEEE80211
case IFT_IEEE80211: /* ditto */
-#endif
-#ifdef IFT_MIP
- case IFT_MIP: /* ditto */
-#endif
case IFT_INFINIBAND:
return (64);
case IFT_FDDI: /* RFC2467 */
diff --git a/sys/netinet6/in6_gif.c b/sys/netinet6/in6_gif.c
index 3db4b4f..126890f 100644
--- a/sys/netinet6/in6_gif.c
+++ b/sys/netinet6/in6_gif.c
@@ -180,6 +180,7 @@ static int
gif_validate6(const struct ip6_hdr *ip6, struct gif_softc *sc,
struct ifnet *ifp)
{
+ int ret;
GIF_RLOCK_ASSERT(sc);
/*
@@ -187,9 +188,14 @@ gif_validate6(const struct ip6_hdr *ip6, struct gif_softc *sc,
* packet. We should compare the *source* address in our configuration
* and the *destination* address of the packet, and vice versa.
*/
- if (!IN6_ARE_ADDR_EQUAL(&sc->gif_ip6hdr->ip6_src, &ip6->ip6_dst) ||
- !IN6_ARE_ADDR_EQUAL(&sc->gif_ip6hdr->ip6_dst, &ip6->ip6_src))
+ if (!IN6_ARE_ADDR_EQUAL(&sc->gif_ip6hdr->ip6_src, &ip6->ip6_dst))
return (0);
+ ret = 128;
+ if (!IN6_ARE_ADDR_EQUAL(&sc->gif_ip6hdr->ip6_dst, &ip6->ip6_src)) {
+ if ((sc->gif_options & GIF_IGNORE_SOURCE) == 0)
+ return (0);
+ } else
+ ret += 128;
/* martian filters on outer source - done in ip6_input */
@@ -214,7 +220,7 @@ gif_validate6(const struct ip6_hdr *ip6, struct gif_softc *sc,
RTFREE_LOCKED(rt);
}
- return (128 * 2);
+ return (ret);
}
/*
diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c
index 06d931b..8c25e98 100644
--- a/sys/netinet6/in6_ifattach.c
+++ b/sys/netinet6/in6_ifattach.c
@@ -274,9 +274,7 @@ found:
case IFT_ISO88025:
case IFT_ATM:
case IFT_IEEE1394:
-#ifdef IFT_IEEE80211
case IFT_IEEE80211:
-#endif
/* IEEE802/EUI64 cases - what others? */
/* IEEE1394 uses 16byte length address starting with EUI64 */
if (addrlen > 8)
@@ -338,9 +336,7 @@ found:
break;
case IFT_GIF:
-#ifdef IFT_STF
case IFT_STF:
-#endif
/*
* RFC2893 says: "SHOULD use IPv4 address as ifid source".
* however, IPv4 address is not very suitable as unique
diff --git a/sys/netinet6/in6_rmx.c b/sys/netinet6/in6_rmx.c
index 1403647..9aef3db 100644
--- a/sys/netinet6/in6_rmx.c
+++ b/sys/netinet6/in6_rmx.c
@@ -263,7 +263,7 @@ in6_inithead(void **head, int off)
rnh->rnh_addaddr = in6_addroute;
if (V__in6_rt_was_here == 0) {
- callout_init(&V_rtq_mtutimer, CALLOUT_MPSAFE);
+ callout_init(&V_rtq_mtutimer, 1);
in6_mtutimo(curvnet); /* kick off timeout first time */
V__in6_rt_was_here = 1;
}
diff --git a/sys/netinet6/ip6_ipsec.c b/sys/netinet6/ip6_ipsec.c
index e6e16ed..d7f08e9 100644
--- a/sys/netinet6/ip6_ipsec.c
+++ b/sys/netinet6/ip6_ipsec.c
@@ -31,7 +31,7 @@
__FBSDID("$FreeBSD$");
#include "opt_inet.h"
-#include "opt_inet6.h"
+#include "opt_sctp.h"
#include "opt_ipsec.h"
#include <sys/param.h>
@@ -58,10 +58,12 @@ __FBSDID("$FreeBSD$");
#include <netinet/in_pcb.h>
#include <netinet/ip_var.h>
#include <netinet/ip_options.h>
+#ifdef SCTP
+#include <netinet/sctp_crc32.h>
+#endif
#include <machine/in_cksum.h>
-#ifdef IPSEC
#include <netipsec/ipsec.h>
#include <netipsec/ipsec6.h>
#include <netipsec/xform.h>
@@ -71,16 +73,12 @@ __FBSDID("$FreeBSD$");
#else
#define KEYDEBUG(lev,arg)
#endif
-#endif /*IPSEC*/
#include <netinet6/ip6_ipsec.h>
#include <netinet6/ip6_var.h>
extern struct protosw inet6sw[];
-
-#ifdef INET6
-#ifdef IPSEC
#ifdef IPSEC_FILTERTUNNEL
static VNET_DEFINE(int, ip6_ipsec6_filtertunnel) = 1;
#else
@@ -92,8 +90,6 @@ SYSCTL_DECL(_net_inet6_ipsec6);
SYSCTL_INT(_net_inet6_ipsec6, OID_AUTO, filtertunnel,
CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(ip6_ipsec6_filtertunnel), 0,
"If set filter packets from an IPsec tunnel.");
-#endif /* IPSEC */
-#endif /* INET6 */
/*
* Check if we have to jump over firewall processing for this packet.
@@ -103,16 +99,14 @@ SYSCTL_INT(_net_inet6_ipsec6, OID_AUTO, filtertunnel,
int
ip6_ipsec_filtertunnel(struct mbuf *m)
{
-#ifdef IPSEC
/*
* Bypass packet filtering for packets previously handled by IPsec.
*/
if (!V_ip6_ipsec6_filtertunnel &&
m_tag_find(m, PACKET_TAG_IPSEC_IN_DONE, NULL) != NULL)
- return 1;
-#endif
- return 0;
+ return (1);
+ return (0);
}
/*
@@ -125,11 +119,7 @@ int
ip6_ipsec_fwd(struct mbuf *m)
{
-#ifdef IPSEC
return (ipsec6_in_reject(m, NULL));
-#else
- return (0);
-#endif /* !IPSEC */
}
/*
@@ -143,7 +133,6 @@ int
ip6_ipsec_input(struct mbuf *m, int nxt)
{
-#ifdef IPSEC
/*
* enforce IPsec policy checking if we are seeing last header.
* note that we do not visit this with protocols with pcb layer
@@ -151,7 +140,6 @@ ip6_ipsec_input(struct mbuf *m, int nxt)
*/
if ((inet6sw[ip6_protox[nxt]].pr_flags & PR_LASTHDR) != 0)
return (ipsec6_in_reject(m, NULL));
-#endif /* IPSEC */
return (0);
}
@@ -164,7 +152,6 @@ ip6_ipsec_input(struct mbuf *m, int nxt)
int
ip6_ipsec_output(struct mbuf **m, struct inpcb *inp, int *error)
{
-#ifdef IPSEC
struct secpolicy *sp;
/*
@@ -257,9 +244,7 @@ reinjected:
bad:
if (sp != NULL)
KEY_FREESP(&sp);
- return 1;
-#endif /* IPSEC */
- return 0;
+ return (1);
}
#if 0
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index eda02d9..d667903 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -2900,14 +2900,6 @@ ip6_mloopback(struct ifnet *ifp, struct mbuf *m, struct sockaddr_in6 *dst)
if (copym == NULL)
return;
}
-
-#ifdef DIAGNOSTIC
- if (copym->m_len < sizeof(*ip6)) {
- m_freem(copym);
- return;
- }
-#endif
-
ip6 = mtod(copym, struct ip6_hdr *);
/*
* clear embedded scope identifiers if necessary.
@@ -2915,7 +2907,11 @@ ip6_mloopback(struct ifnet *ifp, struct mbuf *m, struct sockaddr_in6 *dst)
*/
in6_clearscope(&ip6->ip6_src);
in6_clearscope(&ip6->ip6_dst);
-
+ if (copym->m_pkthdr.csum_flags & CSUM_DELAY_DATA_IPV6) {
+ copym->m_pkthdr.csum_flags |= CSUM_DATA_VALID_IPV6 |
+ CSUM_PSEUDO_HDR;
+ copym->m_pkthdr.csum_data = 0xffff;
+ }
(void)if_simloop(ifp, copym, dst->sin6_family, 0);
}
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index a344d6a..83dda1a 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -2145,12 +2145,8 @@ nd6_need_cache(struct ifnet *ifp)
case IFT_ETHER:
case IFT_FDDI:
case IFT_IEEE1394:
-#ifdef IFT_L2VLAN
case IFT_L2VLAN:
-#endif
-#ifdef IFT_IEEE80211
case IFT_IEEE80211:
-#endif
case IFT_INFINIBAND:
case IFT_BRIDGE:
case IFT_PROPVIRTUAL:
@@ -2235,12 +2231,8 @@ nd6_storelladdr(struct ifnet *ifp, struct mbuf *m,
switch (ifp->if_type) {
case IFT_ETHER:
case IFT_FDDI:
-#ifdef IFT_L2VLAN
case IFT_L2VLAN:
-#endif
-#ifdef IFT_IEEE80211
case IFT_IEEE80211:
-#endif
case IFT_BRIDGE:
case IFT_ISO88025:
ETHER_MAP_IPV6_MULTICAST(&SIN6(dst)->sin6_addr,
diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h
index 22509ac..0b061df 100644
--- a/sys/netinet6/nd6.h
+++ b/sys/netinet6/nd6.h
@@ -87,8 +87,7 @@ struct nd_ifinfo {
#define ND6_IFF_AUTO_LINKLOCAL 0x20
#define ND6_IFF_NO_RADR 0x40
#define ND6_IFF_NO_PREFER_IFACE 0x80 /* XXX: not related to ND. */
-#define ND6_IFF_IGNORELOOP 0x100
-#define ND6_IFF_NO_DAD 0x200
+#define ND6_IFF_NO_DAD 0x100
#define ND6_CREATE LLE_CREATE
#define ND6_EXCLUSIVE LLE_EXCLUSIVE
diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c
index 4b160f7..9c92cd9 100644
--- a/sys/netinet6/nd6_nbr.c
+++ b/sys/netinet6/nd6_nbr.c
@@ -1149,12 +1149,8 @@ nd6_ifptomac(struct ifnet *ifp)
case IFT_ETHER:
case IFT_FDDI:
case IFT_IEEE1394:
-#ifdef IFT_L2VLAN
case IFT_L2VLAN:
-#endif
-#ifdef IFT_IEEE80211
case IFT_IEEE80211:
-#endif
case IFT_INFINIBAND:
case IFT_BRIDGE:
case IFT_ISO88025:
@@ -1449,10 +1445,9 @@ nd6_dad_timer(struct dadq *dp)
dp->dad_ns_lcount > 0 &&
dp->dad_ns_lcount > dp->dad_loopbackprobe) {
/*
- * A looped back probe is detected,
- * Sec. 4.1 in draft-ietf-6man-enhanced-dad-13
- * requires transmission of additional probes until
- * the loopback condition becomes clear.
+ * Sec. 4.1 in RFC 7527 requires transmission of
+ * additional probes until the loopback condition
+ * becomes clear when a looped back probe is detected.
*/
log(LOG_ERR, "%s: a looped back NS message is "
"detected during DAD for %s. "
@@ -1461,16 +1456,6 @@ nd6_dad_timer(struct dadq *dp)
ip6_sprintf(ip6buf, IFA_IN6(ifa)));
dp->dad_loopbackprobe = dp->dad_ns_lcount;
/*
- * An interface with IGNORELOOP is one which a
- * loopback is permanently expected while regular
- * traffic works. In that case, stop DAD after
- * MAX_MULTICAST_SOLICIT number of NS messages
- * regardless of the number of received loopback NS
- * by increasing dad_loopbackprobe in advance.
- */
- if (ND_IFINFO(ifa->ifa_ifp)->flags & ND6_IFF_IGNORELOOP)
- dp->dad_loopbackprobe += V_nd6_mmaxtries;
- /*
* Send an NS immediately and increase dad_count by
* V_nd6_mmaxtries - 1.
*/
@@ -1549,9 +1534,7 @@ nd6_dad_duplicated(struct ifaddr *ifa, struct dadq *dp)
case IFT_FDDI:
case IFT_ATM:
case IFT_IEEE1394:
-#ifdef IFT_IEEE80211
case IFT_IEEE80211:
-#endif
case IFT_INFINIBAND:
in6 = ia->ia_addr.sin6_addr;
if (in6_get_hw_ifid(ifp, &in6) == 0 &&
diff --git a/sys/netipsec/esp.h b/sys/netipsec/esp.h
index eb37397..8eb0963 100644
--- a/sys/netipsec/esp.h
+++ b/sys/netipsec/esp.h
@@ -42,8 +42,7 @@ struct esp {
/*variable size, 32bit bound*/ /* Initialization Vector */
/*variable size*/ /* Payload data */
/*variable size*/ /* padding */
- /*8bit*/ /* pad size */
- /*8bit*/ /* next header */
+ /*8bit*/ /* pad length */
/*8bit*/ /* next header */
/*variable size, 32bit bound*/ /* Authentication data (new IPsec) */
};
@@ -53,8 +52,7 @@ struct newesp {
u_int32_t esp_seq; /* Sequence number */
/*variable size*/ /* (IV and) Payload data */
/*variable size*/ /* padding */
- /*8bit*/ /* pad size */
- /*8bit*/ /* next header */
+ /*8bit*/ /* pad length */
/*8bit*/ /* next header */
/*variable size, 32bit bound*/ /* Authentication data */
};
diff --git a/sys/netipsec/ipsec_input.c b/sys/netipsec/ipsec_input.c
index 6c52781..5837699 100644
--- a/sys/netipsec/ipsec_input.c
+++ b/sys/netipsec/ipsec_input.c
@@ -391,6 +391,7 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip,
ipsec_bpf(m, sav, AF_INET, ENC_IN|ENC_BEFORE);
if ((error = ipsec_filter(&m, PFIL_IN, ENC_IN|ENC_BEFORE)) != 0)
return (error);
+ ip = mtod(m, struct ip *);
#endif /* DEV_ENC */
/* IP-in-IP encapsulation */
diff --git a/sys/netipsec/ipsec_output.c b/sys/netipsec/ipsec_output.c
index 22a50c4..ae36070 100644
--- a/sys/netipsec/ipsec_output.c
+++ b/sys/netipsec/ipsec_output.c
@@ -206,8 +206,7 @@ ipsec_process_done(struct mbuf *m, struct ipsecrequest *isr)
/*
* We're done with IPsec processing, transmit the packet using the
- * appropriate network protocol (IP or IPv6). SPD lookup will be
- * performed again there.
+ * appropriate network protocol (IP or IPv6).
*/
switch (saidx->dst.sa.sa_family) {
#ifdef INET
@@ -578,6 +577,7 @@ ipsec4_process_packet(struct mbuf *m, struct ipsecrequest *isr)
/* pass the mbuf to enc0 for packet filtering */
if ((error = ipsec_filter(&m, PFIL_OUT, ENC_OUT|ENC_BEFORE)) != 0)
goto bad;
+ ip = mtod(m, struct ip *);
#endif
/* Do the appropriate encapsulation, if necessary */
if (isr->saidx.mode == IPSEC_MODE_TUNNEL || /* Tunnel requ'd */
@@ -699,6 +699,7 @@ ipsec6_process_packet(struct mbuf *m, struct ipsecrequest *isr)
/* pass the mbuf to enc0 for packet filtering */
if ((error = ipsec_filter(&m, PFIL_OUT, ENC_OUT|ENC_BEFORE)) != 0)
goto bad;
+ ip6 = mtod(m, struct ip6_hdr *);
#endif /* DEV_ENC */
/* Do the appropriate encapsulation, if necessary */
diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c
index 353dd32..1e70fb2 100644
--- a/sys/netipsec/key.c
+++ b/sys/netipsec/key.c
@@ -537,7 +537,7 @@ static int key_acquire2(struct socket *, struct mbuf *,
const struct sadb_msghdr *);
static int key_register(struct socket *, struct mbuf *,
const struct sadb_msghdr *);
-static int key_expire(struct secasvar *);
+static int key_expire(struct secasvar *, int);
static int key_flush(struct socket *, struct mbuf *,
const struct sadb_msghdr *);
static int key_dump(struct socket *, struct mbuf *,
@@ -2199,7 +2199,7 @@ key_spddelete2(struct socket *so, struct mbuf *m,
}
/*
- * SADB_X_GET processing
+ * SADB_X_SPDGET processing
* receive
* <base, policy(*)>
* from the user(?),
@@ -2237,7 +2237,8 @@ key_spdget(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp)
return key_senderror(so, m, ENOENT);
}
- n = key_setdumpsp(sp, SADB_X_SPDGET, 0, mhp->msg->sadb_msg_pid);
+ n = key_setdumpsp(sp, SADB_X_SPDGET, mhp->msg->sadb_msg_seq,
+ mhp->msg->sadb_msg_pid);
KEY_FREESP(&sp);
if (n != NULL) {
m_freem(m);
@@ -4242,41 +4243,29 @@ key_flush_sad(time_t now)
"time, why?\n", __func__));
continue;
}
-
- /* check SOFT lifetime */
- if (sav->lft_s->addtime != 0 &&
- now - sav->created > sav->lft_s->addtime) {
- key_sa_chgstate(sav, SADB_SASTATE_DYING);
- /*
- * Actually, only send expire message if
- * SA has been used, as it was done before,
- * but should we always send such message,
- * and let IKE daemon decide if it should be
- * renegotiated or not ?
- * XXX expire message will actually NOT be
- * sent if SA is only used after soft
- * lifetime has been reached, see below
- * (DYING state)
- */
- if (sav->lft_c->usetime != 0)
- key_expire(sav);
- }
- /* check SOFT lifetime by bytes */
/*
- * XXX I don't know the way to delete this SA
- * when new SA is installed. Caution when it's
- * installed too big lifetime by time.
+ * RFC 2367:
+ * HARD lifetimes MUST take precedence over SOFT
+ * lifetimes, meaning if the HARD and SOFT lifetimes
+ * are the same, the HARD lifetime will appear on the
+ * EXPIRE message.
*/
- else if (sav->lft_s->bytes != 0 &&
- sav->lft_s->bytes < sav->lft_c->bytes) {
-
+ /* check HARD lifetime */
+ if ((sav->lft_h->addtime != 0 &&
+ now - sav->created > sav->lft_h->addtime) ||
+ (sav->lft_h->bytes != 0 &&
+ sav->lft_h->bytes < sav->lft_c->bytes)) {
+ key_sa_chgstate(sav, SADB_SASTATE_DEAD);
+ key_expire(sav, 1);
+ KEY_FREESAV(&sav);
+ }
+ /* check SOFT lifetime */
+ else if ((sav->lft_s->addtime != 0 &&
+ now - sav->created > sav->lft_s->addtime) ||
+ (sav->lft_s->bytes != 0 &&
+ sav->lft_s->bytes < sav->lft_c->bytes)) {
key_sa_chgstate(sav, SADB_SASTATE_DYING);
- /*
- * XXX If we keep to send expire
- * message in the status of
- * DYING. Do remove below code.
- */
- key_expire(sav);
+ key_expire(sav, 0);
}
}
@@ -4296,6 +4285,7 @@ key_flush_sad(time_t now)
if (sav->lft_h->addtime != 0 &&
now - sav->created > sav->lft_h->addtime) {
key_sa_chgstate(sav, SADB_SASTATE_DEAD);
+ key_expire(sav, 1);
KEY_FREESAV(&sav);
}
#if 0 /* XXX Should we keep to send expire message until HARD lifetime ? */
@@ -4311,13 +4301,14 @@ key_flush_sad(time_t now)
* If there is no SA then sending
* expire message.
*/
- key_expire(sav);
+ key_expire(sav, 0);
}
#endif
/* check HARD lifetime by bytes */
else if (sav->lft_h->bytes != 0 &&
sav->lft_h->bytes < sav->lft_c->bytes) {
key_sa_chgstate(sav, SADB_SASTATE_DEAD);
+ key_expire(sav, 1);
KEY_FREESAV(&sav);
}
}
@@ -6721,7 +6712,7 @@ key_freereg(struct socket *so)
* others : error number
*/
static int
-key_expire(struct secasvar *sav)
+key_expire(struct secasvar *sav, int hard)
{
int satype;
struct mbuf *result = NULL, *m;
@@ -6779,11 +6770,19 @@ key_expire(struct secasvar *sav)
lt->sadb_lifetime_usetime = sav->lft_c->usetime;
lt = (struct sadb_lifetime *)(mtod(m, caddr_t) + len / 2);
lt->sadb_lifetime_len = PFKEY_UNIT64(sizeof(struct sadb_lifetime));
- lt->sadb_lifetime_exttype = SADB_EXT_LIFETIME_SOFT;
- lt->sadb_lifetime_allocations = sav->lft_s->allocations;
- lt->sadb_lifetime_bytes = sav->lft_s->bytes;
- lt->sadb_lifetime_addtime = sav->lft_s->addtime;
- lt->sadb_lifetime_usetime = sav->lft_s->usetime;
+ if (hard) {
+ lt->sadb_lifetime_exttype = SADB_EXT_LIFETIME_HARD;
+ lt->sadb_lifetime_allocations = sav->lft_h->allocations;
+ lt->sadb_lifetime_bytes = sav->lft_h->bytes;
+ lt->sadb_lifetime_addtime = sav->lft_h->addtime;
+ lt->sadb_lifetime_usetime = sav->lft_h->usetime;
+ } else {
+ lt->sadb_lifetime_exttype = SADB_EXT_LIFETIME_SOFT;
+ lt->sadb_lifetime_allocations = sav->lft_s->allocations;
+ lt->sadb_lifetime_bytes = sav->lft_s->bytes;
+ lt->sadb_lifetime_addtime = sav->lft_s->addtime;
+ lt->sadb_lifetime_usetime = sav->lft_s->usetime;
+ }
m_cat(result, m);
/* set sadb_address for source */
@@ -7561,7 +7560,7 @@ key_init(void)
SPACQ_LOCK_INIT();
#ifndef IPSEC_DEBUG2
- callout_init(&key_timer, CALLOUT_MPSAFE);
+ callout_init(&key_timer, 1);
callout_reset(&key_timer, hz, key_timehandler, NULL);
#endif /*IPSEC_DEBUG2*/
diff --git a/sys/netipsec/keysock.c b/sys/netipsec/keysock.c
index 605d79c..4d12957 100644
--- a/sys/netipsec/keysock.c
+++ b/sys/netipsec/keysock.c
@@ -149,8 +149,6 @@ key_sendup0(struct rawcb *rp, struct mbuf *m, int promisc)
PFKEYSTAT_INC(in_nomem);
return (ENOBUFS);
}
- m->m_pkthdr.len += sizeof(*pmsg); /* XXX: is this correct? */
-
pmsg = mtod(m, struct sadb_msg *);
bzero(pmsg, sizeof(*pmsg));
pmsg->sadb_msg_version = PF_KEY_V2;
diff --git a/sys/netpfil/ipfw/dn_sched.h b/sys/netpfil/ipfw/dn_sched.h
index 0d28454..4268edf 100644
--- a/sys/netpfil/ipfw/dn_sched.h
+++ b/sys/netpfil/ipfw/dn_sched.h
@@ -188,5 +188,5 @@ int dn_sched_modevent(module_t mod, int cmd, void *arg);
}; \
DECLARE_MODULE(name, name##_mod, \
SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY); \
- MODULE_DEPEND(name, dummynet, 3, 3, 3);
+ MODULE_DEPEND(name, dummynet, 3, 3, 3)
#endif /* _DN_SCHED_H */
diff --git a/sys/netpfil/ipfw/ip_dn_private.h b/sys/netpfil/ipfw/ip_dn_private.h
index 958c820..42aa378 100644
--- a/sys/netpfil/ipfw/ip_dn_private.h
+++ b/sys/netpfil/ipfw/ip_dn_private.h
@@ -92,7 +92,7 @@ set_oid(struct dn_id *o, int type, int len)
o->type = type;
o->len = len;
o->subtype = 0;
-};
+}
/*
* configuration and global data for a dummynet instance
diff --git a/sys/netpfil/ipfw/ip_dummynet.c b/sys/netpfil/ipfw/ip_dummynet.c
index 06f80df..3ba110e 100644
--- a/sys/netpfil/ipfw/ip_dummynet.c
+++ b/sys/netpfil/ipfw/ip_dummynet.c
@@ -2169,7 +2169,7 @@ ip_dn_init(void)
taskqueue_thread_enqueue, &dn_tq);
taskqueue_start_threads(&dn_tq, 1, PI_NET, "dummynet");
- callout_init(&dn_timeout, CALLOUT_MPSAFE);
+ callout_init(&dn_timeout, 1);
dn_reschedule();
/* Initialize curr_time adjustment mechanics. */
diff --git a/sys/netpfil/ipfw/ip_fw2.c b/sys/netpfil/ipfw/ip_fw2.c
index 4da0ee0..e5017d6 100644
--- a/sys/netpfil/ipfw/ip_fw2.c
+++ b/sys/netpfil/ipfw/ip_fw2.c
@@ -1532,8 +1532,9 @@ do { \
else if (v == 5 /* O_JAIL */)
key = ucred_cache.xid;
#endif /* !__FreeBSD__ */
- } else
+ }
#endif /* !USERSPACE */
+ else
break;
}
match = ipfw_lookup_table(chain,
diff --git a/sys/netpfil/ipfw/ip_fw_dynamic.c b/sys/netpfil/ipfw/ip_fw_dynamic.c
index 2b43869..083244d 100644
--- a/sys/netpfil/ipfw/ip_fw_dynamic.c
+++ b/sys/netpfil/ipfw/ip_fw_dynamic.c
@@ -1395,7 +1395,7 @@ ipfw_dyn_init(struct ip_fw_chain *chain)
/* Enforce limit on dynamic rules */
uma_zone_set_max(V_ipfw_dyn_rule_zone, V_dyn_max);
- callout_init(&V_ipfw_timeout, CALLOUT_MPSAFE);
+ callout_init(&V_ipfw_timeout, 1);
/*
* This can potentially be done on first dynamic rule
diff --git a/sys/netpfil/ipfw/ip_fw_nat.c b/sys/netpfil/ipfw/ip_fw_nat.c
index 201b77a..df40398 100644
--- a/sys/netpfil/ipfw/ip_fw_nat.c
+++ b/sys/netpfil/ipfw/ip_fw_nat.c
@@ -265,6 +265,16 @@ add_redir_spool_cfg(char *buf, struct cfg_nat *ptr)
return (0);
}
+static void
+free_nat_instance(struct cfg_nat *ptr)
+{
+
+ del_redir_spool_cfg(ptr, &ptr->redir_chain);
+ LibAliasUninit(ptr->lib);
+ free(ptr, M_IPFW);
+}
+
+
/*
* ipfw_nat - perform mbuf header translation.
*
@@ -538,7 +548,7 @@ nat44_config(struct ip_fw_chain *chain, struct nat44_cfg_nat *ucfg)
IPFW_UH_WUNLOCK(chain);
if (tcfg != NULL)
- free(tcfg, M_IPFW);
+ free_nat_instance(ptr);
}
/*
@@ -628,9 +638,7 @@ nat44_destroy(struct ip_fw_chain *chain, ip_fw3_opheader *op3,
IPFW_WUNLOCK(chain);
IPFW_UH_WUNLOCK(chain);
- del_redir_spool_cfg(ptr, &ptr->redir_chain);
- LibAliasUninit(ptr->lib);
- free(ptr, M_IPFW);
+ free_nat_instance(ptr);
return (0);
}
@@ -996,9 +1004,7 @@ ipfw_nat_del(struct sockopt *sopt)
flush_nat_ptrs(chain, i);
IPFW_WUNLOCK(chain);
IPFW_UH_WUNLOCK(chain);
- del_redir_spool_cfg(ptr, &ptr->redir_chain);
- LibAliasUninit(ptr->lib);
- free(ptr, M_IPFW);
+ free_nat_instance(ptr);
return (0);
}
@@ -1141,9 +1147,7 @@ vnet_ipfw_nat_uninit(const void *arg __unused)
IPFW_WLOCK(chain);
LIST_FOREACH_SAFE(ptr, &chain->nat, _next, ptr_temp) {
LIST_REMOVE(ptr, _next);
- del_redir_spool_cfg(ptr, &ptr->redir_chain);
- LibAliasUninit(ptr->lib);
- free(ptr, M_IPFW);
+ free_nat_instance(ptr);
}
flush_nat_ptrs(chain, -1 /* flush all */);
V_ipfw_nat_ready = 0;
diff --git a/sys/netpfil/ipfw/ip_fw_pfil.c b/sys/netpfil/ipfw/ip_fw_pfil.c
index 61f182d..3460036 100644
--- a/sys/netpfil/ipfw/ip_fw_pfil.c
+++ b/sys/netpfil/ipfw/ip_fw_pfil.c
@@ -505,7 +505,7 @@ static int
ipfw_hook(int onoff, int pf)
{
struct pfil_head *pfh;
- void *hook_func;
+ pfil_func_t hook_func;
pfh = pfil_head_get(PFIL_TYPE_AF, pf);
if (pfh == NULL)
diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c
index 6f55511..107c4b8 100644
--- a/sys/netpfil/ipfw/ip_fw_sockopt.c
+++ b/sys/netpfil/ipfw/ip_fw_sockopt.c
@@ -1647,7 +1647,6 @@ check_ipfw_rule_body(ipfw_insn *cmd, int cmd_len, struct rule_check_info *ci)
return EINVAL;
if (cmdlen != F_INSN_SIZE(ipfw_insn_nat))
goto bad_size;
- ci->object_opcodes++;
goto check_action;
case O_FORWARD_MAC: /* XXX not implemented yet */
case O_CHECK_STATE:
@@ -2211,7 +2210,7 @@ create_objects_compat(struct ip_fw_chain *ch, ipfw_insn *cmd,
return (error);
}
- return (error);
+ return (0);
}
/*
@@ -2847,7 +2846,7 @@ compare_sh(const void *_a, const void *_b)
* Returns pointer to handler or NULL.
*/
static struct ipfw_sopt_handler *
-find_sh(uint16_t code, uint8_t version, void *handler)
+find_sh(uint16_t code, uint8_t version, sopt_handler_f *handler)
{
struct ipfw_sopt_handler *sh, h;
diff --git a/sys/netpfil/ipfw/ip_fw_table.c b/sys/netpfil/ipfw/ip_fw_table.c
index 7858c78..f942541 100644
--- a/sys/netpfil/ipfw/ip_fw_table.c
+++ b/sys/netpfil/ipfw/ip_fw_table.c
@@ -597,19 +597,21 @@ restart:
/* Pass stack buffer by default */
ta_buf_m = ta_buf;
error = prepare_batch_buffer(ch, ta, tei, count, OP_ADD, &ta_buf_m);
- if (error != 0)
- goto cleanup;
IPFW_UH_WLOCK(ch);
+ del_toperation_state(ch, &ts);
/* Drop reference we've used in first search */
tc->no.refcnt--;
+ /* Check prepare_batch_buffer() error */
+ if (error != 0)
+ goto cleanup;
+
/*
* Check if table swap has happened.
* (so table algo might be changed).
* Restart operation to achieve consistent behavior.
*/
- del_toperation_state(ch, &ts);
if (ts.modified != 0)
goto restart;
@@ -3399,6 +3401,11 @@ ref_rule_objects(struct ip_fw_chain *ch, struct ip_fw *rule,
IPFW_UH_WUNLOCK(ch);
+ found = pidx - oib;
+ KASSERT(found == ci->object_opcodes,
+ ("refcount inconsistency: found: %d total: %d",
+ found, ci->object_opcodes));
+
/* Perform auto-creation for non-existing objects */
if (numnew != 0)
error = create_objects_compat(ch, rule->cmd, oib, pidx, ti);
diff --git a/sys/netpfil/ipfw/ip_fw_table_value.c b/sys/netpfil/ipfw/ip_fw_table_value.c
index c798ac1..c8c755c 100644
--- a/sys/netpfil/ipfw/ip_fw_table_value.c
+++ b/sys/netpfil/ipfw/ip_fw_table_value.c
@@ -563,17 +563,6 @@ ipfw_link_table_values(struct ip_fw_chain *ch, struct tableop_state *ts)
/* Let's try to link values */
for (i = 0; i < count; i++) {
ptei = &tei[i];
- if (ptei->value != 0) {
-
- /*
- * We may be here after several process restarts,
- * so we need to update all fields that might
- * have changed.
- */
- ptv = (struct table_val_link *)ptei->ptv;
- ptv->pval = &pval[i];
- continue;
- }
/* Check if record has appeared */
mask_table_value(ptei->pvalue, &tval, ts->vmask);
diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c
index 3d62cf5..516a92a 100644
--- a/sys/netpfil/pf/if_pfsync.c
+++ b/sys/netpfil/pf/if_pfsync.c
@@ -324,7 +324,7 @@ pfsync_clone_create(struct if_clone *ifc, int unit, caddr_t param)
ifp->if_mtu = ETHERMTU;
mtx_init(&sc->sc_mtx, pfsyncname, NULL, MTX_DEF);
mtx_init(&sc->sc_bulk_mtx, "pfsync bulk", NULL, MTX_DEF);
- callout_init(&sc->sc_tmo, CALLOUT_MPSAFE);
+ callout_init(&sc->sc_tmo, 1);
callout_init_mtx(&sc->sc_bulk_tmo, &sc->sc_bulk_mtx, 0);
callout_init_mtx(&sc->sc_bulkfail_tmo, &sc->sc_bulk_mtx, 0);
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index 6d24634..5652365 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -151,6 +151,7 @@ static VNET_DEFINE(struct pf_send_head, pf_sendqueue);
#define V_pf_sendqueue VNET(pf_sendqueue)
static struct mtx pf_sendqueue_mtx;
+MTX_SYSINIT(pf_sendqueue_mtx, &pf_sendqueue_mtx, "pf send queue", MTX_DEF);
#define PF_SENDQ_LOCK() mtx_lock(&pf_sendqueue_mtx)
#define PF_SENDQ_UNLOCK() mtx_unlock(&pf_sendqueue_mtx)
@@ -172,11 +173,15 @@ static VNET_DEFINE(struct task, pf_overloadtask);
#define V_pf_overloadtask VNET(pf_overloadtask)
static struct mtx pf_overloadqueue_mtx;
+MTX_SYSINIT(pf_overloadqueue_mtx, &pf_overloadqueue_mtx,
+ "pf overload/flush queue", MTX_DEF);
#define PF_OVERLOADQ_LOCK() mtx_lock(&pf_overloadqueue_mtx)
#define PF_OVERLOADQ_UNLOCK() mtx_unlock(&pf_overloadqueue_mtx)
VNET_DEFINE(struct pf_rulequeue, pf_unlinked_rules);
struct mtx pf_unlnkdrules_mtx;
+MTX_SYSINIT(pf_unlnkdrules_mtx, &pf_unlnkdrules_mtx, "pf unlinked rules",
+ MTX_DEF);
static VNET_DEFINE(uma_zone_t, pf_sources_z);
#define V_pf_sources_z VNET(pf_sources_z)
@@ -804,18 +809,13 @@ pf_initialize()
V_pf_altqs_active = &V_pf_altqs[0];
V_pf_altqs_inactive = &V_pf_altqs[1];
-
/* Send & overload+flush queues. */
STAILQ_INIT(&V_pf_sendqueue);
SLIST_INIT(&V_pf_overloadqueue);
TASK_INIT(&V_pf_overloadtask, 0, pf_overload_task, curvnet);
- mtx_init(&pf_sendqueue_mtx, "pf send queue", NULL, MTX_DEF);
- mtx_init(&pf_overloadqueue_mtx, "pf overload/flush queue", NULL,
- MTX_DEF);
/* Unlinked, but may be referenced rules. */
TAILQ_INIT(&V_pf_unlinked_rules);
- mtx_init(&pf_unlnkdrules_mtx, "pf unlinked rules", NULL, MTX_DEF);
}
void
@@ -858,10 +858,6 @@ pf_cleanup()
free(pfse, M_PFTEMP);
}
- mtx_destroy(&pf_sendqueue_mtx);
- mtx_destroy(&pf_overloadqueue_mtx);
- mtx_destroy(&pf_unlnkdrules_mtx);
-
uma_zdestroy(V_pf_sources_z);
uma_zdestroy(V_pf_state_z);
uma_zdestroy(V_pf_state_key_z);
@@ -5903,13 +5899,14 @@ done:
((pd.pf_mtag = pf_get_mtag(m)) == NULL)) {
action = PF_DROP;
REASON_SET(&reason, PFRES_MEMORY);
+ } else {
+ if (pqid || (pd.tos & IPTOS_LOWDELAY))
+ pd.pf_mtag->qid = r->pqid;
+ else
+ pd.pf_mtag->qid = r->qid;
+ /* Add hints for ecn. */
+ pd.pf_mtag->hdr = h;
}
- if (pqid || (pd.tos & IPTOS_LOWDELAY))
- pd.pf_mtag->qid = r->pqid;
- else
- pd.pf_mtag->qid = r->qid;
- /* add hints for ecn */
- pd.pf_mtag->hdr = h;
}
#endif /* ALTQ */
@@ -5948,9 +5945,11 @@ done:
log = 1;
DPFPRINTF(PF_DEBUG_MISC,
("pf: failed to allocate tag\n"));
+ } else {
+ pd.pf_mtag->flags |=
+ PF_FASTFWD_OURS_PRESENT;
+ m->m_flags &= ~M_FASTFWD_OURS;
}
- pd.pf_mtag->flags |= PF_FASTFWD_OURS_PRESENT;
- m->m_flags &= ~M_FASTFWD_OURS;
}
ip_divert_ptr(*m0, dir == PF_IN ? DIR_IN : DIR_OUT);
*m0 = NULL;
@@ -6332,13 +6331,14 @@ done:
((pd.pf_mtag = pf_get_mtag(m)) == NULL)) {
action = PF_DROP;
REASON_SET(&reason, PFRES_MEMORY);
+ } else {
+ if (pd.tos & IPTOS_LOWDELAY)
+ pd.pf_mtag->qid = r->pqid;
+ else
+ pd.pf_mtag->qid = r->qid;
+ /* Add hints for ecn. */
+ pd.pf_mtag->hdr = h;
}
- if (pd.tos & IPTOS_LOWDELAY)
- pd.pf_mtag->qid = r->pqid;
- else
- pd.pf_mtag->qid = r->qid;
- /* add hints for ecn */
- pd.pf_mtag->hdr = h;
}
#endif /* ALTQ */
diff --git a/sys/netpfil/pf/pf_if.c b/sys/netpfil/pf/pf_if.c
index 41acc7d..2f12518 100644
--- a/sys/netpfil/pf/pf_if.c
+++ b/sys/netpfil/pf/pf_if.c
@@ -103,6 +103,8 @@ LIST_HEAD(pfi_list, pfi_kif);
static VNET_DEFINE(struct pfi_list, pfi_unlinked_kifs);
#define V_pfi_unlinked_kifs VNET(pfi_unlinked_kifs)
static struct mtx pfi_unlnkdkifs_mtx;
+MTX_SYSINIT(pfi_unlnkdkifs_mtx, &pfi_unlnkdkifs_mtx, "pf unlinked interfaces",
+ MTX_DEF);
void
pfi_initialize(void)
@@ -115,8 +117,6 @@ pfi_initialize(void)
V_pfi_buffer = malloc(V_pfi_buffer_max * sizeof(*V_pfi_buffer),
PFI_MTYPE, M_WAITOK);
- mtx_init(&pfi_unlnkdkifs_mtx, "pf unlinked interfaces", NULL, MTX_DEF);
-
kif = malloc(sizeof(*kif), PFI_MTYPE, M_WAITOK);
PF_RULES_WLOCK();
V_pfi_all = pfi_kif_attach(kif, IFG_ALL);
@@ -166,8 +166,6 @@ pfi_cleanup(void)
free(p, PFI_MTYPE);
}
- mtx_destroy(&pfi_unlnkdkifs_mtx);
-
free(V_pfi_buffer, PFI_MTYPE);
}
diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c
index c20e00a..3c3556f 100644
--- a/sys/netpfil/pf/pf_ioctl.c
+++ b/sys/netpfil/pf/pf_ioctl.c
@@ -3756,6 +3756,7 @@ pf_unload(void)
wakeup_one(pf_purge_thread);
rw_sleep(pf_purge_thread, &pf_rules_lock, 0, "pftmo", 0);
}
+ PF_RULES_WUNLOCK();
pf_normalize_cleanup();
pfi_cleanup();
pfr_cleanup();
@@ -3763,7 +3764,6 @@ pf_unload(void)
pf_cleanup();
if (IS_DEFAULT_VNET(curvnet))
pf_mtag_cleanup();
- PF_RULES_WUNLOCK();
destroy_dev(pf_dev);
rw_destroy(&pf_rules_lock);
sx_destroy(&pf_ioctl_lock);
diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c
index f169723..3f210c2 100644
--- a/sys/netpfil/pf/pf_norm.c
+++ b/sys/netpfil/pf/pf_norm.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include "opt_pf.h"
#include <sys/param.h>
+#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mbuf.h>
#include <sys/mutex.h>
@@ -108,6 +109,7 @@ struct pf_fragment_tag {
};
static struct mtx pf_frag_mtx;
+MTX_SYSINIT(pf_frag_mtx, &pf_frag_mtx, "pf fragments", MTX_DEF);
#define PF_FRAG_LOCK() mtx_lock(&pf_frag_mtx)
#define PF_FRAG_UNLOCK() mtx_unlock(&pf_frag_mtx)
#define PF_FRAG_ASSERT() mtx_assert(&pf_frag_mtx, MA_OWNED)
@@ -197,8 +199,6 @@ pf_normalize_init(void)
uma_zone_set_max(V_pf_frent_z, PFFRAG_FRENT_HIWAT);
uma_zone_set_warning(V_pf_frent_z, "PF frag entries limit reached");
- mtx_init(&pf_frag_mtx, "pf fragments", NULL, MTX_DEF);
-
TAILQ_INIT(&V_pf_fragqueue);
TAILQ_INIT(&V_pf_cachequeue);
}
@@ -210,8 +210,6 @@ pf_normalize_cleanup(void)
uma_zdestroy(V_pf_state_scrub_z);
uma_zdestroy(V_pf_frent_z);
uma_zdestroy(V_pf_frag_z);
-
- mtx_destroy(&pf_frag_mtx);
}
static int
diff --git a/sys/ofed/drivers/net/mlx4/en_netdev.c b/sys/ofed/drivers/net/mlx4/en_netdev.c
index 68ce125..5988c0d 100644
--- a/sys/ofed/drivers/net/mlx4/en_netdev.c
+++ b/sys/ofed/drivers/net/mlx4/en_netdev.c
@@ -650,6 +650,7 @@ static void mlx4_en_cache_mclist(struct net_device *dev)
struct mlx4_en_mc_list *tmp;
struct mlx4_en_priv *priv = netdev_priv(dev);
+ if_maddr_rlock(dev);
TAILQ_FOREACH(ifma, &dev->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
@@ -658,10 +659,13 @@ static void mlx4_en_cache_mclist(struct net_device *dev)
continue;
/* Make sure the list didn't grow. */
tmp = kzalloc(sizeof(struct mlx4_en_mc_list), GFP_ATOMIC);
+ if (tmp == NULL)
+ break;
memcpy(tmp->addr,
LLADDR((struct sockaddr_dl *)ifma->ifma_addr), ETH_ALEN);
list_add_tail(&tmp->list, &priv->mc_list);
}
+ if_maddr_runlock(dev);
}
static void update_mclist_flags(struct mlx4_en_priv *priv,
diff --git a/sys/ofed/include/linux/bitops.h b/sys/ofed/include/linux/bitops.h
index f225fdc..d3f82fe 100644
--- a/sys/ofed/include/linux/bitops.h
+++ b/sys/ofed/include/linux/bitops.h
@@ -165,6 +165,8 @@ find_next_bit(unsigned long *addr, unsigned long size, unsigned long offset)
mask = (*addr) & ~BIT_MASK(offs);
if (mask)
return (bit + __ffsl(mask));
+ if (size - bit <= BITS_PER_LONG)
+ return (size);
bit += BITS_PER_LONG;
addr++;
}
@@ -203,6 +205,8 @@ find_next_zero_bit(unsigned long *addr, unsigned long size,
mask = ~(*addr) & ~BIT_MASK(offs);
if (mask)
return (bit + __ffsl(mask));
+ if (size - bit <= BITS_PER_LONG)
+ return (size);
bit += BITS_PER_LONG;
addr++;
}
diff --git a/sys/ofed/include/linux/jiffies.h b/sys/ofed/include/linux/jiffies.h
index b8757bb..dce2e15 100644
--- a/sys/ofed/include/linux/jiffies.h
+++ b/sys/ofed/include/linux/jiffies.h
@@ -42,7 +42,7 @@ msecs_to_jiffies(int msec)
tv.tv_sec = msec / 1000;
tv.tv_usec = (msec % 1000) * 1000;
- return (tvtohz(&tv));
+ return (tvtohz(&tv) - 1);
}
#define jiffies ticks
diff --git a/sys/ofed/include/linux/linux_idr.c b/sys/ofed/include/linux/linux_idr.c
index 809e178..a692fb8 100644
--- a/sys/ofed/include/linux/linux_idr.c
+++ b/sys/ofed/include/linux/linux_idr.c
@@ -185,27 +185,37 @@ out:
return (res);
}
-void *
-idr_find(struct idr *idr, int id)
+static inline void *
+idr_find_locked(struct idr *idr, int id)
{
struct idr_layer *il;
void *res;
int layer;
- res = NULL;
+ mtx_assert(&idr->lock, MA_OWNED);
+
id &= MAX_ID_MASK;
- mtx_lock(&idr->lock);
+ res = NULL;
il = idr->top;
layer = idr->layers - 1;
if (il == NULL || id > idr_max(idr))
- goto out;
+ return (NULL);
while (layer && il) {
il = il->ary[idr_pos(id, layer)];
layer--;
}
if (il != NULL)
res = il->ary[id & IDR_MASK];
-out:
+ return (res);
+}
+
+void *
+idr_find(struct idr *idr, int id)
+{
+ void *res;
+
+ mtx_lock(&idr->lock);
+ res = idr_find_locked(idr, id);
mtx_unlock(&idr->lock);
return (res);
}
@@ -331,13 +341,13 @@ idr_get_new(struct idr *idr, void *ptr, int *idp)
}
error = 0;
out:
- mtx_unlock(&idr->lock);
#ifdef INVARIANTS
- if (error == 0 && idr_find(idr, id) != ptr) {
+ if (error == 0 && idr_find_locked(idr, id) != ptr) {
panic("idr_get_new: Failed for idr %p, id %d, ptr %p\n",
idr, id, ptr);
}
#endif
+ mtx_unlock(&idr->lock);
return (error);
}
@@ -438,12 +448,12 @@ restart:
}
error = 0;
out:
- mtx_unlock(&idr->lock);
#ifdef INVARIANTS
- if (error == 0 && idr_find(idr, id) != ptr) {
+ if (error == 0 && idr_find_locked(idr, id) != ptr) {
panic("idr_get_new_above: Failed for idr %p, id %d, ptr %p\n",
idr, id, ptr);
}
#endif
+ mtx_unlock(&idr->lock);
return (error);
}
diff --git a/sys/ofed/include/linux/timer.h b/sys/ofed/include/linux/timer.h
index 0bb85b4..53ee20b 100644
--- a/sys/ofed/include/linux/timer.h
+++ b/sys/ofed/include/linux/timer.h
@@ -48,14 +48,14 @@ extern unsigned long linux_timer_hz_mask;
do { \
(timer)->function = (func); \
(timer)->data = (dat); \
- callout_init(&(timer)->timer_callout, CALLOUT_MPSAFE); \
+ callout_init(&(timer)->timer_callout, 1); \
} while (0)
#define init_timer(timer) \
do { \
(timer)->function = NULL; \
(timer)->data = 0; \
- callout_init(&(timer)->timer_callout, CALLOUT_MPSAFE); \
+ callout_init(&(timer)->timer_callout, 1); \
} while (0)
extern void mod_timer(struct timer_list *, unsigned long);
diff --git a/sys/ofed/include/linux/workqueue.h b/sys/ofed/include/linux/workqueue.h
index 38cd2fe..075016a 100644
--- a/sys/ofed/include/linux/workqueue.h
+++ b/sys/ofed/include/linux/workqueue.h
@@ -78,7 +78,7 @@ do { \
#define INIT_DELAYED_WORK(_work, func) \
do { \
INIT_WORK(&(_work)->work, func); \
- callout_init(&(_work)->timer, CALLOUT_MPSAFE); \
+ callout_init(&(_work)->timer, 1); \
} while (0)
#define INIT_DEFERRABLE_WORK INIT_DELAYED_WORK
diff --git a/sys/pc98/conf/GENERIC b/sys/pc98/conf/GENERIC
index 2312658..b826adb 100644
--- a/sys/pc98/conf/GENERIC
+++ b/sys/pc98/conf/GENERIC
@@ -71,6 +71,9 @@ options CAPABILITY_MODE # Capsicum capability mode
options CAPABILITIES # Capsicum capabilities
options MAC # TrustedBSD MAC Framework
options INCLUDE_CONFIG_FILE # Include this file in kernel
+options RACCT # Resource accounting framework
+options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default
+options RCTL # Resource limits
# Debugging support. Always need this:
options KDB # Enable kernel debugger support.
diff --git a/sys/powerpc/aim/machdep.c b/sys/powerpc/aim/aim_machdep.c
index 1c22220..ab09ab6 100644
--- a/sys/powerpc/aim/machdep.c
+++ b/sys/powerpc/aim/aim_machdep.c
@@ -129,106 +129,14 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/openfirm.h>
-int cold = 1;
#ifdef __powerpc64__
extern int n_slbs;
-int cacheline_size = 128;
-#else
-int cacheline_size = 32;
#endif
-int hw_direct_map = 1;
-
-extern void *ap_pcpu;
-
-struct pcpu __pcpu[MAXCPU];
-
-static struct trapframe frame0;
-
-char machine[] = "powerpc";
-SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, "");
-
-static void cpu_startup(void *);
-SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL);
-
-SYSCTL_INT(_machdep, CPU_CACHELINE, cacheline_size,
- CTLFLAG_RD, &cacheline_size, 0, "");
-
-uintptr_t powerpc_init(vm_offset_t, vm_offset_t, vm_offset_t, void *);
-
-long Maxmem = 0;
-long realmem = 0;
#ifndef __powerpc64__
struct bat battable[16];
#endif
-struct kva_md_info kmi;
-
-static void
-cpu_startup(void *dummy)
-{
-
- /*
- * Initialise the decrementer-based clock.
- */
- decr_init();
-
- /*
- * Good {morning,afternoon,evening,night}.
- */
- cpu_setup(PCPU_GET(cpuid));
-
-#ifdef PERFMON
- perfmon_init();
-#endif
- printf("real memory = %ld (%ld MB)\n", ptoa(physmem),
- ptoa(physmem) / 1048576);
- realmem = physmem;
-
- if (bootverbose)
- printf("available KVA = %zd (%zd MB)\n",
- virtual_end - virtual_avail,
- (virtual_end - virtual_avail) / 1048576);
-
- /*
- * 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) {
- vm_offset_t size1 =
- phys_avail[indx + 1] - phys_avail[indx];
-
- #ifdef __powerpc64__
- printf("0x%016lx - 0x%016lx, %ld bytes (%ld pages)\n",
- #else
- printf("0x%08x - 0x%08x, %d bytes (%ld pages)\n",
- #endif
- phys_avail[indx], phys_avail[indx + 1] - 1, size1,
- size1 / PAGE_SIZE);
- }
- }
-
- vm_ksubmap_init(&kmi);
-
- printf("avail memory = %ld (%ld MB)\n", ptoa(vm_cnt.v_free_count),
- ptoa(vm_cnt.v_free_count) / 1048576);
-
- /*
- * Set up buffers, so they can be used to read disk labels.
- */
- bufinit();
- vm_pager_bufferinit();
-}
-
-extern vm_offset_t __startkernel, __endkernel;
-extern unsigned char __bss_start[];
-extern unsigned char __sbss_start[];
-extern unsigned char __sbss_end[];
-extern unsigned char _end[];
-
#ifndef __powerpc64__
/* Bits for running on 64-bit systems in 32-bit mode. */
extern void *testppc64, *testppc64size;
@@ -252,121 +160,25 @@ extern void *imisstrap, *imisssize;
extern void *dlmisstrap, *dlmisssize;
extern void *dsmisstrap, *dsmisssize;
-uintptr_t
-powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp)
+extern void *ap_pcpu;
+
+void aim_cpu_init(vm_offset_t toc);
+
+void
+aim_cpu_init(vm_offset_t toc)
{
- struct pcpu *pc;
- vm_offset_t startkernel, endkernel;
size_t trap_offset, trapsize;
vm_offset_t trap;
- void *kmdp;
- char *env;
register_t msr, scratch;
uint8_t *cache_check;
int cacheline_warn;
#ifndef __powerpc64__
int ppc64;
#endif
-#ifdef DDB
- vm_offset_t ksym_start;
- vm_offset_t ksym_end;
-#endif
- kmdp = NULL;
trap_offset = 0;
cacheline_warn = 0;
- /* First guess at start/end kernel positions */
- startkernel = __startkernel;
- endkernel = __endkernel;
-
- /* Check for ePAPR loader, which puts a magic value into r6 */
- if (mdp == (void *)0x65504150)
- mdp = NULL;
-
- /*
- * Parse metadata if present and fetch parameters. Must be done
- * before console is inited so cninit gets the right value of
- * boothowto.
- */
- if (mdp != NULL) {
- preload_metadata = mdp;
- kmdp = preload_search_by_type("elf kernel");
- if (kmdp != NULL) {
- boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int);
- kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *);
- endkernel = ulmax(endkernel, MD_FETCH(kmdp,
- MODINFOMD_KERNEND, vm_offset_t));
-#ifdef DDB
- ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t);
- ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t);
- db_fetch_ksymtab(ksym_start, ksym_end);
-#endif
- }
- } else {
- bzero(__sbss_start, __sbss_end - __sbss_start);
- bzero(__bss_start, _end - __bss_start);
- }
-
- /* Store boot environment state */
- OF_initial_setup((void *)fdt, NULL, (int (*)(void *))ofentry);
-
- /*
- * Init params/tunables that can be overridden by the loader
- */
- init_param1();
-
- /*
- * Start initializing proc0 and thread0.
- */
- proc_linkup0(&proc0, &thread0);
- thread0.td_frame = &frame0;
-
- /*
- * Set up per-cpu data.
- */
- pc = __pcpu;
- pcpu_init(pc, 0, sizeof(struct pcpu));
- pc->pc_curthread = &thread0;
-#ifdef __powerpc64__
- __asm __volatile("mr 13,%0" :: "r"(pc->pc_curthread));
-#else
- __asm __volatile("mr 2,%0" :: "r"(pc->pc_curthread));
-#endif
- pc->pc_cpuid = 0;
-
- __asm __volatile("mtsprg 0, %0" :: "r"(pc));
-
- /*
- * Init mutexes, which we use heavily in PMAP
- */
-
- mutex_init();
-
- /*
- * Install the OF client interface
- */
-
- OF_bootstrap();
-
- /*
- * Initialize the console before printing anything.
- */
- cninit();
-
- /*
- * Complain if there is no metadata.
- */
- if (mdp == NULL || kmdp == NULL) {
- printf("powerpc_init: no loader metadata.\n");
- }
-
- /*
- * Init KDB
- */
-
- kdb_init();
-
/* Various very early CPU fix ups */
switch (mfpvr() >> 16) {
/*
@@ -431,9 +243,6 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp)
cacheline_size = 32;
}
- /* Make sure the kernel icache is valid before we go too much further */
- __syncicache((caddr_t)startkernel, endkernel - startkernel);
-
#ifndef __powerpc64__
/*
* Figure out whether we need to use the 64 bit PMAP. This works by
@@ -552,12 +361,6 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp)
}
/*
- * Choose a platform module so we can get the physical memory map.
- */
-
- platform_probe_and_attach();
-
- /*
* Initialise virtual memory. Use BUS_PROBE_GENERIC priority
* in case the platform module had a better idea of what we
* should do.
@@ -566,96 +369,6 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp)
pmap_mmu_install(MMU_TYPE_G5, BUS_PROBE_GENERIC);
else
pmap_mmu_install(MMU_TYPE_OEA, BUS_PROBE_GENERIC);
-
- pmap_bootstrap(startkernel, endkernel);
- mtmsr(PSL_KERNSET & ~PSL_EE);
-
- /*
- * Initialize params/tunables that are derived from memsize
- */
- init_param2(physmem);
-
- /*
- * Grab booted kernel's name
- */
- env = kern_getenv("kernelname");
- if (env != NULL) {
- strlcpy(kernelname, env, sizeof(kernelname));
- freeenv(env);
- }
-
- /*
- * Finish setting up thread0.
- */
- thread0.td_pcb = (struct pcb *)
- ((thread0.td_kstack + thread0.td_kstack_pages * PAGE_SIZE -
- sizeof(struct pcb)) & ~15UL);
- bzero((void *)thread0.td_pcb, sizeof(struct pcb));
- pc->pc_curpcb = thread0.td_pcb;
-
- /* Initialise the message buffer. */
- msgbufinit(msgbufp, msgbufsize);
-
-#ifdef KDB
- if (boothowto & RB_KDB)
- kdb_enter(KDB_WHY_BOOTFLAGS,
- "Boot flags requested debugger");
-#endif
-
- return (((uintptr_t)thread0.td_pcb -
- (sizeof(struct callframe) - 3*sizeof(register_t))) & ~15UL);
-}
-
-void
-bzero(void *buf, size_t len)
-{
- caddr_t p;
-
- p = buf;
-
- while (((vm_offset_t) p & (sizeof(u_long) - 1)) && len) {
- *p++ = 0;
- len--;
- }
-
- while (len >= sizeof(u_long) * 8) {
- *(u_long*) p = 0;
- *((u_long*) p + 1) = 0;
- *((u_long*) p + 2) = 0;
- *((u_long*) p + 3) = 0;
- len -= sizeof(u_long) * 8;
- *((u_long*) p + 4) = 0;
- *((u_long*) p + 5) = 0;
- *((u_long*) p + 6) = 0;
- *((u_long*) p + 7) = 0;
- p += sizeof(u_long) * 8;
- }
-
- while (len >= sizeof(u_long)) {
- *(u_long*) p = 0;
- len -= sizeof(u_long);
- p += sizeof(u_long);
- }
-
- while (len) {
- *p++ = 0;
- len--;
- }
-}
-
-void
-cpu_boot(int howto)
-{
-}
-
-/*
- * Flush the D-cache for non-DMA I/O so that the I-cache can
- * be made coherent later.
- */
-void
-cpu_flush_dcache(void *ptr, size_t len)
-{
- /* TBD */
}
/*
@@ -669,17 +382,6 @@ cpu_halt(void)
}
int
-ptrace_set_pc(struct thread *td, unsigned long addr)
-{
- struct trapframe *tf;
-
- tf = td->td_frame;
- tf->srr0 = (register_t)addr;
-
- return (0);
-}
-
-int
ptrace_single_step(struct thread *td)
{
struct trapframe *tf;
@@ -727,41 +429,7 @@ memcpy(pcpu->pc_slb, PCPU_GET(slb), sizeof(pcpu->pc_slb));
#endif
}
-void
-spinlock_enter(void)
-{
- struct thread *td;
- register_t msr;
-
- td = curthread;
- if (td->td_md.md_spinlock_count == 0) {
- __asm __volatile("or 2,2,2"); /* Set high thread priority */
- msr = intr_disable();
- td->td_md.md_spinlock_count = 1;
- td->td_md.md_saved_msr = msr;
- } else
- td->td_md.md_spinlock_count++;
- critical_enter();
-}
-
-void
-spinlock_exit(void)
-{
- struct thread *td;
- register_t msr;
-
- td = curthread;
- critical_exit();
- msr = td->td_md.md_saved_msr;
- td->td_md.md_spinlock_count--;
- if (td->td_md.md_spinlock_count == 0) {
- intr_restore(msr);
- __asm __volatile("or 6,6,6"); /* Set normal thread priority */
- }
-}
-
#ifndef __powerpc64__
-
uint64_t
va_to_vsid(pmap_t pm, vm_offset_t va)
{
@@ -945,3 +613,4 @@ cpu_sleep()
enable_vec(curthread);
powerpc_sync();
}
+
diff --git a/sys/powerpc/aim/mmu_oea64.c b/sys/powerpc/aim/mmu_oea64.c
index 23bd449..c45f941 100644
--- a/sys/powerpc/aim/mmu_oea64.c
+++ b/sys/powerpc/aim/mmu_oea64.c
@@ -137,8 +137,6 @@ struct ofw_map {
extern unsigned char _etext[];
extern unsigned char _end[];
-extern int ofw_real_mode;
-
/*
* Map of physical memory regions.
*/
@@ -852,8 +850,7 @@ moea64_late_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend
*/
chosen = OF_finddevice("/chosen");
- if (!ofw_real_mode && chosen != -1 &&
- OF_getprop(chosen, "mmu", &mmui, 4) != -1) {
+ if (chosen != -1 && OF_getprop(chosen, "mmu", &mmui, 4) != -1) {
mmu = OF_instance_to_package(mmui);
if (mmu == -1 ||
(sz = OF_getproplen(mmu, "translations")) == -1)
diff --git a/sys/powerpc/booke/machdep.c b/sys/powerpc/booke/booke_machdep.c
index 943063c..2a27775 100644
--- a/sys/powerpc/booke/machdep.c
+++ b/sys/powerpc/booke/booke_machdep.c
@@ -163,6 +163,7 @@ extern unsigned char __bss_start[];
extern unsigned char __sbss_start[];
extern unsigned char __sbss_end[];
extern unsigned char _end[];
+extern vm_offset_t __endkernel;
/*
* Bootinfo is passed to us by legacy loaders. Save the address of the
@@ -170,25 +171,6 @@ extern unsigned char _end[];
*/
uint32_t *bootinfo;
-struct kva_md_info kmi;
-struct pcpu __pcpu[MAXCPU];
-struct trapframe frame0;
-int cold = 1;
-long realmem = 0;
-long Maxmem = 0;
-char machine[] = "powerpc";
-SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, "");
-
-int cacheline_size = 32;
-
-SYSCTL_INT(_machdep, CPU_CACHELINE, cacheline_size,
- CTLFLAG_RD, &cacheline_size, 0, "");
-
-int hw_direct_map = 0;
-
-static void cpu_booke_startup(void *);
-SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_booke_startup, NULL);
-
void print_kernel_section_addr(void);
void print_kenv(void);
u_int booke_init(uint32_t, uint32_t);
@@ -219,6 +201,16 @@ extern void *int_performance_counter;
("Handler " #handler " too far from interrupt vector base")); \
mtspr(ivor, (uintptr_t)(&handler) & 0xffffUL);
+uintptr_t powerpc_init(vm_offset_t fdt, vm_offset_t, vm_offset_t, void *mdp);
+void booke_cpu_init(void);
+
+void
+booke_cpu_init(void)
+{
+
+ pmap_mmu_install(MMU_TYPE_BOOKE, BUS_PROBE_GENERIC);
+}
+
void
ivor_setup(void)
{
@@ -244,90 +236,6 @@ ivor_setup(void)
#endif
}
-static void
-cpu_booke_startup(void *dummy)
-{
- int indx;
- unsigned long size;
-
- /* Initialise the decrementer-based clock. */
- decr_init();
-
- /* Good {morning,afternoon,evening,night}. */
- cpu_setup(PCPU_GET(cpuid));
-
- printf("real memory = %lu (%ld MB)\n", ptoa(physmem),
- ptoa(physmem) / 1048576);
- realmem = physmem;
-
- /* Display any holes after the first chunk of extended memory. */
- if (bootverbose) {
- printf("Physical memory chunk(s):\n");
- for (indx = 0; phys_avail[indx + 1] != 0; indx += 2) {
- size = phys_avail[indx + 1] - phys_avail[indx];
-
- printf("0x%08x - 0x%08x, %lu bytes (%lu pages)\n",
- phys_avail[indx], phys_avail[indx + 1] - 1,
- size, size / PAGE_SIZE);
- }
- }
-
- vm_ksubmap_init(&kmi);
-
- printf("avail memory = %lu (%ld MB)\n", ptoa(vm_cnt.v_free_count),
- ptoa(vm_cnt.v_free_count) / 1048576);
-
- /* Set up buffers, so they can be used to read disk labels. */
- bufinit();
- vm_pager_bufferinit();
-}
-
-static char *
-kenv_next(char *cp)
-{
-
- if (cp != NULL) {
- while (*cp != 0)
- cp++;
- cp++;
- if (*cp == 0)
- cp = NULL;
- }
- return (cp);
-}
-
-void
-print_kenv(void)
-{
- int len;
- char *cp;
-
- debugf("loader passed (static) kenv:\n");
- if (kern_envp == NULL) {
- debugf(" no env, null ptr\n");
- return;
- }
- debugf(" kern_envp = 0x%08x\n", (u_int32_t)kern_envp);
-
- len = 0;
- for (cp = kern_envp; cp != NULL; cp = kenv_next(cp))
- debugf(" %x %s\n", (u_int32_t)cp, cp);
-}
-
-void
-print_kernel_section_addr(void)
-{
-
- debugf("kernel image addresses:\n");
- debugf(" kernel_text = 0x%08x\n", (uint32_t)kernel_text);
- debugf(" _etext (sdata) = 0x%08x\n", (uint32_t)_etext);
- debugf(" _edata = 0x%08x\n", (uint32_t)_edata);
- debugf(" __sbss_start = 0x%08x\n", (uint32_t)__sbss_start);
- debugf(" __sbss_end = 0x%08x\n", (uint32_t)__sbss_end);
- debugf(" __sbss_start = 0x%08x\n", (uint32_t)__bss_start);
- debugf(" _end = 0x%08x\n", (uint32_t)_end);
-}
-
static int
booke_check_for_fdt(uint32_t arg1, vm_offset_t *dtbp)
{
@@ -345,24 +253,20 @@ booke_check_for_fdt(uint32_t arg1, vm_offset_t *dtbp)
return (0);
}
-u_int
+uintptr_t
booke_init(uint32_t arg1, uint32_t arg2)
{
- struct pcpu *pc;
- void *kmdp, *mdp;
+ uintptr_t ret;
+ void *mdp;
vm_offset_t dtbp, end;
-#ifdef DDB
- vm_offset_t ksym_start;
- vm_offset_t ksym_end;
-#endif
-
- kmdp = NULL;
end = (uintptr_t)_end;
dtbp = (vm_offset_t)NULL;
/* Set up TLB initially */
bootinfo = NULL;
+ bzero(__sbss_start, __sbss_end - __sbss_start);
+ bzero(__bss_start, _end - __bss_start);
tlb1_init();
/*
@@ -391,152 +295,22 @@ booke_init(uint32_t arg1, uint32_t arg2)
memmove((void *)end, (void *)dtbp, fdt_totalsize((void *)dtbp));
dtbp = end;
end += fdt_totalsize((void *)dtbp);
+ __endkernel = end;
mdp = NULL;
} else if (arg1 > (uintptr_t)kernel_text) /* FreeBSD loader */
mdp = (void *)arg1;
else /* U-Boot */
mdp = NULL;
- /*
- * Parse metadata and fetch parameters.
- */
- if (mdp != NULL) {
- preload_metadata = mdp;
- kmdp = preload_search_by_type("elf kernel");
- if (kmdp != NULL) {
- boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int);
- kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *);
- dtbp = MD_FETCH(kmdp, MODINFOMD_DTBP, vm_offset_t);
- end = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t);
-
- bootinfo = (uint32_t *)preload_search_info(kmdp,
- MODINFO_METADATA | MODINFOMD_BOOTINFO);
-
-#ifdef DDB
- ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t);
- ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t);
- db_fetch_ksymtab(ksym_start, ksym_end);
-#endif
- }
- } else {
- bzero(__sbss_start, __sbss_end - __sbss_start);
- bzero(__bss_start, _end - __bss_start);
- }
-
-#if defined(FDT_DTB_STATIC)
- /*
- * In case the device tree blob was not retrieved (from metadata) try
- * to use the statically embedded one.
- */
- if (dtbp == (vm_offset_t)NULL)
- dtbp = (vm_offset_t)&fdt_static_dtb;
-#endif
-
- if (OF_install(OFW_FDT, 0) == FALSE)
- while (1);
-
- if (OF_init((void *)dtbp) != 0)
- while (1);
-
- OF_interpret("perform-fixup", 0);
-
/* Reset TLB1 to get rid of temporary mappings */
tlb1_init();
- /* Reset Time Base */
- mttb(0);
-
- /* Init params/tunables that can be overridden by the loader. */
- init_param1();
-
- /* Start initializing proc0 and thread0. */
- proc_linkup0(&proc0, &thread0);
- thread0.td_frame = &frame0;
-
- /* Set up per-cpu data and store the pointer in SPR general 0. */
- pc = &__pcpu[0];
- pcpu_init(pc, 0, sizeof(struct pcpu));
- pc->pc_curthread = &thread0;
-#ifdef __powerpc64__
- __asm __volatile("mr 13,%0" :: "r"(pc->pc_curthread));
-#else
- __asm __volatile("mr 2,%0" :: "r"(pc->pc_curthread));
-#endif
- __asm __volatile("mtsprg 0, %0" :: "r"(pc));
-
- /* Initialize system mutexes. */
- mutex_init();
-
- /* Initialize the console before printing anything. */
- cninit();
-
- /* Print out some debug info... */
- debugf("%s: console initialized\n", __func__);
- debugf(" arg3 mdp = 0x%08x\n", (u_int32_t)mdp);
- debugf(" end = 0x%08x\n", (u_int32_t)end);
- debugf(" boothowto = 0x%08x\n", boothowto);
-#ifdef MPC85XX
- debugf(" kernel ccsrbar = 0x%08x\n", CCSRBAR_VA);
-#endif
- debugf(" MSR = 0x%08x\n", mfmsr());
-#if defined(BOOKE_E500)
- debugf(" HID0 = 0x%08x\n", mfspr(SPR_HID0));
- debugf(" HID1 = 0x%08x\n", mfspr(SPR_HID1));
- debugf(" BUCSR = 0x%08x\n", mfspr(SPR_BUCSR));
-#endif
-
- debugf(" dtbp = 0x%08x\n", (uint32_t)dtbp);
-
- print_kernel_section_addr();
- print_kenv();
-#if defined(BOOKE_E500)
- //tlb1_print_entries();
- //tlb1_print_tlbentries();
-#endif
-
- kdb_init();
-
-#ifdef KDB
- if (boothowto & RB_KDB)
- kdb_enter(KDB_WHY_BOOTFLAGS, "Boot flags requested debugger");
-#endif
-
- /* Initialise platform module */
- platform_probe_and_attach();
-
- /* Initialise virtual memory. */
- pmap_mmu_install(MMU_TYPE_BOOKE, 0);
- pmap_bootstrap((uintptr_t)kernel_text, end);
- debugf("MSR = 0x%08x\n", mfmsr());
-#if defined(BOOKE_E500)
- //tlb1_print_entries();
- //tlb1_print_tlbentries();
-#endif
-
- /* Initialize params/tunables that are derived from memsize. */
- init_param2(physmem);
-
- /* Finish setting up thread0. */
- thread0.td_pcb = (struct pcb *)
- ((thread0.td_kstack + thread0.td_kstack_pages * PAGE_SIZE -
- sizeof(struct pcb)) & ~15);
- bzero((void *)thread0.td_pcb, sizeof(struct pcb));
- pc->pc_curpcb = thread0.td_pcb;
-
- /* Initialise the message buffer. */
- msgbufinit(msgbufp, msgbufsize);
-
- /* Enable Machine Check interrupt. */
- mtmsr(mfmsr() | PSL_ME);
- isync();
+ ret = powerpc_init(dtbp, 0, 0, mdp);
/* Enable L1 caches */
booke_enable_l1_cache();
- debugf("%s: SP = 0x%08x\n", __func__,
- ((uintptr_t)thread0.td_pcb - 16) & ~15);
-
- return (((uintptr_t)thread0.td_pcb - 16) & ~15);
+ return (ret);
}
#define RES_GRANULE 32
@@ -560,63 +334,6 @@ cpu_pcpu_init(struct pcpu *pcpu, int cpuid, size_t sz)
#endif
}
-/*
- * Flush the D-cache for non-DMA I/O so that the I-cache can
- * be made coherent later.
- */
-void
-cpu_flush_dcache(void *ptr, size_t len)
-{
- register_t addr, off;
-
- /*
- * Align the address to a cacheline and adjust the length
- * accordingly. Then round the length to a multiple of the
- * cacheline for easy looping.
- */
- addr = (uintptr_t)ptr;
- off = addr & (cacheline_size - 1);
- addr -= off;
- len = (len + off + cacheline_size - 1) & ~(cacheline_size - 1);
-
- while (len > 0) {
- __asm __volatile ("dcbf 0,%0" :: "r"(addr));
- __asm __volatile ("sync");
- addr += cacheline_size;
- len -= cacheline_size;
- }
-}
-
-void
-spinlock_enter(void)
-{
- struct thread *td;
- register_t msr;
-
- td = curthread;
- if (td->td_md.md_spinlock_count == 0) {
- msr = intr_disable();
- td->td_md.md_spinlock_count = 1;
- td->td_md.md_saved_msr = msr;
- } else
- td->td_md.md_spinlock_count++;
- critical_enter();
-}
-
-void
-spinlock_exit(void)
-{
- struct thread *td;
- register_t msr;
-
- td = curthread;
- critical_exit();
- msr = td->td_md.md_saved_msr;
- td->td_md.md_spinlock_count--;
- if (td->td_md.md_spinlock_count == 0)
- intr_restore(msr);
-}
-
/* Shutdown the CPU as much as possible. */
void
cpu_halt(void)
@@ -628,17 +345,6 @@ cpu_halt(void)
}
int
-ptrace_set_pc(struct thread *td, unsigned long addr)
-{
- struct trapframe *tf;
-
- tf = td->td_frame;
- tf->srr0 = (register_t)addr;
-
- return (0);
-}
-
-int
ptrace_single_step(struct thread *td)
{
struct trapframe *tf;
@@ -680,40 +386,3 @@ kdb_cpu_set_singlestep(void)
kdb_frame->srr1 |= PSL_DE;
}
-void
-bzero(void *buf, size_t len)
-{
- caddr_t p;
-
- p = buf;
-
- while (((vm_offset_t) p & (sizeof(u_long) - 1)) && len) {
- *p++ = 0;
- len--;
- }
-
- while (len >= sizeof(u_long) * 8) {
- *(u_long*) p = 0;
- *((u_long*) p + 1) = 0;
- *((u_long*) p + 2) = 0;
- *((u_long*) p + 3) = 0;
- len -= sizeof(u_long) * 8;
- *((u_long*) p + 4) = 0;
- *((u_long*) p + 5) = 0;
- *((u_long*) p + 6) = 0;
- *((u_long*) p + 7) = 0;
- p += sizeof(u_long) * 8;
- }
-
- while (len >= sizeof(u_long)) {
- *(u_long*) p = 0;
- len -= sizeof(u_long);
- p += sizeof(u_long);
- }
-
- while (len) {
- *p++ = 0;
- len--;
- }
-}
-
diff --git a/sys/powerpc/booke/pmap.c b/sys/powerpc/booke/pmap.c
index 2c6df63..c5e3bf3 100644
--- a/sys/powerpc/booke/pmap.c
+++ b/sys/powerpc/booke/pmap.c
@@ -1031,13 +1031,8 @@ mmu_booke_bootstrap(mmu_t mmu, vm_offset_t start, vm_offset_t kernelend)
* Align kernel start and end address (kernel image).
* Note that kernel end does not necessarily relate to kernsize.
* kernsize is the size of the kernel that is actually mapped.
- * Also note that "start - 1" is deliberate. With SMP, the
- * entry point is exactly a page from the actual load address.
- * As such, trunc_page() has no effect and we're off by a page.
- * Since we always have the ELF header between the load address
- * and the entry point, we can safely subtract 1 to compensate.
*/
- kernstart = trunc_page(start - 1);
+ kernstart = trunc_page(start);
data_start = round_page(kernelend);
data_end = data_start;
diff --git a/sys/powerpc/conf/GENERIC b/sys/powerpc/conf/GENERIC
index e3939be..4172d53 100644
--- a/sys/powerpc/conf/GENERIC
+++ b/sys/powerpc/conf/GENERIC
@@ -32,6 +32,7 @@ options PSIM #GDB PSIM ppc simulator
options MAMBO #IBM Mambo Full System Simulator
options PSERIES #PAPR-compliant systems
+options FDT
options SCHED_ULE #ULE scheduler
options PREEMPTION #Enable kernel thread preemption
options INET #InterNETworking
@@ -76,6 +77,9 @@ options MAC # TrustedBSD MAC Framework
options KDTRACE_HOOKS # Kernel DTrace hooks
options DDB_CTF # Kernel ELF linker loads CTF data
options INCLUDE_CONFIG_FILE # Include this file in kernel
+options RACCT # Resource accounting framework
+options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default
+options RCTL # Resource limits
# Debugging support. Always need this:
options KDB # Enable kernel debugger support.
diff --git a/sys/powerpc/mambo/mambo_console.c b/sys/powerpc/mambo/mambo_console.c
index c8b0ad7..1334581 100644
--- a/sys/powerpc/mambo/mambo_console.c
+++ b/sys/powerpc/mambo/mambo_console.c
@@ -89,7 +89,7 @@ cn_drvinit(void *unused)
polltime = 1;
- callout_init(&mambo_callout, CALLOUT_MPSAFE);
+ callout_init(&mambo_callout, 1);
callout_reset(&mambo_callout, polltime, mambo_timeout, NULL);
}
}
diff --git a/sys/powerpc/mpc85xx/pci_mpc85xx.c b/sys/powerpc/mpc85xx/pci_mpc85xx.c
index f1b958f..0050a98 100644
--- a/sys/powerpc/mpc85xx/pci_mpc85xx.c
+++ b/sys/powerpc/mpc85xx/pci_mpc85xx.c
@@ -570,10 +570,19 @@ fsl_pcib_init(struct fsl_pcib_softc *sc, int bus, int maxslot)
subclass = fsl_pcib_read_config(sc->sc_dev, bus, slot,
func, PCIR_SUBCLASS, 1);
+ /*
+ * The PCI Root Complex comes up as a Processor/PowerPC,
+ * but is a bridge.
+ */
/* Allow only proper PCI-PCI briges */
- if (class != PCIC_BRIDGE)
+ if (class != PCIC_BRIDGE && class != PCIC_PROCESSOR)
continue;
- if (subclass != PCIS_BRIDGE_PCI)
+ if (subclass != PCIS_BRIDGE_PCI &&
+ subclass != PCIS_PROCESSOR_POWERPC)
+ continue;
+
+ if (subclass == PCIS_PROCESSOR_POWERPC &&
+ hdrtype != PCIM_HDRTYPE_BRIDGE)
continue;
secbus++;
@@ -825,4 +834,3 @@ fsl_pcib_decode_win(phandle_t node, struct fsl_pcib_softc *sc)
return (0);
}
-
diff --git a/sys/powerpc/mpc85xx/pci_mpc85xx_pcib.c b/sys/powerpc/mpc85xx/pci_mpc85xx_pcib.c
new file mode 100644
index 0000000..934f3cc
--- /dev/null
+++ b/sys/powerpc/mpc85xx/pci_mpc85xx_pcib.c
@@ -0,0 +1,104 @@
+/*-
+ * Copyright 2015 Justin Hibbits
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce 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: FreeBSD: src/sys/powerpc/mpc85xx/pci_ocp.c,v 1.9 2010/03/23 23:46:28 marcel
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/ktr.h>
+#include <sys/sockio.h>
+#include <sys/mbuf.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/socket.h>
+#include <sys/queue.h>
+#include <sys/bus.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/rman.h>
+#include <sys/endian.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcib_private.h>
+
+#include "pcib_if.h"
+
+static int
+fsl_pcib_rc_probe(device_t dev)
+{
+ printf("Probe called\n");
+ if (pci_get_vendor(dev) != 0x1957)
+ return (ENXIO);
+ if (pci_get_progif(dev) != 0)
+ return (ENXIO);
+ if (pci_get_class(dev) != PCIC_PROCESSOR)
+ return (ENXIO);
+ if (pci_get_subclass(dev) != PCIS_PROCESSOR_POWERPC)
+ return (ENXIO);
+
+ return (BUS_PROBE_DEFAULT);
+}
+
+static int
+fsl_pcib_rc_attach(device_t dev)
+{
+ struct pcib_softc *sc;
+ device_t child;
+
+ pcib_bridge_init(dev);
+ pcib_attach_common(dev);
+
+ sc = device_get_softc(dev);
+ if (sc->bus.sec != 0) {
+ child = device_add_child(dev, "pci", -1);
+ if (child != NULL)
+ return (bus_generic_attach(dev));
+ }
+
+ return (0);
+}
+
+static device_method_t fsl_pcib_rc_methods[] = {
+ DEVMETHOD(device_probe, fsl_pcib_rc_probe),
+ DEVMETHOD(device_attach, fsl_pcib_rc_attach),
+ DEVMETHOD_END
+};
+
+static devclass_t fsl_pcib_rc_devclass;
+DEFINE_CLASS_1(pcib, fsl_pcib_rc_driver, fsl_pcib_rc_methods,
+ sizeof(struct pcib_softc), pcib_driver);
+DRIVER_MODULE(rcpcib, pci, fsl_pcib_rc_driver, fsl_pcib_rc_devclass, 0, 0);
+
diff --git a/sys/powerpc/ofw/ofw_machdep.c b/sys/powerpc/ofw/ofw_machdep.c
index 05af094..31813fb 100644
--- a/sys/powerpc/ofw/ofw_machdep.c
+++ b/sys/powerpc/ofw/ofw_machdep.c
@@ -62,11 +62,12 @@ __FBSDID("$FreeBSD$");
#include <machine/ofw_machdep.h>
#include <machine/trap.h>
+static void *fdt;
+int ofw_real_mode;
+
#ifdef AIM
extern register_t ofmsr[5];
extern void *openfirmware_entry;
-static void *fdt;
-int ofw_real_mode;
char save_trap_init[0x2f00]; /* EXC_LAST */
char save_trap_of[0x2f00]; /* EXC_LAST */
@@ -336,10 +337,10 @@ ofw_mem_regions(struct mem_region *memp, int *memsz,
*availsz = asz;
}
-#ifdef AIM
void
OF_initial_setup(void *fdt_ptr, void *junk, int (*openfirm)(void *))
{
+#ifdef AIM
ofmsr[0] = mfmsr();
#ifdef __powerpc64__
ofmsr[0] &= ~PSL_SF;
@@ -348,22 +349,25 @@ OF_initial_setup(void *fdt_ptr, void *junk, int (*openfirm)(void *))
__asm __volatile("mfsprg1 %0" : "=&r"(ofmsr[2]));
__asm __volatile("mfsprg2 %0" : "=&r"(ofmsr[3]));
__asm __volatile("mfsprg3 %0" : "=&r"(ofmsr[4]));
+ openfirmware_entry = openfirm;
if (ofmsr[0] & PSL_DR)
ofw_real_mode = 0;
else
ofw_real_mode = 1;
+ ofw_save_trap_vec(save_trap_init);
+#else
+ ofw_real_mode = 1;
+#endif
+
fdt = fdt_ptr;
- openfirmware_entry = openfirm;
#ifdef FDT_DTB_STATIC
/* Check for a statically included blob */
if (fdt == NULL)
fdt = &fdt_static_dtb;
#endif
-
- ofw_save_trap_vec(save_trap_init);
}
boolean_t
@@ -371,6 +375,7 @@ OF_bootstrap()
{
boolean_t status = FALSE;
+#ifdef AIM
if (openfirmware_entry != NULL) {
if (ofw_real_mode) {
status = OF_install(OFW_STD_REAL, 0);
@@ -386,18 +391,22 @@ OF_bootstrap()
return status;
OF_init(openfirmware);
- } else if (fdt != NULL) {
+ } else
+#endif
+ if (fdt != NULL) {
status = OF_install(OFW_FDT, 0);
if (status != TRUE)
return status;
OF_init(fdt);
+ OF_interpret("perform-fixup", 0);
}
return (status);
}
+#ifdef AIM
void
ofw_quiesce(void)
{
diff --git a/sys/powerpc/ofw/ofw_pcibus.c b/sys/powerpc/ofw/ofw_pcibus.c
index 66fa341..246b886 100644
--- a/sys/powerpc/ofw/ofw_pcibus.c
+++ b/sys/powerpc/ofw/ofw_pcibus.c
@@ -201,7 +201,8 @@ ofw_pcibus_enum_devtree(device_t dev, u_int domain, u_int busno)
* resource list.
*/
if (dinfo->opd_dinfo.cfg.intpin == 0)
- ofw_bus_intr_to_rl(dev, child, &dinfo->opd_dinfo.resources);
+ ofw_bus_intr_to_rl(dev, child,
+ &dinfo->opd_dinfo.resources, NULL);
}
}
diff --git a/sys/powerpc/powerpc/busdma_machdep.c b/sys/powerpc/powerpc/busdma_machdep.c
index bd226c8..9ea51ce 100644
--- a/sys/powerpc/powerpc/busdma_machdep.c
+++ b/sys/powerpc/powerpc/busdma_machdep.c
@@ -1121,8 +1121,8 @@ add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr,
if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) {
/* Page offset needs to be preserved. */
- bpage->vaddr |= vaddr & PAGE_MASK;
- bpage->busaddr |= vaddr & PAGE_MASK;
+ bpage->vaddr |= addr & PAGE_MASK;
+ bpage->busaddr |= addr & PAGE_MASK;
}
bpage->datavaddr = vaddr;
bpage->dataaddr = addr;
diff --git a/sys/powerpc/powerpc/db_disasm.c b/sys/powerpc/powerpc/db_disasm.c
index 67f90d2..6d525b3 100644
--- a/sys/powerpc/powerpc/db_disasm.c
+++ b/sys/powerpc/powerpc/db_disasm.c
@@ -936,7 +936,7 @@ dis_ppc(const struct opcode *opcodeset, instr_t instr, vm_offset_t loc)
}
db_addr_t
-db_disasm(db_addr_t loc, boolean_t extended)
+db_disasm(db_addr_t loc, bool extended)
{
int class;
instr_t opcode;
diff --git a/sys/powerpc/powerpc/machdep.c b/sys/powerpc/powerpc/machdep.c
new file mode 100644
index 0000000..2bc9496
--- /dev/null
+++ b/sys/powerpc/powerpc/machdep.c
@@ -0,0 +1,502 @@
+/*-
+ * Copyright (C) 1995, 1996 Wolfgang Solfrank.
+ * Copyright (C) 1995, 1996 TooLs GmbH.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with 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.
+ */
+/*-
+ * Copyright (C) 2001 Benno Rice
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND ANY EXPRESS OR
+ * 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.
+ * $NetBSD: machdep.c,v 1.74.2.1 2000/11/01 16:13:48 tv Exp $
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "opt_compat.h"
+#include "opt_ddb.h"
+#include "opt_kstack_pages.h"
+#include "opt_platform.h"
+
+#include <sys/param.h>
+#include <sys/proc.h>
+#include <sys/systm.h>
+#include <sys/bio.h>
+#include <sys/buf.h>
+#include <sys/bus.h>
+#include <sys/cons.h>
+#include <sys/cpu.h>
+#include <sys/eventhandler.h>
+#include <sys/exec.h>
+#include <sys/imgact.h>
+#include <sys/kdb.h>
+#include <sys/kernel.h>
+#include <sys/ktr.h>
+#include <sys/linker.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/msgbuf.h>
+#include <sys/mutex.h>
+#include <sys/ptrace.h>
+#include <sys/reboot.h>
+#include <sys/rwlock.h>
+#include <sys/signalvar.h>
+#include <sys/syscallsubr.h>
+#include <sys/sysctl.h>
+#include <sys/sysent.h>
+#include <sys/sysproto.h>
+#include <sys/ucontext.h>
+#include <sys/uio.h>
+#include <sys/vmmeter.h>
+#include <sys/vnode.h>
+
+#include <net/netisr.h>
+
+#include <vm/vm.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_kern.h>
+#include <vm/vm_page.h>
+#include <vm/vm_map.h>
+#include <vm/vm_object.h>
+#include <vm/vm_pager.h>
+
+#include <machine/altivec.h>
+#ifndef __powerpc64__
+#include <machine/bat.h>
+#endif
+#include <machine/cpu.h>
+#include <machine/elf.h>
+#include <machine/fpu.h>
+#include <machine/hid.h>
+#include <machine/kdb.h>
+#include <machine/md_var.h>
+#include <machine/metadata.h>
+#include <machine/mmuvar.h>
+#include <machine/pcb.h>
+#include <machine/reg.h>
+#include <machine/sigframe.h>
+#include <machine/spr.h>
+#include <machine/trap.h>
+#include <machine/vmparam.h>
+#include <machine/ofw_machdep.h>
+
+#include <ddb/ddb.h>
+
+#include <dev/ofw/openfirm.h>
+
+int cold = 1;
+#ifdef __powerpc64__
+int cacheline_size = 128;
+#else
+int cacheline_size = 32;
+#endif
+int hw_direct_map = 1;
+
+extern void *ap_pcpu;
+
+struct pcpu __pcpu[MAXCPU];
+
+static struct trapframe frame0;
+
+char machine[] = "powerpc";
+SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, "");
+
+static void cpu_startup(void *);
+SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL);
+
+SYSCTL_INT(_machdep, CPU_CACHELINE, cacheline_size,
+ CTLFLAG_RD, &cacheline_size, 0, "");
+
+uintptr_t powerpc_init(vm_offset_t, vm_offset_t, vm_offset_t, void *);
+
+long Maxmem = 0;
+long realmem = 0;
+
+struct kva_md_info kmi;
+
+static void
+cpu_startup(void *dummy)
+{
+
+ /*
+ * Initialise the decrementer-based clock.
+ */
+ decr_init();
+
+ /*
+ * Good {morning,afternoon,evening,night}.
+ */
+ cpu_setup(PCPU_GET(cpuid));
+
+#ifdef PERFMON
+ perfmon_init();
+#endif
+ printf("real memory = %ld (%ld MB)\n", ptoa(physmem),
+ ptoa(physmem) / 1048576);
+ realmem = physmem;
+
+ if (bootverbose)
+ printf("available KVA = %zd (%zd MB)\n",
+ virtual_end - virtual_avail,
+ (virtual_end - virtual_avail) / 1048576);
+
+ /*
+ * 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) {
+ vm_offset_t size1 =
+ phys_avail[indx + 1] - phys_avail[indx];
+
+ #ifdef __powerpc64__
+ printf("0x%016lx - 0x%016lx, %ld bytes (%ld pages)\n",
+ #else
+ printf("0x%08x - 0x%08x, %d bytes (%ld pages)\n",
+ #endif
+ phys_avail[indx], phys_avail[indx + 1] - 1, size1,
+ size1 / PAGE_SIZE);
+ }
+ }
+
+ vm_ksubmap_init(&kmi);
+
+ printf("avail memory = %ld (%ld MB)\n", ptoa(vm_cnt.v_free_count),
+ ptoa(vm_cnt.v_free_count) / 1048576);
+
+ /*
+ * Set up buffers, so they can be used to read disk labels.
+ */
+ bufinit();
+ vm_pager_bufferinit();
+}
+
+extern vm_offset_t __startkernel, __endkernel;
+extern unsigned char __bss_start[];
+extern unsigned char __sbss_start[];
+extern unsigned char __sbss_end[];
+extern unsigned char _end[];
+
+void aim_cpu_init(vm_offset_t toc);
+void booke_cpu_init(void);
+
+uintptr_t
+powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp)
+{
+ struct pcpu *pc;
+ vm_offset_t startkernel, endkernel;
+ void *kmdp;
+ char *env;
+#ifdef DDB
+ vm_offset_t ksym_start;
+ vm_offset_t ksym_end;
+#endif
+
+ kmdp = NULL;
+
+ /* First guess at start/end kernel positions */
+ startkernel = __startkernel;
+ endkernel = __endkernel;
+
+ /* Check for ePAPR loader, which puts a magic value into r6 */
+ if (mdp == (void *)0x65504150)
+ mdp = NULL;
+
+ /*
+ * Parse metadata if present and fetch parameters. Must be done
+ * before console is inited so cninit gets the right value of
+ * boothowto.
+ */
+ if (mdp != NULL) {
+ preload_metadata = mdp;
+ kmdp = preload_search_by_type("elf kernel");
+ if (kmdp != NULL) {
+ boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int);
+ kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *);
+ endkernel = ulmax(endkernel, MD_FETCH(kmdp,
+ MODINFOMD_KERNEND, vm_offset_t));
+#ifdef DDB
+ ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t);
+ ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t);
+ db_fetch_ksymtab(ksym_start, ksym_end);
+#endif
+ }
+ } else {
+ bzero(__sbss_start, __sbss_end - __sbss_start);
+ bzero(__bss_start, _end - __bss_start);
+ }
+#ifdef BOOKE
+ tlb1_init();
+#endif
+
+ /* Store boot environment state */
+ OF_initial_setup((void *)fdt, NULL, (int (*)(void *))ofentry);
+
+ /*
+ * Init params/tunables that can be overridden by the loader
+ */
+ init_param1();
+
+ /*
+ * Start initializing proc0 and thread0.
+ */
+ proc_linkup0(&proc0, &thread0);
+ thread0.td_frame = &frame0;
+
+ /*
+ * Set up per-cpu data.
+ */
+ pc = __pcpu;
+ pcpu_init(pc, 0, sizeof(struct pcpu));
+ pc->pc_curthread = &thread0;
+#ifdef __powerpc64__
+ __asm __volatile("mr 13,%0" :: "r"(pc->pc_curthread));
+#else
+ __asm __volatile("mr 2,%0" :: "r"(pc->pc_curthread));
+#endif
+ pc->pc_cpuid = 0;
+
+ __asm __volatile("mtsprg 0, %0" :: "r"(pc));
+
+ /*
+ * Init mutexes, which we use heavily in PMAP
+ */
+
+ mutex_init();
+
+ /*
+ * Install the OF client interface
+ */
+
+ OF_bootstrap();
+
+ /*
+ * Initialize the console before printing anything.
+ */
+ cninit();
+
+ /*
+ * Complain if there is no metadata.
+ */
+ if (mdp == NULL || kmdp == NULL) {
+ printf("powerpc_init: no loader metadata.\n");
+ }
+
+ /*
+ * Init KDB
+ */
+
+ kdb_init();
+
+#ifdef AIM
+ aim_cpu_init(toc);
+#else /* BOOKE */
+ booke_cpu_init();
+
+ /* Make sure the kernel icache is valid before we go too much further */
+ __syncicache((caddr_t)startkernel, endkernel - startkernel);
+#endif
+
+ /*
+ * Choose a platform module so we can get the physical memory map.
+ */
+
+ platform_probe_and_attach();
+
+ /*
+ * Bring up MMU
+ */
+ pmap_bootstrap(startkernel, endkernel);
+ mtmsr(PSL_KERNSET & ~PSL_EE);
+
+ /*
+ * Initialize params/tunables that are derived from memsize
+ */
+ init_param2(physmem);
+
+ /*
+ * Grab booted kernel's name
+ */
+ env = kern_getenv("kernelname");
+ if (env != NULL) {
+ strlcpy(kernelname, env, sizeof(kernelname));
+ freeenv(env);
+ }
+
+ /*
+ * Finish setting up thread0.
+ */
+ thread0.td_pcb = (struct pcb *)
+ ((thread0.td_kstack + thread0.td_kstack_pages * PAGE_SIZE -
+ sizeof(struct pcb)) & ~15UL);
+ bzero((void *)thread0.td_pcb, sizeof(struct pcb));
+ pc->pc_curpcb = thread0.td_pcb;
+
+ /* Initialise the message buffer. */
+ msgbufinit(msgbufp, msgbufsize);
+
+#ifdef KDB
+ if (boothowto & RB_KDB)
+ kdb_enter(KDB_WHY_BOOTFLAGS,
+ "Boot flags requested debugger");
+#endif
+
+ return (((uintptr_t)thread0.td_pcb -
+ (sizeof(struct callframe) - 3*sizeof(register_t))) & ~15UL);
+}
+
+void
+bzero(void *buf, size_t len)
+{
+ caddr_t p;
+
+ p = buf;
+
+ while (((vm_offset_t) p & (sizeof(u_long) - 1)) && len) {
+ *p++ = 0;
+ len--;
+ }
+
+ while (len >= sizeof(u_long) * 8) {
+ *(u_long*) p = 0;
+ *((u_long*) p + 1) = 0;
+ *((u_long*) p + 2) = 0;
+ *((u_long*) p + 3) = 0;
+ len -= sizeof(u_long) * 8;
+ *((u_long*) p + 4) = 0;
+ *((u_long*) p + 5) = 0;
+ *((u_long*) p + 6) = 0;
+ *((u_long*) p + 7) = 0;
+ p += sizeof(u_long) * 8;
+ }
+
+ while (len >= sizeof(u_long)) {
+ *(u_long*) p = 0;
+ len -= sizeof(u_long);
+ p += sizeof(u_long);
+ }
+
+ while (len) {
+ *p++ = 0;
+ len--;
+ }
+}
+
+/*
+ * Flush the D-cache for non-DMA I/O so that the I-cache can
+ * be made coherent later.
+ */
+void
+cpu_flush_dcache(void *ptr, size_t len)
+{
+ register_t addr, off;
+
+ /*
+ * Align the address to a cacheline and adjust the length
+ * accordingly. Then round the length to a multiple of the
+ * cacheline for easy looping.
+ */
+ addr = (uintptr_t)ptr;
+ off = addr & (cacheline_size - 1);
+ addr -= off;
+ len = (len + off + cacheline_size - 1) & ~(cacheline_size - 1);
+
+ while (len > 0) {
+ __asm __volatile ("dcbf 0,%0" :: "r"(addr));
+ __asm __volatile ("sync");
+ addr += cacheline_size;
+ len -= cacheline_size;
+ }
+}
+
+int
+ptrace_set_pc(struct thread *td, unsigned long addr)
+{
+ struct trapframe *tf;
+
+ tf = td->td_frame;
+ tf->srr0 = (register_t)addr;
+
+ return (0);
+}
+
+void
+spinlock_enter(void)
+{
+ struct thread *td;
+ register_t msr;
+
+ td = curthread;
+ if (td->td_md.md_spinlock_count == 0) {
+ __asm __volatile("or 2,2,2"); /* Set high thread priority */
+ msr = intr_disable();
+ td->td_md.md_spinlock_count = 1;
+ td->td_md.md_saved_msr = msr;
+ } else
+ td->td_md.md_spinlock_count++;
+ critical_enter();
+}
+
+void
+spinlock_exit(void)
+{
+ struct thread *td;
+ register_t msr;
+
+ td = curthread;
+ critical_exit();
+ msr = td->td_md.md_saved_msr;
+ td->td_md.md_spinlock_count--;
+ if (td->td_md.md_spinlock_count == 0) {
+ intr_restore(msr);
+ __asm __volatile("or 6,6,6"); /* Set normal thread priority */
+ }
+}
+
diff --git a/sys/powerpc/aim/uma_machdep.c b/sys/powerpc/powerpc/uma_machdep.c
index 1c27e3e..1c27e3e 100644
--- a/sys/powerpc/aim/uma_machdep.c
+++ b/sys/powerpc/powerpc/uma_machdep.c
diff --git a/sys/powerpc/pseries/phyp_console.c b/sys/powerpc/pseries/phyp_console.c
index 79d9094..261f92b 100644
--- a/sys/powerpc/pseries/phyp_console.c
+++ b/sys/powerpc/pseries/phyp_console.c
@@ -256,7 +256,7 @@ uart_phyp_attach(device_t dev)
bus_setup_intr(dev, sc->irqres, INTR_TYPE_TTY | INTR_MPSAFE,
NULL, uart_phyp_intr, sc, &sc->sc_icookie);
} else {
- callout_init(&sc->callout, CALLOUT_MPSAFE);
+ callout_init(&sc->callout, 1);
sc->polltime = hz / 20;
if (sc->polltime < 1)
sc->polltime = 1;
diff --git a/sys/powerpc/pseries/vdevice.c b/sys/powerpc/pseries/vdevice.c
index 2ec4c33..2323bc7 100644
--- a/sys/powerpc/pseries/vdevice.c
+++ b/sys/powerpc/pseries/vdevice.c
@@ -146,7 +146,7 @@ vdevice_attach(device_t dev)
}
resource_list_init(&dinfo->mdi_resources);
- ofw_bus_intr_to_rl(dev, child, &dinfo->mdi_resources);
+ ofw_bus_intr_to_rl(dev, child, &dinfo->mdi_resources, NULL);
cdev = device_add_child(dev, NULL, -1);
if (cdev == NULL) {
diff --git a/sys/sparc64/conf/GENERIC b/sys/sparc64/conf/GENERIC
index 5685185..f602eeb 100644
--- a/sys/sparc64/conf/GENERIC
+++ b/sys/sparc64/conf/GENERIC
@@ -67,6 +67,9 @@ options CAPABILITY_MODE # Capsicum capability mode
options CAPABILITIES # Capsicum capabilities
options MAC # TrustedBSD MAC Framework
options INCLUDE_CONFIG_FILE # Include this file in kernel
+options RACCT # Resource accounting framework
+options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default
+options RCTL # Resource limits
# Debugging support. Always need this:
options KDB # Enable kernel debugger support.
diff --git a/sys/sparc64/sparc64/db_disasm.c b/sys/sparc64/sparc64/db_disasm.c
index a20219e..55e2109 100644
--- a/sys/sparc64/sparc64/db_disasm.c
+++ b/sys/sparc64/sparc64/db_disasm.c
@@ -803,7 +803,7 @@ static const struct sparc_insn sparc_i[] = {
};
db_addr_t
-db_disasm(db_addr_t loc, boolean_t altfmt)
+db_disasm(db_addr_t loc, bool altfmt)
{
const struct sparc_insn* i_ptr = (struct sparc_insn *)&sparc_i;
unsigned int insn, you_lose, bitmask;
diff --git a/sys/sys/callout.h b/sys/sys/callout.h
index 6e18ae7..5e21164 100644
--- a/sys/sys/callout.h
+++ b/sys/sys/callout.h
@@ -43,7 +43,7 @@
#define CALLOUT_LOCAL_ALLOC 0x0001 /* was allocated from callfree */
#define CALLOUT_ACTIVE 0x0002 /* callout is currently active */
#define CALLOUT_PENDING 0x0004 /* callout is waiting for timeout */
-#define CALLOUT_MPSAFE 0x0008 /* callout handler is mp safe */
+#define CALLOUT_MPSAFE 0x0008 /* deprecated */
#define CALLOUT_RETURNUNLOCKED 0x0010 /* handler returns with mtx unlocked */
#define CALLOUT_SHAREDLOCK 0x0020 /* callout lock held in shared mode */
#define CALLOUT_DFRMIGRATION 0x0040 /* callout in deferred migration mode */
diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index ab7d59d..82cdc6e 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -375,10 +375,8 @@
#endif
#if __GNUC_PREREQ__(4, 1)
-#define __gnu_inline __attribute__((__gnu_inline__))
#define __returns_twice __attribute__((__returns_twice__))
#else
-#define __gnu_inline
#define __returns_twice
#endif
@@ -388,6 +386,12 @@
#define __alloc_size(x)
#endif
+#if __has_builtin(__builtin_unreachable) || __GNUC_PREREQ__(4, 6)
+#define __unreachable() __builtin_unreachable()
+#else
+#define __unreachable() ((void)0)
+#endif
+
#if __has_attribute(alloc_align) || __GNUC_PREREQ__(4, 9)
#define __alloc_align(x) __attribute__((__alloc_align__(x)))
#else
@@ -464,7 +468,7 @@
#define __predict_false(exp) (exp)
#endif
-#if __GNUC_PREREQ__(4, 2)
+#if __GNUC_PREREQ__(4, 0)
#define __hidden __attribute__((__visibility__("hidden")))
#define __exported __attribute__((__visibility__("default")))
#else
@@ -532,6 +536,22 @@
__attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
#endif
+/*
+ * FORTIFY_SOURCE, and perhaps other compiler-specific features, require
+ * the use of non-standard inlining. In general we should try to avoid
+ * using these but GCC-compatible compilers tend to support the extensions
+ * well enough to use them in limited cases.
+ */
+#if __GNUC_PREREQ__(4, 1)
+#if __has_attribute(artificial) || __GNUC_PREREQ__(4, 3)
+#define __gnu_inline __attribute__((__gnu_inline__, __artificial__))
+#else
+#define __gnu_inline __attribute__((__gnu_inline__))
+#endif /* artificial */
+#else
+#define __gnu_inline
+#endif
+
/* Compiler-dependent macros that rely on FreeBSD-specific extensions. */
#if defined(__FreeBSD_cc_version) && __FreeBSD_cc_version >= 300001 && \
defined(__GNUC__) && !defined(__INTEL_COMPILER)
diff --git a/sys/sys/diskmbr.h b/sys/sys/diskmbr.h
index cb05ffa..5f49eb9 100644
--- a/sys/sys/diskmbr.h
+++ b/sys/sys/diskmbr.h
@@ -51,11 +51,13 @@
#define DOSPTYP_EXTLBA 0x0f /* DOS extended partition */
#define DOSPTYP_PPCBOOT 0x41 /* PReP/CHRP boot partition */
#define DOSPTYP_LDM 0x42 /* Win2k dynamic extended partition */
-#define DOSPTYP_386BSD 0xa5 /* 386BSD partition type */
-#define DOSPTYP_HFS 0xaf /* HFS/HFS+ partition type */
#define DOSPTYP_LINSWP 0x82 /* Linux swap partition */
#define DOSPTYP_LINUX 0x83 /* Linux partition */
#define DOSPTYP_LINLVM 0x8e /* Linux LVM partition */
+#define DOSPTYP_386BSD 0xa5 /* 386BSD partition type */
+#define DOSPTYP_APPLE_UFS 0xa8 /* Apple Mac OS X boot */
+#define DOSPTYP_APPLE_BOOT 0xab /* Apple Mac OS X UFS */
+#define DOSPTYP_HFS 0xaf /* HFS/HFS+ partition type */
#define DOSPTYP_PMBR 0xee /* GPT Protective MBR */
#define DOSPTYP_EFI 0xef /* EFI FAT parition */
#define DOSPTYP_VMFS 0xfb /* VMware VMFS partition */
diff --git a/sys/sys/elf_common.h b/sys/sys/elf_common.h
index aa06c70..d429e86 100644
--- a/sys/sys/elf_common.h
+++ b/sys/sys/elf_common.h
@@ -202,6 +202,7 @@ typedef struct {
#define EM_386 3 /* Intel i386. */
#define EM_68K 4 /* Motorola 68000. */
#define EM_88K 5 /* Motorola 88000. */
+#define EM_IAMCU 6 /* Intel MCU. */
#define EM_860 7 /* Intel i860. */
#define EM_MIPS 8 /* MIPS R3000 Big-Endian only. */
#define EM_S370 9 /* IBM System/370. */
@@ -472,6 +473,9 @@ typedef struct {
#define SHF_MASKOS 0x0ff00000 /* OS-specific semantics. */
#define SHF_MASKPROC 0xf0000000 /* Processor-specific semantics. */
+/* Flags for section groups. */
+#define GRP_COMDAT 0x1 /* COMDAT semantics. */
+
/* Values for p_type. */
#define PT_NULL 0 /* Unused entry. */
#define PT_LOAD 1 /* Loadable segment. */
diff --git a/sys/sys/imgact.h b/sys/sys/imgact.h
index ac88a14..4a5ce9c 100644
--- a/sys/sys/imgact.h
+++ b/sys/sys/imgact.h
@@ -86,6 +86,7 @@ struct image_params {
#ifdef _KERNEL
struct sysentvec;
struct thread;
+struct vmspace;
#define IMGACT_CORE_COMPRESS 0x01
@@ -98,6 +99,8 @@ void exec_setregs(struct thread *, struct image_params *, u_long);
int exec_shell_imgact(struct image_params *);
int exec_copyin_args(struct image_args *, char *, enum uio_seg,
char **, char **);
+int pre_execve(struct thread *td, struct vmspace **oldvmspace);
+void post_execve(struct thread *td, int error, struct vmspace *oldvmspace);
#endif
#endif /* !_SYS_IMGACT_H_ */
diff --git a/sys/sys/imgact_elf.h b/sys/sys/imgact_elf.h
index e8d5567..d1d4f21 100644
--- a/sys/sys/imgact_elf.h
+++ b/sys/sys/imgact_elf.h
@@ -52,6 +52,7 @@ typedef struct {
Elf_Size base;
Elf_Size flags;
Elf_Size entry;
+ Elf_Word hdr_eflags; /* e_flags field from ehdr */
} __ElfN(Auxargs);
typedef struct {
diff --git a/sys/sys/ktr.h b/sys/sys/ktr.h
index 6135bc0..07d7c45 100644
--- a/sys/sys/ktr.h
+++ b/sys/sys/ktr.h
@@ -62,7 +62,7 @@ struct ktr_entry {
};
extern cpuset_t ktr_cpumask;
-extern int ktr_mask;
+extern uint64_t ktr_mask;
extern int ktr_entries;
extern int ktr_verbose;
@@ -71,7 +71,7 @@ extern struct ktr_entry *ktr_buf;
#ifdef KTR
-void ktr_tracepoint(u_int mask, const char *file, int line,
+void ktr_tracepoint(uint64_t mask, const char *file, int line,
const char *format, u_long arg1, u_long arg2, u_long arg3,
u_long arg4, u_long arg5, u_long arg6);
diff --git a/sys/sys/malloc.h b/sys/sys/malloc.h
index 6b8a9c0..c09d749 100644
--- a/sys/sys/malloc.h
+++ b/sys/sys/malloc.h
@@ -174,7 +174,7 @@ void contigfree(void *addr, unsigned long size, struct malloc_type *type);
void *contigmalloc(unsigned long size, struct malloc_type *type, int flags,
vm_paddr_t low, vm_paddr_t high, unsigned long alignment,
vm_paddr_t boundary) __malloc_like __result_use_check
- __alloc_size(1);
+ __alloc_size(1) __alloc_align(6);
void free(void *addr, struct malloc_type *type);
void *malloc(unsigned long size, struct malloc_type *type, int flags)
__malloc_like __result_use_check __alloc_size(1);
diff --git a/sys/sys/module.h b/sys/sys/module.h
index 69b74ff..4582bf9 100644
--- a/sys/sys/module.h
+++ b/sys/sys/module.h
@@ -107,7 +107,8 @@ struct mod_metadata {
DATA_SET(modmetadata_set, _mod_metadata##uniquifier)
#define MODULE_DEPEND(module, mdepend, vmin, vpref, vmax) \
- static struct mod_depend _##module##_depend_on_##mdepend = { \
+ static struct mod_depend _##module##_depend_on_##mdepend \
+ __section(".data") = { \
vmin, \
vpref, \
vmax \
@@ -147,7 +148,8 @@ struct mod_metadata {
DECLARE_MODULE_WITH_MAXVER(name, data, sub, order, __FreeBSD_version)
#define MODULE_VERSION(module, version) \
- static struct mod_version _##module##_version = { \
+ static struct mod_version _##module##_version \
+ __section(".data") = { \
version \
}; \
MODULE_METADATA(_##module##_version, MDT_VERSION, \
diff --git a/sys/sys/mouse.h b/sys/sys/mouse.h
index 5329693..24d0ffc 100644
--- a/sys/sys/mouse.h
+++ b/sys/sys/mouse.h
@@ -128,6 +128,13 @@ typedef struct synapticshw {
int verticalScroll;
int horizontalScroll;
int verticalWheel;
+ int capEWmode;
+ int minimumXCoord;
+ int minimumYCoord;
+ int maximumXCoord;
+ int maximumYCoord;
+ int infoXupmm;
+ int infoYupmm;
} synapticshw_t;
/* iftype */
diff --git a/sys/sys/nv.h b/sys/sys/nv.h
index 0876e57..fa5d138 100644
--- a/sys/sys/nv.h
+++ b/sys/sys/nv.h
@@ -64,6 +64,10 @@ typedef struct nvlist nvlist_t;
* Perform case-insensitive lookups of provided names.
*/
#define NV_FLAG_IGNORE_CASE 0x01
+/*
+ * Names don't have to be unique.
+ */
+#define NV_FLAG_NO_UNIQUE 0x02
#if defined(_KERNEL) && defined(MALLOC_DECLARE)
MALLOC_DECLARE(M_NVLIST);
@@ -75,6 +79,7 @@ nvlist_t *nvlist_create(int flags);
void nvlist_destroy(nvlist_t *nvl);
int nvlist_error(const nvlist_t *nvl);
bool nvlist_empty(const nvlist_t *nvl);
+int nvlist_flags(const nvlist_t *nvl);
void nvlist_set_error(nvlist_t *nvl, int error);
nvlist_t *nvlist_clone(const nvlist_t *nvl);
@@ -86,11 +91,11 @@ void nvlist_fdump(const nvlist_t *nvl, FILE *fp);
size_t nvlist_size(const nvlist_t *nvl);
void *nvlist_pack(const nvlist_t *nvl, size_t *sizep);
-nvlist_t *nvlist_unpack(const void *buf, size_t size);
+nvlist_t *nvlist_unpack(const void *buf, size_t size, int flags);
int nvlist_send(int sock, const nvlist_t *nvl);
-nvlist_t *nvlist_recv(int sock);
-nvlist_t *nvlist_xfer(int sock, nvlist_t *nvl);
+nvlist_t *nvlist_recv(int sock, int flags);
+nvlist_t *nvlist_xfer(int sock, nvlist_t *nvl, int flags);
const char *nvlist_next(const nvlist_t *nvl, int *typep, void **cookiep);
@@ -194,129 +199,6 @@ void nvlist_free_descriptor(nvlist_t *nvl, const char *name);
#endif
void nvlist_free_binary(nvlist_t *nvl, const char *name);
-/*
- * Below are the same functions, but which operate on format strings and
- * variable argument lists.
- *
- * Functions that are not inserting a new pair into the nvlist cannot handle
- * a failure to allocate the memory to hold the new name. Therefore these
- * functions are not provided in the kernel.
- */
-
-#ifndef _KERNEL
-bool nvlist_existsf(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-bool nvlist_existsf_type(const nvlist_t *nvl, int type, const char *namefmt, ...) __printflike(3, 4);
-
-bool nvlist_existsf_null(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-bool nvlist_existsf_bool(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-bool nvlist_existsf_number(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-bool nvlist_existsf_string(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-bool nvlist_existsf_nvlist(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-bool nvlist_existsf_descriptor(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-bool nvlist_existsf_binary(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-
-bool nvlist_existsv(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-bool nvlist_existsv_type(const nvlist_t *nvl, int type, const char *namefmt, va_list nameap) __printflike(3, 0);
-
-bool nvlist_existsv_null(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-bool nvlist_existsv_bool(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-bool nvlist_existsv_number(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-bool nvlist_existsv_string(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-bool nvlist_existsv_nvlist(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-bool nvlist_existsv_descriptor(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-bool nvlist_existsv_binary(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-#endif
-
-void nvlist_addf_null(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-void nvlist_addf_bool(nvlist_t *nvl, bool value, const char *namefmt, ...) __printflike(3, 4);
-void nvlist_addf_number(nvlist_t *nvl, uint64_t value, const char *namefmt, ...) __printflike(3, 4);
-void nvlist_addf_string(nvlist_t *nvl, const char *value, const char *namefmt, ...) __printflike(3, 4);
-void nvlist_addf_nvlist(nvlist_t *nvl, const nvlist_t *value, const char *namefmt, ...) __printflike(3, 4);
-#ifndef _KERNEL
-void nvlist_addf_descriptor(nvlist_t *nvl, int value, const char *namefmt, ...) __printflike(3, 4);
-#endif
-void nvlist_addf_binary(nvlist_t *nvl, const void *value, size_t size, const char *namefmt, ...) __printflike(4, 5);
-
-#if !defined(_KERNEL) || defined(_VA_LIST_DECLARED)
-void nvlist_addv_null(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-void nvlist_addv_bool(nvlist_t *nvl, bool value, const char *namefmt, va_list nameap) __printflike(3, 0);
-void nvlist_addv_number(nvlist_t *nvl, uint64_t value, const char *namefmt, va_list nameap) __printflike(3, 0);
-void nvlist_addv_string(nvlist_t *nvl, const char *value, const char *namefmt, va_list nameap) __printflike(3, 0);
-void nvlist_addv_nvlist(nvlist_t *nvl, const nvlist_t *value, const char *namefmt, va_list nameap) __printflike(3, 0);
-#ifndef _KERNEL
-void nvlist_addv_descriptor(nvlist_t *nvl, int value, const char *namefmt, va_list nameap) __printflike(3, 0);
-#endif
-void nvlist_addv_binary(nvlist_t *nvl, const void *value, size_t size, const char *namefmt, va_list nameap) __printflike(4, 0);
-#endif
-
-void nvlist_movef_string(nvlist_t *nvl, char *value, const char *namefmt, ...) __printflike(3, 4);
-void nvlist_movef_nvlist(nvlist_t *nvl, nvlist_t *value, const char *namefmt, ...) __printflike(3, 4);
-#ifndef _KERNEL
-void nvlist_movef_descriptor(nvlist_t *nvl, int value, const char *namefmt, ...) __printflike(3, 4);
-#endif
-void nvlist_movef_binary(nvlist_t *nvl, void *value, size_t size, const char *namefmt, ...) __printflike(4, 5);
-
-#if !defined(_KERNEL) || defined(_VA_LIST_DECLARED)
-void nvlist_movev_string(nvlist_t *nvl, char *value, const char *namefmt, va_list nameap) __printflike(3, 0);
-void nvlist_movev_nvlist(nvlist_t *nvl, nvlist_t *value, const char *namefmt, va_list nameap) __printflike(3, 0);
-#ifndef _KERNEL
-void nvlist_movev_descriptor(nvlist_t *nvl, int value, const char *namefmt, va_list nameap) __printflike(3, 0);
-#endif
-void nvlist_movev_binary(nvlist_t *nvl, void *value, size_t size, const char *namefmt, va_list nameap) __printflike(4, 0);
-#endif
-
-#ifndef _KERNEL
-bool nvlist_getf_bool(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-uint64_t nvlist_getf_number(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-const char *nvlist_getf_string(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-const nvlist_t *nvlist_getf_nvlist(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-int nvlist_getf_descriptor(const nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-const void *nvlist_getf_binary(const nvlist_t *nvl, size_t *sizep, const char *namefmt, ...) __printflike(3, 4);
-
-bool nvlist_getv_bool(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-uint64_t nvlist_getv_number(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-const char *nvlist_getv_string(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-const nvlist_t *nvlist_getv_nvlist(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-int nvlist_getv_descriptor(const nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-const void *nvlist_getv_binary(const nvlist_t *nvl, size_t *sizep, const char *namefmt, va_list nameap) __printflike(3, 0);
-
-bool nvlist_takef_bool(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-uint64_t nvlist_takef_number(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-char *nvlist_takef_string(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-nvlist_t *nvlist_takef_nvlist(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-int nvlist_takef_descriptor(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-void *nvlist_takef_binary(nvlist_t *nvl, size_t *sizep, const char *namefmt, ...) __printflike(3, 4);
-
-bool nvlist_takev_bool(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-uint64_t nvlist_takev_number(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-char *nvlist_takev_string(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-nvlist_t *nvlist_takev_nvlist(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-int nvlist_takev_descriptor(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-void *nvlist_takev_binary(nvlist_t *nvl, size_t *sizep, const char *namefmt, va_list nameap) __printflike(3, 0);
-
-void nvlist_freef(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-void nvlist_freef_type(nvlist_t *nvl, int type, const char *namefmt, ...) __printflike(3, 4);
-
-void nvlist_freef_null(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-void nvlist_freef_bool(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-void nvlist_freef_number(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-void nvlist_freef_string(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-void nvlist_freef_nvlist(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-void nvlist_freef_descriptor(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-void nvlist_freef_binary(nvlist_t *nvl, const char *namefmt, ...) __printflike(2, 3);
-
-void nvlist_freev(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-void nvlist_freev_type(nvlist_t *nvl, int type, const char *namefmt, va_list nameap) __printflike(3, 0);
-
-void nvlist_freev_null(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-void nvlist_freev_bool(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-void nvlist_freev_number(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-void nvlist_freev_string(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-void nvlist_freev_nvlist(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-void nvlist_freev_descriptor(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-void nvlist_freev_binary(nvlist_t *nvl, const char *namefmt, va_list nameap) __printflike(2, 0);
-#endif /* _KERNEL */
-
__END_DECLS
#endif /* !_NV_H_ */
diff --git a/sys/sys/nv_impl.h b/sys/sys/nv_impl.h
index da90e79..c088c3d 100644
--- a/sys/sys/nv_impl.h
+++ b/sys/sys/nv_impl.h
@@ -41,23 +41,24 @@ typedef struct nvpair nvpair_t;
#define NV_TYPE_NVLIST_UP 255
-#define NV_TYPE_FIRST NV_TYPE_NULL
-#define NV_TYPE_LAST NV_TYPE_BINARY
+#define NV_TYPE_FIRST NV_TYPE_NULL
+#define NV_TYPE_LAST NV_TYPE_BINARY
#define NV_FLAG_BIG_ENDIAN 0x80
#ifdef _KERNEL
-#define nv_malloc(size) malloc((size), M_NVLIST, M_NOWAIT)
+#define nv_malloc(size) malloc((size), M_NVLIST, M_WAITOK)
#define nv_calloc(n, size) malloc((n) * (size), M_NVLIST, \
- M_NOWAIT | M_ZERO)
+ M_WAITOK | M_ZERO)
#define nv_realloc(buf, size) realloc((buf), (size), M_NVLIST, \
- M_NOWAIT)
+ M_WAITOK)
#define nv_free(buf) free((buf), M_NVLIST)
#define nv_strdup(buf) strdup((buf), M_NVLIST)
#define nv_vasprintf(ptr, ...) vasprintf(ptr, M_NVLIST, __VA_ARGS__)
-#define SAVE_ERRNO(var) ((void)(var))
-#define RESTORE_ERRNO(var) ((void)(var))
+#define ERRNO_SET(var) do { } while (0)
+#define ERRNO_SAVE() do { do { } while(0)
+#define ERRNO_RESTORE() } while (0)
#define ERRNO_OR_DEFAULT(default) (default)
@@ -70,8 +71,14 @@ typedef struct nvpair nvpair_t;
#define nv_strdup(buf) strdup((buf))
#define nv_vasprintf(ptr, ...) vasprintf(ptr, __VA_ARGS__)
-#define SAVE_ERRNO(var) (var) = errno
-#define RESTORE_ERRNO(var) errno = (var)
+#define ERRNO_SET(var) do { errno = (var); } while (0)
+#define ERRNO_SAVE() do { \
+ int _serrno; \
+ \
+ _serrno = errno
+
+#define ERRNO_RESTORE() errno = _serrno; \
+ } while (0)
#define ERRNO_OR_DEFAULT(default) (errno == 0 ? (default) : errno)
@@ -128,30 +135,4 @@ const void *nvpair_get_binary(const nvpair_t *nvp, size_t *sizep);
void nvpair_free(nvpair_t *nvp);
-nvpair_t *nvpair_createf_null(const char *namefmt, ...) __printflike(1, 2);
-nvpair_t *nvpair_createf_bool(bool value, const char *namefmt, ...) __printflike(2, 3);
-nvpair_t *nvpair_createf_number(uint64_t value, const char *namefmt, ...) __printflike(2, 3);
-nvpair_t *nvpair_createf_string(const char *value, const char *namefmt, ...) __printflike(2, 3);
-nvpair_t *nvpair_createf_nvlist(const nvlist_t *value, const char *namefmt, ...) __printflike(2, 3);
-nvpair_t *nvpair_createf_descriptor(int value, const char *namefmt, ...) __printflike(2, 3);
-nvpair_t *nvpair_createf_binary(const void *value, size_t size, const char *namefmt, ...) __printflike(3, 4);
-
-nvpair_t *nvpair_createv_null(const char *namefmt, va_list nameap) __printflike(1, 0);
-nvpair_t *nvpair_createv_bool(bool value, const char *namefmt, va_list nameap) __printflike(2, 0);
-nvpair_t *nvpair_createv_number(uint64_t value, const char *namefmt, va_list nameap) __printflike(2, 0);
-nvpair_t *nvpair_createv_string(const char *value, const char *namefmt, va_list nameap) __printflike(2, 0);
-nvpair_t *nvpair_createv_nvlist(const nvlist_t *value, const char *namefmt, va_list nameap) __printflike(2, 0);
-nvpair_t *nvpair_createv_descriptor(int value, const char *namefmt, va_list nameap) __printflike(2, 0);
-nvpair_t *nvpair_createv_binary(const void *value, size_t size, const char *namefmt, va_list nameap) __printflike(3, 0);
-
-nvpair_t *nvpair_movef_string(char *value, const char *namefmt, ...) __printflike(2, 3);
-nvpair_t *nvpair_movef_nvlist(nvlist_t *value, const char *namefmt, ...) __printflike(2, 3);
-nvpair_t *nvpair_movef_descriptor(int value, const char *namefmt, ...) __printflike(2, 3);
-nvpair_t *nvpair_movef_binary(void *value, size_t size, const char *namefmt, ...) __printflike(3, 4);
-
-nvpair_t *nvpair_movev_string(char *value, const char *namefmt, va_list nameap) __printflike(2, 0);
-nvpair_t *nvpair_movev_nvlist(nvlist_t *value, const char *namefmt, va_list nameap) __printflike(2, 0);
-nvpair_t *nvpair_movev_descriptor(int value, const char *namefmt, va_list nameap) __printflike(2, 0);
-nvpair_t *nvpair_movev_binary(void *value, size_t size, const char *namefmt, va_list nameap) __printflike(3, 0);
-
#endif /* !_NV_IMPL_H_ */
diff --git a/sys/sys/nvlist_impl.h b/sys/sys/nvlist_impl.h
index a59a90e..8aeac67 100644
--- a/sys/sys/nvlist_impl.h
+++ b/sys/sys/nvlist_impl.h
@@ -38,10 +38,6 @@
#include "nv.h"
-void *nvlist_xpack(const nvlist_t *nvl, int64_t *fdidxp, size_t *sizep);
-nvlist_t *nvlist_xunpack(const void *buf, size_t size, const int *fds,
- size_t nfds);
-
nvpair_t *nvlist_get_nvpair_parent(const nvlist_t *nvl);
const unsigned char *nvlist_unpack_header(nvlist_t *nvl,
const unsigned char *ptr, size_t nfds, bool *isbep, size_t *leftp);
diff --git a/sys/sys/nvpair_impl.h b/sys/sys/nvpair_impl.h
index 121c8ab..61885e6 100644
--- a/sys/sys/nvpair_impl.h
+++ b/sys/sys/nvpair_impl.h
@@ -85,7 +85,7 @@ const unsigned char *nvpair_unpack_number(bool isbe, nvpair_t *nvp,
const unsigned char *nvpair_unpack_string(bool isbe, nvpair_t *nvp,
const unsigned char *ptr, size_t *leftp);
const unsigned char *nvpair_unpack_nvlist(bool isbe, nvpair_t *nvp,
- const unsigned char *ptr, size_t *leftp, size_t nvlist, nvlist_t **child);
+ const unsigned char *ptr, size_t *leftp, size_t nfds, nvlist_t **child);
const unsigned char *nvpair_unpack_descriptor(bool isbe, nvpair_t *nvp,
const unsigned char *ptr, size_t *leftp, const int *fds, size_t nfds);
const unsigned char *nvpair_unpack_binary(bool isbe, nvpair_t *nvp,
diff --git a/sys/sys/param.h b/sys/sys/param.h
index a10f86b..cbc2901 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -58,7 +58,7 @@
* in the range 5 to 9.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 1100070 /* Master, propagated to newvers */
+#define __FreeBSD_version 1100073 /* Master, propagated to newvers */
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
diff --git a/sys/sys/pmc.h b/sys/sys/pmc.h
index 34d9c34..f4d46b2 100644
--- a/sys/sys/pmc.h
+++ b/sys/sys/pmc.h
@@ -73,7 +73,6 @@
#define __PMC_CPUS() \
__PMC_CPU(AMD_K7, 0x00, "AMD K7") \
__PMC_CPU(AMD_K8, 0x01, "AMD K8") \
- __PMC_CPU(ARMV7, 0x500, "ARMv7") \
__PMC_CPU(INTEL_P5, 0x80, "Intel Pentium") \
__PMC_CPU(INTEL_P6, 0x81, "Intel Pentium Pro") \
__PMC_CPU(INTEL_CL, 0x82, "Intel Celeron") \
@@ -105,7 +104,10 @@
__PMC_CPU(PPC_E500, 0x340, "PowerPC e500 Core") \
__PMC_CPU(PPC_MPC85XX, 0x340, "Freescale PowerPC MPC85XX") \
__PMC_CPU(PPC_970, 0x380, "IBM PowerPC 970") \
- __PMC_CPU(GENERIC, 0x400, "Generic")
+ __PMC_CPU(GENERIC, 0x400, "Generic") \
+ __PMC_CPU(ARMV7, 0x500, "ARMv7") \
+ __PMC_CPU(ARMV8_CORTEX_A53, 0x600, "ARMv8 Cortex A53") \
+ __PMC_CPU(ARMV8_CORTEX_A57, 0x601, "ARMv8 Cortex A57")
enum pmc_cputype {
#undef __PMC_CPU
@@ -121,29 +123,30 @@ enum pmc_cputype {
*/
#define __PMC_CLASSES() \
- __PMC_CLASS(TSC) /* CPU Timestamp counter */ \
- __PMC_CLASS(K7) /* AMD K7 performance counters */ \
- __PMC_CLASS(K8) /* AMD K8 performance counters */ \
- __PMC_CLASS(P5) /* Intel Pentium counters */ \
- __PMC_CLASS(P6) /* Intel Pentium Pro counters */ \
- __PMC_CLASS(P4) /* Intel Pentium-IV counters */ \
- __PMC_CLASS(IAF) /* Intel Core2/Atom, fixed function */ \
- __PMC_CLASS(IAP) /* Intel Core...Atom, programmable */ \
- __PMC_CLASS(UCF) /* Intel Uncore fixed function */ \
- __PMC_CLASS(UCP) /* Intel Uncore programmable */ \
- __PMC_CLASS(XSCALE) /* Intel XScale counters */ \
- __PMC_CLASS(ARMV7) /* ARMv7 */ \
- __PMC_CLASS(MIPS24K) /* MIPS 24K */ \
- __PMC_CLASS(OCTEON) /* Cavium Octeon */ \
- __PMC_CLASS(MIPS74K) /* MIPS 74K */ \
- __PMC_CLASS(PPC7450) /* Motorola MPC7450 class */ \
- __PMC_CLASS(PPC970) /* IBM PowerPC 970 class */ \
- __PMC_CLASS(E500) /* Freescale e500 class */ \
- __PMC_CLASS(SOFT) /* Software events */
+ __PMC_CLASS(TSC, 0x000, "CPU Timestamp counter") \
+ __PMC_CLASS(K7, 0x100, "AMD K7 performance counters") \
+ __PMC_CLASS(K8, 0x101, "AMD K8 performance counters") \
+ __PMC_CLASS(P5, 0x102, "Intel Pentium counters") \
+ __PMC_CLASS(P6, 0x103, "Intel Pentium Pro counters") \
+ __PMC_CLASS(P4, 0x104, "Intel Pentium-IV counters") \
+ __PMC_CLASS(IAF, 0x105, "Intel Core2/Atom, fixed function") \
+ __PMC_CLASS(IAP, 0x106, "Intel Core...Atom, programmable") \
+ __PMC_CLASS(UCF, 0x107, "Intel Uncore fixed function") \
+ __PMC_CLASS(UCP, 0x108, "Intel Uncore programmable") \
+ __PMC_CLASS(XSCALE, 0x200, "Intel XScale counters") \
+ __PMC_CLASS(ARMV7, 0x201, "ARMv7") \
+ __PMC_CLASS(ARMV8, 0x202, "ARMv8") \
+ __PMC_CLASS(MIPS24K, 0x300, "MIPS 24K") \
+ __PMC_CLASS(OCTEON, 0x301, "Cavium Octeon") \
+ __PMC_CLASS(MIPS74K, 0x302, "MIPS 74K") \
+ __PMC_CLASS(PPC7450, 0x400, "Motorola MPC7450 class") \
+ __PMC_CLASS(PPC970, 0x401, "IBM PowerPC 970 class") \
+ __PMC_CLASS(E500, 0x402, "Freescale e500 class") \
+ __PMC_CLASS(SOFT, 0x8000, "Software events")
enum pmc_class {
#undef __PMC_CLASS
-#define __PMC_CLASS(N) PMC_CLASS_##N ,
+#define __PMC_CLASS(S,V,D) PMC_CLASS_##S = V,
__PMC_CLASSES()
};
@@ -998,7 +1001,8 @@ extern struct pmc_cpu **pmc_pcpu;
/* driver statistics */
extern struct pmc_op_getdriverstats pmc_stats;
-#if defined(DEBUG)
+#if defined(HWPMC_DEBUG)
+#include <sys/ktr.h>
/* debug flags, major flag groups */
struct pmc_debugflags {
@@ -1015,14 +1019,42 @@ struct pmc_debugflags {
extern struct pmc_debugflags pmc_debugflags;
+#define KTR_PMC KTR_SUBSYS
+
#define PMC_DEBUG_STRSIZE 128
#define PMC_DEBUG_DEFAULT_FLAGS { 0, 0, 0, 0, 0, 0, 0, 0 }
-#define PMCDBG(M,N,L,F,...) do { \
+#define PMCDBG0(M, N, L, F) do { \
if (pmc_debugflags.pdb_ ## M & (1 << PMC_DEBUG_MIN_ ## N)) \
- printf(#M ":" #N ":" #L ": " F "\n", __VA_ARGS__); \
+ CTR0(KTR_PMC, #M ":" #N ":" #L ": " F); \
} while (0)
-
+#define PMCDBG1(M, N, L, F, p1) do { \
+ if (pmc_debugflags.pdb_ ## M & (1 << PMC_DEBUG_MIN_ ## N)) \
+ CTR1(KTR_PMC, #M ":" #N ":" #L ": " F, p1); \
+} while (0)
+#define PMCDBG2(M, N, L, F, p1, p2) do { \
+ if (pmc_debugflags.pdb_ ## M & (1 << PMC_DEBUG_MIN_ ## N)) \
+ CTR2(KTR_PMC, #M ":" #N ":" #L ": " F, p1, p2); \
+} while (0)
+#define PMCDBG3(M, N, L, F, p1, p2, p3) do { \
+ if (pmc_debugflags.pdb_ ## M & (1 << PMC_DEBUG_MIN_ ## N)) \
+ CTR3(KTR_PMC, #M ":" #N ":" #L ": " F, p1, p2, p3); \
+} while (0)
+#define PMCDBG4(M, N, L, F, p1, p2, p3, p4) do { \
+ if (pmc_debugflags.pdb_ ## M & (1 << PMC_DEBUG_MIN_ ## N)) \
+ CTR4(KTR_PMC, #M ":" #N ":" #L ": " F, p1, p2, p3, p4);\
+} while (0)
+#define PMCDBG5(M, N, L, F, p1, p2, p3, p4, p5) do { \
+ if (pmc_debugflags.pdb_ ## M & (1 << PMC_DEBUG_MIN_ ## N)) \
+ CTR5(KTR_PMC, #M ":" #N ":" #L ": " F, p1, p2, p3, p4, \
+ p5); \
+} while (0)
+#define PMCDBG6(M, N, L, F, p1, p2, p3, p4, p5, p6) do { \
+ if (pmc_debugflags.pdb_ ## M & (1 << PMC_DEBUG_MIN_ ## N)) \
+ CTR6(KTR_PMC, #M ":" #N ":" #L ": " F, p1, p2, p3, p4, \
+ p5, p6); \
+} while (0)
+
/* Major numbers */
#define PMC_DEBUG_MAJ_CPU 0 /* cpu switches */
#define PMC_DEBUG_MAJ_CSW 1 /* context switches */
@@ -1088,7 +1120,13 @@ extern struct pmc_debugflags pmc_debugflags;
#define PMC_DEBUG_MIN_CLO 12 /* close */
#else
-#define PMCDBG(M,N,L,F,...) /* nothing */
+#define PMCDBG0(M, N, L, F) /* nothing */
+#define PMCDBG1(M, N, L, F, p1)
+#define PMCDBG2(M, N, L, F, p1, p2)
+#define PMCDBG3(M, N, L, F, p1, p2, p3)
+#define PMCDBG4(M, N, L, F, p1, p2, p3, p4)
+#define PMCDBG5(M, N, L, F, p1, p2, p3, p4, p5)
+#define PMCDBG6(M, N, L, F, p1, p2, p3, p4, p5, p6)
#endif
/* declare a dedicated memory pool */
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 64b99fc..6b1a2f0 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -660,7 +660,7 @@ struct proc {
#define P_SINGLE_BOUNDARY 0x400000 /* Threads should suspend at user boundary. */
#define P_HWPMC 0x800000 /* Process is using HWPMCs */
#define P_JAILED 0x1000000 /* Process is in jail. */
-#define P_TOTAL_STOP 0x2000000 /* Stopped in proc_stop_total. */
+#define P_TOTAL_STOP 0x2000000 /* Stopped in stop_all_proc. */
#define P_INEXEC 0x4000000 /* Process is in execve(). */
#define P_STATCHILD 0x8000000 /* Child process stopped or exited. */
#define P_INMEM 0x10000000 /* Loaded into memory. */
@@ -991,7 +991,6 @@ void thread_suspend_switch(struct thread *, struct proc *p);
void thread_suspend_one(struct thread *td);
void thread_unlink(struct thread *td);
void thread_unsuspend(struct proc *p);
-int thread_unsuspend_one(struct thread *td, struct proc *p);
void thread_wait(struct proc *p);
struct thread *thread_find(struct proc *p, lwpid_t tid);
diff --git a/sys/sys/racct.h b/sys/sys/racct.h
index 966d27a..313d5d0 100644
--- a/sys/sys/racct.h
+++ b/sys/sys/racct.h
@@ -83,6 +83,10 @@ struct ucred;
#define RACCT_DECAYING 0x20
extern int racct_types[];
+extern int racct_enable;
+
+#define ASSERT_RACCT_ENABLED() KASSERT(racct_enable, \
+ ("%s called with !racct_enable", __func__))
/*
* Amount stored in c_resources[] is 10**6 times bigger than what's
diff --git a/sys/sys/seq.h b/sys/sys/seq.h
index eaab86e..21067cb 100644
--- a/sys/sys/seq.h
+++ b/sys/sys/seq.h
@@ -79,7 +79,7 @@ typedef uint32_t seq_t;
* on amd64 but still has unnecessary cost.
*/
static __inline int
-atomic_load_rmb_int(volatile u_int *p)
+atomic_load_rmb_int(volatile const u_int *p)
{
volatile u_int v;
@@ -89,7 +89,7 @@ atomic_load_rmb_int(volatile u_int *p)
}
static __inline int
-atomic_rmb_load_int(volatile u_int *p)
+atomic_rmb_load_int(volatile const u_int *p)
{
volatile u_int v = 0;
@@ -122,7 +122,7 @@ seq_write_end(seq_t *seqp)
}
static __inline seq_t
-seq_read(seq_t *seqp)
+seq_read(const seq_t *seqp)
{
seq_t ret;
@@ -139,7 +139,7 @@ seq_read(seq_t *seqp)
}
static __inline seq_t
-seq_consistent(seq_t *seqp, seq_t oldseq)
+seq_consistent(const seq_t *seqp, seq_t oldseq)
{
return (atomic_rmb_load_int(seqp) == oldseq);
diff --git a/sys/sys/sockio.h b/sys/sys/sockio.h
index f04bb12..8624ad2 100644
--- a/sys/sys/sockio.h
+++ b/sys/sys/sockio.h
@@ -114,6 +114,9 @@
#define SIOCGIFFIB _IOWR('i', 92, struct ifreq) /* get IF fib */
#define SIOCSIFFIB _IOW('i', 93, struct ifreq) /* set IF fib */
+#define SIOCGTUNFIB _IOWR('i', 94, struct ifreq) /* get tunnel fib */
+#define SIOCSTUNFIB _IOW('i', 95, struct ifreq) /* set tunnel fib */
+
#define SIOCSDRVSPEC _IOW('i', 123, struct ifdrv) /* set driver-specific
parameters */
#define SIOCGDRVSPEC _IOWR('i', 123, struct ifdrv) /* get driver-specific
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
index 786414f..acea565 100644
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -237,7 +237,7 @@ void hexdump(const void *ptr, int length, const char *hdr, int flags);
#define ovbcopy(f, t, l) bcopy((f), (t), (l))
void bcopy(const void *from, void *to, size_t len) __nonnull(1) __nonnull(2);
void bzero(void *buf, size_t len) __nonnull(1);
-void explicit_bzero(void *, size_t) __nonnull(1);;
+void explicit_bzero(void *, size_t) __nonnull(1);
void *memcpy(void *to, const void *from, size_t len) __nonnull(1) __nonnull(2);
void *memmove(void *dest, const void *src, size_t n) __nonnull(1) __nonnull(2);
diff --git a/sys/sys/timepps.h b/sys/sys/timepps.h
index ae4b84d..d472c80 100644
--- a/sys/sys/timepps.h
+++ b/sys/sys/timepps.h
@@ -135,6 +135,13 @@ struct pps_kcbind_args {
struct mtx;
+#define KCMODE_EDGEMASK 0x03
+#define KCMODE_ABIFLAG 0x80000000 /* Internal use: abi-aware driver. */
+
+#define PPS_ABI_VERSION 1
+
+#define PPSFLAG_MTX_SPIN 0x01 /* Driver mtx is MTX_SPIN type. */
+
struct pps_state {
/* Capture information. */
struct timehands *capth;
@@ -142,9 +149,6 @@ struct pps_state {
unsigned capgen;
unsigned capcount;
- /* pointer to mutex protecting this state, if any */
- struct mtx *mtx;
-
/* State information. */
pps_params_t ppsparam;
pps_info_t ppsinfo;
@@ -153,11 +157,19 @@ struct pps_state {
int ppscap;
struct timecounter *ppstc;
unsigned ppscount[3];
+ /*
+ * The following fields are valid if the driver calls pps_init_abi().
+ */
+ uint16_t driver_abi; /* Driver sets before pps_init_abi(). */
+ uint16_t kernel_abi; /* Kernel sets during pps_init_abi(). */
+ struct mtx *driver_mtx; /* Optional, valid if non-NULL. */
+ uint32_t flags;
};
void pps_capture(struct pps_state *pps);
void pps_event(struct pps_state *pps, int event);
void pps_init(struct pps_state *pps);
+void pps_init_abi(struct pps_state *pps);
int pps_ioctl(unsigned long cmd, caddr_t data, struct pps_state *pps);
void hardpps(struct timespec *tsp, long nsec);
diff --git a/sys/vm/default_pager.c b/sys/vm/default_pager.c
index 26326a5..98dee45 100644
--- a/sys/vm/default_pager.c
+++ b/sys/vm/default_pager.c
@@ -113,6 +113,7 @@ default_pager_dealloc(object)
/*
* OBJT_DEFAULT objects have no special resources allocated to them.
*/
+ object->type = OBJT_DEAD;
}
/*
diff --git a/sys/vm/device_pager.c b/sys/vm/device_pager.c
index d05ea33..33fba4e 100644
--- a/sys/vm/device_pager.c
+++ b/sys/vm/device_pager.c
@@ -254,6 +254,8 @@ dev_pager_dealloc(object)
!= NULL)
dev_pager_free_page(object, m);
}
+ object->handle = NULL;
+ object->type = OBJT_DEAD;
}
static int
diff --git a/sys/vm/phys_pager.c b/sys/vm/phys_pager.c
index 9e98006..885a451 100644
--- a/sys/vm/phys_pager.c
+++ b/sys/vm/phys_pager.c
@@ -131,6 +131,8 @@ phys_pager_dealloc(vm_object_t object)
mtx_unlock(&phys_pager_mtx);
VM_OBJECT_WLOCK(object);
}
+ object->handle = NULL;
+ object->type = OBJT_DEAD;
}
/*
diff --git a/sys/vm/sg_pager.c b/sys/vm/sg_pager.c
index e35741e..23ebd3a 100644
--- a/sys/vm/sg_pager.c
+++ b/sys/vm/sg_pager.c
@@ -130,6 +130,8 @@ sg_pager_dealloc(vm_object_t object)
sg = object->handle;
sglist_free(sg);
+ object->handle = NULL;
+ object->type = OBJT_DEAD;
}
static int
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index 55e02c4..3005491 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -198,11 +198,13 @@ swap_reserve_by_cred(vm_ooffset_t incr, struct ucred *cred)
panic("swap_reserve: & PAGE_MASK");
#ifdef RACCT
- PROC_LOCK(curproc);
- error = racct_add(curproc, RACCT_SWAP, incr);
- PROC_UNLOCK(curproc);
- if (error != 0)
- return (0);
+ if (racct_enable) {
+ PROC_LOCK(curproc);
+ error = racct_add(curproc, RACCT_SWAP, incr);
+ PROC_UNLOCK(curproc);
+ if (error != 0)
+ return (0);
+ }
#endif
res = 0;
@@ -326,17 +328,16 @@ static int nsw_wcount_async; /* limit write buffers / asynchronous */
static int nsw_wcount_async_max;/* assigned maximum */
static int nsw_cluster_max; /* maximum VOP I/O allowed */
+static int sysctl_swap_async_max(SYSCTL_HANDLER_ARGS);
+SYSCTL_PROC(_vm, OID_AUTO, swap_async_max, CTLTYPE_INT | CTLFLAG_RW,
+ NULL, 0, sysctl_swap_async_max, "I", "Maximum running async swap ops");
+
static struct swblock **swhash;
static int swhash_mask;
static struct mtx swhash_mtx;
-static int swap_async_max = 4; /* maximum in-progress async I/O's */
static struct sx sw_alloc_sx;
-
-SYSCTL_INT(_vm, OID_AUTO, swap_async_max,
- CTLFLAG_RW, &swap_async_max, 0, "Maximum running async swap ops");
-
/*
* "named" and "unnamed" anon region objects. Try to reduce the overhead
* of searching a named list by hashing it just a little.
@@ -696,6 +697,8 @@ swap_pager_dealloc(vm_object_t object)
* if paging is still in progress on some objects.
*/
swp_pager_meta_free_all(object);
+ object->handle = NULL;
+ object->type = OBJT_DEAD;
}
/************************************************************************
@@ -1348,39 +1351,6 @@ swap_pager_putpages(vm_object_t object, vm_page_t *m, int count,
/*
* Step 2
*
- * Update nsw parameters from swap_async_max sysctl values.
- * Do not let the sysop crash the machine with bogus numbers.
- */
- mtx_lock(&pbuf_mtx);
- if (swap_async_max != nsw_wcount_async_max) {
- int n;
-
- /*
- * limit range
- */
- if ((n = swap_async_max) > nswbuf / 2)
- n = nswbuf / 2;
- if (n < 1)
- n = 1;
- swap_async_max = n;
-
- /*
- * Adjust difference ( if possible ). If the current async
- * count is too low, we may not be able to make the adjustment
- * at this time.
- */
- n -= nsw_wcount_async_max;
- if (nsw_wcount_async + n >= 0) {
- nsw_wcount_async += n;
- nsw_wcount_async_max += n;
- wakeup(&nsw_wcount_async);
- }
- }
- mtx_unlock(&pbuf_mtx);
-
- /*
- * Step 3
- *
* Assign swap blocks and issue I/O. We reallocate swap on the fly.
* The page is left dirty until the pageout operation completes
* successfully.
@@ -2833,3 +2803,40 @@ swaponvp(struct thread *td, struct vnode *vp, u_long nblks)
NODEV, 0);
return (0);
}
+
+static int
+sysctl_swap_async_max(SYSCTL_HANDLER_ARGS)
+{
+ int error, new, n;
+
+ new = nsw_wcount_async_max;
+ error = sysctl_handle_int(oidp, &new, 0, req);
+ if (error != 0 || req->newptr == NULL)
+ return (error);
+
+ if (new > nswbuf / 2 || new < 1)
+ return (EINVAL);
+
+ mtx_lock(&pbuf_mtx);
+ while (nsw_wcount_async_max != new) {
+ /*
+ * Adjust difference. If the current async count is too low,
+ * we will need to sqeeze our update slowly in. Sleep with a
+ * higher priority than getpbuf() to finish faster.
+ */
+ n = new - nsw_wcount_async_max;
+ if (nsw_wcount_async + n >= 0) {
+ nsw_wcount_async += n;
+ nsw_wcount_async_max += n;
+ wakeup(&nsw_wcount_async);
+ } else {
+ nsw_wcount_async_max -= nsw_wcount_async;
+ nsw_wcount_async = 0;
+ msleep(&nsw_wcount_async, &pbuf_mtx, PSWP,
+ "swpsysctl", 0);
+ }
+ }
+ mtx_unlock(&pbuf_mtx);
+
+ return (0);
+}
diff --git a/sys/vm/uma.h b/sys/vm/uma.h
index df6cc5c..d3e0658 100644
--- a/sys/vm/uma.h
+++ b/sys/vm/uma.h
@@ -690,4 +690,7 @@ struct uma_percpu_stat {
uint64_t _ups_reserved[5]; /* Reserved. */
};
+void uma_reclaim_wakeup(void);
+void uma_reclaim_worker(void *);
+
#endif /* _VM_UMA_H_ */
diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index 4ff177f..6780bad 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -1891,7 +1891,7 @@ uma_startup3(void)
#ifdef UMA_DEBUG
printf("Starting callout.\n");
#endif
- callout_init(&uma_callout, CALLOUT_MPSAFE);
+ callout_init(&uma_callout, 1);
callout_reset(&uma_callout, UMA_TIMEOUT * hz, uma_timeout, NULL);
#ifdef UMA_DEBUG
printf("UMA startup3 complete.\n");
@@ -3222,16 +3222,17 @@ uma_find_refcnt(uma_zone_t zone, void *item)
}
/* See uma.h */
-void
-uma_reclaim(void)
+static void
+uma_reclaim_locked(bool kmem_danger)
{
+
#ifdef UMA_DEBUG
printf("UMA: vm asked us to release pages!\n");
#endif
- sx_xlock(&uma_drain_lock);
+ sx_assert(&uma_drain_lock, SA_XLOCKED);
bucket_enable();
zone_foreach(zone_drain);
- if (vm_page_count_min()) {
+ if (vm_page_count_min() || kmem_danger) {
cache_drain_safe(NULL);
zone_foreach(zone_drain);
}
@@ -3243,9 +3244,42 @@ uma_reclaim(void)
zone_drain(slabzone);
zone_drain(slabrefzone);
bucket_zone_drain();
+}
+
+void
+uma_reclaim(void)
+{
+
+ sx_xlock(&uma_drain_lock);
+ uma_reclaim_locked(false);
sx_xunlock(&uma_drain_lock);
}
+static int uma_reclaim_needed;
+
+void
+uma_reclaim_wakeup(void)
+{
+
+ uma_reclaim_needed = 1;
+ wakeup(&uma_reclaim_needed);
+}
+
+void
+uma_reclaim_worker(void *arg __unused)
+{
+
+ sx_xlock(&uma_drain_lock);
+ for (;;) {
+ sx_sleep(&uma_reclaim_needed, &uma_drain_lock, PVM,
+ "umarcl", 0);
+ if (uma_reclaim_needed) {
+ uma_reclaim_needed = 0;
+ uma_reclaim_locked(true);
+ }
+ }
+}
+
/* See uma.h */
int
uma_zone_exhausted(uma_zone_t zone)
diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c
index 13f46e1..0c84d44 100644
--- a/sys/vm/vm_fault.c
+++ b/sys/vm/vm_fault.c
@@ -348,6 +348,10 @@ RetryFault:;
vm_map_lock(fs.map);
if (vm_map_lookup_entry(fs.map, vaddr, &fs.entry) &&
(fs.entry->eflags & MAP_ENTRY_IN_TRANSITION)) {
+ if (fs.vp != NULL) {
+ vput(fs.vp);
+ fs.vp = NULL;
+ }
fs.entry->eflags |= MAP_ENTRY_NEEDS_WAKEUP;
vm_map_unlock_and_wait(fs.map, 0);
} else
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index b7e668b..bad9994 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -300,11 +300,11 @@ vmspace_alloc(vm_offset_t min, vm_offset_t max, pmap_pinit_t pinit)
return (vm);
}
+#ifdef RACCT
static void
vmspace_container_reset(struct proc *p)
{
-#ifdef RACCT
PROC_LOCK(p);
racct_set(p, RACCT_DATA, 0);
racct_set(p, RACCT_STACK, 0);
@@ -312,8 +312,8 @@ vmspace_container_reset(struct proc *p)
racct_set(p, RACCT_MEMLOCK, 0);
racct_set(p, RACCT_VMEM, 0);
PROC_UNLOCK(p);
-#endif
}
+#endif
static inline void
vmspace_dofree(struct vmspace *vm)
@@ -415,7 +415,10 @@ vmspace_exit(struct thread *td)
pmap_activate(td);
vmspace_dofree(vm);
}
- vmspace_container_reset(p);
+#ifdef RACCT
+ if (racct_enable)
+ vmspace_container_reset(p);
+#endif
}
/* Acquire reference to vmspace owned by another process. */
@@ -3652,14 +3655,16 @@ Retry:
return (KERN_NO_SPACE);
}
#ifdef RACCT
- PROC_LOCK(p);
- if (is_procstack &&
- racct_set(p, RACCT_STACK, ctob(vm->vm_ssize) + grow_amount)) {
+ if (racct_enable) {
+ PROC_LOCK(p);
+ if (is_procstack && racct_set(p, RACCT_STACK,
+ ctob(vm->vm_ssize) + grow_amount)) {
+ PROC_UNLOCK(p);
+ vm_map_unlock_read(map);
+ return (KERN_NO_SPACE);
+ }
PROC_UNLOCK(p);
- vm_map_unlock_read(map);
- return (KERN_NO_SPACE);
}
- PROC_UNLOCK(p);
#endif
/* Round up the grow amount modulo sgrowsiz */
@@ -3685,15 +3690,17 @@ Retry:
goto out;
}
#ifdef RACCT
- PROC_LOCK(p);
- if (racct_set(p, RACCT_MEMLOCK,
- ptoa(pmap_wired_count(map->pmap)) + grow_amount)) {
+ if (racct_enable) {
+ PROC_LOCK(p);
+ if (racct_set(p, RACCT_MEMLOCK,
+ ptoa(pmap_wired_count(map->pmap)) + grow_amount)) {
+ PROC_UNLOCK(p);
+ vm_map_unlock_read(map);
+ rv = KERN_NO_SPACE;
+ goto out;
+ }
PROC_UNLOCK(p);
- vm_map_unlock_read(map);
- rv = KERN_NO_SPACE;
- goto out;
}
- PROC_UNLOCK(p);
#endif
}
/* If we would blow our VMEM resource limit, no go */
@@ -3703,14 +3710,16 @@ Retry:
goto out;
}
#ifdef RACCT
- PROC_LOCK(p);
- if (racct_set(p, RACCT_VMEM, map->size + grow_amount)) {
+ if (racct_enable) {
+ PROC_LOCK(p);
+ if (racct_set(p, RACCT_VMEM, map->size + grow_amount)) {
+ PROC_UNLOCK(p);
+ vm_map_unlock_read(map);
+ rv = KERN_NO_SPACE;
+ goto out;
+ }
PROC_UNLOCK(p);
- vm_map_unlock_read(map);
- rv = KERN_NO_SPACE;
- goto out;
}
- PROC_UNLOCK(p);
#endif
if (vm_map_lock_upgrade(map))
@@ -3809,7 +3818,7 @@ Retry:
out:
#ifdef RACCT
- if (rv != KERN_SUCCESS) {
+ if (racct_enable && rv != KERN_SUCCESS) {
PROC_LOCK(p);
error = racct_set(p, RACCT_VMEM, map->size);
KASSERT(error == 0, ("decreasing RACCT_VMEM failed"));
diff --git a/sys/vm/vm_meter.c b/sys/vm/vm_meter.c
index 4ec2613..865be71 100644
--- a/sys/vm/vm_meter.c
+++ b/sys/vm/vm_meter.c
@@ -111,14 +111,7 @@ vmtotal(SYSCTL_HANDLER_ARGS)
*/
mtx_lock(&vm_object_list_mtx);
TAILQ_FOREACH(object, &vm_object_list, object_list) {
- if (!VM_OBJECT_TRYWLOCK(object)) {
- /*
- * Avoid a lock-order reversal. Consequently,
- * the reported number of active pages may be
- * greater than the actual number.
- */
- continue;
- }
+ VM_OBJECT_WLOCK(object);
vm_object_clear_flag(object, OBJ_ACTIVE);
VM_OBJECT_WUNLOCK(object);
}
@@ -196,10 +189,9 @@ vmtotal(SYSCTL_HANDLER_ARGS)
mtx_lock(&vm_object_list_mtx);
TAILQ_FOREACH(object, &vm_object_list, object_list) {
/*
- * Perform unsynchronized reads on the object to avoid
- * a lock-order reversal. In this case, the lack of
- * synchronization should not impair the accuracy of
- * the reported statistics.
+ * Perform unsynchronized reads on the object. In
+ * this case, the lack of synchronization should not
+ * impair the accuracy of the reported statistics.
*/
if ((object->flags & OBJ_FICTITIOUS) != 0) {
/*
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index 02634d6..1dd2479 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -1122,16 +1122,18 @@ vm_mlock(struct proc *proc, struct ucred *cred, const void *addr0, size_t len)
if (npages + vm_cnt.v_wire_count > vm_page_max_wired)
return (EAGAIN);
#ifdef RACCT
- PROC_LOCK(proc);
- error = racct_set(proc, RACCT_MEMLOCK, nsize);
- PROC_UNLOCK(proc);
- if (error != 0)
- return (ENOMEM);
+ if (racct_enable) {
+ PROC_LOCK(proc);
+ error = racct_set(proc, RACCT_MEMLOCK, nsize);
+ PROC_UNLOCK(proc);
+ if (error != 0)
+ return (ENOMEM);
+ }
#endif
error = vm_map_wire(map, start, end,
VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
#ifdef RACCT
- if (error != KERN_SUCCESS) {
+ if (racct_enable && error != KERN_SUCCESS) {
PROC_LOCK(proc);
racct_set(proc, RACCT_MEMLOCK,
ptoa(pmap_wired_count(map->pmap)));
@@ -1179,11 +1181,13 @@ sys_mlockall(td, uap)
PROC_UNLOCK(td->td_proc);
}
#ifdef RACCT
- PROC_LOCK(td->td_proc);
- error = racct_set(td->td_proc, RACCT_MEMLOCK, map->size);
- PROC_UNLOCK(td->td_proc);
- if (error != 0)
- return (ENOMEM);
+ if (racct_enable) {
+ PROC_LOCK(td->td_proc);
+ error = racct_set(td->td_proc, RACCT_MEMLOCK, map->size);
+ PROC_UNLOCK(td->td_proc);
+ if (error != 0)
+ return (ENOMEM);
+ }
#endif
if (uap->how & MCL_FUTURE) {
@@ -1205,7 +1209,7 @@ sys_mlockall(td, uap)
error = (error == KERN_SUCCESS ? 0 : EAGAIN);
}
#ifdef RACCT
- if (error != KERN_SUCCESS) {
+ if (racct_enable && error != KERN_SUCCESS) {
PROC_LOCK(td->td_proc);
racct_set(td->td_proc, RACCT_MEMLOCK,
ptoa(pmap_wired_count(map->pmap)));
@@ -1247,7 +1251,7 @@ sys_munlockall(td, uap)
error = vm_map_unwire(map, vm_map_min(map), vm_map_max(map),
VM_MAP_WIRE_USER|VM_MAP_WIRE_HOLESOK);
#ifdef RACCT
- if (error == KERN_SUCCESS) {
+ if (racct_enable && error == KERN_SUCCESS) {
PROC_LOCK(td->td_proc);
racct_set(td->td_proc, RACCT_MEMLOCK, 0);
PROC_UNLOCK(td->td_proc);
@@ -1291,7 +1295,7 @@ sys_munlock(td, uap)
error = vm_map_unwire(&td->td_proc->p_vmspace->vm_map, start, end,
VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
#ifdef RACCT
- if (error == KERN_SUCCESS) {
+ if (racct_enable && error == KERN_SUCCESS) {
PROC_LOCK(td->td_proc);
map = &td->td_proc->p_vmspace->vm_map;
racct_set(td->td_proc, RACCT_MEMLOCK,
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index a1d6701..78cea70 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -166,6 +166,8 @@ vm_object_zdtor(void *mem, int size, void *arg)
vm_object_t object;
object = (vm_object_t)mem;
+ KASSERT(object->ref_count == 0,
+ ("object %p ref_count = %d", object, object->ref_count));
KASSERT(TAILQ_EMPTY(&object->memq),
("object %p has resident pages in its memq", object));
KASSERT(vm_radix_is_empty(&object->rtree),
@@ -187,6 +189,9 @@ vm_object_zdtor(void *mem, int size, void *arg)
KASSERT(object->shadow_count == 0,
("object %p shadow_count = %d",
object, object->shadow_count));
+ KASSERT(object->type == OBJT_DEAD,
+ ("object %p has non-dead type %d",
+ object, object->type));
}
#endif
@@ -199,6 +204,8 @@ vm_object_zinit(void *mem, int size, int flags)
rw_init_flags(&object->lock, "vm object", RW_DUPOK | RW_NEW);
/* These are true for any object that has been freed */
+ object->type = OBJT_DEAD;
+ object->ref_count = 0;
object->rtree.rt_root = 0;
object->rtree.rt_flags = 0;
object->paging_in_progress = 0;
@@ -206,6 +213,10 @@ vm_object_zinit(void *mem, int size, int flags)
object->shadow_count = 0;
object->cache.rt_root = 0;
object->cache.rt_flags = 0;
+
+ mtx_lock(&vm_object_list_mtx);
+ TAILQ_INSERT_TAIL(&vm_object_list, object, object_list);
+ mtx_unlock(&vm_object_list_mtx);
return (0);
}
@@ -252,10 +263,6 @@ _vm_object_allocate(objtype_t type, vm_pindex_t size, vm_object_t object)
#if VM_NRESERVLEVEL > 0
LIST_INIT(&object->rvq);
#endif
-
- mtx_lock(&vm_object_list_mtx);
- TAILQ_INSERT_TAIL(&vm_object_list, object, object_list);
- mtx_unlock(&vm_object_list_mtx);
}
/*
@@ -671,19 +678,9 @@ vm_object_destroy(vm_object_t object)
{
/*
- * Remove the object from the global object list.
- */
- mtx_lock(&vm_object_list_mtx);
- TAILQ_REMOVE(&vm_object_list, object, object_list);
- mtx_unlock(&vm_object_list_mtx);
-
- /*
* Release the allocation charge.
*/
if (object->cred != NULL) {
- KASSERT(object->type == OBJT_DEFAULT ||
- object->type == OBJT_SWAP,
- ("%s: non-swap obj %p has cred", __func__, object));
swap_release_by_cred(object->charge, object->cred);
object->charge = 0;
crfree(object->cred);
@@ -788,6 +785,10 @@ vm_object_terminate(vm_object_t object)
if (__predict_false(!vm_object_cache_is_empty(object)))
vm_page_cache_free(object, 0, 0);
+ KASSERT(object->cred == NULL || object->type == OBJT_DEFAULT ||
+ object->type == OBJT_SWAP,
+ ("%s: non-swap obj %p has cred", __func__, object));
+
/*
* Let the pager know object is dead.
*/
@@ -1803,6 +1804,8 @@ vm_object_collapse(vm_object_t object)
KASSERT(backing_object->ref_count == 1, (
"backing_object %p was somehow re-referenced during collapse!",
backing_object));
+ backing_object->type = OBJT_DEAD;
+ backing_object->ref_count = 0;
VM_OBJECT_WUNLOCK(backing_object);
vm_object_destroy(backing_object);
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index 64ca130..b3b36d6 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -91,12 +91,14 @@ __FBSDID("$FreeBSD$");
#include <sys/lock.h>
#include <sys/kernel.h>
#include <sys/limits.h>
+#include <sys/linker.h>
#include <sys/malloc.h>
#include <sys/mman.h>
#include <sys/msgbuf.h>
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/rwlock.h>
+#include <sys/sbuf.h>
#include <sys/sysctl.h>
#include <sys/vmmeter.h>
#include <sys/vnode.h>
@@ -142,6 +144,12 @@ static int pa_tryrelock_restart;
SYSCTL_INT(_vm, OID_AUTO, tryrelock_restart, CTLFLAG_RD,
&pa_tryrelock_restart, 0, "Number of tryrelock restarts");
+static TAILQ_HEAD(, vm_page) blacklist_head;
+static int sysctl_vm_page_blacklist(SYSCTL_HANDLER_ARGS);
+SYSCTL_PROC(_vm, OID_AUTO, page_blacklist, CTLTYPE_STRING | CTLFLAG_RD |
+ CTLFLAG_MPSAFE, NULL, 0, sysctl_vm_page_blacklist, "A", "Blacklist pages");
+
+
static uma_zone_t fakepg_zone;
static struct vnode *vm_page_alloc_init(vm_page_t m);
@@ -216,35 +224,153 @@ vm_set_page_size(void)
}
/*
- * vm_page_blacklist_lookup:
+ * vm_page_blacklist_next:
*
- * See if a physical address in this page has been listed
- * in the blacklist tunable. Entries in the tunable are
- * separated by spaces or commas. If an invalid integer is
- * encountered then the rest of the string is skipped.
+ * Find the next entry in the provided string of blacklist
+ * addresses. Entries are separated by space, comma, or newline.
+ * If an invalid integer is encountered then the rest of the
+ * string is skipped. Updates the list pointer to the next
+ * character, or NULL if the string is exhausted or invalid.
*/
-static int
-vm_page_blacklist_lookup(char *list, vm_paddr_t pa)
+static vm_paddr_t
+vm_page_blacklist_next(char **list, char *end)
{
vm_paddr_t bad;
char *cp, *pos;
- for (pos = list; *pos != '\0'; pos = cp) {
+ if (list == NULL || *list == NULL)
+ return (0);
+ if (**list =='\0') {
+ *list = NULL;
+ return (0);
+ }
+
+ /*
+ * If there's no end pointer then the buffer is coming from
+ * the kenv and we know it's null-terminated.
+ */
+ if (end == NULL)
+ end = *list + strlen(*list);
+
+ /* Ensure that strtoq() won't walk off the end */
+ if (*end != '\0') {
+ if (*end == '\n' || *end == ' ' || *end == ',')
+ *end = '\0';
+ else {
+ printf("Blacklist not terminated, skipping\n");
+ *list = NULL;
+ return (0);
+ }
+ }
+
+ for (pos = *list; *pos != '\0'; pos = cp) {
bad = strtoq(pos, &cp, 0);
- if (*cp != '\0') {
- if (*cp == ' ' || *cp == ',') {
- cp++;
- if (cp == pos)
+ if (*cp == '\0' || *cp == ' ' || *cp == ',' || *cp == '\n') {
+ if (bad == 0) {
+ if (++cp < end)
continue;
- } else
- break;
- }
- if (pa == trunc_page(bad))
- return (1);
+ else
+ break;
+ }
+ } else
+ break;
+ if (*cp == '\0' || ++cp >= end)
+ *list = NULL;
+ else
+ *list = cp;
+ return (trunc_page(bad));
}
+ printf("Garbage in RAM blacklist, skipping\n");
+ *list = NULL;
return (0);
}
+/*
+ * vm_page_blacklist_check:
+ *
+ * Iterate through the provided string of blacklist addresses, pulling
+ * each entry out of the physical allocator free list and putting it
+ * onto a list for reporting via the vm.page_blacklist sysctl.
+ */
+static void
+vm_page_blacklist_check(char *list, char *end)
+{
+ vm_paddr_t pa;
+ vm_page_t m;
+ char *next;
+ int ret;
+
+ next = list;
+ while (next != NULL) {
+ if ((pa = vm_page_blacklist_next(&next, end)) == 0)
+ continue;
+ m = vm_phys_paddr_to_vm_page(pa);
+ if (m == NULL)
+ continue;
+ mtx_lock(&vm_page_queue_free_mtx);
+ ret = vm_phys_unfree_page(m);
+ mtx_unlock(&vm_page_queue_free_mtx);
+ if (ret == TRUE) {
+ TAILQ_INSERT_TAIL(&blacklist_head, m, listq);
+ if (bootverbose)
+ printf("Skipping page with pa 0x%jx\n",
+ (uintmax_t)pa);
+ }
+ }
+}
+
+/*
+ * vm_page_blacklist_load:
+ *
+ * Search for a special module named "ram_blacklist". It'll be a
+ * plain text file provided by the user via the loader directive
+ * of the same name.
+ */
+static void
+vm_page_blacklist_load(char **list, char **end)
+{
+ void *mod;
+ u_char *ptr;
+ u_int len;
+
+ mod = NULL;
+ ptr = NULL;
+
+ mod = preload_search_by_type("ram_blacklist");
+ if (mod != NULL) {
+ ptr = preload_fetch_addr(mod);
+ len = preload_fetch_size(mod);
+ }
+ *list = ptr;
+ if (ptr != NULL)
+ *end = ptr + len;
+ else
+ *end = NULL;
+ return;
+}
+
+static int
+sysctl_vm_page_blacklist(SYSCTL_HANDLER_ARGS)
+{
+ vm_page_t m;
+ struct sbuf sbuf;
+ int error, first;
+
+ first = 1;
+ error = sysctl_wire_old_buffer(req, 0);
+ if (error != 0)
+ return (error);
+ sbuf_new_for_sysctl(&sbuf, NULL, 128, req);
+ TAILQ_FOREACH(m, &blacklist_head, listq) {
+ sbuf_printf(&sbuf, "%s%#jx", first ? "" : ",",
+ (uintmax_t)m->phys_addr);
+ first = 0;
+ }
+ error = sbuf_finish(&sbuf);
+ sbuf_delete(&sbuf);
+ return (error);
+}
+
static void
vm_page_domain_init(struct vm_domain *vmd)
{
@@ -290,7 +416,7 @@ vm_page_startup(vm_offset_t vaddr)
int i;
vm_paddr_t pa;
vm_paddr_t last_pa;
- char *list;
+ char *list, *listend;
vm_paddr_t end;
vm_paddr_t biggestsize;
vm_paddr_t low_water, high_water;
@@ -305,14 +431,6 @@ vm_page_startup(vm_offset_t vaddr)
phys_avail[i + 1] = trunc_page(phys_avail[i + 1]);
}
-#ifdef XEN
- /*
- * There is no obvious reason why i386 PV Xen needs vm_page structs
- * created for these pseudo-physical addresses. XXX
- */
- vm_phys_add_seg(0, phys_avail[0]);
-#endif
-
low_water = phys_avail[0];
high_water = phys_avail[1];
@@ -477,20 +595,22 @@ vm_page_startup(vm_offset_t vaddr)
*/
vm_cnt.v_page_count = 0;
vm_cnt.v_free_count = 0;
- list = kern_getenv("vm.blacklist");
for (i = 0; phys_avail[i + 1] != 0; i += 2) {
pa = phys_avail[i];
last_pa = phys_avail[i + 1];
while (pa < last_pa) {
- if (list != NULL &&
- vm_page_blacklist_lookup(list, pa))
- printf("Skipping page with pa 0x%jx\n",
- (uintmax_t)pa);
- else
- vm_phys_add_page(pa);
+ vm_phys_add_page(pa);
pa += PAGE_SIZE;
}
}
+
+ TAILQ_INIT(&blacklist_head);
+ vm_page_blacklist_load(&list, &listend);
+ vm_page_blacklist_check(list, listend);
+
+ list = kern_getenv("vm.blacklist");
+ vm_page_blacklist_check(list, NULL);
+
freeenv(list);
#if VM_NRESERVLEVEL > 0
/*
@@ -1636,6 +1756,7 @@ vm_page_alloc(vm_object_t object, vm_pindex_t pindex, int req)
m->wire_count = 0;
}
m->object = NULL;
+ m->oflags = VPO_UNMANAGED;
vm_page_free(m);
return (NULL);
}
@@ -3033,8 +3154,8 @@ vm_page_zero_invalid(vm_page_t m, boolean_t setvalid)
VM_OBJECT_ASSERT_WLOCKED(m->object);
/*
* Scan the valid bits looking for invalid sections that
- * must be zerod. Invalid sub-DEV_BSIZE'd areas ( where the
- * valid bit may be set ) have already been zerod by
+ * must be zeroed. Invalid sub-DEV_BSIZE'd areas ( where the
+ * valid bit may be set ) have already been zeroed by
* vm_page_set_validclean().
*/
for (b = i = 0; i <= PAGE_SIZE / DEV_BSIZE; ++i) {
diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c
index 6f50053..2f57579 100644
--- a/sys/vm/vm_pageout.c
+++ b/sys/vm/vm_pageout.c
@@ -1724,8 +1724,9 @@ vm_pageout_init(void)
static void
vm_pageout(void)
{
+ int error;
#if MAXMEMDOM > 1
- int error, i;
+ int i;
#endif
swap_pager_swap_init();
@@ -1739,6 +1740,10 @@ vm_pageout(void)
}
}
#endif
+ error = kthread_add(uma_reclaim_worker, NULL, curproc, NULL,
+ 0, 0, "uma");
+ if (error != 0)
+ panic("starting uma_reclaim helper, error %d\n", error);
vm_pageout_worker((void *)(uintptr_t)0);
}
@@ -1787,11 +1792,13 @@ vm_daemon(void)
while (TRUE) {
mtx_lock(&vm_daemon_mtx);
+ msleep(&vm_daemon_needed, &vm_daemon_mtx, PPAUSE, "psleep",
#ifdef RACCT
- msleep(&vm_daemon_needed, &vm_daemon_mtx, PPAUSE, "psleep", hz);
+ racct_enable ? hz : 0
#else
- msleep(&vm_daemon_needed, &vm_daemon_mtx, PPAUSE, "psleep", 0);
+ 0
#endif
+ );
swapout_flags = vm_pageout_req_swapout;
vm_pageout_req_swapout = 0;
mtx_unlock(&vm_daemon_mtx);
@@ -1866,33 +1873,40 @@ again:
&vm->vm_map, limit);
}
#ifdef RACCT
- rsize = IDX_TO_OFF(size);
- PROC_LOCK(p);
- racct_set(p, RACCT_RSS, rsize);
- ravailable = racct_get_available(p, RACCT_RSS);
- PROC_UNLOCK(p);
- if (rsize > ravailable) {
- /*
- * Don't be overly aggressive; this might be
- * an innocent process, and the limit could've
- * been exceeded by some memory hog. Don't
- * try to deactivate more than 1/4th of process'
- * resident set size.
- */
- if (attempts <= 8) {
- if (ravailable < rsize - (rsize / 4))
- ravailable = rsize - (rsize / 4);
- }
- vm_pageout_map_deactivate_pages(
- &vm->vm_map, OFF_TO_IDX(ravailable));
- /* Update RSS usage after paging out. */
- size = vmspace_resident_count(vm);
+ if (racct_enable) {
rsize = IDX_TO_OFF(size);
PROC_LOCK(p);
racct_set(p, RACCT_RSS, rsize);
+ ravailable = racct_get_available(p, RACCT_RSS);
PROC_UNLOCK(p);
- if (rsize > ravailable)
- tryagain = 1;
+ if (rsize > ravailable) {
+ /*
+ * Don't be overly aggressive; this
+ * might be an innocent process,
+ * and the limit could've been exceeded
+ * by some memory hog. Don't try
+ * to deactivate more than 1/4th
+ * of process' resident set size.
+ */
+ if (attempts <= 8) {
+ if (ravailable < rsize -
+ (rsize / 4)) {
+ ravailable = rsize -
+ (rsize / 4);
+ }
+ }
+ vm_pageout_map_deactivate_pages(
+ &vm->vm_map,
+ OFF_TO_IDX(ravailable));
+ /* Update RSS usage after paging out. */
+ size = vmspace_resident_count(vm);
+ rsize = IDX_TO_OFF(size);
+ PROC_LOCK(p);
+ racct_set(p, RACCT_RSS, rsize);
+ PROC_UNLOCK(p);
+ if (rsize > ravailable)
+ tryagain = 1;
+ }
}
#endif
vmspace_free(vm);
diff --git a/sys/vm/vm_phys.c b/sys/vm/vm_phys.c
index 5c33be4..71fadd7 100644
--- a/sys/vm/vm_phys.c
+++ b/sys/vm/vm_phys.c
@@ -71,6 +71,7 @@ _Static_assert(sizeof(long) * NBBY >= VM_PHYSSEG_MAX,
"Too many physsegs.");
struct mem_affinity *mem_affinity;
+int *mem_locality;
int vm_ndomains = 1;
@@ -140,6 +141,10 @@ static int sysctl_vm_phys_segs(SYSCTL_HANDLER_ARGS);
SYSCTL_OID(_vm, OID_AUTO, phys_segs, CTLTYPE_STRING | CTLFLAG_RD,
NULL, 0, sysctl_vm_phys_segs, "A", "Phys Seg Info");
+static int sysctl_vm_phys_locality(SYSCTL_HANDLER_ARGS);
+SYSCTL_OID(_vm, OID_AUTO, phys_locality, CTLTYPE_STRING | CTLFLAG_RD,
+ NULL, 0, sysctl_vm_phys_locality, "A", "Phys Locality Info");
+
SYSCTL_INT(_vm, OID_AUTO, ndomains, CTLFLAG_RD,
&vm_ndomains, 0, "Number of physical memory domains available.");
@@ -297,6 +302,48 @@ sysctl_vm_phys_segs(SYSCTL_HANDLER_ARGS)
return (error);
}
+/*
+ * Return affinity, or -1 if there's no affinity information.
+ */
+static int
+vm_phys_mem_affinity(int f, int t)
+{
+
+ if (mem_locality == NULL)
+ return (-1);
+ if (f >= vm_ndomains || t >= vm_ndomains)
+ return (-1);
+ return (mem_locality[f * vm_ndomains + t]);
+}
+
+/*
+ * Outputs the VM locality table.
+ */
+static int
+sysctl_vm_phys_locality(SYSCTL_HANDLER_ARGS)
+{
+ struct sbuf sbuf;
+ int error, i, j;
+
+ error = sysctl_wire_old_buffer(req, 0);
+ if (error != 0)
+ return (error);
+ sbuf_new_for_sysctl(&sbuf, NULL, 128, req);
+
+ sbuf_printf(&sbuf, "\n");
+
+ for (i = 0; i < vm_ndomains; i++) {
+ sbuf_printf(&sbuf, "%d: ", i);
+ for (j = 0; j < vm_ndomains; j++) {
+ sbuf_printf(&sbuf, "%d ", vm_phys_mem_affinity(i, j));
+ }
+ sbuf_printf(&sbuf, "\n");
+ }
+ error = sbuf_finish(&sbuf);
+ sbuf_delete(&sbuf);
+ return (error);
+}
+
static void
vm_freelist_add(struct vm_freelist *fl, vm_page_t m, int order, int tail)
{
diff --git a/sys/vm/vm_phys.h b/sys/vm/vm_phys.h
index 8f3e847..575b93c 100644
--- a/sys/vm/vm_phys.h
+++ b/sys/vm/vm_phys.h
@@ -61,6 +61,7 @@ struct vm_phys_seg {
};
extern struct mem_affinity *mem_affinity;
+extern int *mem_locality;
extern int vm_ndomains;
extern struct vm_phys_seg vm_phys_segs[];
extern int vm_phys_nsegs;
diff --git a/sys/vm/vm_unix.c b/sys/vm/vm_unix.c
index de9aa78..cc77ff7 100644
--- a/sys/vm/vm_unix.c
+++ b/sys/vm/vm_unix.c
@@ -130,35 +130,39 @@ sys_obreak(td, uap)
goto done;
}
#ifdef RACCT
- PROC_LOCK(td->td_proc);
- error = racct_set(td->td_proc, RACCT_DATA, new - base);
- if (error != 0) {
- PROC_UNLOCK(td->td_proc);
- error = ENOMEM;
- goto done;
- }
- error = racct_set(td->td_proc, RACCT_VMEM,
- map->size + (new - old));
- if (error != 0) {
- racct_set_force(td->td_proc, RACCT_DATA, old - base);
- PROC_UNLOCK(td->td_proc);
- error = ENOMEM;
- goto done;
- }
- if (!old_mlock && map->flags & MAP_WIREFUTURE) {
- error = racct_set(td->td_proc, RACCT_MEMLOCK,
- ptoa(pmap_wired_count(map->pmap)) + (new - old));
+ if (racct_enable) {
+ PROC_LOCK(td->td_proc);
+ error = racct_set(td->td_proc, RACCT_DATA, new - base);
+ if (error != 0) {
+ PROC_UNLOCK(td->td_proc);
+ error = ENOMEM;
+ goto done;
+ }
+ error = racct_set(td->td_proc, RACCT_VMEM,
+ map->size + (new - old));
if (error != 0) {
racct_set_force(td->td_proc, RACCT_DATA,
old - base);
- racct_set_force(td->td_proc, RACCT_VMEM,
- map->size);
PROC_UNLOCK(td->td_proc);
error = ENOMEM;
goto done;
}
+ if (!old_mlock && map->flags & MAP_WIREFUTURE) {
+ error = racct_set(td->td_proc, RACCT_MEMLOCK,
+ ptoa(pmap_wired_count(map->pmap)) +
+ (new - old));
+ if (error != 0) {
+ racct_set_force(td->td_proc, RACCT_DATA,
+ old - base);
+ racct_set_force(td->td_proc, RACCT_VMEM,
+ map->size);
+ PROC_UNLOCK(td->td_proc);
+ error = ENOMEM;
+ goto done;
+ }
+ }
+ PROC_UNLOCK(td->td_proc);
}
- PROC_UNLOCK(td->td_proc);
#endif
prot = VM_PROT_RW;
#ifdef COMPAT_FREEBSD32
@@ -170,14 +174,19 @@ sys_obreak(td, uap)
rv = vm_map_insert(map, NULL, 0, old, new, prot, VM_PROT_ALL, 0);
if (rv != KERN_SUCCESS) {
#ifdef RACCT
- PROC_LOCK(td->td_proc);
- racct_set_force(td->td_proc, RACCT_DATA, old - base);
- racct_set_force(td->td_proc, RACCT_VMEM, map->size);
- if (!old_mlock && map->flags & MAP_WIREFUTURE) {
- racct_set_force(td->td_proc, RACCT_MEMLOCK,
- ptoa(pmap_wired_count(map->pmap)));
+ if (racct_enable) {
+ PROC_LOCK(td->td_proc);
+ racct_set_force(td->td_proc,
+ RACCT_DATA, old - base);
+ racct_set_force(td->td_proc,
+ RACCT_VMEM, map->size);
+ if (!old_mlock && map->flags & MAP_WIREFUTURE) {
+ racct_set_force(td->td_proc,
+ RACCT_MEMLOCK,
+ ptoa(pmap_wired_count(map->pmap)));
+ }
+ PROC_UNLOCK(td->td_proc);
}
- PROC_UNLOCK(td->td_proc);
#endif
error = ENOMEM;
goto done;
@@ -205,14 +214,16 @@ sys_obreak(td, uap)
}
vm->vm_dsize -= btoc(old - new);
#ifdef RACCT
- PROC_LOCK(td->td_proc);
- racct_set_force(td->td_proc, RACCT_DATA, new - base);
- racct_set_force(td->td_proc, RACCT_VMEM, map->size);
- if (!old_mlock && map->flags & MAP_WIREFUTURE) {
- racct_set_force(td->td_proc, RACCT_MEMLOCK,
- ptoa(pmap_wired_count(map->pmap)));
+ if (racct_enable) {
+ PROC_LOCK(td->td_proc);
+ racct_set_force(td->td_proc, RACCT_DATA, new - base);
+ racct_set_force(td->td_proc, RACCT_VMEM, map->size);
+ if (!old_mlock && map->flags & MAP_WIREFUTURE) {
+ racct_set_force(td->td_proc, RACCT_MEMLOCK,
+ ptoa(pmap_wired_count(map->pmap)));
+ }
+ PROC_UNLOCK(td->td_proc);
}
- PROC_UNLOCK(td->td_proc);
#endif
}
done:
diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c
index 2878dc3..b65a2a3 100644
--- a/sys/vm/vnode_pager.c
+++ b/sys/vm/vnode_pager.c
@@ -237,6 +237,12 @@ retry:
* Object has been created while we were sleeping
*/
VI_UNLOCK(vp);
+ VM_OBJECT_WLOCK(object);
+ KASSERT(object->ref_count == 1,
+ ("leaked ref %p %d", object, object->ref_count));
+ object->type = OBJT_DEAD;
+ object->ref_count = 0;
+ VM_OBJECT_WUNLOCK(object);
vm_object_destroy(object);
goto retry;
}
@@ -340,16 +346,21 @@ vnode_pager_haspage(vm_object_t object, vm_pindex_t pindex, int *before,
*before += poff;
}
if (after) {
- int numafter;
+ /*
+ * The BMAP vop can report a partial block in the
+ * 'after', but must not report blocks after EOF.
+ * Assert the latter, and truncate 'after' in case
+ * of the former.
+ */
+ KASSERT((reqblock + *after) * pagesperblock <
+ roundup2(object->size, pagesperblock),
+ ("%s: reqblock %jd after %d size %ju", __func__,
+ (intmax_t )reqblock, *after,
+ (uintmax_t )object->size));
*after *= pagesperblock;
- numafter = pagesperblock - (poff + 1);
- if (IDX_TO_OFF(pindex + numafter) >
- object->un_pager.vnp.vnp_size) {
- numafter =
- OFF_TO_IDX(object->un_pager.vnp.vnp_size) -
- pindex;
- }
- *after += numafter;
+ *after += pagesperblock - (poff + 1);
+ if (pindex + *after >= object->size)
+ *after = object->size - 1 - pindex;
}
} else {
if (before) {
diff --git a/sys/x86/acpica/srat.c b/sys/x86/acpica/srat.c
index 8d2a741..2ec0c32 100644
--- a/sys/x86/acpica/srat.c
+++ b/sys/x86/acpica/srat.c
@@ -64,9 +64,97 @@ static vm_paddr_t srat_physaddr;
static int vm_domains[VM_PHYSSEG_MAX];
+static ACPI_TABLE_SLIT *slit;
+static vm_paddr_t slit_physaddr;
+static int vm_locality_table[MAXMEMDOM * MAXMEMDOM];
+
static void srat_walk_table(acpi_subtable_handler *handler, void *arg);
/*
+ * SLIT parsing.
+ */
+
+static void
+slit_parse_table(ACPI_TABLE_SLIT *s)
+{
+ int i, j;
+ int i_domain, j_domain;
+ int offset = 0;
+ uint8_t e;
+
+ /*
+ * This maps the SLIT data into the VM-domain centric view.
+ * There may be sparse entries in the PXM namespace, so
+ * remap them to a VM-domain ID and if it doesn't exist,
+ * skip it.
+ *
+ * It should result in a packed 2d array of VM-domain
+ * locality information entries.
+ */
+
+ if (bootverbose)
+ printf("SLIT.Localities: %d\n", (int) s->LocalityCount);
+ for (i = 0; i < s->LocalityCount; i++) {
+ i_domain = acpi_map_pxm_to_vm_domainid(i);
+ if (i_domain < 0)
+ continue;
+
+ if (bootverbose)
+ printf("%d: ", i);
+ for (j = 0; j < s->LocalityCount; j++) {
+ j_domain = acpi_map_pxm_to_vm_domainid(j);
+ if (j_domain < 0)
+ continue;
+ e = s->Entry[i * s->LocalityCount + j];
+ if (bootverbose)
+ printf("%d ", (int) e);
+ /* 255 == "no locality information" */
+ if (e == 255)
+ vm_locality_table[offset] = -1;
+ else
+ vm_locality_table[offset] = e;
+ offset++;
+ }
+ if (bootverbose)
+ printf("\n");
+ }
+}
+
+/*
+ * Look for an ACPI System Locality Distance Information Table ("SLIT")
+ */
+static int
+parse_slit(void)
+{
+
+ if (resource_disabled("slit", 0)) {
+ return (-1);
+ }
+
+ slit_physaddr = acpi_find_table(ACPI_SIG_SLIT);
+ if (slit_physaddr == 0) {
+ return (-1);
+ }
+
+ /*
+ * Make a pass over the table to populate the cpus[] and
+ * mem_info[] tables.
+ */
+ slit = acpi_map_table(slit_physaddr, ACPI_SIG_SLIT);
+ slit_parse_table(slit);
+ acpi_unmap_table(slit);
+ slit = NULL;
+
+ /* Tell the VM about it! */
+ mem_locality = vm_locality_table;
+ return (0);
+}
+
+/*
+ * SRAT parsing.
+ */
+
+/*
* Returns true if a memory range overlaps with at least one range in
* phys_avail[].
*/
@@ -301,17 +389,17 @@ renumber_domains(void)
/*
* Look for an ACPI System Resource Affinity Table ("SRAT")
*/
-static void
-parse_srat(void *dummy)
+static int
+parse_srat(void)
{
int error;
if (resource_disabled("srat", 0))
- return;
+ return (-1);
srat_physaddr = acpi_find_table(ACPI_SIG_SRAT);
if (srat_physaddr == 0)
- return;
+ return (-1);
/*
* Make a pass over the table to populate the cpus[] and
@@ -325,13 +413,39 @@ parse_srat(void *dummy)
if (error || check_domains() != 0 || check_phys_avail() != 0 ||
renumber_domains() != 0) {
srat_physaddr = 0;
- return;
+ return (-1);
}
/* Point vm_phys at our memory affinity table. */
mem_affinity = mem_info;
+
+ return (0);
+}
+
+static void
+init_mem_locality(void)
+{
+ int i;
+
+ /*
+ * For now, assume -1 == "no locality information for
+ * this pairing.
+ */
+ for (i = 0; i < MAXMEMDOM * MAXMEMDOM; i++)
+ vm_locality_table[i] = -1;
+}
+
+static void
+parse_acpi_tables(void *dummy)
+{
+
+ if (parse_srat() < 0)
+ return;
+ init_mem_locality();
+ (void) parse_slit();
}
-SYSINIT(parse_srat, SI_SUB_VM - 1, SI_ORDER_FIRST, parse_srat, NULL);
+SYSINIT(parse_acpi_tables, SI_SUB_VM - 1, SI_ORDER_FIRST, parse_acpi_tables,
+ NULL);
static void
srat_walk_table(acpi_subtable_handler *handler, void *arg)
diff --git a/sys/x86/include/acpica_machdep.h b/sys/x86/include/acpica_machdep.h
index 46080c0..136285c 100644
--- a/sys/x86/include/acpica_machdep.h
+++ b/sys/x86/include/acpica_machdep.h
@@ -74,6 +74,7 @@ enum intr_polarity;
void acpi_SetDefaultIntrModel(int model);
void acpi_cpu_c1(void);
+void acpi_cpu_idle_mwait(uint32_t mwait_hint);
void *acpi_map_table(vm_paddr_t pa, const char *sig);
void acpi_unmap_table(void *table);
vm_paddr_t acpi_find_table(const char *sig);
diff --git a/sys/x86/include/apicvar.h b/sys/x86/include/apicvar.h
index 818a831..0bd9fe5 100644
--- a/sys/x86/include/apicvar.h
+++ b/sys/x86/include/apicvar.h
@@ -454,6 +454,7 @@ void lapic_handle_error(void);
void lapic_handle_intr(int vector, struct trapframe *frame);
void lapic_handle_timer(struct trapframe *frame);
void xen_intr_handle_upcall(struct trapframe *frame);
+void hv_vector_handler(struct trapframe *frame);
extern int x2apic_mode;
extern int lapic_eoi_suppression;
diff --git a/sys/x86/include/segments.h b/sys/x86/include/segments.h
index a5c1ea4..65b5870 100644
--- a/sys/x86/include/segments.h
+++ b/sys/x86/include/segments.h
@@ -46,11 +46,7 @@
*/
#define SEL_RPL_MASK 3 /* requester priv level */
#define ISPL(s) ((s)&3) /* priority level of a selector */
-#ifdef XEN
-#define SEL_KPL 1 /* kernel priority level */
-#else
#define SEL_KPL 0 /* kernel priority level */
-#endif
#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 */
@@ -244,11 +240,7 @@ union descriptor {
#define GBIOSUTIL_SEL 16 /* BIOS interface (Utility) */
#define GBIOSARGS_SEL 17 /* BIOS interface (Arguments) */
#define GNDIS_SEL 18 /* For the NDIS layer */
-#ifdef XEN
-#define NGDT 9
-#else
#define NGDT 19
-#endif
/*
* Entries in the Local Descriptor Table (LDT)
diff --git a/sys/x86/include/specialreg.h b/sys/x86/include/specialreg.h
index 60f46fb..6c849ff 100644
--- a/sys/x86/include/specialreg.h
+++ b/sys/x86/include/specialreg.h
@@ -53,6 +53,7 @@
#define CR0_CD 0x40000000 /* Cache Disable */
#define CR3_PCID_SAVE 0x8000000000000000
+#define CR3_PCID_MASK 0xfff
/*
* Bits in PPro special registers
@@ -82,6 +83,9 @@
#define EFER_LMA 0x000000400 /* Long mode active (R) */
#define EFER_NXE 0x000000800 /* PTE No-Execute bit enable (R/W) */
#define EFER_SVM 0x000001000 /* SVM enable bit for AMD, reserved for Intel */
+#define EFER_LMSLE 0x000002000 /* Long Mode Segment Limit Enable */
+#define EFER_FFXSR 0x000004000 /* Fast FXSAVE/FSRSTOR */
+#define EFER_TCE 0x000008000 /* Translation Cache Extension */
/*
* Intel Extended Features registers
@@ -191,7 +195,7 @@
#define AMDID_MP 0x00080000
#define AMDID_NX 0x00100000
#define AMDID_EXT_MMX 0x00400000
-#define AMDID_FFXSR 0x01000000
+#define AMDID_FFXSR 0x02000000
#define AMDID_PAGE1GB 0x04000000
#define AMDID_RDTSCP 0x08000000
#define AMDID_LM 0x20000000
diff --git a/sys/x86/x86/busdma_bounce.c b/sys/x86/x86/busdma_bounce.c
index 1438053..dcdeafa 100644
--- a/sys/x86/x86/busdma_bounce.c
+++ b/sys/x86/x86/busdma_bounce.c
@@ -147,11 +147,6 @@ static void _bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_t map,
static int _bus_dmamap_reserve_pages(bus_dma_tag_t dmat, bus_dmamap_t map,
int flags);
-#ifdef XEN
-#undef pmap_kextract
-#define pmap_kextract pmap_kextract_ma
-#endif
-
/*
* Allocate a device specific dma_tag.
*/
@@ -994,8 +989,8 @@ add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr,
if (dmat->common.flags & BUS_DMA_KEEP_PG_OFFSET) {
/* Page offset needs to be preserved. */
- bpage->vaddr |= vaddr & PAGE_MASK;
- bpage->busaddr |= vaddr & PAGE_MASK;
+ bpage->vaddr |= addr & PAGE_MASK;
+ bpage->busaddr |= addr & PAGE_MASK;
}
bpage->datavaddr = vaddr;
bpage->dataaddr = addr;
diff --git a/sys/x86/x86/cpu_machdep.c b/sys/x86/x86/cpu_machdep.c
index 846a123..f07b97e 100644
--- a/sys/x86/x86/cpu_machdep.c
+++ b/sys/x86/x86/cpu_machdep.c
@@ -90,6 +90,7 @@ __FBSDID("$FreeBSD$");
#ifdef SMP
#include <machine/smp.h>
#endif
+#include <x86/acpica_machdep.h>
#include <vm/vm.h>
#include <vm/vm_extern.h>
@@ -100,14 +101,9 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_pager.h>
#include <vm/vm_param.h>
-#ifdef XEN
-/* XEN includes */
-#include <xen/xen-os.h>
-#include <xen/hypervisor.h>
-#include <machine/xen/xenvar.h>
-#include <machine/xen/xenfunc.h>
-#include <xen/xen_intr.h>
-#endif
+#define STATE_RUNNING 0x0
+#define STATE_MWAIT 0x1
+#define STATE_SLEEPING 0x2
/*
* Machine dependent boot() routine
@@ -130,6 +126,38 @@ cpu_flush_dcache(void *ptr, size_t len)
/* Not applicable */
}
+void
+acpi_cpu_c1(void)
+{
+
+ __asm __volatile("sti; hlt");
+}
+
+void
+acpi_cpu_idle_mwait(uint32_t mwait_hint)
+{
+ int *state;
+
+ /*
+ * XXXKIB. Software coordination mode should be supported,
+ * but all Intel CPUs provide hardware coordination.
+ */
+
+ state = (int *)PCPU_PTR(monitorbuf);
+ KASSERT(*state == STATE_SLEEPING,
+ ("cpu_mwait_cx: wrong monitorbuf state"));
+ *state = STATE_MWAIT;
+ cpu_monitor(state, 0, 0);
+ if (*state == STATE_MWAIT)
+ cpu_mwait(MWAIT_INTRBREAK, mwait_hint);
+
+ /*
+ * We should exit on any event that interrupts mwait, because
+ * that event might be a wanted interrupt.
+ */
+ *state = STATE_RUNNING;
+}
+
/* Get current clock frequency for the given cpu id. */
int
cpu_est_clockrate(int cpu_id, uint64_t *rate)
@@ -193,33 +221,6 @@ cpu_est_clockrate(int cpu_id, uint64_t *rate)
return (0);
}
-#if defined(__i386__) && defined(XEN)
-
-static void
-idle_block(void)
-{
-
- HYPERVISOR_sched_op(SCHEDOP_block, 0);
-}
-
-void
-cpu_halt(void)
-{
- HYPERVISOR_shutdown(SHUTDOWN_poweroff);
-}
-
-int scheduler_running;
-
-static void
-cpu_idle_hlt(sbintime_t sbt)
-{
-
- scheduler_running = 1;
- enable_intr();
- idle_block();
-}
-
-#else
/*
* Shutdown the CPU as much as possible
*/
@@ -230,7 +231,14 @@ cpu_halt(void)
halt();
}
-#endif
+bool
+cpu_mwait_usable(void)
+{
+
+ return ((cpu_feature2 & CPUID2_MON) != 0 && ((cpu_mon_mwait_flags &
+ (CPUID5_MON_MWAIT_EXT | CPUID5_MWAIT_INTRBREAK)) ==
+ (CPUID5_MON_MWAIT_EXT | CPUID5_MWAIT_INTRBREAK)));
+}
void (*cpu_idle_hook)(sbintime_t) = NULL; /* ACPI idle hook. */
static int cpu_ident_amdc1e = 0; /* AMD C1E supported. */
@@ -238,10 +246,6 @@ static int idle_mwait = 1; /* Use MONITOR/MWAIT for short idle. */
SYSCTL_INT(_machdep, OID_AUTO, idle_mwait, CTLFLAG_RWTUN, &idle_mwait,
0, "Use MONITOR/MWAIT for short idle");
-#define STATE_RUNNING 0x0
-#define STATE_MWAIT 0x1
-#define STATE_SLEEPING 0x2
-
#ifndef PC98
static void
cpu_idle_acpi(sbintime_t sbt)
@@ -258,12 +262,11 @@ cpu_idle_acpi(sbintime_t sbt)
else if (cpu_idle_hook)
cpu_idle_hook(sbt);
else
- __asm __volatile("sti; hlt");
+ acpi_cpu_c1();
*state = STATE_RUNNING;
}
#endif /* !PC98 */
-#if !defined(__i386__) || !defined(XEN)
static void
cpu_idle_hlt(sbintime_t sbt)
{
@@ -292,10 +295,9 @@ cpu_idle_hlt(sbintime_t sbt)
if (sched_runnable())
enable_intr();
else
- __asm __volatile("sti; hlt");
+ acpi_cpu_c1();
*state = STATE_RUNNING;
}
-#endif
static void
cpu_idle_mwait(sbintime_t sbt)
@@ -370,7 +372,7 @@ cpu_probe_amdc1e(void)
}
}
-#if defined(__i386__) && (defined(PC98) || defined(XEN))
+#if defined(__i386__) && defined(PC98)
void (*cpu_idle_fn)(sbintime_t) = cpu_idle_hlt;
#else
void (*cpu_idle_fn)(sbintime_t) = cpu_idle_acpi;
@@ -379,17 +381,15 @@ void (*cpu_idle_fn)(sbintime_t) = cpu_idle_acpi;
void
cpu_idle(int busy)
{
-#if !defined(__i386__) || !defined(XEN)
uint64_t msr;
-#endif
sbintime_t sbt = -1;
CTR2(KTR_SPARE2, "cpu_idle(%d) at %d",
busy, curcpu);
-#if defined(MP_WATCHDOG) && (!defined(__i386__) || !defined(XEN))
+#ifdef MP_WATCHDOG
ap_watchdog(PCPU_GET(cpuid));
#endif
-#if !defined(__i386__) || !defined(XEN)
+
/* If we are busy - try to use fast methods. */
if (busy) {
if ((cpu_feature2 & CPUID2_MON) && idle_mwait) {
@@ -397,7 +397,6 @@ cpu_idle(int busy)
goto out;
}
}
-#endif
/* If we have time - switch timers into idle mode. */
if (!busy) {
@@ -405,14 +404,12 @@ cpu_idle(int busy)
sbt = cpu_idleclock();
}
-#if !defined(__i386__) || !defined(XEN)
/* Apply AMD APIC timer C1E workaround. */
if (cpu_ident_amdc1e && cpu_disable_c3_sleep) {
msr = rdmsr(MSR_AMDK8_IPM);
if (msr & AMDK8_CMPHALT)
wrmsr(MSR_AMDK8_IPM, msr & ~AMDK8_CMPHALT);
}
-#endif
/* Call main idle method. */
cpu_idle_fn(sbt);
@@ -422,9 +419,7 @@ cpu_idle(int busy)
cpu_activeclock();
critical_exit();
}
-#if !defined(__i386__) || !defined(XEN)
out:
-#endif
CTR2(KTR_SPARE2, "cpu_idle(%d) at %d done",
busy, curcpu);
}
diff --git a/sys/x86/x86/identcpu.c b/sys/x86/x86/identcpu.c
index ca2b5ca..9f39d1c 100644
--- a/sys/x86/x86/identcpu.c
+++ b/sys/x86/x86/identcpu.c
@@ -1190,7 +1190,6 @@ hook_tsc_freq(void *arg __unused)
SYSINIT(hook_tsc_freq, SI_SUB_CONFIGURE, SI_ORDER_ANY, hook_tsc_freq, NULL);
-#ifndef XEN
static const char *const vm_bnames[] = {
"QEMU", /* QEMU */
"Plex86", /* Plex86 */
@@ -1281,7 +1280,6 @@ identify_hypervisor(void)
freeenv(p);
}
}
-#endif
/*
* Final stage of CPU identification.
@@ -1314,9 +1312,7 @@ identify_cpu(void)
cpu_feature2 = regs[2];
#endif
-#ifndef XEN
identify_hypervisor();
-#endif
cpu_vendor_id = find_cpu_vendor_id();
/*
diff --git a/sys/x86/x86/intr_machdep.c b/sys/x86/x86/intr_machdep.c
index b27df4a..d81c913 100644
--- a/sys/x86/x86/intr_machdep.c
+++ b/sys/x86/x86/intr_machdep.c
@@ -532,13 +532,6 @@ intr_shuffle_irqs(void *arg __unused)
struct intsrc *isrc;
int i;
-#ifdef XEN
- /*
- * Doesn't work yet
- */
- return;
-#endif
-
/* Don't bother on UP. */
if (mp_ncpus == 1)
return;
diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c
index e0656ef..d75a452 100644
--- a/sys/x86/x86/local_apic.c
+++ b/sys/x86/x86/local_apic.c
@@ -1579,17 +1579,13 @@ apic_setup_io(void *dummy __unused)
* Local APIC must be registered before other PICs and pseudo PICs
* for proper suspend/resume order.
*/
-#ifndef XEN
intr_register_pic(&lapic_pic);
-#endif
retval = best_enum->apic_setup_io();
if (retval != 0)
printf("%s: Failed to setup I/O APICs: returned %d\n",
best_enum->apic_name, retval);
-#ifdef XEN
- return;
-#endif
+
/*
* Finish setting up the local APIC on the BSP once we know
* how to properly program the LINT pins. In particular, this
diff --git a/sys/x86/x86/mca.c b/sys/x86/x86/mca.c
index 8026b15..b4c7643 100644
--- a/sys/x86/x86/mca.c
+++ b/sys/x86/x86/mca.c
@@ -762,7 +762,7 @@ mca_setup(uint64_t mcg_cap)
mtx_init(&mca_lock, "mca", NULL, MTX_SPIN);
STAILQ_INIT(&mca_records);
TASK_INIT(&mca_scan_task, 0, mca_scan_cpus, NULL);
- callout_init(&mca_timer, CALLOUT_MPSAFE);
+ callout_init(&mca_timer, 1);
STAILQ_INIT(&mca_freelist);
TASK_INIT(&mca_refill_task, 0, mca_refill, NULL);
mca_fill_freelist();
diff --git a/sys/x86/xen/xen_apic.c b/sys/x86/xen/xen_apic.c
index c742920..a65f3b5 100644
--- a/sys/x86/xen/xen_apic.c
+++ b/sys/x86/xen/xen_apic.c
@@ -423,31 +423,29 @@ xen_invltlb(void *arg)
#ifdef __amd64__
static int
-xen_invltlb_pcid(void *arg)
+xen_invltlb_invpcid(void *arg)
{
- invltlb_pcid_handler();
+ invltlb_invpcid_handler();
return (FILTER_HANDLED);
}
-#endif
static int
-xen_invlpg(void *arg)
+xen_invltlb_pcid(void *arg)
{
- invlpg_handler();
+ invltlb_pcid_handler();
return (FILTER_HANDLED);
}
+#endif
-#ifdef __amd64__
static int
-xen_invlpg_pcid(void *arg)
+xen_invlpg(void *arg)
{
- invlpg_pcid_handler();
+ invlpg_handler();
return (FILTER_HANDLED);
}
-#endif
static int
xen_invlrng(void *arg)
@@ -532,8 +530,8 @@ xen_setup_cpus(void)
#ifdef __amd64__
if (pmap_pcid_enabled) {
- xen_ipis[IPI_TO_IDX(IPI_INVLTLB)].filter = xen_invltlb_pcid;
- xen_ipis[IPI_TO_IDX(IPI_INVLPG)].filter = xen_invlpg_pcid;
+ xen_ipis[IPI_TO_IDX(IPI_INVLTLB)].filter = invpcid_works ?
+ xen_invltlb_invpcid : xen_invltlb_pcid;
}
#endif
CPU_FOREACH(i)
diff --git a/sys/x86/xen/xen_intr.c b/sys/x86/xen/xen_intr.c
index 64979b1..3bc4b43 100644
--- a/sys/x86/xen/xen_intr.c
+++ b/sys/x86/xen/xen_intr.c
@@ -1,7 +1,7 @@
/******************************************************************************
* xen_intr.c
*
- * Xen event and interrupt services for x86 PV and HVM guests.
+ * Xen event and interrupt services for x86 HVM guests.
*
* Copyright (c) 2002-2005, K A Fraser
* Copyright (c) 2005, Intel Corporation <xiaofeng.ling@intel.com>
@@ -864,10 +864,8 @@ xen_intr_assign_cpu(struct intsrc *base_isrc, u_int apic_id)
u_int to_cpu, vcpu_id;
int error, masked;
-#ifdef XENHVM
if (xen_vector_callback_enabled == 0)
return (EOPNOTSUPP);
-#endif
to_cpu = apic_cpuid(apic_id);
vcpu_id = pcpu_find(to_cpu)->pc_vcpu_id;
diff --git a/sys/x86/xen/xen_nexus.c b/sys/x86/xen/xen_nexus.c
index f25f970..73506fc 100644
--- a/sys/x86/xen/xen_nexus.c
+++ b/sys/x86/xen/xen_nexus.c
@@ -66,14 +66,11 @@ static int
nexus_xen_attach(device_t dev)
{
int error;
-#ifndef XEN
device_t acpi_dev = NULL;
-#endif
nexus_init_resources();
bus_generic_probe(dev);
-#ifndef XEN
if (xen_initial_domain()) {
/* Disable some ACPI devices that are not usable by Dom0 */
acpi_cpu_disabled = true;
@@ -84,13 +81,10 @@ nexus_xen_attach(device_t dev)
if (acpi_dev == NULL)
panic("Unable to add ACPI bus to Xen Dom0");
}
-#endif
error = bus_generic_attach(dev);
-#ifndef XEN
if (xen_initial_domain() && (error == 0))
acpi_install_wakeup_handler(device_get_softc(acpi_dev));
-#endif
return (error);
}
diff --git a/sys/x86/xen/xenpv.c b/sys/x86/xen/xenpv.c
index bdda883..2e4a9fe 100644
--- a/sys/x86/xen/xenpv.c
+++ b/sys/x86/xen/xenpv.c
@@ -33,11 +33,33 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/pcpu.h>
+#include <sys/rman.h>
#include <sys/smp.h>
+#include <vm/vm.h>
+#include <vm/vm_page.h>
+#include <vm/vm_param.h>
+#include <vm/vm_phys.h>
+
#include <xen/xen-os.h>
#include <xen/gnttab.h>
+#include "xenmem_if.h"
+
+/*
+ * Allocate unused physical memory above 4GB in order to map memory
+ * from foreign domains. We use memory starting at 4GB in order to
+ * prevent clashes with MMIO/ACPI regions.
+ *
+ * Since this is not possible on i386 just use any available memory
+ * chunk and hope we don't clash with anything else.
+ */
+#ifdef __amd64__
+#define LOW_MEM_LIMIT 0x100000000ul
+#else
+#define LOW_MEM_LIMIT 0
+#endif
+
static devclass_t xenpv_devclass;
static void
@@ -85,6 +107,42 @@ xenpv_attach(device_t dev)
return (0);
}
+static struct resource *
+xenpv_alloc_physmem(device_t dev, device_t child, int *res_id, size_t size)
+{
+ struct resource *res;
+ vm_paddr_t phys_addr;
+ int error;
+
+ res = bus_alloc_resource(child, SYS_RES_MEMORY, res_id, LOW_MEM_LIMIT,
+ ~0ul, size, RF_ACTIVE);
+ if (res == NULL)
+ return (NULL);
+
+ phys_addr = rman_get_start(res);
+ error = vm_phys_fictitious_reg_range(phys_addr, phys_addr + size,
+ VM_MEMATTR_DEFAULT);
+ if (error) {
+ bus_release_resource(child, SYS_RES_MEMORY, *res_id, res);
+ return (NULL);
+ }
+
+ return (res);
+}
+
+static int
+xenpv_free_physmem(device_t dev, device_t child, int res_id, struct resource *res)
+{
+ vm_paddr_t phys_addr;
+ size_t size;
+
+ phys_addr = rman_get_start(res);
+ size = rman_get_size(res);
+
+ vm_phys_fictitious_unreg_range(phys_addr, phys_addr + size);
+ return (bus_release_resource(child, SYS_RES_MEMORY, res_id, res));
+}
+
static device_method_t xenpv_methods[] = {
/* Device interface */
DEVMETHOD(device_identify, xenpv_identify),
@@ -100,6 +158,10 @@ static device_method_t xenpv_methods[] = {
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
+ /* Interface to allocate memory for foreign mappings */
+ DEVMETHOD(xenmem_alloc, xenpv_alloc_physmem),
+ DEVMETHOD(xenmem_free, xenpv_free_physmem),
+
DEVMETHOD_END
};
@@ -110,3 +172,25 @@ static driver_t xenpv_driver = {
};
DRIVER_MODULE(xenpv, nexus, xenpv_driver, xenpv_devclass, 0, 0);
+
+struct resource *
+xenmem_alloc(device_t dev, int *res_id, size_t size)
+{
+ device_t parent;
+
+ parent = device_get_parent(dev);
+ if (parent == NULL)
+ return (NULL);
+ return (XENMEM_ALLOC(parent, dev, res_id, size));
+}
+
+int
+xenmem_free(device_t dev, int res_id, struct resource *res)
+{
+ device_t parent;
+
+ parent = device_get_parent(dev);
+ if (parent == NULL)
+ return (ENXIO);
+ return (XENMEM_FREE(parent, dev, res_id, res));
+}
diff --git a/sys/xen/xen-os.h b/sys/xen/xen-os.h
index c982d55..7ceef4f 100644
--- a/sys/xen/xen-os.h
+++ b/sys/xen/xen-os.h
@@ -89,6 +89,13 @@ xen_initial_domain(void)
(HYPERVISOR_start_info->flags & SIF_INITDOMAIN) != 0);
}
+/*
+ * Functions to allocate/free unused memory in order
+ * to map memory from other domains.
+ */
+struct resource *xenmem_alloc(device_t dev, int *res_id, size_t size);
+int xenmem_free(device_t dev, int res_id, struct resource *res);
+
/* Debug/emergency function, prints directly to hypervisor console */
void xc_printf(const char *, ...) __printflike(1, 2);
diff --git a/sys/xen/xenmem/xenmem_if.m b/sys/xen/xenmem/xenmem_if.m
new file mode 100644
index 0000000..5cc2171
--- /dev/null
+++ b/sys/xen/xenmem/xenmem_if.m
@@ -0,0 +1,95 @@
+#-
+# Copyright (c) 2015 Roger Pau Monné <royger@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/bus.h>
+
+INTERFACE xenmem;
+
+#
+# Default implementations of some methods.
+#
+CODE {
+ static struct resource *
+ xenmem_generic_alloc(device_t dev, device_t child, int *res_id,
+ size_t size)
+ {
+ device_t parent;
+
+ parent = device_get_parent(dev);
+ if (parent == NULL)
+ return (NULL);
+ return (XENMEM_ALLOC(parent, child, res_id, size));
+ }
+
+ static int
+ xenmem_generic_free(device_t dev, device_t child, int res_id,
+ struct resource *res)
+ {
+ device_t parent;
+
+ parent = device_get_parent(dev);
+ if (parent == NULL)
+ return (ENXIO);
+ return (XENMEM_FREE(parent, child, res_id, res));
+ }
+};
+
+/**
+ * @brief Request for unused physical memory regions.
+ *
+ * @param _dev the device whose child was being probed.
+ * @param _child the child device which failed to probe.
+ * @param _res_id a pointer to the resource identifier.
+ * @param _size size of the required memory region.
+ *
+ * @returns the resource which was allocated or @c NULL if no
+ * resource could be allocated.
+ */
+METHOD struct resource * alloc {
+ device_t _dev;
+ device_t _child;
+ int *_res_id;
+ size_t _size;
+} DEFAULT xenmem_generic_alloc;
+
+/**
+ * @brief Free physical memory regions.
+ *
+ * @param _dev the device whose child was being probed.
+ * @param _child the child device which failed to probe.
+ * @param _res_id the resource identifier.
+ * @param _res the resource.
+ *
+ * @returns 0 on success, otherwise an error code.
+ */
+METHOD int free {
+ device_t _dev;
+ device_t _child;
+ int _res_id;
+ struct resource *_res;
+} DEFAULT xenmem_generic_free;
diff --git a/tests/Makefile b/tests/Makefile
index 89da82d..12c1509 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -2,6 +2,7 @@
.include <bsd.own.mk>
+SUBDIR= etc
SUBDIR= sys
TESTSDIR= ${TESTSBASE}
diff --git a/etc/tests/Makefile b/tests/etc/Makefile
index 5aacd5b..9aad25c 100644
--- a/etc/tests/Makefile
+++ b/tests/etc/Makefile
@@ -4,7 +4,9 @@
TESTSDIR= ${TESTSBASE}/etc
-.PATH: ${.CURDIR:H:H}/tests
+.PATH: ${.CURDIR:H}
KYUAFILE= yes
+SUBDIR+= rc.d
+
.include <bsd.test.mk>
diff --git a/etc/rc.d/tests/Makefile b/tests/etc/rc.d/Makefile
index 368e8f4..368e8f4 100644
--- a/etc/rc.d/tests/Makefile
+++ b/tests/etc/rc.d/Makefile
diff --git a/etc/rc.d/tests/routing_test.sh b/tests/etc/rc.d/routing_test.sh
index 693af23..693af23 100755
--- a/etc/rc.d/tests/routing_test.sh
+++ b/tests/etc/rc.d/routing_test.sh
diff --git a/tests/freebsd_test_suite/macros.h b/tests/freebsd_test_suite/macros.h
new file mode 100644
index 0000000..8d95f05
--- /dev/null
+++ b/tests/freebsd_test_suite/macros.h
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 2015 EMC / Isilon Storage Division
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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 _FREEBSD_TEST_MACROS_H_
+#define _FREEBSD_TEST_MACROS_H_
+
+#include <sys/param.h>
+#include <sys/module.h>
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+#define ATF_REQUIRE_KERNEL_MODULE(_mod_name) do { \
+ if (modfind(_mod_name) == -1) { \
+ atf_tc_skip("module %s could not be resolved: %s", \
+ _mod_name, strerror(errno)); \
+ } \
+} while(0)
+
+#define PLAIN_REQUIRE_KERNEL_MODULE(_mod_name, _exit_code) do { \
+ if (modfind(_mod_name) == -1) { \
+ printf("module %s could not be resolved: %s\n", \
+ _mod_name, strerror(errno)); \
+ _exit(_exit_code); \
+ } \
+} while(0)
+
+#endif
diff --git a/tests/sys/Makefile b/tests/sys/Makefile
index b54feca..8f37490 100644
--- a/tests/sys/Makefile
+++ b/tests/sys/Makefile
@@ -15,6 +15,7 @@ TESTS_SUBDIRS+= opencrypto
TESTS_SUBDIRS+= posixshm
TESTS_SUBDIRS+= socket
TESTS_SUBDIRS+= vfs
+TESTS_SUBDIRS+= vm
# Items not integrated into kyua runs by default
SUBDIR+= pjdfstest
diff --git a/tests/sys/aio/Makefile b/tests/sys/aio/Makefile
index c6e3f4a..3117462 100644
--- a/tests/sys/aio/Makefile
+++ b/tests/sys/aio/Makefile
@@ -9,6 +9,8 @@ ATF_TESTS_C+= aio_test
DPADD.aio_test+= ${LIBUTIL}
LDADD.aio_test+= -lutil
+CFLAGS+= -I${.CURDIR:H:H}
+
WARNS?= 6
.include <bsd.test.mk>
diff --git a/tests/sys/aio/aio_kqueue_test.c b/tests/sys/aio/aio_kqueue_test.c
index 87b4125..14e4729 100644
--- a/tests/sys/aio/aio_kqueue_test.c
+++ b/tests/sys/aio/aio_kqueue_test.c
@@ -46,25 +46,29 @@
#include <string.h>
#include <unistd.h>
-#define PATH_TEMPLATE "/tmp/aio.XXXXXXXXXX"
+#include "freebsd_test_suite/macros.h"
-#define MAX 128
+#define PATH_TEMPLATE "aio.XXXXXXXXXX"
+
+#define MAX_IOCBS 128
#define MAX_RUNS 300
/* #define DEBUG */
int
main (int argc, char *argv[])
{
- int fd;
- struct aiocb *iocb[MAX], *kq_iocb;
- int i, result, run, error, j;
- char buffer[32768];
- int kq = kqueue();
+ struct aiocb *iocb[MAX_IOCBS], *kq_iocb;
+ char *file, pathname[sizeof(PATH_TEMPLATE)+1];
struct kevent ke, kq_returned;
struct timespec ts;
- int cancel, pending, tmp_file = 0, failed = 0;
- char *file, pathname[sizeof(PATH_TEMPLATE)+1];
+ char buffer[32768];
+ int cancel, error, failed = 0, fd, kq, pending, result, run;
+ int tmp_file = 0;
+ unsigned i, j;
+
+ PLAIN_REQUIRE_KERNEL_MODULE("aio", 0);
+ kq = kqueue();
if (kq < 0) {
perror("No kqeueue\n");
exit(1);
@@ -86,7 +90,7 @@ main (int argc, char *argv[])
#ifdef DEBUG
printf("Run %d\n", run);
#endif
- for (i = 0; i < MAX; i++) {
+ for (i = 0; i < nitems(iocb); i++) {
iocb[i] = (struct aiocb *)calloc(1,
sizeof(struct aiocb));
if (iocb[i] == NULL)
@@ -94,7 +98,7 @@ main (int argc, char *argv[])
}
pending = 0;
- for (i = 0; i < MAX; i++) {
+ for (i = 0; i < nitems(iocb); i++) {
pending++;
iocb[i]->aio_nbytes = sizeof(buffer);
iocb[i]->aio_buf = buffer;
@@ -129,8 +133,8 @@ main (int argc, char *argv[])
}
}
}
- cancel = MAX - pending;
-
+ cancel = nitems(iocb) - pending;
+
i = 0;
while (pending) {
@@ -159,11 +163,11 @@ main (int argc, char *argv[])
break;
#ifdef DEBUG
printf("Try again left %d out of %d %d\n",
- pending, MAX, cancel);
+ pending, nitems(iocb), cancel);
#endif
}
- for (j = 0; j < MAX && iocb[j] != kq_iocb;
+ for (j = 0; j < nitems(iocb) && iocb[j] != kq_iocb;
j++) ;
#ifdef DEBUG
printf("kq_iocb %p\n", kq_iocb);
@@ -190,7 +194,7 @@ main (int argc, char *argv[])
i++;
}
- for (i = 0; i < MAX; i++)
+ for (i = 0; i < nitems(iocb); i++)
free(iocb[i]);
}
diff --git a/tests/sys/aio/aio_test.c b/tests/sys/aio/aio_test.c
index 6975bcb..4134e78 100644
--- a/tests/sys/aio/aio_test.c
+++ b/tests/sys/aio/aio_test.c
@@ -59,6 +59,8 @@
#include <atf-c.h>
+#include "freebsd_test_suite/macros.h"
+
#define PATH_TEMPLATE "aio.XXXXXXXXXX"
/*
@@ -82,15 +84,6 @@ struct aio_context {
static int aio_timedout;
-static void
-aio_available(void)
-{
-
- if (modfind("aio") == -1)
- atf_tc_skip("aio support not available in the kernel; "
- "skipping testcases");
-}
-
/*
* Each test run specifies a timeout in seconds. Use the somewhat obsoleted
* signal(3) and alarm(3) APIs to set this up.
@@ -211,7 +204,7 @@ aio_write_test(struct aio_context *ac)
struct aiocb aio, *aiop;
ssize_t len;
- aio_available();
+ ATF_REQUIRE_KERNEL_MODULE("aio");
bzero(&aio, sizeof(aio));
aio.aio_buf = ac->ac_buffer;
@@ -263,7 +256,7 @@ aio_read_test(struct aio_context *ac)
struct aiocb aio, *aiop;
ssize_t len;
- aio_available();
+ ATF_REQUIRE_KERNEL_MODULE("aio");
bzero(ac->ac_buffer, ac->ac_buflen);
bzero(&aio, sizeof(aio));
@@ -346,7 +339,7 @@ ATF_TC_BODY(aio_file_test, tc)
struct aio_context ac;
int fd;
- aio_available();
+ ATF_REQUIRE_KERNEL_MODULE("aio");
strcpy(pathname, PATH_TEMPLATE);
fd = mkstemp(pathname);
@@ -392,7 +385,7 @@ ATF_TC_BODY(aio_fifo_test, tc)
char pathname[PATH_MAX];
struct aio_context ac;
- aio_available();
+ ATF_REQUIRE_KERNEL_MODULE("aio");
/*
* In theory, mkstemp() can return a name that is then collided with.
@@ -461,7 +454,7 @@ ATF_TC_BODY(aio_unix_socketpair_test, tc)
struct aio_context ac;
int sockets[2];
- aio_available();
+ ATF_REQUIRE_KERNEL_MODULE("aio");
ATF_REQUIRE_MSG(socketpair(PF_UNIX, SOCK_STREAM, 0, sockets) != -1,
"socketpair failed: %s", strerror(errno));
@@ -503,7 +496,7 @@ ATF_TC_BODY(aio_pty_test, tc)
struct termios ts;
int error;
- aio_available();
+ ATF_REQUIRE_KERNEL_MODULE("aio");
ATF_REQUIRE_MSG(openpty(&read_fd, &write_fd, NULL, NULL, NULL) == 0,
"openpty failed: %s", strerror(errno));
@@ -550,7 +543,7 @@ ATF_TC_BODY(aio_pipe_test, tc)
struct aio_context ac;
int pipes[2];
- aio_available();
+ ATF_REQUIRE_KERNEL_MODULE("aio");
ATF_REQUIRE_MSG(pipe(pipes) != -1,
"pipe failed: %s", strerror(errno));
@@ -613,7 +606,7 @@ ATF_TC_BODY(aio_md_test, tc)
struct aio_context ac;
struct md_ioctl mdio;
- aio_available();
+ ATF_REQUIRE_KERNEL_MODULE("aio");
mdctl_fd = open("/dev/" MDCTL_NAME, O_RDWR, 0);
ATF_REQUIRE_MSG(mdctl_fd != -1,
diff --git a/tests/sys/aio/lio_kqueue_test.c b/tests/sys/aio/lio_kqueue_test.c
index ad7fc68..5cc87b3 100644
--- a/tests/sys/aio/lio_kqueue_test.c
+++ b/tests/sys/aio/lio_kqueue_test.c
@@ -48,16 +48,18 @@
#include <string.h>
#include <unistd.h>
-#define PATH_TEMPLATE "/tmp/aio.XXXXXXXXXX"
+#include "freebsd_test_suite/macros.h"
+
+#define PATH_TEMPLATE "aio.XXXXXXXXXX"
#define LIO_MAX 5
-#define MAX LIO_MAX * 16
+#define MAX_IOCBS LIO_MAX * 16
#define MAX_RUNS 300
int
main(int argc, char *argv[]){
int fd;
- struct aiocb *iocb[MAX];
+ struct aiocb *iocb[MAX_IOCBS];
struct aiocb **lio[LIO_MAX], **lio_element, **kq_lio;
int i, result, run, error, j, k;
char buffer[32768];
@@ -69,6 +71,8 @@ main(int argc, char *argv[]){
char *file, pathname[sizeof(PATH_TEMPLATE)-1];
int tmp_file = 0, failed = 0;
+ PLAIN_REQUIRE_KERNEL_MODULE("aio", 0);
+
if (kq < 0) {
perror("No kqeueue\n");
exit(1);
@@ -99,9 +103,9 @@ main(int argc, char *argv[]){
#endif
for (j = 0; j < LIO_MAX; j++) {
lio[j] = (struct aiocb **)
- malloc(sizeof(struct aiocb *) * MAX/LIO_MAX);
- for(i = 0; i < MAX / LIO_MAX; i++) {
- k = (MAX / LIO_MAX * j) + i;
+ malloc(sizeof(struct aiocb *) * MAX_IOCBS/LIO_MAX);
+ for(i = 0; i < MAX_IOCBS / LIO_MAX; i++) {
+ k = (MAX_IOCBS / LIO_MAX * j) + i;
lio_element = lio[j];
lio[j][i] = iocb[k] = (struct aiocb *)
malloc(sizeof(struct aiocb));
@@ -123,7 +127,7 @@ main(int argc, char *argv[]){
sig.sigev_notify = SIGEV_KEVENT;
time(&time1);
result = lio_listio(LIO_NOWAIT, lio[j],
- MAX / LIO_MAX, &sig);
+ MAX_IOCBS / LIO_MAX, &sig);
error = errno;
time(&time2);
#ifdef DEBUG
@@ -203,7 +207,7 @@ main(int argc, char *argv[]){
} else {
printf("PASS: run %d, operation %d result %d \n", run, LIO_MAX - i -1, result);
}
- for(k = 0; k < MAX / LIO_MAX; k++){
+ for(k = 0; k < MAX_IOCBS / LIO_MAX; k++){
result = aio_return(kq_lio[k]);
#ifdef DEBUG
printf("Return Resulto for %d %d is %d\n", j, k, result);
@@ -220,7 +224,7 @@ main(int argc, char *argv[]){
printf("\n");
#endif
- for(k = 0; k < MAX / LIO_MAX; k++) {
+ for(k = 0; k < MAX_IOCBS / LIO_MAX; k++) {
free(lio[j][k]);
}
free(lio[j]);
diff --git a/tests/sys/kern/Makefile b/tests/sys/kern/Makefile
index 3d2127f..bf6aa0d 100644
--- a/tests/sys/kern/Makefile
+++ b/tests/sys/kern/Makefile
@@ -3,7 +3,7 @@
TESTSDIR= ${TESTSBASE}/sys/kern
ATF_TESTS_C+= kern_descrip_test
-TAP_TESTS_C+= mmap_test
+ATF_TESTS_C+= ptrace_test
ATF_TESTS_C+= unix_seqpacket_test
TEST_METADATA.unix_seqpacket_test+= timeout="15"
diff --git a/tests/sys/kern/ptrace_test.c b/tests/sys/kern/ptrace_test.c
new file mode 100644
index 0000000..28b0592
--- /dev/null
+++ b/tests/sys/kern/ptrace_test.c
@@ -0,0 +1,143 @@
+/*-
+ * Copyright (c) 2015 John Baldwin <jhb@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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/ptrace.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <atf-c.h>
+
+/*
+ * Verify that a parent debugger process "sees" the exit of a debugged
+ * process exactly once when attached via PT_TRACE_ME.
+ */
+ATF_TC_WITHOUT_HEAD(ptrace__parent_wait_after_trace_me);
+ATF_TC_BODY(ptrace__parent_wait_after_trace_me, tc)
+{
+ pid_t child, wpid;
+ int status;
+
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ /* Child process. */
+ ATF_REQUIRE(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ /* Trigger a stop. */
+ raise(SIGSTOP);
+
+ exit(1);
+ }
+
+ /* Parent process. */
+
+ /* The first wait() should report the stop from SIGSTOP. */
+ wpid = waitpid(child, &status, 0);
+ ATF_REQUIRE(wpid == child);
+ ATF_REQUIRE(WIFSTOPPED(status));
+ ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+
+ /* Continue the child ignoring the SIGSTOP. */
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (caddr_t)1, 0) != -1);
+
+ /* The second wait() should report the exit status. */
+ wpid = waitpid(child, &status, 0);
+ ATF_REQUIRE(wpid == child);
+ ATF_REQUIRE(WIFEXITED(status));
+ ATF_REQUIRE(WEXITSTATUS(status) == 1);
+
+ /* The child should no longer exist. */
+ wpid = waitpid(child, &status, 0);
+ ATF_REQUIRE(wpid == -1);
+ ATF_REQUIRE(errno == ECHILD);
+}
+
+/*
+ * Verify that a parent debugger process "sees" the exit of a debugged
+ * process exactly once when attached via PT_ATTACH.
+ */
+ATF_TC_WITHOUT_HEAD(ptrace__parent_wait_after_attach);
+ATF_TC_BODY(ptrace__parent_wait_after_attach, tc)
+{
+ pid_t child, wpid;
+ int cpipe[2], status;
+ char c;
+
+ ATF_REQUIRE(pipe(cpipe) == 0);
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ /* Child process. */
+ close(cpipe[0]);
+
+ /* Wait for the parent to attach. */
+ ATF_REQUIRE(read(cpipe[1], &c, sizeof(c)) == 0);
+
+ exit(1);
+ }
+ close(cpipe[1]);
+
+ /* Parent process. */
+
+ /* Attach to the child process. */
+ ATF_REQUIRE(ptrace(PT_ATTACH, child, NULL, 0) == 0);
+
+ /* The first wait() should report the SIGSTOP from PT_ATTACH. */
+ wpid = waitpid(child, &status, 0);
+ ATF_REQUIRE(wpid == child);
+ ATF_REQUIRE(WIFSTOPPED(status));
+ ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+
+ /* Continue the child ignoring the SIGSTOP. */
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (caddr_t)1, 0) != -1);
+
+ /* Signal the child to exit. */
+ close(cpipe[0]);
+
+ /* The second wait() should report the exit status. */
+ wpid = waitpid(child, &status, 0);
+ ATF_REQUIRE(wpid == child);
+ ATF_REQUIRE(WIFEXITED(status));
+ ATF_REQUIRE(WEXITSTATUS(status) == 1);
+
+ /* The child should no longer exist. */
+ wpid = waitpid(child, &status, 0);
+ ATF_REQUIRE(wpid == -1);
+ ATF_REQUIRE(errno == ECHILD);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, ptrace__parent_wait_after_trace_me);
+ ATF_TP_ADD_TC(tp, ptrace__parent_wait_after_attach);
+
+ return (atf_no_error());
+}
diff --git a/tests/sys/mqueue/Makefile b/tests/sys/mqueue/Makefile
index 230fcb7..5af8b25 100644
--- a/tests/sys/mqueue/Makefile
+++ b/tests/sys/mqueue/Makefile
@@ -6,6 +6,8 @@ ATF_TESTS_SH= mqueue_test
BINDIR= ${TESTSDIR}
+CFLAGS+= -I${.CURDIR:H:H}
+
PROGS+= mqtest1
PROGS+= mqtest2
PROGS+= mqtest3
diff --git a/tests/sys/mqueue/mqtest1.c b/tests/sys/mqueue/mqtest1.c
index 5590b87..3accb28 100644
--- a/tests/sys/mqueue/mqtest1.c
+++ b/tests/sys/mqueue/mqtest1.c
@@ -7,6 +7,8 @@
#include <signal.h>
#include <stdio.h>
+#include "freebsd_test_suite/macros.h"
+
#define MQNAME "/mytstqueue1"
int
@@ -17,6 +19,8 @@ main(void)
mqd_t mq;
int status;
+ PLAIN_REQUIRE_KERNEL_MODULE("mqueuefs", 0);
+
attr.mq_maxmsg = 2;
attr.mq_msgsize = 100;
mq = mq_open(MQNAME, O_CREAT | O_RDWR | O_EXCL, 0666, &attr);
diff --git a/tests/sys/mqueue/mqtest2.c b/tests/sys/mqueue/mqtest2.c
index aaef43b..067e619 100644
--- a/tests/sys/mqueue/mqtest2.c
+++ b/tests/sys/mqueue/mqtest2.c
@@ -10,6 +10,8 @@
#include <stdlib.h>
#include <unistd.h>
+#include "freebsd_test_suite/macros.h"
+
#define MQNAME "/mytstqueue2"
#define LOOPS 1000
#define PRIO 10
@@ -29,6 +31,8 @@ main(void)
int status;
pid_t pid;
+ PLAIN_REQUIRE_KERNEL_MODULE("mqueuefs", 0);
+
mq_unlink(MQNAME);
attr.mq_maxmsg = 5;
diff --git a/tests/sys/mqueue/mqtest3.c b/tests/sys/mqueue/mqtest3.c
index 4ee812c..c4b849e 100644
--- a/tests/sys/mqueue/mqtest3.c
+++ b/tests/sys/mqueue/mqtest3.c
@@ -11,6 +11,8 @@
#include <stdlib.h>
#include <unistd.h>
+#include "freebsd_test_suite/macros.h"
+
#define MQNAME "/mytstqueue3"
#define LOOPS 1000
#define PRIO 10
@@ -31,6 +33,8 @@ main(void)
mqd_t mq;
pid_t pid;
+ PLAIN_REQUIRE_KERNEL_MODULE("mqueuefs", 0);
+
mq_unlink(MQNAME);
attr.mq_maxmsg = 5;
diff --git a/tests/sys/mqueue/mqtest4.c b/tests/sys/mqueue/mqtest4.c
index d249cf6..474d212 100644
--- a/tests/sys/mqueue/mqtest4.c
+++ b/tests/sys/mqueue/mqtest4.c
@@ -12,6 +12,8 @@
#include <stdlib.h>
#include <unistd.h>
+#include "freebsd_test_suite/macros.h"
+
#define MQNAME "/mytstqueue4"
#define LOOPS 1000
#define PRIO 10
@@ -32,6 +34,8 @@ main(void)
int kq, status;
pid_t pid;
+ PLAIN_REQUIRE_KERNEL_MODULE("mqueuefs", 0);
+
mq_unlink(MQNAME);
attr.mq_maxmsg = 5;
diff --git a/tests/sys/mqueue/mqtest5.c b/tests/sys/mqueue/mqtest5.c
index 7f4d554..0c8aa89 100644
--- a/tests/sys/mqueue/mqtest5.c
+++ b/tests/sys/mqueue/mqtest5.c
@@ -12,6 +12,8 @@
#include <stdlib.h>
#include <unistd.h>
+#include "freebsd_test_suite/macros.h"
+
#define MQNAME "/mytstqueue5"
#define LOOPS 1000
#define PRIO 10
@@ -34,6 +36,8 @@ main(void)
mqd_t mq;
pid_t pid;
+ PLAIN_REQUIRE_KERNEL_MODULE("mqueuefs", 0);
+
mq_unlink(MQNAME);
sigemptyset(&set);
diff --git a/tests/sys/mqueue/mqueue_test.sh b/tests/sys/mqueue/mqueue_test.sh
index dd2469e..4841418 100755
--- a/tests/sys/mqueue/mqueue_test.sh
+++ b/tests/sys/mqueue/mqueue_test.sh
@@ -1,3 +1,30 @@
+#
+# Copyright (c) 2015 EMC / Isilon Storage Division
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this 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$
+#
mqtest1_head()
{
diff --git a/tests/sys/vm/Makefile b/tests/sys/vm/Makefile
new file mode 100644
index 0000000..1795eef
--- /dev/null
+++ b/tests/sys/vm/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+TESTSDIR= ${TESTSBASE}/sys/vm
+
+TAP_TESTS_C+= mmap_test
+
+.include <bsd.test.mk>
diff --git a/tests/sys/kern/mmap_test.c b/tests/sys/vm/mmap_test.c
index 7591a09..7591a09 100644
--- a/tests/sys/kern/mmap_test.c
+++ b/tests/sys/vm/mmap_test.c
diff --git a/tools/bsdbox/Makefile.base b/tools/bsdbox/Makefile.base
index 1429b09..4eb7056 100644
--- a/tools/bsdbox/Makefile.base
+++ b/tools/bsdbox/Makefile.base
@@ -6,7 +6,7 @@
#
CRUNCH_PROGS_sbin+= dmesg sysctl init reboot
CRUNCH_PROGS_bin+= ls cat dd df cp hostname kill mkdir sleep ps
-CRUNCH_PROGS_bin+= ln rm hostname kenv
+CRUNCH_PROGS_bin+= ln rm hostname kenv mv expr
CRUNCH_PROGS_usr.bin+= true false hexdump tail nc w head uname tset
CRUNCH_PROGS_usr.sbin+= gpioctl
CRUNCH_ALIAS_w= uptime
diff --git a/tools/build/Makefile b/tools/build/Makefile
index 6aead63..2617d8d 100644
--- a/tools/build/Makefile
+++ b/tools/build/Makefile
@@ -25,6 +25,14 @@ CFLAGS+= -I${.CURDIR}/../../contrib/libc-vis \
-I${.CURDIR}/../../lib/libc/include
.endif
+_WITH_REALLOCARRAY!= grep -c reallocarray /usr/include/stdlib.h || true
+.if ${_WITH_REALLOCARRAY} == 0
+.PATH: ${.CURDIR}/../../lib/libc/stdlib
+INCS+= stdlib.h
+SRCS+= reallocarray.c
+CFLAGS+= -I${.CURDIR}/../../lib/libc/include
+.endif
+
.if empty(SRCS)
SRCS= dummy.c
.endif
diff --git a/tools/build/check-links.sh b/tools/build/check-links.sh
index 1c58aa0..57c9437 100755
--- a/tools/build/check-links.sh
+++ b/tools/build/check-links.sh
@@ -20,9 +20,11 @@ libkey() {
ret=0
CHECK_UNRESOLVED=1
-while getopts "U" flag; do
+VERBOSE_RESOLVED=0
+while getopts "Uv" flag; do
case "${flag}" in
U) CHECK_UNRESOLVED=0 ;;
+ v) VERBOSE_RESOLVED=1 ;;
esac
done
shift $((OPTIND-1))
@@ -83,7 +85,7 @@ if [ ${CHECK_UNRESOLVED} -eq 1 ]; then
libkey "crt1.o"
setvar "${libkey}" "${lib_symbols}"
- # No search libs for all symbols and report missing ones.
+ # Now search libs for all symbols and report missing ones.
for sym in ${unresolved_symbols}; do
found=0
for lib in ${list_libs}; do
@@ -91,7 +93,12 @@ if [ ${CHECK_UNRESOLVED} -eq 1 ]; then
eval "lib_symbols=\"\${${libkey}}\""
# lib_symbols now contains symbols for the lib.
case " ${lib_symbols} " in
- *\ ${sym}\ *) found=1 && break ;;
+ *\ ${sym}\ *)
+ [ ${VERBOSE_RESOLVED} -eq 1 ] &&
+ echo "Resolved symbol ${sym} from ${lib}"
+ found=1
+ break
+ ;;
esac
done
if [ $found -eq 0 ]; then
diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc
index 7a4549e..ed39f7d 100644
--- a/tools/build/mk/OptionalObsoleteFiles.inc
+++ b/tools/build/mk/OptionalObsoleteFiles.inc
@@ -781,6 +781,10 @@ OLD_FILES+=usr/share/dtrace/toolkit/hotkernel
OLD_FILES+=usr/share/dtrace/toolkit/hotuser
OLD_FILES+=usr/share/dtrace/toolkit/opensnoop
OLD_FILES+=usr/share/dtrace/toolkit/procsystime
+OLD_FILES+=usr/share/dtrace/tcpconn
+OLD_FILES+=usr/share/dtrace/tcpstate
+OLD_FILES+=usr/share/dtrace/tcptrack
+OLD_FILES+=usr/share/dtrace/udptrack
OLD_FILES+=usr/share/man/man1/dtrace.1.gz
OLD_DIRS+=usr/lib/dtrace
OLD_DIRS+=usr/lib32/dtrace
@@ -1004,15 +1008,11 @@ OLD_DIRS+=usr/include/fs/cuse
.if ${MK_CXX} == no
OLD_FILES+=usr/bin/CC
OLD_FILES+=usr/bin/c++
+.if ${MK_ELFTOOLCHAIN_TOOLS} == no
OLD_FILES+=usr/bin/c++filt
+.endif
OLD_FILES+=usr/bin/g++
OLD_FILES+=usr/libexec/cc1plus
-.if ${MK_GCC} == no
-OLD_FILES+=usr/bin/gperf
-OLD_FILES+=usr/share/info/gperf.info.gz
-OLD_FILES+=usr/share/man/man1/gperf.1.gz
-OLD_FILES+=usr/share/man/man1/gperf.7.gz
-.endif
.endif
.if ${MK_FMTREE} == no
@@ -1720,11 +1720,14 @@ OLD_FILES+=usr/share/man/man8/unstr.8.gz
.endif
.if ${MK_GCC} == no
+.if ${MK_ELFTOOLCHAIN_TOOLS} == no
OLD_FILES+=usr/bin/c++filt
+.endif
OLD_FILES+=usr/bin/g++
OLD_FILES+=usr/bin/gcc
OLD_FILES+=usr/bin/gcov
OLD_FILES+=usr/bin/gcpp
+OLD_FILES+=usr/bin/gperf
.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "i386"
OLD_FILES+=usr/include/gcc/4.2/__wmmintrin_aes.h
OLD_FILES+=usr/include/gcc/4.2/__wmmintrin_pclmul.h
@@ -1744,16 +1747,25 @@ OLD_FILES+=usr/include/gcc/4.2/altivec.h
OLD_FILES+=usr/include/gcc/4.2/ppc-asm.h
OLD_FILES+=usr/include/gcc/4.2/spe.h
.endif
+OLD_FILES+=usr/include/omp.h
+OLD_FILES+=usr/lib/libgcov.a
+OLD_FILES+=usr/lib/libgomp.a
+OLD_FILES+=usr/lib/libgomp.so
+OLD_LIBS+=usr/lib/libgomp.so.1
+OLD_FILES+=usr/lib/libgomp_p.a
OLD_FILES+=usr/libexec/cc1
OLD_FILES+=usr/libexec/cc1plus
OLD_FILES+=usr/share/info/cpp.info.gz
OLD_FILES+=usr/share/info/cppinternals.info.gz
OLD_FILES+=usr/share/info/gcc.info.gz
OLD_FILES+=usr/share/info/gccint.info.gz
+OLD_FILES+=usr/share/info/gperf.info.gz
OLD_FILES+=usr/share/man/man1/g++.1.gz
OLD_FILES+=usr/share/man/man1/gcc.1.gz
OLD_FILES+=usr/share/man/man1/gcov.1.gz
OLD_FILES+=usr/share/man/man1/gcpp.1.gz
+OLD_FILES+=usr/share/man/man1/gperf.1.gz
+OLD_FILES+=usr/share/man/man1/gperf.7.gz
.endif
.if ${MK_GCOV} == no
@@ -1835,7 +1847,6 @@ OLD_FILES+=usr/bin/post-grohtml
OLD_FILES+=usr/bin/pre-grohtml
OLD_FILES+=usr/bin/psroff
OLD_FILES+=usr/bin/refer
-OLD_FILES+=usr/bin/soelim
OLD_FILES+=usr/bin/tbl
OLD_FILES+=usr/bin/tfmtodit
OLD_FILES+=usr/bin/troff
@@ -2242,7 +2253,6 @@ OLD_FILES+=usr/share/man/man1/pfbtops.1.gz
OLD_FILES+=usr/share/man/man1/pic.1.gz
OLD_FILES+=usr/share/man/man1/psroff.1.gz
OLD_FILES+=usr/share/man/man1/refer.1.gz
-OLD_FILES+=usr/share/man/man1/soelim.1.gz
OLD_FILES+=usr/share/man/man1/tbl.1.gz
OLD_FILES+=usr/share/man/man1/tfmtodit.1.gz
OLD_FILES+=usr/share/man/man1/troff.1.gz
diff --git a/tools/build/stdlib.h b/tools/build/stdlib.h
new file mode 100644
index 0000000..5f9b90b
--- /dev/null
+++ b/tools/build/stdlib.h
@@ -0,0 +1,42 @@
+/*-
+ * Copyright (c) 2015 Dimitry Andric <dim@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$
+ */
+
+#ifndef _LEGACY_STDLIB_H_
+#define _LEGACY_STDLIB_H_
+
+#include_next <stdlib.h>
+
+__BEGIN_DECLS
+
+#if __BSD_VISIBLE
+void *reallocarray(void *, size_t, size_t);
+#endif /* __BSD_VISIBLE */
+
+__END_DECLS
+
+#endif /* !_LEGACY_STDLIB_H_ */
diff --git a/tools/regression/p1003_1b/main.c b/tools/regression/p1003_1b/main.c
index 0e87c6c..23c3b02 100644
--- a/tools/regression/p1003_1b/main.c
+++ b/tools/regression/p1003_1b/main.c
@@ -1,5 +1,6 @@
/* $FreeBSD$ */
#include <stdio.h>
+#include <string.h>
int fifo(int argc, char *argv[]);
int memlock(int argc, char *argv[]);
diff --git a/tools/regression/p1003_1b/prutil.c b/tools/regression/p1003_1b/prutil.c
index e0e3d6f..2910b7f 100644
--- a/tools/regression/p1003_1b/prutil.c
+++ b/tools/regression/p1003_1b/prutil.c
@@ -1,10 +1,11 @@
+#include <err.h>
#include <errno.h>
-#include <unistd.h>
#include <sched.h>
#include <stdio.h>
-
-#include <err.h>
+#include <stdlib.h>
#include <sysexits.h>
+#include <unistd.h>
+
#include "prutil.h"
/*
@@ -12,7 +13,7 @@
*/
void quit(const char *text)
{
- err(errno, text);
+ err(errno, "%s", text);
}
char *sched_text(int scheduler)
diff --git a/tools/tools/ath/athaggrstats/Makefile b/tools/tools/ath/athaggrstats/Makefile
index b6234b5..2748b6f 100644
--- a/tools/tools/ath/athaggrstats/Makefile
+++ b/tools/tools/ath/athaggrstats/Makefile
@@ -12,6 +12,7 @@ CLEANFILES+= opt_ah.h
CFLAGS+=-DATH_SUPPORT_ANI
CFLAGS+=-DATH_SUPPORT_TDMA
+CFLAGS+=-I${.CURDIR}/../../../../lib/libbsdstat/
LIBADD+= bsdstat
opt_ah.h:
diff --git a/tools/tools/ath/athstats/Makefile b/tools/tools/ath/athstats/Makefile
index a7ff43b..93f98ae 100644
--- a/tools/tools/ath/athstats/Makefile
+++ b/tools/tools/ath/athstats/Makefile
@@ -8,10 +8,6 @@ MAN=
PROG= athstats
-# Because of a clang preprocessor parser limitation causing this
-# to not compile, use gcc for now.
-#CC= gcc
-
SRCS= main.c athstats.c opt_ah.h ah_osdep.h
CLEANFILES+= opt_ah.h
@@ -21,6 +17,8 @@ CLEANFILES+= opt_ah.h
CFLAGS+=-DATH_SUPPORT_ANI
CFLAGS+=-DATH_SUPPORT_TDMA
+CFLAGS+=-I${.CURDIR}/../../../../lib/libbsdstat/
+
CFLAGS.clang+= -fbracket-depth=512
LIBADD= bsdstat
diff --git a/tools/tools/mwl/mwlstats/Makefile b/tools/tools/mwl/mwlstats/Makefile
index 16decd1..69382b8 100644
--- a/tools/tools/mwl/mwlstats/Makefile
+++ b/tools/tools/mwl/mwlstats/Makefile
@@ -6,6 +6,7 @@ MAN=
SRCS= main.c mwlstats.c
LIBADD= bsdstat
+CFLAGS+=-I${.CURDIR}/../../../../lib/libbsdstat/
.include <bsd.prog.mk>
diff --git a/tools/tools/net80211/wlanstats/Makefile b/tools/tools/net80211/wlanstats/Makefile
index dbd53a6..2d23932 100644
--- a/tools/tools/net80211/wlanstats/Makefile
+++ b/tools/tools/net80211/wlanstats/Makefile
@@ -6,6 +6,7 @@ PROG= wlanstats
BINDIR= /usr/local/bin
MAN=
LIBADD= bsdstat
+CFLAGS+=-I${.CURDIR}/../../../../lib/libbsdstat/
SRCS= wlanstats.c main.c
diff --git a/tools/tools/npe/npestats/Makefile b/tools/tools/npe/npestats/Makefile
index 20f3819..740d359 100644
--- a/tools/tools/npe/npestats/Makefile
+++ b/tools/tools/npe/npestats/Makefile
@@ -5,5 +5,6 @@ SRCS= main.c npestats.c
BINDIR= /usr/local/bin
MAN=
LIBADD= bsdstat
+CFLAGS+=-I${.CURDIR}/../../../../lib/libbsdstat/
.include <bsd.prog.mk>
diff --git a/usr.bin/Makefile b/usr.bin/Makefile
index 557c407..af9b471 100644
--- a/usr.bin/Makefile
+++ b/usr.bin/Makefile
@@ -36,7 +36,7 @@ SUBDIR= ${_addr2line} \
csplit \
ctlstat \
cut \
- demandoc \
+ ${_cxxfilt} \
dirname \
dpv \
du \
@@ -150,7 +150,7 @@ SUBDIR= ${_addr2line} \
showmount \
${_size} \
sockstat \
- soeliminate \
+ soelim \
sort \
split \
stat \
@@ -237,6 +237,7 @@ SUBDIR+= ee
.if ${MK_ELFTOOLCHAIN_TOOLS} != "no"
_addr2line= addr2line
+_cxxfilt= cxxfilt
_elfcopy= elfcopy
_nm= nm
_readelf= readelf
diff --git a/usr.bin/bmake/Makefile b/usr.bin/bmake/Makefile
index 93a1d7d..4abb45fe 100644
--- a/usr.bin/bmake/Makefile
+++ b/usr.bin/bmake/Makefile
@@ -14,10 +14,10 @@ CFLAGS+= -I${.CURDIR}
CLEANDIRS+= FreeBSD
CLEANFILES+= bootstrap
-# $Id: Makefile,v 1.36 2015/04/18 19:58:53 sjg Exp $
+# $Id: Makefile,v 1.38 2015/05/05 21:58:05 sjg Exp $
# Base version on src date
-MAKE_VERSION= 20150418
+MAKE_VERSION= 20150505
PROG?= ${.CURDIR:T}
diff --git a/usr.bin/bmake/unit-tests/Makefile b/usr.bin/bmake/unit-tests/Makefile
index ee35dda..100b467 100644
--- a/usr.bin/bmake/unit-tests/Makefile
+++ b/usr.bin/bmake/unit-tests/Makefile
@@ -5,9 +5,9 @@
SRCTOP?= ${.CURDIR:H:H:H}
-# $Id: Makefile.in,v 1.46 2014/11/06 01:47:57 sjg Exp $
+# $Id: Makefile.in,v 1.47 2015/05/05 21:58:06 sjg Exp $
#
-# $NetBSD: Makefile,v 1.51 2014/10/20 23:21:11 sjg Exp $
+# $NetBSD: Makefile,v 1.52 2015/05/05 21:51:09 sjg Exp $
#
# Unit tests for make(1)
# The main targets are:
@@ -34,6 +34,7 @@ UNIT_TESTS:= ${srcdir}
TESTNAMES= \
comment \
cond1 \
+ cond2 \
error \
export \
export-all \
diff --git a/usr.bin/calendar/calendars/calendar.freebsd b/usr.bin/calendar/calendars/calendar.freebsd
index fc6df82..9ea3d81 100644
--- a/usr.bin/calendar/calendars/calendar.freebsd
+++ b/usr.bin/calendar/calendars/calendar.freebsd
@@ -359,6 +359,7 @@
12/01 Alexey Dokuchaev <danfe@FreeBSD.org> born in Magadan, USSR, 1980
12/02 Ermal Luçi <eri@FreeBSD.org> born in Tirane, Albania, 1980
12/03 Diane Bruce <db@FreeBSD.org> born in Ottawa, Ontario, Canada, 1952
+12/04 Mariusz Zaborski <oshogbo@FreeBSD.org> born in Skierniewice, Poland, 1990
12/05 Ivan Voras <ivoras@FreeBSD.org> born in Slavonski Brod, Croatia, 1981
12/06 Stefan Farfeleder <stefanf@FreeBSD.org> born in Wien, Austria, 1980
12/11 Ganael Laplanche <martymac@FreeBSD.org> born in Reims, France, 1980
diff --git a/usr.bin/calendar/calendars/calendar.holiday b/usr.bin/calendar/calendars/calendar.holiday
index 3fdee69..fe9029e 100644
--- a/usr.bin/calendar/calendars/calendar.holiday
+++ b/usr.bin/calendar/calendars/calendar.holiday
@@ -144,8 +144,8 @@
04/26 Confederate Memorial Day in Florida & Georgia
04/26 Union Day in Tanzania
04/27 Independence Day in Togo
+04/27 King's Birthday in the Netherlands, the Netherlands Antilles
04/29 Showa Day in Japan
-04/30 Queen's Birthday in the Netherlands, the Netherlands Antilles
04/30 The Workers Day in Uruguay
04/MonLast Arbor Day in Wyoming (last Monday)
04/MonLast Confederate Memorial Day in Alabama & Mississippi (last Monday)
diff --git a/usr.bin/checknr/checknr.1 b/usr.bin/checknr/checknr.1
index 8888fdd..a89706e 100644
--- a/usr.bin/checknr/checknr.1
+++ b/usr.bin/checknr/checknr.1
@@ -28,7 +28,7 @@
.\" @(#)checknr.1 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
-.Dd January 26, 2005
+.Dd May 5, 2015
.Dt CHECKNR 1
.Os
.Sh NAME
@@ -157,7 +157,3 @@ There is no way to define a 1 character macro name using
.Pp
Does not correctly recognize certain reasonable constructs,
such as conditionals.
-.Pp
-Input lines are limited to
-.Dv LINE_MAX
-(2048) bytes in length.
diff --git a/usr.bin/checknr/checknr.c b/usr.bin/checknr/checknr.c
index d3e5355..06395b0 100644
--- a/usr.bin/checknr/checknr.c
+++ b/usr.bin/checknr/checknr.c
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
* structured typesetting.
*/
#include <err.h>
+#define _WITH_GETLINE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -57,7 +58,7 @@ __FBSDID("$FreeBSD$");
#define MAXSTK 100 /* Stack size */
#define MAXBR 100 /* Max number of bracket pairs known */
-#define MAXCMDS 500 /* Max number of commands known */
+#define MAXCMDS 600 /* Max number of commands known */
static void addcmd(char *);
static void addmac(const char *);
@@ -133,6 +134,19 @@ static struct brstr {
{"(q", ")q"},
{"(x", ")x"},
{"(z", ")z"},
+ /* The -mdoc package */
+ {"Ao", "Ac"},
+ {"Bd", "Ed"},
+ {"Bk", "Ek"},
+ {"Bo", "Bc"},
+ {"Do", "Dc"},
+ {"Fo", "Fc"},
+ {"Oo", "Oc"},
+ {"Po", "Pc"},
+ {"Qo", "Qc"},
+ {"Rs", "Re"},
+ {"So", "Sc"},
+ {"Xo", "Xc"},
/* Things needed by preprocessors */
{"EQ", "EN"},
{"TS", "TE"},
@@ -146,37 +160,47 @@ static struct brstr {
* Used so we can complain about unrecognized commands.
*/
static const char *knowncmds[MAXCMDS] = {
-"$c", "$f", "$h", "$p", "$s", "(b", "(c", "(d", "(f", "(l", "(q", "(t",
-"(x", "(z", ")b", ")c", ")d", ")f", ")l", ")q", ")t", ")x", ")z", "++",
-"+c", "1C", "1c", "2C", "2c", "@(", "@)", "@C", "@D", "@F", "@I", "@M",
-"@c", "@e", "@f", "@h", "@m", "@n", "@o", "@p", "@r", "@t", "@z", "AB",
-"AE", "AF", "AI", "AL", "AM", "AS", "AT", "AU", "AX", "B", "B1", "B2",
-"BD", "BE", "BG", "BL", "BS", "BT", "BX", "C1", "C2", "CD", "CM", "CT",
-"D", "DA", "DE", "DF", "DL", "DS", "DT", "EC", "EF", "EG", "EH", "EM",
-"EN", "EQ", "EX", "FA", "FD", "FE", "FG", "FJ", "FK", "FL", "FN", "FO",
-"FQ", "FS", "FV", "FX", "H", "HC", "HD", "HM", "HO", "HU", "I", "ID",
-"IE", "IH", "IM", "IP", "IX", "IZ", "KD", "KE", "KF", "KQ", "KS", "LB",
-"LC", "LD", "LE", "LG", "LI", "LP", "MC", "ME", "MF", "MH", "ML", "MR",
-"MT", "ND", "NE", "NH", "NL", "NP", "NS", "OF", "OH", "OK", "OP", "P",
-"P1", "PF", "PH", "PP", "PT", "PX", "PY", "QE", "QP", "QS", "R", "RA",
-"RC", "RE", "RL", "RP", "RQ", "RS", "RT", "S", "S0", "S2", "S3", "SA",
-"SG", "SH", "SK", "SM", "SP", "SY", "T&", "TA", "TB", "TC", "TD", "TE",
-"TH", "TL", "TM", "TP", "TQ", "TR", "TS", "TX", "UL", "US", "UX", "VL",
-"WC", "WH", "XA", "XD", "XE", "XF", "XK", "XP", "XS", "[", "[-", "[0",
-"[1", "[2", "[3", "[4", "[5", "[<", "[>", "[]", "]", "]-", "]<", "]>",
-"][", "ab", "ac", "ad", "af", "am", "ar", "as", "b", "ba", "bc", "bd",
-"bi", "bl", "bp", "br", "bx", "c.", "c2", "cc", "ce", "cf", "ch", "cs",
-"ct", "cu", "da", "de", "di", "dl", "dn", "ds", "dt", "dw", "dy", "ec",
-"ef", "eh", "el", "em", "eo", "ep", "ev", "ex", "fc", "fi", "fl", "fo",
-"fp", "ft", "fz", "hc", "he", "hl", "hp", "ht", "hw", "hx", "hy", "i",
-"ie", "if", "ig", "in", "ip", "it", "ix", "lc", "lg", "li", "ll", "ln",
-"lo", "lp", "ls", "lt", "m1", "m2", "m3", "m4", "mc", "mk", "mo", "n1",
-"n2", "na", "ne", "nf", "nh", "nl", "nm", "nn", "np", "nr", "ns", "nx",
-"of", "oh", "os", "pa", "pc", "pi", "pl", "pm", "pn", "po", "pp", "ps",
-"q", "r", "rb", "rd", "re", "rm", "rn", "ro", "rr", "rs", "rt", "sb",
-"sc", "sh", "sk", "so", "sp", "ss", "st", "sv", "sz", "ta", "tc", "th",
-"ti", "tl", "tm", "tp", "tr", "u", "uf", "uh", "ul", "vs", "wh", "xp",
-"yr", 0
+"$c", "$f", "$h", "$p", "$s", "%A", "%B", "%C", "%D", "%I", "%J", "%N", "%O",
+"%P", "%Q", "%R", "%T", "%V", "(b", "(c", "(d", "(f", "(l", "(q", "(t", "(x",
+"(z", ")b", ")c", ")d", ")f", ")l", ")q", ")t", ")x", ")z", "++", "+c", "1C",
+"1c", "2C", "2c", "@(", "@)", "@C", "@D", "@F", "@I", "@M", "@c", "@e", "@f",
+"@h", "@m", "@n", "@o", "@p", "@r", "@t", "@z", "AB", "AE", "AF", "AI", "AL",
+"AM", "AS", "AT", "AU", "AX", "Ac", "Ad", "An", "Ao", "Ap", "Aq", "Ar", "At",
+"B", "B" , "B1", "B2", "BD", "BE", "BG", "BL", "BS", "BT", "BX", "Bc", "Bd",
+"Bf", "Bk", "Bl", "Bo", "Bq", "Bsx", "Bx", "C1", "C2", "CD", "CM", "CT", "Cd",
+"Cm", "D", "D" , "D1", "DA", "DE", "DF", "DL", "DS", "DT", "Db", "Dc", "Dd",
+"Dl", "Do", "Dq", "Dt", "Dv", "EC", "EF", "EG", "EH", "EM", "EN", "EQ", "EX",
+"Ec", "Ed", "Ef", "Ek", "El", "Em", "Eo", "Er", "Ev", "FA", "FD", "FE", "FG",
+"FJ", "FK", "FL", "FN", "FO", "FQ", "FS", "FV", "FX", "Fa", "Fc", "Fd", "Fl",
+"Fn", "Fo", "Ft", "Fx", "H", "H" , "HC", "HD", "HM", "HO", "HU", "I", "I" ,
+"ID", "IE", "IH", "IM", "IP", "IX", "IZ", "Ic", "In", "It", "KD", "KE", "KF",
+"KQ", "KS", "LB", "LC", "LD", "LE", "LG", "LI", "LP", "Lb", "Li", "MC", "ME",
+"MF", "MH", "ML", "MR", "MT", "ND", "NE", "NH", "NL", "NP", "NS", "Nd", "Nm",
+"No", "Ns", "Nx", "OF", "OH", "OK", "OP", "Oc", "Oo", "Op", "Os", "Ot", "Ox",
+"P", "P" , "P1", "PF", "PH", "PP", "PT", "PX", "PY", "Pa", "Pc", "Pf", "Po",
+"Pp", "Pq", "QE", "QP", "QS", "Qc", "Ql", "Qo", "Qq", "R", "R" , "RA", "RC",
+"RE", "RL", "RP", "RQ", "RS", "RT", "Re", "Rs", "S", "S" , "S0", "S2", "S3",
+"SA", "SG", "SH", "SK", "SM", "SP", "SY", "Sc", "Sh", "Sm", "So", "Sq", "Ss",
+"St", "Sx", "Sy", "T&", "TA", "TB", "TC", "TD", "TE", "TH", "TL", "TM", "TP",
+"TQ", "TR", "TS", "TX", "Tn", "UL", "US", "UX", "Ud", "Ux", "VL", "Va", "Vt",
+"WC", "WH", "XA", "XD", "XE", "XF", "XK", "XP", "XS", "Xc", "Xo", "Xr", "[",
+"[" , "[-", "[0", "[1", "[2", "[3", "[4", "[5", "[<", "[>", "[]", "\\{", "\\}",
+"]", "]" , "]-", "]<", "]>", "][", "ab", "ac", "ad", "af", "am", "ar", "as",
+"b", "b" , "ba", "bc", "bd", "bi", "bl", "bp", "br", "bx", "c.", "c2", "cc",
+"ce", "cf", "ch", "chop", "cs", "ct", "cu", "da", "de", "di", "dl", "dn", "do",
+"ds", "dt", "dw", "dy", "ec", "ef", "eh", "el", "em", "eo", "ep", "ev", "evc",
+"ex", "fallback", "fc", "feature", "fi", "fl", "flig", "fo", "fp", "ft", "ftr",
+"fz", "fzoom", "hc", "he", "hidechar", "hl", "hp", "ht", "hw", "hx", "hy",
+"hylang", "i", "i" , "ie", "if", "ig", "in", "ip", "it", "ix", "kern",
+"kernafter", "kernbefore", "kernpair", "lc", "lc_ctype", "lg", "lhang", "li",
+"ll", "ln", "lo", "lp", "ls", "lt", "m1", "m2", "m3", "m4", "mc", "mk", "mo",
+"n1", "n2", "na", "ne", "nf", "nh", "nl", "nm", "nn", "np", "nr", "ns", "nx",
+"of", "oh", "os", "pa", "papersize", "pc", "pi", "pl", "pm", "pn", "po", "pp",
+"ps", "q", "q" , "r", "r" , "rb", "rd", "re", "recursionlimit", "return",
+"rhang", "rm", "rn", "ro", "rr", "rs", "rt", "sb", "sc", "sh", "shift", "sk",
+"so", "sp", "ss", "st", "sv", "sz", "ta", "tc", "th", "ti", "tl", "tm", "tp",
+"tr", "track", "u", "uf", "uh", "ul", "vs", "wh", "xflag", "xp", "yr",
+0
};
static int lineno; /* current line number in input file */
@@ -210,8 +234,18 @@ main(int argc, char **argv)
for (i=0; br[i].opbr; i++)
;
for (cp=argv[1]+3; cp[-1]; cp += 6) {
- br[i].opbr = strncpy(malloc(3), cp, 2);
- br[i].clbr = strncpy(malloc(3), cp+3, 2);
+ char *tmp;
+
+ if (i >= MAXBR)
+ errx(1, "too many pairs");
+ if ((tmp = malloc(3)) == NULL)
+ err(1, "malloc");
+ strlcpy(tmp, cp, 3);
+ br[i].opbr = tmp;
+ if ((tmp = malloc(3)) == NULL)
+ err(1, "malloc");
+ strlcpy(tmp, cp+3, 3);
+ br[i].clbr = tmp;
addmac(br[i].opbr); /* knows pairs are also known cmds */
addmac(br[i].clbr);
i++;
@@ -250,7 +284,7 @@ main(int argc, char **argv)
nfiles = argc - 1;
if (nfiles > 0) {
- for (i=1; i<argc; i++) {
+ for (i = 1; i < argc; i++) {
cfilename = argv[i];
f = fopen(cfilename, "r");
if (f == NULL)
@@ -279,12 +313,15 @@ static void
process(FILE *f)
{
int i, n;
- char mac[5]; /* The current macro or nroff command */
+ char mac[64]; /* The current macro or nroff command */
+ char *line;
+ size_t linecap;
int pl;
- static char line[256]; /* the current line */
+ line = NULL;
+ linecap = 0;
stktop = -1;
- for (lineno = 1; fgets(line, sizeof line, f); lineno++) {
+ for (lineno = 1; getline(&line, &linecap, f) > 0; lineno++) {
if (line[0] == '.') {
/*
* find and isolate the macro/command name.
@@ -320,9 +357,9 @@ process(FILE *f)
* At this point we process the line looking
* for \s and \f.
*/
- for (i=0; line[i]; i++)
- if (line[i]=='\\' && (i==0 || line[i-1]!='\\')) {
- if (!sflag && line[++i]=='s') {
+ for (i = 0; line[i]; i++)
+ if (line[i] == '\\' && (i == 0 || line[i-1] != '\\')) {
+ if (!sflag && line[++i] == 's') {
pl = line[++i];
if (isdigit(pl)) {
n = pl - '0';
@@ -333,7 +370,8 @@ process(FILE *f)
n = 10 * n + line[i] - '0';
i--;
if (n == 0) {
- if (stk[stktop].opno == SZ) {
+ if (stktop >= 0 &&
+ stk[stktop].opno == SZ) {
stktop--;
} else {
pe(lineno);
@@ -345,10 +383,11 @@ process(FILE *f)
stk[stktop].parm = n;
stk[stktop].lno = lineno;
}
- } else if (!fflag && line[i]=='f') {
+ } else if (!fflag && line[i] == 'f') {
n = line[++i];
if (n == 'P') {
- if (stk[stktop].opno == FT) {
+ if (stktop >= 0 &&
+ stk[stktop].opno == FT) {
stktop--;
} else {
pe(lineno);
@@ -363,11 +402,12 @@ process(FILE *f)
}
}
}
+ free(line);
/*
* We've hit the end and look at all this stuff that hasn't been
* matched yet! Complain, complain.
*/
- for (i=stktop; i>=0; i--) {
+ for (i = stktop; i >= 0; i--) {
complain(i);
}
}
@@ -395,7 +435,8 @@ prop(int i)
break;
default:
printf("Bug: stk[%d].opno = %d = .%s, .%s",
- i, stk[i].opno, br[stk[i].opno].opbr, br[stk[i].opno].clbr);
+ i, stk[i].opno, br[stk[i].opno].opbr,
+ br[stk[i].opno].clbr);
}
}
@@ -557,17 +598,20 @@ addmac(const char *mac)
}
/* binsrch sets slot as a side effect */
#ifdef DEBUG
-printf("binsrch(%s) -> %d\n", mac, slot);
+ printf("binsrch(%s) -> %d\n", mac, slot);
#endif
loc = &knowncmds[slot];
src = &knowncmds[ncmds-1];
dest = src+1;
while (dest > loc)
*dest-- = *src--;
- *loc = strcpy(malloc(3), mac);
+ if ((*loc = strdup(mac)) == NULL)
+ err(1, "strdup");
ncmds++;
#ifdef DEBUG
-printf("after: %s %s %s %s %s, %d cmds\n", knowncmds[slot-2], knowncmds[slot-1], knowncmds[slot], knowncmds[slot+1], knowncmds[slot+2], ncmds);
+ printf("after: %s %s %s %s %s, %d cmds\n",
+ knowncmds[slot-2], knowncmds[slot-1], knowncmds[slot],
+ knowncmds[slot+1], knowncmds[slot+2], ncmds);
#endif
}
@@ -592,12 +636,12 @@ binsrch(const char *mac)
if (d == 0)
d = p[1] - mac[1];
if (d == 0)
- return mid;
+ return (mid);
if (d < 0)
bot = mid + 1;
else
top = mid - 1;
}
slot = bot; /* place it would have gone */
- return -1;
+ return (-1);
}
diff --git a/usr.bin/col/Makefile b/usr.bin/col/Makefile
index 8e3a959..a162866 100644
--- a/usr.bin/col/Makefile
+++ b/usr.bin/col/Makefile
@@ -1,6 +1,12 @@
# @(#)Makefile 8.1 (Berkeley) 6/6/93
# $FreeBSD$
+.include <src.opts.mk>
+
PROG= col
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
.include <bsd.prog.mk>
diff --git a/usr.bin/col/col.1 b/usr.bin/col/col.1
index 9419fe3..fc02ca4 100644
--- a/usr.bin/col/col.1
+++ b/usr.bin/col/col.1
@@ -31,7 +31,7 @@
.\" @(#)col.1 8.1 (Berkeley) 6/29/93
.\" $FreeBSD$
.\"
-.Dd August 4, 2004
+.Dd May 10, 2015
.Dt COL 1
.Os
.Sh NAME
@@ -82,18 +82,33 @@ recognized and interpreted by itself, which are listed below.
Output multiple spaces instead of tabs.
.El
.Pp
-The control sequences for carriage motion that
+In the input stream,
.Nm
-understands and their decimal values are listed in the following
-table:
+understands both the escape sequences of the form escape-digit
+mandated by
+.St -susv2
+and the traditional
+.Bx
+format escape-control-character.
+The control sequences for carriage motion and their ASCII values
+are as follows:
.Pp
.Bl -tag -width "carriage return" -compact
+.It ESC\-BELL
+reverse line feed (escape then bell).
.It ESC\-7
-reverse line feed (escape then 7)
+reverse line feed (escape then 7).
+.It ESC\-BACKSPACE
+half reverse line feed (escape then backspace).
.It ESC\-8
-half reverse line feed (escape then 8)
+half reverse line feed (escape then 8).
+.It ESC\-TAB
+half forward line feed (escape than tab).
.It ESC\-9
-half forward line feed (escape then 9)
+half forward line feed (escape then 9).
+In
+.Fl f
+mode, this sequence may also occur in the output stream.
.It backspace
moves back one column (8); ignored in the first column
.It carriage return
diff --git a/usr.bin/col/col.c b/usr.bin/col/col.c
index e811a52..13df126 100644
--- a/usr.bin/col/col.c
+++ b/usr.bin/col/col.c
@@ -45,11 +45,15 @@ static char sccsid[] = "@(#)col.c 8.5 (Berkeley) 5/4/95";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <sys/capsicum.h>
+
#include <err.h>
+#include <errno.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <termios.h>
#include <unistd.h>
#include <wchar.h>
#include <wctype.h>
@@ -63,9 +67,9 @@ __FBSDID("$FreeBSD$");
#define SI '\017' /* shift in to normal character set */
#define SO '\016' /* shift out to alternate character set */
#define VT '\013' /* vertical tab (aka reverse line feed) */
-#define RLF '\007' /* ESC-07 reverse line feed */
-#define RHLF '\010' /* ESC-010 reverse half-line feed */
-#define FHLF '\011' /* ESC-011 forward half-line feed */
+#define RLF '7' /* ESC-7 reverse line feed */
+#define RHLF '8' /* ESC-8 reverse half-line feed */
+#define FHLF '9' /* ESC-9 forward half-line feed */
/* build up at least this many lines before flushing them out */
#define BUFFER_MARGIN 32
@@ -92,6 +96,7 @@ struct line_str {
int l_max_col; /* max column in the line */
};
+static void addto_lineno(int *, int);
static LINE *alloc_line(void);
static void dowarn(int);
static void flush_line(LINE *);
@@ -104,7 +109,7 @@ static CSET last_set; /* char_set of last char printed */
static LINE *lines;
static int compress_spaces; /* if doing space -> tab conversion */
static int fine; /* if `fine' resolution (half lines) */
-static int max_bufd_lines; /* max # lines to keep in memory */
+static int max_bufd_lines; /* max # of half lines to keep in memory */
static int nblank_lines; /* # blanks after last flushed line */
static int no_backspaces; /* if not to output any backspaces */
static int pass_unknown_seqs; /* pass unknown control sequences */
@@ -129,10 +134,26 @@ main(int argc, char **argv)
int this_line; /* line l points to */
int nflushd_lines; /* number of lines that were flushed */
int adjust, opt, warned, width;
+ const char *errstr;
+ cap_rights_t rights;
+ unsigned long cmd;
(void)setlocale(LC_CTYPE, "");
- max_bufd_lines = 128;
+ cap_rights_init(&rights, CAP_FSTAT, CAP_READ);
+ if (cap_rights_limit(STDIN_FILENO, &rights) < 0 && errno != ENOSYS)
+ err(1, "unable to limit rights for stdin");
+ cap_rights_init(&rights, CAP_FSTAT, CAP_WRITE, CAP_IOCTL);
+ if (cap_rights_limit(STDOUT_FILENO, &rights) < 0 && errno != ENOSYS)
+ err(1, "unable to limit rights for stdout");
+ cmd = TIOCGETA; /* required by isatty(3) in printf(3) */
+ if (cap_ioctls_limit(STDOUT_FILENO, &cmd, 1) < 0 && errno != ENOSYS)
+ err(1, "unable to limit ioctls for stdout");
+
+ if (cap_enter() < 0 && errno != ENOSYS)
+ err(1, "unable to enter capability mode");
+
+ max_bufd_lines = 256;
compress_spaces = 1; /* compress spaces into tabs */
while ((opt = getopt(argc, argv, "bfhl:px")) != -1)
switch (opt) {
@@ -146,8 +167,11 @@ main(int argc, char **argv)
compress_spaces = 1;
break;
case 'l': /* buffered line count */
- if ((max_bufd_lines = atoi(optarg)) <= 0)
- errx(1, "bad -l argument %s", optarg);
+ max_bufd_lines = strtonum(optarg, 1,
+ (INT_MAX - BUFFER_MARGIN) / 2, &errstr) * 2;
+ if (errstr != NULL)
+ errx(1, "bad -l argument, %s: %s", errstr,
+ optarg);
break;
case 'p': /* pass unknown control sequences */
pass_unknown_seqs = 1;
@@ -163,9 +187,6 @@ main(int argc, char **argv)
if (optind != argc)
usage();
- /* this value is in half lines */
- max_bufd_lines *= 2;
-
adjust = cur_col = extra_lines = warned = 0;
cur_line = max_line = nflushd_lines = this_line = 0;
cur_set = last_set = CS_NORMAL;
@@ -184,20 +205,31 @@ main(int argc, char **argv)
continue;
case ESC: /* just ignore EOF */
switch(getwchar()) {
+ /*
+ * In the input stream, accept both the
+ * XPG5 sequences ESC-digit and the
+ * traditional BSD sequences ESC-ctrl.
+ */
+ case '\007':
+ /* FALLTHROUGH */
case RLF:
- cur_line -= 2;
+ addto_lineno(&cur_line, -2);
break;
+ case '\010':
+ /* FALLTHROUGH */
case RHLF:
- cur_line--;
+ addto_lineno(&cur_line, -1);
break;
+ case '\011':
+ /* FALLTHROUGH */
case FHLF:
- cur_line++;
+ addto_lineno(&cur_line, 1);
if (cur_line > max_line)
max_line = cur_line;
}
continue;
case NL:
- cur_line += 2;
+ addto_lineno(&cur_line, 2);
if (cur_line > max_line)
max_line = cur_line;
cur_col = 0;
@@ -216,7 +248,7 @@ main(int argc, char **argv)
++cur_col;
continue;
case VT:
- cur_line -= 2;
+ addto_lineno(&cur_line, -2);
continue;
}
if (iswspace(ch)) {
@@ -229,58 +261,61 @@ main(int argc, char **argv)
}
/* Must stuff ch in a line - are we at the right one? */
- if (cur_line != this_line - adjust) {
+ if (cur_line + adjust != this_line) {
LINE *lnew;
- int nmove;
-
- adjust = 0;
- nmove = cur_line - this_line;
- if (!fine) {
- /* round up to next line */
- if (cur_line & 1) {
- adjust = 1;
- nmove++;
- }
- }
- if (nmove < 0) {
- for (; nmove < 0 && l->l_prev; nmove++)
+
+ /* round up to next line */
+ adjust = !fine && (cur_line & 1);
+
+ if (cur_line + adjust < this_line) {
+ while (cur_line + adjust < this_line &&
+ l->l_prev != NULL) {
l = l->l_prev;
- if (nmove) {
+ this_line--;
+ }
+ if (cur_line + adjust < this_line) {
if (nflushd_lines == 0) {
/*
* Allow backup past first
* line if nothing has been
* flushed yet.
*/
- for (; nmove < 0; nmove++) {
+ while (cur_line + adjust
+ < this_line) {
lnew = alloc_line();
l->l_prev = lnew;
lnew->l_next = l;
l = lines = lnew;
extra_lines++;
+ this_line--;
}
} else {
if (!warned++)
dowarn(cur_line);
- cur_line -= nmove;
+ cur_line = this_line - adjust;
}
}
} else {
/* may need to allocate here */
- for (; nmove > 0 && l->l_next; nmove--)
+ while (cur_line + adjust > this_line) {
+ if (l->l_next == NULL) {
+ l->l_next = alloc_line();
+ l->l_next->l_prev = l;
+ }
l = l->l_next;
- for (; nmove > 0; nmove--) {
- lnew = alloc_line();
- lnew->l_prev = l;
- l->l_next = lnew;
- l = lnew;
+ this_line++;
}
}
- this_line = cur_line + adjust;
- nmove = this_line - nflushd_lines;
- if (nmove >= max_bufd_lines + BUFFER_MARGIN) {
- nflushd_lines += nmove - max_bufd_lines;
- flush_lines(nmove - max_bufd_lines);
+ if (this_line > nflushd_lines &&
+ this_line - nflushd_lines >=
+ max_bufd_lines + BUFFER_MARGIN) {
+ if (extra_lines) {
+ flush_lines(extra_lines);
+ extra_lines = 0;
+ }
+ flush_lines(this_line - nflushd_lines -
+ max_bufd_lines);
+ nflushd_lines = this_line - max_bufd_lines;
}
}
/* grow line's buffer? */
@@ -311,25 +346,23 @@ main(int argc, char **argv)
}
if (ferror(stdin))
err(1, NULL);
- if (max_line == 0)
- exit(0); /* no lines, so just exit */
+ if (extra_lines)
+ flush_lines(extra_lines);
/* goto the last line that had a character on it */
for (; l->l_next; l = l->l_next)
this_line++;
- flush_lines(this_line - nflushd_lines + extra_lines + 1);
+ flush_lines(this_line - nflushd_lines + 1);
/* make sure we leave things in a sane state */
if (last_set != CS_NORMAL)
- PUTC('\017');
+ PUTC(SI);
/* flush out the last few blank lines */
- nblank_lines = max_line - this_line;
+ if (max_line > this_line)
+ nblank_lines = max_line - this_line;
if (max_line & 1)
nblank_lines++;
- else if (!nblank_lines)
- /* missing a \n on the last line? */
- nblank_lines = 2;
flush_blanks();
exit(0);
}
@@ -346,7 +379,8 @@ flush_lines(int nflush)
flush_blanks();
flush_line(l);
}
- nblank_lines++;
+ if (l->l_line || l->l_next)
+ nblank_lines++;
if (l->l_line)
(void)free(l->l_line);
free_line(l);
@@ -377,8 +411,8 @@ flush_blanks(void)
for (i = nb; --i >= 0;)
PUTC('\n');
if (half) {
- PUTC('\033');
- PUTC('\011');
+ PUTC(ESC);
+ PUTC(FHLF);
if (!nb)
PUTC('\r');
}
@@ -480,10 +514,10 @@ flush_line(LINE *l)
if (c->c_set != last_set) {
switch (c->c_set) {
case CS_NORMAL:
- PUTC('\017');
+ PUTC(SI);
break;
case CS_ALTERNATE:
- PUTC('\016');
+ PUTC(SO);
}
last_set = c->c_set;
}
@@ -498,6 +532,23 @@ flush_line(LINE *l)
}
}
+/*
+ * Increment or decrement a line number, checking for overflow.
+ * Stop one below INT_MAX such that the adjust variable is safe.
+ */
+void
+addto_lineno(int *lno, int offset)
+{
+ if (offset > 0) {
+ if (*lno >= INT_MAX - offset)
+ errx(1, "too many lines");
+ } else {
+ if (*lno < INT_MIN - offset)
+ errx(1, "too many reverse line feeds");
+ }
+ *lno += offset;
+}
+
#define NALLOC 64
static LINE *line_freelist;
diff --git a/usr.bin/col/tests/Makefile b/usr.bin/col/tests/Makefile
new file mode 100644
index 0000000..43838e9
--- /dev/null
+++ b/usr.bin/col/tests/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+TESTSDIR= ${TESTSBASE}/usr.bin/col
+
+ATF_TESTS_SH= col
+
+FILES= rlf.in \
+ rlf2.in
+FILESDIR= ${TESTSDIR}
+
+.include <bsd.test.mk>
diff --git a/usr.bin/col/tests/col.sh b/usr.bin/col/tests/col.sh
new file mode 100755
index 0000000..c072aab
--- /dev/null
+++ b/usr.bin/col/tests/col.sh
@@ -0,0 +1,33 @@
+# $FreeBSD$
+
+atf_test_case rlf
+
+rlf_head()
+{
+ atf_set "descr" "testing reverse line feed"
+}
+rlf_body()
+{
+ atf_check \
+ -o inline:"a b\n" \
+ -e empty \
+ -s exit:0 \
+ col < $(atf_get_srcdir)/rlf.in
+
+ atf_check \
+ -o inline:"a b\n" \
+ -e empty \
+ -s exit:0 \
+ col < $(atf_get_srcdir)/rlf2.in
+
+ atf_check \
+ -o inline:"a b\n" \
+ -e empty \
+ -s exit:0 \
+ col -x < $(atf_get_srcdir)/rlf2.in
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case rlf
+}
diff --git a/usr.bin/col/tests/rlf.in b/usr.bin/col/tests/rlf.in
new file mode 100644
index 0000000..57a14e5
--- /dev/null
+++ b/usr.bin/col/tests/rlf.in
@@ -0,0 +1,2 @@
+a
+ 7b
diff --git a/usr.bin/col/tests/rlf2.in b/usr.bin/col/tests/rlf2.in
new file mode 100644
index 0000000..dd46851
--- /dev/null
+++ b/usr.bin/col/tests/rlf2.in
@@ -0,0 +1,2 @@
+a
+ 7b
diff --git a/usr.bin/ctlstat/ctlstat.8 b/usr.bin/ctlstat/ctlstat.8
index 8351d9a..500ffb0 100644
--- a/usr.bin/ctlstat/ctlstat.8
+++ b/usr.bin/ctlstat/ctlstat.8
@@ -34,7 +34,7 @@
.\" $Id: //depot/users/kenm/FreeBSD-test2/usr.bin/ctlstat/ctlstat.8#2 $
.\" $FreeBSD$
.\"
-.Dd March 8, 2015
+.Dd May 22, 2015
.Dt CTLSTAT 8
.Os
.Sh NAME
@@ -117,6 +117,7 @@ every 10 seconds.
.Xr xpt 4 ,
.Xr camcontrol 8 ,
.Xr ctladm 8 ,
+.Xr ctld 8 ,
.Xr iostat 8
.Sh AUTHORS
.An Ken Merry Aq Mt ken@FreeBSD.org
diff --git a/usr.bin/cxxfilt/Makefile b/usr.bin/cxxfilt/Makefile
new file mode 100644
index 0000000..496b240
--- /dev/null
+++ b/usr.bin/cxxfilt/Makefile
@@ -0,0 +1,17 @@
+# $FreeBSD$
+
+.include <src.opts.mk>
+
+ELFTCDIR= ${.CURDIR}/../../contrib/elftoolchain
+SRCDIR= ${ELFTCDIR}/cxxfilt
+
+.PATH: ${SRCDIR}
+
+PROG= c++filt
+SRCS= cxxfilt.c
+
+LIBADD= elftc
+
+CFLAGS+=-I${ELFTCDIR}/libelftc -I${ELFTCDIR}/common
+
+.include <bsd.prog.mk>
diff --git a/usr.bin/demandoc/Makefile b/usr.bin/demandoc/Makefile
deleted file mode 100644
index 03a297b..0000000
--- a/usr.bin/demandoc/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/../../contrib/mdocml
-
-PROG= demandoc
-
-WARNS?= 5
-
-LIBADD= mandoc
-
-.include <bsd.prog.mk>
diff --git a/usr.bin/elfdump/elfdump.c b/usr.bin/elfdump/elfdump.c
index d58587e..cd10ce3 100644
--- a/usr.bin/elfdump/elfdump.c
+++ b/usr.bin/elfdump/elfdump.c
@@ -261,6 +261,7 @@ e_machines(u_int mach)
case EM_386: return "EM_386";
case EM_68K: return "EM_68K";
case EM_88K: return "EM_88K";
+ case EM_IAMCU: return "EM_IAMCU";
case EM_860: return "EM_860";
case EM_MIPS: return "EM_MIPS";
case EM_PPC: return "EM_PPC";
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
index 3b5a847..a46fe65 100644
--- a/usr.bin/kdump/kdump.c
+++ b/usr.bin/kdump/kdump.c
@@ -352,8 +352,6 @@ main(int argc, char *argv[])
limitfd(STDIN_FILENO);
limitfd(STDOUT_FILENO);
limitfd(STDERR_FILENO);
- if (cap_sandboxed())
- fprintf(stderr, "capability mode sandbox enabled\n");
TAILQ_INIT(&trace_procs);
drop_logged = 0;
diff --git a/usr.bin/m4/extern.h b/usr.bin/m4/extern.h
index fd2d3ae..d10f9ae 100644
--- a/usr.bin/m4/extern.h
+++ b/usr.bin/m4/extern.h
@@ -43,7 +43,6 @@ extern unsigned long expansion_id;
/* expr.c */
extern int expr(const char *);
-extern int32_t end_result;
/* gnum4.c */
extern void addtoincludepath(const char *);
diff --git a/usr.bin/m4/gnum4.c b/usr.bin/m4/gnum4.c
index cac01ec..dcccf3b 100644
--- a/usr.bin/m4/gnum4.c
+++ b/usr.bin/m4/gnum4.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gnum4.c,v 1.46 2014/07/10 14:12:31 espie Exp $ */
+/* $OpenBSD: gnum4.c,v 1.50 2015/04/29 00:13:26 millert Exp $ */
/*
* Copyright (c) 1999 Marc Espie
@@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$");
* functions needed to support gnu-m4 extensions, including a fake freezing
*/
-#include <sys/param.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <ctype.h>
@@ -40,10 +39,12 @@ __FBSDID("$FreeBSD$");
#include <regex.h>
#include <stddef.h>
#include <stdlib.h>
+#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
+#include <limits.h>
#include "mdef.h"
#include "stdd.h"
#include "extern.h"
@@ -76,9 +77,7 @@ new_path_entry(const char *dirname)
n = malloc(sizeof(struct path_entry));
if (!n)
errx(1, "out of memory");
- n->name = strdup(dirname);
- if (!n->name)
- errx(1, "out of memory");
+ n->name = xstrdup(dirname);
n->next = 0;
return n;
}
@@ -113,9 +112,7 @@ ensure_m4path(void)
if (!envpath)
return;
/* for portability: getenv result is read-only */
- envpath = strdup(envpath);
- if (!envpath)
- errx(1, "out of memory");
+ envpath = xstrdup(envpath);
for (sweep = envpath;
(path = strsep(&sweep, ":")) != NULL;)
addtoincludepath(path);
@@ -126,7 +123,7 @@ static
struct input_file *
dopath(struct input_file *i, const char *filename)
{
- char path[MAXPATHLEN];
+ char path[PATH_MAX];
struct path_entry *pe;
FILE *f;
@@ -214,8 +211,11 @@ addchars(const char *c, size_t n)
while (current + n > bufsize) {
if (bufsize == 0)
bufsize = 1024;
- else
+ else if (bufsize <= SIZE_MAX/2) {
bufsize *= 2;
+ } else {
+ errx(1, "size overflow");
+ }
buffer = xrealloc(buffer, bufsize, NULL);
}
memcpy(buffer+current, c, n);
diff --git a/usr.bin/m4/look.c b/usr.bin/m4/look.c
index 70497e0..383fbc6 100644
--- a/usr.bin/m4/look.c
+++ b/usr.bin/m4/look.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: look.c,v 1.23 2014/05/12 19:11:19 espie Exp $ */
+/* $OpenBSD: look.c,v 1.24 2014/12/21 09:33:12 espie Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -56,6 +56,9 @@ static void hash_free(void *, void *);
static void *element_alloc(size_t, void *);
static void setup_definition(struct macro_definition *, const char *,
const char *);
+static void free_definition(char *);
+static void keep(char *);
+static int string_in_use(const char *);
static struct ohash_info macro_info = {
offsetof(struct ndblock, name),
@@ -155,7 +158,7 @@ macro_define(const char *name, const char *defn)
ndptr n = create_entry(name);
if (n->d != NULL) {
if (n->d->defn != null)
- free(n->d->defn);
+ free_definition(n->d->defn);
} else {
n->d = xalloc(sizeof(struct macro_definition), NULL);
n->d->next = NULL;
@@ -273,3 +276,64 @@ macro_getbuiltin(const char *name)
else
return p;
}
+
+/* XXX things are slightly more complicated than they seem.
+ * a macro may actually be "live" (in the middle of an expansion
+ * on the stack.
+ * So we actually may need to place it in an array for later...
+ */
+
+static int kept_capacity = 0;
+static int kept_size = 0;
+static char **kept = NULL;
+
+static void
+keep(char *ptr)
+{
+ if (kept_capacity <= kept_size) {
+ if (kept_capacity)
+ kept_capacity *= 2;
+ else
+ kept_capacity = 50;
+ kept = xreallocarray(kept, kept_capacity,
+ sizeof(char *), "Out of memory while saving %d strings\n",
+ kept_capacity);
+ }
+ kept[kept_size++] = ptr;
+}
+
+static int
+string_in_use(const char *ptr)
+{
+ int i;
+ for (i = 0; i <= sp; i++) {
+ if (sstack[i] == STORAGE_MACRO && mstack[i].sstr == ptr)
+ return 1;
+ }
+ return 0;
+}
+
+
+static void
+free_definition(char *ptr)
+{
+ int i;
+
+ /* first try to free old strings */
+ for (i = 0; i < kept_size; i++) {
+ if (!string_in_use(kept[i])) {
+ kept_size--;
+ free(kept[i]);
+ if (i != kept_size)
+ kept[i] = kept[kept_size];
+ i--;
+ }
+ }
+
+ /* then deal with us */
+ if (string_in_use(ptr))
+ keep(ptr);
+ else
+ free(ptr);
+}
+
diff --git a/usr.bin/m4/m4.1 b/usr.bin/m4/m4.1
index 0e1d83a..b7dc131 100644
--- a/usr.bin/m4/m4.1
+++ b/usr.bin/m4/m4.1
@@ -33,7 +33,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd January 12, 2014
+.Dd $Mdocdate: April 14 2014 $
.Dt M4 1
.Os
.Sh NAME
@@ -98,7 +98,9 @@ recognized as special when not followed by an open parenthesis.
.Pp
The options are as follows:
.Bl -tag -width Ds
-.It Fl D Ns Ar name Ns Op Pf = Ns Ar value
+.It Fl D Ns Ar name Ns Oo
+.Pf = Ns Ar value
+.Oc
Define the symbol
.Ar name
to have some value (or
diff --git a/usr.bin/m4/main.c b/usr.bin/m4/main.c
index ced881b..84ba03a 100644
--- a/usr.bin/m4/main.c
+++ b/usr.bin/m4/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.83 2014/05/12 19:11:19 espie Exp $ */
+/* $OpenBSD: main.c,v 1.84 2014/12/21 09:33:12 espie Exp $ */
/* $NetBSD: main.c,v 1.12 1997/02/08 23:54:49 cgd Exp $ */
/*-
@@ -144,6 +144,9 @@ static struct keyblk keywrds[] = { /* m4 keywords to be installed */
#define MAXKEYS (sizeof(keywrds)/sizeof(struct keyblk))
+extern int optind;
+extern char *optarg;
+
#define MAXRECORD 50
static struct position {
char *name;
@@ -396,7 +399,7 @@ macro(void)
/*
* now push the string arguments:
*/
- pushs1(macro_getdef(p)->defn); /* defn string */
+ pushdef(p); /* defn string */
pushs1((char *)macro_name(p)); /* macro name */
pushs(ep); /* start next..*/
diff --git a/usr.bin/m4/mdef.h b/usr.bin/m4/mdef.h
index 0db78ef..49b3f50 100644
--- a/usr.bin/m4/mdef.h
+++ b/usr.bin/m4/mdef.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mdef.h,v 1.31 2011/09/27 07:24:02 espie Exp $ */
+/* $OpenBSD: mdef.h,v 1.32 2014/12/21 09:33:12 espie Exp $ */
/* $NetBSD: mdef.h,v 1.7 1996/01/13 23:25:27 pk Exp $ */
/*
@@ -164,6 +164,10 @@ struct input_file {
int c;
};
+#define STORAGE_STRSPACE 0
+#define STORAGE_MACRO 1
+#define STORAGE_OTHER 2
+
#define CURRENT_NAME (infile[ilevel].name)
#define CURRENT_LINE (infile[ilevel].lineno)
/*
@@ -179,7 +183,7 @@ struct input_file {
if (++sp == (int)STACKMAX) \
enlarge_stack();\
mstack[sp].sfra = (x); \
- sstack[sp] = 0; \
+ sstack[sp] = STORAGE_OTHER; \
} while (0)
#define pushs(x) \
@@ -187,7 +191,7 @@ struct input_file {
if (++sp == (int)STACKMAX) \
enlarge_stack();\
mstack[sp].sstr = (x); \
- sstack[sp] = 1; \
+ sstack[sp] = STORAGE_STRSPACE; \
} while (0)
#define pushs1(x) \
@@ -195,8 +199,17 @@ struct input_file {
if (++sp == (int)STACKMAX) \
enlarge_stack();\
mstack[sp].sstr = (x); \
- sstack[sp] = 0; \
+ sstack[sp] = STORAGE_OTHER; \
+ } while (0)
+
+#define pushdef(p) \
+ do { \
+ if (++sp == (int)STACKMAX) \
+ enlarge_stack();\
+ mstack[sp].sstr = macro_getdef(p)->defn;\
+ sstack[sp] = STORAGE_MACRO; \
} while (0)
+
/*
* . .
diff --git a/usr.bin/m4/misc.c b/usr.bin/m4/misc.c
index 30fb690..eeca68e 100644
--- a/usr.bin/m4/misc.c
+++ b/usr.bin/m4/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.44 2014/05/12 19:11:19 espie Exp $ */
+/* $OpenBSD: misc.c,v 1.45 2014/12/21 09:33:12 espie Exp $ */
/* $NetBSD: misc.c,v 1.6 1995/09/28 05:37:41 tls Exp $ */
/*
@@ -64,7 +64,6 @@ unsigned char *bbase[MAXINP]; /* the base for each ilevel */
unsigned char *bp; /* first available character */
unsigned char *endpbb; /* end of push-back buffer */
-static void *reallocarray(void *, size_t, size_t);
/*
* find the index of second str in the first str.
@@ -188,7 +187,7 @@ enlarge_strspace(void)
errx(1, "string space overflow");
memcpy(newstrspace, strspace, strsize/2);
for (i = 0; i <= sp; i++)
- if (sstack[i])
+ if (sstack[i] == STORAGE_STRSPACE)
mstack[i].sstr = (mstack[i].sstr - strspace)
+ newstrspace;
ep = (ep-strspace) + newstrspace;
@@ -266,7 +265,7 @@ killdiv(void)
extern char *__progname;
void
-m4errx(int exitstatus, const char *fmt, ...)
+m4errx(int eval, const char *fmt, ...)
{
fprintf(stderr, "%s: ", __progname);
fprintf(stderr, "%s at line %lu: ", CURRENT_NAME, CURRENT_LINE);
@@ -278,7 +277,7 @@ m4errx(int exitstatus, const char *fmt, ...)
va_end(ap);
}
fprintf(stderr, "\n");
- exit(exitstatus);
+ exit(eval);
}
/*
@@ -467,37 +466,3 @@ dump_buffer(FILE *f, size_t m)
for (s = bp; s-buf > (long)m;)
fputc(*--s, f);
}
-
-/* $OpenBSD: reallocarray.c,v 1.2 2014/12/08 03:45:00 bcook Exp $ */
-/*
- * Copyright (c) 2008 Otto Moerbeek <otto@drijf.net>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*
- * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX
- * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW
- */
-#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
-
-void *
-reallocarray(void *optr, size_t nmemb, size_t size)
-{
- if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
- nmemb > 0 && SIZE_MAX / nmemb < size) {
- errno = ENOMEM;
- return NULL;
- }
- return realloc(optr, size * nmemb);
-}
diff --git a/usr.bin/m4/parser.y b/usr.bin/m4/parser.y
index 8e8ad8c..3e4c8051 100644
--- a/usr.bin/m4/parser.y
+++ b/usr.bin/m4/parser.y
@@ -19,15 +19,9 @@
*/
#include <math.h>
-#include <stddef.h>
-#include <stdio.h>
#include <stdint.h>
-
-#include "mdef.h"
-#include "extern.h"
-
#define YYSTYPE int32_t
-
+extern int32_t end_result;
extern int yylex(void);
extern int yyerror(const char *);
%}
diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh
index 8541784..5e4d767 100755
--- a/usr.bin/man/man.sh
+++ b/usr.bin/man/man.sh
@@ -311,8 +311,11 @@ man_display_page() {
return
fi
+ if [ -n "$use_width" ]; then
+ mandoc_args="-O width=${use_width}"
+ fi
testline="mandoc -Tlint -Wunsupp 2>/dev/null"
- pipeline="mandoc | $MANPAGER"
+ pipeline="mandoc $mandoc_args | $MANPAGER"
if ! eval "$cattool $manpage | $testline" ;then
if which -s groff; then
diff --git a/usr.bin/mandoc/Makefile b/usr.bin/mandoc/Makefile
index 5368689..cdb512b 100644
--- a/usr.bin/mandoc/Makefile
+++ b/usr.bin/mandoc/Makefile
@@ -9,6 +9,37 @@ FILESDIR= ${SHAREDIR}/mdocml
MAN= mandoc.1 eqn.7 mandoc_char.7 tbl.7 man.7 mdoc.7 # roff.7
MLINKS= mandoc.1 mdocml.1
+LIBMAN_SRCS= man.c \
+ man_hash.c \
+ man_macro.c \
+ man_validate.c
+
+LIBMDOC_SRCS= att.c \
+ lib.c \
+ mdoc.c \
+ mdoc_argv.c \
+ mdoc_hash.c \
+ mdoc_macro.c \
+ mdoc_validate.c \
+ st.c \
+
+LIBROFF_SRCS= eqn.c \
+ roff.c \
+ tbl.c \
+ tbl_data.c \
+ tbl_layout.c \
+ tbl_opts.c \
+
+LIB_SRCS= ${LIBMAN_SRCS} \
+ ${LIBMDOC_SRCS} \
+ ${LIBROFF_SRCS} \
+ chars.c \
+ mandoc.c \
+ mandoc_aux.c \
+ msec.c \
+ preconv.c \
+ read.c
+
HTML_SRCS= eqn_html.c \
html.c \
man_html.c \
@@ -30,7 +61,8 @@ DB_SRCS= mandocdb.c \
mansearch_const.c \
manpath.c
-SRCS= ${HTML_SRCS} \
+SRCS= ${LIB_SRCS} \
+ ${HTML_SRCS} \
${MAN_SRCS} \
${TERM_SRCS} \
main.c \
@@ -43,6 +75,6 @@ WARNS?= 2
CFLAGS+= -DHAVE_CONFIG_H \
-I${.CURDIR}/../../lib/libohash/ \
-I${.CURDIR}/../../contrib/sqlite3
-LIBADD= mandoc ohash sqlite3
+LIBADD= ohash sqlite3
.include <bsd.prog.mk>
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index f04c531..109ef2d 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -315,7 +315,7 @@ intpr(int interval, void (*pfunc)(char *), int af)
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
bool network = false, link = false;
- char *name;
+ char *name, *xname, buf[IFNAMSIZ+1];
if (interface != NULL && strcmp(ifa->ifa_name, interface) != 0)
continue;
@@ -341,10 +341,20 @@ intpr(int interval, void (*pfunc)(char *), int af)
xo_open_instance("interface");
+ if ((ifa->ifa_flags & IFF_UP) == 0) {
+ xname = stpcpy(buf, name);
+ *xname++ = '*';
+ *xname = '\0';
+ xname = buf;
+ } else
+ xname = name;
+
if (Wflag)
- xo_emit("{tk:name/%-7.7s}", name);
+ xo_emit("{etk:name/%s}{e:flags/0x%x}{d:/%7.7s}",
+ name, ifa->ifa_flags, xname);
else
- xo_emit("{tk:name/%-5.5s}", name);
+ xo_emit("{etk:name/%s}{e:flags/0x%x}{d:/%5.5s}",
+ name, ifa->ifa_flags, xname);
#define IFA_MTU(ifa) (((struct if_data *)(ifa)->ifa_data)->ifi_mtu)
show_stat("lu", 6, "mtu", IFA_MTU(ifa), IFA_MTU(ifa));
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index 676f616..ab5a3ed 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -236,7 +236,7 @@ pr_rthdr(int af1)
xo_emit("{T:/%-8.8s} ","Address");
if (Wflag) {
xo_emit("{T:/%-*.*s} {T:/%-*.*s} {T:/%-*.*s} {T:/%*.*s} "
- "{T:/%*.*s} {T:/%*.*s} {T:/%*.*s} {T:/%*s}\n",
+ "{T:/%*.*s} {T:/%*.*s} {T:/%*s}\n",
wid_dst, wid_dst, "Destination",
wid_gw, wid_gw, "Gateway",
wid_flags, wid_flags, "Flags",
@@ -245,7 +245,7 @@ pr_rthdr(int af1)
wid_if, wid_if, "Netif",
wid_expire, "Expire");
} else {
- xo_emit("{T:/%-*.*s} {T:/%-*.*s} {T:/%-*.*s} {T:/%*.*s} "
+ xo_emit("{T:/%-*.*s} {T:/%-*.*s} {T:/%-*.*s} {T:/%*.*s} "
"{T:/%*s}\n",
wid_dst, wid_dst, "Destination",
wid_gw, wid_gw, "Gateway",
@@ -389,7 +389,7 @@ p_rtentry_sysctl(const char *name, struct rt_msghdr *rtm)
p_sockaddr("destination", &addr.u_sa, &mask.u_sa, rtm->rtm_flags,
wid_dst);
p_sockaddr("gateway", &gw.u_sa, NULL, RTF_HOST, wid_gw);
- snprintf(buffer, sizeof(buffer), "{[:-%d}{:flags/%%s}{]:}",
+ snprintf(buffer, sizeof(buffer), "{[:-%d}{:flags/%%s}{]:} ",
wid_flags);
p_flags(rtm->rtm_flags, buffer);
if (Wflag) {
diff --git a/usr.bin/procstat/procstat.1 b/usr.bin/procstat/procstat.1
index 3ef39eb..0fd314f 100644
--- a/usr.bin/procstat/procstat.1
+++ b/usr.bin/procstat/procstat.1
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 10, 2015
+.Dd May 18, 2015
.Dt PROCSTAT 1
.Os
.Sh NAME
@@ -530,6 +530,7 @@ auxiliary vector value
.Xr sockstat 1 ,
.Xr cap_enter 2 ,
.Xr cap_rights_limit 2 ,
+.Xr libprocstat 3 ,
.Xr ddb 4 ,
.Xr stack 9
.Sh AUTHORS
diff --git a/usr.bin/rctl/rctl.8 b/usr.bin/rctl/rctl.8
index 3f72b91..fe14756 100644
--- a/usr.bin/rctl/rctl.8
+++ b/usr.bin/rctl/rctl.8
@@ -233,6 +233,18 @@ for a list of supported signals
Not all actions are supported for all resources.
Attempting to add a rule with an action not supported by a given resource will
result in error.
+.Sh LOADER TUNABLES
+Tunables can be set at the
+.Xr loader 8
+prompt, or
+.Xr loader.conf 5 .
+.Bl -tag -width indent
+.It Va kern.racct.enable: No 1
+Enable
+.Nm .
+This defaults to 1, unless
+.Cd "options RACCT_DEFAULT_TO_DISABLED"
+is set in the kernel configuration file.
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
diff --git a/usr.bin/rctl/rctl.c b/usr.bin/rctl/rctl.c
index 185788d..b534258 100644
--- a/usr.bin/rctl/rctl.c
+++ b/usr.bin/rctl/rctl.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/rctl.h>
+#include <sys/sysctl.h>
#include <assert.h>
#include <ctype.h>
#include <err.h>
@@ -305,13 +306,37 @@ print_rules(char *rules, int hflag, int nflag)
}
static void
+enosys(void)
+{
+ int error, racct_enable;
+ size_t racct_enable_len;
+
+ racct_enable_len = sizeof(racct_enable);
+ error = sysctlbyname("kern.racct.enable",
+ &racct_enable, &racct_enable_len, NULL, 0);
+
+ if (error != 0) {
+ if (errno == ENOENT)
+ errx(1, "RACCT/RCTL support not present in kernel; see rctl(8) for details");
+
+ err(1, "sysctlbyname");
+ }
+
+ if (racct_enable == 0)
+ errx(1, "RACCT/RCTL present, but disabled; enable using kern.racct.enable=1 tunable");
+}
+
+static void
add_rule(char *rule)
{
int error;
error = rctl_add_rule(rule, strlen(rule) + 1, NULL, 0);
- if (error != 0)
+ if (error != 0) {
+ if (errno == ENOSYS)
+ enosys();
err(1, "rctl_add_rule");
+ }
free(rule);
}
@@ -330,8 +355,11 @@ show_limits(char *filter, int hflag, int nflag)
error = rctl_get_limits(filter, strlen(filter) + 1, outbuf,
outbuflen);
- if (error && errno != ERANGE)
+ if (error && errno != ERANGE) {
+ if (errno == ENOSYS)
+ enosys();
err(1, "rctl_get_limits");
+ }
} while (error && errno == ERANGE);
print_rules(outbuf, hflag, nflag);
@@ -345,8 +373,11 @@ remove_rule(char *filter)
int error;
error = rctl_remove_rule(filter, strlen(filter) + 1, NULL, 0);
- if (error != 0)
+ if (error != 0) {
+ if (errno == ENOSYS)
+ enosys();
err(1, "rctl_remove_rule");
+ }
free(filter);
}
@@ -399,8 +430,11 @@ show_usage(char *filter, int hflag)
error = rctl_get_racct(filter, strlen(filter) + 1, outbuf,
outbuflen);
- if (error && errno != ERANGE)
+ if (error && errno != ERANGE) {
+ if (errno == ENOSYS)
+ enosys();
err(1, "rctl_get_racct");
+ }
} while (error && errno == ERANGE);
while ((tmp = strsep(&outbuf, ",")) != NULL) {
@@ -439,8 +473,11 @@ show_rules(char *filter, int hflag, int nflag)
err(1, "realloc");
error = rctl_get_rules(filter, filterlen, outbuf, outbuflen);
- if (error && errno != ERANGE)
+ if (error && errno != ERANGE) {
+ if (errno == ENOSYS)
+ enosys();
err(1, "rctl_get_rules");
+ }
} while (error && errno == ERANGE);
print_rules(outbuf, hflag, nflag);
diff --git a/usr.bin/soelim/Makefile b/usr.bin/soelim/Makefile
new file mode 100644
index 0000000..21eaaff
--- /dev/null
+++ b/usr.bin/soelim/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+.include <src.opts.mk>
+
+PROG= soelim
+
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
+.include <bsd.prog.mk>
diff --git a/usr.bin/soeliminate/soeliminate.1 b/usr.bin/soelim/soelim.1
index eeb5657..57e8614 100644
--- a/usr.bin/soeliminate/soeliminate.1
+++ b/usr.bin/soelim/soelim.1
@@ -24,12 +24,12 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 22, 2014
-.Dt SOELIMINATE 1
+.Dd May 1, 2015
+.Dt SOELIM 1
.Os
.Sh NAME
-.Nm soeliminate
-.Nd interpret .so directive in manpages
+.Nm soelim
+.Nd interpret .so requests in manpages
.Sh SYNOPSIS
.Nm
.Op Fl Crtv
@@ -48,9 +48,9 @@ it replace the line by processing
Otherwise the line is printed to stdout.
.Bl -tag -width "-I dir"
.It Fl C
-Compatibility with GNU groff's
-.Xr soelim 1
-(does nothing).
+Recognise
+.Em .so
+when not followed by a space character.
.It Fl r
Compatibility with GNU groff's
.Xr soelim 1
@@ -78,5 +78,9 @@ The files are always searched first in the current directory.
A file specified with an absolute path will be opened directly without
performing a search.
.Sh SEE ALSO
-.Xr mandoc 1 ,
-.Xr soelim 1
+.Xr mandoc 1
+.Sh AUTHORS
+This version of the
+.Nm
+utility was written by
+.An Baptiste Daroussin Aq Mt bapt@freebsd.org .
diff --git a/usr.bin/soeliminate/soeliminate.c b/usr.bin/soelim/soelim.c
index 80b337f..4d747ee 100644
--- a/usr.bin/soeliminate/soeliminate.c
+++ b/usr.bin/soelim/soelim.c
@@ -27,17 +27,19 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/param.h>
+#include <sys/types.h>
+#include <ctype.h>
+#include <err.h>
+#include <limits.h>
#define _WITH_GETLINE
#include <stdio.h>
-#include <unistd.h>
#include <stdlib.h>
-#include <stdbool.h>
#include <string.h>
#include <stringlist.h>
-#include <err.h>
-#include <ctype.h>
+#include <unistd.h>
+
+#define C_OPTION 0x1
static StringList *includes;
@@ -45,7 +47,7 @@ static void
usage(void)
{
- fprintf(stderr, "usage: soeliminate [-Crtv] [-I dir] [files]\n");
+ fprintf(stderr, "usage: soelim [-Crtv] [-I dir] [files]\n");
exit(EXIT_FAILURE);
}
@@ -54,9 +56,12 @@ static FILE *
soelim_fopen(const char *name)
{
FILE *f;
- char path[MAXPATHLEN];
+ char path[PATH_MAX];
size_t i;
+ if (strcmp(name, "-") == 0)
+ return (stdin);
+
if ((f = fopen(name, "r")) != NULL)
return (f);
@@ -78,10 +83,10 @@ soelim_fopen(const char *name)
}
static int
-soelim_file(FILE *f)
+soelim_file(FILE *f, int flag)
{
char *line = NULL;
- char *walk;
+ char *walk, *cp;
size_t linecap = 0;
ssize_t linelen;
@@ -93,16 +98,33 @@ soelim_file(FILE *f)
printf("%s", line);
continue;
}
+
walk = line + 3;
+ if (!isspace(*walk) && ((flag & C_OPTION) == 0)) {
+ printf("%s", line);
+ continue;
+ }
+
while (isspace(*walk))
walk++;
- while (isspace(walk[strlen(walk) - 1]))
- walk[strlen(walk) - 1] = '\0';
- if (soelim_file(soelim_fopen(walk)) == 1) {
+ cp = walk;
+ while (*cp != '\0' && !isspace(*cp))
+ cp++;
+ *cp = 0;
+ if (cp < line + linelen)
+ cp++;
+
+ if (*walk == '\0') {
+ printf("%s", line);
+ continue;
+ }
+ if (soelim_file(soelim_fopen(walk), flag) == 1) {
free(line);
return (1);
}
+ if (*cp != '\0')
+ printf("%s", cp);
}
free(line);
@@ -116,6 +138,7 @@ main(int argc, char **argv)
{
int ch, i;
int ret = 0;
+ int flags = 0;
includes = sl_init();
if (includes == NULL)
@@ -124,6 +147,8 @@ main(int argc, char **argv)
while ((ch = getopt(argc, argv, "CrtvI:")) != -1) {
switch (ch) {
case 'C':
+ flags |= C_OPTION;
+ break;
case 'r':
case 'v':
case 't':
@@ -142,10 +167,10 @@ main(int argc, char **argv)
argv += optind;
if (argc == 0)
- ret = soelim_file(stdin);
+ ret = soelim_file(stdin, flags);
for (i = 0; i < argc; i++)
- ret = soelim_file(soelim_fopen(argv[i]));
+ ret = soelim_file(soelim_fopen(argv[i]), flags);
sl_free(includes, 0);
diff --git a/usr.bin/soelim/tests/Makefile b/usr.bin/soelim/tests/Makefile
new file mode 100644
index 0000000..4d787cf
--- /dev/null
+++ b/usr.bin/soelim/tests/Makefile
@@ -0,0 +1,15 @@
+# $FreeBSD$
+
+TESTSDIR= ${TESTSBASE}/usr.bin/soelim
+
+ATF_TESTS_SH= soelim
+
+FILES= nonexisting.in \
+ basic.in \
+ basic \
+ basic.out \
+ basic-with-space.in \
+ basic-with-space.out
+FILESDIR= ${TESTSDIR}
+
+.include <bsd.test.mk>
diff --git a/usr.bin/soelim/tests/basic b/usr.bin/soelim/tests/basic
new file mode 100644
index 0000000..c4fe1dd
--- /dev/null
+++ b/usr.bin/soelim/tests/basic
@@ -0,0 +1 @@
+basic has been included
diff --git a/usr.bin/soelim/tests/basic-with-space.in b/usr.bin/soelim/tests/basic-with-space.in
new file mode 100644
index 0000000..971d681
--- /dev/null
+++ b/usr.bin/soelim/tests/basic-with-space.in
@@ -0,0 +1,3 @@
+This is a test
+.so basic something
+end
diff --git a/usr.bin/soelim/tests/basic-with-space.out b/usr.bin/soelim/tests/basic-with-space.out
new file mode 100644
index 0000000..290b2c6
--- /dev/null
+++ b/usr.bin/soelim/tests/basic-with-space.out
@@ -0,0 +1,4 @@
+This is a test
+basic has been included
+something
+end
diff --git a/usr.bin/soelim/tests/basic.in b/usr.bin/soelim/tests/basic.in
new file mode 100644
index 0000000..cd32eb1
--- /dev/null
+++ b/usr.bin/soelim/tests/basic.in
@@ -0,0 +1,3 @@
+This is a test
+.so basic
+end
diff --git a/usr.bin/soelim/tests/basic.out b/usr.bin/soelim/tests/basic.out
new file mode 100644
index 0000000..db59fbb
--- /dev/null
+++ b/usr.bin/soelim/tests/basic.out
@@ -0,0 +1,3 @@
+This is a test
+basic has been included
+end
diff --git a/usr.bin/soelim/tests/nonexisting.in b/usr.bin/soelim/tests/nonexisting.in
new file mode 100644
index 0000000..e07599d
--- /dev/null
+++ b/usr.bin/soelim/tests/nonexisting.in
@@ -0,0 +1,3 @@
+This is a test
+.so nonexistingfile
+This is next
diff --git a/usr.bin/soelim/tests/soelim.sh b/usr.bin/soelim/tests/soelim.sh
new file mode 100755
index 0000000..69c92e4
--- /dev/null
+++ b/usr.bin/soelim/tests/soelim.sh
@@ -0,0 +1,103 @@
+# $FreeBSD$
+
+atf_test_case stdin
+stdin_head()
+{
+ atf_set "descr" "stdin functionality"
+}
+
+stdin_body()
+{
+ # no file after .so
+ atf_check \
+ -o inline:".so\n" \
+ -e empty \
+ -s exit:0 \
+ soelim <<-EOF
+.so
+EOF
+
+ # only space after .so
+ atf_check \
+ -o inline:".so \n" \
+ -e empty \
+ -s exit:0 \
+ soelim <<-EOF
+.so
+EOF
+
+ # explicit stdin
+ atf_check \
+ -o inline:".so\n" \
+ -e empty \
+ -s exit:0 \
+ soelim - <<-EOF
+.so
+EOF
+
+ atf_check \
+ -o empty \
+ -e inline:"soelim: can't open 'afile': No such file or directory\n" \
+ -s exit:1 \
+ soelim <<-EOF
+.so afile
+EOF
+
+ atf_check \
+ -o inline:".soafile\n" \
+ -e empty \
+ -s exit:0 \
+ soelim <<-EOF
+.soafile
+EOF
+
+ atf_check \
+ -o empty \
+ -e inline:"soelim: can't open 'afile': No such file or directory\n" \
+ -s exit:1 \
+ soelim -C <<-EOF
+.soafile
+EOF
+}
+
+atf_test_case files
+files_head()
+{
+ atf_set "descr" "testing files"
+}
+
+files_body()
+{
+ atf_check \
+ -o inline:"This is a test\n" \
+ -e inline:"soelim: can't open 'nonexistingfile': No such file or directory\n" \
+ -s exit:1 \
+ soelim $(atf_get_srcdir)/nonexisting.in
+
+ cp $(atf_get_srcdir)/basic .
+ atf_check \
+ -o file:$(atf_get_srcdir)/basic.out \
+ -e empty \
+ -s exit:0 \
+ soelim $(atf_get_srcdir)/basic.in
+
+ rm -f basic
+ atf_check \
+ -o file:$(atf_get_srcdir)/basic.out \
+ -e empty \
+ -s exit:0 \
+ soelim -I$(atf_get_srcdir) $(atf_get_srcdir)/basic.in
+
+ atf_check \
+ -o file:$(atf_get_srcdir)/basic-with-space.out \
+ -e empty \
+ -s exit:0 \
+ soelim -I$(atf_get_srcdir) $(atf_get_srcdir)/basic-with-space.in
+
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case stdin
+ atf_add_test_case files
+}
diff --git a/usr.bin/soeliminate/Makefile b/usr.bin/soeliminate/Makefile
deleted file mode 100644
index 17d4525..0000000
--- a/usr.bin/soeliminate/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-# $FreeBSD$
-
-PROG= soeliminate
-
-.include <bsd.prog.mk>
diff --git a/usr.bin/ssh-copy-id/ssh-copy-id.sh b/usr.bin/ssh-copy-id/ssh-copy-id.sh
index 09fb3cc..f03d5c0 100755
--- a/usr.bin/ssh-copy-id/ssh-copy-id.sh
+++ b/usr.bin/ssh-copy-id/ssh-copy-id.sh
@@ -48,7 +48,7 @@ sendkey() {
done ; \
if [ -x /sbin/restorecon ]; then \
/sbin/restorecon -F "$HOME/.ssh/" "$keyfile" >/dev/null 2>&1 || true ; \
- fi
+ fi \
'\'
}
diff --git a/usr.bin/tar/Makefile b/usr.bin/tar/Makefile
index f7e7775..e8a9ad4 100644
--- a/usr.bin/tar/Makefile
+++ b/usr.bin/tar/Makefile
@@ -31,7 +31,6 @@ CFLAGS+= -I${LIBARCHIVEDIR}/tar -I${LIBARCHIVEDIR}/libarchive
CFLAGS+= -I${LIBARCHIVEDIR}/libarchive_fe
SYMLINKS= bsdtar ${BINDIR}/tar
MLINKS= bsdtar.1 tar.1
-DEBUG_FLAGS=-g
.PHONY: check test clean-test
check test: $(PROG) bsdtar.1.gz
diff --git a/usr.bin/time/time.c b/usr.bin/time/time.c
index c2ea522..678a2af 100644
--- a/usr.bin/time/time.c
+++ b/usr.bin/time/time.c
@@ -65,6 +65,7 @@ static void showtime(FILE *, struct timeval *, struct timeval *,
static void siginfo(int);
static void usage(void);
+static sig_atomic_t siginfo_recvd;
static char decimal_point;
static struct timeval before_tv;
static int hflag, pflag;
@@ -130,8 +131,17 @@ main(int argc, char **argv)
/* parent */
(void)signal(SIGINT, SIG_IGN);
(void)signal(SIGQUIT, SIG_IGN);
+ siginfo_recvd = 0;
(void)signal(SIGINFO, siginfo);
- while (wait4(pid, &status, 0, &ru) != pid);
+ (void)siginterrupt(SIGINFO, 1);
+ while (wait4(pid, &status, 0, &ru) != pid) {
+ if (siginfo_recvd) {
+ siginfo_recvd = 0;
+ (void)gettimeofday(&after, NULL);
+ getrusage(RUSAGE_CHILDREN, &ru);
+ showtime(stdout, &before_tv, &after, &ru);
+ }
+ }
(void)gettimeofday(&after, NULL);
if ( ! WIFEXITED(status))
warnx("command terminated abnormally");
@@ -292,10 +302,6 @@ showtime(FILE *out, struct timeval *before, struct timeval *after,
static void
siginfo(int sig __unused)
{
- struct timeval after;
- struct rusage ru;
- (void)gettimeofday(&after, NULL);
- getrusage(RUSAGE_CHILDREN, &ru);
- showtime(stdout, &before_tv, &after, &ru);
+ siginfo_recvd = 1;
}
diff --git a/usr.bin/vgrind/Makefile b/usr.bin/vgrind/Makefile
index 612e504..06d9052 100644
--- a/usr.bin/vgrind/Makefile
+++ b/usr.bin/vgrind/Makefile
@@ -11,7 +11,7 @@ FILESDIR= ${SHAREDIR}/misc
FILESDIR_tmac.vgrind= ${SHAREDIR}/tmac
MAN= vgrind.1 vgrindefs.5
-WARNS?= 2
+WARNS?= 3
BINDIR= /usr/libexec
SCRIPTSDIR=/usr/bin
diff --git a/usr.bin/vgrind/extern.h b/usr.bin/vgrind/extern.h
index 6616ca9..812592f 100644
--- a/usr.bin/vgrind/extern.h
+++ b/usr.bin/vgrind/extern.h
@@ -31,9 +31,7 @@
* $FreeBSD$
*/
-typedef int boolean;
-
-extern boolean _escaped; /* if last character was an escape */
+extern bool _escaped; /* if last character was an escape */
extern char *s_start; /* start of the current string */
extern char *l_acmbeg; /* string introducing a comment */
extern char *l_acmend; /* string ending a comment */
@@ -45,11 +43,11 @@ extern char *l_combeg; /* string introducing a comment */
extern char *l_comend; /* string ending a comment */
extern char l_escape; /* character used to escape characters */
extern char *l_keywds[]; /* keyword table address */
-extern boolean l_onecase; /* upper and lower case are equivalent */
+extern bool l_onecase; /* upper and lower case are equivalent */
extern char *l_prcbeg; /* regular expr for procedure begin */
extern char *l_strbeg; /* delimiter for string constant */
extern char *l_strend; /* delimiter for string constant */
-extern boolean l_toplex; /* procedures only defined at top lex level */
+extern bool l_toplex; /* procedures only defined at top lex level */
extern const char *language; /* the language indicator */
#include <sys/cdefs.h>
diff --git a/usr.bin/vgrind/regexp.c b/usr.bin/vgrind/regexp.c
index 2da447d..cd57835 100644
--- a/usr.bin/vgrind/regexp.c
+++ b/usr.bin/vgrind/regexp.c
@@ -44,19 +44,16 @@ static const char sccsid[] = "@(#)regexp.c 8.1 (Berkeley) 6/6/93";
#include <ctype.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
#include "extern.h"
-#define FALSE 0
-#define TRUE !(FALSE)
-#define NIL 0
-
static void expconv(void);
-boolean _escaped; /* true if we are currently _escaped */
+bool _escaped; /* true if we are currently x_escaped */
char *s_start; /* start of string */
-boolean l_onecase; /* true if upper and lower equivalent */
+bool l_onecase; /* true if upper and lower equivalent */
#define makelower(c) (isupper((c)) ? tolower((c)) : (c))
@@ -66,9 +63,7 @@ boolean l_onecase; /* true if upper and lower equivalent */
*/
int
-STRNCMP(s1, s2, len)
- register char *s1,*s2;
- register int len;
+STRNCMP(register char *s1, register char *s2, register int len)
{
if (l_onecase) {
do
@@ -147,18 +142,18 @@ STRNCMP(s1, s2, len)
static char *ccre; /* pointer to current position in converted exp*/
static char *ure; /* pointer current position in unconverted exp */
+/* re: unconverted irregular expression */
char *
-convexp(re)
- char *re; /* unconverted irregular expression */
+convexp(char *re)
{
register char *cre; /* pointer to converted regular expression */
/* allocate room for the converted expression */
- if (re == NIL)
- return (NIL);
+ if (re == NULL)
+ return (NULL);
if (*re == '\0')
- return (NIL);
- cre = malloc (4 * strlen(re) + 3);
+ return (NULL);
+ cre = malloc(4 * strlen(re) + 3);
ccre = cre;
ure = re;
@@ -182,9 +177,9 @@ expconv()
register int temp;
/* let the conversion begin */
- acs = NIL;
- cs = NIL;
- while (*ure != NIL) {
+ acs = NULL;
+ cs = NULL;
+ while (*ure) {
switch (c = *ure++) {
case '\\':
@@ -192,7 +187,7 @@ expconv()
/* escaped characters are just characters */
default:
- if (cs == NIL || (*cs & STR) == 0) {
+ if (cs == NULL || (*cs & STR) == 0) {
cs = ccre;
*cs = STR;
SCNT(cs) = 1;
@@ -207,13 +202,13 @@ expconv()
case 'd':
case 'e':
case 'p':
- if (acs != NIL && acs != cs) {
+ if (acs != NULL && acs != cs) {
do {
temp = OCNT(acs);
OCNT(acs) = ccre - acs;
acs -= temp;
} while (temp != 0);
- acs = NIL;
+ acs = NULL;
}
cs = ccre;
*cs = META;
@@ -226,13 +221,13 @@ expconv()
/* just put the symbol in */
case '^':
case '$':
- if (acs != NIL && acs != cs) {
+ if (acs != NULL && acs != cs) {
do {
temp = OCNT(acs);
OCNT(acs) = ccre - acs;
acs -= temp;
} while (temp != 0);
- acs = NIL;
+ acs = NULL;
}
cs = ccre;
*cs = META;
@@ -248,31 +243,31 @@ expconv()
/* recurse and define a subexpression */
case '(':
- if (acs != NIL && acs != cs) {
+ if (acs != NULL && acs != cs) {
do {
temp = OCNT(acs);
OCNT(acs) = ccre - acs;
acs -= temp;
} while (temp != 0);
- acs = NIL;
+ acs = NULL;
}
cs = ccre;
*cs = OPER;
OSYM(cs) = '(';
ccre = ONEXT(cs);
- expconv ();
+ expconv();
OCNT(cs) = ccre - cs; /* offset to next symbol */
break;
/* return from a recursion */
case ')':
- if (acs != NIL) {
+ if (acs != NULL) {
do {
temp = OCNT(acs);
OCNT(acs) = ccre - acs;
acs -= temp;
} while (temp != 0);
- acs = NIL;
+ acs = NULL;
}
cs = ccre;
*cs = META;
@@ -284,7 +279,7 @@ expconv()
/* the third byte will contain an offset to jump over the */
/* alternate match in case the first did not fail */
case '|':
- if (acs != NIL && acs != cs)
+ if (acs != NULL && acs != cs)
OCNT(ccre) = ccre - acs; /* make a back pointer */
else
OCNT(ccre) = 0;
@@ -298,7 +293,7 @@ expconv()
/* if its not a metasymbol just build a scharacter string */
default:
- if (cs == NIL || (*cs & STR) == 0) {
+ if (cs == NULL || (*cs & STR) == 0) {
cs = ccre;
*cs = STR;
SCNT(cs) = 1;
@@ -309,13 +304,13 @@ expconv()
break;
}
}
- if (acs != NIL) {
+ if (acs != NULL) {
do {
temp = OCNT(acs);
OCNT(acs) = ccre - acs;
acs -= temp;
} while (temp != 0);
- acs = NIL;
+ acs = NULL;
}
return;
}
@@ -344,21 +339,23 @@ expconv()
* character matched.
*/
+/*
+ * s: string to check for a match in
+ * re: a converted irregular expression
+ * mstring: where to put whatever matches a \p
+ */
char *
-expmatch (s, re, mstring)
- register char *s; /* string to check for a match in */
- register char *re; /* a converted irregular expression */
- register char *mstring; /* where to put whatever matches a \p */
+expmatch (register char *s, register char *re, register char *mstring)
{
register char *cs; /* the current symbol */
register char *ptr,*s1; /* temporary pointer */
- boolean matched; /* a temporary boolean */
+ bool matched; /* a temporary bool */
/* initial conditions */
- if (re == NIL)
- return (NIL);
+ if (re == NULL)
+ return (NULL);
cs = re;
- matched = FALSE;
+ matched = false;
/* loop till expression string is exhausted (or at least pretty tired) */
while (*cs) {
@@ -384,7 +381,7 @@ expmatch (s, re, mstring)
} else {
/* no match, error return */
- return (NIL);
+ return (NULL);
}
break;
@@ -406,8 +403,8 @@ expmatch (s, re, mstring)
/* this is a grouping, recurse */
case '(':
- ptr = expmatch (s, ONEXT(cs), mstring);
- if (ptr != NIL) {
+ ptr = expmatch(s, ONEXT(cs), mstring);
+ if (ptr != NULL) {
/* the subexpression matched */
matched = 1;
@@ -423,7 +420,7 @@ expmatch (s, re, mstring)
} else {
/* no match, error return */
- return (NIL);
+ return (NULL);
}
cs = OPTR(cs);
break;
@@ -443,35 +440,35 @@ expmatch (s, re, mstring)
*/
s1 = s;
do {
- ptr = expmatch (s1, MNEXT(cs), mstring);
- if (ptr != NIL && s1 != s) {
+ ptr = expmatch(s1, MNEXT(cs), mstring);
+ if (ptr != NULL && s1 != s) {
/* we have a match, remember the match */
strncpy (mstring, s, s1 - s);
mstring[s1 - s] = '\0';
return (ptr);
- } else if (ptr != NIL && (*cs & OPT)) {
+ } else if (ptr != NULL && (*cs & OPT)) {
/* it was aoptional so no match is ok */
return (ptr);
- } else if (ptr != NIL) {
+ } else if (ptr != NULL) {
/* not optional and we still matched */
- return (NIL);
+ return (NULL);
}
if (!(isalnum(*s1) || *s1 == '_' ||
/* C++ destructor */
*s1 == '~' ||
/* C++ scope operator */
(strlen(s1) > 1 && *s1 == ':' && s1[1] == ':' &&
- (s1++, TRUE))))
- return (NIL);
+ (s1++, true))))
+ return (NULL);
if (*s1 == '\\')
- _escaped = _escaped ? FALSE : TRUE;
+ _escaped = _escaped ? false : true;
else
- _escaped = FALSE;
+ _escaped = false;
} while (*s1++);
- return (NIL);
+ return (NULL);
/* try to match anything */
case 'a':
@@ -482,31 +479,31 @@ expmatch (s, re, mstring)
*/
s1 = s;
do {
- ptr = expmatch (s1, MNEXT(cs), mstring);
- if (ptr != NIL && s1 != s) {
+ ptr = expmatch(s1, MNEXT(cs), mstring);
+ if (ptr != NULL && s1 != s) {
/* we have a match */
return (ptr);
- } else if (ptr != NIL && (*cs & OPT)) {
+ } else if (ptr != NULL && (*cs & OPT)) {
/* it was aoptional so no match is ok */
return (ptr);
- } else if (ptr != NIL) {
+ } else if (ptr != NULL) {
/* not optional and we still matched */
- return (NIL);
+ return (NULL);
}
if (*s1 == '\\')
- _escaped = _escaped ? FALSE : TRUE;
+ _escaped = _escaped ? false : true;
else
- _escaped = FALSE;
+ _escaped = false;
} while (*s1++);
- return (NIL);
+ return (NULL);
/* fail if we are currently _escaped */
case 'e':
if (_escaped)
- return(NIL);
+ return(NULL);
cs = MNEXT(cs);
break;
@@ -538,7 +535,7 @@ expmatch (s, re, mstring)
} else
/* no match, error return */
- return (NIL);
+ return (NULL);
break;
/* check for end of line */
@@ -562,7 +559,7 @@ expmatch (s, re, mstring)
} else
/* no match, error return */
- return (NIL);
+ return (NULL);
break;
/* check for start of line */
@@ -585,7 +582,7 @@ expmatch (s, re, mstring)
} else
/* no match, error return */
- return (NIL);
+ return (NULL);
break;
/* end of a subexpression, return success */
diff --git a/usr.bin/vgrind/vfontedpr.c b/usr.bin/vgrind/vfontedpr.c
index 5baaec0..ec0b4e0 100644
--- a/usr.bin/vgrind/vfontedpr.c
+++ b/usr.bin/vgrind/vfontedpr.c
@@ -47,14 +47,12 @@ static const char sccsid[] = "@(#)vfontedpr.c 8.1 (Berkeley) 6/6/93";
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#include <string.h>
#include <time.h>
#include "pathnames.h"
#include "extern.h"
-#define FALSE 0
-#define TRUE !(FALSE)
-#define NIL 0
#define STANDARD 0
#define ALTERNATE 1
@@ -70,8 +68,8 @@ static const char sccsid[] = "@(#)vfontedpr.c 8.1 (Berkeley) 6/6/93";
#define PSMAX 20 /* size of procedure name stacking */
static int iskw(char *);
-static boolean isproc(char *);
-static void putKcp(char *, char *, boolean);
+static bool isproc(char *);
+static void putKcp(char *, char *, bool);
static void putScp(char *);
static void putcp(int);
static int tabs(char *, char *);
@@ -81,13 +79,13 @@ static int width(char *, char *);
* The state variables
*/
-static boolean filter = FALSE; /* act as a filter (like eqn) */
-static boolean inchr; /* in a string constant */
-static boolean incomm; /* in a comment of the primary type */
-static boolean idx = FALSE; /* form an index */
-static boolean instr; /* in a string constant */
-static boolean nokeyw = FALSE; /* no keywords being flagged */
-static boolean pass = FALSE; /*
+static bool filter = false; /* act as a filter (like eqn) */
+static bool inchr; /* in a string constant */
+static bool incomm; /* in a comment of the primary type */
+static bool idx = false; /* form an index */
+static bool instr; /* in a string constant */
+static bool nokeyw = false; /* no keywords being flagged */
+static bool pass = false; /*
* when acting as a filter, pass indicates
* whether we are currently processing
* input.
@@ -100,7 +98,7 @@ static char * defsfile[2] = { _PATH_VGRINDEFS, 0 };
static int margin;
static int plstack[PSMAX]; /* the procedure nesting level stack */
static char pname[BUFSIZ+1];
-static boolean prccont; /* continue last procedure */
+static bool prccont; /* continue last procedure */
static int psptr; /* the stack index of the current procedure */
static char pstack[PSMAX][PNAMELEN+1]; /* the procedure name stack */
@@ -122,15 +120,15 @@ char *l_nocom; /* regexp for non-comments */
char *l_prcbeg; /* regular expr for procedure begin */
char *l_strbeg; /* delimiter for string constant */
char *l_strend; /* delimiter for string constant */
-boolean l_toplex; /* procedures only defined at top lex level */
+bool l_toplex; /* procedures only defined at top lex level */
const char *language = "c"; /* the language indicator */
#define ps(x) printf("%s", x)
+static char minus[] = "-";
+static char minusn[] = "-n";
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char **argv)
{
const char *fname = "";
struct stat stbuf;
@@ -160,9 +158,9 @@ main(argc, argv)
/* act as a filter like eqn */
if (!strcmp(argv[0], "-f")) {
- filter++;
+ filter = true;
argv[0] = argv[argc-1];
- argv[argc-1] = strdup("-");
+ argv[argc-1] = minus;
continue;
}
@@ -174,13 +172,13 @@ main(argc, argv)
/* build an index */
if (!strcmp(argv[0], "-x")) {
- idx++;
- argv[0] = strdup("-n");
+ idx = true;
+ argv[0] = minusn;
}
/* indicate no keywords */
if (!strcmp(argv[0], "-n")) {
- nokeyw++;
+ nokeyw = true;
argc--, argv++;
continue;
}
@@ -227,17 +225,17 @@ main(argc, argv)
i = cgetent(&defs, defsfile, language);
if (i == -1) {
fprintf (stderr, "no entry for language %s\n", language);
- exit (0);
+ exit(0);
} else if (i == -2) { fprintf(stderr,
"cannot find vgrindefs file %s\n", defsfile[0]);
- exit (0);
+ exit(0);
} else if (i == -3) { fprintf(stderr,
"potential reference loop detected in vgrindefs file %s\n",
defsfile[0]);
exit(0);
}
if (cgetustr(defs, "kw", &cp) == -1)
- nokeyw = TRUE;
+ nokeyw = true;
else {
char **cpp;
@@ -250,7 +248,7 @@ main(argc, argv)
while (*cp != ' ' && *cp != '\t' && *cp)
cp++;
}
- *cpp = NIL;
+ *cpp = NULL;
}
cgetustr(defs, "pb", &cp);
l_prcbeg = convexp(cp);
@@ -282,10 +280,10 @@ main(argc, argv)
/* initialize the program */
- incomm = FALSE;
- instr = FALSE;
- inchr = FALSE;
- _escaped = FALSE;
+ incomm = false;
+ instr = false;
+ inchr = false;
+ _escaped = false;
blklevel = 0;
for (psptr=0; psptr<PSMAX; psptr++) {
pstack[psptr][0] = '\0';
@@ -321,12 +319,12 @@ main(argc, argv)
if (buf[0] == '.') {
printf("%s", buf);
if (!strncmp (buf+1, "vS", 2))
- pass = TRUE;
+ pass = true;
if (!strncmp (buf+1, "vE", 2))
- pass = FALSE;
+ pass = false;
continue;
}
- prccont = FALSE;
+ prccont = false;
if (!filter || pass)
putScp(buf);
else
@@ -349,8 +347,7 @@ main(argc, argv)
#define isidchr(c) (isalnum(c) || (c) == '_')
static void
-putScp(os)
- char *os;
+putScp(char *os)
{
register char *s = os; /* pointer to unmatched string */
char dummy[BUFSIZ]; /* dummy to be used by expmatch */
@@ -363,7 +360,7 @@ putScp(os)
char *nocomptr; /* end of a non-comment delimiter */
s_start = os; /* remember the start for expmatch */
- _escaped = FALSE;
+ _escaped = false;
if (nokeyw || incomm || instr)
goto skip;
if (isproc(s)) {
@@ -382,82 +379,82 @@ skip:
/* check for string, comment, blockstart, etc */
if (!incomm && !instr && !inchr) {
- blkeptr = expmatch (s, l_blkend, dummy);
- blksptr = expmatch (s, l_blkbeg, dummy);
- comptr = expmatch (s, l_combeg, dummy);
- acmptr = expmatch (s, l_acmbeg, dummy);
- strptr = expmatch (s, l_strbeg, dummy);
- chrptr = expmatch (s, l_chrbeg, dummy);
+ blkeptr = expmatch(s, l_blkend, dummy);
+ blksptr = expmatch(s, l_blkbeg, dummy);
+ comptr = expmatch(s, l_combeg, dummy);
+ acmptr = expmatch(s, l_acmbeg, dummy);
+ strptr = expmatch(s, l_strbeg, dummy);
+ chrptr = expmatch(s, l_chrbeg, dummy);
nocomptr = expmatch (s, l_nocom, dummy);
/* start of non-comment? */
- if (nocomptr != NIL)
- if ((nocomptr <= comptr || comptr == NIL)
- && (nocomptr <= acmptr || acmptr == NIL)) {
+ if (nocomptr != NULL)
+ if ((nocomptr <= comptr || comptr == NULL)
+ && (nocomptr <= acmptr || acmptr == NULL)) {
/* continue after non-comment */
- putKcp (s, nocomptr-1, FALSE);
+ putKcp (s, nocomptr-1, false);
s = nocomptr;
continue;
}
/* start of a comment? */
- if (comptr != NIL)
- if ((comptr < strptr || strptr == NIL)
- && (comptr < acmptr || acmptr == NIL)
- && (comptr < chrptr || chrptr == NIL)
- && (comptr < blksptr || blksptr == NIL)
- && (comptr < blkeptr || blkeptr == NIL)) {
- putKcp (s, comptr-1, FALSE);
+ if (comptr != NULL)
+ if ((comptr < strptr || strptr == NULL)
+ && (comptr < acmptr || acmptr == NULL)
+ && (comptr < chrptr || chrptr == NULL)
+ && (comptr < blksptr || blksptr == NULL)
+ && (comptr < blkeptr || blkeptr == NULL)) {
+ putKcp(s, comptr-1, false);
s = comptr;
- incomm = TRUE;
+ incomm = true;
comtype = STANDARD;
if (s != os)
- ps ("\\c");
- ps ("\\c\n'+C\n");
+ ps("\\c");
+ ps("\\c\n'+C\n");
continue;
}
/* start of a comment? */
- if (acmptr != NIL)
- if ((acmptr < strptr || strptr == NIL)
- && (acmptr < chrptr || chrptr == NIL)
- && (acmptr < blksptr || blksptr == NIL)
- && (acmptr < blkeptr || blkeptr == NIL)) {
- putKcp (s, acmptr-1, FALSE);
+ if (acmptr != NULL)
+ if ((acmptr < strptr || strptr == NULL)
+ && (acmptr < chrptr || chrptr == NULL)
+ && (acmptr < blksptr || blksptr == NULL)
+ && (acmptr < blkeptr || blkeptr == NULL)) {
+ putKcp(s, acmptr-1, false);
s = acmptr;
- incomm = TRUE;
+ incomm = true;
comtype = ALTERNATE;
if (s != os)
- ps ("\\c");
- ps ("\\c\n'+C\n");
+ ps("\\c");
+ ps("\\c\n'+C\n");
continue;
}
/* start of a string? */
- if (strptr != NIL)
- if ((strptr < chrptr || chrptr == NIL)
- && (strptr < blksptr || blksptr == NIL)
- && (strptr < blkeptr || blkeptr == NIL)) {
- putKcp (s, strptr-1, FALSE);
+ if (strptr != NULL)
+ if ((strptr < chrptr || chrptr == NULL)
+ && (strptr < blksptr || blksptr == NULL)
+ && (strptr < blkeptr || blkeptr == NULL)) {
+ putKcp(s, strptr-1, false);
s = strptr;
- instr = TRUE;
+ instr = true;
continue;
}
/* start of a character string? */
- if (chrptr != NIL)
- if ((chrptr < blksptr || blksptr == NIL)
- && (chrptr < blkeptr || blkeptr == NIL)) {
- putKcp (s, chrptr-1, FALSE);
+ if (chrptr != NULL)
+ if ((chrptr < blksptr || blksptr == NULL)
+ && (chrptr < blkeptr || blkeptr == NULL)) {
+ putKcp(s, chrptr-1, false);
s = chrptr;
- inchr = TRUE;
+ inchr = true;
continue;
}
/* end of a lexical block */
- if (blkeptr != NIL) {
- if (blkeptr < blksptr || blksptr == NIL) {
- putKcp (s, blkeptr - 1, FALSE);
+ if (blkeptr != NULL) {
+ if (blkeptr < blksptr || blksptr == NULL) {
+ putKcp(s, blkeptr - 1, false);
s = blkeptr;
if (blklevel > 0 /* sanity */)
blklevel--;
@@ -465,13 +462,13 @@ skip:
/* end of current procedure */
if (s != os)
- ps ("\\c");
- ps ("\\c\n'-F\n");
+ ps("\\c");
+ ps("\\c\n'-F\n");
blklevel = plstack[psptr];
/* see if we should print the last proc name */
if (--psptr >= 0)
- prccont = TRUE;
+ prccont = true;
else
psptr = -1;
}
@@ -480,8 +477,8 @@ skip:
}
/* start of a lexical block */
- if (blksptr != NIL) {
- putKcp (s, blksptr - 1, FALSE);
+ if (blksptr != NULL) {
+ putKcp(s, blksptr - 1, false);
s = blksptr;
blklevel++;
continue;
@@ -489,64 +486,66 @@ skip:
/* check for end of comment */
} else if (incomm) {
- comptr = expmatch (s, l_comend, dummy);
- acmptr = expmatch (s, l_acmend, dummy);
- if (((comtype == STANDARD) && (comptr != NIL)) ||
- ((comtype == ALTERNATE) && (acmptr != NIL))) {
+ comptr = expmatch(s, l_comend, dummy);
+ acmptr = expmatch(s, l_acmend, dummy);
+ if (((comtype == STANDARD) && (comptr != NULL)) ||
+ ((comtype == ALTERNATE) && (acmptr != NULL))) {
if (comtype == STANDARD) {
- putKcp (s, comptr-1, TRUE);
+ putKcp(s, comptr-1, true);
s = comptr;
} else {
- putKcp (s, acmptr-1, TRUE);
+ putKcp(s, acmptr-1, true);
s = acmptr;
}
- incomm = FALSE;
+ incomm = false;
ps("\\c\n'-C\n");
continue;
} else {
- putKcp (s, s + strlen(s) -1, TRUE);
+ putKcp(s, s + strlen(s) -1, true);
s = s + strlen(s);
continue;
}
/* check for end of string */
} else if (instr) {
- if ((strptr = expmatch (s, l_strend, dummy)) != NIL) {
- putKcp (s, strptr-1, TRUE);
+ if ((strptr = expmatch(s, l_strend, dummy)) != NULL) {
+ putKcp(s, strptr-1, true);
s = strptr;
- instr = FALSE;
+ instr = false;
continue;
} else {
- putKcp (s, s+strlen(s)-1, TRUE);
+ putKcp(s, s+strlen(s)-1, true);
s = s + strlen(s);
continue;
}
/* check for end of character string */
} else if (inchr) {
- if ((chrptr = expmatch (s, l_chrend, dummy)) != NIL) {
- putKcp (s, chrptr-1, TRUE);
+ if ((chrptr = expmatch(s, l_chrend, dummy)) != NULL) {
+ putKcp(s, chrptr-1, true);
s = chrptr;
- inchr = FALSE;
+ inchr = false;
continue;
} else {
- putKcp (s, s+strlen(s)-1, TRUE);
+ putKcp(s, s+strlen(s)-1, true);
s = s + strlen(s);
continue;
}
}
/* print out the line */
- putKcp (s, s + strlen(s) -1, FALSE);
+ putKcp(s, s + strlen(s) -1, false);
s = s + strlen(s);
} while (*s);
}
+/*
+ * start: start of string to write
+ * end: end of string to write
+ * force: true if we should force nokeyw
+ */
static void
-putKcp (start, end, force)
- char *start; /* start of string to write */
- char *end; /* end of string to write */
- boolean force; /* true if we should force nokeyw */
+putKcp(char *start, char *end, bool force)
{
int i;
int xfld = 0;
@@ -587,22 +586,20 @@ putKcp (start, end, force)
}
}
- putcp ((unsigned char)*start++);
+ putcp((unsigned char)*start++);
}
}
static int
-tabs(s, os)
- char *s, *os;
+tabs(char *s, char *os)
{
return (width(s, os) / 8);
}
static int
-width(s, os)
- register char *s, *os;
+width(register char *s, register char *os)
{
register int i = 0;
@@ -622,8 +619,7 @@ width(s, os)
}
static void
-putcp(c)
- register int c;
+putcp(register int c)
{
switch(c) {
@@ -689,16 +685,15 @@ putcp(c)
/*
* look for a process beginning on this line
*/
-static boolean
-isproc(s)
- char *s;
+static bool
+isproc(char *s)
{
pname[0] = '\0';
if (!l_toplex || blklevel == 0)
- if (expmatch (s, l_prcbeg, pname) != NIL) {
- return (TRUE);
+ if (expmatch(s, l_prcbeg, pname) != NULL) {
+ return (true);
}
- return (FALSE);
+ return (false);
}
@@ -706,8 +701,7 @@ isproc(s)
*/
static int
-iskw(s)
- register char *s;
+iskw(register char *s)
{
register char **ss = l_keywds;
register int i = 1;
@@ -720,4 +714,3 @@ iskw(s)
return (i);
return (0);
}
-
diff --git a/usr.bin/vgrind/vgrindefs.c b/usr.bin/vgrind/vgrindefs.c
index b811c2c..c48a048 100644
--- a/usr.bin/vgrind/vgrindefs.c
+++ b/usr.bin/vgrind/vgrindefs.c
@@ -55,30 +55,30 @@ __FBSDID("$FreeBSD$");
static char *tbuf;
static char *filename;
static int hopcount; /* detect infinite loops in termcap, init 0 */
-char *tskip();
-char *tgetstr();
-char *tdecode();
-char *getenv();
+
+static int tnchktc(void);
+static int tnamatch(char *);
+static char *tskip(register char *);
+static char *tdecode(register char *, char **);
/*
* Get an entry for terminal name in buffer bp,
* from the termcap file. Parse is very rudimentary;
* we just notice escaped newlines.
*/
-tgetent(bp, name, file)
- char *bp, *name, *file;
+int
+tgetent(char *bp, char *name, char *file)
{
register char *cp;
register int c;
register int i = 0, cnt = 0;
char ibuf[BUFSIZ];
- char *cp2;
int tf;
tbuf = bp;
tf = 0;
filename = file;
- tf = open(filename, 0);
+ tf = open(filename, O_RDONLY);
if (tf < 0)
return (-1);
for (;;) {
@@ -125,7 +125,8 @@ tgetent(bp, name, file)
* entries to say "like an HP2621 but doesn't turn on the labels".
* Note that this works because of the left to right scan.
*/
-tnchktc()
+static int
+tnchktc(void)
{
register char *p, *q;
char tcname[16]; /* name of similar terminal */
@@ -143,7 +144,7 @@ tnchktc()
/* p now points to beginning of last field */
if (p[0] != 't' || p[1] != 'c')
return(1);
- strcpy(tcname,p+3);
+ strlcpy(tcname, p+3, 16);
q = tcname;
while (q && *q != ':')
q++;
@@ -161,7 +162,7 @@ tnchktc()
write(STDERR_FILENO, "Vgrind entry too long\n", 23);
q[BUFSIZ - (p-tbuf)] = 0;
}
- strcpy(p, q+1);
+ strlcpy(p, q+1, BUFSIZ - (p - holdtbuf));
tbuf = holdtbuf;
return(1);
}
@@ -172,8 +173,8 @@ tnchktc()
* against each such name. The normal : terminator after the last
* name (before the first field) stops us.
*/
-tnamatch(np)
- char *np;
+static int
+tnamatch(char *np)
{
register char *Np, *Bp;
@@ -199,8 +200,7 @@ tnamatch(np)
* into the termcap file in octal.
*/
static char *
-tskip(bp)
- register char *bp;
+tskip(register char *bp)
{
while (*bp && *bp != ':')
@@ -218,8 +218,8 @@ tskip(bp)
* a # character. If the option is not found we return -1.
* Note that we handle octal numbers beginning with 0.
*/
-tgetnum(id)
- char *id;
+int
+tgetnum(char *id)
{
register int i, base;
register char *bp = tbuf;
@@ -251,8 +251,8 @@ tgetnum(id)
* of the buffer. Return 1 if we find the option, or 0 if it is
* not given.
*/
-tgetflag(id)
- char *id;
+int
+tgetflag(char *id)
{
register char *bp = tbuf;
@@ -278,8 +278,7 @@ tgetflag(id)
* No checking on area overflow.
*/
char *
-tgetstr(id, area)
- char *id, **area;
+tgetstr(char *id, char **area)
{
register char *bp = tbuf;
@@ -303,13 +302,10 @@ tgetstr(id, area)
* string capability escapes.
*/
static char *
-tdecode(str, area)
- register char *str;
- char **area;
+tdecode(register char *str, char **area)
{
register char *cp;
register int c;
- int i;
cp = *area;
while (c = *str++) {
diff --git a/usr.bin/vtfontcvt/vtfontcvt.c b/usr.bin/vtfontcvt/vtfontcvt.c
index 21c519b..07c3547 100644
--- a/usr.bin/vtfontcvt/vtfontcvt.c
+++ b/usr.bin/vtfontcvt/vtfontcvt.c
@@ -473,24 +473,24 @@ print_font_info(void)
{
printf(
"Statistics:\n"
-"- glyph_total: %5u\n"
-"- glyph_normal: %5u\n"
-"- glyph_normal_right: %5u\n"
-"- glyph_bold: %5u\n"
-"- glyph_bold_right: %5u\n"
-"- glyph_unique: %5u\n"
-"- glyph_dupe: %5u\n"
-"- mapping_total: %5u\n"
-"- mapping_normal: %5u\n"
-"- mapping_normal_folded: %5u\n"
-"- mapping_normal_right: %5u\n"
-"- mapping_normal_right_folded: %5u\n"
-"- mapping_bold: %5u\n"
-"- mapping_bold_folded: %5u\n"
-"- mapping_bold_right: %5u\n"
-"- mapping_bold_right_folded: %5u\n"
-"- mapping_unique: %5u\n"
-"- mapping_dupe: %5u\n",
+"- glyph_total: %6u\n"
+"- glyph_normal: %6u\n"
+"- glyph_normal_right: %6u\n"
+"- glyph_bold: %6u\n"
+"- glyph_bold_right: %6u\n"
+"- glyph_unique: %6u\n"
+"- glyph_dupe: %6u\n"
+"- mapping_total: %6u\n"
+"- mapping_normal: %6u\n"
+"- mapping_normal_folded: %6u\n"
+"- mapping_normal_right: %6u\n"
+"- mapping_normal_right_folded: %6u\n"
+"- mapping_bold: %6u\n"
+"- mapping_bold_folded: %6u\n"
+"- mapping_bold_right: %6u\n"
+"- mapping_bold_right_folded: %6u\n"
+"- mapping_unique: %6u\n"
+"- mapping_dupe: %6u\n",
glyph_total,
glyph_count[0],
glyph_count[1],
diff --git a/usr.bin/whois/whois.1 b/usr.bin/whois/whois.1
index 0f0f177..a9ed50a 100644
--- a/usr.bin/whois/whois.1
+++ b/usr.bin/whois/whois.1
@@ -28,7 +28,7 @@
.\" From: @(#)whois.1 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
-.Dd October 2, 2009
+.Dd May 14, 2015
.Dt WHOIS 1
.Os
.Sh NAME
@@ -36,7 +36,7 @@
.Nd "Internet domain name and network number directory service"
.Sh SYNOPSIS
.Nm
-.Op Fl aAbfgiIklmQrR
+.Op Fl aAbfgiIklmPQr
.Op Fl c Ar country-code | Fl h Ar host
.Op Fl p Ar port
.Ar name ...
@@ -47,6 +47,42 @@ utility looks up records in the databases maintained by several
Network Information Centers
.Pq Tn NICs .
.Pp
+By default
+.Nm
+automatically discovers the name of a whois server to use
+from the top-level domain
+.Pq Tn TLD
+of the supplied (single) argument.
+It tries
+.Qq Va TLD Ns Li .whois-servers.net
+and
+.Qq Li whois.nic. Ns Va TLD
+and if neither host exists it falls back to its default server.
+.Pp
+If an IP address is specified, the whois server will default to
+the American Registry for Internet Numbers
+.Pq Tn ARIN .
+If a query to
+.Tn ARIN
+references
+.Tn APNIC , AfriNIC , LACNIC ,
+or
+.Tn RIPE ,
+that server will be queried also, provided that the
+.Fl Q
+option is not specified.
+.Pp
+If
+.Nm
+cannot automatically discover a server,
+it will fall back to
+the host specified in the
+.Ev WHOIS_SERVER
+or
+.Ev RA_SERVER
+environment variables, or if those are not set, it will use
+.Pa whois.crsnic.net .
+.Pp
The options are as follows:
.Bl -tag -width indent
.It Fl a
@@ -88,66 +124,12 @@ Use the US non-military federal government database, which contains points of
contact for subdomains of
.Pa .GOV .
.It Fl h Ar host
-Use the specified host instead of the default variant.
+Use the specified host instead of the default.
Either a host name or an IP address may be specified.
-.Pp
-By default
-.Nm
-constructs the name of a whois server to use from the top-level domain
-.Pq Tn TLD
-of the supplied (single) argument, and appending
-.Qq Li .whois-servers.net .
-This effectively allows a suitable whois server to be selected
-automatically for a large number of
-.Tn TLDs .
-.Pp
-In the event that an IP
-address is specified, the whois server will default to the American
-Registry for Internet Numbers
-.Pq Tn ARIN .
-If a query to
-.Tn ARIN
-references
-.Tn APNIC , AfriNIC , LACNIC ,
-or
-.Tn RIPE ,
-that server will be queried also, provided that the
-.Fl Q
-option is not specified.
-.Pp
-If the query is not a domain name or IP address,
-.Nm
-will fall back to
-.Pa whois.crsnic.net .
.It Fl i
-Use the Network Solutions Registry for Internet Numbers
+Use the obsolete Network Solutions Registry for Internet Numbers
.Pq Pa whois.networksolutions.com
database.
-It contains network numbers and domain contact information for most of
-.Pa .COM , .NET , .ORG
-and
-.Pa .EDU
-domains.
-.Pp
-.Sy NOTE !
-The registration of these domains is now done by a number of
-independent and competing registrars and this database holds no information
-on the domains registered by organizations other than Network Solutions, Inc.
-Also, note that the
-.Tn InterNIC
-database
-.Pq Pa whois.internic.net
-is no longer handled by Network Solutions, Inc.
-For details, see
-.Pa http://www.internic.net/ .
-.Pp
-(Hint: Contact information, identified by the term
-.Em handle ,
-can be looked up by prefixing
-.Qq Li "handle "
-to the
-.Tn NIC
-handle in the query.)
.It Fl I
Use the Internet Assigned Numbers Authority
.Pq Tn IANA
@@ -177,6 +159,10 @@ Connect to the whois server on
If this option is not specified,
.Nm
defaults to port 43.
+.It Fl P
+Use the PeeringDB database of AS numbers.
+It contains details about presence at internet peering points
+for many network operators.
.It Fl Q
Do a quick lookup.
This means that
@@ -190,24 +176,28 @@ Use the R\(aaeseaux IP Europ\(aaeens
database.
It contains network numbers and domain contact information
for Europe.
-.It Fl R
-Use the Russia Network Information Center
-.Pq Tn RIPN
-database.
-It contains network numbers and domain contact information
-for subdomains of
-.Pa .RU .
-This option is deprecated; use the
-.Fl c
-option with an argument of
-.Qq Li RU
-instead.
.El
.Pp
The operands specified to
.Nm
are treated independently and may be used
as queries on different whois servers.
+.Sh ENVIRONMENT
+.Bl -tag
+.It Ev WHOIS_SERVER
+The primary default whois server.
+If this is unset,
+.Nm
+uses the
+.Ev RA_SERVER
+environment variable.
+.It Ev RA_SERVER
+The secondary default whois server.
+If this is unset,
+.Nm
+will use
+.Pa whois.crsnic.net .
+.El
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
diff --git a/usr.bin/whois/whois.c b/usr.bin/whois/whois.c
index 98b0226..6ad8826 100644
--- a/usr.bin/whois/whois.c
+++ b/usr.bin/whois/whois.c
@@ -60,22 +60,25 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#define ABUSEHOST "whois.abuse.net"
-#define NICHOST "whois.crsnic.net"
-#define INICHOST "whois.networksolutions.com"
-#define GNICHOST "whois.nic.gov"
#define ANICHOST "whois.arin.net"
-#define LNICHOST "whois.lacnic.net"
+#define BNICHOST "whois.registro.br"
+#define FNICHOST "whois.afrinic.net"
+#define GERMNICHOST "de.whois-servers.net"
+#define GNICHOST "whois.nic.gov"
+#define IANAHOST "whois.iana.org"
+#define INICHOST "whois.networksolutions.com"
#define KNICHOST "whois.krnic.net"
-#define RNICHOST "whois.ripe.net"
-#define PNICHOST "whois.apnic.net"
+#define LNICHOST "whois.lacnic.net"
#define MNICHOST "whois.ra.net"
+#define NICHOST "whois.crsnic.net"
+#define PDBHOST "whois.peeringdb.com"
+#define PNICHOST "whois.apnic.net"
+#define QNICHOST_HEAD "whois.nic."
#define QNICHOST_TAIL ".whois-servers.net"
-#define BNICHOST "whois.registro.br"
-#define NORIDHOST "whois.norid.no"
-#define IANAHOST "whois.iana.org"
-#define GERMNICHOST "de.whois-servers.net"
-#define FNICHOST "whois.afrinic.net"
+#define RNICHOST "whois.ripe.net"
+
#define DEFAULT_PORT "whois"
+
#define WHOIS_SERVER_ID "Whois Server: "
#define WHOIS_ORG_SERVER_ID "Registrant Street1:Whois Server:"
@@ -84,12 +87,25 @@ __FBSDID("$FreeBSD$");
#define ishost(h) (isalnum((unsigned char)h) || h == '.' || h == '-')
+static struct {
+ const char *suffix, *server;
+} whoiswhere[] = {
+ /* Various handles */
+ { "-ARIN", ANICHOST },
+ { "-NICAT", "at" QNICHOST_TAIL },
+ { "-NORID", "no" QNICHOST_TAIL },
+ { "-RIPE", RNICHOST },
+ /* Nominet's whois server doesn't return referrals to JANET */
+ { ".ac.uk", "ac.uk" QNICHOST_TAIL },
+ { NULL, NULL }
+};
+
static const char *ip_whois[] = { LNICHOST, RNICHOST, PNICHOST, BNICHOST,
FNICHOST, NULL };
static const char *port = DEFAULT_PORT;
static char *choose_server(char *);
-static struct addrinfo *gethostinfo(char const *host, int exit_on_error);
+static struct addrinfo *gethostinfo(char const *host, int exitnoname);
static void s_asprintf(char **ret, const char *format, ...) __printflike(2, 3);
static void usage(void);
static void whois(const char *, const char *, int);
@@ -107,7 +123,7 @@ main(int argc, char *argv[])
country = host = qnichost = NULL;
flags = use_qnichost = 0;
- while ((ch = getopt(argc, argv, "aAbc:fgh:iIklmp:QrR6")) != -1) {
+ while ((ch = getopt(argc, argv, "aAbc:fgh:iIklmp:PQr")) != -1) {
switch (ch) {
case 'a':
host = ANICHOST;
@@ -148,21 +164,15 @@ main(int argc, char *argv[])
case 'p':
port = optarg;
break;
+ case 'P':
+ host = PDBHOST;
+ break;
case 'Q':
flags |= WHOIS_QUICK;
break;
case 'r':
host = RNICHOST;
break;
- case 'R':
- warnx("-R is deprecated; use '-c ru' instead");
- country = "ru";
- break;
- /* Remove in FreeBSD 10 */
- case '6':
- errx(EX_USAGE,
- "-6 is deprecated; use -[aAflr] instead");
- break;
case '?':
default:
usage();
@@ -176,13 +186,12 @@ main(int argc, char *argv[])
usage();
/*
- * If no host or country is specified determine the top level domain
- * from the query. If the TLD is a number, query ARIN. Otherwise, use
- * TLD.whois-server.net. If the domain does not contain '.', fall
- * back to NICHOST.
+ * If no host or country is specified, try to determine the top
+ * level domain from the query, or fall back to NICHOST.
*/
if (host == NULL && country == NULL) {
- if ((host = getenv("RA_SERVER")) == NULL) {
+ if ((host = getenv("WHOIS_SERVER")) == NULL &&
+ (host = getenv("RA_SERVER")) == NULL) {
use_qnichost = 1;
host = NICHOST;
if (!(flags & WHOIS_QUICK))
@@ -210,39 +219,67 @@ main(int argc, char *argv[])
* returns a pointer to newly allocated memory containing the whois server to
* be queried, or a NULL if the correct server couldn't be determined. The
* caller must remember to free(3) the allocated memory.
+ *
+ * If the domain is an IPv6 address or has a known suffix, that determines
+ * the server, else if the TLD is a number, query ARIN, else try a couple of
+ * formulaic server names. Fail if the domain does not contain '.'.
*/
static char *
choose_server(char *domain)
{
char *pos, *retval;
+ int i;
+ struct addrinfo *res;
if (strchr(domain, ':')) {
s_asprintf(&retval, "%s", ANICHOST);
return (retval);
}
- for (pos = strchr(domain, '\0'); pos > domain && *--pos == '.';)
- *pos = '\0';
+ for (pos = strchr(domain, '\0'); pos > domain && pos[-1] == '.';)
+ *--pos = '\0';
if (*domain == '\0')
errx(EX_USAGE, "can't search for a null string");
- if (strlen(domain) > sizeof("-NORID")-1 &&
- strcasecmp(domain + strlen(domain) - sizeof("-NORID") + 1,
- "-NORID") == 0) {
- s_asprintf(&retval, "%s", NORIDHOST);
- return (retval);
+ for (i = 0; whoiswhere[i].suffix != NULL; i++) {
+ size_t suffix_len = strlen(whoiswhere[i].suffix);
+ if (domain + suffix_len < pos &&
+ strcasecmp(pos - suffix_len, whoiswhere[i].suffix) == 0) {
+ s_asprintf(&retval, "%s", whoiswhere[i].server);
+ return (retval);
+ }
}
while (pos > domain && *pos != '.')
--pos;
if (pos <= domain)
return (NULL);
- if (isdigit((unsigned char)*++pos))
+ if (isdigit((unsigned char)*++pos)) {
s_asprintf(&retval, "%s", ANICHOST);
- else
- s_asprintf(&retval, "%s%s", pos, QNICHOST_TAIL);
- return (retval);
+ return (retval);
+ }
+ /* Try possible alternative whois server name formulae. */
+ for (i = 0; ; ++i) {
+ switch (i) {
+ case 0:
+ s_asprintf(&retval, "%s%s", pos, QNICHOST_TAIL);
+ break;
+ case 1:
+ s_asprintf(&retval, "%s%s", QNICHOST_HEAD, pos);
+ break;
+ default:
+ return (NULL);
+ }
+ res = gethostinfo(retval, 0);
+ if (res) {
+ freeaddrinfo(res);
+ return (retval);
+ } else {
+ free(retval);
+ continue;
+ }
+ }
}
static struct addrinfo *
-gethostinfo(char const *host, int exit_on_error)
+gethostinfo(char const *host, int exit_on_noname)
{
struct addrinfo hints, *res;
int error;
@@ -251,13 +288,10 @@ gethostinfo(char const *host, int exit_on_error)
hints.ai_flags = 0;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
+ res = NULL;
error = getaddrinfo(host, port, &hints, &res);
- if (error) {
- warnx("%s: %s", host, gai_strerror(error));
- if (exit_on_error)
- exit(EX_NOHOST);
- return (NULL);
- }
+ if (error && (exit_on_noname || error != EAI_NONAME))
+ err(EX_NOHOST, "%s: %s", host, gai_strerror(error));
return (res);
}
@@ -283,8 +317,9 @@ whois(const char *query, const char *hostname, int flags)
FILE *fp;
struct addrinfo *hostres, *res;
char *buf, *host, *nhost, *p;
- int i, j, s = -1, count;
- size_t c, len;
+ int s = -1, f;
+ nfds_t i, j;
+ size_t c, len, count;
struct pollfd *fds;
int timeout = 180;
@@ -402,9 +437,9 @@ done:
if (s != -1) {
/* Restore default blocking behavior. */
- if ((flags = fcntl(s, F_GETFL)) != -1) {
- flags &= ~O_NONBLOCK;
- if (fcntl(s, F_SETFL, flags) == -1)
+ if ((f = fcntl(s, F_GETFL)) != -1) {
+ f &= ~O_NONBLOCK;
+ if (fcntl(s, F_SETFL, f) == -1)
err(EX_OSERR, "fcntl()");
} else
err(EX_OSERR, "fcntl()");
@@ -480,7 +515,7 @@ static void
usage(void)
{
fprintf(stderr,
- "usage: whois [-aAbfgiIklmQrR6] [-c country-code | -h hostname] "
+ "usage: whois [-aAbfgiIklmPQr] [-c country-code | -h hostname] "
"[-p port] name ...\n");
exit(EX_USAGE);
}
diff --git a/usr.sbin/acpi/acpidb/acpidb.c b/usr.sbin/acpi/acpidb/acpidb.c
index f49420f..b3d0021 100644
--- a/usr.sbin/acpi/acpidb/acpidb.c
+++ b/usr.sbin/acpi/acpidb/acpidb.c
@@ -478,7 +478,7 @@ load_dsdt(const char *dsdtfile)
return (-1);
}
- AcpiDbGetTableFromFile(filetmp, NULL);
+ AcpiDbGetTableFromFile(filetmp, NULL, TRUE);
AcpiDbInitialize();
AcpiGbl_DebuggerConfiguration = 0;
diff --git a/usr.sbin/acpi/iasl/Makefile b/usr.sbin/acpi/iasl/Makefile
index 7f6a1bd..e9faad2 100644
--- a/usr.sbin/acpi/iasl/Makefile
+++ b/usr.sbin/acpi/iasl/Makefile
@@ -4,8 +4,8 @@ PROG= iasl
# common
SRCS= adfile.c adisasm.c adwalk.c ahids.c ahpredef.c \
- ahuuids.c cmfsize.c dmextern.c dmrestag.c dmtable.c \
- dmtbdump.c dmtbinfo.c getopt.c
+ ahtable.c ahuuids.c cmfsize.c dmextern.c dmrestag.c \
+ dmtable.c dmtbdump.c dmtbinfo.c getopt.c
# compiler
SRCS+= aslanalyze.c aslascii.c aslbtypes.c aslcodegen.c \
diff --git a/usr.sbin/bhyve/acpi.c b/usr.sbin/bhyve/acpi.c
index a5a6559..a9dd1cc 100644
--- a/usr.sbin/bhyve/acpi.c
+++ b/usr.sbin/bhyve/acpi.c
@@ -386,7 +386,7 @@ basl_fwrite_fadt(FILE *fp)
EFPRINTF(fp, "[0001]\t\tDuty Cycle Width : 00\n");
EFPRINTF(fp, "[0001]\t\tRTC Day Alarm Index : 00\n");
EFPRINTF(fp, "[0001]\t\tRTC Month Alarm Index : 00\n");
- EFPRINTF(fp, "[0001]\t\tRTC Century Index : 00\n");
+ EFPRINTF(fp, "[0001]\t\tRTC Century Index : 32\n");
EFPRINTF(fp, "[0002]\t\tBoot Flags (decoded below) : 0000\n");
EFPRINTF(fp, "\t\t\tLegacy Devices Supported (V2) : 0\n");
EFPRINTF(fp, "\t\t\t8042 Present on ports 60/64 (V2) : 0\n");
diff --git a/usr.sbin/bhyve/bhyve.8 b/usr.sbin/bhyve/bhyve.8
index e3cf36b..ee0f2ca 100644
--- a/usr.sbin/bhyve/bhyve.8
+++ b/usr.sbin/bhyve/bhyve.8
@@ -193,8 +193,13 @@ format.
.Pp
Block storage devices:
.Bl -tag -width 10n
-.It Pa /filename Ns Oo , Ns Li nocache Oc Ns Oo , Ns Li direct Oc Ns Oo , Ns Li ro Oc
-.It Pa /dev/xxx Ns Oo , Ns Ar nocache Oc Ns Oo , Ns Ar direct Oc Ns Oo , Ns Ar ro Oc
+.It Pa /filename Ns Oo , Ns Ar block-device-options Oc
+.It Pa /dev/xxx Ns Oo , Ns Ar block-device-options Oc
+.El
+.Pp
+The
+.Ar block-device-options
+are:
.Bl -tag -width 8n
.It Li nocache
Open the file with
@@ -204,14 +209,10 @@ Open the file using
.Dv O_SYNC .
.It Li ro
Force the file to be opened read-only.
-.El
-.Pp
-The
-.Li nocache ,
-.Li direct ,
-and
-.Li ro
-options are not available for virtio block devices.
+.It Li sectorsize= Ns Ar logical Ns Oo / Ns Ar physical Oc
+Specify the logical and physical sector sizes of the emulated disk.
+The physical sector size is optional and is equal to the logical sector size
+if not explicitly specified.
.El
.Pp
TTY devices:
diff --git a/usr.sbin/bhyve/block_if.c b/usr.sbin/bhyve/block_if.c
index bcb1617..ef8e11e 100644
--- a/usr.sbin/bhyve/block_if.c
+++ b/usr.sbin/bhyve/block_if.c
@@ -392,16 +392,18 @@ blockif_open(const char *optstr, const char *ident)
{
char tname[MAXCOMLEN + 1];
char name[MAXPATHLEN];
- char *nopt, *xopts;
+ char *nopt, *xopts, *cp;
struct blockif_ctxt *bc;
struct stat sbuf;
struct diocgattr_arg arg;
off_t size, psectsz, psectoff;
int extra, fd, i, sectsz;
- int nocache, sync, ro, candelete, geom;
+ int nocache, sync, ro, candelete, geom, ssopt, pssopt;
pthread_once(&blockif_once, blockif_init);
+ fd = -1;
+ ssopt = 0;
nocache = 0;
sync = 0;
ro = 0;
@@ -410,16 +412,25 @@ blockif_open(const char *optstr, const char *ident)
* The first element in the optstring is always a pathname.
* Optional elements follow
*/
- nopt = strdup(optstr);
- for (xopts = strtok(nopt, ",");
- xopts != NULL;
- xopts = strtok(NULL, ",")) {
- if (!strcmp(xopts, "nocache"))
+ nopt = xopts = strdup(optstr);
+ while (xopts != NULL) {
+ cp = strsep(&xopts, ",");
+ if (cp == nopt) /* file or device pathname */
+ continue;
+ else if (!strcmp(cp, "nocache"))
nocache = 1;
- else if (!strcmp(xopts, "sync"))
+ else if (!strcmp(cp, "sync") || !strcmp(cp, "direct"))
sync = 1;
- else if (!strcmp(xopts, "ro"))
+ else if (!strcmp(cp, "ro"))
ro = 1;
+ else if (sscanf(cp, "sectorsize=%d/%d", &ssopt, &pssopt) == 2)
+ ;
+ else if (sscanf(cp, "sectorsize=%d", &ssopt) == 1)
+ pssopt = ssopt;
+ else {
+ fprintf(stderr, "Invalid device option \"%s\"\n", cp);
+ goto err;
+ }
}
extra = 0;
@@ -437,13 +448,12 @@ blockif_open(const char *optstr, const char *ident)
if (fd < 0) {
perror("Could not open backing file");
- return (NULL);
+ goto err;
}
if (fstat(fd, &sbuf) < 0) {
perror("Could not stat backing file");
- close(fd);
- return (NULL);
+ goto err;
}
/*
@@ -457,8 +467,7 @@ blockif_open(const char *optstr, const char *ident)
if (ioctl(fd, DIOCGMEDIASIZE, &size) < 0 ||
ioctl(fd, DIOCGSECTORSIZE, &sectsz)) {
perror("Could not fetch dev blk/sector size");
- close(fd);
- return (NULL);
+ goto err;
}
assert(size != 0);
assert(sectsz != 0);
@@ -473,10 +482,39 @@ blockif_open(const char *optstr, const char *ident)
} else
psectsz = sbuf.st_blksize;
+ if (ssopt != 0) {
+ if (!powerof2(ssopt) || !powerof2(pssopt) || ssopt < 512 ||
+ ssopt > pssopt) {
+ fprintf(stderr, "Invalid sector size %d/%d\n",
+ ssopt, pssopt);
+ goto err;
+ }
+
+ /*
+ * Some backend drivers (e.g. cd0, ada0) require that the I/O
+ * size be a multiple of the device's sector size.
+ *
+ * Validate that the emulated sector size complies with this
+ * requirement.
+ */
+ if (S_ISCHR(sbuf.st_mode)) {
+ if (ssopt < sectsz || (ssopt % sectsz) != 0) {
+ fprintf(stderr, "Sector size %d incompatible "
+ "with underlying device sector size %d\n",
+ ssopt, sectsz);
+ goto err;
+ }
+ }
+
+ sectsz = ssopt;
+ psectsz = pssopt;
+ psectoff = 0;
+ }
+
bc = calloc(1, sizeof(struct blockif_ctxt));
if (bc == NULL) {
- close(fd);
- return (NULL);
+ perror("calloc");
+ goto err;
}
bc->bc_magic = BLOCKIF_SIG;
@@ -506,6 +544,10 @@ blockif_open(const char *optstr, const char *ident)
}
return (bc);
+err:
+ if (fd >= 0)
+ close(fd);
+ return (NULL);
}
static int
diff --git a/usr.sbin/bhyve/inout.c b/usr.sbin/bhyve/inout.c
index 402b953..929bb3c 100644
--- a/usr.sbin/bhyve/inout.c
+++ b/usr.sbin/bhyve/inout.c
@@ -107,7 +107,7 @@ emulate_inout(struct vmctx *ctx, int vcpu, struct vm_exit *vmexit, int strict)
uint32_t eax, val;
inout_func_t handler;
void *arg;
- int error, retval;
+ int error, fault, retval;
enum vm_reg_name idxreg;
uint64_t gla, index, iterations, count;
struct vm_inout_str *vis;
@@ -163,11 +163,11 @@ emulate_inout(struct vmctx *ctx, int vcpu, struct vm_exit *vmexit, int strict)
}
error = vm_copy_setup(ctx, vcpu, &vis->paging, gla,
- bytes, prot, iov, nitems(iov));
- if (error == -1) {
+ bytes, prot, iov, nitems(iov), &fault);
+ if (error) {
retval = -1; /* Unrecoverable error */
break;
- } else if (error == 1) {
+ } else if (fault) {
retval = 0; /* Resume guest to handle fault */
break;
}
diff --git a/usr.sbin/bhyve/pci_ahci.c b/usr.sbin/bhyve/pci_ahci.c
index 12540a1..35a0859 100644
--- a/usr.sbin/bhyve/pci_ahci.c
+++ b/usr.sbin/bhyve/pci_ahci.c
@@ -135,11 +135,13 @@ struct ahci_port {
char ident[20 + 1];
int atapi;
int reset;
+ int waitforclear;
int mult_sectors;
uint8_t xfermode;
uint8_t err_cfis[20];
uint8_t sense_key;
uint8_t asc;
+ u_int ccs;
uint32_t pending;
uint32_t clb;
@@ -204,6 +206,8 @@ struct pci_ahci_softc {
};
#define ahci_ctx(sc) ((sc)->asc_pi->pi_vmctx)
+static void ahci_handle_port(struct ahci_port *p);
+
static inline void lba_to_msf(uint8_t *buf, int lba)
{
lba += 150;
@@ -269,22 +273,26 @@ ahci_write_fis(struct ahci_port *p, enum sata_fis_type ft, uint8_t *fis)
case FIS_TYPE_REGD2H:
offset = 0x40;
len = 20;
- irq = AHCI_P_IX_DHR;
+ irq = (fis[1] & (1 << 6)) ? AHCI_P_IX_DHR : 0;
break;
case FIS_TYPE_SETDEVBITS:
offset = 0x58;
len = 8;
- irq = AHCI_P_IX_SDB;
+ irq = (fis[1] & (1 << 6)) ? AHCI_P_IX_SDB : 0;
break;
case FIS_TYPE_PIOSETUP:
offset = 0x20;
len = 20;
- irq = 0;
+ irq = (fis[1] & (1 << 6)) ? AHCI_P_IX_PS : 0;
break;
default:
WPRINTF("unsupported fis type %d\n", ft);
return;
}
+ if (fis[2] & ATA_S_ERROR) {
+ p->waitforclear = 1;
+ irq |= AHCI_P_IX_TFE;
+ }
memcpy(p->rfis + offset, fis, len);
if (irq) {
p->is |= irq;
@@ -309,22 +317,23 @@ ahci_write_fis_sdb(struct ahci_port *p, int slot, uint8_t *cfis, uint32_t tfd)
uint8_t error;
error = (tfd >> 8) & 0xff;
+ tfd &= 0x77;
memset(fis, 0, sizeof(fis));
fis[0] = FIS_TYPE_SETDEVBITS;
fis[1] = (1 << 6);
- fis[2] = tfd & 0x77;
+ fis[2] = tfd;
fis[3] = error;
if (fis[2] & ATA_S_ERROR) {
- p->is |= AHCI_P_IX_TFE;
p->err_cfis[0] = slot;
- p->err_cfis[2] = tfd & 0x77;
+ p->err_cfis[2] = tfd;
p->err_cfis[3] = error;
memcpy(&p->err_cfis[4], cfis + 4, 16);
} else {
*(uint32_t *)(fis + 4) = (1 << slot);
p->sact &= ~(1 << slot);
}
- p->tfd = tfd;
+ p->tfd &= ~0x77;
+ p->tfd |= tfd;
ahci_write_fis(p, FIS_TYPE_SETDEVBITS, fis);
}
@@ -351,7 +360,6 @@ ahci_write_fis_d2h(struct ahci_port *p, int slot, uint8_t *cfis, uint32_t tfd)
fis[12] = cfis[12];
fis[13] = cfis[13];
if (fis[2] & ATA_S_ERROR) {
- p->is |= AHCI_P_IX_TFE;
p->err_cfis[0] = 0x80;
p->err_cfis[2] = tfd & 0xff;
p->err_cfis[3] = error;
@@ -363,6 +371,21 @@ ahci_write_fis_d2h(struct ahci_port *p, int slot, uint8_t *cfis, uint32_t tfd)
}
static void
+ahci_write_fis_d2h_ncq(struct ahci_port *p, int slot)
+{
+ uint8_t fis[20];
+
+ p->tfd = ATA_S_READY | ATA_S_DSC;
+ memset(fis, 0, sizeof(fis));
+ fis[0] = FIS_TYPE_REGD2H;
+ fis[1] = 0; /* No interrupt */
+ fis[2] = p->tfd; /* Status */
+ fis[3] = 0; /* No error */
+ p->ci &= ~(1 << slot);
+ ahci_write_fis(p, FIS_TYPE_REGD2H, fis);
+}
+
+static void
ahci_write_reset_fis_d2h(struct ahci_port *p)
{
uint8_t fis[20];
@@ -389,9 +412,11 @@ ahci_check_stopped(struct ahci_port *p)
*/
if (!(p->cmd & AHCI_P_CMD_ST)) {
if (p->pending == 0) {
+ p->ccs = 0;
p->cmd &= ~(AHCI_P_CMD_CR | AHCI_P_CMD_CCS_MASK);
p->ci = 0;
p->sact = 0;
+ p->waitforclear = 0;
}
}
}
@@ -418,7 +443,8 @@ ahci_port_stop(struct ahci_port *p)
slot = aior->slot;
cfis = aior->cfis;
if (cfis[2] == ATA_WRITE_FPDMA_QUEUED ||
- cfis[2] == ATA_READ_FPDMA_QUEUED)
+ cfis[2] == ATA_READ_FPDMA_QUEUED ||
+ cfis[2] == ATA_SEND_FPDMA_QUEUED)
ncq = 1;
if (ncq)
@@ -489,6 +515,9 @@ ahci_reset(struct pci_ahci_softc *sc)
for (i = 0; i < sc->ports; i++) {
sc->port[i].ie = 0;
sc->port[i].is = 0;
+ sc->port[i].cmd = (AHCI_P_CMD_SUD | AHCI_P_CMD_POD);
+ if (sc->port[i].bctx)
+ sc->port[i].cmd |= AHCI_P_CMD_CPS;
sc->port[i].sctl = 0;
ahci_port_reset(&sc->port[i]);
}
@@ -585,12 +614,13 @@ ahci_handle_rw(struct ahci_port *p, int slot, uint8_t *cfis, uint32_t done)
struct ahci_cmd_hdr *hdr;
uint64_t lba;
uint32_t len;
- int err, ncq, readop;
+ int err, first, ncq, readop;
prdt = (struct ahci_prdt_entry *)(cfis + 0x80);
hdr = (struct ahci_cmd_hdr *)(p->cmd_lst + slot * AHCI_CL_SIZE);
ncq = 0;
readop = 1;
+ first = (done == 0);
if (cfis[2] == ATA_WRITE || cfis[2] == ATA_WRITE48 ||
cfis[2] == ATA_WRITE_MUL || cfis[2] == ATA_WRITE_MUL48 ||
@@ -651,14 +681,14 @@ ahci_handle_rw(struct ahci_port *p, int slot, uint8_t *cfis, uint32_t done)
/* Stuff request onto busy list. */
TAILQ_INSERT_HEAD(&p->iobhd, aior, io_blist);
+ if (ncq && first)
+ ahci_write_fis_d2h_ncq(p, slot);
+
if (readop)
err = blockif_read(p->bctx, breq);
else
err = blockif_write(p->bctx, breq);
assert(err == 0);
-
- if (ncq)
- p->ci &= ~(1 << slot);
}
static void
@@ -731,15 +761,18 @@ ahci_handle_dsm_trim(struct ahci_port *p, int slot, uint8_t *cfis, uint32_t done
uint8_t *entry;
uint64_t elba;
uint32_t len, elen;
- int err;
+ int err, first, ncq;
uint8_t buf[512];
+ first = (done == 0);
if (cfis[2] == ATA_DATA_SET_MANAGEMENT) {
len = (uint16_t)cfis[13] << 8 | cfis[12];
len *= 512;
+ ncq = 0;
} else { /* ATA_SEND_FPDMA_QUEUED */
len = (uint16_t)cfis[11] << 8 | cfis[3];
len *= 512;
+ ncq = 1;
}
read_prdt(p, slot, cfis, buf, sizeof(buf));
@@ -758,6 +791,8 @@ next:
ahci_write_fis_d2h(p, slot, cfis, ATA_S_READY | ATA_S_DSC);
p->pending &= ~(1 << slot);
ahci_check_stopped(p);
+ if (!first)
+ ahci_handle_port(p);
return;
}
goto next;
@@ -789,6 +824,9 @@ next:
*/
TAILQ_INSERT_HEAD(&p->iobhd, aior, io_blist);
+ if (ncq && first)
+ ahci_write_fis_d2h_ncq(p, slot);
+
err = blockif_delete(p->bctx, breq);
assert(err == 0);
}
@@ -1544,6 +1582,7 @@ static void
ahci_handle_cmd(struct ahci_port *p, int slot, uint8_t *cfis)
{
+ p->tfd |= ATA_S_BUSY;
switch (cfis[2]) {
case ATA_ATA_IDENTIFY:
handle_identify(p, slot, cfis);
@@ -1725,20 +1764,23 @@ ahci_handle_slot(struct ahci_port *p, int slot)
static void
ahci_handle_port(struct ahci_port *p)
{
- int i;
if (!(p->cmd & AHCI_P_CMD_ST))
return;
/*
* Search for any new commands to issue ignoring those that
- * are already in-flight.
+ * are already in-flight. Stop if device is busy or in error.
*/
- for (i = 0; (i < 32) && p->ci; i++) {
- if ((p->ci & (1 << i)) && !(p->pending & (1 << i))) {
+ for (; (p->ci & ~p->pending) != 0; p->ccs = ((p->ccs + 1) & 31)) {
+ if ((p->tfd & (ATA_S_BUSY | ATA_S_DRQ)) != 0)
+ break;
+ if (p->waitforclear)
+ break;
+ if ((p->ci & ~p->pending & (1 << p->ccs)) != 0) {
p->cmd &= ~AHCI_P_CMD_CCS_MASK;
- p->cmd |= i << AHCI_P_CMD_CCS_SHIFT;
- ahci_handle_slot(p, i);
+ p->cmd |= p->ccs << AHCI_P_CMD_CCS_SHIFT;
+ ahci_handle_slot(p, p->ccs);
}
}
}
@@ -1815,6 +1857,7 @@ ata_ioreq_cb(struct blockif_req *br, int err)
p->pending &= ~(1 << slot);
ahci_check_stopped(p);
+ ahci_handle_port(p);
out:
pthread_mutex_unlock(&sc->mtx);
DPRINTF("%s exit\n", __func__);
@@ -1876,6 +1919,7 @@ atapi_ioreq_cb(struct blockif_req *br, int err)
p->pending &= ~(1 << slot);
ahci_check_stopped(p);
+ ahci_handle_port(p);
out:
pthread_mutex_unlock(&sc->mtx);
DPRINTF("%s exit\n", __func__);
@@ -1940,8 +1984,15 @@ pci_ahci_port_write(struct pci_ahci_softc *sc, uint64_t offset, uint64_t value)
break;
case AHCI_P_CMD:
{
- p->cmd = value;
-
+ p->cmd &= ~(AHCI_P_CMD_ST | AHCI_P_CMD_SUD | AHCI_P_CMD_POD |
+ AHCI_P_CMD_CLO | AHCI_P_CMD_FRE | AHCI_P_CMD_APSTE |
+ AHCI_P_CMD_ATAPI | AHCI_P_CMD_DLAE | AHCI_P_CMD_ALPE |
+ AHCI_P_CMD_ASP | AHCI_P_CMD_ICC_MASK);
+ p->cmd |= (AHCI_P_CMD_ST | AHCI_P_CMD_SUD | AHCI_P_CMD_POD |
+ AHCI_P_CMD_CLO | AHCI_P_CMD_FRE | AHCI_P_CMD_APSTE |
+ AHCI_P_CMD_ATAPI | AHCI_P_CMD_DLAE | AHCI_P_CMD_ALPE |
+ AHCI_P_CMD_ASP | AHCI_P_CMD_ICC_MASK) & value;
+
if (!(value & AHCI_P_CMD_ST)) {
ahci_port_stop(p);
} else {
@@ -1965,10 +2016,14 @@ pci_ahci_port_write(struct pci_ahci_softc *sc, uint64_t offset, uint64_t value)
}
if (value & AHCI_P_CMD_CLO) {
- p->tfd = 0;
+ p->tfd &= ~(ATA_S_BUSY | ATA_S_DRQ);
p->cmd &= ~AHCI_P_CMD_CLO;
}
+ if (value & AHCI_P_CMD_ICC_MASK) {
+ p->cmd &= ~AHCI_P_CMD_ICC_MASK;
+ }
+
ahci_handle_port(p);
break;
}
@@ -2038,7 +2093,7 @@ pci_ahci_write(struct vmctx *ctx, int vcpu, struct pci_devinst *pi,
struct pci_ahci_softc *sc = pi->pi_arg;
assert(baridx == 5);
- assert(size == 4);
+ assert((offset % 4) == 0 && size == 4);
pthread_mutex_lock(&sc->mtx);
@@ -2127,24 +2182,29 @@ pci_ahci_port_read(struct pci_ahci_softc *sc, uint64_t offset)
static uint64_t
pci_ahci_read(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
- uint64_t offset, int size)
+ uint64_t regoff, int size)
{
struct pci_ahci_softc *sc = pi->pi_arg;
+ uint64_t offset;
uint32_t value;
assert(baridx == 5);
- assert(size == 4);
+ assert(size == 1 || size == 2 || size == 4);
+ assert((regoff & (size - 1)) == 0);
pthread_mutex_lock(&sc->mtx);
+ offset = regoff & ~0x3; /* round down to a multiple of 4 bytes */
if (offset < AHCI_OFFSET)
value = pci_ahci_host_read(sc, offset);
else if (offset < AHCI_OFFSET + sc->ports * AHCI_STEP)
value = pci_ahci_port_read(sc, offset);
else {
value = 0;
- WPRINTF("pci_ahci: unknown i/o read offset 0x%"PRIx64"\n", offset);
+ WPRINTF("pci_ahci: unknown i/o read offset 0x%"PRIx64"\n",
+ regoff);
}
+ value >>= 8 * (regoff & 0x3);
pthread_mutex_unlock(&sc->mtx);
diff --git a/usr.sbin/bhyve/pci_emul.c b/usr.sbin/bhyve/pci_emul.c
index a08ac4c..03ff0c0 100644
--- a/usr.sbin/bhyve/pci_emul.c
+++ b/usr.sbin/bhyve/pci_emul.c
@@ -1938,7 +1938,7 @@ INOUT_PORT(pci_cfgdata, CONF1_DATA_PORT+3, IOPORT_F_INOUT, pci_emul_cfgdata);
#define DMEMSZ 4096
struct pci_emul_dsoftc {
uint8_t ioregs[DIOSZ];
- uint8_t memregs[DMEMSZ];
+ uint8_t memregs[2][DMEMSZ];
};
#define PCI_EMUL_MSI_MSGS 4
@@ -1967,6 +1967,9 @@ pci_emul_dinit(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
error = pci_emul_alloc_bar(pi, 1, PCIBAR_MEM32, DMEMSZ);
assert(error == 0);
+ error = pci_emul_alloc_bar(pi, 2, PCIBAR_MEM32, DMEMSZ);
+ assert(error == 0);
+
return (0);
}
@@ -2006,21 +2009,23 @@ pci_emul_diow(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
}
}
- if (baridx == 1) {
+ if (baridx == 1 || baridx == 2) {
if (offset + size > DMEMSZ) {
printf("diow: memw too large, offset %ld size %d\n",
offset, size);
return;
}
+ i = baridx - 1; /* 'memregs' index */
+
if (size == 1) {
- sc->memregs[offset] = value;
+ sc->memregs[i][offset] = value;
} else if (size == 2) {
- *(uint16_t *)&sc->memregs[offset] = value;
+ *(uint16_t *)&sc->memregs[i][offset] = value;
} else if (size == 4) {
- *(uint32_t *)&sc->memregs[offset] = value;
+ *(uint32_t *)&sc->memregs[i][offset] = value;
} else if (size == 8) {
- *(uint64_t *)&sc->memregs[offset] = value;
+ *(uint64_t *)&sc->memregs[i][offset] = value;
} else {
printf("diow: memw unknown size %d\n", size);
}
@@ -2030,7 +2035,7 @@ pci_emul_diow(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
*/
}
- if (baridx > 1) {
+ if (baridx > 2) {
printf("diow: unknown bar idx %d\n", baridx);
}
}
@@ -2041,6 +2046,7 @@ pci_emul_dior(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
{
struct pci_emul_dsoftc *sc = pi->pi_arg;
uint32_t value;
+ int i;
if (baridx == 0) {
if (offset + size > DIOSZ) {
@@ -2059,29 +2065,31 @@ pci_emul_dior(struct vmctx *ctx, int vcpu, struct pci_devinst *pi, int baridx,
printf("dior: ior unknown size %d\n", size);
}
}
-
- if (baridx == 1) {
+
+ if (baridx == 1 || baridx == 2) {
if (offset + size > DMEMSZ) {
printf("dior: memr too large, offset %ld size %d\n",
offset, size);
return (0);
}
-
+
+ i = baridx - 1; /* 'memregs' index */
+
if (size == 1) {
- value = sc->memregs[offset];
+ value = sc->memregs[i][offset];
} else if (size == 2) {
- value = *(uint16_t *) &sc->memregs[offset];
+ value = *(uint16_t *) &sc->memregs[i][offset];
} else if (size == 4) {
- value = *(uint32_t *) &sc->memregs[offset];
+ value = *(uint32_t *) &sc->memregs[i][offset];
} else if (size == 8) {
- value = *(uint64_t *) &sc->memregs[offset];
+ value = *(uint64_t *) &sc->memregs[i][offset];
} else {
printf("dior: ior unknown size %d\n", size);
}
}
- if (baridx > 1) {
+ if (baridx > 2) {
printf("dior: unknown bar idx %d\n", baridx);
return (0);
}
diff --git a/usr.sbin/bhyve/pci_hostbridge.c b/usr.sbin/bhyve/pci_hostbridge.c
index 54a25ae..5c9ea28 100644
--- a/usr.sbin/bhyve/pci_hostbridge.c
+++ b/usr.sbin/bhyve/pci_hostbridge.c
@@ -38,7 +38,7 @@ pci_hostbridge_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
/* config space */
pci_set_cfgdata16(pi, PCIR_VENDOR, 0x1275); /* NetApp */
pci_set_cfgdata16(pi, PCIR_DEVICE, 0x1275); /* NetApp */
- pci_set_cfgdata8(pi, PCIR_HDRTYPE, PCIM_HDRTYPE_BRIDGE);
+ pci_set_cfgdata8(pi, PCIR_HDRTYPE, PCIM_HDRTYPE_NORMAL);
pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_BRIDGE);
pci_set_cfgdata8(pi, PCIR_SUBCLASS, PCIS_BRIDGE_HOST);
diff --git a/usr.sbin/bhyve/pci_virtio_block.c b/usr.sbin/bhyve/pci_virtio_block.c
index 35daa1f..8500be6 100644
--- a/usr.sbin/bhyve/pci_virtio_block.c
+++ b/usr.sbin/bhyve/pci_virtio_block.c
@@ -370,6 +370,7 @@ pci_vtblk_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
pci_set_cfgdata16(pi, PCIR_VENDOR, VIRTIO_VENDOR);
pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_STORAGE);
pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_TYPE_BLOCK);
+ pci_set_cfgdata16(pi, PCIR_SUBVEND_0, VIRTIO_VENDOR);
if (vi_intr_init(&sc->vbsc_vs, 1, fbsdrun_virtio_msix())) {
blockif_close(sc->bc);
diff --git a/usr.sbin/bhyve/pci_virtio_net.c b/usr.sbin/bhyve/pci_virtio_net.c
index 7227488..3781ea9 100644
--- a/usr.sbin/bhyve/pci_virtio_net.c
+++ b/usr.sbin/bhyve/pci_virtio_net.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/select.h>
#include <sys/uio.h>
#include <sys/ioctl.h>
+#include <machine/atomic.h>
#include <net/ethernet.h>
#include <errno.h>
@@ -453,7 +454,7 @@ pci_vtnet_tx_thread(void *param)
{
struct pci_vtnet_softc *sc = param;
struct vqueue_info *vq;
- int have_work, error;
+ int error;
vq = &sc->vsc_queues[VTNET_TXQ];
@@ -467,20 +468,16 @@ pci_vtnet_tx_thread(void *param)
for (;;) {
/* note - tx mutex is locked here */
- do {
+ while (sc->resetting || !vq_has_descs(vq)) {
vq->vq_used->vu_flags &= ~VRING_USED_F_NO_NOTIFY;
- if (sc->resetting)
- have_work = 0;
- else
- have_work = vq_has_descs(vq);
-
- if (!have_work) {
- sc->tx_in_progress = 0;
- error = pthread_cond_wait(&sc->tx_cond,
- &sc->tx_mtx);
- assert(error == 0);
- }
- } while (!have_work);
+ mb();
+ if (!sc->resetting && vq_has_descs(vq))
+ break;
+
+ sc->tx_in_progress = 0;
+ error = pthread_cond_wait(&sc->tx_cond, &sc->tx_mtx);
+ assert(error == 0);
+ }
vq->vq_used->vu_flags |= VRING_USED_F_NO_NOTIFY;
sc->tx_in_progress = 1;
pthread_mutex_unlock(&sc->tx_mtx);
@@ -643,6 +640,7 @@ pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
pci_set_cfgdata16(pi, PCIR_VENDOR, VIRTIO_VENDOR);
pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_NETWORK);
pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_TYPE_NET);
+ pci_set_cfgdata16(pi, PCIR_SUBVEND_0, VIRTIO_VENDOR);
/* Link is up if we managed to open tap device. */
sc->vsc_config.status = (opts == NULL || sc->vsc_tapfd >= 0);
diff --git a/usr.sbin/bhyve/pci_virtio_rnd.c b/usr.sbin/bhyve/pci_virtio_rnd.c
index 92d1d6f..78448f5 100644
--- a/usr.sbin/bhyve/pci_virtio_rnd.c
+++ b/usr.sbin/bhyve/pci_virtio_rnd.c
@@ -170,6 +170,7 @@ pci_vtrnd_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
pci_set_cfgdata16(pi, PCIR_VENDOR, VIRTIO_VENDOR);
pci_set_cfgdata8(pi, PCIR_CLASS, PCIC_CRYPTO);
pci_set_cfgdata16(pi, PCIR_SUBDEV_0, VIRTIO_TYPE_ENTROPY);
+ pci_set_cfgdata16(pi, PCIR_SUBVEND_0, VIRTIO_VENDOR);
if (vi_intr_init(&sc->vrsc_vs, 1, fbsdrun_virtio_msix()))
return (1);
diff --git a/usr.sbin/bhyve/task_switch.c b/usr.sbin/bhyve/task_switch.c
index ba6a9d2..69dfaae 100644
--- a/usr.sbin/bhyve/task_switch.c
+++ b/usr.sbin/bhyve/task_switch.c
@@ -202,7 +202,8 @@ desc_table_limit_check(struct vmctx *ctx, int vcpu, uint16_t sel)
*/
static int
desc_table_rw(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
- uint16_t sel, struct user_segment_descriptor *desc, bool doread)
+ uint16_t sel, struct user_segment_descriptor *desc, bool doread,
+ int *faultptr)
{
struct iovec iov[2];
uint64_t base;
@@ -215,28 +216,30 @@ desc_table_rw(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
assert(limit >= SEL_LIMIT(sel));
error = vm_copy_setup(ctx, vcpu, paging, base + SEL_START(sel),
- sizeof(*desc), doread ? PROT_READ : PROT_WRITE, iov, nitems(iov));
- if (error == 0) {
- if (doread)
- vm_copyin(ctx, vcpu, iov, desc, sizeof(*desc));
- else
- vm_copyout(ctx, vcpu, desc, iov, sizeof(*desc));
- }
- return (error);
+ sizeof(*desc), doread ? PROT_READ : PROT_WRITE, iov, nitems(iov),
+ faultptr);
+ if (error || *faultptr)
+ return (error);
+
+ if (doread)
+ vm_copyin(ctx, vcpu, iov, desc, sizeof(*desc));
+ else
+ vm_copyout(ctx, vcpu, desc, iov, sizeof(*desc));
+ return (0);
}
static int
desc_table_read(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
- uint16_t sel, struct user_segment_descriptor *desc)
+ uint16_t sel, struct user_segment_descriptor *desc, int *faultptr)
{
- return (desc_table_rw(ctx, vcpu, paging, sel, desc, true));
+ return (desc_table_rw(ctx, vcpu, paging, sel, desc, true, faultptr));
}
static int
desc_table_write(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
- uint16_t sel, struct user_segment_descriptor *desc)
+ uint16_t sel, struct user_segment_descriptor *desc, int *faultptr)
{
- return (desc_table_rw(ctx, vcpu, paging, sel, desc, false));
+ return (desc_table_rw(ctx, vcpu, paging, sel, desc, false, faultptr));
}
/*
@@ -248,7 +251,7 @@ desc_table_write(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
*/
static int
read_tss_descriptor(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
- uint16_t sel, struct user_segment_descriptor *desc)
+ uint16_t sel, struct user_segment_descriptor *desc, int *faultptr)
{
struct vm_guest_paging sup_paging;
int error;
@@ -267,7 +270,7 @@ read_tss_descriptor(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
sup_paging = ts->paging;
sup_paging.cpl = 0; /* implicit supervisor mode */
- error = desc_table_read(ctx, vcpu, &sup_paging, sel, desc);
+ error = desc_table_read(ctx, vcpu, &sup_paging, sel, desc, faultptr);
return (error);
}
@@ -301,14 +304,10 @@ ldt_desc(int sd_type)
/*
* Validate the descriptor 'seg_desc' associated with 'segment'.
- *
- * Returns 0 on success.
- * Returns 1 if an exception was injected into the guest.
- * Returns -1 otherwise.
*/
static int
validate_seg_desc(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
- int segment, struct seg_desc *seg_desc)
+ int segment, struct seg_desc *seg_desc, int *faultptr)
{
struct vm_guest_paging sup_paging;
struct user_segment_descriptor usd;
@@ -369,8 +368,8 @@ validate_seg_desc(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
/* Read the descriptor from the GDT/LDT */
sup_paging = ts->paging;
sup_paging.cpl = 0; /* implicit supervisor mode */
- error = desc_table_read(ctx, vcpu, &sup_paging, sel, &usd);
- if (error)
+ error = desc_table_read(ctx, vcpu, &sup_paging, sel, &usd, faultptr);
+ if (error || *faultptr)
return (error);
/* Verify that the descriptor type is compatible with the segment */
@@ -476,14 +475,10 @@ update_seg_desc(struct vmctx *ctx, int vcpu, int reg, struct seg_desc *sd)
/*
* Update the vcpu registers to reflect the state of the new task.
- *
- * Returns 0 on success.
- * Returns 1 if an exception was injected into the guest.
- * Returns -1 otherwise.
*/
static int
tss32_restore(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
- uint16_t ot_sel, struct tss32 *tss, struct iovec *iov)
+ uint16_t ot_sel, struct tss32 *tss, struct iovec *iov, int *faultptr)
{
struct seg_desc seg_desc, seg_desc2;
uint64_t *pdpte, maxphyaddr, reserved;
@@ -565,8 +560,9 @@ tss32_restore(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
vm_copyout(ctx, vcpu, tss, iov, sizeof(*tss));
/* Validate segment descriptors */
- error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_LDTR, &seg_desc);
- if (error)
+ error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_LDTR, &seg_desc,
+ faultptr);
+ if (error || *faultptr)
return (error);
update_seg_desc(ctx, vcpu, VM_REG_GUEST_LDTR, &seg_desc);
@@ -579,33 +575,40 @@ tss32_restore(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
* VM-entry checks so the guest can handle any exception injected
* during task switch emulation.
*/
- error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_CS, &seg_desc);
- if (error)
+ error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_CS, &seg_desc,
+ faultptr);
+ if (error || *faultptr)
return (error);
- error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_SS, &seg_desc2);
- if (error)
+
+ error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_SS, &seg_desc2,
+ faultptr);
+ if (error || *faultptr)
return (error);
update_seg_desc(ctx, vcpu, VM_REG_GUEST_CS, &seg_desc);
update_seg_desc(ctx, vcpu, VM_REG_GUEST_SS, &seg_desc2);
ts->paging.cpl = tss->tss_cs & SEL_RPL_MASK;
- error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_DS, &seg_desc);
- if (error)
+ error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_DS, &seg_desc,
+ faultptr);
+ if (error || *faultptr)
return (error);
update_seg_desc(ctx, vcpu, VM_REG_GUEST_DS, &seg_desc);
- error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_ES, &seg_desc);
- if (error)
+ error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_ES, &seg_desc,
+ faultptr);
+ if (error || *faultptr)
return (error);
update_seg_desc(ctx, vcpu, VM_REG_GUEST_ES, &seg_desc);
- error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_FS, &seg_desc);
- if (error)
+ error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_FS, &seg_desc,
+ faultptr);
+ if (error || *faultptr)
return (error);
update_seg_desc(ctx, vcpu, VM_REG_GUEST_FS, &seg_desc);
- error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_GS, &seg_desc);
- if (error)
+ error = validate_seg_desc(ctx, vcpu, ts, VM_REG_GUEST_GS, &seg_desc,
+ faultptr);
+ if (error || *faultptr)
return (error);
update_seg_desc(ctx, vcpu, VM_REG_GUEST_GS, &seg_desc);
@@ -616,14 +619,10 @@ tss32_restore(struct vmctx *ctx, int vcpu, struct vm_task_switch *ts,
* Push an error code on the stack of the new task. This is needed if the
* task switch was triggered by a hardware exception that causes an error
* code to be saved (e.g. #PF).
- *
- * Returns 0 on success.
- * Returns 1 if an exception was injected into the guest.
- * Returns -1 otherwise.
*/
static int
push_errcode(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
- int task_type, uint32_t errcode)
+ int task_type, uint32_t errcode, int *faultptr)
{
struct iovec iov[2];
struct seg_desc seg_desc;
@@ -632,6 +631,8 @@ push_errcode(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
uint32_t esp;
uint16_t stacksel;
+ *faultptr = 0;
+
cr0 = GETREG(ctx, vcpu, VM_REG_GUEST_CR0);
rflags = GETREG(ctx, vcpu, VM_REG_GUEST_RFLAGS);
stacksel = GETREG(ctx, vcpu, VM_REG_GUEST_SS);
@@ -666,17 +667,19 @@ push_errcode(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
if (vie_calculate_gla(paging->cpu_mode, VM_REG_GUEST_SS,
&seg_desc, esp, bytes, stacksize, PROT_WRITE, &gla)) {
sel_exception(ctx, vcpu, IDT_SS, stacksel, 1);
- return (1);
+ *faultptr = 1;
+ return (0);
}
if (vie_alignment_check(paging->cpl, bytes, cr0, rflags, gla)) {
vm_inject_ac(ctx, vcpu, 1);
- return (1);
+ *faultptr = 1;
+ return (0);
}
error = vm_copy_setup(ctx, vcpu, paging, gla, bytes, PROT_WRITE,
- iov, nitems(iov));
- if (error)
+ iov, nitems(iov), faultptr);
+ if (error || *faultptr)
return (error);
vm_copyout(ctx, vcpu, &errcode, iov, bytes);
@@ -687,16 +690,13 @@ push_errcode(struct vmctx *ctx, int vcpu, struct vm_guest_paging *paging,
/*
* Evaluate return value from helper functions and potentially return to
* the VM run loop.
- * 0: success
- * +1: an exception was injected into the guest vcpu
- * -1: unrecoverable/programming error
*/
-#define CHKERR(x) \
+#define CHKERR(error,fault) \
do { \
- assert(((x) == 0) || ((x) == 1) || ((x) == -1)); \
- if ((x) == -1) \
+ assert((error == 0) || (error == EFAULT)); \
+ if (error) \
return (VMEXIT_ABORT); \
- else if ((x) == 1) \
+ else if (fault) \
return (VMEXIT_CONTINUE); \
} while (0)
@@ -711,7 +711,7 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
struct iovec nt_iov[2], ot_iov[2];
uint64_t cr0, ot_base;
uint32_t eip, ot_lim, access;
- int error, ext, minlimit, nt_type, ot_type, vcpu;
+ int error, ext, fault, minlimit, nt_type, ot_type, vcpu;
enum task_switch_reason reason;
uint16_t nt_sel, ot_sel;
@@ -739,8 +739,9 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
sup_paging.cpl = 0; /* implicit supervisor mode */
/* Fetch the new TSS descriptor */
- error = read_tss_descriptor(ctx, vcpu, task_switch, nt_sel, &nt_desc);
- CHKERR(error);
+ error = read_tss_descriptor(ctx, vcpu, task_switch, nt_sel, &nt_desc,
+ &fault);
+ CHKERR(error, fault);
nt = usd_to_seg_desc(&nt_desc);
@@ -792,8 +793,8 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
/* Fetch the new TSS */
error = vm_copy_setup(ctx, vcpu, &sup_paging, nt.base, minlimit + 1,
- PROT_READ | PROT_WRITE, nt_iov, nitems(nt_iov));
- CHKERR(error);
+ PROT_READ | PROT_WRITE, nt_iov, nitems(nt_iov), &fault);
+ CHKERR(error, fault);
vm_copyin(ctx, vcpu, nt_iov, &newtss, minlimit + 1);
/* Get the old TSS selector from the guest's task register */
@@ -818,13 +819,14 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
assert(ot_type == SDT_SYS386BSY || ot_type == SDT_SYS286BSY);
/* Fetch the old TSS descriptor */
- error = read_tss_descriptor(ctx, vcpu, task_switch, ot_sel, &ot_desc);
- CHKERR(error);
+ error = read_tss_descriptor(ctx, vcpu, task_switch, ot_sel, &ot_desc,
+ &fault);
+ CHKERR(error, fault);
/* Get the old TSS */
error = vm_copy_setup(ctx, vcpu, &sup_paging, ot_base, minlimit + 1,
- PROT_READ | PROT_WRITE, ot_iov, nitems(ot_iov));
- CHKERR(error);
+ PROT_READ | PROT_WRITE, ot_iov, nitems(ot_iov), &fault);
+ CHKERR(error, fault);
vm_copyin(ctx, vcpu, ot_iov, &oldtss, minlimit + 1);
/*
@@ -834,8 +836,8 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
if (reason == TSR_IRET || reason == TSR_JMP) {
ot_desc.sd_type &= ~0x2;
error = desc_table_write(ctx, vcpu, &sup_paging, ot_sel,
- &ot_desc);
- CHKERR(error);
+ &ot_desc, &fault);
+ CHKERR(error, fault);
}
if (nt_type == SDT_SYS286BSY || nt_type == SDT_SYS286TSS) {
@@ -853,8 +855,8 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
if (reason != TSR_IRET) {
nt_desc.sd_type |= 0x2;
error = desc_table_write(ctx, vcpu, &sup_paging, nt_sel,
- &nt_desc);
- CHKERR(error);
+ &nt_desc, &fault);
+ CHKERR(error, fault);
}
/* Update task register to point at the new TSS */
@@ -877,8 +879,9 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
assert(error == 0);
/* Load processor state from new TSS */
- error = tss32_restore(ctx, vcpu, task_switch, ot_sel, &newtss, nt_iov);
- CHKERR(error);
+ error = tss32_restore(ctx, vcpu, task_switch, ot_sel, &newtss, nt_iov,
+ &fault);
+ CHKERR(error, fault);
/*
* Section "Interrupt Tasks" in Intel SDM, Vol 3: if an exception
@@ -889,8 +892,8 @@ vmexit_task_switch(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
assert(task_switch->ext);
assert(task_switch->reason == TSR_IDT_GATE);
error = push_errcode(ctx, vcpu, &task_switch->paging, nt_type,
- task_switch->errcode);
- CHKERR(error);
+ task_switch->errcode, &fault);
+ CHKERR(error, fault);
}
/*
diff --git a/usr.sbin/bhyve/virtio.c b/usr.sbin/bhyve/virtio.c
index 41a9e42..11b1e62 100644
--- a/usr.sbin/bhyve/virtio.c
+++ b/usr.sbin/bhyve/virtio.c
@@ -316,7 +316,7 @@ vq_getchain(struct vqueue_info *vq, uint16_t *pidx,
if ((vdir->vd_flags & VRING_DESC_F_INDIRECT) == 0) {
_vq_record(i, vdir, ctx, iov, n_iov, flags);
i++;
- } else if ((vs->vs_negotiated_caps &
+ } else if ((vs->vs_vc->vc_hv_caps &
VIRTIO_RING_F_INDIRECT_DESC) == 0) {
fprintf(stderr,
"%s: descriptor has forbidden INDIRECT flag, "
diff --git a/usr.sbin/bhyvectl/bhyvectl.c b/usr.sbin/bhyvectl/bhyvectl.c
index 223ee25..7d3017f 100644
--- a/usr.sbin/bhyvectl/bhyvectl.c
+++ b/usr.sbin/bhyvectl/bhyvectl.c
@@ -293,6 +293,7 @@ static int get_guest_pat, get_host_pat;
static int get_guest_sysenter, get_vmcs_link;
static int get_exit_reason, get_vmcs_exit_qualification;
static int get_vmcs_exit_interruption_info, get_vmcs_exit_interruption_error;
+static int get_vmcs_exit_inst_length;
static uint64_t desc_base;
static uint32_t desc_limit, desc_access;
@@ -1145,7 +1146,15 @@ get_misc_vmcs(struct vmctx *ctx, int vcpu)
vcpu, u64);
}
}
-
+
+ if (!error && (get_vmcs_exit_inst_length || get_all)) {
+ error = vm_get_vmcs_field(ctx, vcpu,
+ VMCS_EXIT_INSTRUCTION_LENGTH, &u64);
+ if (error == 0)
+ printf("vmcs_exit_inst_length[%d]\t0x%08x\n", vcpu,
+ (uint32_t)u64);
+ }
+
if (!error && (get_vmcs_exit_qualification || get_all)) {
error = vm_get_vmcs_field(ctx, vcpu, VMCS_EXIT_QUALIFICATION,
&u64);
@@ -1405,6 +1414,8 @@ setup_options(bool cpu_intel)
REQ_ARG, 0, SET_VMCS_ENTRY_INTERRUPTION_INFO },
{ "get-vmcs-exit-qualification",
NO_ARG, &get_vmcs_exit_qualification, 1 },
+ { "get-vmcs-exit-inst-length",
+ NO_ARG, &get_vmcs_exit_inst_length, 1 },
{ "get-vmcs-interruptibility",
NO_ARG, &get_vmcs_interruptibility, 1 },
{ "get-vmcs-exit-interruption-error",
diff --git a/usr.sbin/bhyveload/bhyveload.c b/usr.sbin/bhyveload/bhyveload.c
index eaf71a8..8ebf116 100644
--- a/usr.sbin/bhyveload/bhyveload.c
+++ b/usr.sbin/bhyveload/bhyveload.c
@@ -609,7 +609,7 @@ disk_open(char *path)
{
int err, fd;
- if (ndisks > NDISKS)
+ if (ndisks >= NDISKS)
return (ERANGE);
err = 0;
diff --git a/usr.sbin/bluetooth/bthidd/Makefile b/usr.sbin/bluetooth/bthidd/Makefile
index 587189b..f36d216 100644
--- a/usr.sbin/bluetooth/bthidd/Makefile
+++ b/usr.sbin/bluetooth/bthidd/Makefile
@@ -8,7 +8,6 @@ SRCS= bthidd.c client.c hid.c kbd.c lexer.l parser.y server.c \
session.c
CFLAGS+= -I${.CURDIR}
-DEBUG_FLAGS= -g
LIBADD+= bluetooth usbhid
diff --git a/usr.sbin/bsdinstall/scripts/zfsboot b/usr.sbin/bsdinstall/scripts/zfsboot
index eb90b8c..c759e85 100755
--- a/usr.sbin/bsdinstall/scripts/zfsboot
+++ b/usr.sbin/bsdinstall/scripts/zfsboot
@@ -287,10 +287,12 @@ msg_stripe_desc="Stripe - No Redundancy"
msg_stripe_help="[1+ Disks] Striping provides maximum storage but no redundancy"
msg_swap_encrypt="Encrypt Swap?"
msg_swap_encrypt_help="Encrypt swap partitions with temporary keys, discarded on reboot"
+msg_swap_invalid="The selected swap size (%s) is invalid. Enter a number optionally followed by units. Example: 2G"
msg_swap_mirror="Mirror Swap?"
msg_swap_mirror_help="Mirror swap partitions for redundancy, breaks crash dumps"
msg_swap_size="Swap Size"
msg_swap_size_help="Customize how much swap space is allocated to each selected disk"
+msg_swap_toosmall="The selected swap size (%s) is to small. Please enter a value greater than 100MB or enter 0 for no swap"
msg_these_disks_are_too_small="These disks are too small given the amount of requested\nswap (%s) and/or geli(8) (%s) partitions, which would\ntake 50%% or more of each of the following selected disk\ndevices (not recommended):\n\n %s\n\nRecommend changing partition size(s) and/or selecting a\ndifferent set of devices."
msg_uefi_not_supported="The FreeBSD UEFI loader does not currently support booting root-on-ZFS. Your system will need to boot in legacy (CSM) mode.\nDo you want to continue?"
msg_unable_to_get_disk_capacity="Unable to get disk capacity of \`%s'"
@@ -951,6 +953,8 @@ zfs_create_diskpart()
esac # $ZFSBOOT_PARTITION_SCHEME
# Update fstab(5)
+ local swapsize
+ f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize
if [ "$isswapmirror" ]; then
# This is not the first disk in the mirror, do nothing
elif [ "$ZFSBOOT_SWAP_ENCRYPTION" -a "$ZFSBOOT_SWAP_MIRROR" ]; then
@@ -970,6 +974,8 @@ zfs_create_diskpart()
/dev/$disk${swappart}.eli none swap sw 0 0 \
$BSDINSTALL_TMPETC/fstab ||
return $FAILURE
+ elif [ ${swapsize:-0} -eq 0 ]; then
+ # If swap is 0 sized, don't add it to fstab
else
f_eval_catch $funcname printf "$PRINTF_FSTAB" \
/dev/$disk$swappart none swap sw 0 0 \
@@ -1557,10 +1563,26 @@ while :; do
;;
?" $msg_swap_size")
# Prompt the user to input/change the swap size for each disk
- f_dialog_input input \
- "$msg_please_enter_amount_of_swap_space" \
- "$ZFSBOOT_SWAP_SIZE" &&
- ZFSBOOT_SWAP_SIZE="${input:-0}"
+ while :; do
+ f_dialog_input input \
+ "$msg_please_enter_amount_of_swap_space" \
+ "$ZFSBOOT_SWAP_SIZE" &&
+ ZFSBOOT_SWAP_SIZE="${input:-0}"
+ if f_expand_number "$ZFSBOOT_SWAP_SIZE" swapsize
+ then
+ if [ $swapsize -ne 0 -a $swapsize -lt 104857600 ]; then
+ f_show_err "$msg_swap_toosmall" \
+ "$ZFSBOOT_SWAP_SIZE"
+ continue;
+ else
+ break;
+ fi
+ else
+ f_show_err "$msg_swap_invalid" \
+ "$ZFSBOOT_SWAP_SIZE"
+ continue;
+ fi
+ done
;;
?" $msg_swap_mirror")
# Toggle the variable referenced both by the menu and later
diff --git a/usr.sbin/chown/chgrp.1 b/usr.sbin/chown/chgrp.1
index 8a4c271..6fb0a31 100644
--- a/usr.sbin/chown/chgrp.1
+++ b/usr.sbin/chown/chgrp.1
@@ -31,7 +31,7 @@
.\" @(#)chgrp.1 8.3 (Berkeley) 3/31/94
.\" $FreeBSD$
.\"
-.Dd February 21, 2010
+.Dd April 20, 2015
.Dt CHGRP 1
.Os
.Sh NAME
@@ -60,8 +60,9 @@ The following options are available:
.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.)
+option is specified, symbolic links on the command line are followed
+and hence unaffected by the command.
+(Symbolic links encountered during traversal are not followed.)
.It Fl L
If the
.Fl R
@@ -72,8 +73,12 @@ If the
option is specified, no symbolic links are followed.
This is the default.
.It Fl R
-Change the group ID for the file hierarchies rooted
-in the files instead of just the files themselves.
+Change the group ID of the file hierarchies rooted in the files,
+instead of just the files themselves.
+Beware of unintentionally matching the
+.Dq Pa ".."
+hard link to the parent directory when using wildcards like
+.Dq Li ".*" .
.It Fl f
The force option ignores errors, except for usage errors and does not
query about strange modes (unless the user does not have proper permissions).
diff --git a/usr.sbin/chown/chown.8 b/usr.sbin/chown/chown.8
index b5882a3..6b82728 100644
--- a/usr.sbin/chown/chown.8
+++ b/usr.sbin/chown/chown.8
@@ -28,7 +28,7 @@
.\" @(#)chown.8 8.3 (Berkeley) 3/31/94
.\" $FreeBSD$
.\"
-.Dd February 21, 2010
+.Dd April 20, 2015
.Dt CHOWN 8
.Os
.Sh NAME
@@ -64,8 +64,9 @@ The options are as follows:
.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.)
+option is specified, symbolic links on the command line are followed
+and hence unaffected by the command.
+(Symbolic links encountered during traversal are not followed.)
.It Fl L
If the
.Fl R
@@ -76,8 +77,8 @@ If the
option is specified, no symbolic links are followed.
This is the default.
.It Fl R
-Change the user ID and/or the group ID of the specified directory trees
-(recursively, including their contents) and files.
+Change the user ID and/or the group ID of the file hierarchies rooted
+in the files, instead of just the files themselves.
Beware of unintentionally matching the
.Dq Pa ".."
hard link to the parent directory when using wildcards like
diff --git a/usr.sbin/chown/chown.c b/usr.sbin/chown/chown.c
index 9780f02..457068a 100644
--- a/usr.sbin/chown/chown.c
+++ b/usr.sbin/chown/chown.c
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <err.h>
#include <errno.h>
+#include <fcntl.h>
#include <fts.h>
#include <grp.h>
#include <libgen.h>
@@ -119,18 +120,24 @@ main(int argc, char **argv)
usage();
if (Rflag) {
- fts_options = FTS_PHYSICAL;
if (hflag && (Hflag || Lflag))
errx(1, "the -R%c and -h options may not be "
"specified together", Hflag ? 'H' : 'L');
- if (Hflag)
- fts_options |= FTS_COMFOLLOW;
- else if (Lflag) {
- fts_options &= ~FTS_PHYSICAL;
- fts_options |= FTS_LOGICAL;
+ if (Lflag) {
+ fts_options = FTS_LOGICAL;
+ } else {
+ fts_options = FTS_PHYSICAL;
+
+ if (Hflag) {
+ fts_options |= FTS_COMFOLLOW;
+ }
}
- } else
- fts_options = hflag ? FTS_PHYSICAL : FTS_LOGICAL;
+ } else if (hflag) {
+ fts_options = FTS_PHYSICAL;
+ } else {
+ fts_options = FTS_LOGICAL;
+ }
+
if (xflag)
fts_options |= FTS_XDEV;
@@ -156,6 +163,15 @@ main(int argc, char **argv)
err(1, NULL);
for (rval = 0; (p = fts_read(ftsp)) != NULL;) {
+ int atflag;
+
+ if ((fts_options & FTS_LOGICAL) ||
+ ((fts_options & FTS_COMFOLLOW) &&
+ p->fts_level == FTS_ROOTLEVEL))
+ atflag = 0;
+ else
+ atflag = AT_SYMLINK_NOFOLLOW;
+
switch (p->fts_info) {
case FTS_D: /* Change it at FTS_DP. */
if (!Rflag)
@@ -170,58 +186,44 @@ main(int argc, char **argv)
warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
rval = 1;
continue;
- case FTS_SL:
- 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.
- */
- if (hflag)
- break;
- else
- continue;
default:
break;
}
if ((uid == (uid_t)-1 || uid == p->fts_statp->st_uid) &&
(gid == (gid_t)-1 || gid == p->fts_statp->st_gid))
continue;
- if ((hflag ? lchown : chown)(p->fts_accpath, uid, gid) == -1) {
- if (!fflag) {
- chownerr(p->fts_path);
- rval = 1;
- }
- } else {
- if (vflag) {
- printf("%s", p->fts_path);
- if (vflag > 1) {
- if (ischown) {
- printf(": %ju:%ju -> %ju:%ju",
- (uintmax_t)
- p->fts_statp->st_uid,
- (uintmax_t)
- p->fts_statp->st_gid,
- (uid == (uid_t)-1) ?
- (uintmax_t)
- p->fts_statp->st_uid :
- (uintmax_t)uid,
- (gid == (gid_t)-1) ?
- (uintmax_t)
- p->fts_statp->st_gid :
- (uintmax_t)gid);
- } else {
- printf(": %ju -> %ju",
- (uintmax_t)
- p->fts_statp->st_gid,
- (gid == (gid_t)-1) ?
- (uintmax_t)
- p->fts_statp->st_gid :
- (uintmax_t)gid);
- }
+ if (fchownat(AT_FDCWD, p->fts_accpath, uid, gid, atflag)
+ == -1 && !fflag) {
+ chownerr(p->fts_path);
+ rval = 1;
+ } else if (vflag) {
+ printf("%s", p->fts_path);
+ if (vflag > 1) {
+ if (ischown) {
+ printf(": %ju:%ju -> %ju:%ju",
+ (uintmax_t)
+ p->fts_statp->st_uid,
+ (uintmax_t)
+ p->fts_statp->st_gid,
+ (uid == (uid_t)-1) ?
+ (uintmax_t)
+ p->fts_statp->st_uid :
+ (uintmax_t)uid,
+ (gid == (gid_t)-1) ?
+ (uintmax_t)
+ p->fts_statp->st_gid :
+ (uintmax_t)gid);
+ } else {
+ printf(": %ju -> %ju",
+ (uintmax_t)
+ p->fts_statp->st_gid,
+ (gid == (gid_t)-1) ?
+ (uintmax_t)
+ p->fts_statp->st_gid :
+ (uintmax_t)gid);
}
- printf("\n");
}
+ printf("\n");
}
}
if (errno)
diff --git a/usr.sbin/crunch/crunchide/exec_elf32.c b/usr.sbin/crunch/crunchide/exec_elf32.c
index ca802d8..fc9a959 100644
--- a/usr.sbin/crunch/crunchide/exec_elf32.c
+++ b/usr.sbin/crunch/crunchide/exec_elf32.c
@@ -35,7 +35,7 @@ __RCSID("$NetBSD: exec_elf32.c,v 1.6 1999/09/20 04:12:16 christos Exp $");
#endif
#endif
__FBSDID("$FreeBSD$");
-
+
#ifndef ELFSIZE
#define ELFSIZE 32
#endif
@@ -142,7 +142,7 @@ static void *
xrealloc(void *ptr, size_t size, const char *fn, const char *use)
{
void *rv;
-
+
rv = realloc(ptr, size);
if (rv == NULL) {
free(ptr);
@@ -150,7 +150,7 @@ xrealloc(void *ptr, size_t size, const char *fn, const char *use)
fn, use);
}
return (rv);
-}
+}
int
ELFNAMEEND(check)(int fd, const char *fn)
@@ -178,6 +178,9 @@ ELFNAMEEND(check)(int fd, const char *fn)
switch (xe16toh(eh.e_machine)) {
case EM_386: break;
case EM_ALPHA: break;
+#ifndef EM_AARCH64
+#define EM_AARCH64 183
+#endif
case EM_AARCH64: break;
case EM_ARM: break;
case EM_MIPS: break;
@@ -321,11 +324,14 @@ ELFNAMEEND(hide)(int fd, const char *fn)
*/
/* load section string table for debug use */
- if ((shstrtabp = xmalloc(xewtoh(shstrtabshdr->sh_size), fn,
- "section string table")) == NULL)
+ if ((size = xewtoh(shstrtabshdr->sh_size)) == 0)
+ goto bad;
+ if ((shstrtabp = xmalloc(size, fn, "section string table")) == NULL)
goto bad;
if ((size_t)xreadatoff(fd, shstrtabp, xewtoh(shstrtabshdr->sh_offset),
- xewtoh(shstrtabshdr->sh_size), fn) != xewtoh(shstrtabshdr->sh_size))
+ size, fn) != size)
+ goto bad;
+ if (shstrtabp[size - 1] != '\0')
goto bad;
/* we need symtab, strtab, and everything behind strtab */
@@ -346,7 +352,8 @@ ELFNAMEEND(hide)(int fd, const char *fn)
strtabidx = i;
if (layoutp[i].shdr == symtabshdr || i >= strtabidx) {
off = xewtoh(layoutp[i].shdr->sh_offset);
- size = xewtoh(layoutp[i].shdr->sh_size);
+ if ((size = xewtoh(layoutp[i].shdr->sh_size)) == 0)
+ goto bad;
layoutp[i].bufp = xmalloc(size, fn,
shstrtabp + xewtoh(layoutp[i].shdr->sh_name));
if (layoutp[i].bufp == NULL)
@@ -356,10 +363,13 @@ ELFNAMEEND(hide)(int fd, const char *fn)
goto bad;
/* set symbol table and string table */
- if (layoutp[i].shdr == symtabshdr)
+ if (layoutp[i].shdr == symtabshdr) {
symtabp = layoutp[i].bufp;
- else if (layoutp[i].shdr == strtabshdr)
+ } else if (layoutp[i].shdr == strtabshdr) {
strtabp = layoutp[i].bufp;
+ if (strtabp[size - 1] != '\0')
+ goto bad;
+ }
}
}
diff --git a/usr.sbin/ctladm/ctladm.8 b/usr.sbin/ctladm/ctladm.8
index 7616c24..c4508cc 100644
--- a/usr.sbin/ctladm/ctladm.8
+++ b/usr.sbin/ctladm/ctladm.8
@@ -34,7 +34,7 @@
.\" $Id: //depot/users/kenm/FreeBSD-test2/usr.sbin/ctladm/ctladm.8#3 $
.\" $FreeBSD$
.\"
-.Dd February 1, 2015
+.Dd May 22, 2015
.Dt CTLADM 8
.Os
.Sh NAME
@@ -1160,7 +1160,8 @@ This will result in a sense key of NOT READY (0x02), and an ASC/ASCQ of
.Xr ctl 4 ,
.Xr xpt 4 ,
.Xr camcontrol 8 ,
-.Xr ctld 8
+.Xr ctld 8 ,
+.Xr ctlstat 8
.Sh HISTORY
The
.Nm
diff --git a/usr.sbin/ctld/ctld.8 b/usr.sbin/ctld/ctld.8
index aa9a414..b3bea16 100644
--- a/usr.sbin/ctld/ctld.8
+++ b/usr.sbin/ctld/ctld.8
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 9, 2014
+.Dd May 22, 2015
.Dt CTLD 8
.Os
.Sh NAME
@@ -104,7 +104,8 @@ utility exits 0 on success, and >0 if an error occurs.
.Sh SEE ALSO
.Xr ctl 4 ,
.Xr ctl.conf 5 ,
-.Xr ctladm 8
+.Xr ctladm 8 ,
+.Xr ctlstat 8
.Sh HISTORY
The
.Nm
diff --git a/usr.sbin/ctld/login.c b/usr.sbin/ctld/login.c
index c7b8b95..c6b83d9 100644
--- a/usr.sbin/ctld/login.c
+++ b/usr.sbin/ctld/login.c
@@ -800,9 +800,6 @@ login(struct connection *conn)
}
conn->conn_initiator_name = checked_strdup(initiator_name);
log_set_peer_name(conn->conn_initiator_name);
- /*
- * XXX: This doesn't work (does nothing) because of Capsicum.
- */
setproctitle("%s (%s)", conn->conn_initiator_addr, conn->conn_initiator_name);
redirected = login_portal_redirect(conn, request);
diff --git a/usr.sbin/iostat/iostat.8 b/usr.sbin/iostat/iostat.8
index 5223b72..2073679 100644
--- a/usr.sbin/iostat/iostat.8
+++ b/usr.sbin/iostat/iostat.8
@@ -56,7 +56,7 @@
.\"
.\" @(#)iostat.8 8.1 (Berkeley) 6/6/93
.\"
-.Dd December 15, 2012
+.Dd May 22, 2015
.Dt IOSTAT 8
.Os
.Sh NAME
@@ -494,6 +494,7 @@ flags are given, the TTY and CPU displays will be displayed.
.Xr ps 1 ,
.Xr systat 1 ,
.Xr devstat 3 ,
+.Xr ctlstat 8 ,
.Xr gstat 8 ,
.Xr pstat 8 ,
.Xr vmstat 8
diff --git a/usr.sbin/iovctl/iovctl.c b/usr.sbin/iovctl/iovctl.c
index faa9586..dbf29d8 100644
--- a/usr.sbin/iovctl/iovctl.c
+++ b/usr.sbin/iovctl/iovctl.c
@@ -80,7 +80,7 @@ get_schema(int fd)
err(1, "Could not fetch config schema");
}
- schema = nvlist_unpack(arg.schema, arg.len);
+ schema = nvlist_unpack(arg.schema, arg.len, NV_FLAG_IGNORE_CASE);
if (schema == NULL)
err(1, "Could not unpack schema");
diff --git a/usr.sbin/kbdmap/kbdmap.c b/usr.sbin/kbdmap/kbdmap.c
index bf2aa81..08c0d77 100644
--- a/usr.sbin/kbdmap/kbdmap.c
+++ b/usr.sbin/kbdmap/kbdmap.c
@@ -571,7 +571,7 @@ menu_read(void)
char *p;
int mark, num_keymaps, items, i;
char buffer[256], filename[PATH_MAX];
- char keym[64], lng[64], desc[64];
+ char keym[64], lng[64], desc[256];
char dialect[64], lang_abk[64];
struct keymap *km;
struct keymap **km_sorted;
@@ -616,7 +616,7 @@ menu_read(void)
continue;
/* Parse input, removing newline */
- matches = sscanf(p, "%64[^:]:%64[^:]:%64[^:\n]",
+ matches = sscanf(p, "%64[^:]:%64[^:]:%256[^:\n]",
keym, lng, desc);
if (matches == 3) {
if (strcmp(keym, "FONT")
diff --git a/usr.sbin/mountd/mountd.8 b/usr.sbin/mountd/mountd.8
index fe73743..4dbf5ff 100644
--- a/usr.sbin/mountd/mountd.8
+++ b/usr.sbin/mountd/mountd.8
@@ -38,7 +38,7 @@
mount requests
.Sh SYNOPSIS
.Nm
-.Op Fl 2delnorS
+.Op Fl 2delnrS
.Op Fl h Ar bindip
.Op Fl p Ar port
.Op Ar exportsfile ...
@@ -69,8 +69,7 @@ Output debugging information.
will not detach from the controlling terminal and will print
debugging messages to stderr.
.It Fl e
-The new NFS server that includes NFSv4 support is now the default, so this
-option is now a no-op and should be considered deprecated.
+Ignored; included for backward compatibility.
.It Fl h Ar bindip
Specify specific IP addresses to bind to for TCP and UDP requests.
This option may be specified multiple times.
@@ -98,9 +97,6 @@ This should only be specified if there are clients such as PC's,
that require it.
It will automatically clear the vfs.nfsrv.nfs_privport sysctl flag, which
controls if the kernel will accept NFS requests from reserved ports only.
-.It Fl o
-This flag forces the system to run the old NFS server, which does not
-have NFSv4 support in it.
.It Fl p Ar port
Force
.Nm
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index d71f1d9..d916577 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -253,7 +253,6 @@ static int have_v6 = 1;
int v4root_phase = 0;
char v4root_dirpath[PATH_MAX + 1];
-int run_v4server = 1;
int has_publicfh = 0;
struct pidfh *pfh = NULL;
@@ -312,7 +311,7 @@ main(int argc, char **argv)
else
close(s);
- while ((c = getopt(argc, argv, "2deh:lnop:rS")) != -1)
+ while ((c = getopt(argc, argv, "2deh:lnp:rS")) != -1)
switch (c) {
case '2':
force_v2 = 1;
@@ -332,9 +331,6 @@ main(int argc, char **argv)
case 'l':
dolog = 1;
break;
- case 'o':
- run_v4server = 0;
- break;
case 'p':
endptr = NULL;
svcport = (in_port_t)strtoul(optarg, &endptr, 10);
@@ -371,19 +367,9 @@ main(int argc, char **argv)
usage();
};
- /*
- * Unless the "-o" option was specified, try and run "nfsd".
- * If "-o" was specified, try and run "nfsserver".
- */
- if (run_v4server > 0) {
- if (modfind("nfsd") < 0) {
- /* Not present in kernel, try loading it */
- if (kldload("nfsd") < 0 || modfind("nfsd") < 0)
- errx(1, "NFS server is not available");
- }
- } else if (modfind("nfsserver") < 0) {
+ if (modfind("nfsd") < 0) {
/* Not present in kernel, try loading it */
- if (kldload("nfsserver") < 0 || modfind("nfsserver") < 0)
+ if (kldload("nfsd") < 0 || modfind("nfsd") < 0)
errx(1, "NFS server is not available");
}
@@ -1424,6 +1410,9 @@ get_exportlist_one(void)
}
if (check_dirpath(cp) &&
statfs(cp, &fsb) >= 0) {
+ if ((fsb.f_flags & MNT_AUTOMOUNTED) != 0)
+ syslog(LOG_ERR, "Warning: exporting of "
+ "automounted fs %s not supported", cp);
if (got_nondir) {
syslog(LOG_ERR, "dirs must be first");
getexp_err(ep, tgrp);
@@ -1697,8 +1686,7 @@ get_exportlist(void)
*/
bzero(&eargs, sizeof (eargs));
eargs.export.ex_flags = MNT_DELEXPORT;
- if (run_v4server > 0 &&
- nfssvc(NFSSVC_V4ROOTEXPORT, (caddr_t)&eargs) < 0 &&
+ if (nfssvc(NFSSVC_V4ROOTEXPORT, (caddr_t)&eargs) < 0 &&
errno != ENOENT)
syslog(LOG_ERR, "Can't delete exports for V4:");
@@ -1803,7 +1791,7 @@ get_exportlist(void)
/*
* If there was no public fh, clear any previous one set.
*/
- if (run_v4server > 0 && has_publicfh == 0)
+ if (has_publicfh == 0)
(void) nfssvc(NFSSVC_NOPUBLICFH, NULL);
/* Resume the nfsd. If they weren't suspended, this is harmless. */
@@ -2400,7 +2388,7 @@ do_mount(struct exportlist *ep, struct grouplist *grp, int exflags,
{
struct statfs fsb1;
struct addrinfo *ai;
- struct export_args ea, *eap;
+ struct export_args *eap;
char errmsg[255];
char *cp;
int done;
@@ -2410,10 +2398,7 @@ do_mount(struct exportlist *ep, struct grouplist *grp, int exflags,
int ret;
struct nfsex_args nfsea;
- if (run_v4server > 0)
- eap = &nfsea.export;
- else
- eap = &ea;
+ eap = &nfsea.export;
cp = NULL;
savedc = '\0';
@@ -2493,8 +2478,7 @@ do_mount(struct exportlist *ep, struct grouplist *grp, int exflags,
*/
if (v4root_phase == 2) {
nfsea.fspec = v4root_dirpath;
- if (run_v4server > 0 &&
- nfssvc(NFSSVC_V4ROOTEXPORT, (caddr_t)&nfsea) < 0) {
+ if (nfssvc(NFSSVC_V4ROOTEXPORT, (caddr_t)&nfsea) < 0) {
syslog(LOG_ERR, "Exporting V4: failed");
return (2);
}
@@ -2583,7 +2567,7 @@ do_mount(struct exportlist *ep, struct grouplist *grp, int exflags,
* If this is the public directory, get the file handle
* and load it into the kernel via the nfssvc() syscall.
*/
- if (run_v4server > 0 && (exflags & MNT_EXPUBLIC) != 0) {
+ if ((exflags & MNT_EXPUBLIC) != 0) {
fhandle_t fh;
char *public_name;
diff --git a/usr.sbin/nfsd/nfsd.8 b/usr.sbin/nfsd/nfsd.8
index 9f2c6d4..d014a01 100644
--- a/usr.sbin/nfsd/nfsd.8
+++ b/usr.sbin/nfsd/nfsd.8
@@ -28,7 +28,7 @@
.\" @(#)nfsd.8 8.4 (Berkeley) 3/29/95
.\" $FreeBSD$
.\"
-.Dd January 1, 2015
+.Dd April 25, 2015
.Dt NFSD 8
.Os
.Sh NAME
@@ -38,7 +38,7 @@
server
.Sh SYNOPSIS
.Nm
-.Op Fl arduteo
+.Op Fl ardute
.Op Fl n Ar num_servers
.Op Fl h Ar bindip
.Op Fl Fl maxthreads Ar max_threads
@@ -112,10 +112,7 @@ Serve
.Tn UDP NFS
clients.
.It Fl e
-Enable NFSv4 support.
-It is enabled by default; this option should be considered deprecated.
-.It Fl o
-Disable NFSv4 support.
+Ignored; included for backward compatibility.
.El
.Pp
For example,
diff --git a/usr.sbin/nfsd/nfsd.c b/usr.sbin/nfsd/nfsd.c
index a0cb5a3..f58ed30 100644
--- a/usr.sbin/nfsd/nfsd.c
+++ b/usr.sbin/nfsd/nfsd.c
@@ -87,8 +87,6 @@ static int nfsdcnt; /* number of children */
static int nfsdcnt_set;
static int minthreads;
static int maxthreads;
-static int new_syscall;
-static int run_v4server = 1; /* Force running of nfsv4 server */
static int nfssvc_nfsd; /* Set to correct NFSSVC_xxx flag */
static int stablefd = -1; /* Fd for the stable restart file */
static int backupfd; /* Fd for the backup stable restart file */
@@ -156,7 +154,7 @@ main(int argc, char **argv)
socklen_t len;
int on = 1, unregister, reregister, sock;
int tcp6sock, ip6flag, tcpflag, tcpsock;
- int udpflag, ecode, error, s, srvcnt;
+ int udpflag, ecode, error, s;
int bindhostc, bindanyflag, rpcbreg, rpcbregcnt;
int nfssvc_addsock;
int longindex = 0;
@@ -167,10 +165,10 @@ main(int argc, char **argv)
nfsdcnt = DEFNFSDCNT;
unregister = reregister = tcpflag = maxsock = 0;
bindanyflag = udpflag = connect_type_cnt = bindhostc = 0;
- getopt_shortopts = "ah:n:rdtueo";
+ getopt_shortopts = "ah:n:rdtue";
getopt_usage =
"usage:\n"
- " nfsd [-ardtueo] [-h bindip]\n"
+ " nfsd [-ardtue] [-h bindip]\n"
" [-n numservers] [--minthreads #] [--maxthreads #]\n";
while ((ch = getopt_long(argc, argv, getopt_shortopts, longopts,
&longindex)) != -1)
@@ -205,9 +203,6 @@ main(int argc, char **argv)
case 'e':
/* now a no-op, since this is the default */
break;
- case 'o':
- run_v4server = 0;
- break;
case 0:
lopt = longopts[longindex].name;
if (!strcmp(lopt, "minthreads")) {
@@ -242,15 +237,9 @@ main(int argc, char **argv)
* Unless the "-o" option was specified, try and run "nfsd".
* If "-o" was specified, try and run "nfsserver".
*/
- if (run_v4server > 0) {
- if (modfind("nfsd") < 0) {
- /* Not present in kernel, try loading it */
- if (kldload("nfsd") < 0 || modfind("nfsd") < 0)
- errx(1, "NFS server is not available");
- }
- } else if (modfind("nfsserver") < 0) {
+ if (modfind("nfsd") < 0) {
/* Not present in kernel, try loading it */
- if (kldload("nfsserver") < 0 || modfind("nfsserver") < 0)
+ if (kldload("nfsd") < 0 || modfind("nfsd") < 0)
errx(1, "NFS server is not available");
}
@@ -392,55 +381,21 @@ main(int argc, char **argv)
* level write-back caching. (See SCSI doc for more information
* on how to prevent write-back caching on SCSI disks.)
*/
- if (run_v4server > 0) {
- open_stable(&stablefd, &backupfd);
- if (stablefd < 0) {
- syslog(LOG_ERR, "Can't open %s: %m\n", NFSD_STABLERESTART);
- exit(1);
- }
- /* This system call will fail for old kernels, but that's ok. */
- nfssvc(NFSSVC_BACKUPSTABLE, NULL);
- if (nfssvc(NFSSVC_STABLERESTART, (caddr_t)&stablefd) < 0) {
- syslog(LOG_ERR, "Can't read stable storage file: %m\n");
- exit(1);
- }
- nfssvc_addsock = NFSSVC_NFSDADDSOCK;
- nfssvc_nfsd = NFSSVC_NFSDNFSD;
- new_syscall = TRUE;
- } else {
- nfssvc_addsock = NFSSVC_ADDSOCK;
- nfssvc_nfsd = NFSSVC_NFSD;
- /*
- * Figure out if the kernel supports the new-style
- * NFSSVC_NFSD. Old kernels will return ENXIO because they
- * don't recognise the flag value, new ones will return EINVAL
- * because argp is NULL.
- */
- new_syscall = FALSE;
- if (nfssvc(NFSSVC_NFSD, NULL) < 0 && errno == EINVAL)
- new_syscall = TRUE;
+ open_stable(&stablefd, &backupfd);
+ if (stablefd < 0) {
+ syslog(LOG_ERR, "Can't open %s: %m\n", NFSD_STABLERESTART);
+ exit(1);
}
+ /* This system call will fail for old kernels, but that's ok. */
+ nfssvc(NFSSVC_BACKUPSTABLE, NULL);
+ if (nfssvc(NFSSVC_STABLERESTART, (caddr_t)&stablefd) < 0) {
+ syslog(LOG_ERR, "Can't read stable storage file: %m\n");
+ exit(1);
+ }
+ nfssvc_addsock = NFSSVC_NFSDADDSOCK;
+ nfssvc_nfsd = NFSSVC_NFSDNFSD;
- if (!new_syscall) {
- /* If we use UDP only, we start the last server below. */
- srvcnt = tcpflag ? nfsdcnt : nfsdcnt - 1;
- for (i = 0; i < srvcnt; i++) {
- switch ((pid = fork())) {
- case -1:
- syslog(LOG_ERR, "fork: %m");
- nfsd_exit(1);
- case 0:
- break;
- default:
- children[i] = pid;
- continue;
- }
- (void)signal(SIGUSR1, child_cleanup);
- setproctitle("server");
-
- start_server(0);
- }
- } else if (tcpflag) {
+ if (tcpflag) {
/*
* For TCP mode, we fork once to start the first
* kernel nfsd thread. The kernel will add more
@@ -976,11 +931,6 @@ get_tuned_nfsdcount(void)
} else {
tuned_nfsdcnt = ncpu * 8;
}
- if (!new_syscall && tuned_nfsdcnt > MAXNFSDCNT) {
- warnx("nfsd count %d; truncated to %d", tuned_nfsdcnt,
- MAXNFSDCNT);
- tuned_nfsdcnt = MAXNFSDCNT;
- }
return tuned_nfsdcnt;
}
@@ -994,55 +944,48 @@ start_server(int master)
struct addrinfo *aip, hints;
status = 0;
- if (new_syscall) {
- gethostname(hostname, sizeof (hostname));
- snprintf(principal, sizeof (principal), "nfs@%s", hostname);
- if ((cp = strchr(hostname, '.')) == NULL ||
- *(cp + 1) == '\0') {
- /* If not fully qualified, try getaddrinfo() */
- memset((void *)&hints, 0, sizeof (hints));
- hints.ai_flags = AI_CANONNAME;
- error = getaddrinfo(hostname, NULL, &hints, &aip);
- if (error == 0) {
- if (aip->ai_canonname != NULL &&
- (cp = strchr(aip->ai_canonname, '.')) !=
- NULL && *(cp + 1) != '\0')
- snprintf(principal, sizeof (principal),
- "nfs@%s", aip->ai_canonname);
- freeaddrinfo(aip);
- }
+ gethostname(hostname, sizeof (hostname));
+ snprintf(principal, sizeof (principal), "nfs@%s", hostname);
+ if ((cp = strchr(hostname, '.')) == NULL ||
+ *(cp + 1) == '\0') {
+ /* If not fully qualified, try getaddrinfo() */
+ memset((void *)&hints, 0, sizeof (hints));
+ hints.ai_flags = AI_CANONNAME;
+ error = getaddrinfo(hostname, NULL, &hints, &aip);
+ if (error == 0) {
+ if (aip->ai_canonname != NULL &&
+ (cp = strchr(aip->ai_canonname, '.')) !=
+ NULL && *(cp + 1) != '\0')
+ snprintf(principal, sizeof (principal),
+ "nfs@%s", aip->ai_canonname);
+ freeaddrinfo(aip);
}
- nfsdargs.principal = principal;
+ }
+ nfsdargs.principal = principal;
- if (nfsdcnt_set)
- nfsdargs.minthreads = nfsdargs.maxthreads = nfsdcnt;
- else {
- nfsdargs.minthreads = minthreads_set ? minthreads : get_tuned_nfsdcount();
- nfsdargs.maxthreads = maxthreads_set ? maxthreads : nfsdargs.minthreads;
- if (nfsdargs.maxthreads < nfsdargs.minthreads)
- nfsdargs.maxthreads = nfsdargs.minthreads;
- }
+ if (nfsdcnt_set)
+ nfsdargs.minthreads = nfsdargs.maxthreads = nfsdcnt;
+ else {
+ nfsdargs.minthreads = minthreads_set ? minthreads : get_tuned_nfsdcount();
+ nfsdargs.maxthreads = maxthreads_set ? maxthreads : nfsdargs.minthreads;
+ if (nfsdargs.maxthreads < nfsdargs.minthreads)
+ nfsdargs.maxthreads = nfsdargs.minthreads;
+ }
+ error = nfssvc(nfssvc_nfsd, &nfsdargs);
+ if (error < 0 && errno == EAUTH) {
+ /*
+ * This indicates that it could not register the
+ * rpcsec_gss credentials, usually because the
+ * gssd daemon isn't running.
+ * (only the experimental server with nfsv4)
+ */
+ syslog(LOG_ERR, "No gssd, using AUTH_SYS only");
+ principal[0] = '\0';
error = nfssvc(nfssvc_nfsd, &nfsdargs);
- if (error < 0 && errno == EAUTH) {
- /*
- * This indicates that it could not register the
- * rpcsec_gss credentials, usually because the
- * gssd daemon isn't running.
- * (only the experimental server with nfsv4)
- */
- syslog(LOG_ERR, "No gssd, using AUTH_SYS only");
- principal[0] = '\0';
- error = nfssvc(nfssvc_nfsd, &nfsdargs);
- }
- if (error < 0) {
- syslog(LOG_ERR, "nfssvc: %m");
- status = 1;
- }
- } else {
- if (nfssvc(NFSSVC_OLDNFSD, NULL) < 0) {
- syslog(LOG_ERR, "nfssvc: %m");
- status = 1;
- }
+ }
+ if (error < 0) {
+ syslog(LOG_ERR, "nfssvc: %m");
+ status = 1;
}
if (master)
nfsd_exit(status);
diff --git a/usr.sbin/ntp/config.h b/usr.sbin/ntp/config.h
index b771834..8bcf6e6 100644
--- a/usr.sbin/ntp/config.h
+++ b/usr.sbin/ntp/config.h
@@ -1418,7 +1418,7 @@
#define PACKAGE_NAME "ntp"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "ntp 4.2.8p1"
+#define PACKAGE_STRING "ntp 4.2.8p2"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "ntp"
@@ -1427,7 +1427,7 @@
#define PACKAGE_URL "http://www.ntp.org./"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "4.2.8p1"
+#define PACKAGE_VERSION "4.2.8p2"
/* data dir */
#define PERLLIBDIR "/usr/local/share/ntp/lib"
@@ -1469,13 +1469,21 @@
/* #undef SCO5_CLOCK */
/* The size of `char*', as computed by sizeof. */
+#if defined(__alpha__) || defined(__sparc64__) || defined(__amd64__)
#define SIZEOF_CHARP 8
+#else
+#define SIZEOF_CHARP 4
+#endif
/* The size of `int', as computed by sizeof. */
#define SIZEOF_INT 4
/* The size of `long', as computed by sizeof. */
+#if defined(__alpha__) || defined(__sparc64__) || defined(__amd64__)
#define SIZEOF_LONG 8
+#else
+#define SIZEOF_LONG 4
+#endif
/* The size of `long long', as computed by sizeof. */
#define SIZEOF_LONG_LONG 8
@@ -1490,7 +1498,11 @@
#define SIZEOF_SIGNED_CHAR 1
/* The size of `time_t', as computed by sizeof. */
+#if defined(__alpha__) || defined(__sparc64__) || defined(__amd64__)
#define SIZEOF_TIME_T 8
+#else
+#define SIZEOF_TIME_T 4
+#endif
/* Does SIOCGIFCONF return size in the buffer? */
/* #undef SIZE_RETURNED_IN_BUFFER */
@@ -1516,7 +1528,15 @@
/* #undef STRERROR_R_CHAR_P */
/* canonical system (cpu-vendor-os) of where we should run */
-#define STR_SYSTEM "amd64-portbld-freebsd10.1"
+#if defined(__alpha__)
+#define STR_SYSTEM "alpha-undermydesk-freebsd"
+#elif defined(__sparc64__)
+#define STR_SYSTEM "sparc64-undermydesk-freebsd"
+#elif defined(__amd64__)
+#define STR_SYSTEM "amd64-undermydesk-freebsd"
+#else
+#define STR_SYSTEM "i386-undermydesk-freebsd"
+#endif
/* Does Xettimeofday take 1 arg? */
/* #undef SYSV_TIMEOFDAY */
@@ -1570,7 +1590,7 @@ typedef unsigned int uintptr_t;
/* #undef USE_UDP_SIGPOLL */
/* Version number of package */
-#define VERSION "4.2.8p1"
+#define VERSION "4.2.8p2"
/* vsnprintf expands "%m" to strerror(errno) */
/* #undef VSNPRINTF_PERCENT_M */
diff --git a/usr.sbin/ntp/doc/ntptime.8 b/usr.sbin/ntp/doc/ntptime.8
index f130307..bb3b41a 100644
--- a/usr.sbin/ntp/doc/ntptime.8
+++ b/usr.sbin/ntp/doc/ntptime.8
@@ -1,7 +1,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd January 7, 2000
+.Dd April 27, 2015
.Dt NTPTIME 8
.Os
.Sh NAME
@@ -52,8 +52,6 @@ Specify estimated error, in microseconds.
Specify frequency offset, in parts per million.
.It Fl h
Display help information.
-.It Fl l
-Specify the leap bits as a code from 0 to 3.
.It Fl m Ar max_error
Specify max possible errors, in microseconds.
.It Fl o Ar offset
diff --git a/usr.sbin/ntp/scripts/mkver b/usr.sbin/ntp/scripts/mkver
index bc0e935..f34267d 100755
--- a/usr.sbin/ntp/scripts/mkver
+++ b/usr.sbin/ntp/scripts/mkver
@@ -6,7 +6,7 @@ PROG=${1-UNKNOWN}
ConfStr="$PROG"
-ConfStr="$ConfStr 4.2.8p1"
+ConfStr="$ConfStr 4.2.8p2"
case "$CSET" in
'') ;;
diff --git a/usr.sbin/pmcstat/pmcstat.8 b/usr.sbin/pmcstat/pmcstat.8
index 9a204a4..6478241 100644
--- a/usr.sbin/pmcstat/pmcstat.8
+++ b/usr.sbin/pmcstat/pmcstat.8
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 27, 2015
+.Dd May 8, 2015
.Dt PMCSTAT 8
.Os
.Sh NAME
@@ -279,8 +279,9 @@ Set the pathname of the kernel directory to argument
This directory specifies where
.Nm
should look for the kernel and its modules.
-The default is
-.Pa /boot/kernel .
+The default is to use the path of the running kernel obtained from the
+.Va kern.bootfile
+sysctl.
.It Fl l Ar secs
Set system-wide performance measurement duration for
.Ar secs
diff --git a/usr.sbin/pmcstat/pmcstat.c b/usr.sbin/pmcstat/pmcstat.c
index 77613b4..c7f36bc 100644
--- a/usr.sbin/pmcstat/pmcstat.c
+++ b/usr.sbin/pmcstat/pmcstat.c
@@ -557,7 +557,7 @@ main(int argc, char **argv)
int c, check_driver_stats, current_sampling_count;
int do_callchain, do_descendants, do_logproccsw, do_logprocexit;
int do_print, do_read;
- size_t dummy;
+ size_t len;
int graphdepth;
int pipefd[2], rfd;
int use_cumulative_counts;
@@ -586,7 +586,6 @@ main(int argc, char **argv)
args.pa_verbosity = 1;
args.pa_logfd = -1;
args.pa_fsroot = "";
- args.pa_kernel = strdup("/boot/kernel");
args.pa_samplesdir = ".";
args.pa_printfile = stderr;
args.pa_graphdepth = DEFAULT_CALLGRAPH_DEPTH;
@@ -610,12 +609,20 @@ main(int argc, char **argv)
ev = NULL;
CPU_ZERO(&cpumask);
+ /* Default to using the running system kernel. */
+ len = 0;
+ if (sysctlbyname("kern.bootfile", NULL, &len, NULL, 0) == -1)
+ err(EX_OSERR, "ERROR: Cannot determine path of running kernel");
+ args.pa_kernel = malloc(len + 1);
+ if (sysctlbyname("kern.bootfile", args.pa_kernel, &len, NULL, 0) == -1)
+ err(EX_OSERR, "ERROR: Cannot determine path of running kernel");
+
/*
* The initial CPU mask specifies all non-halted CPUS in the
* system.
*/
- dummy = sizeof(int);
- if (sysctlbyname("hw.ncpu", &ncpu, &dummy, NULL, 0) < 0)
+ len = sizeof(int);
+ if (sysctlbyname("hw.ncpu", &ncpu, &len, NULL, 0) < 0)
err(EX_OSERR, "ERROR: Cannot determine the number of CPUs");
for (hcpu = 0; hcpu < ncpu; hcpu++)
CPU_SET(hcpu, &cpumask);
@@ -1061,33 +1068,31 @@ main(int argc, char **argv)
);
/*
- * Check if "-k kerneldir" was specified, and if whether
- * 'kerneldir' actually refers to a file. If so, use
- * `dirname path` to determine the kernel directory.
+ * Check if 'kerneldir' refers to a file rather than a
+ * directory. If so, use `dirname path` to determine the
+ * kernel directory.
*/
- if (args.pa_flags & FLAG_HAS_KERNELPATH) {
- (void) snprintf(buffer, sizeof(buffer), "%s%s", args.pa_fsroot,
- args.pa_kernel);
+ (void) snprintf(buffer, sizeof(buffer), "%s%s", args.pa_fsroot,
+ args.pa_kernel);
+ if (stat(buffer, &sb) < 0)
+ err(EX_OSERR, "ERROR: Cannot locate kernel \"%s\"",
+ buffer);
+ if (!S_ISREG(sb.st_mode) && !S_ISDIR(sb.st_mode))
+ errx(EX_USAGE, "ERROR: \"%s\": Unsupported file type.",
+ buffer);
+ if (!S_ISDIR(sb.st_mode)) {
+ tmp = args.pa_kernel;
+ args.pa_kernel = strdup(dirname(args.pa_kernel));
+ free(tmp);
+ (void) snprintf(buffer, sizeof(buffer), "%s%s",
+ args.pa_fsroot, args.pa_kernel);
if (stat(buffer, &sb) < 0)
- err(EX_OSERR, "ERROR: Cannot locate kernel \"%s\"",
+ err(EX_OSERR, "ERROR: Cannot stat \"%s\"",
buffer);
- if (!S_ISREG(sb.st_mode) && !S_ISDIR(sb.st_mode))
- errx(EX_USAGE, "ERROR: \"%s\": Unsupported file type.",
+ if (!S_ISDIR(sb.st_mode))
+ errx(EX_USAGE,
+ "ERROR: \"%s\" is not a directory.",
buffer);
- if (!S_ISDIR(sb.st_mode)) {
- tmp = args.pa_kernel;
- args.pa_kernel = strdup(dirname(args.pa_kernel));
- free(tmp);
- (void) snprintf(buffer, sizeof(buffer), "%s%s",
- args.pa_fsroot, args.pa_kernel);
- if (stat(buffer, &sb) < 0)
- err(EX_OSERR, "ERROR: Cannot stat \"%s\"",
- buffer);
- if (!S_ISDIR(sb.st_mode))
- errx(EX_USAGE,
- "ERROR: \"%s\" is not a directory.",
- buffer);
- }
}
/*
diff --git a/usr.sbin/pmcstat/pmcstat_log.c b/usr.sbin/pmcstat/pmcstat_log.c
index 40de320..fbc358d 100644
--- a/usr.sbin/pmcstat/pmcstat_log.c
+++ b/usr.sbin/pmcstat/pmcstat_log.c
@@ -716,7 +716,8 @@ pmcstat_image_get_elf_params(struct pmcstat_image *image)
ph.p_offset);
break;
case PT_LOAD:
- if ((ph.p_offset & (-ph.p_align)) == 0)
+ if ((ph.p_flags & PF_X) != 0 &&
+ (ph.p_offset & (-ph.p_align)) == 0)
image->pi_vaddr = ph.p_vaddr & (-ph.p_align);
break;
}
@@ -1531,7 +1532,9 @@ pmcstat_analyze_log(void)
free(ppm);
}
- /* associate this process image */
+ /*
+ * Associate this process image.
+ */
image_path = pmcstat_string_intern(
ev.pl_u.pl_x.pl_pathname);
assert(image_path != NULL);
diff --git a/usr.sbin/pw/Makefile b/usr.sbin/pw/Makefile
index 269b145..69953da 100644
--- a/usr.sbin/pw/Makefile
+++ b/usr.sbin/pw/Makefile
@@ -8,7 +8,7 @@ SRCS= pw.c pw_conf.c pw_user.c pw_group.c pw_log.c pw_nis.c pw_vpw.c \
WARNS?= 2
-LIBADD= crypt util
+LIBADD= crypt util sbuf
.include <src.opts.mk>
diff --git a/usr.sbin/pw/fileupd.c b/usr.sbin/pw/fileupd.c
index 7df4bb1..dc32712 100644
--- a/usr.sbin/pw/fileupd.c
+++ b/usr.sbin/pw/fileupd.c
@@ -29,32 +29,11 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
-#include <stdio.h>
-#include <fcntl.h>
#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <errno.h>
-#include <unistd.h>
#include "pwupd.h"
int
-extendline(char **buf, int * buflen, int needed)
-{
- if (needed > *buflen) {
- char *tmp = realloc(*buf, needed);
- if (tmp == NULL)
- return -1;
- *buf = tmp;
- *buflen = needed;
- }
- return *buflen;
-}
-
-int
extendarray(char ***buf, int * buflen, int needed)
{
if (needed > *buflen) {
diff --git a/usr.sbin/pw/grupd.c b/usr.sbin/pw/grupd.c
index 3f78e95..74cc390 100644
--- a/usr.sbin/pw/grupd.c
+++ b/usr.sbin/pw/grupd.c
@@ -35,10 +35,6 @@ static const char rcsid[] =
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <sys/param.h>
#include "pwupd.h"
diff --git a/usr.sbin/pw/pw_conf.c b/usr.sbin/pw/pw_conf.c
index 1289b3e..99d3e8f 100644
--- a/usr.sbin/pw/pw_conf.c
+++ b/usr.sbin/pw/pw_conf.c
@@ -29,9 +29,12 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
+#include <sys/types.h>
+#include <sys/sbuf.h>
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
+#include <err.h>
#include "pw.h"
@@ -209,19 +212,16 @@ boolean_str(int val)
char *
newstr(char const * p)
{
- char *q = NULL;
+ char *q;
- if ((p = unquote(p)) != NULL) {
- int l = strlen(p) + 1;
+ if ((p = unquote(p)) == NULL)
+ return (NULL);
- if ((q = malloc(l)) != NULL)
- memcpy(q, p, l);
- }
- return q;
-}
-
-#define LNBUFSZ 1024
+ if ((q = strdup(p)) == NULL)
+ err(1, "strdup()");
+ return (q);
+}
struct userconf *
read_userconfig(char const * file)
@@ -234,8 +234,10 @@ read_userconfig(char const * file)
buf = NULL;
linecap = 0;
- extendarray(&config.groups, &config.numgroups, 200);
- memset(config.groups, 0, config.numgroups * sizeof(char *));
+ config.numgroups = 200;
+ config.groups = calloc(config.numgroups, sizeof(char *));
+ if (config.groups == NULL)
+ err(1, "calloc()");
if (file == NULL)
file = _PATH_PW_CONF;
@@ -366,138 +368,132 @@ int
write_userconfig(char const * file)
{
int fd;
+ int i, j;
+ struct sbuf *buf;
+ FILE *fp;
if (file == NULL)
file = _PATH_PW_CONF;
- if ((fd = open(file, O_CREAT | O_RDWR | O_TRUNC | O_EXLOCK, 0644)) != -1) {
- FILE *fp;
+ if ((fd = open(file, O_CREAT|O_RDWR|O_TRUNC|O_EXLOCK, 0644)) == -1)
+ return (0);
- if ((fp = fdopen(fd, "w")) == NULL)
- close(fd);
- else {
- int i, j, k;
- int len = LNBUFSZ;
- char *buf = malloc(len);
-
- for (i = _UC_NONE; i < _UC_FIELDS; i++) {
- int quote = 1;
- char const *val = buf;
-
- *buf = '\0';
- switch (i) {
- case _UC_DEFAULTPWD:
- val = boolean_str(config.default_password);
- break;
- case _UC_REUSEUID:
- val = boolean_str(config.reuse_uids);
- break;
- case _UC_REUSEGID:
- val = boolean_str(config.reuse_gids);
- break;
- case _UC_NISPASSWD:
- val = config.nispasswd ? config.nispasswd : "";
- quote = 0;
- break;
- case _UC_DOTDIR:
- val = config.dotdir ? config.dotdir : boolean_str(0);
- break;
- case _UC_NEWMAIL:
- val = config.newmail ? config.newmail : boolean_str(0);
- break;
- case _UC_LOGFILE:
- val = config.logfile ? config.logfile : boolean_str(0);
- break;
- case _UC_HOMEROOT:
- val = config.home;
- break;
- case _UC_HOMEMODE:
- sprintf(buf, "%04o", config.homemode);
- quote = 0;
- break;
- case _UC_SHELLPATH:
- val = config.shelldir;
- break;
- case _UC_SHELLS:
- for (j = k = 0; j < _UC_MAXSHELLS && system_shells[j] != NULL; j++) {
- char lbuf[64];
- int l = snprintf(lbuf, sizeof lbuf, "%s\"%s\"", k ? "," : "", system_shells[j]);
- if (l < 0)
- l = 0;
- if (l + k + 1 < len || extendline(&buf, &len, len + LNBUFSZ) != -1) {
- strcpy(buf + k, lbuf);
- k += l;
- }
- }
- quote = 0;
- break;
- case _UC_DEFAULTSHELL:
- val = config.shell_default ? config.shell_default : bourne_shell;
- break;
- case _UC_DEFAULTGROUP:
- val = config.default_group ? config.default_group : "";
- break;
- case _UC_EXTRAGROUPS:
- extendarray(&config.groups, &config.numgroups, 200);
- for (j = k = 0; j < config.numgroups && config.groups[j] != NULL; j++) {
- char lbuf[64];
- int l = snprintf(lbuf, sizeof lbuf, "%s\"%s\"", k ? "," : "", config.groups[j]);
- if (l < 0)
- l = 0;
- if (l + k + 1 < len || extendline(&buf, &len, len + 1024) != -1) {
- strcpy(buf + k, lbuf);
- k += l;
- }
- }
- quote = 0;
- break;
- case _UC_DEFAULTCLASS:
- val = config.default_class ? config.default_class : "";
- break;
- case _UC_MINUID:
- sprintf(buf, "%lu", (unsigned long) config.min_uid);
- quote = 0;
- break;
- case _UC_MAXUID:
- sprintf(buf, "%lu", (unsigned long) config.max_uid);
- quote = 0;
- break;
- case _UC_MINGID:
- sprintf(buf, "%lu", (unsigned long) config.min_gid);
- quote = 0;
- break;
- case _UC_MAXGID:
- sprintf(buf, "%lu", (unsigned long) config.max_gid);
- quote = 0;
- break;
- case _UC_EXPIRE:
- sprintf(buf, "%d", config.expire_days);
- quote = 0;
- break;
- case _UC_PASSWORD:
- sprintf(buf, "%d", config.password_days);
- quote = 0;
- break;
- case _UC_NONE:
- break;
- }
+ if ((fp = fdopen(fd, "w")) == NULL) {
+ close(fd);
+ return (0);
+ }
+
+ buf = sbuf_new_auto();
+ for (i = _UC_NONE; i < _UC_FIELDS; i++) {
+ int quote = 1;
+
+ sbuf_clear(buf);
+ switch (i) {
+ case _UC_DEFAULTPWD:
+ sbuf_cat(buf, boolean_str(config.default_password));
+ break;
+ case _UC_REUSEUID:
+ sbuf_cat(buf, boolean_str(config.reuse_uids));
+ break;
+ case _UC_REUSEGID:
+ sbuf_cat(buf, boolean_str(config.reuse_gids));
+ break;
+ case _UC_NISPASSWD:
+ sbuf_cat(buf, config.nispasswd ? config.nispasswd :
+ "");
+ quote = 0;
+ break;
+ case _UC_DOTDIR:
+ sbuf_cat(buf, config.dotdir ? config.dotdir :
+ boolean_str(0));
+ break;
+ case _UC_NEWMAIL:
+ sbuf_cat(buf, config.newmail ? config.newmail :
+ boolean_str(0));
+ break;
+ case _UC_LOGFILE:
+ sbuf_cat(buf, config.logfile ? config.logfile :
+ boolean_str(0));
+ break;
+ case _UC_HOMEROOT:
+ sbuf_cat(buf, config.home);
+ break;
+ case _UC_HOMEMODE:
+ sbuf_printf(buf, "%04o", config.homemode);
+ quote = 0;
+ break;
+ case _UC_SHELLPATH:
+ sbuf_cat(buf, config.shelldir);
+ break;
+ case _UC_SHELLS:
+ for (j = 0; j < _UC_MAXSHELLS &&
+ system_shells[j] != NULL; j++)
+ sbuf_printf(buf, "%s\"%s\"", j ?
+ "," : "", system_shells[j]);
+ quote = 0;
+ break;
+ case _UC_DEFAULTSHELL:
+ sbuf_cat(buf, config.shell_default ?
+ config.shell_default : bourne_shell);
+ break;
+ case _UC_DEFAULTGROUP:
+ sbuf_cat(buf, config.default_group ?
+ config.default_group : "");
+ break;
+ case _UC_EXTRAGROUPS:
+ for (j = 0; j < config.numgroups &&
+ config.groups[j] != NULL; j++)
+ sbuf_printf(buf, "%s\"%s\"", j ?
+ "," : "", config.groups[j]);
+ quote = 0;
+ break;
+ case _UC_DEFAULTCLASS:
+ sbuf_cat(buf, config.default_class ?
+ config.default_class : "");
+ break;
+ case _UC_MINUID:
+ sbuf_printf(buf, "%lu", (unsigned long) config.min_uid);
+ quote = 0;
+ break;
+ case _UC_MAXUID:
+ sbuf_printf(buf, "%lu", (unsigned long) config.max_uid);
+ quote = 0;
+ break;
+ case _UC_MINGID:
+ sbuf_printf(buf, "%lu", (unsigned long) config.min_gid);
+ quote = 0;
+ break;
+ case _UC_MAXGID:
+ sbuf_printf(buf, "%lu", (unsigned long) config.max_gid);
+ quote = 0;
+ break;
+ case _UC_EXPIRE:
+ sbuf_printf(buf, "%d", config.expire_days);
+ quote = 0;
+ break;
+ case _UC_PASSWORD:
+ sbuf_printf(buf, "%d", config.password_days);
+ quote = 0;
+ break;
+ case _UC_NONE:
+ break;
+ }
+ sbuf_finish(buf);
- if (comments[i])
- fputs(comments[i], fp);
+ if (comments[i])
+ fputs(comments[i], fp);
- if (*kwds[i]) {
- if (quote)
- fprintf(fp, "%s = \"%s\"\n", kwds[i], val);
- else
- fprintf(fp, "%s = %s\n", kwds[i], val);
+ if (*kwds[i]) {
+ if (quote)
+ fprintf(fp, "%s = \"%s\"\n", kwds[i],
+ sbuf_data(buf));
+ else
+ fprintf(fp, "%s = %s\n", kwds[i], sbuf_data(buf));
#if debugging
- printf("WROTE: %s = %s\n", kwds[i], val);
+ printf("WROTE: %s = %s\n", kwds[i], sbuf_data(buf));
#endif
- }
- }
- free(buf);
- return fclose(fp) != EOF;
}
}
- return 0;
+ sbuf_delete(buf);
+ return (fclose(fp) != EOF);
}
diff --git a/usr.sbin/pw/pw_nis.c b/usr.sbin/pw/pw_nis.c
index 918fc30..c786cc7 100644
--- a/usr.sbin/pw/pw_nis.c
+++ b/usr.sbin/pw/pw_nis.c
@@ -29,9 +29,6 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <sys/types.h>
#include <err.h>
#include <pwd.h>
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index 483148a..b058aab 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -40,7 +40,6 @@ static const char rcsid[] =
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
-#include <unistd.h>
#include <login_cap.h>
#include <pwd.h>
#include <grp.h>
@@ -185,8 +184,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
* But we create a symlink from cnf->home -> "/usr" -> cnf->home
*/
if (strchr(cnf->home+1, '/') == NULL) {
- strcpy(dbuf, "/usr");
- strncat(dbuf, cnf->home, MAXPATHLEN-5);
+ snprintf(dbuf, MAXPATHLEN, "/usr%s", cnf->home);
if (mkdir(dbuf, _DEF_DIRMODE) != -1 || errno == EEXIST) {
chown(dbuf, 0, 0);
/*
@@ -364,11 +362,9 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
if (mode == M_LOCK) {
if (strncmp(pwd->pw_passwd, locked_str, sizeof(locked_str)-1) == 0)
errx(EX_DATAERR, "user '%s' is already locked", pwd->pw_name);
- passtmp = malloc(strlen(pwd->pw_passwd) + sizeof(locked_str));
+ asprintf(&passtmp, "%s%s", locked_str, pwd->pw_passwd);
if (passtmp == NULL) /* disaster */
errx(EX_UNAVAILABLE, "out of memory");
- strcpy(passtmp, locked_str);
- strcat(passtmp, pwd->pw_passwd);
pwd->pw_passwd = passtmp;
edited = 1;
} else if (mode == M_UNLOCK) {
@@ -401,7 +397,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
*/
snprintf(file, sizeof(file), "/var/cron/tabs/%s", pwd->pw_name);
if (access(file, F_OK) == 0) {
- sprintf(file, "crontab -u %s -r", pwd->pw_name);
+ snprintf(file, sizeof(file), "crontab -u %s -r", pwd->pw_name);
system(file);
}
}
@@ -409,7 +405,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
* Save these for later, since contents of pwd may be
* invalidated by deletion
*/
- sprintf(file, "%s/%s", _PATH_MAILDIR, pwd->pw_name);
+ snprintf(file, sizeof(file), "%s/%s", _PATH_MAILDIR, pwd->pw_name);
strlcpy(home, pwd->pw_dir, sizeof(home));
gr = GETGRGID(pwd->pw_gid);
if (gr != NULL)
@@ -815,7 +811,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
*/
if (mode == M_ADD) {
if (!PWALTDIR()) {
- sprintf(line, "%s/%s", _PATH_MAILDIR, pwd->pw_name);
+ snprintf(line, sizeof(line), "%s/%s", _PATH_MAILDIR, pwd->pw_name);
close(open(line, O_RDWR | O_CREAT, 0600)); /* Preserve contents &
* mtime */
chown(line, pwd->pw_uid, pwd->pw_gid);
@@ -959,7 +955,7 @@ pw_gidpolicy(struct userconf * cnf, struct cargs * args, char *nam, gid_t prefer
* function will happily handle that case for us and exit.
*/
if (GETGRGID(prefer) == NULL) {
- sprintf(tmp, "%lu", (unsigned long) prefer);
+ snprintf(tmp, sizeof(tmp), "%u", prefer);
addarg(&grpargs, 'g', tmp);
}
if (getarg(args, 'N'))
@@ -1022,17 +1018,16 @@ static char *
pw_homepolicy(struct userconf * cnf, struct cargs * args, char const * user)
{
struct carg *arg = getarg(args, 'd');
+ static char home[128];
if (arg)
- return arg->val;
- else {
- static char home[128];
+ return (arg->val);
- if (cnf->home == NULL || *cnf->home == '\0')
- errx(EX_CONFIG, "no base home directory set");
- sprintf(home, "%s/%s", cnf->home, user);
- return home;
- }
+ if (cnf->home == NULL || *cnf->home == '\0')
+ errx(EX_CONFIG, "no base home directory set");
+ snprintf(home, sizeof(home), "%s/%s", cnf->home, user);
+
+ return (home);
}
static char *
@@ -1053,12 +1048,12 @@ shell_path(char const * path, char *shells[], char *sh)
static char shellpath[256];
if (sh != NULL) {
- sprintf(shellpath, "%s/%s", p, sh);
+ snprintf(shellpath, sizeof(shellpath), "%s/%s", p, sh);
if (access(shellpath, X_OK) == 0)
return shellpath;
} else
for (i = 0; i < _UC_MAXSHELLS && shells[i] != NULL; i++) {
- sprintf(shellpath, "%s/%s", p, shells[i]);
+ snprintf(shellpath, sizeof(shellpath), "%s/%s", p, shells[i]);
if (access(shellpath, X_OK) == 0)
return shellpath;
}
@@ -1308,7 +1303,7 @@ rmat(uid_t uid)
st.st_uid == uid) {
char tmp[MAXPATHLEN];
- sprintf(tmp, "/usr/bin/atrm %s", e->d_name);
+ snprintf(tmp, sizeof(tmp), "/usr/bin/atrm %s", e->d_name);
system(tmp);
}
}
diff --git a/usr.sbin/pw/pwupd.c b/usr.sbin/pw/pwupd.c
index c2a9a53..710e901 100644
--- a/usr.sbin/pw/pwupd.c
+++ b/usr.sbin/pw/pwupd.c
@@ -33,7 +33,6 @@ static const char rcsid[] =
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <stdarg.h>
#include <pwd.h>
#include <libutil.h>
#include <errno.h>
@@ -52,12 +51,13 @@ int
setpwdir(const char * dir)
{
if (dir == NULL)
- return -1;
+ return (-1);
else
pwpath = strdup(dir);
if (pwpath == NULL)
- return -1;
- return 0;
+ return (-1);
+
+ return (0);
}
char *
@@ -66,23 +66,20 @@ getpwpath(char const * file)
static char pathbuf[MAXPATHLEN];
snprintf(pathbuf, sizeof pathbuf, "%s/%s", pwpath, file);
- return pathbuf;
+
+ return (pathbuf);
}
static int
-pwdb(char *arg,...)
+pwdb_check(void)
{
int i = 0;
pid_t pid;
- va_list ap;
char *args[10];
args[i++] = _PATH_PWD_MKDB;
- va_start(ap, arg);
- while (i < 6 && arg != NULL) {
- args[i++] = arg;
- arg = va_arg(ap, char *);
- }
+ args[i++] = "-C";
+
if (pwpath != pathpwd) {
args[i++] = "-d";
args[i++] = pwpath;
@@ -100,65 +97,66 @@ pwdb(char *arg,...)
if (WEXITSTATUS(i))
i = EIO;
}
- va_end(ap);
- return i;
+
+ return (i);
}
static int
pw_update(struct passwd * pwd, char const * user)
{
- int rc = 0;
-
- rc = pwdb("-C", (char *)NULL); /* Check only */
- if (rc == 0) {
- int pfd, tfd;
- struct passwd *pw = NULL;
- struct passwd *old_pw = NULL;
-
- if (pwd != NULL)
- pw = pw_dup(pwd);
-
- if (user != NULL)
- old_pw = GETPWNAM(user);
-
- if (pw_init(pwpath, NULL))
- err(1, "pw_init()");
- if ((pfd = pw_lock()) == -1) {
- pw_fini();
- err(1, "pw_lock()");
- }
- if ((tfd = pw_tmp(-1)) == -1) {
- pw_fini();
- err(1, "pw_tmp()");
- }
- if (pw_copy(pfd, tfd, pw, old_pw) == -1) {
- pw_fini();
- err(1, "pw_copy()");
- }
- /*
- * in case of deletion of a user, the whole database
- * needs to be regenerated
- */
- if (pw_mkdb(pw != NULL ? pw->pw_name : NULL) == -1) {
- pw_fini();
- err(1, "pw_mkdb()");
- }
- free(pw);
+ struct passwd *pw = NULL;
+ struct passwd *old_pw = NULL;
+ int rc, pfd, tfd;
+
+ if ((rc = pwdb_check()) != 0)
+ return (rc);
+
+ if (pwd != NULL)
+ pw = pw_dup(pwd);
+
+ if (user != NULL)
+ old_pw = GETPWNAM(user);
+
+ if (pw_init(pwpath, NULL))
+ err(1, "pw_init()");
+ if ((pfd = pw_lock()) == -1) {
pw_fini();
+ err(1, "pw_lock()");
}
- return 0;
+ if ((tfd = pw_tmp(-1)) == -1) {
+ pw_fini();
+ err(1, "pw_tmp()");
+ }
+ if (pw_copy(pfd, tfd, pw, old_pw) == -1) {
+ pw_fini();
+ err(1, "pw_copy()");
+ }
+ /*
+ * in case of deletion of a user, the whole database
+ * needs to be regenerated
+ */
+ if (pw_mkdb(pw != NULL ? pw->pw_name : NULL) == -1) {
+ pw_fini();
+ err(1, "pw_mkdb()");
+ }
+ free(pw);
+ pw_fini();
+
+ return (0);
}
int
addpwent(struct passwd * pwd)
{
- return pw_update(pwd, NULL);
+
+ return (pw_update(pwd, NULL));
}
int
chgpwent(char const * login, struct passwd * pwd)
{
- return pw_update(pwd, login);
+
+ return (pw_update(pwd, login));
}
int
@@ -167,5 +165,6 @@ delpwent(struct passwd * pwd)
char login[MAXLOGNAME];
strlcpy(login, pwd->pw_name, MAXLOGNAME);
- return pw_update(NULL, login);
+
+ return (pw_update(NULL, login));
}
diff --git a/usr.sbin/pw/pwupd.h b/usr.sbin/pw/pwupd.h
index 200ffee..d6e39ce 100644
--- a/usr.sbin/pw/pwupd.h
+++ b/usr.sbin/pw/pwupd.h
@@ -112,10 +112,7 @@ void vendgrent(void);
void copymkdir(char const * dir, char const * skel, mode_t mode, uid_t uid, gid_t gid);
void rm_r(char const * dir, uid_t uid);
-int extendline(char **buf, int *buflen, int needed);
int extendarray(char ***buf, int *buflen, int needed);
__END_DECLS
-#define PWBUFSZ 1024
-
#endif /* !_PWUPD_H */
diff --git a/usr.sbin/rtsold/if.c b/usr.sbin/rtsold/if.c
index 6274d0f..b8a90b6 100644
--- a/usr.sbin/rtsold/if.c
+++ b/usr.sbin/rtsold/if.c
@@ -247,9 +247,7 @@ lladdropt_length(struct sockaddr_dl *sdl)
{
switch (sdl->sdl_type) {
case IFT_ETHER:
-#ifdef IFT_IEEE80211
case IFT_IEEE80211:
-#endif
return (ROUNDUP8(ETHER_ADDR_LEN + 2));
default:
return (0);
@@ -265,9 +263,7 @@ lladdropt_fill(struct sockaddr_dl *sdl, struct nd_opt_hdr *ndopt)
switch (sdl->sdl_type) {
case IFT_ETHER:
-#ifdef IFT_IEEE80211
case IFT_IEEE80211:
-#endif
ndopt->nd_opt_len = (ROUNDUP8(ETHER_ADDR_LEN + 2)) >> 3;
addr = (char *)(ndopt + 1);
memcpy(addr, LLADDR(sdl), ETHER_ADDR_LEN);
diff --git a/usr.sbin/syslogd/pathnames.h b/usr.sbin/syslogd/pathnames.h
index 24fbc4c..00631e0 100644
--- a/usr.sbin/syslogd/pathnames.h
+++ b/usr.sbin/syslogd/pathnames.h
@@ -30,8 +30,6 @@
* $FreeBSD$
*/
-#include <paths.h>
-
#define _PATH_KLOG "/dev/klog"
#define _PATH_LOGCONF "/etc/syslog.conf"
#define _PATH_LOGPID "/var/run/syslog.pid"
diff --git a/usr.sbin/uefisign/pe.c b/usr.sbin/uefisign/pe.c
index 26bb6d5..f4695b4 100644
--- a/usr.sbin/uefisign/pe.c
+++ b/usr.sbin/uefisign/pe.c
@@ -346,7 +346,9 @@ static void
parse_optional_32_plus(struct executable *x, off_t off,
int number_of_sections)
{
+#if 0
uint32_t computed_checksum;
+#endif
const struct pe_optional_header_32_plus *po;
range_check(x, off, sizeof(*po), "PE Optional Header");
@@ -373,13 +375,13 @@ parse_optional_32_plus(struct executable *x, off_t off,
#if 0
printf("checksum 0x%x at offset %zd, len %zd\n",
po->po_checksum, x->x_checksum_off, x->x_checksum_len);
-#endif
computed_checksum = compute_checksum(x);
if (computed_checksum != po->po_checksum) {
warnx("invalid PE+ checksum; is 0x%x, should be 0x%x",
po->po_checksum, computed_checksum);
}
+#endif
if (x->x_len < x->x_headers_len)
errx(1, "invalid SizeOfHeaders %d", po->po_size_of_headers);
@@ -393,7 +395,9 @@ parse_optional_32_plus(struct executable *x, off_t off,
static void
parse_optional_32(struct executable *x, off_t off, int number_of_sections)
{
+#if 0
uint32_t computed_checksum;
+#endif
const struct pe_optional_header_32 *po;
range_check(x, off, sizeof(*po), "PE Optional Header");
@@ -420,13 +424,13 @@ parse_optional_32(struct executable *x, off_t off, int number_of_sections)
#if 0
printf("checksum at offset %zd, len %zd\n",
x->x_checksum_off, x->x_checksum_len);
-#endif
computed_checksum = compute_checksum(x);
if (computed_checksum != po->po_checksum) {
warnx("invalid PE checksum; is 0x%x, should be 0x%x",
po->po_checksum, computed_checksum);
}
+#endif
if (x->x_len < x->x_headers_len)
errx(1, "invalid SizeOfHeaders %d", po->po_size_of_headers);
OpenPOWER on IntegriCloud